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
sequencelengths
1.02k
1.02k
labels
sequencelengths
1.02k
1.02k
attention_mask
sequencelengths
1.02k
1.02k
sourcelair/ceryx
ceryx/tests/client/connection.py
2
1957
from urllib3.connection import HTTPConnection, HTTPSConnection import os import socket DEFAULT_CERYX_HOST = "ceryx" # Set by Docker Compose in tests CERYX_HOST = os.getenv("CERYX_HOST", DEFAULT_CERYX_HOST) class CeryxTestsHTTPConnection(HTTPConnection): """ Custom-built HTTPConnection for Ceryx tests. Force sets the request's host to the configured Ceryx host, if the request's original host ends with `.ceryx.test`. """ @property def host(self): """ Do what the original property did. We just want to touch the setter. """ return self._dns_host.rstrip('.') @host.setter def host(self, value): """ If the request header ends with `.ceryx.test` then force set the actual host to the configured Ceryx host, so as to send corresponding requests to Ceryx. """ self._dns_host = CERYX_HOST if value.endswith(".ceryx.test") else value class CeryxTestsHTTPSConnection(CeryxTestsHTTPConnection, HTTPSConnection): def __init__( self, host, port=None, key_file=None, cert_file=None, key_password=None, strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, ssl_context=None, server_hostname=None, **kw, ): # Initialise the HTTPConnection subclass created above. CeryxTestsHTTPConnection.__init__( self, host, port, strict=strict, timeout=timeout, **kw, ) self.key_file = key_file self.cert_file = cert_file self.key_password = key_password self.ssl_context = ssl_context self.server_hostname = server_hostname # ------------------------------ # Original comment from upstream # ------------------------------ # # Required property for Google AppEngine 1.9.0 which otherwise causes # HTTPS requests to go out as HTTP. (See Issue #356) self._protocol = 'https'
mit
[ 504, 4011, 19, 14, 2105, 492, 3101, 3225, 12, 14147, 3225, 199, 646, 747, 199, 646, 2838, 421, 199, 3472, 63, 35, 9418, 56, 63, 5449, 275, 298, 67, 994, 88, 2, 221, 327, 2494, 701, 22067, 3599, 3362, 315, 2295, 199, 35, 9418, 56, 63, 5449, 275, 747, 14, 12959, 480, 35, 9418, 56, 63, 5449, 401, 6186, 63, 35, 9418, 56, 63, 5449, 9, 421, 199, 533, 445, 994, 88, 2925, 19114, 8, 19114, 304, 272, 408, 272, 8388, 13, 11730, 3101, 3225, 367, 445, 994, 88, 2295, 14, 18771, 5951, 314, 1056, 1159, 272, 1591, 370, 314, 7526, 445, 994, 88, 1591, 12, 340, 314, 1056, 1159, 3379, 1591, 272, 11187, 543, 19853, 67, 994, 88, 14, 396, 2313, 272, 408, 2286, 768, 1829, 272, 347, 1591, 8, 277, 304, 267, 408, 267, 4226, 4052, 314, 3379, 3324, 8103, 14, 2136, 2951, 2934, 370, 12943, 314, 18743, 14, 267, 408, 267, 372, 291, 423, 5797, 63, 1102, 14, 6735, 7563, 2286, 768, 1102, 14, 8345, 272, 347, 1591, 8, 277, 12, 574, 304, 267, 408, 267, 982, 314, 1056, 1406, 11187, 543, 19853, 67, 994, 88, 14, 396, 64, 2066, 3542, 663, 314, 3503, 267, 1591, 370, 314, 7526, 445, 994, 88, 1591, 12, 880, 465, 370, 3222, 5226, 267, 4145, 370, 445, 994, 88, 14, 267, 408, 267, 291, 423, 5797, 63, 1102, 275, 445, 9418, 56, 63, 5449, 340, 574, 14, 4130, 9520, 67, 994, 88, 14, 396, 531, 587, 574, 421, 199, 533, 445, 994, 88, 2925, 27945, 8, 35, 994, 88, 2925, 19114, 12, 14147, 3225, 304, 272, 347, 636, 826, 721, 267, 291, 12, 1591, 12, 1844, 29, 403, 12, 790, 63, 493, 29, 403, 12, 6250, 63, 493, 29, 403, 12, 267, 790, 63, 2060, 29, 403, 12, 7478, 29, 403, 12, 267, 2653, 29, 3450, 423, 13808, 63, 3472, 63, 8899, 12, 6149, 63, 1100, 29, 403, 12, 267, 1654, 63, 4269, 29, 403, 12, 1011, 829, 12, 272, 3461, 398, 327, 6026, 572, 314, 3101, 3225, 5516, 2737, 3432, 14, 267, 445, 994, 88, 2925, 19114, 855, 826, 721, 288, 291, 12, 1591, 12, 1844, 12, 7478, 29, 4768, 12, 2653, 29, 2593, 12, 1011, 829, 12, 267, 776, 398, 291, 14, 498, 63, 493, 275, 790, 63, 493, 267, 291, 14, 4736, 63, 493, 275, 6250, 63, 493, 267, 291, 14, 498, 63, 2060, 275, 790, 63, 2060, 267, 291, 14, 4266, 63, 1100, 275, 6149, 63, 1100, 267, 291, 14, 1000, 63, 4269, 275, 1654, 63, 4269, 398, 327, 10652, 10965, 267, 327, 12769, 3721, 687, 18932, 267, 327, 10652, 10965, 267, 327, 267, 327, 11105, 3324, 367, 4475, 4693, 8524, 413, 14, 25, 14, 16, 1314, 4257, 14486, 267, 327, 14147, 4145, 370, 2621, 734, 465, 3101, 14, 334, 9295, 13383, 327, 13251, 9, 267, 291, 423, 3922, 275, 283, 2859, 7, 523, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4011, 19, 14, 2105, 492, 3101, 3225, 12, 14147, 3225, 199, 646, 747, 199, 646, 2838, 421, 199, 3472, 63, 35, 9418, 56, 63, 5449, 275, 298, 67, 994, 88, 2, 221, 327, 2494, 701, 22067, 3599, 3362, 315, 2295, 199, 35, 9418, 56, 63, 5449, 275, 747, 14, 12959, 480, 35, 9418, 56, 63, 5449, 401, 6186, 63, 35, 9418, 56, 63, 5449, 9, 421, 199, 533, 445, 994, 88, 2925, 19114, 8, 19114, 304, 272, 408, 272, 8388, 13, 11730, 3101, 3225, 367, 445, 994, 88, 2295, 14, 18771, 5951, 314, 1056, 1159, 272, 1591, 370, 314, 7526, 445, 994, 88, 1591, 12, 340, 314, 1056, 1159, 3379, 1591, 272, 11187, 543, 19853, 67, 994, 88, 14, 396, 2313, 272, 408, 2286, 768, 1829, 272, 347, 1591, 8, 277, 304, 267, 408, 267, 4226, 4052, 314, 3379, 3324, 8103, 14, 2136, 2951, 2934, 370, 12943, 314, 18743, 14, 267, 408, 267, 372, 291, 423, 5797, 63, 1102, 14, 6735, 7563, 2286, 768, 1102, 14, 8345, 272, 347, 1591, 8, 277, 12, 574, 304, 267, 408, 267, 982, 314, 1056, 1406, 11187, 543, 19853, 67, 994, 88, 14, 396, 64, 2066, 3542, 663, 314, 3503, 267, 1591, 370, 314, 7526, 445, 994, 88, 1591, 12, 880, 465, 370, 3222, 5226, 267, 4145, 370, 445, 994, 88, 14, 267, 408, 267, 291, 423, 5797, 63, 1102, 275, 445, 9418, 56, 63, 5449, 340, 574, 14, 4130, 9520, 67, 994, 88, 14, 396, 531, 587, 574, 421, 199, 533, 445, 994, 88, 2925, 27945, 8, 35, 994, 88, 2925, 19114, 12, 14147, 3225, 304, 272, 347, 636, 826, 721, 267, 291, 12, 1591, 12, 1844, 29, 403, 12, 790, 63, 493, 29, 403, 12, 6250, 63, 493, 29, 403, 12, 267, 790, 63, 2060, 29, 403, 12, 7478, 29, 403, 12, 267, 2653, 29, 3450, 423, 13808, 63, 3472, 63, 8899, 12, 6149, 63, 1100, 29, 403, 12, 267, 1654, 63, 4269, 29, 403, 12, 1011, 829, 12, 272, 3461, 398, 327, 6026, 572, 314, 3101, 3225, 5516, 2737, 3432, 14, 267, 445, 994, 88, 2925, 19114, 855, 826, 721, 288, 291, 12, 1591, 12, 1844, 12, 7478, 29, 4768, 12, 2653, 29, 2593, 12, 1011, 829, 12, 267, 776, 398, 291, 14, 498, 63, 493, 275, 790, 63, 493, 267, 291, 14, 4736, 63, 493, 275, 6250, 63, 493, 267, 291, 14, 498, 63, 2060, 275, 790, 63, 2060, 267, 291, 14, 4266, 63, 1100, 275, 6149, 63, 1100, 267, 291, 14, 1000, 63, 4269, 275, 1654, 63, 4269, 398, 327, 10652, 10965, 267, 327, 12769, 3721, 687, 18932, 267, 327, 10652, 10965, 267, 327, 267, 327, 11105, 3324, 367, 4475, 4693, 8524, 413, 14, 25, 14, 16, 1314, 4257, 14486, 267, 327, 14147, 4145, 370, 2621, 734, 465, 3101, 14, 334, 9295, 13383, 327, 13251, 9, 267, 291, 423, 3922, 275, 283, 2859, 7, 523, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Ophiuchus1312/enigma2-master
lib/python/Screens/TimerEdit.py
1
20176
from Components.ActionMap import ActionMap from Components.Button import Button from Components.Label import Label from Components.config import config from Components.MenuList import MenuList from Components.TimerList import TimerList from Components.TimerSanityCheck import TimerSanityCheck from Components.UsageConfig import preferredTimerPath from Components.Sources.StaticText import StaticText from RecordTimer import RecordTimerEntry, parseEvent, AFTEREVENT from Screens.Screen import Screen from Screens.ChoiceBox import ChoiceBox from Screens.MessageBox import MessageBox from ServiceReference import ServiceReference from Screens.TimerEntry import TimerEntry, TimerLog from Tools.BoundFunction import boundFunction from Tools.FuzzyDate import FuzzyTime from Tools.Directories import resolveFilename, SCOPE_HDD from time import time, localtime from timer import TimerEntry as RealTimerEntry from enigma import eServiceCenter import Tools.CopyFiles import os class TimerEditList(Screen): EMPTY = 0 ENABLE = 1 DISABLE = 2 CLEANUP = 3 DELETE = 4 def __init__(self, session): Screen.__init__(self, session) Screen.setTitle(self, _("Timer List")) self.onChangedEntry = [ ] list = [ ] self.list = list self.fillTimerList() self["timerlist"] = TimerList(list) self.key_red_choice = self.EMPTY self.key_yellow_choice = self.EMPTY self.key_blue_choice = self.EMPTY self["key_red"] = Button(" ") self["key_green"] = Button(_("Add")) self["key_yellow"] = Button(" ") self["key_blue"] = Button(" ") self["description"] = Label() self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "ShortcutActions", "TimerEditActions"], { "ok": self.openEdit, "cancel": self.leave, "green": self.addCurrentTimer, "log": self.showLog, "left": self.left, "right": self.right, "up": self.up, "down": self.down }, -1) self.setTitle(_("Timer overview")) self.session.nav.RecordTimer.on_state_change.append(self.onStateChange) self.onShown.append(self.updateState) def createSummary(self): return TimerEditListSummary def up(self): self["timerlist"].instance.moveSelection(self["timerlist"].instance.moveUp) self.updateState() def down(self): self["timerlist"].instance.moveSelection(self["timerlist"].instance.moveDown) self.updateState() def left(self): self["timerlist"].instance.moveSelection(self["timerlist"].instance.pageUp) self.updateState() def right(self): self["timerlist"].instance.moveSelection(self["timerlist"].instance.pageDown) self.updateState() def toggleDisabledState(self): cur=self["timerlist"].getCurrent() if cur: t = cur if t.disabled: # print "try to ENABLE timer" t.enable() timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, cur) if not timersanitycheck.check(): t.disable() print "Sanity check failed" simulTimerList = timersanitycheck.getSimulTimerList() if simulTimerList is not None: self.session.openWithCallback(self.finishedEdit, TimerSanityConflict, simulTimerList) else: print "Sanity check passed" if timersanitycheck.doubleCheck(): t.disable() else: if t.isRunning(): if t.repeated: list = ( (_("Stop current event but not coming events"), "stoponlycurrent"), (_("Stop current event and disable coming events"), "stopall"), (_("Don't stop current event but disable coming events"), "stoponlycoming") ) self.session.openWithCallback(boundFunction(self.runningEventCallback, t), ChoiceBox, title=_("Repeating event currently recording... What do you want to do?"), list = list) else: t.disable() self.session.nav.RecordTimer.timeChanged(t) self.refill() self.updateState() def runningEventCallback(self, t, result): if result is not None: if result[1] == "stoponlycurrent" or result[1] == "stopall": t.enable() t.processRepeated(findRunningEvent = False) self.session.nav.RecordTimer.doActivate(t) if result[1] == "stoponlycoming" or result[1] == "stopall": t.disable() self.session.nav.RecordTimer.timeChanged(t) self.refill() self.updateState() def removeAction(self, descr): actions = self["actions"].actions if descr in actions: del actions[descr] def updateState(self): cur = self["timerlist"].getCurrent() if cur: self["description"].setText(cur.description) if self.key_red_choice != self.DELETE: self["actions"].actions.update({"red":self.removeTimerQuestion}) self["key_red"].setText(_("Delete")) self.key_red_choice = self.DELETE if cur.disabled and (self.key_yellow_choice != self.ENABLE): self["actions"].actions.update({"yellow":self.toggleDisabledState}) self["key_yellow"].setText(_("Enable")) self.key_yellow_choice = self.ENABLE elif cur.isRunning() and not cur.repeated and (self.key_yellow_choice != self.EMPTY): self.removeAction("yellow") self["key_yellow"].setText(" ") self.key_yellow_choice = self.EMPTY elif ((not cur.isRunning())or cur.repeated ) and (not cur.disabled) and (self.key_yellow_choice != self.DISABLE): self["actions"].actions.update({"yellow":self.toggleDisabledState}) self["key_yellow"].setText(_("Disable")) self.key_yellow_choice = self.DISABLE else: if self.key_red_choice != self.EMPTY: self.removeAction("red") self["key_red"].setText(" ") self.key_red_choice = self.EMPTY if self.key_yellow_choice != self.EMPTY: self.removeAction("yellow") self["key_yellow"].setText(" ") self.key_yellow_choice = self.EMPTY showCleanup = True for x in self.list: if (not x[0].disabled) and (x[1] == True): break else: showCleanup = False if showCleanup and (self.key_blue_choice != self.CLEANUP): self["actions"].actions.update({"blue":self.cleanupQuestion}) self["key_blue"].setText(_("Cleanup")) self.key_blue_choice = self.CLEANUP elif (not showCleanup) and (self.key_blue_choice != self.EMPTY): self.removeAction("blue") self["key_blue"].setText(" ") self.key_blue_choice = self.EMPTY if len(self.list) == 0: return timer = self['timerlist'].getCurrent() if timer: try: name = str(timer.name) time = ("%s %s ... %s") % (FuzzyTime(timer.begin)[0], FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1]) duration = ("(%d " + _("mins") + ")") % ((timer.end - timer.begin) / 60) service = str(timer.service_ref.getServiceName()) if timer.state == RealTimerEntry.StateWaiting: state = _("waiting") elif timer.state == RealTimerEntry.StatePrepared: state = _("about to start") elif timer.state == RealTimerEntry.StateRunning: if timer.justplay: state = _("zapped") else: state = _("recording...") elif timer.state == RealTimerEntry.StateEnded: state = _("done!") else: state = _("<unknown>") except: name = "" time = "" duration = "" service = "" else: name = "" time = "" duration = "" service = "" for cb in self.onChangedEntry: cb(name, time, duration, service, state) def fillTimerList(self): #helper function to move finished timers to end of list def eol_compare(x, y): if x[0].state != y[0].state and x[0].state == RealTimerEntry.StateEnded or y[0].state == RealTimerEntry.StateEnded: return cmp(x[0].state, y[0].state) return cmp(x[0].begin, y[0].begin) list = self.list print list del list[:] list.extend([(timer, False) for timer in self.session.nav.RecordTimer.timer_list]) list.extend([(timer, True) for timer in self.session.nav.RecordTimer.processed_timers]) if config.usage.timerlist_finished_timer_position.index: #end of list list.sort(cmp = eol_compare) else: list.sort(key = lambda x: x[0].begin) def showLog(self): cur=self["timerlist"].getCurrent() if cur: self.session.openWithCallback(self.finishedEdit, TimerLog, cur) def openEdit(self): cur=self["timerlist"].getCurrent() if cur: self.session.openWithCallback(self.finishedEdit, TimerEntry, cur) def cleanupQuestion(self): self.session.openWithCallback(self.cleanupTimer, MessageBox, _("Really delete done timers?")) def cleanupTimer(self, delete): if delete: self.session.nav.RecordTimer.cleanup() self.refill() self.updateState() def removeTimerQuestion(self): cur = self["timerlist"].getCurrent() service = str(cur.service_ref.getServiceName()) t = localtime(cur.begin) f = str(t.tm_year) + str(t.tm_mon).zfill(2) + str(t.tm_mday).zfill(2) + " " + str(t.tm_hour).zfill(2) + str(t.tm_min).zfill(2) + " - " + service + " - " + cur.name f = f.replace(':','_') f = f.replace(',','_') f = f.replace('/','_') if not cur: return onhdd = False self.moviename = f path = resolveFilename(SCOPE_HDD) files = os.listdir(path) for file in files: if file.startswith(f): onhdd = True break if onhdd: message = (_("Do you really want to delete %s?") % (cur.name)) choices = [(_("No"), "no"), (_("Yes, delete from Timerlist"), "yes"), (_("Yes, delete from Timerlist and delete recording"), "yesremove")] self.session.openWithCallback(self.startDelete, ChoiceBox, title=message, list=choices) else: self.session.openWithCallback(self.removeTimer, MessageBox, _("Do you really want to delete %s?") % (cur.name), default = False) def startDelete(self, answer): if not answer or not answer[1]: self.close() return if answer[1] == 'no': return elif answer[1] == 'yes': self.removeTimer(True) elif answer[1] == 'yesremove': if config.EMC.movie_trashcan_enable.getValue(): trashpath = config.EMC.movie_trashcan_path.getValue() self.MoveToTrash(trashpath) elif config.usage.movielist_trashcan.getValue(): trashpath = resolveFilename(SCOPE_HDD) + '.Trash' self.MoveToTrash(trashpath) else: self.session.openWithCallback(self.callbackRemoveRecording, MessageBox, _("Do you really want to delete the recording?"), default = False) def callbackRemoveRecording(self, answer): if not answer: return self.delete() def removeTimer(self, result): if not result: return list = self["timerlist"] cur = list.getCurrent() if cur: timer = cur timer.afterEvent = AFTEREVENT.NONE self.session.nav.RecordTimer.removeEntry(timer) self.refill() self.updateState() def MoveToTrash(self, trashpath): self.removeTimer(True) moviepath = os.path.normpath(resolveFilename(SCOPE_HDD)) movedList =[] files = os.listdir(moviepath) for file in files: if file.startswith(self.moviename): movedList.append((os.path.join(moviepath, file), os.path.join(trashpath, file))) Tools.CopyFiles.moveFiles(movedList, None) def delete(self): item = self["timerlist"].getCurrent() if item is None: return # huh? name = item.name service = str(item.service_ref.getServiceName()) t = localtime(item.begin) f = str(t.tm_year) + str(t.tm_mon).zfill(2) + str(t.tm_mday).zfill(2) + " " + str(t.tm_hour).zfill(2) + str(t.tm_min).zfill(2) + " - " + service + " - " + name f = f.replace(':','_') f = f.replace(',','_') f = f.replace('/','_') path = resolveFilename(SCOPE_HDD) self.removeTimer(True) from enigma import eBackgroundFileEraser files = os.listdir(path) for file in files: if file.startswith(f): eBackgroundFileEraser.getInstance().erase(os.path.realpath(path + file)) def refill(self): oldsize = len(self.list) self.fillTimerList() lst = self["timerlist"] newsize = len(self.list) if oldsize and oldsize != newsize: idx = lst.getCurrentIndex() lst.entryRemoved(idx) else: lst.invalidate() def addCurrentTimer(self): event = None service = self.session.nav.getCurrentService() if service is not None: info = service.info() if info is not None: event = info.getEvent(0) # FIXME only works if already playing a service serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceOrGroup()) if event is None: data = (int(time()), int(time() + 60), "", "", None) else: data = parseEvent(event, description = False) self.addTimer(RecordTimerEntry(serviceref, checkOldTimers = True, dirname = preferredTimerPath(), *data)) def addTimer(self, timer): self.session.openWithCallback(self.finishedAdd, TimerEntry, timer) def finishedEdit(self, answer): # print "finished edit" if answer[0]: # print "Edited timer" entry = answer[1] timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, entry) success = False if not timersanitycheck.check(): simulTimerList = timersanitycheck.getSimulTimerList() if simulTimerList is not None: for x in simulTimerList: if x.setAutoincreaseEnd(entry): self.session.nav.RecordTimer.timeChanged(x) if not timersanitycheck.check(): simulTimerList = timersanitycheck.getSimulTimerList() if simulTimerList is not None: self.session.openWithCallback(self.finishedEdit, TimerSanityConflict, timersanitycheck.getSimulTimerList()) else: success = True else: success = True if success: print "Sanity check passed" self.session.nav.RecordTimer.timeChanged(entry) self.fillTimerList() self.updateState() # else: # print "Timeredit aborted" def finishedAdd(self, answer): # print "finished add" if answer[0]: entry = answer[1] simulTimerList = self.session.nav.RecordTimer.record(entry) if simulTimerList is not None: for x in simulTimerList: if x.setAutoincreaseEnd(entry): self.session.nav.RecordTimer.timeChanged(x) simulTimerList = self.session.nav.RecordTimer.record(entry) if simulTimerList is not None: self.session.openWithCallback(self.finishSanityCorrection, TimerSanityConflict, simulTimerList) self.fillTimerList() self.updateState() # else: # print "Timeredit aborted" def finishSanityCorrection(self, answer): self.finishedAdd(answer) def leave(self): self.session.nav.RecordTimer.on_state_change.remove(self.onStateChange) self.close() def onStateChange(self, entry): self.refill() self.updateState() class TimerSanityConflict(Screen): EMPTY = 0 ENABLE = 1 DISABLE = 2 EDIT = 3 def __init__(self, session, timer): Screen.__init__(self, session) self.timer = timer print "TimerSanityConflict" self["timer1"] = TimerList(self.getTimerList(timer[0])) self.list = [] self.list2 = [] count = 0 for x in timer: if count != 0: self.list.append((_("Conflicting timer") + " " + str(count), x)) self.list2.append((timer[count], False)) count += 1 if count == 1: self.list.append((_("Channel not in services list"))) self["list"] = MenuList(self.list) self["timer2"] = TimerList(self.list2) self["key_red"] = Button("Edit") self["key_green"] = Button(" ") self["key_yellow"] = Button(" ") self["key_blue"] = Button(" ") self.key_green_choice = self.EMPTY self.key_yellow_choice = self.EMPTY self.key_blue_choice = self.EMPTY self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "ShortcutActions", "TimerEditActions"], { "ok": self.leave_ok, "cancel": self.leave_cancel, "red": self.editTimer1, "up": self.up, "down": self.down }, -1) self.setTitle(_("Timer sanity error")) self.onShown.append(self.updateState) def getTimerList(self, timer): return [(timer, False)] def editTimer1(self): self.session.openWithCallback(self.finishedEdit, TimerEntry, self["timer1"].getCurrent()) def editTimer2(self): self.session.openWithCallback(self.finishedEdit, TimerEntry, self["timer2"].getCurrent()) def toggleNewTimer(self): if self.timer[0].disabled: self.timer[0].disabled = False self.session.nav.RecordTimer.timeChanged(self.timer[0]) elif not self.timer[0].isRunning(): self.timer[0].disabled = True self.session.nav.RecordTimer.timeChanged(self.timer[0]) self.finishedEdit((True, self.timer[0])) def toggleTimer(self): x = self["list"].getSelectedIndex() + 1 # the first is the new timer so we do +1 here if self.timer[x].disabled: self.timer[x].disabled = False self.session.nav.RecordTimer.timeChanged(self.timer[x]) if not self.timer[0].isRunning(): self.timer[0].disabled = True self.session.nav.RecordTimer.timeChanged(self.timer[0]) elif not self.timer[x].isRunning(): self.timer[x].disabled = True self.session.nav.RecordTimer.timeChanged(self.timer[x]) if self.timer[x].disabled: self.timer[0].disabled = False self.session.nav.RecordTimer.timeChanged(self.timer[0]) self.finishedEdit((True, self.timer[0])) def finishedEdit(self, answer): self.leave_ok() def leave_ok(self): self.close((True, self.timer[0])) def leave_cancel(self): self.close((False, self.timer[0])) def up(self): self["list"].instance.moveSelection(self["list"].instance.moveUp) self["timer2"].moveToIndex(self["list"].getSelectedIndex()) def down(self): self["list"].instance.moveSelection(self["list"].instance.moveDown) self["timer2"].moveToIndex(self["list"].getSelectedIndex()) def removeAction(self, descr): actions = self["actions"].actions if descr in actions: del actions[descr] def updateState(self): if self.timer[0] is not None: if self.timer[0].disabled and self.key_green_choice != self.ENABLE: self["actions"].actions.update({"green":self.toggleTimer}) self["key_green"].setText(_("Enable")) self.key_green_choice = self.ENABLE elif self.timer[0].isRunning() and not self.timer[0].repeated and self.key_green_choice != self.EMPTY: self.removeAction("green") self["key_green"].setText(" ") self.key_green_choice = self.EMPTY elif (not self.timer[0].isRunning() or self.timer[0].repeated ) and self.key_green_choice != self.DISABLE: self["actions"].actions.update({"green":self.toggleNewTimer}) self["key_green"].setText(_("Disable")) self.key_green_choice = self.DISABLE if len(self.timer) > 1: x = self["list"].getSelectedIndex() + 1 # the first is the new timer so we do +1 here if self.timer[x] is not None: if self.key_yellow_choice == self.EMPTY: self["actions"].actions.update({"yellow":self.editTimer2}) self["key_yellow"].setText(_("Edit")) self.key_yellow_choice = self.EDIT if self.timer[x].disabled and self.key_blue_choice != self.ENABLE: self["actions"].actions.update({"blue":self.toggleTimer}) self["key_blue"].setText(_("Enable")) self.key_blue_choice = self.ENABLE elif self.timer[x].isRunning() and not self.timer[x].repeated and self.key_blue_choice != self.EMPTY: self.removeAction("blue") self["key_blue"].setText(" ") self.key_blue_choice = self.EMPTY elif (not self.timer[x].isRunning() or self.timer[x].repeated ) and self.key_blue_choice != self.DISABLE: self["actions"].actions.update({"blue":self.toggleTimer}) self["key_blue"].setText(_("Disable")) self.key_blue_choice = self.DISABLE else: #FIXME.... this doesnt hide the buttons self.... just the text if self.key_yellow_choice != self.EMPTY: self.removeAction("yellow") self["key_yellow"].setText(" ") self.key_yellow_choice = self.EMPTY if self.key_blue_choice != self.EMPTY: self.removeAction("blue") self["key_blue"].setText(" ") self.key_blue_choice = self.EMPTY class TimerEditListSummary(Screen): def __init__(self, session, parent): Screen.__init__(self, session, parent = parent) self["name"] = StaticText("") self["service"] = StaticText("") self["time"] = StaticText("") self["duration"] = StaticText("") self["state"] = StaticText("") self.onShow.append(self.addWatcher) self.onHide.append(self.removeWatcher) def addWatcher(self): self.parent.onChangedEntry.append(self.selectionChanged) self.parent.updateState() def removeWatcher(self): self.parent.onChangedEntry.remove(self.selectionChanged) def selectionChanged(self, name, time, duration, service, state): self["name"].text = name self["service"].text = service self["time"].text = time self["duration"].text = duration self["state"].text = state
gpl-2.0
[ 504, 17823, 14, 3310, 2956, 492, 10033, 2956, 199, 504, 17823, 14, 4259, 492, 16005, 199, 504, 17823, 14, 4314, 492, 10354, 199, 504, 17823, 14, 888, 492, 1101, 199, 504, 17823, 14, 5977, 1296, 492, 18281, 1296, 199, 504, 17823, 14, 7929, 1296, 492, 22287, 1296, 199, 504, 17823, 14, 7929, 25901, 1799, 492, 22287, 25901, 1799, 199, 504, 17823, 14, 7692, 2028, 492, 14388, 7929, 2042, 199, 504, 17823, 14, 13959, 14, 25289, 492, 13599, 1872, 199, 504, 12651, 7929, 492, 12651, 7929, 3900, 12, 2198, 2390, 12, 20089, 1157, 8193, 199, 504, 29372, 14, 9616, 492, 17804, 199, 504, 29372, 14, 9054, 3532, 492, 16053, 3532, 199, 504, 29372, 14, 13695, 492, 28923, 199, 504, 7591, 5083, 492, 7591, 5083, 199, 504, 29372, 14, 7929, 3900, 492, 22287, 3900, 12, 22287, 2445, 199, 504, 23228, 14, 8934, 3481, 492, 3914, 3481, 199, 504, 23228, 14, 38, 14697, 2506, 492, 481, 14697, 1366, 199, 504, 23228, 14, 13752, 492, 7512, 8117, 12, 428, 1439, 1510, 63, 40, 5745, 199, 504, 900, 492, 900, 12, 2257, 521, 199, 504, 9715, 492, 22287, 3900, 465, 14849, 7929, 3900, 199, 504, 655, 27021, 492, 325, 3167, 13551, 199, 646, 23228, 14, 5116, 5535, 199, 646, 747, 199, 199, 533, 22287, 4685, 1296, 8, 9616, 304, 199, 198, 13993, 275, 378, 199, 198, 8898, 275, 413, 199, 198, 13052, 275, 499, 199, 198, 28663, 2160, 275, 650, 199, 198, 7014, 275, 841, 421, 198, 318, 636, 826, 721, 277, 12, 2351, 304, 507, 198, 9616, 855, 826, 721, 277, 12, 2351, 9, 507, 198, 9616, 14, 31675, 8, 277, 12, 3824, 7929, 3820, 2237, 2742, 198, 277, 14, 265, 6970, 3900, 275, 359, 1622, 507, 198, 513, 275, 359, 1622, 507, 198, 277, 14, 513, 275, 769, 507, 198, 277, 14, 4498, 7929, 1296, 342, 2742, 198, 277, 905, 7414, 513, 937, 275, 22287, 1296, 8, 513, 9, 2742, 198, 277, 14, 498, 63, 581, 63, 5095, 275, 291, 14, 13993, 507, 198, 277, 14, 498, 63, 14514, 63, 5095, 275, 291, 14, 13993, 507, 198, 277, 14, 498, 63, 6304, 63, 5095, 275, 291, 14, 13993, 2742, 198, 277, 905, 498, 63, 581, 937, 275, 16005, 480, 6099, 507, 198, 277, 905, 498, 63, 7731, 937, 275, 16005, 6115, 1123, 2237, 507, 198, 277, 905, 498, 63, 14514, 937, 275, 16005, 480, 6099, 507, 198, 277, 905, 498, 63, 6304, 937, 275, 16005, 480, 6099, 2742, 198, 277, 905, 1802, 937, 275, 10354, 342, 2742, 198, 277, 905, 3723, 937, 275, 10033, 2956, 5234, 11622, 9083, 9303, 401, 298, 17015, 9303, 401, 298, 28301, 9303, 401, 298, 7929, 4685, 9303, 2255, 686, 198, 91, 1585, 198, 2, 745, 582, 291, 14, 1490, 4685, 12, 1585, 198, 2, 6406, 582, 291, 14, 12422, 12, 1585, 198, 2, 7731, 582, 291, 14, 525, 5639, 7929, 12, 1585, 198, 2, 793, 582, 291, 14, 2384, 2445, 12, 1585, 198, 2, 3039, 582, 291, 14, 3039, 12, 1585, 198, 2, 1019, 582, 291, 14, 1019, 12, 1585, 198, 2, 384, 582, 291, 14, 384, 12, 1585, 198, 2, 2110, 582, 291, 14, 2110, 686, 198, 1386, 446, 17, 9, 507, 198, 277, 14, 31675, 6115, 7929, 23503, 2237, 507, 198, 277, 14, 1730, 14, 10927, 14, 5433, 7929, 14, 265, 63, 929, 63, 1461, 14, 740, 8, 277, 14, 265, 2223, 4001, 9, 507, 198, 277, 14, 265, 6824, 78, 14, 740, 8, 277, 14, 873, 2223, 9, 421, 198, 318, 1218, 10407, 8, 277, 304, 507, 198, 1107, 22287, 4685, 1296, 10407, 421, 198, 318, 1536, 8, 277, 304, 507, 198, 277, 905, 7414, 513, 4140, 842, 14, 1185, 7713, 8, 277, 905, 7414, 513, 4140, 842, 14, 1185, 1721, 9, 507, 198, 277, 14, 873, 2223, 342, 421, 198, 318, 3224, 8, 277, 304, 507, 198, 277, 905, 7414, 513, 4140, 842, 14, 1185, 7713, 8, 277, 905, 7414, 513, 4140, 842, 14, 1185, 3514, 9, 507, 198, 277, 14, 873, 2223, 342, 421, 198, 318, 3602, 8, 277, 304, 507, 198, 277, 905, 7414, 513, 4140, 842, 14, 1185, 7713, 8, 277, 905, 7414, 513, 4140, 842, 14, 1606, 1721, 9, 507, 198, 277, 14, 873, 2223, 342, 421, 198, 318, 2451, 8, 277, 304, 507, 198, 277, 905, 7414, 513, 4140, 842, 14, 1185, 7713, 8, 277, 905, 7414, 513, 4140, 842, 14, 1606, 3514, 9, 507, 198, 277, 14, 873, 2223, 342, 421, 198, 318, 19420, 15049, 2223, 8, 277, 304, 507, 198, 895, 29, 277, 905, 7414, 513, 4140, 16662, 342, 507, 198, 692, 1094, 26, 686, 198, 84, 275, 1094, 686, 198, 692, 307, 14, 7011, 26, 199, 3, 221, 9622, 198, 1361, 298, 893, 370, 27926, 9715, 2, 1585, 198, 84, 14, 4296, 342, 1585, 198, 27386, 8945, 1074, 275, 22287, 25901, 1799, 8, 277, 14, 1730, 14, 10927, 14, 5433, 7929, 14, 7414, 63, 513, 12, 1094, 9, 1585, 198, 692, 440, 900, 2393, 8945, 1074, 14, 1074, 837, 1871, 198, 84, 14, 5993, 342, 1871, 198, 1361, 298, 25901, 1104, 3405, 2, 1871, 198, 13819, 7929, 1296, 275, 900, 2393, 8945, 1074, 14, 362, 7467, 348, 7929, 1296, 342, 1871, 198, 692, 4389, 348, 7929, 1296, 365, 440, 488, 26, 4671, 198, 277, 14, 1730, 14, 30913, 8, 277, 14, 8669, 4685, 12, 22287, 25901, 15919, 12, 4389, 348, 7929, 1296, 9, 1585, 198, 2836, 26, 1871, 198, 1361, 298, 25901, 1104, 3032, 2, 1871, 198, 692, 900, 2393, 8945, 1074, 14, 3157, 1799, 837, 4671, 198, 84, 14, 5993, 342, 686, 198, 2836, 26, 1585, 198, 692, 307, 14, 374, 9602, 837, 1871, 198, 692, 307, 14, 7593, 26, 4671, 198, 513, 275, 334, 5264, 198, 6115, 6293, 1453, 1566, 1325, 440, 17262, 4474, 1288, 298, 2379, 2118, 1818, 1288, 5264, 198, 6115, 6293, 1453, 1566, 436, 3507, 17262, 4474, 1288, 298, 2379, 452, 1288, 5264, 198, 6115, 16932, 1133, 3631, 1453, 1566, 1325, 3507, 17262, 4474, 1288, 298, 2379, 2118, 7909, 531, 4671, 198, 9, 4671, 198, 277, 14, 1730, 14, 30913, 8, 3556, 3481, 8, 277, 14, 5720, 2390, 2806, 12, 307, 395, 16053, 3532, 12, 2538, 9384, 12945, 1958, 1566, 5544, 20952, 1396, 14791, 886 ]
[ 17823, 14, 3310, 2956, 492, 10033, 2956, 199, 504, 17823, 14, 4259, 492, 16005, 199, 504, 17823, 14, 4314, 492, 10354, 199, 504, 17823, 14, 888, 492, 1101, 199, 504, 17823, 14, 5977, 1296, 492, 18281, 1296, 199, 504, 17823, 14, 7929, 1296, 492, 22287, 1296, 199, 504, 17823, 14, 7929, 25901, 1799, 492, 22287, 25901, 1799, 199, 504, 17823, 14, 7692, 2028, 492, 14388, 7929, 2042, 199, 504, 17823, 14, 13959, 14, 25289, 492, 13599, 1872, 199, 504, 12651, 7929, 492, 12651, 7929, 3900, 12, 2198, 2390, 12, 20089, 1157, 8193, 199, 504, 29372, 14, 9616, 492, 17804, 199, 504, 29372, 14, 9054, 3532, 492, 16053, 3532, 199, 504, 29372, 14, 13695, 492, 28923, 199, 504, 7591, 5083, 492, 7591, 5083, 199, 504, 29372, 14, 7929, 3900, 492, 22287, 3900, 12, 22287, 2445, 199, 504, 23228, 14, 8934, 3481, 492, 3914, 3481, 199, 504, 23228, 14, 38, 14697, 2506, 492, 481, 14697, 1366, 199, 504, 23228, 14, 13752, 492, 7512, 8117, 12, 428, 1439, 1510, 63, 40, 5745, 199, 504, 900, 492, 900, 12, 2257, 521, 199, 504, 9715, 492, 22287, 3900, 465, 14849, 7929, 3900, 199, 504, 655, 27021, 492, 325, 3167, 13551, 199, 646, 23228, 14, 5116, 5535, 199, 646, 747, 199, 199, 533, 22287, 4685, 1296, 8, 9616, 304, 199, 198, 13993, 275, 378, 199, 198, 8898, 275, 413, 199, 198, 13052, 275, 499, 199, 198, 28663, 2160, 275, 650, 199, 198, 7014, 275, 841, 421, 198, 318, 636, 826, 721, 277, 12, 2351, 304, 507, 198, 9616, 855, 826, 721, 277, 12, 2351, 9, 507, 198, 9616, 14, 31675, 8, 277, 12, 3824, 7929, 3820, 2237, 2742, 198, 277, 14, 265, 6970, 3900, 275, 359, 1622, 507, 198, 513, 275, 359, 1622, 507, 198, 277, 14, 513, 275, 769, 507, 198, 277, 14, 4498, 7929, 1296, 342, 2742, 198, 277, 905, 7414, 513, 937, 275, 22287, 1296, 8, 513, 9, 2742, 198, 277, 14, 498, 63, 581, 63, 5095, 275, 291, 14, 13993, 507, 198, 277, 14, 498, 63, 14514, 63, 5095, 275, 291, 14, 13993, 507, 198, 277, 14, 498, 63, 6304, 63, 5095, 275, 291, 14, 13993, 2742, 198, 277, 905, 498, 63, 581, 937, 275, 16005, 480, 6099, 507, 198, 277, 905, 498, 63, 7731, 937, 275, 16005, 6115, 1123, 2237, 507, 198, 277, 905, 498, 63, 14514, 937, 275, 16005, 480, 6099, 507, 198, 277, 905, 498, 63, 6304, 937, 275, 16005, 480, 6099, 2742, 198, 277, 905, 1802, 937, 275, 10354, 342, 2742, 198, 277, 905, 3723, 937, 275, 10033, 2956, 5234, 11622, 9083, 9303, 401, 298, 17015, 9303, 401, 298, 28301, 9303, 401, 298, 7929, 4685, 9303, 2255, 686, 198, 91, 1585, 198, 2, 745, 582, 291, 14, 1490, 4685, 12, 1585, 198, 2, 6406, 582, 291, 14, 12422, 12, 1585, 198, 2, 7731, 582, 291, 14, 525, 5639, 7929, 12, 1585, 198, 2, 793, 582, 291, 14, 2384, 2445, 12, 1585, 198, 2, 3039, 582, 291, 14, 3039, 12, 1585, 198, 2, 1019, 582, 291, 14, 1019, 12, 1585, 198, 2, 384, 582, 291, 14, 384, 12, 1585, 198, 2, 2110, 582, 291, 14, 2110, 686, 198, 1386, 446, 17, 9, 507, 198, 277, 14, 31675, 6115, 7929, 23503, 2237, 507, 198, 277, 14, 1730, 14, 10927, 14, 5433, 7929, 14, 265, 63, 929, 63, 1461, 14, 740, 8, 277, 14, 265, 2223, 4001, 9, 507, 198, 277, 14, 265, 6824, 78, 14, 740, 8, 277, 14, 873, 2223, 9, 421, 198, 318, 1218, 10407, 8, 277, 304, 507, 198, 1107, 22287, 4685, 1296, 10407, 421, 198, 318, 1536, 8, 277, 304, 507, 198, 277, 905, 7414, 513, 4140, 842, 14, 1185, 7713, 8, 277, 905, 7414, 513, 4140, 842, 14, 1185, 1721, 9, 507, 198, 277, 14, 873, 2223, 342, 421, 198, 318, 3224, 8, 277, 304, 507, 198, 277, 905, 7414, 513, 4140, 842, 14, 1185, 7713, 8, 277, 905, 7414, 513, 4140, 842, 14, 1185, 3514, 9, 507, 198, 277, 14, 873, 2223, 342, 421, 198, 318, 3602, 8, 277, 304, 507, 198, 277, 905, 7414, 513, 4140, 842, 14, 1185, 7713, 8, 277, 905, 7414, 513, 4140, 842, 14, 1606, 1721, 9, 507, 198, 277, 14, 873, 2223, 342, 421, 198, 318, 2451, 8, 277, 304, 507, 198, 277, 905, 7414, 513, 4140, 842, 14, 1185, 7713, 8, 277, 905, 7414, 513, 4140, 842, 14, 1606, 3514, 9, 507, 198, 277, 14, 873, 2223, 342, 421, 198, 318, 19420, 15049, 2223, 8, 277, 304, 507, 198, 895, 29, 277, 905, 7414, 513, 4140, 16662, 342, 507, 198, 692, 1094, 26, 686, 198, 84, 275, 1094, 686, 198, 692, 307, 14, 7011, 26, 199, 3, 221, 9622, 198, 1361, 298, 893, 370, 27926, 9715, 2, 1585, 198, 84, 14, 4296, 342, 1585, 198, 27386, 8945, 1074, 275, 22287, 25901, 1799, 8, 277, 14, 1730, 14, 10927, 14, 5433, 7929, 14, 7414, 63, 513, 12, 1094, 9, 1585, 198, 692, 440, 900, 2393, 8945, 1074, 14, 1074, 837, 1871, 198, 84, 14, 5993, 342, 1871, 198, 1361, 298, 25901, 1104, 3405, 2, 1871, 198, 13819, 7929, 1296, 275, 900, 2393, 8945, 1074, 14, 362, 7467, 348, 7929, 1296, 342, 1871, 198, 692, 4389, 348, 7929, 1296, 365, 440, 488, 26, 4671, 198, 277, 14, 1730, 14, 30913, 8, 277, 14, 8669, 4685, 12, 22287, 25901, 15919, 12, 4389, 348, 7929, 1296, 9, 1585, 198, 2836, 26, 1871, 198, 1361, 298, 25901, 1104, 3032, 2, 1871, 198, 692, 900, 2393, 8945, 1074, 14, 3157, 1799, 837, 4671, 198, 84, 14, 5993, 342, 686, 198, 2836, 26, 1585, 198, 692, 307, 14, 374, 9602, 837, 1871, 198, 692, 307, 14, 7593, 26, 4671, 198, 513, 275, 334, 5264, 198, 6115, 6293, 1453, 1566, 1325, 440, 17262, 4474, 1288, 298, 2379, 2118, 1818, 1288, 5264, 198, 6115, 6293, 1453, 1566, 436, 3507, 17262, 4474, 1288, 298, 2379, 452, 1288, 5264, 198, 6115, 16932, 1133, 3631, 1453, 1566, 1325, 3507, 17262, 4474, 1288, 298, 2379, 2118, 7909, 531, 4671, 198, 9, 4671, 198, 277, 14, 1730, 14, 30913, 8, 3556, 3481, 8, 277, 14, 5720, 2390, 2806, 12, 307, 395, 16053, 3532, 12, 2538, 9384, 12945, 1958, 1566, 5544, 20952, 1396, 14791, 886, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jianlirong/incubator-hawq
pxf/src/scripts/pxf_manual_failover.py
12
5127
#!/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. # pxf_manual_failover.py # This python script will adapt the PXF external tables to the new NameNode in case # of High Availability manual failover. # The script receives as input the new namenode host and then goes over each external # table entry in the catalog table pg_exttable and updates the LOCATION field - # replaces the old Namenode host with the new one. import sys from gppylib.db import dbconn def wrongUsage(): 'Print usage string and leave' print "usage: pxf_manual_failover <new_namenode_host> <database> [-h <hawq_master_host>] [-p <hawq_master_port>]" exit() def getNewHost(): 'reads new NameNode from command line - exits if wrong input' if len(sys.argv) < 2: wrongUsage() return sys.argv[1] def getDatabase(): 'reads database from command line - exits if wrong input' if len(sys.argv) < 3: wrongUsage() return sys.argv[2] def getOptionalInput(flag, default): """generic function - retrieves optional parameters from the input If [flag <value>] is not on the command line, we use default Explaining the parsing. This is how the command line string that sys.argv returns, looks like: ['./pxf_manual_failover.py', 'localhost', 'films', '-h', 'isenshackamac.corp.emc.com', '-p', '5432'] """ input = list(sys.argv) if input.count(flag) == 0: return default flag_idx = input.index(flag) if len(input) < flag_idx +1: wrongUsage() return input[flag_idx + 1] def getMasterHost(): 'reads hawq_master_host from command line - optional' return getOptionalInput("-h", "localhost") def getMasterPort(): 'reads hawq_master_port from command line - optional' return getOptionalInput("-p", 5432) def isPxfTable(location): 'decide if this is a PXF table by analyzing the LOCATION field for the table entry in pg_exttable' return cmp(location[1:7],"pxf://") == 0 def makeNewLocation(new_host, location): 'replaces [host] substring in [location] with [new_host]' start = location.find("//") end = location.find(":", start) size = len(location) new_location = location[:start] + "//" + new_host + location[end:size] return new_location def promptUser(new_host, database, hawq_master_host, hawq_master_port): 'Give user a last chance to change his mind' print "Will replace the current Namenode hostname with [" + new_host + "] in database [" + database + "]" print "Hawq master is: [" + hawq_master_host + "] and Hawq port is: [" + str(hawq_master_port) + "]" reply = raw_input('Do you wish to continue: Yes[Y]/No[N] ?') reply = reply.lower() if not(cmp(reply, 'yes') == 0 or cmp(reply, 'y') == 0): print "User decided to cancel operation. Leaving..." exit() def connectToDb(hawq_master_host, hawq_master_port, database): 'connect to database' url = dbconn.DbURL(hawq_master_host ,port = hawq_master_port ,dbname = database ) return dbconn.connect(dburl = url) def updateOneRecord(conn, new_host, row): 'Updates the LOCATION field of one record' if not(isPxfTable(row[0])): return new_location = makeNewLocation(new_host, row[0]) dbconn.execSQL(conn, "UPDATE pg_exttable SET location = '" + new_location + "' WHERE reloid = " + str(row[1])) print "Updated LOCATION for table ", row[2], "oid: ", row[1], \ "\n Old LOCATION: ", row[0], "\n New LOCATION: ", new_location def updateNnHost(conn, new_host): 'update the LOCATION field for each record in pg_exttable' dbconn.execSQL(conn, "set allow_system_table_mods = 'DML'") dbconn.execSQL(conn, "START TRANSACTION") cursor = dbconn.execSQL(conn, "SELECT location, reloid, relname FROM pg_exttable, pg_class WHERE reloid = relfilenode") for row in cursor: updateOneRecord(conn, new_host, row) conn.commit() def main(): 'The driver function of this module' new_host = getNewHost() database = getDatabase() hawq_master_host = getMasterHost() hawq_master_port = getMasterPort() promptUser(new_host, database, hawq_master_host, hawq_master_port) conn = connectToDb(hawq_master_host, hawq_master_port, database) updateNnHost(conn, new_host) conn.close() if __name__ == "__main__": main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 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, 221, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 221, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 3, 299, 1949, 63, 9285, 63, 667, 23165, 14, 647, 199, 3, 961, 2366, 2884, 911, 19520, 314, 510, 25145, 5957, 6716, 370, 314, 892, 2812, 1716, 315, 1930, 199, 3, 402, 16332, 16599, 7615, 8722, 1433, 23165, 14, 221, 199, 3, 710, 2884, 23192, 465, 1324, 314, 892, 536, 932, 1591, 436, 2066, 13538, 1806, 1924, 5957, 199, 3, 1817, 2397, 315, 314, 10594, 1817, 10275, 63, 832, 1224, 436, 7029, 314, 3412, 35, 2594, 901, 446, 221, 199, 3, 19058, 314, 2269, 2812, 932, 1591, 543, 314, 892, 1373, 14, 9948, 199, 646, 984, 199, 504, 15852, 24111, 14, 697, 492, 1592, 1631, 199, 199, 318, 6835, 7692, 837, 2043, 283, 5375, 4503, 1059, 436, 10137, 7, 2043, 870, 298, 3807, 26, 299, 1949, 63, 9285, 63, 667, 23165, 665, 1222, 63, 354, 932, 63, 1102, 30, 665, 4659, 30, 5243, 72, 665, 2411, 87, 81, 63, 4133, 63, 1102, 19109, 5243, 80, 665, 2411, 87, 81, 63, 4133, 63, 719, 30, 8480, 2043, 4458, 342, 199, 199, 318, 664, 4665, 4965, 837, 2043, 283, 15656, 892, 2812, 1716, 687, 1414, 1004, 446, 20100, 340, 6835, 1324, 7, 2043, 340, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 489, 6835, 7692, 342, 2043, 372, 984, 14, 3020, 59, 17, 61, 272, 199, 318, 664, 7243, 837, 2043, 283, 15656, 3050, 687, 1414, 1004, 446, 20100, 340, 6835, 1324, 7, 2043, 340, 822, 8, 1274, 14, 3020, 9, 665, 650, 26, 489, 6835, 7692, 342, 2043, 372, 984, 14, 3020, 59, 18, 61, 272, 199, 318, 664, 7012, 3205, 8, 4173, 12, 849, 304, 2043, 408, 6767, 805, 446, 9619, 2310, 2716, 2633, 687, 314, 1324, 489, 982, 359, 4173, 665, 585, 19109, 365, 440, 641, 314, 1414, 1004, 12, 781, 675, 849, 15166, 1316, 6104, 316, 314, 6057, 14, 961, 365, 4212, 314, 1414, 1004, 1059, 626, 17957, 984, 14, 3020, 2529, 12, 10734, 2839, 26, 17957, 788, 13186, 80, 1949, 63, 9285, 63, 667, 23165, 14, 647, 297, 283, 5967, 297, 283, 1289, 706, 297, 2475, 72, 297, 283, 572, 561, 20875, 65, 3088, 14, 989, 80, 14, 69, 5466, 14, 957, 297, 2475, 80, 297, 283, 1477, 708, 418, 2043, 408, 2043, 1324, 275, 769, 8, 1274, 14, 3020, 9, 2043, 340, 1324, 14, 835, 8, 4173, 9, 508, 378, 26, 489, 372, 849, 2043, 3305, 63, 2996, 275, 1324, 14, 1080, 8, 4173, 9, 2043, 340, 822, 8, 1210, 9, 665, 3305, 63, 2996, 435, 17, 26, 489, 6835, 7692, 342, 2043, 372, 1324, 59, 4173, 63, 2996, 435, 413, 61, 272, 199, 318, 664, 12288, 4965, 837, 2043, 283, 15656, 394, 10084, 81, 63, 4133, 63, 1102, 687, 1414, 1004, 446, 2716, 7, 2043, 372, 664, 7012, 3205, 6096, 72, 401, 298, 5967, 531, 272, 199, 318, 664, 12288, 4313, 837, 2043, 283, 15656, 394, 10084, 81, 63, 4133, 63, 719, 687, 1414, 1004, 446, 2716, 7, 2043, 372, 664, 7012, 3205, 6096, 80, 401, 959, 10657, 9, 2126, 199, 318, 365, 48, 1949, 3186, 8, 1985, 304, 2043, 283, 22612, 271, 340, 642, 365, 282, 510, 25145, 1817, 701, 5909, 20135, 314, 3412, 35, 2594, 901, 367, 314, 1817, 2397, 315, 10275, 63, 832, 1224, 7, 2043, 372, 10467, 8, 1985, 59, 17, 26, 23, 20007, 80, 1949, 921, 531, 508, 378, 199, 199, 318, 1852, 4665, 6592, 8, 1222, 63, 1102, 12, 2909, 304, 2043, 283, 1155, 5862, 359, 1102, 61, 20597, 315, 359, 1985, 61, 543, 359, 1222, 63, 1102, 6616, 2043, 1343, 275, 2909, 14, 1623, 21816, 531, 2043, 1284, 275, 2909, 14, 1623, 480, 6783, 1343, 9, 2043, 1568, 275, 822, 8, 1985, 9, 2043, 892, 63, 1985, 275, 2909, 1491, 928, 61, 435, 23057, 2, 435, 892, 63, 1102, 435, 2909, 59, 500, 26, 890, 61, 2043, 372, 892, 63, 1985, 272, 199, 318, 8457, 1899, 8, 1222, 63, 1102, 12, 3050, 12, 394, 10084, 81, 63, 4133, 63, 1102, 12, 394, 10084, 81, 63, 4133, 63, 719, 304, 2043, 283, 39, 1912, 922, 282, 2061, 22044, 370, 1570, 17049, 25169, 7, 2043, 870, 298, 20326, 3350, 314, 1453, 2812, 932, 6246, 543, 2097, 435, 892, 63, 1102, 435, 32705, 315, 3050, 2097, 435, 3050, 435, 298, 8480, 2043, 870, 298, 40, 10084, 81, 5288, 365, 26, 2097, 435, 394, 10084, 81, 63, 4133, 63, 1102, 435, 32705, 436, 869, 10084, 81, 1844, 365, 26, 2097, 435, 620, 8, 2411, 87, 81, 63, 4133, 63, 719, 9, 435, 298, 8480, 2043, 9351, 275, 3066, 63, 1210, 360, 2585, 1265, 13809, 370, 1980, 26, 29715, 59, 57, 12978, 1944, 59, 46, 61, 5805, 358, 2043, 9351, 275, 9351, 14, 2325, 342, 2043, 340, 440, 8, 5730, 8, 8102, 12, 283, 5066, 358, 508, 378, 503, 10467, 8, 8102, 12, 283, 89, 358, 508, 378, 304, 489, 870, 298, 1899, 12985, 770, 370, 9311, 3439, 14, 7005, 5519, 11500, 489, 4458, 342, 9948, 199, 318, 4907, 1378, 8882, 8, 2411, 87, 81, 63, 4133, 63, 1102, 12, 394, 10084, 81, 63 ]
[ 2647, 15, 1393, 15, 1813, 2366, 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, 221, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 221, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 3, 299, 1949, 63, 9285, 63, 667, 23165, 14, 647, 199, 3, 961, 2366, 2884, 911, 19520, 314, 510, 25145, 5957, 6716, 370, 314, 892, 2812, 1716, 315, 1930, 199, 3, 402, 16332, 16599, 7615, 8722, 1433, 23165, 14, 221, 199, 3, 710, 2884, 23192, 465, 1324, 314, 892, 536, 932, 1591, 436, 2066, 13538, 1806, 1924, 5957, 199, 3, 1817, 2397, 315, 314, 10594, 1817, 10275, 63, 832, 1224, 436, 7029, 314, 3412, 35, 2594, 901, 446, 221, 199, 3, 19058, 314, 2269, 2812, 932, 1591, 543, 314, 892, 1373, 14, 9948, 199, 646, 984, 199, 504, 15852, 24111, 14, 697, 492, 1592, 1631, 199, 199, 318, 6835, 7692, 837, 2043, 283, 5375, 4503, 1059, 436, 10137, 7, 2043, 870, 298, 3807, 26, 299, 1949, 63, 9285, 63, 667, 23165, 665, 1222, 63, 354, 932, 63, 1102, 30, 665, 4659, 30, 5243, 72, 665, 2411, 87, 81, 63, 4133, 63, 1102, 19109, 5243, 80, 665, 2411, 87, 81, 63, 4133, 63, 719, 30, 8480, 2043, 4458, 342, 199, 199, 318, 664, 4665, 4965, 837, 2043, 283, 15656, 892, 2812, 1716, 687, 1414, 1004, 446, 20100, 340, 6835, 1324, 7, 2043, 340, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 489, 6835, 7692, 342, 2043, 372, 984, 14, 3020, 59, 17, 61, 272, 199, 318, 664, 7243, 837, 2043, 283, 15656, 3050, 687, 1414, 1004, 446, 20100, 340, 6835, 1324, 7, 2043, 340, 822, 8, 1274, 14, 3020, 9, 665, 650, 26, 489, 6835, 7692, 342, 2043, 372, 984, 14, 3020, 59, 18, 61, 272, 199, 318, 664, 7012, 3205, 8, 4173, 12, 849, 304, 2043, 408, 6767, 805, 446, 9619, 2310, 2716, 2633, 687, 314, 1324, 489, 982, 359, 4173, 665, 585, 19109, 365, 440, 641, 314, 1414, 1004, 12, 781, 675, 849, 15166, 1316, 6104, 316, 314, 6057, 14, 961, 365, 4212, 314, 1414, 1004, 1059, 626, 17957, 984, 14, 3020, 2529, 12, 10734, 2839, 26, 17957, 788, 13186, 80, 1949, 63, 9285, 63, 667, 23165, 14, 647, 297, 283, 5967, 297, 283, 1289, 706, 297, 2475, 72, 297, 283, 572, 561, 20875, 65, 3088, 14, 989, 80, 14, 69, 5466, 14, 957, 297, 2475, 80, 297, 283, 1477, 708, 418, 2043, 408, 2043, 1324, 275, 769, 8, 1274, 14, 3020, 9, 2043, 340, 1324, 14, 835, 8, 4173, 9, 508, 378, 26, 489, 372, 849, 2043, 3305, 63, 2996, 275, 1324, 14, 1080, 8, 4173, 9, 2043, 340, 822, 8, 1210, 9, 665, 3305, 63, 2996, 435, 17, 26, 489, 6835, 7692, 342, 2043, 372, 1324, 59, 4173, 63, 2996, 435, 413, 61, 272, 199, 318, 664, 12288, 4965, 837, 2043, 283, 15656, 394, 10084, 81, 63, 4133, 63, 1102, 687, 1414, 1004, 446, 2716, 7, 2043, 372, 664, 7012, 3205, 6096, 72, 401, 298, 5967, 531, 272, 199, 318, 664, 12288, 4313, 837, 2043, 283, 15656, 394, 10084, 81, 63, 4133, 63, 719, 687, 1414, 1004, 446, 2716, 7, 2043, 372, 664, 7012, 3205, 6096, 80, 401, 959, 10657, 9, 2126, 199, 318, 365, 48, 1949, 3186, 8, 1985, 304, 2043, 283, 22612, 271, 340, 642, 365, 282, 510, 25145, 1817, 701, 5909, 20135, 314, 3412, 35, 2594, 901, 367, 314, 1817, 2397, 315, 10275, 63, 832, 1224, 7, 2043, 372, 10467, 8, 1985, 59, 17, 26, 23, 20007, 80, 1949, 921, 531, 508, 378, 199, 199, 318, 1852, 4665, 6592, 8, 1222, 63, 1102, 12, 2909, 304, 2043, 283, 1155, 5862, 359, 1102, 61, 20597, 315, 359, 1985, 61, 543, 359, 1222, 63, 1102, 6616, 2043, 1343, 275, 2909, 14, 1623, 21816, 531, 2043, 1284, 275, 2909, 14, 1623, 480, 6783, 1343, 9, 2043, 1568, 275, 822, 8, 1985, 9, 2043, 892, 63, 1985, 275, 2909, 1491, 928, 61, 435, 23057, 2, 435, 892, 63, 1102, 435, 2909, 59, 500, 26, 890, 61, 2043, 372, 892, 63, 1985, 272, 199, 318, 8457, 1899, 8, 1222, 63, 1102, 12, 3050, 12, 394, 10084, 81, 63, 4133, 63, 1102, 12, 394, 10084, 81, 63, 4133, 63, 719, 304, 2043, 283, 39, 1912, 922, 282, 2061, 22044, 370, 1570, 17049, 25169, 7, 2043, 870, 298, 20326, 3350, 314, 1453, 2812, 932, 6246, 543, 2097, 435, 892, 63, 1102, 435, 32705, 315, 3050, 2097, 435, 3050, 435, 298, 8480, 2043, 870, 298, 40, 10084, 81, 5288, 365, 26, 2097, 435, 394, 10084, 81, 63, 4133, 63, 1102, 435, 32705, 436, 869, 10084, 81, 1844, 365, 26, 2097, 435, 620, 8, 2411, 87, 81, 63, 4133, 63, 719, 9, 435, 298, 8480, 2043, 9351, 275, 3066, 63, 1210, 360, 2585, 1265, 13809, 370, 1980, 26, 29715, 59, 57, 12978, 1944, 59, 46, 61, 5805, 358, 2043, 9351, 275, 9351, 14, 2325, 342, 2043, 340, 440, 8, 5730, 8, 8102, 12, 283, 5066, 358, 508, 378, 503, 10467, 8, 8102, 12, 283, 89, 358, 508, 378, 304, 489, 870, 298, 1899, 12985, 770, 370, 9311, 3439, 14, 7005, 5519, 11500, 489, 4458, 342, 9948, 199, 318, 4907, 1378, 8882, 8, 2411, 87, 81, 63, 4133, 63, 1102, 12, 394, 10084, 81, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
Mirdrack/4chanscrapper
lib/python2.7/site-packages/requests/structures.py
1160
2977
# -*- coding: utf-8 -*- """ requests.structures ~~~~~~~~~~~~~~~~~~~ Data structures that power Requests. """ import collections class CaseInsensitiveDict(collections.MutableMapping): """ A case-insensitive ``dict``-like object. Implements all methods and operations of ``collections.MutableMapping`` as well as dict's ``copy``. Also provides ``lower_items``. All keys are expected to be strings. The structure remembers the case of the last key to be set, and ``iter(instance)``, ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()`` will contain case-sensitive keys. However, querying and contains testing is case insensitive:: cid = CaseInsensitiveDict() cid['Accept'] = 'application/json' cid['aCCEPT'] == 'application/json' # True list(cid) == ['Accept'] # True For example, ``headers['content-encoding']`` will return the value of a ``'Content-Encoding'`` response header, regardless of how the header name was originally stored. If the constructor, ``.update``, or equality comparison operations are given keys that have equal ``.lower()``s, the behavior is undefined. """ def __init__(self, data=None, **kwargs): self._store = dict() if data is None: data = {} self.update(data, **kwargs) def __setitem__(self, key, value): # Use the lowercased key for lookups, but store the actual # key alongside the value. self._store[key.lower()] = (key, value) def __getitem__(self, key): return self._store[key.lower()][1] def __delitem__(self, key): del self._store[key.lower()] def __iter__(self): return (casedkey for casedkey, mappedvalue in self._store.values()) def __len__(self): return len(self._store) def lower_items(self): """Like iteritems(), but with all lowercase keys.""" return ( (lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items() ) def __eq__(self, other): if isinstance(other, collections.Mapping): other = CaseInsensitiveDict(other) else: return NotImplemented # Compare insensitively return dict(self.lower_items()) == dict(other.lower_items()) # Copy is required def copy(self): return CaseInsensitiveDict(self._store.values()) def __repr__(self): return str(dict(self.items())) class LookupDict(dict): """Dictionary lookup object.""" def __init__(self, name=None): self.name = name super(LookupDict, self).__init__() def __repr__(self): return '<lookup \'%s\'>' % (self.name) def __getitem__(self, key): # We allow fall-through here, so values default to None return self.__dict__.get(key, None) def get(self, key, default=None): return self.__dict__.get(key, default)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 6615, 14, 13547, 199, 9753, 23597, 199, 199, 1451, 13955, 626, 7074, 20260, 14, 199, 199, 624, 199, 199, 646, 5055, 421, 199, 533, 12425, 32697, 8, 7882, 14, 17707, 7674, 304, 272, 408, 272, 437, 1930, 13, 15851, 1124, 807, 1040, 13, 2930, 909, 14, 339, 24664, 1006, 3102, 436, 5331, 402, 272, 1124, 7882, 14, 17707, 7674, 1040, 465, 5521, 465, 1211, 1159, 1124, 1574, 4345, 6121, 272, 6571, 1124, 2325, 63, 1744, 4345, 339, 2900, 2883, 787, 1420, 370, 506, 3326, 14, 710, 5523, 295, 6334, 314, 272, 1930, 402, 314, 2061, 790, 370, 506, 663, 12, 436, 1124, 1661, 8, 842, 28616, 272, 1124, 1612, 22524, 1124, 1744, 22524, 1124, 16007, 22524, 436, 1124, 4611, 8497, 272, 911, 1395, 1930, 13, 7361, 2883, 14, 9738, 12, 27405, 436, 3509, 272, 5343, 365, 1930, 27845, 447, 398, 12229, 275, 12425, 32697, 342, 267, 12229, 459, 8422, 418, 275, 283, 3578, 15, 1001, 7, 267, 12229, 459, 65, 35, 7177, 418, 508, 283, 3578, 15, 1001, 7, 221, 327, 715, 267, 769, 8, 7504, 9, 508, 788, 8422, 418, 221, 327, 715, 339, 2104, 2893, 12, 1124, 2139, 459, 1317, 13, 2991, 418, 1040, 911, 372, 314, 272, 574, 402, 282, 12692, 2714, 13, 7630, 14700, 1177, 1406, 12, 15270, 272, 402, 4212, 314, 1406, 536, 1990, 20657, 5489, 14, 339, 982, 314, 3787, 12, 21502, 873, 4542, 503, 16612, 9132, 272, 5331, 787, 1627, 2883, 626, 1172, 4472, 21502, 2325, 8497, 83, 12, 314, 272, 5953, 365, 10942, 14, 339, 408, 272, 347, 636, 826, 721, 277, 12, 666, 29, 403, 12, 1011, 958, 304, 267, 291, 423, 1617, 275, 1211, 342, 267, 340, 666, 365, 488, 26, 288, 666, 275, 1052, 267, 291, 14, 873, 8, 576, 12, 1011, 958, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 327, 3645, 314, 12141, 68, 790, 367, 16807, 12, 1325, 3877, 314, 3503, 267, 327, 790, 3180, 2441, 314, 574, 14, 267, 291, 423, 1617, 59, 498, 14, 2325, 5106, 275, 334, 498, 12, 574, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 423, 1617, 59, 498, 14, 2325, 342, 1527, 17, 61, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 2150, 291, 423, 1617, 59, 498, 14, 2325, 5106, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 334, 32738, 498, 367, 1930, 68, 498, 12, 9994, 585, 315, 291, 423, 1617, 14, 1459, 1012, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 423, 1617, 9, 339, 347, 5117, 63, 1744, 8, 277, 304, 267, 408, 12545, 10849, 1062, 1325, 543, 1006, 12141, 2883, 1041, 267, 372, 334, 288, 334, 2325, 498, 12, 790, 637, 59, 17, 566, 288, 367, 334, 2325, 498, 12, 790, 637, 9, 288, 315, 291, 423, 1617, 14, 1744, 342, 267, 776, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 5055, 14, 7674, 304, 288, 1163, 275, 12425, 32697, 8, 1848, 9, 267, 587, 26, 288, 372, 3784, 267, 327, 18955, 315, 2464, 338, 9462, 267, 372, 1211, 8, 277, 14, 2325, 63, 1744, 1012, 508, 1211, 8, 1848, 14, 2325, 63, 1744, 1012, 339, 327, 11247, 365, 1415, 272, 347, 1331, 8, 277, 304, 267, 372, 12425, 32697, 8, 277, 423, 1617, 14, 1459, 1012, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 620, 8, 807, 8, 277, 14, 1744, 4059, 199, 199, 533, 12785, 2141, 8, 807, 304, 272, 408, 11728, 4237, 909, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 1613, 8, 7521, 2141, 12, 291, 2843, 826, 4533, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 3892, 19095, 83, 3985, 3524, 450, 334, 277, 14, 354, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 2136, 2040, 11264, 13, 8304, 2348, 12, 880, 1338, 849, 370, 488, 398, 372, 291, 855, 807, 4343, 362, 8, 498, 12, 488, 9, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 372, 291, 855, 807, 4343, 362, 8, 498, 12, 849, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 6615, 14, 13547, 199, 9753, 23597, 199, 199, 1451, 13955, 626, 7074, 20260, 14, 199, 199, 624, 199, 199, 646, 5055, 421, 199, 533, 12425, 32697, 8, 7882, 14, 17707, 7674, 304, 272, 408, 272, 437, 1930, 13, 15851, 1124, 807, 1040, 13, 2930, 909, 14, 339, 24664, 1006, 3102, 436, 5331, 402, 272, 1124, 7882, 14, 17707, 7674, 1040, 465, 5521, 465, 1211, 1159, 1124, 1574, 4345, 6121, 272, 6571, 1124, 2325, 63, 1744, 4345, 339, 2900, 2883, 787, 1420, 370, 506, 3326, 14, 710, 5523, 295, 6334, 314, 272, 1930, 402, 314, 2061, 790, 370, 506, 663, 12, 436, 1124, 1661, 8, 842, 28616, 272, 1124, 1612, 22524, 1124, 1744, 22524, 1124, 16007, 22524, 436, 1124, 4611, 8497, 272, 911, 1395, 1930, 13, 7361, 2883, 14, 9738, 12, 27405, 436, 3509, 272, 5343, 365, 1930, 27845, 447, 398, 12229, 275, 12425, 32697, 342, 267, 12229, 459, 8422, 418, 275, 283, 3578, 15, 1001, 7, 267, 12229, 459, 65, 35, 7177, 418, 508, 283, 3578, 15, 1001, 7, 221, 327, 715, 267, 769, 8, 7504, 9, 508, 788, 8422, 418, 221, 327, 715, 339, 2104, 2893, 12, 1124, 2139, 459, 1317, 13, 2991, 418, 1040, 911, 372, 314, 272, 574, 402, 282, 12692, 2714, 13, 7630, 14700, 1177, 1406, 12, 15270, 272, 402, 4212, 314, 1406, 536, 1990, 20657, 5489, 14, 339, 982, 314, 3787, 12, 21502, 873, 4542, 503, 16612, 9132, 272, 5331, 787, 1627, 2883, 626, 1172, 4472, 21502, 2325, 8497, 83, 12, 314, 272, 5953, 365, 10942, 14, 339, 408, 272, 347, 636, 826, 721, 277, 12, 666, 29, 403, 12, 1011, 958, 304, 267, 291, 423, 1617, 275, 1211, 342, 267, 340, 666, 365, 488, 26, 288, 666, 275, 1052, 267, 291, 14, 873, 8, 576, 12, 1011, 958, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 327, 3645, 314, 12141, 68, 790, 367, 16807, 12, 1325, 3877, 314, 3503, 267, 327, 790, 3180, 2441, 314, 574, 14, 267, 291, 423, 1617, 59, 498, 14, 2325, 5106, 275, 334, 498, 12, 574, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 423, 1617, 59, 498, 14, 2325, 342, 1527, 17, 61, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 2150, 291, 423, 1617, 59, 498, 14, 2325, 5106, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 334, 32738, 498, 367, 1930, 68, 498, 12, 9994, 585, 315, 291, 423, 1617, 14, 1459, 1012, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 423, 1617, 9, 339, 347, 5117, 63, 1744, 8, 277, 304, 267, 408, 12545, 10849, 1062, 1325, 543, 1006, 12141, 2883, 1041, 267, 372, 334, 288, 334, 2325, 498, 12, 790, 637, 59, 17, 566, 288, 367, 334, 2325, 498, 12, 790, 637, 9, 288, 315, 291, 423, 1617, 14, 1744, 342, 267, 776, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 5055, 14, 7674, 304, 288, 1163, 275, 12425, 32697, 8, 1848, 9, 267, 587, 26, 288, 372, 3784, 267, 327, 18955, 315, 2464, 338, 9462, 267, 372, 1211, 8, 277, 14, 2325, 63, 1744, 1012, 508, 1211, 8, 1848, 14, 2325, 63, 1744, 1012, 339, 327, 11247, 365, 1415, 272, 347, 1331, 8, 277, 304, 267, 372, 12425, 32697, 8, 277, 423, 1617, 14, 1459, 1012, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 620, 8, 807, 8, 277, 14, 1744, 4059, 199, 199, 533, 12785, 2141, 8, 807, 304, 272, 408, 11728, 4237, 909, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 1613, 8, 7521, 2141, 12, 291, 2843, 826, 4533, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 3892, 19095, 83, 3985, 3524, 450, 334, 277, 14, 354, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 2136, 2040, 11264, 13, 8304, 2348, 12, 880, 1338, 849, 370, 488, 398, 372, 291, 855, 807, 4343, 362, 8, 498, 12, 488, 9, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 372, 291, 855, 807, 4343, 362, 8, 498, 12, 849, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
libcrosswind/libcrosswind
platform/windows/compilers/x64/TDM-GCC-64/gdb64/bin/lib/wsgiref/headers.py
229
5879
"""Manage HTTP Response Headers Much of this module is red-handedly pilfered from email.message in the stdlib, so portions are Copyright (C) 2001,2002 Python Software Foundation, and were written by Barry Warsaw. """ from types import ListType, TupleType # Regular expression that matches `special' characters in parameters, the # existence of which force quoting of the parameter value. import re tspecials = re.compile(r'[ \(\)<>@,;:\\"/\[\]\?=]') def _formatparam(param, value=None, quote=1): """Convenience function to format and return a key=value pair. This will quote the value if needed or if quote is true. """ if value is not None and len(value) > 0: if quote or tspecials.search(value): value = value.replace('\\', '\\\\').replace('"', r'\"') return '%s="%s"' % (param, value) else: return '%s=%s' % (param, value) else: return param class Headers: """Manage a collection of HTTP response headers""" def __init__(self,headers): if type(headers) is not ListType: raise TypeError("Headers must be a list of name/value tuples") self._headers = headers def __len__(self): """Return the total number of headers, including duplicates.""" return len(self._headers) def __setitem__(self, name, val): """Set the value of a header.""" del self[name] self._headers.append((name, val)) def __delitem__(self,name): """Delete all occurrences of a header, if present. Does *not* raise an exception if the header is missing. """ name = name.lower() self._headers[:] = [kv for kv in self._headers if kv[0].lower() != name] def __getitem__(self,name): """Get the first header value for 'name' Return None if the header is missing instead of raising an exception. Note that if the header appeared multiple times, the first exactly which occurrance gets returned is undefined. Use getall() to get all the values matching a header field name. """ return self.get(name) def has_key(self, name): """Return true if the message contains the header.""" return self.get(name) is not None __contains__ = has_key def get_all(self, name): """Return a list of all the values for the named field. These will be sorted in the order they appeared in the original header list or were added to this instance, and may contain duplicates. Any fields deleted and re-inserted are always appended to the header list. If no fields exist with the given name, returns an empty list. """ name = name.lower() return [kv[1] for kv in self._headers if kv[0].lower()==name] def get(self,name,default=None): """Get the first header value for 'name', or return 'default'""" name = name.lower() for k,v in self._headers: if k.lower()==name: return v return default def keys(self): """Return a list of all the header field names. These will be sorted in the order they appeared in the original header list, or were added to this instance, and may contain duplicates. Any fields deleted and re-inserted are always appended to the header list. """ return [k for k, v in self._headers] def values(self): """Return a list of all header values. These will be sorted in the order they appeared in the original header list, or were added to this instance, and may contain duplicates. Any fields deleted and re-inserted are always appended to the header list. """ return [v for k, v in self._headers] def items(self): """Get all the header fields and values. These will be sorted in the order they were in the original header list, or were added to this instance, and may contain duplicates. Any fields deleted and re-inserted are always appended to the header list. """ return self._headers[:] def __repr__(self): return "Headers(%r)" % self._headers def __str__(self): """str() returns the formatted headers, complete with end line, suitable for direct HTTP transmission.""" return '\r\n'.join(["%s: %s" % kv for kv in self._headers]+['','']) def setdefault(self,name,value): """Return first matching header value for 'name', or 'value' If there is no header named 'name', add a new header with name 'name' and value 'value'.""" result = self.get(name) if result is None: self._headers.append((name,value)) return value else: return result def add_header(self, _name, _value, **_params): """Extended header setting. _name is the header field to add. keyword arguments can be used to set additional parameters for the header field, with underscores converted to dashes. Normally the parameter will be added as key="value" unless value is None, in which case only the key will be added. Example: h.add_header('content-disposition', 'attachment', filename='bud.gif') Note that unlike the corresponding 'email.message' method, this does *not* handle '(charset, language, value)' tuples: all values must be strings or None. """ parts = [] if _value is not None: parts.append(_value) for k, v in _params.items(): if v is None: parts.append(k.replace('_', '-')) else: parts.append(_formatparam(k.replace('_', '-'), v)) self._headers.append((_name, "; ".join(parts)))
gpl-3.0
[ 624, 20588, 3101, 7232, 21391, 199, 199, 45, 2133, 402, 642, 859, 365, 8992, 13, 72, 7028, 590, 6682, 276, 16179, 687, 3031, 14, 1188, 315, 314, 26678, 12, 199, 1152, 12468, 787, 1898, 334, 35, 9, 12521, 12, 15135, 2018, 2290, 2752, 12, 436, 4898, 199, 8938, 701, 12377, 651, 644, 285, 2231, 87, 14, 199, 624, 199, 199, 504, 2943, 492, 3820, 804, 12, 11634, 804, 199, 199, 3, 18528, 3965, 626, 4450, 658, 6664, 7, 4110, 315, 2633, 12, 314, 199, 3, 23780, 402, 1314, 3542, 18593, 402, 314, 2725, 574, 14, 199, 646, 295, 199, 1086, 910, 2551, 275, 295, 14, 2014, 8, 82, 3894, 971, 2961, 9, 16137, 32, 12, 27, 26, 15022, 6307, 7023, 7272, 23295, 10374, 199, 199, 318, 485, 908, 635, 8, 635, 12, 574, 29, 403, 12, 6313, 29, 17, 304, 272, 408, 714, 23329, 805, 370, 1475, 436, 372, 282, 790, 29, 585, 4092, 14, 339, 961, 911, 6313, 314, 574, 340, 4346, 503, 340, 6313, 365, 2549, 14, 272, 408, 272, 340, 574, 365, 440, 488, 436, 822, 8, 585, 9, 690, 378, 26, 267, 340, 6313, 503, 307, 3017, 2551, 14, 1733, 8, 585, 304, 288, 574, 275, 574, 14, 1814, 20786, 31375, 1959, 1814, 20630, 519, 1154, 9008, 288, 372, 1543, 83, 5961, 83, 4507, 450, 334, 635, 12, 574, 9, 267, 587, 26, 288, 372, 1543, 83, 2458, 83, 7, 450, 334, 635, 12, 574, 9, 272, 587, 26, 267, 372, 1215, 421, 199, 533, 21391, 26, 339, 408, 20588, 282, 3245, 402, 3101, 1177, 2323, 624, 339, 347, 636, 826, 721, 277, 12, 2139, 304, 267, 340, 730, 8, 2139, 9, 365, 440, 3820, 804, 26, 288, 746, 3146, 480, 9883, 1471, 506, 282, 769, 402, 536, 15, 585, 6346, 531, 267, 291, 423, 2139, 275, 2323, 339, 347, 636, 552, 721, 277, 304, 267, 408, 1767, 314, 3141, 1329, 402, 2323, 12, 5893, 15755, 1041, 267, 372, 822, 8, 277, 423, 2139, 9, 339, 347, 636, 8617, 721, 277, 12, 536, 12, 1139, 304, 267, 408, 1084, 314, 574, 402, 282, 1406, 1041, 267, 2150, 291, 59, 354, 61, 267, 291, 423, 2139, 14, 740, 1332, 354, 12, 1139, 430, 339, 347, 636, 13228, 721, 277, 12, 354, 304, 267, 408, 5392, 1006, 22099, 402, 282, 1406, 12, 340, 3451, 14, 398, 12078, 627, 1397, 10, 746, 376, 1919, 340, 314, 1406, 365, 4124, 14, 267, 408, 267, 536, 275, 536, 14, 2325, 342, 267, 291, 423, 2139, 5873, 275, 359, 11475, 367, 16616, 315, 291, 423, 2139, 340, 16616, 59, 16, 1055, 2325, 342, 1137, 536, 61, 339, 347, 636, 6095, 721, 277, 12, 354, 304, 267, 408, 1002, 314, 1642, 1406, 574, 367, 283, 354, 7, 398, 1432, 488, 340, 314, 1406, 365, 4124, 3140, 402, 17026, 376, 1919, 14, 398, 3390, 626, 340, 314, 1406, 5704, 2899, 3663, 5431, 12, 314, 1642, 8840, 1314, 267, 4781, 31331, 7545, 2138, 365, 10942, 14, 221, 3645, 664, 452, 342, 370, 664, 1006, 267, 314, 1338, 4877, 282, 1406, 901, 536, 14, 267, 408, 267, 372, 291, 14, 362, 8, 354, 9, 339, 347, 965, 63, 498, 8, 277, 12, 536, 304, 267, 408, 1767, 2549, 340, 314, 1245, 3509, 314, 1406, 1041, 267, 372, 291, 14, 362, 8, 354, 9, 365, 440, 488, 339, 636, 6134, 363, 275, 965, 63, 498, 2378, 347, 664, 63, 452, 8, 277, 12, 536, 304, 267, 408, 1767, 282, 769, 402, 1006, 314, 1338, 367, 314, 4310, 901, 14, 398, 5723, 911, 506, 3355, 315, 314, 1865, 2985, 5704, 2899, 315, 314, 3379, 1406, 267, 769, 503, 4898, 3483, 370, 642, 1256, 12, 436, 1443, 1395, 15755, 14, 221, 6184, 267, 1504, 5463, 436, 295, 13, 28565, 787, 3544, 11544, 370, 314, 1406, 769, 14, 267, 982, 949, 1504, 2187, 543, 314, 1627, 536, 12, 2529, 376, 2701, 769, 14, 267, 408, 267, 536, 275, 536, 14, 2325, 342, 267, 372, 359, 11475, 59, 17, 61, 367, 16616, 315, 291, 423, 2139, 340, 16616, 59, 16, 1055, 2325, 342, 389, 354, 61, 2378, 347, 664, 8, 277, 12, 354, 12, 885, 29, 403, 304, 267, 408, 1002, 314, 1642, 1406, 574, 367, 283, 354, 297, 503, 372, 283, 885, 26555, 267, 536, 275, 536, 14, 2325, 342, 267, 367, 1022, 12, 86, 315, 291, 423, 2139, 26, 288, 340, 1022, 14, 2325, 342, 389, 354, 26, 355, 372, 373, 267, 372, 849, 2378, 347, 2883, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 1006, 314, 1406, 901, 1561, 14, 398, 5723, 911, 506, 3355, 315, 314, 1865, 2985, 5704, 2899, 315, 314, 3379, 1406, 267, 769, 12, 503, 4898, 3483, 370, 642, 1256, 12, 436, 1443, 1395, 15755, 14, 267, 6184, 1504, 5463, 436, 295, 13, 28565, 787, 3544, 11544, 370, 314, 1406, 267, 769, 14, 267, 408, 267, 372, 359, 75, 367, 1022, 12, 373, 315, 291, 423, 2139, 61, 339, 347, 1338, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 1006, 1406, 1338, 14, 398, 5723, 911, 506, 3355, 315, 314, 1865, 2985, 5704, 2899, 315, 314, 3379, 1406, 267, 769, 12, 503, 4898, 3483, 370, 642, 1256, 12, 436, 1443, 1395, 15755, 14, 267, 6184, 1504, 5463, 436, 295, 13, 28565, 787, 3544, 11544, 370, 314, 1406, 267, 769, 14, 267, 408, 267, 372, 359, 86, 367, 1022, 12, 373, 315, 291, 423, 2139, 61, 339, 347, 2974, 8, 277, 304, 267, 408, 1002, 1006, 314, 1406, 1504, 436, 1338, 14, 398, 5723, 911, 506, 3355, 315, 314, 1865, 2985, 4898, 315, 314, 3379, 1406, 267, 769, 12, 503, 4898, 3483, 370, 642, 1256, 12, 436, 1443, 1395, 15755, 14, 267, 6184, 1504, 5463, 436, 295, 13, 28565, 787, 3544, 11544, 370, 314, 1406, 267, 769, 14, 267, 408, 267, 372, 291, 423, 2139, 5873, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 9883, 4042, 82, 2924, 450, 291, 423, 2139, 339, 347, 636, 495, 721, 277, 304, 267, 408, 495, 342, 2529, 314, 7871, 2323, 12, 4890, 543, 1284, 1004, 12, 267, 11233, 367, 4125, 3101, 1752, 2250, 1041, 267, 372, 1557, 82, 60, 78, 1370, 904, 30387, 83, 26, 450, 83, 2 ]
[ 20588, 3101, 7232, 21391, 199, 199, 45, 2133, 402, 642, 859, 365, 8992, 13, 72, 7028, 590, 6682, 276, 16179, 687, 3031, 14, 1188, 315, 314, 26678, 12, 199, 1152, 12468, 787, 1898, 334, 35, 9, 12521, 12, 15135, 2018, 2290, 2752, 12, 436, 4898, 199, 8938, 701, 12377, 651, 644, 285, 2231, 87, 14, 199, 624, 199, 199, 504, 2943, 492, 3820, 804, 12, 11634, 804, 199, 199, 3, 18528, 3965, 626, 4450, 658, 6664, 7, 4110, 315, 2633, 12, 314, 199, 3, 23780, 402, 1314, 3542, 18593, 402, 314, 2725, 574, 14, 199, 646, 295, 199, 1086, 910, 2551, 275, 295, 14, 2014, 8, 82, 3894, 971, 2961, 9, 16137, 32, 12, 27, 26, 15022, 6307, 7023, 7272, 23295, 10374, 199, 199, 318, 485, 908, 635, 8, 635, 12, 574, 29, 403, 12, 6313, 29, 17, 304, 272, 408, 714, 23329, 805, 370, 1475, 436, 372, 282, 790, 29, 585, 4092, 14, 339, 961, 911, 6313, 314, 574, 340, 4346, 503, 340, 6313, 365, 2549, 14, 272, 408, 272, 340, 574, 365, 440, 488, 436, 822, 8, 585, 9, 690, 378, 26, 267, 340, 6313, 503, 307, 3017, 2551, 14, 1733, 8, 585, 304, 288, 574, 275, 574, 14, 1814, 20786, 31375, 1959, 1814, 20630, 519, 1154, 9008, 288, 372, 1543, 83, 5961, 83, 4507, 450, 334, 635, 12, 574, 9, 267, 587, 26, 288, 372, 1543, 83, 2458, 83, 7, 450, 334, 635, 12, 574, 9, 272, 587, 26, 267, 372, 1215, 421, 199, 533, 21391, 26, 339, 408, 20588, 282, 3245, 402, 3101, 1177, 2323, 624, 339, 347, 636, 826, 721, 277, 12, 2139, 304, 267, 340, 730, 8, 2139, 9, 365, 440, 3820, 804, 26, 288, 746, 3146, 480, 9883, 1471, 506, 282, 769, 402, 536, 15, 585, 6346, 531, 267, 291, 423, 2139, 275, 2323, 339, 347, 636, 552, 721, 277, 304, 267, 408, 1767, 314, 3141, 1329, 402, 2323, 12, 5893, 15755, 1041, 267, 372, 822, 8, 277, 423, 2139, 9, 339, 347, 636, 8617, 721, 277, 12, 536, 12, 1139, 304, 267, 408, 1084, 314, 574, 402, 282, 1406, 1041, 267, 2150, 291, 59, 354, 61, 267, 291, 423, 2139, 14, 740, 1332, 354, 12, 1139, 430, 339, 347, 636, 13228, 721, 277, 12, 354, 304, 267, 408, 5392, 1006, 22099, 402, 282, 1406, 12, 340, 3451, 14, 398, 12078, 627, 1397, 10, 746, 376, 1919, 340, 314, 1406, 365, 4124, 14, 267, 408, 267, 536, 275, 536, 14, 2325, 342, 267, 291, 423, 2139, 5873, 275, 359, 11475, 367, 16616, 315, 291, 423, 2139, 340, 16616, 59, 16, 1055, 2325, 342, 1137, 536, 61, 339, 347, 636, 6095, 721, 277, 12, 354, 304, 267, 408, 1002, 314, 1642, 1406, 574, 367, 283, 354, 7, 398, 1432, 488, 340, 314, 1406, 365, 4124, 3140, 402, 17026, 376, 1919, 14, 398, 3390, 626, 340, 314, 1406, 5704, 2899, 3663, 5431, 12, 314, 1642, 8840, 1314, 267, 4781, 31331, 7545, 2138, 365, 10942, 14, 221, 3645, 664, 452, 342, 370, 664, 1006, 267, 314, 1338, 4877, 282, 1406, 901, 536, 14, 267, 408, 267, 372, 291, 14, 362, 8, 354, 9, 339, 347, 965, 63, 498, 8, 277, 12, 536, 304, 267, 408, 1767, 2549, 340, 314, 1245, 3509, 314, 1406, 1041, 267, 372, 291, 14, 362, 8, 354, 9, 365, 440, 488, 339, 636, 6134, 363, 275, 965, 63, 498, 2378, 347, 664, 63, 452, 8, 277, 12, 536, 304, 267, 408, 1767, 282, 769, 402, 1006, 314, 1338, 367, 314, 4310, 901, 14, 398, 5723, 911, 506, 3355, 315, 314, 1865, 2985, 5704, 2899, 315, 314, 3379, 1406, 267, 769, 503, 4898, 3483, 370, 642, 1256, 12, 436, 1443, 1395, 15755, 14, 221, 6184, 267, 1504, 5463, 436, 295, 13, 28565, 787, 3544, 11544, 370, 314, 1406, 769, 14, 267, 982, 949, 1504, 2187, 543, 314, 1627, 536, 12, 2529, 376, 2701, 769, 14, 267, 408, 267, 536, 275, 536, 14, 2325, 342, 267, 372, 359, 11475, 59, 17, 61, 367, 16616, 315, 291, 423, 2139, 340, 16616, 59, 16, 1055, 2325, 342, 389, 354, 61, 2378, 347, 664, 8, 277, 12, 354, 12, 885, 29, 403, 304, 267, 408, 1002, 314, 1642, 1406, 574, 367, 283, 354, 297, 503, 372, 283, 885, 26555, 267, 536, 275, 536, 14, 2325, 342, 267, 367, 1022, 12, 86, 315, 291, 423, 2139, 26, 288, 340, 1022, 14, 2325, 342, 389, 354, 26, 355, 372, 373, 267, 372, 849, 2378, 347, 2883, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 1006, 314, 1406, 901, 1561, 14, 398, 5723, 911, 506, 3355, 315, 314, 1865, 2985, 5704, 2899, 315, 314, 3379, 1406, 267, 769, 12, 503, 4898, 3483, 370, 642, 1256, 12, 436, 1443, 1395, 15755, 14, 267, 6184, 1504, 5463, 436, 295, 13, 28565, 787, 3544, 11544, 370, 314, 1406, 267, 769, 14, 267, 408, 267, 372, 359, 75, 367, 1022, 12, 373, 315, 291, 423, 2139, 61, 339, 347, 1338, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 1006, 1406, 1338, 14, 398, 5723, 911, 506, 3355, 315, 314, 1865, 2985, 5704, 2899, 315, 314, 3379, 1406, 267, 769, 12, 503, 4898, 3483, 370, 642, 1256, 12, 436, 1443, 1395, 15755, 14, 267, 6184, 1504, 5463, 436, 295, 13, 28565, 787, 3544, 11544, 370, 314, 1406, 267, 769, 14, 267, 408, 267, 372, 359, 86, 367, 1022, 12, 373, 315, 291, 423, 2139, 61, 339, 347, 2974, 8, 277, 304, 267, 408, 1002, 1006, 314, 1406, 1504, 436, 1338, 14, 398, 5723, 911, 506, 3355, 315, 314, 1865, 2985, 4898, 315, 314, 3379, 1406, 267, 769, 12, 503, 4898, 3483, 370, 642, 1256, 12, 436, 1443, 1395, 15755, 14, 267, 6184, 1504, 5463, 436, 295, 13, 28565, 787, 3544, 11544, 370, 314, 1406, 267, 769, 14, 267, 408, 267, 372, 291, 423, 2139, 5873, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 9883, 4042, 82, 2924, 450, 291, 423, 2139, 339, 347, 636, 495, 721, 277, 304, 267, 408, 495, 342, 2529, 314, 7871, 2323, 12, 4890, 543, 1284, 1004, 12, 267, 11233, 367, 4125, 3101, 1752, 2250, 1041, 267, 372, 1557, 82, 60, 78, 1370, 904, 30387, 83, 26, 450, 83, 2, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
prark/bitcoinxt
qa/rpc-tests/test_framework/blocktools.py
93
2057
# blocktools.py - utilities for manipulating blocks and transactions # # Distributed under the MIT/X11 software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. # from mininode import * from script import CScript, CScriptOp # Create a block (with regtest difficulty) def create_block(hashprev, coinbase, nTime=None): block = CBlock() if nTime is None: import time block.nTime = int(time.time()+600) else: block.nTime = nTime block.hashPrevBlock = hashprev block.nBits = 0x207fffff # Will break after a difficulty adjustment... block.vtx.append(coinbase) block.hashMerkleRoot = block.calc_merkle_root() block.calc_sha256() return block def serialize_script_num(value): r = bytearray(0) if value == 0: return r neg = value < 0 absvalue = -value if neg else value while (absvalue): r.append(chr(absvalue & 0xff)) absvalue >>= 8 if r[-1] & 0x80: r.append(0x80 if neg else 0) elif neg: r[-1] |= 0x80 return r counter=1 # Create an anyone-can-spend coinbase transaction, assuming no miner fees def create_coinbase(heightAdjust = 0): global counter coinbase = CTransaction() coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff), ser_string(serialize_script_num(counter+heightAdjust)), 0xffffffff)) counter += 1 coinbaseoutput = CTxOut() coinbaseoutput.nValue = 50*100000000 halvings = int((counter+heightAdjust)/150) # regtest coinbaseoutput.nValue >>= halvings coinbaseoutput.scriptPubKey = "" coinbase.vout = [ coinbaseoutput ] coinbase.calc_sha256() return coinbase # Create a transaction with an anyone-can-spend output, that spends the # nth output of prevtx. def create_transaction(prevtx, n, sig, value): tx = CTransaction() assert(n < len(prevtx.vout)) tx.vin.append(CTxIn(COutPoint(prevtx.sha256, n), sig, 0xffffffff)) tx.vout.append(CTxOut(value, "")) tx.calc_sha256() return tx
mit
[ 3, 1853, 2537, 14, 647, 446, 15841, 367, 13335, 20529, 5664, 436, 15809, 199, 3, 199, 3, 17484, 1334, 314, 10697, 15, 56, 845, 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, 3, 199, 199, 504, 1748, 15993, 492, 627, 199, 504, 2884, 492, 24682, 12, 24682, 4619, 199, 199, 3, 2790, 282, 1853, 334, 1045, 1295, 396, 23976, 17323, 9, 199, 318, 1218, 63, 1457, 8, 2227, 5701, 12, 21914, 1095, 12, 302, 1366, 29, 403, 304, 272, 1853, 275, 445, 3142, 342, 272, 340, 302, 1366, 365, 488, 26, 267, 492, 900, 267, 1853, 14, 78, 1366, 275, 1109, 8, 521, 14, 521, 24543, 6683, 9, 272, 587, 26, 267, 1853, 14, 78, 1366, 275, 302, 1366, 272, 1853, 14, 2227, 18873, 3142, 275, 2631, 5701, 272, 1853, 14, 78, 10787, 275, 378, 88, 10744, 4717, 70, 327, 12823, 2059, 2410, 282, 23976, 17323, 27999, 1396, 272, 1853, 14, 26784, 14, 740, 8, 30488, 9, 272, 1853, 14, 2227, 16797, 23572, 6405, 275, 1853, 14, 8104, 63, 2626, 23572, 63, 1231, 342, 272, 1853, 14, 8104, 63, 4835, 3912, 342, 272, 372, 1853, 199, 199, 318, 8437, 63, 1579, 63, 1507, 8, 585, 304, 272, 519, 275, 11640, 8, 16, 9, 272, 340, 574, 508, 378, 26, 267, 372, 519, 272, 14158, 275, 574, 665, 378, 272, 2853, 585, 275, 446, 585, 340, 14158, 587, 574, 272, 1830, 334, 2101, 585, 304, 267, 519, 14, 740, 8, 10194, 8, 2101, 585, 1253, 378, 3581, 430, 267, 2853, 585, 4331, 29, 1695, 272, 340, 519, 1988, 17, 61, 1253, 378, 88, 1257, 26, 267, 519, 14, 740, 8, 16, 88, 1257, 340, 14158, 587, 378, 9, 272, 916, 14158, 26, 267, 519, 1988, 17, 61, 8901, 378, 88, 1257, 272, 372, 519, 199, 199, 5337, 29, 17, 199, 3, 2790, 376, 29165, 13, 2425, 13, 31340, 21914, 1095, 6008, 12, 18002, 949, 1748, 281, 1964, 397, 199, 318, 1218, 63, 30488, 8, 3333, 17977, 275, 378, 304, 272, 2288, 7055, 272, 21914, 1095, 275, 445, 10161, 342, 272, 21914, 1095, 14, 11908, 14, 740, 8, 27831, 607, 8, 1439, 337, 3428, 8, 16, 12, 378, 21870, 395, 8892, 8926, 63, 875, 8, 3549, 63, 1579, 63, 1507, 8, 5337, 11, 3333, 17977, 1826, 378, 21870, 430, 272, 7055, 847, 413, 272, 21914, 1095, 1199, 275, 445, 8052, 2204, 342, 272, 21914, 1095, 1199, 14, 78, 1110, 275, 5238, 10, 17, 3607, 272, 22939, 86, 780, 275, 1109, 1332, 5337, 11, 3333, 17977, 2447, 8251, 9, 327, 1295, 396, 272, 21914, 1095, 1199, 14, 78, 1110, 4331, 29, 22939, 86, 780, 272, 21914, 1095, 1199, 14, 1579, 29632, 275, 3087, 272, 21914, 1095, 14, 17853, 275, 359, 21914, 1095, 1199, 1622, 272, 21914, 1095, 14, 8104, 63, 4835, 3912, 342, 272, 372, 21914, 1095, 199, 199, 3, 2790, 282, 6008, 543, 376, 29165, 13, 2425, 13, 31340, 1072, 12, 626, 2249, 3198, 314, 199, 3, 30564, 1072, 402, 5071, 2347, 14, 199, 318, 1218, 63, 5945, 8, 5701, 2347, 12, 302, 12, 5259, 12, 574, 304, 272, 4773, 275, 445, 10161, 342, 272, 702, 8, 78, 665, 822, 8, 5701, 2347, 14, 17853, 430, 272, 4773, 14, 11908, 14, 740, 8, 27831, 607, 8, 1439, 337, 3428, 8, 5701, 2347, 14, 4835, 3912, 12, 302, 395, 5259, 12, 378, 21870, 430, 272, 4773, 14, 17853, 14, 740, 8, 27831, 2204, 8, 585, 12, 25491, 272, 4773, 14, 8104, 63, 4835, 3912, 342, 272, 372, 4773, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1853, 2537, 14, 647, 446, 15841, 367, 13335, 20529, 5664, 436, 15809, 199, 3, 199, 3, 17484, 1334, 314, 10697, 15, 56, 845, 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, 3, 199, 199, 504, 1748, 15993, 492, 627, 199, 504, 2884, 492, 24682, 12, 24682, 4619, 199, 199, 3, 2790, 282, 1853, 334, 1045, 1295, 396, 23976, 17323, 9, 199, 318, 1218, 63, 1457, 8, 2227, 5701, 12, 21914, 1095, 12, 302, 1366, 29, 403, 304, 272, 1853, 275, 445, 3142, 342, 272, 340, 302, 1366, 365, 488, 26, 267, 492, 900, 267, 1853, 14, 78, 1366, 275, 1109, 8, 521, 14, 521, 24543, 6683, 9, 272, 587, 26, 267, 1853, 14, 78, 1366, 275, 302, 1366, 272, 1853, 14, 2227, 18873, 3142, 275, 2631, 5701, 272, 1853, 14, 78, 10787, 275, 378, 88, 10744, 4717, 70, 327, 12823, 2059, 2410, 282, 23976, 17323, 27999, 1396, 272, 1853, 14, 26784, 14, 740, 8, 30488, 9, 272, 1853, 14, 2227, 16797, 23572, 6405, 275, 1853, 14, 8104, 63, 2626, 23572, 63, 1231, 342, 272, 1853, 14, 8104, 63, 4835, 3912, 342, 272, 372, 1853, 199, 199, 318, 8437, 63, 1579, 63, 1507, 8, 585, 304, 272, 519, 275, 11640, 8, 16, 9, 272, 340, 574, 508, 378, 26, 267, 372, 519, 272, 14158, 275, 574, 665, 378, 272, 2853, 585, 275, 446, 585, 340, 14158, 587, 574, 272, 1830, 334, 2101, 585, 304, 267, 519, 14, 740, 8, 10194, 8, 2101, 585, 1253, 378, 3581, 430, 267, 2853, 585, 4331, 29, 1695, 272, 340, 519, 1988, 17, 61, 1253, 378, 88, 1257, 26, 267, 519, 14, 740, 8, 16, 88, 1257, 340, 14158, 587, 378, 9, 272, 916, 14158, 26, 267, 519, 1988, 17, 61, 8901, 378, 88, 1257, 272, 372, 519, 199, 199, 5337, 29, 17, 199, 3, 2790, 376, 29165, 13, 2425, 13, 31340, 21914, 1095, 6008, 12, 18002, 949, 1748, 281, 1964, 397, 199, 318, 1218, 63, 30488, 8, 3333, 17977, 275, 378, 304, 272, 2288, 7055, 272, 21914, 1095, 275, 445, 10161, 342, 272, 21914, 1095, 14, 11908, 14, 740, 8, 27831, 607, 8, 1439, 337, 3428, 8, 16, 12, 378, 21870, 395, 8892, 8926, 63, 875, 8, 3549, 63, 1579, 63, 1507, 8, 5337, 11, 3333, 17977, 1826, 378, 21870, 430, 272, 7055, 847, 413, 272, 21914, 1095, 1199, 275, 445, 8052, 2204, 342, 272, 21914, 1095, 1199, 14, 78, 1110, 275, 5238, 10, 17, 3607, 272, 22939, 86, 780, 275, 1109, 1332, 5337, 11, 3333, 17977, 2447, 8251, 9, 327, 1295, 396, 272, 21914, 1095, 1199, 14, 78, 1110, 4331, 29, 22939, 86, 780, 272, 21914, 1095, 1199, 14, 1579, 29632, 275, 3087, 272, 21914, 1095, 14, 17853, 275, 359, 21914, 1095, 1199, 1622, 272, 21914, 1095, 14, 8104, 63, 4835, 3912, 342, 272, 372, 21914, 1095, 199, 199, 3, 2790, 282, 6008, 543, 376, 29165, 13, 2425, 13, 31340, 1072, 12, 626, 2249, 3198, 314, 199, 3, 30564, 1072, 402, 5071, 2347, 14, 199, 318, 1218, 63, 5945, 8, 5701, 2347, 12, 302, 12, 5259, 12, 574, 304, 272, 4773, 275, 445, 10161, 342, 272, 702, 8, 78, 665, 822, 8, 5701, 2347, 14, 17853, 430, 272, 4773, 14, 11908, 14, 740, 8, 27831, 607, 8, 1439, 337, 3428, 8, 5701, 2347, 14, 4835, 3912, 12, 302, 395, 5259, 12, 378, 21870, 430, 272, 4773, 14, 17853, 14, 740, 8, 27831, 2204, 8, 585, 12, 25491, 272, 4773, 14, 8104, 63, 4835, 3912, 342, 272, 372, 4773, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
polaris-gslb/polaris-core
tests/test-polaris-pdns.py
2
1937
#!/usr/bin/env python3 import subprocess import sys import time import json POLARIS_PDNS_FILE = '/opt/polaris/bin/polaris-pdns' def pretty_json(s): d = json.loads(s) return json.dumps(d, indent=4, separators=(',', ': ')) class TestPolarisPDNS: def __init__(self, polaris_pdns_file): self.proc = subprocess.Popen([ polaris_pdns_file ], stdin=subprocess.PIPE, stdout=subprocess.PIPE) def execute_query(self, query): query += '\n' self.proc.stdin.write(query.encode()) self.proc.stdin.flush() output = self.proc.stdout.readline().decode() return pretty_json(output) def prepare_query(self, method, params): q = { 'method': method, 'parameters': { 'qtype': params['qtype'], 'qname': params['qname'], 'remote': params['remote'], 'local': params['local'], 'real-remote': params['real-remote'], 'zone-id': params['zone-id'] } } return json.dumps(q) if __name__ == '__main__': t = TestPolarisPDNS(POLARIS_PDNS_FILE) method = 'lookup' params = { 'qtype': 'A', 'qname': 'www.example.com', 'remote': '10.1.1.21', 'local': '0.0.0.0', 'real-remote': '10.1.1.21/32', 'zone-id': -1 } q = t.prepare_query(method, params) print("query: ", pretty_json(q), "\n") print("response: ", t.execute_query(q)) method = 'lookup' params = { 'qtype': 'SOA', 'qname': 'www.example.com', 'remote': '10.1.1.21', 'local': '0.0.0.0', 'real-remote': '10.1.1.21/32', 'zone-id': -1 } q = t.prepare_query(method, params) print("query: ", pretty_json(q), "\n") print("response: ", t.execute_query(q))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 646, 3873, 199, 646, 984, 199, 646, 900, 199, 646, 2022, 199, 199, 1512, 13174, 1311, 63, 11435, 2709, 63, 3817, 275, 1994, 2992, 15, 2515, 4663, 15, 1393, 15, 2515, 4663, 13, 80, 5797, 7, 199, 199, 318, 7268, 63, 1001, 8, 83, 304, 267, 366, 275, 2022, 14, 3640, 8, 83, 9, 267, 372, 2022, 14, 4180, 8, 68, 12, 4363, 29, 20, 12, 17658, 2687, 23324, 7596, 20005, 421, 199, 533, 1379, 5858, 4663, 11435, 2709, 26, 339, 347, 636, 826, 721, 277, 12, 3708, 4663, 63, 80, 5797, 63, 493, 304, 267, 291, 14, 4687, 275, 3873, 14, 7942, 779, 3708, 4663, 63, 80, 5797, 63, 493, 2156, 3660, 9009, 29, 5781, 14, 6089, 12, 3660, 3839, 29, 5781, 14, 6089, 9, 339, 347, 5341, 63, 1131, 8, 277, 12, 1827, 304, 267, 1827, 847, 1557, 78, 7, 267, 291, 14, 4687, 14, 6626, 14, 952, 8, 1131, 14, 2143, 1012, 267, 291, 14, 4687, 14, 6626, 14, 4939, 342, 398, 1072, 275, 291, 14, 4687, 14, 2703, 14, 6407, 1252, 2708, 342, 267, 372, 7268, 63, 1001, 8, 1199, 9, 339, 347, 9275, 63, 1131, 8, 277, 12, 1083, 12, 1862, 304, 267, 1894, 275, 469, 288, 283, 765, 356, 1083, 12, 288, 283, 3214, 356, 469, 355, 283, 81, 466, 356, 1862, 459, 81, 466, 995, 355, 283, 12333, 356, 1862, 459, 12333, 995, 355, 283, 3846, 356, 1862, 459, 3846, 995, 355, 283, 1832, 356, 1862, 459, 1832, 995, 355, 283, 3093, 13, 3846, 356, 1862, 459, 3093, 13, 3846, 995, 355, 283, 2619, 13, 344, 356, 1862, 459, 2619, 13, 344, 418, 288, 789, 267, 789, 398, 372, 2022, 14, 4180, 8, 81, 9, 10813, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 307, 275, 1379, 5858, 4663, 11435, 2709, 8, 1512, 13174, 1311, 63, 11435, 2709, 63, 3817, 9, 339, 1083, 275, 283, 3892, 7, 272, 1862, 275, 469, 267, 283, 81, 466, 356, 283, 33, 297, 267, 283, 12333, 356, 283, 1544, 14, 2694, 14, 957, 297, 267, 283, 3846, 356, 283, 709, 14, 17, 14, 17, 14, 2025, 297, 267, 283, 1832, 356, 283, 16, 14, 16, 14, 16, 14, 16, 297, 267, 283, 3093, 13, 3846, 356, 283, 709, 14, 17, 14, 17, 14, 2025, 15, 708, 297, 267, 283, 2619, 13, 344, 356, 446, 17, 272, 789, 272, 1894, 275, 307, 14, 6726, 63, 1131, 8, 765, 12, 1862, 9, 272, 870, 480, 1131, 26, 3872, 7268, 63, 1001, 8, 81, 395, 1867, 78, 531, 272, 870, 480, 1310, 26, 3872, 307, 14, 2526, 63, 1131, 8, 81, 430, 339, 1083, 275, 283, 3892, 7, 272, 1862, 275, 469, 267, 283, 81, 466, 356, 283, 4118, 33, 297, 267, 283, 12333, 356, 283, 1544, 14, 2694, 14, 957, 297, 267, 283, 3846, 356, 283, 709, 14, 17, 14, 17, 14, 2025, 297, 267, 283, 1832, 356, 283, 16, 14, 16, 14, 16, 14, 16, 297, 267, 283, 3093, 13, 3846, 356, 283, 709, 14, 17, 14, 17, 14, 2025, 15, 708, 297, 267, 283, 2619, 13, 344, 356, 446, 17, 272, 789, 272, 1894, 275, 307, 14, 6726, 63, 1131, 8, 765, 12, 1862, 9, 272, 870, 480, 1131, 26, 3872, 7268, 63, 1001, 8, 81, 395, 1867, 78, 531, 272, 870, 480, 1310, 26, 3872, 307, 14, 2526, 63, 1131, 8, 81, 430, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 646, 3873, 199, 646, 984, 199, 646, 900, 199, 646, 2022, 199, 199, 1512, 13174, 1311, 63, 11435, 2709, 63, 3817, 275, 1994, 2992, 15, 2515, 4663, 15, 1393, 15, 2515, 4663, 13, 80, 5797, 7, 199, 199, 318, 7268, 63, 1001, 8, 83, 304, 267, 366, 275, 2022, 14, 3640, 8, 83, 9, 267, 372, 2022, 14, 4180, 8, 68, 12, 4363, 29, 20, 12, 17658, 2687, 23324, 7596, 20005, 421, 199, 533, 1379, 5858, 4663, 11435, 2709, 26, 339, 347, 636, 826, 721, 277, 12, 3708, 4663, 63, 80, 5797, 63, 493, 304, 267, 291, 14, 4687, 275, 3873, 14, 7942, 779, 3708, 4663, 63, 80, 5797, 63, 493, 2156, 3660, 9009, 29, 5781, 14, 6089, 12, 3660, 3839, 29, 5781, 14, 6089, 9, 339, 347, 5341, 63, 1131, 8, 277, 12, 1827, 304, 267, 1827, 847, 1557, 78, 7, 267, 291, 14, 4687, 14, 6626, 14, 952, 8, 1131, 14, 2143, 1012, 267, 291, 14, 4687, 14, 6626, 14, 4939, 342, 398, 1072, 275, 291, 14, 4687, 14, 2703, 14, 6407, 1252, 2708, 342, 267, 372, 7268, 63, 1001, 8, 1199, 9, 339, 347, 9275, 63, 1131, 8, 277, 12, 1083, 12, 1862, 304, 267, 1894, 275, 469, 288, 283, 765, 356, 1083, 12, 288, 283, 3214, 356, 469, 355, 283, 81, 466, 356, 1862, 459, 81, 466, 995, 355, 283, 12333, 356, 1862, 459, 12333, 995, 355, 283, 3846, 356, 1862, 459, 3846, 995, 355, 283, 1832, 356, 1862, 459, 1832, 995, 355, 283, 3093, 13, 3846, 356, 1862, 459, 3093, 13, 3846, 995, 355, 283, 2619, 13, 344, 356, 1862, 459, 2619, 13, 344, 418, 288, 789, 267, 789, 398, 372, 2022, 14, 4180, 8, 81, 9, 10813, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 307, 275, 1379, 5858, 4663, 11435, 2709, 8, 1512, 13174, 1311, 63, 11435, 2709, 63, 3817, 9, 339, 1083, 275, 283, 3892, 7, 272, 1862, 275, 469, 267, 283, 81, 466, 356, 283, 33, 297, 267, 283, 12333, 356, 283, 1544, 14, 2694, 14, 957, 297, 267, 283, 3846, 356, 283, 709, 14, 17, 14, 17, 14, 2025, 297, 267, 283, 1832, 356, 283, 16, 14, 16, 14, 16, 14, 16, 297, 267, 283, 3093, 13, 3846, 356, 283, 709, 14, 17, 14, 17, 14, 2025, 15, 708, 297, 267, 283, 2619, 13, 344, 356, 446, 17, 272, 789, 272, 1894, 275, 307, 14, 6726, 63, 1131, 8, 765, 12, 1862, 9, 272, 870, 480, 1131, 26, 3872, 7268, 63, 1001, 8, 81, 395, 1867, 78, 531, 272, 870, 480, 1310, 26, 3872, 307, 14, 2526, 63, 1131, 8, 81, 430, 339, 1083, 275, 283, 3892, 7, 272, 1862, 275, 469, 267, 283, 81, 466, 356, 283, 4118, 33, 297, 267, 283, 12333, 356, 283, 1544, 14, 2694, 14, 957, 297, 267, 283, 3846, 356, 283, 709, 14, 17, 14, 17, 14, 2025, 297, 267, 283, 1832, 356, 283, 16, 14, 16, 14, 16, 14, 16, 297, 267, 283, 3093, 13, 3846, 356, 283, 709, 14, 17, 14, 17, 14, 2025, 15, 708, 297, 267, 283, 2619, 13, 344, 356, 446, 17, 272, 789, 272, 1894, 275, 307, 14, 6726, 63, 1131, 8, 765, 12, 1862, 9, 272, 870, 480, 1131, 26, 3872, 7268, 63, 1001, 8, 81, 395, 1867, 78, 531, 272, 870, 480, 1310, 26, 3872, 307, 14, 2526, 63, 1131, 8, 81, 430, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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ix.py
1
6357
# -*- coding: utf-8 -*- """ Created on Mon Oct 31 15:45:22 2016 @author: wang """ #from matplotlib import pylab as plt #from numpy import fft, fromstring, int16, linspace #import wave from read_wav_xml_good_1 import* from matrix_24_2 import* from max_matrix_norm import* import numpy as np # open a wave file filename = 'francois_filon_pure_3.wav' filename_1 ='francois_filon_pure_3.xml' word ='je' wave_signal_float,framerate, word_start_point, word_length_point, word_end_point= read_wav_xml_good_1(filename,filename_1,word) #print 'word_start_point=',word_start_point #print 'word_length_point=',word_length_point #print 'word_end_point=',word_end_point XJ_1 =wave_signal_float t_step=1920; t_entre_step=1440; t_du_1_1 = int(word_start_point[0]); t_du_1_2 = int(word_end_point[0]); t_du_2_1 = int(word_start_point[1]); t_du_2_2 = int(word_end_point[1]); t_du_3_1 = int(word_start_point[2]); t_du_3_2 = int(word_end_point[2]); t_du_4_1 = int(word_start_point[3]); t_du_4_2 = int(word_end_point[3]); t_du_5_1 = int(word_start_point[4]); t_du_5_2 = int(word_end_point[4]); fs=framerate #XJ_du_1 = wave_signal_float[(t_du_1_1-1):t_du_1_2]; #length_XJ_du_1 = int(word_length_point[0]+1); #x1,y1,z1=matrix_24_2(XJ_du_1,fs) #x1=max_matrix_norm(x1) #============================================================================== # this part is to calcul the first matrix #============================================================================== XJ_du_1_2 = XJ_1[(t_du_1_1-1):(t_du_1_1+t_step)]; x1_1,y1_1,z1_1=matrix_24_2(XJ_du_1_2 ,fs) x1_1=max_matrix_norm(x1_1) matrix_all_step_new_1 = np.zeros([192]) for i in range(0,24): matrix_all_step_new_1[i]=x1_1[i] #============================================================================== # the other colonne is the all fft #============================================================================== for i in range(1,8): XJ_du_1_total = XJ_1[(t_du_1_1+t_entre_step*(i)-1):(t_du_1_1+t_step+t_entre_step*(i) )]; x1_all,y1_all,z1_all=matrix_24_2(XJ_du_1_total,fs) x1_all=max_matrix_norm(x1_all) for j in range(0,24): matrix_all_step_new_1[24*i+j]=x1_all[j] #============================================================================== # this part is to calcul the second matrix #============================================================================== for k in range (1,2): t_start=t_du_2_1 XJ_du_1_2 = XJ_1[(t_start-1):(t_start+t_step)]; x1_1,y1_1,z1_1=matrix_24_2(XJ_du_1_2 ,fs) x1_1=max_matrix_norm(x1_1) matrix_all_step_new_2 = np.zeros([192]) for i in range(0,24): matrix_all_step_new_2[i]=x1_1[i] #============================================================================== # the other colonne is the all fft #============================================================================== for i in range(1,8): XJ_du_1_total = XJ_1[(t_start+t_entre_step*(i)-1):(t_start+t_step+t_entre_step*(i) )]; x1_all,y1_all,z1_all=matrix_24_2(XJ_du_1_total,fs) x1_all=max_matrix_norm(x1_all) for j in range(0,24): matrix_all_step_new_2[24*i+j]=x1_all[j] #============================================================================== # this part is to calcul the 3 matrix #============================================================================== for k in range (1,2): t_start=t_du_3_1 XJ_du_1_2 = XJ_1[(t_start-1):(t_start+t_step)]; x1_1,y1_1,z1_1=matrix_24_2(XJ_du_1_2 ,fs) x1_1=max_matrix_norm(x1_1) matrix_all_step_new_3 = np.zeros([192]) for i in range(0,24): matrix_all_step_new_3[i]=x1_1[i] #============================================================================== # the other colonne is the all fft #============================================================================== for i in range(1,8): XJ_du_1_total = XJ_1[(t_start+t_entre_step*(i)-1):(t_start+t_step+t_entre_step*(i) )]; x1_all,y1_all,z1_all=matrix_24_2(XJ_du_1_total,fs) x1_all=max_matrix_norm(x1_all) for j in range(0,24): matrix_all_step_new_3[24*i+j]=x1_all[j] #============================================================================== # this part is to calcul the 4 matrix #============================================================================== for k in range (1,2): t_start=t_du_4_1 XJ_du_1_2 = XJ_1[(t_start-1):(t_start+t_step)]; x1_1,y1_1,z1_1=matrix_24_2(XJ_du_1_2 ,fs) x1_1=max_matrix_norm(x1_1) matrix_all_step_new_4 = np.zeros([192]) for i in range(0,24): matrix_all_step_new_4[i]=x1_1[i] #============================================================================== # the other colonne is the all fft #============================================================================== for i in range(1,8): # print i XJ_du_1_total = XJ_1[(t_start+t_entre_step*(i)-1):(t_start+t_step+t_entre_step*(i) )]; x1_all,y1_all,z1_all=matrix_24_2(XJ_du_1_total,fs) x1_all=max_matrix_norm(x1_all) for j in range(0,24): matrix_all_step_new_4[24*i+j]=x1_all[j] #print 'matrix_all_step_4=',matrix_all_step_4 #============================================================================== # this part is to calcul the 5 matrix #============================================================================== for k in range (1,2): t_start=t_du_5_1 XJ_du_1_2 = XJ_1[(t_start-1):(t_start+t_step)]; x1_1,y1_1,z1_1=matrix_24_2(XJ_du_1_2 ,fs) x1_1=max_matrix_norm(x1_1) matrix_all_step_new_5 = np.zeros([192]) for i in range(0,24): matrix_all_step_new_5[i]=x1_1[i] #============================================================================== # the other colonne is the all fft #============================================================================== for i in range(1,8): # print i XJ_du_1_total = XJ_1[(t_start+t_entre_step*(i)-1):(t_start+t_step+t_entre_step*(i) )]; x1_all,y1_all,z1_all=matrix_24_2(XJ_du_1_total,fs) x1_all=max_matrix_norm(x1_all) for j in range(0,24): matrix_all_step_new_5[24*i+j]=x1_all[j] #print 'matrix_all_step_5=',matrix_all_step_5 np.savez('je_compare_192_matrix.npz',matrix_all_step_new_1,matrix_all_step_new_2,matrix_all_step_new_3,matrix_all_step_new_4,matrix_all_step_new_5)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10502, 641, 10953, 18365, 7105, 4114, 26, 2322, 26, 1081, 7800, 199, 199, 32, 2502, 26, 336, 621, 199, 624, 199, 3, 504, 8027, 492, 19199, 465, 4488, 199, 3, 504, 2680, 492, 18160, 12, 687, 875, 12, 1109, 975, 12, 7403, 2638, 199, 3, 646, 12204, 199, 199, 504, 1586, 63, 19118, 63, 1652, 63, 8302, 63, 17, 492, 10, 199, 504, 3634, 63, 1194, 63, 18, 492, 10, 199, 504, 1390, 63, 3642, 63, 4791, 492, 10, 199, 199, 646, 2680, 465, 980, 199, 3, 1551, 282, 12204, 570, 199, 1501, 275, 283, 70, 1312, 331, 374, 63, 1289, 265, 63, 5115, 63, 19, 14, 19118, 7, 199, 1501, 63, 17, 275, 7, 70, 1312, 331, 374, 63, 1289, 265, 63, 5115, 63, 19, 14, 1652, 7, 199, 1027, 275, 7, 6532, 7, 199, 199, 10024, 63, 4653, 63, 1609, 12, 1943, 1866, 12, 4349, 63, 928, 63, 1403, 12, 4349, 63, 1267, 63, 1403, 12, 4349, 63, 500, 63, 1403, 29, 1586, 63, 19118, 63, 1652, 63, 8302, 63, 17, 8, 1501, 12, 1501, 63, 17, 12, 1027, 9, 199, 3, 1361, 283, 1027, 63, 928, 63, 1403, 4009, 1027, 63, 928, 63, 1403, 199, 3, 1361, 283, 1027, 63, 1267, 63, 1403, 4009, 1027, 63, 1267, 63, 1403, 199, 3, 1361, 283, 1027, 63, 500, 63, 1403, 4009, 1027, 63, 500, 63, 1403, 199, 199, 56, 42, 63, 17, 275, 10024, 63, 4653, 63, 1609, 199, 199, 84, 63, 2926, 29, 1167, 1165, 27, 199, 84, 63, 484, 264, 63, 2926, 29, 1079, 2167, 27, 199, 199, 84, 63, 2033, 63, 17, 63, 17, 275, 1109, 8, 1027, 63, 928, 63, 1403, 59, 16, 21153, 199, 84, 63, 2033, 63, 17, 63, 18, 275, 1109, 8, 1027, 63, 500, 63, 1403, 59, 16, 21153, 199, 199, 84, 63, 2033, 63, 18, 63, 17, 275, 1109, 8, 1027, 63, 928, 63, 1403, 59, 17, 21153, 199, 84, 63, 2033, 63, 18, 63, 18, 275, 1109, 8, 1027, 63, 500, 63, 1403, 59, 17, 21153, 199, 199, 84, 63, 2033, 63, 19, 63, 17, 275, 1109, 8, 1027, 63, 928, 63, 1403, 59, 18, 21153, 199, 84, 63, 2033, 63, 19, 63, 18, 275, 1109, 8, 1027, 63, 500, 63, 1403, 59, 18, 21153, 199, 199, 84, 63, 2033, 63, 20, 63, 17, 275, 1109, 8, 1027, 63, 928, 63, 1403, 59, 19, 21153, 199, 84, 63, 2033, 63, 20, 63, 18, 275, 1109, 8, 1027, 63, 500, 63, 1403, 59, 19, 21153, 199, 199, 84, 63, 2033, 63, 21, 63, 17, 275, 1109, 8, 1027, 63, 928, 63, 1403, 59, 20, 21153, 199, 84, 63, 2033, 63, 21, 63, 18, 275, 1109, 8, 1027, 63, 500, 63, 1403, 59, 20, 21153, 199, 2319, 29, 1943, 1866, 199, 3, 56, 42, 63, 2033, 63, 17, 275, 12204, 63, 4653, 63, 1609, 7528, 84, 63, 2033, 63, 17, 63, 17, 13, 17, 304, 84, 63, 2033, 63, 17, 63, 18, 11566, 199, 3, 1267, 63, 56, 42, 63, 2033, 63, 17, 275, 1109, 8, 1027, 63, 1267, 63, 1403, 59, 16, 2807, 17, 2736, 199, 3, 88, 17, 12, 89, 17, 12, 90, 17, 29, 3642, 63, 1194, 63, 18, 8, 56, 42, 63, 2033, 63, 17, 12, 2319, 9, 199, 3, 88, 17, 29, 988, 63, 3642, 63, 4791, 8, 88, 17, 9, 421, 199, 31436, 199, 3, 642, 1777, 365, 370, 6966, 314, 1642, 3634, 221, 199, 31436, 199, 56, 42, 63, 2033, 63, 17, 63, 18, 275, 1323, 42, 63, 17, 7528, 84, 63, 2033, 63, 17, 63, 17, 13, 17, 304, 8, 84, 63, 2033, 63, 17, 63, 17, 11, 84, 63, 2926, 1874, 27, 199, 88, 17, 63, 17, 12, 89, 17, 63, 17, 12, 90, 17, 63, 17, 29, 3642, 63, 1194, 63, 18, 8, 56, 42, 63, 2033, 63, 17, 63, 18, 2360, 2319, 9, 199, 88, 17, 63, 17, 29, 988, 63, 3642, 63, 4791, 8, 88, 17, 63, 17, 9, 199, 3642, 63, 452, 63, 2926, 63, 1222, 63, 17, 275, 980, 14, 4250, 779, 5756, 566, 199, 199, 509, 284, 315, 1425, 8, 16, 12, 1194, 304, 272, 3634, 63, 452, 63, 2926, 63, 1222, 63, 17, 59, 73, 10404, 88, 17, 63, 17, 59, 73, 61, 199, 31436, 199, 3, 314, 1163, 18307, 685, 365, 314, 1006, 18160, 199, 31436, 199, 509, 284, 315, 1425, 8, 17, 12, 24, 304, 272, 1323, 42, 63, 2033, 63, 17, 63, 2923, 275, 1323, 42, 63, 17, 7528, 84, 63, 2033, 63, 17, 63, 17, 11, 84, 63, 484, 264, 63, 2926, 5830, 73, 7216, 17, 304, 8, 84, 63, 2033, 63, 17, 63, 17, 11, 84, 63, 2926, 11, 84, 63, 484, 264, 63, 2926, 5830, 73, 9, 776, 11566, 272, 671, 17, 63, 452, 12, 89, 17, 63, 452, 12, 90, 17, 63, 452, 29, 3642, 63, 1194, 63, 18, 8, 56, 42, 63, 2033, 63, 17, 63, 2923, 12, 2319, 9, 272, 671, 17, 63, 452, 29, 988, 63, 3642, 63, 4791, 8, 88, 17, 63, 452, 9, 272, 367, 1335, 315, 1425, 8, 16, 12, 1194, 304, 267, 3634, 63, 452, 63, 2926, 63, 1222, 63, 17, 59, 1194, 10, 73, 11, 74, 10404, 88, 17, 63, 452, 59, 74, 61, 199, 199, 31436, 199, 3, 642, 1777, 365, 370, 6966, 314, 3499, 3634, 199, 31436, 199, 509, 1022, 315, 1425, 334, 17, 12, 18, 304, 272, 307, 63, 928, 29, 84, 63, 2033, 63, 18, 63, 17, 272, 1323, 42, 63, 2033, 63, 17, 63, 18, 275, 1323, 42, 63, 17, 7528, 84, 63, 928, 13, 17, 304, 8, 84, 63, 928, 11, 84, 63, 2926, 1874, 27, 272, 671, 17, 63, 17, 12, 89, 17, 63, 17, 12, 90, 17, 63, 17, 29, 3642, 63, 1194, 63, 18, 8, 56, 42, 63, 2033, 63, 17, 63, 18, 2360, 2319, 9, 272, 671, 17, 63, 17, 29, 988, 63, 3642, 63, 4791, 8, 88, 17, 63, 17, 9, 272, 3634, 63, 452, 63, 2926, 63, 1222, 63, 18, 275, 980, 14, 4250, 779, 5756, 566, 272, 367, 284, 315 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10502, 641, 10953, 18365, 7105, 4114, 26, 2322, 26, 1081, 7800, 199, 199, 32, 2502, 26, 336, 621, 199, 624, 199, 3, 504, 8027, 492, 19199, 465, 4488, 199, 3, 504, 2680, 492, 18160, 12, 687, 875, 12, 1109, 975, 12, 7403, 2638, 199, 3, 646, 12204, 199, 199, 504, 1586, 63, 19118, 63, 1652, 63, 8302, 63, 17, 492, 10, 199, 504, 3634, 63, 1194, 63, 18, 492, 10, 199, 504, 1390, 63, 3642, 63, 4791, 492, 10, 199, 199, 646, 2680, 465, 980, 199, 3, 1551, 282, 12204, 570, 199, 1501, 275, 283, 70, 1312, 331, 374, 63, 1289, 265, 63, 5115, 63, 19, 14, 19118, 7, 199, 1501, 63, 17, 275, 7, 70, 1312, 331, 374, 63, 1289, 265, 63, 5115, 63, 19, 14, 1652, 7, 199, 1027, 275, 7, 6532, 7, 199, 199, 10024, 63, 4653, 63, 1609, 12, 1943, 1866, 12, 4349, 63, 928, 63, 1403, 12, 4349, 63, 1267, 63, 1403, 12, 4349, 63, 500, 63, 1403, 29, 1586, 63, 19118, 63, 1652, 63, 8302, 63, 17, 8, 1501, 12, 1501, 63, 17, 12, 1027, 9, 199, 3, 1361, 283, 1027, 63, 928, 63, 1403, 4009, 1027, 63, 928, 63, 1403, 199, 3, 1361, 283, 1027, 63, 1267, 63, 1403, 4009, 1027, 63, 1267, 63, 1403, 199, 3, 1361, 283, 1027, 63, 500, 63, 1403, 4009, 1027, 63, 500, 63, 1403, 199, 199, 56, 42, 63, 17, 275, 10024, 63, 4653, 63, 1609, 199, 199, 84, 63, 2926, 29, 1167, 1165, 27, 199, 84, 63, 484, 264, 63, 2926, 29, 1079, 2167, 27, 199, 199, 84, 63, 2033, 63, 17, 63, 17, 275, 1109, 8, 1027, 63, 928, 63, 1403, 59, 16, 21153, 199, 84, 63, 2033, 63, 17, 63, 18, 275, 1109, 8, 1027, 63, 500, 63, 1403, 59, 16, 21153, 199, 199, 84, 63, 2033, 63, 18, 63, 17, 275, 1109, 8, 1027, 63, 928, 63, 1403, 59, 17, 21153, 199, 84, 63, 2033, 63, 18, 63, 18, 275, 1109, 8, 1027, 63, 500, 63, 1403, 59, 17, 21153, 199, 199, 84, 63, 2033, 63, 19, 63, 17, 275, 1109, 8, 1027, 63, 928, 63, 1403, 59, 18, 21153, 199, 84, 63, 2033, 63, 19, 63, 18, 275, 1109, 8, 1027, 63, 500, 63, 1403, 59, 18, 21153, 199, 199, 84, 63, 2033, 63, 20, 63, 17, 275, 1109, 8, 1027, 63, 928, 63, 1403, 59, 19, 21153, 199, 84, 63, 2033, 63, 20, 63, 18, 275, 1109, 8, 1027, 63, 500, 63, 1403, 59, 19, 21153, 199, 199, 84, 63, 2033, 63, 21, 63, 17, 275, 1109, 8, 1027, 63, 928, 63, 1403, 59, 20, 21153, 199, 84, 63, 2033, 63, 21, 63, 18, 275, 1109, 8, 1027, 63, 500, 63, 1403, 59, 20, 21153, 199, 2319, 29, 1943, 1866, 199, 3, 56, 42, 63, 2033, 63, 17, 275, 12204, 63, 4653, 63, 1609, 7528, 84, 63, 2033, 63, 17, 63, 17, 13, 17, 304, 84, 63, 2033, 63, 17, 63, 18, 11566, 199, 3, 1267, 63, 56, 42, 63, 2033, 63, 17, 275, 1109, 8, 1027, 63, 1267, 63, 1403, 59, 16, 2807, 17, 2736, 199, 3, 88, 17, 12, 89, 17, 12, 90, 17, 29, 3642, 63, 1194, 63, 18, 8, 56, 42, 63, 2033, 63, 17, 12, 2319, 9, 199, 3, 88, 17, 29, 988, 63, 3642, 63, 4791, 8, 88, 17, 9, 421, 199, 31436, 199, 3, 642, 1777, 365, 370, 6966, 314, 1642, 3634, 221, 199, 31436, 199, 56, 42, 63, 2033, 63, 17, 63, 18, 275, 1323, 42, 63, 17, 7528, 84, 63, 2033, 63, 17, 63, 17, 13, 17, 304, 8, 84, 63, 2033, 63, 17, 63, 17, 11, 84, 63, 2926, 1874, 27, 199, 88, 17, 63, 17, 12, 89, 17, 63, 17, 12, 90, 17, 63, 17, 29, 3642, 63, 1194, 63, 18, 8, 56, 42, 63, 2033, 63, 17, 63, 18, 2360, 2319, 9, 199, 88, 17, 63, 17, 29, 988, 63, 3642, 63, 4791, 8, 88, 17, 63, 17, 9, 199, 3642, 63, 452, 63, 2926, 63, 1222, 63, 17, 275, 980, 14, 4250, 779, 5756, 566, 199, 199, 509, 284, 315, 1425, 8, 16, 12, 1194, 304, 272, 3634, 63, 452, 63, 2926, 63, 1222, 63, 17, 59, 73, 10404, 88, 17, 63, 17, 59, 73, 61, 199, 31436, 199, 3, 314, 1163, 18307, 685, 365, 314, 1006, 18160, 199, 31436, 199, 509, 284, 315, 1425, 8, 17, 12, 24, 304, 272, 1323, 42, 63, 2033, 63, 17, 63, 2923, 275, 1323, 42, 63, 17, 7528, 84, 63, 2033, 63, 17, 63, 17, 11, 84, 63, 484, 264, 63, 2926, 5830, 73, 7216, 17, 304, 8, 84, 63, 2033, 63, 17, 63, 17, 11, 84, 63, 2926, 11, 84, 63, 484, 264, 63, 2926, 5830, 73, 9, 776, 11566, 272, 671, 17, 63, 452, 12, 89, 17, 63, 452, 12, 90, 17, 63, 452, 29, 3642, 63, 1194, 63, 18, 8, 56, 42, 63, 2033, 63, 17, 63, 2923, 12, 2319, 9, 272, 671, 17, 63, 452, 29, 988, 63, 3642, 63, 4791, 8, 88, 17, 63, 452, 9, 272, 367, 1335, 315, 1425, 8, 16, 12, 1194, 304, 267, 3634, 63, 452, 63, 2926, 63, 1222, 63, 17, 59, 1194, 10, 73, 11, 74, 10404, 88, 17, 63, 452, 59, 74, 61, 199, 199, 31436, 199, 3, 642, 1777, 365, 370, 6966, 314, 3499, 3634, 199, 31436, 199, 509, 1022, 315, 1425, 334, 17, 12, 18, 304, 272, 307, 63, 928, 29, 84, 63, 2033, 63, 18, 63, 17, 272, 1323, 42, 63, 2033, 63, 17, 63, 18, 275, 1323, 42, 63, 17, 7528, 84, 63, 928, 13, 17, 304, 8, 84, 63, 928, 11, 84, 63, 2926, 1874, 27, 272, 671, 17, 63, 17, 12, 89, 17, 63, 17, 12, 90, 17, 63, 17, 29, 3642, 63, 1194, 63, 18, 8, 56, 42, 63, 2033, 63, 17, 63, 18, 2360, 2319, 9, 272, 671, 17, 63, 17, 29, 988, 63, 3642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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 ]
wholland/env
env.py
1
6119
#!/usr/bin/python import argparse import json import shutil import os def copy_file(src, dest, backup): success = True if not backup is None: (backup_folder, backup_file) = os.path.split(backup) print("Creating backup file for " + dest + " at " + backup) try: if not os.path.exists(backup_folder): os.makedirs(backup_folder) shutil.copyfile(dest, backup) except Exception as e: print("Backup failed: " + str(e)) success = False if success: (dest_folder, dest_file) = os.path.split(dest) print("Copy file " + src + " to " + dest) try: if not os.path.exists(dest_folder): os.makedirs(dest_folder) shutil.copyfile(src, dest) except IOError as e: print("Copy failed: " + str(e)) def copy_dir(src, dest, backup): success = True if not backup is None: try: print("Creating backup file for " + dest + " at " + backup) rmtree(backup, ignore_errors=True) shutil.copytree(dest, backup) except IOError as e: print("Backup failed: " + str(e)) success = False if success: try: print("Copy directory " + src + " to " + dest) shutil.copytree(src, dest) except IOError as e: print("Copy failed: " + str(e)) def push(args): defs = json.load(open(os.path.expanduser(args.file))) for definition in defs: if definition["group"] in args.categories: print("Pushing " + definition["name"]); src = os.path.expanduser(os.path.join(args.source, definition["source"])) dest = os.path.expanduser(os.path.join(args.target, definition["target"])) backup = os.path.expanduser(os.path.join(args.backup, definition["target"])) if definition["type"].lower() == "f": # Copy a file if args.unsafe: if not args.wimp: copy_file(src, dest, None) else: print("Would copy file. Src:" + src + " Dest:" + dest); else: if not args.wimp: copy_file(src, dest, backup) else: print("Would copy file. Src:" + src + " Dest:" + dest + " Backup:" + backup); elif definition["type"].lower() == "d": # Copy a directory if args.verbose: print(definition["name"] + ": Pushing directory from " + src + " to " + dest) if args.unsafe: if not args.wimp: copy_dir(src, dest, None) else: print("Would copy file. Src:" + src + " Dest:" + dest); else: if not args.wimp: copy_dir(src, dest, backup) else: print("Would copy dir. Src:" + src + " Dest:" + dest + " Backup:" + backup); else: print(definition["name"] + ": Unknown type \""+definition["type"]+"\"") def pull(args): defs = json.load(open(os.path.expanduser(args.file))) for definition in defs: if definition["group"] in args.categories: print("Pulling " + definition["name"]); src = os.path.expanduser(os.path.join(args.target, definition["target"])) dest = os.path.expanduser(os.path.join(args.source, definition["source"])) if definition["type"].lower() == "f": # Copy a file if not args.wimp: copy_file(src, dest, None) else: print("Would copy file. Src:" + src + " Dest:" + dest); elif definition["type"].lower() == "d": # Copy a directory if not args.wimp: copy_dir(src, dest, None) else: print("Would copy directory. Src:" + src + " Dest:" + dest); else: print(definition["name"] + ": Unknown type \""+definition["type"]+"\"") def revert(args): defs = json.load(open(os.path.expanduser(args.file))) for definition in defs: if definition["group"] in args.categories: src = os.path.expanduser(os.path.join(args.backup, definition["target"])) dest = os.path.expanduser(os.path.join(args.target, definition["target"])) if definition["type"].lower() == "f": # Copy a file if not args.wimp: copy_file(src, dest, None) else: print("Would copy file. Src:" + src + " Dest:" + dest); elif definition["type"].lower() == "d": # Copy a directory if not args.wimp: copy_dir(src, dest, None) else: print("Would copy directory. Src:" + src + " Dest:" + dest); else: print(definition["name"] + ": Unknown type \""+definition["type"]+"\"") def main(): default_defs = "~/env/env.def" default_source = "~/env/" default_target = "~/" default_backup = "~/.backup/env/" parser = argparse.ArgumentParser() parser.add_argument("-v", "--verbose", action="store_true", help="Increase Verbosity") parser.add_argument("-f", "--file", default=default_defs, help="Definition File to use") parser.add_argument("-s", "--source", default=default_source, help="Override source root") parser.add_argument("-t", "--target", default=default_target, help="Override target root") parser.add_argument("-w", "--wimp", action="store_true", help="Don't actually make any changes (implies -v)") subparsers = parser.add_subparsers() parser_push = subparsers.add_parser("push", help="Push configs into environment") parser_push.add_argument("-u", "--unsafe", action="store_true", help="No backups Created") parser_push.add_argument("-a", "--All", action="store_true", help="Cleanup Backups") parser_push.add_argument("-b", "--backup", default=default_backup, help="Override backup root") parser_push.add_argument("categories", nargs=argparse.REMAINDER) parser_push.set_defaults(func=push) parser_pull = subparsers.add_parser("pull", help="Pull configs from environment") parser_pull.add_argument("-a", "--All", action="store_true", help="Cleanup Backups") parser_pull.add_argument("categories", nargs=argparse.REMAINDER) parser_pull.set_defaults(func=pull) parser_revert = subparsers.add_parser("revert", help="Revert configs from backups") parser_revert.add_argument("-c", "--cleanup", action="store_true", help="Cleanup Backups") parser_revert.add_argument("-a", "--All", action="store_true", help="Cleanup Backups") parser_revert.add_argument("-b", "--backup", default=default_backup, help="Override backup root") parser_revert.add_argument("categories", nargs=argparse.REMAINDER) parser_revert.set_defaults(func=revert) args = parser.parse_args() if args.wimp: args.verbose = True args.func(args) if __name__ == "__main__": main();
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 646, 7534, 199, 646, 2022, 199, 646, 5145, 199, 646, 747, 199, 199, 318, 1331, 63, 493, 8, 2164, 12, 2053, 12, 6902, 304, 199, 198, 3742, 275, 715, 199, 198, 692, 440, 6902, 365, 488, 26, 507, 198, 8, 5751, 63, 3741, 12, 6902, 63, 493, 9, 275, 747, 14, 515, 14, 1294, 8, 5751, 9, 507, 198, 1361, 480, 14380, 6902, 570, 367, 298, 435, 2053, 435, 298, 737, 298, 435, 6902, 9, 507, 198, 893, 26, 686, 198, 692, 440, 747, 14, 515, 14, 2444, 8, 5751, 63, 3741, 304, 1585, 198, 736, 14, 8347, 8, 5751, 63, 3741, 9, 686, 198, 20938, 14, 21997, 8, 2614, 12, 6902, 9, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 1361, 480, 16559, 3405, 26, 298, 435, 620, 8, 69, 430, 686, 198, 3742, 275, 756, 1585, 199, 198, 692, 3182, 26, 507, 198, 8, 2614, 63, 3741, 12, 2053, 63, 493, 9, 275, 747, 14, 515, 14, 1294, 8, 2614, 9, 507, 198, 1361, 480, 5116, 570, 298, 435, 2928, 435, 298, 370, 298, 435, 2053, 9, 507, 198, 893, 26, 198, 686, 198, 692, 440, 747, 14, 515, 14, 2444, 8, 2614, 63, 3741, 304, 1585, 198, 736, 14, 8347, 8, 2614, 63, 3741, 9, 686, 198, 20938, 14, 21997, 8, 2164, 12, 2053, 9, 507, 198, 2590, 5925, 465, 325, 26, 686, 198, 1361, 480, 5116, 3405, 26, 298, 435, 620, 8, 69, 430, 199, 199, 318, 1331, 63, 694, 8, 2164, 12, 2053, 12, 6902, 304, 199, 198, 3742, 275, 715, 421, 198, 692, 440, 6902, 365, 488, 26, 507, 198, 893, 26, 686, 198, 1361, 480, 14380, 6902, 570, 367, 298, 435, 2053, 435, 298, 737, 298, 435, 6902, 9, 686, 198, 9242, 8, 5751, 12, 3686, 63, 2550, 29, 549, 9, 686, 198, 20938, 14, 29296, 8, 2614, 12, 6902, 9, 507, 198, 2590, 5925, 465, 325, 26, 686, 198, 1361, 480, 16559, 3405, 26, 298, 435, 620, 8, 69, 430, 686, 198, 3742, 275, 756, 421, 198, 692, 3182, 26, 507, 198, 893, 26, 686, 198, 1361, 480, 5116, 2082, 298, 435, 2928, 435, 298, 370, 298, 435, 2053, 9, 686, 198, 20938, 14, 29296, 8, 2164, 12, 2053, 9, 507, 198, 2590, 5925, 465, 325, 26, 686, 198, 1361, 480, 5116, 3405, 26, 298, 435, 620, 8, 69, 430, 199, 199, 318, 6675, 8, 589, 304, 199, 198, 8710, 275, 2022, 14, 912, 8, 1490, 8, 736, 14, 515, 14, 12131, 8, 589, 14, 493, 1724, 199, 198, 509, 5492, 315, 22603, 26, 507, 198, 692, 5492, 905, 923, 937, 315, 1249, 14, 8906, 26, 686, 198, 1361, 480, 10731, 316, 298, 435, 5492, 905, 354, 3135, 27, 686, 198, 2164, 275, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 8, 589, 14, 1365, 12, 5492, 905, 1365, 13045, 686, 198, 2614, 275, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 8, 589, 14, 1375, 12, 5492, 905, 1375, 13045, 686, 198, 5751, 275, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 8, 589, 14, 5751, 12, 5492, 905, 1375, 13045, 686, 198, 692, 5492, 905, 466, 4140, 2325, 342, 508, 298, 70, 582, 1585, 198, 3, 11247, 282, 570, 1585, 198, 692, 1249, 14, 14242, 26, 1871, 198, 692, 440, 1249, 14, 87, 3236, 26, 4671, 198, 1574, 63, 493, 8, 2164, 12, 2053, 12, 488, 9, 1871, 198, 2836, 26, 4671, 198, 1361, 480, 55, 3857, 1331, 570, 14, 428, 1195, 5424, 435, 2928, 435, 298, 20547, 5424, 435, 2053, 2736, 1585, 198, 2836, 26, 1871, 198, 692, 440, 1249, 14, 87, 3236, 26, 4671, 198, 1574, 63, 493, 8, 2164, 12, 2053, 12, 6902, 9, 1871, 198, 2836, 26, 4671, 198, 1361, 480, 55, 3857, 1331, 570, 14, 428, 1195, 5424, 435, 2928, 435, 298, 20547, 5424, 435, 2053, 435, 298, 10257, 384, 5424, 435, 6902, 2736, 686, 198, 4164, 5492, 905, 466, 4140, 2325, 342, 508, 298, 68, 582, 1585, 198, 3, 11247, 282, 2082, 1585, 198, 692, 1249, 14, 3832, 26, 1871, 198, 1361, 8, 7463, 905, 354, 937, 435, 7244, 22643, 316, 2082, 687, 298, 435, 2928, 435, 298, 370, 298, 435, 2053, 9, 1585, 198, 692, 1249, 14, 14242, 26, 1871, 198, 692, 440, 1249, 14, 87, 3236, 26, 4671, 198, 1574, 63, 694, 8, 2164, 12, 2053, 12, 488, 9, 1871, 198, 2836, 26, 4671, 198, 1361, 480, 55, 3857, 1331, 570, 14, 428, 1195, 5424, 435, 2928, 435, 298, 20547, 5424, 435, 2053, 2736, 1585, 198, 2836, 26, 1871, 198, 692, 440, 1249, 14, 87, 3236, 26, 4671, 198, 1574, 63, 694, 8, 2164, 12, 2053, 12, 6902, 9, 1871, 198, 2836, 26, 4671, 198, 1361, 480, 55, 3857, 1331, 2935, 14, 428, 1195, 5424, 435, 2928, 435, 298, 20547, 5424, 435, 2053, 435, 298, 10257, 384, 5424, 435, 6902, 2736, 686, 198, 2836, 26, 1585, 198, 1361, 8, 7463, 905, 354, 937, 435, 7244, 14831, 730, 19669, 11, 7463, 905, 466, 937, 25789, 7230, 199, 199, 318, 10299, 8, 589, 304, 199, 198, 8710, 275, 2022, 14, 912, 8, 1490, 8, 736, 14, 515, 14, 12131, 8, 589, 14, 493, 1724, 199, 198, 509, 5492, 315, 22603, 26, 507, 198, 692, 5492, 905, 923, 937, 315, 1249, 14, 8906, 26, 686, 198, 1361, 480, 27318, 316, 298, 435, 5492, 905, 354, 3135, 27, 686, 198, 2164, 275, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 8, 589, 14, 1375, 12, 5492, 905, 1375, 13045, 686, 198, 2614, 275, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 8, 589, 14, 1365, 12, 5492, 905, 1365, 13045, 686, 198, 692, 5492, 905, 466, 4140, 2325, 342, 508, 298, 70, 582, 1585, 198, 3, 11247, 282, 570, 1585, 198, 692, 440, 1249, 14, 87, 3236, 26, 1871, 198, 1574, 63, 493, 8, 2164, 12, 2053, 12, 488, 9, 1585, 198, 2836, 26, 1871, 198, 1361, 480, 55, 3857, 1331, 570, 14, 428, 1195, 5424, 435, 2928, 435, 298, 20547, 5424, 435, 2053, 2736, 686, 198, 4164, 5492, 905, 466, 4140, 2325, 342, 508, 298 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 646, 7534, 199, 646, 2022, 199, 646, 5145, 199, 646, 747, 199, 199, 318, 1331, 63, 493, 8, 2164, 12, 2053, 12, 6902, 304, 199, 198, 3742, 275, 715, 199, 198, 692, 440, 6902, 365, 488, 26, 507, 198, 8, 5751, 63, 3741, 12, 6902, 63, 493, 9, 275, 747, 14, 515, 14, 1294, 8, 5751, 9, 507, 198, 1361, 480, 14380, 6902, 570, 367, 298, 435, 2053, 435, 298, 737, 298, 435, 6902, 9, 507, 198, 893, 26, 686, 198, 692, 440, 747, 14, 515, 14, 2444, 8, 5751, 63, 3741, 304, 1585, 198, 736, 14, 8347, 8, 5751, 63, 3741, 9, 686, 198, 20938, 14, 21997, 8, 2614, 12, 6902, 9, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 1361, 480, 16559, 3405, 26, 298, 435, 620, 8, 69, 430, 686, 198, 3742, 275, 756, 1585, 199, 198, 692, 3182, 26, 507, 198, 8, 2614, 63, 3741, 12, 2053, 63, 493, 9, 275, 747, 14, 515, 14, 1294, 8, 2614, 9, 507, 198, 1361, 480, 5116, 570, 298, 435, 2928, 435, 298, 370, 298, 435, 2053, 9, 507, 198, 893, 26, 198, 686, 198, 692, 440, 747, 14, 515, 14, 2444, 8, 2614, 63, 3741, 304, 1585, 198, 736, 14, 8347, 8, 2614, 63, 3741, 9, 686, 198, 20938, 14, 21997, 8, 2164, 12, 2053, 9, 507, 198, 2590, 5925, 465, 325, 26, 686, 198, 1361, 480, 5116, 3405, 26, 298, 435, 620, 8, 69, 430, 199, 199, 318, 1331, 63, 694, 8, 2164, 12, 2053, 12, 6902, 304, 199, 198, 3742, 275, 715, 421, 198, 692, 440, 6902, 365, 488, 26, 507, 198, 893, 26, 686, 198, 1361, 480, 14380, 6902, 570, 367, 298, 435, 2053, 435, 298, 737, 298, 435, 6902, 9, 686, 198, 9242, 8, 5751, 12, 3686, 63, 2550, 29, 549, 9, 686, 198, 20938, 14, 29296, 8, 2614, 12, 6902, 9, 507, 198, 2590, 5925, 465, 325, 26, 686, 198, 1361, 480, 16559, 3405, 26, 298, 435, 620, 8, 69, 430, 686, 198, 3742, 275, 756, 421, 198, 692, 3182, 26, 507, 198, 893, 26, 686, 198, 1361, 480, 5116, 2082, 298, 435, 2928, 435, 298, 370, 298, 435, 2053, 9, 686, 198, 20938, 14, 29296, 8, 2164, 12, 2053, 9, 507, 198, 2590, 5925, 465, 325, 26, 686, 198, 1361, 480, 5116, 3405, 26, 298, 435, 620, 8, 69, 430, 199, 199, 318, 6675, 8, 589, 304, 199, 198, 8710, 275, 2022, 14, 912, 8, 1490, 8, 736, 14, 515, 14, 12131, 8, 589, 14, 493, 1724, 199, 198, 509, 5492, 315, 22603, 26, 507, 198, 692, 5492, 905, 923, 937, 315, 1249, 14, 8906, 26, 686, 198, 1361, 480, 10731, 316, 298, 435, 5492, 905, 354, 3135, 27, 686, 198, 2164, 275, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 8, 589, 14, 1365, 12, 5492, 905, 1365, 13045, 686, 198, 2614, 275, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 8, 589, 14, 1375, 12, 5492, 905, 1375, 13045, 686, 198, 5751, 275, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 8, 589, 14, 5751, 12, 5492, 905, 1375, 13045, 686, 198, 692, 5492, 905, 466, 4140, 2325, 342, 508, 298, 70, 582, 1585, 198, 3, 11247, 282, 570, 1585, 198, 692, 1249, 14, 14242, 26, 1871, 198, 692, 440, 1249, 14, 87, 3236, 26, 4671, 198, 1574, 63, 493, 8, 2164, 12, 2053, 12, 488, 9, 1871, 198, 2836, 26, 4671, 198, 1361, 480, 55, 3857, 1331, 570, 14, 428, 1195, 5424, 435, 2928, 435, 298, 20547, 5424, 435, 2053, 2736, 1585, 198, 2836, 26, 1871, 198, 692, 440, 1249, 14, 87, 3236, 26, 4671, 198, 1574, 63, 493, 8, 2164, 12, 2053, 12, 6902, 9, 1871, 198, 2836, 26, 4671, 198, 1361, 480, 55, 3857, 1331, 570, 14, 428, 1195, 5424, 435, 2928, 435, 298, 20547, 5424, 435, 2053, 435, 298, 10257, 384, 5424, 435, 6902, 2736, 686, 198, 4164, 5492, 905, 466, 4140, 2325, 342, 508, 298, 68, 582, 1585, 198, 3, 11247, 282, 2082, 1585, 198, 692, 1249, 14, 3832, 26, 1871, 198, 1361, 8, 7463, 905, 354, 937, 435, 7244, 22643, 316, 2082, 687, 298, 435, 2928, 435, 298, 370, 298, 435, 2053, 9, 1585, 198, 692, 1249, 14, 14242, 26, 1871, 198, 692, 440, 1249, 14, 87, 3236, 26, 4671, 198, 1574, 63, 694, 8, 2164, 12, 2053, 12, 488, 9, 1871, 198, 2836, 26, 4671, 198, 1361, 480, 55, 3857, 1331, 570, 14, 428, 1195, 5424, 435, 2928, 435, 298, 20547, 5424, 435, 2053, 2736, 1585, 198, 2836, 26, 1871, 198, 692, 440, 1249, 14, 87, 3236, 26, 4671, 198, 1574, 63, 694, 8, 2164, 12, 2053, 12, 6902, 9, 1871, 198, 2836, 26, 4671, 198, 1361, 480, 55, 3857, 1331, 2935, 14, 428, 1195, 5424, 435, 2928, 435, 298, 20547, 5424, 435, 2053, 435, 298, 10257, 384, 5424, 435, 6902, 2736, 686, 198, 2836, 26, 1585, 198, 1361, 8, 7463, 905, 354, 937, 435, 7244, 14831, 730, 19669, 11, 7463, 905, 466, 937, 25789, 7230, 199, 199, 318, 10299, 8, 589, 304, 199, 198, 8710, 275, 2022, 14, 912, 8, 1490, 8, 736, 14, 515, 14, 12131, 8, 589, 14, 493, 1724, 199, 198, 509, 5492, 315, 22603, 26, 507, 198, 692, 5492, 905, 923, 937, 315, 1249, 14, 8906, 26, 686, 198, 1361, 480, 27318, 316, 298, 435, 5492, 905, 354, 3135, 27, 686, 198, 2164, 275, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 8, 589, 14, 1375, 12, 5492, 905, 1375, 13045, 686, 198, 2614, 275, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 8, 589, 14, 1365, 12, 5492, 905, 1365, 13045, 686, 198, 692, 5492, 905, 466, 4140, 2325, 342, 508, 298, 70, 582, 1585, 198, 3, 11247, 282, 570, 1585, 198, 692, 440, 1249, 14, 87, 3236, 26, 1871, 198, 1574, 63, 493, 8, 2164, 12, 2053, 12, 488, 9, 1585, 198, 2836, 26, 1871, 198, 1361, 480, 55, 3857, 1331, 570, 14, 428, 1195, 5424, 435, 2928, 435, 298, 20547, 5424, 435, 2053, 2736, 686, 198, 4164, 5492, 905, 466, 4140, 2325, 342, 508, 298, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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main(): global comparisons with open(sys.argv[1], 'r') as f: arr = [int(x) for x in f.read().split()] quicksort(arr, 0, len(arr)-1) # print(arr) print(comparisons) def getPivot(arr, l, r): first = arr[l] mid = arr[(l+r)//2] last = arr[r] if first <= mid <= last or last <= mid <= first: return (l+r)//2 elif mid <= first <= last or last <= first <= mid: return l else: return r def partition(arr, l, r): k = getPivot(arr, l, r) k = random.randint(l, r) pivot = arr[k] arr[k], arr[l] = arr[l], arr[k] i = l+1 for j in range(l+1, r+1): if arr[j] < pivot: arr[j], arr[i] = arr[i], arr[j] i += 1 arr[l], arr[i-1] = arr[i-1], arr[l] return i-1 def quicksort(arr, l, r): if r - l < 0: return global comparisons comparisons += r - l p = partition(arr, l, r) quicksort(arr, l, p-1) quicksort(arr, p+1, r) if __name__ == '__main__': main()
mit
[ 646, 984, 199, 646, 2196, 199, 199, 863, 15864, 275, 378, 199, 199, 318, 2446, 837, 272, 2288, 20448, 272, 543, 1551, 8, 1274, 14, 3020, 59, 17, 467, 283, 82, 358, 465, 289, 26, 267, 7953, 275, 359, 442, 8, 88, 9, 367, 671, 315, 289, 14, 739, 1252, 1294, 5106, 272, 12530, 3191, 8, 5250, 12, 378, 12, 822, 8, 5250, 7216, 17, 9, 272, 327, 870, 8, 5250, 9, 272, 870, 8, 863, 15864, 9, 199, 199, 318, 664, 48, 13685, 8, 5250, 12, 634, 12, 519, 304, 272, 1642, 275, 7953, 59, 76, 61, 272, 10887, 275, 7953, 7528, 76, 11, 82, 28428, 18, 61, 272, 2061, 275, 7953, 59, 82, 61, 272, 340, 1642, 2695, 10887, 2695, 2061, 503, 2061, 2695, 10887, 2695, 1642, 26, 267, 372, 334, 76, 11, 82, 28428, 18, 272, 916, 10887, 2695, 1642, 2695, 2061, 503, 2061, 2695, 1642, 2695, 10887, 26, 267, 372, 634, 272, 587, 26, 267, 372, 519, 199, 199, 318, 6484, 8, 5250, 12, 634, 12, 519, 304, 272, 1022, 275, 664, 48, 13685, 8, 5250, 12, 634, 12, 519, 9, 272, 1022, 275, 2196, 14, 8393, 8, 76, 12, 519, 9, 272, 22292, 275, 7953, 59, 75, 61, 272, 7953, 59, 75, 467, 7953, 59, 76, 61, 275, 7953, 59, 76, 467, 7953, 59, 75, 61, 272, 284, 275, 634, 11, 17, 272, 367, 1335, 315, 1425, 8, 76, 11, 17, 12, 519, 11, 17, 304, 267, 340, 7953, 59, 74, 61, 665, 22292, 26, 288, 7953, 59, 74, 467, 7953, 59, 73, 61, 275, 7953, 59, 73, 467, 7953, 59, 74, 61, 288, 284, 847, 413, 272, 7953, 59, 76, 467, 7953, 59, 73, 13, 17, 61, 275, 7953, 59, 73, 13, 17, 467, 7953, 59, 76, 61, 272, 372, 284, 13, 17, 199, 199, 318, 12530, 3191, 8, 5250, 12, 634, 12, 519, 304, 272, 340, 519, 446, 634, 665, 378, 26, 267, 372, 272, 2288, 20448, 272, 20448, 847, 519, 446, 634, 272, 299, 275, 6484, 8, 5250, 12, 634, 12, 519, 9, 272, 12530, 3191, 8, 5250, 12, 634, 12, 299, 13, 17, 9, 272, 12530, 3191, 8, 5250, 12, 299, 11, 17, 12, 519, 9, 268, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 984, 199, 646, 2196, 199, 199, 863, 15864, 275, 378, 199, 199, 318, 2446, 837, 272, 2288, 20448, 272, 543, 1551, 8, 1274, 14, 3020, 59, 17, 467, 283, 82, 358, 465, 289, 26, 267, 7953, 275, 359, 442, 8, 88, 9, 367, 671, 315, 289, 14, 739, 1252, 1294, 5106, 272, 12530, 3191, 8, 5250, 12, 378, 12, 822, 8, 5250, 7216, 17, 9, 272, 327, 870, 8, 5250, 9, 272, 870, 8, 863, 15864, 9, 199, 199, 318, 664, 48, 13685, 8, 5250, 12, 634, 12, 519, 304, 272, 1642, 275, 7953, 59, 76, 61, 272, 10887, 275, 7953, 7528, 76, 11, 82, 28428, 18, 61, 272, 2061, 275, 7953, 59, 82, 61, 272, 340, 1642, 2695, 10887, 2695, 2061, 503, 2061, 2695, 10887, 2695, 1642, 26, 267, 372, 334, 76, 11, 82, 28428, 18, 272, 916, 10887, 2695, 1642, 2695, 2061, 503, 2061, 2695, 1642, 2695, 10887, 26, 267, 372, 634, 272, 587, 26, 267, 372, 519, 199, 199, 318, 6484, 8, 5250, 12, 634, 12, 519, 304, 272, 1022, 275, 664, 48, 13685, 8, 5250, 12, 634, 12, 519, 9, 272, 1022, 275, 2196, 14, 8393, 8, 76, 12, 519, 9, 272, 22292, 275, 7953, 59, 75, 61, 272, 7953, 59, 75, 467, 7953, 59, 76, 61, 275, 7953, 59, 76, 467, 7953, 59, 75, 61, 272, 284, 275, 634, 11, 17, 272, 367, 1335, 315, 1425, 8, 76, 11, 17, 12, 519, 11, 17, 304, 267, 340, 7953, 59, 74, 61, 665, 22292, 26, 288, 7953, 59, 74, 467, 7953, 59, 73, 61, 275, 7953, 59, 73, 467, 7953, 59, 74, 61, 288, 284, 847, 413, 272, 7953, 59, 76, 467, 7953, 59, 73, 13, 17, 61, 275, 7953, 59, 73, 13, 17, 467, 7953, 59, 76, 61, 272, 372, 284, 13, 17, 199, 199, 318, 12530, 3191, 8, 5250, 12, 634, 12, 519, 304, 272, 340, 519, 446, 634, 665, 378, 26, 267, 372, 272, 2288, 20448, 272, 20448, 847, 519, 446, 634, 272, 299, 275, 6484, 8, 5250, 12, 634, 12, 519, 9, 272, 12530, 3191, 8, 5250, 12, 634, 12, 299, 13, 17, 9, 272, 12530, 3191, 8, 5250, 12, 299, 11, 17, 12, 519, 9, 268, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
kosz85/django
django/conf/locale/nn/formats.py
65
1743
# This file is distributed under the same license as the Django package. # # The *_FORMAT strings use the Django date format syntax, # see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = 'j. F Y' TIME_FORMAT = 'H:i' DATETIME_FORMAT = 'j. F Y H:i' YEAR_MONTH_FORMAT = 'F Y' MONTH_DAY_FORMAT = 'j. F' SHORT_DATE_FORMAT = 'd.m.Y' SHORT_DATETIME_FORMAT = 'd.m.Y H:i' FIRST_DAY_OF_WEEK = 1 # Monday # The *_INPUT_FORMATS strings use the Python strftime format syntax, # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior # Kept ISO formats as they are in first position DATE_INPUT_FORMATS = [ '%Y-%m-%d', '%d.%m.%Y', '%d.%m.%y', # '2006-10-25', '25.10.2006', '25.10.06' # '%d. %b %Y', '%d %b %Y', # '25. okt 2006', '25 okt 2006' # '%d. %b. %Y', '%d %b. %Y', # '25. okt. 2006', '25 okt. 2006' # '%d. %B %Y', '%d %B %Y', # '25. oktober 2006', '25 oktober 2006' ] DATETIME_INPUT_FORMATS = [ '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' '%Y-%m-%d %H:%M:%S.%f', # '2006-10-25 14:30:59.000200' '%Y-%m-%d %H:%M', # '2006-10-25 14:30' '%Y-%m-%d', # '2006-10-25' '%Y-%m-%d', # '2006-10-25' '%d.%m.%Y %H:%M:%S', # '25.10.2006 14:30:59' '%d.%m.%Y %H:%M:%S.%f', # '25.10.2006 14:30:59.000200' '%d.%m.%Y %H:%M', # '25.10.2006 14:30' '%d.%m.%Y', # '25.10.2006' '%d.%m.%y %H:%M:%S', # '25.10.06 14:30:59' '%d.%m.%y %H:%M:%S.%f', # '25.10.06 14:30:59.000200' '%d.%m.%y %H:%M', # '25.10.06 14:30' '%d.%m.%y', # '25.10.06' ] DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '\xa0' # non-breaking space NUMBER_GROUPING = 3
bsd-3-clause
[ 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 14, 481, 1488, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 14, 481, 1488, 869, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 3, 25645, 541, 9055, 6752, 465, 2985, 787, 315, 1642, 3421, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 297, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 283, 7968, 13, 709, 13, 821, 297, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 272, 327, 1543, 68, 14, 450, 66, 450, 57, 297, 1543, 68, 450, 66, 450, 57, 297, 3322, 327, 283, 821, 14, 4112, 84, 8315, 297, 283, 821, 4112, 84, 8315, 7, 272, 327, 1543, 68, 14, 450, 66, 14, 450, 57, 297, 1543, 68, 450, 66, 14, 450, 57, 297, 3515, 327, 283, 821, 14, 4112, 84, 14, 8315, 297, 283, 821, 4112, 84, 14, 8315, 7, 272, 327, 1543, 68, 14, 450, 34, 450, 57, 297, 1543, 68, 450, 34, 450, 57, 297, 3322, 327, 283, 821, 14, 4112, 475, 605, 8315, 297, 283, 821, 4112, 475, 605, 8315, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 263, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 4519, 327, 283, 7968, 13, 709, 13, 821, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 4519, 327, 283, 7968, 13, 709, 13, 821, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 1557, 1800, 16, 7, 221, 327, 2222, 13, 4785, 316, 4601, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 14, 481, 1488, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 14, 481, 1488, 869, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 3, 25645, 541, 9055, 6752, 465, 2985, 787, 315, 1642, 3421, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 297, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 283, 7968, 13, 709, 13, 821, 297, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 272, 327, 1543, 68, 14, 450, 66, 450, 57, 297, 1543, 68, 450, 66, 450, 57, 297, 3322, 327, 283, 821, 14, 4112, 84, 8315, 297, 283, 821, 4112, 84, 8315, 7, 272, 327, 1543, 68, 14, 450, 66, 14, 450, 57, 297, 1543, 68, 450, 66, 14, 450, 57, 297, 3515, 327, 283, 821, 14, 4112, 84, 14, 8315, 297, 283, 821, 4112, 84, 14, 8315, 7, 272, 327, 1543, 68, 14, 450, 34, 450, 57, 297, 1543, 68, 450, 34, 450, 57, 297, 3322, 327, 283, 821, 14, 4112, 475, 605, 8315, 297, 283, 821, 4112, 475, 605, 8315, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 263, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 4519, 327, 283, 7968, 13, 709, 13, 821, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 4519, 327, 283, 7968, 13, 709, 13, 821, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 1557, 1800, 16, 7, 221, 327, 2222, 13, 4785, 316, 4601, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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ticipant.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() from POGOProtos.Data.Battle import BattlePokemonInfo_pb2 as POGOProtos_dot_Data_dot_Battle_dot_BattlePokemonInfo__pb2 from POGOProtos.Data.Player import PlayerPublicProfile_pb2 as POGOProtos_dot_Data_dot_Player_dot_PlayerPublicProfile__pb2 DESCRIPTOR = _descriptor.FileDescriptor( name='POGOProtos/Data/Battle/BattleParticipant.proto', package='POGOProtos.Data.Battle', syntax='proto3', serialized_pb=_b('\n.POGOProtos/Data/Battle/BattleParticipant.proto\x12\x16POGOProtos.Data.Battle\x1a.POGOProtos/Data/Battle/BattlePokemonInfo.proto\x1a\x30POGOProtos/Data/Player/PlayerPublicProfile.proto\"\xac\x02\n\x11\x42\x61ttleParticipant\x12\x41\n\x0e\x61\x63tive_pokemon\x18\x01 \x01(\x0b\x32).POGOProtos.Data.Battle.BattlePokemonInfo\x12K\n\x16trainer_public_profile\x18\x02 \x01(\x0b\x32+.POGOProtos.Data.Player.PlayerPublicProfile\x12\x42\n\x0freverse_pokemon\x18\x03 \x03(\x0b\x32).POGOProtos.Data.Battle.BattlePokemonInfo\x12\x43\n\x10\x64\x65\x66\x65\x61ted_pokemon\x18\x04 \x03(\x0b\x32).POGOProtos.Data.Battle.BattlePokemonInfob\x06proto3') , dependencies=[POGOProtos_dot_Data_dot_Battle_dot_BattlePokemonInfo__pb2.DESCRIPTOR,POGOProtos_dot_Data_dot_Player_dot_PlayerPublicProfile__pb2.DESCRIPTOR,]) _sym_db.RegisterFileDescriptor(DESCRIPTOR) _BATTLEPARTICIPANT = _descriptor.Descriptor( name='BattleParticipant', full_name='POGOProtos.Data.Battle.BattleParticipant', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='active_pokemon', full_name='POGOProtos.Data.Battle.BattleParticipant.active_pokemon', index=0, number=1, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='trainer_public_profile', full_name='POGOProtos.Data.Battle.BattleParticipant.trainer_public_profile', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='reverse_pokemon', full_name='POGOProtos.Data.Battle.BattleParticipant.reverse_pokemon', index=2, number=3, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='defeated_pokemon', full_name='POGOProtos.Data.Battle.BattleParticipant.defeated_pokemon', index=3, number=4, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=173, serialized_end=473, ) _BATTLEPARTICIPANT.fields_by_name['active_pokemon'].message_type = POGOProtos_dot_Data_dot_Battle_dot_BattlePokemonInfo__pb2._BATTLEPOKEMONINFO _BATTLEPARTICIPANT.fields_by_name['trainer_public_profile'].message_type = POGOProtos_dot_Data_dot_Player_dot_PlayerPublicProfile__pb2._PLAYERPUBLICPROFILE _BATTLEPARTICIPANT.fields_by_name['reverse_pokemon'].message_type = POGOProtos_dot_Data_dot_Battle_dot_BattlePokemonInfo__pb2._BATTLEPOKEMONINFO _BATTLEPARTICIPANT.fields_by_name['defeated_pokemon'].message_type = POGOProtos_dot_Data_dot_Battle_dot_BattlePokemonInfo__pb2._BATTLEPOKEMONINFO DESCRIPTOR.message_types_by_name['BattleParticipant'] = _BATTLEPARTICIPANT BattleParticipant = _reflection.GeneratedProtocolMessageType('BattleParticipant', (_message.Message,), dict( DESCRIPTOR = _BATTLEPARTICIPANT, __module__ = 'POGOProtos.Data.Battle.BattleParticipant_pb2' # @@protoc_insertion_point(class_scope:POGOProtos.Data.Battle.BattleParticipant) )) _sym_db.RegisterMessage(BattleParticipant) # @@protoc_insertion_point(module_scope)
mit
[ 3, 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 3, 1350, 26, 3625, 23114, 15, 1451, 15, 34, 29274, 15, 34, 29274, 1262, 16448, 14, 2625, 199, 199, 646, 984, 199, 63, 66, 29, 1274, 14, 1023, 63, 815, 59, 16, 61, 28, 19, 436, 334, 2734, 671, 26, 88, 9, 503, 334, 2734, 671, 26, 88, 14, 2143, 360, 10378, 17, 1333, 199, 504, 6233, 14, 7204, 492, 5872, 465, 485, 4120, 199, 504, 6233, 14, 7204, 492, 1245, 465, 485, 1188, 199, 504, 6233, 14, 7204, 492, 25572, 465, 485, 14906, 199, 504, 6233, 14, 7204, 492, 5272, 63, 4659, 465, 485, 5155, 63, 4659, 199, 504, 6233, 14, 7204, 492, 5872, 63, 3317, 18, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 199, 199, 63, 3840, 63, 697, 275, 485, 5155, 63, 4659, 14, 2698, 342, 421, 199, 504, 3625, 23114, 14, 1451, 14, 34, 29274, 492, 699, 29274, 1575, 17180, 2354, 63, 3317, 18, 465, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 34, 29274, 63, 3287, 63, 34, 29274, 1575, 17180, 2354, 363, 3317, 18, 199, 504, 3625, 23114, 14, 1451, 14, 10921, 492, 25610, 9885, 5736, 63, 3317, 18, 465, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 10921, 63, 3287, 63, 10921, 9885, 5736, 363, 3317, 18, 421, 199, 7580, 275, 485, 4120, 14, 23859, 8, 523, 536, 534, 26676, 15, 1451, 15, 34, 29274, 15, 34, 29274, 1262, 16448, 14, 2625, 297, 523, 2559, 534, 26676, 14, 1451, 14, 34, 29274, 297, 523, 6302, 534, 2625, 19, 297, 523, 6380, 63, 3317, 3699, 66, 2258, 78, 14, 26676, 15, 1451, 15, 34, 29274, 15, 34, 29274, 1262, 16448, 14, 2625, 60, 88, 713, 60, 88, 975, 26676, 14, 1451, 14, 34, 29274, 60, 88, 17, 65, 14, 26676, 15, 1451, 15, 34, 29274, 15, 34, 29274, 1575, 17180, 2354, 14, 2625, 60, 88, 17, 65, 60, 88, 1216, 26676, 15, 1451, 15, 10921, 15, 10921, 9885, 5736, 14, 2625, 13356, 10104, 60, 88, 996, 60, 78, 60, 88, 845, 60, 88, 2260, 60, 88, 2976, 84, 1118, 1262, 16448, 60, 88, 713, 60, 88, 2953, 60, 78, 60, 88, 16, 69, 60, 88, 2976, 60, 88, 2766, 857, 63, 28331, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 680, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1575, 17180, 2354, 60, 88, 713, 43, 60, 78, 60, 88, 975, 2834, 281, 63, 3455, 63, 2913, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 26240, 26676, 14, 1451, 14, 10921, 14, 10921, 9885, 5736, 60, 88, 713, 60, 88, 2260, 60, 78, 60, 88, 16, 70, 4471, 63, 28331, 60, 88, 1085, 60, 88, 1644, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 680, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1575, 17180, 2354, 60, 88, 713, 60, 88, 2824, 60, 78, 60, 88, 709, 60, 88, 772, 60, 88, 2182, 60, 88, 1272, 60, 88, 2182, 60, 88, 2976, 471, 63, 28331, 60, 88, 1085, 60, 88, 966, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 680, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1575, 17180, 2354, 66, 60, 88, 1690, 2625, 19, 358, 523, 2360, 523, 5124, 1524, 26676, 63, 3287, 63, 1451, 63, 3287, 63, 34, 29274, 63, 3287, 63, 34, 29274, 1575, 17180, 2354, 363, 3317, 18, 14, 7580, 12, 26676, 63, 3287, 63, 1451, 63, 3287, 63, 10921, 63, 3287, 63, 10921, 9885, 5736, 363, 3317, 18, 14, 7580, 30453, 199, 63, 3840, 63, 697, 14, 7099, 23859, 8, 7580, 9, 6905, 199, 63, 34, 11712, 906, 14848, 948, 1772, 1441, 275, 485, 4120, 14, 4311, 8, 523, 536, 534, 34, 29274, 1262, 16448, 297, 523, 2615, 63, 354, 534, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1262, 16448, 297, 523, 1788, 29, 403, 12, 523, 570, 29, 7580, 12, 523, 3035, 63, 466, 29, 403, 12, 523, 1504, 1524, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 2682, 63, 28331, 297, 2615, 63, 354, 534, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1262, 16448, 14, 2682, 63, 28331, 297, 1478, 29, 16, 12, 489, 1329, 29, 17, 12, 730, 29, 845, 12, 7246, 63, 466, 29, 709, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 403, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 1511, 29, 403, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 2834, 281, 63, 3455, 63, 2913, 297, 2615, 63, 354, 534, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1262, 16448, 14, 2834, 281, 63, 3455, 63, 2913, 297, 1478, 29, 17, 12, 489, 1329, 29, 18, 12, 730, 29, 845, 12, 7246, 63, 466, 29, 709, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 403, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 1511, 29, 403, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 4471, 63, 28331, 297, 2615, 63, 354, 534, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1262, 16448, 14, 4471, 63, 28331, 297, 1478, 29, 18, 12, 489, 1329, 29, 19, 12, 730, 29, 845, 12, 7246, 63, 466, 29, 709, 12, 1768, 29, 19, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 6034, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 1511, 29, 403, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 318, 69, 972, 63, 28331, 297, 2615, 63 ]
[ 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 3, 1350, 26, 3625, 23114, 15, 1451, 15, 34, 29274, 15, 34, 29274, 1262, 16448, 14, 2625, 199, 199, 646, 984, 199, 63, 66, 29, 1274, 14, 1023, 63, 815, 59, 16, 61, 28, 19, 436, 334, 2734, 671, 26, 88, 9, 503, 334, 2734, 671, 26, 88, 14, 2143, 360, 10378, 17, 1333, 199, 504, 6233, 14, 7204, 492, 5872, 465, 485, 4120, 199, 504, 6233, 14, 7204, 492, 1245, 465, 485, 1188, 199, 504, 6233, 14, 7204, 492, 25572, 465, 485, 14906, 199, 504, 6233, 14, 7204, 492, 5272, 63, 4659, 465, 485, 5155, 63, 4659, 199, 504, 6233, 14, 7204, 492, 5872, 63, 3317, 18, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 199, 199, 63, 3840, 63, 697, 275, 485, 5155, 63, 4659, 14, 2698, 342, 421, 199, 504, 3625, 23114, 14, 1451, 14, 34, 29274, 492, 699, 29274, 1575, 17180, 2354, 63, 3317, 18, 465, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 34, 29274, 63, 3287, 63, 34, 29274, 1575, 17180, 2354, 363, 3317, 18, 199, 504, 3625, 23114, 14, 1451, 14, 10921, 492, 25610, 9885, 5736, 63, 3317, 18, 465, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 10921, 63, 3287, 63, 10921, 9885, 5736, 363, 3317, 18, 421, 199, 7580, 275, 485, 4120, 14, 23859, 8, 523, 536, 534, 26676, 15, 1451, 15, 34, 29274, 15, 34, 29274, 1262, 16448, 14, 2625, 297, 523, 2559, 534, 26676, 14, 1451, 14, 34, 29274, 297, 523, 6302, 534, 2625, 19, 297, 523, 6380, 63, 3317, 3699, 66, 2258, 78, 14, 26676, 15, 1451, 15, 34, 29274, 15, 34, 29274, 1262, 16448, 14, 2625, 60, 88, 713, 60, 88, 975, 26676, 14, 1451, 14, 34, 29274, 60, 88, 17, 65, 14, 26676, 15, 1451, 15, 34, 29274, 15, 34, 29274, 1575, 17180, 2354, 14, 2625, 60, 88, 17, 65, 60, 88, 1216, 26676, 15, 1451, 15, 10921, 15, 10921, 9885, 5736, 14, 2625, 13356, 10104, 60, 88, 996, 60, 78, 60, 88, 845, 60, 88, 2260, 60, 88, 2976, 84, 1118, 1262, 16448, 60, 88, 713, 60, 88, 2953, 60, 78, 60, 88, 16, 69, 60, 88, 2976, 60, 88, 2766, 857, 63, 28331, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 680, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1575, 17180, 2354, 60, 88, 713, 43, 60, 78, 60, 88, 975, 2834, 281, 63, 3455, 63, 2913, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 26240, 26676, 14, 1451, 14, 10921, 14, 10921, 9885, 5736, 60, 88, 713, 60, 88, 2260, 60, 78, 60, 88, 16, 70, 4471, 63, 28331, 60, 88, 1085, 60, 88, 1644, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 680, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1575, 17180, 2354, 60, 88, 713, 60, 88, 2824, 60, 78, 60, 88, 709, 60, 88, 772, 60, 88, 2182, 60, 88, 1272, 60, 88, 2182, 60, 88, 2976, 471, 63, 28331, 60, 88, 1085, 60, 88, 966, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 680, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1575, 17180, 2354, 66, 60, 88, 1690, 2625, 19, 358, 523, 2360, 523, 5124, 1524, 26676, 63, 3287, 63, 1451, 63, 3287, 63, 34, 29274, 63, 3287, 63, 34, 29274, 1575, 17180, 2354, 363, 3317, 18, 14, 7580, 12, 26676, 63, 3287, 63, 1451, 63, 3287, 63, 10921, 63, 3287, 63, 10921, 9885, 5736, 363, 3317, 18, 14, 7580, 30453, 199, 63, 3840, 63, 697, 14, 7099, 23859, 8, 7580, 9, 6905, 199, 63, 34, 11712, 906, 14848, 948, 1772, 1441, 275, 485, 4120, 14, 4311, 8, 523, 536, 534, 34, 29274, 1262, 16448, 297, 523, 2615, 63, 354, 534, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1262, 16448, 297, 523, 1788, 29, 403, 12, 523, 570, 29, 7580, 12, 523, 3035, 63, 466, 29, 403, 12, 523, 1504, 1524, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 2682, 63, 28331, 297, 2615, 63, 354, 534, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1262, 16448, 14, 2682, 63, 28331, 297, 1478, 29, 16, 12, 489, 1329, 29, 17, 12, 730, 29, 845, 12, 7246, 63, 466, 29, 709, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 403, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 1511, 29, 403, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 2834, 281, 63, 3455, 63, 2913, 297, 2615, 63, 354, 534, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1262, 16448, 14, 2834, 281, 63, 3455, 63, 2913, 297, 1478, 29, 17, 12, 489, 1329, 29, 18, 12, 730, 29, 845, 12, 7246, 63, 466, 29, 709, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 403, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 1511, 29, 403, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 4471, 63, 28331, 297, 2615, 63, 354, 534, 26676, 14, 1451, 14, 34, 29274, 14, 34, 29274, 1262, 16448, 14, 4471, 63, 28331, 297, 1478, 29, 18, 12, 489, 1329, 29, 19, 12, 730, 29, 845, 12, 7246, 63, 466, 29, 709, 12, 1768, 29, 19, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 6034, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 1511, 29, 403, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 318, 69, 972, 63, 28331, 297, 2615, 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,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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 ]
sarahfo/oppia
core/domain/dependency_registry_test.py
29
4131
# coding: utf-8 # # Copyright 2014 The Oppia Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Tests for JavaScript library dependencies.""" __author__ = 'Sean Lip' from core.domain import dependency_registry from core.domain import exp_services from core.domain import interaction_registry from core.tests import test_utils import feconf class DependencyRegistryTests(test_utils.GenericTestBase): """Tests for the dependency registry.""" def test_get_dependency_html(self): self.assertIn( 'jsrepl', dependency_registry.Registry.get_dependency_html('jsrepl')) with self.assertRaises(IOError): dependency_registry.Registry.get_dependency_html('a') class DependencyControllerTests(test_utils.GenericTestBase): """Tests for dependency loading on user-facing pages.""" def test_no_dependencies_in_non_exploration_pages(self): response = self.testapp.get(feconf.GALLERY_URL) self.assertEqual(response.status_int, 200) response.mustcontain(no=['jsrepl']) response = self.testapp.get('/about') self.assertEqual(response.status_int, 200) response.mustcontain(no=['jsrepl']) def test_dependencies_loaded_in_exploration_editor(self): exp_services.load_demo('0') # Register and login as an editor. self.signup(self.EDITOR_EMAIL, self.EDITOR_USERNAME) self.login(self.EDITOR_EMAIL) # Verify that the exploration does not have a jsrepl dependency. exploration = exp_services.get_exploration_by_id('0') interaction_ids = exploration.get_interaction_ids() all_dependency_ids = ( interaction_registry.Registry.get_deduplicated_dependency_ids( interaction_ids)) self.assertNotIn('jsrepl', all_dependency_ids) # However, jsrepl is loaded in the exploration editor anyway, since # all dependencies are loaded in the exploration editor. response = self.testapp.get('/create/0') self.assertEqual(response.status_int, 200) response.mustcontain('jsrepl') self.logout() def test_dependency_does_not_load_in_exploration_not_containing_it(self): EXP_ID = '0' exp_services.load_demo(EXP_ID) # Verify that exploration 0 does not have a jsrepl dependency. exploration = exp_services.get_exploration_by_id(EXP_ID) interaction_ids = exploration.get_interaction_ids() all_dependency_ids = ( interaction_registry.Registry.get_deduplicated_dependency_ids( interaction_ids)) self.assertNotIn('jsrepl', all_dependency_ids) # Thus, jsrepl is not loaded in the exploration reader. response = self.testapp.get('/explore/%s' % EXP_ID) self.assertEqual(response.status_int, 200) response.mustcontain(no=['jsrepl']) def test_dependency_loads_in_exploration_containing_it(self): EXP_ID = '1' exp_services.load_demo(EXP_ID) # Verify that exploration 1 has a jsrepl dependency. exploration = exp_services.get_exploration_by_id(EXP_ID) interaction_ids = exploration.get_interaction_ids() all_dependency_ids = ( interaction_registry.Registry.get_deduplicated_dependency_ids( interaction_ids)) self.assertIn('jsrepl', all_dependency_ids) # Thus, jsrepl is loaded in the exploration reader. response = self.testapp.get('/explore/%s' % EXP_ID) self.assertEqual(response.status_int, 200) response.mustcontain('jsrepl')
apache-2.0
[ 3, 2803, 26, 2774, 13, 24, 199, 3, 199, 3, 1898, 6927, 710, 593, 802, 4674, 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, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 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, 624, 2925, 367, 15250, 3555, 5124, 1041, 199, 199, 363, 2502, 363, 275, 283, 1513, 290, 491, 711, 7, 199, 199, 504, 6170, 14, 2261, 492, 5936, 63, 5189, 199, 504, 6170, 14, 2261, 492, 1437, 63, 5950, 199, 504, 6170, 14, 2261, 492, 18752, 63, 5189, 199, 504, 6170, 14, 2219, 492, 511, 63, 1208, 199, 646, 1964, 2190, 421, 199, 533, 22922, 10899, 2925, 8, 396, 63, 1208, 14, 9417, 14440, 304, 272, 408, 2925, 367, 314, 5936, 7086, 1041, 339, 347, 511, 63, 362, 63, 8575, 63, 1360, 8, 277, 304, 267, 291, 14, 4080, 8, 288, 283, 3596, 16349, 297, 288, 5936, 63, 5189, 14, 10899, 14, 362, 63, 8575, 63, 1360, 360, 3596, 16349, 1333, 398, 543, 291, 14, 1855, 8, 13760, 304, 288, 5936, 63, 5189, 14, 10899, 14, 362, 63, 8575, 63, 1360, 360, 65, 358, 421, 199, 533, 22922, 7506, 2925, 8, 396, 63, 1208, 14, 9417, 14440, 304, 272, 408, 2925, 367, 5936, 8697, 641, 922, 13, 32552, 6497, 1041, 339, 347, 511, 63, 889, 63, 5714, 63, 262, 63, 2865, 63, 29028, 63, 5856, 8, 277, 304, 267, 1177, 275, 291, 14, 19700, 14, 362, 8, 771, 2190, 14, 39, 1761, 9418, 63, 2632, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 442, 12, 1926, 9, 267, 1177, 14, 7790, 7747, 8, 889, 2968, 3596, 16349, 1105, 398, 1177, 275, 291, 14, 19700, 14, 362, 2336, 10254, 358, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 442, 12, 1926, 9, 267, 1177, 14, 7790, 7747, 8, 889, 2968, 3596, 16349, 1105, 339, 347, 511, 63, 5714, 63, 4591, 63, 262, 63, 29028, 63, 7515, 8, 277, 304, 267, 1437, 63, 5950, 14, 912, 63, 8768, 360, 16, 358, 398, 327, 11828, 436, 4676, 465, 376, 8823, 14, 267, 291, 14, 19799, 8, 277, 14, 17929, 726, 63, 10089, 12, 291, 14, 17929, 726, 63, 11958, 9, 267, 291, 14, 2886, 8, 277, 14, 17929, 726, 63, 10089, 9, 398, 327, 7635, 626, 314, 31337, 1630, 440, 1172, 282, 8586, 16349, 5936, 14, 267, 31337, 275, 1437, 63, 5950, 14, 362, 63, 29028, 63, 991, 63, 344, 360, 16, 358, 267, 18752, 63, 1580, 275, 31337, 14, 362, 63, 21679, 63, 1580, 342, 267, 1006, 63, 8575, 63, 1580, 275, 334, 288, 18752, 63, 5189, 14, 10899, 14, 362, 63, 770, 16724, 63, 8575, 63, 1580, 8, 355, 18752, 63, 1580, 430, 398, 291, 14, 8795, 360, 3596, 16349, 297, 1006, 63, 8575, 63, 1580, 9, 398, 327, 9738, 12, 8586, 16349, 365, 6511, 315, 314, 31337, 8823, 15988, 12, 3967, 267, 327, 1006, 5124, 787, 6511, 315, 314, 31337, 8823, 14, 267, 1177, 275, 291, 14, 19700, 14, 362, 2336, 981, 15, 16, 358, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 442, 12, 1926, 9, 267, 1177, 14, 7790, 7747, 360, 3596, 16349, 358, 398, 291, 14, 11646, 342, 339, 347, 511, 63, 8575, 63, 9105, 63, 1397, 63, 912, 63, 262, 63, 29028, 63, 1397, 63, 16133, 63, 390, 8, 277, 304, 267, 3651, 48, 63, 998, 275, 283, 16, 7, 398, 1437, 63, 5950, 14, 912, 63, 8768, 8, 11992, 63, 998, 9, 398, 327, 7635, 626, 31337, 378, 1630, 440, 1172, 282, 8586, 16349, 5936, 14, 267, 31337, 275, 1437, 63, 5950, 14, 362, 63, 29028, 63, 991, 63, 344, 8, 11992, 63, 998, 9, 267, 18752, 63, 1580, 275, 31337, 14, 362, 63, 21679, 63, 1580, 342, 267, 1006, 63, 8575, 63, 1580, 275, 334, 288, 18752, 63, 5189, 14, 10899, 14, 362, 63, 770, 16724, 63, 8575, 63, 1580, 8, 355, 18752, 63, 1580, 430, 267, 291, 14, 8795, 360, 3596, 16349, 297, 1006, 63, 8575, 63, 1580, 9, 398, 327, 20227, 12, 8586, 16349, 365, 440, 6511, 315, 314, 31337, 7002, 14, 267, 1177, 275, 291, 14, 19700, 14, 362, 2336, 16971, 264, 3149, 83, 7, 450, 3651, 48, 63, 998, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 442, 12, 1926, 9, 267, 1177, 14, 7790, 7747, 8, 889, 2968, 3596, 16349, 1105, 339, 347, 511, 63, 8575, 63, 3640, 63, 262, 63, 29028, 63, 16133, 63, 390, 8, 277, 304, 267, 3651, 48, 63, 998, 275, 283, 17, 7, 398, 1437, 63, 5950, 14, 912, 63, 8768, 8, 11992, 63, 998, 9, 398, 327, 7635, 626, 31337, 413, 965, 282, 8586, 16349, 5936, 14, 267, 31337, 275, 1437, 63, 5950, 14, 362, 63, 29028, 63, 991, 63, 344, 8, 11992, 63, 998, 9, 267, 18752, 63, 1580, 275, 31337, 14, 362, 63, 21679, 63, 1580, 342, 267, 1006, 63, 8575, 63, 1580, 275, 334, 288, 18752, 63, 5189, 14, 10899, 14, 362, 63, 770, 16724, 63, 8575, 63, 1580, 8, 355, 18752, 63, 1580, 430, 267, 291, 14, 4080, 360, 3596, 16349, 297, 1006, 63, 8575, 63, 1580, 9, 398, 327, 20227, 12, 8586, 16349, 365, 6511, 315, 314, 31337, 7002, 14, 267, 1177, 275, 291, 14, 19700, 14, 362, 2336, 16971, 264, 3149, 83, 7, 450, 3651, 48, 63, 998, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 442, 12, 1926, 9, 267, 1177, 14, 7790, 7747, 360, 3596, 16349, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 26, 2774, 13, 24, 199, 3, 199, 3, 1898, 6927, 710, 593, 802, 4674, 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, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 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, 624, 2925, 367, 15250, 3555, 5124, 1041, 199, 199, 363, 2502, 363, 275, 283, 1513, 290, 491, 711, 7, 199, 199, 504, 6170, 14, 2261, 492, 5936, 63, 5189, 199, 504, 6170, 14, 2261, 492, 1437, 63, 5950, 199, 504, 6170, 14, 2261, 492, 18752, 63, 5189, 199, 504, 6170, 14, 2219, 492, 511, 63, 1208, 199, 646, 1964, 2190, 421, 199, 533, 22922, 10899, 2925, 8, 396, 63, 1208, 14, 9417, 14440, 304, 272, 408, 2925, 367, 314, 5936, 7086, 1041, 339, 347, 511, 63, 362, 63, 8575, 63, 1360, 8, 277, 304, 267, 291, 14, 4080, 8, 288, 283, 3596, 16349, 297, 288, 5936, 63, 5189, 14, 10899, 14, 362, 63, 8575, 63, 1360, 360, 3596, 16349, 1333, 398, 543, 291, 14, 1855, 8, 13760, 304, 288, 5936, 63, 5189, 14, 10899, 14, 362, 63, 8575, 63, 1360, 360, 65, 358, 421, 199, 533, 22922, 7506, 2925, 8, 396, 63, 1208, 14, 9417, 14440, 304, 272, 408, 2925, 367, 5936, 8697, 641, 922, 13, 32552, 6497, 1041, 339, 347, 511, 63, 889, 63, 5714, 63, 262, 63, 2865, 63, 29028, 63, 5856, 8, 277, 304, 267, 1177, 275, 291, 14, 19700, 14, 362, 8, 771, 2190, 14, 39, 1761, 9418, 63, 2632, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 442, 12, 1926, 9, 267, 1177, 14, 7790, 7747, 8, 889, 2968, 3596, 16349, 1105, 398, 1177, 275, 291, 14, 19700, 14, 362, 2336, 10254, 358, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 442, 12, 1926, 9, 267, 1177, 14, 7790, 7747, 8, 889, 2968, 3596, 16349, 1105, 339, 347, 511, 63, 5714, 63, 4591, 63, 262, 63, 29028, 63, 7515, 8, 277, 304, 267, 1437, 63, 5950, 14, 912, 63, 8768, 360, 16, 358, 398, 327, 11828, 436, 4676, 465, 376, 8823, 14, 267, 291, 14, 19799, 8, 277, 14, 17929, 726, 63, 10089, 12, 291, 14, 17929, 726, 63, 11958, 9, 267, 291, 14, 2886, 8, 277, 14, 17929, 726, 63, 10089, 9, 398, 327, 7635, 626, 314, 31337, 1630, 440, 1172, 282, 8586, 16349, 5936, 14, 267, 31337, 275, 1437, 63, 5950, 14, 362, 63, 29028, 63, 991, 63, 344, 360, 16, 358, 267, 18752, 63, 1580, 275, 31337, 14, 362, 63, 21679, 63, 1580, 342, 267, 1006, 63, 8575, 63, 1580, 275, 334, 288, 18752, 63, 5189, 14, 10899, 14, 362, 63, 770, 16724, 63, 8575, 63, 1580, 8, 355, 18752, 63, 1580, 430, 398, 291, 14, 8795, 360, 3596, 16349, 297, 1006, 63, 8575, 63, 1580, 9, 398, 327, 9738, 12, 8586, 16349, 365, 6511, 315, 314, 31337, 8823, 15988, 12, 3967, 267, 327, 1006, 5124, 787, 6511, 315, 314, 31337, 8823, 14, 267, 1177, 275, 291, 14, 19700, 14, 362, 2336, 981, 15, 16, 358, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 442, 12, 1926, 9, 267, 1177, 14, 7790, 7747, 360, 3596, 16349, 358, 398, 291, 14, 11646, 342, 339, 347, 511, 63, 8575, 63, 9105, 63, 1397, 63, 912, 63, 262, 63, 29028, 63, 1397, 63, 16133, 63, 390, 8, 277, 304, 267, 3651, 48, 63, 998, 275, 283, 16, 7, 398, 1437, 63, 5950, 14, 912, 63, 8768, 8, 11992, 63, 998, 9, 398, 327, 7635, 626, 31337, 378, 1630, 440, 1172, 282, 8586, 16349, 5936, 14, 267, 31337, 275, 1437, 63, 5950, 14, 362, 63, 29028, 63, 991, 63, 344, 8, 11992, 63, 998, 9, 267, 18752, 63, 1580, 275, 31337, 14, 362, 63, 21679, 63, 1580, 342, 267, 1006, 63, 8575, 63, 1580, 275, 334, 288, 18752, 63, 5189, 14, 10899, 14, 362, 63, 770, 16724, 63, 8575, 63, 1580, 8, 355, 18752, 63, 1580, 430, 267, 291, 14, 8795, 360, 3596, 16349, 297, 1006, 63, 8575, 63, 1580, 9, 398, 327, 20227, 12, 8586, 16349, 365, 440, 6511, 315, 314, 31337, 7002, 14, 267, 1177, 275, 291, 14, 19700, 14, 362, 2336, 16971, 264, 3149, 83, 7, 450, 3651, 48, 63, 998, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 442, 12, 1926, 9, 267, 1177, 14, 7790, 7747, 8, 889, 2968, 3596, 16349, 1105, 339, 347, 511, 63, 8575, 63, 3640, 63, 262, 63, 29028, 63, 16133, 63, 390, 8, 277, 304, 267, 3651, 48, 63, 998, 275, 283, 17, 7, 398, 1437, 63, 5950, 14, 912, 63, 8768, 8, 11992, 63, 998, 9, 398, 327, 7635, 626, 31337, 413, 965, 282, 8586, 16349, 5936, 14, 267, 31337, 275, 1437, 63, 5950, 14, 362, 63, 29028, 63, 991, 63, 344, 8, 11992, 63, 998, 9, 267, 18752, 63, 1580, 275, 31337, 14, 362, 63, 21679, 63, 1580, 342, 267, 1006, 63, 8575, 63, 1580, 275, 334, 288, 18752, 63, 5189, 14, 10899, 14, 362, 63, 770, 16724, 63, 8575, 63, 1580, 8, 355, 18752, 63, 1580, 430, 267, 291, 14, 4080, 360, 3596, 16349, 297, 1006, 63, 8575, 63, 1580, 9, 398, 327, 20227, 12, 8586, 16349, 365, 6511, 315, 314, 31337, 7002, 14, 267, 1177, 275, 291, 14, 19700, 14, 362, 2336, 16971, 264, 3149, 83, 7, 450, 3651, 48, 63, 998, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 442, 12, 1926, 9, 267, 1177, 14, 7790, 7747,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
jobscore/sync-engine
migrations/env.py
3
2894
from __future__ import with_statement from alembic import context from logging.config import fileConfig # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(context.config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel from inbox.models.base import MailSyncBase target_metadata = MailSyncBase.metadata from inbox.config import config from inbox.ignition import EngineManager # Alembic configuration is confusing. Here we look for a shard id both as a # "main option" (where it's programmatically set by bin/create-db), and in the # "x" argument, which is the primary facility for passing additional # command-line args to alembic. So you would do e.g. # # alembic -x shard_id=1 upgrade +1 # # to target shard 1 for the migration. config_shard_id = context.config.get_main_option('shard_id') x_shard_id = context.get_x_argument(as_dictionary=True).get( 'shard_id') if config_shard_id is not None: shard_id = int(config_shard_id) elif x_shard_id is not None: shard_id = int(x_shard_id) else: raise ValueError('No shard_id is configured for migration; ' 'run `alembic -x shard_id=<target shard id> upgrade +1`') def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output. """ engine_manager = EngineManager(config.get_required('DATABASE_HOSTS'), config.get_required('DATABASE_USERS'), include_disabled=True) engine = engine_manager.engines[shard_id] context.configure(engine=engine, url=engine.url) with context.begin_transaction(): context.run_migrations() def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ engine_manager = EngineManager(config.get_required('DATABASE_HOSTS'), config.get_required('DATABASE_USERS'), include_disabled=True) engine = engine_manager.engines[shard_id] connection = engine.connect() # Set sane lock wait timeout value. connection.execute('SET @@lock_wait_timeout=15') context.configure( connection=connection, target_metadata=target_metadata ) try: with context.begin_transaction(): context.run_migrations() finally: connection.close() if context.is_offline_mode(): run_migrations_offline() else: run_migrations_online()
agpl-3.0
[ 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 30960, 20596, 492, 1067, 199, 199, 504, 2050, 14, 888, 492, 570, 2028, 199, 199, 3, 6551, 25133, 314, 1101, 570, 367, 2018, 2050, 14, 199, 3, 961, 1004, 5951, 1536, 23445, 26014, 14, 199, 493, 2028, 8, 1100, 14, 888, 14, 888, 63, 493, 63, 354, 9, 199, 199, 3, 1050, 2195, 1402, 1159, 24905, 909, 2348, 199, 3, 367, 283, 6898, 974, 22978, 7, 2291, 199, 3, 687, 3002, 571, 492, 3002, 1238, 199, 504, 315, 1977, 14, 992, 14, 1095, 492, 18027, 10878, 1563, 199, 1375, 63, 2343, 275, 18027, 10878, 1563, 14, 2343, 199, 199, 504, 315, 1977, 14, 888, 492, 1101, 199, 504, 315, 1977, 14, 1030, 15415, 492, 12580, 2988, 421, 199, 3, 6832, 20596, 2897, 365, 3743, 4941, 14, 11842, 781, 3648, 367, 282, 11814, 1305, 3865, 465, 282, 199, 3, 298, 973, 945, 2, 334, 4509, 652, 1159, 2240, 17174, 663, 701, 2517, 15, 981, 13, 697, 395, 436, 315, 314, 199, 3, 298, 88, 2, 1423, 12, 1314, 365, 314, 5062, 21395, 367, 9476, 4722, 199, 3, 1414, 13, 604, 1249, 370, 30960, 20596, 14, 2002, 1265, 3955, 886, 325, 14, 71, 14, 199, 3, 199, 3, 30960, 20596, 446, 88, 11814, 63, 344, 29, 17, 10754, 435, 17, 199, 3, 199, 3, 370, 1347, 11814, 413, 367, 314, 8367, 14, 199, 888, 63, 10810, 63, 344, 275, 1067, 14, 888, 14, 362, 63, 973, 63, 1422, 360, 10810, 63, 344, 358, 199, 88, 63, 10810, 63, 344, 275, 1067, 14, 362, 63, 88, 63, 2094, 8, 305, 63, 9086, 29, 549, 680, 362, 8, 272, 283, 10810, 63, 344, 358, 199, 199, 692, 1101, 63, 10810, 63, 344, 365, 440, 488, 26, 272, 11814, 63, 344, 275, 1109, 8, 888, 63, 10810, 63, 344, 9, 199, 4164, 671, 63, 10810, 63, 344, 365, 440, 488, 26, 272, 11814, 63, 344, 275, 1109, 8, 88, 63, 10810, 63, 344, 9, 199, 2836, 26, 272, 746, 1722, 360, 1944, 11814, 63, 344, 365, 7526, 367, 8367, 27, 283, 2151, 283, 1065, 658, 1895, 20596, 446, 88, 11814, 63, 344, 18987, 1375, 11814, 1305, 30, 10754, 435, 17, 64, 358, 421, 199, 318, 1255, 63, 7685, 63, 18430, 837, 272, 408, 2540, 6180, 315, 283, 18430, 7, 818, 14, 339, 961, 1101, 1482, 314, 1067, 543, 2951, 282, 2851, 272, 436, 440, 376, 12580, 12, 10617, 376, 12580, 365, 14712, 272, 2348, 465, 5521, 14, 221, 4885, 16068, 314, 12580, 7143, 272, 781, 2793, 1133, 2755, 1929, 282, 27980, 370, 506, 2808, 14, 339, 28055, 370, 1067, 14, 2526, 342, 2348, 8689, 314, 1627, 1059, 370, 314, 272, 2884, 1072, 14, 339, 408, 272, 6869, 63, 2609, 275, 12580, 2988, 8, 888, 14, 362, 63, 2427, 360, 17873, 63, 23775, 659, 3521, 1101, 14, 362, 63, 2427, 360, 17873, 63, 28164, 659, 3521, 2387, 63, 7011, 29, 549, 9, 272, 6869, 275, 6869, 63, 2609, 14, 30378, 59, 10810, 63, 344, 61, 272, 1067, 14, 6472, 8, 3908, 29, 3908, 12, 1166, 29, 3908, 14, 633, 9, 339, 543, 1067, 14, 5037, 63, 5945, 837, 267, 1067, 14, 1065, 63, 7685, 342, 421, 199, 318, 1255, 63, 7685, 63, 15178, 837, 272, 408, 2540, 6180, 315, 283, 15178, 7, 818, 14, 339, 1010, 642, 15728, 781, 1929, 370, 1218, 376, 12580, 272, 436, 20133, 282, 1950, 543, 314, 1067, 14, 339, 408, 272, 6869, 63, 2609, 275, 12580, 2988, 8, 888, 14, 362, 63, 2427, 360, 17873, 63, 23775, 659, 3521, 1101, 14, 362, 63, 2427, 360, 17873, 63, 28164, 659, 3521, 2387, 63, 7011, 29, 549, 9, 339, 6869, 275, 6869, 63, 2609, 14, 30378, 59, 10810, 63, 344, 61, 272, 1950, 275, 6869, 14, 2242, 342, 272, 327, 2494, 31648, 4650, 3618, 2653, 574, 14, 272, 1950, 14, 2526, 360, 3597, 13365, 831, 63, 2573, 63, 2593, 29, 1046, 358, 272, 1067, 14, 6472, 8, 267, 1950, 29, 2105, 12, 267, 1347, 63, 2343, 29, 1375, 63, 2343, 272, 776, 339, 862, 26, 267, 543, 1067, 14, 5037, 63, 5945, 837, 288, 1067, 14, 1065, 63, 7685, 342, 272, 3753, 26, 267, 1950, 14, 1600, 342, 199, 199, 692, 1067, 14, 374, 63, 18430, 63, 632, 837, 272, 1255, 63, 7685, 63, 18430, 342, 199, 2836, 26, 272, 1255, 63, 7685, 63, 15178, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 543, 63, 6242, 199, 504, 30960, 20596, 492, 1067, 199, 199, 504, 2050, 14, 888, 492, 570, 2028, 199, 199, 3, 6551, 25133, 314, 1101, 570, 367, 2018, 2050, 14, 199, 3, 961, 1004, 5951, 1536, 23445, 26014, 14, 199, 493, 2028, 8, 1100, 14, 888, 14, 888, 63, 493, 63, 354, 9, 199, 199, 3, 1050, 2195, 1402, 1159, 24905, 909, 2348, 199, 3, 367, 283, 6898, 974, 22978, 7, 2291, 199, 3, 687, 3002, 571, 492, 3002, 1238, 199, 504, 315, 1977, 14, 992, 14, 1095, 492, 18027, 10878, 1563, 199, 1375, 63, 2343, 275, 18027, 10878, 1563, 14, 2343, 199, 199, 504, 315, 1977, 14, 888, 492, 1101, 199, 504, 315, 1977, 14, 1030, 15415, 492, 12580, 2988, 421, 199, 3, 6832, 20596, 2897, 365, 3743, 4941, 14, 11842, 781, 3648, 367, 282, 11814, 1305, 3865, 465, 282, 199, 3, 298, 973, 945, 2, 334, 4509, 652, 1159, 2240, 17174, 663, 701, 2517, 15, 981, 13, 697, 395, 436, 315, 314, 199, 3, 298, 88, 2, 1423, 12, 1314, 365, 314, 5062, 21395, 367, 9476, 4722, 199, 3, 1414, 13, 604, 1249, 370, 30960, 20596, 14, 2002, 1265, 3955, 886, 325, 14, 71, 14, 199, 3, 199, 3, 30960, 20596, 446, 88, 11814, 63, 344, 29, 17, 10754, 435, 17, 199, 3, 199, 3, 370, 1347, 11814, 413, 367, 314, 8367, 14, 199, 888, 63, 10810, 63, 344, 275, 1067, 14, 888, 14, 362, 63, 973, 63, 1422, 360, 10810, 63, 344, 358, 199, 88, 63, 10810, 63, 344, 275, 1067, 14, 362, 63, 88, 63, 2094, 8, 305, 63, 9086, 29, 549, 680, 362, 8, 272, 283, 10810, 63, 344, 358, 199, 199, 692, 1101, 63, 10810, 63, 344, 365, 440, 488, 26, 272, 11814, 63, 344, 275, 1109, 8, 888, 63, 10810, 63, 344, 9, 199, 4164, 671, 63, 10810, 63, 344, 365, 440, 488, 26, 272, 11814, 63, 344, 275, 1109, 8, 88, 63, 10810, 63, 344, 9, 199, 2836, 26, 272, 746, 1722, 360, 1944, 11814, 63, 344, 365, 7526, 367, 8367, 27, 283, 2151, 283, 1065, 658, 1895, 20596, 446, 88, 11814, 63, 344, 18987, 1375, 11814, 1305, 30, 10754, 435, 17, 64, 358, 421, 199, 318, 1255, 63, 7685, 63, 18430, 837, 272, 408, 2540, 6180, 315, 283, 18430, 7, 818, 14, 339, 961, 1101, 1482, 314, 1067, 543, 2951, 282, 2851, 272, 436, 440, 376, 12580, 12, 10617, 376, 12580, 365, 14712, 272, 2348, 465, 5521, 14, 221, 4885, 16068, 314, 12580, 7143, 272, 781, 2793, 1133, 2755, 1929, 282, 27980, 370, 506, 2808, 14, 339, 28055, 370, 1067, 14, 2526, 342, 2348, 8689, 314, 1627, 1059, 370, 314, 272, 2884, 1072, 14, 339, 408, 272, 6869, 63, 2609, 275, 12580, 2988, 8, 888, 14, 362, 63, 2427, 360, 17873, 63, 23775, 659, 3521, 1101, 14, 362, 63, 2427, 360, 17873, 63, 28164, 659, 3521, 2387, 63, 7011, 29, 549, 9, 272, 6869, 275, 6869, 63, 2609, 14, 30378, 59, 10810, 63, 344, 61, 272, 1067, 14, 6472, 8, 3908, 29, 3908, 12, 1166, 29, 3908, 14, 633, 9, 339, 543, 1067, 14, 5037, 63, 5945, 837, 267, 1067, 14, 1065, 63, 7685, 342, 421, 199, 318, 1255, 63, 7685, 63, 15178, 837, 272, 408, 2540, 6180, 315, 283, 15178, 7, 818, 14, 339, 1010, 642, 15728, 781, 1929, 370, 1218, 376, 12580, 272, 436, 20133, 282, 1950, 543, 314, 1067, 14, 339, 408, 272, 6869, 63, 2609, 275, 12580, 2988, 8, 888, 14, 362, 63, 2427, 360, 17873, 63, 23775, 659, 3521, 1101, 14, 362, 63, 2427, 360, 17873, 63, 28164, 659, 3521, 2387, 63, 7011, 29, 549, 9, 339, 6869, 275, 6869, 63, 2609, 14, 30378, 59, 10810, 63, 344, 61, 272, 1950, 275, 6869, 14, 2242, 342, 272, 327, 2494, 31648, 4650, 3618, 2653, 574, 14, 272, 1950, 14, 2526, 360, 3597, 13365, 831, 63, 2573, 63, 2593, 29, 1046, 358, 272, 1067, 14, 6472, 8, 267, 1950, 29, 2105, 12, 267, 1347, 63, 2343, 29, 1375, 63, 2343, 272, 776, 339, 862, 26, 267, 543, 1067, 14, 5037, 63, 5945, 837, 288, 1067, 14, 1065, 63, 7685, 342, 272, 3753, 26, 267, 1950, 14, 1600, 342, 199, 199, 692, 1067, 14, 374, 63, 18430, 63, 632, 837, 272, 1255, 63, 7685, 63, 18430, 342, 199, 2836, 26, 272, 1255, 63, 7685, 63, 15178, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
nens/threedi-qgis-plugin
tests/test_geo_utils.py
1
1446
""" Test geo utils. """ from qgis.core import QgsCoordinateTransform from ThreeDiToolbox.tests.utilities import ensure_qgis_app_is_initialized from ThreeDiToolbox.utils.geo_utils import get_coord_transformation_instance import pytest @pytest.fixture def rdnew_to_wgs84(): ensure_qgis_app_is_initialized() src_epsg, dest_epsg = 28992, 4326 transformer = get_coord_transformation_instance(src_epsg, dest_epsg) return transformer @pytest.fixture def wgs84_to_rdnew(): ensure_qgis_app_is_initialized() src_epsg, dest_epsg = 4326, 28992 transformer = get_coord_transformation_instance(src_epsg, dest_epsg) return transformer def test_get_coord_transformation_instance(rdnew_to_wgs84, wgs84_to_rdnew): assert isinstance(rdnew_to_wgs84, QgsCoordinateTransform) assert isinstance(wgs84_to_rdnew, QgsCoordinateTransform) def test_get_coord_transformation_epsg(rdnew_to_wgs84): assert rdnew_to_wgs84.sourceCrs().isValid() assert rdnew_to_wgs84.sourceCrs().authid() == "EPSG:28992" assert rdnew_to_wgs84.destinationCrs().isValid() assert rdnew_to_wgs84.destinationCrs().authid() == "EPSG:4326" def test_get_coord_transformation_epsg_reverse(wgs84_to_rdnew): assert wgs84_to_rdnew.sourceCrs().isValid() assert wgs84_to_rdnew.sourceCrs().authid() == "EPSG:4326" assert wgs84_to_rdnew.destinationCrs().isValid() assert wgs84_to_rdnew.destinationCrs().authid() == "EPSG:28992"
gpl-3.0
[ 624, 199, 774, 8509, 3778, 14, 199, 624, 199, 199, 504, 15640, 14, 1018, 492, 4888, 18017, 6939, 199, 504, 30467, 1341, 5157, 1977, 14, 2219, 14, 16355, 492, 4868, 63, 25325, 63, 571, 63, 374, 63, 12486, 199, 504, 30467, 1341, 5157, 1977, 14, 1208, 14, 6721, 63, 1208, 492, 664, 63, 7988, 63, 31400, 63, 842, 199, 199, 646, 4613, 421, 199, 32, 4462, 14, 5997, 199, 318, 11517, 1222, 63, 475, 63, 87, 458, 1349, 837, 272, 4868, 63, 25325, 63, 571, 63, 374, 63, 12486, 342, 272, 2928, 63, 8277, 71, 12, 2053, 63, 8277, 71, 275, 7294, 16544, 12, 26719, 272, 21484, 275, 664, 63, 7988, 63, 31400, 63, 842, 8, 2164, 63, 8277, 71, 12, 2053, 63, 8277, 71, 9, 272, 372, 21484, 421, 199, 32, 4462, 14, 5997, 199, 318, 336, 458, 1349, 63, 475, 63, 6883, 1222, 837, 272, 4868, 63, 25325, 63, 571, 63, 374, 63, 12486, 342, 272, 2928, 63, 8277, 71, 12, 2053, 63, 8277, 71, 275, 26719, 12, 7294, 16544, 272, 21484, 275, 664, 63, 7988, 63, 31400, 63, 842, 8, 2164, 63, 8277, 71, 12, 2053, 63, 8277, 71, 9, 272, 372, 21484, 421, 199, 318, 511, 63, 362, 63, 7988, 63, 31400, 63, 842, 8, 6883, 1222, 63, 475, 63, 87, 458, 1349, 12, 336, 458, 1349, 63, 475, 63, 6883, 1222, 304, 272, 702, 1228, 8, 6883, 1222, 63, 475, 63, 87, 458, 1349, 12, 4888, 18017, 6939, 9, 272, 702, 1228, 8, 87, 458, 1349, 63, 475, 63, 6883, 1222, 12, 4888, 18017, 6939, 9, 421, 199, 318, 511, 63, 362, 63, 7988, 63, 31400, 63, 8277, 71, 8, 6883, 1222, 63, 475, 63, 87, 458, 1349, 304, 272, 702, 11517, 1222, 63, 475, 63, 87, 458, 1349, 14, 1365, 35, 2393, 1252, 18728, 342, 272, 702, 11517, 1222, 63, 475, 63, 87, 458, 1349, 14, 1365, 35, 2393, 1252, 1178, 344, 342, 508, 298, 19672, 26, 1651, 16544, 2, 272, 702, 11517, 1222, 63, 475, 63, 87, 458, 1349, 14, 6881, 35, 2393, 1252, 18728, 342, 272, 702, 11517, 1222, 63, 475, 63, 87, 458, 1349, 14, 6881, 35, 2393, 1252, 1178, 344, 342, 508, 298, 19672, 26, 17948, 2, 421, 199, 318, 511, 63, 362, 63, 7988, 63, 31400, 63, 8277, 71, 63, 4471, 8, 87, 458, 1349, 63, 475, 63, 6883, 1222, 304, 272, 702, 336, 458, 1349, 63, 475, 63, 6883, 1222, 14, 1365, 35, 2393, 1252, 18728, 342, 272, 702, 336, 458, 1349, 63, 475, 63, 6883, 1222, 14, 1365, 35, 2393, 1252, 1178, 344, 342, 508, 298, 19672, 26, 17948, 2, 272, 702, 336, 458, 1349, 63, 475, 63, 6883, 1222, 14, 6881, 35, 2393, 1252, 18728, 342, 272, 702, 336, 458, 1349, 63, 475, 63, 6883, 1222, 14, 6881, 35, 2393, 1252, 1178, 344, 342, 508, 298, 19672, 26, 1651, 16544, 2, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 774, 8509, 3778, 14, 199, 624, 199, 199, 504, 15640, 14, 1018, 492, 4888, 18017, 6939, 199, 504, 30467, 1341, 5157, 1977, 14, 2219, 14, 16355, 492, 4868, 63, 25325, 63, 571, 63, 374, 63, 12486, 199, 504, 30467, 1341, 5157, 1977, 14, 1208, 14, 6721, 63, 1208, 492, 664, 63, 7988, 63, 31400, 63, 842, 199, 199, 646, 4613, 421, 199, 32, 4462, 14, 5997, 199, 318, 11517, 1222, 63, 475, 63, 87, 458, 1349, 837, 272, 4868, 63, 25325, 63, 571, 63, 374, 63, 12486, 342, 272, 2928, 63, 8277, 71, 12, 2053, 63, 8277, 71, 275, 7294, 16544, 12, 26719, 272, 21484, 275, 664, 63, 7988, 63, 31400, 63, 842, 8, 2164, 63, 8277, 71, 12, 2053, 63, 8277, 71, 9, 272, 372, 21484, 421, 199, 32, 4462, 14, 5997, 199, 318, 336, 458, 1349, 63, 475, 63, 6883, 1222, 837, 272, 4868, 63, 25325, 63, 571, 63, 374, 63, 12486, 342, 272, 2928, 63, 8277, 71, 12, 2053, 63, 8277, 71, 275, 26719, 12, 7294, 16544, 272, 21484, 275, 664, 63, 7988, 63, 31400, 63, 842, 8, 2164, 63, 8277, 71, 12, 2053, 63, 8277, 71, 9, 272, 372, 21484, 421, 199, 318, 511, 63, 362, 63, 7988, 63, 31400, 63, 842, 8, 6883, 1222, 63, 475, 63, 87, 458, 1349, 12, 336, 458, 1349, 63, 475, 63, 6883, 1222, 304, 272, 702, 1228, 8, 6883, 1222, 63, 475, 63, 87, 458, 1349, 12, 4888, 18017, 6939, 9, 272, 702, 1228, 8, 87, 458, 1349, 63, 475, 63, 6883, 1222, 12, 4888, 18017, 6939, 9, 421, 199, 318, 511, 63, 362, 63, 7988, 63, 31400, 63, 8277, 71, 8, 6883, 1222, 63, 475, 63, 87, 458, 1349, 304, 272, 702, 11517, 1222, 63, 475, 63, 87, 458, 1349, 14, 1365, 35, 2393, 1252, 18728, 342, 272, 702, 11517, 1222, 63, 475, 63, 87, 458, 1349, 14, 1365, 35, 2393, 1252, 1178, 344, 342, 508, 298, 19672, 26, 1651, 16544, 2, 272, 702, 11517, 1222, 63, 475, 63, 87, 458, 1349, 14, 6881, 35, 2393, 1252, 18728, 342, 272, 702, 11517, 1222, 63, 475, 63, 87, 458, 1349, 14, 6881, 35, 2393, 1252, 1178, 344, 342, 508, 298, 19672, 26, 17948, 2, 421, 199, 318, 511, 63, 362, 63, 7988, 63, 31400, 63, 8277, 71, 63, 4471, 8, 87, 458, 1349, 63, 475, 63, 6883, 1222, 304, 272, 702, 336, 458, 1349, 63, 475, 63, 6883, 1222, 14, 1365, 35, 2393, 1252, 18728, 342, 272, 702, 336, 458, 1349, 63, 475, 63, 6883, 1222, 14, 1365, 35, 2393, 1252, 1178, 344, 342, 508, 298, 19672, 26, 17948, 2, 272, 702, 336, 458, 1349, 63, 475, 63, 6883, 1222, 14, 6881, 35, 2393, 1252, 18728, 342, 272, 702, 336, 458, 1349, 63, 475, 63, 6883, 1222, 14, 6881, 35, 2393, 1252, 1178, 344, 342, 508, 298, 19672, 26, 1651, 16544, 2, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
xfournet/intellij-community
python/lib/Lib/unicodedata.py
69
6437
from bisect import bisect_left import operator import java.lang.Character # XXX - this is intended as a stopgap measure until 2.5.1, which will have a Java implementation # requires java 6 for `normalize` function # only has one version of the database # does not normalized ideographs _codepoints = {} _eaw = {} _names = {} _segments = [] _eaw_segments = [] Nonesuch = object() def get_int(col): try: return int(col) except ValueError: return None def get_yn(col): if col == 'Y': return 1 else: return 0 def get_numeric(col): try: return float(col) except ValueError: try: a, b = col.split('/') return float(a)/float(b) except: return None def init_unicodedata(data): for row in data: cols = row.split(';') codepoint = int(cols[0], 16) name = cols[1] if name == '<CJK Ideograph, Last>': lookup_name = 'CJK UNIFIED IDEOGRAPH' else: lookup_name = name data = ( cols[2], get_int(cols[3]), cols[4], cols[5], get_int(cols[6]), get_int(cols[7]), get_numeric(cols[8]), get_yn(cols[9]), lookup_name, ) if name.find('First') >= 0: start = codepoint elif name.find('Last') >= 0: _segments.append((start, (start, codepoint), data)) else: _names[name] = unichr(codepoint) _codepoints[codepoint] = data def init_east_asian_width(data): for row in data: if row.startswith('#'): continue row = row.partition('#')[0] cols = row.split(';') if len(cols) < 2: continue cr = cols[0].split('..') width = cols[1].rstrip() if len(cr) == 1: codepoint = int(cr[0], 16) _eaw[codepoint] = width else: start = int(cr[0], 16) end = int(cr[1], 16) _eaw_segments.append((start, (start, end), width)) # xxx - need to normalize the segments, so # <CJK Ideograph, Last> ==> CJK UNIFIED IDEOGRAPH; # may need to do some sort of analysis against CPython for the normalization! def name(unichr, default=None): codepoint = get_codepoint(unichr, "name") v = _codepoints.get(codepoint, None) if v is None: v = check_segments(codepoint, _segments) if v is not None: return "%s-%X" % (v[8], codepoint) if v is None: if default is not Nonesuch: return default raise ValueError() return v[8] # xxx - also need to add logic here so that if it's CJK UNIFIED # IDEOGRAPH-8000, we go against the segment to verify the prefix def lookup(name): return _names[name] def check_segments(codepoint, segments): i = bisect_left(segments, (codepoint,)) if i < len(segments): segment = segments[i - 1] if codepoint <= segment[1][1]: return segment[2] return None def get_codepoint(unichr, fn=None): if not(isinstance(unichr, unicode)): raise TypeError(fn, "() argument 1 must be unicode, not " + type(unichr)) if len(unichr) > 1 or len(unichr) == 0: raise TypeError("need a single Unicode character as parameter") return ord(unichr) def get_eaw(unichr, default, fn): codepoint = get_codepoint(unichr, fn) v = _eaw.get(codepoint, None) if v is None: v = check_segments(codepoint, _eaw_segments) if v is None: if default is not Nonesuch: return default raise ValueError() return v def get(unichr, default, fn, getter): codepoint = get_codepoint(unichr, fn) data = _codepoints.get(codepoint, None) if data is None: data = check_segments(codepoint, _segments) if data is None: if default is not Nonesuch: return default raise ValueError() v = getter(data) if v is None: if default is not Nonesuch: return default raise ValueError() else: return v category_getter = operator.itemgetter(0) combining_getter = operator.itemgetter(1) bidirectional_getter = operator.itemgetter(2) decomposition_getter = operator.itemgetter(3) decimal_getter = operator.itemgetter(4) digit_getter = operator.itemgetter(5) numeric_getter = operator.itemgetter(6) mirrored_getter = operator.itemgetter(7) def decimal(unichr, default=Nonesuch): return get(unichr, default, 'decimal', decimal_getter) def decomposition(unichr, default=''): return get(unichr, default, 'decomposition', decomposition_getter) def digit(unichr, default=Nonesuch): return get(unichr, default, 'digit', digit_getter) def numeric(unichr, default=Nonesuch): return get(unichr, default, 'numeric', numeric_getter) def category(unichr): return get(unichr, 'Cn', 'catgegory', category_getter) def bidirectional(unichr): return get(unichr, '', 'bidirectional', bidirectional_getter) def combining(unichr): return get(unichr, 0, 'combining', combining_getter) def mirrored(unichr): return get(unichr, 0, 'mirrored', mirrored_getter) def east_asian_width(unichr): return get_eaw(unichr, 'N', 'east_asian_width') def jymirrored(unichr): return java.lang.Character.isMirrored(get_codepoint(unichr, 'mirrored')) try: from java.text import Normalizer _forms = { 'NFC': Normalizer.Form.NFC, 'NFKC': Normalizer.Form.NFKC, 'NFD': Normalizer.Form.NFD, 'NFKD': Normalizer.Form.NFKD } def normalize(form, unistr): """ Return the normal form 'form' for the Unicode string unistr. Valid values for form are 'NFC', 'NFKC', 'NFD', and 'NFKD'. """ try: normalizer_form = _forms[form] except KeyError: raise ValueError('invalid normalization form') return Normalizer.normalize(unistr, normalizer_form) except ImportError: pass def init(): import pkgutil import os.path import StringIO import sys my_path = os.path.dirname(__file__) loader = pkgutil.get_loader('unicodedata') init_unicodedata(StringIO.StringIO(loader.get_data(os.path.join(my_path, 'UnicodeData.txt')))) init_east_asian_width(StringIO.StringIO(loader.get_data(os.path.join(my_path, 'EastAsianWidth.txt')))) init()
apache-2.0
[ 504, 19063, 492, 19063, 63, 3039, 199, 646, 4182, 199, 646, 12120, 14, 4159, 14, 14852, 199, 199, 3, 5787, 446, 642, 365, 11619, 465, 282, 3631, 15046, 9775, 5133, 499, 14, 21, 14, 17, 12, 1314, 911, 1172, 282, 9586, 4514, 199, 3, 5074, 12120, 1227, 367, 658, 7721, 64, 805, 199, 3, 1454, 965, 1373, 1015, 402, 314, 3050, 199, 3, 1630, 440, 9657, 284, 2172, 16670, 199, 199, 63, 600, 3438, 275, 1052, 199, 63, 4489, 87, 275, 1052, 199, 63, 1247, 275, 1052, 199, 63, 13879, 275, 942, 199, 63, 4489, 87, 63, 13879, 275, 942, 199, 403, 10180, 275, 909, 342, 199, 199, 318, 664, 63, 442, 8, 761, 304, 272, 862, 26, 267, 372, 1109, 8, 761, 9, 272, 871, 1722, 26, 267, 372, 488, 199, 199, 318, 664, 63, 1236, 8, 761, 304, 272, 340, 1048, 508, 283, 57, 356, 372, 413, 272, 587, 26, 372, 378, 199, 199, 318, 664, 63, 6677, 8, 761, 304, 272, 862, 26, 267, 372, 2069, 8, 761, 9, 272, 871, 1722, 26, 267, 862, 26, 288, 282, 12, 330, 275, 1048, 14, 1294, 7825, 288, 372, 2069, 8, 65, 2447, 1609, 8, 66, 9, 267, 871, 26, 288, 372, 488, 199, 199, 318, 4205, 63, 2975, 576, 8, 576, 304, 272, 367, 1962, 315, 666, 26, 267, 8850, 275, 1962, 14, 1294, 26468, 267, 1233, 1403, 275, 1109, 8, 4574, 59, 16, 467, 3193, 9, 267, 536, 275, 8850, 59, 17, 61, 267, 340, 536, 508, 2650, 35, 25575, 473, 2172, 2180, 12, 15237, 30838, 288, 4237, 63, 354, 275, 283, 35, 25575, 6778, 31223, 473, 1093, 17275, 21126, 7, 267, 587, 26, 288, 4237, 63, 354, 275, 536, 267, 666, 275, 334, 288, 8850, 59, 18, 467, 288, 664, 63, 442, 8, 4574, 59, 19, 2522, 288, 8850, 59, 20, 467, 288, 8850, 59, 21, 467, 288, 664, 63, 442, 8, 4574, 59, 22, 2522, 288, 664, 63, 442, 8, 4574, 59, 23, 2522, 288, 664, 63, 6677, 8, 4574, 59, 24, 2522, 288, 664, 63, 1236, 8, 4574, 59, 25, 2522, 288, 4237, 63, 354, 12, 288, 776, 398, 340, 536, 14, 1623, 360, 7147, 358, 2356, 378, 26, 288, 1343, 275, 1233, 1403, 267, 916, 536, 14, 1623, 360, 6090, 358, 2356, 378, 26, 288, 485, 13879, 14, 740, 1332, 928, 12, 334, 928, 12, 1233, 1403, 395, 666, 430, 267, 587, 26, 288, 485, 1247, 59, 354, 61, 275, 17742, 8, 19300, 9, 288, 485, 600, 3438, 59, 19300, 61, 275, 666, 199, 199, 318, 4205, 63, 14346, 63, 305, 5653, 63, 2063, 8, 576, 304, 272, 367, 1962, 315, 666, 26, 267, 340, 1962, 14, 2460, 7863, 735, 288, 1980, 267, 1962, 275, 1962, 14, 5312, 7863, 5832, 16, 61, 267, 8850, 275, 1962, 14, 1294, 26468, 267, 340, 822, 8, 4574, 9, 665, 499, 26, 288, 1980, 267, 2467, 275, 8850, 59, 16, 1055, 1294, 24893, 358, 267, 3462, 275, 8850, 59, 17, 1055, 6735, 342, 267, 340, 822, 8, 1556, 9, 508, 413, 26, 288, 1233, 1403, 275, 1109, 8, 1556, 59, 16, 467, 3193, 9, 288, 485, 4489, 87, 59, 19300, 61, 275, 3462, 267, 587, 26, 288, 1343, 275, 1109, 8, 1556, 59, 16, 467, 3193, 9, 288, 1284, 275, 1109, 8, 1556, 59, 17, 467, 3193, 9, 288, 485, 4489, 87, 63, 13879, 14, 740, 1332, 928, 12, 334, 928, 12, 1284, 395, 3462, 430, 199, 199, 3, 26571, 446, 1929, 370, 7666, 314, 11998, 12, 880, 199, 3, 665, 35, 25575, 473, 2172, 2180, 12, 15237, 30, 25375, 445, 25575, 6778, 31223, 473, 1093, 17275, 21126, 27, 199, 3, 1443, 1929, 370, 886, 2005, 4069, 402, 11284, 6169, 25654, 367, 314, 16973, 1, 199, 199, 318, 536, 8, 324, 15257, 12, 849, 29, 403, 304, 272, 1233, 1403, 275, 664, 63, 19300, 8, 324, 15257, 12, 298, 354, 531, 272, 373, 275, 485, 600, 3438, 14, 362, 8, 19300, 12, 488, 9, 272, 340, 373, 365, 488, 26, 267, 373, 275, 1104, 63, 13879, 8, 19300, 12, 485, 13879, 9, 267, 340, 373, 365, 440, 488, 26, 288, 372, 2071, 83, 3295, 56, 2, 450, 334, 86, 59, 24, 467, 1233, 1403, 9, 339, 340, 373, 365, 488, 26, 267, 340, 849, 365, 440, 488, 10180, 26, 288, 372, 849, 267, 746, 1722, 342, 272, 372, 373, 59, 24, 61, 199, 199, 3, 26571, 446, 2597, 1929, 370, 1050, 9661, 2348, 880, 626, 340, 652, 1159, 445, 25575, 6778, 31223, 199, 3, 473, 1093, 17275, 21126, 13, 15214, 12, 781, 2621, 6169, 314, 8135, 370, 4911, 314, 2403, 199, 199, 318, 4237, 8, 354, 304, 272, 372, 485, 1247, 59, 354, 61, 199, 199, 318, 1104, 63, 13879, 8, 19300, 12, 11998, 304, 272, 284, 275, 19063, 63, 3039, 8, 13879, 12, 334, 19300, 4641, 272, 340, 284, 665, 822, 8, 13879, 304, 267, 8135, 275, 11998, 59, 73, 446, 413, 61, 267, 340, 1233, 1403, 2695, 8135, 59, 17, 1527, 17, 2189, 288, 372, 8135, 59, 18, 61, 272, 372, 488, 421, 199, 318, 664, 63, 19300, 8, 324, 15257, 12, 4325, 29, 403, 304, 272, 340, 440, 8, 6074, 8, 324, 15257, 12, 2649, 2298, 267, 746, 3146, 8, 2324, 12, 298, 342, 1423, 413, 1471, 506, 2649, 12, 440, 298, 435, 730, 8, 324, 15257, 430, 272, 340, 822, 8, 324, 15257, 9, 690, 413, 503, 822, 8, 324, 15257, 9, 508, 378, 26, 267, 746, 3146, 480, 9321, 282, 2849, 6140, 4528, 465, 2725, 531, 272, 372, 6206, 8, 324, 15257, 9, 199, 199, 318, 664, 63, 4489, 87, 8, 324, 15257, 12, 849, 12, 4325, 304, 272, 1233, 1403, 275, 664, 63, 19300, 8, 324, 15257, 12, 4325, 9, 272, 373, 275, 485, 4489, 87, 14, 362, 8, 19300, 12, 488, 9, 272, 340, 373, 365, 488, 26, 267, 373, 275, 1104, 63, 13879, 8, 19300, 12, 485, 4489, 87, 63, 13879, 9, 339, 340, 373, 365, 488, 26, 267, 340, 849, 365, 440, 488, 10180, 26, 288, 372, 849, 267, 746, 1722, 342, 272, 372, 373, 199, 199, 318, 664, 8, 324, 15257, 12, 849, 12, 4325, 12, 15917, 304, 272, 1233, 1403 ]
[ 19063, 492, 19063, 63, 3039, 199, 646, 4182, 199, 646, 12120, 14, 4159, 14, 14852, 199, 199, 3, 5787, 446, 642, 365, 11619, 465, 282, 3631, 15046, 9775, 5133, 499, 14, 21, 14, 17, 12, 1314, 911, 1172, 282, 9586, 4514, 199, 3, 5074, 12120, 1227, 367, 658, 7721, 64, 805, 199, 3, 1454, 965, 1373, 1015, 402, 314, 3050, 199, 3, 1630, 440, 9657, 284, 2172, 16670, 199, 199, 63, 600, 3438, 275, 1052, 199, 63, 4489, 87, 275, 1052, 199, 63, 1247, 275, 1052, 199, 63, 13879, 275, 942, 199, 63, 4489, 87, 63, 13879, 275, 942, 199, 403, 10180, 275, 909, 342, 199, 199, 318, 664, 63, 442, 8, 761, 304, 272, 862, 26, 267, 372, 1109, 8, 761, 9, 272, 871, 1722, 26, 267, 372, 488, 199, 199, 318, 664, 63, 1236, 8, 761, 304, 272, 340, 1048, 508, 283, 57, 356, 372, 413, 272, 587, 26, 372, 378, 199, 199, 318, 664, 63, 6677, 8, 761, 304, 272, 862, 26, 267, 372, 2069, 8, 761, 9, 272, 871, 1722, 26, 267, 862, 26, 288, 282, 12, 330, 275, 1048, 14, 1294, 7825, 288, 372, 2069, 8, 65, 2447, 1609, 8, 66, 9, 267, 871, 26, 288, 372, 488, 199, 199, 318, 4205, 63, 2975, 576, 8, 576, 304, 272, 367, 1962, 315, 666, 26, 267, 8850, 275, 1962, 14, 1294, 26468, 267, 1233, 1403, 275, 1109, 8, 4574, 59, 16, 467, 3193, 9, 267, 536, 275, 8850, 59, 17, 61, 267, 340, 536, 508, 2650, 35, 25575, 473, 2172, 2180, 12, 15237, 30838, 288, 4237, 63, 354, 275, 283, 35, 25575, 6778, 31223, 473, 1093, 17275, 21126, 7, 267, 587, 26, 288, 4237, 63, 354, 275, 536, 267, 666, 275, 334, 288, 8850, 59, 18, 467, 288, 664, 63, 442, 8, 4574, 59, 19, 2522, 288, 8850, 59, 20, 467, 288, 8850, 59, 21, 467, 288, 664, 63, 442, 8, 4574, 59, 22, 2522, 288, 664, 63, 442, 8, 4574, 59, 23, 2522, 288, 664, 63, 6677, 8, 4574, 59, 24, 2522, 288, 664, 63, 1236, 8, 4574, 59, 25, 2522, 288, 4237, 63, 354, 12, 288, 776, 398, 340, 536, 14, 1623, 360, 7147, 358, 2356, 378, 26, 288, 1343, 275, 1233, 1403, 267, 916, 536, 14, 1623, 360, 6090, 358, 2356, 378, 26, 288, 485, 13879, 14, 740, 1332, 928, 12, 334, 928, 12, 1233, 1403, 395, 666, 430, 267, 587, 26, 288, 485, 1247, 59, 354, 61, 275, 17742, 8, 19300, 9, 288, 485, 600, 3438, 59, 19300, 61, 275, 666, 199, 199, 318, 4205, 63, 14346, 63, 305, 5653, 63, 2063, 8, 576, 304, 272, 367, 1962, 315, 666, 26, 267, 340, 1962, 14, 2460, 7863, 735, 288, 1980, 267, 1962, 275, 1962, 14, 5312, 7863, 5832, 16, 61, 267, 8850, 275, 1962, 14, 1294, 26468, 267, 340, 822, 8, 4574, 9, 665, 499, 26, 288, 1980, 267, 2467, 275, 8850, 59, 16, 1055, 1294, 24893, 358, 267, 3462, 275, 8850, 59, 17, 1055, 6735, 342, 267, 340, 822, 8, 1556, 9, 508, 413, 26, 288, 1233, 1403, 275, 1109, 8, 1556, 59, 16, 467, 3193, 9, 288, 485, 4489, 87, 59, 19300, 61, 275, 3462, 267, 587, 26, 288, 1343, 275, 1109, 8, 1556, 59, 16, 467, 3193, 9, 288, 1284, 275, 1109, 8, 1556, 59, 17, 467, 3193, 9, 288, 485, 4489, 87, 63, 13879, 14, 740, 1332, 928, 12, 334, 928, 12, 1284, 395, 3462, 430, 199, 199, 3, 26571, 446, 1929, 370, 7666, 314, 11998, 12, 880, 199, 3, 665, 35, 25575, 473, 2172, 2180, 12, 15237, 30, 25375, 445, 25575, 6778, 31223, 473, 1093, 17275, 21126, 27, 199, 3, 1443, 1929, 370, 886, 2005, 4069, 402, 11284, 6169, 25654, 367, 314, 16973, 1, 199, 199, 318, 536, 8, 324, 15257, 12, 849, 29, 403, 304, 272, 1233, 1403, 275, 664, 63, 19300, 8, 324, 15257, 12, 298, 354, 531, 272, 373, 275, 485, 600, 3438, 14, 362, 8, 19300, 12, 488, 9, 272, 340, 373, 365, 488, 26, 267, 373, 275, 1104, 63, 13879, 8, 19300, 12, 485, 13879, 9, 267, 340, 373, 365, 440, 488, 26, 288, 372, 2071, 83, 3295, 56, 2, 450, 334, 86, 59, 24, 467, 1233, 1403, 9, 339, 340, 373, 365, 488, 26, 267, 340, 849, 365, 440, 488, 10180, 26, 288, 372, 849, 267, 746, 1722, 342, 272, 372, 373, 59, 24, 61, 199, 199, 3, 26571, 446, 2597, 1929, 370, 1050, 9661, 2348, 880, 626, 340, 652, 1159, 445, 25575, 6778, 31223, 199, 3, 473, 1093, 17275, 21126, 13, 15214, 12, 781, 2621, 6169, 314, 8135, 370, 4911, 314, 2403, 199, 199, 318, 4237, 8, 354, 304, 272, 372, 485, 1247, 59, 354, 61, 199, 199, 318, 1104, 63, 13879, 8, 19300, 12, 11998, 304, 272, 284, 275, 19063, 63, 3039, 8, 13879, 12, 334, 19300, 4641, 272, 340, 284, 665, 822, 8, 13879, 304, 267, 8135, 275, 11998, 59, 73, 446, 413, 61, 267, 340, 1233, 1403, 2695, 8135, 59, 17, 1527, 17, 2189, 288, 372, 8135, 59, 18, 61, 272, 372, 488, 421, 199, 318, 664, 63, 19300, 8, 324, 15257, 12, 4325, 29, 403, 304, 272, 340, 440, 8, 6074, 8, 324, 15257, 12, 2649, 2298, 267, 746, 3146, 8, 2324, 12, 298, 342, 1423, 413, 1471, 506, 2649, 12, 440, 298, 435, 730, 8, 324, 15257, 430, 272, 340, 822, 8, 324, 15257, 9, 690, 413, 503, 822, 8, 324, 15257, 9, 508, 378, 26, 267, 746, 3146, 480, 9321, 282, 2849, 6140, 4528, 465, 2725, 531, 272, 372, 6206, 8, 324, 15257, 9, 199, 199, 318, 664, 63, 4489, 87, 8, 324, 15257, 12, 849, 12, 4325, 304, 272, 1233, 1403, 275, 664, 63, 19300, 8, 324, 15257, 12, 4325, 9, 272, 373, 275, 485, 4489, 87, 14, 362, 8, 19300, 12, 488, 9, 272, 340, 373, 365, 488, 26, 267, 373, 275, 1104, 63, 13879, 8, 19300, 12, 485, 4489, 87, 63, 13879, 9, 339, 340, 373, 365, 488, 26, 267, 340, 849, 365, 440, 488, 10180, 26, 288, 372, 849, 267, 746, 1722, 342, 272, 372, 373, 199, 199, 318, 664, 8, 324, 15257, 12, 849, 12, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
keithroe/vtkoptix
ThirdParty/Twisted/twisted/test/test_ident.py
41
6029
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Test cases for twisted.protocols.ident module. """ import struct from twisted.protocols import ident from twisted.python import failure from twisted.internet import error from twisted.internet import defer from twisted.trial import unittest from twisted.test.proto_helpers import StringTransport class ClassParserTestCase(unittest.TestCase): """ Test parsing of ident responses. """ def setUp(self): """ Create a ident client used in tests. """ self.client = ident.IdentClient() def test_indentError(self): """ 'UNKNOWN-ERROR' error should map to the L{ident.IdentError} exception. """ d = defer.Deferred() self.client.queries.append((d, 123, 456)) self.client.lineReceived('123, 456 : ERROR : UNKNOWN-ERROR') return self.assertFailure(d, ident.IdentError) def test_noUSerError(self): """ 'NO-USER' error should map to the L{ident.NoUser} exception. """ d = defer.Deferred() self.client.queries.append((d, 234, 456)) self.client.lineReceived('234, 456 : ERROR : NO-USER') return self.assertFailure(d, ident.NoUser) def test_invalidPortError(self): """ 'INVALID-PORT' error should map to the L{ident.InvalidPort} exception. """ d = defer.Deferred() self.client.queries.append((d, 345, 567)) self.client.lineReceived('345, 567 : ERROR : INVALID-PORT') return self.assertFailure(d, ident.InvalidPort) def test_hiddenUserError(self): """ 'HIDDEN-USER' error should map to the L{ident.HiddenUser} exception. """ d = defer.Deferred() self.client.queries.append((d, 567, 789)) self.client.lineReceived('567, 789 : ERROR : HIDDEN-USER') return self.assertFailure(d, ident.HiddenUser) def test_lostConnection(self): """ A pending query which failed because of a ConnectionLost should receive an L{ident.IdentError}. """ d = defer.Deferred() self.client.queries.append((d, 765, 432)) self.client.connectionLost(failure.Failure(error.ConnectionLost())) return self.assertFailure(d, ident.IdentError) class TestIdentServer(ident.IdentServer): def lookup(self, serverAddress, clientAddress): return self.resultValue class TestErrorIdentServer(ident.IdentServer): def lookup(self, serverAddress, clientAddress): raise self.exceptionType() class NewException(RuntimeError): pass class ServerParserTestCase(unittest.TestCase): def testErrors(self): p = TestErrorIdentServer() p.makeConnection(StringTransport()) L = [] p.sendLine = L.append p.exceptionType = ident.IdentError p.lineReceived('123, 345') self.assertEqual(L[0], '123, 345 : ERROR : UNKNOWN-ERROR') p.exceptionType = ident.NoUser p.lineReceived('432, 210') self.assertEqual(L[1], '432, 210 : ERROR : NO-USER') p.exceptionType = ident.InvalidPort p.lineReceived('987, 654') self.assertEqual(L[2], '987, 654 : ERROR : INVALID-PORT') p.exceptionType = ident.HiddenUser p.lineReceived('756, 827') self.assertEqual(L[3], '756, 827 : ERROR : HIDDEN-USER') p.exceptionType = NewException p.lineReceived('987, 789') self.assertEqual(L[4], '987, 789 : ERROR : UNKNOWN-ERROR') errs = self.flushLoggedErrors(NewException) self.assertEqual(len(errs), 1) for port in -1, 0, 65536, 65537: del L[:] p.lineReceived('%d, 5' % (port,)) p.lineReceived('5, %d' % (port,)) self.assertEqual( L, ['%d, 5 : ERROR : INVALID-PORT' % (port,), '5, %d : ERROR : INVALID-PORT' % (port,)]) def testSuccess(self): p = TestIdentServer() p.makeConnection(StringTransport()) L = [] p.sendLine = L.append p.resultValue = ('SYS', 'USER') p.lineReceived('123, 456') self.assertEqual(L[0], '123, 456 : USERID : SYS : USER') if struct.pack('=L', 1)[0] == '\x01': _addr1 = '0100007F' _addr2 = '04030201' else: _addr1 = '7F000001' _addr2 = '01020304' class ProcMixinTestCase(unittest.TestCase): line = ('4: %s:0019 %s:02FA 0A 00000000:00000000 ' '00:00000000 00000000 0 0 10927 1 f72a5b80 ' '3000 0 0 2 -1') % (_addr1, _addr2) def testDottedQuadFromHexString(self): p = ident.ProcServerMixin() self.assertEqual(p.dottedQuadFromHexString(_addr1), '127.0.0.1') def testUnpackAddress(self): p = ident.ProcServerMixin() self.assertEqual(p.unpackAddress(_addr1 + ':0277'), ('127.0.0.1', 631)) def testLineParser(self): p = ident.ProcServerMixin() self.assertEqual( p.parseLine(self.line), (('127.0.0.1', 25), ('1.2.3.4', 762), 0)) def testExistingAddress(self): username = [] p = ident.ProcServerMixin() p.entries = lambda: iter([self.line]) p.getUsername = lambda uid: (username.append(uid), 'root')[1] self.assertEqual( p.lookup(('127.0.0.1', 25), ('1.2.3.4', 762)), (p.SYSTEM_NAME, 'root')) self.assertEqual(username, [0]) def testNonExistingAddress(self): p = ident.ProcServerMixin() p.entries = lambda: iter([self.line]) self.assertRaises(ident.NoUser, p.lookup, ('127.0.0.1', 26), ('1.2.3.4', 762)) self.assertRaises(ident.NoUser, p.lookup, ('127.0.0.1', 25), ('1.2.3.5', 762)) self.assertRaises(ident.NoUser, p.lookup, ('127.0.0.1', 25), ('1.2.3.4', 763))
bsd-3-clause
[ 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 774, 5560, 367, 7390, 14, 16541, 14, 5425, 859, 14, 199, 624, 199, 199, 646, 2702, 199, 199, 504, 7390, 14, 16541, 492, 12893, 199, 504, 7390, 14, 1548, 492, 5988, 199, 504, 7390, 14, 4901, 492, 1125, 199, 504, 7390, 14, 4901, 492, 10133, 199, 199, 504, 7390, 14, 14443, 492, 2882, 199, 504, 7390, 14, 396, 14, 2625, 63, 7546, 492, 2624, 7836, 4388, 199, 533, 8089, 2842, 1746, 8, 2796, 14, 1746, 304, 272, 408, 272, 1379, 6057, 402, 12893, 9320, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 2790, 282, 12893, 1890, 1202, 315, 2295, 14, 267, 408, 267, 291, 14, 1258, 275, 12893, 14, 41, 1326, 3041, 342, 2378, 347, 511, 63, 3724, 547, 8, 277, 304, 267, 408, 267, 283, 11588, 13, 3170, 7, 1125, 1077, 2341, 370, 314, 491, 91, 5425, 14, 41, 1326, 547, 93, 1919, 14, 267, 408, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 1258, 14, 10590, 14, 740, 1332, 68, 12, 11869, 12, 31944, 430, 267, 291, 14, 1258, 14, 604, 9392, 360, 4288, 12, 31944, 520, 12539, 520, 24740, 13, 3170, 358, 267, 372, 291, 14, 479, 6782, 8, 68, 12, 12893, 14, 41, 1326, 547, 9, 2378, 347, 511, 63, 889, 53, 1505, 547, 8, 277, 304, 267, 408, 267, 283, 2826, 13, 3791, 7, 1125, 1077, 2341, 370, 314, 491, 91, 5425, 14, 1944, 1899, 93, 1919, 14, 267, 408, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 1258, 14, 10590, 14, 740, 1332, 68, 12, 26569, 12, 31944, 430, 267, 291, 14, 1258, 14, 604, 9392, 360, 5533, 12, 31944, 520, 12539, 520, 4825, 13, 3791, 358, 267, 372, 291, 14, 479, 6782, 8, 68, 12, 12893, 14, 1944, 1899, 9, 2378, 347, 511, 63, 3197, 4313, 547, 8, 277, 304, 267, 408, 267, 283, 9692, 13, 3657, 7, 1125, 1077, 2341, 370, 314, 491, 91, 5425, 14, 3364, 4313, 93, 1919, 14, 267, 408, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 1258, 14, 10590, 14, 740, 1332, 68, 12, 30044, 12, 959, 1822, 430, 267, 291, 14, 1258, 14, 604, 9392, 360, 9908, 12, 959, 1822, 520, 221, 12539, 520, 29901, 13, 3657, 358, 267, 372, 291, 14, 479, 6782, 8, 68, 12, 12893, 14, 3364, 4313, 9, 2378, 347, 511, 63, 5642, 1899, 547, 8, 277, 304, 267, 408, 267, 283, 40, 22436, 13, 3791, 7, 1125, 1077, 2341, 370, 314, 491, 91, 5425, 14, 14983, 1899, 93, 1919, 14, 267, 408, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 1258, 14, 10590, 14, 740, 1332, 68, 12, 959, 1822, 12, 1520, 1407, 430, 267, 291, 14, 1258, 14, 604, 9392, 360, 5308, 12, 1520, 1407, 520, 12539, 520, 869, 22436, 13, 3791, 358, 267, 372, 291, 14, 479, 6782, 8, 68, 12, 12893, 14, 14983, 1899, 9, 2378, 347, 511, 63, 22031, 3225, 8, 277, 304, 267, 408, 267, 437, 9413, 1827, 1314, 3405, 2952, 402, 282, 8113, 14074, 1077, 267, 9128, 376, 491, 91, 5425, 14, 41, 1326, 547, 5565, 267, 408, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 1258, 14, 10590, 14, 740, 1332, 68, 12, 1520, 2182, 12, 841, 708, 430, 267, 291, 14, 1258, 14, 2105, 14074, 8, 5328, 14, 6782, 8, 705, 14, 3225, 14074, 4059, 267, 372, 291, 14, 479, 6782, 8, 68, 12, 12893, 14, 41, 1326, 547, 9, 4388, 199, 533, 1379, 41, 1326, 3120, 8, 5425, 14, 41, 1326, 3120, 304, 272, 347, 4237, 8, 277, 12, 1654, 1476, 12, 1890, 1476, 304, 267, 372, 291, 14, 1099, 1110, 421, 199, 533, 1379, 547, 41, 1326, 3120, 8, 5425, 14, 41, 1326, 3120, 304, 272, 347, 4237, 8, 277, 12, 1654, 1476, 12, 1890, 1476, 304, 267, 746, 291, 14, 1971, 804, 342, 421, 199, 533, 7053, 1726, 8, 13281, 304, 272, 986, 421, 199, 533, 7146, 2842, 1746, 8, 2796, 14, 1746, 304, 272, 347, 511, 9298, 8, 277, 304, 267, 299, 275, 1379, 547, 41, 1326, 3120, 342, 267, 299, 14, 1875, 3225, 8, 1558, 7836, 1012, 267, 491, 275, 942, 267, 299, 14, 2254, 3049, 275, 491, 14, 740, 398, 299, 14, 1971, 804, 275, 12893, 14, 41, 1326, 547, 267, 299, 14, 604, 9392, 360, 4288, 12, 30044, 358, 267, 291, 14, 629, 8, 44, 59, 16, 467, 283, 4288, 12, 30044, 520, 12539, 520, 24740, 13, 3170, 358, 398, 299, 14, 1971, 804, 275, 12893, 14, 1944, 1899, 267, 299, 14, 604, 9392, 360, 10657, 12, 26160, 358, 267, 291, 14, 629, 8, 44, 59, 17, 467, 283, 10657, 12, 26160, 520, 12539, 520, 4825, 13, 3791, 358, 398, 299, 14, 1971, 804, 275, 12893, 14, 3364, 4313, 267, 299, 14, 604, 9392, 360, 23358, 12, 1227, 1477, 358, 267, 291, 14, 629, 8, 44, 59, 18, 467, 283, 23358, 12, 1227, 1477, 520, 12539, 520, 29901, 13, 3657, 358, 398, 299, 14, 1971, 804, 275, 12893, 14, 14983, 1899, 267, 299, 14, 604, 9392, 360, 29152, 12, 1695, 1465, 358, 267, 291, 14, 629, 8, 44, 59, 19, 467, 283, 29152, 12, 1695, 1465, 520, 12539, 520, 869, 22436, 13, 3791, 358, 398, 299, 14, 1971, 804, 275, 7053, 1726, 267, 299, 14, 604, 9392, 360, 23358, 12, 1520, 1407, 358, 267, 291, 14, 629, 8, 44, 59, 20, 467, 283, 23358, 12, 1520, 1407, 520, 12539, 520, 24740, 13, 3170, 358, 267, 2329, 83, 275, 291, 14, 4939, 28985, 9298, 8, 4665, 1726, 9, 267, 291, 14, 629, 8, 552, 8, 1508, 83, 395, 413, 9, 398, 367, 1844, 315, 446, 17, 12, 378, 12, 25980, 12, 12633, 1401, 26, 288, 2150, 491, 5873, 288, 299, 14, 604, 9392, 3508, 68, 12, 959, 7, 450, 334, 719, 4641, 288, 299, 14, 604, 9392, 360, 21, 12, 450, 68, 7, 450, 334, 719, 4641, 288, 291, 14, 629, 8, 355, 491, 12, 15926, 68, 12, 959, 520, 12539, 520, 29901, 13, 3657, 7, 450, 334, 719, 4706, 490, 283, 21, 12, 450, 68, 520 ]
[ 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 774, 5560, 367, 7390, 14, 16541, 14, 5425, 859, 14, 199, 624, 199, 199, 646, 2702, 199, 199, 504, 7390, 14, 16541, 492, 12893, 199, 504, 7390, 14, 1548, 492, 5988, 199, 504, 7390, 14, 4901, 492, 1125, 199, 504, 7390, 14, 4901, 492, 10133, 199, 199, 504, 7390, 14, 14443, 492, 2882, 199, 504, 7390, 14, 396, 14, 2625, 63, 7546, 492, 2624, 7836, 4388, 199, 533, 8089, 2842, 1746, 8, 2796, 14, 1746, 304, 272, 408, 272, 1379, 6057, 402, 12893, 9320, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 2790, 282, 12893, 1890, 1202, 315, 2295, 14, 267, 408, 267, 291, 14, 1258, 275, 12893, 14, 41, 1326, 3041, 342, 2378, 347, 511, 63, 3724, 547, 8, 277, 304, 267, 408, 267, 283, 11588, 13, 3170, 7, 1125, 1077, 2341, 370, 314, 491, 91, 5425, 14, 41, 1326, 547, 93, 1919, 14, 267, 408, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 1258, 14, 10590, 14, 740, 1332, 68, 12, 11869, 12, 31944, 430, 267, 291, 14, 1258, 14, 604, 9392, 360, 4288, 12, 31944, 520, 12539, 520, 24740, 13, 3170, 358, 267, 372, 291, 14, 479, 6782, 8, 68, 12, 12893, 14, 41, 1326, 547, 9, 2378, 347, 511, 63, 889, 53, 1505, 547, 8, 277, 304, 267, 408, 267, 283, 2826, 13, 3791, 7, 1125, 1077, 2341, 370, 314, 491, 91, 5425, 14, 1944, 1899, 93, 1919, 14, 267, 408, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 1258, 14, 10590, 14, 740, 1332, 68, 12, 26569, 12, 31944, 430, 267, 291, 14, 1258, 14, 604, 9392, 360, 5533, 12, 31944, 520, 12539, 520, 4825, 13, 3791, 358, 267, 372, 291, 14, 479, 6782, 8, 68, 12, 12893, 14, 1944, 1899, 9, 2378, 347, 511, 63, 3197, 4313, 547, 8, 277, 304, 267, 408, 267, 283, 9692, 13, 3657, 7, 1125, 1077, 2341, 370, 314, 491, 91, 5425, 14, 3364, 4313, 93, 1919, 14, 267, 408, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 1258, 14, 10590, 14, 740, 1332, 68, 12, 30044, 12, 959, 1822, 430, 267, 291, 14, 1258, 14, 604, 9392, 360, 9908, 12, 959, 1822, 520, 221, 12539, 520, 29901, 13, 3657, 358, 267, 372, 291, 14, 479, 6782, 8, 68, 12, 12893, 14, 3364, 4313, 9, 2378, 347, 511, 63, 5642, 1899, 547, 8, 277, 304, 267, 408, 267, 283, 40, 22436, 13, 3791, 7, 1125, 1077, 2341, 370, 314, 491, 91, 5425, 14, 14983, 1899, 93, 1919, 14, 267, 408, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 1258, 14, 10590, 14, 740, 1332, 68, 12, 959, 1822, 12, 1520, 1407, 430, 267, 291, 14, 1258, 14, 604, 9392, 360, 5308, 12, 1520, 1407, 520, 12539, 520, 869, 22436, 13, 3791, 358, 267, 372, 291, 14, 479, 6782, 8, 68, 12, 12893, 14, 14983, 1899, 9, 2378, 347, 511, 63, 22031, 3225, 8, 277, 304, 267, 408, 267, 437, 9413, 1827, 1314, 3405, 2952, 402, 282, 8113, 14074, 1077, 267, 9128, 376, 491, 91, 5425, 14, 41, 1326, 547, 5565, 267, 408, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 1258, 14, 10590, 14, 740, 1332, 68, 12, 1520, 2182, 12, 841, 708, 430, 267, 291, 14, 1258, 14, 2105, 14074, 8, 5328, 14, 6782, 8, 705, 14, 3225, 14074, 4059, 267, 372, 291, 14, 479, 6782, 8, 68, 12, 12893, 14, 41, 1326, 547, 9, 4388, 199, 533, 1379, 41, 1326, 3120, 8, 5425, 14, 41, 1326, 3120, 304, 272, 347, 4237, 8, 277, 12, 1654, 1476, 12, 1890, 1476, 304, 267, 372, 291, 14, 1099, 1110, 421, 199, 533, 1379, 547, 41, 1326, 3120, 8, 5425, 14, 41, 1326, 3120, 304, 272, 347, 4237, 8, 277, 12, 1654, 1476, 12, 1890, 1476, 304, 267, 746, 291, 14, 1971, 804, 342, 421, 199, 533, 7053, 1726, 8, 13281, 304, 272, 986, 421, 199, 533, 7146, 2842, 1746, 8, 2796, 14, 1746, 304, 272, 347, 511, 9298, 8, 277, 304, 267, 299, 275, 1379, 547, 41, 1326, 3120, 342, 267, 299, 14, 1875, 3225, 8, 1558, 7836, 1012, 267, 491, 275, 942, 267, 299, 14, 2254, 3049, 275, 491, 14, 740, 398, 299, 14, 1971, 804, 275, 12893, 14, 41, 1326, 547, 267, 299, 14, 604, 9392, 360, 4288, 12, 30044, 358, 267, 291, 14, 629, 8, 44, 59, 16, 467, 283, 4288, 12, 30044, 520, 12539, 520, 24740, 13, 3170, 358, 398, 299, 14, 1971, 804, 275, 12893, 14, 1944, 1899, 267, 299, 14, 604, 9392, 360, 10657, 12, 26160, 358, 267, 291, 14, 629, 8, 44, 59, 17, 467, 283, 10657, 12, 26160, 520, 12539, 520, 4825, 13, 3791, 358, 398, 299, 14, 1971, 804, 275, 12893, 14, 3364, 4313, 267, 299, 14, 604, 9392, 360, 23358, 12, 1227, 1477, 358, 267, 291, 14, 629, 8, 44, 59, 18, 467, 283, 23358, 12, 1227, 1477, 520, 12539, 520, 29901, 13, 3657, 358, 398, 299, 14, 1971, 804, 275, 12893, 14, 14983, 1899, 267, 299, 14, 604, 9392, 360, 29152, 12, 1695, 1465, 358, 267, 291, 14, 629, 8, 44, 59, 19, 467, 283, 29152, 12, 1695, 1465, 520, 12539, 520, 869, 22436, 13, 3791, 358, 398, 299, 14, 1971, 804, 275, 7053, 1726, 267, 299, 14, 604, 9392, 360, 23358, 12, 1520, 1407, 358, 267, 291, 14, 629, 8, 44, 59, 20, 467, 283, 23358, 12, 1520, 1407, 520, 12539, 520, 24740, 13, 3170, 358, 267, 2329, 83, 275, 291, 14, 4939, 28985, 9298, 8, 4665, 1726, 9, 267, 291, 14, 629, 8, 552, 8, 1508, 83, 395, 413, 9, 398, 367, 1844, 315, 446, 17, 12, 378, 12, 25980, 12, 12633, 1401, 26, 288, 2150, 491, 5873, 288, 299, 14, 604, 9392, 3508, 68, 12, 959, 7, 450, 334, 719, 4641, 288, 299, 14, 604, 9392, 360, 21, 12, 450, 68, 7, 450, 334, 719, 4641, 288, 291, 14, 629, 8, 355, 491, 12, 15926, 68, 12, 959, 520, 12539, 520, 29901, 13, 3657, 7, 450, 334, 719, 4706, 490, 283, 21, 12, 450, 68, 520, 0 ]
[ 1, 1, 1,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opify-Django
venv/lib/python2.7/site-packages/django/contrib/gis/db/models/sql/compiler.py
93
13247
try: from itertools import zip_longest except ImportError: from itertools import izip_longest as zip_longest from django.utils.six.moves import zip from django.db.backends.util import truncate_name, typecast_timestamp from django.db.models.sql import compiler from django.db.models.sql.constants import MULTI from django.utils import six SQLCompiler = compiler.SQLCompiler class GeoSQLCompiler(compiler.SQLCompiler): def get_columns(self, with_aliases=False): """ Return the list of columns to use in the select statement. If no columns have been specified, returns all columns relating to fields in the model. If 'with_aliases' is true, any column names that are duplicated (without the table names) are given unique aliases. This is needed in some cases to avoid ambiguitity with nested queries. This routine is overridden from Query to handle customized selection of geometry columns. """ qn = self.quote_name_unless_alias qn2 = self.connection.ops.quote_name result = ['(%s) AS %s' % (self.get_extra_select_format(alias) % col[0], qn2(alias)) for alias, col in six.iteritems(self.query.extra_select)] aliases = set(self.query.extra_select.keys()) if with_aliases: col_aliases = aliases.copy() else: col_aliases = set() if self.query.select: only_load = self.deferred_to_columns() # This loop customized for GeoQuery. for col, field in zip(self.query.select, self.query.select_fields): if isinstance(col, (list, tuple)): alias, column = col table = self.query.alias_map[alias].table_name if table in only_load and column not in only_load[table]: continue r = self.get_field_select(field, alias, column) if with_aliases: if col[1] in col_aliases: c_alias = 'Col%d' % len(col_aliases) result.append('%s AS %s' % (r, c_alias)) aliases.add(c_alias) col_aliases.add(c_alias) else: result.append('%s AS %s' % (r, qn2(col[1]))) aliases.add(r) col_aliases.add(col[1]) else: result.append(r) aliases.add(r) col_aliases.add(col[1]) else: result.append(col.as_sql(qn, self.connection)) if hasattr(col, 'alias'): aliases.add(col.alias) col_aliases.add(col.alias) elif self.query.default_cols: cols, new_aliases = self.get_default_columns(with_aliases, col_aliases) result.extend(cols) aliases.update(new_aliases) max_name_length = self.connection.ops.max_name_length() result.extend([ '%s%s' % ( self.get_extra_select_format(alias) % aggregate.as_sql(qn, self.connection), alias is not None and ' AS %s' % qn(truncate_name(alias, max_name_length)) or '' ) for alias, aggregate in self.query.aggregate_select.items() ]) # This loop customized for GeoQuery. for (table, col), field in zip(self.query.related_select_cols, self.query.related_select_fields): r = self.get_field_select(field, table, col) if with_aliases and col in col_aliases: c_alias = 'Col%d' % len(col_aliases) result.append('%s AS %s' % (r, c_alias)) aliases.add(c_alias) col_aliases.add(c_alias) else: result.append(r) aliases.add(r) col_aliases.add(col) self._select_aliases = aliases return result def get_default_columns(self, with_aliases=False, col_aliases=None, start_alias=None, opts=None, as_pairs=False, local_only=False): """ Computes the default columns for selecting every field in the base model. Will sometimes be called to pull in related models (e.g. via select_related), in which case "opts" and "start_alias" will be given to provide a starting point for the traversal. Returns a list of strings, quoted appropriately for use in SQL directly, as well as a set of aliases used in the select statement (if 'as_pairs' is True, returns a list of (alias, col_name) pairs instead of strings as the first component and None as the second component). This routine is overridden from Query to handle customized selection of geometry columns. """ result = [] if opts is None: opts = self.query.model._meta aliases = set() only_load = self.deferred_to_columns() if start_alias: seen = {None: start_alias} for field, model in opts.get_fields_with_model(): # For local fields (even if through proxy) the model should # be None. if model == opts.concrete_model: model = None if local_only and model is not None: continue if start_alias: try: alias = seen[model] except KeyError: link_field = opts.get_ancestor_link(model) alias = self.query.join((start_alias, model._meta.db_table, link_field.column, model._meta.pk.column)) seen[model] = alias else: # If we're starting from the base model of the queryset, the # aliases will have already been set up in pre_sql_setup(), so # we can save time here. alias = self.query.included_inherited_models[model] table = self.query.alias_map[alias].table_name if table in only_load and field.column not in only_load[table]: continue if as_pairs: result.append((alias, field.column)) aliases.add(alias) continue # This part of the function is customized for GeoQuery. We # see if there was any custom selection specified in the # dictionary, and set up the selection format appropriately. field_sel = self.get_field_select(field, alias) if with_aliases and field.column in col_aliases: c_alias = 'Col%d' % len(col_aliases) result.append('%s AS %s' % (field_sel, c_alias)) col_aliases.add(c_alias) aliases.add(c_alias) else: r = field_sel result.append(r) aliases.add(r) if with_aliases: col_aliases.add(field.column) return result, aliases def resolve_columns(self, row, fields=()): """ This routine is necessary so that distances and geometries returned from extra selection SQL get resolved appropriately into Python objects. """ values = [] aliases = list(self.query.extra_select) # Have to set a starting row number offset that is used for # determining the correct starting row index -- needed for # doing pagination with Oracle. rn_offset = 0 if self.connection.ops.oracle: if self.query.high_mark is not None or self.query.low_mark: rn_offset = 1 index_start = rn_offset + len(aliases) # Converting any extra selection values (e.g., geometries and # distance objects added by GeoQuerySet methods). values = [self.query.convert_values(v, self.query.extra_select_fields.get(a, None), self.connection) for v, a in zip(row[rn_offset:index_start], aliases)] if self.connection.ops.oracle or getattr(self.query, 'geo_values', False): # We resolve the rest of the columns if we're on Oracle or if # the `geo_values` attribute is defined. for value, field in zip_longest(row[index_start:], fields): values.append(self.query.convert_values(value, field, self.connection)) else: values.extend(row[index_start:]) return tuple(values) #### Routines unique to GeoQuery #### def get_extra_select_format(self, alias): sel_fmt = '%s' if hasattr(self.query, 'custom_select') and alias in self.query.custom_select: sel_fmt = sel_fmt % self.query.custom_select[alias] return sel_fmt def get_field_select(self, field, alias=None, column=None): """ Returns the SELECT SQL string for the given field. Figures out if any custom selection SQL is needed for the column The `alias` keyword may be used to manually specify the database table where the column exists, if not in the model associated with this `GeoQuery`. Similarly, `column` may be used to specify the exact column name, rather than using the `column` attribute on `field`. """ sel_fmt = self.get_select_format(field) if field in self.query.custom_select: field_sel = sel_fmt % self.query.custom_select[field] else: field_sel = sel_fmt % self._field_column(field, alias, column) return field_sel def get_select_format(self, fld): """ Returns the selection format string, depending on the requirements of the spatial backend. For example, Oracle and MySQL require custom selection formats in order to retrieve geometries in OGC WKT. For all other fields a simple '%s' format string is returned. """ if self.connection.ops.select and hasattr(fld, 'geom_type'): # This allows operations to be done on fields in the SELECT, # overriding their values -- used by the Oracle and MySQL # spatial backends to get database values as WKT, and by the # `transform` method. sel_fmt = self.connection.ops.select # Because WKT doesn't contain spatial reference information, # the SRID is prefixed to the returned WKT to ensure that the # transformed geometries have an SRID different than that of the # field -- this is only used by `transform` for Oracle and # SpatiaLite backends. if self.query.transformed_srid and ( self.connection.ops.oracle or self.connection.ops.spatialite ): sel_fmt = "'SRID=%d;'||%s" % (self.query.transformed_srid, sel_fmt) else: sel_fmt = '%s' return sel_fmt # Private API utilities, subject to change. def _field_column(self, field, table_alias=None, column=None): """ Helper function that returns the database column for the given field. The table and column are returned (quoted) in the proper format, e.g., `"geoapp_city"."point"`. If `table_alias` is not specified, the database table associated with the model of this `GeoQuery` will be used. If `column` is specified, it will be used instead of the value in `field.column`. """ if table_alias is None: table_alias = self.query.model._meta.db_table return "%s.%s" % (self.quote_name_unless_alias(table_alias), self.connection.ops.quote_name(column or field.column)) class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler): pass class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler): pass class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler): pass class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler): pass class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler): """ This is overridden for GeoDjango to properly cast date columns, since `GeoQuery.resolve_columns` is used for spatial values. See #14648, #16757. """ def results_iter(self): if self.connection.ops.oracle: from django.db.models.fields import DateTimeField fields = [DateTimeField()] else: needs_string_cast = self.connection.features.needs_datetime_string_cast offset = len(self.query.extra_select) for rows in self.execute_sql(MULTI): for row in rows: date = row[offset] if self.connection.ops.oracle: date = self.resolve_columns(row, fields)[offset] elif needs_string_cast: date = typecast_timestamp(str(date)) yield date
mit
[ 893, 26, 272, 687, 7975, 492, 3482, 63, 20820, 199, 2590, 3545, 26, 272, 687, 7975, 492, 28697, 63, 20820, 465, 3482, 63, 20820, 199, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 3482, 199, 199, 504, 1639, 14, 697, 14, 7765, 14, 1974, 492, 14547, 63, 354, 12, 730, 2931, 63, 3954, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 492, 6365, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 5559, 492, 24895, 41, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 4657, 9131, 275, 6365, 14, 4657, 9131, 199, 199, 533, 8875, 4657, 9131, 8, 5772, 14, 4657, 9131, 304, 339, 347, 664, 63, 3406, 8, 277, 12, 543, 63, 8602, 29, 797, 304, 267, 408, 267, 1432, 314, 769, 402, 4362, 370, 675, 315, 314, 3504, 5164, 14, 982, 949, 267, 4362, 1172, 2757, 2013, 12, 2529, 1006, 4362, 4668, 1958, 370, 1504, 315, 267, 314, 1402, 14, 398, 982, 283, 1045, 63, 8602, 7, 365, 2549, 12, 1263, 2763, 1561, 626, 787, 21747, 267, 334, 7395, 314, 1817, 1561, 9, 787, 1627, 3747, 5481, 14, 961, 365, 4346, 315, 267, 2005, 5560, 370, 5126, 16353, 528, 1907, 1701, 543, 6032, 9212, 14, 398, 961, 12981, 365, 10087, 687, 8133, 370, 2429, 26707, 7267, 402, 267, 3400, 4362, 14, 267, 408, 267, 18293, 275, 291, 14, 3513, 63, 354, 63, 18447, 63, 3620, 267, 18293, 18, 275, 291, 14, 2105, 14, 1483, 14, 3513, 63, 354, 267, 754, 275, 788, 4042, 83, 9, 4319, 450, 83, 7, 450, 334, 277, 14, 362, 63, 2911, 63, 2416, 63, 908, 8, 3620, 9, 450, 1048, 59, 16, 467, 18293, 18, 8, 3620, 430, 2116, 367, 5162, 12, 1048, 315, 3816, 14, 4611, 8, 277, 14, 1131, 14, 2911, 63, 2416, 1874, 267, 5481, 275, 663, 8, 277, 14, 1131, 14, 2911, 63, 2416, 14, 1612, 1012, 267, 340, 543, 63, 8602, 26, 288, 1048, 63, 8602, 275, 5481, 14, 1574, 342, 267, 587, 26, 288, 1048, 63, 8602, 275, 663, 342, 267, 340, 291, 14, 1131, 14, 2416, 26, 288, 1454, 63, 912, 275, 291, 14, 12116, 63, 475, 63, 3406, 342, 288, 327, 961, 4438, 26707, 367, 8875, 3227, 14, 288, 367, 1048, 12, 901, 315, 3482, 8, 277, 14, 1131, 14, 2416, 12, 291, 14, 1131, 14, 2416, 63, 955, 304, 355, 340, 1228, 8, 761, 12, 334, 513, 12, 2008, 2298, 490, 5162, 12, 2763, 275, 1048, 490, 1817, 275, 291, 14, 1131, 14, 3620, 63, 1130, 59, 3620, 1055, 1224, 63, 354, 490, 340, 1817, 315, 1454, 63, 912, 436, 2763, 440, 315, 1454, 63, 912, 59, 1224, 2189, 717, 1980, 490, 519, 275, 291, 14, 362, 63, 698, 63, 2416, 8, 698, 12, 5162, 12, 2763, 9, 490, 340, 543, 63, 8602, 26, 717, 340, 1048, 59, 17, 61, 315, 1048, 63, 8602, 26, 1169, 286, 63, 3620, 275, 283, 2001, 5, 68, 7, 450, 822, 8, 761, 63, 8602, 9, 1169, 754, 14, 740, 3508, 83, 4319, 450, 83, 7, 450, 334, 82, 12, 286, 63, 3620, 430, 1169, 5481, 14, 525, 8, 67, 63, 3620, 9, 1169, 1048, 63, 8602, 14, 525, 8, 67, 63, 3620, 9, 717, 587, 26, 1169, 754, 14, 740, 3508, 83, 4319, 450, 83, 7, 450, 334, 82, 12, 18293, 18, 8, 761, 59, 17, 11845, 1169, 5481, 14, 525, 8, 82, 9, 1169, 1048, 63, 8602, 14, 525, 8, 761, 59, 17, 566, 490, 587, 26, 717, 754, 14, 740, 8, 82, 9, 717, 5481, 14, 525, 8, 82, 9, 717, 1048, 63, 8602, 14, 525, 8, 761, 59, 17, 566, 355, 587, 26, 490, 754, 14, 740, 8, 761, 14, 305, 63, 3009, 8, 15156, 12, 291, 14, 2105, 430, 4951, 340, 2688, 8, 761, 12, 283, 3620, 735, 717, 5481, 14, 525, 8, 761, 14, 3620, 9, 717, 1048, 63, 8602, 14, 525, 8, 761, 14, 3620, 9, 398, 916, 291, 14, 1131, 14, 885, 63, 4574, 26, 288, 8850, 12, 892, 63, 8602, 275, 291, 14, 362, 63, 885, 63, 3406, 8, 1045, 63, 8602, 12, 490, 1048, 63, 8602, 9, 288, 754, 14, 2880, 8, 4574, 9, 288, 5481, 14, 873, 8, 1222, 63, 8602, 9, 398, 1390, 63, 354, 63, 1267, 275, 291, 14, 2105, 14, 1483, 14, 988, 63, 354, 63, 1267, 342, 267, 754, 14, 2880, 779, 355, 1543, 83, 5, 83, 7, 450, 334, 490, 291, 14, 362, 63, 2911, 63, 2416, 63, 908, 8, 3620, 9, 450, 9531, 14, 305, 63, 3009, 8, 15156, 12, 291, 14, 2105, 395, 490, 5162, 365, 440, 488, 717, 436, 283, 4319, 450, 83, 7, 450, 18293, 8, 12517, 63, 354, 8, 3620, 12, 1390, 63, 354, 63, 1267, 430, 717, 503, 2125, 490, 776, 355, 367, 5162, 12, 9531, 315, 291, 14, 1131, 14, 7516, 63, 2416, 14, 1744, 342, 267, 4794, 398, 327, 961, 4438, 26707, 367, 8875, 3227, 14, 267, 367, 334, 1224, 12, 1048, 395, 901, 315, 3482, 8, 277, 14, 1131, 14, 2407, 63, 2416, 63, 4574, 12, 291, 14, 1131, 14, 2407, 63, 2416, 63, 955, 304, 288, 519, 275, 291, 14, 362, 63, 698, 63, 2416, 8, 698, 12, 1817, 12, 1048, 9, 288, 340, 543, 63, 8602, 436, 1048, 315, 1048, 63, 8602, 26, 355, 286, 63, 3620, 275, 283, 2001, 5, 68, 7, 450, 822, 8, 761, 63, 8602, 9, 355, 754, 14, 740, 3508, 83, 4319, 450, 83, 7, 450, 334, 82, 12, 286, 63, 3620, 430, 355, 5481, 14, 525, 8, 67, 63, 3620, 9, 355, 1048, 63, 8602, 14, 525, 8, 67, 63, 3620, 9, 288, 587, 26, 355, 754, 14, 740, 8, 82, 9, 355, 5481, 14, 525, 8, 82, 9, 355, 1048, 63, 8602, 14, 525, 8, 761, 9, 398, 291, 423, 2416, 63, 8602, 275, 5481, 267, 372, 754, 339, 347, 664, 63, 885, 63, 3406, 8, 277, 12, 543, 63, 8602, 29, 797, 12, 1048, 63, 8602, 29, 403, 12, 288, 1343, 63, 3620, 29, 403, 12, 3999, 29, 403, 12, 465, 63, 7322, 29, 797, 12, 2257, 63, 2118, 29, 797, 304, 267, 408, 267, 28040, 314, 849, 4362, 367, 30090, 4036 ]
[ 26, 272, 687, 7975, 492, 3482, 63, 20820, 199, 2590, 3545, 26, 272, 687, 7975, 492, 28697, 63, 20820, 465, 3482, 63, 20820, 199, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 3482, 199, 199, 504, 1639, 14, 697, 14, 7765, 14, 1974, 492, 14547, 63, 354, 12, 730, 2931, 63, 3954, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 492, 6365, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 5559, 492, 24895, 41, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 4657, 9131, 275, 6365, 14, 4657, 9131, 199, 199, 533, 8875, 4657, 9131, 8, 5772, 14, 4657, 9131, 304, 339, 347, 664, 63, 3406, 8, 277, 12, 543, 63, 8602, 29, 797, 304, 267, 408, 267, 1432, 314, 769, 402, 4362, 370, 675, 315, 314, 3504, 5164, 14, 982, 949, 267, 4362, 1172, 2757, 2013, 12, 2529, 1006, 4362, 4668, 1958, 370, 1504, 315, 267, 314, 1402, 14, 398, 982, 283, 1045, 63, 8602, 7, 365, 2549, 12, 1263, 2763, 1561, 626, 787, 21747, 267, 334, 7395, 314, 1817, 1561, 9, 787, 1627, 3747, 5481, 14, 961, 365, 4346, 315, 267, 2005, 5560, 370, 5126, 16353, 528, 1907, 1701, 543, 6032, 9212, 14, 398, 961, 12981, 365, 10087, 687, 8133, 370, 2429, 26707, 7267, 402, 267, 3400, 4362, 14, 267, 408, 267, 18293, 275, 291, 14, 3513, 63, 354, 63, 18447, 63, 3620, 267, 18293, 18, 275, 291, 14, 2105, 14, 1483, 14, 3513, 63, 354, 267, 754, 275, 788, 4042, 83, 9, 4319, 450, 83, 7, 450, 334, 277, 14, 362, 63, 2911, 63, 2416, 63, 908, 8, 3620, 9, 450, 1048, 59, 16, 467, 18293, 18, 8, 3620, 430, 2116, 367, 5162, 12, 1048, 315, 3816, 14, 4611, 8, 277, 14, 1131, 14, 2911, 63, 2416, 1874, 267, 5481, 275, 663, 8, 277, 14, 1131, 14, 2911, 63, 2416, 14, 1612, 1012, 267, 340, 543, 63, 8602, 26, 288, 1048, 63, 8602, 275, 5481, 14, 1574, 342, 267, 587, 26, 288, 1048, 63, 8602, 275, 663, 342, 267, 340, 291, 14, 1131, 14, 2416, 26, 288, 1454, 63, 912, 275, 291, 14, 12116, 63, 475, 63, 3406, 342, 288, 327, 961, 4438, 26707, 367, 8875, 3227, 14, 288, 367, 1048, 12, 901, 315, 3482, 8, 277, 14, 1131, 14, 2416, 12, 291, 14, 1131, 14, 2416, 63, 955, 304, 355, 340, 1228, 8, 761, 12, 334, 513, 12, 2008, 2298, 490, 5162, 12, 2763, 275, 1048, 490, 1817, 275, 291, 14, 1131, 14, 3620, 63, 1130, 59, 3620, 1055, 1224, 63, 354, 490, 340, 1817, 315, 1454, 63, 912, 436, 2763, 440, 315, 1454, 63, 912, 59, 1224, 2189, 717, 1980, 490, 519, 275, 291, 14, 362, 63, 698, 63, 2416, 8, 698, 12, 5162, 12, 2763, 9, 490, 340, 543, 63, 8602, 26, 717, 340, 1048, 59, 17, 61, 315, 1048, 63, 8602, 26, 1169, 286, 63, 3620, 275, 283, 2001, 5, 68, 7, 450, 822, 8, 761, 63, 8602, 9, 1169, 754, 14, 740, 3508, 83, 4319, 450, 83, 7, 450, 334, 82, 12, 286, 63, 3620, 430, 1169, 5481, 14, 525, 8, 67, 63, 3620, 9, 1169, 1048, 63, 8602, 14, 525, 8, 67, 63, 3620, 9, 717, 587, 26, 1169, 754, 14, 740, 3508, 83, 4319, 450, 83, 7, 450, 334, 82, 12, 18293, 18, 8, 761, 59, 17, 11845, 1169, 5481, 14, 525, 8, 82, 9, 1169, 1048, 63, 8602, 14, 525, 8, 761, 59, 17, 566, 490, 587, 26, 717, 754, 14, 740, 8, 82, 9, 717, 5481, 14, 525, 8, 82, 9, 717, 1048, 63, 8602, 14, 525, 8, 761, 59, 17, 566, 355, 587, 26, 490, 754, 14, 740, 8, 761, 14, 305, 63, 3009, 8, 15156, 12, 291, 14, 2105, 430, 4951, 340, 2688, 8, 761, 12, 283, 3620, 735, 717, 5481, 14, 525, 8, 761, 14, 3620, 9, 717, 1048, 63, 8602, 14, 525, 8, 761, 14, 3620, 9, 398, 916, 291, 14, 1131, 14, 885, 63, 4574, 26, 288, 8850, 12, 892, 63, 8602, 275, 291, 14, 362, 63, 885, 63, 3406, 8, 1045, 63, 8602, 12, 490, 1048, 63, 8602, 9, 288, 754, 14, 2880, 8, 4574, 9, 288, 5481, 14, 873, 8, 1222, 63, 8602, 9, 398, 1390, 63, 354, 63, 1267, 275, 291, 14, 2105, 14, 1483, 14, 988, 63, 354, 63, 1267, 342, 267, 754, 14, 2880, 779, 355, 1543, 83, 5, 83, 7, 450, 334, 490, 291, 14, 362, 63, 2911, 63, 2416, 63, 908, 8, 3620, 9, 450, 9531, 14, 305, 63, 3009, 8, 15156, 12, 291, 14, 2105, 395, 490, 5162, 365, 440, 488, 717, 436, 283, 4319, 450, 83, 7, 450, 18293, 8, 12517, 63, 354, 8, 3620, 12, 1390, 63, 354, 63, 1267, 430, 717, 503, 2125, 490, 776, 355, 367, 5162, 12, 9531, 315, 291, 14, 1131, 14, 7516, 63, 2416, 14, 1744, 342, 267, 4794, 398, 327, 961, 4438, 26707, 367, 8875, 3227, 14, 267, 367, 334, 1224, 12, 1048, 395, 901, 315, 3482, 8, 277, 14, 1131, 14, 2407, 63, 2416, 63, 4574, 12, 291, 14, 1131, 14, 2407, 63, 2416, 63, 955, 304, 288, 519, 275, 291, 14, 362, 63, 698, 63, 2416, 8, 698, 12, 1817, 12, 1048, 9, 288, 340, 543, 63, 8602, 436, 1048, 315, 1048, 63, 8602, 26, 355, 286, 63, 3620, 275, 283, 2001, 5, 68, 7, 450, 822, 8, 761, 63, 8602, 9, 355, 754, 14, 740, 3508, 83, 4319, 450, 83, 7, 450, 334, 82, 12, 286, 63, 3620, 430, 355, 5481, 14, 525, 8, 67, 63, 3620, 9, 355, 1048, 63, 8602, 14, 525, 8, 67, 63, 3620, 9, 288, 587, 26, 355, 754, 14, 740, 8, 82, 9, 355, 5481, 14, 525, 8, 82, 9, 355, 1048, 63, 8602, 14, 525, 8, 761, 9, 398, 291, 423, 2416, 63, 8602, 275, 5481, 267, 372, 754, 339, 347, 664, 63, 885, 63, 3406, 8, 277, 12, 543, 63, 8602, 29, 797, 12, 1048, 63, 8602, 29, 403, 12, 288, 1343, 63, 3620, 29, 403, 12, 3999, 29, 403, 12, 465, 63, 7322, 29, 797, 12, 2257, 63, 2118, 29, 797, 304, 267, 408, 267, 28040, 314, 849, 4362, 367, 30090, 4036, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ar7z1/ansible
lib/ansible/modules/messaging/rabbitmq_policy.py
16
4535
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2013, John Dewey <john@dewey.ws> # 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: rabbitmq_policy short_description: Manage the state of policies in RabbitMQ. description: - Manage the state of a policy in RabbitMQ. version_added: "1.5" author: "John Dewey (@retr0h)" options: name: description: - The name of the policy to manage. required: true vhost: description: - The name of the vhost to apply to. default: / apply_to: description: - What the policy applies to. Requires RabbitMQ 3.2.0 or later. default: all choices: [all, exchanges, queues] version_added: "2.1" pattern: description: - A regex of queues to apply the policy to. required: true tags: description: - A dict or string describing the policy. required: true priority: description: - The priority of the policy. default: 0 node: description: - Erlang node name of the rabbit we wish to configure. default: rabbit state: description: - The state of the policy. default: present choices: [present, absent] ''' EXAMPLES = ''' - name: ensure the default vhost contains the HA policy via a dict rabbitmq_policy: name: HA pattern: .* args: tags: ha-mode: all - name: ensure the default vhost contains the HA policy rabbitmq_policy: name: HA pattern: .* tags: ha-mode: all ''' import json from ansible.module_utils.basic import AnsibleModule class RabbitMqPolicy(object): def __init__(self, module, name): self._module = module self._name = name self._vhost = module.params['vhost'] self._pattern = module.params['pattern'] self._apply_to = module.params['apply_to'] self._tags = module.params['tags'] self._priority = module.params['priority'] self._node = module.params['node'] self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True) def _exec(self, args, run_in_check_mode=False): if not self._module.check_mode or (self._module.check_mode and run_in_check_mode): cmd = [self._rabbitmqctl, '-q', '-n', self._node] args.insert(1, '-p') args.insert(2, self._vhost) rc, out, err = self._module.run_command(cmd + args, check_rc=True) return out.splitlines() return list() def list(self): policies = self._exec(['list_policies'], True) for policy in policies: if not policy: continue policy_name = policy.split('\t')[1] if policy_name == self._name: return True return False def set(self): args = ['set_policy'] args.append(self._name) args.append(self._pattern) args.append(json.dumps(self._tags)) args.append('--priority') args.append(self._priority) if self._apply_to != 'all': args.append('--apply-to') args.append(self._apply_to) return self._exec(args) def clear(self): return self._exec(['clear_policy', self._name]) def main(): arg_spec = dict( name=dict(required=True), vhost=dict(default='/'), pattern=dict(required=True), apply_to=dict(default='all', choices=['all', 'exchanges', 'queues']), tags=dict(type='dict', required=True), priority=dict(default='0'), node=dict(default='rabbit'), state=dict(default='present', choices=['present', 'absent']), ) module = AnsibleModule( argument_spec=arg_spec, supports_check_mode=True ) name = module.params['name'] state = module.params['state'] rabbitmq_policy = RabbitMqPolicy(module, name) result = dict(changed=False, name=name, state=state) if rabbitmq_policy.list(): if state == 'absent': rabbitmq_policy.clear() result['changed'] = True else: result['changed'] = False elif state == 'present': rabbitmq_policy.set() result['changed'] = True module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6171, 12, 17815, 577, 546, 14655, 665, 20216, 32, 271, 1129, 89, 14, 3569, 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, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 29773, 29490, 63, 3185, 199, 3612, 63, 1802, 26, 14944, 314, 1174, 402, 14118, 315, 820, 371, 2075, 14449, 14, 199, 1802, 26, 523, 446, 14944, 314, 1174, 402, 282, 4592, 315, 820, 371, 2075, 14449, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 21, 2, 199, 2502, 26, 298, 12923, 577, 546, 14655, 8593, 264, 454, 16, 72, 2924, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 710, 536, 402, 314, 4592, 370, 9635, 14, 272, 1415, 26, 2549, 523, 373, 1102, 26, 272, 1369, 26, 489, 446, 710, 536, 402, 314, 373, 1102, 370, 4838, 370, 14, 272, 849, 26, 1182, 523, 4838, 63, 475, 26, 272, 1369, 26, 489, 446, 14791, 314, 4592, 12966, 370, 14, 15127, 820, 371, 2075, 14449, 650, 14, 18, 14, 16, 503, 2945, 14, 272, 849, 26, 1006, 272, 3415, 26, 359, 452, 12, 444, 6627, 12, 21366, 61, 272, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 523, 3851, 26, 272, 1369, 26, 489, 446, 437, 5163, 402, 21366, 370, 4838, 314, 4592, 370, 14, 272, 1415, 26, 2549, 523, 3762, 26, 272, 1369, 26, 489, 446, 437, 1211, 503, 1059, 13660, 314, 4592, 14, 272, 1415, 26, 2549, 523, 7464, 26, 272, 1369, 26, 489, 446, 710, 7464, 402, 314, 4592, 14, 272, 849, 26, 378, 523, 1031, 26, 272, 1369, 26, 489, 446, 221, 23223, 1031, 536, 402, 314, 29773, 2075, 781, 13809, 370, 7908, 14, 272, 849, 26, 29773, 2075, 523, 1174, 26, 272, 1369, 26, 489, 446, 710, 1174, 402, 314, 4592, 14, 272, 849, 26, 3451, 272, 3415, 26, 359, 1881, 12, 9552, 61, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 4868, 314, 849, 373, 1102, 3509, 314, 16100, 4592, 4799, 282, 1211, 523, 29773, 29490, 63, 3185, 26, 272, 536, 26, 16100, 272, 3851, 26, 23076, 523, 1249, 26, 272, 3762, 26, 489, 18251, 13, 632, 26, 1006, 199, 199, 13, 536, 26, 4868, 314, 849, 373, 1102, 3509, 314, 16100, 4592, 523, 29773, 29490, 63, 3185, 26, 272, 536, 26, 16100, 272, 3851, 26, 23076, 272, 3762, 26, 489, 18251, 13, 632, 26, 1006, 199, 2344, 199, 199, 646, 2022, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 533, 820, 371, 2075, 45, 81, 4845, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 859, 12, 536, 304, 267, 291, 423, 578, 275, 859, 267, 291, 423, 354, 275, 536, 267, 291, 423, 32071, 275, 859, 14, 1162, 459, 32071, 418, 267, 291, 423, 3401, 275, 859, 14, 1162, 459, 3401, 418, 267, 291, 423, 4998, 63, 475, 275, 859, 14, 1162, 459, 4998, 63, 475, 418, 267, 291, 423, 2969, 275, 859, 14, 1162, 459, 2969, 418, 267, 291, 423, 6693, 275, 859, 14, 1162, 459, 6693, 418, 267, 291, 423, 932, 275, 859, 14, 1162, 459, 932, 418, 267, 291, 423, 14411, 29490, 8077, 275, 859, 14, 362, 63, 1393, 63, 515, 360, 14411, 29490, 8077, 297, 715, 9, 339, 347, 485, 1628, 8, 277, 12, 1249, 12, 1255, 63, 262, 63, 1074, 63, 632, 29, 797, 304, 267, 340, 440, 291, 423, 578, 14, 1074, 63, 632, 503, 334, 277, 423, 578, 14, 1074, 63, 632, 436, 1255, 63, 262, 63, 1074, 63, 632, 304, 288, 2088, 275, 359, 277, 423, 14411, 29490, 8077, 12, 2475, 81, 297, 2475, 78, 297, 291, 423, 932, 61, 288, 1249, 14, 3176, 8, 17, 12, 2475, 80, 358, 288, 1249, 14, 3176, 8, 18, 12, 291, 423, 32071, 9, 288, 4819, 12, 734, 12, 2329, 275, 291, 423, 578, 14, 1065, 63, 1531, 8, 1760, 435, 1249, 12, 1104, 63, 1195, 29, 549, 9, 288, 372, 734, 14, 7644, 342, 267, 372, 769, 342, 339, 347, 769, 8, 277, 304, 267, 14118, 275, 291, 423, 1628, 2941, 513, 63, 11767, 995, 715, 9, 398, 367, 4592, 315, 14118, 26, 288, 340, 440, 4592, 26, 355, 1980, 288, 4592, 63, 354, 275, 4592, 14, 1294, 2258, 84, 5832, 17, 61, 288, 340, 4592, 63, 354, 508, 291, 423, 354, 26, 355, 372, 715, 267, 372, 756, 339, 347, 663, 8, 277, 304, 267, 1249, 275, 788, 409, 63, 3185, 418, 267, 1249, 14, 740, 8, 277, 423, 354, 9, 267, 1249, 14, 740, 8, 277, 423, 3401, 9, 267, 1249, 14, 740, 8, 1001, 14, 4180, 8, 277, 423, 2969, 430, 267, 1249, 14, 740, 4517, 6693, 358, 267, 1249, 14, 740, 8, 277, 423, 6693, 9, 267, 340, 291, 423, 4998, 63, 475, 1137, 283, 452, 356, 288, 1249, 14, 740, 4517, 4998, 13, 475, 358, 288, 1249, 14, 740, 8, 277, 423, 4998, 63, 475, 9, 267, 372, 291, 423, 1628, 8, 589, 9, 339, 347, 5436, 8, 277, 304, 267, 372, 291, 423, 1628, 2941, 3584, 63, 3185, 297, 291, 423, 354, 566, 421, 199, 318, 2446, 837, 272, 1680, 63, 1650, 275, 1211, 8, 267, 536, 29, 807, 8, 2427, 29, 549, 395, 267, 373, 1102, 29, 807, 8, 885, 8805, 659, 267, 3851, 29, 807, 8, 2427, 29, 549, 395, 267, 4838, 63, 475, 29, 807, 8, 885, 534, 452, 297, 3415, 2968, 452, 297, 283, 476, 6627, 297, 283, 18849, 3815, 267, 3762, 29, 807, 8, 466, 534, 807, 297, 1415, 29, 549, 395, 267, 7464, 29, 807, 8, 885, 534, 16, 659, 267, 1031 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6171, 12, 17815, 577, 546, 14655, 665, 20216, 32, 271, 1129, 89, 14, 3569, 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, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 29773, 29490, 63, 3185, 199, 3612, 63, 1802, 26, 14944, 314, 1174, 402, 14118, 315, 820, 371, 2075, 14449, 14, 199, 1802, 26, 523, 446, 14944, 314, 1174, 402, 282, 4592, 315, 820, 371, 2075, 14449, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 21, 2, 199, 2502, 26, 298, 12923, 577, 546, 14655, 8593, 264, 454, 16, 72, 2924, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 710, 536, 402, 314, 4592, 370, 9635, 14, 272, 1415, 26, 2549, 523, 373, 1102, 26, 272, 1369, 26, 489, 446, 710, 536, 402, 314, 373, 1102, 370, 4838, 370, 14, 272, 849, 26, 1182, 523, 4838, 63, 475, 26, 272, 1369, 26, 489, 446, 14791, 314, 4592, 12966, 370, 14, 15127, 820, 371, 2075, 14449, 650, 14, 18, 14, 16, 503, 2945, 14, 272, 849, 26, 1006, 272, 3415, 26, 359, 452, 12, 444, 6627, 12, 21366, 61, 272, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 523, 3851, 26, 272, 1369, 26, 489, 446, 437, 5163, 402, 21366, 370, 4838, 314, 4592, 370, 14, 272, 1415, 26, 2549, 523, 3762, 26, 272, 1369, 26, 489, 446, 437, 1211, 503, 1059, 13660, 314, 4592, 14, 272, 1415, 26, 2549, 523, 7464, 26, 272, 1369, 26, 489, 446, 710, 7464, 402, 314, 4592, 14, 272, 849, 26, 378, 523, 1031, 26, 272, 1369, 26, 489, 446, 221, 23223, 1031, 536, 402, 314, 29773, 2075, 781, 13809, 370, 7908, 14, 272, 849, 26, 29773, 2075, 523, 1174, 26, 272, 1369, 26, 489, 446, 710, 1174, 402, 314, 4592, 14, 272, 849, 26, 3451, 272, 3415, 26, 359, 1881, 12, 9552, 61, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 4868, 314, 849, 373, 1102, 3509, 314, 16100, 4592, 4799, 282, 1211, 523, 29773, 29490, 63, 3185, 26, 272, 536, 26, 16100, 272, 3851, 26, 23076, 523, 1249, 26, 272, 3762, 26, 489, 18251, 13, 632, 26, 1006, 199, 199, 13, 536, 26, 4868, 314, 849, 373, 1102, 3509, 314, 16100, 4592, 523, 29773, 29490, 63, 3185, 26, 272, 536, 26, 16100, 272, 3851, 26, 23076, 272, 3762, 26, 489, 18251, 13, 632, 26, 1006, 199, 2344, 199, 199, 646, 2022, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 533, 820, 371, 2075, 45, 81, 4845, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 859, 12, 536, 304, 267, 291, 423, 578, 275, 859, 267, 291, 423, 354, 275, 536, 267, 291, 423, 32071, 275, 859, 14, 1162, 459, 32071, 418, 267, 291, 423, 3401, 275, 859, 14, 1162, 459, 3401, 418, 267, 291, 423, 4998, 63, 475, 275, 859, 14, 1162, 459, 4998, 63, 475, 418, 267, 291, 423, 2969, 275, 859, 14, 1162, 459, 2969, 418, 267, 291, 423, 6693, 275, 859, 14, 1162, 459, 6693, 418, 267, 291, 423, 932, 275, 859, 14, 1162, 459, 932, 418, 267, 291, 423, 14411, 29490, 8077, 275, 859, 14, 362, 63, 1393, 63, 515, 360, 14411, 29490, 8077, 297, 715, 9, 339, 347, 485, 1628, 8, 277, 12, 1249, 12, 1255, 63, 262, 63, 1074, 63, 632, 29, 797, 304, 267, 340, 440, 291, 423, 578, 14, 1074, 63, 632, 503, 334, 277, 423, 578, 14, 1074, 63, 632, 436, 1255, 63, 262, 63, 1074, 63, 632, 304, 288, 2088, 275, 359, 277, 423, 14411, 29490, 8077, 12, 2475, 81, 297, 2475, 78, 297, 291, 423, 932, 61, 288, 1249, 14, 3176, 8, 17, 12, 2475, 80, 358, 288, 1249, 14, 3176, 8, 18, 12, 291, 423, 32071, 9, 288, 4819, 12, 734, 12, 2329, 275, 291, 423, 578, 14, 1065, 63, 1531, 8, 1760, 435, 1249, 12, 1104, 63, 1195, 29, 549, 9, 288, 372, 734, 14, 7644, 342, 267, 372, 769, 342, 339, 347, 769, 8, 277, 304, 267, 14118, 275, 291, 423, 1628, 2941, 513, 63, 11767, 995, 715, 9, 398, 367, 4592, 315, 14118, 26, 288, 340, 440, 4592, 26, 355, 1980, 288, 4592, 63, 354, 275, 4592, 14, 1294, 2258, 84, 5832, 17, 61, 288, 340, 4592, 63, 354, 508, 291, 423, 354, 26, 355, 372, 715, 267, 372, 756, 339, 347, 663, 8, 277, 304, 267, 1249, 275, 788, 409, 63, 3185, 418, 267, 1249, 14, 740, 8, 277, 423, 354, 9, 267, 1249, 14, 740, 8, 277, 423, 3401, 9, 267, 1249, 14, 740, 8, 1001, 14, 4180, 8, 277, 423, 2969, 430, 267, 1249, 14, 740, 4517, 6693, 358, 267, 1249, 14, 740, 8, 277, 423, 6693, 9, 267, 340, 291, 423, 4998, 63, 475, 1137, 283, 452, 356, 288, 1249, 14, 740, 4517, 4998, 13, 475, 358, 288, 1249, 14, 740, 8, 277, 423, 4998, 63, 475, 9, 267, 372, 291, 423, 1628, 8, 589, 9, 339, 347, 5436, 8, 277, 304, 267, 372, 291, 423, 1628, 2941, 3584, 63, 3185, 297, 291, 423, 354, 566, 421, 199, 318, 2446, 837, 272, 1680, 63, 1650, 275, 1211, 8, 267, 536, 29, 807, 8, 2427, 29, 549, 395, 267, 373, 1102, 29, 807, 8, 885, 8805, 659, 267, 3851, 29, 807, 8, 2427, 29, 549, 395, 267, 4838, 63, 475, 29, 807, 8, 885, 534, 452, 297, 3415, 2968, 452, 297, 283, 476, 6627, 297, 283, 18849, 3815, 267, 3762, 29, 807, 8, 466, 534, 807, 297, 1415, 29, 549, 395, 267, 7464, 29, 807, 8, 885, 534, 16, 659, 267, 1031, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
knoguchi/kenix-scm
server/lib/boto/swf/layer1_decisions.py
18
11934
""" Helper class for creating decision responses. """ class Layer1Decisions(object): """ Use this object to build a list of decisions for a decision response. Each method call will add append a new decision. Retrieve the list of decisions from the _data attribute. """ def __init__(self): self._data = [] def schedule_activity_task(self, activity_id, activity_type_name, activity_type_version, task_list=None, control=None, heartbeat_timeout=None, schedule_to_close_timeout=None, schedule_to_start_timeout=None, start_to_close_timeout=None, input=None): """ Schedules an activity task. :type activity_id: string :param activity_id: The activityId of the type of the activity being scheduled. :type activity_type_name: string :param activity_type_name: The name of the type of the activity being scheduled. :type activity_type_version: string :param activity_type_version: The version of the type of the activity being scheduled. :type task_list: string :param task_list: If set, specifies the name of the task list in which to schedule the activity task. If not specified, the defaultTaskList registered with the activity type will be used. Note: a task list for this activity task must be specified either as a default for the activity type or through this field. If neither this field is set nor a default task list was specified at registration time then a fault will be returned. """ o = {} o['decisionType'] = 'ScheduleActivityTask' attrs = o['scheduleActivityTaskDecisionAttributes'] = {} attrs['activityId'] = activity_id attrs['activityType'] = { 'name': activity_type_name, 'version': activity_type_version, } if task_list is not None: attrs['taskList'] = {'name': task_list} if control is not None: attrs['control'] = control if heartbeat_timeout is not None: attrs['heartbeatTimeout'] = heartbeat_timeout if schedule_to_close_timeout is not None: attrs['scheduleToCloseTimeout'] = schedule_to_close_timeout if schedule_to_start_timeout is not None: attrs['scheduleToStartTimeout'] = schedule_to_start_timeout if start_to_close_timeout is not None: attrs['startToCloseTimeout'] = start_to_close_timeout if input is not None: attrs['input'] = input self._data.append(o) def request_cancel_activity_task(self, activity_id): """ Attempts to cancel a previously scheduled activity task. If the activity task was scheduled but has not been assigned to a worker, then it will be canceled. If the activity task was already assigned to a worker, then the worker will be informed that cancellation has been requested in the response to RecordActivityTaskHeartbeat. """ o = {} o['decisionType'] = 'RequestCancelActivityTask' attrs = o['requestCancelActivityTaskDecisionAttributes'] = {} attrs['activityId'] = activity_id self._data.append(o) def record_marker(self, marker_name, details=None): """ Records a MarkerRecorded event in the history. Markers can be used for adding custom information in the history for instance to let deciders know that they do not need to look at the history beyond the marker event. """ o = {} o['decisionType'] = 'RecordMarker' attrs = o['recordMarkerDecisionAttributes'] = {} attrs['markerName'] = marker_name if details is not None: attrs['details'] = details self._data.append(o) def complete_workflow_execution(self, result=None): """ Closes the workflow execution and records a WorkflowExecutionCompleted event in the history """ o = {} o['decisionType'] = 'CompleteWorkflowExecution' attrs = o['completeWorkflowExecutionDecisionAttributes'] = {} if result is not None: attrs['result'] = result self._data.append(o) def fail_workflow_execution(self, reason=None, details=None): """ Closes the workflow execution and records a WorkflowExecutionFailed event in the history. """ o = {} o['decisionType'] = 'FailWorkflowExecution' attrs = o['failWorkflowExecutionDecisionAttributes'] = {} if reason is not None: attrs['reason'] = reason if details is not None: attrs['details'] = details self._data.append(o) def cancel_workflow_executions(self, details=None): """ Closes the workflow execution and records a WorkflowExecutionCanceled event in the history. """ o = {} o['decisionType'] = 'CancelWorkflowExecution' attrs = o['cancelWorkflowExecutionsDecisionAttributes'] = {} if details is not None: attrs['details'] = details self._data.append(o) def continue_as_new_workflow_execution(self, child_policy=None, execution_start_to_close_timeout=None, input=None, tag_list=None, task_list=None, start_to_close_timeout=None, workflow_type_version=None): """ Closes the workflow execution and starts a new workflow execution of the same type using the same workflow id and a unique run Id. A WorkflowExecutionContinuedAsNew event is recorded in the history. """ o = {} o['decisionType'] = 'ContinueAsNewWorkflowExecution' attrs = o['continueAsNewWorkflowExecutionDecisionAttributes'] = {} if child_policy is not None: attrs['childPolicy'] = child_policy if execution_start_to_close_timeout is not None: attrs['executionStartToCloseTimeout'] = execution_start_to_close_timeout if input is not None: attrs['input'] = input if tag_list is not None: attrs['tagList'] = tag_list if task_list is not None: attrs['taskList'] = {'name': task_list} if start_to_close_timeout is not None: attrs['startToCloseTimeout'] = start_to_close_timeout if workflow_type_version is not None: attrs['workflowTypeVersion'] = workflow_type_version self._data.append(o) def start_timer(self, start_to_fire_timeout, timer_id, control=None): """ Starts a timer for this workflow execution and records a TimerStarted event in the history. This timer will fire after the specified delay and record a TimerFired event. """ o = {} o['decisionType'] = 'StartTimer' attrs = o['startTimerDecisionAttributes'] = {} attrs['startToFireTimeout'] = start_to_fire_timeout attrs['timerId'] = timer_id if control is not None: attrs['control'] = control self._data.append(o) def cancel_timer(self, timer_id): """ Cancels a previously started timer and records a TimerCanceled event in the history. """ o = {} o['decisionType'] = 'CancelTimer' attrs = o['cancelTimerDecisionAttributes'] = {} attrs['timerId'] = timer_id self._data.append(o) def signal_external_workflow_execution(self, workflow_id, signal_name, run_id=None, control=None, input=None): """ Requests a signal to be delivered to the specified external workflow execution and records a SignalExternalWorkflowExecutionInitiated event in the history. """ o = {} o['decisionType'] = 'SignalExternalWorkflowExecution' attrs = o['signalExternalWorkflowExecutionDecisionAttributes'] = {} attrs['workflowId'] = workflow_id attrs['signalName'] = signal_name if run_id is not None: attrs['runId'] = run_id if control is not None: attrs['control'] = control if input is not None: attrs['input'] = input self._data.append(o) def request_cancel_external_workflow_execution(self, workflow_id, control=None, run_id=None): """ Requests that a request be made to cancel the specified external workflow execution and records a RequestCancelExternalWorkflowExecutionInitiated event in the history. """ o = {} o['decisionType'] = 'RequestCancelExternalWorkflowExecution' attrs = o['requestCancelExternalWorkflowExecutionDecisionAttributes'] = {} attrs['workflowId'] = workflow_id if control is not None: attrs['control'] = control if run_id is not None: attrs['runId'] = run_id self._data.append(o) def start_child_workflow_execution(self, workflow_type_name, workflow_type_version, workflow_id, child_policy=None, control=None, execution_start_to_close_timeout=None, input=None, tag_list=None, task_list=None, task_start_to_close_timeout=None): """ Requests that a child workflow execution be started and records a StartChildWorkflowExecutionInitiated event in the history. The child workflow execution is a separate workflow execution with its own history. """ o = {} o['decisionType'] = 'StartChildWorkflowExecution' attrs = o['startChildWorkflowExecutionDecisionAttributes'] = {} attrs['workflowType'] = { 'name': workflow_type_name, 'version': workflow_type_version, } attrs['workflowId'] = workflow_id if child_policy is not None: attrs['childPolicy'] = child_policy if control is not None: attrs['control'] = control if execution_start_to_close_timeout is not None: attrs['executionStartToCloseTimeout'] = execution_start_to_close_timeout if input is not None: attrs['input'] = input if tag_list is not None: attrs['tagList'] = tag_list if task_list is not None: attrs['taskList'] = {'name': task_list} if task_start_to_close_timeout is not None: attrs['taskStartToCloseTimeout'] = task_start_to_close_timeout self._data.append(o)
apache-2.0
[ 624, 199, 4433, 1021, 367, 6425, 14692, 9320, 14, 199, 624, 421, 199, 533, 11915, 17, 872, 559, 1356, 8, 785, 304, 272, 408, 272, 3645, 642, 909, 370, 1900, 282, 769, 402, 12985, 1356, 367, 282, 14692, 1177, 14, 272, 7048, 1083, 1240, 911, 1050, 5666, 282, 892, 14692, 14, 221, 13939, 314, 769, 272, 402, 12985, 1356, 687, 314, 485, 576, 2225, 14, 339, 408, 272, 347, 636, 826, 721, 277, 304, 267, 291, 423, 576, 275, 942, 339, 347, 8732, 63, 8240, 63, 1765, 8, 277, 12, 3044, 10679, 63, 344, 12, 3044, 10679, 63, 466, 63, 354, 12, 3044, 10679, 63, 466, 63, 1023, 12, 3044, 2120, 63, 513, 29, 403, 12, 3044, 3304, 29, 403, 12, 3044, 32015, 63, 2593, 29, 403, 12, 3044, 8732, 63, 475, 63, 1600, 63, 2593, 29, 403, 12, 3044, 8732, 63, 475, 63, 928, 63, 2593, 29, 403, 12, 3044, 1343, 63, 475, 63, 1600, 63, 2593, 29, 403, 12, 3044, 1324, 29, 403, 304, 267, 408, 267, 24317, 83, 376, 10679, 2120, 14, 398, 520, 466, 10679, 63, 344, 26, 1059, 267, 520, 635, 10679, 63, 344, 26, 710, 10679, 1304, 402, 314, 730, 402, 314, 10679, 288, 3769, 18416, 14, 398, 520, 466, 10679, 63, 466, 63, 354, 26, 1059, 267, 520, 635, 10679, 63, 466, 63, 354, 26, 710, 536, 402, 314, 730, 402, 314, 10679, 288, 3769, 18416, 14, 398, 520, 466, 10679, 63, 466, 63, 1023, 26, 1059, 267, 520, 635, 10679, 63, 466, 63, 1023, 26, 710, 1015, 402, 314, 730, 402, 314, 288, 10679, 3769, 18416, 14, 398, 520, 466, 2120, 63, 513, 26, 1059, 267, 520, 635, 2120, 63, 513, 26, 982, 663, 12, 9314, 314, 536, 402, 314, 2120, 769, 315, 288, 1314, 370, 8732, 314, 10679, 2120, 14, 982, 440, 2013, 12, 314, 288, 849, 4476, 1296, 7264, 543, 314, 10679, 730, 911, 506, 1202, 14, 288, 3390, 26, 282, 2120, 769, 367, 642, 10679, 2120, 1471, 506, 2013, 1902, 288, 465, 282, 849, 367, 314, 10679, 730, 503, 4012, 642, 901, 14, 982, 288, 15564, 642, 901, 365, 663, 6590, 282, 849, 2120, 769, 1990, 2013, 288, 737, 10991, 900, 2066, 282, 16898, 911, 506, 2138, 14, 267, 408, 267, 312, 275, 1052, 267, 312, 459, 16622, 804, 418, 275, 283, 15535, 14350, 4476, 7, 267, 3290, 275, 312, 459, 7211, 14350, 4476, 872, 3688, 5379, 418, 275, 1052, 267, 3290, 459, 8240, 1304, 418, 275, 10679, 63, 344, 267, 3290, 459, 8240, 804, 418, 275, 469, 288, 283, 354, 356, 10679, 63, 466, 63, 354, 12, 288, 283, 1023, 356, 10679, 63, 466, 63, 1023, 12, 267, 789, 267, 340, 2120, 63, 513, 365, 440, 488, 26, 288, 3290, 459, 1765, 1296, 418, 275, 791, 354, 356, 2120, 63, 513, 93, 267, 340, 3304, 365, 440, 488, 26, 288, 3290, 459, 2785, 418, 275, 3304, 267, 340, 32015, 63, 2593, 365, 440, 488, 26, 288, 3290, 459, 22685, 6372, 418, 275, 32015, 63, 2593, 267, 340, 8732, 63, 475, 63, 1600, 63, 2593, 365, 440, 488, 26, 288, 3290, 459, 7211, 1378, 4724, 6372, 418, 275, 8732, 63, 475, 63, 1600, 63, 2593, 267, 340, 8732, 63, 475, 63, 928, 63, 2593, 365, 440, 488, 26, 288, 3290, 459, 7211, 1378, 3162, 6372, 418, 275, 8732, 63, 475, 63, 928, 63, 2593, 267, 340, 1343, 63, 475, 63, 1600, 63, 2593, 365, 440, 488, 26, 288, 3290, 459, 928, 1378, 4724, 6372, 418, 275, 1343, 63, 475, 63, 1600, 63, 2593, 267, 340, 1324, 365, 440, 488, 26, 288, 3290, 459, 1210, 418, 275, 1324, 267, 291, 423, 576, 14, 740, 8, 79, 9, 339, 347, 1056, 63, 6406, 63, 8240, 63, 1765, 8, 277, 12, 10679, 63, 344, 304, 267, 408, 267, 17413, 1086, 370, 9311, 282, 10889, 18416, 10679, 2120, 14, 982, 267, 314, 10679, 2120, 1990, 18416, 1325, 965, 440, 2757, 7943, 370, 282, 267, 7239, 12, 2066, 652, 911, 506, 286, 18959, 14, 982, 314, 10679, 2120, 1990, 267, 2575, 7943, 370, 282, 7239, 12, 2066, 314, 7239, 911, 506, 315, 6194, 267, 626, 9311, 2212, 965, 2757, 5839, 315, 314, 1177, 370, 267, 12651, 14350, 4476, 1966, 16145, 14, 267, 408, 267, 312, 275, 1052, 267, 312, 459, 16622, 804, 418, 275, 283, 2017, 9083, 14350, 4476, 7, 267, 3290, 275, 312, 459, 1069, 9083, 14350, 4476, 872, 3688, 5379, 418, 275, 1052, 267, 3290, 459, 8240, 1304, 418, 275, 10679, 63, 344, 267, 291, 423, 576, 14, 740, 8, 79, 9, 339, 347, 2777, 63, 4211, 8, 277, 12, 3608, 63, 354, 12, 2436, 29, 403, 304, 267, 408, 267, 799, 3692, 282, 26903, 497, 15402, 1566, 315, 314, 7994, 14, 7173, 1192, 883, 506, 267, 1202, 367, 7791, 3537, 2556, 315, 314, 7994, 367, 1256, 267, 370, 4691, 12985, 7735, 5715, 626, 2985, 886, 440, 1929, 370, 3648, 737, 314, 267, 7994, 20561, 314, 3608, 1566, 14, 267, 408, 267, 312, 275, 1052, 267, 312, 459, 16622, 804, 418, 275, 283, 5433, 12825, 7, 267, 3290, 275, 312, 459, 3059, 12825, 872, 3688, 5379, 418, 275, 1052, 267, 3290, 459, 4211, 985, 418, 275, 3608, 63, 354, 267, 340, 2436, 365, 440, 488, 26, 288, 3290, 459, 5087, 418, 275, 2436, 267, 291, 423, 576, 14, 740, 8, 79, 9, 339, 347, 4890, 63, 8856, 63, 9416, 8, 277, 12, 754, 29, 403, 304, 267, 408, 267, 5980, 874, 314, 10431, 6451, 436, 5767, 282, 27282, 11310, 19908, 267, 1566, 315, 314, 7994, 267, 408, 267, 312, 275, 1052, 267, 312, 459, 16622, 804, 418, 275, 283, 14175, 17527, 11310, 7, 267, 3290, 275, 312, 459, 4883, 17527, 11310, 872, 3688, 5379, 418, 275, 1052, 267, 340, 754, 365, 440, 488, 26, 288, 3290, 459, 1099, 418, 275, 754, 267, 291, 423, 576, 14, 740, 8, 79, 9, 339, 347, 2449, 63, 8856, 63, 9416, 8, 277, 12, 4499, 29, 403, 12, 2436, 29, 403, 304, 267, 408, 267, 5980, 874, 314, 10431, 6451, 436, 5767, 282, 267, 27282, 11310, 4276, 1566, 315, 314, 7994, 14, 267, 408, 267, 312, 275, 1052, 267, 312, 459, 16622, 804, 418, 275, 283, 4874, 17527, 11310, 7 ]
[ 199, 4433, 1021, 367, 6425, 14692, 9320, 14, 199, 624, 421, 199, 533, 11915, 17, 872, 559, 1356, 8, 785, 304, 272, 408, 272, 3645, 642, 909, 370, 1900, 282, 769, 402, 12985, 1356, 367, 282, 14692, 1177, 14, 272, 7048, 1083, 1240, 911, 1050, 5666, 282, 892, 14692, 14, 221, 13939, 314, 769, 272, 402, 12985, 1356, 687, 314, 485, 576, 2225, 14, 339, 408, 272, 347, 636, 826, 721, 277, 304, 267, 291, 423, 576, 275, 942, 339, 347, 8732, 63, 8240, 63, 1765, 8, 277, 12, 3044, 10679, 63, 344, 12, 3044, 10679, 63, 466, 63, 354, 12, 3044, 10679, 63, 466, 63, 1023, 12, 3044, 2120, 63, 513, 29, 403, 12, 3044, 3304, 29, 403, 12, 3044, 32015, 63, 2593, 29, 403, 12, 3044, 8732, 63, 475, 63, 1600, 63, 2593, 29, 403, 12, 3044, 8732, 63, 475, 63, 928, 63, 2593, 29, 403, 12, 3044, 1343, 63, 475, 63, 1600, 63, 2593, 29, 403, 12, 3044, 1324, 29, 403, 304, 267, 408, 267, 24317, 83, 376, 10679, 2120, 14, 398, 520, 466, 10679, 63, 344, 26, 1059, 267, 520, 635, 10679, 63, 344, 26, 710, 10679, 1304, 402, 314, 730, 402, 314, 10679, 288, 3769, 18416, 14, 398, 520, 466, 10679, 63, 466, 63, 354, 26, 1059, 267, 520, 635, 10679, 63, 466, 63, 354, 26, 710, 536, 402, 314, 730, 402, 314, 10679, 288, 3769, 18416, 14, 398, 520, 466, 10679, 63, 466, 63, 1023, 26, 1059, 267, 520, 635, 10679, 63, 466, 63, 1023, 26, 710, 1015, 402, 314, 730, 402, 314, 288, 10679, 3769, 18416, 14, 398, 520, 466, 2120, 63, 513, 26, 1059, 267, 520, 635, 2120, 63, 513, 26, 982, 663, 12, 9314, 314, 536, 402, 314, 2120, 769, 315, 288, 1314, 370, 8732, 314, 10679, 2120, 14, 982, 440, 2013, 12, 314, 288, 849, 4476, 1296, 7264, 543, 314, 10679, 730, 911, 506, 1202, 14, 288, 3390, 26, 282, 2120, 769, 367, 642, 10679, 2120, 1471, 506, 2013, 1902, 288, 465, 282, 849, 367, 314, 10679, 730, 503, 4012, 642, 901, 14, 982, 288, 15564, 642, 901, 365, 663, 6590, 282, 849, 2120, 769, 1990, 2013, 288, 737, 10991, 900, 2066, 282, 16898, 911, 506, 2138, 14, 267, 408, 267, 312, 275, 1052, 267, 312, 459, 16622, 804, 418, 275, 283, 15535, 14350, 4476, 7, 267, 3290, 275, 312, 459, 7211, 14350, 4476, 872, 3688, 5379, 418, 275, 1052, 267, 3290, 459, 8240, 1304, 418, 275, 10679, 63, 344, 267, 3290, 459, 8240, 804, 418, 275, 469, 288, 283, 354, 356, 10679, 63, 466, 63, 354, 12, 288, 283, 1023, 356, 10679, 63, 466, 63, 1023, 12, 267, 789, 267, 340, 2120, 63, 513, 365, 440, 488, 26, 288, 3290, 459, 1765, 1296, 418, 275, 791, 354, 356, 2120, 63, 513, 93, 267, 340, 3304, 365, 440, 488, 26, 288, 3290, 459, 2785, 418, 275, 3304, 267, 340, 32015, 63, 2593, 365, 440, 488, 26, 288, 3290, 459, 22685, 6372, 418, 275, 32015, 63, 2593, 267, 340, 8732, 63, 475, 63, 1600, 63, 2593, 365, 440, 488, 26, 288, 3290, 459, 7211, 1378, 4724, 6372, 418, 275, 8732, 63, 475, 63, 1600, 63, 2593, 267, 340, 8732, 63, 475, 63, 928, 63, 2593, 365, 440, 488, 26, 288, 3290, 459, 7211, 1378, 3162, 6372, 418, 275, 8732, 63, 475, 63, 928, 63, 2593, 267, 340, 1343, 63, 475, 63, 1600, 63, 2593, 365, 440, 488, 26, 288, 3290, 459, 928, 1378, 4724, 6372, 418, 275, 1343, 63, 475, 63, 1600, 63, 2593, 267, 340, 1324, 365, 440, 488, 26, 288, 3290, 459, 1210, 418, 275, 1324, 267, 291, 423, 576, 14, 740, 8, 79, 9, 339, 347, 1056, 63, 6406, 63, 8240, 63, 1765, 8, 277, 12, 10679, 63, 344, 304, 267, 408, 267, 17413, 1086, 370, 9311, 282, 10889, 18416, 10679, 2120, 14, 982, 267, 314, 10679, 2120, 1990, 18416, 1325, 965, 440, 2757, 7943, 370, 282, 267, 7239, 12, 2066, 652, 911, 506, 286, 18959, 14, 982, 314, 10679, 2120, 1990, 267, 2575, 7943, 370, 282, 7239, 12, 2066, 314, 7239, 911, 506, 315, 6194, 267, 626, 9311, 2212, 965, 2757, 5839, 315, 314, 1177, 370, 267, 12651, 14350, 4476, 1966, 16145, 14, 267, 408, 267, 312, 275, 1052, 267, 312, 459, 16622, 804, 418, 275, 283, 2017, 9083, 14350, 4476, 7, 267, 3290, 275, 312, 459, 1069, 9083, 14350, 4476, 872, 3688, 5379, 418, 275, 1052, 267, 3290, 459, 8240, 1304, 418, 275, 10679, 63, 344, 267, 291, 423, 576, 14, 740, 8, 79, 9, 339, 347, 2777, 63, 4211, 8, 277, 12, 3608, 63, 354, 12, 2436, 29, 403, 304, 267, 408, 267, 799, 3692, 282, 26903, 497, 15402, 1566, 315, 314, 7994, 14, 7173, 1192, 883, 506, 267, 1202, 367, 7791, 3537, 2556, 315, 314, 7994, 367, 1256, 267, 370, 4691, 12985, 7735, 5715, 626, 2985, 886, 440, 1929, 370, 3648, 737, 314, 267, 7994, 20561, 314, 3608, 1566, 14, 267, 408, 267, 312, 275, 1052, 267, 312, 459, 16622, 804, 418, 275, 283, 5433, 12825, 7, 267, 3290, 275, 312, 459, 3059, 12825, 872, 3688, 5379, 418, 275, 1052, 267, 3290, 459, 4211, 985, 418, 275, 3608, 63, 354, 267, 340, 2436, 365, 440, 488, 26, 288, 3290, 459, 5087, 418, 275, 2436, 267, 291, 423, 576, 14, 740, 8, 79, 9, 339, 347, 4890, 63, 8856, 63, 9416, 8, 277, 12, 754, 29, 403, 304, 267, 408, 267, 5980, 874, 314, 10431, 6451, 436, 5767, 282, 27282, 11310, 19908, 267, 1566, 315, 314, 7994, 267, 408, 267, 312, 275, 1052, 267, 312, 459, 16622, 804, 418, 275, 283, 14175, 17527, 11310, 7, 267, 3290, 275, 312, 459, 4883, 17527, 11310, 872, 3688, 5379, 418, 275, 1052, 267, 340, 754, 365, 440, 488, 26, 288, 3290, 459, 1099, 418, 275, 754, 267, 291, 423, 576, 14, 740, 8, 79, 9, 339, 347, 2449, 63, 8856, 63, 9416, 8, 277, 12, 4499, 29, 403, 12, 2436, 29, 403, 304, 267, 408, 267, 5980, 874, 314, 10431, 6451, 436, 5767, 282, 267, 27282, 11310, 4276, 1566, 315, 314, 7994, 14, 267, 408, 267, 312, 275, 1052, 267, 312, 459, 16622, 804, 418, 275, 283, 4874, 17527, 11310, 7, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
JingJunYin/tensorflow
tensorflow/tools/api/generator/create_python_api_test.py
32
2857
# 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. # ============================================================================= """Tests for create_python_api.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import imp import sys from tensorflow.python.platform import test from tensorflow.python.util.tf_export import tf_export from tensorflow.tools.api.generator import create_python_api @tf_export('test_op', 'test_op1') def test_op(): pass @tf_export('TestClass', 'NewTestClass') class TestClass(object): pass _TEST_CONSTANT = 5 _MODULE_NAME = 'test.tensorflow.test_module' class CreatePythonApiTest(test.TestCase): def setUp(self): # Add fake op to a module that has 'tensorflow' in the name. sys.modules[_MODULE_NAME] = imp.new_module(_MODULE_NAME) setattr(sys.modules[_MODULE_NAME], 'test_op', test_op) setattr(sys.modules[_MODULE_NAME], 'TestClass', TestClass) test_op.__module__ = _MODULE_NAME TestClass.__module__ = _MODULE_NAME tf_export('consts._TEST_CONSTANT').export_constant( _MODULE_NAME, '_TEST_CONSTANT') def tearDown(self): del sys.modules[_MODULE_NAME] def testFunctionImportIsAdded(self): imports = create_python_api.get_api_imports() expected_import = ( 'from test.tensorflow.test_module import test_op as test_op1') self.assertTrue( expected_import in str(imports), msg='%s not in %s' % (expected_import, str(imports))) expected_import = 'from test.tensorflow.test_module import test_op' self.assertTrue( expected_import in str(imports), msg='%s not in %s' % (expected_import, str(imports))) def testClassImportIsAdded(self): imports = create_python_api.get_api_imports() expected_import = 'from test.tensorflow.test_module import TestClass' self.assertTrue( 'TestClass' in str(imports), msg='%s not in %s' % (expected_import, str(imports))) def testConstantIsAdded(self): imports = create_python_api.get_api_imports() expected = 'from test.tensorflow.test_module import _TEST_CONSTANT' self.assertTrue(expected in str(imports), msg='%s not in %s' % (expected, str(imports))) if __name__ == '__main__': test.main()
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, 26237, 199, 624, 2925, 367, 1218, 63, 1548, 63, 1246, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 1742, 199, 646, 984, 199, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 1974, 14, 3249, 63, 3790, 492, 2833, 63, 3790, 199, 504, 3228, 14, 2537, 14, 1246, 14, 4679, 492, 1218, 63, 1548, 63, 1246, 421, 199, 32, 3249, 63, 3790, 360, 396, 63, 411, 297, 283, 396, 63, 411, 17, 358, 199, 318, 511, 63, 411, 837, 523, 986, 421, 199, 32, 3249, 63, 3790, 360, 22009, 297, 283, 4665, 22009, 358, 199, 533, 1379, 2543, 8, 785, 304, 523, 986, 421, 199, 63, 2864, 63, 25825, 275, 959, 199, 63, 10001, 63, 2339, 275, 283, 396, 14, 16008, 14, 396, 63, 578, 7, 421, 199, 533, 2790, 4718, 7394, 774, 8, 396, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 327, 2654, 4026, 1687, 370, 282, 859, 626, 965, 283, 16008, 7, 315, 314, 536, 14, 272, 984, 14, 3112, 13040, 10001, 63, 2339, 61, 275, 1742, 14, 1222, 63, 578, 1547, 10001, 63, 2339, 9, 272, 5371, 8, 1274, 14, 3112, 13040, 10001, 63, 2339, 467, 283, 396, 63, 411, 297, 511, 63, 411, 9, 272, 5371, 8, 1274, 14, 3112, 13040, 10001, 63, 2339, 467, 283, 22009, 297, 1379, 2543, 9, 272, 511, 63, 411, 855, 578, 363, 275, 485, 10001, 63, 2339, 272, 1379, 2543, 855, 578, 363, 275, 485, 10001, 63, 2339, 272, 2833, 63, 3790, 360, 20473, 423, 2864, 63, 25825, 1959, 3790, 63, 4083, 8, 267, 485, 10001, 63, 2339, 12, 2513, 2864, 63, 25825, 358, 819, 347, 6766, 8, 277, 304, 272, 2150, 984, 14, 3112, 13040, 10001, 63, 2339, 61, 819, 347, 511, 3481, 6295, 1831, 20201, 8, 277, 304, 272, 8925, 275, 1218, 63, 1548, 63, 1246, 14, 362, 63, 1246, 63, 12775, 342, 272, 1420, 63, 646, 275, 334, 267, 283, 504, 511, 14, 16008, 14, 396, 63, 578, 492, 511, 63, 411, 465, 511, 63, 411, 17, 358, 272, 291, 14, 1815, 8, 267, 1420, 63, 646, 315, 620, 8, 12775, 395, 267, 1499, 9569, 83, 440, 315, 450, 83, 7, 450, 334, 2062, 63, 646, 12, 620, 8, 12775, 1724, 339, 1420, 63, 646, 275, 283, 504, 511, 14, 16008, 14, 396, 63, 578, 492, 511, 63, 411, 7, 272, 291, 14, 1815, 8, 267, 1420, 63, 646, 315, 620, 8, 12775, 395, 267, 1499, 9569, 83, 440, 315, 450, 83, 7, 450, 334, 2062, 63, 646, 12, 620, 8, 12775, 1724, 819, 347, 511, 2543, 6295, 1831, 20201, 8, 277, 304, 272, 8925, 275, 1218, 63, 1548, 63, 1246, 14, 362, 63, 1246, 63, 12775, 342, 272, 1420, 63, 646, 275, 283, 504, 511, 14, 16008, 14, 396, 63, 578, 492, 1379, 2543, 7, 272, 291, 14, 1815, 8, 267, 283, 22009, 7, 315, 620, 8, 12775, 395, 267, 1499, 9569, 83, 440, 315, 450, 83, 7, 450, 334, 2062, 63, 646, 12, 620, 8, 12775, 1724, 819, 347, 511, 9737, 1831, 20201, 8, 277, 304, 272, 8925, 275, 1218, 63, 1548, 63, 1246, 14, 362, 63, 1246, 63, 12775, 342, 272, 1420, 275, 283, 504, 511, 14, 16008, 14, 396, 63, 578, 492, 485, 2864, 63, 25825, 7, 272, 291, 14, 1815, 8, 2062, 315, 620, 8, 12775, 395, 490, 1499, 9569, 83, 440, 315, 450, 83, 7, 450, 334, 2062, 12, 620, 8, 12775, 1724, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 511, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 26237, 199, 624, 2925, 367, 1218, 63, 1548, 63, 1246, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 1742, 199, 646, 984, 199, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 1974, 14, 3249, 63, 3790, 492, 2833, 63, 3790, 199, 504, 3228, 14, 2537, 14, 1246, 14, 4679, 492, 1218, 63, 1548, 63, 1246, 421, 199, 32, 3249, 63, 3790, 360, 396, 63, 411, 297, 283, 396, 63, 411, 17, 358, 199, 318, 511, 63, 411, 837, 523, 986, 421, 199, 32, 3249, 63, 3790, 360, 22009, 297, 283, 4665, 22009, 358, 199, 533, 1379, 2543, 8, 785, 304, 523, 986, 421, 199, 63, 2864, 63, 25825, 275, 959, 199, 63, 10001, 63, 2339, 275, 283, 396, 14, 16008, 14, 396, 63, 578, 7, 421, 199, 533, 2790, 4718, 7394, 774, 8, 396, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 327, 2654, 4026, 1687, 370, 282, 859, 626, 965, 283, 16008, 7, 315, 314, 536, 14, 272, 984, 14, 3112, 13040, 10001, 63, 2339, 61, 275, 1742, 14, 1222, 63, 578, 1547, 10001, 63, 2339, 9, 272, 5371, 8, 1274, 14, 3112, 13040, 10001, 63, 2339, 467, 283, 396, 63, 411, 297, 511, 63, 411, 9, 272, 5371, 8, 1274, 14, 3112, 13040, 10001, 63, 2339, 467, 283, 22009, 297, 1379, 2543, 9, 272, 511, 63, 411, 855, 578, 363, 275, 485, 10001, 63, 2339, 272, 1379, 2543, 855, 578, 363, 275, 485, 10001, 63, 2339, 272, 2833, 63, 3790, 360, 20473, 423, 2864, 63, 25825, 1959, 3790, 63, 4083, 8, 267, 485, 10001, 63, 2339, 12, 2513, 2864, 63, 25825, 358, 819, 347, 6766, 8, 277, 304, 272, 2150, 984, 14, 3112, 13040, 10001, 63, 2339, 61, 819, 347, 511, 3481, 6295, 1831, 20201, 8, 277, 304, 272, 8925, 275, 1218, 63, 1548, 63, 1246, 14, 362, 63, 1246, 63, 12775, 342, 272, 1420, 63, 646, 275, 334, 267, 283, 504, 511, 14, 16008, 14, 396, 63, 578, 492, 511, 63, 411, 465, 511, 63, 411, 17, 358, 272, 291, 14, 1815, 8, 267, 1420, 63, 646, 315, 620, 8, 12775, 395, 267, 1499, 9569, 83, 440, 315, 450, 83, 7, 450, 334, 2062, 63, 646, 12, 620, 8, 12775, 1724, 339, 1420, 63, 646, 275, 283, 504, 511, 14, 16008, 14, 396, 63, 578, 492, 511, 63, 411, 7, 272, 291, 14, 1815, 8, 267, 1420, 63, 646, 315, 620, 8, 12775, 395, 267, 1499, 9569, 83, 440, 315, 450, 83, 7, 450, 334, 2062, 63, 646, 12, 620, 8, 12775, 1724, 819, 347, 511, 2543, 6295, 1831, 20201, 8, 277, 304, 272, 8925, 275, 1218, 63, 1548, 63, 1246, 14, 362, 63, 1246, 63, 12775, 342, 272, 1420, 63, 646, 275, 283, 504, 511, 14, 16008, 14, 396, 63, 578, 492, 1379, 2543, 7, 272, 291, 14, 1815, 8, 267, 283, 22009, 7, 315, 620, 8, 12775, 395, 267, 1499, 9569, 83, 440, 315, 450, 83, 7, 450, 334, 2062, 63, 646, 12, 620, 8, 12775, 1724, 819, 347, 511, 9737, 1831, 20201, 8, 277, 304, 272, 8925, 275, 1218, 63, 1548, 63, 1246, 14, 362, 63, 1246, 63, 12775, 342, 272, 1420, 275, 283, 504, 511, 14, 16008, 14, 396, 63, 578, 492, 485, 2864, 63, 25825, 7, 272, 291, 14, 1815, 8, 2062, 315, 620, 8, 12775, 395, 490, 1499, 9569, 83, 440, 315, 450, 83, 7, 450, 334, 2062, 12, 620, 8, 12775, 1724, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 511, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mhogg/scipy
scipy/sparse/linalg/isolve/setup.py
108
1408
#!/usr/bin/env python from __future__ import division, print_function, absolute_import from os.path import join def configuration(parent_package='',top_path=None): from numpy.distutils.system_info import get_info, NotFoundError from numpy.distutils.misc_util import Configuration from scipy._build_utils import get_g77_abi_wrappers config = Configuration('isolve',parent_package,top_path) lapack_opt = get_info('lapack_opt') if not lapack_opt: raise NotFoundError('no lapack/blas resources found') # iterative methods methods = ['BiCGREVCOM.f.src', 'BiCGSTABREVCOM.f.src', 'CGREVCOM.f.src', 'CGSREVCOM.f.src', # 'ChebyREVCOM.f.src', 'GMRESREVCOM.f.src', # 'JacobiREVCOM.f.src', 'QMRREVCOM.f.src', # 'SORREVCOM.f.src' ] Util = ['STOPTEST2.f.src','getbreak.f.src'] sources = Util + methods + ['_iterative.pyf.src'] sources = [join('iterative', x) for x in sources] sources += get_g77_abi_wrappers(lapack_opt) config.add_extension('_iterative', sources=sources, extra_info=lapack_opt) config.add_data_dir('tests') return config if __name__ == '__main__': from numpy.distutils.core import setup setup(**configuration(top_path='').todict())
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 504, 747, 14, 515, 492, 4263, 421, 199, 318, 2897, 8, 1708, 63, 2491, 4581, 2119, 63, 515, 29, 403, 304, 272, 687, 2680, 14, 13350, 14, 2253, 63, 815, 492, 664, 63, 815, 12, 21909, 547, 272, 687, 2680, 14, 13350, 14, 9923, 63, 1974, 492, 11595, 272, 687, 7026, 423, 1506, 63, 1208, 492, 664, 63, 71, 1138, 63, 14677, 63, 21148, 339, 1101, 275, 11595, 360, 374, 3344, 297, 1708, 63, 2491, 12, 2119, 63, 515, 9, 339, 1127, 1389, 63, 2992, 275, 664, 63, 815, 360, 26760, 63, 2992, 358, 339, 340, 440, 1127, 1389, 63, 2992, 26, 267, 746, 21909, 547, 360, 889, 1127, 1389, 15, 21044, 5944, 1911, 358, 339, 327, 4826, 857, 3102, 272, 3102, 275, 788, 17975, 4064, 23817, 11265, 14, 70, 14, 2164, 297, 2049, 283, 17975, 4064, 840, 1217, 23817, 11265, 14, 70, 14, 2164, 297, 2049, 283, 4064, 23817, 11265, 14, 70, 14, 2164, 297, 2049, 283, 4064, 51, 23817, 11265, 14, 70, 14, 2164, 297, 199, 3, 5185, 283, 20335, 991, 23817, 11265, 14, 70, 14, 2164, 297, 2049, 283, 22636, 3830, 23817, 11265, 14, 70, 14, 2164, 297, 199, 3, 5185, 283, 42, 13286, 4492, 23817, 11265, 14, 70, 14, 2164, 297, 2049, 283, 49, 22153, 23817, 11265, 14, 70, 14, 2164, 297, 199, 3, 5185, 283, 26508, 23817, 11265, 14, 70, 14, 2164, 7, 2049, 1622, 339, 21248, 275, 788, 11632, 2864, 18, 14, 70, 14, 2164, 1673, 362, 4785, 14, 70, 14, 2164, 418, 272, 5274, 275, 21248, 435, 3102, 435, 4044, 1175, 30498, 14, 647, 70, 14, 2164, 418, 272, 5274, 275, 359, 904, 360, 1175, 30498, 297, 671, 9, 367, 671, 315, 5274, 61, 272, 5274, 847, 664, 63, 71, 1138, 63, 14677, 63, 21148, 8, 26760, 63, 2992, 9, 339, 1101, 14, 525, 63, 3435, 6412, 1175, 30498, 297, 586, 5274, 29, 4553, 12, 586, 2402, 63, 815, 29, 26760, 63, 2992, 9, 339, 1101, 14, 525, 63, 576, 63, 694, 360, 2219, 358, 339, 372, 1101, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 2680, 14, 13350, 14, 1018, 492, 3272, 339, 3272, 3682, 4758, 8, 2119, 63, 515, 534, 1959, 475, 807, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 504, 747, 14, 515, 492, 4263, 421, 199, 318, 2897, 8, 1708, 63, 2491, 4581, 2119, 63, 515, 29, 403, 304, 272, 687, 2680, 14, 13350, 14, 2253, 63, 815, 492, 664, 63, 815, 12, 21909, 547, 272, 687, 2680, 14, 13350, 14, 9923, 63, 1974, 492, 11595, 272, 687, 7026, 423, 1506, 63, 1208, 492, 664, 63, 71, 1138, 63, 14677, 63, 21148, 339, 1101, 275, 11595, 360, 374, 3344, 297, 1708, 63, 2491, 12, 2119, 63, 515, 9, 339, 1127, 1389, 63, 2992, 275, 664, 63, 815, 360, 26760, 63, 2992, 358, 339, 340, 440, 1127, 1389, 63, 2992, 26, 267, 746, 21909, 547, 360, 889, 1127, 1389, 15, 21044, 5944, 1911, 358, 339, 327, 4826, 857, 3102, 272, 3102, 275, 788, 17975, 4064, 23817, 11265, 14, 70, 14, 2164, 297, 2049, 283, 17975, 4064, 840, 1217, 23817, 11265, 14, 70, 14, 2164, 297, 2049, 283, 4064, 23817, 11265, 14, 70, 14, 2164, 297, 2049, 283, 4064, 51, 23817, 11265, 14, 70, 14, 2164, 297, 199, 3, 5185, 283, 20335, 991, 23817, 11265, 14, 70, 14, 2164, 297, 2049, 283, 22636, 3830, 23817, 11265, 14, 70, 14, 2164, 297, 199, 3, 5185, 283, 42, 13286, 4492, 23817, 11265, 14, 70, 14, 2164, 297, 2049, 283, 49, 22153, 23817, 11265, 14, 70, 14, 2164, 297, 199, 3, 5185, 283, 26508, 23817, 11265, 14, 70, 14, 2164, 7, 2049, 1622, 339, 21248, 275, 788, 11632, 2864, 18, 14, 70, 14, 2164, 1673, 362, 4785, 14, 70, 14, 2164, 418, 272, 5274, 275, 21248, 435, 3102, 435, 4044, 1175, 30498, 14, 647, 70, 14, 2164, 418, 272, 5274, 275, 359, 904, 360, 1175, 30498, 297, 671, 9, 367, 671, 315, 5274, 61, 272, 5274, 847, 664, 63, 71, 1138, 63, 14677, 63, 21148, 8, 26760, 63, 2992, 9, 339, 1101, 14, 525, 63, 3435, 6412, 1175, 30498, 297, 586, 5274, 29, 4553, 12, 586, 2402, 63, 815, 29, 26760, 63, 2992, 9, 339, 1101, 14, 525, 63, 576, 63, 694, 360, 2219, 358, 339, 372, 1101, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 2680, 14, 13350, 14, 1018, 492, 3272, 339, 3272, 3682, 4758, 8, 2119, 63, 515, 534, 1959, 475, 807, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Basis/pip
pip/_vendor/html5lib/filters/optionaltags.py
1727
10500
from __future__ import absolute_import, division, unicode_literals from . import _base class Filter(_base.Filter): def slider(self): previous1 = previous2 = None for token in self.source: if previous1 is not None: yield previous2, previous1, token previous2 = previous1 previous1 = token yield previous2, previous1, None def __iter__(self): for previous, token, next in self.slider(): type = token["type"] if type == "StartTag": if (token["data"] or not self.is_optional_start(token["name"], previous, next)): yield token elif type == "EndTag": if not self.is_optional_end(token["name"], next): yield token else: yield token def is_optional_start(self, tagname, previous, next): type = next and next["type"] or None if tagname in 'html': # An html element's start tag may be omitted if the first thing # inside the html element is not a space character or a comment. return type not in ("Comment", "SpaceCharacters") elif tagname == 'head': # A head element's start tag may be omitted if the first thing # inside the head element is an element. # XXX: we also omit the start tag if the head element is empty if type in ("StartTag", "EmptyTag"): return True elif type == "EndTag": return next["name"] == "head" elif tagname == 'body': # A body element's start tag may be omitted if the first thing # inside the body element is not a space character or a comment, # except if the first thing inside the body element is a script # or style element and the node immediately preceding the body # element is a head element whose end tag has been omitted. if type in ("Comment", "SpaceCharacters"): return False elif type == "StartTag": # XXX: we do not look at the preceding event, so we never omit # the body element's start tag if it's followed by a script or # a style element. return next["name"] not in ('script', 'style') else: return True elif tagname == 'colgroup': # A colgroup element's start tag may be omitted if the first thing # inside the colgroup element is a col element, and if the element # is not immediately preceeded by another colgroup element whose # end tag has been omitted. if type in ("StartTag", "EmptyTag"): # XXX: we do not look at the preceding event, so instead we never # omit the colgroup element's end tag when it is immediately # followed by another colgroup element. See is_optional_end. return next["name"] == "col" else: return False elif tagname == 'tbody': # A tbody element's start tag may be omitted if the first thing # inside the tbody element is a tr element, and if the element is # not immediately preceeded by a tbody, thead, or tfoot element # whose end tag has been omitted. if type == "StartTag": # omit the thead and tfoot elements' end tag when they are # immediately followed by a tbody element. See is_optional_end. if previous and previous['type'] == 'EndTag' and \ previous['name'] in ('tbody', 'thead', 'tfoot'): return False return next["name"] == 'tr' else: return False return False def is_optional_end(self, tagname, next): type = next and next["type"] or None if tagname in ('html', 'head', 'body'): # An html element's end tag may be omitted if the html element # is not immediately followed by a space character or a comment. return type not in ("Comment", "SpaceCharacters") elif tagname in ('li', 'optgroup', 'tr'): # A li element's end tag may be omitted if the li element is # immediately followed by another li element or if there is # no more content in the parent element. # An optgroup element's end tag may be omitted if the optgroup # element is immediately followed by another optgroup element, # or if there is no more content in the parent element. # A tr element's end tag may be omitted if the tr element is # immediately followed by another tr element, or if there is # no more content in the parent element. if type == "StartTag": return next["name"] == tagname else: return type == "EndTag" or type is None elif tagname in ('dt', 'dd'): # A dt element's end tag may be omitted if the dt element is # immediately followed by another dt element or a dd element. # A dd element's end tag may be omitted if the dd element is # immediately followed by another dd element or a dt element, # or if there is no more content in the parent element. if type == "StartTag": return next["name"] in ('dt', 'dd') elif tagname == 'dd': return type == "EndTag" or type is None else: return False elif tagname == 'p': # A p element's end tag may be omitted if the p element is # immediately followed by an address, article, aside, # blockquote, datagrid, dialog, dir, div, dl, fieldset, # footer, form, h1, h2, h3, h4, h5, h6, header, hr, menu, # nav, ol, p, pre, section, table, or ul, element, or if # there is no more content in the parent element. if type in ("StartTag", "EmptyTag"): return next["name"] in ('address', 'article', 'aside', 'blockquote', 'datagrid', 'dialog', 'dir', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul') else: return type == "EndTag" or type is None elif tagname == 'option': # An option element's end tag may be omitted if the option # element is immediately followed by another option element, # or if it is immediately followed by an <code>optgroup</code> # element, or if there is no more content in the parent # element. if type == "StartTag": return next["name"] in ('option', 'optgroup') else: return type == "EndTag" or type is None elif tagname in ('rt', 'rp'): # An rt element's end tag may be omitted if the rt element is # immediately followed by an rt or rp element, or if there is # no more content in the parent element. # An rp element's end tag may be omitted if the rp element is # immediately followed by an rt or rp element, or if there is # no more content in the parent element. if type == "StartTag": return next["name"] in ('rt', 'rp') else: return type == "EndTag" or type is None elif tagname == 'colgroup': # A colgroup element's end tag may be omitted if the colgroup # element is not immediately followed by a space character or # a comment. if type in ("Comment", "SpaceCharacters"): return False elif type == "StartTag": # XXX: we also look for an immediately following colgroup # element. See is_optional_start. return next["name"] != 'colgroup' else: return True elif tagname in ('thead', 'tbody'): # A thead element's end tag may be omitted if the thead element # is immediately followed by a tbody or tfoot element. # A tbody element's end tag may be omitted if the tbody element # is immediately followed by a tbody or tfoot element, or if # there is no more content in the parent element. # A tfoot element's end tag may be omitted if the tfoot element # is immediately followed by a tbody element, or if there is no # more content in the parent element. # XXX: we never omit the end tag when the following element is # a tbody. See is_optional_start. if type == "StartTag": return next["name"] in ['tbody', 'tfoot'] elif tagname == 'tbody': return type == "EndTag" or type is None else: return False elif tagname == 'tfoot': # A tfoot element's end tag may be omitted if the tfoot element # is immediately followed by a tbody element, or if there is no # more content in the parent element. # XXX: we never omit the end tag when the following element is # a tbody. See is_optional_start. if type == "StartTag": return next["name"] == 'tbody' else: return type == "EndTag" or type is None elif tagname in ('td', 'th'): # A td element's end tag may be omitted if the td element is # immediately followed by a td or th element, or if there is # no more content in the parent element. # A th element's end tag may be omitted if the th element is # immediately followed by a td or th element, or if there is # no more content in the parent element. if type == "StartTag": return next["name"] in ('td', 'th') else: return type == "EndTag" or type is None return False
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 1275, 492, 485, 1095, 421, 199, 533, 9388, 1547, 1095, 14, 4131, 304, 272, 347, 31608, 8, 277, 304, 267, 4136, 17, 275, 4136, 18, 275, 488, 267, 367, 1526, 315, 291, 14, 1365, 26, 288, 340, 4136, 17, 365, 440, 488, 26, 355, 1995, 4136, 18, 12, 4136, 17, 12, 1526, 288, 4136, 18, 275, 4136, 17, 288, 4136, 17, 275, 1526, 267, 1995, 4136, 18, 12, 4136, 17, 12, 488, 339, 347, 636, 1661, 721, 277, 304, 267, 367, 4136, 12, 1526, 12, 2163, 315, 291, 14, 20860, 837, 288, 730, 275, 1526, 905, 466, 937, 288, 340, 730, 508, 298, 17697, 582, 355, 340, 334, 1418, 905, 576, 937, 503, 717, 440, 291, 14, 374, 63, 4144, 63, 928, 8, 1418, 905, 354, 2255, 4136, 12, 2163, 2298, 490, 1995, 1526, 288, 916, 730, 508, 298, 16906, 582, 355, 340, 440, 291, 14, 374, 63, 4144, 63, 500, 8, 1418, 905, 354, 2255, 2163, 304, 490, 1995, 1526, 288, 587, 26, 355, 1995, 1526, 339, 347, 365, 63, 4144, 63, 928, 8, 277, 12, 24009, 12, 4136, 12, 2163, 304, 267, 730, 275, 2163, 436, 2163, 905, 466, 937, 503, 488, 267, 340, 24009, 315, 283, 1360, 356, 288, 327, 1626, 3517, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 3517, 1819, 365, 440, 282, 4601, 4528, 503, 282, 3721, 14, 288, 372, 730, 440, 315, 1689, 7488, 401, 298, 28501, 531, 267, 916, 24009, 508, 283, 2993, 356, 288, 327, 437, 4854, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 4854, 1819, 365, 376, 1819, 14, 288, 327, 5787, 26, 781, 2597, 19413, 314, 1343, 1947, 340, 314, 4854, 1819, 365, 2701, 288, 340, 730, 315, 1689, 17697, 401, 298, 4699, 1931, 2349, 355, 372, 715, 288, 916, 730, 508, 298, 16906, 582, 355, 372, 2163, 905, 354, 937, 508, 298, 2993, 2, 267, 916, 24009, 508, 283, 2030, 356, 288, 327, 437, 2396, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 2396, 1819, 365, 440, 282, 4601, 4528, 503, 282, 3721, 12, 288, 327, 871, 340, 314, 1642, 8377, 6272, 314, 2396, 1819, 365, 282, 2884, 288, 327, 503, 3449, 1819, 436, 314, 1031, 9939, 22627, 314, 2396, 288, 327, 1819, 365, 282, 4854, 1819, 7447, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 315, 1689, 7488, 401, 298, 28501, 2349, 355, 372, 756, 288, 916, 730, 508, 298, 17697, 582, 355, 327, 5787, 26, 781, 886, 440, 3648, 737, 314, 22627, 1566, 12, 880, 781, 7078, 19413, 355, 327, 314, 2396, 1819, 1159, 1343, 1947, 340, 652, 1159, 9437, 701, 282, 2884, 503, 355, 327, 282, 3449, 1819, 14, 355, 372, 2163, 905, 354, 937, 440, 315, 661, 1579, 297, 283, 2487, 358, 288, 587, 26, 355, 372, 715, 267, 916, 24009, 508, 283, 761, 923, 356, 288, 327, 437, 1048, 923, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 1048, 923, 1819, 365, 282, 1048, 1819, 12, 436, 340, 314, 1819, 288, 327, 365, 440, 9939, 9222, 6133, 701, 4573, 1048, 923, 1819, 7447, 288, 327, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 315, 1689, 17697, 401, 298, 4699, 1931, 2349, 355, 327, 5787, 26, 781, 886, 440, 3648, 737, 314, 22627, 1566, 12, 880, 3140, 781, 7078, 355, 327, 19413, 314, 1048, 923, 1819, 1159, 1284, 1947, 1380, 652, 365, 9939, 355, 327, 9437, 701, 4573, 1048, 923, 1819, 14, 1666, 365, 63, 4144, 63, 500, 14, 355, 372, 2163, 905, 354, 937, 508, 298, 761, 2, 288, 587, 26, 355, 372, 756, 267, 916, 24009, 508, 283, 17847, 356, 288, 327, 437, 307, 2030, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 307, 2030, 1819, 365, 282, 5651, 1819, 12, 436, 340, 314, 1819, 365, 288, 327, 440, 9939, 9222, 6133, 701, 282, 307, 2030, 12, 314, 350, 12, 503, 307, 11407, 1819, 288, 327, 7447, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 508, 298, 17697, 582, 355, 327, 19413, 314, 314, 350, 436, 307, 11407, 4008, 7, 1284, 1947, 1380, 2985, 787, 355, 327, 9939, 9437, 701, 282, 307, 2030, 1819, 14, 1666, 365, 63, 4144, 63, 500, 14, 355, 340, 4136, 436, 4136, 459, 466, 418, 508, 283, 16906, 7, 436, 971, 717, 4136, 459, 354, 418, 315, 661, 17847, 297, 283, 21519, 297, 283, 84, 11407, 735, 490, 372, 756, 355, 372, 2163, 905, 354, 937, 508, 283, 454, 7, 288, 587, 26, 355, 372, 756, 267, 372, 756, 339, 347, 365, 63, 4144, 63, 500, 8, 277, 12, 24009, 12, 2163, 304, 267, 730, 275, 2163, 436, 2163, 905, 466, 937, 503, 488, 267, 340, 24009, 315, 661, 1360, 297, 283, 2993, 297, 283, 2030, 735, 288, 327, 1626, 3517, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 3517, 1819, 288, 327, 365, 440, 9939, 9437, 701, 282, 4601, 4528, 503, 282, 3721, 14, 288, 372, 730, 440, 315, 1689, 7488, 401, 298, 28501, 531, 267, 916, 24009, 315, 661, 317, 297, 283, 2992, 923, 297, 283, 454, 735, 288, 327, 437, 1212, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 1212, 1819, 365, 288, 327, 9939, 9437, 701, 4573, 1212, 1819, 503, 340, 2337, 365, 288, 327, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 327, 1626, 2450, 923, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 2450, 923, 288, 327, 1819, 365, 9939, 9437, 701, 4573, 2450, 923, 1819, 12, 288, 327, 503, 340, 2337, 365, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 327, 437, 5651, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 5651, 1819, 365, 288, 327, 9939, 9437, 701, 4573, 5651, 1819, 12, 503, 340, 2337, 365, 288, 327, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 340, 730, 508, 298, 17697, 582, 355, 372, 2163, 905, 354, 937, 508, 24009, 288, 587, 26, 355, 372, 730, 508, 298, 16906, 2 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 1275, 492, 485, 1095, 421, 199, 533, 9388, 1547, 1095, 14, 4131, 304, 272, 347, 31608, 8, 277, 304, 267, 4136, 17, 275, 4136, 18, 275, 488, 267, 367, 1526, 315, 291, 14, 1365, 26, 288, 340, 4136, 17, 365, 440, 488, 26, 355, 1995, 4136, 18, 12, 4136, 17, 12, 1526, 288, 4136, 18, 275, 4136, 17, 288, 4136, 17, 275, 1526, 267, 1995, 4136, 18, 12, 4136, 17, 12, 488, 339, 347, 636, 1661, 721, 277, 304, 267, 367, 4136, 12, 1526, 12, 2163, 315, 291, 14, 20860, 837, 288, 730, 275, 1526, 905, 466, 937, 288, 340, 730, 508, 298, 17697, 582, 355, 340, 334, 1418, 905, 576, 937, 503, 717, 440, 291, 14, 374, 63, 4144, 63, 928, 8, 1418, 905, 354, 2255, 4136, 12, 2163, 2298, 490, 1995, 1526, 288, 916, 730, 508, 298, 16906, 582, 355, 340, 440, 291, 14, 374, 63, 4144, 63, 500, 8, 1418, 905, 354, 2255, 2163, 304, 490, 1995, 1526, 288, 587, 26, 355, 1995, 1526, 339, 347, 365, 63, 4144, 63, 928, 8, 277, 12, 24009, 12, 4136, 12, 2163, 304, 267, 730, 275, 2163, 436, 2163, 905, 466, 937, 503, 488, 267, 340, 24009, 315, 283, 1360, 356, 288, 327, 1626, 3517, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 3517, 1819, 365, 440, 282, 4601, 4528, 503, 282, 3721, 14, 288, 372, 730, 440, 315, 1689, 7488, 401, 298, 28501, 531, 267, 916, 24009, 508, 283, 2993, 356, 288, 327, 437, 4854, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 4854, 1819, 365, 376, 1819, 14, 288, 327, 5787, 26, 781, 2597, 19413, 314, 1343, 1947, 340, 314, 4854, 1819, 365, 2701, 288, 340, 730, 315, 1689, 17697, 401, 298, 4699, 1931, 2349, 355, 372, 715, 288, 916, 730, 508, 298, 16906, 582, 355, 372, 2163, 905, 354, 937, 508, 298, 2993, 2, 267, 916, 24009, 508, 283, 2030, 356, 288, 327, 437, 2396, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 2396, 1819, 365, 440, 282, 4601, 4528, 503, 282, 3721, 12, 288, 327, 871, 340, 314, 1642, 8377, 6272, 314, 2396, 1819, 365, 282, 2884, 288, 327, 503, 3449, 1819, 436, 314, 1031, 9939, 22627, 314, 2396, 288, 327, 1819, 365, 282, 4854, 1819, 7447, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 315, 1689, 7488, 401, 298, 28501, 2349, 355, 372, 756, 288, 916, 730, 508, 298, 17697, 582, 355, 327, 5787, 26, 781, 886, 440, 3648, 737, 314, 22627, 1566, 12, 880, 781, 7078, 19413, 355, 327, 314, 2396, 1819, 1159, 1343, 1947, 340, 652, 1159, 9437, 701, 282, 2884, 503, 355, 327, 282, 3449, 1819, 14, 355, 372, 2163, 905, 354, 937, 440, 315, 661, 1579, 297, 283, 2487, 358, 288, 587, 26, 355, 372, 715, 267, 916, 24009, 508, 283, 761, 923, 356, 288, 327, 437, 1048, 923, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 1048, 923, 1819, 365, 282, 1048, 1819, 12, 436, 340, 314, 1819, 288, 327, 365, 440, 9939, 9222, 6133, 701, 4573, 1048, 923, 1819, 7447, 288, 327, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 315, 1689, 17697, 401, 298, 4699, 1931, 2349, 355, 327, 5787, 26, 781, 886, 440, 3648, 737, 314, 22627, 1566, 12, 880, 3140, 781, 7078, 355, 327, 19413, 314, 1048, 923, 1819, 1159, 1284, 1947, 1380, 652, 365, 9939, 355, 327, 9437, 701, 4573, 1048, 923, 1819, 14, 1666, 365, 63, 4144, 63, 500, 14, 355, 372, 2163, 905, 354, 937, 508, 298, 761, 2, 288, 587, 26, 355, 372, 756, 267, 916, 24009, 508, 283, 17847, 356, 288, 327, 437, 307, 2030, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 307, 2030, 1819, 365, 282, 5651, 1819, 12, 436, 340, 314, 1819, 365, 288, 327, 440, 9939, 9222, 6133, 701, 282, 307, 2030, 12, 314, 350, 12, 503, 307, 11407, 1819, 288, 327, 7447, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 508, 298, 17697, 582, 355, 327, 19413, 314, 314, 350, 436, 307, 11407, 4008, 7, 1284, 1947, 1380, 2985, 787, 355, 327, 9939, 9437, 701, 282, 307, 2030, 1819, 14, 1666, 365, 63, 4144, 63, 500, 14, 355, 340, 4136, 436, 4136, 459, 466, 418, 508, 283, 16906, 7, 436, 971, 717, 4136, 459, 354, 418, 315, 661, 17847, 297, 283, 21519, 297, 283, 84, 11407, 735, 490, 372, 756, 355, 372, 2163, 905, 354, 937, 508, 283, 454, 7, 288, 587, 26, 355, 372, 756, 267, 372, 756, 339, 347, 365, 63, 4144, 63, 500, 8, 277, 12, 24009, 12, 2163, 304, 267, 730, 275, 2163, 436, 2163, 905, 466, 937, 503, 488, 267, 340, 24009, 315, 661, 1360, 297, 283, 2993, 297, 283, 2030, 735, 288, 327, 1626, 3517, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 3517, 1819, 288, 327, 365, 440, 9939, 9437, 701, 282, 4601, 4528, 503, 282, 3721, 14, 288, 372, 730, 440, 315, 1689, 7488, 401, 298, 28501, 531, 267, 916, 24009, 315, 661, 317, 297, 283, 2992, 923, 297, 283, 454, 735, 288, 327, 437, 1212, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 1212, 1819, 365, 288, 327, 9939, 9437, 701, 4573, 1212, 1819, 503, 340, 2337, 365, 288, 327, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 327, 1626, 2450, 923, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 2450, 923, 288, 327, 1819, 365, 9939, 9437, 701, 4573, 2450, 923, 1819, 12, 288, 327, 503, 340, 2337, 365, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 327, 437, 5651, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 5651, 1819, 365, 288, 327, 9939, 9437, 701, 4573, 5651, 1819, 12, 503, 340, 2337, 365, 288, 327, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 340, 730, 508, 298, 17697, 582, 355, 372, 2163, 905, 354, 937, 508, 24009, 288, 587, 26, 355, 372, 730, 508, 298, 16906, 2, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
uhlik/blendmaxwell
mxs.py
2
222633
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 # -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright (c) 2015 Jakub Uhlík # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is furnished # to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. import os import platform import datetime import struct import math import sys import numpy from .log import log, LogStyles from . import utils s = platform.system() if(s == 'Darwin'): pass elif(s == 'Linux'): try: from pymaxwell import * except ImportError: mp = os.environ.get("MAXWELL3_ROOT") if(not mp): raise OSError("missing MAXWELL3_ROOT environment variable") pp = os.path.abspath(os.path.join(mp, 'python', 'pymaxwell', 'python3.5')) if(not os.path.exists(pp)): raise OSError("pymaxwell for python 3.5 does not exist ({})".format(pp)) sys.path.insert(0, pp) from pymaxwell import * elif(s == 'Windows'): try: from pymaxwell import * except ImportError: mp = os.environ.get("MAXWELL3_ROOT") if(not mp): raise OSError("missing MAXWELL3_ROOT environment variable") pp = os.path.abspath(os.path.join(mp, 'python', 'pymaxwell', 'python3.5')) if(not os.path.exists(pp)): raise OSError("pymaxwell for python 3.5 does not exist ({})".format(pp)) sys.path.insert(0, pp) os.environ['PATH'] = ';'.join([mp, os.environ['PATH']]) from pymaxwell import * def read_mxm_preview(path): import numpy s = Cmaxwell(mwcallback) m = s.readMaterial(path) a, _ = m.getPreview() r = numpy.copy(a) return r def material_preview_scene(scene, tmp_dir, quality, ): s = Cmaxwell(mwcallback) log('reading scene: {}'.format(scene), 2) ok = s.readMXS(scene) if(not ok): log('error reading scene: {}'.format(scene), 2, LogStyles.ERROR, ) return None def get_material_names(s): it = CmaxwellMaterialIterator() o = it.first(s) l = [] while not o.isNull(): name = o.getName() l.append(name) o = it.next() return l names = get_material_names(s) for n in names: if(n.lower() == 'preview'): break log('swapping material: {}'.format(n), 2) material = s.getMaterial(n) p = os.path.join(tmp_dir, 'material.mxm') material.read(p) material.forceToWriteIntoScene() log('setting parameters..', 2) s.setRenderParameter('ENGINE', bytes(quality, encoding='UTF-8')) exr = os.path.join(tmp_dir, "render.exr") s.setPath('RENDER', exr, 32) s.setRenderParameter('DO NOT SAVE MXI FILE', False) s.setRenderParameter('DO NOT SAVE IMAGE FILE', False) src_dir, _ = os.path.split(scene) ok = s.addSearchingPath(src_dir) sp = os.path.join(tmp_dir, "scene.mxs") log('writing scene: {}'.format(sp), 2) ok = s.writeMXS(sp) if(not ok): log('error writing scene: {}'.format(sp), 2, LogStyles.ERROR, ) return None log('done.', 2) return sp def material_preview_mxi(tmp_dir): mp = os.path.join(tmp_dir, 'render.mxi') ep = os.path.join(tmp_dir, 'render.exr') import numpy a = numpy.zeros((1, 1, 3), dtype=numpy.float, ) if(os.path.exists(mp)): log('reading mxi: {}'.format(mp), 2) i = CmaxwellMxi() i.read(mp) a, _ = i.getRenderBuffer(32) elif(os.path.exists(ep)): log('reading exr: {}'.format(ep), 2) i = CmaxwellMxi() i.readImage(ep) i.write(mp) a, _ = i.getRenderBuffer(32) else: log('image not found..', 2) return a def viewport_render_scene(tmp_dir, quality, ): s = Cmaxwell(mwcallback) p = os.path.join(tmp_dir, "scene.mxs") ok = s.readMXS(p) if(not ok): return False s.setRenderParameter('ENGINE', bytes(quality, encoding='UTF-8')) mxi = os.path.join(tmp_dir, "render.mxi") s.setRenderParameter('MXI FULLNAME', bytes(mxi, encoding='UTF-8')) exr = os.path.join(tmp_dir, "render.exr") s.setPath('RENDER', exr, 32) s.setRenderParameter('DO NOT SAVE MXI FILE', False) s.setRenderParameter('DO NOT SAVE IMAGE FILE', False) # turn off channels s.setRenderParameter('EMBED CHANNELS', 1) ls = ['DO ALPHA CHANNEL', 'DO IDOBJECT CHANNEL', 'DO IDMATERIAL CHANNEL', 'DO SHADOW PASS CHANNEL', 'DO MOTION CHANNEL', 'DO ROUGHNESS CHANNEL', 'DO FRESNEL CHANNEL', 'DO NORMALS CHANNEL', 'DO POSITION CHANNEL', 'DO ZBUFFER CHANNEL', 'DO DEEP CHANNEL', 'DO UV CHANNEL', 'DO ALPHA CUSTOM CHANNEL', 'DO REFLECTANCE CHANNEL', ] for n in ls: s.setRenderParameter(n, 0) ok = s.writeMXS(p) if(not ok): return False return True def viewport_render_mxi(tmp_dir): ep = os.path.join(tmp_dir, 'render2.exr') a = numpy.zeros((1, 1, 3), dtype=numpy.float, ) if(os.path.exists(ep)): log('reading exr: {}'.format(ep), 2) i = CmaxwellMxi() i.readImage(ep) # i.write(mp) a, _ = i.getRenderBuffer(32) else: log('image not found..', 2, LogStyles.ERROR) return a class MXSWriter(): def __init__(self, path, append=False, ): """Create scene or load existing. path string (path) append bool """ if(__name__ != "__main__"): if(platform.system() == 'Darwin'): raise ImportError("No pymaxwell directly in Blender on Mac OS X..") log(self.__class__.__name__, 1, LogStyles.MESSAGE, prefix="* ", ) self.path = path self.mxs = Cmaxwell(mwcallback) pid = utils.get_plugin_id() if(pid != ""): # write here directly, even though it is also part of scene data, but api change just for this is pointless.. self.mxs.setPluginID(pid) if(append): log("appending to existing scene..", 2, prefix="* ", ) self.mxs.readMXS(self.path) else: log("creating new scene..", 2, prefix="* ", ) self.mgr = CextensionManager.instance() self.mgr.loadAllExtensions() def write(self): """Write scene fo file. (no parameters..) """ log("saving scene..", 2) ok = self.mxs.writeMXS(self.path) log("done.", 2) return ok def erase_unused_materials(self): self.mxs.eraseUnusedMaterials() def set_base_and_pivot(self, o, matrix=None, motion=None, ): """Convert float tuples to Cbases and set to object. o CmaxwellObject base ((3 float), (3 float), (3 float), (3 float)) or None pivot ((3 float), (3 float), (3 float), (3 float)) or None """ if(matrix is None): matrix = ([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]) base = matrix[0] pivot = matrix[1] l = matrix[2] r = matrix[3] s = matrix[4] b = Cbase() b.origin = Cvector(*base[0]) b.xAxis = Cvector(*base[1]) b.yAxis = Cvector(*base[2]) b.zAxis = Cvector(*base[3]) p = Cbase() p.origin = Cvector(*pivot[0]) p.xAxis = Cvector(*pivot[1]) p.yAxis = Cvector(*pivot[2]) p.zAxis = Cvector(*pivot[3]) o.setBaseAndPivot(b, p) o.setPivotPosition(Cvector(*l)) o.setPivotRotation(Cvector(*r)) o.setPosition(Cvector(*l)) o.setRotation(Cvector(*r)) o.setScale(Cvector(*s)) if(motion is not None): for(t, _, b, p) in motion: bb = Cbase() bb.origin = Cvector(*b[0]) bb.xAxis = Cvector(*b[1]) bb.yAxis = Cvector(*b[2]) bb.zAxis = Cvector(*b[3]) pp = Cbase() pp.origin = Cvector(*p[0]) pp.xAxis = Cvector(*p[1]) pp.yAxis = Cvector(*p[2]) pp.zAxis = Cvector(*p[3]) o.setBaseAndPivot(bb, pp, t, ) def set_object_props(self, o, hide=False, opacity=100, cid=(1.0, 1.0, 1.0), hcam=False, hcamsc=False, hgi=False, hrr=False, hzcp=False, blocked_emitters=None, ): """Set common object properties. o CmaxwellObject hide bool opacity float cid (float, float, float) 0.0 - 1.0 rgb hcam bool hcamsc bool hgi bool hrr bool hzcp bool blocked_emitters list of blocked emitter object names """ if(hide): o.setHide(hide) if(opacity != 100.0): o.setOpacity(opacity) c = Crgb() c.assign(*cid) o.setColorID(c) if(hcam): o.setHideToCamera(True) if(hcamsc): o.setHideToCameraInShadowsPass(True) if(hgi): o.setHideToGI(True) if(hrr): o.setHideToReflectionsRefractions(True) if(hzcp): o.excludeOfCutPlanes(True) if(blocked_emitters): for n in blocked_emitters: ok = o.addExcludedLight(n) def texture_data_to_mxparams(self, name, data, mxparams, ): """Create CtextureMap, fill with parameters and put into mxparams. name string data dict {'type': string, 'path': string, 'channel': int, 'use_global_map': bool, 'tile_method_type': [bool, bool], 'tile_method_units': int, 'repeat': [float, float], 'mirror': [bool, bool], 'offset': [float, float], 'rotation': float, 'invert': bool, 'alpha_only': bool, 'interpolation': bool, 'brightness': float, 'contrast': float, 'saturation': float, 'hue': float, 'rgb_clamp': [float, float], } mxparams mxparams """ d = data if(d is None): return t = CtextureMap() t.setPath(d['path']) v = Cvector2D() v.assign(*d['repeat']) t.scale = v v = Cvector2D() v.assign(*d['offset']) t.offset = v t.rotation = d['rotation'] t.uvwChannelID = d['channel'] t.uIsTiled = d['tile_method_type'][0] t.vIsTiled = d['tile_method_type'][1] t.uIsMirrored = d['mirror'][0] t.vIsMirrored = d['mirror'][1] t.invert = d['invert'] # t.doGammaCorrection = 0 t.useAbsoluteUnits = d['tile_method_units'] t.normalMappingFlipRed = d['normal_mapping_flip_red'] t.normalMappingFlipGreen = d['normal_mapping_flip_green'] t.normalMappingFullRangeBlue = d['normal_mapping_full_range_blue'] t.useAlpha = d['alpha_only'] t.typeInterpolation = d['interpolation'] t.saturation = d['saturation'] / 100 t.contrast = d['contrast'] / 100 t.brightness = d['brightness'] / 100 t.hue = d['hue'] / 180 t.clampMin = d['rgb_clamp'][0] / 255 t.clampMax = d['rgb_clamp'][1] / 255 t.useGlobalMap = d['use_global_map'] # t.cosA = 1.000000 # t.sinA = 0.000000 ok = mxparams.setTextureMap(name, t) return mxparams def texture(self, d, ): """Create CtextureMap from parameters d dict """ if(d is None): return s = self.mxs t = CtextureMap() t.setPath(d['path']) t.uvwChannelID = d['channel'] t.brightness = d['brightness'] / 100 t.contrast = d['contrast'] / 100 t.saturation = d['saturation'] / 100 t.hue = d['hue'] / 180 t.useGlobalMap = d['use_global_map'] t.useAbsoluteUnits = d['tile_method_units'] t.uIsTiled = d['tile_method_type'][0] t.vIsTiled = d['tile_method_type'][1] t.uIsMirrored = d['mirror'][0] t.vIsMirrored = d['mirror'][1] vec = Cvector2D() vec.assign(d['offset'][0], d['offset'][1]) t.offset = vec t.rotation = d['rotation'] t.invert = d['invert'] t.useAlpha = d['alpha_only'] if(d['interpolation']): t.typeInterpolation = 1 else: t.typeInterpolation = 0 t.clampMin = d['rgb_clamp'][0] / 255 t.clampMax = d['rgb_clamp'][1] / 255 vec = Cvector2D() vec.assign(d['repeat'][0], d['repeat'][1]) t.scale = vec t.normalMappingFlipRed = d['normal_mapping_flip_red'] t.normalMappingFlipGreen = d['normal_mapping_flip_green'] t.normalMappingFullRangeBlue = d['normal_mapping_full_range_blue'] for i, pt in enumerate(d['procedural']): if(pt['use'] == 'BRICK'): e = self.mgr.createDefaultTextureExtension('Brick') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setFloat('Brick width', pt['brick_brick_width']) p.setFloat('Brick height', pt['brick_brick_height']) p.setInt('Brick offset', pt['brick_brick_offset']) p.setInt('Random offset', pt['brick_random_offset']) p.setByte('Double brick', pt['brick_double_brick']) p.setFloat('Small brick width', pt['brick_small_brick_width']) p.setByte('Round corners', pt['brick_round_corners']) p.setFloat('Boundary sharpness U', pt['brick_boundary_sharpness_u']) p.setFloat('Boundary sharpness V', pt['brick_boundary_sharpness_v']) p.setInt('Boundary noise detail', pt['brick_boundary_noise_detail']) p.setFloat('Boundary noise region U', pt['brick_boundary_noise_region_u']) p.setFloat('Boundary noise region V', pt['brick_boundary_noise_region_v']) p.setUInt('Seed', pt['brick_seed']) p.setByte('Random rotation', pt['brick_random_rotation']) p.setInt('Color variation', pt['brick_color_variation']) c = Crgb() c.assign(*pt['brick_brick_color_0']) p.setRgb('Brick color 0', c) self.texture_data_to_mxparams('Brick texture 0', pt['brick_brick_texture_0'], p, ) p.setInt('Sampling factor 0', pt['brick_sampling_factor_0']) p.setInt('Weight 0', pt['brick_weight_0']) c = Crgb() c.assign(*pt['brick_brick_color_1']) p.setRgb('Brick color 1', c) self.texture_data_to_mxparams('Brick texture 1', pt['brick_brick_texture_1'], p, ) p.setInt('Sampling factor 1', pt['brick_sampling_factor_1']) p.setInt('Weight 1', pt['brick_weight_1']) c = Crgb() c.assign(*pt['brick_brick_color_2']) p.setRgb('Brick color 2', c) self.texture_data_to_mxparams('Brick texture 2', pt['brick_brick_texture_2'], p, ) p.setInt('Sampling factor 2', pt['brick_sampling_factor_2']) p.setInt('Weight 2', pt['brick_weight_2']) p.setFloat('Mortar thickness', pt['brick_mortar_thickness']) c = Crgb() c.assign(*pt['brick_mortar_color']) p.setRgb('Mortar color', c) self.texture_data_to_mxparams('Mortar texture', pt['brick_mortar_texture'], p, ) t.addProceduralTexture(p) elif(pt['use'] == 'CHECKER'): e = self.mgr.createDefaultTextureExtension('Checker') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) c = Crgb() c.assign(*pt['checker_color_0']) p.setRgb('Color0', c) c = Crgb() c.assign(*pt['checker_color_1']) p.setRgb('Color1', c) p.setUInt('Number of elements U', pt['checker_number_of_elements_u']) p.setUInt('Number of elements V', pt['checker_number_of_elements_v']) p.setFloat('Transition sharpness', pt['checker_transition_sharpness']) p.setUInt('Fall-off', pt['checker_falloff']) t.addProceduralTexture(p) elif(pt['use'] == 'CIRCLE'): e = self.mgr.createDefaultTextureExtension('Circle') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) c = Crgb() c.assign(*pt['circle_background_color']) p.setRgb('Background color', c) c = Crgb() c.assign(*pt['circle_circle_color']) p.setRgb('Circle color', c) p.setFloat('RadiusU', pt['circle_radius_u']) p.setFloat('RadiusV', pt['circle_radius_v']) p.setFloat('Transition factor', pt['circle_transition_factor']) p.setUInt('Fall-off', pt['circle_falloff']) t.addProceduralTexture(p) elif(pt['use'] == 'GRADIENT3'): e = self.mgr.createDefaultTextureExtension('Gradient3') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setByte('Gradient U', pt['gradient3_gradient_u']) c = Crgb() c.assign(*pt['gradient3_color0_u']) p.setRgb('Color0 U', c) c = Crgb() c.assign(*pt['gradient3_color1_u']) p.setRgb('Color1 U', c) c = Crgb() c.assign(*pt['gradient3_color2_u']) p.setRgb('Color2 U', c) p.setUInt('Gradient type U', pt['gradient3_gradient_type_u']) p.setFloat('Color1 U position', pt['gradient3_color1_u_position']) p.setByte('Gradient V', pt['gradient3_gradient_v']) c = Crgb() c.assign(*pt['gradient3_color0_v']) p.setRgb('Color0 V', c) c = Crgb() c.assign(*pt['gradient3_color1_v']) p.setRgb('Color1 V', c) c = Crgb() c.assign(*pt['gradient3_color2_v']) p.setRgb('Color2 V', c) p.setUInt('Gradient type V', pt['gradient3_gradient_type_v']) p.setFloat('Color1 V position', pt['gradient3_color1_v_position']) t.addProceduralTexture(p) elif(pt['use'] == 'GRADIENT'): e = self.mgr.createDefaultTextureExtension('Gradient') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setByte('Gradient U', pt['gradient_gradient_u']) c = Crgb() c.assign(*pt['gradient_color0_u']) p.setRgb('Color0 U', c) c = Crgb() c.assign(*pt['gradient_color1_u']) p.setRgb('Color1 U', c) p.setUInt('Gradient type U', pt['gradient_gradient_type_u']) p.setFloat('Transition factor U', pt['gradient_transition_factor_u']) p.setByte('Gradient V', pt['gradient_gradient_v']) c = Crgb() c.assign(*pt['gradient_color0_v']) p.setRgb('Color0 V', c) c = Crgb() c.assign(*pt['gradient_color1_v']) p.setRgb('Color1 V', c) p.setUInt('Gradient type V', pt['gradient_gradient_type_v']) p.setFloat('Transition factor V', pt['gradient_transition_factor_v']) t.addProceduralTexture(p) elif(pt['use'] == 'GRID'): e = self.mgr.createDefaultTextureExtension('Grid') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) c = Crgb() c.assign(*pt['grid_boundary_color']) p.setRgb('Boundary color', c) c = Crgb() c.assign(*pt['grid_cell_color']) p.setRgb('Cell color', c) p.setFloat('Cell width', pt['grid_cell_width']) p.setFloat('Cell height', pt['grid_cell_height']) if(pt['grid_horizontal_lines']): p.setFloat('Boundary thickness U', pt['grid_boundary_thickness_u']) else: p.setFloat('Boundary thickness U', 0.0) if(pt['grid_vertical_lines']): p.setFloat('Boundary thickness V', pt['grid_boundary_thickness_v']) else: p.setFloat('Boundary thickness V', 0.0) p.setFloat('Transition sharpness', pt['grid_transition_sharpness']) p.setUInt('Fall-off', pt['grid_falloff']) t.addProceduralTexture(p) elif(pt['use'] == 'MARBLE'): e = self.mgr.createDefaultTextureExtension('Marble') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setUInt('Coordinates type', pt['marble_coordinates_type']) c = Crgb() c.assign(*pt['marble_color0']) p.setRgb('Color0', c) c = Crgb() c.assign(*pt['marble_color1']) p.setRgb('Color1', c) c = Crgb() c.assign(*pt['marble_color2']) p.setRgb('Color2', c) p.setFloat('Frequency', pt['marble_frequency']) p.setFloat('Detail', pt['marble_detail']) p.setInt('Octaves', pt['marble_octaves']) p.setUInt('Seed', pt['marble_seed']) t.addProceduralTexture(p) elif(pt['use'] == 'NOISE'): e = self.mgr.createDefaultTextureExtension('Noise') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setUInt('Coordinates type', pt['noise_coordinates_type']) c = Crgb() c.assign(*pt['noise_noise_color']) p.setRgb('Noise color', c) c = Crgb() c.assign(*pt['noise_background_color']) p.setRgb('Background color', c) p.setFloat('Detail', pt['noise_detail']) p.setFloat('Persistance', pt['noise_persistance']) p.setInt('Octaves', pt['noise_octaves']) p.setFloat('Low value', pt['noise_low_value']) p.setFloat('High value', pt['noise_high_value']) p.setUInt('Seed', pt['noise_seed']) t.addProceduralTexture(p) elif(pt['use'] == 'VORONOI'): e = self.mgr.createDefaultTextureExtension('Voronoi') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setUInt('Coordinates type', pt['voronoi_coordinates_type']) c = Crgb() c.assign(*pt['voronoi_color0']) p.setRgb('Color0', c) c = Crgb() c.assign(*pt['voronoi_color1']) p.setRgb('Color1', c) p.setInt('Detail', pt['voronoi_detail']) p.setUInt('Distance', pt['voronoi_distance']) p.setUInt('Combination', pt['voronoi_combination']) p.setFloat('Low value', pt['voronoi_low_value']) p.setFloat('High value', pt['voronoi_high_value']) p.setUInt('Seed', pt['voronoi_seed']) t.addProceduralTexture(p) elif(pt['use'] == 'TILED'): e = self.mgr.createDefaultTextureExtension('TiledTexture') p = e.getExtensionData() p.setFloat('Blend factor', pt['blending_factor']) c = Crgb() c.assign(*pt['tiled_base_color']) p.setRgb('Base Color', c) p.setByte('Use base color', pt['tiled_use_base_color']) p.setString('Filename_mask', pt['tiled_token_mask']) p.setString('Filename', pt['tiled_filename']) # 'Map U tile range' UCHAR # 'Map V tile range' UCHAR t.addProceduralTexture(p) elif(pt['use'] == 'WIREFRAME'): e = self.mgr.createDefaultTextureExtension('WireframeTexture') p = e.getExtensionData() c = Crgb() c.assign(*pt['wireframe_fill_color']) p.setRgb('Fill Color', c) c = Crgb() c.assign(*pt['wireframe_edge_color']) p.setRgb('Edge Color', c) c = Crgb() c.assign(*pt['wireframe_coplanar_edge_color']) p.setRgb('Coplanar Edge Color', c) p.setFloat('Edge Width', pt['wireframe_edge_width']) p.setFloat('Coplanar Edge Width', pt['wireframe_coplanar_edge_width']) p.setFloat('Coplanar Threshold', pt['wireframe_coplanar_threshold']) t.addProceduralTexture(p) else: raise TypeError("{0} is unknown procedural texture type".format(pt['use'])) return t def material_placeholder(self, n=None, ): if(n is not None): pass else: n = 'MATERIAL_PLACEHOLDER' s = self.mxs m = s.createMaterial(n) l = m.addLayer() b = l.addBSDF() r = b.getReflectance() a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = CtextureMap() mgr = CextensionManager.instance() mgr.loadAllExtensions() e = mgr.createDefaultTextureExtension('Checker') ch = e.getExtensionData() ch.setUInt('Number of elements U', 32) ch.setUInt('Number of elements V', 32) t.addProceduralTexture(ch) a.textureMap = t r.setAttribute('color', a) return m def material_default(self, n, ): s = self.mxs m = s.createMaterial(n) l = m.addLayer() b = l.addBSDF() return m def material_external(self, d, ): s = self.mxs p = d['path'] t = s.readMaterial(p) t.setName(d['name']) m = s.addMaterial(t) if(not d['embed']): m.setReference(1, p) return m def material_custom(self, d, ): s = self.mxs m = s.createMaterial(d['name']) d = d['data'] def global_props(d, m): # global properties if(d['override_map']): t = self.texture(d['override_map']) if(t is not None): m.setGlobalMap(t) if(d['bump_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(d['bump_map']) if(t is not None): a.textureMap = t if(d['bump_map_use_normal']): a.value = d['bump_normal'] else: a.value = d['bump'] m.setAttribute('bump', a) m.setNormalMapState(d['bump_map_use_normal']) m.setDispersion(d['dispersion']) m.setMatteShadow(d['shadow']) m.setMatte(d['matte']) m.setNestedPriority(d['priority']) c = Crgb() c.assign(*d['id']) m.setColorID(c) if(d['active_display_map']): t = self.texture(d['active_display_map']) m.setActiveDisplayMap(t) def displacement(d, m): if(not d['enabled']): return m.enableDisplacement(True) if(d['map'] is not None): t = self.texture(d['map']) m.setDisplacementMap(t) m.setDisplacementCommonParameters(d['type'], d['subdivision'], int(d['smoothing']), d['offset'], d['subdivision_method'], d['uv_interpolation'], ) m.setHeightMapDisplacementParameters(d['height'], d['height_units'], d['adaptive'], ) v = Cvector(*d['v3d_scale']) m.setVectorDisplacementParameters(v, d['v3d_transform'], d['v3d_rgb_mapping'], d['v3d_preset'], ) def add_bsdf(d, l): b = l.addBSDF() b.setName(d['name']) bp = d['bsdf_props'] # weight if(bp['weight_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['weight_map']) if(t is not None): a.textureMap = t a.value = bp['weight'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = bp['weight'] b.setWeight(a) # enabled if(not bp['visible']): b.setState(False) # ior r = b.getReflectance() if(bp['ior'] == 1): # measured data r.setActiveIorMode(1) r.setComplexIor(bp['complex_ior']) else: if(bp['reflectance_0_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['reflectance_0_map']) if(t is not None): a.textureMap = t a.rgb.assign(*bp['reflectance_0']) else: a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*bp['reflectance_0']) r.setAttribute('color', a) if(bp['reflectance_90_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['reflectance_90_map']) if(t is not None): a.textureMap = t a.rgb.assign(*bp['reflectance_90']) else: a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*bp['reflectance_90']) r.setAttribute('color.tangential', a) if(bp['transmittance_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['transmittance_map']) if(t is not None): a.textureMap = t a.rgb.assign(*bp['transmittance']) else: a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*bp['transmittance']) r.setAttribute('transmittance.color', a) r.setAbsorptionDistance(bp['attenuation_units'], bp['attenuation']) r.setIOR(bp['nd'], bp['abbe']) if(bp['force_fresnel']): r.enableForceFresnel(True) r.setConductor(bp['k']) if(bp['r2_enabled']): r.setFresnelCustom(bp['r2_falloff_angle'], bp['r2_influence'], True, ) # surface if(bp['roughness_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['roughness_map']) if(t is not None): a.textureMap = t a.value = bp['roughness'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = bp['roughness'] b.setAttribute('roughness', a) if(bp['bump_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['bump_map']) if(t is not None): a.textureMap = t if(bp['bump_map_use_normal']): a.value = bp['bump_normal'] else: a.value = bp['bump'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE if(bp['bump_map_use_normal']): a.value = bp['bump_normal'] else: a.value = bp['bump'] b.setAttribute('bump', a) b.setNormalMapState(bp['bump_map_use_normal']) if(bp['anisotropy_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['anisotropy_map']) if(t is not None): a.textureMap = t a.value = bp['anisotropy'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = bp['anisotropy'] b.setAttribute('anisotropy', a) if(bp['anisotropy_angle_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['anisotropy_angle_map']) if(t is not None): a.textureMap = t a.value = bp['anisotropy_angle'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = bp['anisotropy_angle'] b.setAttribute('angle', a) # subsurface a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*bp['scattering']) r.setAttribute('scattering', a) r.setScatteringParameters(bp['coef'], bp['asymmetry'], bp['single_sided']) if(bp['single_sided']): if(bp['single_sided_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['single_sided_map']) if(t is not None): a.textureMap = t a.value = bp['single_sided_value'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = bp['single_sided_value'] r.setScatteringThickness(a) r.setScatteringThicknessRange(bp['single_sided_min'], bp['single_sided_max']) # coating cp = d['coating'] if(cp['enabled']): c = b.addCoating() if(cp['thickness_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(cp['thickness_map']) if(t is not None): a.textureMap = t a.value = cp['thickness'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = cp['thickness'] c.setThickness(a) c.setThicknessRange(cp['thickness_map_min'], cp['thickness_map_max']) r = c.getReflectance() if(cp['ior'] == 1): # measured data r.setActiveIorMode(1) r.setComplexIor(cp['complex_ior']) else: if(cp['reflectance_0_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(cp['reflectance_0_map']) if(t is not None): a.textureMap = t a.rgb.assign(*cp['reflectance_0']) else: a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*cp['reflectance_0']) r.setAttribute('color', a) if(cp['reflectance_90_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(cp['reflectance_90_map']) if(t is not None): a.textureMap = t a.rgb.assign(*cp['reflectance_90']) else: a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*cp['reflectance_90']) r.setAttribute('color.tangential', a) r.setIOR(cp['nd'], 1.0, ) if(cp['force_fresnel']): r.enableForceFresnel(True) r.setConductor(cp['k']) if(cp['r2_enabled']): r.setFresnelCustom(cp['r2_falloff_angle'], 0.0, True, ) def add_emitter(d, l): e = l.createEmitter() if(d['type'] == 0): e.setLobeType(EMISSION_LOBE_DEFAULT) elif(d['type'] == 1): e.setLobeType(EMISSION_LOBE_IES) e.setLobeIES(d['ies_data']) e.setIESLobeIntensity(d['ies_intensity']) elif(d['type'] == 2): e.setLobeType(EMISSION_LOBE_SPOTLIGHT) if(d['spot_map'] is not None): t = self.texture(d['spot_map']) if(t is not None): e.setLobeImageProjectedMap(d['spot_map_enabled'], t) e.setSpotConeAngle(d['spot_cone_angle']) e.setSpotFallOffAngle(d['spot_falloff_angle']) e.setSpotFallOffType(d['spot_falloff_type']) e.setSpotBlur(d['spot_blur']) if(d['emission'] == 0): e.setActiveEmissionType(EMISSION_TYPE_PAIR) ep = CemitterPair() c = Crgb() c.assign(*d['color']) ep.rgb.assign(c) ep.temperature = d['color_black_body'] ep.watts = d['luminance_power'] ep.luminousEfficacy = d['luminance_efficacy'] ep.luminousPower = d['luminance_output'] ep.illuminance = d['luminance_output'] ep.luminousIntensity = d['luminance_output'] ep.luminance = d['luminance_output'] e.setPair(ep) if(d['luminance'] == 0): u = EMISSION_UNITS_WATTS_AND_LUMINOUS_EFFICACY elif(d['luminance'] == 1): u = EMISSION_UNITS_LUMINOUS_POWER elif(d['luminance'] == 2): u = EMISSION_UNITS_ILLUMINANCE elif(d['luminance'] == 3): u = EMISSION_UNITS_LUMINOUS_INTENSITY elif(d['luminance'] == 4): u = EMISSION_UNITS_LUMINANCE if(d['color_black_body_enabled']): e.setActivePair(EMISSION_COLOR_TEMPERATURE, u) else: e.setActivePair(EMISSION_RGB, u) elif(d['emission'] == 1): e.setActiveEmissionType(EMISSION_TYPE_TEMPERATURE) e.setTemperature(d['temperature_value']) elif(d['emission'] == 2): e.setActiveEmissionType(EMISSION_TYPE_MXI) a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(d['hdr_map']) if(t is not None): a.textureMap = t a.value = d['hdr_intensity'] e.setMXI(a) e.setState(True) def add_layer(d, m): l = m.addLayer() l.setName(d['name']) lpd = d['layer_props'] if(not lpd['visible']): l.setEnabled(False) if(lpd['blending'] == 1): l.setStackedBlendingMode(1) if(lpd['opacity_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(lpd['opacity_map']) if(t is not None): a.textureMap = t a.value = lpd['opacity'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = lpd['opacity'] l.setAttribute('weight', a) epd = d['emitter'] if(epd['enabled']): add_emitter(epd, l) for b in d['bsdfs']: add_bsdf(b, l) global_props(d['global_props'], m) displacement(d['displacement'], m) for layer in d['layers']: add_layer(layer, m) return m def material(self, d, ): s = self.mxs if(d['subtype'] == 'EXTERNAL'): if(d['path'] == ''): m = self.material_placeholder(d['name']) else: m = self.material_external(d) if(d['override']): # global properties if(d['override_map']): t = self.texture(d['override_map']) if(t is not None): m.setGlobalMap(t) if(d['bump_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(d['bump_map']) if(t is not None): a.textureMap = t if(d['bump_map_use_normal']): a.value = d['bump_normal'] else: a.value = d['bump'] m.setAttribute('bump', a) m.setNormalMapState(d['bump_map_use_normal']) m.setDispersion(d['dispersion']) m.setMatteShadow(d['shadow']) m.setMatte(d['matte']) m.setNestedPriority(d['priority']) c = Crgb() c.assign(*d['id']) m.setColorID(c) elif(d['subtype'] == 'EXTENSION'): if(d['use'] == 'EMITTER'): m = s.createMaterial(d['name']) l = m.addLayer() e = l.createEmitter() if(d['emitter_type'] == 0): e.setLobeType(EMISSION_LOBE_DEFAULT) elif(d['emitter_type'] == 1): e.setLobeType(EMISSION_LOBE_IES) e.setLobeIES(d['emitter_ies_data']) e.setIESLobeIntensity(d['emitter_ies_intensity']) elif(d['emitter_type'] == 2): e.setLobeType(EMISSION_LOBE_SPOTLIGHT) if(d['emitter_spot_map'] is not None): t = self.texture(d['emitter_spot_map']) if(t is not None): e.setLobeImageProjectedMap(d['emitter_spot_map_enabled'], t) e.setSpotConeAngle(d['emitter_spot_cone_angle']) e.setSpotFallOffAngle(d['emitter_spot_falloff_angle']) e.setSpotFallOffType(d['emitter_spot_falloff_type']) e.setSpotBlur(d['emitter_spot_blur']) if(d['emitter_emission'] == 0): e.setActiveEmissionType(EMISSION_TYPE_PAIR) ep = CemitterPair() c = Crgb() c.assign(*d['emitter_color']) ep.rgb.assign(c) ep.temperature = d['emitter_color_black_body'] ep.watts = d['emitter_luminance_power'] ep.luminousEfficacy = d['emitter_luminance_efficacy'] ep.luminousPower = d['emitter_luminance_output'] ep.illuminance = d['emitter_luminance_output'] ep.luminousIntensity = d['emitter_luminance_output'] ep.luminance = d['emitter_luminance_output'] e.setPair(ep) if(d['emitter_luminance'] == 0): u = EMISSION_UNITS_WATTS_AND_LUMINOUS_EFFICACY elif(d['emitter_luminance'] == 1): u = EMISSION_UNITS_LUMINOUS_POWER elif(d['emitter_luminance'] == 2): u = EMISSION_UNITS_ILLUMINANCE elif(d['emitter_luminance'] == 3): u = EMISSION_UNITS_LUMINOUS_INTENSITY elif(d['emitter_luminance'] == 4): u = EMISSION_UNITS_LUMINANCE if(d['emitter_color_black_body_enabled']): e.setActivePair(EMISSION_COLOR_TEMPERATURE, u) else: e.setActivePair(EMISSION_RGB, u) elif(d['emitter_emission'] == 1): e.setActiveEmissionType(EMISSION_TYPE_TEMPERATURE) e.setTemperature(d['emitter_temperature_value']) elif(d['emitter_emission'] == 2): e.setActiveEmissionType(EMISSION_TYPE_MXI) a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(d['emitter_hdr_map']) if(t is not None): a.textureMap = t a.value = d['emitter_hdr_intensity'] e.setMXI(a) e.setState(True) def global_props(d, m): # global properties if(d['override_map']): t = texture(d['override_map'], s, ) if(t is not None): m.setGlobalMap(t) if(d['bump_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = texture(d['bump_map'], s, ) if(t is not None): a.textureMap = t if(d['bump_map_use_normal']): a.value = d['bump_normal'] else: a.value = d['bump'] m.setAttribute('bump', a) m.setNormalMapState(d['bump_map_use_normal']) m.setDispersion(d['dispersion']) m.setMatteShadow(d['shadow']) m.setMatte(d['matte']) m.setNestedPriority(d['priority']) c = Crgb() c.assign(*d['id']) m.setColorID(c) if(d['active_display_map']): t = texture(d['active_display_map'], s, ) m.setActiveDisplayMap(t) global_props(d, m) else: m = CextensionManager.instance() m.loadAllExtensions() if(d['use'] == 'AGS'): e = m.createDefaultMaterialModifierExtension('AGS') p = e.getExtensionData() c = Crgb() c.assign(*d['ags_color']) p.setRgb('Color', c) p.setFloat('Reflection', d['ags_reflection']) p.setUInt('Type', d['ags_type']) elif(d['use'] == 'OPAQUE'): e = m.createDefaultMaterialModifierExtension('Opaque') p = e.getExtensionData() p.setByte('Color Type', d['opaque_color_type']) c = Crgb() c.assign(*d['opaque_color']) p.setRgb('Color', c) self.texture_data_to_mxparams('Color Map', d['opaque_color_map'], p, ) p.setByte('Shininess Type', d['opaque_shininess_type']) p.setFloat('Shininess', d['opaque_shininess']) self.texture_data_to_mxparams('Shininess Map', d['opaque_shininess_map'], p, ) p.setByte('Roughness Type', d['opaque_roughness_type']) p.setFloat('Roughness', d['opaque_roughness']) self.texture_data_to_mxparams('Roughness Map', d['opaque_roughness_map'], p, ) p.setByte('Clearcoat', d['opaque_clearcoat']) elif(d['use'] == 'TRANSPARENT'): e = m.createDefaultMaterialModifierExtension('Transparent') p = e.getExtensionData() p.setByte('Color Type', d['transparent_color_type']) c = Crgb() c.assign(*d['transparent_color']) p.setRgb('Color', c) self.texture_data_to_mxparams('Color Map', d['transparent_color_map'], p, ) p.setFloat('Ior', d['transparent_ior']) p.setFloat('Transparency', d['transparent_transparency']) p.setByte('Roughness Type', d['transparent_roughness_type']) p.setFloat('Roughness', d['transparent_roughness']) self.texture_data_to_mxparams('Roughness Map', d['transparent_roughness_map'], p, ) p.setFloat('Specular Tint', d['transparent_specular_tint']) p.setFloat('Dispersion', d['transparent_dispersion']) p.setByte('Clearcoat', d['transparent_clearcoat']) elif(d['use'] == 'METAL'): e = m.createDefaultMaterialModifierExtension('Metal') p = e.getExtensionData() p.setUInt('IOR', d['metal_ior']) p.setFloat('Tint', d['metal_tint']) p.setByte('Color Type', d['metal_color_type']) c = Crgb() c.assign(*d['metal_color']) p.setRgb('Color', c) self.texture_data_to_mxparams('Color Map', d['metal_color_map'], p, ) p.setByte('Roughness Type', d['metal_roughness_type']) p.setFloat('Roughness', d['metal_roughness']) self.texture_data_to_mxparams('Roughness Map', d['metal_roughness_map'], p, ) p.setByte('Anisotropy Type', d['metal_anisotropy_type']) p.setFloat('Anisotropy', d['metal_anisotropy']) self.texture_data_to_mxparams('Anisotropy Map', d['metal_anisotropy_map'], p, ) p.setByte('Angle Type', d['metal_angle_type']) p.setFloat('Angle', d['metal_angle']) self.texture_data_to_mxparams('Angle Map', d['metal_angle_map'], p, ) p.setByte('Dust Type', d['metal_dust_type']) p.setFloat('Dust', d['metal_dust']) self.texture_data_to_mxparams('Dust Map', d['metal_dust_map'], p, ) p.setByte('Perforation Enabled', d['metal_perforation_enabled']) self.texture_data_to_mxparams('Perforation Map', d['metal_perforation_map'], p, ) elif(d['use'] == 'TRANSLUCENT'): e = m.createDefaultMaterialModifierExtension('Translucent') p = e.getExtensionData() p.setFloat('Scale', d['translucent_scale']) p.setFloat('Ior', d['translucent_ior']) p.setByte('Color Type', d['translucent_color_type']) c = Crgb() c.assign(*d['translucent_color']) p.setRgb('Color', c) self.texture_data_to_mxparams('Color Map', d['translucent_color_map'], p, ) p.setFloat('Hue Shift', d['translucent_hue_shift']) p.setByte('Invert Hue', d['translucent_invert_hue']) p.setFloat('Vibrance', d['translucent_vibrance']) p.setFloat('Density', d['translucent_density']) p.setFloat('Opacity', d['translucent_opacity']) p.setByte('Roughness Type', d['translucent_roughness_type']) p.setFloat('Roughness', d['translucent_roughness']) self.texture_data_to_mxparams('Roughness Map', d['translucent_roughness_map'], p, ) p.setFloat('Specular Tint', d['translucent_specular_tint']) p.setByte('Clearcoat', d['translucent_clearcoat']) p.setFloat('Clearcoat Ior', d['translucent_clearcoat_ior']) elif(d['use'] == 'CARPAINT'): e = m.createDefaultMaterialModifierExtension('Car Paint') p = e.getExtensionData() c = Crgb() c.assign(*d['carpaint_color']) p.setRgb('Color', c) p.setFloat('Metallic', d['carpaint_metallic']) p.setFloat('Topcoat', d['carpaint_topcoat']) elif(d['use'] == 'HAIR'): e = m.createDefaultMaterialModifierExtension('Hair') p = e.getExtensionData() p.setByte('Color Type', d['hair_color_type']) c = Crgb() c.assign(*d['hair_color']) p.setRgb('Color', c) self.texture_data_to_mxparams('Color Map', d['hair_color_map'], p, ) self.texture_data_to_mxparams('Root-Tip Map', d['hair_root_tip_map'], p, ) p.setByte('Root-Tip Weight Type', d['hair_root_tip_weight_type']) p.setFloat('Root-Tip Weight', d['hair_root_tip_weight']) self.texture_data_to_mxparams('Root-Tip Weight Map', d['hair_root_tip_weight_map'], p, ) p.setFloat('Primary Highlight Strength', d['hair_primary_highlight_strength']) p.setFloat('Primary Highlight Spread', d['hair_primary_highlight_spread']) c = Crgb() c.assign(*d['hair_primary_highlight_tint']) p.setRgb('Primary Highlight Tint', c) p.setFloat('Secondary Highlight Strength', d['hair_secondary_highlight_strength']) p.setFloat('Secondary Highlight Spread', d['hair_secondary_highlight_spread']) c = Crgb() c.assign(*d['hair_secondary_highlight_tint']) p.setRgb('Secondary Highlight Tint', c) m = s.createMaterial(d['name']) m.applyMaterialModifierExtension(p) # global properties if(d['override_map']): t = self.texture(d['override_map']) if(t is not None): m.setGlobalMap(t) if(d['bump_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(d['bump_map']) if(t is not None): a.textureMap = t if(d['bump_map_use_normal']): a.value = d['bump_normal'] else: a.value = d['bump'] m.setAttribute('bump', a) m.setNormalMapState(d['bump_map_use_normal']) m.setDispersion(d['dispersion']) m.setMatteShadow(d['shadow']) m.setMatte(d['matte']) m.setNestedPriority(d['priority']) c = Crgb() c.assign(*d['id']) m.setColorID(c) if(d['active_display_map']): t = self.texture(d['active_display_map']) m.setActiveDisplayMap(t) def displacement(d, m): if(not d['enabled']): return m.enableDisplacement(True) if(d['map'] is not None): t = self.texture(d['map']) m.setDisplacementMap(t) m.setDisplacementCommonParameters(d['type'], d['subdivision'], int(d['smoothing']), d['offset'], d['subdivision_method'], d['uv_interpolation'], ) m.setHeightMapDisplacementParameters(d['height'], d['height_units'], d['adaptive'], ) v = Cvector(*d['v3d_scale']) m.setVectorDisplacementParameters(v, d['v3d_transform'], d['v3d_rgb_mapping'], d['v3d_preset'], ) try: displacement(d['displacement'], m) except KeyError: pass elif(d['subtype'] == 'CUSTOM'): m = self.material_custom(d) else: raise TypeError("Material '{}' {} is unknown type".format(d['name'], d['subtype'])) def get_material(self, n, ): """get material by name from scene, if material is missing, create and return placeholder""" def get_material_names(s): it = CmaxwellMaterialIterator() o = it.first(s) l = [] while not o.isNull(): name = o.getName() l.append(name) o = it.next() return l s = self.mxs names = get_material_names(s) m = None if(n in names): m = s.getMaterial(n) if(m is None): # should not happen because i stopped changing material names.. but i leave it here m = self.material_placeholder() return m def camera(self, props, steps, active=False, lens_extra=None, response=None, region=None, custom_bokeh=(1.0, 0.0, False), cut_planes=(0.0, 1e7, False), shift_lens=(0.0, 0.0), ): """Create camera. props (string name, int nSteps, float shutter, float filmWidth, float filmHeight, float iso, int diaphragmType, float angle, int nBlades, float fps, int xRes, int yRes, float pixelAspect, int lensType, int projectionType) steps [(int iStep, [3 float] origin, [3 float] focalPoint, [3 float] up, float focalLength, float fStop, bool focalLengthNeedCorrection), ..., ] active bool lens_extra float or None response string or None region (float x1, float y1, float x2, float y2, string type) or None custom_bokeh (float ratio, float angle, bool enabled) or None cut_planes (float near, float far, bool enabled) or None shift_lens (float x, float y) or None """ s = self.mxs if(props[13] in [6, 7]): props2 = list(props[:]) props2[13] = TYPE_EXTENSION_LENS c = s.addCamera(*props2) else: c = s.addCamera(*props) for step in steps: l = list(step[:]) l[1] = Cvector(*l[1]) l[2] = Cvector(*l[2]) l[3] = Cvector(*l[3]) c.setStep(*l) # TYPE_THIN_LENS, TYPE_PINHOLE, TYPE_ORTHO if(lens_extra is not None): if(props[13] == TYPE_FISHEYE_LENS): c.setFishLensProperties(lens_extra) if(props[13] == TYPE_SPHERICAL_LENS): c.setSphericalLensProperties(lens_extra) if(props[13] == TYPE_CYLINDRICAL_LENS): c.setCylindricalLensProperties(lens_extra) if(props[13] == 6): p = MXparamList() p.createString('EXTENSION_NAME', 'Lat-Long Stereo') p.createUInt('Type', lens_extra[0], 0, 2) p.createFloat('FOV Vertical', lens_extra[1], 180.0, 0.0) p.createFloat('FOV Horizontal', lens_extra[2], 360.0, 0.0) p.createByte('Flip Ray X', lens_extra[3], 0, 1) p.createByte('Flip Ray Y', lens_extra[4], 0, 1) p.createFloat('Parallax Distance', lens_extra[5], 0.0, 360.0) p.createByte('Zenith Mode', lens_extra[6], 0, 1) p.createFloat('Separation', lens_extra[7], 0.0, 100000.0) p.createTextureMap('Separation Map', CtextureMap()) self.texture_data_to_mxparams('Separation Map', lens_extra[8], p, ) c.applyCameraLensExtension(p) if(props[13] == 7): p = MXparamList() p.createString('EXTENSION_NAME', 'Fish Stereo') p.createUInt('Type', lens_extra[0], 0, 2) p.createFloat('FOV', lens_extra[1], 0.0, 360.0) p.createFloat('Separation', lens_extra[2], 0.0, 1000000.0) p.createTextureMap('Separation Map', CtextureMap()) self.texture_data_to_mxparams('Separation Map', lens_extra[3], p, ) p.createByte('Vertical Mode', lens_extra[4], 0, 1) p.createFloat('Dome Radius', lens_extra[5], 1.0, 1000000.0) p.createTextureMap('Turn Map', CtextureMap()) self.texture_data_to_mxparams('Turn Map', lens_extra[6], p, ) p.createByte('Dome Tilt Compensation', lens_extra[7], 0, 1) p.createFloat('Dome Tilt', lens_extra[8], 0.0, 90.0) p.createTextureMap('Tilt Map', CtextureMap()) self.texture_data_to_mxparams('Tilt Map', lens_extra[9], p, ) c.applyCameraLensExtension(p) if(response is not None): c.setCameraResponsePreset(response) if(custom_bokeh is not None): c.setCustomBokeh(*custom_bokeh) if(cut_planes is not None): c.setCutPlanes(*cut_planes) if(shift_lens is not None): c.setShiftLens(*shift_lens) if(region is not None): if(region[2] == props[3]): region[2] -= 1 if(region[3] == props[4]): region[3] -= 1 c.setScreenRegion(*region) if(active): c.setActive() return c def empty(self, name, matrix, motion, object_props=None, ): """Create empty object. name string matrix (((3 float), (3 float), (3 float), (3 float)), ((3 float), (3 float), (3 float), (3 float)), (3 float), (3 float), (3 float)) - base, pivot, location, rotation, scale object_props (bool hide, float opacity, tuple cid=(int, int, int), bool hcam, bool hcamsc, bool hgi, bool hrr, bool hzcp, ) or None """ s = self.mxs o = s.createMesh(name, 0, 0, 0, 0, ) self.set_base_and_pivot(o, matrix, motion, ) if(object_props is not None): self.set_object_props(o, *object_props) return o def mesh(self, name, matrix, motion, num_positions, vertices, normals, triangles, triangle_normals, uv_channels, object_props=None, num_materials=0, materials=[], triangle_materials=None, backface_material=None, ): """Create mesh object. name string base ((3 float), (3 float), (3 float), (3 float)) pivot ((3 float), (3 float), (3 float), (3 float)) num_positions int vertices [[(float x, float y, float z), ..., ], [...], ] normals [[(float x, float y, float z), ..., ], [...], ] triangles [(int iv0, int iv1, int iv2, int in0, int in1, int in2, ), ..., ], ] # (3x vertex index, 3x normal index) triangle_normals [[(float x, float y, float z), ..., ], [...], ] uv_channels [[(float u1, float v1, float w1, float u2, float v2, float w2, float u3, float v3, float w3, ), ..., ], ..., ] or None # ordered by uv index and ordered by triangle index num_materials int object_props (bool hide, float opacity, tuple cid=(int, int, int), bool hcam, bool hcamsc, bool hgi, bool hrr, bool hzcp, ) or None materials [(string path, bool embed), ..., ] or None triangle_materials [(int tri_id, int mat_id), ..., ] or None backface_material (string path, bool embed) or None """ s = self.mxs o = s.createMesh(name, len(vertices[0]), len(normals[0]) + len(triangle_normals[0]), len(triangles), num_positions) if(uv_channels is not None): for i in range(len(uv_channels)): o.addChannelUVW(i) # an = 0 for ip in range(num_positions): an = 0 verts = vertices[ip] norms = normals[ip] for i, loc in enumerate(verts): o.setVertex(i, ip, Cvector(*loc), ) o.setNormal(i, ip, Cvector(*norms[i]), ) an += 1 for ip in range(num_positions): trinorms = triangle_normals[ip] for i, nor in enumerate(trinorms): o.setNormal(an + i, ip, Cvector(*nor), ) if(type(triangles) is not list): # pymaxwell does not like numpy arrays.. Cvectors has no problems, but setTriangle does.. triangles = triangles.tolist() for i, tri in enumerate(triangles): o.setTriangle(i, *tri) if(uv_channels is not None): for iuv, uv in enumerate(uv_channels): for it, t in enumerate(uv): o.setTriangleUVW(it, iuv, *t) self.set_base_and_pivot(o, matrix, motion, ) if(object_props is not None): self.set_object_props(o, *object_props) if(materials is not None): if(num_materials > 1): # multi material mats = [] for i in range(num_materials): try: n = materials[i] mat = self.get_material(n) except: mat = self.material_placeholder() mats.append(mat) # pymaxwell does not like numpy arrays.. if(type(triangle_materials) is not list): triangle_materials = triangle_materials.tolist() for tid, mid in triangle_materials: o.setTriangleMaterial(tid, mats[mid]) else: # single material if(len(materials) == 1): if(materials[0] != ''): mat = self.get_material(materials[0]) o.setMaterial(mat) else: # no material pass if(backface_material is not None): if(backface_material != ''): # only single backface material mat = self.get_material(backface_material) o.setBackfaceMaterial(mat) return o def instance(self, name, instanced_name, matrix, motion=None, object_props=None, materials=None, backface_material=None, ): """Create instance of mesh object. Instanced object must exist in scene. name string instanced_name string base ((3 float), (3 float), (3 float), (3 float)) pivot ((3 float), (3 float), (3 float), (3 float)) object_props (bool hide, float opacity, tuple cid=(int, int, int), bool hcam, bool hcamsc, bool hgi, bool hrr, bool hzcp, ) or None material (string path, bool embed) or None backface_material (string path, bool embed) or None """ s = self.mxs bo = s.getObject(instanced_name) o = s.createInstancement(name, bo) self.set_base_and_pivot(o, matrix, motion, ) if(object_props is not None): self.set_object_props(o, *object_props) if(materials is not None): if(len(materials) > 1): # multi material instances inherits material from base object pass else: # single material, and i think (not sure) i can't make instance with different material than base in blender.. if(len(materials) == 1): if(materials[0] != ''): mat = self.get_material(materials[0]) o.setMaterial(mat) if(backface_material is not None): if(backface_material != ''): mat = self.get_material(backface_material) o.setBackfaceMaterial(mat) return o def reference(self, name, path, flags, matrix, motion=None, object_props=None, material=None, backface_material=None, ): """Create MXS reference object. name string path string (path) flags [bool, bool, bool, bool] base ((3 float), (3 float), (3 float), (3 float)) pivot ((3 float), (3 float), (3 float), (3 float)) object_props (bool hide, float opacity, tuple cid=(int, int, int), bool hcam, bool hcamsc, bool hgi, bool hrr, bool hzcp, ) or None """ s = self.mxs o = s.createMesh(name, 0, 0, 0, 0, ) o.setReferencedScenePath(path) if(flags[0]): o.setReferencedOverrideFlags(FLAG_OVERRIDE_HIDE) if(flags[1]): o.setReferencedOverrideFlags(FLAG_OVERRIDE_HIDE_TO_CAMERA) if(flags[2]): o.setReferencedOverrideFlags(FLAG_OVERRIDE_HIDE_TO_REFL_REFR) if(flags[3]): o.setReferencedOverrideFlags(FLAG_OVERRIDE_HIDE_TO_GI) self.set_base_and_pivot(o, matrix, motion, ) if(object_props is not None): self.set_object_props(o, *object_props) if(material is not None): if(material != ''): mat = self.get_material(material) o.setMaterial(mat) if(backface_material is not None): if(backface_material != ''): mat = self.get_material(backface_material) o.setBackfaceMaterial(mat) return o def hierarchy(self, tree, ): """Set hierarchy of all objects at once. tree [(obj_name, parent_name or None, ), ..., ] """ s = self.mxs for on, pn, _ in tree: if(pn is not None): o = s.getObject(on) p = s.getObject(pn) o.setParent(p) def environment(self, env_type=None, sky_type=None, sky=None, dome=None, sun_type=None, sun=None, ibl=None, ): """Set Environment properties. env_type string or None PHYSICAL_SKY, IMAGE_BASED, NONE sky_type string or None PHYSICAL, CONSTANT sky dict or None {sky_use_preset bool sky_preset string (path) sky_intensity float sky_planet_refl float sky_ozone float sky_water float sky_turbidity_coeff float sky_wavelength_exp float sky_reflectance float sky_asymmetry float} dome dict or None {dome_intensity float dome_zenith [float, float, float] dome_horizon [float, float, float] dome_mid_point float} sun_type string or None DISABLED, PHYSICAL, CUSTOM sun dict or None {sun_power float sun_radius_factor float sun_temp float sun_color [float, float, float] sun_location_type string LATLONG, ANGLES, DIRECTION sun_latlong_lat float sun_latlong_lon float sun_date string sun_time string sun_latlong_gmt int sun_latlong_gmt_auto bool sun_latlong_ground_rotation float sun_angles_zenith float sun_angles_azimuth float sun_dir_x float sun_dir_y float sun_dir_z float} ibl dict or None {ibl_intensity float ibl_interpolation bool ibl_screen_mapping bool ibl_bg_type string HDR_IMAGE, ACTIVE_SKY, DISABLED ibl_bg_map string (path) ibl_bg_intensity float ibl_bg_scale_x float ibl_bg_scale_y float ibl_bg_offset_x float ibl_bg_offset_y float ibl_refl_type string HDR_IMAGE, ACTIVE_SKY, DISABLED ibl_refl_map string (path) ibl_refl_intensity float ibl_refl_scale_x float ibl_refl_scale_y float ibl_refl_offset_x float ibl_refl_offset_y float ibl_refr_type string HDR_IMAGE, ACTIVE_SKY, DISABLED ibl_refr_map string (path) ibl_refr_intensity float ibl_refr_scale_x float ibl_refr_scale_y float ibl_refr_offset_x float ibl_refr_offset_y float ibl_illum_type string HDR_IMAGE, ACTIVE_SKY, DISABLED ibl_illum_map string (path) ibl_illum_intensity float ibl_illum_scale_x float ibl_illum_scale_y float ibl_illum_offset_x float ibl_illum_offset_y float} """ s = self.mxs env = s.getEnvironment() if(env_type == 'PHYSICAL_SKY' or env_type == 'IMAGE_BASED'): if(sky_type is not None): env.setActiveSky(sky_type) if(sky_type == 'PHYSICAL'): if(not sky["sky_use_preset"]): env.setPhysicalSkyAtmosphere(sky["sky_intensity"], sky["sky_ozone"], sky["sky_water"], sky["sky_turbidity_coeff"], sky["sky_wavelength_exp"], sky["sky_reflectance"], sky["sky_asymmetry"], sky["sky_planet_refl"], ) else: env.loadSkyFromPreset(sky["sky_preset"]) elif(sky_type == 'CONSTANT'): hc = Crgb() hc.assign(*dome['dome_horizon']) zc = Crgb() zc.assign(*dome['dome_zenith']) env.setSkyConstant(dome["dome_intensity"], hc, zc, dome['dome_mid_point']) sc = Crgb() sc.assign(*sun['sun_color']) if(sun_type == 'PHYSICAL'): env.setSunProperties(SUN_PHYSICAL, sun["sun_temp"], sun["sun_power"], sun["sun_radius_factor"], sc) elif(sun_type == 'CUSTOM'): env.setSunProperties(SUN_CONSTANT, sun["sun_temp"], sun["sun_power"], sun["sun_radius_factor"], sc) else: # sun_type == 'DISABLED' or sun_type == None env.setSunProperties(SUN_DISABLED, sun["sun_temp"], sun["sun_power"], sun["sun_radius_factor"], sc) if(sun['sun_location_type'] == 'LATLONG'): env.setSunPositionType(0) l = sun["sun_date"].split(".") date = datetime.date(int(l[2]), int(l[1]), int(l[0])) day = int(date.timetuple().tm_yday) l = sun["sun_time"].split(":") hour = int(l[0]) minute = int(l[1]) time = hour + (minute / 60) env.setSunLongitudeAndLatitude(sun["sun_latlong_lon"], sun["sun_latlong_lat"], sun["sun_latlong_gmt"], day, time) env.setSunRotation(sun["sun_latlong_ground_rotation"]) elif(sun['sun_location_type'] == 'ANGLES'): env.setSunPositionType(1) env.setSunAngles(sun["sun_angles_zenith"], sun["sun_angles_azimuth"]) elif(sun['sun_location_type'] == 'DIRECTION'): env.setSunPositionType(2) env.setSunDirection(Cvector(sun["sun_dir_x"], sun["sun_dir_y"], sun["sun_dir_z"])) if(env_type == 'IMAGE_BASED'): env.enableEnvironment(True) def state(s): # channel state: 0 = Disabled; 1 = Enabled; 2 = Use active sky instead. if(s == 'HDR_IMAGE'): return 1 if(s == 'ACTIVE_SKY'): return 2 if(s == 'SAME_AS_BG'): # same as bg, set the same values as in bg layer return 3 return 0 if(ibl is not None): env.setEnvironmentWeight(ibl["ibl_intensity"]) s = state(ibl["ibl_bg_type"]) env.setEnvironmentLayer(IBL_LAYER_BACKGROUND, ibl["ibl_bg_map"], s, not ibl["ibl_screen_mapping"], not ibl["ibl_interpolation"], ibl["ibl_bg_intensity"], ibl["ibl_bg_scale_x"], ibl["ibl_bg_scale_y"], ibl["ibl_bg_offset_x"], ibl["ibl_bg_offset_y"], ) s = state(ibl["ibl_refl_type"]) if(s == 3): s = state(ibl["ibl_bg_type"]) env.setEnvironmentLayer(IBL_LAYER_REFLECTION, ibl["ibl_bg_map"], s, not ibl["ibl_screen_mapping"], not ibl["ibl_interpolation"], ibl["ibl_bg_intensity"], ibl["ibl_bg_scale_x"], ibl["ibl_bg_scale_y"], ibl["ibl_bg_offset_x"], ibl["ibl_bg_offset_y"], ) else: env.setEnvironmentLayer(IBL_LAYER_REFLECTION, ibl["ibl_refl_map"], s, not ibl["ibl_screen_mapping"], not ibl["ibl_interpolation"], ibl["ibl_refl_intensity"], ibl["ibl_refl_scale_x"], ibl["ibl_refl_scale_y"], ibl["ibl_refl_offset_x"], ibl["ibl_refl_offset_y"], ) s = state(ibl["ibl_refr_type"]) if(s == 3): s = state(ibl["ibl_bg_type"]) env.setEnvironmentLayer(IBL_LAYER_REFRACTION, ibl["ibl_bg_map"], s, not ibl["ibl_screen_mapping"], not ibl["ibl_interpolation"], ibl["ibl_bg_intensity"], ibl["ibl_bg_scale_x"], ibl["ibl_bg_scale_y"], ibl["ibl_bg_offset_x"], ibl["ibl_bg_offset_y"], ) else: env.setEnvironmentLayer(IBL_LAYER_REFRACTION, ibl["ibl_refr_map"], s, not ibl["ibl_screen_mapping"], not ibl["ibl_interpolation"], ibl["ibl_refr_intensity"], ibl["ibl_refr_scale_x"], ibl["ibl_refr_scale_y"], ibl["ibl_refr_offset_x"], ibl["ibl_refr_offset_y"], ) s = state(ibl["ibl_illum_type"]) if(s == 3): s = state(ibl["ibl_bg_type"]) env.setEnvironmentLayer(IBL_LAYER_ILLUMINATION, ibl["ibl_bg_map"], s, not ibl["ibl_screen_mapping"], not ibl["ibl_interpolation"], ibl["ibl_bg_intensity"], ibl["ibl_bg_scale_x"], ibl["ibl_bg_scale_y"], ibl["ibl_bg_offset_x"], ibl["ibl_bg_offset_y"], ) else: env.setEnvironmentLayer(IBL_LAYER_ILLUMINATION, ibl["ibl_illum_map"], s, not ibl["ibl_screen_mapping"], not ibl["ibl_interpolation"], ibl["ibl_illum_intensity"], ibl["ibl_illum_scale_x"], ibl["ibl_illum_scale_y"], ibl["ibl_illum_offset_x"], ibl["ibl_illum_offset_y"], ) else: # env_type == 'NONE' or env_type == None env.setActiveSky('') def parameters(self, scene, materials=None, generals=None, tone=None, simulens=None, illum_caustics=None, other=None, text_overlay=None, ): """Set scene render parameters. scene dict {cpu_threads int, multilight int, multilight_type int, quality string RS1, RS0 sampling_level float, time int, }, materials dict {override bool, override_path string (path), search_path string (path), } or None generals dict {diplacement bool, dispersion bool, motion_blur bool, } or None tone dict {burn float, color_space int, gamma float, sharpness bool, sharpness_value float, tint float, whitepoint float, } or None simulens dict {aperture_map string (path), devignetting bool, devignetting_value float, diffraction bool, diffraction_value float, frequency float, obstacle_map string (path), scattering bool, scattering_value float, } or None illum_caustics dict {illumination int, refl_caustics int, refr_caustics int, } or None other dict {protect bool, } """ s = self.mxs # s.setRenderParameter('ENGINE', scene["quality"]) s.setRenderParameter('ENGINE', bytes(scene["quality"], encoding='UTF-8')) s.setRenderParameter('NUM THREADS', scene["cpu_threads"]) s.setRenderParameter('STOP TIME', scene["time"] * 60) s.setRenderParameter('SAMPLING LEVEL', scene["sampling_level"]) s.setRenderParameter('USE MULTILIGHT', scene["multilight"]) s.setRenderParameter('SAVE LIGHTS IN SEPARATE FILES', scene["multilight_type"]) if(generals is not None): s.setRenderParameter('DO MOTION BLUR', generals["motion_blur"]) s.setRenderParameter('DO DISPLACEMENT', generals["diplacement"]) s.setRenderParameter('DO DISPERSION', generals["dispersion"]) if(illum_caustics is not None): v = illum_caustics['illumination'] if(v == 3): s.setRenderParameter('DO DIRECT LAYER', 0) s.setRenderParameter('DO INDIRECT LAYER', 0) elif(v == 2): s.setRenderParameter('DO DIRECT LAYER', 0) s.setRenderParameter('DO INDIRECT LAYER', 1) elif(v == 1): s.setRenderParameter('DO DIRECT LAYER', 1) s.setRenderParameter('DO INDIRECT LAYER', 0) else: s.setRenderParameter('DO DIRECT LAYER', 1) s.setRenderParameter('DO INDIRECT LAYER', 1) v = illum_caustics['refl_caustics'] if(v == 3): s.setRenderParameter('DO DIRECT REFLECTION CAUSTIC LAYER', 0) s.setRenderParameter('DO INDIRECT REFLECTION CAUSTIC LAYER', 0) elif(v == 2): s.setRenderParameter('DO DIRECT REFLECTION CAUSTIC LAYER', 0) s.setRenderParameter('DO INDIRECT REFLECTION CAUSTIC LAYER', 1) elif(v == 1): s.setRenderParameter('DO DIRECT REFLECTION CAUSTIC LAYER', 1) s.setRenderParameter('DO INDIRECT REFLECTION CAUSTIC LAYER', 0) else: s.setRenderParameter('DO DIRECT REFLECTION CAUSTIC LAYER', 1) s.setRenderParameter('DO INDIRECT REFLECTION CAUSTIC LAYER', 1) v = illum_caustics['refr_caustics'] if(v == 3): s.setRenderParameter('DO DIRECT REFRACTION CAUSTIC LAYER', 0) s.setRenderParameter('DO INDIRECT REFRACTION CAUSTIC LAYER', 0) elif(v == 2): s.setRenderParameter('DO DIRECT REFRACTION CAUSTIC LAYER', 0) s.setRenderParameter('DO INDIRECT REFRACTION CAUSTIC LAYER', 1) elif(v == 1): s.setRenderParameter('DO DIRECT REFRACTION CAUSTIC LAYER', 1) s.setRenderParameter('DO INDIRECT REFRACTION CAUSTIC LAYER', 0) else: s.setRenderParameter('DO DIRECT REFRACTION CAUSTIC LAYER', 1) s.setRenderParameter('DO INDIRECT REFRACTION CAUSTIC LAYER', 1) if(simulens is not None): s.setRenderParameter('DO DEVIGNETTING', simulens["devignetting"]) s.setRenderParameter('DEVIGNETTING', simulens["devignetting_value"]) s.setRenderParameter('DO SCATTERING_LENS', simulens["scattering"]) s.setRenderParameter('SCATTERING_LENS', simulens["scattering_value"]) if(simulens["diffraction"]): s.enableDiffraction() s.setDiffraction(simulens["diffraction_value"], simulens["frequency"], simulens["aperture_map"], simulens["obstacle_map"]) if(tone is not None): s.setRenderParameter('DO SHARPNESS', tone["sharpness"]) s.setRenderParameter('SHARPNESS', tone["sharpness_value"]) s.setToneMapping(tone["gamma"], tone["burn"]) s.setColorSpace(tone["color_space"]) s.setWhitePoint(tone["whitepoint"], tone["tint"]) if(materials is not None): if(materials["override"]): s.setOverrideMaterial(True) if(materials["override_path"] != ""): s.setOverrideMaterial(materials["override_path"]) if(materials["search_path"] != ""): s.addSearchingPath(materials["search_path"]) if(materials["default_material"] != ""): s.setDefaultMaterial(True) s.setDefaultMaterial(materials["default_material"]) else: s.setDefaultMaterial(False) if(other is not None): if(other['protect']): s.enableProtection(True) else: s.enableProtection(False) if(other['extra_sampling_enabled']): s.setRenderParameter('DO EXTRA SAMPLING', 1) s.setRenderParameter('EXTRA SAMPLING SL', other['extra_sampling_sl']) s.setRenderParameter('EXTRA SAMPLING MASK', other['extra_sampling_mask']) if(platform.system() == 'Linux'): # wtf? s.setRenderParameter('EXTRA SAMPLING CUSTOM ALPHA', bytes(other['extra_sampling_custom_alpha'], encoding='UTF-8')) s.setRenderParameter('EXTRA SAMPLING USER BITMAP', bytes(other['extra_sampling_user_bitmap'], encoding='UTF-8')) else: s.setRenderParameter('EXTRA SAMPLING CUSTOM ALPHA', other['extra_sampling_custom_alpha']) s.setRenderParameter('EXTRA SAMPLING USER BITMAP', other['extra_sampling_user_bitmap']) if(other['extra_sampling_invert']): s.setRenderParameter('EXTRA SAMPLING INVERT', 1) if(text_overlay is not None): if(text_overlay['enabled']): o = CoverlayTextOptions() o.enabled_ = 1 o.text_ = Cstring(text_overlay['text']) o.position_ = text_overlay['position'] c = Crgb() c.assign(*text_overlay['color']) o.color_ = c.toRGB8() o.backgroundEnabled_ = text_overlay['background'] c = Crgb() c.assign(*text_overlay['background_color']) o.backgroundColor_ = c.toRGB8() s.setOverlayTextOptions(o) def channels(self, base_path, mxi, image, image_depth='RGB8', channels_output_mode=0, channels_render=True, channels_render_type=0, channels=None, ): """Set scene render channels. base_path string (path) mxi string (path) image string (path) image_depth string RGB8, RGB16, RGB32 channels_output_mode int channels_render bool channels_render_type int channels dict {channels_alpha bool channels_alpha_file string channels_alpha_opaque bool channels_custom_alpha bool channels_custom_alpha_file string channels_deep bool channels_deep_file string channels_deep_max_samples int channels_deep_min_dist float channels_deep_type int channels_fresnel bool channels_fresnel_file string channels_material_id bool channels_material_id_file string channels_motion_vector bool channels_motion_vector_file string channels_normals bool channels_normals_file string channels_normals_space int channels_object_id bool channels_object_id_file string channels_position bool channels_position_file string channels_position_space int channels_roughness bool channels_roughness_file string channels_shadow bool channels_shadow_file string channels_uv bool channels_uv_file string channels_z_buffer bool channels_z_buffer_far float channels_z_buffer_file string channels_z_buffer_near float} or None """ def get_ext_depth(t, e=None): if(e is not None): t = "{}{}".format(e[1:].upper(), int(t[3:])) if(t == 'RGB8'): return ('.tif', 8) elif(t == 'RGB16'): return ('.tif', 16) elif(t == 'RGB32'): return ('.tif', 32) elif(t == 'PNG8'): return ('.png', 8) elif(t == 'PNG16'): return ('.png', 16) elif(t == 'TGA'): return ('.tga', 8) elif(t == 'TIF8'): return ('.tif', 8) elif(t == 'TIF16'): return ('.tif', 16) elif(t == 'TIF32'): return ('.tif', 32) elif(t == 'EXR16'): return ('.exr', 16) elif(t == 'EXR32'): return ('.exr', 32) elif(t == 'EXR_DEEP'): return ('.exr', 32) elif(t == 'JPG'): return ('.jpg', 8) elif(t == 'JP2'): return ('.jp2', 8) elif(t == 'HDR'): return ('.hdr', 32) elif(t == 'DTEX'): return ('.dtex', 32) elif(t == 'PSD8'): return ('.psd', 8) elif(t == 'PSD16'): return ('.psd', 16) elif(t == 'PSD32'): return ('.psd', 32) else: return ('.tif', 8) s = self.mxs s.setRenderParameter('DO NOT SAVE MXI FILE', (mxi is None)) s.setRenderParameter('DO NOT SAVE IMAGE FILE', (image is None)) if(mxi is not None): # s.setRenderParameter('MXI FULLNAME', mxi) # s.setRenderParameter('MXI FULLNAME', bytes(mxi, encoding='UTF-8')) if(platform.system() == 'Linux'): # wtf? s.setRenderParameter('MXI FULLNAME', bytes(mxi, encoding='UTF-8')) else: # s.setRenderParameter('MXI FULLNAME', mxi) s.setRenderParameter('MXI FULLNAME', bytes(mxi, encoding='UTF-8')) if(image is not None): if(image_depth is None): image_depth = 'RGB8' _, depth = get_ext_depth(image_depth, os.path.splitext(os.path.split(image)[1])[1]) s.setPath('RENDER', image, depth) s.setRenderParameter('DO RENDER CHANNEL', int(channels_render)) s.setRenderParameter('EMBED CHANNELS', channels_output_mode) s.setRenderParameter('RENDER LAYERS', channels_render_type) if(channels is not None): e, depth = get_ext_depth(channels["channels_alpha_file"]) s.setPath('ALPHA', "{}_alpha{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_shadow_file"]) s.setPath('SHADOW', "{}_shadow{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_object_id_file"]) s.setPath('OBJECT', "{}_object_id{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_material_id_file"]) s.setPath('MATERIAL', "{}_material_id{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_motion_vector_file"]) s.setPath('MOTION', "{}_motion_vector{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_z_buffer_file"]) s.setPath('Z', "{}_z_buffer{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_roughness_file"]) s.setPath('ROUGHNESS', "{}_roughness{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_fresnel_file"]) s.setPath('FRESNEL', "{}_fresnel{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_normals_file"]) s.setPath('NORMALS', "{}_normals{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_position_file"]) s.setPath('POSITION', "{}_position{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_deep_file"]) s.setPath('DEEP', "{}_deep{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_uv_file"]) s.setPath('UV', "{}_uv{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_custom_alpha_file"]) s.setPath('ALPHA_CUSTOM', "{}_custom_alpha{}".format(base_path, e), depth) e, depth = get_ext_depth(channels["channels_reflectance_file"]) s.setPath('REFLECTANCE', "{}_reflectance{}".format(base_path, e), depth) s.setRenderParameter('DO ALPHA CHANNEL', int(channels["channels_alpha"])) s.setRenderParameter('OPAQUE ALPHA', int(channels["channels_alpha_opaque"])) s.setRenderParameter('DO IDOBJECT CHANNEL', int(channels["channels_object_id"])) s.setRenderParameter('DO IDMATERIAL CHANNEL', int(channels["channels_material_id"])) s.setRenderParameter('DO SHADOW PASS CHANNEL', int(channels["channels_shadow"])) s.setRenderParameter('DO MOTION CHANNEL', int(channels["channels_motion_vector"])) s.setRenderParameter('DO ROUGHNESS CHANNEL', int(channels["channels_roughness"])) s.setRenderParameter('DO FRESNEL CHANNEL', int(channels["channels_fresnel"])) s.setRenderParameter('DO NORMALS CHANNEL', int(channels["channels_normals"])) s.setRenderParameter('NORMALS CHANNEL SPACE', channels["channels_normals_space"]) s.setRenderParameter('POSITION CHANNEL SPACE', channels["channels_position_space"]) s.setRenderParameter('DO POSITION CHANNEL', int(channels["channels_position"])) s.setRenderParameter('DO ZBUFFER CHANNEL', int(channels["channels_z_buffer"])) s.setRenderParameter('ZBUFFER RANGE', (channels["channels_z_buffer_near"], channels["channels_z_buffer_far"])) s.setRenderParameter('DO DEEP CHANNEL', int(channels["channels_deep"])) s.setRenderParameter('DEEP CHANNEL TYPE', channels["channels_deep_type"]) s.setRenderParameter('DEEP MIN DISTANCE', channels["channels_deep_min_dist"]) s.setRenderParameter('DEEP MAX SAMPLES', channels["channels_deep_max_samples"]) s.setRenderParameter('DO UV CHANNEL', int(channels["channels_uv"])) # s.setRenderParameter('MOTION CHANNEL TYPE', ?) s.setRenderParameter('DO ALPHA CUSTOM CHANNEL', int(channels["channels_custom_alpha"])) s.setRenderParameter('DO REFLECTANCE CHANNEL', int(channels["channels_reflectance"])) def custom_alphas(self, groups, ): """Set custom alphas. groups list of dicts: {'name': string, 'objects': list of strings, 'opaque': bool, } """ s = self.mxs def get_material_names(s): it = CmaxwellMaterialIterator() o = it.first(s) l = [] while not o.isNull(): name = o.getName() l.append(name) o = it.next() return l def get_object_names(s): it = CmaxwellObjectIterator() o = it.first(s) l = [] while not o.isNull(): name, _ = o.getName() l.append(name) o = it.next() return l sobs = get_object_names(s) smats = get_material_names(s) for a in groups: s.createCustomAlphaChannel(a['name'], a['opaque']) for n in a['objects']: if(n in sobs): o = s.getObject(n) o.addToCustomAlpha(a['name']) for n in a['materials']: if(n in smats): m = s.getMaterial(n) m.addToCustomAlpha(a['name']) def ext_particles(self, name, properties, matrix, motion=None, object_props=None, material=None, backface_material=None, ): """Create particles object. name string properties dict base ((3 float), (3 float), (3 float), (3 float)) pivot ((3 float), (3 float), (3 float), (3 float)) object_props (bool hide, float opacity, tuple cid=(int, int, int), bool hcam, bool hcamsc, bool hgi, bool hrr, bool hzcp, ) or None material (string path, bool embed) or None backface_material (string path, bool embed) or None """ s = self.mxs e = self.mgr.createDefaultGeometryProceduralExtension('MaxwellParticles') p = e.getExtensionData() d = properties if(d['embed'] is True): c = Cbase() c.origin = Cvector(0.0, 0.0, 0.0) c.xAxis = Cvector(1.0, 0.0, 0.0) c.yAxis = Cvector(0.0, 1.0, 0.0) c.zAxis = Cvector(0.0, 0.0, 1.0) p.setFloatArray('PARTICLE_POSITIONS', list(d['pdata']['PARTICLE_POSITIONS']), c) p.setFloatArray('PARTICLE_SPEEDS', list(d['pdata']['PARTICLE_SPEEDS']), c) p.setFloatArray('PARTICLE_RADII', list(d['pdata']['PARTICLE_RADII']), c) p.setIntArray('PARTICLE_IDS', list(d['pdata']['PARTICLE_IDS'])) p.setFloatArray('PARTICLE_NORMALS', list(d['pdata']['PARTICLE_NORMALS']), c) p.setFloatArray('PARTICLE_UVW', list(d['pdata']['PARTICLE_UVW']), c) else: p.setString('FileName', d['filename']) p.setFloat('Radius Factor', d['radius_multiplier']) p.setFloat('MB Factor', d['motion_blur_multiplier']) p.setFloat('Shutter 1/', d['shutter_speed']) p.setFloat('Load particles %', d['load_particles']) p.setUInt('Axis', d['axis_system']) p.setInt('Frame#', d['frame_number']) p.setFloat('fps', d['fps']) p.setInt('Create N particles per particle', d['extra_create_np_pp']) p.setFloat('Extra particles dispersion', d['extra_dispersion']) p.setFloat('Extra particles deformation', d['extra_deformation']) p.setByte('Load particle Force', d['load_force']) p.setByte('Load particle Vorticity', d['load_vorticity']) p.setByte('Load particle Normal', d['load_normal']) p.setByte('Load particle neighbors no.', d['load_neighbors_num']) p.setByte('Load particle UV', d['load_uv']) p.setByte('Load particle Age', d['load_age']) p.setByte('Load particle Isolation Time', d['load_isolation_time']) p.setByte('Load particle Viscosity', d['load_viscosity']) p.setByte('Load particle Density', d['load_density']) p.setByte('Load particle Pressure', d['load_pressure']) p.setByte('Load particle Mass', d['load_mass']) p.setByte('Load particle Temperature', d['load_temperature']) p.setByte('Load particle ID', d['load_id']) p.setFloat('Min Force', d['min_force']) p.setFloat('Max Force', d['max_force']) p.setFloat('Min Vorticity', d['min_vorticity']) p.setFloat('Max Vorticity', d['max_vorticity']) p.setInt('Min Nneighbors', d['min_nneighbors']) p.setInt('Max Nneighbors', d['max_nneighbors']) p.setFloat('Min Age', d['min_age']) p.setFloat('Max Age', d['max_age']) p.setFloat('Min Isolation Time', d['min_isolation_time']) p.setFloat('Max Isolation Time', d['max_isolation_time']) p.setFloat('Min Viscosity', d['min_viscosity']) p.setFloat('Max Viscosity', d['max_viscosity']) p.setFloat('Min Density', d['min_density']) p.setFloat('Max Density', d['max_density']) p.setFloat('Min Pressure', d['min_pressure']) p.setFloat('Max Pressure', d['max_pressure']) p.setFloat('Min Mass', d['min_mass']) p.setFloat('Max Mass', d['max_mass']) p.setFloat('Min Temperature', d['min_temperature']) p.setFloat('Max Temperature', d['max_temperature']) p.setFloat('Min Velocity', d['min_velocity']) p.setFloat('Max Velocity', d['max_velocity']) o = s.createGeometryProceduralObject(name, p) a, _ = o.addChannelUVW() o.generateCustomUVW(0, a) self.set_base_and_pivot(o, matrix, motion, ) if(object_props is not None): self.set_object_props(o, *object_props) if(material is not None): if(material != ''): mat = self.get_material(material) o.setMaterial(mat) if(backface_material is not None): if(backface_material != ''): mat = self.get_material(backface_material) o.setBackfaceMaterial(mat) return o def ext_hair(self, name, extension, matrix, motion, root_radius, tip_radius, data, object_props=None, display_percent=10, display_max=1000, material=None, backface_material=None, ): """Create hair/grass object. name string extension string ('MaxwellHair' ,'MGrassP') base ((3 float), (3 float), (3 float), (3 float)) pivot ((3 float), (3 float), (3 float), (3 float)) root_radius float tip_radius float data dict of extension data object_props (bool hide, float opacity, tuple cid=(int, int, int), bool hcam, bool hcamsc, bool hgi, bool hrr, bool hzcp, ) or None display_percent int display_max int material (string path, bool embed) or None backface_material (string path, bool embed) or None """ s = self.mxs e = self.mgr.createDefaultGeometryProceduralExtension(extension) p = e.getExtensionData() p.setByteArray('HAIR_MAJOR_VER', data['HAIR_MAJOR_VER']) p.setByteArray('HAIR_MINOR_VER', data['HAIR_MINOR_VER']) p.setByteArray('HAIR_FLAG_ROOT_UVS', data['HAIR_FLAG_ROOT_UVS']) m = memoryview(struct.pack("I", data['HAIR_GUIDES_COUNT'][0])).tolist() p.setByteArray('HAIR_GUIDES_COUNT', m) m = memoryview(struct.pack("I", data['HAIR_GUIDES_POINT_COUNT'][0])).tolist() p.setByteArray('HAIR_GUIDES_POINT_COUNT', m) c = Cbase() c.origin = Cvector(0.0, 0.0, 0.0) c.xAxis = Cvector(1.0, 0.0, 0.0) c.yAxis = Cvector(0.0, 1.0, 0.0) c.zAxis = Cvector(0.0, 0.0, 1.0) p.setFloatArray('HAIR_POINTS', list(data['HAIR_POINTS']), c) p.setFloatArray('HAIR_NORMALS', list(data['HAIR_NORMALS']), c) if(data['HAIR_FLAG_ROOT_UVS'][0] == 1): p.setFloatArray('HAIR_ROOT_UVS', list(data['HAIR_ROOT_UVS']), c) p.setUInt('Display Percent', display_percent) if(extension == 'MaxwellHair'): p.setUInt('Display Max. Hairs', display_max) p.setDouble('Root Radius', root_radius) p.setDouble('Tip Radius', tip_radius) if(extension == 'MGrassP'): p.setUInt('Display Max. Hairs', display_max) p.setDouble('Root Radius', root_radius) p.setDouble('Tip Radius', tip_radius) o = s.createGeometryProceduralObject(name, p) if(extension == 'MaxwellHair'): a, _ = o.addChannelUVW() o.generateCustomUVW(0, a) b, _ = o.addChannelUVW() o.generateCustomUVW(1, b) c, _ = o.addChannelUVW() o.generateCustomUVW(2, c) if(extension == 'MGrassP'): a, _ = o.addChannelUVW() o.generateCustomUVW(0, a) b, _ = o.addChannelUVW() o.generateCustomUVW(1, b) self.set_base_and_pivot(o, matrix, motion, ) if(object_props is not None): self.set_object_props(o, *object_props) if(material is not None): if(material != ''): mat = self.get_material(material) o.setMaterial(mat) if(backface_material is not None): if(backface_material != ''): mat = self.get_material(backface_material) o.setBackfaceMaterial(mat) return o def ext_sea(self, name, matrix, motion=None, object_props=None, geometry=None, wind=None, material=None, backface_material=None, ): """Create sea extension object. name string base ((3 float), (3 float), (3 float), (3 float)) pivot ((3 float), (3 float), (3 float), (3 float)) object_props (bool hide, float opacity, tuple cid=(int, int, int), bool hcam, bool hcamsc, bool hgi, bool hrr, bool hzcp, ) or None geometry (float reference_time, int resolution, float ocean_depth, float vertical_scale, float ocean_dim, int ocean_seed, bool enable_choppyness, float choppy_factor, ) wind (float ocean_wind_mod, float ocean_wind_dir, float ocean_wind_alignment, float ocean_min_wave_length, float damp_factor_against_wind, ) material (string path, bool embed) or None backface_material (string path, bool embed) or None """ s = self.mxs e = self.mgr.createDefaultGeometryLoaderExtension('MaxwellSea') p = e.getExtensionData() p.setFloat('Reference Time', geometry[0]) p.setUInt('Resolution', geometry[1]) p.setFloat('Ocean Depth', geometry[2]) p.setFloat('Vertical Scale', geometry[3]) p.setFloat('Ocean Dim', geometry[4]) p.setUInt('Ocean Seed', geometry[5]) p.setByte('Enable Choppyness', geometry[6]) p.setFloat('Choppy factor', geometry[7]) p.setByte('Enable White Caps', geometry[8]) p.setFloat('Ocean Wind Mod.', wind[0]) p.setFloat('Ocean Wind Dir.', wind[1]) p.setFloat('Ocean Wind Alignment', wind[2]) p.setFloat('Ocean Min. Wave Length', wind[3]) p.setFloat('Damp Factor Against Wind', wind[4]) o = s.createGeometryLoaderObject(name, p) self.set_base_and_pivot(o, matrix, motion, ) if(object_props is not None): self.set_object_props(o, *object_props) if(material is not None): if(material != ''): mat = self.get_material(material) o.setMaterial(mat) if(backface_material is not None): if(backface_material != ''): mat = self.get_material(backface_material) o.setBackfaceMaterial(mat) def ext_volumetrics(self, name, properties, matrix, motion=None, object_props=None, material=None, backface_material=None, ): """Create Volumetrics Extension Object. name string properties (int type 1, float density) or (int type 2, float density, int seed, float low, float high, float detail, int octaves, float perssistence) base ((3 float), (3 float), (3 float), (3 float)) pivot ((3 float), (3 float), (3 float), (3 float)) object_props (bool hide, float opacity, tuple cid=(int, int, int), bool hcam, bool hcamsc, bool hgi, bool hrr, bool hzcp, ) or None material (string path, bool embed) or None backface_material (string path, bool embed) or None """ s = self.mxs e = self.mgr.createDefaultGeometryProceduralExtension('MaxwellVolumetric') p = e.getExtensionData() d = properties p.setByte('Create Constant Density', d[0]) p.setFloat('ConstantDensity', d[1]) if(d[0] == 2): p.setUInt('Seed', d[2]) p.setFloat('Low value', d[3]) p.setFloat('High value', d[4]) p.setFloat('Detail', d[5]) p.setInt('Octaves', d[6]) p.setFloat('Persistance', d[7]) o = s.createGeometryProceduralObject(name, p) self.set_base_and_pivot(o, matrix, motion, ) if(object_props is not None): self.set_object_props(o, *object_props) if(material is not None): if(material != ''): mat = self.get_material(material) o.setMaterial(mat) if(backface_material is not None): if(backface_material != ''): mat = self.get_material(backface_material) o.setBackfaceMaterial(mat) return o def mod_grass(self, object_name, properties, material=None, backface_material=None, ): """Create grass object modifier extension. object_name string properties dict of many, many properties, see code.. material (string path, bool embed) or None backface_material (string path, bool embed) or None """ s = self.mxs e = self.mgr.createDefaultGeometryModifierExtension('MaxwellGrass') p = e.getExtensionData() if(material is not None): mat = self.get_material(material) if(mat is not None): p.setString('Material', mat.getName()) if(backface_material is not None): mat = self.get_material(backface_material) if(mat is not None): p.setString('Double Sided Material', mat.getName()) p.setUInt('Density', properties['density']) self.texture_data_to_mxparams('Density Map', properties['density_map'], p, ) p.setFloat('Length', properties['length']) self.texture_data_to_mxparams('Length Map', properties['length_map'], p, ) p.setFloat('Length Variation', properties['length_variation']) p.setFloat('Root Width', properties['root_width']) p.setFloat('Tip Width', properties['tip_width']) p.setFloat('Direction Type', properties['direction_type']) p.setFloat('Initial Angle', properties['initial_angle']) p.setFloat('Initial Angle Variation', properties['initial_angle_variation']) self.texture_data_to_mxparams('Initial Angle Map', properties['initial_angle_map'], p, ) p.setFloat('Start Bend', properties['start_bend']) p.setFloat('Start Bend Variation', properties['start_bend_variation']) self.texture_data_to_mxparams('Start Bend Map', properties['start_bend_map'], p, ) p.setFloat('Bend Radius', properties['bend_radius']) p.setFloat('Bend Radius Variation', properties['bend_radius_variation']) self.texture_data_to_mxparams('Bend Radius Map', properties['bend_radius_map'], p, ) p.setFloat('Bend Angle', properties['bend_angle']) p.setFloat('Bend Angle Variation', properties['bend_angle_variation']) self.texture_data_to_mxparams('Bend Angle Map', properties['bend_angle_map'], p, ) p.setFloat('Cut Off', properties['cut_off']) p.setFloat('Cut Off Variation', properties['cut_off_variation']) self.texture_data_to_mxparams('Cut Off Map', properties['cut_off_map'], p, ) p.setUInt('Points per Blade', properties['points_per_blade']) p.setUInt('Primitive Type', properties['primitive_type']) p.setUInt('Seed', properties['seed']) p.setByte('Enable LOD', properties['lod']) p.setFloat('LOD Min Distance', properties['lod_min_distance']) p.setFloat('LOD Max Distance', properties['lod_max_distance']) p.setFloat('LOD Max Distance Density', properties['lod_max_distance_density']) p.setUInt('Display Percent', properties['display_percent']) p.setUInt('Display Max. Blades', properties['display_max_blades']) o = s.getObject(object_name) o.applyGeometryModifierExtension(p) return o def mod_subdivision(self, object_name, level=2, scheme=0, interpolation=2, crease=0.0, smooth_angle=90.0, quads=None, ): """Create subdivision object modifier extension. object_name string level int scheme int (0, "Catmull-Clark"), (1, "Loop") interpolation int (0, "None"), (1, "Edges"), (2, "Edges And Corners"), (3, "Sharp") crease float smooth float quads [[int, int], ...] or None """ s = self.mxs e = self.mgr.createDefaultGeometryModifierExtension('SubdivisionModifier') p = e.getExtensionData() p.setUInt('Subdivision Level', level) p.setUInt('Subdivision Scheme', scheme) p.setUInt('Interpolation', interpolation) p.setFloat('Crease', crease) p.setFloat('Smooth Angle', smooth_angle) o = s.getObject(object_name) if(scheme == 0 and quads is not None): for t, q in quads: o.setTriangleQuadBuddy(t, q) o.applyGeometryModifierExtension(p) return o def mod_scatter(self, object_name, scatter_object, inherit_objectid=False, remove_overlapped=False, density=None, seed=0, scale=None, rotation=None, lod=None, angle=None, display_percent=10, display_max=1000, ): """Create scatter object modifier extension. object_name string scatter_object string inherit_objectid bool density (float, density_map or None) or None seed int scale ((float, float, float), scale_map or None, scale_variation (float, float, float)) or None rotation ((float, float, float), rotation_map or None, rotation_variation (float, float, float), rotation_direction int (0, "Polygon Normal"), (1, "World Z")) or None lod (bool, lod_min_distance float, lod_max_distance float, lod_max_distance_density float) or None display_percent int display_max int """ s = self.mxs e = self.mgr.createDefaultGeometryModifierExtension('MaxwellScatter') p = e.getExtensionData() p.setString('Object', scatter_object) p.setByte('Inherit ObjectID', inherit_objectid) if(density is not None): p.setFloat('Density', density[0]) self.texture_data_to_mxparams('Density Map', density[1], p, ) p.setUInt('Seed', seed) p.setByte('Remove Overlapped', remove_overlapped) if(scale is not None): p.setFloat('Scale X', scale[0]) p.setFloat('Scale Y', scale[1]) p.setFloat('Scale Z', scale[2]) self.texture_data_to_mxparams('Scale Map', scale[3], p, ) p.setFloat('Scale X Variation', scale[4]) p.setFloat('Scale Y Variation', scale[5]) p.setFloat('Scale Z Variation', scale[6]) p.setByte('Uniform Scale', scale[7]) if(rotation is not None): p.setFloat('Rotation X', rotation[0]) p.setFloat('Rotation Y', rotation[1]) p.setFloat('Rotation Z', rotation[2]) self.texture_data_to_mxparams('Rotation Map', rotation[3], p, ) p.setFloat('Rotation X Variation', rotation[4]) p.setFloat('Rotation Y Variation', rotation[5]) p.setFloat('Rotation Z Variation', rotation[6]) p.setUInt('Direction Type', rotation[7]) if(lod is not None): p.setByte('Enable LOD', lod[0]) p.setFloat('LOD Min Distance', lod[1]) p.setFloat('LOD Max Distance', lod[2]) p.setFloat('LOD Max Distance Density', lod[3]) if(angle is not None): p.setFloat('Direction Type', angle[0]) p.setFloat('Initial Angle', angle[1]) p.setFloat('Initial Angle Variation', angle[2]) self.texture_data_to_mxparams('Initial Angle Map', angle[3], p, ) p.setUInt('Display Percent', display_percent) p.setUInt('Display Max. Blades', display_max) o = s.getObject(object_name) o.applyGeometryModifierExtension(p) return o def mod_cloner(self, object_name, cloned_object, render_emitter, pdata, radius=1.0, mb_factor=1.0, load_percent=100.0, start_offset=0, ex_npp=0, ex_p_dispersion=0.0, ex_p_deformation=0.0, align_to_velocity=False, scale_with_radius=False, inherit_obj_id=False, frame=1, fps=24.0, display_percent=10, display_max=1000, ): """Create cloner object modifier extension. object_name string cloned_object string render_emitter bool pdata string or dict radius float mb_factor float load_percent float start_offset int ex_npp int ex_p_dispersion float ex_p_deformation float align_to_velocity bool scale_with_radius bool inherit_obj_id bool frame int fps float display_percent int display_max int """ s = self.mxs e = self.mgr.createDefaultGeometryModifierExtension('MaxwellCloner') p = e.getExtensionData() if(type(pdata) is dict): c = Cbase() c.origin = Cvector(0.0, 0.0, 0.0) c.xAxis = Cvector(1.0, 0.0, 0.0) c.yAxis = Cvector(0.0, 1.0, 0.0) c.zAxis = Cvector(0.0, 0.0, 1.0) p.setFloatArray('PARTICLE_POSITIONS', list(pdata['PARTICLE_POSITIONS']), c) p.setFloatArray('PARTICLE_SPEEDS', list(pdata['PARTICLE_SPEEDS']), c) p.setFloatArray('PARTICLE_RADII', list(pdata['PARTICLE_RADII']), c) p.setIntArray('PARTICLE_IDS', list(pdata['PARTICLE_IDS'])) else: p.setString('FileName', pdata) p.setFloat('Radius Factor', radius) p.setFloat('MB Factor', mb_factor) p.setFloat('Load particles %', load_percent) p.setUInt('Start offset', start_offset) p.setUInt('Create N particles per particle', ex_npp) p.setFloat('Extra particles dispersion', ex_p_dispersion) p.setFloat('Extra particles deformation', ex_p_deformation) p.setByte('Use velocity', align_to_velocity) p.setByte('Scale with particle radius', scale_with_radius) p.setByte('Inherit ObjectID', inherit_obj_id) p.setInt('Frame#', frame) p.setFloat('fps', fps) p.setUInt('Display Percent', display_percent) p.setUInt('Display Max. Particles', display_max) if(not render_emitter): o = s.getObject(object_name) o.setHide(True) o = s.getObject(cloned_object) o.applyGeometryModifierExtension(p) return o def wireframe_override_object_materials(self, clay_mat_name, wire_base_name, ): s = self.mxs it = CmaxwellObjectIterator() o = it.first(scene) l = [] while not o.isNull(): name, _ = o.getName() l.append(name) o = it.next() for o in l: # do not set material to wire base if(o.getName()[0] != wire_base_name): if(o.isInstance()[0] == 1): instanced = o.getInstanced() # do not set material to wire base instances if(instanced.getName()[0] != wire_base_name): o.setMaterial(clay_mat_name) else: o.setMaterial(clay_mat_name) def wireframe_zero_scale_base(self, wire_base_name): s = self.mxs o = s.getObject(wire_base_name) z = (0.0, 0.0, 0.0) b = Cbase() b.origin = Cvector(*z) b.xAxis = Cvector(*z) b.yAxis = Cvector(*z) b.zAxis = Cvector(*z) p = Cbase() p.origin = Cvector(*z) p.xAxis = Cvector(1.0, 0.0, 0.0) p.yAxis = Cvector(0.0, 1.0, 0.0) p.zAxis = Cvector(0.0, 0.0, 1.0) o.setBaseAndPivot(b, p) o.setScale(Cvector(0, 0, 0)) class MXMWriter(): def __init__(self, path, data, ): """Create Extension MXM. path string (path) data dict """ if(__name__ != "__main__"): if(platform.system() == 'Darwin'): raise ImportError("No pymaxwell for Mac OS X..") log(self.__class__.__name__, 1, LogStyles.MESSAGE, prefix="* ", ) self.path = path self.mxs = Cmaxwell(mwcallback) self.mgr = CextensionManager.instance() self.mgr.loadAllExtensions() mat = self.material(data) if(mat is not None): log("writing to: {}".format(self.path), 2, prefix="* ", ) mat.write(path) log("done.", 2, prefix="* ", ) else: raise RuntimeError("Something unexpected happened..") def texture_data_to_mxparams(self, name, data, mxparams, ): """Create CtextureMap, fill with parameters and put into mxparams. name string data dict {'type': string, 'path': string, 'channel': int, 'use_global_map': bool, 'tile_method_type': [bool, bool], 'tile_method_units': int, 'repeat': [float, float], 'mirror': [bool, bool], 'offset': [float, float], 'rotation': float, 'invert': bool, 'alpha_only': bool, 'interpolation': bool, 'brightness': float, 'contrast': float, 'saturation': float, 'hue': float, 'rgb_clamp': [float, float], } mxparams mxparams """ d = data if(d is None): return t = CtextureMap() t.setPath(d['path']) v = Cvector2D() v.assign(*d['repeat']) t.scale = v v = Cvector2D() v.assign(*d['offset']) t.offset = v t.rotation = d['rotation'] t.uvwChannelID = d['channel'] t.uIsTiled = d['tile_method_type'][0] t.vIsTiled = d['tile_method_type'][1] t.uIsMirrored = d['mirror'][0] t.vIsMirrored = d['mirror'][1] t.invert = d['invert'] # t.doGammaCorrection = 0 t.useAbsoluteUnits = d['tile_method_units'] t.normalMappingFlipRed = d['normal_mapping_flip_red'] t.normalMappingFlipGreen = d['normal_mapping_flip_green'] t.normalMappingFullRangeBlue = d['normal_mapping_full_range_blue'] t.useAlpha = d['alpha_only'] t.typeInterpolation = d['interpolation'] t.saturation = d['saturation'] / 100 t.contrast = d['contrast'] / 100 t.brightness = d['brightness'] / 100 t.hue = d['hue'] / 180 t.clampMin = d['rgb_clamp'][0] / 255 t.clampMax = d['rgb_clamp'][1] / 255 t.useGlobalMap = d['use_global_map'] # t.cosA = 1.000000 # t.sinA = 0.000000 ok = mxparams.setTextureMap(name, t) return mxparams def texture(self, d, ): """Create CtextureMap from parameters d dict """ s = self.mxs t = CtextureMap() t.setPath(d['path']) t.uvwChannelID = d['channel'] t.brightness = d['brightness'] / 100 t.contrast = d['contrast'] / 100 t.saturation = d['saturation'] / 100 t.hue = d['hue'] / 180 t.useGlobalMap = d['use_global_map'] t.useAbsoluteUnits = d['tile_method_units'] t.uIsTiled = d['tile_method_type'][0] t.vIsTiled = d['tile_method_type'][1] t.uIsMirrored = d['mirror'][0] t.vIsMirrored = d['mirror'][1] vec = Cvector2D() vec.assign(d['offset'][0], d['offset'][1]) t.offset = vec t.rotation = d['rotation'] t.invert = d['invert'] t.useAlpha = d['alpha_only'] if(d['interpolation']): t.typeInterpolation = 1 else: t.typeInterpolation = 0 t.clampMin = d['rgb_clamp'][0] / 255 t.clampMax = d['rgb_clamp'][1] / 255 vec = Cvector2D() vec.assign(d['repeat'][0], d['repeat'][1]) t.scale = vec t.normalMappingFlipRed = d['normal_mapping_flip_red'] t.normalMappingFlipGreen = d['normal_mapping_flip_green'] t.normalMappingFullRangeBlue = d['normal_mapping_full_range_blue'] for i, pt in enumerate(d['procedural']): if(pt['use'] == 'BRICK'): e = self.mgr.createDefaultTextureExtension('Brick') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setFloat('Brick width', pt['brick_brick_width']) p.setFloat('Brick height', pt['brick_brick_height']) p.setInt('Brick offset', pt['brick_brick_offset']) p.setInt('Random offset', pt['brick_random_offset']) p.setByte('Double brick', pt['brick_double_brick']) p.setFloat('Small brick width', pt['brick_small_brick_width']) p.setByte('Round corners', pt['brick_round_corners']) p.setFloat('Boundary sharpness U', pt['brick_boundary_sharpness_u']) p.setFloat('Boundary sharpness V', pt['brick_boundary_sharpness_v']) p.setInt('Boundary noise detail', pt['brick_boundary_noise_detail']) p.setFloat('Boundary noise region U', pt['brick_boundary_noise_region_u']) p.setFloat('Boundary noise region V', pt['brick_boundary_noise_region_v']) p.setUInt('Seed', pt['brick_seed']) p.setByte('Random rotation', pt['brick_random_rotation']) p.setInt('Color variation', pt['brick_color_variation']) c = Crgb() c.assign(*pt['brick_brick_color_0']) p.setRgb('Brick color 0', c) self.texture_data_to_mxparams('Brick texture 0', pt['brick_brick_texture_0'], p, ) p.setInt('Sampling factor 0', pt['brick_sampling_factor_0']) p.setInt('Weight 0', pt['brick_weight_0']) c = Crgb() c.assign(*pt['brick_brick_color_1']) p.setRgb('Brick color 1', c) self.texture_data_to_mxparams('Brick texture 1', pt['brick_brick_texture_1'], p, ) p.setInt('Sampling factor 1', pt['brick_sampling_factor_1']) p.setInt('Weight 1', pt['brick_weight_1']) c = Crgb() c.assign(*pt['brick_brick_color_2']) p.setRgb('Brick color 2', c) self.texture_data_to_mxparams('Brick texture 2', pt['brick_brick_texture_2'], p, ) p.setInt('Sampling factor 2', pt['brick_sampling_factor_2']) p.setInt('Weight 2', pt['brick_weight_2']) p.setFloat('Mortar thickness', pt['brick_mortar_thickness']) c = Crgb() c.assign(*pt['brick_mortar_color']) p.setRgb('Mortar color', c) self.texture_data_to_mxparams('Mortar texture', pt['brick_mortar_texture'], p, ) t.addProceduralTexture(p) elif(pt['use'] == 'CHECKER'): e = self.mgr.createDefaultTextureExtension('Checker') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) c = Crgb() c.assign(*pt['checker_color_0']) p.setRgb('Color0', c) c = Crgb() c.assign(*pt['checker_color_1']) p.setRgb('Color1', c) p.setUInt('Number of elements U', pt['checker_number_of_elements_u']) p.setUInt('Number of elements V', pt['checker_number_of_elements_v']) p.setFloat('Transition sharpness', pt['checker_transition_sharpness']) p.setUInt('Fall-off', pt['checker_falloff']) t.addProceduralTexture(p) elif(pt['use'] == 'CIRCLE'): e = self.mgr.createDefaultTextureExtension('Circle') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) c = Crgb() c.assign(*pt['circle_background_color']) p.setRgb('Background color', c) c = Crgb() c.assign(*pt['circle_circle_color']) p.setRgb('Circle color', c) p.setFloat('RadiusU', pt['circle_radius_u']) p.setFloat('RadiusV', pt['circle_radius_v']) p.setFloat('Transition factor', pt['circle_transition_factor']) p.setUInt('Fall-off', pt['circle_falloff']) t.addProceduralTexture(p) elif(pt['use'] == 'GRADIENT3'): e = self.mgr.createDefaultTextureExtension('Gradient3') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setByte('Gradient U', pt['gradient3_gradient_u']) c = Crgb() c.assign(*pt['gradient3_color0_u']) p.setRgb('Color0 U', c) c = Crgb() c.assign(*pt['gradient3_color1_u']) p.setRgb('Color1 U', c) c = Crgb() c.assign(*pt['gradient3_color2_u']) p.setRgb('Color2 U', c) p.setUInt('Gradient type U', pt['gradient3_gradient_type_u']) p.setFloat('Color1 U position', pt['gradient3_color1_u_position']) p.setByte('Gradient V', pt['gradient3_gradient_v']) c = Crgb() c.assign(*pt['gradient3_color0_v']) p.setRgb('Color0 V', c) c = Crgb() c.assign(*pt['gradient3_color1_v']) p.setRgb('Color1 V', c) c = Crgb() c.assign(*pt['gradient3_color2_v']) p.setRgb('Color2 V', c) p.setUInt('Gradient type V', pt['gradient3_gradient_type_v']) p.setFloat('Color1 V position', pt['gradient3_color1_v_position']) t.addProceduralTexture(p) elif(pt['use'] == 'GRADIENT'): e = self.mgr.createDefaultTextureExtension('Gradient') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setByte('Gradient U', pt['gradient_gradient_u']) c = Crgb() c.assign(*pt['gradient_color0_u']) p.setRgb('Color0 U', c) c = Crgb() c.assign(*pt['gradient_color1_u']) p.setRgb('Color1 U', c) p.setUInt('Gradient type U', pt['gradient_gradient_type_u']) p.setFloat('Transition factor U', pt['gradient_transition_factor_u']) p.setByte('Gradient V', pt['gradient_gradient_v']) c = Crgb() c.assign(*pt['gradient_color0_v']) p.setRgb('Color0 V', c) c = Crgb() c.assign(*pt['gradient_color1_v']) p.setRgb('Color1 V', c) p.setUInt('Gradient type V', pt['gradient_gradient_type_v']) p.setFloat('Transition factor V', pt['gradient_transition_factor_v']) t.addProceduralTexture(p) elif(pt['use'] == 'GRID'): e = self.mgr.createDefaultTextureExtension('Grid') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) c = Crgb() c.assign(*pt['grid_boundary_color']) p.setRgb('Boundary color', c) c = Crgb() c.assign(*pt['grid_cell_color']) p.setRgb('Cell color', c) p.setFloat('Cell width', pt['grid_cell_width']) p.setFloat('Cell height', pt['grid_cell_height']) if(pt['grid_horizontal_lines']): p.setFloat('Boundary thickness U', pt['grid_boundary_thickness_u']) else: p.setFloat('Boundary thickness U', 0.0) if(pt['grid_vertical_lines']): p.setFloat('Boundary thickness V', pt['grid_boundary_thickness_v']) else: p.setFloat('Boundary thickness V', 0.0) p.setFloat('Transition sharpness', pt['grid_transition_sharpness']) p.setUInt('Fall-off', pt['grid_falloff']) t.addProceduralTexture(p) elif(pt['use'] == 'MARBLE'): e = self.mgr.createDefaultTextureExtension('Marble') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setUInt('Coordinates type', pt['marble_coordinates_type']) c = Crgb() c.assign(*pt['marble_color0']) p.setRgb('Color0', c) c = Crgb() c.assign(*pt['marble_color1']) p.setRgb('Color1', c) c = Crgb() c.assign(*pt['marble_color2']) p.setRgb('Color2', c) p.setFloat('Frequency', pt['marble_frequency']) p.setFloat('Detail', pt['marble_detail']) p.setInt('Octaves', pt['marble_octaves']) p.setUInt('Seed', pt['marble_seed']) t.addProceduralTexture(p) elif(pt['use'] == 'NOISE'): e = self.mgr.createDefaultTextureExtension('Noise') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setUInt('Coordinates type', pt['noise_coordinates_type']) c = Crgb() c.assign(*pt['noise_noise_color']) p.setRgb('Noise color', c) c = Crgb() c.assign(*pt['noise_background_color']) p.setRgb('Background color', c) p.setFloat('Detail', pt['noise_detail']) p.setFloat('Persistance', pt['noise_persistance']) p.setInt('Octaves', pt['noise_octaves']) p.setFloat('Low value', pt['noise_low_value']) p.setFloat('High value', pt['noise_high_value']) p.setUInt('Seed', pt['noise_seed']) t.addProceduralTexture(p) elif(pt['use'] == 'VORONOI'): e = self.mgr.createDefaultTextureExtension('Voronoi') p = e.getExtensionData() p.setFloat('Blend procedural', pt['blending_factor']) p.setUInt('Coordinates type', pt['voronoi_coordinates_type']) c = Crgb() c.assign(*pt['voronoi_color0']) p.setRgb('Color0', c) c = Crgb() c.assign(*pt['voronoi_color1']) p.setRgb('Color1', c) p.setInt('Detail', pt['voronoi_detail']) p.setUInt('Distance', pt['voronoi_distance']) p.setUInt('Combination', pt['voronoi_combination']) p.setFloat('Low value', pt['voronoi_low_value']) p.setFloat('High value', pt['voronoi_high_value']) p.setUInt('Seed', pt['voronoi_seed']) t.addProceduralTexture(p) elif(pt['use'] == 'TILED'): e = self.mgr.createDefaultTextureExtension('TiledTexture') p = e.getExtensionData() p.setFloat('Blend factor', pt['blending_factor']) c = Crgb() c.assign(*pt['tiled_base_color']) p.setRgb('Base Color', c) p.setByte('Use base color', pt['tiled_use_base_color']) p.setString('Filename_mask', pt['tiled_token_mask']) p.setString('Filename', pt['tiled_filename']) # 'Map U tile range' UCHAR # 'Map V tile range' UCHAR t.addProceduralTexture(p) elif(pt['use'] == 'WIREFRAME'): e = self.mgr.createDefaultTextureExtension('WireframeTexture') p = e.getExtensionData() c = Crgb() c.assign(*pt['wireframe_fill_color']) p.setRgb('Fill Color', c) c = Crgb() c.assign(*pt['wireframe_edge_color']) p.setRgb('Edge Color', c) c = Crgb() c.assign(*pt['wireframe_coplanar_edge_color']) p.setRgb('Coplanar Edge Color', c) p.setFloat('Edge Width', pt['wireframe_edge_width']) p.setFloat('Coplanar Edge Width', pt['wireframe_coplanar_edge_width']) p.setFloat('Coplanar Threshold', pt['wireframe_coplanar_threshold']) t.addProceduralTexture(p) else: raise TypeError("{0} is unknown procedural texture type".format(pt['use'])) return t def material_placeholder(self, n=None, ): if(n is not None): pass else: n = 'MATERIAL_PLACEHOLDER' s = self.mxs m = s.createMaterial(n) l = m.addLayer() b = l.addBSDF() r = b.getReflectance() a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = CtextureMap() mgr = CextensionManager.instance() mgr.loadAllExtensions() e = mgr.createDefaultTextureExtension('Checker') ch = e.getExtensionData() ch.setUInt('Number of elements U', 32) ch.setUInt('Number of elements V', 32) t.addProceduralTexture(ch) a.textureMap = t r.setAttribute('color', a) return m def material_default(self, n, ): s = self.mxs m = s.createMaterial(n) l = m.addLayer() b = l.addBSDF() return m def material_external(self, d, ): s = self.mxs p = d['path'] t = s.readMaterial(p) t.setName(d['name']) m = s.addMaterial(t) if(not d['embed']): m.setReference(1, p) return m def material_custom(self, d, ): s = self.mxs m = s.createMaterial(d['name']) d = d['data'] def global_props(d, m): # global properties if(d['override_map']): t = self.texture(d['override_map']) if(t is not None): m.setGlobalMap(t) if(d['bump_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(d['bump_map']) if(t is not None): a.textureMap = t if(d['bump_map_use_normal']): a.value = d['bump_normal'] else: a.value = d['bump'] m.setAttribute('bump', a) m.setNormalMapState(d['bump_map_use_normal']) m.setDispersion(d['dispersion']) m.setMatteShadow(d['shadow']) m.setMatte(d['matte']) m.setNestedPriority(d['priority']) c = Crgb() c.assign(*d['id']) m.setColorID(c) if(d['active_display_map']): t = self.texture(d['active_display_map']) m.setActiveDisplayMap(t) def displacement(d, m): if(not d['enabled']): return m.enableDisplacement(True) if(d['map'] is not None): t = self.texture(d['map']) m.setDisplacementMap(t) m.setDisplacementCommonParameters(d['type'], d['subdivision'], int(d['smoothing']), d['offset'], d['subdivision_method'], d['uv_interpolation'], ) m.setHeightMapDisplacementParameters(d['height'], d['height_units'], d['adaptive'], ) v = Cvector(*d['v3d_scale']) m.setVectorDisplacementParameters(v, d['v3d_transform'], d['v3d_rgb_mapping'], d['v3d_preset'], ) def add_bsdf(d, l): b = l.addBSDF() b.setName(d['name']) bp = d['bsdf_props'] # weight if(bp['weight_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['weight_map']) if(t is not None): a.textureMap = t a.value = bp['weight'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = bp['weight'] b.setWeight(a) # enabled if(not bp['visible']): b.setState(False) # ior r = b.getReflectance() if(bp['ior'] == 1): # measured data r.setActiveIorMode(1) r.setComplexIor(bp['complex_ior']) else: if(bp['reflectance_0_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['reflectance_0_map']) if(t is not None): a.textureMap = t a.rgb.assign(*bp['reflectance_0']) else: a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*bp['reflectance_0']) r.setAttribute('color', a) if(bp['reflectance_90_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['reflectance_90_map']) if(t is not None): a.textureMap = t a.rgb.assign(*bp['reflectance_90']) else: a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*bp['reflectance_90']) r.setAttribute('color.tangential', a) if(bp['transmittance_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['transmittance_map']) if(t is not None): a.textureMap = t a.rgb.assign(*bp['transmittance']) else: a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*bp['transmittance']) r.setAttribute('transmittance.color', a) r.setAbsorptionDistance(bp['attenuation_units'], bp['attenuation']) r.setIOR(bp['nd'], bp['abbe']) if(bp['force_fresnel']): r.enableForceFresnel(True) r.setConductor(bp['k']) if(bp['r2_enabled']): r.setFresnelCustom(bp['r2_falloff_angle'], bp['r2_influence'], True, ) # surface if(bp['roughness_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['roughness_map']) if(t is not None): a.textureMap = t a.value = bp['roughness'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = bp['roughness'] b.setAttribute('roughness', a) if(bp['bump_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['bump_map']) if(t is not None): a.textureMap = t if(bp['bump_map_use_normal']): a.value = bp['bump_normal'] else: a.value = bp['bump'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE if(bp['bump_map_use_normal']): a.value = bp['bump_normal'] else: a.value = bp['bump'] b.setAttribute('bump', a) b.setNormalMapState(bp['bump_map_use_normal']) if(bp['anisotropy_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['anisotropy_map']) if(t is not None): a.textureMap = t a.value = bp['anisotropy'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = bp['anisotropy'] b.setAttribute('anisotropy', a) if(bp['anisotropy_angle_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['anisotropy_angle_map']) if(t is not None): a.textureMap = t a.value = bp['anisotropy_angle'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = bp['anisotropy_angle'] b.setAttribute('angle', a) # subsurface a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*bp['scattering']) r.setAttribute('scattering', a) r.setScatteringParameters(bp['coef'], bp['asymmetry'], bp['single_sided']) if(bp['single_sided']): if(bp['single_sided_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(bp['single_sided_map']) if(t is not None): a.textureMap = t a.value = bp['single_sided_value'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = bp['single_sided_value'] r.setScatteringThickness(a) r.setScatteringThicknessRange(bp['single_sided_min'], bp['single_sided_max']) # coating cp = d['coating'] if(cp['enabled']): c = b.addCoating() if(cp['thickness_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(cp['thickness_map']) if(t is not None): a.textureMap = t a.value = cp['thickness'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = cp['thickness'] c.setThickness(a) c.setThicknessRange(cp['thickness_map_min'], cp['thickness_map_max']) r = c.getReflectance() if(cp['ior'] == 1): # measured data r.setActiveIorMode(1) r.setComplexIor(cp['complex_ior']) else: if(cp['reflectance_0_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(cp['reflectance_0_map']) if(t is not None): a.textureMap = t a.rgb.assign(*cp['reflectance_0']) else: a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*cp['reflectance_0']) r.setAttribute('color', a) if(cp['reflectance_90_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(cp['reflectance_90_map']) if(t is not None): a.textureMap = t a.rgb.assign(*cp['reflectance_90']) else: a = Cattribute() a.activeType = MAP_TYPE_RGB a.rgb.assign(*cp['reflectance_90']) r.setAttribute('color.tangential', a) r.setIOR(cp['nd'], 1.0, ) if(cp['force_fresnel']): r.enableForceFresnel(True) r.setConductor(cp['k']) if(cp['r2_enabled']): r.setFresnelCustom(cp['r2_falloff_angle'], 0.0, True, ) def add_emitter(d, l): e = l.createEmitter() if(d['type'] == 0): e.setLobeType(EMISSION_LOBE_DEFAULT) elif(d['type'] == 1): e.setLobeType(EMISSION_LOBE_IES) e.setLobeIES(d['ies_data']) e.setIESLobeIntensity(d['ies_intensity']) elif(d['type'] == 2): e.setLobeType(EMISSION_LOBE_SPOTLIGHT) if(d['spot_map'] is not None): t = self.texture(d['spot_map']) if(t is not None): e.setLobeImageProjectedMap(d['spot_map_enabled'], t) e.setSpotConeAngle(d['spot_cone_angle']) e.setSpotFallOffAngle(d['spot_falloff_angle']) e.setSpotFallOffType(d['spot_falloff_type']) e.setSpotBlur(d['spot_blur']) if(d['emission'] == 0): e.setActiveEmissionType(EMISSION_TYPE_PAIR) ep = CemitterPair() c = Crgb() c.assign(*d['color']) ep.rgb.assign(c) ep.temperature = d['color_black_body'] ep.watts = d['luminance_power'] ep.luminousEfficacy = d['luminance_efficacy'] ep.luminousPower = d['luminance_output'] ep.illuminance = d['luminance_output'] ep.luminousIntensity = d['luminance_output'] ep.luminance = d['luminance_output'] e.setPair(ep) if(d['luminance'] == 0): u = EMISSION_UNITS_WATTS_AND_LUMINOUS_EFFICACY elif(d['luminance'] == 1): u = EMISSION_UNITS_LUMINOUS_POWER elif(d['luminance'] == 2): u = EMISSION_UNITS_ILLUMINANCE elif(d['luminance'] == 3): u = EMISSION_UNITS_LUMINOUS_INTENSITY elif(d['luminance'] == 4): u = EMISSION_UNITS_LUMINANCE if(d['color_black_body_enabled']): e.setActivePair(EMISSION_COLOR_TEMPERATURE, u) else: e.setActivePair(EMISSION_RGB, u) elif(d['emission'] == 1): e.setActiveEmissionType(EMISSION_TYPE_TEMPERATURE) e.setTemperature(d['temperature_value']) elif(d['emission'] == 2): e.setActiveEmissionType(EMISSION_TYPE_MXI) a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(d['hdr_map']) if(t is not None): a.textureMap = t a.value = d['hdr_intensity'] e.setMXI(a) e.setState(True) def add_layer(d, m): l = m.addLayer() l.setName(d['name']) lpd = d['layer_props'] if(not lpd['visible']): l.setEnabled(False) if(lpd['blending'] == 1): l.setStackedBlendingMode(1) if(lpd['opacity_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(lpd['opacity_map']) if(t is not None): a.textureMap = t a.value = lpd['opacity'] else: a = Cattribute() a.activeType = MAP_TYPE_VALUE a.value = lpd['opacity'] l.setAttribute('weight', a) epd = d['emitter'] if(epd['enabled']): add_emitter(epd, l) for b in d['bsdfs']: add_bsdf(b, l) global_props(d['global_props'], m) displacement(d['displacement'], m) for layer in d['layers']: add_layer(layer, m) return m def material(self, d, ): s = self.mxs if(d['subtype'] == 'EXTERNAL'): if(d['path'] == ''): m = self.material_placeholder(d['name']) else: m = self.material_external(d) if(d['override']): # global properties if(d['override_map']): t = self.texture(d['override_map']) if(t is not None): m.setGlobalMap(t) if(d['bump_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(d['bump_map']) if(t is not None): a.textureMap = t if(d['bump_map_use_normal']): a.value = d['bump_normal'] else: a.value = d['bump'] m.setAttribute('bump', a) m.setNormalMapState(d['bump_map_use_normal']) m.setDispersion(d['dispersion']) m.setMatteShadow(d['shadow']) m.setMatte(d['matte']) m.setNestedPriority(d['priority']) c = Crgb() c.assign(*d['id']) m.setColorID(c) elif(d['subtype'] == 'EXTENSION'): if(d['use'] == 'EMITTER'): m = s.createMaterial(d['name']) l = m.addLayer() e = l.createEmitter() if(d['emitter_type'] == 0): e.setLobeType(EMISSION_LOBE_DEFAULT) elif(d['emitter_type'] == 1): e.setLobeType(EMISSION_LOBE_IES) e.setLobeIES(d['emitter_ies_data']) e.setIESLobeIntensity(d['emitter_ies_intensity']) elif(d['emitter_type'] == 2): e.setLobeType(EMISSION_LOBE_SPOTLIGHT) if(d['emitter_spot_map'] is not None): t = self.texture(d['emitter_spot_map']) if(t is not None): e.setLobeImageProjectedMap(d['emitter_spot_map_enabled'], t) e.setSpotConeAngle(d['emitter_spot_cone_angle']) e.setSpotFallOffAngle(d['emitter_spot_falloff_angle']) e.setSpotFallOffType(d['emitter_spot_falloff_type']) e.setSpotBlur(d['emitter_spot_blur']) if(d['emitter_emission'] == 0): e.setActiveEmissionType(EMISSION_TYPE_PAIR) ep = CemitterPair() c = Crgb() c.assign(*d['emitter_color']) ep.rgb.assign(c) ep.temperature = d['emitter_color_black_body'] ep.watts = d['emitter_luminance_power'] ep.luminousEfficacy = d['emitter_luminance_efficacy'] ep.luminousPower = d['emitter_luminance_output'] ep.illuminance = d['emitter_luminance_output'] ep.luminousIntensity = d['emitter_luminance_output'] ep.luminance = d['emitter_luminance_output'] e.setPair(ep) if(d['emitter_color_black_body_enabled']): if(d['emitter_luminance'] == 0): u = EMISSION_UNITS_WATTS_AND_LUMINOUS_EFFICACY elif(d['emitter_luminance'] == 1): u = EMISSION_UNITS_LUMINOUS_POWER elif(d['emitter_luminance'] == 2): u = EMISSION_UNITS_ILLUMINANCE elif(d['emitter_luminance'] == 3): u = EMISSION_UNITS_LUMINOUS_INTENSITY elif(d['emitter_luminance'] == 4): u = EMISSION_UNITS_LUMINANCE e.setActivePair(EMISSION_COLOR_TEMPERATURE, u) else: if(d['emitter_luminance'] == 0): u = EMISSION_UNITS_WATTS_AND_LUMINOUS_EFFICACY elif(d['emitter_luminance'] == 1): u = EMISSION_UNITS_LUMINOUS_POWER elif(d['emitter_luminance'] == 2): u = EMISSION_UNITS_ILLUMINANCE elif(d['emitter_luminance'] == 3): u = EMISSION_UNITS_LUMINOUS_INTENSITY elif(d['emitter_luminance'] == 4): u = EMISSION_UNITS_LUMINANCE e.setActivePair(EMISSION_RGB, u) elif(d['emitter_emission'] == 1): e.setActiveEmissionType(EMISSION_TYPE_TEMPERATURE) e.setTemperature(d['emitter_temperature_value']) elif(d['emitter_emission'] == 2): e.setActiveEmissionType(EMISSION_TYPE_MXI) a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(d['emitter_hdr_map']) if(t is not None): a.textureMap = t a.value = d['emitter_hdr_intensity'] e.setMXI(a) e.setState(True) def global_props(d, m): # global properties if(d['override_map']): t = texture(d['override_map'], s, ) if(t is not None): m.setGlobalMap(t) if(d['bump_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = texture(d['bump_map'], s, ) if(t is not None): a.textureMap = t if(d['bump_map_use_normal']): a.value = d['bump_normal'] else: a.value = d['bump'] m.setAttribute('bump', a) m.setNormalMapState(d['bump_map_use_normal']) m.setDispersion(d['dispersion']) m.setMatteShadow(d['shadow']) m.setMatte(d['matte']) m.setNestedPriority(d['priority']) c = Crgb() c.assign(*d['id']) m.setColorID(c) if(d['active_display_map']): t = texture(d['active_display_map'], s, ) m.setActiveDisplayMap(t) global_props(d, m) else: m = CextensionManager.instance() m.loadAllExtensions() if(d['use'] == 'AGS'): e = m.createDefaultMaterialModifierExtension('AGS') p = e.getExtensionData() c = Crgb() c.assign(*d['ags_color']) p.setRgb('Color', c) p.setFloat('Reflection', d['ags_reflection']) p.setUInt('Type', d['ags_type']) elif(d['use'] == 'OPAQUE'): e = m.createDefaultMaterialModifierExtension('Opaque') p = e.getExtensionData() p.setByte('Color Type', d['opaque_color_type']) c = Crgb() c.assign(*d['opaque_color']) p.setRgb('Color', c) self.texture_data_to_mxparams('Color Map', d['opaque_color_map'], p, ) p.setByte('Shininess Type', d['opaque_shininess_type']) p.setFloat('Shininess', d['opaque_shininess']) self.texture_data_to_mxparams('Shininess Map', d['opaque_shininess_map'], p, ) p.setByte('Roughness Type', d['opaque_roughness_type']) p.setFloat('Roughness', d['opaque_roughness']) self.texture_data_to_mxparams('Roughness Map', d['opaque_roughness_map'], p, ) p.setByte('Clearcoat', d['opaque_clearcoat']) elif(d['use'] == 'TRANSPARENT'): e = m.createDefaultMaterialModifierExtension('Transparent') p = e.getExtensionData() p.setByte('Color Type', d['transparent_color_type']) c = Crgb() c.assign(*d['transparent_color']) p.setRgb('Color', c) self.texture_data_to_mxparams('Color Map', d['transparent_color_map'], p, ) p.setFloat('Ior', d['transparent_ior']) p.setFloat('Transparency', d['transparent_transparency']) p.setByte('Roughness Type', d['transparent_roughness_type']) p.setFloat('Roughness', d['transparent_roughness']) self.texture_data_to_mxparams('Roughness Map', d['transparent_roughness_map'], p, ) p.setFloat('Specular Tint', d['transparent_specular_tint']) p.setFloat('Dispersion', d['transparent_dispersion']) p.setByte('Clearcoat', d['transparent_clearcoat']) elif(d['use'] == 'METAL'): e = m.createDefaultMaterialModifierExtension('Metal') p = e.getExtensionData() p.setUInt('IOR', d['metal_ior']) p.setFloat('Tint', d['metal_tint']) p.setByte('Color Type', d['metal_color_type']) c = Crgb() c.assign(*d['metal_color']) p.setRgb('Color', c) self.texture_data_to_mxparams('Color Map', d['metal_color_map'], p, ) p.setByte('Roughness Type', d['metal_roughness_type']) p.setFloat('Roughness', d['metal_roughness']) self.texture_data_to_mxparams('Roughness Map', d['metal_roughness_map'], p, ) p.setByte('Anisotropy Type', d['metal_anisotropy_type']) p.setFloat('Anisotropy', d['metal_anisotropy']) self.texture_data_to_mxparams('Anisotropy Map', d['metal_anisotropy_map'], p, ) p.setByte('Angle Type', d['metal_angle_type']) p.setFloat('Angle', d['metal_angle']) self.texture_data_to_mxparams('Angle Map', d['metal_angle_map'], p, ) p.setByte('Dust Type', d['metal_dust_type']) p.setFloat('Dust', d['metal_dust']) self.texture_data_to_mxparams('Dust Map', d['metal_dust_map'], p, ) p.setByte('Perforation Enabled', d['metal_perforation_enabled']) self.texture_data_to_mxparams('Perforation Map', d['metal_perforation_map'], p, ) elif(d['use'] == 'TRANSLUCENT'): e = m.createDefaultMaterialModifierExtension('Translucent') p = e.getExtensionData() p.setFloat('Scale', d['translucent_scale']) p.setFloat('Ior', d['translucent_ior']) p.setByte('Color Type', d['translucent_color_type']) c = Crgb() c.assign(*d['translucent_color']) p.setRgb('Color', c) self.texture_data_to_mxparams('Color Map', d['translucent_color_map'], p, ) p.setFloat('Hue Shift', d['translucent_hue_shift']) p.setByte('Invert Hue', d['translucent_invert_hue']) p.setFloat('Vibrance', d['translucent_vibrance']) p.setFloat('Density', d['translucent_density']) p.setFloat('Opacity', d['translucent_opacity']) p.setByte('Roughness Type', d['translucent_roughness_type']) p.setFloat('Roughness', d['translucent_roughness']) self.texture_data_to_mxparams('Roughness Map', d['translucent_roughness_map'], p, ) p.setFloat('Specular Tint', d['translucent_specular_tint']) p.setByte('Clearcoat', d['translucent_clearcoat']) p.setFloat('Clearcoat Ior', d['translucent_clearcoat_ior']) elif(d['use'] == 'CARPAINT'): e = m.createDefaultMaterialModifierExtension('Car Paint') p = e.getExtensionData() c = Crgb() c.assign(*d['carpaint_color']) p.setRgb('Color', c) p.setFloat('Metallic', d['carpaint_metallic']) p.setFloat('Topcoat', d['carpaint_topcoat']) elif(d['use'] == 'HAIR'): e = m.createDefaultMaterialModifierExtension('Hair') p = e.getExtensionData() p.setByte('Color Type', d['hair_color_type']) c = Crgb() c.assign(*d['hair_color']) p.setRgb('Color', c) self.texture_data_to_mxparams('Color Map', d['hair_color_map'], p, ) self.texture_data_to_mxparams('Root-Tip Map', d['hair_root_tip_map'], p, ) p.setByte('Root-Tip Weight Type', d['hair_root_tip_weight_type']) p.setFloat('Root-Tip Weight', d['hair_root_tip_weight']) self.texture_data_to_mxparams('Root-Tip Weight Map', d['hair_root_tip_weight_map'], p, ) p.setFloat('Primary Highlight Strength', d['hair_primary_highlight_strength']) p.setFloat('Primary Highlight Spread', d['hair_primary_highlight_spread']) c = Crgb() c.assign(*d['hair_primary_highlight_tint']) p.setRgb('Primary Highlight Tint', c) p.setFloat('Secondary Highlight Strength', d['hair_secondary_highlight_strength']) p.setFloat('Secondary Highlight Spread', d['hair_secondary_highlight_spread']) c = Crgb() c.assign(*d['hair_secondary_highlight_tint']) p.setRgb('Secondary Highlight Tint', c) m = s.createMaterial(d['name']) m.applyMaterialModifierExtension(p) # global properties if(d['override_map']): t = self.texture(d['override_map']) if(t is not None): m.setGlobalMap(t) if(d['bump_map_enabled']): a = Cattribute() a.activeType = MAP_TYPE_BITMAP t = self.texture(d['bump_map']) if(t is not None): a.textureMap = t if(d['bump_map_use_normal']): a.value = d['bump_normal'] else: a.value = d['bump'] m.setAttribute('bump', a) m.setNormalMapState(d['bump_map_use_normal']) m.setDispersion(d['dispersion']) m.setMatteShadow(d['shadow']) m.setMatte(d['matte']) m.setNestedPriority(d['priority']) c = Crgb() c.assign(*d['id']) m.setColorID(c) if(d['active_display_map']): t = texture(d['active_display_map'], s, ) m.setActiveDisplayMap(t) def displacement(d, m): if(not d['enabled']): return m.enableDisplacement(True) if(d['map'] is not None): t = self.texture(d['map']) m.setDisplacementMap(t) m.setDisplacementCommonParameters(d['type'], d['subdivision'], int(d['smoothing']), d['offset'], d['subdivision_method'], d['uv_interpolation'], ) m.setHeightMapDisplacementParameters(d['height'], d['height_units'], d['adaptive'], ) v = Cvector(*d['v3d_scale']) m.setVectorDisplacementParameters(v, d['v3d_transform'], d['v3d_rgb_mapping'], d['v3d_preset'], ) try: displacement(d['displacement'], m) except KeyError: pass elif(d['subtype'] == 'CUSTOM'): m = self.material_custom(d) else: raise TypeError("Material '{}' {} is unknown type".format(d['name'], d['subtype'])) return m def get_material(self, n, ): """get material by name from scene, if material is missing, create and return placeholder""" def get_material_names(s): it = CmaxwellMaterialIterator() o = it.first(s) l = [] while not o.isNull(): name = o.getName() l.append(name) o = it.next() return l s = self.mxs names = get_material_names(s) m = None if(n in names): m = s.getMaterial(n) if(m is None): # should not happen because i stopped changing material names.. but i leave it here m = self.material_placeholder() return m class MXMEmitterCheck(): def __init__(self, path, ): if(__name__ != "__main__"): if(platform.system() == 'Darwin'): raise ImportError("No pymaxwell for Mac OS X..") log(self.__class__.__name__, 1, LogStyles.MESSAGE, prefix="* ", ) self.path = path self.mxs = Cmaxwell(mwcallback) self.emitter = False m = self.mxs.readMaterial(self.path) for i in range(m.getNumLayers()[0]): l = m.getLayer(i) e = l.getEmitter() if(e.isNull()): # no emitter layer self.emitter = False return if(not e.getState()[0]): # there is, but is disabled self.emitter = False return # is emitter self.emitter = True class MXSReader(): def __init__(self, path, ): if(__name__ != "__main__"): if(platform.system() == 'Darwin'): raise ImportError("No pymaxwell for Mac OS X..") log(self.__class__.__name__, 1, LogStyles.MESSAGE, prefix="* ", ) self.path = path self.mxs = Cmaxwell(mwcallback) log("loading {}".format(self.path), 2, prefix="* ", ) self.mxs.readMXS(self.path) if(self.mxs.isProtectionEnabled()): raise RuntimeError("Protected MXS") self._prepare() def _mxs_get_objects_names(self): s = self.mxs it = CmaxwellObjectIterator() o = it.first(s) l = [] while not o.isNull(): name, _ = o.getName() l.append(name) o = it.next() return l def _mxs_object(self, o): object_name, _ = o.getName() is_instance, _ = o.isInstance() is_mesh, _ = o.isMesh() if(is_instance == 0 and is_mesh == 0): log("{}: only empties, meshes and instances are supported..".format(object_name), 2, LogStyles.WARNING, ) return None # skip not posrotscale initialized objects is_init, _ = o.isPosRotScaleInitialized() if(not is_init): # log("{}: object is not initialized, skipping..".format(object_name), 2, LogStyles.WARNING, ) log("{}: object is not initialized..".format(object_name), 2, LogStyles.WARNING, ) # return None r = {'name': o.getName()[0], 'vertices': [], 'normals': [], 'triangles': [], 'trianglesUVW': [], 'matrix': (), 'parent': None, 'type': '', 'materials': [], 'nmats': 0, 'matnames': [], } if(is_instance == 1): io = o.getInstanced() ion = io.getName()[0] b, p = self._base_and_pivot(o) r = {'name': o.getName()[0], 'base': b, 'pivot': p, 'parent': None, 'type': 'INSTANCE', 'instanced': ion, } # no multi material instances, always one material per instance m, _ = o.getMaterial() if(m.isNull() == 1): r['material'] = None else: r['material'] = o.getName() p, _ = o.getParent() if(not p.isNull()): r['parent'] = p.getName()[0] cid, _ = o.getColorID() rgb8 = cid.toRGB8() col = [str(rgb8.r()), str(rgb8.g()), str(rgb8.b())] r['colorid'] = ", ".join(col) h = [] if(o.getHideToCamera()): h.append("C") if(o.getHideToGI()): h.append("GI") if(o.getHideToReflectionsRefractions()): h.append("RR") r['hidden'] = ", ".join(h) r['referenced_mxs'] = False r['referenced_mxs_path'] = None rmp = io.getReferencedScenePath() if(rmp != ""): r['referenced_mxs'] = True r['referenced_mxs_path'] = rmp return r # counts nv, _ = o.getVerticesCount() nn, _ = o.getNormalsCount() nt, _ = o.getTrianglesCount() nppv, _ = o.getPositionsPerVertexCount() ppv = 0 r['referenced_mxs'] = False r['referenced_mxs_path'] = None if(nv > 0): r['type'] = 'MESH' cid, _ = o.getColorID() rgb8 = cid.toRGB8() col = [str(rgb8.r()), str(rgb8.g()), str(rgb8.b())] r['colorid'] = ", ".join(col) h = [] if(o.getHideToCamera()): h.append("C") if(o.getHideToGI()): h.append("GI") if(o.getHideToReflectionsRefractions()): h.append("RR") r['hidden'] = ", ".join(h) else: r['type'] = 'EMPTY' rmp = o.getReferencedScenePath() if(rmp != ""): r['referenced_mxs'] = True r['referenced_mxs_path'] = rmp cid, _ = o.getColorID() rgb8 = cid.toRGB8() col = [str(rgb8.r()), str(rgb8.g()), str(rgb8.b())] r['colorid'] = ", ".join(col) if(nppv - 1 != ppv and nv != 0): log("only one position per vertex is supported..", 2, LogStyles.WARNING, ) # vertices for i in range(nv): v, _ = o.getVertex(i, ppv) # (float x, float y, float z) r['vertices'].append((v.x(), v.y(), v.z())) # normals for i in range(nn): v, _ = o.getNormal(i, ppv) # (float x, float y, float z) r['normals'].append((v.x(), v.y(), v.z())) # triangles for i in range(nt): t = o.getTriangle(i) # (int v1, int v2, int v3, int n1, int n2, int n3) r['triangles'].append(t) # materials mats = [] for i in range(nt): m, _ = o.getTriangleMaterial(i) if(m.isNull() == 1): n = None else: n = m.getName() if(n not in mats): mats.append(n) r['materials'].append((i, n)) r['nmats'] = len(mats) r['matnames'] = mats # uv channels ncuv, _ = o.getChannelsUVWCount() for cuv in range(ncuv): # uv triangles r['trianglesUVW'].append([]) for i in range(nt): t = o.getTriangleUVW(i, cuv) # float u1, float v1, float w1, float u2, float v2, float w2, float u3, float v3, float w3 r['trianglesUVW'][cuv].append(t) # base and pivot to matrix b, p = self._base_and_pivot(o) r['base'] = b r['pivot'] = p # parent p, _ = o.getParent() if(not p.isNull()): r['parent'] = p.getName()[0] return r def _mxs_camera(self, c): v = c.getValues() v = {'name': v[0], 'nSteps': v[1], 'shutter': v[2], 'filmWidth': v[3], 'filmHeight': v[4], 'iso': v[5], 'pDiaphragmType': v[6], 'angle': v[7], 'nBlades': v[8], 'fps': v[9], 'xRes': v[10], 'yRes': v[11], 'pixelAspect': v[12], 'lensType': v[13], } s = c.getStep(0) o = s[0] f = s[1] u = s[2] # skip weird cameras flc = s[3] co = s[0] fp = s[1] d = Cvector() d.substract(fp, co) fd = d.norm() if(flc == 0.0 or fd == 0.0): log("{}: impossible camera, skipping..".format(v['name']), 2, LogStyles.WARNING) return None r = {'name': v['name'], 'shutter': 1.0 / v['shutter'], 'iso': v['iso'], 'x_res': v['xRes'], 'y_res': v['yRes'], 'pixel_aspect': v['pixelAspect'], 'origin': (o.x(), o.y(), o.z()), 'focal_point': (f.x(), f.y(), f.z()), 'up': (u.x(), u.y(), u.z()), 'focal_length': self._uncorrect_focal_length(s) * 1000.0, 'f_stop': s[4], 'film_width': round(v['filmWidth'] * 1000.0, 3), 'film_height': round(v['filmHeight'] * 1000.0, 3), 'active': False, 'sensor_fit': None, 'shift_x': 0.0, 'shift_y': 0.0, 'zclip': False, 'zclip_near': 0.0, 'zclip_far': 1000000.0, 'type': 'CAMERA', } if(r['film_width'] > r['film_height']): r['sensor_fit'] = 'HORIZONTAL' else: r['sensor_fit'] = 'VERTICAL' cp = c.getCutPlanes() if(cp[2] is True): r['zclip'] = True r['zclip_near'] = cp[0] r['zclip_far'] = cp[1] sl = c.getShiftLens() r['shift_x'] = sl[0] r['shift_y'] = sl[1] d = c.getDiaphragm() r['diaphragm_type'] = d[0][0] r['diaphragm_angle'] = d[1] r['diaphragm_blades'] = d[2] return r def _base_and_pivot(self, o): b, p, _ = o.getBaseAndPivot() o = b.origin x = b.xAxis y = b.yAxis z = b.zAxis rb = [[o.x(), o.y(), o.z()], [x.x(), x.y(), x.z()], [y.x(), y.y(), y.z()], [z.x(), z.y(), z.z()]] rp = ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0), ) return rb, rp def _uncorrect_focal_length(self, step): flc = step[3] o = step[0] fp = step[1] d = Cvector() d.substract(fp, o) fd = d.norm() fluc = 1.0 / (1.0 / flc - 1 / fd) return fluc def _prepare(self): s = self.mxs self.object_names = self._mxs_get_objects_names() def _is_emitter(self, o): is_instance, _ = o.isInstance() is_mesh, _ = o.isMesh() if(not is_mesh and not is_instance): return False if(is_mesh): nt, _ = o.getTrianglesCount() mats = [] for i in range(nt): m, _ = o.getTriangleMaterial(i) if(not m.isNull()): if(m not in mats): mats.append(m) for m in mats: nl, _ = m.getNumLayers() for i in range(nl): l = m.getLayer(i) e = l.getEmitter() if(not e.isNull()): return True if(is_instance): m, _ = o.getMaterial() if(not m.isNull()): nl, _ = m.getNumLayers() for i in range(nl): l = m.getLayer(i) e = l.getEmitter() if(not e.isNull()): return True return False def _global_transform(self, o): cb, _ = o.getWorldTransform() o = cb.origin x = cb.xAxis y = cb.yAxis z = cb.zAxis rb = [[o.x(), o.y(), o.z()], [x.x(), x.y(), x.z()], [y.x(), y.y(), y.z()], [z.x(), z.y(), z.z()]] rp = ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0), ) return rb, rp def objects(self, only_emitters=False): if(only_emitters): s = self.mxs data = [] log("converting emitters..", 2) for n in self.object_names: d = None o = s.getObject(n) if(self._is_emitter(o)): d = self._mxs_object(o) if(d is not None): b, p = self._global_transform(o) d['base'] = b d['pivot'] = p d['parent'] = None data.append(d) else: s = self.mxs data = [] log("converting empties, meshes and instances..", 2) for n in self.object_names: d = None o = s.getObject(n) d = self._mxs_object(o) if(d is not None): data.append(d) return data def cameras(self): s = self.mxs data = [] log("converting cameras..", 2) nms = s.getCameraNames() cams = [] if(type(nms) == list): for n in nms: cams.append(s.getCamera(n)) for c in cams: d = self._mxs_camera(c) if(d is not None): data.append(d) # set active camera if(len(cams) > 1): # if there is just one camera, this behaves badly. # use it just when there are two or more cameras.. active_cam = s.getActiveCamera() active_cam_name = active_cam.getName() for o in data: if(o['type'] == 'CAMERA'): if(o['name'] == active_cam_name): o['active'] = True else: for o in data: if(o['type'] == 'CAMERA'): o['active'] = True return data def sun(self): s = self.mxs data = [] env = s.getEnvironment() if(env.getSunProperties()[0] == 1): log("converting sun..", 2) if(env.getSunPositionType() == 2): v, _ = env.getSunDirection() else: v, _ = env.getSunDirectionUsedForRendering() d = {'name': "The Sun", 'xyz': (v.x(), v.y(), v.z()), 'type': 'SUN', } data.append(d) return data class MXSSceneWrapper(): def __init__(self, load_extensions=True, ): if(__name__ != "__main__"): if(platform.system() == 'Darwin'): raise ImportError("No pymaxwell directly in Blender on Mac OS X..") log(self.__class__.__name__, 1, LogStyles.MESSAGE, prefix="* ", ) log("creating new scene..", 2, prefix="* ", ) self.mxs = Cmaxwell(mwcallback) pid = utils.get_plugin_id() if(pid != ""): # write here directly, even though it is also part of scene data, but api change just for this is pointless.. self.mxs.setPluginID(pid) self.mgr = None if(load_extensions): log("loadinf extensions..", 2, prefix="* ", ) self.mgr = CextensionManager.instance() self.mgr.loadAllExtensions() class MXMReader(): def __init__(self, mxm_path, ): def texture(t): if(t is None): return None if(t.isEmpty()): return None d = {'path': t.getPath(), 'use_global_map': t.useGlobalMap, 'channel': t.uvwChannelID, 'brightness': t.brightness * 100, 'contrast': t.contrast * 100, 'saturation': t.saturation * 100, 'hue': t.hue * 180, 'rotation': t.rotation, 'invert': t.invert, 'interpolation': t.typeInterpolation, 'use_alpha': t.useAlpha, 'repeat': [t.scale.x(), t.scale.y()], 'mirror': [t.uIsMirrored, t.vIsMirrored], 'offset': [t.offset.x(), t.offset.y()], 'clamp': [int(t.clampMin * 255), int(t.clampMax * 255)], 'tiling_units': t.useAbsoluteUnits, 'tiling_method': [t.uIsTiled, t.vIsTiled], 'normal_mapping_flip_red': t.normalMappingFlipRed, 'normal_mapping_flip_green': t.normalMappingFlipGreen, 'normal_mapping_full_range_blue': t.normalMappingFullRangeBlue, } # t.cosA # t.doGammaCorrection # t.sinA # t.theTextureExtensions d['procedural'] = [] if(t.hasProceduralTextures()): n = t.getProceduralTexturesCount() for i in range(n): pd = extension(None, None, t, i) d['procedural'].append(pd) return d def material(s, m): data = {} if(m.isNull()): return data # defaults bsdfd = {'visible': True, 'weight': 100.0, 'weight_map_enabled': False, 'weight_map': None, 'ior': 0, 'complex_ior': "", 'reflectance_0': (0.6, 0.6, 0.6, ), 'reflectance_0_map_enabled': False, 'reflectance_0_map': None, 'reflectance_90': (1.0, 1.0, 1.0, ), 'reflectance_90_map_enabled': False, 'reflectance_90_map': None, 'transmittance': (0.0, 0.0, 0.0), 'transmittance_map_enabled': False, 'transmittance_map': None, 'attenuation': 1.0, 'attenuation_units': 0, 'nd': 3.0, 'force_fresnel': False, 'k': 0.0, 'abbe': 1.0, 'r2_enabled': False, 'r2_falloff_angle': 75.0, 'r2_influence': 0.0, 'roughness': 100.0, 'roughness_map_enabled': False, 'roughness_map': None, 'bump': 30.0, 'bump_map_enabled': False, 'bump_map': None, 'bump_map_use_normal': False, 'bump_normal': 100.0, 'anisotropy': 0.0, 'anisotropy_map_enabled': False, 'anisotropy_map': None, 'anisotropy_angle': 0.0, 'anisotropy_angle_map_enabled': False, 'anisotropy_angle_map': None, 'scattering': (0.5, 0.5, 0.5, ), 'coef': 0.0, 'asymmetry': 0.0, 'single_sided': False, 'single_sided_value': 1.0, 'single_sided_map_enabled': False, 'single_sided_map': None, 'single_sided_min': 0.001, 'single_sided_max': 10.0, } coatingd = {'enabled': False, 'thickness': 500.0, 'thickness_map_enabled': False, 'thickness_map': None, 'thickness_map_min': 100.0, 'thickness_map_max': 1000.0, 'ior': 0, 'complex_ior': "", 'reflectance_0': (0.6, 0.6, 0.6, ), 'reflectance_0_map_enabled': False, 'reflectance_0_map': None, 'reflectance_90': (1.0, 1.0, 1.0, ), 'reflectance_90_map_enabled': False, 'reflectance_90_map': None, 'nd': 3.0, 'force_fresnel': False, 'k': 0.0, 'r2_enabled': False, 'r2_falloff_angle': 75.0, } displacementd = {'enabled': False, 'map': None, 'type': 1, 'subdivision': 5, 'adaptive': False, 'subdivision_method': 0, 'offset': 0.5, 'smoothing': True, 'uv_interpolation': 2, 'height': 2.0, 'height_units': 0, 'v3d_preset': 0, 'v3d_transform': 0, 'v3d_rgb_mapping': 0, 'v3d_scale': (1.0, 1.0, 1.0), } emitterd = {'enabled': False, 'type': 0, 'ies_data': "", 'ies_intensity': 1.0, 'spot_map_enabled': False, 'spot_map': "", 'spot_cone_angle': 45.0, 'spot_falloff_angle': 10.0, 'spot_falloff_type': 0, 'spot_blur': 1.0, 'emission': 0, 'color': (1.0, 1.0, 1.0, ), 'color_black_body_enabled': False, 'color_black_body': 6500.0, 'luminance': 0, 'luminance_power': 40.0, 'luminance_efficacy': 17.6, 'luminance_output': 100.0, 'temperature_value': 6500.0, 'hdr_map': None, 'hdr_intensity': 1.0, } layerd = {'visible': True, 'opacity': 100.0, 'opacity_map_enabled': False, 'opacity_map': None, 'blending': 0, } globald = {'override_map': None, 'bump': 30.0, 'bump_map_enabled': False, 'bump_map': None, 'bump_map_use_normal': False, 'bump_normal': 100.0, 'dispersion': False, 'shadow': False, 'matte': False, 'priority': 0, 'id': (0.0, 0.0, 0.0), 'active_display_map': None, } # structure structure = [] nl, _ = m.getNumLayers() for i in range(nl): l = m.getLayer(i) ln, _ = l.getName() nb, _ = l.getNumBSDFs() bs = [] for j in range(nb): b = l.getBSDF(j) bn = b.getName() bs.append([bn, b]) ls = [ln, l, bs] structure.append(ls) # default data data['global_props'] = globald.copy() data['displacement'] = displacementd.copy() data['layers'] = [] for i, sl in enumerate(structure): bsdfs = [] for j, sb in enumerate(sl[2]): bsdfs.append({'name': sb[0], 'bsdf_props': bsdfd.copy(), 'coating': coatingd.copy(), }) layer = {'name': sl[0], 'layer_props': layerd.copy(), 'bsdfs': bsdfs, 'emitter': emitterd.copy(), } data['layers'].append(layer) # custom data def global_props(m, d): t, _ = m.getGlobalMap() d['override_map'] = texture(t) a, _ = m.getAttribute('bump') if(a.activeType == MAP_TYPE_BITMAP): d['bump_map_enabled'] = True d['bump_map'] = texture(a.textureMap) d['bump_map_use_normal'] = m.getNormalMapState()[0] if(d['bump_map_use_normal']): d['bump_normal'] = a.value else: d['bump'] = a.value else: d['bump_map_enabled'] = False d['bump_map'] = None d['bump_map_use_normal'] = m.getNormalMapState()[0] if(d['bump_map_use_normal']): d['bump_normal'] = a.value else: d['bump'] = a.value d['dispersion'] = m.getDispersion()[0] d['shadow'] = m.getMatteShadow()[0] d['matte'] = m.getMatte()[0] d['priority'] = m.getNestedPriority()[0] c, _ = m.getColorID() d['id'] = [c.r(), c.g(), c.b()] return d data['global_props'] = global_props(m, data['global_props']) def displacement(m, d): if(not m.isDisplacementEnabled()[0]): return d d['enabled'] = True t, _ = m.getDisplacementMap() d['map'] = texture(t) displacementType, subdivisionLevel, smoothness, offset, subdivisionType, interpolationUvType, minLOD, maxLOD, _ = m.getDisplacementCommonParameters() height, absoluteHeight, adaptive, _ = m.getHeightMapDisplacementParameters() scale, transformType, mapping, preset, _ = m.getVectorDisplacementParameters() d['type'] = displacementType d['subdivision'] = subdivisionLevel d['adaptive'] = adaptive d['subdivision_method'] = subdivisionType d['offset'] = offset d['smoothing'] = bool(smoothness) d['uv_interpolation'] = interpolationUvType d['height'] = height d['height_units'] = absoluteHeight d['v3d_preset'] = preset d['v3d_transform'] = transformType d['v3d_rgb_mapping'] = mapping d['v3d_scale'] = (scale.x(), scale.y(), scale.z(), ) return d data['displacement'] = displacement(m, data['displacement']) def cattribute_rgb(a): if(a.activeType == MAP_TYPE_BITMAP): c = (a.rgb.r(), a.rgb.g(), a.rgb.b()) e = True m = texture(a.textureMap) else: c = (a.rgb.r(), a.rgb.g(), a.rgb.b()) e = False m = None return c, e, m def cattribute_value(a): if(a.activeType == MAP_TYPE_BITMAP): v = a.value e = True m = texture(a.textureMap) else: v = a.value e = False m = None return v, e, m def layer_props(l, d): d['visible'] = l.getEnabled()[0] d['blending'] = l.getStackedBlendingMode()[0] a, _ = l.getAttribute('weight') if(a.activeType == MAP_TYPE_BITMAP): d['opacity'] = a.value d['opacity_map_enabled'] = True d['opacity_map'] = texture(a.textureMap) else: d['opacity'] = a.value d['opacity_map_enabled'] = False d['opacity_map'] = None return d def emitter(l, d): e = l.getEmitter() if(e.isNull()): d['enabled'] = False return d d['enabled'] = True d['type'] = e.getLobeType()[0] d['ies_data'] = e.getLobeIES() d['ies_intensity'] = e.getIESLobeIntensity()[0] t, _ = e.getLobeImageProjectedMap() d['spot_map_enabled'] = (not t.isEmpty()) d['spot_map'] = texture(t) d['spot_cone_angle'] = e.getSpotConeAngle()[0] d['spot_falloff_angle'] = e.getSpotFallOffAngle()[0] d['spot_falloff_type'] = e.getSpotFallOffType()[0] d['spot_blur'] = e.getSpotBlur()[0] d['emission'] = e.getActiveEmissionType()[0] ep, _ = e.getPair() colorType, units, _ = e.getActivePair() d['color'] = (ep.rgb.r(), ep.rgb.g(), ep.rgb.b(), ) d['color_black_body'] = ep.temperature d['luminance'] = units if(units == EMISSION_UNITS_WATTS_AND_LUMINOUS_EFFICACY): d['luminance_power'] = ep.watts d['luminance_efficacy'] = ep.luminousEfficacy elif(units == EMISSION_UNITS_LUMINOUS_POWER): d['luminance_output'] = ep.luminousPower elif(units == EMISSION_UNITS_ILLUMINANCE): d['luminance_output'] = ep.illuminance elif(units == EMISSION_UNITS_LUMINOUS_INTENSITY): d['luminance_output'] = ep.luminousIntensity elif(units == EMISSION_UNITS_LUMINANCE): d['luminance_output'] = ep.luminance if(colorType == EMISSION_COLOR_TEMPERATURE): d['color_black_body_enabled'] = True d['temperature_value'] = e.getTemperature()[0] a, _ = e.getMXI() if(a.activeType == MAP_TYPE_BITMAP): d['hdr_map'] = texture(a.textureMap) d['hdr_intensity'] = a.value else: d['hdr_map'] = None d['hdr_intensity'] = a.value return d def bsdf_props(b, d): d['visible'] = b.getState()[0] a, _ = b.getWeight() if(a.activeType == MAP_TYPE_BITMAP): d['weight_map_enabled'] = True d['weight'] = a.value d['weight_map'] = texture(a.textureMap) else: d['weight_map_enabled'] = False d['weight'] = a.value d['weight_map'] = None r = b.getReflectance() d['ior'] = r.getActiveIorMode()[0] d['complex_ior'] = r.getComplexIor() d['reflectance_0'], d['reflectance_0_map_enabled'], d['reflectance_0_map'] = cattribute_rgb(r.getAttribute('color')[0]) d['reflectance_90'], d['reflectance_90_map_enabled'], d['reflectance_90_map'] = cattribute_rgb(r.getAttribute('color.tangential')[0]) d['transmittance'], d['transmittance_map_enabled'], d['transmittance_map'] = cattribute_rgb(r.getAttribute('transmittance.color')[0]) d['attenuation_units'], d['attenuation'] = r.getAbsorptionDistance() d['nd'], d['abbe'], _ = r.getIOR() d['force_fresnel'], _ = r.getForceFresnel() d['k'], _ = r.getConductor() d['r2_falloff_angle'], d['r2_influence'], d['r2_enabled'], _ = r.getFresnelCustom() d['roughness'], d['roughness_map_enabled'], d['roughness_map'] = cattribute_value(b.getAttribute('roughness')[0]) d['bump_map_use_normal'] = b.getNormalMapState()[0] if(d['bump_map_use_normal']): d['bump_normal'], d['bump_map_enabled'], d['bump_map'] = cattribute_value(b.getAttribute('bump')[0]) else: d['bump'], d['bump_map_enabled'], d['bump_map'] = cattribute_value(b.getAttribute('bump')[0]) d['anisotropy'], d['anisotropy_map_enabled'], d['anisotropy_map'] = cattribute_value(b.getAttribute('anisotropy')[0]) d['anisotropy_angle'], d['anisotropy_angle_map_enabled'], d['anisotropy_angle_map'] = cattribute_value(b.getAttribute('angle')[0]) a, _ = r.getAttribute('scattering') d['scattering'] = (a.rgb.r(), a.rgb.g(), a.rgb.b(), ) d['coef'], d['asymmetry'], d['single_sided'], _ = r.getScatteringParameters() d['single_sided_value'], d['single_sided_map_enabled'], d['single_sided_map'] = cattribute_value(r.getScatteringThickness()[0]) d['single_sided_min'], d['single_sided_max'], _ = r.getScatteringThicknessRange() return d def coating(b, d): nc, _ = b.getNumCoatings() if(nc > 0): c = b.getCoating(0) else: d['enabled'] = False return d d['enabled'] = True d['thickness'], d['thickness_map_enabled'], d['thickness_map'] = cattribute_value(c.getThickness()[0]) d['thickness_map_min'], d['thickness_map_max'], _ = c.getThicknessRange() r = c.getReflectance() d['ior'] = r.getActiveIorMode()[0] d['complex_ior'] = r.getComplexIor() d['reflectance_0'], d['reflectance_0_map_enabled'], d['reflectance_0_map'] = cattribute_rgb(r.getAttribute('color')[0]) d['reflectance_90'], d['reflectance_90_map_enabled'], d['reflectance_90_map'] = cattribute_rgb(r.getAttribute('color.tangential')[0]) d['nd'], _, _ = r.getIOR() d['force_fresnel'], _ = r.getForceFresnel() d['k'], _ = r.getConductor() d['r2_falloff_angle'], _, d['r2_enabled'], _ = r.getFresnelCustom() return d for i, sl in enumerate(structure): l = sl[1] data['layers'][i]['layer_props'] = layer_props(l, data['layers'][i]['layer_props']) data['layers'][i]['emitter'] = emitter(l, data['layers'][i]['emitter']) for j, bs in enumerate(sl[2]): b = bs[1] data['layers'][i]['bsdfs'][j]['bsdf_props'] = bsdf_props(b, data['layers'][i]['bsdfs'][j]['bsdf_props']) data['layers'][i]['bsdfs'][j]['coating'] = coating(b, data['layers'][i]['bsdfs'][j]['coating']) return data def extension(s, m, pt=None, pi=None, ): def texture(t): if(t is None): return None if(t.isEmpty()): return None d = {'path': t.getPath(), 'use_global_map': t.useGlobalMap, 'channel': t.uvwChannelID, 'brightness': t.brightness * 100, 'contrast': t.contrast * 100, 'saturation': t.saturation * 100, 'hue': t.hue * 180, 'rotation': t.rotation, 'invert': t.invert, 'interpolation': t.typeInterpolation, 'use_alpha': t.useAlpha, 'repeat': [t.scale.x(), t.scale.y()], 'mirror': [t.uIsMirrored, t.vIsMirrored], 'offset': [t.offset.x(), t.offset.y()], 'clamp': [int(t.clampMin * 255), int(t.clampMax * 255)], 'tiling_units': t.useAbsoluteUnits, 'tiling_method': [t.uIsTiled, t.vIsTiled], 'normal_mapping_flip_red': t.normalMappingFlipRed, 'normal_mapping_flip_green': t.normalMappingFlipGreen, 'normal_mapping_full_range_blue': t.normalMappingFullRangeBlue, } return d def mxparamlistarray(v): return None def rgb(v): return (v.r(), v.g(), v.b()) if(pt is not None and pi is not None): params = pt.getProceduralTexture(pi) else: params, _ = m.getMaterialModifierExtensionParams() types = [(0, 'UCHAR', params.getByte, ), (1, 'UINT', params.getUInt, ), (2, 'INT', params.getInt, ), (3, 'FLOAT', params.getFloat, ), (4, 'DOUBLE', params.getDouble, ), (5, 'STRING', params.getString, ), (6, 'FLOATARRAY', params.getFloatArray, ), (7, 'DOUBLEARRAY', params.getDoubleArray, ), (8, 'BYTEARRAY', params.getByteArray, ), (9, 'INTARRAY', params.getIntArray, ), (10, 'MXPARAMLIST', params.getTextureMap, ), (11, 'MXPARAMLISTARRAY', mxparamlistarray, ), (12, 'RGB', params.getRgb, ), ] d = {} for i in range(params.getNumItems()): name, data, _, _, data_type, _, data_count, _ = params.getByIndex(i) _, _, f = types[data_type] k = name if(data_type not in [10, 11, 12]): v, _ = f(name) else: if(data_type == 10): v = texture(f(name)[0]) elif(data_type == 11): pass elif(data_type == 12): v = rgb(f(name)[0]) d[k] = v return d log("{0} {1} {0}".format("-" * 30, self.__class__.__name__), 0, LogStyles.MESSAGE, prefix="", ) log("path: {}".format(mxm_path), 1, LogStyles.MESSAGE) s = Cmaxwell(mwcallback) m = s.readMaterial(mxm_path) self.data = material(s, m) if(m.hasMaterialModifier()): self.data['extension'] = extension(s, m) class MXSReferenceReader(): def __init__(self, path, ): log("maxwell meshes to data:", 1) log("reading mxs scene from: {0}".format(path), 2) scene = Cmaxwell(mwcallback) ok = scene.readMXS(path) if(not ok): raise RuntimeError("Error during reading scene {}".format(path)) nms = self.get_objects_names(scene) data = [] log("reading meshes..", 2) for n in nms: d = None o = scene.getObject(n) if(not o.isNull()): if(o.isMesh()[0] == 1 and o.isInstance()[0] == 0): d = self.object(o) if(d is not None): data.append(d) log("reading instances..", 2) for n in nms: d = None o = scene.getObject(n) if(not o.isNull()): if(o.isMesh()[0] == 0 and o.isInstance()[0] == 1): io = o.getInstanced() ion = io.getName()[0] for a in data: if(a['name'] == ion): b, p = self.global_transform(o) d = {'name': o.getName()[0], 'base': b, 'pivot': p, 'vertices': a['vertices'][:], } if(d is not None): data.append(d) self.data = data log("done.", 2) def get_objects_names(self, scene): it = CmaxwellObjectIterator() o = it.first(scene) l = [] while not o.isNull(): name, _ = o.getName() l.append(name) o = it.next() return l def object(self, o): is_instance, _ = o.isInstance() is_mesh, _ = o.isMesh() if(is_instance == 0 and is_mesh == 0): return None def get_verts(o): vs = [] nv, _ = o.getVerticesCount() for i in range(nv): v, _ = o.getVertex(i, 0) vs.append((v.x(), v.y(), v.z())) return vs b, p = self.global_transform(o) r = {'name': o.getName()[0], 'base': b, 'pivot': p, 'vertices': [], } if(is_instance == 1): io = o.getInstanced() r['vertices'] = get_verts(io) else: r['vertices'] = get_verts(o) return r def global_transform(self, o): cb, _ = o.getWorldTransform() o = cb.origin x = cb.xAxis y = cb.yAxis z = cb.zAxis rb = [[o.x(), o.y(), o.z()], [x.x(), x.y(), x.z()], [y.x(), y.y(), y.z()], [z.x(), z.y(), z.z()]] rp = ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0), ) return rb, rp
gpl-2.0
[ 3381, 7424, 15, 30052, 15, 4718, 14, 4857, 15, 21167, 15, 19, 14, 21, 15, 1393, 15, 1548, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 710, 10697, 844, 334, 13965, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 6900, 1603, 1151, 456, 738, 15544, 13676, 75, 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, 13985, 199, 3, 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, 1006, 199, 3, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 199, 3, 2334, 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, 199, 3, 1621, 2334, 4141, 14, 199, 199, 646, 747, 199, 646, 4298, 199, 646, 2197, 199, 646, 2702, 199, 646, 3473, 199, 646, 984, 199, 199, 646, 2680, 199, 199, 504, 1275, 793, 492, 943, 12, 5297, 30349, 199, 504, 1275, 492, 3778, 199, 199, 83, 275, 4298, 14, 2253, 342, 199, 692, 8, 83, 508, 283, 31065, 735, 272, 986, 199, 4164, 8, 83, 508, 283, 14091, 735, 272, 862, 26, 267, 687, 1134, 988, 20501, 492, 627, 272, 871, 3545, 26, 267, 6118, 275, 747, 14, 2314, 14, 362, 480, 4283, 55, 14952, 19, 63, 5441, 531, 267, 340, 8, 1397, 6118, 304, 288, 746, 6440, 480, 4752, 9141, 55, 14952, 19, 63, 5441, 3734, 1750, 531, 267, 11618, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 311, 12, 283, 1548, 297, 283, 647, 988, 20501, 297, 283, 1548, 19, 14, 21, 1333, 267, 340, 8, 1397, 747, 14, 515, 14, 2444, 8, 802, 2298, 288, 746, 6440, 480, 647, 988, 20501, 367, 2366, 650, 14, 21, 1630, 440, 2187, 11459, 25974, 908, 8, 802, 430, 267, 984, 14, 515, 14, 3176, 8, 16, 12, 11618, 9, 267, 687, 1134, 988, 20501, 492, 627, 199, 4164, 8, 83, 508, 283, 8647, 735, 272, 862, 26, 267, 687, 1134, 988, 20501, 492, 627, 272, 871, 3545, 26, 267, 6118, 275, 747, 14, 2314, 14, 362, 480, 4283, 55, 14952, 19, 63, 5441, 531, 267, 340, 8, 1397, 6118, 304, 288, 746, 6440, 480, 4752, 9141, 55, 14952, 19, 63, 5441, 3734, 1750, 531, 267, 11618, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 311, 12, 283, 1548, 297, 283, 647, 988, 20501, 297, 283, 1548, 19, 14, 21, 1333, 267, 340, 8, 1397, 747, 14, 515, 14, 2444, 8, 802, 2298, 288, 746, 6440, 480, 647, 988, 20501, 367, 2366, 650, 14, 21, 1630, 440, 2187, 11459, 25974, 908, 8, 802, 430, 267, 984, 14, 515, 14, 3176, 8, 16, 12, 11618, 9, 267, 747, 14, 2314, 459, 3243, 418, 275, 30955, 904, 779, 311, 12, 747, 14, 2314, 459, 3243, 12121, 267, 687, 1134, 988, 20501, 492, 627, 421, 199, 318, 1586, 63, 9457, 77, 63, 7780, 8, 515, 304, 272, 492, 2680, 272, 308, 275, 445, 988, 20501, 8, 14716, 3058, 9, 272, 333, 275, 308, 14, 739, 15787, 8, 515, 9, 272, 282, 12, 485, 275, 333, 14, 362, 27116, 342, 272, 519, 275, 2680, 14, 1574, 8, 65, 9, 272, 372, 519, 421, 199, 318, 6285, 63, 7780, 63, 10436, 8, 10436, 12, 3529, 63, 694, 12, 11030, 12, 3461, 272, 308, 275, 445, 988, 20501, 8, 14716, 3058, 9, 272, 943, 360, 19332, 13856, 26, 9499, 908, 8, 10436, 395, 499, 9, 272, 4112, 275, 308, 14, 739, 17401, 51, 8, 10436, 9, 272, 340, 8, 1397, 4112, 304, 267, 943, 360, 705, 7664, 13856, 26, 9499, 908, 8, 10436, 395, 499, 12, 5297, 30349, 14, 3170, 12, 776, 267, 372, 488, 2286, 347, 664, 63, 9820, 63, 1247, 8, 83, 304, 267, 652, 275, 445, 988, 20501, 15787, 3585, 342, 267, 312, 275, 652, 14, 2246, 8, 83, 9, 267, 634, 275, 942, 267, 1830, 440, 312, 14, 374, 8849, 837, 288, 536, 275, 312, 14, 16405, 342, 288, 634, 14, 740, 8, 354, 9, 288, 312, 275, 652, 14, 2184, 342, 267, 372, 634, 2286, 1561, 275, 664, 63, 9820, 63, 1247, 8, 83, 9, 272, 367, 302, 315, 1561, 26, 267, 340, 8, 78, 14, 2325, 342, 508, 283, 7780, 735, 288, 2059, 2286, 943, 360, 3519, 3262, 6285, 26, 9499, 908, 8, 78, 395, 499, 9, 272, 6285, 275, 308, 14, 362, 15787, 8, 78, 9, 272, 299, 275, 747, 14, 515, 14, 904, 8, 2791, 63, 694, 12, 283, 9820, 14, 9457, 77, 358, 272, 6285, 14, 739, 8, 80, 9, 272, 6285, 14, 3990, 1378, 3534, 19448, 14216, 342, 2286, 943, 360, 6031, 2633, 703, 297, 499, 9, 272, 308, 14, 409, 9216, 4720, 360, 15956, 297, 2783, 8, 9161, 12, 2644, 534, 6610, 13, 24, 1333, 2286, 444, 82, 275, 747, 14, 515, 14, 904, 8, 2791, 63, 694, 12, 298, 3352, 14, 476, 82, 531, 272, 308, 14, 409, 2042, 360, 31587, 297, 444, 82, 12, 4337, 9, 2286, 308, 14, 409, 9216, 4720, 360, 1649, 2845, 13950, 2524, 603, 56, 41, 13024, 297, 756, 9, 272, 308, 14, 409, 9216, 4720, 360, 1649, 2845, 13950, 2524, 25228, 13024, 297, 756, 9, 2286 ]
[ 7424, 15, 30052, 15, 4718, 14, 4857, 15, 21167, 15, 19, 14, 21, 15, 1393, 15, 1548, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 710, 10697, 844, 334, 13965, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 6900, 1603, 1151, 456, 738, 15544, 13676, 75, 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, 13985, 199, 3, 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, 1006, 199, 3, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 199, 3, 2334, 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, 199, 3, 1621, 2334, 4141, 14, 199, 199, 646, 747, 199, 646, 4298, 199, 646, 2197, 199, 646, 2702, 199, 646, 3473, 199, 646, 984, 199, 199, 646, 2680, 199, 199, 504, 1275, 793, 492, 943, 12, 5297, 30349, 199, 504, 1275, 492, 3778, 199, 199, 83, 275, 4298, 14, 2253, 342, 199, 692, 8, 83, 508, 283, 31065, 735, 272, 986, 199, 4164, 8, 83, 508, 283, 14091, 735, 272, 862, 26, 267, 687, 1134, 988, 20501, 492, 627, 272, 871, 3545, 26, 267, 6118, 275, 747, 14, 2314, 14, 362, 480, 4283, 55, 14952, 19, 63, 5441, 531, 267, 340, 8, 1397, 6118, 304, 288, 746, 6440, 480, 4752, 9141, 55, 14952, 19, 63, 5441, 3734, 1750, 531, 267, 11618, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 311, 12, 283, 1548, 297, 283, 647, 988, 20501, 297, 283, 1548, 19, 14, 21, 1333, 267, 340, 8, 1397, 747, 14, 515, 14, 2444, 8, 802, 2298, 288, 746, 6440, 480, 647, 988, 20501, 367, 2366, 650, 14, 21, 1630, 440, 2187, 11459, 25974, 908, 8, 802, 430, 267, 984, 14, 515, 14, 3176, 8, 16, 12, 11618, 9, 267, 687, 1134, 988, 20501, 492, 627, 199, 4164, 8, 83, 508, 283, 8647, 735, 272, 862, 26, 267, 687, 1134, 988, 20501, 492, 627, 272, 871, 3545, 26, 267, 6118, 275, 747, 14, 2314, 14, 362, 480, 4283, 55, 14952, 19, 63, 5441, 531, 267, 340, 8, 1397, 6118, 304, 288, 746, 6440, 480, 4752, 9141, 55, 14952, 19, 63, 5441, 3734, 1750, 531, 267, 11618, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 311, 12, 283, 1548, 297, 283, 647, 988, 20501, 297, 283, 1548, 19, 14, 21, 1333, 267, 340, 8, 1397, 747, 14, 515, 14, 2444, 8, 802, 2298, 288, 746, 6440, 480, 647, 988, 20501, 367, 2366, 650, 14, 21, 1630, 440, 2187, 11459, 25974, 908, 8, 802, 430, 267, 984, 14, 515, 14, 3176, 8, 16, 12, 11618, 9, 267, 747, 14, 2314, 459, 3243, 418, 275, 30955, 904, 779, 311, 12, 747, 14, 2314, 459, 3243, 12121, 267, 687, 1134, 988, 20501, 492, 627, 421, 199, 318, 1586, 63, 9457, 77, 63, 7780, 8, 515, 304, 272, 492, 2680, 272, 308, 275, 445, 988, 20501, 8, 14716, 3058, 9, 272, 333, 275, 308, 14, 739, 15787, 8, 515, 9, 272, 282, 12, 485, 275, 333, 14, 362, 27116, 342, 272, 519, 275, 2680, 14, 1574, 8, 65, 9, 272, 372, 519, 421, 199, 318, 6285, 63, 7780, 63, 10436, 8, 10436, 12, 3529, 63, 694, 12, 11030, 12, 3461, 272, 308, 275, 445, 988, 20501, 8, 14716, 3058, 9, 272, 943, 360, 19332, 13856, 26, 9499, 908, 8, 10436, 395, 499, 9, 272, 4112, 275, 308, 14, 739, 17401, 51, 8, 10436, 9, 272, 340, 8, 1397, 4112, 304, 267, 943, 360, 705, 7664, 13856, 26, 9499, 908, 8, 10436, 395, 499, 12, 5297, 30349, 14, 3170, 12, 776, 267, 372, 488, 2286, 347, 664, 63, 9820, 63, 1247, 8, 83, 304, 267, 652, 275, 445, 988, 20501, 15787, 3585, 342, 267, 312, 275, 652, 14, 2246, 8, 83, 9, 267, 634, 275, 942, 267, 1830, 440, 312, 14, 374, 8849, 837, 288, 536, 275, 312, 14, 16405, 342, 288, 634, 14, 740, 8, 354, 9, 288, 312, 275, 652, 14, 2184, 342, 267, 372, 634, 2286, 1561, 275, 664, 63, 9820, 63, 1247, 8, 83, 9, 272, 367, 302, 315, 1561, 26, 267, 340, 8, 78, 14, 2325, 342, 508, 283, 7780, 735, 288, 2059, 2286, 943, 360, 3519, 3262, 6285, 26, 9499, 908, 8, 78, 395, 499, 9, 272, 6285, 275, 308, 14, 362, 15787, 8, 78, 9, 272, 299, 275, 747, 14, 515, 14, 904, 8, 2791, 63, 694, 12, 283, 9820, 14, 9457, 77, 358, 272, 6285, 14, 739, 8, 80, 9, 272, 6285, 14, 3990, 1378, 3534, 19448, 14216, 342, 2286, 943, 360, 6031, 2633, 703, 297, 499, 9, 272, 308, 14, 409, 9216, 4720, 360, 15956, 297, 2783, 8, 9161, 12, 2644, 534, 6610, 13, 24, 1333, 2286, 444, 82, 275, 747, 14, 515, 14, 904, 8, 2791, 63, 694, 12, 298, 3352, 14, 476, 82, 531, 272, 308, 14, 409, 2042, 360, 31587, 297, 444, 82, 12, 4337, 9, 2286, 308, 14, 409, 9216, 4720, 360, 1649, 2845, 13950, 2524, 603, 56, 41, 13024, 297, 756, 9, 272, 308, 14, 409, 9216, 4720, 360, 1649, 2845, 13950, 2524, 25228, 13024, 297, 756, 9, 2286, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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018, Dag Wieers (dagwieers) <dag@wieers.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': 'certified'} DOCUMENTATION = r''' --- module: aci_firmware_source short_description: Manage firmware image sources (firmware:OSource) description: - Manage firmware image sources on Cisco ACI fabrics. version_added: '2.5' options: source: description: - The identifying name for the outside source of images, such as an HTTP or SCP server. type: str required: yes aliases: [ name, source_name ] polling_interval: description: - Polling interval in minutes. type: int url_protocol: description: - The Firmware download protocol. type: str choices: [ http, local, scp, usbkey ] default: scp aliases: [ url_proto ] url: description: The firmware URL for the image(s) on the source. type: str url_password: description: The Firmware password or key string. type: str url_username: description: The username for the source. type: str state: description: - Use C(present) or C(absent) for adding or removing. - Use C(query) for listing an object or multiple objects. type: str choices: [ absent, present, query ] default: present extends_documentation_fragment: aci seealso: - name: APIC Management Information Model reference description: More information about the internal APIC class B(firmware:OSource). link: https://developer.cisco.com/docs/apic-mim-ref/ author: - Dag Wieers (@dagwieers) ''' EXAMPLES = r''' - name: Add firmware source aci_firmware_source: host: apic username: admin password: SomeSecretPassword source: aci-msft-pkg-3.1.1i.zip url: foo.bar.cisco.com/download/cisco/aci/aci-msft-pkg-3.1.1i.zip url_protocol: http state: present delegate_to: localhost - name: Remove firmware source aci_firmware_source: host: apic username: admin password: SomeSecretPassword source: aci-msft-pkg-3.1.1i.zip state: absent delegate_to: localhost - name: Query a specific firmware source aci_firmware_source: host: apic username: admin password: SomeSecretPassword source: aci-msft-pkg-3.1.1i.zip state: query delegate_to: localhost register: query_result - name: Query all firmware sources aci_firmware_source: host: apic username: admin password: SomeSecretPassword state: query delegate_to: localhost register: query_result ''' RETURN = r''' current: description: The existing configuration from the APIC after the module has finished returned: success type: list sample: [ { "fvTenant": { "attributes": { "descr": "Production environment", "dn": "uni/tn-production", "name": "production", "nameAlias": "", "ownerKey": "", "ownerTag": "" } } } ] error: description: The error information as returned from the APIC returned: failure type: dict sample: { "code": "122", "text": "unknown managed object class foo" } raw: description: The raw output returned by the APIC REST API (xml or json) returned: parse error type: str sample: '<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>' sent: description: The actual/minimal configuration pushed to the APIC returned: info type: list sample: { "fvTenant": { "attributes": { "descr": "Production environment" } } } previous: description: The original configuration from the APIC before the module has started returned: info type: list sample: [ { "fvTenant": { "attributes": { "descr": "Production", "dn": "uni/tn-production", "name": "production", "nameAlias": "", "ownerKey": "", "ownerTag": "" } } } ] proposed: description: The assembled configuration from the user-provided parameters returned: info type: dict sample: { "fvTenant": { "attributes": { "descr": "Production environment", "name": "production" } } } filter_string: description: The filter string used for the request returned: failure or debug type: str sample: ?rsp-prop-include=config-only method: description: The HTTP method used for the request to the APIC returned: failure or debug type: str sample: POST response: description: The HTTP response from the APIC returned: failure or debug type: str sample: OK (30 bytes) status: description: The HTTP status from the APIC returned: failure or debug type: int sample: 200 url: description: The HTTP url used for the request to the APIC returned: failure or debug type: str sample: https://10.11.12.13/api/mo/uni/tn-production.json ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec def main(): argument_spec = aci_argument_spec() argument_spec.update( source=dict(type='str', aliases=['name', 'source_name']), # Not required for querying all objects polling_interval=dict(type='int'), url=dict(type='str'), url_username=dict(type='str'), url_password=dict(type='str', no_log=True), url_protocol=dict(type='str', default='scp', choices=['http', 'local', 'scp', 'usbkey'], aliases=['url_proto']), state=dict(type='str', default='present', choices=['absent', 'present', 'query']), ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, required_if=[ ['state', 'absent', ['source']], ['state', 'present', ['url_protocol', 'source', 'url']], ], ) polling_interval = module.params['polling_interval'] url_protocol = module.params['url_protocol'] state = module.params['state'] source = module.params['source'] url = module.params['url'] url_password = module.params['url_password'] url_username = module.params['url_username'] aci = ACIModule(module) aci.construct_url( root_class=dict( aci_class='firmwareOSource', aci_rn='fabric/fwrepop', module_object=source, target_filter={'name': source}, ), ) aci.get_existing() if state == 'present': aci.payload( aci_class='firmwareOSource', class_config=dict( name=source, url=url, password=url_password, pollingInterval=polling_interval, proto=url_protocol, user=url_username, ), ) aci.get_diff(aci_class='firmwareOSource') aci.post_config() elif state == 'absent': aci.delete_config() aci.exit_json() if __name__ == "__main__": main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 14894, 12, 26110, 644, 1873, 1192, 334, 7406, 87, 1873, 1192, 9, 665, 7406, 32, 87, 1873, 1192, 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, 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, 2247, 8981, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 19631, 63, 26374, 63, 1365, 199, 3612, 63, 1802, 26, 14944, 27969, 1834, 5274, 334, 26374, 26, 47, 2980, 9, 199, 1802, 26, 199, 13, 14944, 27969, 1834, 5274, 641, 28356, 437, 3553, 31507, 11818, 14, 199, 1023, 63, 3270, 26, 283, 18, 14, 21, 7, 199, 1419, 26, 523, 1350, 26, 272, 1369, 26, 272, 446, 710, 21119, 536, 367, 314, 9682, 1350, 402, 5935, 12, 4066, 465, 376, 3101, 503, 428, 2890, 1654, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 272, 5481, 26, 359, 536, 12, 1350, 63, 354, 1622, 523, 12353, 63, 4284, 26, 272, 1369, 26, 272, 446, 8467, 2983, 6252, 315, 9395, 14, 272, 730, 26, 1109, 523, 1166, 63, 3922, 26, 272, 1369, 26, 272, 446, 710, 481, 20678, 5235, 4113, 14, 272, 730, 26, 620, 272, 3415, 26, 359, 1455, 12, 2257, 12, 308, 1850, 12, 27923, 498, 1622, 272, 849, 26, 308, 1850, 272, 5481, 26, 359, 1166, 63, 2625, 1622, 523, 1166, 26, 272, 1369, 26, 489, 710, 27969, 2851, 367, 314, 1834, 8, 83, 9, 641, 314, 1350, 14, 272, 730, 26, 620, 523, 1166, 63, 2060, 26, 272, 1369, 26, 489, 710, 481, 20678, 2505, 503, 790, 1059, 14, 272, 730, 26, 620, 523, 1166, 63, 2473, 26, 272, 1369, 26, 489, 710, 3434, 367, 314, 1350, 14, 272, 730, 26, 620, 523, 1174, 26, 272, 1369, 26, 272, 446, 3645, 445, 8, 1881, 9, 503, 445, 8, 5575, 9, 367, 7791, 503, 12881, 14, 272, 446, 3645, 445, 8, 1131, 9, 367, 13778, 376, 909, 503, 3663, 2251, 14, 272, 730, 26, 620, 272, 3415, 26, 359, 9552, 12, 3451, 12, 1827, 1622, 272, 849, 26, 3451, 199, 11036, 63, 9970, 63, 7677, 26, 19631, 199, 3239, 12344, 26, 199, 13, 536, 26, 25418, 8259, 17064, 5822, 3659, 523, 1369, 26, 16917, 2556, 3595, 314, 5007, 25418, 1021, 699, 8, 26374, 26, 47, 2980, 680, 523, 2142, 26, 4178, 921, 11071, 14, 19597, 14, 957, 15, 4757, 15, 20789, 13, 77, 1017, 13, 1121, 15, 199, 2502, 26, 199, 13, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2654, 27969, 1350, 523, 19631, 63, 26374, 63, 1365, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 1350, 26, 19631, 13, 706, 856, 13, 4600, 13, 19, 14, 17, 14, 17, 73, 14, 3065, 272, 1166, 26, 3925, 14, 1700, 14, 19597, 14, 957, 15, 4249, 15, 19597, 15, 22832, 15, 22832, 13, 706, 856, 13, 4600, 13, 19, 14, 17, 14, 17, 73, 14, 3065, 272, 1166, 63, 3922, 26, 1455, 272, 1174, 26, 3451, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 5852, 27969, 1350, 523, 19631, 63, 26374, 63, 1365, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 1350, 26, 19631, 13, 706, 856, 13, 4600, 13, 19, 14, 17, 14, 17, 73, 14, 3065, 272, 1174, 26, 9552, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 8133, 282, 2488, 27969, 1350, 523, 19631, 63, 26374, 63, 1365, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 1350, 26, 19631, 13, 706, 856, 13, 4600, 13, 19, 14, 17, 14, 17, 73, 14, 3065, 272, 1174, 26, 1827, 523, 13080, 63, 475, 26, 11667, 523, 2274, 26, 1827, 63, 1099, 199, 199, 13, 536, 26, 8133, 1006, 27969, 5274, 523, 19631, 63, 26374, 63, 1365, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 1174, 26, 1827, 523, 13080, 63, 475, 26, 11667, 523, 2274, 26, 1827, 63, 1099, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 1818, 26, 523, 1369, 26, 710, 3411, 2897, 687, 314, 25418, 2410, 314, 859, 965, 9158, 523, 2138, 26, 3182, 523, 730, 26, 769, 523, 2690, 26, 272, 359, 267, 469, 288, 298, 13692, 27807, 582, 469, 355, 298, 2987, 582, 469, 490, 298, 12113, 582, 298, 26432, 3734, 401, 490, 298, 4272, 582, 298, 5411, 15, 5889, 13, 10777, 401, 490, 298, 354, 582, 298, 10777, 401, 490, 298, 354, 14149, 582, 4873, 490, 298, 4597, 1197, 582, 4873, 490, 298, 4597, 1931, 582, 3087, 355, 789, 288, 789, 267, 789, 272, 1622, 199, 705, 26, 523, 1369, 26, 710, 1125, 2556, 465, 2138, 687, 314, 25418, 523, 2138, 26, 5988, 523, 730, 26, 1211, 523, 2690, 26, 272, 469, 267, 298, 600, 582, 298, 7507, 401, 267, 298, 505, 582, 298, 5187, 12883, 909, 1021, 3925, 2, 272, 789, 199, 1773, 26, 523, 1369, 26, 710, 3066, 1072, 2138, 701, 314, 25418, 14880, 3261, 334, 1652, 503, 2022, 9, 523, 2138, 26, 2198, 1125, 523, 730, 26, 620, 523, 2690, 26, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 14863, 2535, 1017, 576, 3141, 2353, 628, 17, 8186, 705, 1233, 628, 7507, 2, 1318, 628, 5187, 12883, 909, 1021, 3925, 15313, 2957, 1017, 576, 3524, 199, 1150, 26, 523, 1369, 26, 710, 3503, 15, 21508, 2897, 22319, 370, 314, 25418, 523, 2138, 26, 2256, 523, 730, 26, 769, 523, 2690, 26, 272, 469, 267, 298, 13692 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 14894, 12, 26110, 644, 1873, 1192, 334, 7406, 87, 1873, 1192, 9, 665, 7406, 32, 87, 1873, 1192, 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, 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, 2247, 8981, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 19631, 63, 26374, 63, 1365, 199, 3612, 63, 1802, 26, 14944, 27969, 1834, 5274, 334, 26374, 26, 47, 2980, 9, 199, 1802, 26, 199, 13, 14944, 27969, 1834, 5274, 641, 28356, 437, 3553, 31507, 11818, 14, 199, 1023, 63, 3270, 26, 283, 18, 14, 21, 7, 199, 1419, 26, 523, 1350, 26, 272, 1369, 26, 272, 446, 710, 21119, 536, 367, 314, 9682, 1350, 402, 5935, 12, 4066, 465, 376, 3101, 503, 428, 2890, 1654, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 272, 5481, 26, 359, 536, 12, 1350, 63, 354, 1622, 523, 12353, 63, 4284, 26, 272, 1369, 26, 272, 446, 8467, 2983, 6252, 315, 9395, 14, 272, 730, 26, 1109, 523, 1166, 63, 3922, 26, 272, 1369, 26, 272, 446, 710, 481, 20678, 5235, 4113, 14, 272, 730, 26, 620, 272, 3415, 26, 359, 1455, 12, 2257, 12, 308, 1850, 12, 27923, 498, 1622, 272, 849, 26, 308, 1850, 272, 5481, 26, 359, 1166, 63, 2625, 1622, 523, 1166, 26, 272, 1369, 26, 489, 710, 27969, 2851, 367, 314, 1834, 8, 83, 9, 641, 314, 1350, 14, 272, 730, 26, 620, 523, 1166, 63, 2060, 26, 272, 1369, 26, 489, 710, 481, 20678, 2505, 503, 790, 1059, 14, 272, 730, 26, 620, 523, 1166, 63, 2473, 26, 272, 1369, 26, 489, 710, 3434, 367, 314, 1350, 14, 272, 730, 26, 620, 523, 1174, 26, 272, 1369, 26, 272, 446, 3645, 445, 8, 1881, 9, 503, 445, 8, 5575, 9, 367, 7791, 503, 12881, 14, 272, 446, 3645, 445, 8, 1131, 9, 367, 13778, 376, 909, 503, 3663, 2251, 14, 272, 730, 26, 620, 272, 3415, 26, 359, 9552, 12, 3451, 12, 1827, 1622, 272, 849, 26, 3451, 199, 11036, 63, 9970, 63, 7677, 26, 19631, 199, 3239, 12344, 26, 199, 13, 536, 26, 25418, 8259, 17064, 5822, 3659, 523, 1369, 26, 16917, 2556, 3595, 314, 5007, 25418, 1021, 699, 8, 26374, 26, 47, 2980, 680, 523, 2142, 26, 4178, 921, 11071, 14, 19597, 14, 957, 15, 4757, 15, 20789, 13, 77, 1017, 13, 1121, 15, 199, 2502, 26, 199, 13, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2654, 27969, 1350, 523, 19631, 63, 26374, 63, 1365, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 1350, 26, 19631, 13, 706, 856, 13, 4600, 13, 19, 14, 17, 14, 17, 73, 14, 3065, 272, 1166, 26, 3925, 14, 1700, 14, 19597, 14, 957, 15, 4249, 15, 19597, 15, 22832, 15, 22832, 13, 706, 856, 13, 4600, 13, 19, 14, 17, 14, 17, 73, 14, 3065, 272, 1166, 63, 3922, 26, 1455, 272, 1174, 26, 3451, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 5852, 27969, 1350, 523, 19631, 63, 26374, 63, 1365, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 1350, 26, 19631, 13, 706, 856, 13, 4600, 13, 19, 14, 17, 14, 17, 73, 14, 3065, 272, 1174, 26, 9552, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 8133, 282, 2488, 27969, 1350, 523, 19631, 63, 26374, 63, 1365, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 1350, 26, 19631, 13, 706, 856, 13, 4600, 13, 19, 14, 17, 14, 17, 73, 14, 3065, 272, 1174, 26, 1827, 523, 13080, 63, 475, 26, 11667, 523, 2274, 26, 1827, 63, 1099, 199, 199, 13, 536, 26, 8133, 1006, 27969, 5274, 523, 19631, 63, 26374, 63, 1365, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 1174, 26, 1827, 523, 13080, 63, 475, 26, 11667, 523, 2274, 26, 1827, 63, 1099, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 1818, 26, 523, 1369, 26, 710, 3411, 2897, 687, 314, 25418, 2410, 314, 859, 965, 9158, 523, 2138, 26, 3182, 523, 730, 26, 769, 523, 2690, 26, 272, 359, 267, 469, 288, 298, 13692, 27807, 582, 469, 355, 298, 2987, 582, 469, 490, 298, 12113, 582, 298, 26432, 3734, 401, 490, 298, 4272, 582, 298, 5411, 15, 5889, 13, 10777, 401, 490, 298, 354, 582, 298, 10777, 401, 490, 298, 354, 14149, 582, 4873, 490, 298, 4597, 1197, 582, 4873, 490, 298, 4597, 1931, 582, 3087, 355, 789, 288, 789, 267, 789, 272, 1622, 199, 705, 26, 523, 1369, 26, 710, 1125, 2556, 465, 2138, 687, 314, 25418, 523, 2138, 26, 5988, 523, 730, 26, 1211, 523, 2690, 26, 272, 469, 267, 298, 600, 582, 298, 7507, 401, 267, 298, 505, 582, 298, 5187, 12883, 909, 1021, 3925, 2, 272, 789, 199, 1773, 26, 523, 1369, 26, 710, 3066, 1072, 2138, 701, 314, 25418, 14880, 3261, 334, 1652, 503, 2022, 9, 523, 2138, 26, 2198, 1125, 523, 730, 26, 620, 523, 2690, 26, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 14863, 2535, 1017, 576, 3141, 2353, 628, 17, 8186, 705, 1233, 628, 7507, 2, 1318, 628, 5187, 12883, 909, 1021, 3925, 15313, 2957, 1017, 576, 3524, 199, 1150, 26, 523, 1369, 26, 710, 3503, 15, 21508, 2897, 22319, 370, 314, 25418, 523, 2138, 26, 2256, 523, 730, 26, 769, 523, 2690, 26, 272, 469, 267, 298, 13692, 0 ]
[ 1, 1, 1, 1, 1, 1, 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/base_api.py
2
21953
# 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 functools import logging from typing import Any, Callable, cast, Dict, List, Optional, Set, Tuple, Type, Union from apispec import APISpec from apispec.exceptions import DuplicateComponentNameError from flask import Blueprint, g, Response from flask_appbuilder import AppBuilder, Model, ModelRestApi from flask_appbuilder.api import expose, protect, rison, safe from flask_appbuilder.models.filters import BaseFilter, Filters from flask_appbuilder.models.sqla.filters import FilterStartsWith from flask_appbuilder.models.sqla.interface import SQLAInterface from flask_babel import lazy_gettext as _ from marshmallow import fields, Schema from sqlalchemy import and_, distinct, func from sqlalchemy.orm.query import Query from superset.extensions import db, event_logger, security_manager from superset.models.core import FavStar from superset.models.dashboard import Dashboard from superset.models.slice import Slice from superset.schemas import error_payload_content from superset.sql_lab import Query as SqllabQuery from superset.stats_logger import BaseStatsLogger from superset.typing import FlaskResponse from superset.utils.core import time_function logger = logging.getLogger(__name__) get_related_schema = { "type": "object", "properties": { "page_size": {"type": "integer"}, "page": {"type": "integer"}, "include_ids": {"type": "array", "items": {"type": "integer"}}, "filter": {"type": "string"}, }, } class RelatedResultResponseSchema(Schema): value = fields.Integer(description="The related item identifier") text = fields.String(description="The related item string representation") class RelatedResponseSchema(Schema): count = fields.Integer(description="The total number of related values") result = fields.List(fields.Nested(RelatedResultResponseSchema)) class DistinctResultResponseSchema(Schema): text = fields.String(description="The distinct item") class DistincResponseSchema(Schema): count = fields.Integer(description="The total number of distinct values") result = fields.List(fields.Nested(DistinctResultResponseSchema)) def statsd_metrics(f: Callable[..., Any]) -> Callable[..., Any]: """ Handle sending all statsd metrics from the REST API """ def wraps(self: "BaseSupersetModelRestApi", *args: Any, **kwargs: Any) -> Response: try: duration, response = time_function(f, self, *args, **kwargs) except Exception as ex: self.incr_stats("error", f.__name__) raise ex self.send_stats_metrics(response, f.__name__, duration) return response return functools.update_wrapper(wraps, f) class RelatedFieldFilter: # data class to specify what filter to use on a /related endpoint # pylint: disable=too-few-public-methods def __init__(self, field_name: str, filter_class: Type[BaseFilter]): self.field_name = field_name self.filter_class = filter_class class BaseFavoriteFilter(BaseFilter): # pylint: disable=too-few-public-methods """ Base Custom filter for the GET list that filters all dashboards, slices that a user has favored or not """ name = _("Is favorite") arg_name = "" class_name = "" """ The FavStar class_name to user """ model: Type[Union[Dashboard, Slice, SqllabQuery]] = Dashboard """ The SQLAlchemy model """ def apply(self, query: Query, value: Any) -> Query: # If anonymous user filter nothing if security_manager.current_user is None: return query users_favorite_query = db.session.query(FavStar.obj_id).filter( and_( FavStar.user_id == g.user.get_id(), FavStar.class_name == self.class_name, ) ) if value: return query.filter(and_(self.model.id.in_(users_favorite_query))) return query.filter(and_(~self.model.id.in_(users_favorite_query))) class BaseSupersetModelRestApi(ModelRestApi): """ Extends FAB's ModelResApi to implement specific superset generic functionality """ csrf_exempt = False method_permission_name = { "bulk_delete": "delete", "data": "list", "data_from_cache": "list", "delete": "delete", "distinct": "list", "export": "mulexport", "import_": "add", "get": "show", "get_list": "list", "info": "list", "post": "add", "put": "edit", "refresh": "edit", "related": "list", "related_objects": "list", "schemas": "list", "select_star": "list", "table_metadata": "list", "test_connection": "post", "thumbnail": "list", "viz_types": "list", } order_rel_fields: Dict[str, Tuple[str, str]] = {} """ Impose ordering on related fields query:: order_rel_fields = { "<RELATED_FIELD>": ("<RELATED_FIELD_FIELD>", "<asc|desc>"), ... } """ # pylint: disable=pointless-string-statement related_field_filters: Dict[str, Union[RelatedFieldFilter, str]] = {} """ Declare the filters for related fields:: related_fields = { "<RELATED_FIELD>": <RelatedFieldFilter>) } """ # pylint: disable=pointless-string-statement filter_rel_fields: Dict[str, BaseFilter] = {} """ Declare the related field base filter:: filter_rel_fields_field = { "<RELATED_FIELD>": "<FILTER>") } """ # pylint: disable=pointless-string-statement allowed_rel_fields: Set[str] = set() """ Declare a set of allowed related fields that the `related` endpoint supports """ # pylint: disable=pointless-string-statement text_field_rel_fields: Dict[str, str] = {} """ Declare an alternative for the human readable representation of the Model object:: text_field_rel_fields = { "<RELATED_FIELD>": "<RELATED_OBJECT_FIELD>" } """ # pylint: disable=pointless-string-statement allowed_distinct_fields: Set[str] = set() openapi_spec_component_schemas: Tuple[Type[Schema], ...] = tuple() """ Add extra schemas to the OpenAPI component schemas section """ # pylint: disable=pointless-string-statement add_columns: List[str] edit_columns: List[str] list_columns: List[str] show_columns: List[str] responses = { "400": {"description": "Bad request", "content": error_payload_content}, "401": {"description": "Unauthorized", "content": error_payload_content}, "403": {"description": "Forbidden", "content": error_payload_content}, "404": {"description": "Not found", "content": error_payload_content}, "422": { "description": "Could not process entity", "content": error_payload_content, }, "500": {"description": "Fatal error", "content": error_payload_content}, } def __init__(self) -> None: # Setup statsd self.stats_logger = BaseStatsLogger() # Add base API spec base query parameter schemas if self.apispec_parameter_schemas is None: # type: ignore self.apispec_parameter_schemas = {} self.apispec_parameter_schemas["get_related_schema"] = get_related_schema if self.openapi_spec_component_schemas is None: self.openapi_spec_component_schemas = () self.openapi_spec_component_schemas = self.openapi_spec_component_schemas + ( RelatedResponseSchema, DistincResponseSchema, ) super().__init__() def add_apispec_components(self, api_spec: APISpec) -> None: """ Adds extra OpenApi schema spec components, these are declared on the `openapi_spec_component_schemas` class property """ for schema in self.openapi_spec_component_schemas: try: api_spec.components.schema( schema.__name__, schema=schema, ) except DuplicateComponentNameError: pass super().add_apispec_components(api_spec) def create_blueprint( self, appbuilder: AppBuilder, *args: Any, **kwargs: Any ) -> Blueprint: self.stats_logger = self.appbuilder.get_app.config["STATS_LOGGER"] return super().create_blueprint(appbuilder, *args, **kwargs) def _init_properties(self) -> None: model_id = self.datamodel.get_pk_name() if self.list_columns is None and not self.list_model_schema: self.list_columns = [model_id] if self.show_columns is None and not self.show_model_schema: self.show_columns = [model_id] if self.edit_columns is None and not self.edit_model_schema: self.edit_columns = [model_id] if self.add_columns is None and not self.add_model_schema: self.add_columns = [model_id] super()._init_properties() def _get_related_filter( self, datamodel: SQLAInterface, column_name: str, value: str ) -> Filters: filter_field = self.related_field_filters.get(column_name) if isinstance(filter_field, str): filter_field = RelatedFieldFilter(cast(str, filter_field), FilterStartsWith) filter_field = cast(RelatedFieldFilter, filter_field) search_columns = [filter_field.field_name] if filter_field else None filters = datamodel.get_filters(search_columns) base_filters = self.filter_rel_fields.get(column_name) if base_filters: filters.add_filter_list(base_filters) if value and filter_field: filters.add_filter( filter_field.field_name, filter_field.filter_class, value ) return filters def _get_distinct_filter(self, column_name: str, value: str) -> Filters: filter_field = RelatedFieldFilter(column_name, FilterStartsWith) filter_field = cast(RelatedFieldFilter, filter_field) search_columns = [filter_field.field_name] if filter_field else None filters = self.datamodel.get_filters(search_columns) filters.add_filter_list(self.base_filters) if value and filter_field: filters.add_filter( filter_field.field_name, filter_field.filter_class, value ) return filters def _get_text_for_model(self, model: Model, column_name: str) -> str: if column_name in self.text_field_rel_fields: model_column_name = self.text_field_rel_fields.get(column_name) if model_column_name: return getattr(model, model_column_name) return str(model) def _get_result_from_rows( self, datamodel: SQLAInterface, rows: List[Model], column_name: str ) -> List[Dict[str, Any]]: return [ { "value": datamodel.get_pk_value(row), "text": self._get_text_for_model(row, column_name), } for row in rows ] def _add_extra_ids_to_result( self, datamodel: SQLAInterface, column_name: str, ids: List[int], result: List[Dict[str, Any]], ) -> None: if ids: # Filter out already present values on the result values = [row["value"] for row in result] ids = [id_ for id_ in ids if id_ not in values] pk_col = datamodel.get_pk() # Fetch requested values from ids extra_rows = db.session.query(datamodel.obj).filter(pk_col.in_(ids)).all() result += self._get_result_from_rows(datamodel, extra_rows, column_name) def incr_stats(self, action: str, func_name: str) -> None: """ Proxy function for statsd.incr to impose a key structure for REST API's :param action: String with an action name eg: error, success :param func_name: The function name """ self.stats_logger.incr(f"{self.__class__.__name__}.{func_name}.{action}") def timing_stats(self, action: str, func_name: str, value: float) -> None: """ Proxy function for statsd.incr to impose a key structure for REST API's :param action: String with an action name eg: error, success :param func_name: The function name :param value: A float with the time it took for the endpoint to execute """ self.stats_logger.timing( f"{self.__class__.__name__}.{func_name}.{action}", value ) def send_stats_metrics( self, response: Response, key: str, time_delta: Optional[float] = None ) -> None: """ Helper function to handle sending statsd metrics :param response: flask response object, will evaluate if it was an error :param key: The function name :param time_delta: Optional time it took for the endpoint to execute """ if 200 <= response.status_code < 400: self.incr_stats("success", key) else: self.incr_stats("error", key) if time_delta: self.timing_stats("time", key, time_delta) @event_logger.log_this_with_context( action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.info", object_ref=False, log_to_statsd=False, ) def info_headless(self, **kwargs: Any) -> Response: """ Add statsd metrics to builtin FAB _info endpoint """ duration, response = time_function(super().info_headless, **kwargs) self.send_stats_metrics(response, self.info.__name__, duration) return response @event_logger.log_this_with_context( action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get", object_ref=False, log_to_statsd=False, ) def get_headless(self, pk: int, **kwargs: Any) -> Response: """ Add statsd metrics to builtin FAB GET endpoint """ duration, response = time_function(super().get_headless, pk, **kwargs) self.send_stats_metrics(response, self.get.__name__, duration) return response @event_logger.log_this_with_context( action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get_list", object_ref=False, log_to_statsd=False, ) def get_list_headless(self, **kwargs: Any) -> Response: """ Add statsd metrics to builtin FAB GET list endpoint """ duration, response = time_function(super().get_list_headless, **kwargs) self.send_stats_metrics(response, self.get_list.__name__, duration) return response @event_logger.log_this_with_context( action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.post", object_ref=False, log_to_statsd=False, ) def post_headless(self) -> Response: """ Add statsd metrics to builtin FAB POST endpoint """ duration, response = time_function(super().post_headless) self.send_stats_metrics(response, self.post.__name__, duration) return response @event_logger.log_this_with_context( action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.put", object_ref=False, log_to_statsd=False, ) def put_headless(self, pk: int) -> Response: """ Add statsd metrics to builtin FAB PUT endpoint """ duration, response = time_function(super().put_headless, pk) self.send_stats_metrics(response, self.put.__name__, duration) return response @event_logger.log_this_with_context( action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.delete", object_ref=False, log_to_statsd=False, ) def delete_headless(self, pk: int) -> Response: """ Add statsd metrics to builtin FAB DELETE endpoint """ duration, response = time_function(super().delete_headless, pk) self.send_stats_metrics(response, self.delete.__name__, duration) return response @expose("/related/<column_name>", methods=["GET"]) @protect() @safe @statsd_metrics @rison(get_related_schema) def related(self, column_name: str, **kwargs: Any) -> FlaskResponse: """Get related fields data --- get: parameters: - in: path schema: type: string name: column_name - in: query name: q content: application/json: schema: $ref: '#/components/schemas/get_related_schema' responses: 200: description: Related column data content: application/json: schema: schema: $ref: "#/components/schemas/RelatedResponseSchema" 400: $ref: '#/components/responses/400' 401: $ref: '#/components/responses/401' 404: $ref: '#/components/responses/404' 500: $ref: '#/components/responses/500' """ if column_name not in self.allowed_rel_fields: self.incr_stats("error", self.related.__name__) return self.response_404() args = kwargs.get("rison", {}) # handle pagination page, page_size = self._handle_page_args(args) try: datamodel = self.datamodel.get_related_interface(column_name) except KeyError: return self.response_404() page, page_size = self._sanitize_page_args(page, page_size) # handle ordering order_field = self.order_rel_fields.get(column_name) if order_field: order_column, order_direction = order_field else: order_column, order_direction = "", "" # handle filters filters = self._get_related_filter(datamodel, column_name, args.get("filter")) # Make the query _, rows = datamodel.query( filters, order_column, order_direction, page=page, page_size=page_size ) # produce response result = self._get_result_from_rows(datamodel, rows, column_name) # If ids are specified make sure we fetch and include them on the response ids = args.get("include_ids") self._add_extra_ids_to_result(datamodel, column_name, ids, result) return self.response(200, count=len(result), result=result) @expose("/distinct/<column_name>", methods=["GET"]) @protect() @safe @statsd_metrics @rison(get_related_schema) def distinct(self, column_name: str, **kwargs: Any) -> FlaskResponse: """Get distinct values from field data --- get: parameters: - in: path schema: type: string name: column_name - in: query name: q content: application/json: schema: $ref: '#/components/schemas/get_related_schema' responses: 200: description: Distinct field data content: application/json: schema: schema: $ref: "#/components/schemas/DistincResponseSchema" 400: $ref: '#/components/responses/400' 401: $ref: '#/components/responses/401' 404: $ref: '#/components/responses/404' 500: $ref: '#/components/responses/500' """ if column_name not in self.allowed_distinct_fields: self.incr_stats("error", self.related.__name__) return self.response_404() args = kwargs.get("rison", {}) # handle pagination page, page_size = self._sanitize_page_args(*self._handle_page_args(args)) # Create generic base filters with added request filter filters = self._get_distinct_filter(column_name, args.get("filter")) # Make the query query_count = self.appbuilder.get_session.query( func.count(distinct(getattr(self.datamodel.obj, column_name))) ) count = self.datamodel.apply_filters(query_count, filters).scalar() if count == 0: return self.response(200, count=count, result=[]) query = self.appbuilder.get_session.query( distinct(getattr(self.datamodel.obj, column_name)) ) # Apply generic base filters with added request filter query = self.datamodel.apply_filters(query, filters) # Apply sort query = self.datamodel.apply_order_by(query, column_name, "asc") # Apply pagination result = self.datamodel.apply_pagination(query, page, page_size).all() # produce response result = [ {"text": item[0], "value": item[0]} for item in result if item[0] is not None ] return self.response(200, count=count, result=result)
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 646, 9143, 199, 646, 2050, 199, 504, 14090, 492, 6184, 12, 16975, 12, 9106, 12, 7448, 12, 3820, 12, 4879, 12, 2494, 12, 11634, 12, 2434, 12, 15961, 199, 199, 504, 2771, 374, 733, 492, 10319, 1311, 733, 199, 504, 2771, 374, 733, 14, 3924, 492, 23942, 7004, 985, 547, 199, 504, 7209, 492, 22447, 1361, 12, 486, 12, 7232, 199, 504, 7209, 63, 571, 5649, 492, 4693, 6437, 12, 5822, 12, 5822, 13726, 7394, 199, 504, 7209, 63, 571, 5649, 14, 1246, 492, 23705, 12, 25863, 12, 8012, 834, 12, 5048, 199, 504, 7209, 63, 571, 5649, 14, 992, 14, 4273, 492, 3523, 4131, 12, 21240, 199, 504, 7209, 63, 571, 5649, 14, 992, 14, 3526, 416, 14, 4273, 492, 9388, 32142, 3007, 199, 504, 7209, 63, 571, 5649, 14, 992, 14, 3526, 416, 14, 3266, 492, 5385, 33, 4267, 199, 504, 7209, 63, 66, 902, 492, 9617, 63, 5152, 465, 485, 199, 504, 7557, 609, 2174, 674, 492, 1504, 12, 13268, 199, 504, 8335, 492, 436, 3131, 15392, 12, 2562, 199, 504, 8335, 14, 1025, 14, 1131, 492, 8133, 199, 199, 504, 1613, 409, 14, 5359, 492, 1592, 12, 1566, 63, 2921, 12, 6391, 63, 2609, 199, 504, 1613, 409, 14, 992, 14, 1018, 492, 481, 1214, 23197, 199, 504, 1613, 409, 14, 992, 14, 9743, 492, 577, 1119, 3576, 199, 504, 1613, 409, 14, 992, 14, 5224, 492, 30823, 199, 504, 1613, 409, 14, 9482, 492, 1125, 63, 4749, 63, 1317, 199, 504, 1613, 409, 14, 3009, 63, 5561, 492, 8133, 465, 428, 81, 914, 371, 3227, 199, 504, 1613, 409, 14, 3200, 63, 2921, 492, 3523, 8257, 4455, 199, 504, 1613, 409, 14, 29747, 492, 16704, 2364, 199, 504, 1613, 409, 14, 1208, 14, 1018, 492, 900, 63, 1593, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 362, 63, 2407, 63, 3629, 275, 469, 272, 298, 466, 582, 298, 785, 401, 272, 298, 3282, 582, 469, 267, 298, 1606, 63, 890, 582, 2420, 466, 582, 298, 4115, 6018, 267, 298, 1606, 582, 2420, 466, 582, 298, 4115, 6018, 267, 298, 2613, 63, 1580, 582, 2420, 466, 582, 298, 1144, 401, 298, 1744, 582, 2420, 466, 582, 298, 4115, 3570, 1386, 267, 298, 1541, 582, 2420, 466, 582, 298, 875, 6018, 272, 1660, 199, 93, 421, 199, 533, 20116, 2889, 2364, 6700, 8, 6700, 304, 272, 574, 275, 1504, 14, 2674, 8, 1802, 628, 1918, 4048, 1242, 5148, 531, 272, 1318, 275, 1504, 14, 1558, 8, 1802, 628, 1918, 4048, 1242, 1059, 6025, 531, 421, 199, 533, 20116, 2364, 6700, 8, 6700, 304, 272, 2338, 275, 1504, 14, 2674, 8, 1802, 628, 1918, 3141, 1329, 402, 4048, 1338, 531, 272, 754, 275, 1504, 14, 1296, 8, 955, 14, 13029, 8, 13885, 2889, 2364, 6700, 430, 421, 199, 533, 10113, 8737, 2889, 2364, 6700, 8, 6700, 304, 272, 1318, 275, 1504, 14, 1558, 8, 1802, 628, 1918, 15392, 1242, 531, 421, 199, 533, 10113, 6559, 2364, 6700, 8, 6700, 304, 272, 2338, 275, 1504, 14, 2674, 8, 1802, 628, 1918, 3141, 1329, 402, 15392, 1338, 531, 272, 754, 275, 1504, 14, 1296, 8, 955, 14, 13029, 8, 12012, 8737, 2889, 2364, 6700, 430, 421, 199, 318, 5020, 68, 63, 6759, 8, 70, 26, 16975, 18999, 6184, 566, 1035, 16975, 18999, 6184, 2189, 272, 408, 272, 8690, 10209, 1006, 5020, 68, 7186, 687, 314, 14880, 3261, 272, 408, 339, 347, 14018, 8, 277, 26, 298, 1563, 11823, 409, 1685, 13726, 7394, 401, 627, 589, 26, 6184, 12, 1011, 958, 26, 6184, 9, 1035, 7232, 26, 267, 862, 26, 288, 7373, 12, 1177, 275, 900, 63, 1593, 8, 70, 12, 291, 12, 627, 589, 12, 1011, 958, 9, 267, 871, 2186, 465, 444, 26, 288, 291, 14, 19362, 63, 3200, 480, 705, 401, 289, 855, 354, 3368, 288, 746, 444, 398, 291, 14, 2254, 63, 3200, 63, 6759, 8, 1310, 12, 289, 855, 354, 3108, 7373, 9, 267, 372, 1177, 339, 372, 9143, 14, 873, 63, 5029, 8, 13582, 12, 289, 9, 421, 199, 533, 20116, 792, 4131, 26, 272, 327, 666, 1021, 370, 4165, 4052, 2457, 370, 675, 641, 282, 1182, 2407, 6037, 272, 327, 4287, 26, 3507, 29, 7354, 13, 70, 546, 13, 3455, 13, 2474, 272, 347, 636, 826, 721, 277, 12, 901, 63, 354, 26, 620, 12, 2457, 63, 533, 26, 2434, 59, 1563, 4131, 4682, 267, 291, 14, 698, 63, 354, 275, 901, 63, 354, 267, 291, 14, 1541, 63, 533, 275, 2457, 63, 533, 421, 199, 533, 3523, 24335, 1175, 4131, 8, 1563, 4131, 304, 221, 327, 4287, 26, 3507, 29, 7354, 13, 70, 546, 13, 3455, 13, 2474, 272, 408, 272, 3523, 8388, 2457, 367, 314, 9576, 769, 626, 4766, 1006, 11847, 19267, 12, 17184, 272, 626, 282, 922, 965, 289, 1214, 2908, 503, 440, 272, 408, 339, 536, 275, 3824, 1831, 17914, 1175, 531, 272, 1680, 63, 354, 275, 3087, 272, 1021, 63, 354, 275, 3087, 272, 408, 710, 481, 1214, 23197, 1021, 63, 354, 370, 922, 408, 272, 1402, 26, 2434, 59, 15540, 59, 30122, 12, 30823, 12, 428, 81, 914 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 646, 9143, 199, 646, 2050, 199, 504, 14090, 492, 6184, 12, 16975, 12, 9106, 12, 7448, 12, 3820, 12, 4879, 12, 2494, 12, 11634, 12, 2434, 12, 15961, 199, 199, 504, 2771, 374, 733, 492, 10319, 1311, 733, 199, 504, 2771, 374, 733, 14, 3924, 492, 23942, 7004, 985, 547, 199, 504, 7209, 492, 22447, 1361, 12, 486, 12, 7232, 199, 504, 7209, 63, 571, 5649, 492, 4693, 6437, 12, 5822, 12, 5822, 13726, 7394, 199, 504, 7209, 63, 571, 5649, 14, 1246, 492, 23705, 12, 25863, 12, 8012, 834, 12, 5048, 199, 504, 7209, 63, 571, 5649, 14, 992, 14, 4273, 492, 3523, 4131, 12, 21240, 199, 504, 7209, 63, 571, 5649, 14, 992, 14, 3526, 416, 14, 4273, 492, 9388, 32142, 3007, 199, 504, 7209, 63, 571, 5649, 14, 992, 14, 3526, 416, 14, 3266, 492, 5385, 33, 4267, 199, 504, 7209, 63, 66, 902, 492, 9617, 63, 5152, 465, 485, 199, 504, 7557, 609, 2174, 674, 492, 1504, 12, 13268, 199, 504, 8335, 492, 436, 3131, 15392, 12, 2562, 199, 504, 8335, 14, 1025, 14, 1131, 492, 8133, 199, 199, 504, 1613, 409, 14, 5359, 492, 1592, 12, 1566, 63, 2921, 12, 6391, 63, 2609, 199, 504, 1613, 409, 14, 992, 14, 1018, 492, 481, 1214, 23197, 199, 504, 1613, 409, 14, 992, 14, 9743, 492, 577, 1119, 3576, 199, 504, 1613, 409, 14, 992, 14, 5224, 492, 30823, 199, 504, 1613, 409, 14, 9482, 492, 1125, 63, 4749, 63, 1317, 199, 504, 1613, 409, 14, 3009, 63, 5561, 492, 8133, 465, 428, 81, 914, 371, 3227, 199, 504, 1613, 409, 14, 3200, 63, 2921, 492, 3523, 8257, 4455, 199, 504, 1613, 409, 14, 29747, 492, 16704, 2364, 199, 504, 1613, 409, 14, 1208, 14, 1018, 492, 900, 63, 1593, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 362, 63, 2407, 63, 3629, 275, 469, 272, 298, 466, 582, 298, 785, 401, 272, 298, 3282, 582, 469, 267, 298, 1606, 63, 890, 582, 2420, 466, 582, 298, 4115, 6018, 267, 298, 1606, 582, 2420, 466, 582, 298, 4115, 6018, 267, 298, 2613, 63, 1580, 582, 2420, 466, 582, 298, 1144, 401, 298, 1744, 582, 2420, 466, 582, 298, 4115, 3570, 1386, 267, 298, 1541, 582, 2420, 466, 582, 298, 875, 6018, 272, 1660, 199, 93, 421, 199, 533, 20116, 2889, 2364, 6700, 8, 6700, 304, 272, 574, 275, 1504, 14, 2674, 8, 1802, 628, 1918, 4048, 1242, 5148, 531, 272, 1318, 275, 1504, 14, 1558, 8, 1802, 628, 1918, 4048, 1242, 1059, 6025, 531, 421, 199, 533, 20116, 2364, 6700, 8, 6700, 304, 272, 2338, 275, 1504, 14, 2674, 8, 1802, 628, 1918, 3141, 1329, 402, 4048, 1338, 531, 272, 754, 275, 1504, 14, 1296, 8, 955, 14, 13029, 8, 13885, 2889, 2364, 6700, 430, 421, 199, 533, 10113, 8737, 2889, 2364, 6700, 8, 6700, 304, 272, 1318, 275, 1504, 14, 1558, 8, 1802, 628, 1918, 15392, 1242, 531, 421, 199, 533, 10113, 6559, 2364, 6700, 8, 6700, 304, 272, 2338, 275, 1504, 14, 2674, 8, 1802, 628, 1918, 3141, 1329, 402, 15392, 1338, 531, 272, 754, 275, 1504, 14, 1296, 8, 955, 14, 13029, 8, 12012, 8737, 2889, 2364, 6700, 430, 421, 199, 318, 5020, 68, 63, 6759, 8, 70, 26, 16975, 18999, 6184, 566, 1035, 16975, 18999, 6184, 2189, 272, 408, 272, 8690, 10209, 1006, 5020, 68, 7186, 687, 314, 14880, 3261, 272, 408, 339, 347, 14018, 8, 277, 26, 298, 1563, 11823, 409, 1685, 13726, 7394, 401, 627, 589, 26, 6184, 12, 1011, 958, 26, 6184, 9, 1035, 7232, 26, 267, 862, 26, 288, 7373, 12, 1177, 275, 900, 63, 1593, 8, 70, 12, 291, 12, 627, 589, 12, 1011, 958, 9, 267, 871, 2186, 465, 444, 26, 288, 291, 14, 19362, 63, 3200, 480, 705, 401, 289, 855, 354, 3368, 288, 746, 444, 398, 291, 14, 2254, 63, 3200, 63, 6759, 8, 1310, 12, 289, 855, 354, 3108, 7373, 9, 267, 372, 1177, 339, 372, 9143, 14, 873, 63, 5029, 8, 13582, 12, 289, 9, 421, 199, 533, 20116, 792, 4131, 26, 272, 327, 666, 1021, 370, 4165, 4052, 2457, 370, 675, 641, 282, 1182, 2407, 6037, 272, 327, 4287, 26, 3507, 29, 7354, 13, 70, 546, 13, 3455, 13, 2474, 272, 347, 636, 826, 721, 277, 12, 901, 63, 354, 26, 620, 12, 2457, 63, 533, 26, 2434, 59, 1563, 4131, 4682, 267, 291, 14, 698, 63, 354, 275, 901, 63, 354, 267, 291, 14, 1541, 63, 533, 275, 2457, 63, 533, 421, 199, 533, 3523, 24335, 1175, 4131, 8, 1563, 4131, 304, 221, 327, 4287, 26, 3507, 29, 7354, 13, 70, 546, 13, 3455, 13, 2474, 272, 408, 272, 3523, 8388, 2457, 367, 314, 9576, 769, 626, 4766, 1006, 11847, 19267, 12, 17184, 272, 626, 282, 922, 965, 289, 1214, 2908, 503, 440, 272, 408, 339, 536, 275, 3824, 1831, 17914, 1175, 531, 272, 1680, 63, 354, 275, 3087, 272, 1021, 63, 354, 275, 3087, 272, 408, 710, 481, 1214, 23197, 1021, 63, 354, 370, 922, 408, 272, 1402, 26, 2434, 59, 15540, 59, 30122, 12, 30823, 12, 428, 81, 914, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kustodian/ansible
test/units/modules/network/f5/test_bigip_smtp.py
22
4984
# -*- coding: utf-8 -*- # # Copyright: (c) 2017, F5 Networks Inc. # GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os import json import pytest import sys if sys.version_info < (2, 7): pytestmark = pytest.mark.skip("F5 Ansible modules require Python >= 2.7") from ansible.module_utils.basic import AnsibleModule try: from library.modules.bigip_smtp import ApiParameters from library.modules.bigip_smtp import ModuleParameters from library.modules.bigip_smtp import ModuleManager from library.modules.bigip_smtp import ArgumentSpec # In Ansible 2.8, Ansible changed import paths. from test.units.compat import unittest from test.units.compat.mock import Mock from test.units.modules.utils import set_module_args except ImportError: from ansible.modules.network.f5.bigip_smtp import ApiParameters from ansible.modules.network.f5.bigip_smtp import ModuleParameters from ansible.modules.network.f5.bigip_smtp import ModuleManager from ansible.modules.network.f5.bigip_smtp import ArgumentSpec # Ansible 2.8 imports from units.compat import unittest from units.compat.mock import Mock from units.modules.utils import set_module_args fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') fixture_data = {} def load_fixture(name): path = os.path.join(fixture_path, name) if path in fixture_data: return fixture_data[path] with open(path) as f: data = f.read() try: data = json.loads(data) except Exception: pass fixture_data[path] = data return data class TestParameters(unittest.TestCase): def test_module_parameters(self): args = dict( name='foo', smtp_server='1.1.1.1', smtp_server_port='25', smtp_server_username='admin', smtp_server_password='password', local_host_name='smtp.mydomain.com', encryption='tls', update_password='always', from_address='no-reply@mydomain.com', authentication=True, ) p = ModuleParameters(params=args) assert p.name == 'foo' assert p.smtp_server == '1.1.1.1' assert p.smtp_server_port == 25 assert p.smtp_server_username == 'admin' assert p.smtp_server_password == 'password' assert p.local_host_name == 'smtp.mydomain.com' assert p.encryption == 'tls' assert p.update_password == 'always' assert p.from_address == 'no-reply@mydomain.com' assert p.authentication_disabled is None assert p.authentication_enabled is True def test_api_parameters(self): p = ApiParameters(params=load_fixture('load_sys_smtp_server.json')) assert p.name == 'foo' assert p.smtp_server == 'mail.foo.bar' assert p.smtp_server_port == 465 assert p.smtp_server_username == 'admin' assert p.smtp_server_password == '$M$Ch$this-is-encrypted==' assert p.local_host_name == 'mail-host.foo.bar' assert p.encryption == 'ssl' assert p.from_address == 'no-reply@foo.bar' assert p.authentication_disabled is None assert p.authentication_enabled is True class TestManager(unittest.TestCase): def setUp(self): self.spec = ArgumentSpec() def test_create_monitor(self, *args): set_module_args(dict( name='foo', smtp_server='1.1.1.1', smtp_server_port='25', smtp_server_username='admin', smtp_server_password='password', local_host_name='smtp.mydomain.com', encryption='tls', update_password='always', from_address='no-reply@mydomain.com', authentication=True, partition='Common', provider=dict( server='localhost', password='password', user='admin' ) )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(side_effect=[False, True]) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['encryption'] == 'tls' assert results['smtp_server'] == '1.1.1.1' assert results['smtp_server_port'] == 25 assert results['local_host_name'] == 'smtp.mydomain.com' assert results['authentication'] is True assert results['from_address'] == 'no-reply@mydomain.com' assert 'smtp_server_username' not in results assert 'smtp_server_password' not in results
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 481, 21, 17138, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 2022, 199, 646, 4613, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 1520, 304, 272, 4613, 1657, 275, 4613, 14, 1657, 14, 2759, 480, 38, 21, 2622, 4621, 4409, 2018, 2356, 499, 14, 23, 531, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 199, 893, 26, 272, 687, 3555, 14, 3112, 14, 17833, 63, 15592, 492, 31145, 272, 687, 3555, 14, 3112, 14, 17833, 63, 15592, 492, 5673, 5976, 272, 687, 3555, 14, 3112, 14, 17833, 63, 15592, 492, 24118, 272, 687, 3555, 14, 3112, 14, 17833, 63, 15592, 492, 28405, 339, 327, 1010, 2622, 499, 14, 24, 12, 2622, 2896, 492, 3792, 14, 272, 687, 511, 14, 5260, 14, 5819, 492, 2882, 272, 687, 511, 14, 5260, 14, 5819, 14, 1805, 492, 4420, 339, 687, 511, 14, 5260, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 199, 2590, 3545, 26, 272, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 15592, 492, 31145, 272, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 15592, 492, 5673, 5976, 272, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 15592, 492, 24118, 272, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 15592, 492, 28405, 339, 327, 2622, 499, 14, 24, 8925, 272, 687, 6204, 14, 5819, 492, 2882, 272, 687, 6204, 14, 5819, 14, 1805, 492, 4420, 339, 687, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 421, 199, 5997, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 199, 5997, 63, 576, 275, 1052, 421, 199, 318, 2248, 63, 5997, 8, 354, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 5997, 63, 515, 12, 536, 9, 339, 340, 931, 315, 10949, 63, 576, 26, 267, 372, 10949, 63, 576, 59, 515, 61, 339, 543, 1551, 8, 515, 9, 465, 289, 26, 267, 666, 275, 289, 14, 739, 342, 339, 862, 26, 267, 666, 275, 2022, 14, 3640, 8, 576, 9, 272, 871, 2186, 26, 267, 986, 339, 10949, 63, 576, 59, 515, 61, 275, 666, 272, 372, 666, 421, 199, 533, 1379, 5976, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 578, 63, 3214, 8, 277, 304, 267, 1249, 275, 1211, 8, 288, 536, 534, 1421, 297, 288, 14400, 63, 1000, 534, 17, 14, 17, 14, 17, 14, 17, 297, 288, 14400, 63, 1000, 63, 719, 534, 821, 297, 288, 14400, 63, 1000, 63, 2473, 534, 2113, 297, 288, 14400, 63, 1000, 63, 2060, 534, 2060, 297, 288, 2257, 63, 1102, 63, 354, 534, 15592, 14, 30945, 14, 957, 297, 288, 14396, 534, 9945, 297, 288, 1678, 63, 2060, 534, 9223, 297, 288, 687, 63, 1562, 534, 889, 13, 8102, 32, 30945, 14, 957, 297, 288, 6299, 29, 549, 12, 267, 776, 398, 299, 275, 5673, 5976, 8, 1162, 29, 589, 9, 267, 702, 299, 14, 354, 508, 283, 1421, 7, 267, 702, 299, 14, 15592, 63, 1000, 508, 283, 17, 14, 17, 14, 17, 14, 17, 7, 267, 702, 299, 14, 15592, 63, 1000, 63, 719, 508, 5661, 267, 702, 299, 14, 15592, 63, 1000, 63, 2473, 508, 283, 2113, 7, 267, 702, 299, 14, 15592, 63, 1000, 63, 2060, 508, 283, 2060, 7, 267, 702, 299, 14, 1832, 63, 1102, 63, 354, 508, 283, 15592, 14, 30945, 14, 957, 7, 267, 702, 299, 14, 15113, 508, 283, 9945, 7, 267, 702, 299, 14, 873, 63, 2060, 508, 283, 9223, 7, 267, 702, 299, 14, 504, 63, 1562, 508, 283, 889, 13, 8102, 32, 30945, 14, 957, 7, 267, 702, 299, 14, 11725, 63, 7011, 365, 488, 267, 702, 299, 14, 11725, 63, 3827, 365, 715, 339, 347, 511, 63, 1246, 63, 3214, 8, 277, 304, 267, 299, 275, 31145, 8, 1162, 29, 912, 63, 5997, 360, 912, 63, 1274, 63, 15592, 63, 1000, 14, 1001, 1333, 267, 702, 299, 14, 354, 508, 283, 1421, 7, 267, 702, 299, 14, 15592, 63, 1000, 508, 283, 1198, 14, 1421, 14, 1700, 7, 267, 702, 299, 14, 15592, 63, 1000, 63, 719, 508, 841, 2182, 267, 702, 299, 14, 15592, 63, 1000, 63, 2473, 508, 283, 2113, 7, 267, 702, 299, 14, 15592, 63, 1000, 63, 2060, 508, 4505, 45, 4, 1049, 4, 3749, 13, 374, 13, 15078, 6803, 267, 702, 299, 14, 1832, 63, 1102, 63, 354, 508, 283, 1198, 13, 1102, 14, 1421, 14, 1700, 7, 267, 702, 299, 14, 15113, 508, 283, 4266, 7, 267, 702, 299, 14, 504, 63, 1562, 508, 283, 889, 13, 8102, 32, 1421, 14, 1700, 7, 267, 702, 299, 14, 11725, 63, 7011, 365, 488, 267, 702, 299, 14, 11725, 63, 3827, 365, 715, 421, 199, 533, 1379, 2988, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1650, 275, 28405, 342, 339, 347, 511, 63, 981, 63, 7157, 8, 277, 12, 627, 589, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 536, 534, 1421, 297, 288, 14400, 63, 1000, 534, 17, 14, 17, 14, 17, 14, 17, 297, 288, 14400, 63, 1000, 63, 719, 534, 821, 297, 288, 14400, 63, 1000, 63, 2473, 534, 2113, 297, 288, 14400, 63, 1000, 63, 2060, 534, 2060, 297, 288, 2257, 63, 1102, 63, 354, 534, 15592, 14, 30945, 14, 957, 297, 288, 14396, 534, 9945, 297, 288, 1678, 63, 2060, 534, 9223, 297, 288, 687, 63, 1562, 534, 889, 13, 8102, 32, 30945, 14, 957, 297, 288, 6299, 29, 549, 12, 288, 6484, 534, 7844, 297, 288, 5022, 29, 807, 8 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 481, 21, 17138, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 2022, 199, 646, 4613, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 1520, 304, 272, 4613, 1657, 275, 4613, 14, 1657, 14, 2759, 480, 38, 21, 2622, 4621, 4409, 2018, 2356, 499, 14, 23, 531, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 199, 893, 26, 272, 687, 3555, 14, 3112, 14, 17833, 63, 15592, 492, 31145, 272, 687, 3555, 14, 3112, 14, 17833, 63, 15592, 492, 5673, 5976, 272, 687, 3555, 14, 3112, 14, 17833, 63, 15592, 492, 24118, 272, 687, 3555, 14, 3112, 14, 17833, 63, 15592, 492, 28405, 339, 327, 1010, 2622, 499, 14, 24, 12, 2622, 2896, 492, 3792, 14, 272, 687, 511, 14, 5260, 14, 5819, 492, 2882, 272, 687, 511, 14, 5260, 14, 5819, 14, 1805, 492, 4420, 339, 687, 511, 14, 5260, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 199, 2590, 3545, 26, 272, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 15592, 492, 31145, 272, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 15592, 492, 5673, 5976, 272, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 15592, 492, 24118, 272, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 15592, 492, 28405, 339, 327, 2622, 499, 14, 24, 8925, 272, 687, 6204, 14, 5819, 492, 2882, 272, 687, 6204, 14, 5819, 14, 1805, 492, 4420, 339, 687, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 421, 199, 5997, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 199, 5997, 63, 576, 275, 1052, 421, 199, 318, 2248, 63, 5997, 8, 354, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 5997, 63, 515, 12, 536, 9, 339, 340, 931, 315, 10949, 63, 576, 26, 267, 372, 10949, 63, 576, 59, 515, 61, 339, 543, 1551, 8, 515, 9, 465, 289, 26, 267, 666, 275, 289, 14, 739, 342, 339, 862, 26, 267, 666, 275, 2022, 14, 3640, 8, 576, 9, 272, 871, 2186, 26, 267, 986, 339, 10949, 63, 576, 59, 515, 61, 275, 666, 272, 372, 666, 421, 199, 533, 1379, 5976, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 578, 63, 3214, 8, 277, 304, 267, 1249, 275, 1211, 8, 288, 536, 534, 1421, 297, 288, 14400, 63, 1000, 534, 17, 14, 17, 14, 17, 14, 17, 297, 288, 14400, 63, 1000, 63, 719, 534, 821, 297, 288, 14400, 63, 1000, 63, 2473, 534, 2113, 297, 288, 14400, 63, 1000, 63, 2060, 534, 2060, 297, 288, 2257, 63, 1102, 63, 354, 534, 15592, 14, 30945, 14, 957, 297, 288, 14396, 534, 9945, 297, 288, 1678, 63, 2060, 534, 9223, 297, 288, 687, 63, 1562, 534, 889, 13, 8102, 32, 30945, 14, 957, 297, 288, 6299, 29, 549, 12, 267, 776, 398, 299, 275, 5673, 5976, 8, 1162, 29, 589, 9, 267, 702, 299, 14, 354, 508, 283, 1421, 7, 267, 702, 299, 14, 15592, 63, 1000, 508, 283, 17, 14, 17, 14, 17, 14, 17, 7, 267, 702, 299, 14, 15592, 63, 1000, 63, 719, 508, 5661, 267, 702, 299, 14, 15592, 63, 1000, 63, 2473, 508, 283, 2113, 7, 267, 702, 299, 14, 15592, 63, 1000, 63, 2060, 508, 283, 2060, 7, 267, 702, 299, 14, 1832, 63, 1102, 63, 354, 508, 283, 15592, 14, 30945, 14, 957, 7, 267, 702, 299, 14, 15113, 508, 283, 9945, 7, 267, 702, 299, 14, 873, 63, 2060, 508, 283, 9223, 7, 267, 702, 299, 14, 504, 63, 1562, 508, 283, 889, 13, 8102, 32, 30945, 14, 957, 7, 267, 702, 299, 14, 11725, 63, 7011, 365, 488, 267, 702, 299, 14, 11725, 63, 3827, 365, 715, 339, 347, 511, 63, 1246, 63, 3214, 8, 277, 304, 267, 299, 275, 31145, 8, 1162, 29, 912, 63, 5997, 360, 912, 63, 1274, 63, 15592, 63, 1000, 14, 1001, 1333, 267, 702, 299, 14, 354, 508, 283, 1421, 7, 267, 702, 299, 14, 15592, 63, 1000, 508, 283, 1198, 14, 1421, 14, 1700, 7, 267, 702, 299, 14, 15592, 63, 1000, 63, 719, 508, 841, 2182, 267, 702, 299, 14, 15592, 63, 1000, 63, 2473, 508, 283, 2113, 7, 267, 702, 299, 14, 15592, 63, 1000, 63, 2060, 508, 4505, 45, 4, 1049, 4, 3749, 13, 374, 13, 15078, 6803, 267, 702, 299, 14, 1832, 63, 1102, 63, 354, 508, 283, 1198, 13, 1102, 14, 1421, 14, 1700, 7, 267, 702, 299, 14, 15113, 508, 283, 4266, 7, 267, 702, 299, 14, 504, 63, 1562, 508, 283, 889, 13, 8102, 32, 1421, 14, 1700, 7, 267, 702, 299, 14, 11725, 63, 7011, 365, 488, 267, 702, 299, 14, 11725, 63, 3827, 365, 715, 421, 199, 533, 1379, 2988, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1650, 275, 28405, 342, 339, 347, 511, 63, 981, 63, 7157, 8, 277, 12, 627, 589, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 536, 534, 1421, 297, 288, 14400, 63, 1000, 534, 17, 14, 17, 14, 17, 14, 17, 297, 288, 14400, 63, 1000, 63, 719, 534, 821, 297, 288, 14400, 63, 1000, 63, 2473, 534, 2113, 297, 288, 14400, 63, 1000, 63, 2060, 534, 2060, 297, 288, 2257, 63, 1102, 63, 354, 534, 15592, 14, 30945, 14, 957, 297, 288, 14396, 534, 9945, 297, 288, 1678, 63, 2060, 534, 9223, 297, 288, 687, 63, 1562, 534, 889, 13, 8102, 32, 30945, 14, 957, 297, 288, 6299, 29, 549, 12, 288, 6484, 534, 7844, 297, 288, 5022, 29, 807, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
nzavagli/UnrealPy
UnrealPyEmbed/Development/Python/2015.08.07-Python2710-x64-Source-vs2015/Python27/Source/Jinja2-2.7.3/docs/jinjaext.py
17
6953
# -*- coding: utf-8 -*- """ Jinja Documentation Extensions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for automatically documenting filters and tests. :copyright: Copyright 2008 by Armin Ronacher. :license: BSD. """ import collections import os import re import inspect import jinja2 from itertools import islice from types import BuiltinFunctionType from docutils import nodes from docutils.statemachine import ViewList from sphinx.ext.autodoc import prepare_docstring from sphinx.application import TemplateBridge from pygments.style import Style from pygments.token import Keyword, Name, Comment, String, Error, \ Number, Operator, Generic from jinja2 import Environment, FileSystemLoader from jinja2.utils import next def parse_rst(state, content_offset, doc): node = nodes.section() # hack around title style bookkeeping surrounding_title_styles = state.memo.title_styles surrounding_section_level = state.memo.section_level state.memo.title_styles = [] state.memo.section_level = 0 state.nested_parse(doc, content_offset, node, match_titles=1) state.memo.title_styles = surrounding_title_styles state.memo.section_level = surrounding_section_level return node.children class JinjaStyle(Style): title = 'Jinja Style' default_style = "" styles = { Comment: 'italic #aaaaaa', Comment.Preproc: 'noitalic #B11414', Comment.Special: 'italic #505050', Keyword: 'bold #B80000', Keyword.Type: '#808080', Operator.Word: 'bold #B80000', Name.Builtin: '#333333', Name.Function: '#333333', Name.Class: 'bold #333333', Name.Namespace: 'bold #333333', Name.Entity: 'bold #363636', Name.Attribute: '#686868', Name.Tag: 'bold #686868', Name.Decorator: '#686868', String: '#AA891C', Number: '#444444', Generic.Heading: 'bold #000080', Generic.Subheading: 'bold #800080', Generic.Deleted: '#aa0000', Generic.Inserted: '#00aa00', Generic.Error: '#aa0000', Generic.Emph: 'italic', Generic.Strong: 'bold', Generic.Prompt: '#555555', Generic.Output: '#888888', Generic.Traceback: '#aa0000', Error: '#F00 bg:#FAA' } _sig_re = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*(\(.*?\))') def format_function(name, aliases, func): lines = inspect.getdoc(func).splitlines() signature = '()' if isinstance(func, BuiltinFunctionType): match = _sig_re.match(lines[0]) if match is not None: del lines[:1 + bool(lines and not lines[0])] signature = match.group(1) else: try: argspec = inspect.getargspec(func) if getattr(func, 'environmentfilter', False) or \ getattr(func, 'contextfilter', False) or \ getattr(func, 'evalcontextfilter', False): del argspec[0][0] signature = inspect.formatargspec(*argspec) except: pass result = ['.. function:: %s%s' % (name, signature), ''] result.extend(' ' + line for line in lines) if aliases: result.extend(('', ' :aliases: %s' % ', '.join( '``%s``' % x for x in sorted(aliases)))) return result def dump_functions(mapping): def directive(dirname, arguments, options, content, lineno, content_offset, block_text, state, state_machine): reverse_mapping = {} for name, func in mapping.items(): reverse_mapping.setdefault(func, []).append(name) filters = [] for func, names in reverse_mapping.items(): aliases = sorted(names, key=lambda x: len(x)) name = aliases.pop() filters.append((name, aliases, func)) filters.sort() result = ViewList() for name, aliases, func in filters: for item in format_function(name, aliases, func): result.append(item, '<jinjaext>') node = nodes.paragraph() state.nested_parse(result, content_offset, node) return node.children return directive from jinja2.defaults import DEFAULT_FILTERS, DEFAULT_TESTS jinja_filters = dump_functions(DEFAULT_FILTERS) jinja_tests = dump_functions(DEFAULT_TESTS) def jinja_nodes(dirname, arguments, options, content, lineno, content_offset, block_text, state, state_machine): from jinja2.nodes import Node doc = ViewList() def walk(node, indent): p = ' ' * indent sig = ', '.join(node.fields) doc.append(p + '.. autoclass:: %s(%s)' % (node.__name__, sig), '') if node.abstract: members = [] for key, name in node.__dict__.items(): if not key.startswith('_') and \ not hasattr(node.__base__, key) and isinstance(name, collections.Callable): members.append(key) if members: members.sort() doc.append('%s :members: %s' % (p, ', '.join(members)), '') if node.__base__ != object: doc.append('', '') doc.append('%s :Node type: :class:`%s`' % (p, node.__base__.__name__), '') doc.append('', '') children = node.__subclasses__() children.sort(key=lambda x: x.__name__.lower()) for child in children: walk(child, indent) walk(Node, 0) return parse_rst(state, content_offset, doc) def inject_toc(app, doctree, docname): titleiter = iter(doctree.traverse(nodes.title)) try: # skip first title, we are not interested in that one next(titleiter) title = next(titleiter) # and check if there is at least another title next(titleiter) except StopIteration: return tocnode = nodes.section('') tocnode['classes'].append('toc') toctitle = nodes.section('') toctitle['classes'].append('toctitle') toctitle.append(nodes.title(text='Table Of Contents')) tocnode.append(toctitle) tocnode += doctree.document.settings.env.get_toc_for(docname)[0][1] title.parent.insert(title.parent.children.index(title), tocnode) def setup(app): app.add_directive('jinjafilters', jinja_filters, 0, (0, 0, 0)) app.add_directive('jinjatests', jinja_tests, 0, (0, 0, 0)) app.add_directive('jinjanodes', jinja_nodes, 0, (0, 0, 0)) # uncomment for inline toc. links are broken unfortunately ##app.connect('doctree-resolved', inject_toc)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 17300, 15249, 11524, 1356, 272, 18294, 22935, 1714, 339, 12502, 367, 5847, 29904, 4766, 436, 2295, 14, 339, 520, 7307, 26, 1898, 9079, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 646, 5055, 199, 646, 747, 199, 646, 295, 199, 646, 6485, 199, 646, 10321, 18, 199, 504, 7975, 492, 365, 3037, 199, 504, 2943, 492, 22422, 26371, 199, 504, 18382, 492, 3380, 199, 504, 18382, 14, 929, 6744, 492, 10935, 1296, 199, 504, 15882, 14, 832, 14, 28056, 492, 9275, 63, 12485, 199, 504, 15882, 14, 3578, 492, 5458, 14491, 199, 504, 13277, 14, 2487, 492, 19442, 199, 504, 13277, 14, 1418, 492, 6431, 12, 2812, 12, 6819, 12, 2624, 12, 4520, 12, 971, 1362, 4860, 12, 11013, 12, 8307, 199, 504, 10321, 18, 492, 9711, 12, 23754, 5455, 199, 504, 10321, 18, 14, 1208, 492, 2163, 421, 199, 318, 2198, 63, 8332, 8, 929, 12, 1564, 63, 2743, 12, 1382, 304, 272, 1031, 275, 3380, 14, 2792, 342, 272, 327, 11176, 6818, 2538, 3449, 6719, 3250, 316, 272, 6296, 15326, 63, 1213, 63, 12955, 275, 1174, 14, 11979, 14, 1213, 63, 12955, 272, 6296, 15326, 63, 2792, 63, 1896, 275, 1174, 14, 11979, 14, 2792, 63, 1896, 272, 1174, 14, 11979, 14, 1213, 63, 12955, 275, 942, 272, 1174, 14, 11979, 14, 2792, 63, 1896, 275, 378, 272, 1174, 14, 6376, 63, 1122, 8, 1301, 12, 1564, 63, 2743, 12, 1031, 12, 1336, 63, 8916, 29, 17, 9, 272, 1174, 14, 11979, 14, 1213, 63, 12955, 275, 6296, 15326, 63, 1213, 63, 12955, 272, 1174, 14, 11979, 14, 2792, 63, 1896, 275, 6296, 15326, 63, 2792, 63, 1896, 272, 372, 1031, 14, 3223, 421, 199, 533, 17300, 6609, 8, 6609, 304, 272, 2538, 275, 283, 42, 4135, 19442, 7, 272, 849, 63, 2487, 275, 3087, 272, 15725, 275, 469, 267, 6819, 26, 8540, 283, 21843, 327, 6000, 2158, 297, 267, 6819, 14, 19285, 26, 3322, 283, 889, 21843, 327, 34, 7636, 1079, 297, 267, 6819, 14, 12246, 26, 3322, 283, 21843, 327, 1400, 1400, 1400, 297, 398, 6431, 26, 8540, 283, 9771, 327, 34, 24, 993, 297, 267, 6431, 14, 804, 26, 5185, 3943, 15844, 1257, 297, 398, 11013, 14, 10155, 26, 4519, 283, 9771, 327, 34, 24, 993, 297, 398, 2812, 14, 12306, 26, 5185, 3943, 28380, 297, 267, 2812, 14, 3481, 26, 4519, 3943, 28380, 297, 267, 2812, 14, 2543, 26, 463, 283, 9771, 327, 28380, 297, 267, 2812, 14, 8814, 26, 3777, 283, 9771, 327, 28380, 297, 267, 2812, 14, 7302, 26, 4483, 283, 9771, 327, 1344, 1344, 1344, 297, 267, 2812, 14, 1646, 26, 3777, 3943, 10253, 15430, 297, 267, 2812, 14, 1931, 26, 7861, 283, 9771, 327, 10253, 15430, 297, 267, 2812, 14, 14946, 26, 3777, 3943, 10253, 15430, 297, 398, 2624, 26, 9326, 3943, 2276, 15601, 35, 297, 267, 4860, 26, 9326, 3943, 22872, 1602, 297, 398, 8307, 14, 23818, 26, 3322, 283, 9771, 327, 993, 1257, 297, 267, 8307, 14, 2610, 13983, 26, 260, 283, 9771, 327, 15214, 1257, 297, 267, 8307, 14, 17735, 26, 3322, 3943, 2158, 993, 297, 267, 8307, 14, 607, 9449, 26, 3698, 3943, 383, 2158, 383, 297, 267, 8307, 14, 547, 26, 4519, 3943, 2158, 993, 297, 267, 8307, 14, 37, 311, 72, 26, 5185, 283, 21843, 297, 267, 8307, 14, 2848, 951, 26, 3777, 283, 9771, 297, 267, 8307, 14, 20430, 26, 3777, 3943, 19161, 1229, 297, 267, 8307, 14, 2959, 26, 3777, 3943, 14871, 1299, 297, 267, 8307, 14, 15905, 26, 3515, 3943, 2158, 993, 297, 398, 4520, 26, 10473, 3943, 38, 383, 12994, 15596, 2078, 33, 7, 272, 789, 421, 199, 63, 4093, 63, 264, 275, 295, 14, 2014, 8, 82, 23811, 65, 13, 6353, 13, 58, 17900, 65, 13, 6353, 13, 58, 16, 13, 25, 15555, 2961, 17140, 60, 28435, 421, 199, 318, 1475, 63, 1593, 8, 354, 12, 5481, 12, 2562, 304, 272, 2385, 275, 6485, 14, 362, 1301, 8, 1532, 680, 7644, 342, 272, 4955, 275, 26380, 272, 340, 1228, 8, 1532, 12, 22422, 26371, 304, 267, 1336, 275, 485, 4093, 63, 264, 14, 1431, 8, 1278, 59, 16, 566, 267, 340, 1336, 365, 440, 488, 26, 288, 2150, 2385, 1491, 17, 435, 2155, 8, 1278, 436, 440, 2385, 59, 16, 12457, 288, 4955, 275, 1336, 14, 923, 8, 17, 9, 272, 587, 26, 267, 862, 26, 288, 26632, 275, 6485, 14, 29836, 8, 1532, 9, 288, 340, 2519, 8, 1532, 12, 283, 5418, 1541, 297, 756, 9, 503, 971, 2049, 2519, 8, 1532, 12, 283, 1100, 1541, 297, 756, 9, 503, 971, 2049, 2519, 8, 1532, 12, 283, 2579, 1100, 1541, 297, 756, 304, 355, 2150, 26632, 59, 16, 1527, 16, 61, 288, 4955, 275, 6485, 14, 908, 15644, 2031, 15644, 9, 267, 871, 26, 288, 986, 272, 754, 275, 788, 703, 805, 447, 450, 83, 5, 83, 7, 450, 334, 354, 12, 4955, 395, 28696, 272, 754, 14, 2880, 360, 259, 283, 435, 1004, 367, 1004, 315, 2385, 9, 272, 340, 5481, 26, 267, 754, 14, 2880, 4725, 297, 283, 259, 520, 8602, 26, 450, 83, 7, 450, 1656, 1987, 904, 8, 1993, 283, 1040, 5, 83, 1040, 7, 450, 671, 367, 671, 315, 3355, 8, 8602, 7845, 272, 372, 754, 421, 199, 318, 5461, 63, 5777, 8, 4745, 304, 272, 347, 13613, 8, 3475, 12, 2368, 12, 1511, 12, 1564, 12, 5874, 12, 1993, 1564, 63, 2743, 12, 1853, 63, 505, 12, 1174, 12, 1174, 63, 6744, 304, 267, 3837, 63, 4745, 275, 1052, 267, 367, 536, 12, 2562, 315, 4412, 14, 1744, 837, 288, 3837, 63, 4745, 14, 5486, 8, 1532, 12, 15364, 740, 8, 354, 9, 267, 4766, 275, 942, 267, 367, 2562, 12, 1561, 315, 3837, 63, 4745, 14, 1744, 837, 288, 5481, 275, 3355, 8, 1247, 12, 790, 29, 2734, 671, 26, 822, 8, 88, 430, 288, 536, 275, 5481, 14, 1935, 342, 288, 4766, 14, 740, 1332, 354, 12, 5481, 12, 2562, 430, 267, 4766, 14, 3191, 342, 398, 754, 275, 10935, 1296, 342, 267, 367, 536, 12, 5481, 12, 2562, 315, 4766, 26, 288, 367, 1242, 315 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 17300, 15249, 11524, 1356, 272, 18294, 22935, 1714, 339, 12502, 367, 5847, 29904, 4766, 436, 2295, 14, 339, 520, 7307, 26, 1898, 9079, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 646, 5055, 199, 646, 747, 199, 646, 295, 199, 646, 6485, 199, 646, 10321, 18, 199, 504, 7975, 492, 365, 3037, 199, 504, 2943, 492, 22422, 26371, 199, 504, 18382, 492, 3380, 199, 504, 18382, 14, 929, 6744, 492, 10935, 1296, 199, 504, 15882, 14, 832, 14, 28056, 492, 9275, 63, 12485, 199, 504, 15882, 14, 3578, 492, 5458, 14491, 199, 504, 13277, 14, 2487, 492, 19442, 199, 504, 13277, 14, 1418, 492, 6431, 12, 2812, 12, 6819, 12, 2624, 12, 4520, 12, 971, 1362, 4860, 12, 11013, 12, 8307, 199, 504, 10321, 18, 492, 9711, 12, 23754, 5455, 199, 504, 10321, 18, 14, 1208, 492, 2163, 421, 199, 318, 2198, 63, 8332, 8, 929, 12, 1564, 63, 2743, 12, 1382, 304, 272, 1031, 275, 3380, 14, 2792, 342, 272, 327, 11176, 6818, 2538, 3449, 6719, 3250, 316, 272, 6296, 15326, 63, 1213, 63, 12955, 275, 1174, 14, 11979, 14, 1213, 63, 12955, 272, 6296, 15326, 63, 2792, 63, 1896, 275, 1174, 14, 11979, 14, 2792, 63, 1896, 272, 1174, 14, 11979, 14, 1213, 63, 12955, 275, 942, 272, 1174, 14, 11979, 14, 2792, 63, 1896, 275, 378, 272, 1174, 14, 6376, 63, 1122, 8, 1301, 12, 1564, 63, 2743, 12, 1031, 12, 1336, 63, 8916, 29, 17, 9, 272, 1174, 14, 11979, 14, 1213, 63, 12955, 275, 6296, 15326, 63, 1213, 63, 12955, 272, 1174, 14, 11979, 14, 2792, 63, 1896, 275, 6296, 15326, 63, 2792, 63, 1896, 272, 372, 1031, 14, 3223, 421, 199, 533, 17300, 6609, 8, 6609, 304, 272, 2538, 275, 283, 42, 4135, 19442, 7, 272, 849, 63, 2487, 275, 3087, 272, 15725, 275, 469, 267, 6819, 26, 8540, 283, 21843, 327, 6000, 2158, 297, 267, 6819, 14, 19285, 26, 3322, 283, 889, 21843, 327, 34, 7636, 1079, 297, 267, 6819, 14, 12246, 26, 3322, 283, 21843, 327, 1400, 1400, 1400, 297, 398, 6431, 26, 8540, 283, 9771, 327, 34, 24, 993, 297, 267, 6431, 14, 804, 26, 5185, 3943, 15844, 1257, 297, 398, 11013, 14, 10155, 26, 4519, 283, 9771, 327, 34, 24, 993, 297, 398, 2812, 14, 12306, 26, 5185, 3943, 28380, 297, 267, 2812, 14, 3481, 26, 4519, 3943, 28380, 297, 267, 2812, 14, 2543, 26, 463, 283, 9771, 327, 28380, 297, 267, 2812, 14, 8814, 26, 3777, 283, 9771, 327, 28380, 297, 267, 2812, 14, 7302, 26, 4483, 283, 9771, 327, 1344, 1344, 1344, 297, 267, 2812, 14, 1646, 26, 3777, 3943, 10253, 15430, 297, 267, 2812, 14, 1931, 26, 7861, 283, 9771, 327, 10253, 15430, 297, 267, 2812, 14, 14946, 26, 3777, 3943, 10253, 15430, 297, 398, 2624, 26, 9326, 3943, 2276, 15601, 35, 297, 267, 4860, 26, 9326, 3943, 22872, 1602, 297, 398, 8307, 14, 23818, 26, 3322, 283, 9771, 327, 993, 1257, 297, 267, 8307, 14, 2610, 13983, 26, 260, 283, 9771, 327, 15214, 1257, 297, 267, 8307, 14, 17735, 26, 3322, 3943, 2158, 993, 297, 267, 8307, 14, 607, 9449, 26, 3698, 3943, 383, 2158, 383, 297, 267, 8307, 14, 547, 26, 4519, 3943, 2158, 993, 297, 267, 8307, 14, 37, 311, 72, 26, 5185, 283, 21843, 297, 267, 8307, 14, 2848, 951, 26, 3777, 283, 9771, 297, 267, 8307, 14, 20430, 26, 3777, 3943, 19161, 1229, 297, 267, 8307, 14, 2959, 26, 3777, 3943, 14871, 1299, 297, 267, 8307, 14, 15905, 26, 3515, 3943, 2158, 993, 297, 398, 4520, 26, 10473, 3943, 38, 383, 12994, 15596, 2078, 33, 7, 272, 789, 421, 199, 63, 4093, 63, 264, 275, 295, 14, 2014, 8, 82, 23811, 65, 13, 6353, 13, 58, 17900, 65, 13, 6353, 13, 58, 16, 13, 25, 15555, 2961, 17140, 60, 28435, 421, 199, 318, 1475, 63, 1593, 8, 354, 12, 5481, 12, 2562, 304, 272, 2385, 275, 6485, 14, 362, 1301, 8, 1532, 680, 7644, 342, 272, 4955, 275, 26380, 272, 340, 1228, 8, 1532, 12, 22422, 26371, 304, 267, 1336, 275, 485, 4093, 63, 264, 14, 1431, 8, 1278, 59, 16, 566, 267, 340, 1336, 365, 440, 488, 26, 288, 2150, 2385, 1491, 17, 435, 2155, 8, 1278, 436, 440, 2385, 59, 16, 12457, 288, 4955, 275, 1336, 14, 923, 8, 17, 9, 272, 587, 26, 267, 862, 26, 288, 26632, 275, 6485, 14, 29836, 8, 1532, 9, 288, 340, 2519, 8, 1532, 12, 283, 5418, 1541, 297, 756, 9, 503, 971, 2049, 2519, 8, 1532, 12, 283, 1100, 1541, 297, 756, 9, 503, 971, 2049, 2519, 8, 1532, 12, 283, 2579, 1100, 1541, 297, 756, 304, 355, 2150, 26632, 59, 16, 1527, 16, 61, 288, 4955, 275, 6485, 14, 908, 15644, 2031, 15644, 9, 267, 871, 26, 288, 986, 272, 754, 275, 788, 703, 805, 447, 450, 83, 5, 83, 7, 450, 334, 354, 12, 4955, 395, 28696, 272, 754, 14, 2880, 360, 259, 283, 435, 1004, 367, 1004, 315, 2385, 9, 272, 340, 5481, 26, 267, 754, 14, 2880, 4725, 297, 283, 259, 520, 8602, 26, 450, 83, 7, 450, 1656, 1987, 904, 8, 1993, 283, 1040, 5, 83, 1040, 7, 450, 671, 367, 671, 315, 3355, 8, 8602, 7845, 272, 372, 754, 421, 199, 318, 5461, 63, 5777, 8, 4745, 304, 272, 347, 13613, 8, 3475, 12, 2368, 12, 1511, 12, 1564, 12, 5874, 12, 1993, 1564, 63, 2743, 12, 1853, 63, 505, 12, 1174, 12, 1174, 63, 6744, 304, 267, 3837, 63, 4745, 275, 1052, 267, 367, 536, 12, 2562, 315, 4412, 14, 1744, 837, 288, 3837, 63, 4745, 14, 5486, 8, 1532, 12, 15364, 740, 8, 354, 9, 267, 4766, 275, 942, 267, 367, 2562, 12, 1561, 315, 3837, 63, 4745, 14, 1744, 837, 288, 5481, 275, 3355, 8, 1247, 12, 790, 29, 2734, 671, 26, 822, 8, 88, 430, 288, 536, 275, 5481, 14, 1935, 342, 288, 4766, 14, 740, 1332, 354, 12, 5481, 12, 2562, 430, 267, 4766, 14, 3191, 342, 398, 754, 275, 10935, 1296, 342, 267, 367, 536, 12, 5481, 12, 2562, 315, 4766, 26, 288, 367, 1242, 315, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
catherinemoresco/feedme
venv/lib/python2.7/site-packages/gunicorn/app/base.py
24
4153
# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. import os import sys import traceback from gunicorn import util from gunicorn.arbiter import Arbiter from gunicorn.config import Config, get_default_config_file from gunicorn import debug from gunicorn.six import execfile_ class Application(object): """\ An application interface for configuring and loading the various necessities for any given web framework. """ def __init__(self, usage=None, prog=None): self.usage = usage self.cfg = None self.callable = None self.prog = prog self.logger = None self.do_load_config() def do_load_config(self): try: self.load_config() except Exception as e: sys.stderr.write("\nError: %s\n" % str(e)) sys.stderr.flush() sys.exit(1) def load_config_from_file(self, filename): if not os.path.exists(filename): raise RuntimeError("%r doesn't exist" % filename) cfg = { "__builtins__": __builtins__, "__name__": "__config__", "__file__": filename, "__doc__": None, "__package__": None } try: execfile_(filename, cfg, cfg) except Exception: print("Failed to read config file: %s" % filename) traceback.print_exc() sys.exit(1) for k, v in cfg.items(): # Ignore unknown names if k not in self.cfg.settings: continue try: self.cfg.set(k.lower(), v) except: sys.stderr.write("Invalid value for %s: %s\n\n" % (k, v)) raise return cfg def load_config(self): # init configuration self.cfg = Config(self.usage, prog=self.prog) # parse console args parser = self.cfg.parser() args = parser.parse_args() # optional settings from apps cfg = self.init(parser, args, args.args) # Load up the any app specific configuration if cfg and cfg is not None: for k, v in cfg.items(): self.cfg.set(k.lower(), v) if args.config: self.load_config_from_file(args.config) else: default_config = get_default_config_file() if default_config is not None: self.load_config_from_file(default_config) # Lastly, update the configuration with any command line # settings. for k, v in args.__dict__.items(): if v is None: continue if k == "args": continue self.cfg.set(k.lower(), v) def init(self, parser, opts, args): raise NotImplementedError def load(self): raise NotImplementedError def reload(self): self.do_load_config() if self.cfg.spew: debug.spew() def wsgi(self): if self.callable is None: self.callable = self.load() return self.callable def run(self): if self.cfg.check_config: try: self.load() except: sys.stderr.write("\nError while loading the application:\n\n") traceback.print_exc() sys.stderr.flush() sys.exit(1) sys.exit(0) if self.cfg.spew: debug.spew() if self.cfg.daemon: util.daemonize(self.cfg.enable_stdio_inheritance) # set python paths if self.cfg.pythonpath and self.cfg.pythonpath is not None: paths = self.cfg.pythonpath.split(",") for path in paths: pythonpath = os.path.abspath(path) if pythonpath not in sys.path: sys.path.insert(0, pythonpath) try: Arbiter(self).run() except RuntimeError as e: sys.stderr.write("\nError: %s\n\n" % e) sys.stderr.flush() sys.exit(1)
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 446, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 486, 29067, 14286, 1334, 314, 10697, 4190, 14, 199, 3, 1666, 314, 12840, 367, 1655, 2556, 14, 199, 199, 646, 747, 199, 646, 984, 199, 646, 5190, 199, 199, 504, 486, 29067, 492, 4884, 199, 504, 486, 29067, 14, 10325, 1661, 492, 1952, 66, 1661, 199, 504, 486, 29067, 14, 888, 492, 4094, 12, 664, 63, 885, 63, 888, 63, 493, 199, 504, 486, 29067, 492, 3105, 199, 504, 486, 29067, 14, 4174, 492, 22711, 63, 199, 199, 533, 13515, 8, 785, 304, 272, 9638, 272, 1626, 4223, 3217, 367, 1101, 4039, 436, 8697, 272, 314, 7750, 1279, 823, 338, 1417, 367, 1263, 1627, 3330, 10059, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4503, 29, 403, 12, 13205, 29, 403, 304, 267, 291, 14, 3807, 275, 4503, 267, 291, 14, 4128, 275, 488, 267, 291, 14, 8296, 275, 488, 267, 291, 14, 6595, 275, 13205, 267, 291, 14, 2921, 275, 488, 267, 291, 14, 1117, 63, 912, 63, 888, 342, 339, 347, 886, 63, 912, 63, 888, 8, 277, 304, 267, 862, 26, 288, 291, 14, 912, 63, 888, 342, 267, 871, 2186, 465, 325, 26, 288, 984, 14, 3083, 14, 952, 4582, 78, 547, 26, 450, 83, 60, 78, 2, 450, 620, 8, 69, 430, 288, 984, 14, 3083, 14, 4939, 342, 288, 984, 14, 2224, 8, 17, 9, 339, 347, 2248, 63, 888, 63, 504, 63, 493, 8, 277, 12, 1788, 304, 398, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 288, 746, 6064, 3647, 82, 3181, 1133, 2187, 2, 450, 1788, 9, 398, 4810, 275, 469, 288, 4396, 10372, 5727, 636, 10372, 3108, 288, 4396, 354, 5727, 4396, 888, 13915, 288, 4396, 493, 5727, 1788, 12, 288, 4396, 1301, 5727, 488, 12, 288, 4396, 2491, 5727, 488, 267, 789, 267, 862, 26, 288, 22711, 2531, 1501, 12, 4810, 12, 4810, 9, 267, 871, 2186, 26, 288, 870, 480, 4276, 370, 1586, 1101, 570, 26, 450, 83, 2, 450, 1788, 9, 288, 5190, 14, 1361, 63, 2804, 342, 288, 984, 14, 2224, 8, 17, 9, 398, 367, 1022, 12, 373, 315, 4810, 14, 1744, 837, 288, 327, 14092, 5809, 1561, 288, 340, 1022, 440, 315, 291, 14, 4128, 14, 1751, 26, 355, 1980, 288, 862, 26, 355, 291, 14, 4128, 14, 409, 8, 75, 14, 2325, 1062, 373, 9, 288, 871, 26, 355, 984, 14, 3083, 14, 952, 480, 3364, 574, 367, 450, 83, 26, 450, 83, 60, 78, 60, 78, 2, 450, 334, 75, 12, 373, 430, 355, 746, 398, 372, 4810, 339, 347, 2248, 63, 888, 8, 277, 304, 267, 327, 4205, 2897, 267, 291, 14, 4128, 275, 4094, 8, 277, 14, 3807, 12, 13205, 29, 277, 14, 6595, 9, 398, 327, 2198, 8559, 1249, 267, 1798, 275, 291, 14, 4128, 14, 2087, 342, 267, 1249, 275, 1798, 14, 1122, 63, 589, 342, 398, 327, 2716, 2202, 687, 8686, 267, 4810, 275, 291, 14, 826, 8, 2087, 12, 1249, 12, 1249, 14, 589, 9, 398, 327, 7190, 1536, 314, 1263, 1145, 2488, 2897, 267, 340, 4810, 436, 4810, 365, 440, 488, 26, 288, 367, 1022, 12, 373, 315, 4810, 14, 1744, 837, 355, 291, 14, 4128, 14, 409, 8, 75, 14, 2325, 1062, 373, 9, 398, 340, 1249, 14, 888, 26, 288, 291, 14, 912, 63, 888, 63, 504, 63, 493, 8, 589, 14, 888, 9, 267, 587, 26, 288, 849, 63, 888, 275, 664, 63, 885, 63, 888, 63, 493, 342, 288, 340, 849, 63, 888, 365, 440, 488, 26, 355, 291, 14, 912, 63, 888, 63, 504, 63, 493, 8, 885, 63, 888, 9, 398, 327, 15237, 590, 12, 1678, 314, 2897, 543, 1263, 1414, 1004, 267, 327, 2202, 14, 267, 367, 1022, 12, 373, 315, 1249, 855, 807, 4343, 1744, 837, 288, 340, 373, 365, 488, 26, 355, 1980, 288, 340, 1022, 508, 298, 589, 582, 355, 1980, 288, 291, 14, 4128, 14, 409, 8, 75, 14, 2325, 1062, 373, 9, 339, 347, 4205, 8, 277, 12, 1798, 12, 3999, 12, 1249, 304, 267, 746, 4279, 339, 347, 2248, 8, 277, 304, 267, 746, 4279, 339, 347, 13101, 8, 277, 304, 267, 291, 14, 1117, 63, 912, 63, 888, 342, 267, 340, 291, 14, 4128, 14, 12325, 87, 26, 288, 3105, 14, 12325, 87, 342, 339, 347, 12464, 8, 277, 304, 267, 340, 291, 14, 8296, 365, 488, 26, 288, 291, 14, 8296, 275, 291, 14, 912, 342, 267, 372, 291, 14, 8296, 339, 347, 1255, 8, 277, 304, 267, 340, 291, 14, 4128, 14, 1074, 63, 888, 26, 288, 862, 26, 355, 291, 14, 912, 342, 288, 871, 26, 355, 984, 14, 3083, 14, 952, 4582, 78, 547, 1830, 8697, 314, 4223, 3427, 78, 60, 78, 531, 355, 5190, 14, 1361, 63, 2804, 342, 355, 984, 14, 3083, 14, 4939, 342, 355, 984, 14, 2224, 8, 17, 9, 288, 984, 14, 2224, 8, 16, 9, 398, 340, 291, 14, 4128, 14, 12325, 87, 26, 288, 3105, 14, 12325, 87, 342, 398, 340, 291, 14, 4128, 14, 10824, 26, 288, 4884, 14, 10824, 794, 8, 277, 14, 4128, 14, 4296, 63, 32011, 63, 13136, 9, 398, 327, 663, 2366, 3792, 267, 340, 291, 14, 4128, 14, 1548, 515, 436, 291, 14, 4128, 14, 1548, 515, 365, 440, 488, 26, 288, 3792, 275, 291, 14, 4128, 14, 1548, 515, 14, 1294, 20324, 288, 367, 931, 315, 3792, 26, 355, 2366, 515, 275, 747, 14, 515, 14, 4832, 8, 515, 9, 355, 340, 2366, 515, 440, 315, 984, 14, 515, 26, 490, 984, 14, 515, 14, 3176, 8, 16, 12, 2366, 515, 9, 398, 862, 26, 288, 1952, 66, 1661, 8, 277, 680, 1065, 342, 267, 871, 6064, 465, 325, 26, 288, 984, 14, 3083, 14, 952, 4582, 78, 547, 26, 450, 83, 60, 78, 60, 78, 2, 450, 325, 9, 288, 984, 14, 3083, 14, 4939, 342, 288, 984, 14, 2224, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 446, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 486, 29067, 14286, 1334, 314, 10697, 4190, 14, 199, 3, 1666, 314, 12840, 367, 1655, 2556, 14, 199, 199, 646, 747, 199, 646, 984, 199, 646, 5190, 199, 199, 504, 486, 29067, 492, 4884, 199, 504, 486, 29067, 14, 10325, 1661, 492, 1952, 66, 1661, 199, 504, 486, 29067, 14, 888, 492, 4094, 12, 664, 63, 885, 63, 888, 63, 493, 199, 504, 486, 29067, 492, 3105, 199, 504, 486, 29067, 14, 4174, 492, 22711, 63, 199, 199, 533, 13515, 8, 785, 304, 272, 9638, 272, 1626, 4223, 3217, 367, 1101, 4039, 436, 8697, 272, 314, 7750, 1279, 823, 338, 1417, 367, 1263, 1627, 3330, 10059, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4503, 29, 403, 12, 13205, 29, 403, 304, 267, 291, 14, 3807, 275, 4503, 267, 291, 14, 4128, 275, 488, 267, 291, 14, 8296, 275, 488, 267, 291, 14, 6595, 275, 13205, 267, 291, 14, 2921, 275, 488, 267, 291, 14, 1117, 63, 912, 63, 888, 342, 339, 347, 886, 63, 912, 63, 888, 8, 277, 304, 267, 862, 26, 288, 291, 14, 912, 63, 888, 342, 267, 871, 2186, 465, 325, 26, 288, 984, 14, 3083, 14, 952, 4582, 78, 547, 26, 450, 83, 60, 78, 2, 450, 620, 8, 69, 430, 288, 984, 14, 3083, 14, 4939, 342, 288, 984, 14, 2224, 8, 17, 9, 339, 347, 2248, 63, 888, 63, 504, 63, 493, 8, 277, 12, 1788, 304, 398, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 288, 746, 6064, 3647, 82, 3181, 1133, 2187, 2, 450, 1788, 9, 398, 4810, 275, 469, 288, 4396, 10372, 5727, 636, 10372, 3108, 288, 4396, 354, 5727, 4396, 888, 13915, 288, 4396, 493, 5727, 1788, 12, 288, 4396, 1301, 5727, 488, 12, 288, 4396, 2491, 5727, 488, 267, 789, 267, 862, 26, 288, 22711, 2531, 1501, 12, 4810, 12, 4810, 9, 267, 871, 2186, 26, 288, 870, 480, 4276, 370, 1586, 1101, 570, 26, 450, 83, 2, 450, 1788, 9, 288, 5190, 14, 1361, 63, 2804, 342, 288, 984, 14, 2224, 8, 17, 9, 398, 367, 1022, 12, 373, 315, 4810, 14, 1744, 837, 288, 327, 14092, 5809, 1561, 288, 340, 1022, 440, 315, 291, 14, 4128, 14, 1751, 26, 355, 1980, 288, 862, 26, 355, 291, 14, 4128, 14, 409, 8, 75, 14, 2325, 1062, 373, 9, 288, 871, 26, 355, 984, 14, 3083, 14, 952, 480, 3364, 574, 367, 450, 83, 26, 450, 83, 60, 78, 60, 78, 2, 450, 334, 75, 12, 373, 430, 355, 746, 398, 372, 4810, 339, 347, 2248, 63, 888, 8, 277, 304, 267, 327, 4205, 2897, 267, 291, 14, 4128, 275, 4094, 8, 277, 14, 3807, 12, 13205, 29, 277, 14, 6595, 9, 398, 327, 2198, 8559, 1249, 267, 1798, 275, 291, 14, 4128, 14, 2087, 342, 267, 1249, 275, 1798, 14, 1122, 63, 589, 342, 398, 327, 2716, 2202, 687, 8686, 267, 4810, 275, 291, 14, 826, 8, 2087, 12, 1249, 12, 1249, 14, 589, 9, 398, 327, 7190, 1536, 314, 1263, 1145, 2488, 2897, 267, 340, 4810, 436, 4810, 365, 440, 488, 26, 288, 367, 1022, 12, 373, 315, 4810, 14, 1744, 837, 355, 291, 14, 4128, 14, 409, 8, 75, 14, 2325, 1062, 373, 9, 398, 340, 1249, 14, 888, 26, 288, 291, 14, 912, 63, 888, 63, 504, 63, 493, 8, 589, 14, 888, 9, 267, 587, 26, 288, 849, 63, 888, 275, 664, 63, 885, 63, 888, 63, 493, 342, 288, 340, 849, 63, 888, 365, 440, 488, 26, 355, 291, 14, 912, 63, 888, 63, 504, 63, 493, 8, 885, 63, 888, 9, 398, 327, 15237, 590, 12, 1678, 314, 2897, 543, 1263, 1414, 1004, 267, 327, 2202, 14, 267, 367, 1022, 12, 373, 315, 1249, 855, 807, 4343, 1744, 837, 288, 340, 373, 365, 488, 26, 355, 1980, 288, 340, 1022, 508, 298, 589, 582, 355, 1980, 288, 291, 14, 4128, 14, 409, 8, 75, 14, 2325, 1062, 373, 9, 339, 347, 4205, 8, 277, 12, 1798, 12, 3999, 12, 1249, 304, 267, 746, 4279, 339, 347, 2248, 8, 277, 304, 267, 746, 4279, 339, 347, 13101, 8, 277, 304, 267, 291, 14, 1117, 63, 912, 63, 888, 342, 267, 340, 291, 14, 4128, 14, 12325, 87, 26, 288, 3105, 14, 12325, 87, 342, 339, 347, 12464, 8, 277, 304, 267, 340, 291, 14, 8296, 365, 488, 26, 288, 291, 14, 8296, 275, 291, 14, 912, 342, 267, 372, 291, 14, 8296, 339, 347, 1255, 8, 277, 304, 267, 340, 291, 14, 4128, 14, 1074, 63, 888, 26, 288, 862, 26, 355, 291, 14, 912, 342, 288, 871, 26, 355, 984, 14, 3083, 14, 952, 4582, 78, 547, 1830, 8697, 314, 4223, 3427, 78, 60, 78, 531, 355, 5190, 14, 1361, 63, 2804, 342, 355, 984, 14, 3083, 14, 4939, 342, 355, 984, 14, 2224, 8, 17, 9, 288, 984, 14, 2224, 8, 16, 9, 398, 340, 291, 14, 4128, 14, 12325, 87, 26, 288, 3105, 14, 12325, 87, 342, 398, 340, 291, 14, 4128, 14, 10824, 26, 288, 4884, 14, 10824, 794, 8, 277, 14, 4128, 14, 4296, 63, 32011, 63, 13136, 9, 398, 327, 663, 2366, 3792, 267, 340, 291, 14, 4128, 14, 1548, 515, 436, 291, 14, 4128, 14, 1548, 515, 365, 440, 488, 26, 288, 3792, 275, 291, 14, 4128, 14, 1548, 515, 14, 1294, 20324, 288, 367, 931, 315, 3792, 26, 355, 2366, 515, 275, 747, 14, 515, 14, 4832, 8, 515, 9, 355, 340, 2366, 515, 440, 315, 984, 14, 515, 26, 490, 984, 14, 515, 14, 3176, 8, 16, 12, 2366, 515, 9, 398, 862, 26, 288, 1952, 66, 1661, 8, 277, 680, 1065, 342, 267, 871, 6064, 465, 325, 26, 288, 984, 14, 3083, 14, 952, 4582, 78, 547, 26, 450, 83, 60, 78, 60, 78, 2, 450, 325, 9, 288, 984, 14, 3083, 14, 4939, 342, 288, 984, 14, 2224, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
snasoft/QtCreatorPluginsPack
Bin/3rdParty/vera/bin/lib/ast.py
255
11805
# -*- coding: utf-8 -*- """ ast ~~~ The `ast` module helps Python applications to process trees of the Python abstract syntax grammar. The abstract syntax itself might change with each Python release; this module helps to find out programmatically what the current grammar looks like and allows modifications of it. An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as a flag to the `compile()` builtin function or by using the `parse()` function from this module. The result will be a tree of objects whose classes all inherit from `ast.AST`. A modified abstract syntax tree can be compiled into a Python code object using the built-in `compile()` function. Additionally various helper functions are provided that make working with the trees simpler. The main intention of the helper functions and this module in general is to provide an easy to use interface for libraries that work tightly with the python syntax (template engines for example). :copyright: Copyright 2008 by Armin Ronacher. :license: Python License. """ from _ast import * from _ast import __version__ def parse(source, filename='<unknown>', mode='exec'): """ Parse the source into an AST node. Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). """ return compile(source, filename, mode, PyCF_ONLY_AST) def literal_eval(node_or_string): """ Safely evaluate an expression node or a string containing a Python expression. The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None. """ _safe_names = {'None': None, 'True': True, 'False': False} if isinstance(node_or_string, basestring): node_or_string = parse(node_or_string, mode='eval') if isinstance(node_or_string, Expression): node_or_string = node_or_string.body def _convert(node): if isinstance(node, Str): return node.s elif isinstance(node, Num): return node.n elif isinstance(node, Tuple): return tuple(map(_convert, node.elts)) elif isinstance(node, List): return list(map(_convert, node.elts)) elif isinstance(node, Dict): return dict((_convert(k), _convert(v)) for k, v in zip(node.keys, node.values)) elif isinstance(node, Name): if node.id in _safe_names: return _safe_names[node.id] elif isinstance(node, BinOp) and \ isinstance(node.op, (Add, Sub)) and \ isinstance(node.right, Num) and \ isinstance(node.right.n, complex) and \ isinstance(node.left, Num) and \ isinstance(node.left.n, (int, long, float)): left = node.left.n right = node.right.n if isinstance(node.op, Add): return left + right else: return left - right raise ValueError('malformed string') return _convert(node_or_string) def dump(node, annotate_fields=True, include_attributes=False): """ Return a formatted dump of the tree in *node*. This is mainly useful for debugging purposes. The returned string will show the names and the values for fields. This makes the code impossible to evaluate, so if evaluation is wanted *annotate_fields* must be set to False. Attributes such as line numbers and column offsets are not dumped by default. If this is wanted, *include_attributes* can be set to True. """ def _format(node): if isinstance(node, AST): fields = [(a, _format(b)) for a, b in iter_fields(node)] rv = '%s(%s' % (node.__class__.__name__, ', '.join( ('%s=%s' % field for field in fields) if annotate_fields else (b for a, b in fields) )) if include_attributes and node._attributes: rv += fields and ', ' or ' ' rv += ', '.join('%s=%s' % (a, _format(getattr(node, a))) for a in node._attributes) return rv + ')' elif isinstance(node, list): return '[%s]' % ', '.join(_format(x) for x in node) return repr(node) if not isinstance(node, AST): raise TypeError('expected AST, got %r' % node.__class__.__name__) return _format(node) def copy_location(new_node, old_node): """ Copy source location (`lineno` and `col_offset` attributes) from *old_node* to *new_node* if possible, and return *new_node*. """ for attr in 'lineno', 'col_offset': if attr in old_node._attributes and attr in new_node._attributes \ and hasattr(old_node, attr): setattr(new_node, attr, getattr(old_node, attr)) return new_node def fix_missing_locations(node): """ When you compile a node tree with compile(), the compiler expects lineno and col_offset attributes for every node that supports them. This is rather tedious to fill in for generated nodes, so this helper adds these attributes recursively where not already set, by setting them to the values of the parent node. It works recursively starting at *node*. """ def _fix(node, lineno, col_offset): if 'lineno' in node._attributes: if not hasattr(node, 'lineno'): node.lineno = lineno else: lineno = node.lineno if 'col_offset' in node._attributes: if not hasattr(node, 'col_offset'): node.col_offset = col_offset else: col_offset = node.col_offset for child in iter_child_nodes(node): _fix(child, lineno, col_offset) _fix(node, 1, 0) return node def increment_lineno(node, n=1): """ Increment the line number of each node in the tree starting at *node* by *n*. This is useful to "move code" to a different location in a file. """ for child in walk(node): if 'lineno' in child._attributes: child.lineno = getattr(child, 'lineno', 0) + n return node def iter_fields(node): """ Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` that is present on *node*. """ for field in node._fields: try: yield field, getattr(node, field) except AttributeError: pass def iter_child_nodes(node): """ Yield all direct child nodes of *node*, that is, all fields that are nodes and all items of fields that are lists of nodes. """ for name, field in iter_fields(node): if isinstance(field, AST): yield field elif isinstance(field, list): for item in field: if isinstance(item, AST): yield item def get_docstring(node, clean=True): """ Return the docstring for the given node or None if no docstring can be found. If the node provided does not have docstrings a TypeError will be raised. """ if not isinstance(node, (FunctionDef, ClassDef, Module)): raise TypeError("%r can't have docstrings" % node.__class__.__name__) if node.body and isinstance(node.body[0], Expr) and \ isinstance(node.body[0].value, Str): if clean: import inspect return inspect.cleandoc(node.body[0].value.s) return node.body[0].value.s def walk(node): """ Recursively yield all descendant nodes in the tree starting at *node* (including *node* itself), in no specified order. This is useful if you only want to modify nodes in place and don't care about the context. """ from collections import deque todo = deque([node]) while todo: node = todo.popleft() todo.extend(iter_child_nodes(node)) yield node class NodeVisitor(object): """ A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the `visit` method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are ``'visit_'`` + class name of the node. So a `TryFinally` node visit function would be `visit_TryFinally`. This behavior can be changed by overriding the `visit` method. If no visitor function exists for a node (return value `None`) the `generic_visit` visitor is used instead. Don't use the `NodeVisitor` if you want to apply changes to nodes during traversing. For this a special visitor exists (`NodeTransformer`) that allows modifications. """ def visit(self, node): """Visit a node.""" method = 'visit_' + node.__class__.__name__ visitor = getattr(self, method, self.generic_visit) return visitor(node) def generic_visit(self, node): """Called if no explicit visitor function exists for a node.""" for field, value in iter_fields(node): if isinstance(value, list): for item in value: if isinstance(item, AST): self.visit(item) elif isinstance(value, AST): self.visit(value) class NodeTransformer(NodeVisitor): """ A :class:`NodeVisitor` subclass that walks the abstract syntax tree and allows modification of nodes. The `NodeTransformer` will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is ``None``, the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups (``foo``) to ``data['foo']``:: class RewriteName(NodeTransformer): def visit_Name(self, node): return copy_location(Subscript( value=Name(id='data', ctx=Load()), slice=Index(value=Str(s=node.id)), ctx=node.ctx ), node) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth:`generic_visit` method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this:: node = YourTransformer().visit(node) """ def generic_visit(self, node): for field, old_value in iter_fields(node): old_value = getattr(node, field, None) if isinstance(old_value, list): new_values = [] for value in old_value: if isinstance(value, AST): value = self.visit(value) if value is None: continue elif not isinstance(value, AST): new_values.extend(value) continue new_values.append(value) old_value[:] = new_values elif isinstance(old_value, AST): new_node = self.visit(old_value) if new_node is None: delattr(node, field) else: setattr(node, field, new_node) return node
lgpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 6073, 272, 221, 23597, 339, 710, 658, 1810, 64, 859, 22577, 2018, 13103, 370, 2112, 14416, 402, 314, 2018, 272, 9006, 6302, 12528, 14, 221, 710, 9006, 6302, 6337, 5594, 1570, 543, 272, 1924, 2018, 4683, 27, 642, 859, 22577, 370, 2342, 734, 2240, 17174, 4052, 272, 314, 1453, 12528, 10734, 2839, 436, 6127, 23070, 402, 652, 14, 339, 1626, 9006, 6302, 3123, 883, 506, 4046, 701, 9476, 658, 1810, 14, 2713, 5487, 63, 10452, 63, 11307, 64, 465, 272, 282, 3305, 370, 314, 658, 2014, 11995, 6762, 805, 503, 701, 1808, 314, 658, 1122, 11995, 272, 805, 687, 642, 859, 14, 221, 710, 754, 911, 506, 282, 3123, 402, 2251, 7447, 272, 3992, 1006, 8287, 687, 658, 1810, 14, 11307, 2313, 339, 437, 6042, 9006, 6302, 3123, 883, 506, 10311, 1901, 282, 2018, 1233, 909, 272, 1808, 314, 6137, 13, 262, 658, 2014, 11995, 805, 14, 339, 25448, 7750, 5922, 3423, 787, 2741, 626, 1852, 6449, 543, 272, 314, 14416, 28293, 14, 221, 710, 2446, 25343, 402, 314, 5922, 3423, 436, 642, 272, 859, 315, 8605, 365, 370, 5647, 376, 8837, 370, 675, 3217, 367, 8363, 272, 626, 1736, 3367, 913, 590, 543, 314, 2366, 6302, 334, 1160, 28156, 367, 2893, 680, 2378, 520, 7307, 26, 1898, 9079, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 2018, 844, 14, 199, 624, 199, 504, 485, 1810, 492, 627, 199, 504, 485, 1810, 492, 636, 1023, 363, 421, 199, 318, 2198, 8, 1365, 12, 1788, 15829, 5187, 4206, 818, 534, 1628, 735, 272, 408, 272, 6077, 314, 1350, 1901, 376, 20788, 1031, 14, 272, 24228, 370, 6555, 8, 1365, 12, 1788, 12, 818, 12, 1611, 5487, 63, 10452, 63, 11307, 680, 272, 408, 272, 372, 6555, 8, 1365, 12, 1788, 12, 818, 12, 1611, 5487, 63, 10452, 63, 11307, 9, 421, 199, 318, 8785, 63, 2579, 8, 932, 63, 269, 63, 875, 304, 272, 408, 272, 428, 2756, 7742, 9352, 376, 3965, 1031, 503, 282, 1059, 3035, 282, 2018, 272, 3965, 14, 221, 710, 1059, 503, 1031, 2741, 1443, 1454, 17568, 402, 314, 2569, 272, 2018, 8785, 13955, 26, 3326, 12, 5579, 12, 6346, 12, 5548, 12, 10809, 12, 1234, 16721, 796, 12, 272, 436, 488, 14, 272, 408, 272, 485, 3489, 63, 1247, 275, 791, 403, 356, 488, 12, 283, 549, 356, 715, 12, 283, 797, 356, 756, 93, 272, 340, 1228, 8, 932, 63, 269, 63, 875, 12, 7116, 304, 267, 1031, 63, 269, 63, 875, 275, 2198, 8, 932, 63, 269, 63, 875, 12, 818, 534, 2579, 358, 272, 340, 1228, 8, 932, 63, 269, 63, 875, 12, 22013, 304, 267, 1031, 63, 269, 63, 875, 275, 1031, 63, 269, 63, 875, 14, 2030, 272, 347, 485, 3916, 8, 932, 304, 267, 340, 1228, 8, 932, 12, 8303, 304, 288, 372, 1031, 14, 83, 267, 916, 1228, 8, 932, 12, 16817, 304, 288, 372, 1031, 14, 78, 267, 916, 1228, 8, 932, 12, 11634, 304, 288, 372, 2008, 8, 1130, 1547, 3916, 12, 1031, 14, 352, 1086, 430, 267, 916, 1228, 8, 932, 12, 3820, 304, 288, 372, 769, 8, 1130, 1547, 3916, 12, 1031, 14, 352, 1086, 430, 267, 916, 1228, 8, 932, 12, 7448, 304, 288, 372, 1211, 1332, 63, 3916, 8, 75, 395, 485, 3916, 8, 86, 430, 367, 1022, 12, 373, 717, 315, 3482, 8, 932, 14, 1612, 12, 1031, 14, 1459, 430, 267, 916, 1228, 8, 932, 12, 2812, 304, 288, 340, 1031, 14, 344, 315, 485, 3489, 63, 1247, 26, 355, 372, 485, 3489, 63, 1247, 59, 932, 14, 344, 61, 267, 916, 1228, 8, 932, 12, 32613, 4619, 9, 436, 971, 1467, 1228, 8, 932, 14, 411, 12, 334, 1123, 12, 4804, 430, 436, 971, 1467, 1228, 8, 932, 14, 1019, 12, 16817, 9, 436, 971, 1467, 1228, 8, 932, 14, 1019, 14, 78, 12, 6114, 9, 436, 971, 1467, 1228, 8, 932, 14, 3039, 12, 16817, 9, 436, 971, 1467, 1228, 8, 932, 14, 3039, 14, 78, 12, 334, 442, 12, 1846, 12, 2069, 2298, 288, 3602, 275, 1031, 14, 3039, 14, 78, 288, 2451, 275, 1031, 14, 1019, 14, 78, 288, 340, 1228, 8, 932, 14, 411, 12, 2654, 304, 355, 372, 3602, 435, 2451, 288, 587, 26, 355, 372, 3602, 446, 2451, 267, 746, 1722, 360, 31029, 1059, 358, 272, 372, 485, 3916, 8, 932, 63, 269, 63, 875, 9, 421, 199, 318, 5461, 8, 932, 12, 28987, 63, 955, 29, 549, 12, 2387, 63, 2987, 29, 797, 304, 272, 408, 272, 1432, 282, 7871, 5461, 402, 314, 3123, 315, 627, 932, 4856, 221, 961, 365, 27580, 2997, 367, 272, 10201, 12901, 14, 221, 710, 2138, 1059, 911, 2498, 314, 1561, 436, 314, 1338, 272, 367, 1504, 14, 221, 961, 7704, 314, 1233, 26847, 370, 9352, 12, 880, 340, 11735, 365, 272, 13632, 627, 10898, 63, 955, 10, 1471, 506, 663, 370, 756, 14, 221, 9382, 4066, 465, 1004, 272, 5579, 436, 2763, 15340, 787, 440, 31374, 701, 849, 14, 221, 982, 642, 365, 13632, 12, 272, 627, 2613, 63, 2987, 10, 883, 506, 663, 370, 715, 14, 272, 408, 272, 347, 485, 908, 8, 932, 304, 267, 340, 1228, 8, 932, 12, 20788, 304, 288, 1504, 275, 3842, 65, 12, 485, 908, 8, 66, 430, 367, 282, 12, 330, 315, 2740, 63, 955, 8, 932, 1874, 288, 4336, 275, 1543, 83, 4042, 83, 7, 450, 334, 932, 855, 533, 4914, 354, 3108, 1656, 1987, 904, 8, 355, 16651, 83, 2458, 83, 7, 450, 901, 367, 901, 315, 1504, 9, 355, 340, 28987, 63, 955, 587, 355, 334, 66, 367, 282, 12, 330, 315, 1504, 9, 288, 5082, 288, 340, 2387, 63, 2987, 436, 1031, 423, 2987, 26, 355, 4336, 847, 1504, 436, 1656, 283, 503, 283, 283, 355, 4336, 847, 1656, 1987, 904, 3508, 83, 2458, 83, 7, 450, 334, 65, 12, 485, 908, 8, 5675, 8, 932, 12, 282, 1724, 1816, 367, 282, 315, 1031, 423, 2987, 9, 288, 372, 4336, 435, 16107, 267, 916, 1228, 8, 932, 12, 769, 304, 288, 372, 30423, 83, 6616, 450, 1656, 1987, 904, 1547, 908, 8, 88, 9, 367, 671 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 6073, 272, 221, 23597, 339, 710, 658, 1810, 64, 859, 22577, 2018, 13103, 370, 2112, 14416, 402, 314, 2018, 272, 9006, 6302, 12528, 14, 221, 710, 9006, 6302, 6337, 5594, 1570, 543, 272, 1924, 2018, 4683, 27, 642, 859, 22577, 370, 2342, 734, 2240, 17174, 4052, 272, 314, 1453, 12528, 10734, 2839, 436, 6127, 23070, 402, 652, 14, 339, 1626, 9006, 6302, 3123, 883, 506, 4046, 701, 9476, 658, 1810, 14, 2713, 5487, 63, 10452, 63, 11307, 64, 465, 272, 282, 3305, 370, 314, 658, 2014, 11995, 6762, 805, 503, 701, 1808, 314, 658, 1122, 11995, 272, 805, 687, 642, 859, 14, 221, 710, 754, 911, 506, 282, 3123, 402, 2251, 7447, 272, 3992, 1006, 8287, 687, 658, 1810, 14, 11307, 2313, 339, 437, 6042, 9006, 6302, 3123, 883, 506, 10311, 1901, 282, 2018, 1233, 909, 272, 1808, 314, 6137, 13, 262, 658, 2014, 11995, 805, 14, 339, 25448, 7750, 5922, 3423, 787, 2741, 626, 1852, 6449, 543, 272, 314, 14416, 28293, 14, 221, 710, 2446, 25343, 402, 314, 5922, 3423, 436, 642, 272, 859, 315, 8605, 365, 370, 5647, 376, 8837, 370, 675, 3217, 367, 8363, 272, 626, 1736, 3367, 913, 590, 543, 314, 2366, 6302, 334, 1160, 28156, 367, 2893, 680, 2378, 520, 7307, 26, 1898, 9079, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 2018, 844, 14, 199, 624, 199, 504, 485, 1810, 492, 627, 199, 504, 485, 1810, 492, 636, 1023, 363, 421, 199, 318, 2198, 8, 1365, 12, 1788, 15829, 5187, 4206, 818, 534, 1628, 735, 272, 408, 272, 6077, 314, 1350, 1901, 376, 20788, 1031, 14, 272, 24228, 370, 6555, 8, 1365, 12, 1788, 12, 818, 12, 1611, 5487, 63, 10452, 63, 11307, 680, 272, 408, 272, 372, 6555, 8, 1365, 12, 1788, 12, 818, 12, 1611, 5487, 63, 10452, 63, 11307, 9, 421, 199, 318, 8785, 63, 2579, 8, 932, 63, 269, 63, 875, 304, 272, 408, 272, 428, 2756, 7742, 9352, 376, 3965, 1031, 503, 282, 1059, 3035, 282, 2018, 272, 3965, 14, 221, 710, 1059, 503, 1031, 2741, 1443, 1454, 17568, 402, 314, 2569, 272, 2018, 8785, 13955, 26, 3326, 12, 5579, 12, 6346, 12, 5548, 12, 10809, 12, 1234, 16721, 796, 12, 272, 436, 488, 14, 272, 408, 272, 485, 3489, 63, 1247, 275, 791, 403, 356, 488, 12, 283, 549, 356, 715, 12, 283, 797, 356, 756, 93, 272, 340, 1228, 8, 932, 63, 269, 63, 875, 12, 7116, 304, 267, 1031, 63, 269, 63, 875, 275, 2198, 8, 932, 63, 269, 63, 875, 12, 818, 534, 2579, 358, 272, 340, 1228, 8, 932, 63, 269, 63, 875, 12, 22013, 304, 267, 1031, 63, 269, 63, 875, 275, 1031, 63, 269, 63, 875, 14, 2030, 272, 347, 485, 3916, 8, 932, 304, 267, 340, 1228, 8, 932, 12, 8303, 304, 288, 372, 1031, 14, 83, 267, 916, 1228, 8, 932, 12, 16817, 304, 288, 372, 1031, 14, 78, 267, 916, 1228, 8, 932, 12, 11634, 304, 288, 372, 2008, 8, 1130, 1547, 3916, 12, 1031, 14, 352, 1086, 430, 267, 916, 1228, 8, 932, 12, 3820, 304, 288, 372, 769, 8, 1130, 1547, 3916, 12, 1031, 14, 352, 1086, 430, 267, 916, 1228, 8, 932, 12, 7448, 304, 288, 372, 1211, 1332, 63, 3916, 8, 75, 395, 485, 3916, 8, 86, 430, 367, 1022, 12, 373, 717, 315, 3482, 8, 932, 14, 1612, 12, 1031, 14, 1459, 430, 267, 916, 1228, 8, 932, 12, 2812, 304, 288, 340, 1031, 14, 344, 315, 485, 3489, 63, 1247, 26, 355, 372, 485, 3489, 63, 1247, 59, 932, 14, 344, 61, 267, 916, 1228, 8, 932, 12, 32613, 4619, 9, 436, 971, 1467, 1228, 8, 932, 14, 411, 12, 334, 1123, 12, 4804, 430, 436, 971, 1467, 1228, 8, 932, 14, 1019, 12, 16817, 9, 436, 971, 1467, 1228, 8, 932, 14, 1019, 14, 78, 12, 6114, 9, 436, 971, 1467, 1228, 8, 932, 14, 3039, 12, 16817, 9, 436, 971, 1467, 1228, 8, 932, 14, 3039, 14, 78, 12, 334, 442, 12, 1846, 12, 2069, 2298, 288, 3602, 275, 1031, 14, 3039, 14, 78, 288, 2451, 275, 1031, 14, 1019, 14, 78, 288, 340, 1228, 8, 932, 14, 411, 12, 2654, 304, 355, 372, 3602, 435, 2451, 288, 587, 26, 355, 372, 3602, 446, 2451, 267, 746, 1722, 360, 31029, 1059, 358, 272, 372, 485, 3916, 8, 932, 63, 269, 63, 875, 9, 421, 199, 318, 5461, 8, 932, 12, 28987, 63, 955, 29, 549, 12, 2387, 63, 2987, 29, 797, 304, 272, 408, 272, 1432, 282, 7871, 5461, 402, 314, 3123, 315, 627, 932, 4856, 221, 961, 365, 27580, 2997, 367, 272, 10201, 12901, 14, 221, 710, 2138, 1059, 911, 2498, 314, 1561, 436, 314, 1338, 272, 367, 1504, 14, 221, 961, 7704, 314, 1233, 26847, 370, 9352, 12, 880, 340, 11735, 365, 272, 13632, 627, 10898, 63, 955, 10, 1471, 506, 663, 370, 756, 14, 221, 9382, 4066, 465, 1004, 272, 5579, 436, 2763, 15340, 787, 440, 31374, 701, 849, 14, 221, 982, 642, 365, 13632, 12, 272, 627, 2613, 63, 2987, 10, 883, 506, 663, 370, 715, 14, 272, 408, 272, 347, 485, 908, 8, 932, 304, 267, 340, 1228, 8, 932, 12, 20788, 304, 288, 1504, 275, 3842, 65, 12, 485, 908, 8, 66, 430, 367, 282, 12, 330, 315, 2740, 63, 955, 8, 932, 1874, 288, 4336, 275, 1543, 83, 4042, 83, 7, 450, 334, 932, 855, 533, 4914, 354, 3108, 1656, 1987, 904, 8, 355, 16651, 83, 2458, 83, 7, 450, 901, 367, 901, 315, 1504, 9, 355, 340, 28987, 63, 955, 587, 355, 334, 66, 367, 282, 12, 330, 315, 1504, 9, 288, 5082, 288, 340, 2387, 63, 2987, 436, 1031, 423, 2987, 26, 355, 4336, 847, 1504, 436, 1656, 283, 503, 283, 283, 355, 4336, 847, 1656, 1987, 904, 3508, 83, 2458, 83, 7, 450, 334, 65, 12, 485, 908, 8, 5675, 8, 932, 12, 282, 1724, 1816, 367, 282, 315, 1031, 423, 2987, 9, 288, 372, 4336, 435, 16107, 267, 916, 1228, 8, 932, 12, 769, 304, 288, 372, 30423, 83, 6616, 450, 1656, 1987, 904, 1547, 908, 8, 88, 9, 367, 671, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mezz64/home-assistant
homeassistant/components/xiaomi/device_tracker.py
12
5680
"""Support for Xiaomi Mi routers.""" import logging import requests import voluptuous as vol from homeassistant.components.device_tracker import ( DOMAIN, PLATFORM_SCHEMA, DeviceScanner, ) from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, HTTP_OK import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_HOST): cv.string, vol.Required(CONF_USERNAME, default="admin"): cv.string, vol.Required(CONF_PASSWORD): cv.string, } ) def get_scanner(hass, config): """Validate the configuration and return a Xiaomi Device Scanner.""" scanner = XiaomiDeviceScanner(config[DOMAIN]) return scanner if scanner.success_init else None class XiaomiDeviceScanner(DeviceScanner): """This class queries a Xiaomi Mi router. Adapted from Luci scanner. """ def __init__(self, config): """Initialize the scanner.""" self.host = config[CONF_HOST] self.username = config[CONF_USERNAME] self.password = config[CONF_PASSWORD] self.last_results = {} self.token = _get_token(self.host, self.username, self.password) self.mac2name = None self.success_init = self.token is not None def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" self._update_info() return self.last_results def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" if self.mac2name is None: result = self._retrieve_list_with_retry() if result: hosts = [x for x in result if "mac" in x and "name" in x] mac2name_list = [(x["mac"].upper(), x["name"]) for x in hosts] self.mac2name = dict(mac2name_list) else: # Error, handled in the _retrieve_list_with_retry return return self.mac2name.get(device.upper(), None) def _update_info(self): """Ensure the information from the router are up to date. Returns true if scanning successful. """ if not self.success_init: return False result = self._retrieve_list_with_retry() if result: self._store_result(result) return True return False def _retrieve_list_with_retry(self): """Retrieve the device list with a retry if token is invalid. Return the list if successful. """ _LOGGER.info("Refreshing device list") result = _retrieve_list(self.host, self.token) if result: return result _LOGGER.info("Refreshing token and retrying device list refresh") self.token = _get_token(self.host, self.username, self.password) return _retrieve_list(self.host, self.token) def _store_result(self, result): """Extract and store the device list in self.last_results.""" self.last_results = [] for device_entry in result: # Check if the device is marked as connected if int(device_entry["online"]) == 1: self.last_results.append(device_entry["mac"]) def _retrieve_list(host, token, **kwargs): """Get device list for the given host.""" url = "http://{}/cgi-bin/luci/;stok={}/api/misystem/devicelist" url = url.format(host, token) try: res = requests.get(url, timeout=5, **kwargs) except requests.exceptions.Timeout: _LOGGER.exception("Connection to the router timed out at URL %s", url) return if res.status_code != HTTP_OK: _LOGGER.exception("Connection failed with http code %s", res.status_code) return try: result = res.json() except ValueError: # If json decoder could not parse the response _LOGGER.exception("Failed to parse response from mi router") return try: xiaomi_code = result["code"] except KeyError: _LOGGER.exception("No field code in response from mi router. %s", result) return if xiaomi_code == 0: try: return result["list"] except KeyError: _LOGGER.exception("No list in response from mi router. %s", result) return else: _LOGGER.info( "Receive wrong Xiaomi code %s, expected 0 in response %s", xiaomi_code, result, ) return def _get_token(host, username, password): """Get authentication token for the given host+username+password.""" url = f"http://{host}/cgi-bin/luci/api/xqsystem/login" data = {"username": username, "password": password} try: res = requests.post(url, data=data, timeout=5) except requests.exceptions.Timeout: _LOGGER.exception("Connection to the router timed out") return if res.status_code == HTTP_OK: try: result = res.json() except ValueError: # If JSON decoder could not parse the response _LOGGER.exception("Failed to parse response from mi router") return try: return result["token"] except KeyError: error_message = ( "Xiaomi token cannot be refreshed, response from " + "url: [%s] \nwith parameter: [%s] \nwas: [%s]" ) _LOGGER.exception(error_message, url, data, result) return else: _LOGGER.error( "Invalid response: [%s] at url: [%s] with data [%s]", res, url, data )
apache-2.0
[ 624, 11532, 367, 1323, 4674, 676, 73, 603, 73, 24464, 1041, 199, 646, 2050, 199, 199, 646, 4145, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 1782, 63, 8877, 492, 334, 272, 15265, 12, 272, 21966, 63, 10926, 12, 272, 12272, 20843, 12, 199, 9, 199, 504, 8846, 14, 1297, 492, 6392, 63, 5449, 12, 6392, 63, 9032, 12, 6392, 63, 11958, 12, 3101, 63, 3593, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 8, 272, 469, 267, 5236, 14, 8030, 8, 3103, 63, 5449, 304, 6277, 14, 875, 12, 267, 5236, 14, 8030, 8, 3103, 63, 11958, 12, 849, 628, 2113, 2349, 6277, 14, 875, 12, 267, 5236, 14, 8030, 8, 3103, 63, 9032, 304, 6277, 14, 875, 12, 272, 789, 199, 9, 421, 199, 318, 664, 63, 16378, 8, 5387, 12, 1101, 304, 272, 408, 12584, 314, 2897, 436, 372, 282, 1323, 4674, 676, 73, 12272, 28628, 1041, 272, 19121, 275, 1323, 4674, 676, 73, 2510, 20843, 8, 888, 59, 7378, 566, 339, 372, 19121, 340, 19121, 14, 3742, 63, 826, 587, 488, 421, 199, 533, 1323, 4674, 676, 73, 2510, 20843, 8, 2510, 20843, 304, 272, 408, 2765, 1021, 9212, 282, 1323, 4674, 676, 73, 603, 73, 6197, 14, 339, 4431, 18309, 687, 30936, 559, 19121, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1101, 304, 267, 408, 9345, 314, 19121, 1041, 267, 291, 14, 1102, 275, 1101, 59, 3103, 63, 5449, 61, 267, 291, 14, 2473, 275, 1101, 59, 3103, 63, 11958, 61, 267, 291, 14, 2060, 275, 1101, 59, 3103, 63, 9032, 61, 398, 291, 14, 2019, 63, 2604, 275, 1052, 267, 291, 14, 1418, 275, 485, 362, 63, 1418, 8, 277, 14, 1102, 12, 291, 14, 2473, 12, 291, 14, 2060, 9, 398, 291, 14, 3088, 18, 354, 275, 488, 267, 291, 14, 3742, 63, 826, 275, 291, 14, 1418, 365, 440, 488, 339, 347, 8000, 63, 6410, 8, 277, 304, 267, 408, 15936, 367, 892, 7256, 436, 372, 282, 769, 543, 1911, 2243, 11449, 1041, 267, 291, 423, 873, 63, 815, 342, 267, 372, 291, 14, 2019, 63, 2604, 339, 347, 664, 63, 1782, 63, 354, 8, 277, 12, 2243, 304, 267, 408, 1767, 314, 536, 402, 314, 1627, 2243, 503, 488, 340, 781, 2793, 1133, 5715, 1041, 267, 340, 291, 14, 3088, 18, 354, 365, 488, 26, 288, 754, 275, 291, 423, 14270, 63, 513, 63, 1045, 63, 7154, 342, 288, 340, 754, 26, 355, 7057, 275, 359, 88, 367, 671, 315, 754, 340, 298, 3088, 2, 315, 671, 436, 298, 354, 2, 315, 671, 61, 355, 4497, 18, 354, 63, 513, 275, 3842, 88, 905, 3088, 4140, 4142, 1062, 671, 905, 354, 3135, 367, 671, 315, 7057, 61, 355, 291, 14, 3088, 18, 354, 275, 1211, 8, 3088, 18, 354, 63, 513, 9, 288, 587, 26, 355, 327, 4520, 12, 8860, 315, 314, 485, 14270, 63, 513, 63, 1045, 63, 7154, 355, 372, 267, 372, 291, 14, 3088, 18, 354, 14, 362, 8, 1782, 14, 4142, 1062, 488, 9, 339, 347, 485, 873, 63, 815, 8, 277, 304, 267, 408, 13913, 314, 2556, 687, 314, 6197, 787, 1536, 370, 1434, 14, 398, 1803, 2549, 340, 24928, 9512, 14, 267, 408, 267, 340, 440, 291, 14, 3742, 63, 826, 26, 288, 372, 756, 398, 754, 275, 291, 423, 14270, 63, 513, 63, 1045, 63, 7154, 342, 267, 340, 754, 26, 288, 291, 423, 1617, 63, 1099, 8, 1099, 9, 288, 372, 715, 267, 372, 756, 339, 347, 485, 14270, 63, 513, 63, 1045, 63, 7154, 8, 277, 304, 267, 408, 15310, 314, 2243, 769, 543, 282, 7269, 340, 1526, 365, 3866, 14, 398, 1432, 314, 769, 340, 9512, 14, 267, 408, 267, 485, 10186, 14, 815, 480, 18730, 316, 2243, 769, 531, 267, 754, 275, 485, 14270, 63, 513, 8, 277, 14, 1102, 12, 291, 14, 1418, 9, 267, 340, 754, 26, 288, 372, 754, 398, 485, 10186, 14, 815, 480, 18730, 316, 1526, 436, 7269, 316, 2243, 769, 9236, 531, 267, 291, 14, 1418, 275, 485, 362, 63, 1418, 8, 277, 14, 1102, 12, 291, 14, 2473, 12, 291, 14, 2060, 9, 267, 372, 485, 14270, 63, 513, 8, 277, 14, 1102, 12, 291, 14, 1418, 9, 339, 347, 485, 1617, 63, 1099, 8, 277, 12, 754, 304, 267, 408, 12147, 436, 3877, 314, 2243, 769, 315, 291, 14, 2019, 63, 2604, 1041, 267, 291, 14, 2019, 63, 2604, 275, 942, 267, 367, 2243, 63, 2373, 315, 754, 26, 288, 327, 2670, 340, 314, 2243, 365, 11584, 465, 8539, 288, 340, 1109, 8, 1782, 63, 2373, 905, 15178, 3135, 508, 413, 26, 355, 291, 14, 2019, 63, 2604, 14, 740, 8, 1782, 63, 2373, 905, 3088, 3135, 421, 199, 318, 485, 14270, 63, 513, 8, 1102, 12, 1526, 12, 1011, 958, 304, 272, 408, 1002, 2243, 769, 367, 314, 1627, 1591, 1041, 272, 1166, 275, 298, 1014, 921, 2440, 15, 13814, 13, 1393, 15, 10836, 559, 15, 27, 270, 745, 7622, 15, 1246, 15, 1292, 3045, 15, 1782, 513, 2, 272, 1166, 275, 1166, 14, 908, 8, 1102, 12, 1526, 9, 272, 862, 26, 267, 522, 275, 4145, 14, 362, 8, 633, 12, 2653, 29, 21, 12, 1011, 958, 9, 272, 871, 4145, 14, 3924, 14, 6372, 26, 267, 485, 10186, 14, 1971, 480, 3225, 370, 314, 6197, 18590, 734, 737, 2851, 450, 83, 401, 1166, 9, 267, 372, 272, 340, 522, 14, 1205, 63, 600, 1137, 3101, 63, 3593, 26, 267, 485, 10186, 14, 1971, 480, 3225, 3405, 543, 1455, 1233, 450, 83, 401, 522, 14, 1205, 63, 600, 9, 267, 372, 272, 862, 26, 267, 754, 275, 522, 14, 1001, 342, 272, 871, 1722, 26, 267, 327, 982, 2022, 10334, 4293, 440, 2198, 314, 1177, 267, 485, 10186, 14, 1971, 480, 4276, 370, 2198, 1177, 687, 10684, 6197, 531, 267, 372, 272, 862, 26, 267, 671, 4674, 676, 73, 63, 600, 275, 754, 905, 600, 937, 272, 871, 4067, 26, 267, 485, 10186, 14, 1971, 480, 1944, 901, 1233, 315, 1177, 687 ]
[ 11532, 367, 1323, 4674, 676, 73, 603, 73, 24464, 1041, 199, 646, 2050, 199, 199, 646, 4145, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 1782, 63, 8877, 492, 334, 272, 15265, 12, 272, 21966, 63, 10926, 12, 272, 12272, 20843, 12, 199, 9, 199, 504, 8846, 14, 1297, 492, 6392, 63, 5449, 12, 6392, 63, 9032, 12, 6392, 63, 11958, 12, 3101, 63, 3593, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 8, 272, 469, 267, 5236, 14, 8030, 8, 3103, 63, 5449, 304, 6277, 14, 875, 12, 267, 5236, 14, 8030, 8, 3103, 63, 11958, 12, 849, 628, 2113, 2349, 6277, 14, 875, 12, 267, 5236, 14, 8030, 8, 3103, 63, 9032, 304, 6277, 14, 875, 12, 272, 789, 199, 9, 421, 199, 318, 664, 63, 16378, 8, 5387, 12, 1101, 304, 272, 408, 12584, 314, 2897, 436, 372, 282, 1323, 4674, 676, 73, 12272, 28628, 1041, 272, 19121, 275, 1323, 4674, 676, 73, 2510, 20843, 8, 888, 59, 7378, 566, 339, 372, 19121, 340, 19121, 14, 3742, 63, 826, 587, 488, 421, 199, 533, 1323, 4674, 676, 73, 2510, 20843, 8, 2510, 20843, 304, 272, 408, 2765, 1021, 9212, 282, 1323, 4674, 676, 73, 603, 73, 6197, 14, 339, 4431, 18309, 687, 30936, 559, 19121, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1101, 304, 267, 408, 9345, 314, 19121, 1041, 267, 291, 14, 1102, 275, 1101, 59, 3103, 63, 5449, 61, 267, 291, 14, 2473, 275, 1101, 59, 3103, 63, 11958, 61, 267, 291, 14, 2060, 275, 1101, 59, 3103, 63, 9032, 61, 398, 291, 14, 2019, 63, 2604, 275, 1052, 267, 291, 14, 1418, 275, 485, 362, 63, 1418, 8, 277, 14, 1102, 12, 291, 14, 2473, 12, 291, 14, 2060, 9, 398, 291, 14, 3088, 18, 354, 275, 488, 267, 291, 14, 3742, 63, 826, 275, 291, 14, 1418, 365, 440, 488, 339, 347, 8000, 63, 6410, 8, 277, 304, 267, 408, 15936, 367, 892, 7256, 436, 372, 282, 769, 543, 1911, 2243, 11449, 1041, 267, 291, 423, 873, 63, 815, 342, 267, 372, 291, 14, 2019, 63, 2604, 339, 347, 664, 63, 1782, 63, 354, 8, 277, 12, 2243, 304, 267, 408, 1767, 314, 536, 402, 314, 1627, 2243, 503, 488, 340, 781, 2793, 1133, 5715, 1041, 267, 340, 291, 14, 3088, 18, 354, 365, 488, 26, 288, 754, 275, 291, 423, 14270, 63, 513, 63, 1045, 63, 7154, 342, 288, 340, 754, 26, 355, 7057, 275, 359, 88, 367, 671, 315, 754, 340, 298, 3088, 2, 315, 671, 436, 298, 354, 2, 315, 671, 61, 355, 4497, 18, 354, 63, 513, 275, 3842, 88, 905, 3088, 4140, 4142, 1062, 671, 905, 354, 3135, 367, 671, 315, 7057, 61, 355, 291, 14, 3088, 18, 354, 275, 1211, 8, 3088, 18, 354, 63, 513, 9, 288, 587, 26, 355, 327, 4520, 12, 8860, 315, 314, 485, 14270, 63, 513, 63, 1045, 63, 7154, 355, 372, 267, 372, 291, 14, 3088, 18, 354, 14, 362, 8, 1782, 14, 4142, 1062, 488, 9, 339, 347, 485, 873, 63, 815, 8, 277, 304, 267, 408, 13913, 314, 2556, 687, 314, 6197, 787, 1536, 370, 1434, 14, 398, 1803, 2549, 340, 24928, 9512, 14, 267, 408, 267, 340, 440, 291, 14, 3742, 63, 826, 26, 288, 372, 756, 398, 754, 275, 291, 423, 14270, 63, 513, 63, 1045, 63, 7154, 342, 267, 340, 754, 26, 288, 291, 423, 1617, 63, 1099, 8, 1099, 9, 288, 372, 715, 267, 372, 756, 339, 347, 485, 14270, 63, 513, 63, 1045, 63, 7154, 8, 277, 304, 267, 408, 15310, 314, 2243, 769, 543, 282, 7269, 340, 1526, 365, 3866, 14, 398, 1432, 314, 769, 340, 9512, 14, 267, 408, 267, 485, 10186, 14, 815, 480, 18730, 316, 2243, 769, 531, 267, 754, 275, 485, 14270, 63, 513, 8, 277, 14, 1102, 12, 291, 14, 1418, 9, 267, 340, 754, 26, 288, 372, 754, 398, 485, 10186, 14, 815, 480, 18730, 316, 1526, 436, 7269, 316, 2243, 769, 9236, 531, 267, 291, 14, 1418, 275, 485, 362, 63, 1418, 8, 277, 14, 1102, 12, 291, 14, 2473, 12, 291, 14, 2060, 9, 267, 372, 485, 14270, 63, 513, 8, 277, 14, 1102, 12, 291, 14, 1418, 9, 339, 347, 485, 1617, 63, 1099, 8, 277, 12, 754, 304, 267, 408, 12147, 436, 3877, 314, 2243, 769, 315, 291, 14, 2019, 63, 2604, 1041, 267, 291, 14, 2019, 63, 2604, 275, 942, 267, 367, 2243, 63, 2373, 315, 754, 26, 288, 327, 2670, 340, 314, 2243, 365, 11584, 465, 8539, 288, 340, 1109, 8, 1782, 63, 2373, 905, 15178, 3135, 508, 413, 26, 355, 291, 14, 2019, 63, 2604, 14, 740, 8, 1782, 63, 2373, 905, 3088, 3135, 421, 199, 318, 485, 14270, 63, 513, 8, 1102, 12, 1526, 12, 1011, 958, 304, 272, 408, 1002, 2243, 769, 367, 314, 1627, 1591, 1041, 272, 1166, 275, 298, 1014, 921, 2440, 15, 13814, 13, 1393, 15, 10836, 559, 15, 27, 270, 745, 7622, 15, 1246, 15, 1292, 3045, 15, 1782, 513, 2, 272, 1166, 275, 1166, 14, 908, 8, 1102, 12, 1526, 9, 272, 862, 26, 267, 522, 275, 4145, 14, 362, 8, 633, 12, 2653, 29, 21, 12, 1011, 958, 9, 272, 871, 4145, 14, 3924, 14, 6372, 26, 267, 485, 10186, 14, 1971, 480, 3225, 370, 314, 6197, 18590, 734, 737, 2851, 450, 83, 401, 1166, 9, 267, 372, 272, 340, 522, 14, 1205, 63, 600, 1137, 3101, 63, 3593, 26, 267, 485, 10186, 14, 1971, 480, 3225, 3405, 543, 1455, 1233, 450, 83, 401, 522, 14, 1205, 63, 600, 9, 267, 372, 272, 862, 26, 267, 754, 275, 522, 14, 1001, 342, 272, 871, 1722, 26, 267, 327, 982, 2022, 10334, 4293, 440, 2198, 314, 1177, 267, 485, 10186, 14, 1971, 480, 4276, 370, 2198, 1177, 687, 10684, 6197, 531, 267, 372, 272, 862, 26, 267, 671, 4674, 676, 73, 63, 600, 275, 754, 905, 600, 937, 272, 871, 4067, 26, 267,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
xiaolonginfo/decode-Django
Django-1.5.1/tests/regressiontests/expressions_regress/tests.py
46
15966
""" Spanning tests for all the operations that F() expressions can perform. """ from __future__ import absolute_import import datetime from django.db import connection from django.db.models import F from django.test import TestCase, Approximate, skipUnlessDBFeature from .models import Number, Experiment class ExpressionsRegressTests(TestCase): def setUp(self): Number(integer=-1).save() Number(integer=42).save() Number(integer=1337).save() self.assertEqual(Number.objects.update(float=F('integer')), 3) def test_fill_with_value_from_same_object(self): """ We can fill a value in all objects with an other value of the same object. """ self.assertQuerysetEqual( Number.objects.all(), [ '<Number: -1, -1.000>', '<Number: 42, 42.000>', '<Number: 1337, 1337.000>' ] ) def test_increment_value(self): """ We can increment a value of all objects in a query set. """ self.assertEqual( Number.objects.filter(integer__gt=0) .update(integer=F('integer') + 1), 2) self.assertQuerysetEqual( Number.objects.all(), [ '<Number: -1, -1.000>', '<Number: 43, 42.000>', '<Number: 1338, 1337.000>' ] ) def test_filter_not_equals_other_field(self): """ We can filter for objects, where a value is not equals the value of an other field. """ self.assertEqual( Number.objects.filter(integer__gt=0) .update(integer=F('integer') + 1), 2) self.assertQuerysetEqual( Number.objects.exclude(float=F('integer')), [ '<Number: 43, 42.000>', '<Number: 1338, 1337.000>' ] ) def test_complex_expressions(self): """ Complex expressions of different connection types are possible. """ n = Number.objects.create(integer=10, float=123.45) self.assertEqual(Number.objects.filter(pk=n.pk) .update(float=F('integer') + F('float') * 2), 1) self.assertEqual(Number.objects.get(pk=n.pk).integer, 10) self.assertEqual(Number.objects.get(pk=n.pk).float, Approximate(256.900, places=3)) class ExpressionOperatorTests(TestCase): def setUp(self): self.n = Number.objects.create(integer=42, float=15.5) def test_lefthand_addition(self): # LH Addition of floats and integers Number.objects.filter(pk=self.n.pk).update( integer=F('integer') + 15, float=F('float') + 42.7 ) self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 57) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(58.200, places=3)) def test_lefthand_subtraction(self): # LH Subtraction of floats and integers Number.objects.filter(pk=self.n.pk).update(integer=F('integer') - 15, float=F('float') - 42.7) self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 27) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(-27.200, places=3)) def test_lefthand_multiplication(self): # Multiplication of floats and integers Number.objects.filter(pk=self.n.pk).update(integer=F('integer') * 15, float=F('float') * 42.7) self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 630) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(661.850, places=3)) def test_lefthand_division(self): # LH Division of floats and integers Number.objects.filter(pk=self.n.pk).update(integer=F('integer') / 2, float=F('float') / 42.7) self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 21) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(0.363, places=3)) def test_lefthand_modulo(self): # LH Modulo arithmetic on integers Number.objects.filter(pk=self.n.pk).update(integer=F('integer') % 20) self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 2) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(15.500, places=3)) def test_lefthand_bitwise_and(self): # LH Bitwise ands on integers Number.objects.filter(pk=self.n.pk).update(integer=F('integer').bitand(56)) self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 40) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(15.500, places=3)) @skipUnlessDBFeature('supports_bitwise_or') def test_lefthand_bitwise_or(self): # LH Bitwise or on integers Number.objects.filter(pk=self.n.pk).update(integer=F('integer').bitor(48)) self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 58) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(15.500, places=3)) def test_right_hand_addition(self): # Right hand operators Number.objects.filter(pk=self.n.pk).update(integer=15 + F('integer'), float=42.7 + F('float')) # RH Addition of floats and integers self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 57) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(58.200, places=3)) def test_right_hand_subtraction(self): Number.objects.filter(pk=self.n.pk).update(integer=15 - F('integer'), float=42.7 - F('float')) # RH Subtraction of floats and integers self.assertEqual(Number.objects.get(pk=self.n.pk).integer, -27) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(27.200, places=3)) def test_right_hand_multiplication(self): # RH Multiplication of floats and integers Number.objects.filter(pk=self.n.pk).update(integer=15 * F('integer'), float=42.7 * F('float')) self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 630) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(661.850, places=3)) def test_right_hand_division(self): # RH Division of floats and integers Number.objects.filter(pk=self.n.pk).update(integer=640 / F('integer'), float=42.7 / F('float')) self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 15) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(2.755, places=3)) def test_right_hand_modulo(self): # RH Modulo arithmetic on integers Number.objects.filter(pk=self.n.pk).update(integer=69 % F('integer')) self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 27) self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(15.500, places=3)) class FTimeDeltaTests(TestCase): def setUp(self): sday = datetime.date(2010, 6, 25) stime = datetime.datetime(2010, 6, 25, 12, 15, 30, 747000) midnight = datetime.time(0) delta0 = datetime.timedelta(0) delta1 = datetime.timedelta(microseconds=253000) delta2 = datetime.timedelta(seconds=44) delta3 = datetime.timedelta(hours=21, minutes=8) delta4 = datetime.timedelta(days=10) # Test data is set so that deltas and delays will be # strictly increasing. self.deltas = [] self.delays = [] self.days_long = [] # e0: started same day as assigned, zero duration end = stime+delta0 e0 = Experiment.objects.create(name='e0', assigned=sday, start=stime, end=end, completed=end.date()) self.deltas.append(delta0) self.delays.append(e0.start- datetime.datetime.combine(e0.assigned, midnight)) self.days_long.append(e0.completed-e0.assigned) # e1: started one day after assigned, tiny duration, data # set so that end time has no fractional seconds, which # tests an edge case on sqlite. This Experiment is only # included in the test data when the DB supports microsecond # precision. if connection.features.supports_microsecond_precision: delay = datetime.timedelta(1) end = stime + delay + delta1 e1 = Experiment.objects.create(name='e1', assigned=sday, start=stime+delay, end=end, completed=end.date()) self.deltas.append(delta1) self.delays.append(e1.start- datetime.datetime.combine(e1.assigned, midnight)) self.days_long.append(e1.completed-e1.assigned) # e2: started three days after assigned, small duration end = stime+delta2 e2 = Experiment.objects.create(name='e2', assigned=sday-datetime.timedelta(3), start=stime, end=end, completed=end.date()) self.deltas.append(delta2) self.delays.append(e2.start- datetime.datetime.combine(e2.assigned, midnight)) self.days_long.append(e2.completed-e2.assigned) # e3: started four days after assigned, medium duration delay = datetime.timedelta(4) end = stime + delay + delta3 e3 = Experiment.objects.create(name='e3', assigned=sday, start=stime+delay, end=end, completed=end.date()) self.deltas.append(delta3) self.delays.append(e3.start- datetime.datetime.combine(e3.assigned, midnight)) self.days_long.append(e3.completed-e3.assigned) # e4: started 10 days after assignment, long duration end = stime + delta4 e4 = Experiment.objects.create(name='e4', assigned=sday-datetime.timedelta(10), start=stime, end=end, completed=end.date()) self.deltas.append(delta4) self.delays.append(e4.start- datetime.datetime.combine(e4.assigned, midnight)) self.days_long.append(e4.completed-e4.assigned) self.expnames = [e.name for e in Experiment.objects.all()] def test_delta_add(self): for i in range(len(self.deltas)): delta = self.deltas[i] test_set = [e.name for e in Experiment.objects.filter(end__lt=F('start')+delta)] self.assertEqual(test_set, self.expnames[:i]) test_set = [e.name for e in Experiment.objects.filter(end__lte=F('start')+delta)] self.assertEqual(test_set, self.expnames[:i+1]) def test_delta_subtract(self): for i in range(len(self.deltas)): delta = self.deltas[i] test_set = [e.name for e in Experiment.objects.filter(start__gt=F('end')-delta)] self.assertEqual(test_set, self.expnames[:i]) test_set = [e.name for e in Experiment.objects.filter(start__gte=F('end')-delta)] self.assertEqual(test_set, self.expnames[:i+1]) def test_exclude(self): for i in range(len(self.deltas)): delta = self.deltas[i] test_set = [e.name for e in Experiment.objects.exclude(end__lt=F('start')+delta)] self.assertEqual(test_set, self.expnames[i:]) test_set = [e.name for e in Experiment.objects.exclude(end__lte=F('start')+delta)] self.assertEqual(test_set, self.expnames[i+1:]) def test_date_comparison(self): for i in range(len(self.days_long)): days = self.days_long[i] test_set = [e.name for e in Experiment.objects.filter(completed__lt=F('assigned')+days)] self.assertEqual(test_set, self.expnames[:i]) test_set = [e.name for e in Experiment.objects.filter(completed__lte=F('assigned')+days)] self.assertEqual(test_set, self.expnames[:i+1]) @skipUnlessDBFeature("supports_mixed_date_datetime_comparisons") def test_mixed_comparisons1(self): for i in range(len(self.delays)): delay = self.delays[i] if not connection.features.supports_microsecond_precision: delay = datetime.timedelta(delay.days, delay.seconds) test_set = [e.name for e in Experiment.objects.filter(assigned__gt=F('start')-delay)] self.assertEqual(test_set, self.expnames[:i]) test_set = [e.name for e in Experiment.objects.filter(assigned__gte=F('start')-delay)] self.assertEqual(test_set, self.expnames[:i+1]) def test_mixed_comparisons2(self): delays = [datetime.timedelta(delay.days) for delay in self.delays] for i in range(len(delays)): delay = delays[i] test_set = [e.name for e in Experiment.objects.filter(start__lt=F('assigned')+delay)] self.assertEqual(test_set, self.expnames[:i]) test_set = [e.name for e in Experiment.objects.filter(start__lte=F('assigned')+delay+ datetime.timedelta(1))] self.assertEqual(test_set, self.expnames[:i+1]) def test_delta_update(self): for i in range(len(self.deltas)): delta = self.deltas[i] exps = Experiment.objects.all() expected_durations = [e.duration() for e in exps] expected_starts = [e.start+delta for e in exps] expected_ends = [e.end+delta for e in exps] Experiment.objects.update(start=F('start')+delta, end=F('end')+delta) exps = Experiment.objects.all() new_starts = [e.start for e in exps] new_ends = [e.end for e in exps] new_durations = [e.duration() for e in exps] self.assertEqual(expected_starts, new_starts) self.assertEqual(expected_ends, new_ends) self.assertEqual(expected_durations, new_durations) def test_delta_invalid_op_mult(self): raised = False try: r = repr(Experiment.objects.filter(end__lt=F('start')*self.deltas[0])) except TypeError: raised = True self.assertTrue(raised, "TypeError not raised on attempt to multiply datetime by timedelta.") def test_delta_invalid_op_div(self): raised = False try: r = repr(Experiment.objects.filter(end__lt=F('start')/self.deltas[0])) except TypeError: raised = True self.assertTrue(raised, "TypeError not raised on attempt to divide datetime by timedelta.") def test_delta_invalid_op_mod(self): raised = False try: r = repr(Experiment.objects.filter(end__lt=F('start')%self.deltas[0])) except TypeError: raised = True self.assertTrue(raised, "TypeError not raised on attempt to modulo divide datetime by timedelta.") def test_delta_invalid_op_and(self): raised = False try: r = repr(Experiment.objects.filter(end__lt=F('start').bitand(self.deltas[0]))) except TypeError: raised = True self.assertTrue(raised, "TypeError not raised on attempt to binary and a datetime with a timedelta.") def test_delta_invalid_op_or(self): raised = False try: r = repr(Experiment.objects.filter(end__lt=F('start').bitor(self.deltas[0]))) except TypeError: raised = True self.assertTrue(raised, "TypeError not raised on attempt to binary or a datetime with a timedelta.")
gpl-2.0
[ 624, 199, 5058, 11495, 2295, 367, 1006, 314, 5331, 626, 481, 342, 8455, 883, 5147, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2197, 199, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 697, 14, 992, 492, 481, 199, 504, 1639, 14, 396, 492, 7640, 12, 13450, 8221, 6897, 12, 3372, 5524, 18093, 199, 199, 504, 1275, 992, 492, 4860, 12, 23997, 421, 199, 533, 7910, 6274, 2872, 753, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 4860, 8, 4115, 4022, 17, 680, 2117, 342, 267, 4860, 8, 4115, 29, 2260, 680, 2117, 342, 267, 4860, 8, 4115, 29, 969, 1401, 680, 2117, 342, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 873, 8, 1609, 29, 38, 360, 4115, 3855, 650, 9, 339, 347, 511, 63, 4498, 63, 1045, 63, 585, 63, 504, 63, 7191, 63, 785, 8, 277, 304, 267, 408, 267, 2136, 883, 5554, 282, 574, 315, 1006, 2251, 543, 376, 1163, 574, 402, 314, 267, 2011, 909, 14, 267, 408, 267, 291, 14, 7108, 8, 355, 4860, 14, 1462, 14, 452, 1062, 355, 359, 490, 2650, 3259, 26, 446, 17, 12, 446, 17, 14, 1493, 4206, 490, 2650, 3259, 26, 5685, 12, 5685, 14, 1493, 4206, 490, 2650, 3259, 26, 413, 11062, 12, 413, 11062, 14, 1493, 3524, 355, 1622, 267, 776, 339, 347, 511, 63, 9728, 63, 585, 8, 277, 304, 267, 408, 267, 2136, 883, 11609, 282, 574, 402, 1006, 2251, 315, 282, 1827, 663, 14, 267, 408, 267, 291, 14, 629, 8, 288, 4860, 14, 1462, 14, 1541, 8, 4115, 363, 3308, 29, 16, 9, 2116, 1275, 873, 8, 4115, 29, 38, 360, 4115, 358, 435, 413, 395, 288, 499, 9, 398, 291, 14, 7108, 8, 355, 4860, 14, 1462, 14, 452, 1062, 355, 359, 490, 2650, 3259, 26, 446, 17, 12, 446, 17, 14, 1493, 4206, 490, 2650, 3259, 26, 11851, 12, 5685, 14, 1493, 4206, 490, 2650, 3259, 26, 413, 13744, 12, 413, 11062, 14, 1493, 3524, 355, 1622, 267, 776, 339, 347, 511, 63, 1541, 63, 1397, 63, 11332, 63, 1848, 63, 698, 8, 277, 304, 267, 408, 267, 2136, 883, 2457, 367, 2251, 12, 2382, 282, 574, 365, 440, 18527, 314, 574, 267, 402, 376, 1163, 901, 14, 267, 408, 267, 291, 14, 629, 8, 288, 4860, 14, 1462, 14, 1541, 8, 4115, 363, 3308, 29, 16, 9, 2116, 1275, 873, 8, 4115, 29, 38, 360, 4115, 358, 435, 413, 395, 288, 499, 9, 267, 291, 14, 7108, 8, 355, 4860, 14, 1462, 14, 5473, 8, 1609, 29, 38, 360, 4115, 3855, 355, 359, 490, 2650, 3259, 26, 11851, 12, 5685, 14, 1493, 4206, 490, 2650, 3259, 26, 413, 13744, 12, 413, 11062, 14, 1493, 3524, 355, 1622, 267, 776, 339, 347, 511, 63, 5254, 63, 15264, 8, 277, 304, 267, 408, 267, 19178, 8455, 402, 3365, 1950, 2943, 787, 3962, 14, 267, 408, 267, 302, 275, 4860, 14, 1462, 14, 981, 8, 4115, 29, 709, 12, 2069, 29, 4288, 14, 2322, 9, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 1541, 8, 2051, 29, 78, 14, 2051, 9, 1816, 1275, 873, 8, 1609, 29, 38, 360, 4115, 358, 435, 481, 360, 1609, 358, 627, 499, 395, 2079, 413, 9, 398, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 78, 14, 2051, 680, 4115, 12, 1616, 9, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 78, 14, 2051, 680, 1609, 12, 13450, 8221, 6897, 8, 3912, 14, 17518, 12, 9825, 29, 19, 430, 199, 199, 533, 22013, 7961, 2925, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 78, 275, 4860, 14, 1462, 14, 981, 8, 4115, 29, 2260, 12, 2069, 29, 1046, 14, 21, 9, 339, 347, 511, 63, 21491, 273, 460, 63, 26799, 8, 277, 304, 267, 327, 491, 40, 4431, 1671, 402, 15657, 436, 9446, 267, 4860, 14, 1462, 14, 1541, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 873, 8, 288, 3000, 29, 38, 360, 4115, 358, 435, 4114, 12, 288, 2069, 29, 38, 360, 1609, 358, 435, 5685, 14, 23, 267, 776, 398, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 4115, 12, 12699, 9, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 1609, 12, 13450, 8221, 6897, 8, 2010, 14, 1840, 12, 9825, 29, 19, 430, 339, 347, 511, 63, 21491, 273, 460, 63, 954, 26137, 8, 277, 304, 267, 327, 491, 40, 4804, 26137, 402, 15657, 436, 9446, 267, 4860, 14, 1462, 14, 1541, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 873, 8, 4115, 29, 38, 360, 4115, 358, 446, 4114, 12, 6343, 2069, 29, 38, 360, 1609, 358, 446, 5685, 14, 23, 9, 398, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 4115, 12, 8087, 9, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 1609, 12, 13450, 8221, 6897, 2801, 1465, 14, 1840, 12, 9825, 29, 19, 430, 339, 347, 511, 63, 21491, 273, 460, 63, 8016, 1863, 8, 277, 304, 267, 327, 603, 2092, 1863, 402, 15657, 436, 9446, 267, 4860, 14, 1462, 14, 1541, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 873, 8, 4115, 29, 38, 360, 4115, 358, 627, 4114, 12, 6343, 2069, 29, 38, 360, 1609, 358, 627, 5685, 14, 23, 9, 398, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 4115, 12, 1227, 1216, 9, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 1609, 12, 13450, 8221, 6897, 8, 19528, 14, 21419, 12, 9825, 29, 19, 430, 339, 347, 511, 63, 21491, 273, 460, 63, 25035, 8, 277, 304, 267, 327, 491, 40, 3757, 2317, 402, 15657, 436, 9446, 267, 4860, 14, 1462, 14, 1541, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 873, 8 ]
[ 199, 5058, 11495, 2295, 367, 1006, 314, 5331, 626, 481, 342, 8455, 883, 5147, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2197, 199, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 697, 14, 992, 492, 481, 199, 504, 1639, 14, 396, 492, 7640, 12, 13450, 8221, 6897, 12, 3372, 5524, 18093, 199, 199, 504, 1275, 992, 492, 4860, 12, 23997, 421, 199, 533, 7910, 6274, 2872, 753, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 4860, 8, 4115, 4022, 17, 680, 2117, 342, 267, 4860, 8, 4115, 29, 2260, 680, 2117, 342, 267, 4860, 8, 4115, 29, 969, 1401, 680, 2117, 342, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 873, 8, 1609, 29, 38, 360, 4115, 3855, 650, 9, 339, 347, 511, 63, 4498, 63, 1045, 63, 585, 63, 504, 63, 7191, 63, 785, 8, 277, 304, 267, 408, 267, 2136, 883, 5554, 282, 574, 315, 1006, 2251, 543, 376, 1163, 574, 402, 314, 267, 2011, 909, 14, 267, 408, 267, 291, 14, 7108, 8, 355, 4860, 14, 1462, 14, 452, 1062, 355, 359, 490, 2650, 3259, 26, 446, 17, 12, 446, 17, 14, 1493, 4206, 490, 2650, 3259, 26, 5685, 12, 5685, 14, 1493, 4206, 490, 2650, 3259, 26, 413, 11062, 12, 413, 11062, 14, 1493, 3524, 355, 1622, 267, 776, 339, 347, 511, 63, 9728, 63, 585, 8, 277, 304, 267, 408, 267, 2136, 883, 11609, 282, 574, 402, 1006, 2251, 315, 282, 1827, 663, 14, 267, 408, 267, 291, 14, 629, 8, 288, 4860, 14, 1462, 14, 1541, 8, 4115, 363, 3308, 29, 16, 9, 2116, 1275, 873, 8, 4115, 29, 38, 360, 4115, 358, 435, 413, 395, 288, 499, 9, 398, 291, 14, 7108, 8, 355, 4860, 14, 1462, 14, 452, 1062, 355, 359, 490, 2650, 3259, 26, 446, 17, 12, 446, 17, 14, 1493, 4206, 490, 2650, 3259, 26, 11851, 12, 5685, 14, 1493, 4206, 490, 2650, 3259, 26, 413, 13744, 12, 413, 11062, 14, 1493, 3524, 355, 1622, 267, 776, 339, 347, 511, 63, 1541, 63, 1397, 63, 11332, 63, 1848, 63, 698, 8, 277, 304, 267, 408, 267, 2136, 883, 2457, 367, 2251, 12, 2382, 282, 574, 365, 440, 18527, 314, 574, 267, 402, 376, 1163, 901, 14, 267, 408, 267, 291, 14, 629, 8, 288, 4860, 14, 1462, 14, 1541, 8, 4115, 363, 3308, 29, 16, 9, 2116, 1275, 873, 8, 4115, 29, 38, 360, 4115, 358, 435, 413, 395, 288, 499, 9, 267, 291, 14, 7108, 8, 355, 4860, 14, 1462, 14, 5473, 8, 1609, 29, 38, 360, 4115, 3855, 355, 359, 490, 2650, 3259, 26, 11851, 12, 5685, 14, 1493, 4206, 490, 2650, 3259, 26, 413, 13744, 12, 413, 11062, 14, 1493, 3524, 355, 1622, 267, 776, 339, 347, 511, 63, 5254, 63, 15264, 8, 277, 304, 267, 408, 267, 19178, 8455, 402, 3365, 1950, 2943, 787, 3962, 14, 267, 408, 267, 302, 275, 4860, 14, 1462, 14, 981, 8, 4115, 29, 709, 12, 2069, 29, 4288, 14, 2322, 9, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 1541, 8, 2051, 29, 78, 14, 2051, 9, 1816, 1275, 873, 8, 1609, 29, 38, 360, 4115, 358, 435, 481, 360, 1609, 358, 627, 499, 395, 2079, 413, 9, 398, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 78, 14, 2051, 680, 4115, 12, 1616, 9, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 78, 14, 2051, 680, 1609, 12, 13450, 8221, 6897, 8, 3912, 14, 17518, 12, 9825, 29, 19, 430, 199, 199, 533, 22013, 7961, 2925, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 78, 275, 4860, 14, 1462, 14, 981, 8, 4115, 29, 2260, 12, 2069, 29, 1046, 14, 21, 9, 339, 347, 511, 63, 21491, 273, 460, 63, 26799, 8, 277, 304, 267, 327, 491, 40, 4431, 1671, 402, 15657, 436, 9446, 267, 4860, 14, 1462, 14, 1541, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 873, 8, 288, 3000, 29, 38, 360, 4115, 358, 435, 4114, 12, 288, 2069, 29, 38, 360, 1609, 358, 435, 5685, 14, 23, 267, 776, 398, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 4115, 12, 12699, 9, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 1609, 12, 13450, 8221, 6897, 8, 2010, 14, 1840, 12, 9825, 29, 19, 430, 339, 347, 511, 63, 21491, 273, 460, 63, 954, 26137, 8, 277, 304, 267, 327, 491, 40, 4804, 26137, 402, 15657, 436, 9446, 267, 4860, 14, 1462, 14, 1541, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 873, 8, 4115, 29, 38, 360, 4115, 358, 446, 4114, 12, 6343, 2069, 29, 38, 360, 1609, 358, 446, 5685, 14, 23, 9, 398, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 4115, 12, 8087, 9, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 1609, 12, 13450, 8221, 6897, 2801, 1465, 14, 1840, 12, 9825, 29, 19, 430, 339, 347, 511, 63, 21491, 273, 460, 63, 8016, 1863, 8, 277, 304, 267, 327, 603, 2092, 1863, 402, 15657, 436, 9446, 267, 4860, 14, 1462, 14, 1541, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 873, 8, 4115, 29, 38, 360, 4115, 358, 627, 4114, 12, 6343, 2069, 29, 38, 360, 1609, 358, 627, 5685, 14, 23, 9, 398, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 4115, 12, 1227, 1216, 9, 267, 291, 14, 629, 8, 3259, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 78, 14, 2051, 680, 1609, 12, 13450, 8221, 6897, 8, 19528, 14, 21419, 12, 9825, 29, 19, 430, 339, 347, 511, 63, 21491, 273, 460, 63, 25035, 8, 277, 304, 267, 327, 491, 40, 3757, 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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 ]
yewang15215/django
tests/auth_tests/test_basic.py
12
7419
# -*- coding: utf-8 -*- from __future__ import unicode_literals import warnings from django.contrib.auth import get_user, get_user_model from django.contrib.auth.models import AnonymousUser, User from django.core.exceptions import ImproperlyConfigured from django.db import IntegrityError from django.http import HttpRequest from django.test import TestCase, override_settings from django.utils import translation from .models import CustomUser class BasicTestCase(TestCase): def test_user(self): "Users can be created and can set their password" u = User.objects.create_user('testuser', 'test@example.com', 'testpw') self.assertTrue(u.has_usable_password()) self.assertFalse(u.check_password('bad')) self.assertTrue(u.check_password('testpw')) # Check we can manually set an unusable password u.set_unusable_password() u.save() self.assertFalse(u.check_password('testpw')) self.assertFalse(u.has_usable_password()) u.set_password('testpw') self.assertTrue(u.check_password('testpw')) u.set_password(None) self.assertFalse(u.has_usable_password()) # Check username getter self.assertEqual(u.get_username(), 'testuser') # Check authentication/permissions self.assertFalse(u.is_anonymous) self.assertTrue(u.is_authenticated) self.assertFalse(u.is_staff) self.assertTrue(u.is_active) self.assertFalse(u.is_superuser) # Check API-based user creation with no password u2 = User.objects.create_user('testuser2', 'test2@example.com') self.assertFalse(u2.has_usable_password()) def test_unicode_username(self): User.objects.create_user('jörg') User.objects.create_user('Григорий') # Two equivalent unicode normalized usernames should be duplicates omega_username = 'iamtheΩ' # U+03A9 GREEK CAPITAL LETTER OMEGA ohm_username = 'iamtheΩ' # U+2126 OHM SIGN User.objects.create_user(ohm_username) with self.assertRaises(IntegrityError): User.objects.create_user(omega_username) def test_is_anonymous_authenticated_method_deprecation(self): deprecation_message = ( 'Using user.is_authenticated() and user.is_anonymous() as a ' 'method is deprecated. Remove the parentheses to use it as an ' 'attribute.' ) u = User.objects.create_user('testuser', 'test@example.com', 'testpw') # Backwards-compatibility callables with warnings.catch_warnings(record=True) as warns: warnings.simplefilter('always') self.assertFalse(u.is_anonymous()) self.assertEqual(len(warns), 1) self.assertEqual(str(warns[0].message), deprecation_message) with warnings.catch_warnings(record=True) as warns: warnings.simplefilter('always') self.assertTrue(u.is_authenticated()) self.assertEqual(len(warns), 1) self.assertEqual(str(warns[0].message), deprecation_message) def test_user_no_email(self): "Users can be created without an email" u = User.objects.create_user('testuser1') self.assertEqual(u.email, '') u2 = User.objects.create_user('testuser2', email='') self.assertEqual(u2.email, '') u3 = User.objects.create_user('testuser3', email=None) self.assertEqual(u3.email, '') def test_anonymous_user(self): "Check the properties of the anonymous user" a = AnonymousUser() self.assertIsNone(a.pk) self.assertEqual(a.username, '') self.assertEqual(a.get_username(), '') self.assertTrue(a.is_anonymous) self.assertFalse(a.is_authenticated) self.assertFalse(a.is_staff) self.assertFalse(a.is_active) self.assertFalse(a.is_superuser) self.assertEqual(a.groups.all().count(), 0) self.assertEqual(a.user_permissions.all().count(), 0) def test_anonymous_user_is_anonymous_authenticated_method_deprecation(self): a = AnonymousUser() deprecation_message = ( 'Using user.is_authenticated() and user.is_anonymous() as a ' 'method is deprecated. Remove the parentheses to use it as an ' 'attribute.' ) # Backwards-compatibility callables with warnings.catch_warnings(record=True) as warns: warnings.simplefilter('always') # prevent warnings from appearing as errors self.assertTrue(a.is_anonymous()) self.assertEqual(len(warns), 1) self.assertEqual(str(warns[0].message), deprecation_message) with warnings.catch_warnings(record=True) as warns: warnings.simplefilter('always') # prevent warnings from appearing as errors self.assertFalse(a.is_authenticated()) self.assertEqual(len(warns), 1) self.assertEqual(str(warns[0].message), deprecation_message) def test_superuser(self): "Check the creation and properties of a superuser" super = User.objects.create_superuser('super', 'super@example.com', 'super') self.assertTrue(super.is_superuser) self.assertTrue(super.is_active) self.assertTrue(super.is_staff) def test_get_user_model(self): "The current user model can be retrieved" self.assertEqual(get_user_model(), User) @override_settings(AUTH_USER_MODEL='auth_tests.CustomUser') def test_swappable_user(self): "The current user model can be swapped out for another" self.assertEqual(get_user_model(), CustomUser) with self.assertRaises(AttributeError): User.objects.all() @override_settings(AUTH_USER_MODEL='badsetting') def test_swappable_user_bad_setting(self): "The alternate user setting must point to something in the format app.model" with self.assertRaises(ImproperlyConfigured): get_user_model() @override_settings(AUTH_USER_MODEL='thismodel.doesntexist') def test_swappable_user_nonexistent_model(self): "The current user model must point to an installed model" with self.assertRaises(ImproperlyConfigured): get_user_model() def test_user_verbose_names_translatable(self): "Default User model verbose names are translatable (#19945)" with translation.override('en'): self.assertEqual(User._meta.verbose_name, 'user') self.assertEqual(User._meta.verbose_name_plural, 'users') with translation.override('es'): self.assertEqual(User._meta.verbose_name, 'usuario') self.assertEqual(User._meta.verbose_name_plural, 'usuarios') class TestGetUser(TestCase): def test_get_user_anonymous(self): request = HttpRequest() request.session = self.client.session user = get_user(request) self.assertIsInstance(user, AnonymousUser) def test_get_user(self): created_user = User.objects.create_user('testuser', 'test@example.com', 'testpw') self.client.login(username='testuser', password='testpw') request = HttpRequest() request.session = self.client.session user = get_user(request) self.assertIsInstance(user, User) self.assertEqual(user.username, created_user.username)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 3598, 199, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 12, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 29952, 12, 2876, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 492, 26864, 199, 504, 1639, 14, 1014, 492, 20730, 199, 504, 1639, 14, 396, 492, 7640, 12, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 492, 7761, 199, 199, 504, 1275, 992, 492, 8388, 1899, 421, 199, 533, 10082, 1746, 8, 1746, 304, 272, 347, 511, 63, 751, 8, 277, 304, 267, 298, 12117, 883, 506, 2737, 436, 883, 663, 3932, 2505, 2, 267, 399, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 297, 283, 396, 32, 2694, 14, 957, 297, 283, 396, 8796, 358, 267, 291, 14, 1815, 8, 85, 14, 1989, 63, 14418, 63, 2060, 1012, 267, 291, 14, 3334, 8, 85, 14, 1074, 63, 2060, 360, 4087, 1333, 267, 291, 14, 1815, 8, 85, 14, 1074, 63, 2060, 360, 396, 8796, 1333, 398, 327, 2670, 781, 883, 10250, 663, 376, 625, 14418, 2505, 267, 399, 14, 409, 63, 324, 14418, 63, 2060, 342, 267, 399, 14, 2117, 342, 267, 291, 14, 3334, 8, 85, 14, 1074, 63, 2060, 360, 396, 8796, 1333, 267, 291, 14, 3334, 8, 85, 14, 1989, 63, 14418, 63, 2060, 1012, 267, 399, 14, 409, 63, 2060, 360, 396, 8796, 358, 267, 291, 14, 1815, 8, 85, 14, 1074, 63, 2060, 360, 396, 8796, 1333, 267, 399, 14, 409, 63, 2060, 8, 403, 9, 267, 291, 14, 3334, 8, 85, 14, 1989, 63, 14418, 63, 2060, 1012, 398, 327, 2670, 3434, 15917, 267, 291, 14, 629, 8, 85, 14, 362, 63, 2473, 1062, 283, 21029, 358, 398, 327, 2670, 6299, 15, 6060, 267, 291, 14, 3334, 8, 85, 14, 374, 63, 12628, 9, 267, 291, 14, 1815, 8, 85, 14, 374, 63, 12177, 9, 267, 291, 14, 3334, 8, 85, 14, 374, 63, 7018, 9, 267, 291, 14, 1815, 8, 85, 14, 374, 63, 2682, 9, 267, 291, 14, 3334, 8, 85, 14, 374, 63, 11434, 9, 398, 327, 2670, 3261, 13, 6788, 922, 7143, 543, 949, 2505, 267, 399, 18, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 18, 297, 283, 396, 18, 32, 2694, 14, 957, 358, 267, 291, 14, 3334, 8, 85, 18, 14, 1989, 63, 14418, 63, 2060, 1012, 339, 347, 511, 63, 2975, 63, 2473, 8, 277, 304, 267, 2876, 14, 1462, 14, 981, 63, 751, 360, 74, 14614, 12430, 358, 267, 2876, 14, 1462, 14, 981, 63, 751, 360, 141, 242, 7753, 16863, 112, 26438, 16863, 118, 358, 267, 327, 16853, 7353, 2649, 9657, 922, 1247, 1077, 506, 15755, 267, 29566, 63, 2473, 275, 283, 17741, 1589, 139, 103, 7, 221, 327, 738, 11, 1644, 33, 25, 7571, 2678, 1578, 593, 31724, 267, 312, 14038, 63, 2473, 275, 283, 17741, 1589, 159, 227, 100, 7, 221, 327, 738, 11, 18, 7957, 593, 27699, 5056, 267, 2876, 14, 1462, 14, 981, 63, 751, 8, 79, 14038, 63, 2473, 9, 267, 543, 291, 14, 1855, 8, 24823, 304, 288, 2876, 14, 1462, 14, 981, 63, 751, 8, 23524, 63, 2473, 9, 339, 347, 511, 63, 374, 63, 12628, 63, 12177, 63, 765, 63, 15383, 8, 277, 304, 267, 17831, 63, 1188, 275, 334, 288, 283, 10369, 922, 14, 374, 63, 12177, 342, 436, 922, 14, 374, 63, 12628, 342, 465, 282, 283, 288, 283, 765, 365, 5906, 14, 5852, 314, 23592, 370, 675, 652, 465, 376, 283, 288, 283, 3215, 3530, 267, 776, 267, 399, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 297, 283, 396, 32, 2694, 14, 957, 297, 283, 396, 8796, 358, 267, 327, 10257, 4751, 13, 15390, 28041, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 3429, 561, 26, 288, 3598, 14, 18815, 360, 9223, 358, 288, 291, 14, 3334, 8, 85, 14, 374, 63, 12628, 1012, 288, 291, 14, 629, 8, 552, 8, 19811, 395, 413, 9, 288, 291, 14, 629, 8, 495, 8, 19811, 59, 16, 1055, 1188, 395, 17831, 63, 1188, 9, 398, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 3429, 561, 26, 288, 3598, 14, 18815, 360, 9223, 358, 288, 291, 14, 1815, 8, 85, 14, 374, 63, 12177, 1012, 288, 291, 14, 629, 8, 552, 8, 19811, 395, 413, 9, 288, 291, 14, 629, 8, 495, 8, 19811, 59, 16, 1055, 1188, 395, 17831, 63, 1188, 9, 339, 347, 511, 63, 751, 63, 889, 63, 2123, 8, 277, 304, 267, 298, 12117, 883, 506, 2737, 1928, 376, 3031, 2, 267, 399, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 17, 358, 267, 291, 14, 629, 8, 85, 14, 2123, 12, 4074, 398, 399, 18, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 18, 297, 3031, 13275, 267, 291, 14, 629, 8, 85, 18, 14, 2123, 12, 4074, 398, 399, 19, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 19, 297, 3031, 29, 403, 9, 267, 291, 14, 629, 8, 85, 19, 14, 2123, 12, 4074, 339, 347, 511, 63, 12628, 63, 751, 8, 277, 304, 267, 298, 1799, 314, 4382, 402, 314, 16535, 922, 2, 267, 282, 275, 29952, 342, 267, 291, 14, 7702, 8, 65, 14, 2051, 9, 267, 291, 14, 629, 8, 65, 14, 2473, 12, 4074, 267, 291, 14, 629, 8, 65, 14, 362, 63, 2473, 1062, 4074, 267, 291, 14, 1815, 8, 65, 14, 374, 63, 12628, 9, 267, 291, 14, 3334, 8, 65, 14, 374, 63, 12177, 9, 267, 291, 14, 3334, 8, 65, 14, 374, 63, 7018, 9, 267, 291, 14, 3334, 8, 65, 14, 374, 63, 2682, 9, 267, 291, 14, 3334, 8, 65, 14, 374, 63, 11434, 9, 267, 291, 14, 629, 8, 65, 14, 2634, 14, 452, 1252, 835, 1062, 378, 9, 267, 291, 14, 629, 8, 65, 14, 751, 63, 6060, 14, 452, 1252, 835, 1062, 378, 9, 339, 347, 511, 63, 12628, 63, 751, 63 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 3598, 199, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 12, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 29952, 12, 2876, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 492, 26864, 199, 504, 1639, 14, 1014, 492, 20730, 199, 504, 1639, 14, 396, 492, 7640, 12, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 492, 7761, 199, 199, 504, 1275, 992, 492, 8388, 1899, 421, 199, 533, 10082, 1746, 8, 1746, 304, 272, 347, 511, 63, 751, 8, 277, 304, 267, 298, 12117, 883, 506, 2737, 436, 883, 663, 3932, 2505, 2, 267, 399, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 297, 283, 396, 32, 2694, 14, 957, 297, 283, 396, 8796, 358, 267, 291, 14, 1815, 8, 85, 14, 1989, 63, 14418, 63, 2060, 1012, 267, 291, 14, 3334, 8, 85, 14, 1074, 63, 2060, 360, 4087, 1333, 267, 291, 14, 1815, 8, 85, 14, 1074, 63, 2060, 360, 396, 8796, 1333, 398, 327, 2670, 781, 883, 10250, 663, 376, 625, 14418, 2505, 267, 399, 14, 409, 63, 324, 14418, 63, 2060, 342, 267, 399, 14, 2117, 342, 267, 291, 14, 3334, 8, 85, 14, 1074, 63, 2060, 360, 396, 8796, 1333, 267, 291, 14, 3334, 8, 85, 14, 1989, 63, 14418, 63, 2060, 1012, 267, 399, 14, 409, 63, 2060, 360, 396, 8796, 358, 267, 291, 14, 1815, 8, 85, 14, 1074, 63, 2060, 360, 396, 8796, 1333, 267, 399, 14, 409, 63, 2060, 8, 403, 9, 267, 291, 14, 3334, 8, 85, 14, 1989, 63, 14418, 63, 2060, 1012, 398, 327, 2670, 3434, 15917, 267, 291, 14, 629, 8, 85, 14, 362, 63, 2473, 1062, 283, 21029, 358, 398, 327, 2670, 6299, 15, 6060, 267, 291, 14, 3334, 8, 85, 14, 374, 63, 12628, 9, 267, 291, 14, 1815, 8, 85, 14, 374, 63, 12177, 9, 267, 291, 14, 3334, 8, 85, 14, 374, 63, 7018, 9, 267, 291, 14, 1815, 8, 85, 14, 374, 63, 2682, 9, 267, 291, 14, 3334, 8, 85, 14, 374, 63, 11434, 9, 398, 327, 2670, 3261, 13, 6788, 922, 7143, 543, 949, 2505, 267, 399, 18, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 18, 297, 283, 396, 18, 32, 2694, 14, 957, 358, 267, 291, 14, 3334, 8, 85, 18, 14, 1989, 63, 14418, 63, 2060, 1012, 339, 347, 511, 63, 2975, 63, 2473, 8, 277, 304, 267, 2876, 14, 1462, 14, 981, 63, 751, 360, 74, 14614, 12430, 358, 267, 2876, 14, 1462, 14, 981, 63, 751, 360, 141, 242, 7753, 16863, 112, 26438, 16863, 118, 358, 267, 327, 16853, 7353, 2649, 9657, 922, 1247, 1077, 506, 15755, 267, 29566, 63, 2473, 275, 283, 17741, 1589, 139, 103, 7, 221, 327, 738, 11, 1644, 33, 25, 7571, 2678, 1578, 593, 31724, 267, 312, 14038, 63, 2473, 275, 283, 17741, 1589, 159, 227, 100, 7, 221, 327, 738, 11, 18, 7957, 593, 27699, 5056, 267, 2876, 14, 1462, 14, 981, 63, 751, 8, 79, 14038, 63, 2473, 9, 267, 543, 291, 14, 1855, 8, 24823, 304, 288, 2876, 14, 1462, 14, 981, 63, 751, 8, 23524, 63, 2473, 9, 339, 347, 511, 63, 374, 63, 12628, 63, 12177, 63, 765, 63, 15383, 8, 277, 304, 267, 17831, 63, 1188, 275, 334, 288, 283, 10369, 922, 14, 374, 63, 12177, 342, 436, 922, 14, 374, 63, 12628, 342, 465, 282, 283, 288, 283, 765, 365, 5906, 14, 5852, 314, 23592, 370, 675, 652, 465, 376, 283, 288, 283, 3215, 3530, 267, 776, 267, 399, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 297, 283, 396, 32, 2694, 14, 957, 297, 283, 396, 8796, 358, 267, 327, 10257, 4751, 13, 15390, 28041, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 3429, 561, 26, 288, 3598, 14, 18815, 360, 9223, 358, 288, 291, 14, 3334, 8, 85, 14, 374, 63, 12628, 1012, 288, 291, 14, 629, 8, 552, 8, 19811, 395, 413, 9, 288, 291, 14, 629, 8, 495, 8, 19811, 59, 16, 1055, 1188, 395, 17831, 63, 1188, 9, 398, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 3429, 561, 26, 288, 3598, 14, 18815, 360, 9223, 358, 288, 291, 14, 1815, 8, 85, 14, 374, 63, 12177, 1012, 288, 291, 14, 629, 8, 552, 8, 19811, 395, 413, 9, 288, 291, 14, 629, 8, 495, 8, 19811, 59, 16, 1055, 1188, 395, 17831, 63, 1188, 9, 339, 347, 511, 63, 751, 63, 889, 63, 2123, 8, 277, 304, 267, 298, 12117, 883, 506, 2737, 1928, 376, 3031, 2, 267, 399, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 17, 358, 267, 291, 14, 629, 8, 85, 14, 2123, 12, 4074, 398, 399, 18, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 18, 297, 3031, 13275, 267, 291, 14, 629, 8, 85, 18, 14, 2123, 12, 4074, 398, 399, 19, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 19, 297, 3031, 29, 403, 9, 267, 291, 14, 629, 8, 85, 19, 14, 2123, 12, 4074, 339, 347, 511, 63, 12628, 63, 751, 8, 277, 304, 267, 298, 1799, 314, 4382, 402, 314, 16535, 922, 2, 267, 282, 275, 29952, 342, 267, 291, 14, 7702, 8, 65, 14, 2051, 9, 267, 291, 14, 629, 8, 65, 14, 2473, 12, 4074, 267, 291, 14, 629, 8, 65, 14, 362, 63, 2473, 1062, 4074, 267, 291, 14, 1815, 8, 65, 14, 374, 63, 12628, 9, 267, 291, 14, 3334, 8, 65, 14, 374, 63, 12177, 9, 267, 291, 14, 3334, 8, 65, 14, 374, 63, 7018, 9, 267, 291, 14, 3334, 8, 65, 14, 374, 63, 2682, 9, 267, 291, 14, 3334, 8, 65, 14, 374, 63, 11434, 9, 267, 291, 14, 629, 8, 65, 14, 2634, 14, 452, 1252, 835, 1062, 378, 9, 267, 291, 14,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
vdemeester/docker-py
tests/integration/regression_test.py
4
2232
import io import random import docker import six from .base import BaseAPIIntegrationTest, TEST_IMG import pytest class TestRegressions(BaseAPIIntegrationTest): def test_443_handle_nonchunked_response_in_stream(self): dfile = io.BytesIO() with pytest.raises(docker.errors.APIError) as exc: for line in self.client.build(fileobj=dfile, tag="a/b/c"): pass assert exc.value.is_error() dfile.close() def test_542_truncate_ids_client_side(self): self.client.start( self.client.create_container(TEST_IMG, ['true']) ) result = self.client.containers(all=True, trunc=True) assert len(result[0]['Id']) == 12 def test_647_support_doubleslash_in_image_names(self): with pytest.raises(docker.errors.APIError): self.client.inspect_image('gensokyo.jp//kirisame') def test_649_handle_timeout_value_none(self): self.client.timeout = None ctnr = self.client.create_container(TEST_IMG, ['sleep', '2']) self.client.start(ctnr) self.client.stop(ctnr) def test_715_handle_user_param_as_int_value(self): ctnr = self.client.create_container(TEST_IMG, ['id', '-u'], user=1000) self.client.start(ctnr) self.client.wait(ctnr) logs = self.client.logs(ctnr) if six.PY3: logs = logs.decode('utf-8') assert logs == '1000\n' def test_792_explicit_port_protocol(self): tcp_port, udp_port = random.sample(range(9999, 32000), 2) ctnr = self.client.create_container( TEST_IMG, ['sleep', '9999'], ports=[2000, (2000, 'udp')], host_config=self.client.create_host_config( port_bindings={'2000/tcp': tcp_port, '2000/udp': udp_port} ) ) self.tmp_containers.append(ctnr) self.client.start(ctnr) assert self.client.port( ctnr, 2000 )[0]['HostPort'] == six.text_type(tcp_port) assert self.client.port( ctnr, '2000/tcp' )[0]['HostPort'] == six.text_type(tcp_port) assert self.client.port( ctnr, '2000/udp' )[0]['HostPort'] == six.text_type(udp_port)
apache-2.0
[ 646, 5890, 199, 646, 2196, 199, 199, 646, 12424, 199, 646, 3816, 199, 199, 504, 1275, 1095, 492, 3523, 3735, 20405, 774, 12, 7393, 63, 26246, 199, 646, 4613, 421, 199, 533, 1379, 2872, 6274, 8, 1563, 3735, 20405, 774, 304, 272, 347, 511, 63, 16284, 63, 2479, 63, 2865, 19955, 63, 1310, 63, 262, 63, 1745, 8, 277, 304, 267, 366, 493, 275, 5890, 14, 15466, 342, 267, 543, 4613, 14, 3536, 8, 9991, 14, 2550, 14, 3735, 547, 9, 465, 3178, 26, 288, 367, 1004, 315, 291, 14, 1258, 14, 1506, 8, 9234, 29, 68, 493, 12, 1947, 628, 65, 15, 66, 15, 67, 2349, 355, 986, 267, 702, 3178, 14, 585, 14, 374, 63, 705, 342, 267, 366, 493, 14, 1600, 342, 339, 347, 511, 63, 19861, 63, 12517, 63, 1580, 63, 1258, 63, 2441, 8, 277, 304, 267, 291, 14, 1258, 14, 928, 8, 288, 291, 14, 1258, 14, 981, 63, 3600, 8, 2864, 63, 26246, 12, 788, 2052, 1105, 267, 776, 267, 754, 275, 291, 14, 1258, 14, 13577, 8, 452, 29, 549, 12, 8181, 67, 29, 549, 9, 267, 702, 822, 8, 1099, 59, 16, 2733, 1304, 1105, 508, 3144, 339, 347, 511, 63, 8557, 63, 4058, 63, 3157, 7001, 63, 262, 63, 1569, 63, 1247, 8, 277, 304, 267, 543, 4613, 14, 3536, 8, 9991, 14, 2550, 14, 3735, 547, 304, 288, 291, 14, 1258, 14, 10955, 63, 1569, 360, 18278, 745, 16540, 14, 11538, 501, 8810, 5719, 313, 358, 339, 347, 511, 63, 11228, 63, 2479, 63, 2593, 63, 585, 63, 3592, 8, 277, 304, 267, 291, 14, 1258, 14, 2593, 275, 488, 267, 286, 5889, 82, 275, 291, 14, 1258, 14, 981, 63, 3600, 8, 2864, 63, 26246, 12, 788, 4532, 297, 283, 18, 1105, 267, 291, 14, 1258, 14, 928, 8, 319, 7865, 9, 267, 291, 14, 1258, 14, 2379, 8, 319, 7865, 9, 339, 347, 511, 63, 30028, 63, 2479, 63, 751, 63, 635, 63, 305, 63, 442, 63, 585, 8, 277, 304, 267, 286, 5889, 82, 275, 291, 14, 1258, 14, 981, 63, 3600, 8, 2864, 63, 26246, 12, 788, 344, 297, 2475, 85, 995, 922, 29, 5279, 9, 267, 291, 14, 1258, 14, 928, 8, 319, 7865, 9, 267, 291, 14, 1258, 14, 2573, 8, 319, 7865, 9, 267, 9610, 275, 291, 14, 1258, 14, 7270, 8, 319, 7865, 9, 267, 340, 3816, 14, 4521, 19, 26, 288, 9610, 275, 9610, 14, 2708, 360, 1624, 13, 24, 358, 267, 702, 9610, 508, 283, 5279, 60, 78, 7, 339, 347, 511, 63, 22364, 63, 10306, 63, 719, 63, 3922, 8, 277, 304, 398, 14719, 63, 719, 12, 18419, 63, 719, 275, 2196, 14, 3271, 8, 1842, 8, 5008, 12, 4337, 1493, 395, 499, 9, 267, 286, 5889, 82, 275, 291, 14, 1258, 14, 981, 63, 3600, 8, 288, 7393, 63, 26246, 12, 788, 4532, 297, 283, 5008, 995, 8873, 1524, 8269, 12, 334, 8269, 12, 283, 15036, 2665, 288, 1591, 63, 888, 29, 277, 14, 1258, 14, 981, 63, 1102, 63, 888, 8, 355, 1844, 63, 10880, 3713, 8269, 15, 8815, 356, 14719, 63, 719, 12, 283, 8269, 15, 15036, 356, 18419, 63, 719, 93, 288, 776, 267, 776, 267, 291, 14, 2791, 63, 13577, 14, 740, 8, 319, 7865, 9, 267, 291, 14, 1258, 14, 928, 8, 319, 7865, 9, 267, 702, 291, 14, 1258, 14, 719, 8, 288, 286, 5889, 82, 12, 12293, 267, 29688, 16, 2733, 4965, 4313, 418, 508, 3816, 14, 505, 63, 466, 8, 8815, 63, 719, 9, 267, 702, 291, 14, 1258, 14, 719, 8, 288, 286, 5889, 82, 12, 283, 8269, 15, 8815, 7, 267, 29688, 16, 2733, 4965, 4313, 418, 508, 3816, 14, 505, 63, 466, 8, 8815, 63, 719, 9, 267, 702, 291, 14, 1258, 14, 719, 8, 288, 286, 5889, 82, 12, 283, 8269, 15, 15036, 7, 267, 29688, 16, 2733, 4965, 4313, 418, 508, 3816, 14, 505, 63, 466, 8, 15036, 63, 719, 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 ]
[ 5890, 199, 646, 2196, 199, 199, 646, 12424, 199, 646, 3816, 199, 199, 504, 1275, 1095, 492, 3523, 3735, 20405, 774, 12, 7393, 63, 26246, 199, 646, 4613, 421, 199, 533, 1379, 2872, 6274, 8, 1563, 3735, 20405, 774, 304, 272, 347, 511, 63, 16284, 63, 2479, 63, 2865, 19955, 63, 1310, 63, 262, 63, 1745, 8, 277, 304, 267, 366, 493, 275, 5890, 14, 15466, 342, 267, 543, 4613, 14, 3536, 8, 9991, 14, 2550, 14, 3735, 547, 9, 465, 3178, 26, 288, 367, 1004, 315, 291, 14, 1258, 14, 1506, 8, 9234, 29, 68, 493, 12, 1947, 628, 65, 15, 66, 15, 67, 2349, 355, 986, 267, 702, 3178, 14, 585, 14, 374, 63, 705, 342, 267, 366, 493, 14, 1600, 342, 339, 347, 511, 63, 19861, 63, 12517, 63, 1580, 63, 1258, 63, 2441, 8, 277, 304, 267, 291, 14, 1258, 14, 928, 8, 288, 291, 14, 1258, 14, 981, 63, 3600, 8, 2864, 63, 26246, 12, 788, 2052, 1105, 267, 776, 267, 754, 275, 291, 14, 1258, 14, 13577, 8, 452, 29, 549, 12, 8181, 67, 29, 549, 9, 267, 702, 822, 8, 1099, 59, 16, 2733, 1304, 1105, 508, 3144, 339, 347, 511, 63, 8557, 63, 4058, 63, 3157, 7001, 63, 262, 63, 1569, 63, 1247, 8, 277, 304, 267, 543, 4613, 14, 3536, 8, 9991, 14, 2550, 14, 3735, 547, 304, 288, 291, 14, 1258, 14, 10955, 63, 1569, 360, 18278, 745, 16540, 14, 11538, 501, 8810, 5719, 313, 358, 339, 347, 511, 63, 11228, 63, 2479, 63, 2593, 63, 585, 63, 3592, 8, 277, 304, 267, 291, 14, 1258, 14, 2593, 275, 488, 267, 286, 5889, 82, 275, 291, 14, 1258, 14, 981, 63, 3600, 8, 2864, 63, 26246, 12, 788, 4532, 297, 283, 18, 1105, 267, 291, 14, 1258, 14, 928, 8, 319, 7865, 9, 267, 291, 14, 1258, 14, 2379, 8, 319, 7865, 9, 339, 347, 511, 63, 30028, 63, 2479, 63, 751, 63, 635, 63, 305, 63, 442, 63, 585, 8, 277, 304, 267, 286, 5889, 82, 275, 291, 14, 1258, 14, 981, 63, 3600, 8, 2864, 63, 26246, 12, 788, 344, 297, 2475, 85, 995, 922, 29, 5279, 9, 267, 291, 14, 1258, 14, 928, 8, 319, 7865, 9, 267, 291, 14, 1258, 14, 2573, 8, 319, 7865, 9, 267, 9610, 275, 291, 14, 1258, 14, 7270, 8, 319, 7865, 9, 267, 340, 3816, 14, 4521, 19, 26, 288, 9610, 275, 9610, 14, 2708, 360, 1624, 13, 24, 358, 267, 702, 9610, 508, 283, 5279, 60, 78, 7, 339, 347, 511, 63, 22364, 63, 10306, 63, 719, 63, 3922, 8, 277, 304, 398, 14719, 63, 719, 12, 18419, 63, 719, 275, 2196, 14, 3271, 8, 1842, 8, 5008, 12, 4337, 1493, 395, 499, 9, 267, 286, 5889, 82, 275, 291, 14, 1258, 14, 981, 63, 3600, 8, 288, 7393, 63, 26246, 12, 788, 4532, 297, 283, 5008, 995, 8873, 1524, 8269, 12, 334, 8269, 12, 283, 15036, 2665, 288, 1591, 63, 888, 29, 277, 14, 1258, 14, 981, 63, 1102, 63, 888, 8, 355, 1844, 63, 10880, 3713, 8269, 15, 8815, 356, 14719, 63, 719, 12, 283, 8269, 15, 15036, 356, 18419, 63, 719, 93, 288, 776, 267, 776, 267, 291, 14, 2791, 63, 13577, 14, 740, 8, 319, 7865, 9, 267, 291, 14, 1258, 14, 928, 8, 319, 7865, 9, 267, 702, 291, 14, 1258, 14, 719, 8, 288, 286, 5889, 82, 12, 12293, 267, 29688, 16, 2733, 4965, 4313, 418, 508, 3816, 14, 505, 63, 466, 8, 8815, 63, 719, 9, 267, 702, 291, 14, 1258, 14, 719, 8, 288, 286, 5889, 82, 12, 283, 8269, 15, 8815, 7, 267, 29688, 16, 2733, 4965, 4313, 418, 508, 3816, 14, 505, 63, 466, 8, 8815, 63, 719, 9, 267, 702, 291, 14, 1258, 14, 719, 8, 288, 286, 5889, 82, 12, 283, 8269, 15, 15036, 7, 267, 29688, 16, 2733, 4965, 4313, 418, 508, 3816, 14, 505, 63, 466, 8, 15036, 63, 719, 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,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, 0, 0, 0, 0, 0 ]
Workday/OpenFrame
tools/telemetry/catapult_base/refactor/offset_token.py
16
3155
# Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import collections import itertools import token import tokenize def _Pairwise(iterable): """s -> (None, s0), (s0, s1), (s1, s2), (s2, s3), ...""" a, b = itertools.tee(iterable) a = itertools.chain((None,), a) return itertools.izip(a, b) class OffsetToken(object): """A Python token with a relative position. A token is represented by a type defined in Python's token module, a string representing the content, and an offset. Using relative positions makes it easy to insert and remove tokens. """ def __init__(self, token_type, string, offset): self._type = token_type self._string = string self._offset = offset @property def type(self): return self._type @property def type_name(self): return token.tok_name[self._type] @property def string(self): return self._string @string.setter def string(self, value): self._string = value @property def offset(self): return self._offset def __str__(self): return str((self.type_name, self.string, self.offset)) def Tokenize(f): """Read tokens from a file-like object. Args: f: Any object that has a readline method. Returns: A collections.deque containing OffsetTokens. Deques are cheaper and easier to manipulate sequentially than lists. """ f.seek(0) tokenize_tokens = tokenize.generate_tokens(f.readline) offset_tokens = collections.deque() for prev_token, next_token in _Pairwise(tokenize_tokens): token_type, string, (srow, scol), _, _ = next_token if not prev_token: offset_tokens.append(OffsetToken(token_type, string, (0, 0))) else: erow, ecol = prev_token[3] if erow == srow: offset_tokens.append(OffsetToken(token_type, string, (0, scol-ecol))) else: offset_tokens.append(OffsetToken(token_type, string, (srow-erow, scol))) return offset_tokens def Untokenize(offset_tokens): """Return the string representation of an iterable of OffsetTokens.""" # Make a copy. Don't modify the original. offset_tokens = collections.deque(offset_tokens) # Strip leading NL tokens. while offset_tokens[0].type == tokenize.NL: offset_tokens.popleft() # Strip leading vertical whitespace. first_token = offset_tokens.popleft() # Take care not to modify the existing token. Create a new one in its place. first_token = OffsetToken(first_token.type, first_token.string, (0, first_token.offset[1])) offset_tokens.appendleft(first_token) # Convert OffsetTokens to tokenize tokens. tokenize_tokens = [] row = 1 col = 0 for t in offset_tokens: offset_row, offset_col = t.offset if offset_row == 0: col += offset_col else: row += offset_row col = offset_col tokenize_tokens.append((t.type, t.string, (row, col), (row, col), None)) # tokenize can't handle whitespace before line continuations. # So add a space. return tokenize.untokenize(tokenize_tokens).replace('\\\n', ' \\\n')
bsd-3-clause
[ 3, 1898, 6900, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 5055, 199, 646, 7975, 199, 646, 1526, 199, 646, 13343, 421, 199, 318, 485, 12882, 2605, 8, 8147, 304, 523, 408, 83, 1035, 334, 403, 12, 308, 16, 395, 334, 83, 16, 12, 308, 17, 395, 334, 83, 17, 12, 308, 18, 395, 334, 83, 18, 12, 308, 19, 395, 2508, 1041, 523, 282, 12, 330, 275, 7975, 14, 15557, 8, 8147, 9, 523, 282, 275, 7975, 14, 4429, 1332, 403, 4706, 282, 9, 523, 372, 7975, 14, 565, 711, 8, 65, 12, 330, 9, 421, 199, 533, 29432, 3264, 8, 785, 304, 523, 408, 33, 2018, 1526, 543, 282, 3847, 3421, 14, 819, 437, 1526, 365, 11159, 701, 282, 730, 3247, 315, 2018, 1159, 1526, 859, 12, 282, 1059, 523, 6144, 314, 1564, 12, 436, 376, 3268, 14, 11719, 3847, 12266, 7704, 652, 523, 8837, 370, 5518, 436, 2813, 4645, 14, 523, 408, 523, 347, 636, 826, 721, 277, 12, 1526, 63, 466, 12, 1059, 12, 3268, 304, 272, 291, 423, 466, 275, 1526, 63, 466, 272, 291, 423, 875, 275, 1059, 272, 291, 423, 2743, 275, 3268, 819, 768, 1829, 523, 347, 730, 8, 277, 304, 272, 372, 291, 423, 466, 819, 768, 1829, 523, 347, 730, 63, 354, 8, 277, 304, 272, 372, 1526, 14, 9305, 63, 354, 59, 277, 423, 466, 61, 819, 768, 1829, 523, 347, 1059, 8, 277, 304, 272, 372, 291, 423, 875, 819, 768, 875, 14, 8345, 523, 347, 1059, 8, 277, 12, 574, 304, 272, 291, 423, 875, 275, 574, 819, 768, 1829, 523, 347, 3268, 8, 277, 304, 272, 372, 291, 423, 2743, 819, 347, 636, 495, 721, 277, 304, 272, 372, 620, 1332, 277, 14, 466, 63, 354, 12, 291, 14, 875, 12, 291, 14, 2743, 430, 421, 199, 318, 8767, 794, 8, 70, 304, 523, 408, 3284, 4645, 687, 282, 570, 13, 2930, 909, 14, 819, 3033, 26, 272, 289, 26, 6184, 909, 626, 965, 282, 14441, 1083, 14, 819, 1803, 26, 272, 437, 5055, 14, 22983, 3035, 29432, 16419, 14, 1487, 19658, 787, 17546, 9804, 436, 14905, 272, 370, 27232, 542, 1514, 9406, 2419, 5548, 14, 523, 408, 523, 289, 14, 5507, 8, 16, 9, 523, 13343, 63, 4504, 275, 13343, 14, 4208, 63, 4504, 8, 70, 14, 6407, 9, 819, 3268, 63, 4504, 275, 5055, 14, 22983, 342, 523, 367, 5071, 63, 1418, 12, 2163, 63, 1418, 315, 485, 12882, 2605, 8, 15246, 63, 4504, 304, 272, 1526, 63, 466, 12, 1059, 12, 334, 83, 1143, 12, 308, 761, 395, 5501, 485, 275, 2163, 63, 1418, 272, 340, 440, 5071, 63, 1418, 26, 489, 3268, 63, 4504, 14, 740, 8, 6397, 3264, 8, 1418, 63, 466, 12, 1059, 12, 334, 16, 12, 378, 1724, 272, 587, 26, 489, 9266, 583, 12, 325, 761, 275, 5071, 63, 1418, 59, 19, 61, 489, 340, 9266, 583, 508, 308, 1143, 26, 267, 3268, 63, 4504, 14, 740, 8, 6397, 3264, 8, 1418, 63, 466, 12, 1059, 12, 334, 16, 12, 308, 761, 13, 69, 761, 1724, 489, 587, 26, 267, 3268, 63, 4504, 14, 740, 8, 6397, 3264, 8, 1418, 63, 466, 12, 1059, 12, 334, 83, 1143, 13, 281, 583, 12, 308, 761, 1724, 819, 372, 3268, 63, 4504, 421, 199, 318, 738, 343, 2858, 794, 8, 2743, 63, 4504, 304, 523, 408, 1767, 314, 1059, 6025, 402, 376, 6076, 402, 29432, 16419, 1041, 523, 327, 4155, 282, 1331, 14, 7529, 1133, 2811, 314, 3379, 14, 523, 3268, 63, 4504, 275, 5055, 14, 22983, 8, 2743, 63, 4504, 9, 819, 327, 19828, 9186, 24719, 4645, 14, 523, 1830, 3268, 63, 4504, 59, 16, 1055, 466, 508, 13343, 14, 14176, 26, 272, 3268, 63, 4504, 14, 25704, 342, 819, 327, 19828, 9186, 13763, 8139, 14, 523, 1642, 63, 1418, 275, 3268, 63, 4504, 14, 25704, 342, 523, 327, 18146, 10296, 440, 370, 2811, 314, 3411, 1526, 14, 2790, 282, 892, 1373, 315, 2399, 4192, 14, 523, 1642, 63, 1418, 275, 29432, 3264, 8, 2246, 63, 1418, 14, 466, 12, 1642, 63, 1418, 14, 875, 12, 1169, 334, 16, 12, 1642, 63, 1418, 14, 2743, 59, 17, 2459, 523, 3268, 63, 4504, 14, 740, 3039, 8, 2246, 63, 1418, 9, 819, 327, 7905, 29432, 16419, 370, 13343, 4645, 14, 523, 13343, 63, 4504, 275, 942, 523, 1962, 275, 413, 523, 1048, 275, 378, 523, 367, 307, 315, 3268, 63, 4504, 26, 272, 3268, 63, 1143, 12, 3268, 63, 761, 275, 307, 14, 2743, 272, 340, 3268, 63, 1143, 508, 378, 26, 489, 1048, 847, 3268, 63, 761, 272, 587, 26, 489, 1962, 847, 3268, 63, 1143, 489, 1048, 275, 3268, 63, 761, 272, 13343, 63, 4504, 14, 740, 1332, 84, 14, 466, 12, 307, 14, 875, 12, 334, 1143, 12, 1048, 395, 334, 1143, 12, 1048, 395, 488, 430, 819, 327, 13343, 883, 1133, 2429, 8139, 2544, 1004, 9832, 18012, 14, 523, 327, 2002, 1050, 282, 4601, 14, 523, 372, 13343, 14, 324, 15246, 8, 15246, 63, 4504, 680, 1814, 360, 9780, 78, 297, 283, 32432, 78, 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 ]
[ 1898, 6900, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 5055, 199, 646, 7975, 199, 646, 1526, 199, 646, 13343, 421, 199, 318, 485, 12882, 2605, 8, 8147, 304, 523, 408, 83, 1035, 334, 403, 12, 308, 16, 395, 334, 83, 16, 12, 308, 17, 395, 334, 83, 17, 12, 308, 18, 395, 334, 83, 18, 12, 308, 19, 395, 2508, 1041, 523, 282, 12, 330, 275, 7975, 14, 15557, 8, 8147, 9, 523, 282, 275, 7975, 14, 4429, 1332, 403, 4706, 282, 9, 523, 372, 7975, 14, 565, 711, 8, 65, 12, 330, 9, 421, 199, 533, 29432, 3264, 8, 785, 304, 523, 408, 33, 2018, 1526, 543, 282, 3847, 3421, 14, 819, 437, 1526, 365, 11159, 701, 282, 730, 3247, 315, 2018, 1159, 1526, 859, 12, 282, 1059, 523, 6144, 314, 1564, 12, 436, 376, 3268, 14, 11719, 3847, 12266, 7704, 652, 523, 8837, 370, 5518, 436, 2813, 4645, 14, 523, 408, 523, 347, 636, 826, 721, 277, 12, 1526, 63, 466, 12, 1059, 12, 3268, 304, 272, 291, 423, 466, 275, 1526, 63, 466, 272, 291, 423, 875, 275, 1059, 272, 291, 423, 2743, 275, 3268, 819, 768, 1829, 523, 347, 730, 8, 277, 304, 272, 372, 291, 423, 466, 819, 768, 1829, 523, 347, 730, 63, 354, 8, 277, 304, 272, 372, 1526, 14, 9305, 63, 354, 59, 277, 423, 466, 61, 819, 768, 1829, 523, 347, 1059, 8, 277, 304, 272, 372, 291, 423, 875, 819, 768, 875, 14, 8345, 523, 347, 1059, 8, 277, 12, 574, 304, 272, 291, 423, 875, 275, 574, 819, 768, 1829, 523, 347, 3268, 8, 277, 304, 272, 372, 291, 423, 2743, 819, 347, 636, 495, 721, 277, 304, 272, 372, 620, 1332, 277, 14, 466, 63, 354, 12, 291, 14, 875, 12, 291, 14, 2743, 430, 421, 199, 318, 8767, 794, 8, 70, 304, 523, 408, 3284, 4645, 687, 282, 570, 13, 2930, 909, 14, 819, 3033, 26, 272, 289, 26, 6184, 909, 626, 965, 282, 14441, 1083, 14, 819, 1803, 26, 272, 437, 5055, 14, 22983, 3035, 29432, 16419, 14, 1487, 19658, 787, 17546, 9804, 436, 14905, 272, 370, 27232, 542, 1514, 9406, 2419, 5548, 14, 523, 408, 523, 289, 14, 5507, 8, 16, 9, 523, 13343, 63, 4504, 275, 13343, 14, 4208, 63, 4504, 8, 70, 14, 6407, 9, 819, 3268, 63, 4504, 275, 5055, 14, 22983, 342, 523, 367, 5071, 63, 1418, 12, 2163, 63, 1418, 315, 485, 12882, 2605, 8, 15246, 63, 4504, 304, 272, 1526, 63, 466, 12, 1059, 12, 334, 83, 1143, 12, 308, 761, 395, 5501, 485, 275, 2163, 63, 1418, 272, 340, 440, 5071, 63, 1418, 26, 489, 3268, 63, 4504, 14, 740, 8, 6397, 3264, 8, 1418, 63, 466, 12, 1059, 12, 334, 16, 12, 378, 1724, 272, 587, 26, 489, 9266, 583, 12, 325, 761, 275, 5071, 63, 1418, 59, 19, 61, 489, 340, 9266, 583, 508, 308, 1143, 26, 267, 3268, 63, 4504, 14, 740, 8, 6397, 3264, 8, 1418, 63, 466, 12, 1059, 12, 334, 16, 12, 308, 761, 13, 69, 761, 1724, 489, 587, 26, 267, 3268, 63, 4504, 14, 740, 8, 6397, 3264, 8, 1418, 63, 466, 12, 1059, 12, 334, 83, 1143, 13, 281, 583, 12, 308, 761, 1724, 819, 372, 3268, 63, 4504, 421, 199, 318, 738, 343, 2858, 794, 8, 2743, 63, 4504, 304, 523, 408, 1767, 314, 1059, 6025, 402, 376, 6076, 402, 29432, 16419, 1041, 523, 327, 4155, 282, 1331, 14, 7529, 1133, 2811, 314, 3379, 14, 523, 3268, 63, 4504, 275, 5055, 14, 22983, 8, 2743, 63, 4504, 9, 819, 327, 19828, 9186, 24719, 4645, 14, 523, 1830, 3268, 63, 4504, 59, 16, 1055, 466, 508, 13343, 14, 14176, 26, 272, 3268, 63, 4504, 14, 25704, 342, 819, 327, 19828, 9186, 13763, 8139, 14, 523, 1642, 63, 1418, 275, 3268, 63, 4504, 14, 25704, 342, 523, 327, 18146, 10296, 440, 370, 2811, 314, 3411, 1526, 14, 2790, 282, 892, 1373, 315, 2399, 4192, 14, 523, 1642, 63, 1418, 275, 29432, 3264, 8, 2246, 63, 1418, 14, 466, 12, 1642, 63, 1418, 14, 875, 12, 1169, 334, 16, 12, 1642, 63, 1418, 14, 2743, 59, 17, 2459, 523, 3268, 63, 4504, 14, 740, 3039, 8, 2246, 63, 1418, 9, 819, 327, 7905, 29432, 16419, 370, 13343, 4645, 14, 523, 13343, 63, 4504, 275, 942, 523, 1962, 275, 413, 523, 1048, 275, 378, 523, 367, 307, 315, 3268, 63, 4504, 26, 272, 3268, 63, 1143, 12, 3268, 63, 761, 275, 307, 14, 2743, 272, 340, 3268, 63, 1143, 508, 378, 26, 489, 1048, 847, 3268, 63, 761, 272, 587, 26, 489, 1962, 847, 3268, 63, 1143, 489, 1048, 275, 3268, 63, 761, 272, 13343, 63, 4504, 14, 740, 1332, 84, 14, 466, 12, 307, 14, 875, 12, 334, 1143, 12, 1048, 395, 334, 1143, 12, 1048, 395, 488, 430, 819, 327, 13343, 883, 1133, 2429, 8139, 2544, 1004, 9832, 18012, 14, 523, 327, 2002, 1050, 282, 4601, 14, 523, 372, 13343, 14, 324, 15246, 8, 15246, 63, 4504, 680, 1814, 360, 9780, 78, 297, 283, 32432, 78, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1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_brkn2.py
1
2000
# Copyright (c) 2016 Sippy Software, Inc. All rights reserved. # # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation and/or # other materials provided with the distribution. # # 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. from test_cases.reinv_fail import a_test_reinv_fail from test_cases.reinvite import b_test_reinvite class a_test_reinv_brkn2(a_test_reinv_fail): cld = 'bob_reinv_brkn2' cli = 'alice_reinv_brkn2' def reinvite(self, ua): if not self.connect_done or self.disconnect_done: return sdp_body_bak = ua.lSDP ua.lSDP = sdp_body_bak.getCopy() for sect in ua.lSDP.content.sections: sect.c_header = None rval = a_test_reinv_fail.reinvite(self, ua) ua.lSDP = sdp_body_bak return rval class b_test_reinv_brkn2(b_test_reinvite): cli = 'bob_reinv_brkn2'
bsd-2-clause
[ 3, 1898, 334, 67, 9, 7800, 428, 711, 647, 2290, 12, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 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, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 436, 15, 269, 199, 3, 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, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 199, 3, 1821, 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, 1634, 5749, 199, 3, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 511, 63, 9403, 14, 264, 5350, 63, 1633, 492, 282, 63, 396, 63, 264, 5350, 63, 1633, 199, 504, 511, 63, 9403, 14, 264, 19061, 492, 330, 63, 396, 63, 264, 19061, 199, 199, 533, 282, 63, 396, 63, 264, 5350, 63, 3289, 18974, 18, 8, 65, 63, 396, 63, 264, 5350, 63, 1633, 304, 272, 824, 68, 275, 283, 7913, 63, 264, 5350, 63, 3289, 18974, 18, 7, 272, 5053, 275, 283, 19179, 63, 264, 5350, 63, 3289, 18974, 18, 7, 339, 347, 295, 19061, 8, 277, 12, 18500, 304, 267, 340, 440, 291, 14, 2242, 63, 4456, 503, 291, 14, 10673, 63, 4456, 26, 288, 372, 267, 308, 5780, 63, 2030, 63, 27162, 275, 18500, 14, 76, 3693, 48, 267, 18500, 14, 76, 3693, 48, 275, 308, 5780, 63, 2030, 63, 27162, 14, 362, 5116, 342, 267, 367, 21750, 315, 18500, 14, 76, 3693, 48, 14, 1317, 14, 7786, 26, 288, 21750, 14, 67, 63, 1291, 275, 488, 267, 15010, 275, 282, 63, 396, 63, 264, 5350, 63, 1633, 14, 264, 19061, 8, 277, 12, 18500, 9, 267, 18500, 14, 76, 3693, 48, 275, 308, 5780, 63, 2030, 63, 27162, 267, 372, 15010, 199, 199, 533, 330, 63, 396, 63, 264, 5350, 63, 3289, 18974, 18, 8, 66, 63, 396, 63, 264, 19061, 304, 272, 5053, 275, 283, 7913, 63, 264, 5350, 63, 3289, 18974, 18, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 7800, 428, 711, 647, 2290, 12, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 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, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 436, 15, 269, 199, 3, 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, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 199, 3, 1821, 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, 1634, 5749, 199, 3, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 511, 63, 9403, 14, 264, 5350, 63, 1633, 492, 282, 63, 396, 63, 264, 5350, 63, 1633, 199, 504, 511, 63, 9403, 14, 264, 19061, 492, 330, 63, 396, 63, 264, 19061, 199, 199, 533, 282, 63, 396, 63, 264, 5350, 63, 3289, 18974, 18, 8, 65, 63, 396, 63, 264, 5350, 63, 1633, 304, 272, 824, 68, 275, 283, 7913, 63, 264, 5350, 63, 3289, 18974, 18, 7, 272, 5053, 275, 283, 19179, 63, 264, 5350, 63, 3289, 18974, 18, 7, 339, 347, 295, 19061, 8, 277, 12, 18500, 304, 267, 340, 440, 291, 14, 2242, 63, 4456, 503, 291, 14, 10673, 63, 4456, 26, 288, 372, 267, 308, 5780, 63, 2030, 63, 27162, 275, 18500, 14, 76, 3693, 48, 267, 18500, 14, 76, 3693, 48, 275, 308, 5780, 63, 2030, 63, 27162, 14, 362, 5116, 342, 267, 367, 21750, 315, 18500, 14, 76, 3693, 48, 14, 1317, 14, 7786, 26, 288, 21750, 14, 67, 63, 1291, 275, 488, 267, 15010, 275, 282, 63, 396, 63, 264, 5350, 63, 1633, 14, 264, 19061, 8, 277, 12, 18500, 9, 267, 18500, 14, 76, 3693, 48, 275, 308, 5780, 63, 2030, 63, 27162, 267, 372, 15010, 199, 199, 533, 330, 63, 396, 63, 264, 5350, 63, 3289, 18974, 18, 8, 66, 63, 396, 63, 264, 19061, 304, 272, 5053, 275, 283, 7913, 63, 264, 5350, 63, 3289, 18974, 18, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
akosyakov/intellij-community
python/lib/Lib/stat.py
145
1667
"""Constants/functions for interpreting results of os.stat() and os.lstat(). Suggested usage: from stat import * """ # XXX Strictly spoken, this module may have to be adapted for each POSIX # implementation; in practice, however, the numeric constants used by # stat() are almost universal (even for stat() emulations on non-UNIX # systems like MS-DOS). # Indices for stat struct members in tuple returned by os.stat() ST_MODE = 0 ST_INO = 1 ST_DEV = 2 ST_NLINK = 3 ST_UID = 4 ST_GID = 5 ST_SIZE = 6 ST_ATIME = 7 ST_MTIME = 8 ST_CTIME = 9 # Extract bits from the mode def S_IMODE(mode): return mode & 07777 def S_IFMT(mode): return mode & 0170000 # Constants used as S_IFMT() for various file types # (not all are implemented on all systems) S_IFDIR = 0040000 S_IFCHR = 0020000 S_IFBLK = 0060000 S_IFREG = 0100000 S_IFIFO = 0010000 S_IFLNK = 0120000 S_IFSOCK = 0140000 # Functions to test for each file type def S_ISDIR(mode): return S_IFMT(mode) == S_IFDIR def S_ISCHR(mode): return S_IFMT(mode) == S_IFCHR def S_ISBLK(mode): return S_IFMT(mode) == S_IFBLK def S_ISREG(mode): return S_IFMT(mode) == S_IFREG def S_ISFIFO(mode): return S_IFMT(mode) == S_IFIFO def S_ISLNK(mode): return S_IFMT(mode) == S_IFLNK def S_ISSOCK(mode): return S_IFMT(mode) == S_IFSOCK # Names for permission bits S_ISUID = 04000 S_ISGID = 02000 S_ENFMT = S_ISGID S_ISVTX = 01000 S_IREAD = 00400 S_IWRITE = 00200 S_IEXEC = 00100 S_IRWXU = 00700 S_IRUSR = 00400 S_IWUSR = 00200 S_IXUSR = 00100 S_IRWXG = 00070 S_IRGRP = 00040 S_IWGRP = 00020 S_IXGRP = 00010 S_IRWXO = 00007 S_IROTH = 00004 S_IWOTH = 00002 S_IXOTH = 00001
apache-2.0
[ 624, 22185, 15, 5777, 367, 6421, 1337, 2058, 402, 747, 14, 3736, 342, 436, 747, 14, 26956, 1252, 199, 199, 51, 17417, 4503, 26, 687, 5672, 492, 627, 199, 624, 199, 199, 3, 5787, 23052, 590, 25664, 917, 12, 642, 859, 1443, 1172, 370, 506, 26266, 367, 1924, 18169, 199, 3, 4514, 27, 315, 24471, 12, 13432, 12, 314, 8950, 5262, 1202, 701, 199, 3, 5672, 342, 787, 18871, 17508, 334, 12056, 367, 5672, 342, 17423, 1298, 641, 2222, 13, 19584, 199, 3, 10460, 2839, 14282, 13, 32735, 680, 199, 199, 3, 1010, 12503, 367, 5672, 2702, 7556, 315, 2008, 2138, 701, 747, 14, 3736, 342, 199, 199, 840, 63, 6963, 221, 275, 378, 199, 840, 63, 568, 47, 257, 275, 413, 199, 840, 63, 13260, 257, 275, 499, 199, 840, 63, 46, 7916, 275, 650, 199, 840, 63, 6685, 257, 275, 841, 199, 840, 63, 39, 998, 257, 275, 959, 199, 840, 63, 4305, 221, 275, 1227, 199, 840, 63, 619, 3465, 275, 1520, 199, 840, 63, 45, 4961, 275, 1695, 199, 840, 63, 1028, 3465, 275, 1749, 199, 199, 3, 12892, 5821, 687, 314, 818, 199, 199, 318, 428, 63, 1469, 9125, 8, 632, 304, 272, 372, 818, 1253, 378, 16713, 199, 199, 318, 428, 63, 4656, 5747, 8, 632, 304, 272, 372, 818, 1253, 378, 1196, 993, 199, 199, 3, 22296, 1202, 465, 428, 63, 4656, 5747, 342, 367, 7750, 570, 2943, 199, 3, 334, 1397, 1006, 787, 6366, 641, 1006, 10460, 9, 199, 199, 51, 63, 4656, 3022, 221, 275, 378, 966, 993, 199, 51, 63, 4656, 1244, 50, 221, 275, 378, 996, 993, 199, 51, 63, 4656, 7847, 43, 221, 275, 378, 1690, 993, 199, 51, 63, 4656, 5616, 221, 275, 378, 15274, 199, 51, 63, 11100, 3230, 221, 275, 378, 614, 993, 199, 51, 63, 41, 3143, 22780, 221, 275, 378, 713, 993, 199, 51, 63, 4656, 9469, 275, 378, 1079, 993, 199, 199, 3, 17471, 370, 511, 367, 1924, 570, 730, 199, 199, 318, 428, 63, 1311, 3022, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 3022, 199, 199, 318, 428, 63, 1311, 1244, 50, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 1244, 50, 199, 199, 318, 428, 63, 1311, 7847, 43, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 7847, 43, 199, 199, 318, 428, 63, 1311, 5616, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 5616, 199, 199, 318, 428, 63, 1311, 20925, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 11100, 3230, 199, 199, 318, 428, 63, 1311, 44, 22780, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 41, 3143, 22780, 199, 199, 318, 428, 63, 1311, 9469, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 9469, 199, 199, 3, 23923, 367, 4983, 5821, 199, 199, 51, 63, 1311, 6685, 275, 378, 23641, 199, 51, 63, 1311, 39, 998, 275, 378, 8269, 199, 51, 63, 742, 22831, 275, 428, 63, 1311, 39, 998, 199, 51, 63, 1311, 8156, 56, 275, 378, 5279, 199, 51, 63, 41, 5670, 275, 378, 27130, 199, 51, 63, 41, 10387, 275, 378, 24215, 199, 51, 63, 41, 10276, 275, 378, 16569, 199, 51, 63, 3927, 16783, 53, 275, 378, 1780, 383, 199, 51, 63, 3927, 22592, 275, 378, 27130, 199, 51, 63, 22275, 22592, 275, 378, 24215, 199, 51, 63, 3867, 22592, 275, 378, 16569, 199, 51, 63, 3927, 16783, 39, 275, 21551, 2760, 199, 51, 63, 3927, 3975, 48, 275, 21551, 2167, 199, 51, 63, 22275, 3975, 48, 275, 378, 20734, 199, 51, 63, 3867, 3975, 48, 275, 378, 17657, 199, 51, 63, 3927, 16783, 47, 275, 378, 22530, 199, 51, 63, 41, 1092, 2080, 275, 378, 16643, 199, 51, 63, 22275, 22949, 275, 378, 9425, 199, 51, 63, 3867, 22949, 275, 378, 4183, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 22185, 15, 5777, 367, 6421, 1337, 2058, 402, 747, 14, 3736, 342, 436, 747, 14, 26956, 1252, 199, 199, 51, 17417, 4503, 26, 687, 5672, 492, 627, 199, 624, 199, 199, 3, 5787, 23052, 590, 25664, 917, 12, 642, 859, 1443, 1172, 370, 506, 26266, 367, 1924, 18169, 199, 3, 4514, 27, 315, 24471, 12, 13432, 12, 314, 8950, 5262, 1202, 701, 199, 3, 5672, 342, 787, 18871, 17508, 334, 12056, 367, 5672, 342, 17423, 1298, 641, 2222, 13, 19584, 199, 3, 10460, 2839, 14282, 13, 32735, 680, 199, 199, 3, 1010, 12503, 367, 5672, 2702, 7556, 315, 2008, 2138, 701, 747, 14, 3736, 342, 199, 199, 840, 63, 6963, 221, 275, 378, 199, 840, 63, 568, 47, 257, 275, 413, 199, 840, 63, 13260, 257, 275, 499, 199, 840, 63, 46, 7916, 275, 650, 199, 840, 63, 6685, 257, 275, 841, 199, 840, 63, 39, 998, 257, 275, 959, 199, 840, 63, 4305, 221, 275, 1227, 199, 840, 63, 619, 3465, 275, 1520, 199, 840, 63, 45, 4961, 275, 1695, 199, 840, 63, 1028, 3465, 275, 1749, 199, 199, 3, 12892, 5821, 687, 314, 818, 199, 199, 318, 428, 63, 1469, 9125, 8, 632, 304, 272, 372, 818, 1253, 378, 16713, 199, 199, 318, 428, 63, 4656, 5747, 8, 632, 304, 272, 372, 818, 1253, 378, 1196, 993, 199, 199, 3, 22296, 1202, 465, 428, 63, 4656, 5747, 342, 367, 7750, 570, 2943, 199, 3, 334, 1397, 1006, 787, 6366, 641, 1006, 10460, 9, 199, 199, 51, 63, 4656, 3022, 221, 275, 378, 966, 993, 199, 51, 63, 4656, 1244, 50, 221, 275, 378, 996, 993, 199, 51, 63, 4656, 7847, 43, 221, 275, 378, 1690, 993, 199, 51, 63, 4656, 5616, 221, 275, 378, 15274, 199, 51, 63, 11100, 3230, 221, 275, 378, 614, 993, 199, 51, 63, 41, 3143, 22780, 221, 275, 378, 713, 993, 199, 51, 63, 4656, 9469, 275, 378, 1079, 993, 199, 199, 3, 17471, 370, 511, 367, 1924, 570, 730, 199, 199, 318, 428, 63, 1311, 3022, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 3022, 199, 199, 318, 428, 63, 1311, 1244, 50, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 1244, 50, 199, 199, 318, 428, 63, 1311, 7847, 43, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 7847, 43, 199, 199, 318, 428, 63, 1311, 5616, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 5616, 199, 199, 318, 428, 63, 1311, 20925, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 11100, 3230, 199, 199, 318, 428, 63, 1311, 44, 22780, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 41, 3143, 22780, 199, 199, 318, 428, 63, 1311, 9469, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 9469, 199, 199, 3, 23923, 367, 4983, 5821, 199, 199, 51, 63, 1311, 6685, 275, 378, 23641, 199, 51, 63, 1311, 39, 998, 275, 378, 8269, 199, 51, 63, 742, 22831, 275, 428, 63, 1311, 39, 998, 199, 51, 63, 1311, 8156, 56, 275, 378, 5279, 199, 51, 63, 41, 5670, 275, 378, 27130, 199, 51, 63, 41, 10387, 275, 378, 24215, 199, 51, 63, 41, 10276, 275, 378, 16569, 199, 51, 63, 3927, 16783, 53, 275, 378, 1780, 383, 199, 51, 63, 3927, 22592, 275, 378, 27130, 199, 51, 63, 22275, 22592, 275, 378, 24215, 199, 51, 63, 3867, 22592, 275, 378, 16569, 199, 51, 63, 3927, 16783, 39, 275, 21551, 2760, 199, 51, 63, 3927, 3975, 48, 275, 21551, 2167, 199, 51, 63, 22275, 3975, 48, 275, 378, 20734, 199, 51, 63, 3867, 3975, 48, 275, 378, 17657, 199, 51, 63, 3927, 16783, 47, 275, 378, 22530, 199, 51, 63, 41, 1092, 2080, 275, 378, 16643, 199, 51, 63, 22275, 22949, 275, 378, 9425, 199, 51, 63, 3867, 22949, 275, 378, 4183, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
gameduell/duell
bin/win/python2.7.9/Lib/site-packages/pip/_vendor/requests/packages/chardet/langbulgarianmodel.py
2965
12784
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Communicator client code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### # 255: Control characters that usually does not exist in any text # 254: Carriage/Return # 253: symbol (punctuation) that does not belong to word # 252: 0 - 9 # Character Mapping Table: # this table is modified base on win1251BulgarianCharToOrderMap, so # only number <64 is sure valid Latin5_BulgarianCharToOrderMap = ( 255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10 253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20 252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30 253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 40 110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 50 253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 60 116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 70 194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209, # 80 210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225, # 90 81,226,227,228,229,230,105,231,232,233,234,235,236, 45,237,238, # a0 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # b0 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,239, 67,240, 60, 56, # c0 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # d0 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,241, 42, 16, # e0 62,242,243,244, 58,245, 98,246,247,248,249,250,251, 91,252,253, # f0 ) win1251BulgarianCharToOrderMap = ( 255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10 253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20 252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30 253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 40 110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 50 253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 60 116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 70 206,207,208,209,210,211,212,213,120,214,215,216,217,218,219,220, # 80 221, 78, 64, 83,121, 98,117,105,222,223,224,225,226,227,228,229, # 90 88,230,231,232,233,122, 89,106,234,235,236,237,238, 45,239,240, # a0 73, 80,118,114,241,242,243,244,245, 62, 58,246,247,248,249,250, # b0 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # c0 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,251, 67,252, 60, 56, # d0 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # e0 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,253, 42, 16, # f0 ) # Model Table: # total sequences: 100% # first 512 sequences: 96.9392% # first 1024 sequences:3.0618% # rest sequences: 0.2992% # negative sequences: 0.0020% BulgarianLangModel = ( 0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,2,2,3,2,2,1,2,2, 3,1,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,0,1, 0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,2,3,3,3,3,3,3,3,3,0,3,1,0, 0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0, 0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3,2,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0, 0,0,0,0,0,0,0,0,0,0,1,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0,0,0,0,1,0,0,0,0,0,0,0, 1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,2,0,0,2,0,1,0,0,1,0,0,1, 1,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0, 1,1,1,1,1,1,1,2,0,0,0,0,0,0,2,1,0,1,1,0,0,1,1,1,0,1,0,0,0,0,0,0, 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1,1,1,0,1,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, ) Latin5BulgarianModel = { 'charToOrderMap': Latin5_BulgarianCharToOrderMap, 'precedenceMatrix': BulgarianLangModel, 'mTypicalPositiveRatio': 0.969392, 'keepEnglishLetter': False, 'charsetName': "ISO-8859-5" } Win1251BulgarianModel = { 'charToOrderMap': win1251BulgarianCharToOrderMap, 'precedenceMatrix': BulgarianLangModel, 'mTypicalPositiveRatio': 0.969392, 'keepEnglishLetter': False, 'charsetName': "windows-1251" } # flake8: noqa
bsd-2-clause
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 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, 3, 5450, 26, 8612, 4110, 626, 9987, 1630, 440, 2187, 315, 1263, 1318, 199, 3, 22540, 26, 14243, 25220, 15, 1767, 199, 3, 26727, 26, 5272, 334, 25181, 9, 626, 1630, 440, 13511, 370, 4349, 199, 3, 27210, 26, 378, 446, 1749, 199, 199, 3, 17660, 12340, 6957, 26, 199, 3, 642, 1817, 365, 6042, 1300, 641, 4747, 21381, 34, 27092, 15289, 24516, 12, 880, 199, 3, 1454, 1329, 665, 772, 365, 3238, 1686, 199, 199, 27317, 21, 63, 34, 27092, 15289, 24516, 275, 334, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 221, 327, 8733, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 221, 327, 1616, 199, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 3388, 199, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 4233, 199, 3781, 12, 8375, 12, 9137, 12, 8806, 12, 1960, 12, 15323, 12, 6996, 12, 7555, 12, 4893, 12, 13734, 12, 10233, 12, 19071, 12, 7759, 12, 14646, 12, 18729, 12, 18051, 12, 221, 327, 6335, 199, 6019, 12, 11656, 12, 8079, 12, 21358, 12, 9720, 12, 7119, 12, 8264, 12, 15580, 12, 6673, 12, 11775, 12, 7680, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 5238, 199, 3781, 12, 11738, 12, 14610, 12, 10045, 12, 14157, 12, 13668, 12, 10851, 12, 6094, 12, 8845, 12, 20140, 12, 10860, 12, 6785, 12, 16102, 12, 10300, 12, 10513, 12, 17245, 12, 221, 327, 5212, 199, 7524, 12, 11874, 12, 16412, 12, 18969, 12, 15997, 12, 9225, 12, 10800, 12, 11165, 12, 10905, 12, 7155, 12, 1840, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 10045, 199, 10860, 12, 11874, 12, 10800, 12, 11165, 12, 10905, 12, 7155, 12, 1840, 12, 1797, 12, 4999, 12, 11341, 12, 6686, 12, 10629, 12, 11089, 12, 10744, 12, 10630, 12, 11303, 12, 221, 327, 5939, 199, 12725, 12, 12832, 12, 11722, 12, 14271, 12, 6886, 12, 7842, 12, 9669, 12, 9335, 12, 9252, 12, 8867, 12, 11174, 12, 11564, 12, 9485, 12, 11583, 12, 8731, 12, 10932, 12, 221, 327, 9137, 199, 19071, 12, 11085, 12, 11385, 12, 12048, 12, 11182, 12, 9687, 12, 7320, 12, 11921, 12, 8001, 12, 10034, 12, 5533, 12, 8276, 12, 10008, 12, 10416, 12, 10638, 12, 12332, 12, 221, 327, 282, 16, 199, 7105, 12, 4337, 12, 8685, 12, 11851, 12, 6877, 12, 10868, 12, 12766, 12, 10954, 12, 6335, 12, 8155, 12, 9404, 12, 12426, 12, 10448, 12, 8780, 12, 13385, 12, 4233, 12, 221, 327, 330, 16, 199, 10551, 12, 7294, 12, 8177, 12, 8026, 12, 9615, 12, 12260, 12, 13564, 12, 5238, 12, 13470, 12, 12699, 12, 17017, 12, 9803, 12, 13296, 12, 9873, 12, 5212, 12, 12001, 12, 221, 327, 286, 16, 523, 413, 12, 6155, 12, 221, 1749, 12, 3388, 12, 4119, 12, 221, 650, 12, 6546, 12, 4114, 12, 221, 499, 12, 7875, 12, 3144, 12, 1616, 12, 4329, 12, 221, 1227, 12, 221, 841, 12, 4944, 12, 221, 327, 366, 16, 523, 1520, 12, 221, 1695, 12, 221, 959, 12, 5851, 12, 7349, 12, 5661, 12, 6928, 12, 7829, 12, 8087, 12, 5504, 12, 5557, 12, 13098, 12, 14589, 12, 13571, 12, 5685, 12, 3193, 12, 221, 327, 325, 16, 199, 16202, 12, 13212, 12, 13440, 12, 11603, 12, 13713, 12, 11677, 12, 16096, 12, 11440, 12, 11717, 12, 11242, 12, 11032, 12, 7991, 12, 12140, 12, 21358, 12, 6390, 12, 3781, 12, 221, 327, 289, 16, 199, 9, 199, 199, 2676, 21381, 34, 27092, 15289, 24516, 275, 334, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 221, 327, 8733, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 221, 327, 1616, 199, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 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, 3, 5450, 26, 8612, 4110, 626, 9987, 1630, 440, 2187, 315, 1263, 1318, 199, 3, 22540, 26, 14243, 25220, 15, 1767, 199, 3, 26727, 26, 5272, 334, 25181, 9, 626, 1630, 440, 13511, 370, 4349, 199, 3, 27210, 26, 378, 446, 1749, 199, 199, 3, 17660, 12340, 6957, 26, 199, 3, 642, 1817, 365, 6042, 1300, 641, 4747, 21381, 34, 27092, 15289, 24516, 12, 880, 199, 3, 1454, 1329, 665, 772, 365, 3238, 1686, 199, 199, 27317, 21, 63, 34, 27092, 15289, 24516, 275, 334, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 221, 327, 8733, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 221, 327, 1616, 199, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 3388, 199, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 4233, 199, 3781, 12, 8375, 12, 9137, 12, 8806, 12, 1960, 12, 15323, 12, 6996, 12, 7555, 12, 4893, 12, 13734, 12, 10233, 12, 19071, 12, 7759, 12, 14646, 12, 18729, 12, 18051, 12, 221, 327, 6335, 199, 6019, 12, 11656, 12, 8079, 12, 21358, 12, 9720, 12, 7119, 12, 8264, 12, 15580, 12, 6673, 12, 11775, 12, 7680, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 5238, 199, 3781, 12, 11738, 12, 14610, 12, 10045, 12, 14157, 12, 13668, 12, 10851, 12, 6094, 12, 8845, 12, 20140, 12, 10860, 12, 6785, 12, 16102, 12, 10300, 12, 10513, 12, 17245, 12, 221, 327, 5212, 199, 7524, 12, 11874, 12, 16412, 12, 18969, 12, 15997, 12, 9225, 12, 10800, 12, 11165, 12, 10905, 12, 7155, 12, 1840, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 10045, 199, 10860, 12, 11874, 12, 10800, 12, 11165, 12, 10905, 12, 7155, 12, 1840, 12, 1797, 12, 4999, 12, 11341, 12, 6686, 12, 10629, 12, 11089, 12, 10744, 12, 10630, 12, 11303, 12, 221, 327, 5939, 199, 12725, 12, 12832, 12, 11722, 12, 14271, 12, 6886, 12, 7842, 12, 9669, 12, 9335, 12, 9252, 12, 8867, 12, 11174, 12, 11564, 12, 9485, 12, 11583, 12, 8731, 12, 10932, 12, 221, 327, 9137, 199, 19071, 12, 11085, 12, 11385, 12, 12048, 12, 11182, 12, 9687, 12, 7320, 12, 11921, 12, 8001, 12, 10034, 12, 5533, 12, 8276, 12, 10008, 12, 10416, 12, 10638, 12, 12332, 12, 221, 327, 282, 16, 199, 7105, 12, 4337, 12, 8685, 12, 11851, 12, 6877, 12, 10868, 12, 12766, 12, 10954, 12, 6335, 12, 8155, 12, 9404, 12, 12426, 12, 10448, 12, 8780, 12, 13385, 12, 4233, 12, 221, 327, 330, 16, 199, 10551, 12, 7294, 12, 8177, 12, 8026, 12, 9615, 12, 12260, 12, 13564, 12, 5238, 12, 13470, 12, 12699, 12, 17017, 12, 9803, 12, 13296, 12, 9873, 12, 5212, 12, 12001, 12, 221, 327, 286, 16, 523, 413, 12, 6155, 12, 221, 1749, 12, 3388, 12, 4119, 12, 221, 650, 12, 6546, 12, 4114, 12, 221, 499, 12, 7875, 12, 3144, 12, 1616, 12, 4329, 12, 221, 1227, 12, 221, 841, 12, 4944, 12, 221, 327, 366, 16, 523, 1520, 12, 221, 1695, 12, 221, 959, 12, 5851, 12, 7349, 12, 5661, 12, 6928, 12, 7829, 12, 8087, 12, 5504, 12, 5557, 12, 13098, 12, 14589, 12, 13571, 12, 5685, 12, 3193, 12, 221, 327, 325, 16, 199, 16202, 12, 13212, 12, 13440, 12, 11603, 12, 13713, 12, 11677, 12, 16096, 12, 11440, 12, 11717, 12, 11242, 12, 11032, 12, 7991, 12, 12140, 12, 21358, 12, 6390, 12, 3781, 12, 221, 327, 289, 16, 199, 9, 199, 199, 2676, 21381, 34, 27092, 15289, 24516, 275, 334, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 221, 327, 8733, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 221, 327, 1616, 199, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mringel/ThinkStats2
code/timeseries.py
66
18035
"""This file contains code for use with "Think Stats", by Allen B. Downey, available from greenteapress.com Copyright 2014 Allen B. Downey License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html """ from __future__ import print_function import pandas import numpy as np import statsmodels.formula.api as smf import statsmodels.tsa.stattools as smtsa import matplotlib.pyplot as pyplot import thinkplot import thinkstats2 FORMATS = ['png'] def ReadData(): """Reads data about cannabis transactions. http://zmjones.com/static/data/mj-clean.csv returns: DataFrame """ transactions = pandas.read_csv('mj-clean.csv', parse_dates=[5]) return transactions def tmean(series): """Computes a trimmed mean. series: Series returns: float """ t = series.values n = len(t) if n <= 3: return t.mean() trim = max(1, n/10) return np.mean(sorted(t)[trim:n-trim]) def GroupByDay(transactions, func=np.mean): """Groups transactions by day and compute the daily mean ppg. transactions: DataFrame of transactions returns: DataFrame of daily prices """ groups = transactions[['date', 'ppg']].groupby('date') daily = groups.aggregate(func) daily['date'] = daily.index start = daily.date[0] one_year = np.timedelta64(1, 'Y') daily['years'] = (daily.date - start) / one_year return daily def GroupByQualityAndDay(transactions): """Divides transactions by quality and computes mean daily price. transaction: DataFrame of transactions returns: map from quality to time series of ppg """ groups = transactions.groupby('quality') dailies = {} for name, group in groups: dailies[name] = GroupByDay(group) return dailies def PlotDailies(dailies): """Makes a plot with daily prices for different qualities. dailies: map from name to DataFrame """ thinkplot.PrePlot(rows=3) for i, (name, daily) in enumerate(dailies.items()): thinkplot.SubPlot(i+1) title = 'price per gram ($)' if i == 0 else '' thinkplot.Config(ylim=[0, 20], title=title) thinkplot.Scatter(daily.ppg, s=10, label=name) if i == 2: pyplot.xticks(rotation=30) else: thinkplot.Config(xticks=[]) thinkplot.Save(root='timeseries1', formats=FORMATS) def RunLinearModel(daily): """Runs a linear model of prices versus years. daily: DataFrame of daily prices returns: model, results """ model = smf.ols('ppg ~ years', data=daily) results = model.fit() return model, results def PlotFittedValues(model, results, label=''): """Plots original data and fitted values. model: StatsModel model object results: StatsModel results object """ years = model.exog[:, 1] values = model.endog thinkplot.Scatter(years, values, s=15, label=label) thinkplot.Plot(years, results.fittedvalues, label='model') def PlotResiduals(model, results): """Plots the residuals of a model. model: StatsModel model object results: StatsModel results object """ years = model.exog[:, 1] thinkplot.Plot(years, results.resid, linewidth=0.5, alpha=0.5) def PlotResidualPercentiles(model, results, index=1, num_bins=20): """Plots percentiles of the residuals. model: StatsModel model object results: StatsModel results object index: which exogenous variable to use num_bins: how many bins to divide the x-axis into """ exog = model.exog[:, index] resid = results.resid.values df = pandas.DataFrame(dict(exog=exog, resid=resid)) bins = np.linspace(np.min(exog), np.max(exog), num_bins) indices = np.digitize(exog, bins) groups = df.groupby(indices) means = [group.exog.mean() for _, group in groups][1:-1] cdfs = [thinkstats2.Cdf(group.resid) for _, group in groups][1:-1] thinkplot.PrePlot(3) for percent in [75, 50, 25]: percentiles = [cdf.Percentile(percent) for cdf in cdfs] label = '%dth' % percent thinkplot.Plot(means, percentiles, label=label) def SimulateResults(daily, iters=101, func=RunLinearModel): """Run simulations based on resampling residuals. daily: DataFrame of daily prices iters: number of simulations func: function that fits a model to the data returns: list of result objects """ _, results = func(daily) fake = daily.copy() result_seq = [] for _ in range(iters): fake.ppg = results.fittedvalues + thinkstats2.Resample(results.resid) _, fake_results = func(fake) result_seq.append(fake_results) return result_seq def SimulateIntervals(daily, iters=101, func=RunLinearModel): """Run simulations based on different subsets of the data. daily: DataFrame of daily prices iters: number of simulations func: function that fits a model to the data returns: list of result objects """ result_seq = [] starts = np.linspace(0, len(daily), iters).astype(int) for start in starts[:-2]: subset = daily[start:] _, results = func(subset) fake = subset.copy() for _ in range(iters): fake.ppg = (results.fittedvalues + thinkstats2.Resample(results.resid)) _, fake_results = func(fake) result_seq.append(fake_results) return result_seq def GeneratePredictions(result_seq, years, add_resid=False): """Generates an array of predicted values from a list of model results. When add_resid is False, predictions represent sampling error only. When add_resid is True, they also include residual error (which is more relevant to prediction). result_seq: list of model results years: sequence of times (in years) to make predictions for add_resid: boolean, whether to add in resampled residuals returns: sequence of predictions """ n = len(years) d = dict(Intercept=np.ones(n), years=years, years2=years**2) predict_df = pandas.DataFrame(d) predict_seq = [] for fake_results in result_seq: predict = fake_results.predict(predict_df) if add_resid: predict += thinkstats2.Resample(fake_results.resid, n) predict_seq.append(predict) return predict_seq def GenerateSimplePrediction(results, years): """Generates a simple prediction. results: results object years: sequence of times (in years) to make predictions for returns: sequence of predicted values """ n = len(years) inter = np.ones(n) d = dict(Intercept=inter, years=years, years2=years**2) predict_df = pandas.DataFrame(d) predict = results.predict(predict_df) return predict def PlotPredictions(daily, years, iters=101, percent=90, func=RunLinearModel): """Plots predictions. daily: DataFrame of daily prices years: sequence of times (in years) to make predictions for iters: number of simulations percent: what percentile range to show func: function that fits a model to the data """ result_seq = SimulateResults(daily, iters=iters, func=func) p = (100 - percent) / 2 percents = p, 100-p predict_seq = GeneratePredictions(result_seq, years, add_resid=True) low, high = thinkstats2.PercentileRows(predict_seq, percents) thinkplot.FillBetween(years, low, high, alpha=0.3, color='gray') predict_seq = GeneratePredictions(result_seq, years, add_resid=False) low, high = thinkstats2.PercentileRows(predict_seq, percents) thinkplot.FillBetween(years, low, high, alpha=0.5, color='gray') def PlotIntervals(daily, years, iters=101, percent=90, func=RunLinearModel): """Plots predictions based on different intervals. daily: DataFrame of daily prices years: sequence of times (in years) to make predictions for iters: number of simulations percent: what percentile range to show func: function that fits a model to the data """ result_seq = SimulateIntervals(daily, iters=iters, func=func) p = (100 - percent) / 2 percents = p, 100-p predict_seq = GeneratePredictions(result_seq, years, add_resid=True) low, high = thinkstats2.PercentileRows(predict_seq, percents) thinkplot.FillBetween(years, low, high, alpha=0.2, color='gray') def Correlate(dailies): """Compute the correlation matrix between prices for difference qualities. dailies: map from quality to time series of ppg returns: correlation matrix """ df = pandas.DataFrame() for name, daily in dailies.items(): df[name] = daily.ppg return df.corr() def CorrelateResid(dailies): """Compute the correlation matrix between residuals. dailies: map from quality to time series of ppg returns: correlation matrix """ df = pandas.DataFrame() for name, daily in dailies.items(): _, results = RunLinearModel(daily) df[name] = results.resid return df.corr() def TestCorrelateResid(dailies, iters=101): """Tests observed correlations. dailies: map from quality to time series of ppg iters: number of simulations """ t = [] names = ['high', 'medium', 'low'] for name in names: daily = dailies[name] t.append(SimulateResults(daily, iters=iters)) corr = CorrelateResid(dailies) arrays = [] for result_seq in zip(*t): df = pandas.DataFrame() for name, results in zip(names, result_seq): df[name] = results.resid opp_sign = corr * df.corr() < 0 arrays.append((opp_sign.astype(int))) print(np.sum(arrays)) def RunModels(dailies): """Runs linear regression for each group in dailies. dailies: map from group name to DataFrame """ rows = [] for daily in dailies.values(): _, results = RunLinearModel(daily) intercept, slope = results.params p1, p2 = results.pvalues r2 = results.rsquared s = r'%0.3f (%0.2g) & %0.3f (%0.2g) & %0.3f \\' row = s % (intercept, p1, slope, p2, r2) rows.append(row) # print results in a LaTeX table print(r'\begin{tabular}{|c|c|c|}') print(r'\hline') print(r'intercept & slope & $R^2$ \\ \hline') for row in rows: print(row) print(r'\hline') print(r'\end{tabular}') def FillMissing(daily, span=30): """Fills missing values with an exponentially weighted moving average. Resulting DataFrame has new columns 'ewma' and 'resid'. daily: DataFrame of daily prices span: window size (sort of) passed to ewma returns: new DataFrame of daily prices """ dates = pandas.date_range(daily.index.min(), daily.index.max()) reindexed = daily.reindex(dates) ewma = pandas.ewma(reindexed.ppg, span=span) resid = (reindexed.ppg - ewma).dropna() fake_data = ewma + thinkstats2.Resample(resid, len(reindexed)) reindexed.ppg.fillna(fake_data, inplace=True) reindexed['ewma'] = ewma reindexed['resid'] = reindexed.ppg - ewma return reindexed def AddWeeklySeasonality(daily): """Adds a weekly pattern. daily: DataFrame of daily prices returns: new DataFrame of daily prices """ frisat = (daily.index.dayofweek==4) | (daily.index.dayofweek==5) fake = daily.copy() fake.ppg[frisat] += np.random.uniform(0, 2, frisat.sum()) return fake def PrintSerialCorrelations(dailies): """Prints a table of correlations with different lags. dailies: map from category name to DataFrame of daily prices """ filled_dailies = {} for name, daily in dailies.items(): filled_dailies[name] = FillMissing(daily, span=30) # print serial correlations for raw price data for name, filled in filled_dailies.items(): corr = thinkstats2.SerialCorr(filled.ppg, lag=1) print(name, corr) rows = [] for lag in [1, 7, 30, 365]: row = [str(lag)] for name, filled in filled_dailies.items(): corr = thinkstats2.SerialCorr(filled.resid, lag) row.append('%.2g' % corr) rows.append(row) print(r'\begin{tabular}{|c|c|c|c|}') print(r'\hline') print(r'lag & high & medium & low \\ \hline') for row in rows: print(' & '.join(row) + r' \\') print(r'\hline') print(r'\end{tabular}') filled = filled_dailies['high'] acf = smtsa.acf(filled.resid, nlags=365, unbiased=True) print('%0.3f, %0.3f, %0.3f, %0.3f, %0.3f' % (acf[0], acf[1], acf[7], acf[30], acf[365])) def SimulateAutocorrelation(daily, iters=1001, nlags=40): """Resample residuals, compute autocorrelation, and plot percentiles. daily: DataFrame iters: number of simulations to run nlags: maximum lags to compute autocorrelation """ # run simulations t = [] for _ in range(iters): filled = FillMissing(daily, span=30) resid = thinkstats2.Resample(filled.resid) acf = smtsa.acf(resid, nlags=nlags, unbiased=True)[1:] t.append(np.abs(acf)) high = thinkstats2.PercentileRows(t, [97.5])[0] low = -high lags = range(1, nlags+1) thinkplot.FillBetween(lags, low, high, alpha=0.2, color='gray') def PlotAutoCorrelation(dailies, nlags=40, add_weekly=False): """Plots autocorrelation functions. dailies: map from category name to DataFrame of daily prices nlags: number of lags to compute add_weekly: boolean, whether to add a simulated weekly pattern """ thinkplot.PrePlot(3) daily = dailies['high'] SimulateAutocorrelation(daily) for name, daily in dailies.items(): if add_weekly: daily = AddWeeklySeasonality(daily) filled = FillMissing(daily, span=30) acf = smtsa.acf(filled.resid, nlags=nlags, unbiased=True) lags = np.arange(len(acf)) thinkplot.Plot(lags[1:], acf[1:], label=name) def MakeAcfPlot(dailies): """Makes a figure showing autocorrelation functions. dailies: map from category name to DataFrame of daily prices """ axis = [0, 41, -0.2, 0.2] thinkplot.PrePlot(cols=2) PlotAutoCorrelation(dailies, add_weekly=False) thinkplot.Config(axis=axis, loc='lower right', ylabel='correlation', xlabel='lag (day)') thinkplot.SubPlot(2) PlotAutoCorrelation(dailies, add_weekly=True) thinkplot.Save(root='timeseries9', axis=axis, loc='lower right', xlabel='lag (days)', formats=FORMATS) def PlotRollingMean(daily, name): """Plots rolling mean and EWMA. daily: DataFrame of daily prices """ dates = pandas.date_range(daily.index.min(), daily.index.max()) reindexed = daily.reindex(dates) thinkplot.PrePlot(cols=2) thinkplot.Scatter(reindexed.ppg, s=15, alpha=0.1, label=name) roll_mean = pandas.rolling_mean(reindexed.ppg, 30) thinkplot.Plot(roll_mean, label='rolling mean') pyplot.xticks(rotation=30) thinkplot.Config(ylabel='price per gram ($)') thinkplot.SubPlot(2) thinkplot.Scatter(reindexed.ppg, s=15, alpha=0.1, label=name) ewma = pandas.ewma(reindexed.ppg, span=30) thinkplot.Plot(ewma, label='EWMA') pyplot.xticks(rotation=30) thinkplot.Save(root='timeseries10', formats=FORMATS) def PlotFilled(daily, name): """Plots the EWMA and filled data. daily: DataFrame of daily prices """ filled = FillMissing(daily, span=30) thinkplot.Scatter(filled.ppg, s=15, alpha=0.3, label=name) thinkplot.Plot(filled.ewma, label='EWMA', alpha=0.4) pyplot.xticks(rotation=30) thinkplot.Save(root='timeseries8', ylabel='price per gram ($)', formats=FORMATS) def PlotLinearModel(daily, name): """Plots a linear fit to a sequence of prices, and the residuals. daily: DataFrame of daily prices name: string """ model, results = RunLinearModel(daily) PlotFittedValues(model, results, label=name) thinkplot.Save(root='timeseries2', title='fitted values', xlabel='years', xlim=[-0.1, 3.8], ylabel='price per gram ($)', formats=FORMATS) PlotResidualPercentiles(model, results) thinkplot.Save(root='timeseries3', title='residuals', xlabel='years', ylabel='price per gram ($)', formats=FORMATS) #years = np.linspace(0, 5, 101) #predict = GenerateSimplePrediction(results, years) def main(name): thinkstats2.RandomSeed(18) transactions = ReadData() dailies = GroupByQualityAndDay(transactions) PlotDailies(dailies) RunModels(dailies) PrintSerialCorrelations(dailies) MakeAcfPlot(dailies) name = 'high' daily = dailies[name] PlotLinearModel(daily, name) PlotRollingMean(daily, name) PlotFilled(daily, name) years = np.linspace(0, 5, 101) thinkplot.Scatter(daily.years, daily.ppg, alpha=0.1, label=name) PlotPredictions(daily, years) xlim = years[0]-0.1, years[-1]+0.1 thinkplot.Save(root='timeseries4', title='predictions', xlabel='years', xlim=xlim, ylabel='price per gram ($)', formats=FORMATS) name = 'medium' daily = dailies[name] thinkplot.Scatter(daily.years, daily.ppg, alpha=0.1, label=name) PlotIntervals(daily, years) PlotPredictions(daily, years) xlim = years[0]-0.1, years[-1]+0.1 thinkplot.Save(root='timeseries5', title='predictions', xlabel='years', xlim=xlim, ylabel='price per gram ($)', formats=FORMATS) if __name__ == '__main__': import sys main(*sys.argv)
gpl-3.0
[ 624, 2765, 570, 3509, 1233, 367, 675, 543, 298, 2719, 2292, 29062, 401, 199, 991, 4580, 552, 699, 14, 577, 583, 23263, 12, 2808, 687, 12431, 266, 439, 753, 14, 957, 199, 199, 7384, 6927, 4580, 552, 699, 14, 577, 583, 23263, 199, 3761, 26, 1664, 14629, 86, 19, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 10634, 199, 646, 2680, 465, 980, 199, 646, 5020, 992, 14, 16798, 14, 1246, 465, 4383, 70, 199, 646, 5020, 992, 14, 1086, 65, 14, 3736, 2537, 465, 4383, 1086, 65, 199, 199, 646, 8027, 14, 13563, 465, 1134, 2798, 199, 199, 646, 13516, 2798, 199, 646, 13516, 3200, 18, 199, 199, 14019, 275, 788, 4524, 418, 199, 199, 318, 5574, 1451, 837, 272, 408, 23614, 666, 3595, 883, 78, 371, 374, 15809, 14, 339, 1455, 921, 90, 77, 74, 4548, 14, 957, 15, 1986, 15, 576, 15, 77, 74, 13, 3118, 14, 4737, 339, 2529, 26, 10071, 272, 408, 272, 15809, 275, 10634, 14, 739, 63, 4737, 360, 77, 74, 13, 3118, 14, 4737, 297, 2198, 63, 9356, 1524, 21, 566, 272, 372, 15809, 421, 199, 318, 307, 3670, 8, 5602, 304, 272, 408, 22594, 282, 24196, 4615, 14, 339, 6779, 26, 12403, 18407, 2529, 26, 2069, 272, 408, 272, 307, 275, 6779, 14, 1459, 272, 302, 275, 822, 8, 84, 9, 272, 340, 302, 2695, 650, 26, 267, 372, 307, 14, 3670, 342, 272, 11639, 275, 1390, 8, 17, 12, 302, 15, 709, 9, 272, 372, 980, 14, 3670, 8, 5917, 8, 84, 2788, 12263, 26, 78, 13, 12263, 566, 421, 199, 318, 5611, 2175, 12631, 8, 13754, 12, 2562, 29, 1590, 14, 3670, 304, 272, 408, 10177, 15809, 701, 5382, 436, 4526, 314, 26122, 4615, 299, 4198, 14, 339, 15809, 26, 10071, 402, 15809, 339, 2529, 26, 10071, 402, 26122, 1979, 823, 272, 408, 272, 4652, 275, 15809, 59, 459, 602, 297, 283, 802, 71, 418, 1055, 16968, 360, 602, 358, 272, 26122, 275, 4652, 14, 7516, 8, 1532, 9, 339, 26122, 459, 602, 418, 275, 26122, 14, 1080, 272, 1343, 275, 26122, 14, 602, 59, 16, 61, 272, 1373, 63, 3403, 275, 980, 14, 7473, 772, 8, 17, 12, 283, 57, 358, 272, 26122, 459, 18431, 418, 275, 334, 18621, 14, 602, 446, 1343, 9, 1182, 1373, 63, 3403, 339, 372, 26122, 421, 199, 318, 5611, 2175, 19436, 3325, 12631, 8, 13754, 304, 272, 408, 1341, 9652, 15809, 701, 11030, 436, 21445, 4615, 26122, 8033, 14, 339, 6008, 26, 10071, 402, 15809, 2286, 2529, 26, 2341, 687, 11030, 370, 900, 6779, 402, 299, 4198, 272, 408, 272, 4652, 275, 15809, 14, 16968, 360, 9161, 358, 272, 12927, 20111, 275, 1052, 272, 367, 536, 12, 1572, 315, 4652, 26, 267, 12927, 20111, 59, 354, 61, 275, 5611, 2175, 12631, 8, 923, 9, 260, 339, 372, 12927, 20111, 421, 199, 318, 14794, 25014, 20111, 8, 983, 20111, 304, 272, 408, 27142, 282, 5137, 543, 26122, 1979, 823, 367, 3365, 6420, 12107, 14, 339, 12927, 20111, 26, 2341, 687, 536, 370, 10071, 272, 408, 272, 13516, 2798, 14, 2398, 10711, 8, 3838, 29, 19, 9, 272, 367, 284, 12, 334, 354, 12, 26122, 9, 315, 3874, 8, 983, 20111, 14, 1744, 5109, 267, 13516, 2798, 14, 2610, 10711, 8, 73, 11, 17, 9, 267, 2538, 275, 283, 4777, 1126, 1999, 77, 334, 4, 3171, 340, 284, 508, 378, 587, 2125, 267, 13516, 2798, 14, 2028, 8, 18123, 1524, 16, 12, 3388, 467, 2538, 29, 1213, 9, 267, 13516, 2798, 14, 51, 20569, 8, 18621, 14, 802, 71, 12, 308, 29, 709, 12, 1768, 29, 354, 9, 267, 340, 284, 508, 499, 26, 7205, 1134, 2798, 14, 26217, 8, 15362, 29, 1216, 9, 267, 587, 26, 288, 13516, 2798, 14, 2028, 8, 26217, 14285, 339, 13516, 2798, 14, 8229, 8, 1231, 534, 28551, 17, 297, 673, 6752, 29, 14019, 9, 421, 199, 318, 3378, 10608, 1685, 8, 18621, 304, 272, 408, 16291, 282, 7798, 1402, 402, 1979, 823, 809, 25253, 17399, 14, 339, 26122, 26, 10071, 402, 26122, 1979, 823, 339, 2529, 26, 1402, 12, 2058, 272, 408, 272, 1402, 275, 4383, 70, 14, 1446, 360, 802, 71, 6146, 17399, 297, 666, 29, 18621, 9, 272, 2058, 275, 1402, 14, 3269, 342, 272, 372, 1402, 12, 2058, 421, 199, 318, 14794, 13776, 471, 6550, 8, 1238, 12, 2058, 12, 1768, 9280, 272, 408, 48, 4555, 3379, 666, 436, 26093, 1338, 14, 339, 1402, 26, 29062, 1685, 1402, 909, 272, 2058, 26, 29062, 1685, 2058, 909, 272, 408, 272, 17399, 275, 1402, 14, 23919, 3981, 413, 61, 272, 1338, 275, 1402, 14, 27647, 272, 13516, 2798, 14, 51, 20569, 8, 18431, 12, 1338, 12, 308, 29, 1046, 12, 1768, 29, 1302, 9, 272, 13516, 2798, 14, 10711, 8, 18431, 12, 2058, 14, 21903, 1459, 12, 1768, 534, 1238, 358, 421, 199, 318, 14794, 497, 10969, 83, 8, 1238, 12, 2058, 304, 272, 408, 48, 4555, 314, 16731, 83, 402, 282, 1402, 14, 339, 1402, 26, 29062, 1685, 1402, 909, 272, 2058, 26, 29062, 1685, 2058, 909, 14821, 408, 272, 17399, 275, 1402, 14, 23919, 3981, 413, 61, 272, 13516, 2798, 14, 10711, 8, 18431, 12, 2058, 14, 19581, 12, 21213, 29, 16, 14, 21, 12, 5131, 29, 16, 14, 21, 9, 421, 199, 318, 14794, 497, 10969, 2623, 2497, 18819, 8, 1238, 12, 2058, 12, 1478, 29, 17, 12, 1967, 63, 11329, 29, 1165, 304, 272, 408, 48, 4555, 1126, 2497, 18819, 402, 314, 16731, 83, 14, 339, 1402, 26, 29062, 1685, 1402, 909, 272, 2058, 26, 29062, 1685, 2058, 909, 272, 1478, 26, 1314, 444, 26300, 1785, 1750, 370, 675, 272, 1967, 63, 11329, 26, 4212, 5002, 13341, 370, 23003, 314, 671, 13, 3127, 1901, 272, 408, 272, 444, 974, 275, 1402, 14, 23919, 3981, 1478, 61, 272, 23185, 275, 2058, 14, 19581, 14, 1459, 272, 4051, 275, 10634, 14, 9205, 8, 807, 8, 23919, 29, 23919, 12, 23185, 29, 19581, 430, 339, 13341, 275, 980, 14, 11649, 8, 1590, 14, 827, 8, 23919, 395, 980, 14, 988, 8, 23919, 395, 1967, 63, 11329, 9, 272, 4918 ]
[ 2765, 570, 3509, 1233, 367, 675, 543, 298, 2719, 2292, 29062, 401, 199, 991, 4580, 552, 699, 14, 577, 583, 23263, 12, 2808, 687, 12431, 266, 439, 753, 14, 957, 199, 199, 7384, 6927, 4580, 552, 699, 14, 577, 583, 23263, 199, 3761, 26, 1664, 14629, 86, 19, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 10634, 199, 646, 2680, 465, 980, 199, 646, 5020, 992, 14, 16798, 14, 1246, 465, 4383, 70, 199, 646, 5020, 992, 14, 1086, 65, 14, 3736, 2537, 465, 4383, 1086, 65, 199, 199, 646, 8027, 14, 13563, 465, 1134, 2798, 199, 199, 646, 13516, 2798, 199, 646, 13516, 3200, 18, 199, 199, 14019, 275, 788, 4524, 418, 199, 199, 318, 5574, 1451, 837, 272, 408, 23614, 666, 3595, 883, 78, 371, 374, 15809, 14, 339, 1455, 921, 90, 77, 74, 4548, 14, 957, 15, 1986, 15, 576, 15, 77, 74, 13, 3118, 14, 4737, 339, 2529, 26, 10071, 272, 408, 272, 15809, 275, 10634, 14, 739, 63, 4737, 360, 77, 74, 13, 3118, 14, 4737, 297, 2198, 63, 9356, 1524, 21, 566, 272, 372, 15809, 421, 199, 318, 307, 3670, 8, 5602, 304, 272, 408, 22594, 282, 24196, 4615, 14, 339, 6779, 26, 12403, 18407, 2529, 26, 2069, 272, 408, 272, 307, 275, 6779, 14, 1459, 272, 302, 275, 822, 8, 84, 9, 272, 340, 302, 2695, 650, 26, 267, 372, 307, 14, 3670, 342, 272, 11639, 275, 1390, 8, 17, 12, 302, 15, 709, 9, 272, 372, 980, 14, 3670, 8, 5917, 8, 84, 2788, 12263, 26, 78, 13, 12263, 566, 421, 199, 318, 5611, 2175, 12631, 8, 13754, 12, 2562, 29, 1590, 14, 3670, 304, 272, 408, 10177, 15809, 701, 5382, 436, 4526, 314, 26122, 4615, 299, 4198, 14, 339, 15809, 26, 10071, 402, 15809, 339, 2529, 26, 10071, 402, 26122, 1979, 823, 272, 408, 272, 4652, 275, 15809, 59, 459, 602, 297, 283, 802, 71, 418, 1055, 16968, 360, 602, 358, 272, 26122, 275, 4652, 14, 7516, 8, 1532, 9, 339, 26122, 459, 602, 418, 275, 26122, 14, 1080, 272, 1343, 275, 26122, 14, 602, 59, 16, 61, 272, 1373, 63, 3403, 275, 980, 14, 7473, 772, 8, 17, 12, 283, 57, 358, 272, 26122, 459, 18431, 418, 275, 334, 18621, 14, 602, 446, 1343, 9, 1182, 1373, 63, 3403, 339, 372, 26122, 421, 199, 318, 5611, 2175, 19436, 3325, 12631, 8, 13754, 304, 272, 408, 1341, 9652, 15809, 701, 11030, 436, 21445, 4615, 26122, 8033, 14, 339, 6008, 26, 10071, 402, 15809, 2286, 2529, 26, 2341, 687, 11030, 370, 900, 6779, 402, 299, 4198, 272, 408, 272, 4652, 275, 15809, 14, 16968, 360, 9161, 358, 272, 12927, 20111, 275, 1052, 272, 367, 536, 12, 1572, 315, 4652, 26, 267, 12927, 20111, 59, 354, 61, 275, 5611, 2175, 12631, 8, 923, 9, 260, 339, 372, 12927, 20111, 421, 199, 318, 14794, 25014, 20111, 8, 983, 20111, 304, 272, 408, 27142, 282, 5137, 543, 26122, 1979, 823, 367, 3365, 6420, 12107, 14, 339, 12927, 20111, 26, 2341, 687, 536, 370, 10071, 272, 408, 272, 13516, 2798, 14, 2398, 10711, 8, 3838, 29, 19, 9, 272, 367, 284, 12, 334, 354, 12, 26122, 9, 315, 3874, 8, 983, 20111, 14, 1744, 5109, 267, 13516, 2798, 14, 2610, 10711, 8, 73, 11, 17, 9, 267, 2538, 275, 283, 4777, 1126, 1999, 77, 334, 4, 3171, 340, 284, 508, 378, 587, 2125, 267, 13516, 2798, 14, 2028, 8, 18123, 1524, 16, 12, 3388, 467, 2538, 29, 1213, 9, 267, 13516, 2798, 14, 51, 20569, 8, 18621, 14, 802, 71, 12, 308, 29, 709, 12, 1768, 29, 354, 9, 267, 340, 284, 508, 499, 26, 7205, 1134, 2798, 14, 26217, 8, 15362, 29, 1216, 9, 267, 587, 26, 288, 13516, 2798, 14, 2028, 8, 26217, 14285, 339, 13516, 2798, 14, 8229, 8, 1231, 534, 28551, 17, 297, 673, 6752, 29, 14019, 9, 421, 199, 318, 3378, 10608, 1685, 8, 18621, 304, 272, 408, 16291, 282, 7798, 1402, 402, 1979, 823, 809, 25253, 17399, 14, 339, 26122, 26, 10071, 402, 26122, 1979, 823, 339, 2529, 26, 1402, 12, 2058, 272, 408, 272, 1402, 275, 4383, 70, 14, 1446, 360, 802, 71, 6146, 17399, 297, 666, 29, 18621, 9, 272, 2058, 275, 1402, 14, 3269, 342, 272, 372, 1402, 12, 2058, 421, 199, 318, 14794, 13776, 471, 6550, 8, 1238, 12, 2058, 12, 1768, 9280, 272, 408, 48, 4555, 3379, 666, 436, 26093, 1338, 14, 339, 1402, 26, 29062, 1685, 1402, 909, 272, 2058, 26, 29062, 1685, 2058, 909, 272, 408, 272, 17399, 275, 1402, 14, 23919, 3981, 413, 61, 272, 1338, 275, 1402, 14, 27647, 272, 13516, 2798, 14, 51, 20569, 8, 18431, 12, 1338, 12, 308, 29, 1046, 12, 1768, 29, 1302, 9, 272, 13516, 2798, 14, 10711, 8, 18431, 12, 2058, 14, 21903, 1459, 12, 1768, 534, 1238, 358, 421, 199, 318, 14794, 497, 10969, 83, 8, 1238, 12, 2058, 304, 272, 408, 48, 4555, 314, 16731, 83, 402, 282, 1402, 14, 339, 1402, 26, 29062, 1685, 1402, 909, 272, 2058, 26, 29062, 1685, 2058, 909, 14821, 408, 272, 17399, 275, 1402, 14, 23919, 3981, 413, 61, 272, 13516, 2798, 14, 10711, 8, 18431, 12, 2058, 14, 19581, 12, 21213, 29, 16, 14, 21, 12, 5131, 29, 16, 14, 21, 9, 421, 199, 318, 14794, 497, 10969, 2623, 2497, 18819, 8, 1238, 12, 2058, 12, 1478, 29, 17, 12, 1967, 63, 11329, 29, 1165, 304, 272, 408, 48, 4555, 1126, 2497, 18819, 402, 314, 16731, 83, 14, 339, 1402, 26, 29062, 1685, 1402, 909, 272, 2058, 26, 29062, 1685, 2058, 909, 272, 1478, 26, 1314, 444, 26300, 1785, 1750, 370, 675, 272, 1967, 63, 11329, 26, 4212, 5002, 13341, 370, 23003, 314, 671, 13, 3127, 1901, 272, 408, 272, 444, 974, 275, 1402, 14, 23919, 3981, 1478, 61, 272, 23185, 275, 2058, 14, 19581, 14, 1459, 272, 4051, 275, 10634, 14, 9205, 8, 807, 8, 23919, 29, 23919, 12, 23185, 29, 19581, 430, 339, 13341, 275, 980, 14, 11649, 8, 1590, 14, 827, 8, 23919, 395, 980, 14, 988, 8, 23919, 395, 1967, 63, 11329, 9, 272, 4918, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
spacewalkproject/spacewalk
java/scripts/api/managechannel.py
16
2371
#!/usr/bin/python """ Script to : - create unique channels for given users - Push Content to the same for each user """ import os import xmlrpclib # Setup SATELLITE_HOST = "test10-64.rhndev.redhat.com" SATELLITE_URL = "http://%s/rpc/api" % SATELLITE_HOST SATELLITE_LOGIN_HASH ={'prad03':'redhat', 'prad02' : 'redhat'} SUFFIX_HASH = {'prad03' : '03', 'prad02' : '02'} CHANNEL_INFO = {'label' : 'channel-', 'name' : 'channel-', 'summary' : 'dummy channel', 'archLabel' : 'channel-ia32', 'parentLabel' : ''} PKG_CONTENT_DIR = '/tmp/upload/' client = xmlrpclib.Server(SATELLITE_URL, verbose=0) def getKeys(users): """ Generate session key for each user """ keylist = {} for login,password in users.items(): sessionkey = client.auth.login(login, password) keylist[login] = sessionkey return keylist def createChannels(keylist, info): """ Create unique channels per user """ channel_list = {} for login,key in keylist.items(): # create channel under each org # Channel label,name should be unique label = info['label'] + SUFFIX_HASH[login] name = info['name'] + SUFFIX_HASH[login] try: print "Creating Channel: ",label client.channel.software.create(key, label, name, \ info['summary'], info['archLabel'], \ info['parentLabel']) except xmlrpclib.Fault, e: print e channel_list[login] = label return channel_list def pushContent(users, channels): """ Invoke rhnpush to push packages to channels """ for login,password in users.items(): print "Pushing Content to %s" % channels[login] push_cmd = 'rhnpush --server=%s/APP --username=%s --password=%s \ --dir=%s --channel=%s -vvvv --tolerant --nosig' % \ (SATELLITE_HOST, login, password, PKG_CONTENT_DIR, \ channels[login]) os.system(push_cmd) def main(): # Create Session keys keys = getKeys(SATELLITE_LOGIN_HASH) # Create channels channel_list = createChannels(keys, CHANNEL_INFO) # push content to channels pushContent(SATELLITE_LOGIN_HASH, channel_list) if __name__ == '__main__': main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 624, 199, 5229, 370, 520, 199, 13, 1218, 3747, 9245, 367, 1627, 4390, 199, 13, 22643, 6646, 370, 314, 2011, 367, 1924, 922, 199, 624, 199, 199, 646, 747, 199, 646, 19122, 199, 199, 3, 12439, 199, 51, 1951, 4464, 4427, 63, 5449, 275, 298, 396, 709, 13, 772, 14, 82, 6164, 2374, 14, 17164, 14, 957, 2, 199, 51, 1951, 4464, 4427, 63, 2632, 275, 298, 1014, 13827, 83, 15, 4354, 15, 1246, 2, 450, 428, 1951, 4464, 4427, 63, 5449, 199, 199, 51, 1951, 4464, 4427, 63, 17208, 63, 14395, 275, 1445, 80, 9525, 1644, 5242, 17164, 297, 283, 80, 9525, 996, 7, 520, 283, 17164, 936, 199, 199, 12273, 63, 14395, 275, 791, 80, 9525, 1644, 7, 520, 283, 1644, 297, 283, 80, 9525, 996, 7, 520, 283, 996, 936, 199, 199, 14833, 63, 4531, 275, 791, 1302, 7, 520, 283, 2775, 14382, 355, 283, 354, 7, 221, 520, 283, 2775, 14382, 355, 283, 4705, 7, 520, 283, 5869, 3623, 297, 355, 283, 1047, 4314, 7, 520, 283, 2775, 13, 4674, 708, 297, 355, 283, 1708, 4314, 7, 520, 28174, 199, 199, 18150, 63, 9663, 63, 3022, 275, 1994, 2791, 15, 5064, 4805, 199, 199, 1258, 275, 19122, 14, 3120, 8, 51, 1951, 4464, 4427, 63, 2632, 12, 3376, 29, 16, 9, 199, 199, 318, 664, 6340, 8, 3707, 304, 272, 408, 272, 7958, 2351, 790, 367, 1924, 922, 272, 408, 272, 790, 513, 275, 1052, 272, 367, 4676, 12, 2060, 315, 4390, 14, 1744, 837, 267, 2351, 498, 275, 1890, 14, 1178, 14, 2886, 8, 2886, 12, 2505, 9, 267, 790, 513, 59, 2886, 61, 275, 2351, 498, 272, 372, 790, 513, 199, 199, 318, 1218, 27138, 8, 498, 513, 12, 2256, 304, 272, 408, 272, 2790, 3747, 9245, 1126, 922, 272, 408, 272, 3623, 63, 513, 275, 1052, 272, 367, 4676, 12, 498, 315, 790, 513, 14, 1744, 837, 267, 327, 1218, 3623, 1334, 1924, 5981, 267, 327, 17270, 1768, 12, 354, 1077, 506, 3747, 267, 1768, 275, 2256, 459, 1302, 418, 435, 5698, 1665, 3867, 63, 14395, 59, 2886, 61, 267, 536, 221, 275, 2256, 459, 354, 418, 221, 435, 5698, 1665, 3867, 63, 14395, 59, 2886, 61, 267, 862, 26, 288, 870, 298, 14380, 17270, 26, 3872, 1302, 288, 1890, 14, 2775, 14, 15619, 14, 981, 8, 498, 12, 1768, 12, 536, 12, 971, 2511, 2256, 459, 4705, 995, 2256, 459, 1047, 4314, 995, 971, 2511, 2256, 459, 1708, 4314, 1105, 267, 871, 19122, 14, 16665, 12, 325, 26, 288, 870, 325, 267, 3623, 63, 513, 59, 2886, 61, 275, 1768, 272, 372, 3623, 63, 513, 199, 199, 318, 6675, 2714, 8, 3707, 12, 9245, 304, 272, 408, 1362, 31049, 26006, 1590, 2084, 370, 6675, 6117, 370, 9245, 272, 408, 272, 367, 4676, 12, 2060, 315, 4390, 14, 1744, 837, 267, 870, 298, 10731, 316, 6646, 370, 450, 83, 2, 450, 9245, 59, 2886, 61, 267, 6675, 63, 1760, 275, 283, 17157, 1590, 2084, 1553, 1000, 2458, 83, 15, 7121, 1553, 2473, 2458, 83, 1553, 2060, 2458, 83, 971, 490, 1553, 694, 2458, 83, 1553, 2775, 2458, 83, 446, 30448, 1553, 475, 1435, 867, 1553, 889, 4093, 7, 450, 971, 673, 334, 51, 1951, 4464, 4427, 63, 5449, 12, 4676, 12, 2505, 12, 30281, 63, 9663, 63, 3022, 12, 971, 490, 9245, 59, 2886, 566, 267, 747, 14, 2253, 8, 5335, 63, 1760, 9, 199, 199, 318, 2446, 837, 272, 327, 2790, 8596, 2883, 272, 2883, 275, 664, 6340, 8, 51, 1951, 4464, 4427, 63, 17208, 63, 14395, 9, 272, 327, 2790, 9245, 272, 3623, 63, 513, 275, 1218, 27138, 8, 1612, 12, 6624, 13935, 63, 4531, 9, 272, 327, 6675, 1564, 370, 9245, 272, 6675, 2714, 8, 51, 1951, 4464, 4427, 63, 17208, 63, 14395, 12, 3623, 63, 513, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 624, 199, 5229, 370, 520, 199, 13, 1218, 3747, 9245, 367, 1627, 4390, 199, 13, 22643, 6646, 370, 314, 2011, 367, 1924, 922, 199, 624, 199, 199, 646, 747, 199, 646, 19122, 199, 199, 3, 12439, 199, 51, 1951, 4464, 4427, 63, 5449, 275, 298, 396, 709, 13, 772, 14, 82, 6164, 2374, 14, 17164, 14, 957, 2, 199, 51, 1951, 4464, 4427, 63, 2632, 275, 298, 1014, 13827, 83, 15, 4354, 15, 1246, 2, 450, 428, 1951, 4464, 4427, 63, 5449, 199, 199, 51, 1951, 4464, 4427, 63, 17208, 63, 14395, 275, 1445, 80, 9525, 1644, 5242, 17164, 297, 283, 80, 9525, 996, 7, 520, 283, 17164, 936, 199, 199, 12273, 63, 14395, 275, 791, 80, 9525, 1644, 7, 520, 283, 1644, 297, 283, 80, 9525, 996, 7, 520, 283, 996, 936, 199, 199, 14833, 63, 4531, 275, 791, 1302, 7, 520, 283, 2775, 14382, 355, 283, 354, 7, 221, 520, 283, 2775, 14382, 355, 283, 4705, 7, 520, 283, 5869, 3623, 297, 355, 283, 1047, 4314, 7, 520, 283, 2775, 13, 4674, 708, 297, 355, 283, 1708, 4314, 7, 520, 28174, 199, 199, 18150, 63, 9663, 63, 3022, 275, 1994, 2791, 15, 5064, 4805, 199, 199, 1258, 275, 19122, 14, 3120, 8, 51, 1951, 4464, 4427, 63, 2632, 12, 3376, 29, 16, 9, 199, 199, 318, 664, 6340, 8, 3707, 304, 272, 408, 272, 7958, 2351, 790, 367, 1924, 922, 272, 408, 272, 790, 513, 275, 1052, 272, 367, 4676, 12, 2060, 315, 4390, 14, 1744, 837, 267, 2351, 498, 275, 1890, 14, 1178, 14, 2886, 8, 2886, 12, 2505, 9, 267, 790, 513, 59, 2886, 61, 275, 2351, 498, 272, 372, 790, 513, 199, 199, 318, 1218, 27138, 8, 498, 513, 12, 2256, 304, 272, 408, 272, 2790, 3747, 9245, 1126, 922, 272, 408, 272, 3623, 63, 513, 275, 1052, 272, 367, 4676, 12, 498, 315, 790, 513, 14, 1744, 837, 267, 327, 1218, 3623, 1334, 1924, 5981, 267, 327, 17270, 1768, 12, 354, 1077, 506, 3747, 267, 1768, 275, 2256, 459, 1302, 418, 435, 5698, 1665, 3867, 63, 14395, 59, 2886, 61, 267, 536, 221, 275, 2256, 459, 354, 418, 221, 435, 5698, 1665, 3867, 63, 14395, 59, 2886, 61, 267, 862, 26, 288, 870, 298, 14380, 17270, 26, 3872, 1302, 288, 1890, 14, 2775, 14, 15619, 14, 981, 8, 498, 12, 1768, 12, 536, 12, 971, 2511, 2256, 459, 4705, 995, 2256, 459, 1047, 4314, 995, 971, 2511, 2256, 459, 1708, 4314, 1105, 267, 871, 19122, 14, 16665, 12, 325, 26, 288, 870, 325, 267, 3623, 63, 513, 59, 2886, 61, 275, 1768, 272, 372, 3623, 63, 513, 199, 199, 318, 6675, 2714, 8, 3707, 12, 9245, 304, 272, 408, 1362, 31049, 26006, 1590, 2084, 370, 6675, 6117, 370, 9245, 272, 408, 272, 367, 4676, 12, 2060, 315, 4390, 14, 1744, 837, 267, 870, 298, 10731, 316, 6646, 370, 450, 83, 2, 450, 9245, 59, 2886, 61, 267, 6675, 63, 1760, 275, 283, 17157, 1590, 2084, 1553, 1000, 2458, 83, 15, 7121, 1553, 2473, 2458, 83, 1553, 2060, 2458, 83, 971, 490, 1553, 694, 2458, 83, 1553, 2775, 2458, 83, 446, 30448, 1553, 475, 1435, 867, 1553, 889, 4093, 7, 450, 971, 673, 334, 51, 1951, 4464, 4427, 63, 5449, 12, 4676, 12, 2505, 12, 30281, 63, 9663, 63, 3022, 12, 971, 490, 9245, 59, 2886, 566, 267, 747, 14, 2253, 8, 5335, 63, 1760, 9, 199, 199, 318, 2446, 837, 272, 327, 2790, 8596, 2883, 272, 2883, 275, 664, 6340, 8, 51, 1951, 4464, 4427, 63, 17208, 63, 14395, 9, 272, 327, 2790, 9245, 272, 3623, 63, 513, 275, 1218, 27138, 8, 1612, 12, 6624, 13935, 63, 4531, 9, 272, 327, 6675, 1564, 370, 9245, 272, 6675, 2714, 8, 51, 1951, 4464, 4427, 63, 17208, 63, 14395, 12, 3623, 63, 513, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1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
moreati/django
django/utils/jslex.py
335
7778
"""JsLex: a lexer for Javascript""" # Originally from https://bitbucket.org/ned/jslex from __future__ import unicode_literals import re class Tok(object): """ A specification for a token class. """ num = 0 def __init__(self, name, regex, next=None): self.id = Tok.num Tok.num += 1 self.name = name self.regex = regex self.next = next def literals(choices, prefix="", suffix=""): """ Create a regex from a space-separated list of literal `choices`. If provided, `prefix` and `suffix` will be attached to each choice individually. """ return "|".join(prefix + re.escape(c) + suffix for c in choices.split()) class Lexer(object): """ A generic multi-state regex-based lexer. """ def __init__(self, states, first): self.regexes = {} self.toks = {} for state, rules in states.items(): parts = [] for tok in rules: groupid = "t%d" % tok.id self.toks[groupid] = tok parts.append("(?P<%s>%s)" % (groupid, tok.regex)) self.regexes[state] = re.compile("|".join(parts), re.MULTILINE | re.VERBOSE) self.state = first def lex(self, text): """ Lexically analyze `text`. Yields pairs (`name`, `tokentext`). """ end = len(text) state = self.state regexes = self.regexes toks = self.toks start = 0 while start < end: for match in regexes[state].finditer(text, start): name = match.lastgroup tok = toks[name] toktext = match.group(name) start += len(toktext) yield (tok.name, toktext) if tok.next: state = tok.next break self.state = state class JsLexer(Lexer): """ A Javascript lexer >>> lexer = JsLexer() >>> list(lexer.lex("a = 1")) [('id', 'a'), ('ws', ' '), ('punct', '='), ('ws', ' '), ('dnum', '1')] This doesn't properly handle non-ASCII characters in the Javascript source. """ # Because these tokens are matched as alternatives in a regex, longer # possibilities must appear in the list before shorter ones, for example, # '>>' before '>'. # # Note that we don't have to detect malformed Javascript, only properly # lex correct Javascript, so much of this is simplified. # Details of Javascript lexical structure are taken from # http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf # A useful explanation of automatic semicolon insertion is at # http://inimino.org/~inimino/blog/javascript_semicolons both_before = [ Tok("comment", r"/\*(.|\n)*?\*/"), Tok("linecomment", r"//.*?$"), Tok("ws", r"\s+"), Tok("keyword", literals(""" break case catch class const continue debugger default delete do else enum export extends finally for function if import in instanceof new return super switch this throw try typeof var void while with """, suffix=r"\b"), next='reg'), Tok("reserved", literals("null true false", suffix=r"\b"), next='div'), Tok("id", r""" ([a-zA-Z_$ ]|\\u[0-9a-fA-Z]{4}) # first char ([a-zA-Z_$0-9]|\\u[0-9a-fA-F]{4})* # rest chars """, next='div'), Tok("hnum", r"0[xX][0-9a-fA-F]+", next='div'), Tok("onum", r"0[0-7]+"), Tok("dnum", r""" ( (0|[1-9][0-9]*) # DecimalIntegerLiteral \. # dot [0-9]* # DecimalDigits-opt ([eE][-+]?[0-9]+)? # ExponentPart-opt | \. # dot [0-9]+ # DecimalDigits ([eE][-+]?[0-9]+)? # ExponentPart-opt | (0|[1-9][0-9]*) # DecimalIntegerLiteral ([eE][-+]?[0-9]+)? # ExponentPart-opt ) """, next='div'), Tok("punct", literals(""" >>>= === !== >>> <<= >>= <= >= == != << >> && || += -= *= %= &= |= ^= """), next="reg"), Tok("punct", literals("++ -- ) ]"), next='div'), Tok("punct", literals("{ } ( [ . ; , < > + - * % & | ^ ! ~ ? : ="), next='reg'), Tok("string", r'"([^"\\]|(\\(.|\n)))*?"', next='div'), Tok("string", r"'([^'\\]|(\\(.|\n)))*?'", next='div'), ] both_after = [ Tok("other", r"."), ] states = { # slash will mean division 'div': both_before + [ Tok("punct", literals("/= /"), next='reg'), ] + both_after, # slash will mean regex 'reg': both_before + [ Tok("regex", r""" / # opening slash # First character is.. ( [^*\\/[] # anything but * \ / or [ | \\. # or an escape sequence | \[ # or a class, which has ( [^\]\\] # anything but \ or ] | \\. # or an escape sequence )* # many times \] ) # Following characters are same, except for excluding a star ( [^\\/[] # anything but \ / or [ | \\. # or an escape sequence | \[ # or a class, which has ( [^\]\\] # anything but \ or ] | \\. # or an escape sequence )* # many times \] )* # many times / # closing slash [a-zA-Z0-9]* # trailing flags """, next='div'), ] + both_after, } def __init__(self): super(JsLexer, self).__init__(self.states, 'reg') def prepare_js_for_gettext(js): """ Convert the Javascript source `js` into something resembling C for xgettext. What actually happens is that all the regex literals are replaced with "REGEX". """ def escape_quotes(m): """Used in a regex to properly escape double quotes.""" s = m.group(0) if s == '"': return r'\"' else: return s lexer = JsLexer() c = [] for name, tok in lexer.lex(js): if name == 'regex': # C doesn't grok regexes, and they aren't needed for gettext, # so just output a string instead. tok = '"REGEX"' elif name == 'string': # C doesn't have single-quoted strings, so make all strings # double-quoted. if tok.startswith("'"): guts = re.sub(r"\\.|.", escape_quotes, tok[1:-1]) tok = '"' + guts + '"' elif name == 'id': # C can't deal with Unicode escapes in identifiers. We don't # need them for gettext anyway, so replace them with something # innocuous tok = tok.replace("\\", "U") c.append(tok) return ''.join(c)
bsd-3-clause
[ 624, 16633, 44, 476, 26, 282, 10426, 367, 31861, 624, 199, 3, 31534, 1183, 687, 4178, 921, 25668, 14, 1308, 15, 7439, 15, 3596, 3113, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 421, 199, 533, 377, 745, 8, 785, 304, 272, 408, 272, 437, 8929, 367, 282, 1526, 1021, 14, 272, 408, 272, 1967, 275, 378, 339, 347, 636, 826, 721, 277, 12, 536, 12, 5163, 12, 2163, 29, 403, 304, 267, 291, 14, 344, 275, 377, 745, 14, 1507, 267, 377, 745, 14, 1507, 847, 413, 267, 291, 14, 354, 275, 536, 267, 291, 14, 3821, 275, 5163, 267, 291, 14, 2184, 275, 2163, 421, 199, 318, 18041, 8, 4577, 12, 2403, 8772, 4739, 17364, 272, 408, 272, 2790, 282, 5163, 687, 282, 4601, 13, 12794, 769, 402, 8785, 658, 4577, 2313, 339, 982, 2741, 12, 658, 1861, 64, 436, 658, 4511, 64, 911, 506, 10102, 370, 1924, 7141, 272, 7814, 3163, 14, 272, 408, 272, 372, 15733, 1674, 904, 8, 1861, 435, 295, 14, 3765, 8, 67, 9, 435, 4739, 367, 286, 315, 3415, 14, 1294, 1012, 421, 199, 533, 21125, 8, 785, 304, 272, 408, 272, 437, 7809, 3510, 13, 929, 5163, 13, 6788, 10426, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 6363, 12, 1642, 304, 267, 291, 14, 29283, 275, 1052, 267, 291, 14, 29328, 275, 1052, 398, 367, 1174, 12, 4713, 315, 6363, 14, 1744, 837, 288, 4184, 275, 942, 288, 367, 8431, 315, 4713, 26, 355, 1572, 344, 275, 298, 84, 5, 68, 2, 450, 8431, 14, 344, 355, 291, 14, 29328, 59, 923, 344, 61, 275, 8431, 355, 4184, 14, 740, 480, 2229, 48, 21110, 83, 6598, 83, 2924, 450, 334, 923, 344, 12, 8431, 14, 3821, 430, 288, 291, 14, 29283, 59, 929, 61, 275, 295, 14, 2014, 25795, 1674, 904, 8, 4181, 395, 295, 14, 16661, 1204, 295, 14, 16075, 9, 398, 291, 14, 929, 275, 1642, 339, 347, 7103, 8, 277, 12, 1318, 304, 267, 408, 267, 491, 476, 7288, 19897, 658, 505, 2313, 398, 23771, 83, 6342, 13493, 354, 3559, 658, 1418, 505, 14963, 267, 408, 267, 1284, 275, 822, 8, 505, 9, 267, 1174, 275, 291, 14, 929, 267, 5163, 397, 275, 291, 14, 29283, 267, 28415, 275, 291, 14, 29328, 267, 1343, 275, 378, 398, 1830, 1343, 665, 1284, 26, 288, 367, 1336, 315, 5163, 397, 59, 929, 1055, 19373, 8, 505, 12, 1343, 304, 355, 536, 275, 1336, 14, 2019, 923, 355, 8431, 275, 28415, 59, 354, 61, 355, 8431, 505, 275, 1336, 14, 923, 8, 354, 9, 355, 1343, 847, 822, 8, 9305, 505, 9, 355, 1995, 334, 9305, 14, 354, 12, 8431, 505, 9, 2234, 340, 8431, 14, 2184, 26, 490, 1174, 275, 8431, 14, 2184, 490, 2059, 398, 291, 14, 929, 275, 1174, 421, 199, 533, 26231, 5838, 8, 5838, 304, 272, 408, 272, 437, 31861, 10426, 339, 1306, 10426, 275, 26231, 5838, 342, 272, 1306, 769, 8, 11729, 14, 3113, 480, 65, 275, 413, 2237, 272, 4274, 344, 297, 283, 65, 659, 661, 3569, 297, 283, 17748, 661, 27003, 297, 26143, 659, 661, 3569, 297, 283, 17748, 661, 68, 1507, 297, 283, 17, 5440, 339, 961, 3181, 1133, 7684, 2429, 2222, 13, 12292, 4110, 315, 314, 31861, 1350, 14, 272, 408, 339, 327, 13821, 3520, 4645, 787, 7838, 465, 8679, 10661, 315, 282, 5163, 12, 8088, 272, 327, 2086, 23422, 1471, 7468, 315, 314, 769, 2544, 18299, 7869, 12, 367, 2893, 12, 272, 327, 283, 1140, 7, 2544, 12696, 1370, 272, 327, 272, 327, 3390, 626, 781, 2793, 1133, 1172, 370, 9696, 24159, 31861, 12, 1454, 7684, 272, 327, 7103, 3211, 31861, 12, 880, 8298, 402, 642, 365, 26867, 14, 339, 327, 15621, 402, 31861, 7103, 2652, 5523, 787, 9394, 687, 272, 327, 1455, 921, 1544, 14, 825, 391, 13, 4404, 6279, 14, 1308, 15, 27190, 15, 1725, 15, 4220, 2054, 13, 840, 15, 4220, 2054, 13, 14820, 14, 5607, 339, 327, 437, 2997, 17531, 402, 4834, 18734, 12167, 22470, 365, 737, 272, 327, 1455, 921, 2730, 827, 79, 14, 1308, 22500, 2730, 827, 79, 15, 11486, 15, 9554, 63, 19290, 761, 4654, 339, 3865, 63, 5182, 275, 359, 267, 377, 745, 480, 3349, 401, 519, 2, 6307, 5830, 14, 6113, 78, 3342, 8995, 15870, 1288, 267, 377, 745, 480, 604, 3349, 401, 519, 2, 501, 6697, 4, 1288, 267, 377, 745, 480, 3569, 401, 519, 3212, 83, 11, 1288, 267, 377, 745, 480, 6691, 401, 18041, 4852, 2574, 2059, 1930, 8579, 1021, 950, 1980, 14958, 2574, 849, 3145, 886, 587, 4952, 4843, 16879, 2574, 3753, 367, 805, 340, 492, 315, 1256, 1618, 2574, 892, 372, 1613, 6258, 642, 7978, 862, 730, 1618, 2574, 2729, 2309, 1830, 543, 2574, 10327, 4739, 29, 82, 3212, 66, 1288, 2163, 534, 1135, 659, 267, 377, 745, 480, 10421, 401, 18041, 480, 2307, 2549, 3055, 401, 4739, 29, 82, 3212, 66, 1288, 2163, 534, 3015, 659, 267, 377, 745, 480, 344, 401, 519, 624, 2116, 7287, 65, 13, 6353, 13, 58, 63, 4, 257, 1622, 17780, 85, 59, 16, 13, 25, 65, 13, 13753, 13, 58, 8194, 20, 1552, 257, 327, 1642, 1495, 2116, 7287, 65, 13, 6353, 13, 58, 63, 4, 16, 13, 25, 11752, 1103, 85, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 20, 1552, 10, 221, 327, 4618, 8365, 2116, 10327, 2163, 534, 3015, 659, 267, 377, 745, 480, 72, 1507, 401, 519, 2, 16, 59, 24110, 1527, 16, 13, 25, 65, 13, 13753, 13, 38, 2807, 401, 2163, 534, 3015, 659, 267, 377, 745, 480, 265, 453, 401, 519, 2, 16, 59, 16, 13, 23, 2807, 1288, 267, 377, 745, 480, 68, 1507, 401, 519, 624, 490, 334, 257, 334, 16, 17884, 17, 13, 25, 1527, 16, 13, 25, 23849, 258, 327, 6345, 2674, 7621, 717, 971, 14, 8295, 327, 6308, 717, 359, 16, 13, 25, 3672, 4519, 327, 6345, 29371, 13, 2992, 717, 7287, 20565, 1527, 6793, 21852, 16, 13, 25, 23763, 221, 327, 1316, 10339, 8416, 13, 2992, 490, 1204, 717, 971, 14, 8295, 327, 6308, 717, 359, 16, 13, 25, 2807, 4519, 327, 6345, 29371, 717, 7287, 20565, 1527, 6793, 21852 ]
[ 16633, 44, 476, 26, 282, 10426, 367, 31861, 624, 199, 3, 31534, 1183, 687, 4178, 921, 25668, 14, 1308, 15, 7439, 15, 3596, 3113, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 421, 199, 533, 377, 745, 8, 785, 304, 272, 408, 272, 437, 8929, 367, 282, 1526, 1021, 14, 272, 408, 272, 1967, 275, 378, 339, 347, 636, 826, 721, 277, 12, 536, 12, 5163, 12, 2163, 29, 403, 304, 267, 291, 14, 344, 275, 377, 745, 14, 1507, 267, 377, 745, 14, 1507, 847, 413, 267, 291, 14, 354, 275, 536, 267, 291, 14, 3821, 275, 5163, 267, 291, 14, 2184, 275, 2163, 421, 199, 318, 18041, 8, 4577, 12, 2403, 8772, 4739, 17364, 272, 408, 272, 2790, 282, 5163, 687, 282, 4601, 13, 12794, 769, 402, 8785, 658, 4577, 2313, 339, 982, 2741, 12, 658, 1861, 64, 436, 658, 4511, 64, 911, 506, 10102, 370, 1924, 7141, 272, 7814, 3163, 14, 272, 408, 272, 372, 15733, 1674, 904, 8, 1861, 435, 295, 14, 3765, 8, 67, 9, 435, 4739, 367, 286, 315, 3415, 14, 1294, 1012, 421, 199, 533, 21125, 8, 785, 304, 272, 408, 272, 437, 7809, 3510, 13, 929, 5163, 13, 6788, 10426, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 6363, 12, 1642, 304, 267, 291, 14, 29283, 275, 1052, 267, 291, 14, 29328, 275, 1052, 398, 367, 1174, 12, 4713, 315, 6363, 14, 1744, 837, 288, 4184, 275, 942, 288, 367, 8431, 315, 4713, 26, 355, 1572, 344, 275, 298, 84, 5, 68, 2, 450, 8431, 14, 344, 355, 291, 14, 29328, 59, 923, 344, 61, 275, 8431, 355, 4184, 14, 740, 480, 2229, 48, 21110, 83, 6598, 83, 2924, 450, 334, 923, 344, 12, 8431, 14, 3821, 430, 288, 291, 14, 29283, 59, 929, 61, 275, 295, 14, 2014, 25795, 1674, 904, 8, 4181, 395, 295, 14, 16661, 1204, 295, 14, 16075, 9, 398, 291, 14, 929, 275, 1642, 339, 347, 7103, 8, 277, 12, 1318, 304, 267, 408, 267, 491, 476, 7288, 19897, 658, 505, 2313, 398, 23771, 83, 6342, 13493, 354, 3559, 658, 1418, 505, 14963, 267, 408, 267, 1284, 275, 822, 8, 505, 9, 267, 1174, 275, 291, 14, 929, 267, 5163, 397, 275, 291, 14, 29283, 267, 28415, 275, 291, 14, 29328, 267, 1343, 275, 378, 398, 1830, 1343, 665, 1284, 26, 288, 367, 1336, 315, 5163, 397, 59, 929, 1055, 19373, 8, 505, 12, 1343, 304, 355, 536, 275, 1336, 14, 2019, 923, 355, 8431, 275, 28415, 59, 354, 61, 355, 8431, 505, 275, 1336, 14, 923, 8, 354, 9, 355, 1343, 847, 822, 8, 9305, 505, 9, 355, 1995, 334, 9305, 14, 354, 12, 8431, 505, 9, 2234, 340, 8431, 14, 2184, 26, 490, 1174, 275, 8431, 14, 2184, 490, 2059, 398, 291, 14, 929, 275, 1174, 421, 199, 533, 26231, 5838, 8, 5838, 304, 272, 408, 272, 437, 31861, 10426, 339, 1306, 10426, 275, 26231, 5838, 342, 272, 1306, 769, 8, 11729, 14, 3113, 480, 65, 275, 413, 2237, 272, 4274, 344, 297, 283, 65, 659, 661, 3569, 297, 283, 17748, 661, 27003, 297, 26143, 659, 661, 3569, 297, 283, 17748, 661, 68, 1507, 297, 283, 17, 5440, 339, 961, 3181, 1133, 7684, 2429, 2222, 13, 12292, 4110, 315, 314, 31861, 1350, 14, 272, 408, 339, 327, 13821, 3520, 4645, 787, 7838, 465, 8679, 10661, 315, 282, 5163, 12, 8088, 272, 327, 2086, 23422, 1471, 7468, 315, 314, 769, 2544, 18299, 7869, 12, 367, 2893, 12, 272, 327, 283, 1140, 7, 2544, 12696, 1370, 272, 327, 272, 327, 3390, 626, 781, 2793, 1133, 1172, 370, 9696, 24159, 31861, 12, 1454, 7684, 272, 327, 7103, 3211, 31861, 12, 880, 8298, 402, 642, 365, 26867, 14, 339, 327, 15621, 402, 31861, 7103, 2652, 5523, 787, 9394, 687, 272, 327, 1455, 921, 1544, 14, 825, 391, 13, 4404, 6279, 14, 1308, 15, 27190, 15, 1725, 15, 4220, 2054, 13, 840, 15, 4220, 2054, 13, 14820, 14, 5607, 339, 327, 437, 2997, 17531, 402, 4834, 18734, 12167, 22470, 365, 737, 272, 327, 1455, 921, 2730, 827, 79, 14, 1308, 22500, 2730, 827, 79, 15, 11486, 15, 9554, 63, 19290, 761, 4654, 339, 3865, 63, 5182, 275, 359, 267, 377, 745, 480, 3349, 401, 519, 2, 6307, 5830, 14, 6113, 78, 3342, 8995, 15870, 1288, 267, 377, 745, 480, 604, 3349, 401, 519, 2, 501, 6697, 4, 1288, 267, 377, 745, 480, 3569, 401, 519, 3212, 83, 11, 1288, 267, 377, 745, 480, 6691, 401, 18041, 4852, 2574, 2059, 1930, 8579, 1021, 950, 1980, 14958, 2574, 849, 3145, 886, 587, 4952, 4843, 16879, 2574, 3753, 367, 805, 340, 492, 315, 1256, 1618, 2574, 892, 372, 1613, 6258, 642, 7978, 862, 730, 1618, 2574, 2729, 2309, 1830, 543, 2574, 10327, 4739, 29, 82, 3212, 66, 1288, 2163, 534, 1135, 659, 267, 377, 745, 480, 10421, 401, 18041, 480, 2307, 2549, 3055, 401, 4739, 29, 82, 3212, 66, 1288, 2163, 534, 3015, 659, 267, 377, 745, 480, 344, 401, 519, 624, 2116, 7287, 65, 13, 6353, 13, 58, 63, 4, 257, 1622, 17780, 85, 59, 16, 13, 25, 65, 13, 13753, 13, 58, 8194, 20, 1552, 257, 327, 1642, 1495, 2116, 7287, 65, 13, 6353, 13, 58, 63, 4, 16, 13, 25, 11752, 1103, 85, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 20, 1552, 10, 221, 327, 4618, 8365, 2116, 10327, 2163, 534, 3015, 659, 267, 377, 745, 480, 72, 1507, 401, 519, 2, 16, 59, 24110, 1527, 16, 13, 25, 65, 13, 13753, 13, 38, 2807, 401, 2163, 534, 3015, 659, 267, 377, 745, 480, 265, 453, 401, 519, 2, 16, 59, 16, 13, 23, 2807, 1288, 267, 377, 745, 480, 68, 1507, 401, 519, 624, 490, 334, 257, 334, 16, 17884, 17, 13, 25, 1527, 16, 13, 25, 23849, 258, 327, 6345, 2674, 7621, 717, 971, 14, 8295, 327, 6308, 717, 359, 16, 13, 25, 3672, 4519, 327, 6345, 29371, 13, 2992, 717, 7287, 20565, 1527, 6793, 21852, 16, 13, 25, 23763, 221, 327, 1316, 10339, 8416, 13, 2992, 490, 1204, 717, 971, 14, 8295, 327, 6308, 717, 359, 16, 13, 25, 2807, 4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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
puremourning/YouCompleteMe
python/ycm/client/completer_available_request.py
7
1464
# Copyright (C) 2013 Google Inc. # # This file is part of YouCompleteMe. # # YouCompleteMe 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. # # YouCompleteMe 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 YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. from ycm.client.base_request import BaseRequest, BuildRequestData class CompleterAvailableRequest( BaseRequest ): def __init__( self, filetypes ): super( CompleterAvailableRequest, self ).__init__() self.filetypes = filetypes self._response = None def Start( self ): request_data = BuildRequestData() request_data.update( { 'filetypes': self.filetypes } ) self._response = self.PostDataToHandler( request_data, 'semantic_completion_available' ) def Response( self ): return self._response def SendCompleterAvailableRequest( filetypes ): request = CompleterAvailableRequest( filetypes ) # This is a blocking call. request.Start() return request.Response()
gpl-3.0
[ 3, 1898, 334, 35, 9, 6171, 221, 4475, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2047, 14175, 1352, 14, 199, 3, 199, 3, 2047, 14175, 1352, 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, 2047, 14175, 1352, 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, 2047, 14175, 1352, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 612, 4400, 14, 1258, 14, 1095, 63, 1069, 492, 3523, 2017, 12, 6516, 2017, 1451, 421, 199, 533, 12515, 351, 11464, 2017, 8, 3523, 2017, 3461, 523, 347, 636, 826, 721, 291, 12, 570, 1313, 3461, 272, 1613, 8, 12515, 351, 11464, 2017, 12, 291, 221, 2843, 826, 4533, 272, 291, 14, 493, 1313, 275, 570, 1313, 272, 291, 423, 1310, 275, 488, 8330, 347, 7707, 8, 291, 3461, 272, 1056, 63, 576, 275, 6516, 2017, 1451, 342, 272, 1056, 63, 576, 14, 873, 8, 469, 283, 493, 1313, 356, 291, 14, 493, 1313, 789, 776, 272, 291, 423, 1310, 275, 291, 14, 6564, 1451, 1378, 2461, 8, 1056, 63, 576, 12, 6163, 283, 261, 23127, 63, 13207, 63, 4561, 7, 776, 8330, 347, 7232, 8, 291, 3461, 272, 372, 291, 423, 1310, 421, 199, 318, 10217, 6600, 351, 11464, 2017, 8, 570, 1313, 3461, 523, 1056, 275, 12515, 351, 11464, 2017, 8, 570, 1313, 776, 523, 327, 961, 365, 282, 14592, 1240, 14, 523, 1056, 14, 3162, 342, 523, 372, 1056, 14, 2364, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 6171, 221, 4475, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2047, 14175, 1352, 14, 199, 3, 199, 3, 2047, 14175, 1352, 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, 2047, 14175, 1352, 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, 2047, 14175, 1352, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 612, 4400, 14, 1258, 14, 1095, 63, 1069, 492, 3523, 2017, 12, 6516, 2017, 1451, 421, 199, 533, 12515, 351, 11464, 2017, 8, 3523, 2017, 3461, 523, 347, 636, 826, 721, 291, 12, 570, 1313, 3461, 272, 1613, 8, 12515, 351, 11464, 2017, 12, 291, 221, 2843, 826, 4533, 272, 291, 14, 493, 1313, 275, 570, 1313, 272, 291, 423, 1310, 275, 488, 8330, 347, 7707, 8, 291, 3461, 272, 1056, 63, 576, 275, 6516, 2017, 1451, 342, 272, 1056, 63, 576, 14, 873, 8, 469, 283, 493, 1313, 356, 291, 14, 493, 1313, 789, 776, 272, 291, 423, 1310, 275, 291, 14, 6564, 1451, 1378, 2461, 8, 1056, 63, 576, 12, 6163, 283, 261, 23127, 63, 13207, 63, 4561, 7, 776, 8330, 347, 7232, 8, 291, 3461, 272, 372, 291, 423, 1310, 421, 199, 318, 10217, 6600, 351, 11464, 2017, 8, 570, 1313, 3461, 523, 1056, 275, 12515, 351, 11464, 2017, 8, 570, 1313, 776, 523, 327, 961, 365, 282, 14592, 1240, 14, 523, 1056, 14, 3162, 342, 523, 372, 1056, 14, 2364, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rizar/attention-lvcsr
libs/blocks/tests/monitoring/test_monitored_quantity.py
2
1638
import numpy import theano from fuel.datasets import IterableDataset from blocks.monitoring.evaluators import DatasetEvaluator from blocks.monitoring.aggregation import MonitoredQuantity from blocks.bricks.cost import CategoricalCrossEntropy class CrossEntropy(MonitoredQuantity): def __init__(self, **kwargs): super(CrossEntropy, self).__init__(**kwargs) def initialize(self): self.total_cross_entropy, self.examples_seen = 0.0, 0 def accumulate(self, target, predicted): import numpy self.total_cross_entropy += -(target * numpy.log(predicted)).sum() self.examples_seen += 1 def readout(self): res = self.total_cross_entropy / self.examples_seen return res def test_dataset_evaluators(): X = theano.tensor.vector('X') Y = theano.tensor.vector('Y') data = [numpy.arange(1, 7, dtype=theano.config.floatX).reshape(3, 2), numpy.arange(11, 17, dtype=theano.config.floatX).reshape(3, 2)] data_stream = IterableDataset(dict(X=data[0], Y=data[1])).get_example_stream() validator = DatasetEvaluator([ CrossEntropy(requires=[X, Y], name="monitored_cross_entropy0"), # to test two same quantities and make sure that state will be reset CrossEntropy(requires=[X, Y], name="monitored_cross_entropy1"), CategoricalCrossEntropy().apply(X, Y), ]) values = validator.evaluate(data_stream) numpy.testing.assert_allclose( values['monitored_cross_entropy1'], values['categoricalcrossentropy_apply_cost'])
mit
[ 646, 2680, 199, 646, 14377, 199, 504, 289, 13086, 14, 12281, 492, 19937, 9271, 199, 199, 504, 5664, 14, 20554, 14, 2579, 85, 2750, 492, 20284, 10006, 16530, 199, 504, 5664, 14, 20554, 14, 21016, 492, 10953, 17043, 19703, 199, 504, 5664, 14, 30855, 14, 6336, 492, 31227, 14072, 31224, 421, 199, 533, 28965, 31224, 8, 6671, 17043, 19703, 304, 272, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 1613, 8, 14072, 31224, 12, 291, 2843, 826, 14155, 958, 9, 339, 347, 8265, 8, 277, 304, 267, 291, 14, 2923, 63, 7925, 63, 10435, 12, 291, 14, 8589, 63, 8606, 275, 378, 14, 16, 12, 378, 339, 347, 30535, 8, 277, 12, 1347, 12, 14746, 304, 267, 492, 2680, 267, 291, 14, 2923, 63, 7925, 63, 10435, 847, 24953, 1375, 627, 2680, 14, 793, 8, 21118, 4992, 1838, 342, 267, 291, 14, 8589, 63, 8606, 847, 413, 339, 347, 1586, 548, 8, 277, 304, 267, 522, 275, 291, 14, 2923, 63, 7925, 63, 10435, 1182, 291, 14, 8589, 63, 8606, 267, 372, 522, 421, 199, 318, 511, 63, 5214, 63, 2579, 85, 2750, 837, 272, 1323, 275, 14377, 14, 3128, 14, 4106, 360, 56, 358, 272, 1488, 275, 14377, 14, 3128, 14, 4106, 360, 57, 358, 339, 666, 275, 359, 4714, 14, 5605, 8, 17, 12, 1520, 12, 2152, 29, 32057, 14, 888, 14, 31293, 680, 5217, 8, 19, 12, 499, 395, 288, 2680, 14, 5605, 8, 845, 12, 5557, 12, 2152, 29, 32057, 14, 888, 14, 31293, 680, 5217, 8, 19, 12, 499, 1874, 272, 666, 63, 1745, 275, 19937, 9271, 8, 807, 8, 56, 29, 576, 59, 16, 467, 4318, 1488, 29, 576, 59, 17, 2459, 14, 362, 63, 2694, 63, 1745, 342, 339, 11822, 275, 20284, 10006, 16530, 779, 267, 28965, 31224, 8, 6537, 1524, 56, 12, 1488, 467, 2151, 536, 628, 2106, 17043, 63, 7925, 63, 10435, 16, 1288, 267, 327, 370, 511, 2877, 2011, 13621, 1417, 436, 1852, 3238, 626, 1174, 911, 506, 5305, 267, 28965, 31224, 8, 6537, 1524, 56, 12, 1488, 467, 2151, 536, 628, 2106, 17043, 63, 7925, 63, 10435, 17, 1288, 267, 31227, 14072, 31224, 1252, 4998, 8, 56, 12, 1488, 395, 4794, 272, 1338, 275, 11822, 14, 7383, 8, 576, 63, 1745, 9, 272, 2680, 14, 4776, 14, 479, 63, 7520, 8, 267, 1338, 459, 2106, 17043, 63, 7925, 63, 10435, 17, 995, 267, 1338, 459, 16810, 20363, 1150, 7537, 63, 4998, 63, 6336, 1105, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2680, 199, 646, 14377, 199, 504, 289, 13086, 14, 12281, 492, 19937, 9271, 199, 199, 504, 5664, 14, 20554, 14, 2579, 85, 2750, 492, 20284, 10006, 16530, 199, 504, 5664, 14, 20554, 14, 21016, 492, 10953, 17043, 19703, 199, 504, 5664, 14, 30855, 14, 6336, 492, 31227, 14072, 31224, 421, 199, 533, 28965, 31224, 8, 6671, 17043, 19703, 304, 272, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 1613, 8, 14072, 31224, 12, 291, 2843, 826, 14155, 958, 9, 339, 347, 8265, 8, 277, 304, 267, 291, 14, 2923, 63, 7925, 63, 10435, 12, 291, 14, 8589, 63, 8606, 275, 378, 14, 16, 12, 378, 339, 347, 30535, 8, 277, 12, 1347, 12, 14746, 304, 267, 492, 2680, 267, 291, 14, 2923, 63, 7925, 63, 10435, 847, 24953, 1375, 627, 2680, 14, 793, 8, 21118, 4992, 1838, 342, 267, 291, 14, 8589, 63, 8606, 847, 413, 339, 347, 1586, 548, 8, 277, 304, 267, 522, 275, 291, 14, 2923, 63, 7925, 63, 10435, 1182, 291, 14, 8589, 63, 8606, 267, 372, 522, 421, 199, 318, 511, 63, 5214, 63, 2579, 85, 2750, 837, 272, 1323, 275, 14377, 14, 3128, 14, 4106, 360, 56, 358, 272, 1488, 275, 14377, 14, 3128, 14, 4106, 360, 57, 358, 339, 666, 275, 359, 4714, 14, 5605, 8, 17, 12, 1520, 12, 2152, 29, 32057, 14, 888, 14, 31293, 680, 5217, 8, 19, 12, 499, 395, 288, 2680, 14, 5605, 8, 845, 12, 5557, 12, 2152, 29, 32057, 14, 888, 14, 31293, 680, 5217, 8, 19, 12, 499, 1874, 272, 666, 63, 1745, 275, 19937, 9271, 8, 807, 8, 56, 29, 576, 59, 16, 467, 4318, 1488, 29, 576, 59, 17, 2459, 14, 362, 63, 2694, 63, 1745, 342, 339, 11822, 275, 20284, 10006, 16530, 779, 267, 28965, 31224, 8, 6537, 1524, 56, 12, 1488, 467, 2151, 536, 628, 2106, 17043, 63, 7925, 63, 10435, 16, 1288, 267, 327, 370, 511, 2877, 2011, 13621, 1417, 436, 1852, 3238, 626, 1174, 911, 506, 5305, 267, 28965, 31224, 8, 6537, 1524, 56, 12, 1488, 467, 2151, 536, 628, 2106, 17043, 63, 7925, 63, 10435, 17, 1288, 267, 31227, 14072, 31224, 1252, 4998, 8, 56, 12, 1488, 395, 4794, 272, 1338, 275, 11822, 14, 7383, 8, 576, 63, 1745, 9, 272, 2680, 14, 4776, 14, 479, 63, 7520, 8, 267, 1338, 459, 2106, 17043, 63, 7925, 63, 10435, 17, 995, 267, 1338, 459, 16810, 20363, 1150, 7537, 63, 4998, 63, 6336, 1105, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
CatsAndDogsbvba/odoo
openerp/report/render/html2html/html2html.py
443
4238
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.report.render.rml2pdf import utils import copy import base64 import cStringIO import re from reportlab.lib.utils import ImageReader _regex = re.compile('\[\[(.+?)\]\]') utils._regex = re.compile('\[\[\s*(.+?)\s*\]\]',re.DOTALL) class html2html(object): def __init__(self, html, localcontext): self.localcontext = localcontext self.etree = html self._node = None def render(self): def process_text(node,new_node): if new_node.tag in ['story','tr','section']: new_node.attrib.clear() for child in utils._child_get(node, self): new_child = copy.deepcopy(child) new_node.append(new_child) if len(child): for n in new_child: new_child.text = utils._process_text(self, child.text) new_child.tail = utils._process_text(self, child.tail) new_child.remove(n) process_text(child, new_child) else: if new_child.tag=='img' and new_child.get('name'): if _regex.findall(new_child.get('name')) : src = utils._process_text(self, new_child.get('name')) if src : new_child.set('src','data:image/gif;base64,%s'%src) output = cStringIO.StringIO(base64.decodestring(src)) img = ImageReader(output) (width,height) = img.getSize() if not new_child.get('width'): new_child.set('width',str(width)) if not new_child.get('height') : new_child.set('height',str(height)) else : new_child.getparent().remove(new_child) new_child.text = utils._process_text(self, child.text) new_child.tail = utils._process_text(self, child.tail) self._node = copy.deepcopy(self.etree) for n in self._node: self._node.remove(n) process_text(self.etree, self._node) return self._node def url_modify(self,root): for n in root: if (n.text.find('<a ')>=0 or n.text.find('&lt;a')>=0) and n.text.find('href')>=0 and n.text.find('style')<=0 : node = (n.tag=='span' and n.getparent().tag=='u') and n.getparent().getparent() or ((n.tag=='span') and n.getparent()) or n style = node.get('color') and "style='color:%s; text-decoration: none;'"%node.get('color') or '' if n.text.find('&lt;a')>=0: t = '&lt;a ' else : t = '<a ' href = n.text.split(t)[-1] n.text = ' '.join([t,style,href]) self.url_modify(n) return root def parseString(node, localcontext = {}): r = html2html(node, localcontext) root = r.render() root = r.url_modify(root) return root # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 3070, 14, 3352, 14, 16300, 18, 5607, 492, 3778, 199, 646, 1331, 199, 646, 1300, 772, 199, 646, 15073, 199, 646, 295, 199, 504, 21773, 14, 773, 14, 1208, 492, 6047, 5929, 199, 199, 63, 3821, 275, 295, 14, 2014, 2258, 7023, 7528, 11198, 2862, 7272, 10374, 199, 1208, 423, 3821, 275, 295, 14, 2014, 2258, 7023, 7023, 83, 5830, 11198, 2862, 83, 7590, 7272, 4300, 264, 14, 16504, 9, 199, 533, 3517, 18, 1360, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3517, 12, 2257, 1100, 304, 267, 291, 14, 17886, 275, 2257, 1100, 267, 291, 14, 9464, 275, 3517, 267, 291, 423, 932, 275, 488, 2378, 347, 3795, 8, 277, 304, 267, 347, 2112, 63, 505, 8, 932, 12, 1222, 63, 932, 304, 288, 340, 892, 63, 932, 14, 1450, 315, 788, 17372, 1673, 454, 1673, 2792, 2565, 355, 892, 63, 932, 14, 6640, 14, 3584, 342, 288, 367, 1982, 315, 3778, 423, 1739, 63, 362, 8, 932, 12, 291, 304, 355, 892, 63, 1739, 275, 1331, 14, 8293, 8, 1739, 9, 355, 892, 63, 932, 14, 740, 8, 1222, 63, 1739, 9, 355, 340, 822, 8, 1739, 304, 490, 367, 302, 315, 892, 63, 1739, 26, 717, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 717, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 717, 892, 63, 1739, 14, 2168, 8, 78, 9, 490, 2112, 63, 505, 8, 1739, 12, 892, 63, 1739, 9, 355, 587, 26, 490, 340, 892, 63, 1739, 14, 1450, 6803, 4060, 7, 436, 892, 63, 1739, 14, 362, 360, 354, 735, 717, 340, 485, 3821, 14, 6452, 8, 1222, 63, 1739, 14, 362, 360, 354, 1333, 520, 1169, 2928, 275, 221, 3778, 423, 1412, 63, 505, 8, 277, 12, 892, 63, 1739, 14, 362, 360, 354, 1333, 1169, 340, 2928, 520, 1816, 892, 63, 1739, 14, 409, 360, 2164, 1673, 576, 26, 1569, 15, 14513, 27, 1095, 772, 8719, 83, 5956, 2164, 9, 1816, 1072, 275, 15073, 14, 6424, 8, 1095, 772, 14, 2708, 875, 8, 2164, 430, 1816, 6050, 275, 6047, 5929, 8, 1199, 9, 1816, 334, 2063, 12, 3333, 9, 275, 6050, 14, 362, 2320, 342, 1816, 340, 440, 892, 63, 1739, 14, 362, 360, 2063, 735, 2511, 892, 63, 1739, 14, 409, 360, 2063, 297, 495, 8, 2063, 430, 1816, 340, 440, 892, 63, 1739, 14, 362, 360, 3333, 358, 520, 2511, 892, 63, 1739, 14, 409, 360, 3333, 297, 495, 8, 3333, 430, 1169, 587, 520, 1816, 892, 63, 1739, 14, 362, 1708, 1252, 2168, 8, 1222, 63, 1739, 9, 490, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 490, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 267, 291, 423, 932, 275, 1331, 14, 8293, 8, 277, 14, 9464, 9, 267, 367, 302, 315, 291, 423, 932, 26, 288, 291, 423, 932, 14, 2168, 8, 78, 9, 267, 2112, 63, 505, 8, 277, 14, 9464, 12, 291, 423, 932, 9, 267, 372, 291, 423, 932, 5493, 347, 1166, 63, 8951, 8, 277, 12, 1231, 304, 267, 367, 302, 315, 1738, 26, 288, 340, 334, 78, 14, 505, 14, 1623, 4827, 65, 5320, 8119, 16, 503, 302, 14, 505, 14, 1623, 20040, 4116, 27, 65, 358, 8119, 16, 9, 436, 302, 14, 505, 14, 1623, 360, 6399, 358, 8119, 16, 436, 302, 14, 505, 14, 1623, 360, 2487, 358, 12932, 16, 520, 355, 1031, 275, 334, 78, 14, 1450, 6803, 3751, 7, 436, 302, 14, 362, 1708, 1252, 1450, 6803, 85, 358, 436, 302, 14, 362, 1708, 1252, 362, 1708, 342, 503, 3666, 78, 14, 1450, 6803, 3751, 358, 436, 302, 14, 362, 1708, 1012, 503, 302, 355, 3449, 275, 1031, 14, 362, 360, 2326, 358, 436, 298, 2487, 534, 2326, 2689, 83, 27, 1318, 13, 6518, 425, 26, 7179, 27, 4065, 5, 932, 14, 362, 360, 2326, 358, 503, 2125, 355, 340, 302, 14, 505, 14, 1623, 20040, 4116, 27, 65, 358, 8119, 16, 26, 490, 307, 275, 7673, 4116, 27, 65, 283, 355, 587, 520, 490, 307, 275, 2650, 65, 283, 355, 4369, 275, 302, 14, 505, 14, 1294, 8, 84, 15786, 17, 61, 355, 302, 14, 505, 275, 283, 1987, 904, 779, 84, 12, 2487, 12, 6399, 566, 288, 291, 14, 633, 63, 8951, 8, 78, 9, 267, 372, 1738, 199, 199, 318, 2198, 1558, 8, 932, 12, 2257, 1100, 275, 1052, 304, 272, 519, 275, 3517, 18, 1360, 8, 932, 12, 2257, 1100, 9, 272, 1738, 275, 519, 14, 3352, 342, 272, 1738, 275, 519, 14, 633, 63, 8951, 8, 1231, 9, 272, 372, 1738, 421, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 3070, 14, 3352, 14, 16300, 18, 5607, 492, 3778, 199, 646, 1331, 199, 646, 1300, 772, 199, 646, 15073, 199, 646, 295, 199, 504, 21773, 14, 773, 14, 1208, 492, 6047, 5929, 199, 199, 63, 3821, 275, 295, 14, 2014, 2258, 7023, 7528, 11198, 2862, 7272, 10374, 199, 1208, 423, 3821, 275, 295, 14, 2014, 2258, 7023, 7023, 83, 5830, 11198, 2862, 83, 7590, 7272, 4300, 264, 14, 16504, 9, 199, 533, 3517, 18, 1360, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3517, 12, 2257, 1100, 304, 267, 291, 14, 17886, 275, 2257, 1100, 267, 291, 14, 9464, 275, 3517, 267, 291, 423, 932, 275, 488, 2378, 347, 3795, 8, 277, 304, 267, 347, 2112, 63, 505, 8, 932, 12, 1222, 63, 932, 304, 288, 340, 892, 63, 932, 14, 1450, 315, 788, 17372, 1673, 454, 1673, 2792, 2565, 355, 892, 63, 932, 14, 6640, 14, 3584, 342, 288, 367, 1982, 315, 3778, 423, 1739, 63, 362, 8, 932, 12, 291, 304, 355, 892, 63, 1739, 275, 1331, 14, 8293, 8, 1739, 9, 355, 892, 63, 932, 14, 740, 8, 1222, 63, 1739, 9, 355, 340, 822, 8, 1739, 304, 490, 367, 302, 315, 892, 63, 1739, 26, 717, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 717, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 717, 892, 63, 1739, 14, 2168, 8, 78, 9, 490, 2112, 63, 505, 8, 1739, 12, 892, 63, 1739, 9, 355, 587, 26, 490, 340, 892, 63, 1739, 14, 1450, 6803, 4060, 7, 436, 892, 63, 1739, 14, 362, 360, 354, 735, 717, 340, 485, 3821, 14, 6452, 8, 1222, 63, 1739, 14, 362, 360, 354, 1333, 520, 1169, 2928, 275, 221, 3778, 423, 1412, 63, 505, 8, 277, 12, 892, 63, 1739, 14, 362, 360, 354, 1333, 1169, 340, 2928, 520, 1816, 892, 63, 1739, 14, 409, 360, 2164, 1673, 576, 26, 1569, 15, 14513, 27, 1095, 772, 8719, 83, 5956, 2164, 9, 1816, 1072, 275, 15073, 14, 6424, 8, 1095, 772, 14, 2708, 875, 8, 2164, 430, 1816, 6050, 275, 6047, 5929, 8, 1199, 9, 1816, 334, 2063, 12, 3333, 9, 275, 6050, 14, 362, 2320, 342, 1816, 340, 440, 892, 63, 1739, 14, 362, 360, 2063, 735, 2511, 892, 63, 1739, 14, 409, 360, 2063, 297, 495, 8, 2063, 430, 1816, 340, 440, 892, 63, 1739, 14, 362, 360, 3333, 358, 520, 2511, 892, 63, 1739, 14, 409, 360, 3333, 297, 495, 8, 3333, 430, 1169, 587, 520, 1816, 892, 63, 1739, 14, 362, 1708, 1252, 2168, 8, 1222, 63, 1739, 9, 490, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 490, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 267, 291, 423, 932, 275, 1331, 14, 8293, 8, 277, 14, 9464, 9, 267, 367, 302, 315, 291, 423, 932, 26, 288, 291, 423, 932, 14, 2168, 8, 78, 9, 267, 2112, 63, 505, 8, 277, 14, 9464, 12, 291, 423, 932, 9, 267, 372, 291, 423, 932, 5493, 347, 1166, 63, 8951, 8, 277, 12, 1231, 304, 267, 367, 302, 315, 1738, 26, 288, 340, 334, 78, 14, 505, 14, 1623, 4827, 65, 5320, 8119, 16, 503, 302, 14, 505, 14, 1623, 20040, 4116, 27, 65, 358, 8119, 16, 9, 436, 302, 14, 505, 14, 1623, 360, 6399, 358, 8119, 16, 436, 302, 14, 505, 14, 1623, 360, 2487, 358, 12932, 16, 520, 355, 1031, 275, 334, 78, 14, 1450, 6803, 3751, 7, 436, 302, 14, 362, 1708, 1252, 1450, 6803, 85, 358, 436, 302, 14, 362, 1708, 1252, 362, 1708, 342, 503, 3666, 78, 14, 1450, 6803, 3751, 358, 436, 302, 14, 362, 1708, 1012, 503, 302, 355, 3449, 275, 1031, 14, 362, 360, 2326, 358, 436, 298, 2487, 534, 2326, 2689, 83, 27, 1318, 13, 6518, 425, 26, 7179, 27, 4065, 5, 932, 14, 362, 360, 2326, 358, 503, 2125, 355, 340, 302, 14, 505, 14, 1623, 20040, 4116, 27, 65, 358, 8119, 16, 26, 490, 307, 275, 7673, 4116, 27, 65, 283, 355, 587, 520, 490, 307, 275, 2650, 65, 283, 355, 4369, 275, 302, 14, 505, 14, 1294, 8, 84, 15786, 17, 61, 355, 302, 14, 505, 275, 283, 1987, 904, 779, 84, 12, 2487, 12, 6399, 566, 288, 291, 14, 633, 63, 8951, 8, 78, 9, 267, 372, 1738, 199, 199, 318, 2198, 1558, 8, 932, 12, 2257, 1100, 275, 1052, 304, 272, 519, 275, 3517, 18, 1360, 8, 932, 12, 2257, 1100, 9, 272, 1738, 275, 519, 14, 3352, 342, 272, 1738, 275, 519, 14, 633, 63, 8951, 8, 1231, 9, 272, 372, 1738, 421, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cnrat/fail2ban
fail2ban/tests/action_d/test_badips.py
19
2735
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban 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. # # Fail2Ban 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 Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os import unittest import sys from ..dummyjail import DummyJail from ..utils import CONFIG_DIR if sys.version_info >= (2,7): class BadIPsActionTest(unittest.TestCase): def setUp(self): """Call before every test case.""" self.jail = DummyJail() self.jail.actions.add("test") pythonModule = os.path.join(CONFIG_DIR, "action.d", "badips.py") self.jail.actions.add("badips", pythonModule, initOpts={ 'category': "ssh", 'banaction': "test", }) self.action = self.jail.actions["badips"] def tearDown(self): """Call after every test case.""" # Must cancel timer! if self.action._timer: self.action._timer.cancel() def testCategory(self): categories = self.action.getCategories() self.assertTrue("ssh" in categories) self.assertTrue(len(categories) >= 10) self.assertRaises( ValueError, setattr, self.action, "category", "invalid-category") # Not valid for reporting category... self.assertRaises( ValueError, setattr, self.action, "category", "mail") # but valid for blacklisting. self.action.bancategory = "mail" def testScore(self): self.assertRaises(ValueError, setattr, self.action, "score", -5) self.action.score = 5 self.action.score = "5" def testBanaction(self): self.assertRaises( ValueError, setattr, self.action, "banaction", "invalid-action") self.action.banaction = "test" def testUpdateperiod(self): self.assertRaises( ValueError, setattr, self.action, "updateperiod", -50) self.assertRaises( ValueError, setattr, self.action, "updateperiod", 0) self.action.updateperiod = 900 self.action.updateperiod = "900" def testStart(self): self.action.start() self.assertTrue(len(self.action._bannedips) > 10) def testStop(self): self.testStart() self.action.stop() self.assertTrue(len(self.action._bannedips) == 0)
gpl-2.0
[ 3, 325, 19309, 26, 1882, 818, 26, 2366, 27, 1134, 13, 3724, 13, 2743, 26, 841, 27, 4363, 13, 8741, 13, 632, 26, 307, 1882, 199, 3, 1321, 26, 663, 18133, 29, 1548, 23014, 29, 20, 6714, 29, 20, 5584, 29, 20, 949, 386, 520, 199, 199, 3, 961, 570, 365, 1777, 402, 12176, 18, 28018, 14, 199, 3, 199, 3, 12176, 18, 28018, 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, 12176, 18, 28018, 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, 12176, 18, 28018, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 14, 199, 199, 646, 747, 199, 646, 2882, 199, 646, 984, 199, 199, 504, 2508, 5869, 74, 1054, 492, 9762, 42, 1054, 199, 504, 2508, 1208, 492, 15869, 63, 3022, 199, 199, 692, 984, 14, 1023, 63, 815, 2356, 334, 18, 12, 23, 304, 199, 198, 533, 8857, 1772, 83, 3310, 774, 8, 2796, 14, 1746, 304, 2742, 198, 318, 3613, 8, 277, 304, 686, 198, 624, 2176, 2544, 4036, 511, 1930, 1041, 686, 198, 277, 14, 74, 1054, 275, 9762, 42, 1054, 342, 6319, 198, 277, 14, 74, 1054, 14, 3723, 14, 525, 480, 396, 531, 6319, 198, 1548, 2377, 275, 747, 14, 515, 14, 904, 8, 5569, 63, 3022, 12, 298, 1287, 14, 68, 401, 298, 2470, 328, 1190, 14, 647, 531, 686, 198, 277, 14, 74, 1054, 14, 3723, 14, 525, 480, 2470, 328, 1190, 401, 2366, 2377, 12, 4205, 24429, 3126, 1585, 198, 7, 3710, 356, 298, 5510, 401, 1585, 198, 7, 13206, 1287, 356, 298, 396, 401, 1585, 198, 1552, 686, 198, 277, 14, 1287, 275, 291, 14, 74, 1054, 14, 3723, 905, 2470, 328, 1190, 937, 2742, 198, 318, 6766, 8, 277, 304, 686, 198, 624, 2176, 2410, 4036, 511, 1930, 1041, 686, 198, 3, 9498, 9311, 9715, 1, 686, 198, 692, 291, 14, 1287, 423, 7414, 26, 1585, 198, 277, 14, 1287, 423, 7414, 14, 6406, 342, 2742, 198, 318, 511, 7841, 8, 277, 304, 686, 198, 8906, 275, 291, 14, 1287, 14, 362, 28731, 342, 686, 198, 277, 14, 1815, 480, 5510, 2, 315, 9695, 9, 686, 198, 277, 14, 1815, 8, 552, 8, 8906, 9, 2356, 1616, 9, 6319, 198, 277, 14, 1855, 8, 1585, 198, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 3710, 401, 1585, 198, 2, 3197, 13, 3710, 531, 6319, 198, 3, 2832, 1686, 367, 17290, 4637, 1396, 686, 198, 277, 14, 1855, 8, 1585, 198, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 3710, 401, 298, 1198, 531, 686, 198, 3, 1325, 1686, 367, 12136, 16115, 14, 686, 198, 277, 14, 1287, 14, 13206, 3710, 275, 298, 1198, 2, 2742, 198, 318, 511, 12642, 8, 277, 304, 686, 198, 277, 14, 1855, 8, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 3397, 401, 446, 21, 9, 686, 198, 277, 14, 1287, 14, 3397, 275, 959, 686, 198, 277, 14, 1287, 14, 3397, 275, 298, 21, 2, 2742, 198, 318, 511, 28018, 1287, 8, 277, 304, 686, 198, 277, 14, 1855, 8, 1585, 198, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 13206, 1287, 401, 1585, 198, 2, 3197, 13, 1287, 531, 686, 198, 277, 14, 1287, 14, 13206, 1287, 275, 298, 396, 2, 2742, 198, 318, 511, 4152, 5191, 8, 277, 304, 686, 198, 277, 14, 1855, 8, 1585, 198, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 873, 5191, 401, 446, 1400, 9, 686, 198, 277, 14, 1855, 8, 1585, 198, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 873, 5191, 401, 378, 9, 686, 198, 277, 14, 1287, 14, 873, 5191, 275, 27151, 686, 198, 277, 14, 1287, 14, 873, 5191, 275, 298, 17518, 2, 2742, 198, 318, 511, 3162, 8, 277, 304, 686, 198, 277, 14, 1287, 14, 928, 342, 686, 198, 277, 14, 1815, 8, 552, 8, 277, 14, 1287, 423, 13206, 685, 328, 1190, 9, 690, 1616, 9, 2742, 198, 318, 511, 6293, 8, 277, 304, 686, 198, 277, 14, 396, 3162, 342, 686, 198, 277, 14, 1287, 14, 2379, 342, 686, 198, 277, 14, 1815, 8, 552, 8, 277, 14, 1287, 423, 13206, 685, 328, 1190, 9, 508, 378, 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 ]
[ 325, 19309, 26, 1882, 818, 26, 2366, 27, 1134, 13, 3724, 13, 2743, 26, 841, 27, 4363, 13, 8741, 13, 632, 26, 307, 1882, 199, 3, 1321, 26, 663, 18133, 29, 1548, 23014, 29, 20, 6714, 29, 20, 5584, 29, 20, 949, 386, 520, 199, 199, 3, 961, 570, 365, 1777, 402, 12176, 18, 28018, 14, 199, 3, 199, 3, 12176, 18, 28018, 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, 12176, 18, 28018, 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, 12176, 18, 28018, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 14, 199, 199, 646, 747, 199, 646, 2882, 199, 646, 984, 199, 199, 504, 2508, 5869, 74, 1054, 492, 9762, 42, 1054, 199, 504, 2508, 1208, 492, 15869, 63, 3022, 199, 199, 692, 984, 14, 1023, 63, 815, 2356, 334, 18, 12, 23, 304, 199, 198, 533, 8857, 1772, 83, 3310, 774, 8, 2796, 14, 1746, 304, 2742, 198, 318, 3613, 8, 277, 304, 686, 198, 624, 2176, 2544, 4036, 511, 1930, 1041, 686, 198, 277, 14, 74, 1054, 275, 9762, 42, 1054, 342, 6319, 198, 277, 14, 74, 1054, 14, 3723, 14, 525, 480, 396, 531, 6319, 198, 1548, 2377, 275, 747, 14, 515, 14, 904, 8, 5569, 63, 3022, 12, 298, 1287, 14, 68, 401, 298, 2470, 328, 1190, 14, 647, 531, 686, 198, 277, 14, 74, 1054, 14, 3723, 14, 525, 480, 2470, 328, 1190, 401, 2366, 2377, 12, 4205, 24429, 3126, 1585, 198, 7, 3710, 356, 298, 5510, 401, 1585, 198, 7, 13206, 1287, 356, 298, 396, 401, 1585, 198, 1552, 686, 198, 277, 14, 1287, 275, 291, 14, 74, 1054, 14, 3723, 905, 2470, 328, 1190, 937, 2742, 198, 318, 6766, 8, 277, 304, 686, 198, 624, 2176, 2410, 4036, 511, 1930, 1041, 686, 198, 3, 9498, 9311, 9715, 1, 686, 198, 692, 291, 14, 1287, 423, 7414, 26, 1585, 198, 277, 14, 1287, 423, 7414, 14, 6406, 342, 2742, 198, 318, 511, 7841, 8, 277, 304, 686, 198, 8906, 275, 291, 14, 1287, 14, 362, 28731, 342, 686, 198, 277, 14, 1815, 480, 5510, 2, 315, 9695, 9, 686, 198, 277, 14, 1815, 8, 552, 8, 8906, 9, 2356, 1616, 9, 6319, 198, 277, 14, 1855, 8, 1585, 198, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 3710, 401, 1585, 198, 2, 3197, 13, 3710, 531, 6319, 198, 3, 2832, 1686, 367, 17290, 4637, 1396, 686, 198, 277, 14, 1855, 8, 1585, 198, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 3710, 401, 298, 1198, 531, 686, 198, 3, 1325, 1686, 367, 12136, 16115, 14, 686, 198, 277, 14, 1287, 14, 13206, 3710, 275, 298, 1198, 2, 2742, 198, 318, 511, 12642, 8, 277, 304, 686, 198, 277, 14, 1855, 8, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 3397, 401, 446, 21, 9, 686, 198, 277, 14, 1287, 14, 3397, 275, 959, 686, 198, 277, 14, 1287, 14, 3397, 275, 298, 21, 2, 2742, 198, 318, 511, 28018, 1287, 8, 277, 304, 686, 198, 277, 14, 1855, 8, 1585, 198, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 13206, 1287, 401, 1585, 198, 2, 3197, 13, 1287, 531, 686, 198, 277, 14, 1287, 14, 13206, 1287, 275, 298, 396, 2, 2742, 198, 318, 511, 4152, 5191, 8, 277, 304, 686, 198, 277, 14, 1855, 8, 1585, 198, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 873, 5191, 401, 446, 1400, 9, 686, 198, 277, 14, 1855, 8, 1585, 198, 3393, 12, 5371, 12, 291, 14, 1287, 12, 298, 873, 5191, 401, 378, 9, 686, 198, 277, 14, 1287, 14, 873, 5191, 275, 27151, 686, 198, 277, 14, 1287, 14, 873, 5191, 275, 298, 17518, 2, 2742, 198, 318, 511, 3162, 8, 277, 304, 686, 198, 277, 14, 1287, 14, 928, 342, 686, 198, 277, 14, 1815, 8, 552, 8, 277, 14, 1287, 423, 13206, 685, 328, 1190, 9, 690, 1616, 9, 2742, 198, 318, 511, 6293, 8, 277, 304, 686, 198, 277, 14, 396, 3162, 342, 686, 198, 277, 14, 1287, 14, 2379, 342, 686, 198, 277, 14, 1815, 8, 552, 8, 277, 14, 1287, 423, 13206, 685, 328, 1190, 9, 508, 378, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
nemesisdesign/django
tests/null_queries/tests.py
55
2973
from __future__ import unicode_literals from django.core.exceptions import FieldError from django.test import TestCase from .models import Choice, Inner, OuterA, OuterB, Poll class NullQueriesTests(TestCase): def test_none_as_null(self): """ Regression test for the use of None as a query value. None is interpreted as an SQL NULL, but only in __exact and __iexact queries. Set up some initial polls and choices """ p1 = Poll(question='Why?') p1.save() c1 = Choice(poll=p1, choice='Because.') c1.save() c2 = Choice(poll=p1, choice='Why Not?') c2.save() # Exact query with value None returns nothing ("is NULL" in sql, # but every 'id' field has a value). self.assertQuerysetEqual(Choice.objects.filter(choice__exact=None), []) # The same behavior for iexact query. self.assertQuerysetEqual(Choice.objects.filter(choice__iexact=None), []) # Excluding the previous result returns everything. self.assertQuerysetEqual( Choice.objects.exclude(choice=None).order_by('id'), [ '<Choice: Choice: Because. in poll Q: Why? >', '<Choice: Choice: Why Not? in poll Q: Why? >' ] ) # Valid query, but fails because foo isn't a keyword with self.assertRaises(FieldError): Choice.objects.filter(foo__exact=None) # Can't use None on anything other than __exact and __iexact with self.assertRaises(ValueError): Choice.objects.filter(id__gt=None) # Related managers use __exact=None implicitly if the object hasn't been saved. p2 = Poll(question="How?") self.assertEqual(repr(p2.choice_set.all()), '<QuerySet []>') def test_reverse_relations(self): """ Querying across reverse relations and then another relation should insert outer joins correctly so as not to exclude results. """ obj = OuterA.objects.create() self.assertQuerysetEqual( OuterA.objects.filter(inner__third=None), ['<OuterA: OuterA object>'] ) self.assertQuerysetEqual( OuterA.objects.filter(inner__third__data=None), ['<OuterA: OuterA object>'] ) Inner.objects.create(first=obj) self.assertQuerysetEqual( Inner.objects.filter(first__inner__third=None), ['<Inner: Inner object>'] ) # Ticket #13815: check if <reverse>_isnull=False does not produce # faulty empty lists OuterB.objects.create(data="reverse") self.assertQuerysetEqual( OuterB.objects.filter(inner__isnull=False), [] ) Inner.objects.create(first=obj) self.assertQuerysetEqual( OuterB.objects.exclude(inner__isnull=False), ['<OuterB: OuterB object>'] )
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 16053, 12, 19646, 12, 593, 2699, 33, 12, 593, 2699, 34, 12, 25306, 421, 199, 533, 12119, 13611, 2925, 8, 1746, 304, 339, 347, 511, 63, 3592, 63, 305, 63, 2307, 8, 277, 304, 267, 408, 267, 13262, 511, 367, 314, 675, 402, 488, 465, 282, 1827, 574, 14, 398, 488, 365, 11922, 465, 376, 5385, 5962, 12, 1325, 1454, 315, 636, 7327, 436, 636, 32344, 267, 9212, 14, 267, 2494, 1536, 2005, 2536, 3708, 478, 436, 3415, 267, 408, 267, 299, 17, 275, 25306, 8, 4790, 534, 55, 3577, 18478, 267, 299, 17, 14, 2117, 342, 267, 286, 17, 275, 16053, 8, 6843, 29, 80, 17, 12, 7141, 534, 3655, 2651, 2659, 267, 286, 17, 14, 2117, 342, 267, 286, 18, 275, 16053, 8, 6843, 29, 80, 17, 12, 7141, 534, 55, 3577, 2832, 18478, 267, 286, 18, 14, 2117, 342, 398, 327, 1316, 2442, 1827, 543, 574, 488, 2529, 6548, 1689, 374, 5962, 2, 315, 3875, 12, 267, 327, 1325, 4036, 283, 344, 7, 901, 965, 282, 574, 680, 267, 291, 14, 7108, 8, 9054, 14, 1462, 14, 1541, 8, 5095, 363, 7327, 29, 403, 395, 3073, 398, 327, 710, 2011, 5953, 367, 284, 7327, 1827, 14, 267, 291, 14, 7108, 8, 9054, 14, 1462, 14, 1541, 8, 5095, 363, 32344, 29, 403, 395, 3073, 398, 327, 1316, 4923, 314, 4136, 754, 2529, 8137, 14, 267, 291, 14, 7108, 8, 288, 16053, 14, 1462, 14, 5473, 8, 5095, 29, 403, 680, 1648, 63, 991, 360, 344, 659, 288, 359, 355, 2650, 9054, 26, 16053, 26, 13821, 14, 315, 11271, 1413, 26, 6827, 31, 3445, 355, 2650, 9054, 26, 16053, 26, 6827, 2832, 31, 315, 11271, 1413, 26, 6827, 31, 690, 7, 288, 1622, 267, 776, 398, 327, 4821, 1827, 12, 1325, 6918, 2952, 3925, 5712, 1133, 282, 4252, 267, 543, 291, 14, 1855, 8, 792, 547, 304, 288, 16053, 14, 1462, 14, 1541, 8, 1421, 363, 7327, 29, 403, 9, 398, 327, 6855, 1133, 675, 488, 641, 7003, 1163, 2419, 636, 7327, 436, 636, 32344, 267, 543, 291, 14, 1855, 8, 3393, 304, 288, 16053, 14, 1462, 14, 1541, 8, 344, 363, 3308, 29, 403, 9, 398, 327, 20116, 19680, 675, 636, 7327, 29, 403, 19796, 340, 314, 909, 18699, 1133, 2757, 6290, 14, 267, 299, 18, 275, 25306, 8, 4790, 628, 18335, 18582, 267, 291, 14, 629, 8, 2722, 8, 80, 18, 14, 5095, 63, 409, 14, 452, 4000, 2650, 13689, 942, 5971, 339, 347, 511, 63, 4471, 63, 15741, 8, 277, 304, 267, 408, 267, 8133, 316, 9371, 3837, 16109, 436, 2066, 4573, 5850, 1077, 267, 5518, 6890, 18266, 6657, 880, 465, 440, 370, 5760, 2058, 14, 267, 408, 267, 1559, 275, 593, 2699, 33, 14, 1462, 14, 981, 342, 267, 291, 14, 7108, 8, 288, 593, 2699, 33, 14, 1462, 14, 1541, 8, 5216, 363, 11470, 29, 403, 395, 288, 12329, 47, 2699, 33, 26, 593, 2699, 33, 909, 18763, 267, 776, 267, 291, 14, 7108, 8, 288, 593, 2699, 33, 14, 1462, 14, 1541, 8, 5216, 363, 11470, 363, 576, 29, 403, 395, 288, 12329, 47, 2699, 33, 26, 593, 2699, 33, 909, 18763, 267, 776, 398, 19646, 14, 1462, 14, 981, 8, 2246, 29, 1113, 9, 267, 291, 14, 7108, 8, 288, 19646, 14, 1462, 14, 1541, 8, 2246, 363, 5216, 363, 11470, 29, 403, 395, 288, 12329, 22964, 26, 19646, 909, 18763, 267, 776, 398, 327, 21932, 327, 8527, 1046, 26, 1104, 340, 665, 4471, 30, 63, 15114, 29, 797, 1630, 440, 7389, 267, 327, 1433, 17323, 2701, 5548, 267, 593, 2699, 34, 14, 1462, 14, 981, 8, 576, 628, 4471, 531, 267, 291, 14, 7108, 8, 288, 593, 2699, 34, 14, 1462, 14, 1541, 8, 5216, 363, 15114, 29, 797, 395, 288, 942, 267, 776, 267, 19646, 14, 1462, 14, 981, 8, 2246, 29, 1113, 9, 267, 291, 14, 7108, 8, 288, 593, 2699, 34, 14, 1462, 14, 5473, 8, 5216, 363, 15114, 29, 797, 395, 288, 12329, 47, 2699, 34, 26, 593, 2699, 34, 909, 18763, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 16053, 12, 19646, 12, 593, 2699, 33, 12, 593, 2699, 34, 12, 25306, 421, 199, 533, 12119, 13611, 2925, 8, 1746, 304, 339, 347, 511, 63, 3592, 63, 305, 63, 2307, 8, 277, 304, 267, 408, 267, 13262, 511, 367, 314, 675, 402, 488, 465, 282, 1827, 574, 14, 398, 488, 365, 11922, 465, 376, 5385, 5962, 12, 1325, 1454, 315, 636, 7327, 436, 636, 32344, 267, 9212, 14, 267, 2494, 1536, 2005, 2536, 3708, 478, 436, 3415, 267, 408, 267, 299, 17, 275, 25306, 8, 4790, 534, 55, 3577, 18478, 267, 299, 17, 14, 2117, 342, 267, 286, 17, 275, 16053, 8, 6843, 29, 80, 17, 12, 7141, 534, 3655, 2651, 2659, 267, 286, 17, 14, 2117, 342, 267, 286, 18, 275, 16053, 8, 6843, 29, 80, 17, 12, 7141, 534, 55, 3577, 2832, 18478, 267, 286, 18, 14, 2117, 342, 398, 327, 1316, 2442, 1827, 543, 574, 488, 2529, 6548, 1689, 374, 5962, 2, 315, 3875, 12, 267, 327, 1325, 4036, 283, 344, 7, 901, 965, 282, 574, 680, 267, 291, 14, 7108, 8, 9054, 14, 1462, 14, 1541, 8, 5095, 363, 7327, 29, 403, 395, 3073, 398, 327, 710, 2011, 5953, 367, 284, 7327, 1827, 14, 267, 291, 14, 7108, 8, 9054, 14, 1462, 14, 1541, 8, 5095, 363, 32344, 29, 403, 395, 3073, 398, 327, 1316, 4923, 314, 4136, 754, 2529, 8137, 14, 267, 291, 14, 7108, 8, 288, 16053, 14, 1462, 14, 5473, 8, 5095, 29, 403, 680, 1648, 63, 991, 360, 344, 659, 288, 359, 355, 2650, 9054, 26, 16053, 26, 13821, 14, 315, 11271, 1413, 26, 6827, 31, 3445, 355, 2650, 9054, 26, 16053, 26, 6827, 2832, 31, 315, 11271, 1413, 26, 6827, 31, 690, 7, 288, 1622, 267, 776, 398, 327, 4821, 1827, 12, 1325, 6918, 2952, 3925, 5712, 1133, 282, 4252, 267, 543, 291, 14, 1855, 8, 792, 547, 304, 288, 16053, 14, 1462, 14, 1541, 8, 1421, 363, 7327, 29, 403, 9, 398, 327, 6855, 1133, 675, 488, 641, 7003, 1163, 2419, 636, 7327, 436, 636, 32344, 267, 543, 291, 14, 1855, 8, 3393, 304, 288, 16053, 14, 1462, 14, 1541, 8, 344, 363, 3308, 29, 403, 9, 398, 327, 20116, 19680, 675, 636, 7327, 29, 403, 19796, 340, 314, 909, 18699, 1133, 2757, 6290, 14, 267, 299, 18, 275, 25306, 8, 4790, 628, 18335, 18582, 267, 291, 14, 629, 8, 2722, 8, 80, 18, 14, 5095, 63, 409, 14, 452, 4000, 2650, 13689, 942, 5971, 339, 347, 511, 63, 4471, 63, 15741, 8, 277, 304, 267, 408, 267, 8133, 316, 9371, 3837, 16109, 436, 2066, 4573, 5850, 1077, 267, 5518, 6890, 18266, 6657, 880, 465, 440, 370, 5760, 2058, 14, 267, 408, 267, 1559, 275, 593, 2699, 33, 14, 1462, 14, 981, 342, 267, 291, 14, 7108, 8, 288, 593, 2699, 33, 14, 1462, 14, 1541, 8, 5216, 363, 11470, 29, 403, 395, 288, 12329, 47, 2699, 33, 26, 593, 2699, 33, 909, 18763, 267, 776, 267, 291, 14, 7108, 8, 288, 593, 2699, 33, 14, 1462, 14, 1541, 8, 5216, 363, 11470, 363, 576, 29, 403, 395, 288, 12329, 47, 2699, 33, 26, 593, 2699, 33, 909, 18763, 267, 776, 398, 19646, 14, 1462, 14, 981, 8, 2246, 29, 1113, 9, 267, 291, 14, 7108, 8, 288, 19646, 14, 1462, 14, 1541, 8, 2246, 363, 5216, 363, 11470, 29, 403, 395, 288, 12329, 22964, 26, 19646, 909, 18763, 267, 776, 398, 327, 21932, 327, 8527, 1046, 26, 1104, 340, 665, 4471, 30, 63, 15114, 29, 797, 1630, 440, 7389, 267, 327, 1433, 17323, 2701, 5548, 267, 593, 2699, 34, 14, 1462, 14, 981, 8, 576, 628, 4471, 531, 267, 291, 14, 7108, 8, 288, 593, 2699, 34, 14, 1462, 14, 1541, 8, 5216, 363, 15114, 29, 797, 395, 288, 942, 267, 776, 267, 19646, 14, 1462, 14, 981, 8, 2246, 29, 1113, 9, 267, 291, 14, 7108, 8, 288, 593, 2699, 34, 14, 1462, 14, 5473, 8, 5216, 363, 15114, 29, 797, 395, 288, 12329, 47, 2699, 34, 26, 593, 2699, 34, 909, 18763, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
renesugar/arrow
python/pyarrow/tests/test_jvm.py
5
13848
# -*- coding: utf-8 -*- # 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 json import os import pyarrow as pa import pyarrow.jvm as pa_jvm import pytest import six import sys import xml.etree.ElementTree as ET jpype = pytest.importorskip("jpype") @pytest.fixture(scope="session") def root_allocator(): # This test requires Arrow Java to be built in the same source tree pom_path = os.path.join( os.path.dirname(__file__), '..', '..', '..', 'java', 'pom.xml') tree = ET.parse(pom_path) version = tree.getroot().find( 'POM:version', namespaces={ 'POM': 'http://maven.apache.org/POM/4.0.0' }).text jar_path = os.path.join( os.path.dirname(__file__), '..', '..', '..', 'java', 'tools', 'target', 'arrow-tools-{}-jar-with-dependencies.jar'.format(version)) jar_path = os.getenv("ARROW_TOOLS_JAR", jar_path) jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=" + jar_path) return jpype.JPackage("org").apache.arrow.memory.RootAllocator(sys.maxsize) def test_jvm_buffer(root_allocator): # Create a buffer jvm_buffer = root_allocator.buffer(8) for i in range(8): jvm_buffer.setByte(i, 8 - i) # Convert to Python buf = pa_jvm.jvm_buffer(jvm_buffer) # Check its content assert buf.to_pybytes() == b'\x08\x07\x06\x05\x04\x03\x02\x01' def _jvm_field(jvm_spec): om = jpype.JClass('com.fasterxml.jackson.databind.ObjectMapper')() pojo_Field = jpype.JClass('org.apache.arrow.vector.types.pojo.Field') return om.readValue(jvm_spec, pojo_Field) def _jvm_schema(jvm_spec, metadata=None): field = _jvm_field(jvm_spec) schema_cls = jpype.JClass('org.apache.arrow.vector.types.pojo.Schema') fields = jpype.JClass('java.util.ArrayList')() fields.add(field) if metadata: dct = jpype.JClass('java.util.HashMap')() for k, v in six.iteritems(metadata): dct.put(k, v) return schema_cls(fields, dct) else: return schema_cls(fields) # In the following, we use the JSON serialization of the Field objects in Java. # This ensures that we neither rely on the exact mechanics on how to construct # them using Java code as well as enables us to define them as parameters # without to invoke the JVM. # # The specifications were created using: # # om = jpype.JClass('com.fasterxml.jackson.databind.ObjectMapper')() # field = … # Code to instantiate the field # jvm_spec = om.writeValueAsString(field) @pytest.mark.parametrize('pa_type,jvm_spec', [ (pa.null(), '{"name":"null"}'), (pa.bool_(), '{"name":"bool"}'), (pa.int8(), '{"name":"int","bitWidth":8,"isSigned":true}'), (pa.int16(), '{"name":"int","bitWidth":16,"isSigned":true}'), (pa.int32(), '{"name":"int","bitWidth":32,"isSigned":true}'), (pa.int64(), '{"name":"int","bitWidth":64,"isSigned":true}'), (pa.uint8(), '{"name":"int","bitWidth":8,"isSigned":false}'), (pa.uint16(), '{"name":"int","bitWidth":16,"isSigned":false}'), (pa.uint32(), '{"name":"int","bitWidth":32,"isSigned":false}'), (pa.uint64(), '{"name":"int","bitWidth":64,"isSigned":false}'), (pa.float16(), '{"name":"floatingpoint","precision":"HALF"}'), (pa.float32(), '{"name":"floatingpoint","precision":"SINGLE"}'), (pa.float64(), '{"name":"floatingpoint","precision":"DOUBLE"}'), (pa.time32('s'), '{"name":"time","unit":"SECOND","bitWidth":32}'), (pa.time32('ms'), '{"name":"time","unit":"MILLISECOND","bitWidth":32}'), (pa.time64('us'), '{"name":"time","unit":"MICROSECOND","bitWidth":64}'), (pa.time64('ns'), '{"name":"time","unit":"NANOSECOND","bitWidth":64}'), (pa.timestamp('s'), '{"name":"timestamp","unit":"SECOND",' '"timezone":null}'), (pa.timestamp('ms'), '{"name":"timestamp","unit":"MILLISECOND",' '"timezone":null}'), (pa.timestamp('us'), '{"name":"timestamp","unit":"MICROSECOND",' '"timezone":null}'), (pa.timestamp('ns'), '{"name":"timestamp","unit":"NANOSECOND",' '"timezone":null}'), (pa.timestamp('ns', tz='UTC'), '{"name":"timestamp","unit":"NANOSECOND"' ',"timezone":"UTC"}'), (pa.timestamp('ns', tz='Europe/Paris'), '{"name":"timestamp",' '"unit":"NANOSECOND","timezone":"Europe/Paris"}'), (pa.date32(), '{"name":"date","unit":"DAY"}'), (pa.date64(), '{"name":"date","unit":"MILLISECOND"}'), (pa.decimal128(19, 4), '{"name":"decimal","precision":19,"scale":4}'), (pa.string(), '{"name":"utf8"}'), (pa.binary(), '{"name":"binary"}'), (pa.binary(10), '{"name":"fixedsizebinary","byteWidth":10}'), # TODO(ARROW-2609): complex types that have children # pa.list_(pa.int32()), # pa.struct([pa.field('a', pa.int32()), # pa.field('b', pa.int8()), # pa.field('c', pa.string())]), # pa.union([pa.field('a', pa.binary(10)), # pa.field('b', pa.string())], mode=pa.lib.UnionMode_DENSE), # pa.union([pa.field('a', pa.binary(10)), # pa.field('b', pa.string())], mode=pa.lib.UnionMode_SPARSE), # TODO: DictionaryType requires a vector in the type # pa.dictionary(pa.int32(), pa.array(['a', 'b', 'c'])), ]) @pytest.mark.parametrize('nullable', [True, False]) def test_jvm_types(root_allocator, pa_type, jvm_spec, nullable): spec = { 'name': 'field_name', 'nullable': nullable, 'type': json.loads(jvm_spec), # TODO: This needs to be set for complex types 'children': [] } jvm_field = _jvm_field(json.dumps(spec)) result = pa_jvm.field(jvm_field) expected_field = pa.field('field_name', pa_type, nullable=nullable) assert result == expected_field jvm_schema = _jvm_schema(json.dumps(spec)) result = pa_jvm.schema(jvm_schema) assert result == pa.schema([expected_field]) # Schema with custom metadata jvm_schema = _jvm_schema(json.dumps(spec), {'meta': 'data'}) result = pa_jvm.schema(jvm_schema) assert result == pa.schema([expected_field], {'meta': 'data'}) # These test parameters mostly use an integer range as an input as this is # often the only type that is understood by both Python and Java # implementations of Arrow. @pytest.mark.parametrize('pa_type,py_data,jvm_type', [ (pa.bool_(), [True, False, True, True], 'BitVector'), (pa.uint8(), list(range(128)), 'UInt1Vector'), (pa.uint16(), list(range(128)), 'UInt2Vector'), (pa.int32(), list(range(128)), 'IntVector'), (pa.int64(), list(range(128)), 'BigIntVector'), (pa.float32(), list(range(128)), 'Float4Vector'), (pa.float64(), list(range(128)), 'Float8Vector'), (pa.timestamp('s'), list(range(128)), 'TimeStampSecVector'), (pa.timestamp('ms'), list(range(128)), 'TimeStampMilliVector'), (pa.timestamp('us'), list(range(128)), 'TimeStampMicroVector'), (pa.timestamp('ns'), list(range(128)), 'TimeStampNanoVector'), # TODO(ARROW-2605): These types miss a conversion from pure Python objects # * pa.time32('s') # * pa.time32('ms') # * pa.time64('us') # * pa.time64('ns') (pa.date32(), list(range(128)), 'DateDayVector'), (pa.date64(), list(range(128)), 'DateMilliVector'), # TODO(ARROW-2606): pa.decimal128(19, 4) ]) def test_jvm_array(root_allocator, pa_type, py_data, jvm_type): # Create vector cls = "org.apache.arrow.vector.{}".format(jvm_type) jvm_vector = jpype.JClass(cls)("vector", root_allocator) jvm_vector.allocateNew(len(py_data)) for i, val in enumerate(py_data): jvm_vector.setSafe(i, val) jvm_vector.setValueCount(len(py_data)) py_array = pa.array(py_data, type=pa_type) jvm_array = pa_jvm.array(jvm_vector) assert py_array.equals(jvm_array) # These test parameters mostly use an integer range as an input as this is # often the only type that is understood by both Python and Java # implementations of Arrow. @pytest.mark.parametrize('pa_type,py_data,jvm_type,jvm_spec', [ # TODO: null (pa.bool_(), [True, False, True, True], 'BitVector', '{"name":"bool"}'), ( pa.uint8(), list(range(128)), 'UInt1Vector', '{"name":"int","bitWidth":8,"isSigned":false}' ), ( pa.uint16(), list(range(128)), 'UInt2Vector', '{"name":"int","bitWidth":16,"isSigned":false}' ), ( pa.uint32(), list(range(128)), 'UInt4Vector', '{"name":"int","bitWidth":32,"isSigned":false}' ), ( pa.uint64(), list(range(128)), 'UInt8Vector', '{"name":"int","bitWidth":64,"isSigned":false}' ), ( pa.int8(), list(range(128)), 'TinyIntVector', '{"name":"int","bitWidth":8,"isSigned":true}' ), ( pa.int16(), list(range(128)), 'SmallIntVector', '{"name":"int","bitWidth":16,"isSigned":true}' ), ( pa.int32(), list(range(128)), 'IntVector', '{"name":"int","bitWidth":32,"isSigned":true}' ), ( pa.int64(), list(range(128)), 'BigIntVector', '{"name":"int","bitWidth":64,"isSigned":true}' ), # TODO: float16 ( pa.float32(), list(range(128)), 'Float4Vector', '{"name":"floatingpoint","precision":"SINGLE"}' ), ( pa.float64(), list(range(128)), 'Float8Vector', '{"name":"floatingpoint","precision":"DOUBLE"}' ), ( pa.timestamp('s'), list(range(128)), 'TimeStampSecVector', '{"name":"timestamp","unit":"SECOND","timezone":null}' ), ( pa.timestamp('ms'), list(range(128)), 'TimeStampMilliVector', '{"name":"timestamp","unit":"MILLISECOND","timezone":null}' ), ( pa.timestamp('us'), list(range(128)), 'TimeStampMicroVector', '{"name":"timestamp","unit":"MICROSECOND","timezone":null}' ), ( pa.timestamp('ns'), list(range(128)), 'TimeStampNanoVector', '{"name":"timestamp","unit":"NANOSECOND","timezone":null}' ), # TODO(ARROW-2605): These types miss a conversion from pure Python objects # * pa.time32('s') # * pa.time32('ms') # * pa.time64('us') # * pa.time64('ns') ( pa.date32(), list(range(128)), 'DateDayVector', '{"name":"date","unit":"DAY"}' ), ( pa.date64(), list(range(128)), 'DateMilliVector', '{"name":"date","unit":"MILLISECOND"}' ), # TODO(ARROW-2606): pa.decimal128(19, 4) ]) def test_jvm_record_batch(root_allocator, pa_type, py_data, jvm_type, jvm_spec): # Create vector cls = "org.apache.arrow.vector.{}".format(jvm_type) jvm_vector = jpype.JClass(cls)("vector", root_allocator) jvm_vector.allocateNew(len(py_data)) for i, val in enumerate(py_data): jvm_vector.setSafe(i, val) jvm_vector.setValueCount(len(py_data)) # Create field spec = { 'name': 'field_name', 'nullable': False, 'type': json.loads(jvm_spec), # TODO: This needs to be set for complex types 'children': [] } jvm_field = _jvm_field(json.dumps(spec)) # Create VectorSchemaRoot jvm_fields = jpype.JClass('java.util.ArrayList')() jvm_fields.add(jvm_field) jvm_vectors = jpype.JClass('java.util.ArrayList')() jvm_vectors.add(jvm_vector) jvm_vsr = jpype.JClass('org.apache.arrow.vector.VectorSchemaRoot') jvm_vsr = jvm_vsr(jvm_fields, jvm_vectors, len(py_data)) py_record_batch = pa.RecordBatch.from_arrays( [pa.array(py_data, type=pa_type)], ['col'] ) jvm_record_batch = pa_jvm.record_batch(jvm_vsr) assert py_record_batch.equals(jvm_record_batch) def _string_to_varchar_holder(ra, string): nvch_cls = "org.apache.arrow.vector.holders.NullableVarCharHolder" holder = jpype.JClass(nvch_cls)() if string is None: holder.isSet = 0 else: holder.isSet = 1 value = jpype.JClass("java.lang.String")("string") std_charsets = jpype.JClass("java.nio.charset.StandardCharsets") bytes_ = value.getBytes(std_charsets.UTF_8) holder.buffer = ra.buffer(len(bytes_)) holder.buffer.setBytes(0, bytes_, 0, len(bytes_)) holder.start = 0 holder.end = len(bytes_) return holder # TODO(ARROW-2607) @pytest.mark.xfail(reason="from_buffers is only supported for " "primitive arrays yet") def test_jvm_string_array(root_allocator): data = [u"string", None, u"töst"] cls = "org.apache.arrow.vector.VarCharVector" jvm_vector = jpype.JClass(cls)("vector", root_allocator) jvm_vector.allocateNew() for i, string in enumerate(data): holder = _string_to_varchar_holder(root_allocator, "string") jvm_vector.setSafe(i, holder) jvm_vector.setValueCount(i + 1) py_array = pa.array(data, type=pa.string()) jvm_array = pa_jvm.array(jvm_vector) assert py_array.equals(jvm_array)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 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, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 1134, 7691, 465, 691, 199, 646, 1134, 7691, 14, 15813, 465, 691, 63, 15813, 199, 646, 4613, 199, 646, 3816, 199, 646, 984, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 421, 199, 11538, 514, 275, 4613, 14, 646, 269, 2759, 480, 11538, 514, 531, 421, 199, 32, 4462, 14, 5997, 8, 2645, 628, 1730, 531, 199, 318, 1738, 63, 14228, 837, 272, 327, 961, 511, 5074, 1952, 1143, 9586, 370, 506, 6137, 315, 314, 2011, 1350, 3123, 272, 299, 676, 63, 515, 275, 747, 14, 515, 14, 904, 8, 267, 747, 14, 515, 14, 3475, 3460, 493, 10139, 19155, 19155, 19155, 267, 283, 6138, 297, 283, 555, 77, 14, 1652, 358, 272, 3123, 275, 12265, 14, 1122, 8, 555, 77, 63, 515, 9, 272, 1015, 275, 3123, 14, 24544, 1252, 1623, 8, 267, 283, 1512, 45, 26, 1023, 297, 267, 10747, 3126, 288, 283, 1512, 45, 356, 283, 1014, 921, 391, 1856, 14, 3796, 14, 1308, 15, 1512, 45, 15, 20, 14, 16, 14, 16, 7, 267, 789, 680, 505, 272, 16290, 63, 515, 275, 747, 14, 515, 14, 904, 8, 267, 747, 14, 515, 14, 3475, 3460, 493, 10139, 19155, 19155, 19155, 267, 283, 6138, 297, 283, 2537, 297, 283, 1375, 297, 267, 283, 7691, 13, 2537, 13, 2440, 13, 7338, 13, 1045, 13, 5714, 14, 7338, 1370, 908, 8, 1023, 430, 272, 16290, 63, 515, 275, 747, 14, 12959, 480, 689, 11415, 63, 20261, 63, 42, 689, 401, 16290, 63, 515, 9, 272, 28921, 514, 14, 928, 42, 6849, 8, 11538, 514, 14, 362, 2698, 42, 54, 1658, 1619, 1062, 3905, 36, 6138, 14, 533, 14, 515, 628, 435, 16290, 63, 515, 9, 272, 372, 28921, 514, 14, 42, 8599, 480, 1308, 3471, 3796, 14, 7691, 14, 4844, 14, 6405, 20191, 8, 1274, 14, 13634, 9, 421, 199, 318, 511, 63, 15813, 63, 2738, 8, 1231, 63, 14228, 304, 272, 327, 2790, 282, 3335, 272, 1335, 2611, 63, 2738, 275, 1738, 63, 14228, 14, 2738, 8, 24, 9, 272, 367, 284, 315, 1425, 8, 24, 304, 267, 1335, 2611, 63, 2738, 14, 409, 4861, 8, 73, 12, 1695, 446, 284, 9, 339, 327, 7905, 370, 2018, 272, 4123, 275, 691, 63, 15813, 14, 15813, 63, 2738, 8, 15813, 63, 2738, 9, 339, 327, 2670, 2399, 1564, 272, 702, 4123, 14, 475, 63, 647, 2394, 342, 508, 330, 1154, 88, 2036, 60, 88, 1780, 60, 88, 1690, 60, 88, 1717, 60, 88, 966, 60, 88, 1644, 60, 88, 996, 60, 88, 614, 7, 421, 199, 318, 485, 15813, 63, 698, 8, 15813, 63, 1650, 304, 272, 30511, 275, 28921, 514, 14, 42, 2543, 360, 957, 14, 70, 2311, 1652, 14, 19193, 834, 14, 68, 1936, 688, 14, 1692, 11880, 358, 342, 272, 1115, 743, 63, 792, 275, 28921, 514, 14, 42, 2543, 360, 1308, 14, 3796, 14, 7691, 14, 4106, 14, 1313, 14, 555, 743, 14, 792, 358, 272, 372, 30511, 14, 739, 1110, 8, 15813, 63, 1650, 12, 1115, 743, 63, 792, 9, 421, 199, 318, 485, 15813, 63, 3629, 8, 15813, 63, 1650, 12, 3341, 29, 403, 304, 272, 901, 275, 485, 15813, 63, 698, 8, 15813, 63, 1650, 9, 272, 4177, 63, 1886, 275, 28921, 514, 14, 42, 2543, 360, 1308, 14, 3796, 14, 7691, 14, 4106, 14, 1313, 14, 555, 743, 14, 6700, 358, 272, 1504, 275, 28921, 514, 14, 42, 2543, 360, 6138, 14, 1974, 14, 3836, 1296, 358, 342, 272, 1504, 14, 525, 8, 698, 9, 272, 340, 3341, 26, 267, 16354, 275, 28921, 514, 14, 42, 2543, 360, 6138, 14, 1974, 14, 3476, 2956, 358, 342, 267, 367, 1022, 12, 373, 315, 3816, 14, 4611, 8, 2343, 304, 288, 16354, 14, 524, 8, 75, 12, 373, 9, 267, 372, 4177, 63, 1886, 8, 955, 12, 16354, 9, 272, 587, 26, 267, 372, 4177, 63, 1886, 8, 955, 9, 421, 199, 3, 1010, 314, 2569, 12, 781, 675, 314, 4840, 16953, 402, 314, 5024, 2251, 315, 9586, 14, 199, 3, 961, 15620, 626, 781, 15564, 19687, 641, 314, 5835, 562, 11984, 2932, 641, 4212, 370, 6982, 199, 3, 3062, 1808, 9586, 1233, 465, 5521, 465, 22741, 2739, 370, 5627, 3062, 465, 2633, 199, 3, 1928, 370, 12677, 314, 1603, 6849, 14, 199, 3, 199, 3, 710, 28754, 4898, 2737, 1808, 26, 199, 3, 199, 3, 257, 30511, 275, 28921, 514, 14, 42, 2543, 360, 957, 14, 70, 2311, 1652, 14, 19193, 834, 14, 68, 1936, 688, 14, 1692, 11880, 358, 342, 199, 3, 257, 901, 275, 27430, 100, 221, 327, 5495, 370, 17321, 314, 901, 199, 3, 257, 1335, 2611, 63, 1650, 275, 30511, 14, 952, 1110, 2822, 1558, 8, 698, 9, 199, 32, 4462, 14, 1657, 14, 10396, 360, 387, 63, 466, 12, 15813, 63, 1650, 297, 359, 272, 334, 387, 14, 2307, 1062, 17137, 354, 5122, 2307, 3570, 659, 272, 334, 387, 14, 2245, 63, 1062, 17137, 354, 5122, 2245, 3570, 659, 272, 334, 387, 14, 442, 24, 1062, 17137, 354, 5122, 442, 2266, 2075 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 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, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 1134, 7691, 465, 691, 199, 646, 1134, 7691, 14, 15813, 465, 691, 63, 15813, 199, 646, 4613, 199, 646, 3816, 199, 646, 984, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 421, 199, 11538, 514, 275, 4613, 14, 646, 269, 2759, 480, 11538, 514, 531, 421, 199, 32, 4462, 14, 5997, 8, 2645, 628, 1730, 531, 199, 318, 1738, 63, 14228, 837, 272, 327, 961, 511, 5074, 1952, 1143, 9586, 370, 506, 6137, 315, 314, 2011, 1350, 3123, 272, 299, 676, 63, 515, 275, 747, 14, 515, 14, 904, 8, 267, 747, 14, 515, 14, 3475, 3460, 493, 10139, 19155, 19155, 19155, 267, 283, 6138, 297, 283, 555, 77, 14, 1652, 358, 272, 3123, 275, 12265, 14, 1122, 8, 555, 77, 63, 515, 9, 272, 1015, 275, 3123, 14, 24544, 1252, 1623, 8, 267, 283, 1512, 45, 26, 1023, 297, 267, 10747, 3126, 288, 283, 1512, 45, 356, 283, 1014, 921, 391, 1856, 14, 3796, 14, 1308, 15, 1512, 45, 15, 20, 14, 16, 14, 16, 7, 267, 789, 680, 505, 272, 16290, 63, 515, 275, 747, 14, 515, 14, 904, 8, 267, 747, 14, 515, 14, 3475, 3460, 493, 10139, 19155, 19155, 19155, 267, 283, 6138, 297, 283, 2537, 297, 283, 1375, 297, 267, 283, 7691, 13, 2537, 13, 2440, 13, 7338, 13, 1045, 13, 5714, 14, 7338, 1370, 908, 8, 1023, 430, 272, 16290, 63, 515, 275, 747, 14, 12959, 480, 689, 11415, 63, 20261, 63, 42, 689, 401, 16290, 63, 515, 9, 272, 28921, 514, 14, 928, 42, 6849, 8, 11538, 514, 14, 362, 2698, 42, 54, 1658, 1619, 1062, 3905, 36, 6138, 14, 533, 14, 515, 628, 435, 16290, 63, 515, 9, 272, 372, 28921, 514, 14, 42, 8599, 480, 1308, 3471, 3796, 14, 7691, 14, 4844, 14, 6405, 20191, 8, 1274, 14, 13634, 9, 421, 199, 318, 511, 63, 15813, 63, 2738, 8, 1231, 63, 14228, 304, 272, 327, 2790, 282, 3335, 272, 1335, 2611, 63, 2738, 275, 1738, 63, 14228, 14, 2738, 8, 24, 9, 272, 367, 284, 315, 1425, 8, 24, 304, 267, 1335, 2611, 63, 2738, 14, 409, 4861, 8, 73, 12, 1695, 446, 284, 9, 339, 327, 7905, 370, 2018, 272, 4123, 275, 691, 63, 15813, 14, 15813, 63, 2738, 8, 15813, 63, 2738, 9, 339, 327, 2670, 2399, 1564, 272, 702, 4123, 14, 475, 63, 647, 2394, 342, 508, 330, 1154, 88, 2036, 60, 88, 1780, 60, 88, 1690, 60, 88, 1717, 60, 88, 966, 60, 88, 1644, 60, 88, 996, 60, 88, 614, 7, 421, 199, 318, 485, 15813, 63, 698, 8, 15813, 63, 1650, 304, 272, 30511, 275, 28921, 514, 14, 42, 2543, 360, 957, 14, 70, 2311, 1652, 14, 19193, 834, 14, 68, 1936, 688, 14, 1692, 11880, 358, 342, 272, 1115, 743, 63, 792, 275, 28921, 514, 14, 42, 2543, 360, 1308, 14, 3796, 14, 7691, 14, 4106, 14, 1313, 14, 555, 743, 14, 792, 358, 272, 372, 30511, 14, 739, 1110, 8, 15813, 63, 1650, 12, 1115, 743, 63, 792, 9, 421, 199, 318, 485, 15813, 63, 3629, 8, 15813, 63, 1650, 12, 3341, 29, 403, 304, 272, 901, 275, 485, 15813, 63, 698, 8, 15813, 63, 1650, 9, 272, 4177, 63, 1886, 275, 28921, 514, 14, 42, 2543, 360, 1308, 14, 3796, 14, 7691, 14, 4106, 14, 1313, 14, 555, 743, 14, 6700, 358, 272, 1504, 275, 28921, 514, 14, 42, 2543, 360, 6138, 14, 1974, 14, 3836, 1296, 358, 342, 272, 1504, 14, 525, 8, 698, 9, 272, 340, 3341, 26, 267, 16354, 275, 28921, 514, 14, 42, 2543, 360, 6138, 14, 1974, 14, 3476, 2956, 358, 342, 267, 367, 1022, 12, 373, 315, 3816, 14, 4611, 8, 2343, 304, 288, 16354, 14, 524, 8, 75, 12, 373, 9, 267, 372, 4177, 63, 1886, 8, 955, 12, 16354, 9, 272, 587, 26, 267, 372, 4177, 63, 1886, 8, 955, 9, 421, 199, 3, 1010, 314, 2569, 12, 781, 675, 314, 4840, 16953, 402, 314, 5024, 2251, 315, 9586, 14, 199, 3, 961, 15620, 626, 781, 15564, 19687, 641, 314, 5835, 562, 11984, 2932, 641, 4212, 370, 6982, 199, 3, 3062, 1808, 9586, 1233, 465, 5521, 465, 22741, 2739, 370, 5627, 3062, 465, 2633, 199, 3, 1928, 370, 12677, 314, 1603, 6849, 14, 199, 3, 199, 3, 710, 28754, 4898, 2737, 1808, 26, 199, 3, 199, 3, 257, 30511, 275, 28921, 514, 14, 42, 2543, 360, 957, 14, 70, 2311, 1652, 14, 19193, 834, 14, 68, 1936, 688, 14, 1692, 11880, 358, 342, 199, 3, 257, 901, 275, 27430, 100, 221, 327, 5495, 370, 17321, 314, 901, 199, 3, 257, 1335, 2611, 63, 1650, 275, 30511, 14, 952, 1110, 2822, 1558, 8, 698, 9, 199, 32, 4462, 14, 1657, 14, 10396, 360, 387, 63, 466, 12, 15813, 63, 1650, 297, 359, 272, 334, 387, 14, 2307, 1062, 17137, 354, 5122, 2307, 3570, 659, 272, 334, 387, 14, 2245, 63, 1062, 17137, 354, 5122, 2245, 3570, 659, 272, 334, 387, 14, 442, 24, 1062, 17137, 354, 5122, 442, 2266, 2075, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ol-loginov/intellij-community
python/lib/Lib/distutils/command/install_egg_info.py
438
2587
"""distutils.command.install_egg_info Implements the Distutils 'install_egg_info' command, for installing a package's PKG-INFO metadata.""" from distutils.cmd import Command from distutils import log, dir_util import os, sys, re class install_egg_info(Command): """Install an .egg-info file for the package""" description = "Install package's PKG-INFO metadata as an .egg-info file" user_options = [ ('install-dir=', 'd', "directory to install to"), ] def initialize_options(self): self.install_dir = None def finalize_options(self): self.set_undefined_options('install_lib',('install_dir','install_dir')) basename = "%s-%s-py%s.egg-info" % ( to_filename(safe_name(self.distribution.get_name())), to_filename(safe_version(self.distribution.get_version())), sys.version[:3] ) self.target = os.path.join(self.install_dir, basename) self.outputs = [self.target] def run(self): target = self.target if os.path.isdir(target) and not os.path.islink(target): dir_util.remove_tree(target, dry_run=self.dry_run) elif os.path.exists(target): self.execute(os.unlink,(self.target,),"Removing "+target) elif not os.path.isdir(self.install_dir): self.execute(os.makedirs, (self.install_dir,), "Creating "+self.install_dir) log.info("Writing %s", target) if not self.dry_run: f = open(target, 'w') self.distribution.metadata.write_pkg_file(f) f.close() def get_outputs(self): return self.outputs # The following routines are taken from setuptools' pkg_resources module and # can be replaced by importing them from pkg_resources once it is included # in the stdlib. def safe_name(name): """Convert an arbitrary string to a standard distribution name Any runs of non-alphanumeric/. characters are replaced with a single '-'. """ return re.sub('[^A-Za-z0-9.]+', '-', name) def safe_version(version): """Convert an arbitrary string to a standard version string Spaces become dots, and all other non-alphanumeric characters become dashes, with runs of multiple dashes condensed to a single dash. """ version = version.replace(' ','.') return re.sub('[^A-Za-z0-9.]+', '-', version) def to_filename(name): """Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'. """ return name.replace('-','_')
apache-2.0
[ 624, 13350, 14, 1531, 14, 3174, 63, 5799, 63, 815, 199, 199, 29452, 314, 12577, 283, 3174, 63, 5799, 63, 815, 7, 1414, 12, 367, 22200, 199, 65, 2559, 1159, 30281, 13, 4531, 3341, 1041, 421, 199, 504, 7065, 14, 1760, 492, 5817, 199, 504, 7065, 492, 943, 12, 2935, 63, 1974, 199, 646, 747, 12, 984, 12, 295, 199, 199, 533, 3907, 63, 5799, 63, 815, 8, 3110, 304, 272, 408, 8154, 376, 1275, 5799, 13, 815, 570, 367, 314, 2559, 624, 339, 1369, 275, 298, 8154, 2559, 1159, 30281, 13, 4531, 3341, 465, 376, 1275, 5799, 13, 815, 570, 2, 272, 922, 63, 1419, 275, 359, 267, 661, 3174, 13, 694, 4009, 283, 68, 297, 298, 3619, 370, 3907, 370, 1288, 272, 1622, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 291, 14, 3174, 63, 694, 275, 488, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 291, 14, 409, 63, 10705, 63, 1419, 360, 3174, 63, 773, 297, 360, 3174, 63, 694, 1673, 3174, 63, 694, 1333, 267, 9593, 275, 2071, 83, 3295, 83, 13, 647, 5, 83, 14, 5799, 13, 815, 2, 450, 334, 288, 370, 63, 1501, 8, 3489, 63, 354, 8, 277, 14, 4972, 14, 362, 63, 354, 22606, 288, 370, 63, 1501, 8, 3489, 63, 1023, 8, 277, 14, 4972, 14, 362, 63, 1023, 22606, 288, 984, 14, 1023, 1491, 19, 61, 267, 776, 267, 291, 14, 1375, 275, 747, 14, 515, 14, 904, 8, 277, 14, 3174, 63, 694, 12, 9593, 9, 267, 291, 14, 4467, 275, 359, 277, 14, 1375, 61, 339, 347, 1255, 8, 277, 304, 267, 1347, 275, 291, 14, 1375, 267, 340, 747, 14, 515, 14, 6027, 8, 1375, 9, 436, 440, 747, 14, 515, 14, 20719, 8, 1375, 304, 288, 2935, 63, 1974, 14, 2168, 63, 2350, 8, 1375, 12, 9951, 63, 1065, 29, 277, 14, 10481, 63, 1065, 9, 267, 916, 747, 14, 515, 14, 2444, 8, 1375, 304, 288, 291, 14, 2526, 8, 736, 14, 7162, 12803, 277, 14, 1375, 4706, 2, 23420, 7210, 1375, 9, 267, 916, 440, 747, 14, 515, 14, 6027, 8, 277, 14, 3174, 63, 694, 304, 288, 291, 14, 2526, 8, 736, 14, 8347, 12, 334, 277, 14, 3174, 63, 694, 4706, 586, 298, 14380, 7210, 277, 14, 3174, 63, 694, 9, 267, 943, 14, 815, 480, 16646, 450, 83, 401, 1347, 9, 267, 340, 440, 291, 14, 10481, 63, 1065, 26, 288, 289, 275, 1551, 8, 1375, 12, 283, 87, 358, 288, 291, 14, 4972, 14, 2343, 14, 952, 63, 4600, 63, 493, 8, 70, 9, 288, 289, 14, 1600, 342, 339, 347, 664, 63, 4467, 8, 277, 304, 267, 372, 291, 14, 4467, 421, 199, 3, 710, 2569, 14975, 787, 9394, 687, 9116, 7, 5496, 63, 4435, 859, 436, 199, 3, 883, 506, 8717, 701, 16306, 3062, 687, 5496, 63, 4435, 5403, 652, 365, 5120, 199, 3, 315, 314, 26678, 14, 199, 199, 318, 5048, 63, 354, 8, 354, 304, 272, 408, 7306, 376, 9697, 1059, 370, 282, 4465, 4084, 536, 339, 6184, 7858, 402, 2222, 13, 31119, 8083, 4110, 787, 8717, 543, 282, 2849, 2475, 1370, 272, 408, 272, 372, 295, 14, 954, 360, 4735, 33, 13, 13163, 13, 90, 16, 13, 25, 14, 11529, 17525, 536, 9, 421, 199, 318, 5048, 63, 1023, 8, 1023, 304, 272, 408, 7306, 376, 9697, 1059, 370, 282, 4465, 1015, 1059, 339, 428, 4285, 8649, 21185, 12, 436, 1006, 1163, 2222, 13, 31119, 4110, 8649, 272, 21106, 12, 543, 7858, 402, 3663, 21106, 406, 848, 939, 370, 282, 2849, 11847, 14, 272, 408, 272, 1015, 275, 1015, 14, 1814, 360, 12814, 358, 272, 372, 295, 14, 954, 360, 4735, 33, 13, 13163, 13, 90, 16, 13, 25, 14, 11529, 17525, 1015, 9, 421, 199, 318, 370, 63, 1501, 8, 354, 304, 272, 408, 7306, 282, 2199, 503, 1015, 536, 370, 2399, 1788, 13, 13572, 1824, 339, 6184, 10791, 4110, 787, 5544, 8717, 543, 2513, 1370, 272, 408, 272, 372, 536, 14, 1814, 3654, 1673, 15452, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 13350, 14, 1531, 14, 3174, 63, 5799, 63, 815, 199, 199, 29452, 314, 12577, 283, 3174, 63, 5799, 63, 815, 7, 1414, 12, 367, 22200, 199, 65, 2559, 1159, 30281, 13, 4531, 3341, 1041, 421, 199, 504, 7065, 14, 1760, 492, 5817, 199, 504, 7065, 492, 943, 12, 2935, 63, 1974, 199, 646, 747, 12, 984, 12, 295, 199, 199, 533, 3907, 63, 5799, 63, 815, 8, 3110, 304, 272, 408, 8154, 376, 1275, 5799, 13, 815, 570, 367, 314, 2559, 624, 339, 1369, 275, 298, 8154, 2559, 1159, 30281, 13, 4531, 3341, 465, 376, 1275, 5799, 13, 815, 570, 2, 272, 922, 63, 1419, 275, 359, 267, 661, 3174, 13, 694, 4009, 283, 68, 297, 298, 3619, 370, 3907, 370, 1288, 272, 1622, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 291, 14, 3174, 63, 694, 275, 488, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 291, 14, 409, 63, 10705, 63, 1419, 360, 3174, 63, 773, 297, 360, 3174, 63, 694, 1673, 3174, 63, 694, 1333, 267, 9593, 275, 2071, 83, 3295, 83, 13, 647, 5, 83, 14, 5799, 13, 815, 2, 450, 334, 288, 370, 63, 1501, 8, 3489, 63, 354, 8, 277, 14, 4972, 14, 362, 63, 354, 22606, 288, 370, 63, 1501, 8, 3489, 63, 1023, 8, 277, 14, 4972, 14, 362, 63, 1023, 22606, 288, 984, 14, 1023, 1491, 19, 61, 267, 776, 267, 291, 14, 1375, 275, 747, 14, 515, 14, 904, 8, 277, 14, 3174, 63, 694, 12, 9593, 9, 267, 291, 14, 4467, 275, 359, 277, 14, 1375, 61, 339, 347, 1255, 8, 277, 304, 267, 1347, 275, 291, 14, 1375, 267, 340, 747, 14, 515, 14, 6027, 8, 1375, 9, 436, 440, 747, 14, 515, 14, 20719, 8, 1375, 304, 288, 2935, 63, 1974, 14, 2168, 63, 2350, 8, 1375, 12, 9951, 63, 1065, 29, 277, 14, 10481, 63, 1065, 9, 267, 916, 747, 14, 515, 14, 2444, 8, 1375, 304, 288, 291, 14, 2526, 8, 736, 14, 7162, 12803, 277, 14, 1375, 4706, 2, 23420, 7210, 1375, 9, 267, 916, 440, 747, 14, 515, 14, 6027, 8, 277, 14, 3174, 63, 694, 304, 288, 291, 14, 2526, 8, 736, 14, 8347, 12, 334, 277, 14, 3174, 63, 694, 4706, 586, 298, 14380, 7210, 277, 14, 3174, 63, 694, 9, 267, 943, 14, 815, 480, 16646, 450, 83, 401, 1347, 9, 267, 340, 440, 291, 14, 10481, 63, 1065, 26, 288, 289, 275, 1551, 8, 1375, 12, 283, 87, 358, 288, 291, 14, 4972, 14, 2343, 14, 952, 63, 4600, 63, 493, 8, 70, 9, 288, 289, 14, 1600, 342, 339, 347, 664, 63, 4467, 8, 277, 304, 267, 372, 291, 14, 4467, 421, 199, 3, 710, 2569, 14975, 787, 9394, 687, 9116, 7, 5496, 63, 4435, 859, 436, 199, 3, 883, 506, 8717, 701, 16306, 3062, 687, 5496, 63, 4435, 5403, 652, 365, 5120, 199, 3, 315, 314, 26678, 14, 199, 199, 318, 5048, 63, 354, 8, 354, 304, 272, 408, 7306, 376, 9697, 1059, 370, 282, 4465, 4084, 536, 339, 6184, 7858, 402, 2222, 13, 31119, 8083, 4110, 787, 8717, 543, 282, 2849, 2475, 1370, 272, 408, 272, 372, 295, 14, 954, 360, 4735, 33, 13, 13163, 13, 90, 16, 13, 25, 14, 11529, 17525, 536, 9, 421, 199, 318, 5048, 63, 1023, 8, 1023, 304, 272, 408, 7306, 376, 9697, 1059, 370, 282, 4465, 1015, 1059, 339, 428, 4285, 8649, 21185, 12, 436, 1006, 1163, 2222, 13, 31119, 4110, 8649, 272, 21106, 12, 543, 7858, 402, 3663, 21106, 406, 848, 939, 370, 282, 2849, 11847, 14, 272, 408, 272, 1015, 275, 1015, 14, 1814, 360, 12814, 358, 272, 372, 295, 14, 954, 360, 4735, 33, 13, 13163, 13, 90, 16, 13, 25, 14, 11529, 17525, 1015, 9, 421, 199, 318, 370, 63, 1501, 8, 354, 304, 272, 408, 7306, 282, 2199, 503, 1015, 536, 370, 2399, 1788, 13, 13572, 1824, 339, 6184, 10791, 4110, 787, 5544, 8717, 543, 2513, 1370, 272, 408, 272, 372, 536, 14, 1814, 3654, 1673, 15452, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
pycroscopy/pycroscopy
tests/io/test_hdf_writer.py
1
36224
# -*- coding: utf-8 -*- """ Created on Tue Nov 3 15:07:16 2017 @author: Suhas Somnath """ from __future__ import division, print_function, unicode_literals, absolute_import import unittest import os import h5py import numpy as np import sys sys.path.append("../../../pycroscopy/") from pycroscopy.io.virtual_data import VirtualGroup, VirtualDataset from pycroscopy.io.hdf_writer import HDFwriter from pyUSID.io.hdf_utils import get_attr, get_h5_obj_refs # Until an elegant solution presents itself class TestHDFWriter(unittest.TestCase): @staticmethod def __delete_existing_file(file_path): if os.path.exists(file_path): os.remove(file_path) def test_init_invalid_input(self): with self.assertRaises(TypeError): _ = HDFwriter(4) def test_init_path_non_existant_file_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) writer = HDFwriter(file_path) self.assertIsInstance(writer, HDFwriter, "writer should be an HDFwriter") writer.close() os.remove(file_path) def test_init_path_existing_file_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) h5_f = h5py.File(file_path) h5_f.close() # Existing h5 file writer = HDFwriter(file_path) self.assertIsInstance(writer, HDFwriter, "writer should be an HDFwriter") writer.close() os.remove(file_path) def test_init_h5_handle_r_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) h5_f = h5py.File(file_path) h5_f.close() h5_f = h5py.File(file_path, mode='r') # hdf handle but of mode r with self.assertRaises(TypeError): _ = HDFwriter(h5_f) os.remove(file_path) def test_init_h5_handle_r_plus_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) h5_f = h5py.File(file_path) h5_f.close() h5_f = h5py.File(file_path, mode='r+') # open h5 file handle or mode r+ writer = HDFwriter(h5_f) self.assertIsInstance(writer, HDFwriter, "writer should be an HDFwriter") writer.close() os.remove(file_path) def test_init_h5_handle_w_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) h5_f = h5py.File(file_path) h5_f.close() h5_f = h5py.File(file_path, mode='w') # open h5 file handle or mode w writer = HDFwriter(h5_f) self.assertIsInstance(writer, HDFwriter, "writer should be an HDFwriter") writer.close() os.remove(file_path) def test_init_h5_handle_closed(self): file_path = 'test.h5' self.__delete_existing_file(file_path) h5_f = h5py.File(file_path) h5_f.close() # Existing h5 file but closed with self.assertRaises(ValueError): _ = HDFwriter(h5_f) os.remove(file_path) def test_simple_dset_write_success_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: dtype = np.uint16 dset_name = 'test' data = np.random.randint(0, high=15, size=5, dtype=dtype) microdset = VirtualDataset(dset_name, data) writer = HDFwriter(h5_f) h5_d = writer._create_simple_dset(h5_f, microdset) self.assertIsInstance(h5_d, h5py.Dataset) self.assertEqual(h5_d.parent, h5_f) self.assertEqual(h5_d.name, '/' + dset_name) self.assertEqual(h5_d.shape, data.shape) self.assertTrue(np.allclose(h5_d[()], data)) self.assertEqual(h5_d.dtype, dtype) os.remove(file_path) def test_simple_dset_write_success_more_options_02(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: dset_name = 'test' data = np.random.rand(16, 1024) dtype = data.dtype compression = 'gzip' chunking=(1, 1024) microdset = VirtualDataset(dset_name, data, dtype=dtype, compression=compression, chunking=chunking) writer = HDFwriter(h5_f) h5_d = writer._create_simple_dset(h5_f, microdset) self.assertIsInstance(h5_d, h5py.Dataset) self.assertEqual(h5_d.parent, h5_f) self.assertEqual(h5_d.name, '/' + dset_name) self.assertEqual(h5_d.shape, data.shape) self.assertTrue(np.allclose(h5_d[()], data)) self.assertEqual(h5_d.dtype, dtype) self.assertEqual(h5_d.compression, compression) self.assertEqual(h5_d.chunks, chunking) os.remove(file_path) def test_simple_dset_write_success_more_options_03(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: dset_name = 'test' data = np.random.rand(16, 1024) dtype = np.float16 compression = 'gzip' chunking=(1, 1024) microdset = VirtualDataset(dset_name, data, dtype=dtype, compression=compression, chunking=chunking) writer = HDFwriter(h5_f) h5_d = writer._create_simple_dset(h5_f, microdset) self.assertIsInstance(h5_d, h5py.Dataset) self.assertEqual(h5_d.parent, h5_f) self.assertEqual(h5_d.name, '/' + dset_name) self.assertEqual(h5_d.shape, data.shape) self.assertEqual(h5_d.dtype, dtype) self.assertEqual(h5_d.compression, compression) self.assertEqual(h5_d.chunks, chunking) self.assertTrue(np.all(h5_d[()] - data < 1E-3)) os.remove(file_path) def test_empty_dset_write_success_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: dset_name = 'test' maxshape = (16, 1024) microdset = VirtualDataset(dset_name, None, maxshape=maxshape) writer = HDFwriter(h5_f) h5_d = writer._create_empty_dset(h5_f, microdset) self.assertIsInstance(h5_d, h5py.Dataset) self.assertEqual(h5_d.parent, h5_f) self.assertEqual(h5_d.name, '/' + dset_name) self.assertEqual(h5_d.shape, maxshape) self.assertEqual(h5_d.maxshape, maxshape) # dtype is assigned automatically by h5py. Not to be tested here os.remove(file_path) def test_empty_dset_write_success_w_options_02(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: dset_name = 'test' maxshape = (16, 1024) chunking = (1, 1024) compression = 'gzip' dtype = np.float16 microdset = VirtualDataset(dset_name, None, maxshape=maxshape, dtype=dtype, compression=compression, chunking=chunking) writer = HDFwriter(h5_f) h5_d = writer._create_empty_dset(h5_f, microdset) self.assertIsInstance(h5_d, h5py.Dataset) self.assertEqual(h5_d.parent, h5_f) self.assertEqual(h5_d.name, '/' + dset_name) self.assertEqual(h5_d.dtype, dtype) self.assertEqual(h5_d.compression, compression) self.assertEqual(h5_d.chunks, chunking) self.assertEqual(h5_d.shape, maxshape) self.assertEqual(h5_d.maxshape, maxshape) os.remove(file_path) def test_expandable_dset_write_success_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: dset_name = 'test' maxshape = (None, 1024) data = np.random.rand(1, 1024) microdset = VirtualDataset(dset_name, data, maxshape=maxshape) writer = HDFwriter(h5_f) h5_d = writer._create_resizeable_dset(h5_f, microdset) self.assertIsInstance(h5_d, h5py.Dataset) self.assertEqual(h5_d.parent, h5_f) self.assertEqual(h5_d.name, '/' + dset_name) self.assertEqual(h5_d.shape, data.shape) self.assertEqual(h5_d.maxshape, maxshape) self.assertTrue(np.allclose(h5_d[()], data)) # Now test to make sure that the dataset can be expanded: # TODO: add this to the example! expansion_axis = 0 h5_d.resize(h5_d.shape[expansion_axis] + 1, axis=expansion_axis) self.assertEqual(h5_d.shape, (data.shape[0]+1, data.shape[1])) self.assertEqual(h5_d.maxshape, maxshape) # Finally try checking to see if this new data is also present in the file new_data = np.random.rand(1024) h5_d[1] = new_data data = np.vstack((np.squeeze(data), new_data)) self.assertTrue(np.allclose(h5_d[()], data)) os.remove(file_path) # TODO: will have to check to see if the parent is correctly declared for the group def test_group_create_non_indexed_simple_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: grp_name = 'test' micro_group = VirtualGroup(grp_name) writer = HDFwriter(h5_f) h5_grp = writer._create_group(h5_f, micro_group) self.assertIsInstance(h5_grp, h5py.Group) self.assertEqual(h5_grp.parent, h5_f) self.assertEqual(h5_grp.name, '/' + grp_name) # self.assertEqual(len(h5_grp.items), 0) os.remove(file_path) def test_group_create_indexed_simple_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: grp_name = 'test_' micro_group = VirtualGroup(grp_name) writer = HDFwriter(h5_f) h5_grp = writer._create_group(h5_f, micro_group) self.assertIsInstance(h5_grp, h5py.Group) self.assertEqual(h5_grp.parent, h5_f) self.assertEqual(h5_grp.name, '/' + grp_name + '000') # self.assertEqual(len(h5_grp.items), 0) os.remove(file_path) def test_group_create_root_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: grp_name = '' micro_group = VirtualGroup(grp_name) writer = HDFwriter(h5_f) with self.assertRaises(ValueError): _ = writer._create_group(h5_f, micro_group) os.remove(file_path) def test_group_create_indexed_nested_01(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: outer_grp_name = 'outer_' micro_group = VirtualGroup(outer_grp_name) writer = HDFwriter(h5_f) h5_outer_grp = writer._create_group(h5_f, micro_group) self.assertIsInstance(h5_outer_grp, h5py.Group) self.assertEqual(h5_outer_grp.parent, h5_f) self.assertEqual(h5_outer_grp.name, '/' + outer_grp_name + '000') inner_grp_name = 'inner_' micro_group = VirtualGroup(inner_grp_name) h5_inner_grp = writer._create_group(h5_outer_grp, micro_group) self.assertIsInstance(h5_inner_grp, h5py.Group) self.assertEqual(h5_inner_grp.parent, h5_outer_grp) self.assertEqual(h5_inner_grp.name, h5_outer_grp.name + '/' + inner_grp_name + '000') os.remove(file_path) def test_write_legal_reg_ref_multi_dim_data(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(5, 7) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) attrs = {'labels': {'even_rows': (slice(0, None, 2), slice(None)), 'odd_rows': (slice(1, None, 2), slice(None))}} writer._write_dset_attributes(h5_dset, attrs.copy()) h5_f.flush() # two atts point to region references. one for labels self.assertEqual(len(h5_dset.attrs), 1 + len(attrs['labels'])) # check if the labels attribute was written: self.assertTrue(np.all([x in list(attrs['labels'].keys()) for x in get_attr(h5_dset, 'labels')])) expected_data = [data[:None:2], data[1:None:2]] written_data = [h5_dset[h5_dset.attrs['even_rows']], h5_dset[h5_dset.attrs['odd_rows']]] for exp, act in zip(expected_data, written_data): self.assertTrue(np.allclose(exp, act)) os.remove(file_path) def test_write_legal_reg_ref_multi_dim_data_2nd_dim(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(5, 3) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) attrs = {'labels': {'even_rows': (slice(None), slice(0, None, 2)), 'odd_rows': (slice(None), slice(1, None, 2))}} writer._write_dset_attributes(h5_dset, attrs.copy()) h5_f.flush() # two atts point to region references. one for labels self.assertEqual(len(h5_dset.attrs), 1 + len(attrs['labels'])) # check if the labels attribute was written: self.assertTrue(np.all([x in list(attrs['labels'].keys()) for x in get_attr(h5_dset, 'labels')])) expected_data = [data[:, 0:None:2], data[:, 1:None:2]] written_data = [h5_dset[h5_dset.attrs['even_rows']], h5_dset[h5_dset.attrs['odd_rows']]] for exp, act in zip(expected_data, written_data): self.assertTrue(np.allclose(exp, act)) os.remove(file_path) def test_write_legal_reg_ref_one_dim_data(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(7) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) attrs = {'labels': {'even_rows': (slice(0, None, 2)), 'odd_rows': (slice(1, None, 2))}} writer._write_dset_attributes(h5_dset, attrs.copy()) h5_f.flush() # two atts point to region references. one for labels self.assertEqual(len(h5_dset.attrs), 1 + len(attrs['labels'])) # check if the labels attribute was written: self.assertTrue(np.all([x in list(attrs['labels'].keys()) for x in get_attr(h5_dset, 'labels')])) expected_data = [data[:None:2], data[1:None:2]] written_data = [h5_dset[h5_dset.attrs['even_rows']], h5_dset[h5_dset.attrs['odd_rows']]] for exp, act in zip(expected_data, written_data): self.assertTrue(np.allclose(exp, act)) os.remove(file_path) def test_generate_and_write_reg_ref_legal(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(2, 7) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) attrs = {'labels': ['row_1', 'row_2']} if sys.version_info.major == 3: with self.assertWarns(UserWarning): writer._write_dset_attributes(h5_dset, attrs.copy()) else: writer._write_dset_attributes(h5_dset, attrs.copy()) h5_f.flush() # two atts point to region references. one for labels self.assertEqual(len(h5_dset.attrs), 1 + len(attrs['labels'])) # check if the labels attribute was written: self.assertTrue(np.all([x in list(attrs['labels']) for x in get_attr(h5_dset, 'labels')])) expected_data = [data[0], data[1]] written_data = [h5_dset[h5_dset.attrs['row_1']], h5_dset[h5_dset.attrs['row_2']]] for exp, act in zip(expected_data, written_data): self.assertTrue(np.allclose(np.squeeze(exp), np.squeeze(act))) os.remove(file_path) def test_generate_and_write_reg_ref_illegal(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(3, 7) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) # with self.assertWarns(UserWarning): writer._write_dset_attributes(h5_dset, {'labels': ['row_1', 'row_2']}) self.assertEqual(len(h5_dset.attrs), 0) h5_f.flush() os.remove(file_path) def test_generate_and_write_reg_ref_illegal(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(2, 7) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) # with self.assertWarns(UserWarning): with self.assertRaises(TypeError): writer._write_dset_attributes(h5_dset, {'labels': [1, np.arange(3)]}) os.remove(file_path) def test_write_illegal_reg_ref_too_many_slices(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(5, 7) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) attrs = {'labels': {'even_rows': (slice(0, None, 2), slice(None), slice(None)), 'odd_rows': (slice(1, None, 2), slice(None), slice(None))}} with self.assertRaises(ValueError): writer._write_dset_attributes(h5_dset, attrs.copy()) os.remove(file_path) def test_write_illegal_reg_ref_too_few_slices(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(5, 7) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) attrs = {'labels': {'even_rows': (slice(0, None, 2)), 'odd_rows': (slice(1, None, 2))}} with self.assertRaises(ValueError): writer._write_dset_attributes(h5_dset, attrs.copy()) os.remove(file_path) def test_write_reg_ref_slice_dim_larger_than_data(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(5, 7) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) attrs = {'labels': {'even_rows': (slice(0, 15, 2), slice(None)), 'odd_rows': (slice(1, 15, 2), slice(None))}} writer._write_dset_attributes(h5_dset, attrs.copy()) h5_f.flush() # two atts point to region references. one for labels self.assertEqual(len(h5_dset.attrs), 1 + len(attrs['labels'])) # check if the labels attribute was written: self.assertTrue(np.all([x in list(attrs['labels'].keys()) for x in get_attr(h5_dset, 'labels')])) expected_data = [data[:None:2], data[1:None:2]] written_data = [h5_dset[h5_dset.attrs['even_rows']], h5_dset[h5_dset.attrs['odd_rows']]] for exp, act in zip(expected_data, written_data): self.assertTrue(np.allclose(exp, act)) os.remove(file_path) def test_write_illegal_reg_ref_not_slice_objs(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(5, 7) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) attrs = {'labels': {'even_rows': (slice(0, None, 2), 15), 'odd_rows': (slice(1, None, 2), 'hello')}} with self.assertRaises(TypeError): writer._write_dset_attributes(h5_dset, attrs.copy()) os.remove(file_path) def test_write_simple_atts_reg_ref_to_dset(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(5, 7) h5_dset = writer._create_simple_dset(h5_f, VirtualDataset('test', data)) self.assertIsInstance(h5_dset, h5py.Dataset) attrs = {'att_1': 'string_val', 'att_2': 1.2345, 'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3'], 'labels': {'even_rows': (slice(0, None, 2), slice(None)), 'odd_rows': (slice(1, None, 2), slice(None))} } writer._write_dset_attributes(h5_dset, attrs.copy()) reg_ref = attrs.pop('labels') self.assertEqual(len(h5_dset.attrs), len(attrs) + 1 + len(reg_ref)) for key, expected_val in attrs.items(): self.assertTrue(np.all(get_attr(h5_dset, key) == expected_val)) self.assertTrue(np.all([x in list(reg_ref.keys()) for x in get_attr(h5_dset, 'labels')])) expected_data = [data[:None:2], data[1:None:2]] written_data = [h5_dset[h5_dset.attrs['even_rows']], h5_dset[h5_dset.attrs['odd_rows']]] for exp, act in zip(expected_data, written_data): self.assertTrue(np.allclose(exp, act)) os.remove(file_path) def test_write_invalid_input(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) with self.assertRaises(TypeError): _ = writer.write(np.arange(5)) def test_write_dset_under_root(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) data = np.random.rand(5, 7) attrs = {'att_1': 'string_val', 'att_2': 1.2345, 'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3'], 'labels': {'even_rows': (slice(0, None, 2), slice(None)), 'odd_rows': (slice(1, None, 2), slice(None))} } micro_dset = VirtualDataset('test', data) micro_dset.attrs = attrs.copy() [h5_dset] = writer.write(micro_dset) self.assertIsInstance(h5_dset, h5py.Dataset) reg_ref = attrs.pop('labels') self.assertEqual(len(h5_dset.attrs), len(attrs) + 1 + len(reg_ref)) for key, expected_val in attrs.items(): self.assertTrue(np.all(get_attr(h5_dset, key) == expected_val)) self.assertTrue(np.all([x in list(reg_ref.keys()) for x in get_attr(h5_dset, 'labels')])) expected_data = [data[:None:2], data[1:None:2]] written_data = [h5_dset[h5_dset.attrs['even_rows']], h5_dset[h5_dset.attrs['odd_rows']]] for exp, act in zip(expected_data, written_data): self.assertTrue(np.allclose(exp, act)) os.remove(file_path) def test_write_dset_under_existing_group(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) h5_g = writer._create_group(h5_f, VirtualGroup('test_group')) self.assertIsInstance(h5_g, h5py.Group) data = np.random.rand(5, 7) attrs = {'att_1': 'string_val', 'att_2': 1.2345, 'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3'], 'labels': {'even_rows': (slice(0, None, 2), slice(None)), 'odd_rows': (slice(1, None, 2), slice(None))} } micro_dset = VirtualDataset('test', data, parent='/test_group') micro_dset.attrs = attrs.copy() [h5_dset] = writer.write(micro_dset) self.assertIsInstance(h5_dset, h5py.Dataset) self.assertEqual(h5_dset.parent, h5_g) reg_ref = attrs.pop('labels') self.assertEqual(len(h5_dset.attrs), len(attrs) + 1 + len(reg_ref)) for key, expected_val in attrs.items(): self.assertTrue(np.all(get_attr(h5_dset, key) == expected_val)) self.assertTrue(np.all([x in list(reg_ref.keys()) for x in get_attr(h5_dset, 'labels')])) expected_data = [data[:None:2], data[1:None:2]] written_data = [h5_dset[h5_dset.attrs['even_rows']], h5_dset[h5_dset.attrs['odd_rows']]] for exp, act in zip(expected_data, written_data): self.assertTrue(np.allclose(exp, act)) os.remove(file_path) def test_write_dset_under_invalid_group(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) with self.assertRaises(KeyError): _ = writer.write(VirtualDataset('test', np.random.rand(5, 7), parent='/does_not_exist')) os.remove(file_path) def test_write_root(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: attrs = {'att_1': 'string_val', 'att_2': 1.2345, 'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3']} micro_group = VirtualGroup('') micro_group.attrs = attrs writer = HDFwriter(h5_f) [ret_val] = writer.write(micro_group) self.assertIsInstance(ret_val, h5py.File) self.assertEqual(h5_f, ret_val) for key, expected_val in attrs.items(): self.assertTrue(np.all(get_attr(h5_f, key) == expected_val)) os.remove(file_path) def test_write_single_group(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: attrs = {'att_1': 'string_val', 'att_2': 1.2345, 'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3']} micro_group = VirtualGroup('Test_') micro_group.attrs = attrs writer = HDFwriter(h5_f) [h5_group] = writer.write(micro_group) for key, expected_val in attrs.items(): self.assertTrue(np.all(get_attr(h5_group, key) == expected_val)) os.remove(file_path) def test_group_indexing_sequential(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: writer = HDFwriter(h5_f) micro_group_0 = VirtualGroup('Test_', attrs={'att_1': 'string_val', 'att_2': 1.2345}) [h5_group_0] = writer.write(micro_group_0) _ = writer.write(VirtualGroup('blah')) self.assertIsInstance(h5_group_0, h5py.Group) self.assertEqual(h5_group_0.name, '/Test_000') for key, expected_val in micro_group_0.attrs.items(): self.assertTrue(np.all(get_attr(h5_group_0, key) == expected_val)) micro_group_1 = VirtualGroup('Test_', attrs={'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3']}) [h5_group_1] = writer.write(micro_group_1) self.assertIsInstance(h5_group_1, h5py.Group) self.assertEqual(h5_group_1.name, '/Test_001') for key, expected_val in micro_group_1.attrs.items(): self.assertTrue(np.all(get_attr(h5_group_1, key) == expected_val)) os.remove(file_path) def test_group_indexing_simultaneous(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: micro_group_0 = VirtualGroup('Test_', attrs = {'att_1': 'string_val', 'att_2': 1.2345}) micro_group_1 = VirtualGroup('Test_', attrs={'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3']}) root_group = VirtualGroup('', children=[VirtualGroup('blah'), micro_group_0, VirtualGroup('meh'), micro_group_1]) writer = HDFwriter(h5_f) h5_refs_list = writer.write(root_group) [h5_group_1] = get_h5_obj_refs(['Test_001'], h5_refs_list) [h5_group_0] = get_h5_obj_refs(['Test_000'], h5_refs_list) self.assertIsInstance(h5_group_0, h5py.Group) self.assertEqual(h5_group_0.name, '/Test_000') for key, expected_val in micro_group_0.attrs.items(): self.assertTrue(np.all(get_attr(h5_group_0, key) == expected_val)) self.assertIsInstance(h5_group_1, h5py.Group) self.assertEqual(h5_group_1.name, '/Test_001') for key, expected_val in micro_group_1.attrs.items(): self.assertTrue(np.all(get_attr(h5_group_1, key) == expected_val)) os.remove(file_path) def test_write_simple_tree(self): file_path = 'test.h5' self.__delete_existing_file(file_path) with h5py.File(file_path) as h5_f: inner_dset_data = np.random.rand(5, 7) inner_dset_attrs = {'att_1': 'string_val', 'att_2': 1.2345, 'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3'], 'labels': {'even_rows': (slice(0, None, 2), slice(None)), 'odd_rows': (slice(1, None, 2), slice(None))} } inner_dset = VirtualDataset('inner_dset', inner_dset_data) inner_dset.attrs = inner_dset_attrs.copy() attrs_inner_grp = {'att_1': 'string_val', 'att_2': 1.2345, 'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3']} inner_group = VirtualGroup('indexed_inner_group_') inner_group.attrs = attrs_inner_grp inner_group.add_children(inner_dset) outer_dset_data = np.random.rand(5, 7) outer_dset_attrs = {'att_1': 'string_val', 'att_2': 1.2345, 'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3'], 'labels': {'even_rows': (slice(0, None, 2), slice(None)), 'odd_rows': (slice(1, None, 2), slice(None))} } outer_dset = VirtualDataset('test', outer_dset_data, parent='/test_group') outer_dset.attrs = outer_dset_attrs.copy() attrs_outer_grp = {'att_1': 'string_val', 'att_2': 1.2345, 'att_3': [1, 2, 3, 4], 'att_4': ['str_1', 'str_2', 'str_3']} outer_group = VirtualGroup('unindexed_outer_group') outer_group.attrs = attrs_outer_grp outer_group.add_children([inner_group, outer_dset]) writer = HDFwriter(h5_f) h5_refs_list = writer.write(outer_group) # I don't know of a more elegant way to do this: [h5_outer_dset] = get_h5_obj_refs([outer_dset.name], h5_refs_list) [h5_inner_dset] = get_h5_obj_refs([inner_dset.name], h5_refs_list) [h5_outer_group] = get_h5_obj_refs([outer_group.name], h5_refs_list) [h5_inner_group] = get_h5_obj_refs(['indexed_inner_group_000'], h5_refs_list) self.assertIsInstance(h5_outer_dset, h5py.Dataset) self.assertIsInstance(h5_inner_dset, h5py.Dataset) self.assertIsInstance(h5_outer_group, h5py.Group) self.assertIsInstance(h5_inner_group, h5py.Group) # check assertions for the inner dataset first self.assertEqual(h5_inner_dset.parent, h5_inner_group) reg_ref = inner_dset_attrs.pop('labels') self.assertEqual(len(h5_inner_dset.attrs), len(inner_dset_attrs) + 1 + len(reg_ref)) for key, expected_val in inner_dset_attrs.items(): self.assertTrue(np.all(get_attr(h5_inner_dset, key) == expected_val)) self.assertTrue(np.all([x in list(reg_ref.keys()) for x in get_attr(h5_inner_dset, 'labels')])) expected_data = [inner_dset_data[:None:2], inner_dset_data[1:None:2]] written_data = [h5_inner_dset[h5_inner_dset.attrs['even_rows']], h5_inner_dset[h5_inner_dset.attrs['odd_rows']]] for exp, act in zip(expected_data, written_data): self.assertTrue(np.allclose(exp, act)) # check assertions for the inner data group next: self.assertEqual(h5_inner_group.parent, h5_outer_group) for key, expected_val in attrs_inner_grp.items(): self.assertTrue(np.all(get_attr(h5_inner_group, key) == expected_val)) # check the outer dataset next: self.assertEqual(h5_outer_dset.parent, h5_outer_group) reg_ref = outer_dset_attrs.pop('labels') self.assertEqual(len(h5_outer_dset.attrs), len(outer_dset_attrs) + 1 + len(reg_ref)) for key, expected_val in outer_dset_attrs.items(): self.assertTrue(np.all(get_attr(h5_outer_dset, key) == expected_val)) self.assertTrue(np.all([x in list(reg_ref.keys()) for x in get_attr(h5_outer_dset, 'labels')])) expected_data = [outer_dset_data[:None:2], outer_dset_data[1:None:2]] written_data = [h5_outer_dset[h5_outer_dset.attrs['even_rows']], h5_outer_dset[h5_outer_dset.attrs['odd_rows']]] for exp, act in zip(expected_data, written_data): self.assertTrue(np.allclose(exp, act)) # Finally check the outer group: self.assertEqual(h5_outer_group.parent, h5_f) for key, expected_val in attrs_outer_grp.items(): self.assertTrue(np.all(get_attr(h5_outer_group, key) == expected_val)) os.remove(file_path) if __name__ == '__main__': unittest.main()
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10502, 641, 377, 310, 3091, 86, 221, 650, 4114, 26, 1780, 26, 975, 9708, 199, 199, 32, 2502, 26, 428, 85, 1989, 428, 676, 78, 1619, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 12, 3679, 63, 646, 199, 646, 2882, 199, 646, 747, 199, 646, 394, 21, 647, 199, 646, 2680, 465, 980, 199, 199, 646, 984, 199, 1274, 14, 515, 14, 740, 480, 29866, 11357, 4796, 1574, 13589, 199, 504, 1134, 20363, 1574, 14, 2308, 14, 2065, 63, 576, 492, 13311, 2448, 12, 13311, 9271, 199, 504, 1134, 20363, 1574, 14, 2308, 14, 19912, 63, 5491, 492, 24521, 5491, 199, 504, 1134, 1668, 998, 14, 2308, 14, 19912, 63, 1208, 492, 664, 63, 962, 12, 664, 63, 72, 21, 63, 1113, 63, 7655, 221, 327, 1910, 2270, 376, 325, 4170, 867, 8744, 3451, 83, 6337, 421, 199, 533, 1379, 30165, 6261, 8, 2796, 14, 1746, 304, 339, 768, 4639, 272, 347, 636, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 304, 267, 340, 747, 14, 515, 14, 2444, 8, 493, 63, 515, 304, 288, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 3197, 63, 1210, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 4333, 304, 288, 485, 275, 24521, 5491, 8, 20, 9, 339, 347, 511, 63, 826, 63, 515, 63, 2865, 63, 4494, 867, 63, 493, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 398, 7060, 275, 24521, 5491, 8, 493, 63, 515, 9, 267, 291, 14, 6926, 8, 5491, 12, 24521, 5491, 12, 298, 5491, 1077, 506, 376, 24521, 5491, 531, 267, 7060, 14, 1600, 342, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 515, 63, 5952, 63, 493, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 14, 1600, 342, 267, 327, 1316, 26958, 394, 21, 570, 267, 7060, 275, 24521, 5491, 8, 493, 63, 515, 9, 267, 291, 14, 6926, 8, 5491, 12, 24521, 5491, 12, 298, 5491, 1077, 506, 376, 24521, 5491, 531, 267, 7060, 14, 1600, 342, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 72, 21, 63, 2479, 63, 82, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 14, 1600, 342, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 12, 818, 534, 82, 358, 267, 327, 394, 1587, 2429, 1325, 402, 818, 519, 267, 543, 291, 14, 1855, 8, 4333, 304, 288, 485, 275, 24521, 5491, 8, 72, 21, 63, 70, 9, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 72, 21, 63, 2479, 63, 82, 63, 6666, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 14, 1600, 342, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 12, 818, 534, 82, 13854, 267, 327, 1551, 394, 21, 570, 2429, 503, 818, 519, 11, 398, 7060, 275, 24521, 5491, 8, 72, 21, 63, 70, 9, 267, 291, 14, 6926, 8, 5491, 12, 24521, 5491, 12, 298, 5491, 1077, 506, 376, 24521, 5491, 531, 267, 7060, 14, 1600, 342, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 72, 21, 63, 2479, 63, 87, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 14, 1600, 342, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 12, 818, 534, 87, 358, 267, 327, 1551, 394, 21, 570, 2429, 503, 818, 336, 398, 7060, 275, 24521, 5491, 8, 72, 21, 63, 70, 9, 267, 291, 14, 6926, 8, 5491, 12, 24521, 5491, 12, 298, 5491, 1077, 506, 376, 24521, 5491, 531, 267, 7060, 14, 1600, 342, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 72, 21, 63, 2479, 63, 5938, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 14, 1600, 342, 267, 327, 1316, 26958, 394, 21, 570, 1325, 6876, 267, 543, 291, 14, 1855, 8, 3393, 304, 288, 485, 275, 24521, 5491, 8, 72, 21, 63, 70, 9, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 4129, 63, 68, 409, 63, 952, 63, 3742, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 543, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 465, 394, 21, 63, 70, 26, 953, 2152, 275, 980, 14, 1635, 975, 288, 366, 409, 63, 354, 275, 283, 396, 7, 288, 666, 275, 980, 14, 2355, 14, 8393, 8, 16, 12, 4721, 29, 1046, 12, 1568 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10502, 641, 377, 310, 3091, 86, 221, 650, 4114, 26, 1780, 26, 975, 9708, 199, 199, 32, 2502, 26, 428, 85, 1989, 428, 676, 78, 1619, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 12, 3679, 63, 646, 199, 646, 2882, 199, 646, 747, 199, 646, 394, 21, 647, 199, 646, 2680, 465, 980, 199, 199, 646, 984, 199, 1274, 14, 515, 14, 740, 480, 29866, 11357, 4796, 1574, 13589, 199, 504, 1134, 20363, 1574, 14, 2308, 14, 2065, 63, 576, 492, 13311, 2448, 12, 13311, 9271, 199, 504, 1134, 20363, 1574, 14, 2308, 14, 19912, 63, 5491, 492, 24521, 5491, 199, 504, 1134, 1668, 998, 14, 2308, 14, 19912, 63, 1208, 492, 664, 63, 962, 12, 664, 63, 72, 21, 63, 1113, 63, 7655, 221, 327, 1910, 2270, 376, 325, 4170, 867, 8744, 3451, 83, 6337, 421, 199, 533, 1379, 30165, 6261, 8, 2796, 14, 1746, 304, 339, 768, 4639, 272, 347, 636, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 304, 267, 340, 747, 14, 515, 14, 2444, 8, 493, 63, 515, 304, 288, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 3197, 63, 1210, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 4333, 304, 288, 485, 275, 24521, 5491, 8, 20, 9, 339, 347, 511, 63, 826, 63, 515, 63, 2865, 63, 4494, 867, 63, 493, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 398, 7060, 275, 24521, 5491, 8, 493, 63, 515, 9, 267, 291, 14, 6926, 8, 5491, 12, 24521, 5491, 12, 298, 5491, 1077, 506, 376, 24521, 5491, 531, 267, 7060, 14, 1600, 342, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 515, 63, 5952, 63, 493, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 14, 1600, 342, 267, 327, 1316, 26958, 394, 21, 570, 267, 7060, 275, 24521, 5491, 8, 493, 63, 515, 9, 267, 291, 14, 6926, 8, 5491, 12, 24521, 5491, 12, 298, 5491, 1077, 506, 376, 24521, 5491, 531, 267, 7060, 14, 1600, 342, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 72, 21, 63, 2479, 63, 82, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 14, 1600, 342, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 12, 818, 534, 82, 358, 267, 327, 394, 1587, 2429, 1325, 402, 818, 519, 267, 543, 291, 14, 1855, 8, 4333, 304, 288, 485, 275, 24521, 5491, 8, 72, 21, 63, 70, 9, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 72, 21, 63, 2479, 63, 82, 63, 6666, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 14, 1600, 342, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 12, 818, 534, 82, 13854, 267, 327, 1551, 394, 21, 570, 2429, 503, 818, 519, 11, 398, 7060, 275, 24521, 5491, 8, 72, 21, 63, 70, 9, 267, 291, 14, 6926, 8, 5491, 12, 24521, 5491, 12, 298, 5491, 1077, 506, 376, 24521, 5491, 531, 267, 7060, 14, 1600, 342, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 72, 21, 63, 2479, 63, 87, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 14, 1600, 342, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 12, 818, 534, 87, 358, 267, 327, 1551, 394, 21, 570, 2429, 503, 818, 336, 398, 7060, 275, 24521, 5491, 8, 72, 21, 63, 70, 9, 267, 291, 14, 6926, 8, 5491, 12, 24521, 5491, 12, 298, 5491, 1077, 506, 376, 24521, 5491, 531, 267, 7060, 14, 1600, 342, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 826, 63, 72, 21, 63, 2479, 63, 5938, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 275, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 267, 394, 21, 63, 70, 14, 1600, 342, 267, 327, 1316, 26958, 394, 21, 570, 1325, 6876, 267, 543, 291, 14, 1855, 8, 3393, 304, 288, 485, 275, 24521, 5491, 8, 72, 21, 63, 70, 9, 267, 747, 14, 2168, 8, 493, 63, 515, 9, 339, 347, 511, 63, 4129, 63, 68, 409, 63, 952, 63, 3742, 63, 614, 8, 277, 304, 267, 570, 63, 515, 275, 283, 396, 14, 72, 21, 7, 267, 291, 855, 1807, 63, 5952, 63, 493, 8, 493, 63, 515, 9, 267, 543, 394, 21, 647, 14, 1173, 8, 493, 63, 515, 9, 465, 394, 21, 63, 70, 26, 953, 2152, 275, 980, 14, 1635, 975, 288, 366, 409, 63, 354, 275, 283, 396, 7, 288, 666, 275, 980, 14, 2355, 14, 8393, 8, 16, 12, 4721, 29, 1046, 12, 1568, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gmalmquist/pants
src/python/pants/backend/python/interpreter_cache.py
5
8302
# coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, unicode_literals, with_statement) import os import shutil from pex.interpreter import PythonIdentity, PythonInterpreter from pex.package import EggPackage, Package, SourcePackage from pex.resolver import resolve from pants.util.dirutil import safe_concurrent_creation, safe_mkdir # TODO(wickman) Create a safer version of this and add to twitter.common.dirutil def _safe_link(src, dst): try: os.unlink(dst) except OSError: pass os.symlink(src, dst) class PythonInterpreterCache(object): @staticmethod def _matches(interpreter, filters): return any(interpreter.identity.matches(filt) for filt in filters) @classmethod def _matching(cls, interpreters, filters): for interpreter in interpreters: if cls._matches(interpreter, filters): yield interpreter @classmethod def select_interpreter(cls, compatibilities, allow_multiple=False): """Given a set of interpreters, either return them all if ``allow_multiple`` is ``True``; otherwise, return the lowest compatible interpreter. """ if allow_multiple: return compatibilities return [min(compatibilities)] if compatibilities else [] def __init__(self, python_setup, python_repos, logger=None): self._python_setup = python_setup self._python_repos = python_repos self._cache_dir = python_setup.interpreter_cache_dir safe_mkdir(self._cache_dir) self._interpreters = set() self._logger = logger or (lambda msg: True) self._default_filters = (python_setup.interpreter_requirement or b'',) @property def interpreters(self): """Returns the set of cached interpreters.""" return self._interpreters def _interpreter_from_path(self, path, filters): interpreter_dir = os.path.basename(path) identity = PythonIdentity.from_path(interpreter_dir) try: executable = os.readlink(os.path.join(path, 'python')) except OSError: return None interpreter = PythonInterpreter(executable, identity) if self._matches(interpreter, filters): return self._resolve(interpreter) return None def _setup_interpreter(self, interpreter, cache_target_path): with safe_concurrent_creation(cache_target_path) as safe_path: os.mkdir(safe_path) # Parent will already have been created by safe_concurrent_creation. os.symlink(interpreter.binary, os.path.join(safe_path, 'python')) return self._resolve(interpreter, safe_path) def _setup_cached(self, filters): """Find all currently-cached interpreters.""" for interpreter_dir in os.listdir(self._cache_dir): path = os.path.join(self._cache_dir, interpreter_dir) pi = self._interpreter_from_path(path, filters) if pi: self._logger('Detected interpreter {}: {}'.format(pi.binary, str(pi.identity))) self._interpreters.add(pi) def _setup_paths(self, paths, filters): """Find interpreters under paths, and cache them.""" for interpreter in self._matching(PythonInterpreter.all(paths), filters): identity_str = str(interpreter.identity) cache_path = os.path.join(self._cache_dir, identity_str) pi = self._interpreter_from_path(cache_path, filters) if pi is None: self._setup_interpreter(interpreter, cache_path) pi = self._interpreter_from_path(cache_path, filters) if pi is None: continue self._interpreters.add(pi) def matched_interpreters(self, filters): """Given some filters, yield any interpreter that matches at least one of them. :param filters: A sequence of strings that constrain the interpreter compatibility for this cache, using the Requirement-style format, e.g. ``'CPython>=3', or just ['>=2.7','<3']`` for requirements agnostic to interpreter class. """ for match in self._matching(self._interpreters, filters): yield match def setup(self, paths=(), force=False, filters=(b'',)): """Sets up a cache of python interpreters. NB: Must be called prior to accessing the ``interpreters`` property or the ``matches`` method. :param paths: The paths to search for a python interpreter; the system ``PATH`` by default. :param bool force: When ``True`` the interpreter cache is always re-built. :param filters: A sequence of strings that constrain the interpreter compatibility for this cache, using the Requirement-style format, e.g. ``'CPython>=3', or just ['>=2.7','<3']`` for requirements agnostic to interpreter class. """ filters = self._default_filters if not any(filters) else filters setup_paths = paths or os.getenv('PATH').split(os.pathsep) self._setup_cached(filters) def unsatisfied_filters(): return filter(lambda filt: len(list(self._matching(self._interpreters, [filt]))) == 0, filters) if force or len(unsatisfied_filters()) > 0: self._setup_paths(setup_paths, filters) for filt in unsatisfied_filters(): self._logger('No valid interpreters found for {}!'.format(filt)) matches = list(self.matched_interpreters(filters)) if len(matches) == 0: self._logger('Found no valid interpreters!') return matches def _resolve(self, interpreter, interpreter_dir=None): """Resolve and cache an interpreter with a setuptools and wheel capability.""" interpreter = self._resolve_interpreter(interpreter, interpreter_dir, self._python_setup.setuptools_requirement()) if interpreter: return self._resolve_interpreter(interpreter, interpreter_dir, self._python_setup.wheel_requirement()) def _resolve_interpreter(self, interpreter, interpreter_dir, requirement): """Given a :class:`PythonInterpreter` and a requirement, return an interpreter with the capability of resolving that requirement or ``None`` if it's not possible to install a suitable requirement. If interpreter_dir is unspecified, operates on the default location. """ if interpreter.satisfies([requirement]): return interpreter if not interpreter_dir: interpreter_dir = os.path.join(self._cache_dir, str(interpreter.identity)) target_link = os.path.join(interpreter_dir, requirement.key) bdist = self._resolve_and_link(interpreter, requirement, target_link) if bdist: return interpreter.with_extra(bdist.name, bdist.raw_version, bdist.path) else: self._logger('Failed to resolve requirement {} for {}'.format(requirement, interpreter)) def _resolve_and_link(self, interpreter, requirement, target_link): # Short-circuit if there is a local copy. if os.path.exists(target_link) and os.path.exists(os.path.realpath(target_link)): bdist = Package.from_href(os.path.realpath(target_link)) if bdist.satisfies(requirement): return bdist # Since we're resolving to bootstrap a bare interpreter, we won't have wheel available. # Explicitly set the precedence to avoid resolution of wheels or distillation of sdists into # wheels. precedence = (EggPackage, SourcePackage) distributions = resolve(requirements=[requirement], fetchers=self._python_repos.get_fetchers(), interpreter=interpreter, context=self._python_repos.get_network_context(), precedence=precedence) if not distributions: return None assert len(distributions) == 1, ('Expected exactly 1 distribution to be resolved for {}, ' 'found:\n\t{}'.format(requirement, '\n\t'.join(map(str, distributions)))) dist_location = distributions[0].location target_location = os.path.join(os.path.dirname(target_link), os.path.basename(dist_location)) shutil.move(dist_location, target_location) _safe_link(target_location, target_link) self._logger(' installed {}'.format(target_location)) return Package.from_href(target_location)
apache-2.0
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 1898, 6927, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 16952, 12, 6032, 63, 14129, 12, 870, 63, 1593, 12, 717, 2649, 63, 5955, 12, 543, 63, 6242, 9, 199, 199, 646, 747, 199, 646, 5145, 199, 199, 504, 299, 476, 14, 20244, 492, 2018, 10193, 12, 2018, 2620, 26499, 199, 504, 299, 476, 14, 2491, 492, 662, 2721, 8599, 12, 15665, 12, 5800, 8599, 199, 504, 299, 476, 14, 7717, 492, 7512, 199, 199, 504, 18081, 14, 1974, 14, 694, 1974, 492, 5048, 63, 27237, 63, 8782, 12, 5048, 63, 8215, 421, 199, 3, 3254, 8, 87, 2000, 1237, 9, 2790, 282, 2937, 2412, 1015, 402, 642, 436, 1050, 370, 15811, 14, 2330, 14, 694, 1974, 199, 318, 485, 3489, 63, 1073, 8, 2164, 12, 5042, 304, 523, 862, 26, 272, 747, 14, 7162, 8, 5119, 9, 523, 871, 6440, 26, 272, 986, 523, 747, 14, 13380, 8, 2164, 12, 5042, 9, 421, 199, 533, 2018, 2620, 26499, 4437, 8, 785, 304, 523, 768, 4639, 523, 347, 485, 6742, 8, 20244, 12, 4766, 304, 272, 372, 1263, 8, 20244, 14, 5582, 14, 6742, 8, 18872, 9, 367, 26964, 315, 4766, 9, 819, 768, 3744, 523, 347, 485, 9467, 8, 1886, 12, 6421, 878, 12, 4766, 304, 272, 367, 12693, 315, 6421, 878, 26, 489, 340, 843, 423, 6742, 8, 20244, 12, 4766, 304, 267, 1995, 12693, 819, 768, 3744, 523, 347, 3504, 63, 20244, 8, 1886, 12, 1013, 2159, 66, 5462, 12, 2040, 63, 6048, 29, 797, 304, 272, 408, 13735, 282, 663, 402, 6421, 878, 12, 1902, 372, 3062, 1006, 340, 1124, 3306, 63, 6048, 1040, 365, 1124, 549, 1040, 27, 272, 4257, 12, 372, 314, 18966, 9025, 12693, 14, 272, 408, 272, 340, 2040, 63, 6048, 26, 489, 372, 1013, 2159, 66, 5462, 272, 372, 359, 827, 8, 863, 2159, 66, 5462, 1874, 340, 1013, 2159, 66, 5462, 587, 942, 819, 347, 636, 826, 721, 277, 12, 2366, 63, 2758, 12, 2366, 63, 11857, 12, 2512, 29, 403, 304, 272, 291, 423, 1548, 63, 2758, 275, 2366, 63, 2758, 272, 291, 423, 1548, 63, 11857, 275, 2366, 63, 11857, 272, 291, 423, 1637, 63, 694, 275, 2366, 63, 2758, 14, 20244, 63, 1637, 63, 694, 272, 5048, 63, 8215, 8, 277, 423, 1637, 63, 694, 9, 272, 291, 423, 12108, 878, 275, 663, 342, 272, 291, 423, 2921, 275, 2512, 503, 334, 2734, 1499, 26, 715, 9, 272, 291, 423, 885, 63, 4273, 275, 334, 1548, 63, 2758, 14, 20244, 63, 12434, 503, 330, 6448, 9, 819, 768, 1829, 523, 347, 6421, 878, 8, 277, 304, 272, 408, 3407, 314, 663, 402, 6328, 6421, 878, 1041, 272, 372, 291, 423, 12108, 878, 819, 347, 485, 20244, 63, 504, 63, 515, 8, 277, 12, 931, 12, 4766, 304, 272, 12693, 63, 694, 275, 747, 14, 515, 14, 4846, 8, 515, 9, 272, 8503, 275, 2018, 10193, 14, 504, 63, 515, 8, 20244, 63, 694, 9, 272, 862, 26, 489, 7286, 275, 747, 14, 31654, 8, 736, 14, 515, 14, 904, 8, 515, 12, 283, 1548, 1333, 272, 871, 6440, 26, 489, 372, 488, 272, 12693, 275, 2018, 2620, 26499, 8, 5904, 12, 8503, 9, 272, 340, 291, 423, 6742, 8, 20244, 12, 4766, 304, 489, 372, 291, 423, 6983, 8, 20244, 9, 272, 372, 488, 819, 347, 485, 2758, 63, 20244, 8, 277, 12, 12693, 12, 2581, 63, 1375, 63, 515, 304, 272, 543, 5048, 63, 27237, 63, 8782, 8, 1637, 63, 1375, 63, 515, 9, 465, 5048, 63, 515, 26, 489, 747, 14, 8215, 8, 3489, 63, 515, 9, 221, 327, 16396, 911, 2575, 1172, 2757, 2737, 701, 5048, 63, 27237, 63, 8782, 14, 489, 747, 14, 13380, 8, 20244, 14, 3008, 12, 747, 14, 515, 14, 904, 8, 3489, 63, 515, 12, 283, 1548, 1333, 489, 372, 291, 423, 6983, 8, 20244, 12, 5048, 63, 515, 9, 819, 347, 485, 2758, 63, 5245, 8, 277, 12, 4766, 304, 272, 408, 6591, 1006, 5544, 13, 5245, 6421, 878, 1041, 272, 367, 12693, 63, 694, 315, 747, 14, 7374, 8, 277, 423, 1637, 63, 694, 304, 489, 931, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1637, 63, 694, 12, 12693, 63, 694, 9, 489, 6682, 275, 291, 423, 20244, 63, 504, 63, 515, 8, 515, 12, 4766, 9, 489, 340, 6682, 26, 267, 291, 423, 2921, 360, 872, 4530, 12693, 24702, 9499, 908, 8, 1038, 14, 3008, 12, 620, 8, 1038, 14, 5582, 1724, 267, 291, 423, 12108, 878, 14, 525, 8, 1038, 9, 819, 347, 485, 2758, 63, 3771, 8, 277, 12, 3792, 12, 4766, 304, 272, 408, 6591, 6421, 878, 1334, 3792, 12, 436, 2581, 3062, 1041, 272, 367, 12693, 315, 291, 423, 9467, 8, 4718, 2620, 26499, 14, 452, 8, 3771, 395, 4766, 304, 489, 8503, 63, 495, 275, 620, 8, 20244, 14, 5582, 9, 489, 2581, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1637, 63, 694, 12, 8503, 63, 495, 9, 489, 6682, 275, 291, 423, 20244, 63, 504, 63, 515, 8, 1637, 63, 515, 12, 4766, 9, 489, 340, 6682, 365, 488, 26, 267, 291, 423, 2758, 63, 20244, 8, 20244, 12, 2581, 63, 515, 9, 267, 6682, 275, 291, 423, 20244, 63, 504, 63, 515, 8, 1637, 63, 515, 12, 4766, 9, 267, 340, 6682, 365, 488, 26, 881, 1980, 489, 291, 423, 12108, 878, 14, 525, 8, 1038, 9, 819, 347, 7838, 63, 12108, 878, 8, 277, 12, 4766, 304, 272, 408, 13735, 2005, 4766, 12, 1995, 1263, 12693, 626, 4450, 737, 5210, 1373, 402, 3062, 14, 339, 520, 635, 4766, 26, 437, 3414, 402, 3326, 626, 950, 6322, 314, 12693, 7163, 367, 642, 489, 2581, 12, 1808, 314, 25013, 13, 2487, 1475, 12, 325, 14, 71, 14, 12692, 35, 4718, 8119, 19, 297, 503, 2951, 788, 8119, 18, 14, 23, 1673, 28, 19, 418, 1040, 489, 367, 9760, 282, 784, 941, 530, 370, 12693, 1021, 14, 272, 408 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 1898, 6927, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 16952, 12, 6032, 63, 14129, 12, 870, 63, 1593, 12, 717, 2649, 63, 5955, 12, 543, 63, 6242, 9, 199, 199, 646, 747, 199, 646, 5145, 199, 199, 504, 299, 476, 14, 20244, 492, 2018, 10193, 12, 2018, 2620, 26499, 199, 504, 299, 476, 14, 2491, 492, 662, 2721, 8599, 12, 15665, 12, 5800, 8599, 199, 504, 299, 476, 14, 7717, 492, 7512, 199, 199, 504, 18081, 14, 1974, 14, 694, 1974, 492, 5048, 63, 27237, 63, 8782, 12, 5048, 63, 8215, 421, 199, 3, 3254, 8, 87, 2000, 1237, 9, 2790, 282, 2937, 2412, 1015, 402, 642, 436, 1050, 370, 15811, 14, 2330, 14, 694, 1974, 199, 318, 485, 3489, 63, 1073, 8, 2164, 12, 5042, 304, 523, 862, 26, 272, 747, 14, 7162, 8, 5119, 9, 523, 871, 6440, 26, 272, 986, 523, 747, 14, 13380, 8, 2164, 12, 5042, 9, 421, 199, 533, 2018, 2620, 26499, 4437, 8, 785, 304, 523, 768, 4639, 523, 347, 485, 6742, 8, 20244, 12, 4766, 304, 272, 372, 1263, 8, 20244, 14, 5582, 14, 6742, 8, 18872, 9, 367, 26964, 315, 4766, 9, 819, 768, 3744, 523, 347, 485, 9467, 8, 1886, 12, 6421, 878, 12, 4766, 304, 272, 367, 12693, 315, 6421, 878, 26, 489, 340, 843, 423, 6742, 8, 20244, 12, 4766, 304, 267, 1995, 12693, 819, 768, 3744, 523, 347, 3504, 63, 20244, 8, 1886, 12, 1013, 2159, 66, 5462, 12, 2040, 63, 6048, 29, 797, 304, 272, 408, 13735, 282, 663, 402, 6421, 878, 12, 1902, 372, 3062, 1006, 340, 1124, 3306, 63, 6048, 1040, 365, 1124, 549, 1040, 27, 272, 4257, 12, 372, 314, 18966, 9025, 12693, 14, 272, 408, 272, 340, 2040, 63, 6048, 26, 489, 372, 1013, 2159, 66, 5462, 272, 372, 359, 827, 8, 863, 2159, 66, 5462, 1874, 340, 1013, 2159, 66, 5462, 587, 942, 819, 347, 636, 826, 721, 277, 12, 2366, 63, 2758, 12, 2366, 63, 11857, 12, 2512, 29, 403, 304, 272, 291, 423, 1548, 63, 2758, 275, 2366, 63, 2758, 272, 291, 423, 1548, 63, 11857, 275, 2366, 63, 11857, 272, 291, 423, 1637, 63, 694, 275, 2366, 63, 2758, 14, 20244, 63, 1637, 63, 694, 272, 5048, 63, 8215, 8, 277, 423, 1637, 63, 694, 9, 272, 291, 423, 12108, 878, 275, 663, 342, 272, 291, 423, 2921, 275, 2512, 503, 334, 2734, 1499, 26, 715, 9, 272, 291, 423, 885, 63, 4273, 275, 334, 1548, 63, 2758, 14, 20244, 63, 12434, 503, 330, 6448, 9, 819, 768, 1829, 523, 347, 6421, 878, 8, 277, 304, 272, 408, 3407, 314, 663, 402, 6328, 6421, 878, 1041, 272, 372, 291, 423, 12108, 878, 819, 347, 485, 20244, 63, 504, 63, 515, 8, 277, 12, 931, 12, 4766, 304, 272, 12693, 63, 694, 275, 747, 14, 515, 14, 4846, 8, 515, 9, 272, 8503, 275, 2018, 10193, 14, 504, 63, 515, 8, 20244, 63, 694, 9, 272, 862, 26, 489, 7286, 275, 747, 14, 31654, 8, 736, 14, 515, 14, 904, 8, 515, 12, 283, 1548, 1333, 272, 871, 6440, 26, 489, 372, 488, 272, 12693, 275, 2018, 2620, 26499, 8, 5904, 12, 8503, 9, 272, 340, 291, 423, 6742, 8, 20244, 12, 4766, 304, 489, 372, 291, 423, 6983, 8, 20244, 9, 272, 372, 488, 819, 347, 485, 2758, 63, 20244, 8, 277, 12, 12693, 12, 2581, 63, 1375, 63, 515, 304, 272, 543, 5048, 63, 27237, 63, 8782, 8, 1637, 63, 1375, 63, 515, 9, 465, 5048, 63, 515, 26, 489, 747, 14, 8215, 8, 3489, 63, 515, 9, 221, 327, 16396, 911, 2575, 1172, 2757, 2737, 701, 5048, 63, 27237, 63, 8782, 14, 489, 747, 14, 13380, 8, 20244, 14, 3008, 12, 747, 14, 515, 14, 904, 8, 3489, 63, 515, 12, 283, 1548, 1333, 489, 372, 291, 423, 6983, 8, 20244, 12, 5048, 63, 515, 9, 819, 347, 485, 2758, 63, 5245, 8, 277, 12, 4766, 304, 272, 408, 6591, 1006, 5544, 13, 5245, 6421, 878, 1041, 272, 367, 12693, 63, 694, 315, 747, 14, 7374, 8, 277, 423, 1637, 63, 694, 304, 489, 931, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1637, 63, 694, 12, 12693, 63, 694, 9, 489, 6682, 275, 291, 423, 20244, 63, 504, 63, 515, 8, 515, 12, 4766, 9, 489, 340, 6682, 26, 267, 291, 423, 2921, 360, 872, 4530, 12693, 24702, 9499, 908, 8, 1038, 14, 3008, 12, 620, 8, 1038, 14, 5582, 1724, 267, 291, 423, 12108, 878, 14, 525, 8, 1038, 9, 819, 347, 485, 2758, 63, 3771, 8, 277, 12, 3792, 12, 4766, 304, 272, 408, 6591, 6421, 878, 1334, 3792, 12, 436, 2581, 3062, 1041, 272, 367, 12693, 315, 291, 423, 9467, 8, 4718, 2620, 26499, 14, 452, 8, 3771, 395, 4766, 304, 489, 8503, 63, 495, 275, 620, 8, 20244, 14, 5582, 9, 489, 2581, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1637, 63, 694, 12, 8503, 63, 495, 9, 489, 6682, 275, 291, 423, 20244, 63, 504, 63, 515, 8, 1637, 63, 515, 12, 4766, 9, 489, 340, 6682, 365, 488, 26, 267, 291, 423, 2758, 63, 20244, 8, 20244, 12, 2581, 63, 515, 9, 267, 6682, 275, 291, 423, 20244, 63, 504, 63, 515, 8, 1637, 63, 515, 12, 4766, 9, 267, 340, 6682, 365, 488, 26, 881, 1980, 489, 291, 423, 12108, 878, 14, 525, 8, 1038, 9, 819, 347, 7838, 63, 12108, 878, 8, 277, 12, 4766, 304, 272, 408, 13735, 2005, 4766, 12, 1995, 1263, 12693, 626, 4450, 737, 5210, 1373, 402, 3062, 14, 339, 520, 635, 4766, 26, 437, 3414, 402, 3326, 626, 950, 6322, 314, 12693, 7163, 367, 642, 489, 2581, 12, 1808, 314, 25013, 13, 2487, 1475, 12, 325, 14, 71, 14, 12692, 35, 4718, 8119, 19, 297, 503, 2951, 788, 8119, 18, 14, 23, 1673, 28, 19, 418, 1040, 489, 367, 9760, 282, 784, 941, 530, 370, 12693, 1021, 14, 272, 408, 0 ]
[ 1,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Vauxoo/maintainer-tools
tools/set_repo_labels.py
13
2539
# -*- coding: utf-8 -*- """ Create and modify labels on github to have same labels and same color on all repo """ from .github_login import login REPO_TO_IGNORE = [ 'odoo-community.org', 'community-data-files', 'contribute-md-template', 'website', ] # here is the list of labels we need in each repo all_labels = { '7.0': '000000', '8.0': '000000', 'bug': 'fc2929', 'duplicate': 'cccccc', 'enhancement': '84b6eb', 'help wanted': '159818', 'invalid': 'e6e6e6', 'question': 'cc317c', 'needs fixing': 'eb6420', 'needs review': 'fbca04', 'work in progress': '0052cc', 'wontfix': 'ffffff', } def main(): gh = login() all_repos = gh.iter_user_repos('OCA') for repo in all_repos: if repo.name in REPO_TO_IGNORE: continue labels = repo.iter_labels() existing_labels = dict((l.name, l.color) for l in labels) to_create = [] to_change_color = [] for needed_label in all_labels: if needed_label not in existing_labels.keys(): to_create.append(needed_label) elif existing_labels[needed_label] != all_labels[needed_label]: to_change_color.append(needed_label) extra_labels = [l for l in existing_labels if l not in all_labels] if to_create: print ('Repo %s - Create %s missing labels' % (repo.name, len(to_create))) for label_name in to_create: success = repo.create_label(label_name, all_labels[label_name]) if not success: print ("Failed to create a label on '%s'!" " Please check you access right to this repository." % repo.name) if to_change_color: print ('Repo %s - Update %s labels with wrong color' % (repo.name, len(to_change_color))) for label_name in to_change_color: success = repo.update_label(label_name, all_labels[label_name]) if not success: print ("Failed to update a label on '%s'!" " Please check you access right to this repository." % repo.name) if extra_labels: print ('Repo %s - Found %s extra labels' % (repo.name, len(extra_labels))) for label_name in extra_labels: print label_name if __name__ == '__main__': main()
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 2499, 436, 2811, 3628, 641, 12869, 370, 1172, 2011, 3628, 436, 2011, 3164, 199, 265, 1006, 3831, 199, 624, 199, 504, 1275, 5031, 63, 2886, 492, 4676, 199, 199, 20424, 63, 2566, 63, 11209, 275, 359, 272, 283, 22058, 13, 9387, 14, 1308, 297, 272, 283, 9387, 13, 576, 13, 1725, 297, 272, 283, 388, 999, 13, 1064, 13, 1160, 297, 272, 283, 7360, 297, 272, 1622, 199, 199, 3, 2348, 365, 314, 769, 402, 3628, 781, 1929, 315, 1924, 3831, 199, 452, 63, 3512, 275, 469, 272, 283, 23, 14, 16, 356, 283, 3273, 297, 272, 283, 24, 14, 16, 356, 283, 3273, 297, 272, 283, 1266, 356, 283, 3003, 1398, 1398, 297, 272, 283, 11081, 356, 283, 13720, 2055, 297, 272, 283, 287, 14666, 434, 356, 283, 1349, 66, 22, 2871, 297, 272, 283, 3437, 13632, 356, 283, 1046, 2905, 1085, 297, 272, 283, 3197, 356, 283, 69, 22, 69, 22, 69, 22, 297, 272, 283, 4790, 356, 283, 2055, 21974, 67, 297, 272, 283, 10065, 5325, 316, 356, 283, 2871, 772, 1165, 297, 272, 283, 10065, 11248, 356, 283, 4675, 696, 966, 297, 272, 283, 800, 315, 6696, 356, 283, 383, 2528, 2055, 297, 272, 283, 87, 1888, 970, 356, 283, 12596, 297, 272, 789, 421, 199, 318, 2446, 837, 272, 23310, 275, 4676, 342, 339, 1006, 63, 11857, 275, 23310, 14, 1661, 63, 751, 63, 11857, 360, 47, 3263, 358, 339, 367, 3831, 315, 1006, 63, 11857, 26, 267, 340, 3831, 14, 354, 315, 5363, 1512, 63, 2566, 63, 11209, 26, 288, 1980, 267, 3628, 275, 3831, 14, 1661, 63, 3512, 342, 398, 3411, 63, 3512, 275, 1211, 1332, 76, 14, 354, 12, 634, 14, 2326, 9, 367, 634, 315, 3628, 9, 398, 370, 63, 981, 275, 942, 267, 370, 63, 1461, 63, 2326, 275, 942, 267, 367, 4346, 63, 1302, 315, 1006, 63, 3512, 26, 288, 340, 4346, 63, 1302, 440, 315, 3411, 63, 3512, 14, 1612, 837, 355, 370, 63, 981, 14, 740, 8, 11368, 63, 1302, 9, 288, 916, 3411, 63, 3512, 59, 11368, 63, 1302, 61, 1137, 1006, 63, 3512, 59, 11368, 63, 1302, 2189, 355, 370, 63, 1461, 63, 2326, 14, 740, 8, 11368, 63, 1302, 9, 398, 2402, 63, 3512, 275, 359, 76, 367, 634, 315, 3411, 63, 3512, 340, 634, 440, 315, 1006, 63, 3512, 61, 398, 340, 370, 63, 981, 26, 288, 870, 661, 11334, 450, 83, 446, 2790, 450, 83, 4124, 3628, 7, 673, 450, 334, 3417, 14, 354, 12, 822, 8, 475, 63, 981, 1724, 953, 367, 1768, 63, 354, 315, 370, 63, 981, 26, 355, 3182, 275, 3831, 14, 981, 63, 1302, 8, 1302, 63, 354, 12, 1006, 63, 3512, 59, 1302, 63, 354, 566, 355, 340, 440, 3182, 26, 490, 870, 1689, 4276, 370, 1218, 282, 1768, 641, 1543, 83, 7, 9539, 2574, 298, 7754, 1104, 1265, 2879, 2451, 370, 642, 7611, 2122, 2574, 450, 3831, 14, 354, 9, 398, 340, 370, 63, 1461, 63, 2326, 26, 288, 870, 661, 11334, 450, 83, 446, 6162, 450, 83, 3628, 543, 6835, 3164, 7, 673, 450, 334, 3417, 14, 354, 12, 822, 8, 475, 63, 1461, 63, 2326, 1724, 953, 367, 1768, 63, 354, 315, 370, 63, 1461, 63, 2326, 26, 355, 3182, 275, 3831, 14, 873, 63, 1302, 8, 1302, 63, 354, 12, 1006, 63, 3512, 59, 1302, 63, 354, 566, 355, 340, 440, 3182, 26, 490, 870, 1689, 4276, 370, 1678, 282, 1768, 641, 1543, 83, 7, 9539, 2574, 298, 7754, 1104, 1265, 2879, 2451, 370, 642, 7611, 2122, 2574, 450, 3831, 14, 354, 9, 398, 340, 2402, 63, 3512, 26, 288, 870, 661, 11334, 450, 83, 446, 2643, 450, 83, 2402, 3628, 7, 673, 450, 334, 3417, 14, 354, 12, 822, 8, 2911, 63, 3512, 1724, 288, 367, 1768, 63, 354, 315, 2402, 63, 3512, 26, 355, 870, 1768, 63, 354, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 2499, 436, 2811, 3628, 641, 12869, 370, 1172, 2011, 3628, 436, 2011, 3164, 199, 265, 1006, 3831, 199, 624, 199, 504, 1275, 5031, 63, 2886, 492, 4676, 199, 199, 20424, 63, 2566, 63, 11209, 275, 359, 272, 283, 22058, 13, 9387, 14, 1308, 297, 272, 283, 9387, 13, 576, 13, 1725, 297, 272, 283, 388, 999, 13, 1064, 13, 1160, 297, 272, 283, 7360, 297, 272, 1622, 199, 199, 3, 2348, 365, 314, 769, 402, 3628, 781, 1929, 315, 1924, 3831, 199, 452, 63, 3512, 275, 469, 272, 283, 23, 14, 16, 356, 283, 3273, 297, 272, 283, 24, 14, 16, 356, 283, 3273, 297, 272, 283, 1266, 356, 283, 3003, 1398, 1398, 297, 272, 283, 11081, 356, 283, 13720, 2055, 297, 272, 283, 287, 14666, 434, 356, 283, 1349, 66, 22, 2871, 297, 272, 283, 3437, 13632, 356, 283, 1046, 2905, 1085, 297, 272, 283, 3197, 356, 283, 69, 22, 69, 22, 69, 22, 297, 272, 283, 4790, 356, 283, 2055, 21974, 67, 297, 272, 283, 10065, 5325, 316, 356, 283, 2871, 772, 1165, 297, 272, 283, 10065, 11248, 356, 283, 4675, 696, 966, 297, 272, 283, 800, 315, 6696, 356, 283, 383, 2528, 2055, 297, 272, 283, 87, 1888, 970, 356, 283, 12596, 297, 272, 789, 421, 199, 318, 2446, 837, 272, 23310, 275, 4676, 342, 339, 1006, 63, 11857, 275, 23310, 14, 1661, 63, 751, 63, 11857, 360, 47, 3263, 358, 339, 367, 3831, 315, 1006, 63, 11857, 26, 267, 340, 3831, 14, 354, 315, 5363, 1512, 63, 2566, 63, 11209, 26, 288, 1980, 267, 3628, 275, 3831, 14, 1661, 63, 3512, 342, 398, 3411, 63, 3512, 275, 1211, 1332, 76, 14, 354, 12, 634, 14, 2326, 9, 367, 634, 315, 3628, 9, 398, 370, 63, 981, 275, 942, 267, 370, 63, 1461, 63, 2326, 275, 942, 267, 367, 4346, 63, 1302, 315, 1006, 63, 3512, 26, 288, 340, 4346, 63, 1302, 440, 315, 3411, 63, 3512, 14, 1612, 837, 355, 370, 63, 981, 14, 740, 8, 11368, 63, 1302, 9, 288, 916, 3411, 63, 3512, 59, 11368, 63, 1302, 61, 1137, 1006, 63, 3512, 59, 11368, 63, 1302, 2189, 355, 370, 63, 1461, 63, 2326, 14, 740, 8, 11368, 63, 1302, 9, 398, 2402, 63, 3512, 275, 359, 76, 367, 634, 315, 3411, 63, 3512, 340, 634, 440, 315, 1006, 63, 3512, 61, 398, 340, 370, 63, 981, 26, 288, 870, 661, 11334, 450, 83, 446, 2790, 450, 83, 4124, 3628, 7, 673, 450, 334, 3417, 14, 354, 12, 822, 8, 475, 63, 981, 1724, 953, 367, 1768, 63, 354, 315, 370, 63, 981, 26, 355, 3182, 275, 3831, 14, 981, 63, 1302, 8, 1302, 63, 354, 12, 1006, 63, 3512, 59, 1302, 63, 354, 566, 355, 340, 440, 3182, 26, 490, 870, 1689, 4276, 370, 1218, 282, 1768, 641, 1543, 83, 7, 9539, 2574, 298, 7754, 1104, 1265, 2879, 2451, 370, 642, 7611, 2122, 2574, 450, 3831, 14, 354, 9, 398, 340, 370, 63, 1461, 63, 2326, 26, 288, 870, 661, 11334, 450, 83, 446, 6162, 450, 83, 3628, 543, 6835, 3164, 7, 673, 450, 334, 3417, 14, 354, 12, 822, 8, 475, 63, 1461, 63, 2326, 1724, 953, 367, 1768, 63, 354, 315, 370, 63, 1461, 63, 2326, 26, 355, 3182, 275, 3831, 14, 873, 63, 1302, 8, 1302, 63, 354, 12, 1006, 63, 3512, 59, 1302, 63, 354, 566, 355, 340, 440, 3182, 26, 490, 870, 1689, 4276, 370, 1678, 282, 1768, 641, 1543, 83, 7, 9539, 2574, 298, 7754, 1104, 1265, 2879, 2451, 370, 642, 7611, 2122, 2574, 450, 3831, 14, 354, 9, 398, 340, 2402, 63, 3512, 26, 288, 870, 661, 11334, 450, 83, 446, 2643, 450, 83, 2402, 3628, 7, 673, 450, 334, 3417, 14, 354, 12, 822, 8, 2911, 63, 3512, 1724, 288, 367, 1768, 63, 354, 315, 2402, 63, 3512, 26, 355, 870, 1768, 63, 354, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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History: # 1996-03-24 fl Created # 1996-08-13 fl Added logical operations (for "1" images) # 2000-10-12 fl Added offset method (from Image.py) # # Copyright (c) 1997-2000 by Secret Labs AB # Copyright (c) 1996-2000 by Fredrik Lundh # # See the README file for information on usage and redistribution. # import Image ## # The <b>ImageChops</b> module contains a number of arithmetical image # operations, called <i>channel operations</i> ("chops"). These can be # used for various purposes, including special effects, image # compositions, algorithmic painting, and more. # <p> # At this time, channel operations are only implemented for 8-bit # images (e.g. &quot;L&quot; and &quot;RGB&quot;). # <p> # Most channel operations take one or two image arguments and returns # a new image. Unless otherwise noted, the result of a channel # operation is always clipped to the range 0 to MAX (which is 255 for # all modes supported by the operations in this module). ## ## # Return an image with the same size as the given image, but filled # with the given pixel value. # # @param image Reference image. # @param value Pixel value. # @return An image object. def constant(image, value): "Fill a channel with a given grey level" return Image.new("L", image.size, value) ## # Copy image. # # @param image Source image. # @return A copy of the source image. def duplicate(image): "Create a copy of a channel" return image.copy() ## # Inverts an image # (MAX - image). # # @param image Source image. # @return An image object. def invert(image): "Invert a channel" image.load() return image._new(image.im.chop_invert()) ## # Compare images, and return lighter pixel value # (max(image1, image2)). # <p> # Compares the two images, pixel by pixel, and returns a new image # containing the lighter values. # # @param image1 First image. # @param image1 Second image. # @return An image object. def lighter(image1, image2): "Select the lighter pixels from each image" image1.load() image2.load() return image1._new(image1.im.chop_lighter(image2.im)) ## # Compare images, and return darker pixel value # (min(image1, image2)). # <p> # Compares the two images, pixel by pixel, and returns a new image # containing the darker values. # # @param image1 First image. # @param image1 Second image. # @return An image object. def darker(image1, image2): "Select the darker pixels from each image" image1.load() image2.load() return image1._new(image1.im.chop_darker(image2.im)) ## # Calculate absolute difference # (abs(image1 - image2)). # <p> # Returns the absolute value of the difference between the two images. # # @param image1 First image. # @param image1 Second image. # @return An image object. def difference(image1, image2): "Subtract one image from another" image1.load() image2.load() return image1._new(image1.im.chop_difference(image2.im)) ## # Superimpose positive images # (image1 * image2 / MAX). # <p> # Superimposes two images on top of each other. If you multiply an # image with a solid black image, the result is black. If you multiply # with a solid white image, the image is unaffected. # # @param image1 First image. # @param image1 Second image. # @return An image object. def multiply(image1, image2): "Superimpose two positive images" image1.load() image2.load() return image1._new(image1.im.chop_multiply(image2.im)) ## # Superimpose negative images # (MAX - ((MAX - image1) * (MAX - image2) / MAX)). # <p> # Superimposes two inverted images on top of each other. # # @param image1 First image. # @param image1 Second image. # @return An image object. def screen(image1, image2): "Superimpose two negative images" image1.load() image2.load() return image1._new(image1.im.chop_screen(image2.im)) ## # Add images # ((image1 + image2) / scale + offset). # <p> # Adds two images, dividing the result by scale and adding the # offset. If omitted, scale defaults to 1.0, and offset to 0.0. # # @param image1 First image. # @param image1 Second image. # @return An image object. def add(image1, image2, scale=1.0, offset=0): "Add two images" image1.load() image2.load() return image1._new(image1.im.chop_add(image2.im, scale, offset)) ## # Subtract images # ((image1 - image2) / scale + offset). # <p> # Subtracts two images, dividing the result by scale and adding the # offset. If omitted, scale defaults to 1.0, and offset to 0.0. # # @param image1 First image. # @param image1 Second image. # @return An image object. def subtract(image1, image2, scale=1.0, offset=0): "Subtract two images" image1.load() image2.load() return image1._new(image1.im.chop_subtract(image2.im, scale, offset)) ## # Add images without clipping # ((image1 + image2) % MAX). # <p> # Adds two images, without clipping the result. # # @param image1 First image. # @param image1 Second image. # @return An image object. def add_modulo(image1, image2): "Add two images without clipping" image1.load() image2.load() return image1._new(image1.im.chop_add_modulo(image2.im)) ## # Subtract images without clipping # ((image1 - image2) % MAX). # <p> # Subtracts two images, without clipping the result. # # @param image1 First image. # @param image1 Second image. # @return An image object. def subtract_modulo(image1, image2): "Subtract two images without clipping" image1.load() image2.load() return image1._new(image1.im.chop_subtract_modulo(image2.im)) ## # Logical AND # (image1 and image2). def logical_and(image1, image2): "Logical and between two images" image1.load() image2.load() return image1._new(image1.im.chop_and(image2.im)) ## # Logical OR # (image1 or image2). def logical_or(image1, image2): "Logical or between two images" image1.load() image2.load() return image1._new(image1.im.chop_or(image2.im)) ## # Logical XOR # (image1 xor image2). def logical_xor(image1, image2): "Logical xor between two images" image1.load() image2.load() return image1._new(image1.im.chop_xor(image2.im)) ## # Blend images using constant transparency weight. # <p> # Same as the <b>blend</b> function in the <b>Image</b> module. def blend(image1, image2, alpha): "Blend two images using a constant transparency weight" return Image.blend(image1, image2, alpha) ## # Create composite using transparency mask. # <p> # Same as the <b>composite</b> function in the <b>Image</b> module. def composite(image1, image2, mask): "Create composite image by blending images using a transparency mask" return Image.composite(image1, image2, mask) ## # Offset image data. # <p> # Returns a copy of the image where data has been offset by the given # distances. Data wraps around the edges. If yoffset is omitted, it # is assumed to be equal to xoffset. # # @param image Source image. # @param xoffset The horizontal distance. # @param yoffset The vertical distance. If omitted, both # distances are set to the same value. # @return An Image object. def offset(image, xoffset, yoffset=None): "Offset image in horizontal and/or vertical direction" if yoffset is None: yoffset = xoffset image.load() return image._new(image.im.offset(xoffset, yoffset))
gpl-2.0
[ 3, 199, 3, 710, 2018, 473, 391, 1540, 11243, 14, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 4465, 3623, 5331, 199, 3, 199, 3, 27829, 26, 199, 3, 31347, 13, 1644, 13, 1194, 2717, 257, 18208, 199, 3, 31347, 13, 2036, 13, 969, 2717, 257, 16230, 11461, 5331, 334, 509, 298, 17, 2, 5935, 9, 199, 3, 12293, 13, 709, 13, 713, 2717, 257, 16230, 3268, 1083, 334, 504, 6047, 14, 647, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 9013, 23, 13, 8269, 701, 23580, 491, 2101, 14840, 199, 3, 1898, 334, 67, 9, 31347, 13, 8269, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 646, 6047, 421, 199, 309, 199, 3, 710, 665, 66, 30, 3491, 1049, 1483, 1108, 66, 30, 859, 3509, 282, 1329, 402, 14554, 273, 278, 3294, 1834, 199, 3, 5331, 12, 2797, 665, 73, 30, 2775, 5331, 1108, 73, 30, 1689, 335, 1483, 3471, 5723, 883, 506, 199, 3, 1202, 367, 7750, 12901, 12, 5893, 4539, 22414, 12, 1834, 199, 3, 11395, 6150, 12, 5563, 530, 32055, 316, 12, 436, 1655, 14, 199, 3, 665, 80, 30, 199, 3, 2854, 642, 900, 12, 3623, 5331, 787, 1454, 6366, 367, 1695, 13, 2075, 199, 3, 5935, 334, 69, 14, 71, 14, 1253, 5184, 27, 44, 6, 5184, 27, 436, 1253, 5184, 27, 12067, 6, 5184, 27, 680, 199, 3, 665, 80, 30, 199, 3, 17536, 3623, 5331, 5452, 1373, 503, 2877, 1834, 2368, 436, 2529, 199, 3, 282, 892, 1834, 14, 221, 4158, 4257, 949, 471, 12, 314, 754, 402, 282, 3623, 199, 3, 3439, 365, 3544, 11353, 1915, 370, 314, 1425, 378, 370, 9141, 334, 6777, 365, 5450, 367, 199, 3, 1006, 12404, 3748, 701, 314, 5331, 315, 642, 859, 680, 199, 309, 199, 309, 199, 3, 1432, 376, 1834, 543, 314, 2011, 1568, 465, 314, 1627, 1834, 12, 1325, 13457, 199, 3, 543, 314, 1627, 7148, 574, 14, 199, 3, 199, 3, 768, 635, 1834, 10944, 1834, 14, 199, 3, 768, 635, 574, 510, 5887, 574, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199, 318, 4413, 8, 1569, 12, 574, 304, 272, 298, 12914, 282, 3623, 543, 282, 1627, 30357, 2166, 2, 339, 372, 6047, 14, 1222, 480, 44, 401, 1834, 14, 890, 12, 574, 9, 199, 199, 309, 199, 3, 11247, 1834, 14, 199, 3, 199, 3, 768, 635, 1834, 5800, 1834, 14, 199, 3, 768, 1107, 437, 1331, 402, 314, 1350, 1834, 14, 199, 199, 318, 9250, 8, 1569, 304, 272, 298, 2499, 282, 1331, 402, 282, 3623, 2, 339, 372, 1834, 14, 1574, 342, 199, 199, 309, 199, 3, 1010, 21505, 376, 1834, 199, 3, 334, 4283, 446, 1834, 680, 199, 3, 199, 3, 768, 635, 1834, 5800, 1834, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199, 199, 318, 25281, 8, 1569, 304, 272, 298, 26498, 282, 3623, 2, 339, 1834, 14, 912, 342, 272, 372, 1834, 423, 1222, 8, 1569, 14, 1017, 14, 335, 411, 63, 18957, 1012, 199, 199, 309, 199, 3, 18955, 5935, 12, 436, 372, 1212, 3561, 351, 7148, 574, 199, 3, 334, 988, 8, 1569, 17, 12, 1834, 18, 4992, 199, 3, 665, 80, 30, 199, 3, 3599, 11044, 314, 2877, 5935, 12, 7148, 701, 7148, 12, 436, 2529, 282, 892, 1834, 199, 3, 3035, 314, 1212, 3561, 351, 1338, 14, 199, 3, 199, 3, 768, 635, 1834, 17, 7758, 1834, 14, 199, 3, 768, 635, 1834, 17, 16707, 1834, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199, 199, 318, 1212, 3561, 351, 8, 1569, 17, 12, 1834, 18, 304, 272, 298, 5446, 314, 1212, 3561, 351, 11094, 687, 1924, 1834, 2, 339, 1834, 17, 14, 912, 342, 272, 1834, 18, 14, 912, 342, 272, 372, 1834, 17, 423, 1222, 8, 1569, 17, 14, 1017, 14, 335, 411, 63, 18975, 351, 8, 1569, 18, 14, 1017, 430, 199, 199, 309, 199, 3, 18955, 5935, 12, 436, 372, 23531, 281, 7148, 574, 199, 3, 334, 827, 8, 1569, 17, 12, 1834, 18, 4992, 199, 3, 665, 80, 30, 199, 3, 3599, 11044, 314, 2877, 5935, 12, 7148, 701, 7148, 12, 436, 2529, 282, 892, 1834, 199, 3, 3035, 314, 23531, 281, 1338, 14, 199, 3, 199, 3, 768, 635, 1834, 17, 7758, 1834, 14, 199, 3, 768, 635, 1834, 17, 16707, 1834, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199, 199, 318, 23531, 281, 8, 1569, 17, 12, 1834, 18, 304, 272, 298, 5446, 314, 23531, 281, 11094, 687, 1924, 1834, 2, 339, 1834, 17, 14, 912, 342, 272, 1834, 18, 14, 912, 342, 272, 372, 1834, 17, 423, 1222, 8, 1569, 17, 14, 1017, 14, 335, 411, 63, 13625, 281, 8, 1569, 18, 14, 1017, 430, 199, 199, 309, 199, 3, 12707, 3679, 8865, 199, 3, 334, 2101, 8, 1569, 17, 446, 1834, 18, 4992, 199, 3, 665, 80, 30, 199, 3, 1803, 314, 3679, 574, 402, 314, 8865, 3382, 314, 2877, 5935, 14, 199, 3, 199, 3, 768, 635, 1834, 17, 7758, 1834, 14, 199, 3, 768, 635, 1834, 17, 16707, 1834, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199, 199, 318, 8865, 8, 1569, 17, 12, 1834, 18, 304, 272, 298, 2610, 6908, 1373, 1834, 687, 4573, 2, 339, 1834, 17, 14, 912, 342, 272, 1834, 18, 14, 912, 342, 272, 372, 1834, 17, 423, 1222, 8, 1569, 17, 14, 1017, 14, 335, 411, 63, 9196, 8, 1569, 18, 14, 1017, 430, 199, 199, 309, 199, 3, 17897, 3236, 3362, 7317, 5935, 199, 3, 334, 1569, 17, 627, 1834, 18, 1182, 9141, 680, 199, 3, 665, 80, 30, 199, 3, 17897, 3236, 32128, 2877, 5935, 641, 2746, 402, 1924, 1163, 14, 982, 1265, 21699, 376, 199, 3, 1834, 543, 282, 18609, 12136, 1834, 12, 314, 754, 365, 12136, 14, 982, 1265, 21699, 199, 3, 543, 282, 18609, 10424, 1834, 12, 314, 1834, 365, 625, 26653, 14, 199, 3, 199, 3, 768, 635, 1834, 17, 7758, 1834, 14, 199, 3, 768, 635, 1834, 17, 16707, 1834, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199 ]
[ 199, 3, 710, 2018, 473, 391, 1540, 11243, 14, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 4465, 3623, 5331, 199, 3, 199, 3, 27829, 26, 199, 3, 31347, 13, 1644, 13, 1194, 2717, 257, 18208, 199, 3, 31347, 13, 2036, 13, 969, 2717, 257, 16230, 11461, 5331, 334, 509, 298, 17, 2, 5935, 9, 199, 3, 12293, 13, 709, 13, 713, 2717, 257, 16230, 3268, 1083, 334, 504, 6047, 14, 647, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 9013, 23, 13, 8269, 701, 23580, 491, 2101, 14840, 199, 3, 1898, 334, 67, 9, 31347, 13, 8269, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 646, 6047, 421, 199, 309, 199, 3, 710, 665, 66, 30, 3491, 1049, 1483, 1108, 66, 30, 859, 3509, 282, 1329, 402, 14554, 273, 278, 3294, 1834, 199, 3, 5331, 12, 2797, 665, 73, 30, 2775, 5331, 1108, 73, 30, 1689, 335, 1483, 3471, 5723, 883, 506, 199, 3, 1202, 367, 7750, 12901, 12, 5893, 4539, 22414, 12, 1834, 199, 3, 11395, 6150, 12, 5563, 530, 32055, 316, 12, 436, 1655, 14, 199, 3, 665, 80, 30, 199, 3, 2854, 642, 900, 12, 3623, 5331, 787, 1454, 6366, 367, 1695, 13, 2075, 199, 3, 5935, 334, 69, 14, 71, 14, 1253, 5184, 27, 44, 6, 5184, 27, 436, 1253, 5184, 27, 12067, 6, 5184, 27, 680, 199, 3, 665, 80, 30, 199, 3, 17536, 3623, 5331, 5452, 1373, 503, 2877, 1834, 2368, 436, 2529, 199, 3, 282, 892, 1834, 14, 221, 4158, 4257, 949, 471, 12, 314, 754, 402, 282, 3623, 199, 3, 3439, 365, 3544, 11353, 1915, 370, 314, 1425, 378, 370, 9141, 334, 6777, 365, 5450, 367, 199, 3, 1006, 12404, 3748, 701, 314, 5331, 315, 642, 859, 680, 199, 309, 199, 309, 199, 3, 1432, 376, 1834, 543, 314, 2011, 1568, 465, 314, 1627, 1834, 12, 1325, 13457, 199, 3, 543, 314, 1627, 7148, 574, 14, 199, 3, 199, 3, 768, 635, 1834, 10944, 1834, 14, 199, 3, 768, 635, 574, 510, 5887, 574, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199, 318, 4413, 8, 1569, 12, 574, 304, 272, 298, 12914, 282, 3623, 543, 282, 1627, 30357, 2166, 2, 339, 372, 6047, 14, 1222, 480, 44, 401, 1834, 14, 890, 12, 574, 9, 199, 199, 309, 199, 3, 11247, 1834, 14, 199, 3, 199, 3, 768, 635, 1834, 5800, 1834, 14, 199, 3, 768, 1107, 437, 1331, 402, 314, 1350, 1834, 14, 199, 199, 318, 9250, 8, 1569, 304, 272, 298, 2499, 282, 1331, 402, 282, 3623, 2, 339, 372, 1834, 14, 1574, 342, 199, 199, 309, 199, 3, 1010, 21505, 376, 1834, 199, 3, 334, 4283, 446, 1834, 680, 199, 3, 199, 3, 768, 635, 1834, 5800, 1834, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199, 199, 318, 25281, 8, 1569, 304, 272, 298, 26498, 282, 3623, 2, 339, 1834, 14, 912, 342, 272, 372, 1834, 423, 1222, 8, 1569, 14, 1017, 14, 335, 411, 63, 18957, 1012, 199, 199, 309, 199, 3, 18955, 5935, 12, 436, 372, 1212, 3561, 351, 7148, 574, 199, 3, 334, 988, 8, 1569, 17, 12, 1834, 18, 4992, 199, 3, 665, 80, 30, 199, 3, 3599, 11044, 314, 2877, 5935, 12, 7148, 701, 7148, 12, 436, 2529, 282, 892, 1834, 199, 3, 3035, 314, 1212, 3561, 351, 1338, 14, 199, 3, 199, 3, 768, 635, 1834, 17, 7758, 1834, 14, 199, 3, 768, 635, 1834, 17, 16707, 1834, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199, 199, 318, 1212, 3561, 351, 8, 1569, 17, 12, 1834, 18, 304, 272, 298, 5446, 314, 1212, 3561, 351, 11094, 687, 1924, 1834, 2, 339, 1834, 17, 14, 912, 342, 272, 1834, 18, 14, 912, 342, 272, 372, 1834, 17, 423, 1222, 8, 1569, 17, 14, 1017, 14, 335, 411, 63, 18975, 351, 8, 1569, 18, 14, 1017, 430, 199, 199, 309, 199, 3, 18955, 5935, 12, 436, 372, 23531, 281, 7148, 574, 199, 3, 334, 827, 8, 1569, 17, 12, 1834, 18, 4992, 199, 3, 665, 80, 30, 199, 3, 3599, 11044, 314, 2877, 5935, 12, 7148, 701, 7148, 12, 436, 2529, 282, 892, 1834, 199, 3, 3035, 314, 23531, 281, 1338, 14, 199, 3, 199, 3, 768, 635, 1834, 17, 7758, 1834, 14, 199, 3, 768, 635, 1834, 17, 16707, 1834, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199, 199, 318, 23531, 281, 8, 1569, 17, 12, 1834, 18, 304, 272, 298, 5446, 314, 23531, 281, 11094, 687, 1924, 1834, 2, 339, 1834, 17, 14, 912, 342, 272, 1834, 18, 14, 912, 342, 272, 372, 1834, 17, 423, 1222, 8, 1569, 17, 14, 1017, 14, 335, 411, 63, 13625, 281, 8, 1569, 18, 14, 1017, 430, 199, 199, 309, 199, 3, 12707, 3679, 8865, 199, 3, 334, 2101, 8, 1569, 17, 446, 1834, 18, 4992, 199, 3, 665, 80, 30, 199, 3, 1803, 314, 3679, 574, 402, 314, 8865, 3382, 314, 2877, 5935, 14, 199, 3, 199, 3, 768, 635, 1834, 17, 7758, 1834, 14, 199, 3, 768, 635, 1834, 17, 16707, 1834, 14, 199, 3, 768, 1107, 1626, 1834, 909, 14, 199, 199, 318, 8865, 8, 1569, 17, 12, 1834, 18, 304, 272, 298, 2610, 6908, 1373, 1834, 687, 4573, 2, 339, 1834, 17, 14, 912, 342, 272, 1834, 18, 14, 912, 342, 272, 372, 1834, 17, 423, 1222, 8, 1569, 17, 14, 1017, 14, 335, 411, 63, 9196, 8, 1569, 18, 14, 1017, 430, 199, 199, 309, 199, 3, 17897, 3236, 3362, 7317, 5935, 199, 3, 334, 1569, 17, 627, 1834, 18, 1182, 9141, 680, 199, 3, 665, 80, 30, 199, 3, 17897, 3236, 32128, 2877, 5935, 641, 2746, 402, 1924, 1163, 14, 982, 1265, 21699, 376, 199, 3, 1834, 543, 282, 18609, 12136, 1834, 12, 314, 754, 365, 12136, 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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 ]
BMJHayward/numpy
numpy/polynomial/hermite_e.py
49
57120
""" Objects for dealing with Hermite_e series. This module provides a number of objects (mostly functions) useful for dealing with Hermite_e series, including a `HermiteE` class that encapsulates the usual arithmetic operations. (General information on how this module represents and works with such polynomials is in the docstring for its "parent" sub-package, `numpy.polynomial`). Constants --------- - `hermedomain` -- Hermite_e series default domain, [-1,1]. - `hermezero` -- Hermite_e series that evaluates identically to 0. - `hermeone` -- Hermite_e series that evaluates identically to 1. - `hermex` -- Hermite_e series for the identity map, ``f(x) = x``. Arithmetic ---------- - `hermemulx` -- multiply a Hermite_e series in ``P_i(x)`` by ``x``. - `hermeadd` -- add two Hermite_e series. - `hermesub` -- subtract one Hermite_e series from another. - `hermemul` -- multiply two Hermite_e series. - `hermediv` -- divide one Hermite_e series by another. - `hermeval` -- evaluate a Hermite_e series at given points. - `hermeval2d` -- evaluate a 2D Hermite_e series at given points. - `hermeval3d` -- evaluate a 3D Hermite_e series at given points. - `hermegrid2d` -- evaluate a 2D Hermite_e series on a Cartesian product. - `hermegrid3d` -- evaluate a 3D Hermite_e series on a Cartesian product. Calculus -------- - `hermeder` -- differentiate a Hermite_e series. - `hermeint` -- integrate a Hermite_e series. Misc Functions -------------- - `hermefromroots` -- create a Hermite_e series with specified roots. - `hermeroots` -- find the roots of a Hermite_e series. - `hermevander` -- Vandermonde-like matrix for Hermite_e polynomials. - `hermevander2d` -- Vandermonde-like matrix for 2D power series. - `hermevander3d` -- Vandermonde-like matrix for 3D power series. - `hermegauss` -- Gauss-Hermite_e quadrature, points and weights. - `hermeweight` -- Hermite_e weight function. - `hermecompanion` -- symmetrized companion matrix in Hermite_e form. - `hermefit` -- least-squares fit returning a Hermite_e series. - `hermetrim` -- trim leading coefficients from a Hermite_e series. - `hermeline` -- Hermite_e series of given straight line. - `herme2poly` -- convert a Hermite_e series to a polynomial. - `poly2herme` -- convert a polynomial to a Hermite_e series. Classes ------- - `HermiteE` -- A Hermite_e series class. See also -------- `numpy.polynomial` """ from __future__ import division, absolute_import, print_function import warnings import numpy as np import numpy.linalg as la from . import polyutils as pu from ._polybase import ABCPolyBase __all__ = [ 'hermezero', 'hermeone', 'hermex', 'hermedomain', 'hermeline', 'hermeadd', 'hermesub', 'hermemulx', 'hermemul', 'hermediv', 'hermepow', 'hermeval', 'hermeder', 'hermeint', 'herme2poly', 'poly2herme', 'hermefromroots', 'hermevander', 'hermefit', 'hermetrim', 'hermeroots', 'HermiteE', 'hermeval2d', 'hermeval3d', 'hermegrid2d', 'hermegrid3d', 'hermevander2d', 'hermevander3d', 'hermecompanion', 'hermegauss', 'hermeweight'] hermetrim = pu.trimcoef def poly2herme(pol): """ poly2herme(pol) Convert a polynomial to a Hermite series. Convert an array representing the coefficients of a polynomial (relative to the "standard" basis) ordered from lowest degree to highest, to an array of the coefficients of the equivalent Hermite series, ordered from lowest to highest degree. Parameters ---------- pol : array_like 1-D array containing the polynomial coefficients Returns ------- c : ndarray 1-D array containing the coefficients of the equivalent Hermite series. See Also -------- herme2poly Notes ----- The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance. Examples -------- >>> from numpy.polynomial.hermite_e import poly2herme >>> poly2herme(np.arange(4)) array([ 2., 10., 2., 3.]) """ [pol] = pu.as_series([pol]) deg = len(pol) - 1 res = 0 for i in range(deg, -1, -1): res = hermeadd(hermemulx(res), pol[i]) return res def herme2poly(c): """ Convert a Hermite series to a polynomial. Convert an array representing the coefficients of a Hermite series, ordered from lowest degree to highest, to an array of the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest to highest degree. Parameters ---------- c : array_like 1-D array containing the Hermite series coefficients, ordered from lowest order term to highest. Returns ------- pol : ndarray 1-D array containing the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest order term to highest. See Also -------- poly2herme Notes ----- The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance. Examples -------- >>> from numpy.polynomial.hermite_e import herme2poly >>> herme2poly([ 2., 10., 2., 3.]) array([ 0., 1., 2., 3.]) """ from .polynomial import polyadd, polysub, polymulx [c] = pu.as_series([c]) n = len(c) if n == 1: return c if n == 2: return c else: c0 = c[-2] c1 = c[-1] # i is the current degree of c1 for i in range(n - 1, 1, -1): tmp = c0 c0 = polysub(c[i - 2], c1*(i - 1)) c1 = polyadd(tmp, polymulx(c1)) return polyadd(c0, polymulx(c1)) # # These are constant arrays are of integer type so as to be compatible # with the widest range of other types, such as Decimal. # # Hermite hermedomain = np.array([-1, 1]) # Hermite coefficients representing zero. hermezero = np.array([0]) # Hermite coefficients representing one. hermeone = np.array([1]) # Hermite coefficients representing the identity x. hermex = np.array([0, 1]) def hermeline(off, scl): """ Hermite series whose graph is a straight line. Parameters ---------- off, scl : scalars The specified line is given by ``off + scl*x``. Returns ------- y : ndarray This module's representation of the Hermite series for ``off + scl*x``. See Also -------- polyline, chebline Examples -------- >>> from numpy.polynomial.hermite_e import hermeline >>> from numpy.polynomial.hermite_e import hermeline, hermeval >>> hermeval(0,hermeline(3, 2)) 3.0 >>> hermeval(1,hermeline(3, 2)) 5.0 """ if scl != 0: return np.array([off, scl]) else: return np.array([off]) def hermefromroots(roots): """ Generate a HermiteE series with given roots. The function returns the coefficients of the polynomial .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), in HermiteE form, where the `r_n` are the roots specified in `roots`. If a zero has multiplicity n, then it must appear in `roots` n times. For instance, if 2 is a root of multiplicity three and 3 is a root of multiplicity 2, then `roots` looks something like [2, 2, 2, 3, 3]. The roots can appear in any order. If the returned coefficients are `c`, then .. math:: p(x) = c_0 + c_1 * He_1(x) + ... + c_n * He_n(x) The coefficient of the last term is not generally 1 for monic polynomials in HermiteE form. Parameters ---------- roots : array_like Sequence containing the roots. Returns ------- out : ndarray 1-D array of coefficients. If all roots are real then `out` is a real array, if some of the roots are complex, then `out` is complex even if all the coefficients in the result are real (see Examples below). See Also -------- polyfromroots, legfromroots, lagfromroots, hermfromroots, chebfromroots. Examples -------- >>> from numpy.polynomial.hermite_e import hermefromroots, hermeval >>> coef = hermefromroots((-1, 0, 1)) >>> hermeval((-1, 0, 1), coef) array([ 0., 0., 0.]) >>> coef = hermefromroots((-1j, 1j)) >>> hermeval((-1j, 1j), coef) array([ 0.+0.j, 0.+0.j]) """ if len(roots) == 0: return np.ones(1) else: [roots] = pu.as_series([roots], trim=False) roots.sort() p = [hermeline(-r, 1) for r in roots] n = len(p) while n > 1: m, r = divmod(n, 2) tmp = [hermemul(p[i], p[i+m]) for i in range(m)] if r: tmp[0] = hermemul(tmp[0], p[-1]) p = tmp n = m return p[0] def hermeadd(c1, c2): """ Add one Hermite series to another. Returns the sum of two Hermite series `c1` + `c2`. The arguments are sequences of coefficients ordered from lowest order term to highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : array_like 1-D arrays of Hermite series coefficients ordered from low to high. Returns ------- out : ndarray Array representing the Hermite series of their sum. See Also -------- hermesub, hermemul, hermediv, hermepow Notes ----- Unlike multiplication, division, etc., the sum of two Hermite series is a Hermite series (without having to "reproject" the result onto the basis set) so addition, just like that of "standard" polynomials, is simply "component-wise." Examples -------- >>> from numpy.polynomial.hermite_e import hermeadd >>> hermeadd([1, 2, 3], [1, 2, 3, 4]) array([ 2., 4., 6., 4.]) """ # c1, c2 are trimmed copies [c1, c2] = pu.as_series([c1, c2]) if len(c1) > len(c2): c1[:c2.size] += c2 ret = c1 else: c2[:c1.size] += c1 ret = c2 return pu.trimseq(ret) def hermesub(c1, c2): """ Subtract one Hermite series from another. Returns the difference of two Hermite series `c1` - `c2`. The sequences of coefficients are from lowest order term to highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : array_like 1-D arrays of Hermite series coefficients ordered from low to high. Returns ------- out : ndarray Of Hermite series coefficients representing their difference. See Also -------- hermeadd, hermemul, hermediv, hermepow Notes ----- Unlike multiplication, division, etc., the difference of two Hermite series is a Hermite series (without having to "reproject" the result onto the basis set) so subtraction, just like that of "standard" polynomials, is simply "component-wise." Examples -------- >>> from numpy.polynomial.hermite_e import hermesub >>> hermesub([1, 2, 3, 4], [1, 2, 3]) array([ 0., 0., 0., 4.]) """ # c1, c2 are trimmed copies [c1, c2] = pu.as_series([c1, c2]) if len(c1) > len(c2): c1[:c2.size] -= c2 ret = c1 else: c2 = -c2 c2[:c1.size] += c1 ret = c2 return pu.trimseq(ret) def hermemulx(c): """Multiply a Hermite series by x. Multiply the Hermite series `c` by x, where x is the independent variable. Parameters ---------- c : array_like 1-D array of Hermite series coefficients ordered from low to high. Returns ------- out : ndarray Array representing the result of the multiplication. Notes ----- The multiplication uses the recursion relationship for Hermite polynomials in the form .. math:: xP_i(x) = (P_{i + 1}(x) + iP_{i - 1}(x))) Examples -------- >>> from numpy.polynomial.hermite_e import hermemulx >>> hermemulx([1, 2, 3]) array([ 2., 7., 2., 3.]) """ # c is a trimmed copy [c] = pu.as_series([c]) # The zero series needs special treatment if len(c) == 1 and c[0] == 0: return c prd = np.empty(len(c) + 1, dtype=c.dtype) prd[0] = c[0]*0 prd[1] = c[0] for i in range(1, len(c)): prd[i + 1] = c[i] prd[i - 1] += c[i]*i return prd def hermemul(c1, c2): """ Multiply one Hermite series by another. Returns the product of two Hermite series `c1` * `c2`. The arguments are sequences of coefficients, from lowest order "term" to highest, e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : array_like 1-D arrays of Hermite series coefficients ordered from low to high. Returns ------- out : ndarray Of Hermite series coefficients representing their product. See Also -------- hermeadd, hermesub, hermediv, hermepow Notes ----- In general, the (polynomial) product of two C-series results in terms that are not in the Hermite polynomial basis set. Thus, to express the product as a Hermite series, it is necessary to "reproject" the product onto said basis set, which may produce "unintuitive" (but correct) results; see Examples section below. Examples -------- >>> from numpy.polynomial.hermite_e import hermemul >>> hermemul([1, 2, 3], [0, 1, 2]) array([ 14., 15., 28., 7., 6.]) """ # s1, s2 are trimmed copies [c1, c2] = pu.as_series([c1, c2]) if len(c1) > len(c2): c = c2 xs = c1 else: c = c1 xs = c2 if len(c) == 1: c0 = c[0]*xs c1 = 0 elif len(c) == 2: c0 = c[0]*xs c1 = c[1]*xs else: nd = len(c) c0 = c[-2]*xs c1 = c[-1]*xs for i in range(3, len(c) + 1): tmp = c0 nd = nd - 1 c0 = hermesub(c[-i]*xs, c1*(nd - 1)) c1 = hermeadd(tmp, hermemulx(c1)) return hermeadd(c0, hermemulx(c1)) def hermediv(c1, c2): """ Divide one Hermite series by another. Returns the quotient-with-remainder of two Hermite series `c1` / `c2`. The arguments are sequences of coefficients from lowest order "term" to highest, e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : array_like 1-D arrays of Hermite series coefficients ordered from low to high. Returns ------- [quo, rem] : ndarrays Of Hermite series coefficients representing the quotient and remainder. See Also -------- hermeadd, hermesub, hermemul, hermepow Notes ----- In general, the (polynomial) division of one Hermite series by another results in quotient and remainder terms that are not in the Hermite polynomial basis set. Thus, to express these results as a Hermite series, it is necessary to "reproject" the results onto the Hermite basis set, which may produce "unintuitive" (but correct) results; see Examples section below. Examples -------- >>> from numpy.polynomial.hermite_e import hermediv >>> hermediv([ 14., 15., 28., 7., 6.], [0, 1, 2]) (array([ 1., 2., 3.]), array([ 0.])) >>> hermediv([ 15., 17., 28., 7., 6.], [0, 1, 2]) (array([ 1., 2., 3.]), array([ 1., 2.])) """ # c1, c2 are trimmed copies [c1, c2] = pu.as_series([c1, c2]) if c2[-1] == 0: raise ZeroDivisionError() lc1 = len(c1) lc2 = len(c2) if lc1 < lc2: return c1[:1]*0, c1 elif lc2 == 1: return c1/c2[-1], c1[:1]*0 else: quo = np.empty(lc1 - lc2 + 1, dtype=c1.dtype) rem = c1 for i in range(lc1 - lc2, - 1, -1): p = hermemul([0]*i + [1], c2) q = rem[-1]/p[-1] rem = rem[:-1] - q*p[:-1] quo[i] = q return quo, pu.trimseq(rem) def hermepow(c, pow, maxpower=16): """Raise a Hermite series to a power. Returns the Hermite series `c` raised to the power `pow`. The argument `c` is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series ``P_0 + 2*P_1 + 3*P_2.`` Parameters ---------- c : array_like 1-D array of Hermite series coefficients ordered from low to high. pow : integer Power to which the series will be raised maxpower : integer, optional Maximum power allowed. This is mainly to limit growth of the series to unmanageable size. Default is 16 Returns ------- coef : ndarray Hermite series of power. See Also -------- hermeadd, hermesub, hermemul, hermediv Examples -------- >>> from numpy.polynomial.hermite_e import hermepow >>> hermepow([1, 2, 3], 2) array([ 23., 28., 46., 12., 9.]) """ # c is a trimmed copy [c] = pu.as_series([c]) power = int(pow) if power != pow or power < 0: raise ValueError("Power must be a non-negative integer.") elif maxpower is not None and power > maxpower: raise ValueError("Power is too large") elif power == 0: return np.array([1], dtype=c.dtype) elif power == 1: return c else: # This can be made more efficient by using powers of two # in the usual way. prd = c for i in range(2, power + 1): prd = hermemul(prd, c) return prd def hermeder(c, m=1, scl=1, axis=0): """ Differentiate a Hermite_e series. Returns the series coefficients `c` differentiated `m` times along `axis`. At each iteration the result is multiplied by `scl` (the scaling factor is for use in a linear change of variable). The argument `c` is an array of coefficients from low to high degree along each axis, e.g., [1,2,3] represents the series ``1*He_0 + 2*He_1 + 3*He_2`` while [[1,2],[1,2]] represents ``1*He_0(x)*He_0(y) + 1*He_1(x)*He_0(y) + 2*He_0(x)*He_1(y) + 2*He_1(x)*He_1(y)`` if axis=0 is ``x`` and axis=1 is ``y``. Parameters ---------- c : array_like Array of Hermite_e series coefficients. If `c` is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index. m : int, optional Number of derivatives taken, must be non-negative. (Default: 1) scl : scalar, optional Each differentiation is multiplied by `scl`. The end result is multiplication by ``scl**m``. This is for use in a linear change of variable. (Default: 1) axis : int, optional Axis over which the derivative is taken. (Default: 0). .. versionadded:: 1.7.0 Returns ------- der : ndarray Hermite series of the derivative. See Also -------- hermeint Notes ----- In general, the result of differentiating a Hermite series does not resemble the same operation on a power series. Thus the result of this function may be "unintuitive," albeit correct; see Examples section below. Examples -------- >>> from numpy.polynomial.hermite_e import hermeder >>> hermeder([ 1., 1., 1., 1.]) array([ 1., 2., 3.]) >>> hermeder([-0.25, 1., 1./2., 1./3., 1./4 ], m=2) array([ 1., 2., 3.]) """ c = np.array(c, ndmin=1, copy=1) if c.dtype.char in '?bBhHiIlLqQpP': c = c.astype(np.double) cnt, iaxis = [int(t) for t in [m, axis]] if cnt != m: raise ValueError("The order of derivation must be integer") if cnt < 0: raise ValueError("The order of derivation must be non-negative") if iaxis != axis: raise ValueError("The axis must be integer") if not -c.ndim <= iaxis < c.ndim: raise ValueError("The axis is out of range") if iaxis < 0: iaxis += c.ndim if cnt == 0: return c c = np.rollaxis(c, iaxis) n = len(c) if cnt >= n: return c[:1]*0 else: for i in range(cnt): n = n - 1 c *= scl der = np.empty((n,) + c.shape[1:], dtype=c.dtype) for j in range(n, 0, -1): der[j - 1] = j*c[j] c = der c = np.rollaxis(c, 0, iaxis + 1) return c def hermeint(c, m=1, k=[], lbnd=0, scl=1, axis=0): """ Integrate a Hermite_e series. Returns the Hermite_e series coefficients `c` integrated `m` times from `lbnd` along `axis`. At each iteration the resulting series is **multiplied** by `scl` and an integration constant, `k`, is added. The scaling factor is for use in a linear change of variable. ("Buyer beware": note that, depending on what one is doing, one may want `scl` to be the reciprocal of what one might expect; for more information, see the Notes section below.) The argument `c` is an array of coefficients from low to high degree along each axis, e.g., [1,2,3] represents the series ``H_0 + 2*H_1 + 3*H_2`` while [[1,2],[1,2]] represents ``1*H_0(x)*H_0(y) + 1*H_1(x)*H_0(y) + 2*H_0(x)*H_1(y) + 2*H_1(x)*H_1(y)`` if axis=0 is ``x`` and axis=1 is ``y``. Parameters ---------- c : array_like Array of Hermite_e series coefficients. If c is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index. m : int, optional Order of integration, must be positive. (Default: 1) k : {[], list, scalar}, optional Integration constant(s). The value of the first integral at ``lbnd`` is the first value in the list, the value of the second integral at ``lbnd`` is the second value, etc. If ``k == []`` (the default), all constants are set to zero. If ``m == 1``, a single scalar can be given instead of a list. lbnd : scalar, optional The lower bound of the integral. (Default: 0) scl : scalar, optional Following each integration the result is *multiplied* by `scl` before the integration constant is added. (Default: 1) axis : int, optional Axis over which the integral is taken. (Default: 0). .. versionadded:: 1.7.0 Returns ------- S : ndarray Hermite_e series coefficients of the integral. Raises ------ ValueError If ``m < 0``, ``len(k) > m``, ``np.isscalar(lbnd) == False``, or ``np.isscalar(scl) == False``. See Also -------- hermeder Notes ----- Note that the result of each integration is *multiplied* by `scl`. Why is this important to note? Say one is making a linear change of variable :math:`u = ax + b` in an integral relative to `x`. Then .. math::`dx = du/a`, so one will need to set `scl` equal to :math:`1/a` - perhaps not what one would have first thought. Also note that, in general, the result of integrating a C-series needs to be "reprojected" onto the C-series basis set. Thus, typically, the result of this function is "unintuitive," albeit correct; see Examples section below. Examples -------- >>> from numpy.polynomial.hermite_e import hermeint >>> hermeint([1, 2, 3]) # integrate once, value 0 at 0. array([ 1., 1., 1., 1.]) >>> hermeint([1, 2, 3], m=2) # integrate twice, value & deriv 0 at 0 array([-0.25 , 1. , 0.5 , 0.33333333, 0.25 ]) >>> hermeint([1, 2, 3], k=1) # integrate once, value 1 at 0. array([ 2., 1., 1., 1.]) >>> hermeint([1, 2, 3], lbnd=-1) # integrate once, value 0 at -1 array([-1., 1., 1., 1.]) >>> hermeint([1, 2, 3], m=2, k=[1, 2], lbnd=-1) array([ 1.83333333, 0. , 0.5 , 0.33333333, 0.25 ]) """ c = np.array(c, ndmin=1, copy=1) if c.dtype.char in '?bBhHiIlLqQpP': c = c.astype(np.double) if not np.iterable(k): k = [k] cnt, iaxis = [int(t) for t in [m, axis]] if cnt != m: raise ValueError("The order of integration must be integer") if cnt < 0: raise ValueError("The order of integration must be non-negative") if len(k) > cnt: raise ValueError("Too many integration constants") if iaxis != axis: raise ValueError("The axis must be integer") if not -c.ndim <= iaxis < c.ndim: raise ValueError("The axis is out of range") if iaxis < 0: iaxis += c.ndim if cnt == 0: return c c = np.rollaxis(c, iaxis) k = list(k) + [0]*(cnt - len(k)) for i in range(cnt): n = len(c) c *= scl if n == 1 and np.all(c[0] == 0): c[0] += k[i] else: tmp = np.empty((n + 1,) + c.shape[1:], dtype=c.dtype) tmp[0] = c[0]*0 tmp[1] = c[0] for j in range(1, n): tmp[j + 1] = c[j]/(j + 1) tmp[0] += k[i] - hermeval(lbnd, tmp) c = tmp c = np.rollaxis(c, 0, iaxis + 1) return c def hermeval(x, c, tensor=True): """ Evaluate an HermiteE series at points x. If `c` is of length `n + 1`, this function returns the value: .. math:: p(x) = c_0 * He_0(x) + c_1 * He_1(x) + ... + c_n * He_n(x) The parameter `x` is converted to an array only if it is a tuple or a list, otherwise it is treated as a scalar. In either case, either `x` or its elements must support multiplication and addition both with themselves and with the elements of `c`. If `c` is a 1-D array, then `p(x)` will have the same shape as `x`. If `c` is multidimensional, then the shape of the result depends on the value of `tensor`. If `tensor` is true the shape will be c.shape[1:] + x.shape. If `tensor` is false the shape will be c.shape[1:]. Note that scalars have shape (,). Trailing zeros in the coefficients will be used in the evaluation, so they should be avoided if efficiency is a concern. Parameters ---------- x : array_like, compatible object If `x` is a list or tuple, it is converted to an ndarray, otherwise it is left unchanged and treated as a scalar. In either case, `x` or its elements must support addition and multiplication with with themselves and with the elements of `c`. c : array_like Array of coefficients ordered so that the coefficients for terms of degree n are contained in c[n]. If `c` is multidimensional the remaining indices enumerate multiple polynomials. In the two dimensional case the coefficients may be thought of as stored in the columns of `c`. tensor : boolean, optional If True, the shape of the coefficient array is extended with ones on the right, one for each dimension of `x`. Scalars have dimension 0 for this action. The result is that every column of coefficients in `c` is evaluated for every element of `x`. If False, `x` is broadcast over the columns of `c` for the evaluation. This keyword is useful when `c` is multidimensional. The default value is True. .. versionadded:: 1.7.0 Returns ------- values : ndarray, algebra_like The shape of the return value is described above. See Also -------- hermeval2d, hermegrid2d, hermeval3d, hermegrid3d Notes ----- The evaluation uses Clenshaw recursion, aka synthetic division. Examples -------- >>> from numpy.polynomial.hermite_e import hermeval >>> coef = [1,2,3] >>> hermeval(1, coef) 3.0 >>> hermeval([[1,2],[3,4]], coef) array([[ 3., 14.], [ 31., 54.]]) """ c = np.array(c, ndmin=1, copy=0) if c.dtype.char in '?bBhHiIlLqQpP': c = c.astype(np.double) if isinstance(x, (tuple, list)): x = np.asarray(x) if isinstance(x, np.ndarray) and tensor: c = c.reshape(c.shape + (1,)*x.ndim) if len(c) == 1: c0 = c[0] c1 = 0 elif len(c) == 2: c0 = c[0] c1 = c[1] else: nd = len(c) c0 = c[-2] c1 = c[-1] for i in range(3, len(c) + 1): tmp = c0 nd = nd - 1 c0 = c[-i] - c1*(nd - 1) c1 = tmp + c1*x return c0 + c1*x def hermeval2d(x, y, c): """ Evaluate a 2-D HermiteE series at points (x, y). This function returns the values: .. math:: p(x,y) = \\sum_{i,j} c_{i,j} * He_i(x) * He_j(y) The parameters `x` and `y` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the same shape after conversion. In either case, either `x` and `y` or their elements must support multiplication and addition both with themselves and with the elements of `c`. If `c` is a 1-D array a one is implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape. Parameters ---------- x, y : array_like, compatible objects The two dimensional series is evaluated at the points `(x, y)`, where `x` and `y` must have the same shape. If `x` or `y` is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn't an ndarray it is treated as a scalar. c : array_like Array of coefficients ordered so that the coefficient of the term of multi-degree i,j is contained in ``c[i,j]``. If `c` has dimension greater than two the remaining indices enumerate multiple sets of coefficients. Returns ------- values : ndarray, compatible object The values of the two dimensional polynomial at points formed with pairs of corresponding values from `x` and `y`. See Also -------- hermeval, hermegrid2d, hermeval3d, hermegrid3d Notes ----- .. versionadded::1.7.0 """ try: x, y = np.array((x, y), copy=0) except: raise ValueError('x, y are incompatible') c = hermeval(x, c) c = hermeval(y, c, tensor=False) return c def hermegrid2d(x, y, c): """ Evaluate a 2-D HermiteE series on the Cartesian product of x and y. This function returns the values: .. math:: p(a,b) = \sum_{i,j} c_{i,j} * H_i(a) * H_j(b) where the points `(a, b)` consist of all pairs formed by taking `a` from `x` and `b` from `y`. The resulting points form a grid with `x` in the first dimension and `y` in the second. The parameters `x` and `y` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars. In either case, either `x` and `y` or their elements must support multiplication and addition both with themselves and with the elements of `c`. If `c` has fewer than two dimensions, ones are implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape. Parameters ---------- x, y : array_like, compatible objects The two dimensional series is evaluated at the points in the Cartesian product of `x` and `y`. If `x` or `y` is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn't an ndarray, it is treated as a scalar. c : array_like Array of coefficients ordered so that the coefficients for terms of degree i,j are contained in ``c[i,j]``. If `c` has dimension greater than two the remaining indices enumerate multiple sets of coefficients. Returns ------- values : ndarray, compatible object The values of the two dimensional polynomial at points in the Cartesian product of `x` and `y`. See Also -------- hermeval, hermeval2d, hermeval3d, hermegrid3d Notes ----- .. versionadded::1.7.0 """ c = hermeval(x, c) c = hermeval(y, c) return c def hermeval3d(x, y, z, c): """ Evaluate a 3-D Hermite_e series at points (x, y, z). This function returns the values: .. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * He_i(x) * He_j(y) * He_k(z) The parameters `x`, `y`, and `z` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the same shape after conversion. In either case, either `x`, `y`, and `z` or their elements must support multiplication and addition both with themselves and with the elements of `c`. If `c` has fewer than 3 dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape. Parameters ---------- x, y, z : array_like, compatible object The three dimensional series is evaluated at the points `(x, y, z)`, where `x`, `y`, and `z` must have the same shape. If any of `x`, `y`, or `z` is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn't an ndarray it is treated as a scalar. c : array_like Array of coefficients ordered so that the coefficient of the term of multi-degree i,j,k is contained in ``c[i,j,k]``. If `c` has dimension greater than 3 the remaining indices enumerate multiple sets of coefficients. Returns ------- values : ndarray, compatible object The values of the multidimensional polynomial on points formed with triples of corresponding values from `x`, `y`, and `z`. See Also -------- hermeval, hermeval2d, hermegrid2d, hermegrid3d Notes ----- .. versionadded::1.7.0 """ try: x, y, z = np.array((x, y, z), copy=0) except: raise ValueError('x, y, z are incompatible') c = hermeval(x, c) c = hermeval(y, c, tensor=False) c = hermeval(z, c, tensor=False) return c def hermegrid3d(x, y, z, c): """ Evaluate a 3-D HermiteE series on the Cartesian product of x, y, and z. This function returns the values: .. math:: p(a,b,c) = \\sum_{i,j,k} c_{i,j,k} * He_i(a) * He_j(b) * He_k(c) where the points `(a, b, c)` consist of all triples formed by taking `a` from `x`, `b` from `y`, and `c` from `z`. The resulting points form a grid with `x` in the first dimension, `y` in the second, and `z` in the third. The parameters `x`, `y`, and `z` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars. In either case, either `x`, `y`, and `z` or their elements must support multiplication and addition both with themselves and with the elements of `c`. If `c` has fewer than three dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape + y.shape + z.shape. Parameters ---------- x, y, z : array_like, compatible objects The three dimensional series is evaluated at the points in the Cartesian product of `x`, `y`, and `z`. If `x`,`y`, or `z` is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn't an ndarray, it is treated as a scalar. c : array_like Array of coefficients ordered so that the coefficients for terms of degree i,j are contained in ``c[i,j]``. If `c` has dimension greater than two the remaining indices enumerate multiple sets of coefficients. Returns ------- values : ndarray, compatible object The values of the two dimensional polynomial at points in the Cartesian product of `x` and `y`. See Also -------- hermeval, hermeval2d, hermegrid2d, hermeval3d Notes ----- .. versionadded::1.7.0 """ c = hermeval(x, c) c = hermeval(y, c) c = hermeval(z, c) return c def hermevander(x, deg): """Pseudo-Vandermonde matrix of given degree. Returns the pseudo-Vandermonde matrix of degree `deg` and sample points `x`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., i] = He_i(x), where `0 <= i <= deg`. The leading indices of `V` index the elements of `x` and the last index is the degree of the HermiteE polynomial. If `c` is a 1-D array of coefficients of length `n + 1` and `V` is the array ``V = hermevander(x, n)``, then ``np.dot(V, c)`` and ``hermeval(x, c)`` are the same up to roundoff. This equivalence is useful both for least squares fitting and for the evaluation of a large number of HermiteE series of the same degree and sample points. Parameters ---------- x : array_like Array of points. The dtype is converted to float64 or complex128 depending on whether any of the elements are complex. If `x` is scalar it is converted to a 1-D array. deg : int Degree of the resulting matrix. Returns ------- vander : ndarray The pseudo-Vandermonde matrix. The shape of the returned matrix is ``x.shape + (deg + 1,)``, where The last index is the degree of the corresponding HermiteE polynomial. The dtype will be the same as the converted `x`. Examples -------- >>> from numpy.polynomial.hermite_e import hermevander >>> x = np.array([-1, 0, 1]) >>> hermevander(x, 3) array([[ 1., -1., 0., 2.], [ 1., 0., -1., -0.], [ 1., 1., 0., -2.]]) """ ideg = int(deg) if ideg != deg: raise ValueError("deg must be integer") if ideg < 0: raise ValueError("deg must be non-negative") x = np.array(x, copy=0, ndmin=1) + 0.0 dims = (ideg + 1,) + x.shape dtyp = x.dtype v = np.empty(dims, dtype=dtyp) v[0] = x*0 + 1 if ideg > 0: v[1] = x for i in range(2, ideg + 1): v[i] = (v[i-1]*x - v[i-2]*(i - 1)) return np.rollaxis(v, 0, v.ndim) def hermevander2d(x, y, deg): """Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y)`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., deg[1]*i + j] = He_i(x) * He_j(y), where `0 <= i <= deg[0]` and `0 <= j <= deg[1]`. The leading indices of `V` index the points `(x, y)` and the last index encodes the degrees of the HermiteE polynomials. If ``V = hermevander2d(x, y, [xdeg, ydeg])``, then the columns of `V` correspond to the elements of a 2-D coefficient array `c` of shape (xdeg + 1, ydeg + 1) in the order .. math:: c_{00}, c_{01}, c_{02} ... , c_{10}, c_{11}, c_{12} ... and ``np.dot(V, c.flat)`` and ``hermeval2d(x, y, c)`` will be the same up to roundoff. This equivalence is useful both for least squares fitting and for the evaluation of a large number of 2-D HermiteE series of the same degrees and sample points. Parameters ---------- x, y : array_like Arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. deg : list of ints List of maximum degrees of the form [x_deg, y_deg]. Returns ------- vander2d : ndarray The shape of the returned matrix is ``x.shape + (order,)``, where :math:`order = (deg[0]+1)*(deg([1]+1)`. The dtype will be the same as the converted `x` and `y`. See Also -------- hermevander, hermevander3d. hermeval2d, hermeval3d Notes ----- .. versionadded::1.7.0 """ ideg = [int(d) for d in deg] is_valid = [id == d and id >= 0 for id, d in zip(ideg, deg)] if is_valid != [1, 1]: raise ValueError("degrees must be non-negative integers") degx, degy = ideg x, y = np.array((x, y), copy=0) + 0.0 vx = hermevander(x, degx) vy = hermevander(y, degy) v = vx[..., None]*vy[..., None,:] return v.reshape(v.shape[:-2] + (-1,)) def hermevander3d(x, y, z, deg): """Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y, z)`. If `l, m, n` are the given degrees in `x, y, z`, then Hehe pseudo-Vandermonde matrix is defined by .. math:: V[..., (m+1)(n+1)i + (n+1)j + k] = He_i(x)*He_j(y)*He_k(z), where `0 <= i <= l`, `0 <= j <= m`, and `0 <= j <= n`. The leading indices of `V` index the points `(x, y, z)` and the last index encodes the degrees of the HermiteE polynomials. If ``V = hermevander3d(x, y, z, [xdeg, ydeg, zdeg])``, then the columns of `V` correspond to the elements of a 3-D coefficient array `c` of shape (xdeg + 1, ydeg + 1, zdeg + 1) in the order .. math:: c_{000}, c_{001}, c_{002},... , c_{010}, c_{011}, c_{012},... and ``np.dot(V, c.flat)`` and ``hermeval3d(x, y, z, c)`` will be the same up to roundoff. This equivalence is useful both for least squares fitting and for the evaluation of a large number of 3-D HermiteE series of the same degrees and sample points. Parameters ---------- x, y, z : array_like Arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. deg : list of ints List of maximum degrees of the form [x_deg, y_deg, z_deg]. Returns ------- vander3d : ndarray The shape of the returned matrix is ``x.shape + (order,)``, where :math:`order = (deg[0]+1)*(deg([1]+1)*(deg[2]+1)`. The dtype will be the same as the converted `x`, `y`, and `z`. See Also -------- hermevander, hermevander3d. hermeval2d, hermeval3d Notes ----- .. versionadded::1.7.0 """ ideg = [int(d) for d in deg] is_valid = [id == d and id >= 0 for id, d in zip(ideg, deg)] if is_valid != [1, 1, 1]: raise ValueError("degrees must be non-negative integers") degx, degy, degz = ideg x, y, z = np.array((x, y, z), copy=0) + 0.0 vx = hermevander(x, degx) vy = hermevander(y, degy) vz = hermevander(z, degz) v = vx[..., None, None]*vy[..., None,:, None]*vz[..., None, None,:] return v.reshape(v.shape[:-3] + (-1,)) def hermefit(x, y, deg, rcond=None, full=False, w=None): """ Least squares fit of Hermite series to data. Return the coefficients of a HermiteE series of degree `deg` that is the least squares fit to the data values `y` given at points `x`. If `y` is 1-D the returned coefficients will also be 1-D. If `y` is 2-D multiple fits are done, one for each column of `y`, and the resulting coefficients are stored in the corresponding columns of a 2-D return. The fitted polynomial(s) are in the form .. math:: p(x) = c_0 + c_1 * He_1(x) + ... + c_n * He_n(x), where `n` is `deg`. Parameters ---------- x : array_like, shape (M,) x-coordinates of the M sample points ``(x[i], y[i])``. y : array_like, shape (M,) or (M, K) y-coordinates of the sample points. Several data sets of sample points sharing the same x-coordinates can be fitted at once by passing in a 2D-array that contains one dataset per column. deg : int Degree of the fitting polynomial rcond : float, optional Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be ignored. The default value is len(x)*eps, where eps is the relative precision of the float type, about 2e-16 in most cases. full : bool, optional Switch determining nature of return value. When it is False (the default) just the coefficients are returned, when True diagnostic information from the singular value decomposition is also returned. w : array_like, shape (`M`,), optional Weights. If not None, the contribution of each point ``(x[i],y[i])`` to the fit is weighted by `w[i]`. Ideally the weights are chosen so that the errors of the products ``w[i]*y[i]`` all have the same variance. The default value is None. Returns ------- coef : ndarray, shape (M,) or (M, K) Hermite coefficients ordered from low to high. If `y` was 2-D, the coefficients for the data in column k of `y` are in column `k`. [residuals, rank, singular_values, rcond] : list These values are only returned if `full` = True resid -- sum of squared residuals of the least squares fit rank -- the numerical rank of the scaled Vandermonde matrix sv -- singular values of the scaled Vandermonde matrix rcond -- value of `rcond`. For more details, see `linalg.lstsq`. Warns ----- RankWarning The rank of the coefficient matrix in the least-squares fit is deficient. The warning is only raised if `full` = False. The warnings can be turned off by >>> import warnings >>> warnings.simplefilter('ignore', RankWarning) See Also -------- chebfit, legfit, polyfit, hermfit, polyfit hermeval : Evaluates a Hermite series. hermevander : pseudo Vandermonde matrix of Hermite series. hermeweight : HermiteE weight function. linalg.lstsq : Computes a least-squares fit from the matrix. scipy.interpolate.UnivariateSpline : Computes spline fits. Notes ----- The solution is the coefficients of the HermiteE series `p` that minimizes the sum of the weighted squared errors .. math:: E = \\sum_j w_j^2 * |y_j - p(x_j)|^2, where the :math:`w_j` are the weights. This problem is solved by setting up the (typically) overdetermined matrix equation .. math:: V(x) * c = w * y, where `V` is the pseudo Vandermonde matrix of `x`, the elements of `c` are the coefficients to be solved for, and the elements of `y` are the observed values. This equation is then solved using the singular value decomposition of `V`. If some of the singular values of `V` are so small that they are neglected, then a `RankWarning` will be issued. This means that the coefficient values may be poorly determined. Using a lower order fit will usually get rid of the warning. The `rcond` parameter can also be set to a value smaller than its default, but the resulting fit may be spurious and have large contributions from roundoff error. Fits using HermiteE series are probably most useful when the data can be approximated by ``sqrt(w(x)) * p(x)``, where `w(x)` is the HermiteE weight. In that case the weight ``sqrt(w(x[i])`` should be used together with data values ``y[i]/sqrt(w(x[i])``. The weight function is available as `hermeweight`. References ---------- .. [1] Wikipedia, "Curve fitting", http://en.wikipedia.org/wiki/Curve_fitting Examples -------- >>> from numpy.polynomial.hermite_e import hermefik, hermeval >>> x = np.linspace(-10, 10) >>> err = np.random.randn(len(x))/10 >>> y = hermeval(x, [1, 2, 3]) + err >>> hermefit(x, y, 2) array([ 1.01690445, 1.99951418, 2.99948696]) """ order = int(deg) + 1 x = np.asarray(x) + 0.0 y = np.asarray(y) + 0.0 # check arguments. if deg < 0: raise ValueError("expected deg >= 0") if x.ndim != 1: raise TypeError("expected 1D vector for x") if x.size == 0: raise TypeError("expected non-empty vector for x") if y.ndim < 1 or y.ndim > 2: raise TypeError("expected 1D or 2D array for y") if len(x) != len(y): raise TypeError("expected x and y to have same length") # set up the least squares matrices in transposed form lhs = hermevander(x, deg).T rhs = y.T if w is not None: w = np.asarray(w) + 0.0 if w.ndim != 1: raise TypeError("expected 1D vector for w") if len(x) != len(w): raise TypeError("expected x and w to have same length") # apply weights. Don't use inplace operations as they # can cause problems with NA. lhs = lhs * w rhs = rhs * w # set rcond if rcond is None: rcond = len(x)*np.finfo(x.dtype).eps # Determine the norms of the design matrix columns. if issubclass(lhs.dtype.type, np.complexfloating): scl = np.sqrt((np.square(lhs.real) + np.square(lhs.imag)).sum(1)) else: scl = np.sqrt(np.square(lhs).sum(1)) scl[scl == 0] = 1 # Solve the least squares problem. c, resids, rank, s = la.lstsq(lhs.T/scl, rhs.T, rcond) c = (c.T/scl).T # warn on rank reduction if rank != order and not full: msg = "The fit may be poorly conditioned" warnings.warn(msg, pu.RankWarning) if full: return c, [resids, rank, s, rcond] else: return c def hermecompanion(c): """ Return the scaled companion matrix of c. The basis polynomials are scaled so that the companion matrix is symmetric when `c` is an HermiteE basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are guaranteed to be real if `numpy.linalg.eigvalsh` is used to obtain them. Parameters ---------- c : array_like 1-D array of HermiteE series coefficients ordered from low to high degree. Returns ------- mat : ndarray Scaled companion matrix of dimensions (deg, deg). Notes ----- .. versionadded::1.7.0 """ # c is a trimmed copy [c] = pu.as_series([c]) if len(c) < 2: raise ValueError('Series must have maximum degree of at least 1.') if len(c) == 2: return np.array([[-c[0]/c[1]]]) n = len(c) - 1 mat = np.zeros((n, n), dtype=c.dtype) scl = np.hstack((1., 1./np.sqrt(np.arange(n - 1, 0, -1)))) scl = np.multiply.accumulate(scl)[::-1] top = mat.reshape(-1)[1::n+1] bot = mat.reshape(-1)[n::n+1] top[...] = np.sqrt(np.arange(1, n)) bot[...] = top mat[:, -1] -= scl*c[:-1]/c[-1] return mat def hermeroots(c): """ Compute the roots of a HermiteE series. Return the roots (a.k.a. "zeros") of the polynomial .. math:: p(x) = \\sum_i c[i] * He_i(x). Parameters ---------- c : 1-D array_like 1-D array of coefficients. Returns ------- out : ndarray Array of the roots of the series. If all the roots are real, then `out` is also real, otherwise it is complex. See Also -------- polyroots, legroots, lagroots, hermroots, chebroots Notes ----- The root estimates are obtained as the eigenvalues of the companion matrix, Roots far from the origin of the complex plane may have large errors due to the numerical instability of the series for such values. Roots with multiplicity greater than 1 will also show larger errors as the value of the series near such points is relatively insensitive to errors in the roots. Isolated roots near the origin can be improved by a few iterations of Newton's method. The HermiteE series basis polynomials aren't powers of `x` so the results of this function may seem unintuitive. Examples -------- >>> from numpy.polynomial.hermite_e import hermeroots, hermefromroots >>> coef = hermefromroots([-1, 0, 1]) >>> coef array([ 0., 2., 0., 1.]) >>> hermeroots(coef) array([-1., 0., 1.]) """ # c is a trimmed copy [c] = pu.as_series([c]) if len(c) <= 1: return np.array([], dtype=c.dtype) if len(c) == 2: return np.array([-c[0]/c[1]]) m = hermecompanion(c) r = la.eigvals(m) r.sort() return r def _normed_hermite_e_n(x, n): """ Evaluate a normalized HermiteE polynomial. Compute the value of the normalized HermiteE polynomial of degree ``n`` at the points ``x``. Parameters ---------- x : ndarray of double. Points at which to evaluate the function n : int Degree of the normalized HermiteE function to be evaluated. Returns ------- values : ndarray The shape of the return value is described above. Notes ----- .. versionadded:: 1.10.0 This function is needed for finding the Gauss points and integration weights for high degrees. The values of the standard HermiteE functions overflow when n >= 207. """ if n == 0: return np.ones(x.shape)/np.sqrt(np.sqrt(2*np.pi)) c0 = 0. c1 = 1./np.sqrt(np.sqrt(2*np.pi)) nd = float(n) for i in range(n - 1): tmp = c0 c0 = -c1*np.sqrt((nd - 1.)/nd) c1 = tmp + c1*x*np.sqrt(1./nd) nd = nd - 1.0 return c0 + c1*x def hermegauss(deg): """ Gauss-HermiteE quadrature. Computes the sample points and weights for Gauss-HermiteE quadrature. These sample points and weights will correctly integrate polynomials of degree :math:`2*deg - 1` or less over the interval :math:`[-\inf, \inf]` with the weight function :math:`f(x) = \exp(-x^2/2)`. Parameters ---------- deg : int Number of sample points and weights. It must be >= 1. Returns ------- x : ndarray 1-D ndarray containing the sample points. y : ndarray 1-D ndarray containing the weights. Notes ----- .. versionadded::1.7.0 The results have only been tested up to degree 100, higher degrees may be problematic. The weights are determined by using the fact that .. math:: w_k = c / (He'_n(x_k) * He_{n-1}(x_k)) where :math:`c` is a constant independent of :math:`k` and :math:`x_k` is the k'th root of :math:`He_n`, and then scaling the results to get the right value when integrating 1. """ ideg = int(deg) if ideg != deg or ideg < 1: raise ValueError("deg must be a non-negative integer") # first approximation of roots. We use the fact that the companion # matrix is symmetric in this case in order to obtain better zeros. c = np.array([0]*deg + [1]) m = hermecompanion(c) x = la.eigvalsh(m) x.sort() # improve roots by one application of Newton dy = _normed_hermite_e_n(x, ideg) df = _normed_hermite_e_n(x, ideg - 1) * np.sqrt(ideg) x -= dy/df # compute the weights. We scale the factor to avoid possible numerical # overflow. fm = _normed_hermite_e_n(x, ideg - 1) fm /= np.abs(fm).max() w = 1/(fm * fm) # for Hermite_e we can also symmetrize w = (w + w[::-1])/2 x = (x - x[::-1])/2 # scale w to get the right value w *= np.sqrt(2*np.pi) / w.sum() return x, w def hermeweight(x): """Weight function of the Hermite_e polynomials. The weight function is :math:`\exp(-x^2/2)` and the interval of integration is :math:`[-\inf, \inf]`. the HermiteE polynomials are orthogonal, but not normalized, with respect to this weight function. Parameters ---------- x : array_like Values at which the weight function will be computed. Returns ------- w : ndarray The weight function at `x`. Notes ----- .. versionadded::1.7.0 """ w = np.exp(-.5*x**2) return w # # HermiteE series class # class HermiteE(ABCPolyBase): """An HermiteE series class. The HermiteE class provides the standard Python numerical methods '+', '-', '*', '//', '%', 'divmod', '**', and '()' as well as the attributes and methods listed in the `ABCPolyBase` documentation. Parameters ---------- coef : array_like HermiteE coefficients in order of increasing degree, i.e, ``(1, 2, 3)`` gives ``1*He_0(x) + 2*He_1(X) + 3*He_2(x)``. domain : (2,) array_like, optional Domain to use. The interval ``[domain[0], domain[1]]`` is mapped to the interval ``[window[0], window[1]]`` by shifting and scaling. The default value is [-1, 1]. window : (2,) array_like, optional Window, see `domain` for its use. The default value is [-1, 1]. .. versionadded:: 1.6.0 """ # Virtual Functions _add = staticmethod(hermeadd) _sub = staticmethod(hermesub) _mul = staticmethod(hermemul) _div = staticmethod(hermediv) _pow = staticmethod(hermepow) _val = staticmethod(hermeval) _int = staticmethod(hermeint) _der = staticmethod(hermeder) _fit = staticmethod(hermefit) _line = staticmethod(hermeline) _roots = staticmethod(hermeroots) _fromroots = staticmethod(hermefromroots) # Virtual properties nickname = 'herme' domain = np.array(hermedomain) window = np.array(hermedomain)
bsd-3-clause
[ 624, 199, 11188, 367, 23654, 543, 26526, 63, 69, 6779, 14, 199, 199, 2765, 859, 6571, 282, 1329, 402, 2251, 334, 2786, 590, 3423, 9, 2997, 367, 199, 21245, 316, 543, 26526, 63, 69, 6779, 12, 5893, 282, 658, 40, 281, 19130, 37, 64, 1021, 626, 199, 287, 12029, 15409, 314, 20195, 24166, 5331, 14, 221, 334, 14109, 2556, 199, 265, 4212, 642, 859, 8469, 436, 5419, 543, 4066, 27599, 365, 315, 314, 199, 12485, 367, 2399, 298, 1708, 2, 1007, 13, 2491, 12, 658, 4714, 14, 22104, 14963, 199, 199, 22185, 199, 9960, 199, 13, 658, 24607, 2261, 64, 1553, 26526, 63, 69, 6779, 849, 2881, 12, 5243, 17, 12, 17, 1055, 199, 13, 658, 24607, 4262, 64, 1553, 26526, 63, 69, 6779, 626, 22014, 6120, 17269, 370, 378, 14, 199, 13, 658, 24607, 368, 64, 1553, 26526, 63, 69, 6779, 626, 22014, 6120, 17269, 370, 413, 14, 199, 13, 658, 24607, 88, 64, 1553, 26526, 63, 69, 6779, 367, 314, 8503, 2341, 12, 1124, 70, 8, 88, 9, 275, 671, 4345, 199, 199, 26291, 18764, 199, 9460, 199, 13, 658, 24607, 3703, 88, 64, 1553, 21699, 282, 26526, 63, 69, 6779, 315, 1124, 48, 63, 73, 8, 88, 9719, 701, 1124, 88, 4345, 199, 13, 658, 24607, 525, 64, 1553, 1050, 2877, 26526, 63, 69, 6779, 14, 199, 13, 658, 24607, 954, 64, 1553, 24129, 1373, 26526, 63, 69, 6779, 687, 4573, 14, 199, 13, 658, 24607, 3703, 64, 1553, 21699, 2877, 26526, 63, 69, 6779, 14, 199, 13, 658, 24607, 3015, 64, 1553, 23003, 1373, 26526, 63, 69, 6779, 701, 4573, 14, 199, 13, 658, 24607, 637, 64, 1553, 9352, 282, 26526, 63, 69, 6779, 737, 1627, 4501, 14, 199, 13, 658, 24607, 637, 18, 68, 64, 1553, 9352, 282, 499, 36, 26526, 63, 69, 6779, 737, 1627, 4501, 14, 199, 13, 658, 24607, 637, 19, 68, 64, 1553, 9352, 282, 650, 36, 26526, 63, 69, 6779, 737, 1627, 4501, 14, 199, 13, 658, 24607, 3825, 18, 68, 64, 1553, 9352, 282, 499, 36, 26526, 63, 69, 6779, 641, 282, 14243, 19157, 3336, 14, 199, 13, 658, 24607, 3825, 19, 68, 64, 1553, 9352, 282, 650, 36, 26526, 63, 69, 6779, 641, 282, 14243, 19157, 3336, 14, 199, 199, 13862, 527, 199, 518, 199, 13, 658, 24607, 424, 64, 1553, 26796, 323, 282, 26526, 63, 69, 6779, 14, 199, 13, 658, 24607, 442, 64, 1553, 21494, 282, 26526, 63, 69, 6779, 14, 199, 199, 29926, 17471, 199, 10965, 199, 13, 658, 24607, 504, 12065, 64, 1553, 1218, 282, 26526, 63, 69, 6779, 543, 2013, 14361, 14, 199, 13, 658, 24607, 12065, 64, 1553, 2342, 314, 14361, 402, 282, 26526, 63, 69, 6779, 14, 199, 13, 658, 24607, 86, 11438, 64, 1553, 812, 11438, 2106, 271, 13, 2930, 3634, 367, 26526, 63, 69, 27599, 14, 199, 13, 658, 24607, 86, 11438, 18, 68, 64, 1553, 812, 11438, 2106, 271, 13, 2930, 3634, 367, 499, 36, 7074, 6779, 14, 199, 13, 658, 24607, 86, 11438, 19, 68, 64, 1553, 812, 11438, 2106, 271, 13, 2930, 3634, 367, 650, 36, 7074, 6779, 14, 199, 13, 658, 24607, 25898, 64, 1553, 598, 23822, 13, 40, 281, 19130, 63, 69, 16744, 30985, 12, 4501, 436, 4931, 14, 199, 13, 658, 24607, 3463, 64, 1553, 26526, 63, 69, 5401, 805, 14, 199, 13, 658, 24607, 863, 32012, 64, 1553, 4678, 3318, 7068, 1013, 32012, 3634, 315, 26526, 63, 69, 1824, 14, 199, 13, 658, 24607, 3269, 64, 1553, 5210, 13, 20956, 5542, 8152, 282, 26526, 63, 69, 6779, 14, 199, 13, 658, 2523, 3318, 77, 64, 1553, 11639, 9186, 12343, 687, 282, 26526, 63, 69, 6779, 14, 199, 13, 658, 24607, 604, 64, 1553, 26526, 63, 69, 6779, 402, 1627, 23669, 1004, 14, 199, 13, 658, 24607, 18, 6023, 64, 1553, 3957, 282, 26526, 63, 69, 6779, 370, 282, 11849, 14, 199, 13, 658, 6023, 18, 24607, 64, 1553, 3957, 282, 11849, 370, 282, 26526, 63, 69, 6779, 14, 199, 199, 15711, 199, 12797, 199, 13, 658, 40, 281, 19130, 37, 64, 1553, 437, 26526, 63, 69, 6779, 1021, 14, 199, 199, 9295, 2597, 199, 518, 199, 64, 4714, 14, 22104, 64, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 3598, 199, 646, 2680, 465, 980, 199, 646, 2680, 14, 10096, 465, 1127, 199, 199, 504, 1275, 492, 8446, 1208, 465, 18848, 199, 504, 13653, 6023, 1095, 492, 14840, 2890, 16242, 1563, 199, 199, 363, 452, 363, 275, 359, 272, 283, 24607, 4262, 297, 283, 24607, 368, 297, 283, 24607, 88, 297, 283, 24607, 2261, 297, 283, 24607, 604, 297, 272, 283, 24607, 525, 297, 283, 24607, 954, 297, 283, 24607, 3703, 88, 297, 283, 24607, 3703, 297, 283, 24607, 3015, 297, 272, 283, 24607, 8278, 297, 283, 24607, 637, 297, 283, 24607, 424, 297, 283, 24607, 442, 297, 283, 24607, 18, 6023, 297, 272, 283, 6023, 18, 24607, 297, 283, 24607, 504, 12065, 297, 283, 24607, 86, 11438, 297, 283, 24607, 3269, 297, 283, 2523, 3318, 77, 297, 272, 283, 24607, 12065, 297, 283, 40, 281, 19130, 37, 297, 283, 24607, 637, 18, 68, 297, 283, 24607, 637, 19, 68, 297, 283, 24607, 3825, 18, 68, 297, 272, 283, 24607, 3825, 19, 68, 297, 283, 24607, 86, 11438, 18, 68, 297, 283, 24607, 86, 11438, 19, 68, 297, 283, 24607, 863, 32012, 297, 272, 283, 24607, 25898, 297, 283, 24607, 3463, 418, 199, 199, 2523, 3318, 77, 275, 18848, 14, 12263, 8009, 421, 199, 318, 8446, 18, 24607, 8, 2515, 304, 272, 408, 272, 8446, 18, 24607, 8, 2515, 9, 339, 7905, 282, 11849, 370, 282, 26526, 6779, 14, 339, 7905, 376, 1625, 6144, 314, 12343, 402, 282, 11849, 334, 6188, 272, 370, 314, 298, 6807, 2, 5597, 9, 7741, 687, 18966, 13666, 370, 15356, 12, 370, 376, 272, 1625, 402, 314, 12343, 402, 314, 7353, 26526, 6779, 12, 7741, 272, 687, 18966, 370, 15356, 13666, 14, 339, 3897, 272, 4143, 272, 3708, 520, 1625, 63, 2930, 267, 413, 13, 36, 1625, 3035, 314, 11849, 12343, 339, 1803, 272, 5514, 272, 286, 520, 6800, 267, 413, 13, 36, 1625, 3035, 314, 12343, 402 ]
[ 199, 11188, 367, 23654, 543, 26526, 63, 69, 6779, 14, 199, 199, 2765, 859, 6571, 282, 1329, 402, 2251, 334, 2786, 590, 3423, 9, 2997, 367, 199, 21245, 316, 543, 26526, 63, 69, 6779, 12, 5893, 282, 658, 40, 281, 19130, 37, 64, 1021, 626, 199, 287, 12029, 15409, 314, 20195, 24166, 5331, 14, 221, 334, 14109, 2556, 199, 265, 4212, 642, 859, 8469, 436, 5419, 543, 4066, 27599, 365, 315, 314, 199, 12485, 367, 2399, 298, 1708, 2, 1007, 13, 2491, 12, 658, 4714, 14, 22104, 14963, 199, 199, 22185, 199, 9960, 199, 13, 658, 24607, 2261, 64, 1553, 26526, 63, 69, 6779, 849, 2881, 12, 5243, 17, 12, 17, 1055, 199, 13, 658, 24607, 4262, 64, 1553, 26526, 63, 69, 6779, 626, 22014, 6120, 17269, 370, 378, 14, 199, 13, 658, 24607, 368, 64, 1553, 26526, 63, 69, 6779, 626, 22014, 6120, 17269, 370, 413, 14, 199, 13, 658, 24607, 88, 64, 1553, 26526, 63, 69, 6779, 367, 314, 8503, 2341, 12, 1124, 70, 8, 88, 9, 275, 671, 4345, 199, 199, 26291, 18764, 199, 9460, 199, 13, 658, 24607, 3703, 88, 64, 1553, 21699, 282, 26526, 63, 69, 6779, 315, 1124, 48, 63, 73, 8, 88, 9719, 701, 1124, 88, 4345, 199, 13, 658, 24607, 525, 64, 1553, 1050, 2877, 26526, 63, 69, 6779, 14, 199, 13, 658, 24607, 954, 64, 1553, 24129, 1373, 26526, 63, 69, 6779, 687, 4573, 14, 199, 13, 658, 24607, 3703, 64, 1553, 21699, 2877, 26526, 63, 69, 6779, 14, 199, 13, 658, 24607, 3015, 64, 1553, 23003, 1373, 26526, 63, 69, 6779, 701, 4573, 14, 199, 13, 658, 24607, 637, 64, 1553, 9352, 282, 26526, 63, 69, 6779, 737, 1627, 4501, 14, 199, 13, 658, 24607, 637, 18, 68, 64, 1553, 9352, 282, 499, 36, 26526, 63, 69, 6779, 737, 1627, 4501, 14, 199, 13, 658, 24607, 637, 19, 68, 64, 1553, 9352, 282, 650, 36, 26526, 63, 69, 6779, 737, 1627, 4501, 14, 199, 13, 658, 24607, 3825, 18, 68, 64, 1553, 9352, 282, 499, 36, 26526, 63, 69, 6779, 641, 282, 14243, 19157, 3336, 14, 199, 13, 658, 24607, 3825, 19, 68, 64, 1553, 9352, 282, 650, 36, 26526, 63, 69, 6779, 641, 282, 14243, 19157, 3336, 14, 199, 199, 13862, 527, 199, 518, 199, 13, 658, 24607, 424, 64, 1553, 26796, 323, 282, 26526, 63, 69, 6779, 14, 199, 13, 658, 24607, 442, 64, 1553, 21494, 282, 26526, 63, 69, 6779, 14, 199, 199, 29926, 17471, 199, 10965, 199, 13, 658, 24607, 504, 12065, 64, 1553, 1218, 282, 26526, 63, 69, 6779, 543, 2013, 14361, 14, 199, 13, 658, 24607, 12065, 64, 1553, 2342, 314, 14361, 402, 282, 26526, 63, 69, 6779, 14, 199, 13, 658, 24607, 86, 11438, 64, 1553, 812, 11438, 2106, 271, 13, 2930, 3634, 367, 26526, 63, 69, 27599, 14, 199, 13, 658, 24607, 86, 11438, 18, 68, 64, 1553, 812, 11438, 2106, 271, 13, 2930, 3634, 367, 499, 36, 7074, 6779, 14, 199, 13, 658, 24607, 86, 11438, 19, 68, 64, 1553, 812, 11438, 2106, 271, 13, 2930, 3634, 367, 650, 36, 7074, 6779, 14, 199, 13, 658, 24607, 25898, 64, 1553, 598, 23822, 13, 40, 281, 19130, 63, 69, 16744, 30985, 12, 4501, 436, 4931, 14, 199, 13, 658, 24607, 3463, 64, 1553, 26526, 63, 69, 5401, 805, 14, 199, 13, 658, 24607, 863, 32012, 64, 1553, 4678, 3318, 7068, 1013, 32012, 3634, 315, 26526, 63, 69, 1824, 14, 199, 13, 658, 24607, 3269, 64, 1553, 5210, 13, 20956, 5542, 8152, 282, 26526, 63, 69, 6779, 14, 199, 13, 658, 2523, 3318, 77, 64, 1553, 11639, 9186, 12343, 687, 282, 26526, 63, 69, 6779, 14, 199, 13, 658, 24607, 604, 64, 1553, 26526, 63, 69, 6779, 402, 1627, 23669, 1004, 14, 199, 13, 658, 24607, 18, 6023, 64, 1553, 3957, 282, 26526, 63, 69, 6779, 370, 282, 11849, 14, 199, 13, 658, 6023, 18, 24607, 64, 1553, 3957, 282, 11849, 370, 282, 26526, 63, 69, 6779, 14, 199, 199, 15711, 199, 12797, 199, 13, 658, 40, 281, 19130, 37, 64, 1553, 437, 26526, 63, 69, 6779, 1021, 14, 199, 199, 9295, 2597, 199, 518, 199, 64, 4714, 14, 22104, 64, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 3598, 199, 646, 2680, 465, 980, 199, 646, 2680, 14, 10096, 465, 1127, 199, 199, 504, 1275, 492, 8446, 1208, 465, 18848, 199, 504, 13653, 6023, 1095, 492, 14840, 2890, 16242, 1563, 199, 199, 363, 452, 363, 275, 359, 272, 283, 24607, 4262, 297, 283, 24607, 368, 297, 283, 24607, 88, 297, 283, 24607, 2261, 297, 283, 24607, 604, 297, 272, 283, 24607, 525, 297, 283, 24607, 954, 297, 283, 24607, 3703, 88, 297, 283, 24607, 3703, 297, 283, 24607, 3015, 297, 272, 283, 24607, 8278, 297, 283, 24607, 637, 297, 283, 24607, 424, 297, 283, 24607, 442, 297, 283, 24607, 18, 6023, 297, 272, 283, 6023, 18, 24607, 297, 283, 24607, 504, 12065, 297, 283, 24607, 86, 11438, 297, 283, 24607, 3269, 297, 283, 2523, 3318, 77, 297, 272, 283, 24607, 12065, 297, 283, 40, 281, 19130, 37, 297, 283, 24607, 637, 18, 68, 297, 283, 24607, 637, 19, 68, 297, 283, 24607, 3825, 18, 68, 297, 272, 283, 24607, 3825, 19, 68, 297, 283, 24607, 86, 11438, 18, 68, 297, 283, 24607, 86, 11438, 19, 68, 297, 283, 24607, 863, 32012, 297, 272, 283, 24607, 25898, 297, 283, 24607, 3463, 418, 199, 199, 2523, 3318, 77, 275, 18848, 14, 12263, 8009, 421, 199, 318, 8446, 18, 24607, 8, 2515, 304, 272, 408, 272, 8446, 18, 24607, 8, 2515, 9, 339, 7905, 282, 11849, 370, 282, 26526, 6779, 14, 339, 7905, 376, 1625, 6144, 314, 12343, 402, 282, 11849, 334, 6188, 272, 370, 314, 298, 6807, 2, 5597, 9, 7741, 687, 18966, 13666, 370, 15356, 12, 370, 376, 272, 1625, 402, 314, 12343, 402, 314, 7353, 26526, 6779, 12, 7741, 272, 687, 18966, 370, 15356, 13666, 14, 339, 3897, 272, 4143, 272, 3708, 520, 1625, 63, 2930, 267, 413, 13, 36, 1625, 3035, 314, 11849, 12343, 339, 1803, 272, 5514, 272, 286, 520, 6800, 267, 413, 13, 36, 1625, 3035, 314, 12343, 402, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
entomb/CouchPotatoServer
libs/xmpp/commands.py
200
16116
## $Id: commands.py,v 1.17 2007/08/28 09:54:15 normanr Exp $ ## Ad-Hoc Command manager ## Mike Albon (c) 5th January 2005 ## 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, 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. """This module is a ad-hoc command processor for xmpppy. It uses the plug-in mechanism like most of the core library. It depends on a DISCO browser manager. There are 3 classes here, a command processor Commands like the Browser, and a command template plugin Command, and an example command. To use this module: Instansiate the module with the parent transport and disco browser manager as parameters. 'Plug in' commands using the command template. The command feature must be added to existing disco replies where neccessary. What it supplies: Automatic command registration with the disco browser manager. Automatic listing of commands in the public command list. A means of handling requests, by redirection though the command manager. """ from protocol import * from client import PlugIn class Commands(PlugIn): """Commands is an ancestor of PlugIn and can be attached to any session. The commands class provides a lookup and browse mechnism. It follows the same priciple of the Browser class, for Service Discovery to provide the list of commands, it adds the 'list' disco type to your existing disco handler function. How it works: The commands are added into the existing Browser on the correct nodes. When the command list is built the supplied discovery handler function needs to have a 'list' option in type. This then gets enumerated, all results returned as None are ignored. The command executed is then called using it's Execute method. All session management is handled by the command itself. """ def __init__(self, browser): """Initialises class and sets up local variables""" PlugIn.__init__(self) DBG_LINE='commands' self._exported_methods=[] self._handlers={'':{}} self._browser = browser def plugin(self, owner): """Makes handlers within the session""" # Plug into the session and the disco manager # We only need get and set, results are not needed by a service provider, only a service user. owner.RegisterHandler('iq',self._CommandHandler,typ='set',ns=NS_COMMANDS) owner.RegisterHandler('iq',self._CommandHandler,typ='get',ns=NS_COMMANDS) self._browser.setDiscoHandler(self._DiscoHandler,node=NS_COMMANDS,jid='') def plugout(self): """Removes handlers from the session""" # unPlug from the session and the disco manager self._owner.UnregisterHandler('iq',self._CommandHandler,ns=NS_COMMANDS) for jid in self._handlers: self._browser.delDiscoHandler(self._DiscoHandler,node=NS_COMMANDS) def _CommandHandler(self,conn,request): """The internal method to process the routing of command execution requests""" # This is the command handler itself. # We must: # Pass on command execution to command handler # (Do we need to keep session details here, or can that be done in the command?) jid = str(request.getTo()) try: node = request.getTagAttr('command','node') except: conn.send(Error(request,ERR_BAD_REQUEST)) raise NodeProcessed if self._handlers.has_key(jid): if self._handlers[jid].has_key(node): self._handlers[jid][node]['execute'](conn,request) else: conn.send(Error(request,ERR_ITEM_NOT_FOUND)) raise NodeProcessed elif self._handlers[''].has_key(node): self._handlers[''][node]['execute'](conn,request) else: conn.send(Error(request,ERR_ITEM_NOT_FOUND)) raise NodeProcessed def _DiscoHandler(self,conn,request,typ): """The internal method to process service discovery requests""" # This is the disco manager handler. if typ == 'items': # We must: # Generate a list of commands and return the list # * This handler does not handle individual commands disco requests. # Pseudo: # Enumerate the 'item' disco of each command for the specified jid # Build responce and send # To make this code easy to write we add an 'list' disco type, it returns a tuple or 'none' if not advertised list = [] items = [] jid = str(request.getTo()) # Get specific jid based results if self._handlers.has_key(jid): for each in self._handlers[jid].keys(): items.append((jid,each)) else: # Get generic results for each in self._handlers[''].keys(): items.append(('',each)) if items != []: for each in items: i = self._handlers[each[0]][each[1]]['disco'](conn,request,'list') if i != None: list.append(Node(tag='item',attrs={'jid':i[0],'node':i[1],'name':i[2]})) iq = request.buildReply('result') if request.getQuerynode(): iq.setQuerynode(request.getQuerynode()) iq.setQueryPayload(list) conn.send(iq) else: conn.send(Error(request,ERR_ITEM_NOT_FOUND)) raise NodeProcessed elif typ == 'info': return {'ids':[{'category':'automation','type':'command-list'}],'features':[]} def addCommand(self,name,cmddisco,cmdexecute,jid=''): """The method to call if adding a new command to the session, the requred parameters of cmddisco and cmdexecute are the methods to enable that command to be executed""" # This command takes a command object and the name of the command for registration # We must: # Add item into disco # Add item into command list if not self._handlers.has_key(jid): self._handlers[jid]={} self._browser.setDiscoHandler(self._DiscoHandler,node=NS_COMMANDS,jid=jid) if self._handlers[jid].has_key(name): raise NameError,'Command Exists' else: self._handlers[jid][name]={'disco':cmddisco,'execute':cmdexecute} # Need to add disco stuff here self._browser.setDiscoHandler(cmddisco,node=name,jid=jid) def delCommand(self,name,jid=''): """Removed command from the session""" # This command takes a command object and the name used for registration # We must: # Remove item from disco # Remove item from command list if not self._handlers.has_key(jid): raise NameError,'Jid not found' if not self._handlers[jid].has_key(name): raise NameError, 'Command not found' else: #Do disco removal here command = self.getCommand(name,jid)['disco'] del self._handlers[jid][name] self._browser.delDiscoHandler(command,node=name,jid=jid) def getCommand(self,name,jid=''): """Returns the command tuple""" # This gets the command object with name # We must: # Return item that matches this name if not self._handlers.has_key(jid): raise NameError,'Jid not found' elif not self._handlers[jid].has_key(name): raise NameError,'Command not found' else: return self._handlers[jid][name] class Command_Handler_Prototype(PlugIn): """This is a prototype command handler, as each command uses a disco method and execute method you can implement it any way you like, however this is my first attempt at making a generic handler that you can hang process stages on too. There is an example command below. The parameters are as follows: name : the name of the command within the jabber environment description : the natural language description discofeatures : the features supported by the command initial : the initial command in the from of {'execute':commandname} All stages set the 'actions' dictionary for each session to represent the possible options available. """ name = 'examplecommand' count = 0 description = 'an example command' discofeatures = [NS_COMMANDS,NS_DATA] # This is the command template def __init__(self,jid=''): """Set up the class""" PlugIn.__init__(self) DBG_LINE='command' self.sessioncount = 0 self.sessions = {} # Disco information for command list pre-formatted as a tuple self.discoinfo = {'ids':[{'category':'automation','type':'command-node','name':self.description}],'features': self.discofeatures} self._jid = jid def plugin(self,owner): """Plug command into the commands class""" # The owner in this instance is the Command Processor self._commands = owner self._owner = owner._owner self._commands.addCommand(self.name,self._DiscoHandler,self.Execute,jid=self._jid) def plugout(self): """Remove command from the commands class""" self._commands.delCommand(self.name,self._jid) def getSessionID(self): """Returns an id for the command session""" self.count = self.count+1 return 'cmd-%s-%d'%(self.name,self.count) def Execute(self,conn,request): """The method that handles all the commands, and routes them to the correct method for that stage.""" # New request or old? try: session = request.getTagAttr('command','sessionid') except: session = None try: action = request.getTagAttr('command','action') except: action = None if action == None: action = 'execute' # Check session is in session list if self.sessions.has_key(session): if self.sessions[session]['jid']==request.getFrom(): # Check action is vaild if self.sessions[session]['actions'].has_key(action): # Execute next action self.sessions[session]['actions'][action](conn,request) else: # Stage not presented as an option self._owner.send(Error(request,ERR_BAD_REQUEST)) raise NodeProcessed else: # Jid and session don't match. Go away imposter self._owner.send(Error(request,ERR_BAD_REQUEST)) raise NodeProcessed elif session != None: # Not on this sessionid you won't. self._owner.send(Error(request,ERR_BAD_REQUEST)) raise NodeProcessed else: # New session self.initial[action](conn,request) def _DiscoHandler(self,conn,request,type): """The handler for discovery events""" if type == 'list': return (request.getTo(),self.name,self.description) elif type == 'items': return [] elif type == 'info': return self.discoinfo class TestCommand(Command_Handler_Prototype): """ Example class. You should read source if you wish to understate how it works. Generally, it presents a "master" that giudes user through to calculate something. """ name = 'testcommand' description = 'a noddy example command' def __init__(self,jid=''): """ Init internal constants. """ Command_Handler_Prototype.__init__(self,jid) self.initial = {'execute':self.cmdFirstStage} def cmdFirstStage(self,conn,request): """ Determine """ # This is the only place this should be repeated as all other stages should have SessionIDs try: session = request.getTagAttr('command','sessionid') except: session = None if session == None: session = self.getSessionID() self.sessions[session]={'jid':request.getFrom(),'actions':{'cancel':self.cmdCancel,'next':self.cmdSecondStage,'execute':self.cmdSecondStage},'data':{'type':None}} # As this is the first stage we only send a form reply = request.buildReply('result') form = DataForm(title='Select type of operation',data=['Use the combobox to select the type of calculation you would like to do, then click Next',DataField(name='calctype',desc='Calculation Type',value=self.sessions[session]['data']['type'],options=[['circlediameter','Calculate the Diameter of a circle'],['circlearea','Calculate the area of a circle']],typ='list-single',required=1)]) replypayload = [Node('actions',attrs={'execute':'next'},payload=[Node('next')]),form] reply.addChild(name='command',namespace=NS_COMMANDS,attrs={'node':request.getTagAttr('command','node'),'sessionid':session,'status':'executing'},payload=replypayload) self._owner.send(reply) raise NodeProcessed def cmdSecondStage(self,conn,request): form = DataForm(node = request.getTag(name='command').getTag(name='x',namespace=NS_DATA)) self.sessions[request.getTagAttr('command','sessionid')]['data']['type']=form.getField('calctype').getValue() self.sessions[request.getTagAttr('command','sessionid')]['actions']={'cancel':self.cmdCancel,None:self.cmdThirdStage,'previous':self.cmdFirstStage,'execute':self.cmdThirdStage,'next':self.cmdThirdStage} # The form generation is split out to another method as it may be called by cmdThirdStage self.cmdSecondStageReply(conn,request) def cmdSecondStageReply(self,conn,request): reply = request.buildReply('result') form = DataForm(title = 'Enter the radius', data=['Enter the radius of the circle (numbers only)',DataField(desc='Radius',name='radius',typ='text-single')]) replypayload = [Node('actions',attrs={'execute':'complete'},payload=[Node('complete'),Node('prev')]),form] reply.addChild(name='command',namespace=NS_COMMANDS,attrs={'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'executing'},payload=replypayload) self._owner.send(reply) raise NodeProcessed def cmdThirdStage(self,conn,request): form = DataForm(node = request.getTag(name='command').getTag(name='x',namespace=NS_DATA)) try: num = float(form.getField('radius').getValue()) except: self.cmdSecondStageReply(conn,request) from math import pi if self.sessions[request.getTagAttr('command','sessionid')]['data']['type'] == 'circlearea': result = (num**2)*pi else: result = num*2*pi reply = request.buildReply('result') form = DataForm(typ='result',data=[DataField(desc='result',name='result',value=result)]) reply.addChild(name='command',namespace=NS_COMMANDS,attrs={'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'completed'},payload=[form]) self._owner.send(reply) raise NodeProcessed def cmdCancel(self,conn,request): reply = request.buildReply('result') reply.addChild(name='command',namespace=NS_COMMANDS,attrs={'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'cancelled'}) self._owner.send(reply) del self.sessions[request.getTagAttr('command','sessionid')]
gpl-3.0
[ 309, 2672, 1304, 26, 3718, 14, 647, 12, 86, 413, 14, 1196, 10219, 15, 2036, 15, 1651, 21798, 26, 1477, 26, 1046, 6316, 290, 82, 7910, 2672, 199, 199, 309, 4431, 13, 40, 679, 5817, 5256, 199, 309, 603, 7455, 4580, 13520, 334, 67, 9, 959, 273, 17474, 20527, 11811, 199, 199, 309, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 309, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 309, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 12, 503, 334, 292, 2195, 945, 9, 199, 309, 257, 1263, 2945, 1015, 14, 199, 309, 199, 309, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 309, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 309, 257, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 421, 199, 624, 2765, 859, 365, 282, 1503, 13, 20402, 1414, 12495, 367, 671, 17901, 647, 14, 2779, 4440, 314, 14202, 13, 262, 14729, 2839, 4750, 402, 314, 6170, 3555, 14, 2779, 8350, 641, 282, 7587, 1439, 7042, 5256, 14, 199, 199, 10924, 787, 650, 3992, 2348, 12, 282, 1414, 12495, 5817, 83, 2839, 314, 27620, 12, 436, 282, 1414, 1978, 3589, 5817, 12, 436, 376, 2893, 1414, 14, 199, 199, 1378, 675, 642, 859, 26, 2286, 1010, 9746, 338, 323, 314, 859, 543, 314, 1676, 7773, 436, 2153, 331, 7042, 5256, 465, 2633, 14, 272, 283, 19173, 315, 7, 3718, 1808, 314, 1414, 1978, 14, 272, 710, 1414, 3878, 1471, 506, 3483, 370, 3411, 2153, 331, 1833, 6528, 2382, 302, 825, 5205, 14, 1362, 199, 21015, 652, 4973, 6528, 26, 2286, 9195, 3889, 1414, 10991, 543, 314, 2153, 331, 7042, 5256, 14, 272, 9195, 3889, 13778, 402, 3718, 315, 314, 4575, 1414, 769, 14, 272, 437, 4910, 402, 7252, 4145, 12, 701, 23713, 10617, 314, 1414, 5256, 14, 199, 624, 199, 199, 504, 4113, 492, 627, 199, 504, 1890, 492, 7497, 1518, 607, 199, 199, 533, 5817, 83, 8, 19173, 607, 304, 272, 408, 14680, 365, 376, 18432, 402, 7497, 1518, 607, 436, 883, 506, 10102, 370, 1263, 2351, 14, 2286, 710, 3718, 1021, 6571, 282, 4237, 436, 19249, 562, 11019, 19185, 14, 2779, 11924, 314, 2011, 1979, 6237, 274, 402, 314, 27620, 1021, 12, 367, 7591, 5289, 6913, 370, 5647, 314, 769, 402, 3718, 12, 652, 9584, 314, 283, 513, 7, 2153, 331, 730, 370, 2195, 3411, 2153, 331, 3016, 805, 14, 221, 2286, 7494, 652, 5419, 26, 267, 710, 3718, 787, 3483, 1901, 314, 3411, 27620, 641, 314, 3211, 3380, 14, 3979, 314, 1414, 769, 365, 6137, 314, 6841, 13172, 3016, 805, 4839, 370, 1172, 282, 283, 513, 7, 945, 315, 730, 14, 961, 2066, 7545, 3720, 12601, 12, 1006, 2058, 2138, 465, 488, 787, 5525, 14, 267, 710, 1414, 7934, 365, 2066, 2797, 1808, 652, 1159, 17009, 1083, 14, 2900, 2351, 10041, 365, 8860, 701, 314, 1414, 6337, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 7042, 304, 267, 408, 5733, 1388, 1021, 436, 5951, 1536, 2257, 2860, 624, 267, 7497, 1518, 607, 855, 826, 721, 277, 9, 267, 6249, 39, 63, 6174, 534, 4405, 7, 267, 291, 423, 23028, 63, 2474, 9811, 267, 291, 423, 5586, 3713, 356, 2440, 93, 267, 291, 423, 5750, 275, 7042, 339, 347, 3589, 8, 277, 12, 5771, 304, 267, 408, 27142, 8297, 4453, 314, 2351, 624, 267, 327, 7497, 1518, 1901, 314, 2351, 436, 314, 2153, 331, 5256, 267, 327, 2136, 1454, 1929, 664, 436, 663, 12, 2058, 787, 440, 4346, 701, 282, 2435, 5022, 12, 1454, 282, 2435, 922, 14, 267, 5771, 14, 7099, 2461, 360, 9962, 297, 277, 423, 3110, 2461, 12, 9749, 534, 409, 297, 561, 29, 2709, 63, 28442, 9, 267, 5771, 14, 7099, 2461, 360, 9962, 297, 277, 423, 3110, 2461, 12, 9749, 534, 362, 297, 561, 29, 2709, 63, 28442, 9, 267, 291, 423, 5750, 14, 409, 2825, 331, 2461, 8, 277, 423, 2825, 331, 2461, 12, 932, 29, 2709, 63, 28442, 12, 14203, 13275, 5493, 347, 14202, 548, 8, 277, 304, 267, 408, 22948, 8297, 687, 314, 2351, 624, 267, 327, 625, 19173, 687, 314, 2351, 436, 314, 2153, 331, 5256, 267, 291, 423, 4597, 14, 27419, 2461, 360, 9962, 297, 277, 423, 3110, 2461, 12, 561, 29, 2709, 63, 28442, 9, 267, 367, 21752, 315, 291, 423, 5586, 26, 288, 291, 423, 5750, 14, 2264, 2825, 331, 2461, 8, 277, 423, 2825, 331, 2461, 12, 932, 29, 2709, 63, 28442, 9, 339, 347, 485, 3110, 2461, 8, 277, 12, 1631, 12, 1069, 304, 267, 408, 1918, 5007, 1083, 370, 2112, 314, 14870, 402, 1414, 6451, 4145, 624, 267, 327, 961, 365, 314, 1414, 3016, 6337, 14, 267, 327, 2136, 1471, 26, 267, 327, 257, 8325, 641, 1414, 6451, 370, 1414, 3016, 267, 327, 257, 334, 2585, 781, 1929, 370, 4215, 2351, 2436, 2348, 12, 503, 883, 626, 506, 4224, 315, 314, 1414, 17076, 267, 21752, 275, 620, 8, 1069, 14, 362, 1378, 1012, 267, 862, 26, 288, 1031, 275, 1056, 14, 362, 1931, 7144, 360, 1531, 1673, 932, 358, 267, 871, 26, 288, 2557, 14, 2254, 8, 547, 8, 1069, 12, 2666, 63, 9439, 63, 6780, 430, 288, 746, 5013, 919, 4234, 267, 340, 291, 423, 5586, 14, 1989, 63, 498, 8, 14203, 304, 288, 340, 291, 423, 5586, 59, 14203, 1055, 1989, 63, 498, 8, 932, 304, 355, 291, 423, 5586, 59, 14203, 1527, 932, 2733, 2526, 21407, 1631, 12, 1069, 9, 288, 587, 26, 355, 2557, 14, 2254, 8, 547, 8, 1069, 12, 2666, 63, 10439, 63, 4609, 63, 13945, 430, 355, 746, 5013, 919, 4234, 267, 916, 291, 423, 5586, 459, 2278, 1989, 63, 498, 8, 932, 304, 355, 291, 423, 5586, 459, 3488, 932, 2733, 2526, 21407, 1631, 12, 1069, 9, 267, 587, 26, 288, 2557, 14, 2254, 8, 547, 8, 1069, 12, 2666, 63, 10439, 63, 4609, 63, 13945, 430, 288, 746, 5013, 919, 4234, 339, 347, 485, 2825, 331, 2461, 8, 277, 12, 1631, 12, 1069, 12, 9749, 304, 267, 408 ]
[ 2672, 1304, 26, 3718, 14, 647, 12, 86, 413, 14, 1196, 10219, 15, 2036, 15, 1651, 21798, 26, 1477, 26, 1046, 6316, 290, 82, 7910, 2672, 199, 199, 309, 4431, 13, 40, 679, 5817, 5256, 199, 309, 603, 7455, 4580, 13520, 334, 67, 9, 959, 273, 17474, 20527, 11811, 199, 199, 309, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 309, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 309, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 12, 503, 334, 292, 2195, 945, 9, 199, 309, 257, 1263, 2945, 1015, 14, 199, 309, 199, 309, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 309, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 309, 257, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 421, 199, 624, 2765, 859, 365, 282, 1503, 13, 20402, 1414, 12495, 367, 671, 17901, 647, 14, 2779, 4440, 314, 14202, 13, 262, 14729, 2839, 4750, 402, 314, 6170, 3555, 14, 2779, 8350, 641, 282, 7587, 1439, 7042, 5256, 14, 199, 199, 10924, 787, 650, 3992, 2348, 12, 282, 1414, 12495, 5817, 83, 2839, 314, 27620, 12, 436, 282, 1414, 1978, 3589, 5817, 12, 436, 376, 2893, 1414, 14, 199, 199, 1378, 675, 642, 859, 26, 2286, 1010, 9746, 338, 323, 314, 859, 543, 314, 1676, 7773, 436, 2153, 331, 7042, 5256, 465, 2633, 14, 272, 283, 19173, 315, 7, 3718, 1808, 314, 1414, 1978, 14, 272, 710, 1414, 3878, 1471, 506, 3483, 370, 3411, 2153, 331, 1833, 6528, 2382, 302, 825, 5205, 14, 1362, 199, 21015, 652, 4973, 6528, 26, 2286, 9195, 3889, 1414, 10991, 543, 314, 2153, 331, 7042, 5256, 14, 272, 9195, 3889, 13778, 402, 3718, 315, 314, 4575, 1414, 769, 14, 272, 437, 4910, 402, 7252, 4145, 12, 701, 23713, 10617, 314, 1414, 5256, 14, 199, 624, 199, 199, 504, 4113, 492, 627, 199, 504, 1890, 492, 7497, 1518, 607, 199, 199, 533, 5817, 83, 8, 19173, 607, 304, 272, 408, 14680, 365, 376, 18432, 402, 7497, 1518, 607, 436, 883, 506, 10102, 370, 1263, 2351, 14, 2286, 710, 3718, 1021, 6571, 282, 4237, 436, 19249, 562, 11019, 19185, 14, 2779, 11924, 314, 2011, 1979, 6237, 274, 402, 314, 27620, 1021, 12, 367, 7591, 5289, 6913, 370, 5647, 314, 769, 402, 3718, 12, 652, 9584, 314, 283, 513, 7, 2153, 331, 730, 370, 2195, 3411, 2153, 331, 3016, 805, 14, 221, 2286, 7494, 652, 5419, 26, 267, 710, 3718, 787, 3483, 1901, 314, 3411, 27620, 641, 314, 3211, 3380, 14, 3979, 314, 1414, 769, 365, 6137, 314, 6841, 13172, 3016, 805, 4839, 370, 1172, 282, 283, 513, 7, 945, 315, 730, 14, 961, 2066, 7545, 3720, 12601, 12, 1006, 2058, 2138, 465, 488, 787, 5525, 14, 267, 710, 1414, 7934, 365, 2066, 2797, 1808, 652, 1159, 17009, 1083, 14, 2900, 2351, 10041, 365, 8860, 701, 314, 1414, 6337, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 7042, 304, 267, 408, 5733, 1388, 1021, 436, 5951, 1536, 2257, 2860, 624, 267, 7497, 1518, 607, 855, 826, 721, 277, 9, 267, 6249, 39, 63, 6174, 534, 4405, 7, 267, 291, 423, 23028, 63, 2474, 9811, 267, 291, 423, 5586, 3713, 356, 2440, 93, 267, 291, 423, 5750, 275, 7042, 339, 347, 3589, 8, 277, 12, 5771, 304, 267, 408, 27142, 8297, 4453, 314, 2351, 624, 267, 327, 7497, 1518, 1901, 314, 2351, 436, 314, 2153, 331, 5256, 267, 327, 2136, 1454, 1929, 664, 436, 663, 12, 2058, 787, 440, 4346, 701, 282, 2435, 5022, 12, 1454, 282, 2435, 922, 14, 267, 5771, 14, 7099, 2461, 360, 9962, 297, 277, 423, 3110, 2461, 12, 9749, 534, 409, 297, 561, 29, 2709, 63, 28442, 9, 267, 5771, 14, 7099, 2461, 360, 9962, 297, 277, 423, 3110, 2461, 12, 9749, 534, 362, 297, 561, 29, 2709, 63, 28442, 9, 267, 291, 423, 5750, 14, 409, 2825, 331, 2461, 8, 277, 423, 2825, 331, 2461, 12, 932, 29, 2709, 63, 28442, 12, 14203, 13275, 5493, 347, 14202, 548, 8, 277, 304, 267, 408, 22948, 8297, 687, 314, 2351, 624, 267, 327, 625, 19173, 687, 314, 2351, 436, 314, 2153, 331, 5256, 267, 291, 423, 4597, 14, 27419, 2461, 360, 9962, 297, 277, 423, 3110, 2461, 12, 561, 29, 2709, 63, 28442, 9, 267, 367, 21752, 315, 291, 423, 5586, 26, 288, 291, 423, 5750, 14, 2264, 2825, 331, 2461, 8, 277, 423, 2825, 331, 2461, 12, 932, 29, 2709, 63, 28442, 9, 339, 347, 485, 3110, 2461, 8, 277, 12, 1631, 12, 1069, 304, 267, 408, 1918, 5007, 1083, 370, 2112, 314, 14870, 402, 1414, 6451, 4145, 624, 267, 327, 961, 365, 314, 1414, 3016, 6337, 14, 267, 327, 2136, 1471, 26, 267, 327, 257, 8325, 641, 1414, 6451, 370, 1414, 3016, 267, 327, 257, 334, 2585, 781, 1929, 370, 4215, 2351, 2436, 2348, 12, 503, 883, 626, 506, 4224, 315, 314, 1414, 17076, 267, 21752, 275, 620, 8, 1069, 14, 362, 1378, 1012, 267, 862, 26, 288, 1031, 275, 1056, 14, 362, 1931, 7144, 360, 1531, 1673, 932, 358, 267, 871, 26, 288, 2557, 14, 2254, 8, 547, 8, 1069, 12, 2666, 63, 9439, 63, 6780, 430, 288, 746, 5013, 919, 4234, 267, 340, 291, 423, 5586, 14, 1989, 63, 498, 8, 14203, 304, 288, 340, 291, 423, 5586, 59, 14203, 1055, 1989, 63, 498, 8, 932, 304, 355, 291, 423, 5586, 59, 14203, 1527, 932, 2733, 2526, 21407, 1631, 12, 1069, 9, 288, 587, 26, 355, 2557, 14, 2254, 8, 547, 8, 1069, 12, 2666, 63, 10439, 63, 4609, 63, 13945, 430, 355, 746, 5013, 919, 4234, 267, 916, 291, 423, 5586, 459, 2278, 1989, 63, 498, 8, 932, 304, 355, 291, 423, 5586, 459, 3488, 932, 2733, 2526, 21407, 1631, 12, 1069, 9, 267, 587, 26, 288, 2557, 14, 2254, 8, 547, 8, 1069, 12, 2666, 63, 10439, 63, 4609, 63, 13945, 430, 288, 746, 5013, 919, 4234, 339, 347, 485, 2825, 331, 2461, 8, 277, 12, 1631, 12, 1069, 12, 9749, 304, 267, 408, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yl565/statsmodels
statsmodels/stats/contingency_tables.py
4
43623
""" Methods for analyzing two-way contingency tables (i.e. frequency tables for observations that are cross-classified with respect to two categorical variables). The main classes are: * Table : implements methods that can be applied to any two-way contingency table. * SquareTable : implements methods that can be applied to a square two-way contingency table. * Table2x2 : implements methods that can be applied to a 2x2 contingency table. * StratifiedTable : implements methods that can be applied to a collection of contingency tables. Also contains functions for conducting Mcnemar's test and Cochran's q test. Note that the inference procedures may depend on how the data were sampled. In general the observed units are independent and identically distributed. """ from __future__ import division from statsmodels.tools.decorators import cache_readonly, resettable_cache import numpy as np from scipy import stats import pandas as pd from statsmodels import iolib from statsmodels.tools.sm_exceptions import SingularMatrixWarning def _make_df_square(table): """ Reindex a pandas DataFrame so that it becomes square, meaning that the row and column indices contain the same values, in the same order. The row and column index are extended to achieve this. """ if not isinstance(table, pd.DataFrame): return table # If the table is not square, make it square if table.shape[0] != table.shape[1]: ix = list(set(table.index) | set(table.columns)) table = table.reindex(ix, axis=0) table = table.reindex(ix, axis=1) # Ensures that the rows and columns are in the same order. table = table.reindex(table.columns) return table class _Bunch(object): def __repr__(self): return "<bunch object containing statsmodels results>" class Table(object): """ Analyses that can be performed on a two-way contingency table. Parameters ---------- table : array-like A contingency table. shift_zeros : boolean If True and any cell count is zero, add 0.5 to all values in the table. Attributes ---------- table_orig : array-like The original table is cached as `table_orig`. marginal_probabilities : tuple of two ndarrays The estimated row and column marginal distributions. independence_probabilities : ndarray Estimated cell probabilities under row/column independence. fittedvalues : ndarray Fitted values under independence. resid_pearson : ndarray The Pearson residuals under row/column independence. standardized_resids : ndarray Residuals for the independent row/column model with approximate unit variance. chi2_contribs : ndarray The contribution of each cell to the chi^2 statistic. local_logodds_ratios : ndarray The local log odds ratios are calculated for each 2x2 subtable formed from adjacent rows and columns. local_oddsratios : ndarray The local odds ratios are calculated from each 2x2 subtable formed from adjacent rows and columns. cumulative_log_oddsratios : ndarray The cumulative log odds ratio at a given pair of thresholds is calculated by reducing the table to a 2x2 table based on dichotomizing the rows and columns at the given thresholds. The table of cumulative log odds ratios presents all possible cumulative log odds ratios that can be formed from a given table. cumulative_oddsratios : ndarray The cumulative odds ratios are calculated by reducing the table to a 2x2 table based on cutting the rows and columns at a given point. The table of cumulative odds ratios presents all possible cumulative odds ratios that can be formed from a given table. See also -------- statsmodels.graphics.mosaicplot.mosaic scipy.stats.chi2_contingency Notes ----- The inference procedures used here are all based on a sampling model in which the units are independent and identically distributed, with each unit being classified with respect to two categorical variables. References ---------- Definitions of residuals: https://onlinecourses.science.psu.edu/stat504/node/86 """ def __init__(self, table, shift_zeros=True): self.table_orig = table self.table = np.asarray(table, dtype=np.float64) if shift_zeros and (self.table.min() == 0): self.table = self.table + 0.5 @classmethod def from_data(cls, data, shift_zeros=True): """ Construct a Table object from data. Parameters ---------- data : array-like The raw data, from which a contingency table is constructed using the first two columns. shift_zeros : boolean If True and any cell count is zero, add 0.5 to all values in the table. Returns ------- A Table instance. """ if isinstance(data, pd.DataFrame): table = pd.crosstab(data.iloc[:, 0], data.iloc[:, 1]) else: table = pd.crosstab(data[:, 0], data[:, 1]) return cls(table, shift_zeros) def test_nominal_association(self): """ Assess independence for nominal factors. Assessment of independence between rows and columns using chi^2 testing. The rows and columns are treated as nominal (unordered) categorical variables. Returns ------- A bunch containing the following attributes: statistic : float The chi^2 test statistic. df : integer The degrees of freedom of the reference distribution pvalue : float The p-value for the test. """ statistic = np.asarray(self.chi2_contribs).sum() df = np.prod(np.asarray(self.table.shape) - 1) pvalue = 1 - stats.chi2.cdf(statistic, df) b = _Bunch() b.statistic = statistic b.df = df b.pvalue = pvalue return b def test_ordinal_association(self, row_scores=None, col_scores=None): """ Assess independence between two ordinal variables. This is the 'linear by linear' association test, which uses weights or scores to target the test to have more power against ordered alternatives. Parameters ---------- row_scores : array-like An array of numeric row scores col_scores : array-like An array of numeric column scores Returns ------- A bunch with the following attributes: statistic : float The test statistic. null_mean : float The expected value of the test statistic under the null hypothesis. null_sd : float The standard deviation of the test statistic under the null hypothesis. zscore : float The Z-score for the test statistic. pvalue : float The p-value for the test. Notes ----- The scores define the trend to which the test is most sensitive. Using the default row and column scores gives the Cochran-Armitage trend test. """ if row_scores is None: row_scores = np.arange(self.table.shape[0]) if col_scores is None: col_scores = np.arange(self.table.shape[1]) if len(row_scores) != self.table.shape[0]: raise ValueError("The length of `row_scores` must match the first dimension of `table`.") if len(col_scores) != self.table.shape[1]: raise ValueError("The length of `col_scores` must match the second dimension of `table`.") # The test statistic statistic = np.dot(row_scores, np.dot(self.table, col_scores)) # Some needed quantities n_obs = self.table.sum() rtot = self.table.sum(1) um = np.dot(row_scores, rtot) u2m = np.dot(row_scores**2, rtot) ctot = self.table.sum(0) vn = np.dot(col_scores, ctot) v2n = np.dot(col_scores**2, ctot) # The null mean and variance of the test statistic e_stat = um * vn / n_obs v_stat = (u2m - um**2 / n_obs) * (v2n - vn**2 / n_obs) / (n_obs - 1) sd_stat = np.sqrt(v_stat) zscore = (statistic - e_stat) / sd_stat pvalue = 2 * stats.norm.cdf(-np.abs(zscore)) b = _Bunch() b.statistic = statistic b.null_mean = e_stat b.null_sd = sd_stat b.zscore = zscore b.pvalue = pvalue return b @cache_readonly def marginal_probabilities(self): # docstring for cached attributes in init above n = self.table.sum() row = self.table.sum(1) / n col = self.table.sum(0) / n if isinstance(self.table_orig, pd.DataFrame): row = pd.Series(row, self.table_orig.index) col = pd.Series(col, self.table_orig.columns) return row, col @cache_readonly def independence_probabilities(self): # docstring for cached attributes in init above row, col = self.marginal_probabilities itab = np.outer(row, col) if isinstance(self.table_orig, pd.DataFrame): itab = pd.DataFrame(itab, self.table_orig.index, self.table_orig.columns) return itab @cache_readonly def fittedvalues(self): # docstring for cached attributes in init above probs = self.independence_probabilities fit = self.table.sum() * probs return fit @cache_readonly def resid_pearson(self): # docstring for cached attributes in init above fit = self.fittedvalues resids = (self.table - fit) / np.sqrt(fit) return resids @cache_readonly def standardized_resids(self): # docstring for cached attributes in init above row, col = self.marginal_probabilities sresids = self.resid_pearson / np.sqrt(np.outer(1 - row, 1 - col)) return sresids @cache_readonly def chi2_contribs(self): # docstring for cached attributes in init above return self.resid_pearson**2 @cache_readonly def local_log_oddsratios(self): # docstring for cached attributes in init above ta = self.table.copy() a = ta[0:-1, 0:-1] b = ta[0:-1, 1:] c = ta[1:, 0:-1] d = ta[1:, 1:] tab = np.log(a) + np.log(d) - np.log(b) - np.log(c) rslt = np.empty(self.table.shape, np.float64) rslt *= np.nan rslt[0:-1, 0:-1] = tab if isinstance(self.table_orig, pd.DataFrame): rslt = pd.DataFrame(rslt, index=self.table_orig.index, columns=self.table_orig.columns) return rslt @cache_readonly def local_oddsratios(self): # docstring for cached attributes in init above return np.exp(self.local_log_oddsratios) @cache_readonly def cumulative_log_oddsratios(self): # docstring for cached attributes in init above ta = self.table.cumsum(0).cumsum(1) a = ta[0:-1, 0:-1] b = ta[0:-1, -1:] - a c = ta[-1:, 0:-1] - a d = ta[-1, -1] - (a + b + c) tab = np.log(a) + np.log(d) - np.log(b) - np.log(c) rslt = np.empty(self.table.shape, np.float64) rslt *= np.nan rslt[0:-1, 0:-1] = tab if isinstance(self.table_orig, pd.DataFrame): rslt = pd.DataFrame(rslt, index=self.table_orig.index, columns=self.table_orig.columns) return rslt @cache_readonly def cumulative_oddsratios(self): # docstring for cached attributes in init above return np.exp(self.cumulative_log_oddsratios) class SquareTable(Table): """ Methods for analyzing a square contingency table. Parameters ---------- table : array-like A square contingency table, or DataFrame that is converted to a square form. shift_zeros : boolean If True and any cell count is zero, add 0.5 to all values in the table. These methods should only be used when the rows and columns of the table have the same categories. If `table` is provided as a Pandas DataFrame, the row and column indices will be extended to create a square table. Otherwise the table should be provided in a square form, with the (implicit) row and column categories appearing in the same order. """ def __init__(self, table, shift_zeros=True): table = _make_df_square(table) # Non-pandas passes through k1, k2 = table.shape if k1 != k2: raise ValueError('table must be square') super(SquareTable, self).__init__(table, shift_zeros) def symmetry(self, method="bowker"): """ Test for symmetry of a joint distribution. This procedure tests the null hypothesis that the joint distribution is symmetric around the main diagonal, that is .. math:: p_{i, j} = p_{j, i} for all i, j Returns ------- A bunch with attributes: statistic : float chisquare test statistic p-value : float p-value of the test statistic based on chisquare distribution df : int degrees of freedom of the chisquare distribution Notes ----- The implementation is based on the SAS documentation. R includes it in `mcnemar.test` if the table is not 2 by 2. However a more direct generalization of the McNemar test to larger tables is provided by the homogeneity test (TableSymmetry.homogeneity). The p-value is based on the chi-square distribution which requires that the sample size is not very small to be a good approximation of the true distribution. For 2x2 contingency tables the exact distribution can be obtained with `mcnemar` See Also -------- mcnemar homogeneity """ if method.lower() != "bowker": raise ValueError("method for symmetry testing must be 'bowker'") k = self.table.shape[0] upp_idx = np.triu_indices(k, 1) tril = self.table.T[upp_idx] # lower triangle in column order triu = self.table[upp_idx] # upper triangle in row order statistic = ((tril - triu)**2 / (tril + triu + 1e-20)).sum() df = k * (k-1) / 2. pvalue = stats.chi2.sf(statistic, df) b = _Bunch() b.statistic = statistic b.pvalue = pvalue b.df = df return b def homogeneity(self, method="stuart_maxwell"): """ Compare row and column marginal distributions. Parameters ---------- method : string Either 'stuart_maxwell' or 'bhapkar', leading to two different estimates of the covariance matrix for the estimated difference between the row margins and the column margins. Returns a bunch with attributes: statistic : float The chi^2 test statistic pvalue : float The p-value of the test statistic df : integer The degrees of freedom of the reference distribution Notes ----- For a 2x2 table this is equivalent to McNemar's test. More generally the procedure tests the null hypothesis that the marginal distribution of the row factor is equal to the marginal distribution of the column factor. For this to be meaningful, the two factors must have the same sample space (i.e. the same categories). """ if self.table.shape[0] < 1: raise ValueError('table is empty') elif self.table.shape[0] == 1: b = _Bunch() b.statistic = 0 b.pvalue = 1 b.df = 0 return b method = method.lower() if method not in ["bhapkar", "stuart_maxwell"]: raise ValueError("method '%s' for homogeneity not known" % method) n_obs = self.table.sum() pr = self.table.astype(np.float64) / n_obs # Compute margins, eliminate last row/column so there is no # degeneracy row = pr.sum(1)[0:-1] col = pr.sum(0)[0:-1] pr = pr[0:-1, 0:-1] # The estimated difference between row and column margins. d = col - row # The degrees of freedom of the chi^2 reference distribution. df = pr.shape[0] if method == "bhapkar": vmat = -(pr + pr.T) - np.outer(d, d) dv = col + row - 2*np.diag(pr) - d**2 np.fill_diagonal(vmat, dv) elif method == "stuart_maxwell": vmat = -(pr + pr.T) dv = row + col - 2*np.diag(pr) np.fill_diagonal(vmat, dv) try: statistic = n_obs * np.dot(d, np.linalg.solve(vmat, d)) except np.linalg.LinAlgError: import warnings warnings.warn("Unable to invert covariance matrix", SingularMatrixWarning) b = _Bunch() b.statistic = np.nan b.pvalue = np.nan b.df = df return b pvalue = 1 - stats.chi2.cdf(statistic, df) b = _Bunch() b.statistic = statistic b.pvalue = pvalue b.df = df return b def summary(self, alpha=0.05, float_format="%.3f"): """ Produce a summary of the analysis. Parameters ---------- alpha : float `1 - alpha` is the nominal coverage probability of the interval. float_format : string Used to format numeric values in the table. method : string The method for producing the confidence interval. Currently must be 'normal' which uses the normal approximation. """ fmt = float_format headers = ["Statistic", "P-value", "DF"] stubs = ["Symmetry", "Homogeneity"] sy = self.symmetry() hm = self.homogeneity() data = [[fmt % sy.statistic, fmt % sy.pvalue, '%d' % sy.df], [fmt % hm.statistic, fmt % hm.pvalue, '%d' % hm.df]] tab = iolib.SimpleTable(data, headers, stubs, data_aligns="r", table_dec_above='') return tab class Table2x2(SquareTable): """ Analyses that can be performed on a 2x2 contingency table. Parameters ---------- table : array-like A 2x2 contingency table shift_zeros : boolean If true, 0.5 is added to all cells of the table if any cell is equal to zero. Attributes ---------- log_oddsratio : float The log odds ratio of the table. log_oddsratio_se : float The asymptotic standard error of the estimated log odds ratio. oddsratio : float The odds ratio of the table. riskratio : float The ratio between the risk in the first row and the risk in the second row. Column 0 is interpreted as containing the number of occurences of the event of interest. log_riskratio : float The estimated log risk ratio for the table. log_riskratio_se : float The standard error of the estimated log risk ratio for the table. Notes ----- The inference procedures used here are all based on a sampling model in which the units are independent and identically distributed, with each unit being classified with respect to two categorical variables. Note that for the risk ratio, the analysis is not symmetric with respect to the rows and columns of the contingency table. The two rows define population subgroups, column 0 is the number of 'events', and column 1 is the number of 'non-events'. """ def __init__(self, table, shift_zeros=True): if (table.ndim != 2) or (table.shape[0] != 2) or (table.shape[1] != 2): raise ValueError("Table2x2 takes a 2x2 table as input.") super(Table2x2, self).__init__(table, shift_zeros) @classmethod def from_data(cls, data, shift_zeros=True): """ Construct a Table object from data. Parameters ---------- data : array-like The raw data, the first column defines the rows and the second column defines the columns. shift_zeros : boolean If True, and if there are any zeros in the contingency table, add 0.5 to all four cells of the table. """ if isinstance(data, pd.DataFrame): table = pd.crosstab(data.iloc[:, 0], data.iloc[:, 1]) else: table = pd.crosstab(data[:, 0], data[:, 1]) return cls(table, shift_zeros) @cache_readonly def log_oddsratio(self): # docstring for cached attributes in init above f = self.table.flatten() return np.dot(np.log(f), np.r_[1, -1, -1, 1]) @cache_readonly def oddsratio(self): # docstring for cached attributes in init above return self.table[0, 0] * self.table[1, 1] / (self.table[0, 1] * self.table[1, 0]) @cache_readonly def log_oddsratio_se(self): # docstring for cached attributes in init above return np.sqrt(np.sum(1 / self.table)) def oddsratio_pvalue(self, null=1): """ P-value for a hypothesis test about the odds ratio. Parameters ---------- null : float The null value of the odds ratio. """ return self.log_oddsratio_pvalue(np.log(null)) def log_oddsratio_pvalue(self, null=0): """ P-value for a hypothesis test about the log odds ratio. Parameters ---------- null : float The null value of the log odds ratio. """ zscore = (self.log_oddsratio - null) / self.log_oddsratio_se pvalue = 2 * stats.norm.cdf(-np.abs(zscore)) return pvalue def log_oddsratio_confint(self, alpha=0.05, method="normal"): """ A confidence level for the log odds ratio. Parameters ---------- alpha : float `1 - alpha` is the nominal coverage probability of the confidence interval. method : string The method for producing the confidence interval. Currently must be 'normal' which uses the normal approximation. """ f = -stats.norm.ppf(alpha / 2) lor = self.log_oddsratio se = self.log_oddsratio_se lcb = lor - f * se ucb = lor + f * se return lcb, ucb def oddsratio_confint(self, alpha=0.05, method="normal"): """ A confidence interval for the odds ratio. Parameters ---------- alpha : float `1 - alpha` is the nominal coverage probability of the confidence interval. method : string The method for producing the confidence interval. Currently must be 'normal' which uses the normal approximation. """ lcb, ucb = self.log_oddsratio_confint(alpha, method=method) return np.exp(lcb), np.exp(ucb) @cache_readonly def riskratio(self): # docstring for cached attributes in init above p = self.table[:, 0] / self.table.sum(1) return p[0] / p[1] @cache_readonly def log_riskratio(self): # docstring for cached attributes in init above return np.log(self.riskratio) @cache_readonly def log_riskratio_se(self): # docstring for cached attributes in init above n = self.table.sum(1) p = self.table[:, 0] / n va = np.sum((1 - p) / (n*p)) return np.sqrt(va) def riskratio_pvalue(self, null=1): """ p-value for a hypothesis test about the risk ratio. Parameters ---------- null : float The null value of the risk ratio. """ return self.log_riskratio_pvalue(np.log(null)) def log_riskratio_pvalue(self, null=0): """ p-value for a hypothesis test about the log risk ratio. Parameters ---------- null : float The null value of the log risk ratio. """ zscore = (self.log_riskratio - null) / self.log_riskratio_se pvalue = 2 * stats.norm.cdf(-np.abs(zscore)) return pvalue def log_riskratio_confint(self, alpha=0.05, method="normal"): """ A confidence interval for the log risk ratio. Parameters ---------- alpha : float `1 - alpha` is the nominal coverage probability of the confidence interval. method : string The method for producing the confidence interval. Currently must be 'normal' which uses the normal approximation. """ f = -stats.norm.ppf(alpha / 2) lrr = self.log_riskratio se = self.log_riskratio_se lcb = lrr - f * se ucb = lrr + f * se return lcb, ucb def riskratio_confint(self, alpha=0.05, method="normal"): """ A confidence interval for the risk ratio. Parameters ---------- alpha : float `1 - alpha` is the nominal coverage probability of the confidence interval. method : string The method for producing the confidence interval. Currently must be 'normal' which uses the normal approximation. """ lcb, ucb = self.log_riskratio_confint(alpha, method=method) return np.exp(lcb), np.exp(ucb) def summary(self, alpha=0.05, float_format="%.3f", method="normal"): """ Summarizes results for a 2x2 table analysis. Parameters ---------- alpha : float `1 - alpha` is the nominal coverage probability of the confidence intervals. float_format : string Used to format the numeric values in the table. method : string The method for producing the confidence interval. Currently must be 'normal' which uses the normal approximation. """ def fmt(x): if type(x) is str: return x return float_format % x headers = ["Estimate", "SE", "LCB", "UCB", "p-value"] stubs = ["Odds ratio", "Log odds ratio", "Risk ratio", "Log risk ratio"] lcb1, ucb1 = self.oddsratio_confint(alpha, method) lcb2, ucb2 = self.log_oddsratio_confint(alpha, method) lcb3, ucb3 = self.riskratio_confint(alpha, method) lcb4, ucb4 = self.log_riskratio_confint(alpha, method) data = [[fmt(x) for x in [self.oddsratio, "", lcb1, ucb1, self.oddsratio_pvalue()]], [fmt(x) for x in [self.log_oddsratio, self.log_oddsratio_se, lcb2, ucb2, self.oddsratio_pvalue()]], [fmt(x) for x in [self.riskratio, "", lcb2, ucb2, self.riskratio_pvalue()]], [fmt(x) for x in [self.log_riskratio, self.log_riskratio_se, lcb4, ucb4, self.riskratio_pvalue()]]] tab = iolib.SimpleTable(data, headers, stubs, data_aligns="r", table_dec_above='') return tab class StratifiedTable(object): """ Analyses for a collection of 2x2 contingency tables. Such a collection may arise by stratifying a single 2x2 table with respect to another factor. This class implements the 'Cochran-Mantel-Haenszel' and 'Breslow-Day' procedures for analyzing collections of 2x2 contingency tables. Parameters ---------- tables : list or ndarray Either a list containing several 2x2 contingency tables, or a 2x2xk ndarray in which each slice along the third axis is a 2x2 contingency table. Attributes ---------- logodds_pooled : float An estimate of the pooled log odds ratio. This is the Mantel-Haenszel estimate of an odds ratio that is common to all the tables. log_oddsratio_se : float The estimated standard error of the pooled log odds ratio, following Robins, Breslow and Greenland (Biometrics 42:311-323). oddsratio_pooled : float An estimate of the pooled odds ratio. This is the Mantel-Haenszel estimate of an odds ratio that is common to all tables. risk_pooled : float An estimate of the pooled risk ratio. This is an estimate of a risk ratio that is common to all the tables. Notes ----- This results are based on a sampling model in which the units are independent both within and between strata. """ def __init__(self, tables, shift_zeros=False): if isinstance(tables, np.ndarray): sp = tables.shape if (len(sp) != 3) or (sp[0] != 2) or (sp[1] != 2): raise ValueError("If an ndarray, argument must be 2x2xn") table = tables else: # Create a data cube table = np.dstack(tables).astype(np.float64) if shift_zeros: zx = (table == 0).sum(0).sum(0) ix = np.flatnonzero(zx > 0) if len(ix) > 0: table = table.copy() table[:, :, ix] += 0.5 self.table = table self._cache = resettable_cache() # Quantities to precompute. Table entries are [[a, b], [c, # d]], 'ad' is 'a * d', 'apb' is 'a + b', 'dma' is 'd - a', # etc. self._apb = table[0, 0, :] + table[0, 1, :] self._apc = table[0, 0, :] + table[1, 0, :] self._bpd = table[0, 1, :] + table[1, 1, :] self._cpd = table[1, 0, :] + table[1, 1, :] self._ad = table[0, 0, :] * table[1, 1, :] self._bc = table[0, 1, :] * table[1, 0, :] self._apd = table[0, 0, :] + table[1, 1, :] self._dma = table[1, 1, :] - table[0, 0, :] self._n = table.sum(0).sum(0) @classmethod def from_data(cls, var1, var2, strata, data): """ Construct a StratifiedTable object from data. Parameters ---------- var1 : int or string The column index or name of `data` containing the variable defining the rows of the contingency table. The variable must have only two distinct values. var2 : int or string The column index or name of `data` containing the variable defining the columns of the contingency table. The variable must have only two distinct values. strata : int or string The column index of name of `data` containing the variable defining the strata. data : array-like The raw data. A cross-table for analysis is constructed from the first two columns. Returns ------- A StratifiedTable instance. """ if not isinstance(data, pd.DataFrame): data1 = pd.DataFrame(index=data.index, column=[var1, var2, strata]) data1.loc[:, var1] = data[:, var1] data1.loc[:, var2] = data[:, var2] data1.loc[:, strata] = data[:, strata] else: data1 = data[[var1, var2, strata]] gb = data1.groupby(strata).groups tables = [] for g in gb: ii = gb[g] tab = pd.crosstab(data1.loc[ii, var1], data1.loc[ii, var2]) tables.append(tab) return cls(tables) def test_null_odds(self, correction=False): """ Test that all tables have odds ratio equal to 1. This is the 'Mantel-Haenszel' test. Parameters ---------- correction : boolean If True, use the continuity correction when calculating the test statistic. Returns ------- A bunch containing the chi^2 test statistic and p-value. """ statistic = np.sum(self.table[0, 0, :] - self._apb * self._apc / self._n) statistic = np.abs(statistic) if correction: statistic -= 0.5 statistic = statistic**2 denom = self._apb * self._apc * self._bpd * self._cpd denom /= (self._n**2 * (self._n - 1)) denom = np.sum(denom) statistic /= denom # df is always 1 pvalue = 1 - stats.chi2.cdf(statistic, 1) b = _Bunch() b.statistic = statistic b.pvalue = pvalue return b @cache_readonly def oddsratio_pooled(self): # doc for cached attributes in init above odds_ratio = np.sum(self._ad / self._n) / np.sum(self._bc / self._n) return odds_ratio @cache_readonly def logodds_pooled(self): # doc for cached attributes in init above return np.log(self.oddsratio_pooled) @cache_readonly def risk_pooled(self): # doc for cached attributes in init above acd = self.table[0, 0, :] * self._cpd cab = self.table[1, 0, :] * self._apb rr = np.sum(acd / self._n) / np.sum(cab / self._n) return rr @cache_readonly def logodds_pooled_se(self): # doc for cached attributes in init above adns = np.sum(self._ad / self._n) bcns = np.sum(self._bc / self._n) lor_va = np.sum(self._apd * self._ad / self._n**2) / adns**2 mid = self._apd * self._bc / self._n**2 mid += (1 - self._apd / self._n) * self._ad / self._n mid = np.sum(mid) mid /= (adns * bcns) lor_va += mid lor_va += np.sum((1 - self._apd / self._n) * self._bc / self._n) / bcns**2 lor_va /= 2 lor_se = np.sqrt(lor_va) return lor_se def logodds_pooled_confint(self, alpha=0.05, method="normal"): """ A confidence interval for the pooled log odds ratio. Parameters ---------- alpha : float `1 - alpha` is the nominal coverage probability of the interval. method : string The method for producing the confidence interval. Currently must be 'normal' which uses the normal approximation. Returns ------- lcb : float The lower confidence limit. ucb : float The upper confidence limit. """ lor = np.log(self.oddsratio_pooled) lor_se = self.logodds_pooled_se f = -stats.norm.ppf(alpha / 2) lcb = lor - f * lor_se ucb = lor + f * lor_se return lcb, ucb def oddsratio_pooled_confint(self, alpha=0.05, method="normal"): """ A confidence interval for the pooled odds ratio. Parameters ---------- alpha : float `1 - alpha` is the nominal coverage probability of the interval. method : string The method for producing the confidence interval. Currently must be 'normal' which uses the normal approximation. Returns ------- lcb : float The lower confidence limit. ucb : float The upper confidence limit. """ lcb, ucb = self.logodds_pooled_confint(alpha, method=method) lcb = np.exp(lcb) ucb = np.exp(ucb) return lcb, ucb def test_equal_odds(self, adjust=False): """ Test that all odds ratios are identical. This is the 'Breslow-Day' testing procedure. Parameters ---------- adjust : boolean Use the 'Tarone' adjustment to achieve the chi^2 asymptotic distribution. Returns ------- A bunch containing the following attributes: statistic : float The chi^2 test statistic. p-value : float The p-value for the test. """ table = self.table r = self.oddsratio_pooled a = 1 - r b = r * (self._apb + self._apc) + self._dma c = -r * self._apb * self._apc # Expected value of first cell e11 = (-b + np.sqrt(b**2 - 4*a*c)) / (2*a) # Variance of the first cell v11 = 1 / e11 + 1 / (self._apc - e11) + 1 / (self._apb - e11) + 1 / (self._dma + e11) v11 = 1 / v11 statistic = np.sum((table[0, 0, :] - e11)**2 / v11) if adjust: adj = table[0, 0, :].sum() - e11.sum() adj = adj**2 adj /= np.sum(v11) statistic -= adj pvalue = 1 - stats.chi2.cdf(statistic, table.shape[2] - 1) b = _Bunch() b.statistic = statistic b.pvalue = pvalue return b def summary(self, alpha=0.05, float_format="%.3f", method="normal"): """ A summary of all the main results. Parameters ---------- alpha : float `1 - alpha` is the nominal coverage probability of the confidence intervals. float_format : string Used for formatting numeric values in the summary. method : string The method for producing the confidence interval. Currently must be 'normal' which uses the normal approximation. """ def fmt(x): if type(x) is str: return x return float_format % x co_lcb, co_ucb = self.oddsratio_pooled_confint(alpha=alpha, method=method) clo_lcb, clo_ucb = self.logodds_pooled_confint(alpha=alpha, method=method) headers = ["Estimate", "LCB", "UCB"] stubs = ["Pooled odds", "Pooled log odds", "Pooled risk ratio", ""] data = [[fmt(x) for x in [self.oddsratio_pooled, co_lcb, co_ucb]], [fmt(x) for x in [self.logodds_pooled, clo_lcb, clo_ucb]], [fmt(x) for x in [self.risk_pooled, "", ""]], ['', '', '']] tab1 = iolib.SimpleTable(data, headers, stubs, data_aligns="r", table_dec_above='') headers = ["Statistic", "P-value", ""] stubs = ["Test of OR=1", "Test constant OR"] rslt1 = self.test_null_odds() rslt2 = self.test_equal_odds() data = [[fmt(x) for x in [rslt1.statistic, rslt1.pvalue, ""]], [fmt(x) for x in [rslt2.statistic, rslt2.pvalue, ""]]] tab2 = iolib.SimpleTable(data, headers, stubs, data_aligns="r") tab1.extend(tab2) headers = ["", "", ""] stubs = ["Number of tables", "Min n", "Max n", "Avg n", "Total n"] ss = self.table.sum(0).sum(0) data = [["%d" % self.table.shape[2], '', ''], ["%d" % min(ss), '', ''], ["%d" % max(ss), '', ''], ["%.0f" % np.mean(ss), '', ''], ["%d" % sum(ss), '', '', '']] tab3 = iolib.SimpleTable(data, headers, stubs, data_aligns="r") tab1.extend(tab3) return tab1 def mcnemar(table, exact=True, correction=True): """ McNemar test of homogeneity. Parameters ---------- table : array-like A square contingency table. exact : bool If exact is true, then the binomial distribution will be used. If exact is false, then the chisquare distribution will be used, which is the approximation to the distribution of the test statistic for large sample sizes. correction : bool If true, then a continuity correction is used for the chisquare distribution (if exact is false.) Returns ------- A bunch with attributes: statistic : float or int, array The test statistic is the chisquare statistic if exact is false. If the exact binomial distribution is used, then this contains the min(n1, n2), where n1, n2 are cases that are zero in one sample but one in the other sample. pvalue : float or array p-value of the null hypothesis of equal marginal distributions. Notes ----- This is a special case of Cochran's Q test, and of the homogeneity test. The results when the chisquare distribution is used are identical, except for continuity correction. """ table = _make_df_square(table) table = np.asarray(table, dtype=np.float64) n1, n2 = table[0, 1], table[1, 0] if exact: statistic = np.minimum(n1, n2) # binom is symmetric with p=0.5 pvalue = stats.binom.cdf(statistic, n1 + n2, 0.5) * 2 pvalue = np.minimum(pvalue, 1) # limit to 1 if n1==n2 else: corr = int(correction) # convert bool to 0 or 1 statistic = (np.abs(n1 - n2) - corr)**2 / (1. * (n1 + n2)) df = 1 pvalue = stats.chi2.sf(statistic, df) b = _Bunch() b.statistic = statistic b.pvalue = pvalue return b def cochrans_q(x, return_object=True): """ Cochran's Q test for identical binomial proportions. Parameters ---------- x : array_like, 2d (N, k) data with N cases and k variables return_object : boolean Return values as bunch instead of as individual values. Returns ------- Returns a bunch containing the following attributes, or the individual values according to the value of `return_object`. statistic : float test statistic pvalue : float pvalue from the chisquare distribution Notes ----- Cochran's Q is a k-sample extension of the McNemar test. If there are only two groups, then Cochran's Q test and the McNemar test are equivalent. The procedure tests that the probability of success is the same for every group. The alternative hypothesis is that at least two groups have a different probability of success. In Wikipedia terminology, rows are blocks and columns are treatments. The number of rows N, should be large for the chisquare distribution to be a good approximation. The Null hypothesis of the test is that all treatments have the same effect. References ---------- http://en.wikipedia.org/wiki/Cochran_test SAS Manual for NPAR TESTS """ x = np.asarray(x, dtype=np.float64) gruni = np.unique(x) N, k = x.shape count_row_success = (x == gruni[-1]).sum(1, float) count_col_success = (x == gruni[-1]).sum(0, float) count_row_ss = count_row_success.sum() count_col_ss = count_col_success.sum() assert count_row_ss == count_col_ss #just a calculation check # From the SAS manual q_stat = (k-1) * (k * np.sum(count_col_success**2) - count_col_ss**2) \ / (k * count_row_ss - np.sum(count_row_success**2)) # Note: the denominator looks just like k times the variance of # the columns # Wikipedia uses a different, but equivalent expression #q_stat = (k-1) * (k * np.sum(count_row_success**2) - count_row_ss**2) \ # / (k * count_col_ss - np.sum(count_col_success**2)) df = k - 1 pvalue = stats.chi2.sf(q_stat, df) if return_object: b = _Bunch() b.statistic = q_stat b.df = df b.pvalue = pvalue return b return q_stat, pvalue, df
bsd-3-clause
[ 624, 199, 10385, 367, 5909, 20135, 2877, 13, 3316, 406, 1337, 9501, 6716, 334, 73, 14, 69, 14, 9857, 199, 5987, 367, 19739, 626, 787, 8059, 13, 12334, 1290, 543, 14021, 370, 2877, 199, 16810, 2860, 680, 199, 199, 1918, 2446, 3992, 787, 26, 819, 627, 6957, 520, 9031, 3102, 626, 883, 506, 6781, 370, 1263, 2877, 13, 3316, 523, 406, 1337, 9501, 1817, 14, 819, 627, 428, 5937, 3186, 520, 9031, 3102, 626, 883, 506, 6781, 370, 282, 12386, 523, 2877, 13, 3316, 406, 1337, 9501, 1817, 14, 819, 627, 6957, 18, 88, 18, 520, 9031, 3102, 626, 883, 506, 6781, 370, 282, 499, 88, 18, 523, 406, 1337, 9501, 1817, 14, 819, 627, 428, 1239, 8981, 3186, 520, 9031, 3102, 626, 883, 506, 6781, 370, 282, 523, 3245, 402, 406, 1337, 9501, 6716, 14, 199, 199, 31892, 3509, 3423, 367, 406, 1601, 316, 22895, 685, 4584, 1159, 511, 436, 1849, 335, 1312, 1159, 1894, 199, 396, 14, 199, 199, 7443, 626, 314, 17353, 557, 6867, 1482, 1443, 11687, 641, 4212, 314, 666, 4898, 199, 25042, 14, 221, 1010, 8605, 314, 20802, 6204, 787, 12717, 436, 199, 9281, 17269, 1854, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 5020, 992, 14, 2537, 14, 11582, 492, 2581, 63, 6753, 12, 5305, 1224, 63, 1637, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5020, 199, 646, 10634, 465, 6454, 199, 504, 5020, 992, 492, 5890, 773, 199, 504, 5020, 992, 14, 2537, 14, 3300, 63, 3924, 492, 428, 14257, 6443, 3849, 4388, 199, 318, 485, 1875, 63, 1587, 63, 9646, 8, 1224, 304, 272, 408, 272, 799, 1080, 282, 10634, 10071, 880, 626, 652, 15410, 12386, 12, 11150, 626, 272, 314, 1962, 436, 2763, 4918, 1395, 314, 2011, 1338, 12, 315, 314, 2011, 272, 1865, 14, 221, 710, 1962, 436, 2763, 1478, 787, 9243, 370, 32194, 642, 14, 272, 408, 339, 340, 440, 1228, 8, 1224, 12, 6454, 14, 9205, 304, 267, 372, 1817, 339, 327, 982, 314, 1817, 365, 440, 12386, 12, 1852, 652, 12386, 272, 340, 1817, 14, 1392, 59, 16, 61, 1137, 1817, 14, 1392, 59, 17, 2189, 267, 20593, 275, 769, 8, 409, 8, 1224, 14, 1080, 9, 1204, 663, 8, 1224, 14, 3406, 430, 267, 1817, 275, 1817, 14, 21764, 8, 1148, 12, 3114, 29, 16, 9, 267, 1817, 275, 1817, 14, 21764, 8, 1148, 12, 3114, 29, 17, 9, 339, 327, 29652, 626, 314, 4730, 436, 4362, 787, 315, 314, 2011, 1865, 14, 272, 1817, 275, 1817, 14, 21764, 8, 1224, 14, 3406, 9, 339, 372, 1817, 421, 199, 533, 485, 34, 4689, 8, 785, 304, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 66, 4689, 909, 3035, 5020, 992, 2058, 4335, 421, 199, 533, 6957, 8, 785, 304, 272, 408, 272, 14279, 874, 626, 883, 506, 10585, 641, 282, 2877, 13, 3316, 406, 1337, 9501, 1817, 14, 339, 3897, 272, 4143, 272, 1817, 520, 1625, 13, 2930, 267, 437, 406, 1337, 9501, 1817, 14, 272, 7706, 63, 4250, 520, 5046, 267, 982, 715, 436, 1263, 4917, 2338, 365, 4697, 12, 1050, 378, 14, 21, 370, 1006, 1338, 267, 315, 314, 1817, 14, 339, 9382, 272, 4143, 272, 1817, 63, 2981, 520, 1625, 13, 2930, 267, 710, 3379, 1817, 365, 6328, 465, 658, 1224, 63, 2981, 2313, 272, 11042, 279, 63, 27583, 520, 2008, 402, 2877, 302, 4460, 4814, 267, 710, 20077, 1962, 436, 2763, 11042, 279, 10208, 14, 272, 31043, 29578, 63, 27583, 520, 6800, 267, 15896, 12754, 4917, 19555, 1334, 1962, 15, 2301, 31043, 29578, 14, 272, 26093, 1459, 520, 6800, 267, 25971, 471, 1338, 1334, 31043, 29578, 14, 272, 23185, 63, 16343, 834, 520, 6800, 267, 710, 510, 2210, 834, 16731, 83, 1334, 1962, 15, 2301, 31043, 29578, 14, 272, 28974, 7068, 63, 20807, 795, 520, 6800, 267, 799, 10969, 83, 367, 314, 12717, 1962, 15, 2301, 1402, 543, 19917, 267, 4137, 11773, 14, 272, 23275, 18, 63, 388, 19577, 520, 6800, 267, 710, 406, 15980, 402, 1924, 4917, 370, 314, 23275, 62, 18, 22394, 14, 272, 2257, 63, 793, 364, 795, 63, 345, 9636, 520, 6800, 267, 710, 2257, 943, 16699, 83, 660, 9636, 787, 12950, 367, 1924, 499, 88, 18, 1007, 1224, 267, 28917, 687, 24113, 4730, 436, 4362, 14, 272, 2257, 63, 364, 795, 345, 9636, 520, 6800, 267, 710, 2257, 16699, 83, 660, 9636, 787, 12950, 687, 1924, 499, 88, 18, 1007, 1224, 267, 28917, 687, 24113, 4730, 436, 4362, 14, 272, 25814, 63, 793, 63, 364, 795, 345, 9636, 520, 6800, 267, 710, 25814, 943, 16699, 83, 10463, 737, 282, 1627, 4092, 402, 22757, 365, 267, 12950, 701, 295, 14713, 314, 1817, 370, 282, 499, 88, 18, 1817, 4079, 641, 267, 487, 335, 357, 676, 9147, 314, 4730, 436, 4362, 737, 314, 1627, 22757, 14, 267, 710, 1817, 402, 25814, 943, 16699, 83, 660, 9636, 3451, 83, 1006, 3962, 267, 25814, 943, 16699, 83, 660, 9636, 626, 883, 506, 28917, 687, 282, 1627, 267, 1817, 14, 272, 25814, 63, 364, 795, 345, 9636, 520, 6800, 267, 710, 25814, 16699, 83, 660, 9636, 787, 12950, 701, 295, 14713, 314, 267, 1817, 370, 282, 499, 88, 18, 1817, 4079, 641, 10415, 1337, 314, 4730, 436, 4362, 737, 267, 282, 1627, 2376, 14, 221, 710, 1817, 402, 25814, 16699, 83, 660, 9636, 3451, 83, 267, 1006, 3962, 25814, 16699, 83, 660, 9636, 626, 883, 506, 28917, 687, 282, 267, 1627, 1817, 14, 339, 1666, 2597, 272, 3001, 272, 5020, 992, 14, 15707, 14, 573, 2231, 530, 2798, 14, 573, 2231, 530, 272, 7026, 14, 3200, 14, 13175, 18, 63, 388, 1337, 9501, 339, 8144, 272, 9063, 272, 710, 17353, 557, 6867, 1482, 1202, 2348, 787, 1006, 4079, 641, 282, 15877, 272, 1402, 315, 1314, 314, 6204, 787, 12717, 436, 6120, 17269, 272, 1854, 12, 543, 1924, 4137, 3769, 11534, 1290, 543, 14021, 370, 2877, 272, 22138, 2860, 14, 339, 14504, 272, 4143, 272, 22659, 852, 402, 16731, 83, 26, 267, 4178, 921, 15178, 11653, 14, 9907, 4894, 14, 1190, 85, 14, 8654, 15, 3736, 24081, 15, 932, 15, 1184, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1817, 12, 7706, 63, 4250, 29, 549, 304 ]
[ 199, 10385, 367, 5909, 20135, 2877, 13, 3316, 406, 1337, 9501, 6716, 334, 73, 14, 69, 14, 9857, 199, 5987, 367, 19739, 626, 787, 8059, 13, 12334, 1290, 543, 14021, 370, 2877, 199, 16810, 2860, 680, 199, 199, 1918, 2446, 3992, 787, 26, 819, 627, 6957, 520, 9031, 3102, 626, 883, 506, 6781, 370, 1263, 2877, 13, 3316, 523, 406, 1337, 9501, 1817, 14, 819, 627, 428, 5937, 3186, 520, 9031, 3102, 626, 883, 506, 6781, 370, 282, 12386, 523, 2877, 13, 3316, 406, 1337, 9501, 1817, 14, 819, 627, 6957, 18, 88, 18, 520, 9031, 3102, 626, 883, 506, 6781, 370, 282, 499, 88, 18, 523, 406, 1337, 9501, 1817, 14, 819, 627, 428, 1239, 8981, 3186, 520, 9031, 3102, 626, 883, 506, 6781, 370, 282, 523, 3245, 402, 406, 1337, 9501, 6716, 14, 199, 199, 31892, 3509, 3423, 367, 406, 1601, 316, 22895, 685, 4584, 1159, 511, 436, 1849, 335, 1312, 1159, 1894, 199, 396, 14, 199, 199, 7443, 626, 314, 17353, 557, 6867, 1482, 1443, 11687, 641, 4212, 314, 666, 4898, 199, 25042, 14, 221, 1010, 8605, 314, 20802, 6204, 787, 12717, 436, 199, 9281, 17269, 1854, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 5020, 992, 14, 2537, 14, 11582, 492, 2581, 63, 6753, 12, 5305, 1224, 63, 1637, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5020, 199, 646, 10634, 465, 6454, 199, 504, 5020, 992, 492, 5890, 773, 199, 504, 5020, 992, 14, 2537, 14, 3300, 63, 3924, 492, 428, 14257, 6443, 3849, 4388, 199, 318, 485, 1875, 63, 1587, 63, 9646, 8, 1224, 304, 272, 408, 272, 799, 1080, 282, 10634, 10071, 880, 626, 652, 15410, 12386, 12, 11150, 626, 272, 314, 1962, 436, 2763, 4918, 1395, 314, 2011, 1338, 12, 315, 314, 2011, 272, 1865, 14, 221, 710, 1962, 436, 2763, 1478, 787, 9243, 370, 32194, 642, 14, 272, 408, 339, 340, 440, 1228, 8, 1224, 12, 6454, 14, 9205, 304, 267, 372, 1817, 339, 327, 982, 314, 1817, 365, 440, 12386, 12, 1852, 652, 12386, 272, 340, 1817, 14, 1392, 59, 16, 61, 1137, 1817, 14, 1392, 59, 17, 2189, 267, 20593, 275, 769, 8, 409, 8, 1224, 14, 1080, 9, 1204, 663, 8, 1224, 14, 3406, 430, 267, 1817, 275, 1817, 14, 21764, 8, 1148, 12, 3114, 29, 16, 9, 267, 1817, 275, 1817, 14, 21764, 8, 1148, 12, 3114, 29, 17, 9, 339, 327, 29652, 626, 314, 4730, 436, 4362, 787, 315, 314, 2011, 1865, 14, 272, 1817, 275, 1817, 14, 21764, 8, 1224, 14, 3406, 9, 339, 372, 1817, 421, 199, 533, 485, 34, 4689, 8, 785, 304, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 66, 4689, 909, 3035, 5020, 992, 2058, 4335, 421, 199, 533, 6957, 8, 785, 304, 272, 408, 272, 14279, 874, 626, 883, 506, 10585, 641, 282, 2877, 13, 3316, 406, 1337, 9501, 1817, 14, 339, 3897, 272, 4143, 272, 1817, 520, 1625, 13, 2930, 267, 437, 406, 1337, 9501, 1817, 14, 272, 7706, 63, 4250, 520, 5046, 267, 982, 715, 436, 1263, 4917, 2338, 365, 4697, 12, 1050, 378, 14, 21, 370, 1006, 1338, 267, 315, 314, 1817, 14, 339, 9382, 272, 4143, 272, 1817, 63, 2981, 520, 1625, 13, 2930, 267, 710, 3379, 1817, 365, 6328, 465, 658, 1224, 63, 2981, 2313, 272, 11042, 279, 63, 27583, 520, 2008, 402, 2877, 302, 4460, 4814, 267, 710, 20077, 1962, 436, 2763, 11042, 279, 10208, 14, 272, 31043, 29578, 63, 27583, 520, 6800, 267, 15896, 12754, 4917, 19555, 1334, 1962, 15, 2301, 31043, 29578, 14, 272, 26093, 1459, 520, 6800, 267, 25971, 471, 1338, 1334, 31043, 29578, 14, 272, 23185, 63, 16343, 834, 520, 6800, 267, 710, 510, 2210, 834, 16731, 83, 1334, 1962, 15, 2301, 31043, 29578, 14, 272, 28974, 7068, 63, 20807, 795, 520, 6800, 267, 799, 10969, 83, 367, 314, 12717, 1962, 15, 2301, 1402, 543, 19917, 267, 4137, 11773, 14, 272, 23275, 18, 63, 388, 19577, 520, 6800, 267, 710, 406, 15980, 402, 1924, 4917, 370, 314, 23275, 62, 18, 22394, 14, 272, 2257, 63, 793, 364, 795, 63, 345, 9636, 520, 6800, 267, 710, 2257, 943, 16699, 83, 660, 9636, 787, 12950, 367, 1924, 499, 88, 18, 1007, 1224, 267, 28917, 687, 24113, 4730, 436, 4362, 14, 272, 2257, 63, 364, 795, 345, 9636, 520, 6800, 267, 710, 2257, 16699, 83, 660, 9636, 787, 12950, 687, 1924, 499, 88, 18, 1007, 1224, 267, 28917, 687, 24113, 4730, 436, 4362, 14, 272, 25814, 63, 793, 63, 364, 795, 345, 9636, 520, 6800, 267, 710, 25814, 943, 16699, 83, 10463, 737, 282, 1627, 4092, 402, 22757, 365, 267, 12950, 701, 295, 14713, 314, 1817, 370, 282, 499, 88, 18, 1817, 4079, 641, 267, 487, 335, 357, 676, 9147, 314, 4730, 436, 4362, 737, 314, 1627, 22757, 14, 267, 710, 1817, 402, 25814, 943, 16699, 83, 660, 9636, 3451, 83, 1006, 3962, 267, 25814, 943, 16699, 83, 660, 9636, 626, 883, 506, 28917, 687, 282, 1627, 267, 1817, 14, 272, 25814, 63, 364, 795, 345, 9636, 520, 6800, 267, 710, 25814, 16699, 83, 660, 9636, 787, 12950, 701, 295, 14713, 314, 267, 1817, 370, 282, 499, 88, 18, 1817, 4079, 641, 10415, 1337, 314, 4730, 436, 4362, 737, 267, 282, 1627, 2376, 14, 221, 710, 1817, 402, 25814, 16699, 83, 660, 9636, 3451, 83, 267, 1006, 3962, 25814, 16699, 83, 660, 9636, 626, 883, 506, 28917, 687, 282, 267, 1627, 1817, 14, 339, 1666, 2597, 272, 3001, 272, 5020, 992, 14, 15707, 14, 573, 2231, 530, 2798, 14, 573, 2231, 530, 272, 7026, 14, 3200, 14, 13175, 18, 63, 388, 1337, 9501, 339, 8144, 272, 9063, 272, 710, 17353, 557, 6867, 1482, 1202, 2348, 787, 1006, 4079, 641, 282, 15877, 272, 1402, 315, 1314, 314, 6204, 787, 12717, 436, 6120, 17269, 272, 1854, 12, 543, 1924, 4137, 3769, 11534, 1290, 543, 14021, 370, 2877, 272, 22138, 2860, 14, 339, 14504, 272, 4143, 272, 22659, 852, 402, 16731, 83, 26, 267, 4178, 921, 15178, 11653, 14, 9907, 4894, 14, 1190, 85, 14, 8654, 15, 3736, 24081, 15, 932, 15, 1184, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1817, 12, 7706, 63, 4250, 29, 549, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
Gui13/CouchPotatoServer
couchpotato/core/media/_base/media/main.py
2
16591
import traceback from string import ascii_lowercase from CodernityDB.database import RecordNotFound from couchpotato import tryInt, get_db from couchpotato.api import addApiView from couchpotato.core.event import fireEvent, fireEventAsync, addEvent from couchpotato.core.helpers.encoding import toUnicode from couchpotato.core.helpers.variable import splitString, getImdb, getTitle from couchpotato.core.logger import CPLog from couchpotato.core.media import MediaBase from .index import MediaIndex, MediaStatusIndex, MediaTypeIndex, TitleSearchIndex, TitleIndex, StartsWithIndex, MediaChildrenIndex log = CPLog(__name__) class MediaPlugin(MediaBase): _database = { 'media': MediaIndex, 'media_search_title': TitleSearchIndex, 'media_status': MediaStatusIndex, 'media_by_type': MediaTypeIndex, 'media_title': TitleIndex, 'media_startswith': StartsWithIndex, 'media_children': MediaChildrenIndex, } def __init__(self): addApiView('media.refresh', self.refresh, docs = { 'desc': 'Refresh a any media type by ID', 'params': { 'id': {'desc': 'Movie, Show, Season or Episode ID(s) you want to refresh.', 'type': 'int (comma separated)'}, } }) addApiView('media.list', self.listView, docs = { 'desc': 'List media', 'params': { 'type': {'type': 'string', 'desc': 'Media type to filter on.'}, 'status': {'type': 'array or csv', 'desc': 'Filter movie by status. Example:"active,done"'}, 'release_status': {'type': 'array or csv', 'desc': 'Filter movie by status of its releases. Example:"snatched,available"'}, 'limit_offset': {'desc': 'Limit and offset the movie list. Examples: "50" or "50,30"'}, 'starts_with': {'desc': 'Starts with these characters. Example: "a" returns all movies starting with the letter "a"'}, 'search': {'desc': 'Search movie title'}, }, 'return': {'type': 'object', 'example': """{ 'success': True, 'empty': bool, any movies returned or not, 'media': array, media found, }"""} }) addApiView('media.get', self.getView, docs = { 'desc': 'Get media by id', 'params': { 'id': {'desc': 'The id of the media'}, } }) addApiView('media.delete', self.deleteView, docs = { 'desc': 'Delete a media from the wanted list', 'params': { 'id': {'desc': 'Media ID(s) you want to delete.', 'type': 'int (comma separated)'}, 'delete_from': {'desc': 'Delete media from this page', 'type': 'string: all (default), wanted, manage'}, } }) addApiView('media.available_chars', self.charView) addEvent('app.load', self.addSingleRefreshView, priority = 100) addEvent('app.load', self.addSingleListView, priority = 100) addEvent('app.load', self.addSingleCharView, priority = 100) addEvent('app.load', self.addSingleDeleteView, priority = 100) addEvent('media.get', self.get) addEvent('media.with_status', self.withStatus) addEvent('media.with_identifiers', self.withIdentifiers) addEvent('media.list', self.list) addEvent('media.delete', self.delete) addEvent('media.restatus', self.restatus) def refresh(self, id = '', **kwargs): handlers = [] ids = splitString(id) for x in ids: refresh_handler = self.createRefreshHandler(x) if refresh_handler: handlers.append(refresh_handler) fireEvent('notify.frontend', type = 'media.busy', data = {'_id': ids}) fireEventAsync('schedule.queue', handlers = handlers) return { 'success': True, } def createRefreshHandler(self, media_id): try: media = get_db().get('id', media_id) event = '%s.update_info' % media.get('type') def handler(): fireEvent(event, media_id = media_id, on_complete = self.createOnComplete(media_id)) return handler except: log.error('Refresh handler for non existing media: %s', traceback.format_exc()) def addSingleRefreshView(self): for media_type in fireEvent('media.types', merge = True): addApiView('%s.refresh' % media_type, self.refresh) def get(self, media_id): try: db = get_db() imdb_id = getImdb(str(media_id)) if imdb_id: media = db.get('media', 'imdb-%s' % imdb_id, with_doc = True)['doc'] else: media = db.get('id', media_id) if media: # Attach category try: media['category'] = db.get('id', media.get('category_id')) except: pass media['releases'] = fireEvent('release.for_media', media['_id'], single = True) return media except RecordNotFound: log.error('Media with id "%s" not found', media_id) except: raise def getView(self, id = None, **kwargs): media = self.get(id) if id else None return { 'success': media is not None, 'media': media, } def withStatus(self, status, with_doc = True): db = get_db() status = list(status if isinstance(status, (list, tuple)) else [status]) for s in status: for ms in db.get_many('media_status', s, with_doc = with_doc): yield ms['doc'] if with_doc else ms def withIdentifiers(self, identifiers, with_doc = False): db = get_db() for x in identifiers: try: media = db.get('media', '%s-%s' % (x, identifiers[x]), with_doc = with_doc) return media except: pass log.debug('No media found with identifiers: %s', identifiers) def list(self, types = None, status = None, release_status = None, status_or = False, limit_offset = None, starts_with = None, search = None): db = get_db() # Make a list from string if status and not isinstance(status, (list, tuple)): status = [status] if release_status and not isinstance(release_status, (list, tuple)): release_status = [release_status] if types and not isinstance(types, (list, tuple)): types = [types] # query media ids if types: all_media_ids = set() for media_type in types: all_media_ids = all_media_ids.union(set([x['_id'] for x in db.get_many('media_by_type', media_type)])) else: all_media_ids = set([x['_id'] for x in db.all('media')]) media_ids = list(all_media_ids) filter_by = {} # Filter on movie status if status and len(status) > 0: filter_by['media_status'] = set() for media_status in fireEvent('media.with_status', status, with_doc = False, single = True): filter_by['media_status'].add(media_status.get('_id')) # Filter on release status if release_status and len(release_status) > 0: filter_by['release_status'] = set() for release_status in fireEvent('release.with_status', release_status, with_doc = False, single = True): filter_by['release_status'].add(release_status.get('media_id')) # Add search filters if starts_with: filter_by['starts_with'] = set() starts_with = toUnicode(starts_with.lower())[0] starts_with = starts_with if starts_with in ascii_lowercase else '#' filter_by['starts_with'] = [x['_id'] for x in db.get_many('media_startswith', starts_with)] # Filter with search query if search: filter_by['search'] = [x['_id'] for x in db.get_many('media_search_title', search)] if status_or and 'media_status' in filter_by and 'release_status' in filter_by: filter_by['status'] = list(filter_by['media_status']) + list(filter_by['release_status']) del filter_by['media_status'] del filter_by['release_status'] # Filter by combining ids for x in filter_by: media_ids = [n for n in media_ids if n in filter_by[x]] total_count = len(media_ids) if total_count == 0: return 0, [] offset = 0 limit = -1 if limit_offset: splt = splitString(limit_offset) if isinstance(limit_offset, (str, unicode)) else limit_offset limit = tryInt(splt[0]) offset = tryInt(0 if len(splt) is 1 else splt[1]) # List movies based on title order medias = [] for m in db.all('media_title'): media_id = m['_id'] if media_id not in media_ids: continue if offset > 0: offset -= 1 continue media = fireEvent('media.get', media_id, single = True) # Merge releases with movie dict medias.append(media) # remove from media ids media_ids.remove(media_id) if len(media_ids) == 0 or len(medias) == limit: break return total_count, medias def listView(self, **kwargs): total_movies, movies = self.list( types = splitString(kwargs.get('type')), status = splitString(kwargs.get('status')), release_status = splitString(kwargs.get('release_status')), status_or = kwargs.get('status_or') is not None, limit_offset = kwargs.get('limit_offset'), starts_with = kwargs.get('starts_with'), search = kwargs.get('search') ) return { 'success': True, 'empty': len(movies) == 0, 'total': total_movies, 'movies': movies, } def addSingleListView(self): for media_type in fireEvent('media.types', merge = True): def tempList(*args, **kwargs): return self.listView(types = media_type, **kwargs) addApiView('%s.list' % media_type, tempList) def availableChars(self, types = None, status = None, release_status = None): db = get_db() # Make a list from string if status and not isinstance(status, (list, tuple)): status = [status] if release_status and not isinstance(release_status, (list, tuple)): release_status = [release_status] if types and not isinstance(types, (list, tuple)): types = [types] # query media ids if types: all_media_ids = set() for media_type in types: all_media_ids = all_media_ids.union(set([x['_id'] for x in db.get_many('media_by_type', media_type)])) else: all_media_ids = set([x['_id'] for x in db.all('media')]) media_ids = all_media_ids filter_by = {} # Filter on movie status if status and len(status) > 0: filter_by['media_status'] = set() for media_status in fireEvent('media.with_status', status, with_doc = False, single = True): filter_by['media_status'].add(media_status.get('_id')) # Filter on release status if release_status and len(release_status) > 0: filter_by['release_status'] = set() for release_status in fireEvent('release.with_status', release_status, with_doc = False, single = True): filter_by['release_status'].add(release_status.get('media_id')) # Filter by combining ids for x in filter_by: media_ids = [n for n in media_ids if n in filter_by[x]] chars = set() for x in db.all('media_startswith'): if x['_id'] in media_ids: chars.add(x['key']) if len(chars) == 25: break return list(chars) def charView(self, **kwargs): type = splitString(kwargs.get('type', 'movie')) status = splitString(kwargs.get('status', None)) release_status = splitString(kwargs.get('release_status', None)) chars = self.availableChars(type, status, release_status) return { 'success': True, 'empty': len(chars) == 0, 'chars': chars, } def addSingleCharView(self): for media_type in fireEvent('media.types', merge = True): def tempChar(*args, **kwargs): return self.charView(types = media_type, **kwargs) addApiView('%s.available_chars' % media_type, tempChar) def delete(self, media_id, delete_from = None): try: db = get_db() media = db.get('id', media_id) if media: deleted = False media_releases = fireEvent('release.for_media', media['_id'], single = True) if delete_from == 'all': # Delete connected releases for release in media_releases: db.delete(release) db.delete(media) deleted = True else: total_releases = len(media_releases) total_deleted = 0 new_media_status = None for release in media_releases: if delete_from in ['wanted', 'snatched', 'late']: if release.get('status') != 'done': db.delete(release) total_deleted += 1 new_media_status = 'done' elif delete_from == 'manage': if release.get('status') == 'done': db.delete(release) total_deleted += 1 if (total_releases == total_deleted and media['status'] != 'active') or (delete_from == 'wanted' and media['status'] == 'active') or (not new_media_status and delete_from == 'late'): db.delete(media) deleted = True elif new_media_status: media['status'] = new_media_status db.update(media) else: fireEvent('media.restatus', media.get('_id'), single = True) if deleted: fireEvent('notify.frontend', type = 'media.deleted', data = media) except: log.error('Failed deleting media: %s', traceback.format_exc()) return True def deleteView(self, id = '', **kwargs): ids = splitString(id) for media_id in ids: self.delete(media_id, delete_from = kwargs.get('delete_from', 'all')) return { 'success': True, } def addSingleDeleteView(self): for media_type in fireEvent('media.types', merge = True): def tempDelete(*args, **kwargs): return self.deleteView(types = media_type, *args, **kwargs) addApiView('%s.delete' % media_type, tempDelete) def restatus(self, media_id): try: db = get_db() m = db.get('id', media_id) previous_status = m['status'] log.debug('Changing status for %s', getTitle(m)) if not m['profile_id']: m['status'] = 'done' else: move_to_wanted = True profile = db.get('id', m['profile_id']) media_releases = fireEvent('release.for_media', m['_id'], single = True) for q_identifier in profile['qualities']: index = profile['qualities'].index(q_identifier) for release in media_releases: if q_identifier == release['quality'] and (release.get('status') == 'done' and profile['finish'][index]): move_to_wanted = False m['status'] = 'active' if move_to_wanted else 'done' # Only update when status has changed if previous_status != m['status']: db.update(m) return True except: log.error('Failed restatus: %s', traceback.format_exc())
gpl-3.0
[ 646, 5190, 199, 504, 1059, 492, 13294, 63, 21636, 199, 199, 504, 5495, 11641, 1209, 2846, 14, 4659, 492, 12651, 4667, 199, 504, 28877, 30780, 492, 862, 3241, 12, 664, 63, 697, 199, 504, 28877, 30780, 14, 1246, 492, 1050, 7394, 2768, 199, 504, 28877, 30780, 14, 1018, 14, 1430, 492, 8344, 2390, 12, 8344, 2390, 12807, 12, 1050, 2390, 199, 504, 28877, 30780, 14, 1018, 14, 7546, 14, 2991, 492, 370, 7087, 199, 504, 28877, 30780, 14, 1018, 14, 7546, 14, 1975, 492, 3715, 1558, 12, 664, 16221, 697, 12, 664, 6888, 199, 504, 28877, 30780, 14, 1018, 14, 2921, 492, 19701, 2445, 199, 504, 28877, 30780, 14, 1018, 14, 4603, 492, 12300, 1563, 199, 504, 1275, 1080, 492, 12300, 2681, 12, 12300, 3694, 2681, 12, 12300, 804, 2681, 12, 16881, 5278, 2681, 12, 16881, 2681, 12, 7707, 83, 3007, 2681, 12, 12300, 7139, 2681, 421, 199, 793, 275, 19701, 2445, 3460, 354, 3368, 421, 199, 533, 12300, 5061, 8, 11398, 1563, 304, 339, 485, 4659, 275, 469, 267, 283, 4603, 356, 12300, 2681, 12, 267, 283, 4603, 63, 1733, 63, 1213, 356, 16881, 5278, 2681, 12, 267, 283, 4603, 63, 1205, 356, 12300, 3694, 2681, 12, 267, 283, 4603, 63, 991, 63, 466, 356, 12300, 804, 2681, 12, 267, 283, 4603, 63, 1213, 356, 16881, 2681, 12, 267, 283, 4603, 63, 2460, 356, 7707, 83, 3007, 2681, 12, 267, 283, 4603, 63, 3223, 356, 12300, 7139, 2681, 12, 272, 789, 339, 347, 636, 826, 721, 277, 304, 398, 1050, 7394, 2768, 360, 4603, 14, 6635, 297, 291, 14, 6635, 12, 9149, 275, 469, 288, 283, 3257, 356, 283, 18730, 282, 1263, 5898, 730, 701, 2870, 297, 288, 283, 1162, 356, 469, 355, 283, 344, 356, 791, 3257, 356, 283, 19088, 12, 12968, 12, 3240, 2660, 503, 27255, 6045, 2870, 8, 83, 9, 1265, 2934, 370, 9236, 3130, 283, 466, 356, 283, 442, 334, 13184, 11673, 9, 2267, 288, 789, 267, 3828, 398, 1050, 7394, 2768, 360, 4603, 14, 513, 297, 291, 14, 513, 2768, 12, 9149, 275, 469, 288, 283, 3257, 356, 283, 1296, 5898, 297, 288, 283, 1162, 356, 469, 355, 283, 466, 356, 791, 466, 356, 283, 875, 297, 283, 3257, 356, 283, 11398, 730, 370, 2457, 641, 14, 2267, 355, 283, 1205, 356, 791, 466, 356, 283, 1144, 503, 7392, 297, 283, 3257, 356, 283, 4131, 14360, 701, 2004, 14, 5679, 5424, 2682, 12, 4456, 2, 2267, 355, 283, 3221, 63, 1205, 356, 791, 466, 356, 283, 1144, 503, 7392, 297, 283, 3257, 356, 283, 4131, 14360, 701, 2004, 402, 2399, 19015, 14, 5679, 5424, 5167, 693, 379, 12, 4561, 2, 2267, 355, 283, 3097, 63, 2743, 356, 791, 3257, 356, 283, 8407, 436, 3268, 314, 14360, 769, 14, 6058, 26, 298, 1400, 2, 503, 298, 1400, 12, 1216, 2, 2267, 355, 283, 17116, 63, 1045, 356, 791, 3257, 356, 283, 32142, 543, 3520, 4110, 14, 5679, 26, 298, 65, 2, 2529, 1006, 1303, 14484, 6617, 543, 314, 8082, 298, 65, 2, 2267, 355, 283, 1733, 356, 791, 3257, 356, 283, 5278, 14360, 2538, 2267, 288, 1660, 288, 283, 1107, 356, 791, 466, 356, 283, 785, 297, 283, 2694, 356, 408, 91, 272, 283, 3742, 356, 715, 12, 272, 283, 1667, 356, 2155, 12, 1263, 1303, 14484, 2138, 503, 440, 12, 272, 283, 4603, 356, 1625, 12, 5898, 1911, 12, 199, 30437, 93, 267, 3828, 398, 1050, 7394, 2768, 360, 4603, 14, 362, 297, 291, 14, 362, 2768, 12, 9149, 275, 469, 288, 283, 3257, 356, 283, 1002, 5898, 701, 1305, 297, 288, 283, 1162, 356, 469, 355, 283, 344, 356, 791, 3257, 356, 283, 1918, 1305, 402, 314, 5898, 2267, 288, 789, 267, 3828, 398, 1050, 7394, 2768, 360, 4603, 14, 1807, 297, 291, 14, 1807, 2768, 12, 9149, 275, 469, 288, 283, 3257, 356, 283, 5392, 282, 5898, 687, 314, 13632, 769, 297, 288, 283, 1162, 356, 469, 355, 283, 344, 356, 791, 3257, 356, 283, 11398, 2870, 8, 83, 9, 1265, 2934, 370, 3145, 3130, 283, 466, 356, 283, 442, 334, 13184, 11673, 9, 2267, 355, 283, 1807, 63, 504, 356, 791, 3257, 356, 283, 5392, 5898, 687, 642, 2034, 297, 283, 466, 356, 283, 875, 26, 1006, 334, 885, 395, 13632, 12, 9635, 2267, 288, 789, 267, 3828, 398, 1050, 7394, 2768, 360, 4603, 14, 4561, 63, 6574, 297, 291, 14, 1560, 2768, 9, 398, 1050, 2390, 360, 571, 14, 912, 297, 291, 14, 525, 7200, 18730, 2768, 12, 7464, 275, 2948, 9, 267, 1050, 2390, 360, 571, 14, 912, 297, 291, 14, 525, 7200, 23239, 12, 7464, 275, 2948, 9, 267, 1050, 2390, 360, 571, 14, 912, 297, 291, 14, 525, 7200, 1610, 2768, 12, 7464, 275, 2948, 9, 267, 1050, 2390, 360, 571, 14, 912, 297, 291, 14, 525, 7200, 5392, 2768, 12, 7464, 275, 2948, 9, 398, 1050, 2390, 360, 4603, 14, 362, 297, 291, 14, 362, 9, 267, 1050, 2390, 360, 4603, 14, 1045, 63, 1205, 297, 291, 14, 1045, 3694, 9, 267, 1050, 2390, 360, 4603, 14, 1045, 63, 14227, 297, 291, 14, 1045, 41, 8577, 9, 267, 1050, 2390, 360, 4603, 14, 513, 297, 291, 14, 513, 9, 267, 1050, 2390, 360, 4603, 14, 1807, 297, 291, 14, 1807, 9, 267, 1050, 2390, 360, 4603, 14, 264, 1205, 297, 291, 14, 264, 1205, 9, 339, 347, 9236, 8, 277, 12, 1305, 275, 3260, 1011, 958, 304, 267, 8297, 275, 942, 267, 2762, 275, 3715, 1558, 8, 344, 9, 398, 367, 671, 315, 2762, 26, 953, 9236, 63, 2232, 275, 291, 14, 981, 18730, 2461, 8, 88, 9, 288, 340, 9236, 63, 2232, 26, 355, 8297, 14, 740, 8, 6635, 63, 2232, 9, 398, 8344, 2390, 360, 6814, 14, 18062, 297, 730, 275, 283, 4603, 14, 25265, 297, 666, 275, 32136, 344, 356, 2762, 1552, 267, 8344, 2390, 12807, 360, 7211, 14, 1825, 297, 8297, 275, 8297, 9, 398, 372, 469, 288, 283, 3742, 356, 715, 12, 267, 789, 339, 347, 1218, 18730, 2461, 8, 277, 12, 5898, 63, 344, 304, 398, 862, 26, 288, 5898, 275, 664, 63, 697, 1252, 362, 360, 344, 297, 5898, 63, 344, 9, 288, 1566, 275, 1543, 83, 14, 873, 63, 815, 7, 450 ]
[ 5190, 199, 504, 1059, 492, 13294, 63, 21636, 199, 199, 504, 5495, 11641, 1209, 2846, 14, 4659, 492, 12651, 4667, 199, 504, 28877, 30780, 492, 862, 3241, 12, 664, 63, 697, 199, 504, 28877, 30780, 14, 1246, 492, 1050, 7394, 2768, 199, 504, 28877, 30780, 14, 1018, 14, 1430, 492, 8344, 2390, 12, 8344, 2390, 12807, 12, 1050, 2390, 199, 504, 28877, 30780, 14, 1018, 14, 7546, 14, 2991, 492, 370, 7087, 199, 504, 28877, 30780, 14, 1018, 14, 7546, 14, 1975, 492, 3715, 1558, 12, 664, 16221, 697, 12, 664, 6888, 199, 504, 28877, 30780, 14, 1018, 14, 2921, 492, 19701, 2445, 199, 504, 28877, 30780, 14, 1018, 14, 4603, 492, 12300, 1563, 199, 504, 1275, 1080, 492, 12300, 2681, 12, 12300, 3694, 2681, 12, 12300, 804, 2681, 12, 16881, 5278, 2681, 12, 16881, 2681, 12, 7707, 83, 3007, 2681, 12, 12300, 7139, 2681, 421, 199, 793, 275, 19701, 2445, 3460, 354, 3368, 421, 199, 533, 12300, 5061, 8, 11398, 1563, 304, 339, 485, 4659, 275, 469, 267, 283, 4603, 356, 12300, 2681, 12, 267, 283, 4603, 63, 1733, 63, 1213, 356, 16881, 5278, 2681, 12, 267, 283, 4603, 63, 1205, 356, 12300, 3694, 2681, 12, 267, 283, 4603, 63, 991, 63, 466, 356, 12300, 804, 2681, 12, 267, 283, 4603, 63, 1213, 356, 16881, 2681, 12, 267, 283, 4603, 63, 2460, 356, 7707, 83, 3007, 2681, 12, 267, 283, 4603, 63, 3223, 356, 12300, 7139, 2681, 12, 272, 789, 339, 347, 636, 826, 721, 277, 304, 398, 1050, 7394, 2768, 360, 4603, 14, 6635, 297, 291, 14, 6635, 12, 9149, 275, 469, 288, 283, 3257, 356, 283, 18730, 282, 1263, 5898, 730, 701, 2870, 297, 288, 283, 1162, 356, 469, 355, 283, 344, 356, 791, 3257, 356, 283, 19088, 12, 12968, 12, 3240, 2660, 503, 27255, 6045, 2870, 8, 83, 9, 1265, 2934, 370, 9236, 3130, 283, 466, 356, 283, 442, 334, 13184, 11673, 9, 2267, 288, 789, 267, 3828, 398, 1050, 7394, 2768, 360, 4603, 14, 513, 297, 291, 14, 513, 2768, 12, 9149, 275, 469, 288, 283, 3257, 356, 283, 1296, 5898, 297, 288, 283, 1162, 356, 469, 355, 283, 466, 356, 791, 466, 356, 283, 875, 297, 283, 3257, 356, 283, 11398, 730, 370, 2457, 641, 14, 2267, 355, 283, 1205, 356, 791, 466, 356, 283, 1144, 503, 7392, 297, 283, 3257, 356, 283, 4131, 14360, 701, 2004, 14, 5679, 5424, 2682, 12, 4456, 2, 2267, 355, 283, 3221, 63, 1205, 356, 791, 466, 356, 283, 1144, 503, 7392, 297, 283, 3257, 356, 283, 4131, 14360, 701, 2004, 402, 2399, 19015, 14, 5679, 5424, 5167, 693, 379, 12, 4561, 2, 2267, 355, 283, 3097, 63, 2743, 356, 791, 3257, 356, 283, 8407, 436, 3268, 314, 14360, 769, 14, 6058, 26, 298, 1400, 2, 503, 298, 1400, 12, 1216, 2, 2267, 355, 283, 17116, 63, 1045, 356, 791, 3257, 356, 283, 32142, 543, 3520, 4110, 14, 5679, 26, 298, 65, 2, 2529, 1006, 1303, 14484, 6617, 543, 314, 8082, 298, 65, 2, 2267, 355, 283, 1733, 356, 791, 3257, 356, 283, 5278, 14360, 2538, 2267, 288, 1660, 288, 283, 1107, 356, 791, 466, 356, 283, 785, 297, 283, 2694, 356, 408, 91, 272, 283, 3742, 356, 715, 12, 272, 283, 1667, 356, 2155, 12, 1263, 1303, 14484, 2138, 503, 440, 12, 272, 283, 4603, 356, 1625, 12, 5898, 1911, 12, 199, 30437, 93, 267, 3828, 398, 1050, 7394, 2768, 360, 4603, 14, 362, 297, 291, 14, 362, 2768, 12, 9149, 275, 469, 288, 283, 3257, 356, 283, 1002, 5898, 701, 1305, 297, 288, 283, 1162, 356, 469, 355, 283, 344, 356, 791, 3257, 356, 283, 1918, 1305, 402, 314, 5898, 2267, 288, 789, 267, 3828, 398, 1050, 7394, 2768, 360, 4603, 14, 1807, 297, 291, 14, 1807, 2768, 12, 9149, 275, 469, 288, 283, 3257, 356, 283, 5392, 282, 5898, 687, 314, 13632, 769, 297, 288, 283, 1162, 356, 469, 355, 283, 344, 356, 791, 3257, 356, 283, 11398, 2870, 8, 83, 9, 1265, 2934, 370, 3145, 3130, 283, 466, 356, 283, 442, 334, 13184, 11673, 9, 2267, 355, 283, 1807, 63, 504, 356, 791, 3257, 356, 283, 5392, 5898, 687, 642, 2034, 297, 283, 466, 356, 283, 875, 26, 1006, 334, 885, 395, 13632, 12, 9635, 2267, 288, 789, 267, 3828, 398, 1050, 7394, 2768, 360, 4603, 14, 4561, 63, 6574, 297, 291, 14, 1560, 2768, 9, 398, 1050, 2390, 360, 571, 14, 912, 297, 291, 14, 525, 7200, 18730, 2768, 12, 7464, 275, 2948, 9, 267, 1050, 2390, 360, 571, 14, 912, 297, 291, 14, 525, 7200, 23239, 12, 7464, 275, 2948, 9, 267, 1050, 2390, 360, 571, 14, 912, 297, 291, 14, 525, 7200, 1610, 2768, 12, 7464, 275, 2948, 9, 267, 1050, 2390, 360, 571, 14, 912, 297, 291, 14, 525, 7200, 5392, 2768, 12, 7464, 275, 2948, 9, 398, 1050, 2390, 360, 4603, 14, 362, 297, 291, 14, 362, 9, 267, 1050, 2390, 360, 4603, 14, 1045, 63, 1205, 297, 291, 14, 1045, 3694, 9, 267, 1050, 2390, 360, 4603, 14, 1045, 63, 14227, 297, 291, 14, 1045, 41, 8577, 9, 267, 1050, 2390, 360, 4603, 14, 513, 297, 291, 14, 513, 9, 267, 1050, 2390, 360, 4603, 14, 1807, 297, 291, 14, 1807, 9, 267, 1050, 2390, 360, 4603, 14, 264, 1205, 297, 291, 14, 264, 1205, 9, 339, 347, 9236, 8, 277, 12, 1305, 275, 3260, 1011, 958, 304, 267, 8297, 275, 942, 267, 2762, 275, 3715, 1558, 8, 344, 9, 398, 367, 671, 315, 2762, 26, 953, 9236, 63, 2232, 275, 291, 14, 981, 18730, 2461, 8, 88, 9, 288, 340, 9236, 63, 2232, 26, 355, 8297, 14, 740, 8, 6635, 63, 2232, 9, 398, 8344, 2390, 360, 6814, 14, 18062, 297, 730, 275, 283, 4603, 14, 25265, 297, 666, 275, 32136, 344, 356, 2762, 1552, 267, 8344, 2390, 12807, 360, 7211, 14, 1825, 297, 8297, 275, 8297, 9, 398, 372, 469, 288, 283, 3742, 356, 715, 12, 267, 789, 339, 347, 1218, 18730, 2461, 8, 277, 12, 5898, 63, 344, 304, 398, 862, 26, 288, 5898, 275, 664, 63, 697, 1252, 362, 360, 344, 297, 5898, 63, 344, 9, 288, 1566, 275, 1543, 83, 14, 873, 63, 815, 7, 450, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gorcz/security_monkey
security_monkey/watchers/iam/iam_group.py
2
6319
# Copyright 2014 Netflix, 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. """ .. module: security_monkey.watchers.iam.iam_group :platform: Unix .. version:: $$VERSION$$ .. moduleauthor:: Patrick Kelley <pkelley@netflix.com> @monkeysecurity """ from security_monkey.watcher import Watcher from security_monkey.watcher import ChangeItem from security_monkey.exceptions import InvalidAWSJSON from security_monkey.exceptions import BotoConnectionIssue from security_monkey import app import json import urllib def all_managed_policies(conn): managed_policies = {} for policy in conn.policies.all(): for attached_group in policy.attached_groups.all(): policy = { "name": policy.policy_name, "arn": policy.arn, "version": policy.default_version_id } if attached_group.arn not in managed_policies: managed_policies[attached_group.arn] = [policy] else: managed_policies[attached_group.arn].append(policy) return managed_policies class IAMGroup(Watcher): index = 'iamgroup' i_am_singular = 'IAM Group' i_am_plural = 'IAM Groups' def __init__(self, accounts=None, debug=False): super(IAMGroup, self).__init__(accounts=accounts, debug=debug) def get_all_groups(self, conn): all_groups = [] marker = None while True: groups_response = self.wrap_aws_rate_limited_call( conn.get_all_groups, marker=marker ) all_groups.extend(groups_response.groups) if hasattr(groups_response, 'marker'): marker = groups_response.marker else: break return all_groups def get_all_group_policies(self, conn, group_name): all_group_policies = [] marker = None while True: group_policies = self.wrap_aws_rate_limited_call( conn.get_all_group_policies, group_name, marker=marker ) all_group_policies.extend(group_policies.policy_names) if hasattr(group_policies, 'marker'): marker = group_policies.marker else: break return all_group_policies def get_all_group_users(self, conn, group_name): all_group_users = [] marker = None while True: group_users_response = self.wrap_aws_rate_limited_call( conn.get_group, group_name, marker=marker ) all_group_users.extend(group_users_response.users) if hasattr(group_users_response, 'marker'): marker = group_users_response.marker else: break return all_group_users def slurp(self): """ :returns: item_list - list of IAM Groups. :returns: exception_map - A dict where the keys are a tuple containing the location of the exception and the value is the actual exception """ self.prep_for_slurp() item_list = [] exception_map = {} from security_monkey.common.sts_connect import connect for account in self.accounts: try: iam_b3 = connect(account, 'iam_boto3') managed_policies = all_managed_policies(iam_b3) iam = connect(account, 'iam') groups = self.get_all_groups(iam) except Exception as e: exc = BotoConnectionIssue(str(e), 'iamgroup', account, None) self.slurp_exception((self.index, account, 'universal'), exc, exception_map) continue for group in groups: app.logger.debug("Slurping %s (%s) from %s" % (self.i_am_singular, group.group_name, account)) if self.check_ignore_list(group.group_name): continue item_config = { 'group': dict(group), 'grouppolicies': {}, 'users': {} } if managed_policies.has_key(group.arn): item_config['managed_policies'] = managed_policies.get(group.arn) ### GROUP POLICIES ### group_policies = self.get_all_group_policies(iam, group.group_name) for policy_name in group_policies: policy = self.wrap_aws_rate_limited_call(iam.get_group_policy, group.group_name, policy_name) policy = policy.policy_document policy = urllib.unquote(policy) try: policydict = json.loads(policy) except: exc = InvalidAWSJSON(policy) self.slurp_exception((self.index, account, 'universal', group.group_name), exc, exception_map) item_config['grouppolicies'][policy_name] = dict(policydict) ### GROUP USERS ### group_users = self.get_all_group_users(iam, group['group_name']) for user in group_users: item_config['users'][user.arn] = user.user_name item = IAMGroupItem(account=account, name=group.group_name, config=item_config) item_list.append(item) return item_list, exception_map class IAMGroupItem(ChangeItem): def __init__(self, account=None, name=None, config={}): super(IAMGroupItem, self).__init__( index=IAMGroup.index, region='universal', account=account, name=name, new_config=config)
apache-2.0
[ 3, 258, 1898, 6927, 5365, 70, 20528, 12, 3277, 14, 199, 3, 199, 3, 258, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 258, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 258, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 258, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 258, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 258, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 258, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 258, 4204, 1334, 314, 844, 14, 199, 624, 199, 703, 859, 26, 6391, 63, 20372, 14, 6821, 1192, 14, 17741, 14, 17741, 63, 923, 272, 520, 3246, 26, 13074, 199, 199, 703, 1015, 447, 2672, 4, 4612, 23174, 199, 703, 28966, 447, 510, 292, 27091, 1804, 352, 15515, 665, 2051, 352, 15515, 32, 846, 70, 20528, 14, 957, 30, 768, 20372, 4416, 199, 199, 624, 199, 199, 504, 6391, 63, 20372, 14, 22226, 492, 29075, 281, 199, 504, 6391, 63, 20372, 14, 22226, 492, 7743, 2081, 199, 504, 6391, 63, 20372, 14, 3924, 492, 6378, 13226, 6243, 199, 504, 6391, 63, 20372, 14, 3924, 492, 24411, 3225, 17106, 199, 504, 6391, 63, 20372, 492, 1145, 199, 199, 646, 2022, 199, 646, 4011, 421, 199, 318, 1006, 63, 11122, 63, 11767, 8, 1631, 304, 272, 12883, 63, 11767, 275, 1052, 339, 367, 4592, 315, 2557, 14, 11767, 14, 452, 837, 267, 367, 10102, 63, 923, 315, 4592, 14, 17099, 63, 2634, 14, 452, 837, 288, 4592, 275, 469, 355, 298, 354, 582, 4592, 14, 3185, 63, 354, 12, 355, 298, 1060, 582, 4592, 14, 1060, 12, 355, 298, 1023, 582, 4592, 14, 885, 63, 1023, 63, 344, 288, 789, 953, 340, 10102, 63, 923, 14, 1060, 440, 315, 12883, 63, 11767, 26, 355, 12883, 63, 11767, 59, 17099, 63, 923, 14, 1060, 61, 275, 359, 3185, 61, 288, 587, 26, 355, 12883, 63, 11767, 59, 17099, 63, 923, 14, 1060, 1055, 740, 8, 3185, 9, 339, 372, 12883, 63, 11767, 421, 199, 533, 28155, 2448, 8, 13978, 281, 304, 272, 1478, 275, 283, 17741, 923, 7, 272, 284, 63, 455, 63, 17045, 275, 283, 41, 1156, 5611, 7, 272, 284, 63, 455, 63, 10019, 275, 283, 41, 1156, 25031, 7, 339, 347, 636, 826, 721, 277, 12, 12639, 29, 403, 12, 3105, 29, 797, 304, 267, 1613, 8, 41, 1156, 2448, 12, 291, 2843, 826, 721, 8370, 29, 8370, 12, 3105, 29, 1757, 9, 339, 347, 664, 63, 452, 63, 2634, 8, 277, 12, 2557, 304, 267, 1006, 63, 2634, 275, 942, 267, 3608, 275, 488, 398, 1830, 715, 26, 288, 4652, 63, 1310, 275, 291, 14, 3823, 63, 7231, 63, 1866, 63, 14136, 63, 1250, 8, 355, 2557, 14, 362, 63, 452, 63, 2634, 12, 355, 3608, 29, 4211, 288, 776, 953, 1006, 63, 2634, 14, 2880, 8, 2634, 63, 1310, 14, 2634, 9, 288, 340, 2688, 8, 2634, 63, 1310, 12, 283, 4211, 735, 355, 3608, 275, 4652, 63, 1310, 14, 4211, 288, 587, 26, 355, 2059, 398, 372, 1006, 63, 2634, 339, 347, 664, 63, 452, 63, 923, 63, 11767, 8, 277, 12, 2557, 12, 1572, 63, 354, 304, 267, 1006, 63, 923, 63, 11767, 275, 942, 267, 3608, 275, 488, 398, 1830, 715, 26, 288, 1572, 63, 11767, 275, 291, 14, 3823, 63, 7231, 63, 1866, 63, 14136, 63, 1250, 8, 355, 2557, 14, 362, 63, 452, 63, 923, 63, 11767, 12, 355, 1572, 63, 354, 12, 355, 3608, 29, 4211, 288, 776, 953, 1006, 63, 923, 63, 11767, 14, 2880, 8, 923, 63, 11767, 14, 3185, 63, 1247, 9, 288, 340, 2688, 8, 923, 63, 11767, 12, 283, 4211, 735, 355, 3608, 275, 1572, 63, 11767, 14, 4211, 288, 587, 26, 355, 2059, 398, 372, 1006, 63, 923, 63, 11767, 339, 347, 664, 63, 452, 63, 923, 63, 3707, 8, 277, 12, 2557, 12, 1572, 63, 354, 304, 267, 1006, 63, 923, 63, 3707, 275, 942, 267, 3608, 275, 488, 398, 1830, 715, 26, 288, 1572, 63, 3707, 63, 1310, 275, 291, 14, 3823, 63, 7231, 63, 1866, 63, 14136, 63, 1250, 8, 355, 2557, 14, 362, 63, 923, 12, 355, 1572, 63, 354, 12, 355, 3608, 29, 4211, 288, 776, 953, 1006, 63, 923, 63, 3707, 14, 2880, 8, 923, 63, 3707, 63, 1310, 14, 3707, 9, 288, 340, 2688, 8, 923, 63, 3707, 63, 1310, 12, 283, 4211, 735, 355, 3608, 275, 1572, 63, 3707, 63, 1310, 14, 4211, 288, 587, 26, 355, 2059, 398, 372, 1006, 63, 923, 63, 3707, 339, 347, 5340, 300, 80, 8, 277, 304, 267, 408, 267, 520, 5808, 26, 1242, 63, 513, 446, 769, 402, 28155, 25031, 14, 267, 520, 5808, 26, 1919, 63, 1130, 446, 437, 1211, 2382, 314, 2883, 787, 282, 2008, 3035, 314, 288, 2909, 402, 314, 1919, 436, 314, 574, 365, 314, 3503, 1919, 267, 408, 267, 291, 14, 10837, 63, 509, 63, 2482, 300, 80, 342, 267, 1242, 63, 513, 275, 942, 267, 1919, 63, 1130, 275, 1052, 398, 687, 6391, 63, 20372, 14, 2330, 14, 10329, 63, 2242, 492, 4907, 267, 367, 2933, 315, 291, 14, 8370, 26, 953, 862, 26, 355, 22361, 63, 66, 19, 275, 4907, 8, 2048, 12, 283, 17741, 63, 10914, 19, 358, 355, 12883, 63, 11767, 275, 1006, 63, 11122, 63, 11767, 8, 17741, 63, 66, 19, 9, 2234, 22361, 275, 4907, 8, 2048, 12, 283, 17741, 358, 355, 4652, 275, 291, 14, 362, 63, 452, 63, 2634, 8, 17741, 9, 288, 871, 2186, 465, 325, 26, 355, 3178, 275, 24411, 3225, 17106, 8, 495, 8, 69, 395, 283, 17741, 923, 297, 2933, 12, 488, 9, 355, 291, 14, 2482, 300, 80, 63, 1971, 1332, 277, 14, 1080, 12, 2933, 12, 283, 24866, 659, 3178, 12, 1919, 63, 1130, 9, 355, 1980, 953, 367, 1572, 315, 4652, 26 ]
[ 258, 1898, 6927, 5365, 70, 20528, 12, 3277, 14, 199, 3, 199, 3, 258, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 258, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 258, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 258, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 258, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 258, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 258, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 258, 4204, 1334, 314, 844, 14, 199, 624, 199, 703, 859, 26, 6391, 63, 20372, 14, 6821, 1192, 14, 17741, 14, 17741, 63, 923, 272, 520, 3246, 26, 13074, 199, 199, 703, 1015, 447, 2672, 4, 4612, 23174, 199, 703, 28966, 447, 510, 292, 27091, 1804, 352, 15515, 665, 2051, 352, 15515, 32, 846, 70, 20528, 14, 957, 30, 768, 20372, 4416, 199, 199, 624, 199, 199, 504, 6391, 63, 20372, 14, 22226, 492, 29075, 281, 199, 504, 6391, 63, 20372, 14, 22226, 492, 7743, 2081, 199, 504, 6391, 63, 20372, 14, 3924, 492, 6378, 13226, 6243, 199, 504, 6391, 63, 20372, 14, 3924, 492, 24411, 3225, 17106, 199, 504, 6391, 63, 20372, 492, 1145, 199, 199, 646, 2022, 199, 646, 4011, 421, 199, 318, 1006, 63, 11122, 63, 11767, 8, 1631, 304, 272, 12883, 63, 11767, 275, 1052, 339, 367, 4592, 315, 2557, 14, 11767, 14, 452, 837, 267, 367, 10102, 63, 923, 315, 4592, 14, 17099, 63, 2634, 14, 452, 837, 288, 4592, 275, 469, 355, 298, 354, 582, 4592, 14, 3185, 63, 354, 12, 355, 298, 1060, 582, 4592, 14, 1060, 12, 355, 298, 1023, 582, 4592, 14, 885, 63, 1023, 63, 344, 288, 789, 953, 340, 10102, 63, 923, 14, 1060, 440, 315, 12883, 63, 11767, 26, 355, 12883, 63, 11767, 59, 17099, 63, 923, 14, 1060, 61, 275, 359, 3185, 61, 288, 587, 26, 355, 12883, 63, 11767, 59, 17099, 63, 923, 14, 1060, 1055, 740, 8, 3185, 9, 339, 372, 12883, 63, 11767, 421, 199, 533, 28155, 2448, 8, 13978, 281, 304, 272, 1478, 275, 283, 17741, 923, 7, 272, 284, 63, 455, 63, 17045, 275, 283, 41, 1156, 5611, 7, 272, 284, 63, 455, 63, 10019, 275, 283, 41, 1156, 25031, 7, 339, 347, 636, 826, 721, 277, 12, 12639, 29, 403, 12, 3105, 29, 797, 304, 267, 1613, 8, 41, 1156, 2448, 12, 291, 2843, 826, 721, 8370, 29, 8370, 12, 3105, 29, 1757, 9, 339, 347, 664, 63, 452, 63, 2634, 8, 277, 12, 2557, 304, 267, 1006, 63, 2634, 275, 942, 267, 3608, 275, 488, 398, 1830, 715, 26, 288, 4652, 63, 1310, 275, 291, 14, 3823, 63, 7231, 63, 1866, 63, 14136, 63, 1250, 8, 355, 2557, 14, 362, 63, 452, 63, 2634, 12, 355, 3608, 29, 4211, 288, 776, 953, 1006, 63, 2634, 14, 2880, 8, 2634, 63, 1310, 14, 2634, 9, 288, 340, 2688, 8, 2634, 63, 1310, 12, 283, 4211, 735, 355, 3608, 275, 4652, 63, 1310, 14, 4211, 288, 587, 26, 355, 2059, 398, 372, 1006, 63, 2634, 339, 347, 664, 63, 452, 63, 923, 63, 11767, 8, 277, 12, 2557, 12, 1572, 63, 354, 304, 267, 1006, 63, 923, 63, 11767, 275, 942, 267, 3608, 275, 488, 398, 1830, 715, 26, 288, 1572, 63, 11767, 275, 291, 14, 3823, 63, 7231, 63, 1866, 63, 14136, 63, 1250, 8, 355, 2557, 14, 362, 63, 452, 63, 923, 63, 11767, 12, 355, 1572, 63, 354, 12, 355, 3608, 29, 4211, 288, 776, 953, 1006, 63, 923, 63, 11767, 14, 2880, 8, 923, 63, 11767, 14, 3185, 63, 1247, 9, 288, 340, 2688, 8, 923, 63, 11767, 12, 283, 4211, 735, 355, 3608, 275, 1572, 63, 11767, 14, 4211, 288, 587, 26, 355, 2059, 398, 372, 1006, 63, 923, 63, 11767, 339, 347, 664, 63, 452, 63, 923, 63, 3707, 8, 277, 12, 2557, 12, 1572, 63, 354, 304, 267, 1006, 63, 923, 63, 3707, 275, 942, 267, 3608, 275, 488, 398, 1830, 715, 26, 288, 1572, 63, 3707, 63, 1310, 275, 291, 14, 3823, 63, 7231, 63, 1866, 63, 14136, 63, 1250, 8, 355, 2557, 14, 362, 63, 923, 12, 355, 1572, 63, 354, 12, 355, 3608, 29, 4211, 288, 776, 953, 1006, 63, 923, 63, 3707, 14, 2880, 8, 923, 63, 3707, 63, 1310, 14, 3707, 9, 288, 340, 2688, 8, 923, 63, 3707, 63, 1310, 12, 283, 4211, 735, 355, 3608, 275, 1572, 63, 3707, 63, 1310, 14, 4211, 288, 587, 26, 355, 2059, 398, 372, 1006, 63, 923, 63, 3707, 339, 347, 5340, 300, 80, 8, 277, 304, 267, 408, 267, 520, 5808, 26, 1242, 63, 513, 446, 769, 402, 28155, 25031, 14, 267, 520, 5808, 26, 1919, 63, 1130, 446, 437, 1211, 2382, 314, 2883, 787, 282, 2008, 3035, 314, 288, 2909, 402, 314, 1919, 436, 314, 574, 365, 314, 3503, 1919, 267, 408, 267, 291, 14, 10837, 63, 509, 63, 2482, 300, 80, 342, 267, 1242, 63, 513, 275, 942, 267, 1919, 63, 1130, 275, 1052, 398, 687, 6391, 63, 20372, 14, 2330, 14, 10329, 63, 2242, 492, 4907, 267, 367, 2933, 315, 291, 14, 8370, 26, 953, 862, 26, 355, 22361, 63, 66, 19, 275, 4907, 8, 2048, 12, 283, 17741, 63, 10914, 19, 358, 355, 12883, 63, 11767, 275, 1006, 63, 11122, 63, 11767, 8, 17741, 63, 66, 19, 9, 2234, 22361, 275, 4907, 8, 2048, 12, 283, 17741, 358, 355, 4652, 275, 291, 14, 362, 63, 452, 63, 2634, 8, 17741, 9, 288, 871, 2186, 465, 325, 26, 355, 3178, 275, 24411, 3225, 17106, 8, 495, 8, 69, 395, 283, 17741, 923, 297, 2933, 12, 488, 9, 355, 291, 14, 2482, 300, 80, 63, 1971, 1332, 277, 14, 1080, 12, 2933, 12, 283, 24866, 659, 3178, 12, 1919, 63, 1130, 9, 355, 1980, 953, 367, 1572, 315, 4652, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json from units.compat.mock import patch from ansible.modules.network.netvisor import pn_stp from units.modules.utils import set_module_args from .nvos_module import TestNvosModule, load_fixture class TestStpModule(TestNvosModule): module = pn_stp def setUp(self): self.mock_run_nvos_commands = patch('ansible.modules.network.netvisor.pn_stp.run_cli') self.run_nvos_commands = self.mock_run_nvos_commands.start() def tearDown(self): self.mock_run_nvos_commands.stop() def run_cli_patch(self, module, cli, state_map): if state_map['update'] == 'stp-modify': results = dict( changed=True, cli_cmd=cli ) module.exit_json(**results) def load_fixtures(self, commands=None, state=None, transport='cli'): self.run_nvos_commands.side_effect = self.run_cli_patch def test_stp_modify_t1(self): set_module_args({'pn_cliswitch': 'sw01', 'pn_hello_time': '3', 'pn_stp_mode': 'rstp', 'state': 'update'}) result = self.execute_module(changed=True, state='update') expected_cmd = '/usr/bin/cli --quiet -e --no-login-prompt switch sw01 stp-modify hello-time 3 root-guard-wait-time 20 mst-max-hops 20 max-age 20 ' expected_cmd += 'stp-mode rstp forwarding-delay 15 bridge-priority 32768' self.assertEqual(result['cli_cmd'], expected_cmd) def test_stp_modify_t2(self): set_module_args({'pn_cliswitch': 'sw01', 'pn_root_guard_wait_time': '50', 'state': 'update'}) result = self.execute_module(changed=True, state='update') expected_cmd = '/usr/bin/cli --quiet -e --no-login-prompt switch sw01 stp-modify hello-time 2 root-guard-wait-time 50 mst-max-hops 20 ' expected_cmd += 'max-age 20 forwarding-delay 15 bridge-priority 32768' self.assertEqual(result['cli_cmd'], expected_cmd)
gpl-3.0
[ 3, 1898, 26, 334, 67, 9, 14894, 12, 7497, 2302, 5610, 17138, 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, 646, 2022, 199, 199, 504, 6204, 14, 5819, 14, 1805, 492, 3371, 199, 504, 3242, 14, 3112, 14, 1200, 14, 846, 8286, 492, 13631, 63, 20643, 199, 504, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 199, 504, 1275, 15969, 736, 63, 578, 492, 1379, 46, 86, 736, 2377, 12, 2248, 63, 5997, 421, 199, 533, 1379, 51, 683, 2377, 8, 774, 46, 86, 736, 2377, 304, 339, 859, 275, 13631, 63, 20643, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1805, 63, 1065, 63, 15969, 736, 63, 4405, 275, 3371, 360, 4853, 14, 3112, 14, 1200, 14, 846, 8286, 14, 4812, 63, 20643, 14, 1065, 63, 2764, 358, 267, 291, 14, 1065, 63, 15969, 736, 63, 4405, 275, 291, 14, 1805, 63, 1065, 63, 15969, 736, 63, 4405, 14, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1805, 63, 1065, 63, 15969, 736, 63, 4405, 14, 2379, 342, 339, 347, 1255, 63, 2764, 63, 2068, 8, 277, 12, 859, 12, 5053, 12, 1174, 63, 1130, 304, 267, 340, 1174, 63, 1130, 459, 873, 418, 508, 283, 20643, 13, 8951, 356, 288, 2058, 275, 1211, 8, 355, 2896, 29, 549, 12, 355, 5053, 63, 1760, 29, 2764, 288, 776, 267, 859, 14, 2224, 63, 1001, 3682, 2604, 9, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 12, 1174, 29, 403, 12, 7773, 534, 2764, 735, 267, 291, 14, 1065, 63, 15969, 736, 63, 4405, 14, 2441, 63, 5881, 275, 291, 14, 1065, 63, 2764, 63, 2068, 339, 347, 511, 63, 20643, 63, 8951, 63, 84, 17, 8, 277, 304, 267, 663, 63, 578, 63, 589, 3252, 4812, 63, 2764, 5656, 356, 283, 3519, 614, 297, 283, 4812, 63, 5006, 63, 521, 356, 283, 19, 297, 586, 283, 4812, 63, 20643, 63, 632, 356, 283, 8332, 80, 297, 283, 929, 356, 283, 873, 3071, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 1174, 534, 873, 358, 267, 1420, 63, 1760, 275, 1994, 2647, 15, 1393, 15, 2764, 1553, 10243, 446, 69, 1553, 889, 13, 2886, 13, 7650, 221, 6258, 5584, 614, 410, 80, 13, 8951, 221, 16509, 13, 521, 650, 1738, 13, 15606, 13, 2573, 13, 521, 3388, 333, 270, 13, 988, 13, 72, 1483, 3388, 1390, 13, 474, 3388, 283, 267, 1420, 63, 1760, 847, 283, 20643, 13, 632, 519, 20643, 24119, 13, 5814, 4114, 13928, 13, 6693, 20939, 2333, 7, 267, 291, 14, 629, 8, 1099, 459, 2764, 63, 1760, 995, 1420, 63, 1760, 9, 339, 347, 511, 63, 20643, 63, 8951, 63, 84, 18, 8, 277, 304, 267, 663, 63, 578, 63, 589, 3252, 4812, 63, 2764, 5656, 356, 283, 3519, 614, 297, 283, 4812, 63, 1231, 63, 15606, 63, 2573, 63, 521, 356, 283, 1400, 297, 586, 283, 929, 356, 283, 873, 3071, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 1174, 534, 873, 358, 267, 1420, 63, 1760, 275, 1994, 2647, 15, 1393, 15, 2764, 1553, 10243, 446, 69, 1553, 889, 13, 2886, 13, 7650, 221, 6258, 5584, 614, 410, 80, 13, 8951, 221, 16509, 13, 521, 499, 1738, 13, 15606, 13, 2573, 13, 521, 5238, 333, 270, 13, 988, 13, 72, 1483, 3388, 283, 267, 1420, 63, 1760, 847, 283, 988, 13, 474, 3388, 24119, 13, 5814, 4114, 13928, 13, 6693, 20939, 2333, 7, 267, 291, 14, 629, 8, 1099, 459, 2764, 63, 1760, 995, 1420, 63, 1760, 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 ]
[ 1898, 26, 334, 67, 9, 14894, 12, 7497, 2302, 5610, 17138, 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, 646, 2022, 199, 199, 504, 6204, 14, 5819, 14, 1805, 492, 3371, 199, 504, 3242, 14, 3112, 14, 1200, 14, 846, 8286, 492, 13631, 63, 20643, 199, 504, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 199, 504, 1275, 15969, 736, 63, 578, 492, 1379, 46, 86, 736, 2377, 12, 2248, 63, 5997, 421, 199, 533, 1379, 51, 683, 2377, 8, 774, 46, 86, 736, 2377, 304, 339, 859, 275, 13631, 63, 20643, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1805, 63, 1065, 63, 15969, 736, 63, 4405, 275, 3371, 360, 4853, 14, 3112, 14, 1200, 14, 846, 8286, 14, 4812, 63, 20643, 14, 1065, 63, 2764, 358, 267, 291, 14, 1065, 63, 15969, 736, 63, 4405, 275, 291, 14, 1805, 63, 1065, 63, 15969, 736, 63, 4405, 14, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1805, 63, 1065, 63, 15969, 736, 63, 4405, 14, 2379, 342, 339, 347, 1255, 63, 2764, 63, 2068, 8, 277, 12, 859, 12, 5053, 12, 1174, 63, 1130, 304, 267, 340, 1174, 63, 1130, 459, 873, 418, 508, 283, 20643, 13, 8951, 356, 288, 2058, 275, 1211, 8, 355, 2896, 29, 549, 12, 355, 5053, 63, 1760, 29, 2764, 288, 776, 267, 859, 14, 2224, 63, 1001, 3682, 2604, 9, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 12, 1174, 29, 403, 12, 7773, 534, 2764, 735, 267, 291, 14, 1065, 63, 15969, 736, 63, 4405, 14, 2441, 63, 5881, 275, 291, 14, 1065, 63, 2764, 63, 2068, 339, 347, 511, 63, 20643, 63, 8951, 63, 84, 17, 8, 277, 304, 267, 663, 63, 578, 63, 589, 3252, 4812, 63, 2764, 5656, 356, 283, 3519, 614, 297, 283, 4812, 63, 5006, 63, 521, 356, 283, 19, 297, 586, 283, 4812, 63, 20643, 63, 632, 356, 283, 8332, 80, 297, 283, 929, 356, 283, 873, 3071, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 1174, 534, 873, 358, 267, 1420, 63, 1760, 275, 1994, 2647, 15, 1393, 15, 2764, 1553, 10243, 446, 69, 1553, 889, 13, 2886, 13, 7650, 221, 6258, 5584, 614, 410, 80, 13, 8951, 221, 16509, 13, 521, 650, 1738, 13, 15606, 13, 2573, 13, 521, 3388, 333, 270, 13, 988, 13, 72, 1483, 3388, 1390, 13, 474, 3388, 283, 267, 1420, 63, 1760, 847, 283, 20643, 13, 632, 519, 20643, 24119, 13, 5814, 4114, 13928, 13, 6693, 20939, 2333, 7, 267, 291, 14, 629, 8, 1099, 459, 2764, 63, 1760, 995, 1420, 63, 1760, 9, 339, 347, 511, 63, 20643, 63, 8951, 63, 84, 18, 8, 277, 304, 267, 663, 63, 578, 63, 589, 3252, 4812, 63, 2764, 5656, 356, 283, 3519, 614, 297, 283, 4812, 63, 1231, 63, 15606, 63, 2573, 63, 521, 356, 283, 1400, 297, 586, 283, 929, 356, 283, 873, 3071, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 1174, 534, 873, 358, 267, 1420, 63, 1760, 275, 1994, 2647, 15, 1393, 15, 2764, 1553, 10243, 446, 69, 1553, 889, 13, 2886, 13, 7650, 221, 6258, 5584, 614, 410, 80, 13, 8951, 221, 16509, 13, 521, 499, 1738, 13, 15606, 13, 2573, 13, 521, 5238, 333, 270, 13, 988, 13, 72, 1483, 3388, 283, 267, 1420, 63, 1760, 847, 283, 988, 13, 474, 3388, 24119, 13, 5814, 4114, 13928, 13, 6693, 20939, 2333, 7, 267, 291, 14, 629, 8, 1099, 459, 2764, 63, 1760, 995, 1420, 63, 1760, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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py
83
8428
"""Manage shelves of pickled objects. A "shelf" is a persistent, dictionary-like object. The difference with dbm databases is that the values (not the keys!) in a shelf can be essentially arbitrary Python objects -- anything that the "pickle" module can handle. This includes most class instances, recursive data types, and objects containing lots of shared sub-objects. The keys are ordinary strings. To summarize the interface (key is a string, data is an arbitrary object): import shelve d = shelve.open(filename) # open, with (g)dbm filename -- no suffix d[key] = data # store data at key (overwrites old data if # using an existing key) data = d[key] # retrieve a COPY of the data at key (raise # KeyError if no such key) -- NOTE that this # access returns a *copy* of the entry! del d[key] # delete data stored at key (raises KeyError # if no such key) flag = key in d # true if the key exists list = d.keys() # a list of all existing keys (slow!) d.close() # close it Dependent on the implementation, closing a persistent dictionary may or may not be necessary to flush changes to disk. Normally, d[key] returns a COPY of the entry. This needs care when mutable entries are mutated: for example, if d[key] is a list, d[key].append(anitem) does NOT modify the entry d[key] itself, as stored in the persistent mapping -- it only modifies the copy, which is then immediately discarded, so that the append has NO effect whatsoever. To append an item to d[key] in a way that will affect the persistent mapping, use: data = d[key] data.append(anitem) d[key] = data To avoid the problem with mutable entries, you may pass the keyword argument writeback=True in the call to shelve.open. When you use: d = shelve.open(filename, writeback=True) then d keeps a cache of all entries you access, and writes them all back to the persistent mapping when you call d.close(). This ensures that such usage as d[key].append(anitem) works as intended. However, using keyword argument writeback=True may consume vast amount of memory for the cache, and it may make d.close() very slow, if you access many of d's entries after opening it in this way: d has no way to check which of the entries you access are mutable and/or which ones you actually mutate, so it must cache, and write back at close, all of the entries that you access. You can call d.sync() to write back all the entries in the cache, and empty the cache (d.sync() also synchronizes the persistent dictionary on disk, if feasible). """ from pickle import Pickler, Unpickler from io import BytesIO import collections __all__ = ["Shelf", "BsdDbShelf", "DbfilenameShelf", "open"] class _ClosedDict(collections.MutableMapping): 'Marker for a closed dict. Access attempts raise a ValueError.' def closed(self, *args): raise ValueError('invalid operation on closed shelf') __iter__ = __len__ = __getitem__ = __setitem__ = __delitem__ = keys = closed def __repr__(self): return '<Closed Dictionary>' class Shelf(collections.MutableMapping): """Base class for shelf implementations. This is initialized with a dictionary-like object. See the module's __doc__ string for an overview of the interface. """ def __init__(self, dict, protocol=None, writeback=False, keyencoding="utf-8"): self.dict = dict if protocol is None: protocol = 3 self._protocol = protocol self.writeback = writeback self.cache = {} self.keyencoding = keyencoding def __iter__(self): for k in self.dict.keys(): yield k.decode(self.keyencoding) def __len__(self): return len(self.dict) def __contains__(self, key): return key.encode(self.keyencoding) in self.dict def get(self, key, default=None): if key.encode(self.keyencoding) in self.dict: return self[key] return default def __getitem__(self, key): try: value = self.cache[key] except KeyError: f = BytesIO(self.dict[key.encode(self.keyencoding)]) value = Unpickler(f).load() if self.writeback: self.cache[key] = value return value def __setitem__(self, key, value): if self.writeback: self.cache[key] = value f = BytesIO() p = Pickler(f, self._protocol) p.dump(value) self.dict[key.encode(self.keyencoding)] = f.getvalue() def __delitem__(self, key): del self.dict[key.encode(self.keyencoding)] try: del self.cache[key] except KeyError: pass def __enter__(self): return self def __exit__(self, type, value, traceback): self.close() def close(self): self.sync() try: self.dict.close() except AttributeError: pass # Catch errors that may happen when close is called from __del__ # because CPython is in interpreter shutdown. try: self.dict = _ClosedDict() except (NameError, TypeError): self.dict = None def __del__(self): if not hasattr(self, 'writeback'): # __init__ didn't succeed, so don't bother closing # see http://bugs.python.org/issue1339007 for details return self.close() def sync(self): if self.writeback and self.cache: self.writeback = False for key, entry in self.cache.items(): self[key] = entry self.writeback = True self.cache = {} if hasattr(self.dict, 'sync'): self.dict.sync() class BsdDbShelf(Shelf): """Shelf implementation using the "BSD" db interface. This adds methods first(), next(), previous(), last() and set_location() that have no counterpart in [g]dbm databases. The actual database must be opened using one of the "bsddb" modules "open" routines (i.e. bsddb.hashopen, bsddb.btopen or bsddb.rnopen) and passed to the constructor. See the module's __doc__ string for an overview of the interface. """ def __init__(self, dict, protocol=None, writeback=False, keyencoding="utf-8"): Shelf.__init__(self, dict, protocol, writeback, keyencoding) def set_location(self, key): (key, value) = self.dict.set_location(key) f = BytesIO(value) return (key.decode(self.keyencoding), Unpickler(f).load()) def next(self): (key, value) = next(self.dict) f = BytesIO(value) return (key.decode(self.keyencoding), Unpickler(f).load()) def previous(self): (key, value) = self.dict.previous() f = BytesIO(value) return (key.decode(self.keyencoding), Unpickler(f).load()) def first(self): (key, value) = self.dict.first() f = BytesIO(value) return (key.decode(self.keyencoding), Unpickler(f).load()) def last(self): (key, value) = self.dict.last() f = BytesIO(value) return (key.decode(self.keyencoding), Unpickler(f).load()) class DbfilenameShelf(Shelf): """Shelf implementation using the "dbm" generic dbm interface. This is initialized with the filename for the dbm database. See the module's __doc__ string for an overview of the interface. """ def __init__(self, filename, flag='c', protocol=None, writeback=False): import dbm Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback) def open(filename, flag='c', protocol=None, writeback=False): """Open a persistent dictionary for reading and writing. The filename parameter is the base filename for the underlying database. As a side-effect, an extension may be added to the filename and more than one file may be created. The optional flag parameter has the same interpretation as the flag parameter of dbm.open(). The optional protocol parameter specifies the version of the pickle protocol (0, 1, or 2). See the module's __doc__ string for an overview of the interface. """ return DbfilenameShelf(filename, flag, protocol, writeback)
gpl-2.0
[ 624, 20588, 1033, 352, 2310, 402, 18731, 2251, 14, 199, 199, 33, 298, 19195, 276, 2, 365, 282, 16149, 12, 2600, 13, 2930, 909, 14, 221, 710, 8865, 199, 1045, 31093, 16219, 365, 626, 314, 1338, 334, 1397, 314, 2883, 21866, 315, 282, 21920, 276, 883, 199, 1235, 28891, 9697, 2018, 2251, 1553, 7003, 626, 314, 298, 8092, 2, 199, 578, 883, 2429, 14, 221, 961, 6952, 4750, 1021, 4454, 12, 9133, 666, 199, 1313, 12, 436, 2251, 3035, 24213, 402, 5709, 1007, 13, 1462, 14, 221, 710, 2883, 199, 1530, 24801, 3326, 14, 199, 199, 1378, 22301, 314, 3217, 334, 498, 365, 282, 1059, 12, 666, 365, 376, 9697, 199, 785, 304, 398, 492, 1033, 15320, 267, 366, 275, 1033, 15320, 14, 1490, 8, 1501, 9, 327, 1551, 12, 543, 334, 71, 9, 20666, 1788, 1553, 949, 4739, 398, 366, 59, 498, 61, 275, 666, 257, 327, 3877, 666, 737, 790, 334, 1883, 16334, 2269, 666, 340, 717, 327, 1808, 376, 3411, 790, 9, 267, 666, 275, 366, 59, 498, 61, 257, 327, 8044, 282, 9357, 402, 314, 666, 737, 790, 334, 3730, 717, 327, 4067, 340, 949, 4066, 790, 9, 1553, 6944, 626, 642, 717, 327, 2879, 2529, 282, 627, 1574, 10, 402, 314, 2397, 1, 267, 2150, 366, 59, 498, 61, 420, 327, 3145, 666, 5489, 737, 790, 334, 3536, 4067, 717, 327, 340, 949, 4066, 790, 9, 267, 3305, 275, 790, 315, 366, 327, 2549, 340, 314, 790, 3495, 267, 769, 275, 366, 14, 1612, 342, 327, 282, 769, 402, 1006, 3411, 2883, 334, 14362, 21866, 398, 366, 14, 1600, 342, 755, 327, 4002, 652, 199, 199, 872, 5476, 641, 314, 4514, 12, 11261, 282, 16149, 2600, 1443, 199, 269, 1443, 440, 506, 5784, 370, 8976, 4493, 370, 4543, 14, 199, 199, 15548, 1183, 12, 366, 59, 498, 61, 2529, 282, 9357, 402, 314, 2397, 14, 221, 961, 4839, 10296, 1380, 199, 17404, 4811, 787, 8567, 972, 26, 367, 2893, 12, 340, 366, 59, 498, 61, 365, 282, 769, 12, 267, 366, 59, 498, 1055, 740, 8, 290, 1053, 9, 199, 9105, 2845, 2811, 314, 2397, 366, 59, 498, 61, 6337, 12, 465, 5489, 315, 314, 16149, 199, 4745, 1553, 652, 1454, 26473, 314, 1331, 12, 1314, 365, 2066, 9939, 199, 6409, 12910, 12, 880, 626, 314, 5666, 965, 4825, 7763, 4052, 1152, 5907, 14, 221, 4005, 5666, 376, 199, 1053, 370, 366, 59, 498, 61, 315, 282, 4340, 626, 911, 12787, 314, 16149, 4412, 12, 675, 26, 267, 666, 275, 366, 59, 498, 61, 267, 666, 14, 740, 8, 290, 1053, 9, 267, 366, 59, 498, 61, 275, 666, 199, 199, 1378, 5126, 314, 5160, 543, 17194, 4811, 12, 1265, 1443, 986, 314, 4252, 199, 2094, 2218, 894, 29, 549, 315, 314, 1240, 370, 1033, 15320, 14, 1490, 14, 221, 3979, 1265, 675, 26, 267, 366, 275, 1033, 15320, 14, 1490, 8, 1501, 12, 2218, 894, 29, 549, 9, 199, 12726, 366, 18578, 282, 2581, 402, 1006, 4811, 1265, 2879, 12, 436, 14511, 3062, 1006, 1771, 199, 475, 314, 16149, 4412, 1380, 1265, 1240, 366, 14, 1600, 1252, 221, 961, 15620, 626, 199, 10180, 4503, 465, 366, 59, 498, 1055, 740, 8, 290, 1053, 9, 5419, 465, 11619, 14, 199, 199, 18335, 5907, 12, 1808, 4252, 1423, 2218, 894, 29, 549, 1443, 9451, 373, 1810, 5982, 199, 1618, 4402, 367, 314, 2581, 12, 436, 652, 1443, 1852, 366, 14, 1600, 342, 7437, 11999, 12, 340, 1265, 199, 2732, 5002, 402, 366, 1159, 4811, 2410, 13618, 652, 315, 642, 4340, 26, 366, 965, 949, 4340, 370, 199, 1074, 1314, 402, 314, 4811, 1265, 2879, 787, 17194, 436, 15, 269, 1314, 7869, 1265, 199, 2442, 3163, 31173, 12, 880, 652, 1471, 2581, 12, 436, 2218, 1771, 737, 4002, 12, 1006, 402, 314, 199, 3189, 626, 1265, 2879, 14, 221, 2047, 883, 1240, 366, 14, 5186, 342, 370, 2218, 1771, 1006, 314, 199, 3189, 315, 314, 2581, 12, 436, 2701, 314, 2581, 334, 68, 14, 5186, 342, 2597, 15354, 6491, 199, 1589, 16149, 2600, 641, 4543, 12, 340, 1964, 305, 7247, 680, 199, 624, 199, 199, 504, 5927, 492, 16568, 1435, 12, 1910, 23468, 199, 504, 5890, 492, 11808, 199, 199, 646, 5055, 199, 199, 363, 452, 363, 275, 2097, 31306, 276, 401, 298, 34, 3893, 8882, 31306, 276, 401, 298, 8882, 1501, 31306, 276, 401, 298, 1490, 937, 199, 199, 533, 485, 15190, 2141, 8, 7882, 14, 17707, 7674, 304, 272, 283, 12825, 367, 282, 6876, 1211, 14, 221, 11003, 12454, 746, 282, 1722, 3530, 339, 347, 6876, 8, 277, 12, 627, 589, 304, 267, 746, 1722, 360, 3197, 3439, 641, 6876, 21920, 276, 358, 272, 636, 1661, 363, 275, 636, 552, 363, 275, 636, 6095, 363, 275, 636, 8617, 363, 275, 636, 13228, 363, 275, 2883, 275, 6876, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 15190, 11932, 3524, 421, 199, 533, 428, 426, 276, 8, 7882, 14, 17707, 7674, 304, 272, 408, 1563, 1021, 367, 21920, 276, 12591, 14, 339, 961, 365, 10038, 543, 282, 2600, 13, 2930, 909, 14, 272, 1666, 314, 859, 1159, 636, 1301, 363, 1059, 367, 376, 23503, 402, 314, 3217, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1211, 12, 4113, 29, 403, 12, 2218, 894, 29, 797, 12, 326, 790, 2991, 628, 1624, 13, 24, 2349, 267, 291, 14, 807, 275, 1211, 267, 340, 4113, 365, 488, 26, 288, 4113, 275, 650, 267, 291, 423, 3922, 275, 4113, 267, 291, 14, 952, 894, 275, 2218, 894, 267, 291, 14, 1637, 275, 1052, 267, 291, 14, 498, 2991, 275, 790, 2991, 339, 347, 636, 1661, 721, 277, 304, 267, 367, 1022, 315, 291, 14, 807, 14, 1612, 837, 288, 1995, 1022, 14, 2708, 8, 277, 14, 498, 2991, 9, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 14, 807, 9, 339, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 372, 790, 14, 2143, 8, 277, 14, 498, 2991, 9, 315, 291, 14, 807, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 340, 790, 14, 2143, 8, 277, 14, 498, 2991, 9, 315, 291, 14, 807, 26, 288, 372, 291, 59 ]
[ 20588, 1033, 352, 2310, 402, 18731, 2251, 14, 199, 199, 33, 298, 19195, 276, 2, 365, 282, 16149, 12, 2600, 13, 2930, 909, 14, 221, 710, 8865, 199, 1045, 31093, 16219, 365, 626, 314, 1338, 334, 1397, 314, 2883, 21866, 315, 282, 21920, 276, 883, 199, 1235, 28891, 9697, 2018, 2251, 1553, 7003, 626, 314, 298, 8092, 2, 199, 578, 883, 2429, 14, 221, 961, 6952, 4750, 1021, 4454, 12, 9133, 666, 199, 1313, 12, 436, 2251, 3035, 24213, 402, 5709, 1007, 13, 1462, 14, 221, 710, 2883, 199, 1530, 24801, 3326, 14, 199, 199, 1378, 22301, 314, 3217, 334, 498, 365, 282, 1059, 12, 666, 365, 376, 9697, 199, 785, 304, 398, 492, 1033, 15320, 267, 366, 275, 1033, 15320, 14, 1490, 8, 1501, 9, 327, 1551, 12, 543, 334, 71, 9, 20666, 1788, 1553, 949, 4739, 398, 366, 59, 498, 61, 275, 666, 257, 327, 3877, 666, 737, 790, 334, 1883, 16334, 2269, 666, 340, 717, 327, 1808, 376, 3411, 790, 9, 267, 666, 275, 366, 59, 498, 61, 257, 327, 8044, 282, 9357, 402, 314, 666, 737, 790, 334, 3730, 717, 327, 4067, 340, 949, 4066, 790, 9, 1553, 6944, 626, 642, 717, 327, 2879, 2529, 282, 627, 1574, 10, 402, 314, 2397, 1, 267, 2150, 366, 59, 498, 61, 420, 327, 3145, 666, 5489, 737, 790, 334, 3536, 4067, 717, 327, 340, 949, 4066, 790, 9, 267, 3305, 275, 790, 315, 366, 327, 2549, 340, 314, 790, 3495, 267, 769, 275, 366, 14, 1612, 342, 327, 282, 769, 402, 1006, 3411, 2883, 334, 14362, 21866, 398, 366, 14, 1600, 342, 755, 327, 4002, 652, 199, 199, 872, 5476, 641, 314, 4514, 12, 11261, 282, 16149, 2600, 1443, 199, 269, 1443, 440, 506, 5784, 370, 8976, 4493, 370, 4543, 14, 199, 199, 15548, 1183, 12, 366, 59, 498, 61, 2529, 282, 9357, 402, 314, 2397, 14, 221, 961, 4839, 10296, 1380, 199, 17404, 4811, 787, 8567, 972, 26, 367, 2893, 12, 340, 366, 59, 498, 61, 365, 282, 769, 12, 267, 366, 59, 498, 1055, 740, 8, 290, 1053, 9, 199, 9105, 2845, 2811, 314, 2397, 366, 59, 498, 61, 6337, 12, 465, 5489, 315, 314, 16149, 199, 4745, 1553, 652, 1454, 26473, 314, 1331, 12, 1314, 365, 2066, 9939, 199, 6409, 12910, 12, 880, 626, 314, 5666, 965, 4825, 7763, 4052, 1152, 5907, 14, 221, 4005, 5666, 376, 199, 1053, 370, 366, 59, 498, 61, 315, 282, 4340, 626, 911, 12787, 314, 16149, 4412, 12, 675, 26, 267, 666, 275, 366, 59, 498, 61, 267, 666, 14, 740, 8, 290, 1053, 9, 267, 366, 59, 498, 61, 275, 666, 199, 199, 1378, 5126, 314, 5160, 543, 17194, 4811, 12, 1265, 1443, 986, 314, 4252, 199, 2094, 2218, 894, 29, 549, 315, 314, 1240, 370, 1033, 15320, 14, 1490, 14, 221, 3979, 1265, 675, 26, 267, 366, 275, 1033, 15320, 14, 1490, 8, 1501, 12, 2218, 894, 29, 549, 9, 199, 12726, 366, 18578, 282, 2581, 402, 1006, 4811, 1265, 2879, 12, 436, 14511, 3062, 1006, 1771, 199, 475, 314, 16149, 4412, 1380, 1265, 1240, 366, 14, 1600, 1252, 221, 961, 15620, 626, 199, 10180, 4503, 465, 366, 59, 498, 1055, 740, 8, 290, 1053, 9, 5419, 465, 11619, 14, 199, 199, 18335, 5907, 12, 1808, 4252, 1423, 2218, 894, 29, 549, 1443, 9451, 373, 1810, 5982, 199, 1618, 4402, 367, 314, 2581, 12, 436, 652, 1443, 1852, 366, 14, 1600, 342, 7437, 11999, 12, 340, 1265, 199, 2732, 5002, 402, 366, 1159, 4811, 2410, 13618, 652, 315, 642, 4340, 26, 366, 965, 949, 4340, 370, 199, 1074, 1314, 402, 314, 4811, 1265, 2879, 787, 17194, 436, 15, 269, 1314, 7869, 1265, 199, 2442, 3163, 31173, 12, 880, 652, 1471, 2581, 12, 436, 2218, 1771, 737, 4002, 12, 1006, 402, 314, 199, 3189, 626, 1265, 2879, 14, 221, 2047, 883, 1240, 366, 14, 5186, 342, 370, 2218, 1771, 1006, 314, 199, 3189, 315, 314, 2581, 12, 436, 2701, 314, 2581, 334, 68, 14, 5186, 342, 2597, 15354, 6491, 199, 1589, 16149, 2600, 641, 4543, 12, 340, 1964, 305, 7247, 680, 199, 624, 199, 199, 504, 5927, 492, 16568, 1435, 12, 1910, 23468, 199, 504, 5890, 492, 11808, 199, 199, 646, 5055, 199, 199, 363, 452, 363, 275, 2097, 31306, 276, 401, 298, 34, 3893, 8882, 31306, 276, 401, 298, 8882, 1501, 31306, 276, 401, 298, 1490, 937, 199, 199, 533, 485, 15190, 2141, 8, 7882, 14, 17707, 7674, 304, 272, 283, 12825, 367, 282, 6876, 1211, 14, 221, 11003, 12454, 746, 282, 1722, 3530, 339, 347, 6876, 8, 277, 12, 627, 589, 304, 267, 746, 1722, 360, 3197, 3439, 641, 6876, 21920, 276, 358, 272, 636, 1661, 363, 275, 636, 552, 363, 275, 636, 6095, 363, 275, 636, 8617, 363, 275, 636, 13228, 363, 275, 2883, 275, 6876, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 15190, 11932, 3524, 421, 199, 533, 428, 426, 276, 8, 7882, 14, 17707, 7674, 304, 272, 408, 1563, 1021, 367, 21920, 276, 12591, 14, 339, 961, 365, 10038, 543, 282, 2600, 13, 2930, 909, 14, 272, 1666, 314, 859, 1159, 636, 1301, 363, 1059, 367, 376, 23503, 402, 314, 3217, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1211, 12, 4113, 29, 403, 12, 2218, 894, 29, 797, 12, 326, 790, 2991, 628, 1624, 13, 24, 2349, 267, 291, 14, 807, 275, 1211, 267, 340, 4113, 365, 488, 26, 288, 4113, 275, 650, 267, 291, 423, 3922, 275, 4113, 267, 291, 14, 952, 894, 275, 2218, 894, 267, 291, 14, 1637, 275, 1052, 267, 291, 14, 498, 2991, 275, 790, 2991, 339, 347, 636, 1661, 721, 277, 304, 267, 367, 1022, 315, 291, 14, 807, 14, 1612, 837, 288, 1995, 1022, 14, 2708, 8, 277, 14, 498, 2991, 9, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 14, 807, 9, 339, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 372, 790, 14, 2143, 8, 277, 14, 498, 2991, 9, 315, 291, 14, 807, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 340, 790, 14, 2143, 8, 277, 14, 498, 2991, 9, 315, 291, 14, 807, 26, 288, 372, 291, 59, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
danakj/chromium
third_party/closure_linter/closure_linter/tokenutil_test.py
109
7678
#!/usr/bin/env python # # Copyright 2012 The Closure Linter 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. """Unit tests for the scopeutil module.""" # Allow non-Google copyright # pylint: disable=g-bad-file-header __author__ = ('nnaze@google.com (Nathan Naze)') import unittest as googletest from closure_linter import ecmametadatapass from closure_linter import javascripttokens from closure_linter import testutil from closure_linter import tokenutil class FakeToken(object): pass class TokenUtilTest(googletest.TestCase): def testGetTokenRange(self): a = FakeToken() b = FakeToken() c = FakeToken() d = FakeToken() e = FakeToken() a.next = b b.next = c c.next = d self.assertEquals([a, b, c, d], tokenutil.GetTokenRange(a, d)) # This is an error as e does not come after a in the token chain. self.assertRaises(Exception, lambda: tokenutil.GetTokenRange(a, e)) def testTokensToString(self): a = FakeToken() b = FakeToken() c = FakeToken() d = FakeToken() e = FakeToken() a.string = 'aaa' b.string = 'bbb' c.string = 'ccc' d.string = 'ddd' e.string = 'eee' a.line_number = 5 b.line_number = 6 c.line_number = 6 d.line_number = 10 e.line_number = 11 self.assertEquals( 'aaa\nbbbccc\n\n\n\nddd\neee', tokenutil.TokensToString([a, b, c, d, e])) self.assertEquals( 'ddd\neee\naaa\nbbbccc', tokenutil.TokensToString([d, e, a, b, c]), 'Neighboring tokens not in line_number order should have a newline ' 'between them.') def testGetPreviousCodeToken(self): tokens = testutil.TokenizeSource(""" start1. // comment /* another comment */ end1 """) def _GetTokenStartingWith(token_starts_with): for t in tokens: if t.string.startswith(token_starts_with): return t self.assertEquals( None, tokenutil.GetPreviousCodeToken(_GetTokenStartingWith('start1'))) self.assertEquals( 'start1.', tokenutil.GetPreviousCodeToken(_GetTokenStartingWith('end1')).string) def testGetNextCodeToken(self): tokens = testutil.TokenizeSource(""" start1. // comment /* another comment */ end1 """) def _GetTokenStartingWith(token_starts_with): for t in tokens: if t.string.startswith(token_starts_with): return t self.assertEquals( 'end1', tokenutil.GetNextCodeToken(_GetTokenStartingWith('start1')).string) self.assertEquals( None, tokenutil.GetNextCodeToken(_GetTokenStartingWith('end1'))) def testGetIdentifierStart(self): tokens = testutil.TokenizeSource(""" start1 . // comment prototype. /* another comment */ end1 ['edge'][case].prototype. end2 = function() {} """) def _GetTokenStartingWith(token_starts_with): for t in tokens: if t.string.startswith(token_starts_with): return t self.assertEquals( 'start1', tokenutil.GetIdentifierStart(_GetTokenStartingWith('end1')).string) self.assertEquals( 'start1', tokenutil.GetIdentifierStart(_GetTokenStartingWith('start1')).string) self.assertEquals( None, tokenutil.GetIdentifierStart(_GetTokenStartingWith('end2'))) def testInsertTokenBefore(self): self.AssertInsertTokenAfterBefore(False) def testInsertTokenAfter(self): self.AssertInsertTokenAfterBefore(True) def AssertInsertTokenAfterBefore(self, after): new_token = javascripttokens.JavaScriptToken( 'a', javascripttokens.JavaScriptTokenType.IDENTIFIER, 1, 1) existing_token1 = javascripttokens.JavaScriptToken( 'var', javascripttokens.JavaScriptTokenType.KEYWORD, 1, 1) existing_token1.start_index = 0 existing_token1.metadata = ecmametadatapass.EcmaMetaData() existing_token2 = javascripttokens.JavaScriptToken( ' ', javascripttokens.JavaScriptTokenType.WHITESPACE, 1, 1) existing_token2.start_index = 3 existing_token2.metadata = ecmametadatapass.EcmaMetaData() existing_token2.metadata.last_code = existing_token1 existing_token1.next = existing_token2 existing_token2.previous = existing_token1 if after: tokenutil.InsertTokenAfter(new_token, existing_token1) else: tokenutil.InsertTokenBefore(new_token, existing_token2) self.assertEquals(existing_token1, new_token.previous) self.assertEquals(existing_token2, new_token.next) self.assertEquals(new_token, existing_token1.next) self.assertEquals(new_token, existing_token2.previous) self.assertEquals(existing_token1, new_token.metadata.last_code) self.assertEquals(new_token, existing_token2.metadata.last_code) self.assertEquals(0, existing_token1.start_index) self.assertEquals(3, new_token.start_index) self.assertEquals(4, existing_token2.start_index) def testGetIdentifierForToken(self): tokens = testutil.TokenizeSource(""" start1.abc.def.prototype. onContinuedLine (start2.abc.def .hij.klm .nop) start3.abc.def .hij = function() {}; // An absurd multi-liner. start4.abc.def. hij. klm = function() {}; start5 . aaa . bbb . ccc shouldntBePartOfThePreviousSymbol start6.abc.def ghi.shouldntBePartOfThePreviousSymbol var start7 = 42; function start8() { } start9.abc. // why is there a comment here? def /* another comment */ shouldntBePart start10.abc // why is there a comment here? .def /* another comment */ shouldntBePart start11.abc. middle1.shouldNotBeIdentifier """) def _GetTokenStartingWith(token_starts_with): for t in tokens: if t.string.startswith(token_starts_with): return t self.assertEquals( 'start1.abc.def.prototype.onContinuedLine', tokenutil.GetIdentifierForToken(_GetTokenStartingWith('start1'))) self.assertEquals( 'start2.abc.def.hij.klm.nop', tokenutil.GetIdentifierForToken(_GetTokenStartingWith('start2'))) self.assertEquals( 'start3.abc.def.hij', tokenutil.GetIdentifierForToken(_GetTokenStartingWith('start3'))) self.assertEquals( 'start4.abc.def.hij.klm', tokenutil.GetIdentifierForToken(_GetTokenStartingWith('start4'))) self.assertEquals( 'start5.aaa.bbb.ccc', tokenutil.GetIdentifierForToken(_GetTokenStartingWith('start5'))) self.assertEquals( 'start6.abc.def', tokenutil.GetIdentifierForToken(_GetTokenStartingWith('start6'))) self.assertEquals( 'start7', tokenutil.GetIdentifierForToken(_GetTokenStartingWith('start7'))) self.assertEquals( 'start8', tokenutil.GetIdentifierForToken(_GetTokenStartingWith('start8'))) self.assertEquals( 'start9.abc.def', tokenutil.GetIdentifierForToken(_GetTokenStartingWith('start9'))) self.assertEquals( 'start10.abc.def', tokenutil.GetIdentifierForToken(_GetTokenStartingWith('start10'))) self.assertIsNone( tokenutil.GetIdentifierForToken(_GetTokenStartingWith('middle1'))) if __name__ == '__main__': googletest.main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6029, 710, 5980, 3253, 491, 1058, 6642, 14, 2900, 5924, 5702, 14, 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, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 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, 624, 5072, 2295, 367, 314, 4194, 1974, 859, 1041, 199, 199, 3, 9812, 2222, 13, 13266, 4248, 199, 3, 4287, 26, 3507, 29, 71, 13, 4087, 13, 493, 13, 1291, 199, 199, 363, 2502, 363, 275, 661, 78, 3540, 806, 32, 3098, 14, 957, 334, 46, 1619, 290, 11290, 806, 5942, 199, 199, 646, 2882, 465, 31141, 199, 199, 504, 17903, 63, 25240, 492, 325, 4400, 313, 1732, 1529, 199, 504, 17903, 63, 25240, 492, 18910, 4504, 199, 504, 17903, 63, 25240, 492, 511, 1974, 199, 504, 17903, 63, 25240, 492, 1526, 1974, 421, 199, 533, 7777, 3264, 8, 785, 304, 523, 986, 421, 199, 533, 8767, 9562, 774, 8, 3098, 396, 14, 1746, 304, 819, 347, 19970, 3264, 4709, 8, 277, 304, 339, 282, 275, 7777, 3264, 342, 272, 330, 275, 7777, 3264, 342, 272, 286, 275, 7777, 3264, 342, 272, 366, 275, 7777, 3264, 342, 272, 325, 275, 7777, 3264, 342, 339, 282, 14, 2184, 275, 330, 272, 330, 14, 2184, 275, 286, 272, 286, 14, 2184, 275, 366, 339, 291, 14, 2947, 779, 65, 12, 330, 12, 286, 12, 366, 467, 1526, 1974, 14, 1002, 3264, 4709, 8, 65, 12, 366, 430, 339, 327, 961, 365, 376, 1125, 465, 325, 1630, 440, 11492, 2410, 282, 315, 314, 1526, 6036, 14, 272, 291, 14, 1855, 8, 1726, 12, 2400, 26, 1526, 1974, 14, 1002, 3264, 4709, 8, 65, 12, 325, 430, 819, 347, 511, 16419, 7756, 8, 277, 304, 339, 282, 275, 7777, 3264, 342, 272, 330, 275, 7777, 3264, 342, 272, 286, 275, 7777, 3264, 342, 272, 366, 275, 7777, 3264, 342, 272, 325, 275, 7777, 3264, 342, 339, 282, 14, 875, 275, 283, 11629, 7, 272, 330, 14, 875, 275, 283, 19482, 7, 272, 286, 14, 875, 275, 283, 19504, 7, 272, 366, 14, 875, 275, 283, 15389, 7, 272, 325, 14, 875, 275, 283, 18777, 7, 339, 282, 14, 604, 63, 1955, 275, 959, 272, 330, 14, 604, 63, 1955, 275, 1227, 272, 286, 14, 604, 63, 1955, 275, 1227, 272, 366, 14, 604, 63, 1955, 275, 1616, 272, 325, 14, 604, 63, 1955, 275, 4119, 339, 291, 14, 2947, 8, 267, 283, 11629, 60, 78, 19482, 19504, 60, 78, 60, 78, 60, 78, 60, 78, 15389, 60, 685, 1024, 297, 267, 1526, 1974, 14, 16419, 7756, 779, 65, 12, 330, 12, 286, 12, 366, 12, 325, 2459, 339, 291, 14, 2947, 8, 267, 283, 15389, 60, 685, 1024, 60, 78, 11629, 60, 78, 19482, 19504, 297, 267, 1526, 1974, 14, 16419, 7756, 779, 68, 12, 325, 12, 282, 12, 330, 12, 286, 2522, 267, 283, 4698, 4594, 6854, 4645, 440, 315, 1004, 63, 1955, 1865, 1077, 1172, 282, 8057, 283, 267, 283, 13007, 3062, 2659, 819, 347, 19970, 18021, 3034, 3264, 8, 277, 304, 339, 4645, 275, 511, 1974, 14, 3264, 794, 2980, 4852, 199, 928, 17, 14, 5001, 3721, 272, 13505, 4573, 3721, 11589, 272, 1284, 17, 199, 6141, 339, 347, 485, 1002, 3264, 14139, 3007, 8, 1418, 63, 17116, 63, 1045, 304, 489, 367, 307, 315, 4645, 26, 267, 340, 307, 14, 875, 14, 2460, 8, 1418, 63, 17116, 63, 1045, 304, 881, 372, 307, 339, 291, 14, 2947, 8, 267, 488, 12, 267, 1526, 1974, 14, 1002, 18021, 3034, 3264, 1547, 1002, 3264, 14139, 3007, 360, 928, 17, 7058, 339, 291, 14, 2947, 8, 267, 283, 928, 17, 3130, 267, 1526, 1974, 14, 1002, 18021, 3034, 3264, 1547, 1002, 3264, 14139, 3007, 360, 500, 17, 11103, 875, 9, 819, 347, 19970, 5765, 3034, 3264, 8, 277, 304, 339, 4645, 275, 511, 1974, 14, 3264, 794, 2980, 4852, 199, 928, 17, 14, 5001, 3721, 272, 13505, 4573, 3721, 11589, 272, 1284, 17, 199, 6141, 339, 347, 485, 1002, 3264, 14139, 3007, 8, 1418, 63, 17116, 63, 1045, 304, 489, 367, 307, 315, 4645, 26, 267, 340, 307, 14, 875, 14, 2460, 8, 1418, 63, 17116, 63, 1045, 304, 881, 372, 307, 339, 291, 14, 2947, 8, 267, 283, 500, 17, 297, 267, 1526, 1974, 14, 20079, 3034, 3264, 1547, 1002, 3264, 14139, 3007, 360, 928, 17, 11103, 875, 9, 339, 291, 14, 2947, 8, 267, 488, 12, 267, 1526, 1974, 14, 20079, 3034, 3264, 1547, 1002, 3264, 14139, 3007, 360, 500, 17, 7058, 819, 347, 19970, 7544, 3162, 8, 277, 304, 339, 4645, 275, 511, 1974, 14, 3264, 794, 2980, 4852, 199, 928, 17, 1275, 5001, 3721, 272, 19393, 14, 13505, 4573, 3721, 11589, 272, 1284, 17, 199, 199, 459, 5173, 3488, 2546, 1055, 16141, 14, 272, 1284, 18, 275, 805, 342, 1052, 199, 6141, 339, 347, 485, 1002, 3264, 14139, 3007, 8, 1418, 63, 17116, 63, 1045, 304, 489, 367, 307, 315, 4645, 26, 267, 340, 307, 14, 875, 14, 2460, 8, 1418, 63, 17116, 63, 1045, 304, 881, 372, 307, 339, 291, 14, 2947, 8, 267, 283, 928, 17, 297, 267, 1526, 1974, 14, 1002, 7544, 3162, 1547, 1002, 3264, 14139, 3007, 360, 500, 17, 11103, 875, 9, 339, 291, 14, 2947, 8, 267, 283, 928, 17, 297, 267, 1526, 1974, 14, 1002, 7544, 3162, 1547, 1002, 3264, 14139, 3007, 360, 928, 17, 11103, 875, 9, 339, 291, 14, 2947, 8, 267, 488, 12, 267, 1526, 1974, 14, 1002, 7544, 3162, 1547, 1002, 3264, 14139, 3007, 360, 500 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6029, 710, 5980, 3253, 491, 1058, 6642, 14, 2900, 5924, 5702, 14, 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, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 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, 624, 5072, 2295, 367, 314, 4194, 1974, 859, 1041, 199, 199, 3, 9812, 2222, 13, 13266, 4248, 199, 3, 4287, 26, 3507, 29, 71, 13, 4087, 13, 493, 13, 1291, 199, 199, 363, 2502, 363, 275, 661, 78, 3540, 806, 32, 3098, 14, 957, 334, 46, 1619, 290, 11290, 806, 5942, 199, 199, 646, 2882, 465, 31141, 199, 199, 504, 17903, 63, 25240, 492, 325, 4400, 313, 1732, 1529, 199, 504, 17903, 63, 25240, 492, 18910, 4504, 199, 504, 17903, 63, 25240, 492, 511, 1974, 199, 504, 17903, 63, 25240, 492, 1526, 1974, 421, 199, 533, 7777, 3264, 8, 785, 304, 523, 986, 421, 199, 533, 8767, 9562, 774, 8, 3098, 396, 14, 1746, 304, 819, 347, 19970, 3264, 4709, 8, 277, 304, 339, 282, 275, 7777, 3264, 342, 272, 330, 275, 7777, 3264, 342, 272, 286, 275, 7777, 3264, 342, 272, 366, 275, 7777, 3264, 342, 272, 325, 275, 7777, 3264, 342, 339, 282, 14, 2184, 275, 330, 272, 330, 14, 2184, 275, 286, 272, 286, 14, 2184, 275, 366, 339, 291, 14, 2947, 779, 65, 12, 330, 12, 286, 12, 366, 467, 1526, 1974, 14, 1002, 3264, 4709, 8, 65, 12, 366, 430, 339, 327, 961, 365, 376, 1125, 465, 325, 1630, 440, 11492, 2410, 282, 315, 314, 1526, 6036, 14, 272, 291, 14, 1855, 8, 1726, 12, 2400, 26, 1526, 1974, 14, 1002, 3264, 4709, 8, 65, 12, 325, 430, 819, 347, 511, 16419, 7756, 8, 277, 304, 339, 282, 275, 7777, 3264, 342, 272, 330, 275, 7777, 3264, 342, 272, 286, 275, 7777, 3264, 342, 272, 366, 275, 7777, 3264, 342, 272, 325, 275, 7777, 3264, 342, 339, 282, 14, 875, 275, 283, 11629, 7, 272, 330, 14, 875, 275, 283, 19482, 7, 272, 286, 14, 875, 275, 283, 19504, 7, 272, 366, 14, 875, 275, 283, 15389, 7, 272, 325, 14, 875, 275, 283, 18777, 7, 339, 282, 14, 604, 63, 1955, 275, 959, 272, 330, 14, 604, 63, 1955, 275, 1227, 272, 286, 14, 604, 63, 1955, 275, 1227, 272, 366, 14, 604, 63, 1955, 275, 1616, 272, 325, 14, 604, 63, 1955, 275, 4119, 339, 291, 14, 2947, 8, 267, 283, 11629, 60, 78, 19482, 19504, 60, 78, 60, 78, 60, 78, 60, 78, 15389, 60, 685, 1024, 297, 267, 1526, 1974, 14, 16419, 7756, 779, 65, 12, 330, 12, 286, 12, 366, 12, 325, 2459, 339, 291, 14, 2947, 8, 267, 283, 15389, 60, 685, 1024, 60, 78, 11629, 60, 78, 19482, 19504, 297, 267, 1526, 1974, 14, 16419, 7756, 779, 68, 12, 325, 12, 282, 12, 330, 12, 286, 2522, 267, 283, 4698, 4594, 6854, 4645, 440, 315, 1004, 63, 1955, 1865, 1077, 1172, 282, 8057, 283, 267, 283, 13007, 3062, 2659, 819, 347, 19970, 18021, 3034, 3264, 8, 277, 304, 339, 4645, 275, 511, 1974, 14, 3264, 794, 2980, 4852, 199, 928, 17, 14, 5001, 3721, 272, 13505, 4573, 3721, 11589, 272, 1284, 17, 199, 6141, 339, 347, 485, 1002, 3264, 14139, 3007, 8, 1418, 63, 17116, 63, 1045, 304, 489, 367, 307, 315, 4645, 26, 267, 340, 307, 14, 875, 14, 2460, 8, 1418, 63, 17116, 63, 1045, 304, 881, 372, 307, 339, 291, 14, 2947, 8, 267, 488, 12, 267, 1526, 1974, 14, 1002, 18021, 3034, 3264, 1547, 1002, 3264, 14139, 3007, 360, 928, 17, 7058, 339, 291, 14, 2947, 8, 267, 283, 928, 17, 3130, 267, 1526, 1974, 14, 1002, 18021, 3034, 3264, 1547, 1002, 3264, 14139, 3007, 360, 500, 17, 11103, 875, 9, 819, 347, 19970, 5765, 3034, 3264, 8, 277, 304, 339, 4645, 275, 511, 1974, 14, 3264, 794, 2980, 4852, 199, 928, 17, 14, 5001, 3721, 272, 13505, 4573, 3721, 11589, 272, 1284, 17, 199, 6141, 339, 347, 485, 1002, 3264, 14139, 3007, 8, 1418, 63, 17116, 63, 1045, 304, 489, 367, 307, 315, 4645, 26, 267, 340, 307, 14, 875, 14, 2460, 8, 1418, 63, 17116, 63, 1045, 304, 881, 372, 307, 339, 291, 14, 2947, 8, 267, 283, 500, 17, 297, 267, 1526, 1974, 14, 20079, 3034, 3264, 1547, 1002, 3264, 14139, 3007, 360, 928, 17, 11103, 875, 9, 339, 291, 14, 2947, 8, 267, 488, 12, 267, 1526, 1974, 14, 20079, 3034, 3264, 1547, 1002, 3264, 14139, 3007, 360, 500, 17, 7058, 819, 347, 19970, 7544, 3162, 8, 277, 304, 339, 4645, 275, 511, 1974, 14, 3264, 794, 2980, 4852, 199, 928, 17, 1275, 5001, 3721, 272, 19393, 14, 13505, 4573, 3721, 11589, 272, 1284, 17, 199, 199, 459, 5173, 3488, 2546, 1055, 16141, 14, 272, 1284, 18, 275, 805, 342, 1052, 199, 6141, 339, 347, 485, 1002, 3264, 14139, 3007, 8, 1418, 63, 17116, 63, 1045, 304, 489, 367, 307, 315, 4645, 26, 267, 340, 307, 14, 875, 14, 2460, 8, 1418, 63, 17116, 63, 1045, 304, 881, 372, 307, 339, 291, 14, 2947, 8, 267, 283, 928, 17, 297, 267, 1526, 1974, 14, 1002, 7544, 3162, 1547, 1002, 3264, 14139, 3007, 360, 500, 17, 11103, 875, 9, 339, 291, 14, 2947, 8, 267, 283, 928, 17, 297, 267, 1526, 1974, 14, 1002, 7544, 3162, 1547, 1002, 3264, 14139, 3007, 360, 928, 17, 11103, 875, 9, 339, 291, 14, 2947, 8, 267, 488, 12, 267, 1526, 1974,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Qalthos/ansible
lib/ansible/modules/storage/netapp/na_elementsw_network_interfaces.py
44
10836
#!/usr/bin/python # (c) 2018, NetApp, Inc # GNU General Public License v3.0+ (see COPYING or # https://www.gnu.org/licenses/gpl-3.0.txt) ''' Element Software Node Network Interfaces - Bond 1G and 10G configuration ''' from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'certified'} DOCUMENTATION = ''' module: na_elementsw_network_interfaces short_description: NetApp Element Software Configure Node Network Interfaces extends_documentation_fragment: - netapp.solidfire version_added: '2.7' author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> description: - Configure Element SW Node Network Interfaces for Bond 1G and 10G IP address. options: method: description: - Type of Method used to configure the interface. - method depends on other settings such as the use of a static IP address, which will change the method to static. - loopback - Used to define the IPv4 loopback interface. - manual - Used to define interfaces for which no configuration is done by default. - dhcp - May be used to obtain an IP address via DHCP. - static - Used to define Ethernet interfaces with statically allocated IPv4 addresses. choices: ['loopback', 'manual', 'dhcp', 'static'] required: true ip_address_1g: description: - IP address for the 1G network. required: true ip_address_10g: description: - IP address for the 10G network. required: true subnet_1g: description: - 1GbE Subnet Mask. required: true subnet_10g: description: - 10GbE Subnet Mask. required: true gateway_address_1g: description: - Router network address to send packets out of the local network. required: true gateway_address_10g: description: - Router network address to send packets out of the local network. required: true mtu_1g: description: - Maximum Transmission Unit for 1GbE, Largest packet size that a network protocol can transmit. - Must be greater than or equal to 1500 bytes. default: '1500' mtu_10g: description: - Maximum Transmission Unit for 10GbE, Largest packet size that a network protocol can transmit. - Must be greater than or equal to 1500 bytes. default: '1500' dns_nameservers: description: - List of addresses for domain name servers. dns_search_domains: description: - List of DNS search domains. bond_mode_1g: description: - Bond mode for 1GbE configuration. choices: ['ActivePassive', 'ALB', 'LACP'] default: 'ActivePassive' bond_mode_10g: description: - Bond mode for 10GbE configuration. choices: ['ActivePassive', 'ALB', 'LACP'] default: 'ActivePassive' lacp_1g: description: - Link Aggregation Control Protocol useful only if LACP is selected as the Bond Mode. - Slow - Packets are transmitted at 30 second intervals. - Fast - Packets are transmitted in 1 second intervals. choices: ['Fast', 'Slow'] default: 'Slow' lacp_10g: description: - Link Aggregation Control Protocol useful only if LACP is selected as the Bond Mode. - Slow - Packets are transmitted at 30 second intervals. - Fast - Packets are transmitted in 1 second intervals. choices: ['Fast', 'Slow'] default: 'Slow' virtual_network_tag: description: - This is the primary network tag. All nodes in a cluster have the same VLAN tag. ''' EXAMPLES = """ - name: Set Node network interfaces configuration for Bond 1G and 10G properties tags: - elementsw_network_interfaces na_elementsw_network_interfaces: hostname: "{{ elementsw_hostname }}" username: "{{ elementsw_username }}" password: "{{ elementsw_password }}" method: static ip_address_1g: 10.226.109.68 ip_address_10g: 10.226.201.72 subnet_1g: 255.255.255.0 subnet_10g: 255.255.255.0 gateway_address_1g: 10.193.139.1 gateway_address_10g: 10.193.140.1 mtu_1g: 1500 mtu_10g: 9000 bond_mode_1g: ActivePassive bond_mode_10g: LACP lacp_10g: Fast """ RETURN = """ msg: description: Success message returned: success type: str """ import traceback from ansible.module_utils.basic import AnsibleModule from ansible.module_utils._text import to_native import ansible.module_utils.netapp as netapp_utils HAS_SF_SDK = netapp_utils.has_sf_sdk() try: from solidfire.models import Network, NetworkConfig HAS_SF_SDK = True except Exception: HAS_SF_SDK = False class ElementSWNetworkInterfaces(object): """ Element Software Network Interfaces - Bond 1G and 10G Network configuration """ def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( method=dict(type='str', required=True, choices=['loopback', 'manual', 'dhcp', 'static']), ip_address_1g=dict(type='str', required=True), ip_address_10g=dict(type='str', required=True), subnet_1g=dict(type='str', required=True), subnet_10g=dict(type='str', required=True), gateway_address_1g=dict(type='str', required=True), gateway_address_10g=dict(type='str', required=True), mtu_1g=dict(type='str', default='1500'), mtu_10g=dict(type='str', default='1500'), dns_nameservers=dict(type='list'), dns_search_domains=dict(type='list'), bond_mode_1g=dict(type='str', default='ActivePassive', choices=['ActivePassive', 'ALB', 'LACP']), bond_mode_10g=dict(type='str', default='ActivePassive', choices=['ActivePassive', 'ALB', 'LACP']), lacp_1g=dict(type='str', default='Slow', choices=['Fast', 'Slow']), lacp_10g=dict(type='str', default='Slow', choices=['Fast', 'Slow']), virtual_network_tag=dict(type='str'), ) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True, ) input_params = self.module.params self.method = input_params['method'] self.ip_address_1g = input_params['ip_address_1g'] self.ip_address_10g = input_params['ip_address_10g'] self.subnet_1g = input_params['subnet_1g'] self.subnet_10g = input_params['subnet_10g'] self.gateway_address_1g = input_params['gateway_address_1g'] self.gateway_address_10g = input_params['gateway_address_10g'] self.mtu_1g = input_params['mtu_1g'] self.mtu_10g = input_params['mtu_10g'] self.dns_nameservers = input_params['dns_nameservers'] self.dns_search_domains = input_params['dns_search_domains'] self.bond_mode_1g = input_params['bond_mode_1g'] self.bond_mode_10g = input_params['bond_mode_10g'] self.lacp_1g = input_params['lacp_1g'] self.lacp_10g = input_params['lacp_10g'] self.virtual_network_tag = input_params['virtual_network_tag'] if HAS_SF_SDK is False: self.module.fail_json(msg="Unable to import the SolidFire Python SDK") else: self.sfe = netapp_utils.create_sf_connection(module=self.module, port=442) def set_network_config(self): """ set network configuration """ try: self.sfe.set_network_config(network=self.network_object) except Exception as exception_object: self.module.fail_json(msg='Error network setting for node %s' % (to_native(exception_object)), exception=traceback.format_exc()) def get_network_params_object(self): """ Get Element SW Network object :description: get Network object :return: NetworkConfig object :rtype: object(NetworkConfig object) """ try: bond_1g_network = NetworkConfig(method=self.method, address=self.ip_address_1g, netmask=self.subnet_1g, gateway=self.gateway_address_1g, mtu=self.mtu_1g, dns_nameservers=self.dns_nameservers, dns_search=self.dns_search_domains, bond_mode=self.bond_mode_1g, bond_lacp_rate=self.lacp_1g, virtual_network_tag=self.virtual_network_tag) bond_10g_network = NetworkConfig(method=self.method, address=self.ip_address_10g, netmask=self.subnet_10g, gateway=self.gateway_address_10g, mtu=self.mtu_10g, dns_nameservers=self.dns_nameservers, dns_search=self.dns_search_domains, bond_mode=self.bond_mode_10g, bond_lacp_rate=self.lacp_10g, virtual_network_tag=self.virtual_network_tag) network_object = Network(bond1_g=bond_1g_network, bond10_g=bond_10g_network) return network_object except Exception as e: self.module.fail_json(msg='Error with setting up network object for node 1G and 10G configuration : %s' % to_native(e), exception=to_native(e)) def apply(self): """ Check connection and initialize node with cluster ownership """ changed = False result_message = None self.network_object = self.get_network_params_object() if self.network_object is not None: self.set_network_config() changed = True else: result_message = "Skipping changes, No change requested" self.module.exit_json(changed=changed, msg=result_message) def main(): """ Main function """ elementsw_network_interfaces = ElementSWNetworkInterfaces() elementsw_network_interfaces.apply() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 334, 67, 9, 14894, 12, 28076, 12, 3277, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 199, 3, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 2344, 199, 2162, 2290, 5013, 7220, 6551, 4309, 446, 699, 7835, 413, 39, 436, 1616, 39, 2897, 199, 2344, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 2247, 8981, 936, 421, 199, 8948, 275, 1449, 199, 199, 578, 26, 11802, 63, 2108, 3519, 63, 1200, 63, 7436, 199, 199, 3612, 63, 1802, 26, 28076, 6566, 2290, 15453, 5013, 7220, 6551, 4309, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 15742, 14, 18533, 8935, 199, 1023, 63, 3270, 26, 283, 18, 14, 23, 7, 199, 2502, 26, 28076, 2622, 11682, 8593, 67, 1047, 73, 24, 647, 9, 665, 2753, 13, 4853, 5969, 32, 25830, 14, 957, 30, 199, 1802, 26, 199, 13, 15453, 6566, 17548, 5013, 7220, 6551, 4309, 367, 699, 7835, 413, 39, 436, 1616, 39, 3531, 2287, 14, 199, 199, 1419, 26, 272, 1083, 26, 267, 1369, 26, 267, 446, 2434, 402, 9075, 1202, 370, 7908, 314, 3217, 14, 267, 446, 1083, 8350, 641, 1163, 2202, 4066, 465, 314, 675, 402, 282, 2955, 3531, 2287, 12, 1314, 911, 1570, 314, 1083, 370, 2955, 14, 267, 446, 4438, 894, 446, 8051, 370, 5627, 314, 6509, 20, 4438, 894, 3217, 14, 267, 446, 8722, 446, 8051, 370, 5627, 8386, 367, 1314, 949, 2897, 365, 4224, 701, 849, 14, 267, 446, 19064, 446, 10162, 506, 1202, 370, 3332, 376, 3531, 2287, 4799, 26821, 14, 267, 446, 2955, 446, 8051, 370, 5627, 26125, 8386, 543, 2955, 1183, 17659, 6509, 20, 7149, 14, 267, 3415, 26, 788, 23983, 297, 283, 9285, 297, 283, 10801, 297, 283, 1986, 418, 267, 1415, 26, 2549, 339, 3384, 63, 1562, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 3531, 2287, 367, 314, 413, 39, 2784, 14, 267, 1415, 26, 2549, 339, 3384, 63, 1562, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 3531, 2287, 367, 314, 1616, 39, 2784, 14, 267, 1415, 26, 2549, 339, 6303, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 413, 30271, 37, 4804, 846, 17581, 14, 267, 1415, 26, 2549, 339, 6303, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 1616, 30271, 37, 4804, 846, 17581, 14, 267, 1415, 26, 2549, 339, 10391, 63, 1562, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 22708, 2784, 2287, 370, 3222, 14593, 734, 402, 314, 2257, 2784, 14, 267, 1415, 26, 2549, 339, 10391, 63, 1562, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 22708, 2784, 2287, 370, 3222, 14593, 734, 402, 314, 2257, 2784, 14, 267, 1415, 26, 2549, 339, 28270, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 14212, 6266, 2250, 12008, 367, 413, 30271, 37, 12, 491, 285, 3199, 3644, 1568, 626, 282, 2784, 4113, 883, 27754, 14, 267, 446, 9498, 506, 8932, 2419, 503, 4472, 370, 24970, 2783, 14, 267, 849, 26, 283, 27607, 7, 339, 28270, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 14212, 6266, 2250, 12008, 367, 1616, 30271, 37, 12, 491, 285, 3199, 3644, 1568, 626, 282, 2784, 4113, 883, 27754, 14, 267, 446, 9498, 506, 8932, 2419, 503, 4472, 370, 24970, 2783, 14, 267, 849, 26, 283, 27607, 7, 339, 6715, 63, 28620, 26, 267, 1369, 26, 267, 446, 3820, 402, 7149, 367, 2881, 536, 8037, 14, 339, 6715, 63, 1733, 63, 9756, 26, 267, 1369, 26, 267, 446, 3820, 402, 10237, 2754, 14006, 14, 339, 23119, 63, 632, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 699, 7835, 818, 367, 413, 30271, 37, 2897, 14, 267, 3415, 26, 788, 7472, 48, 13202, 297, 283, 748, 34, 297, 283, 44, 1348, 48, 418, 267, 849, 26, 283, 7472, 48, 13202, 7, 339, 23119, 63, 632, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 699, 7835, 818, 367, 1616, 30271, 37, 2897, 14, 267, 3415, 26, 788, 7472, 48, 13202, 297, 283, 748, 34, 297, 283, 44, 1348, 48, 418, 267, 849, 26, 283, 7472, 48, 13202, 7, 339, 1127, 1850, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 10967, 21369, 425, 8612, 11557, 2997, 1454, 340, 491, 1348, 48, 365, 4895, 465, 314, 699, 7835, 4900, 14, 267, 446, 428, 674, 446, 9954, 8716, 787, 29818, 737, 4233, 3499, 15802, 14, 267, 446, 22613, 446, 9954, 8716, 787, 29818, 315, 413, 3499, 15802, 14, 267, 3415, 26, 788, 16976, 297, 283, 51, 674, 418, 267, 849, 26, 283, 51, 674, 7, 339, 1127, 1850, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 10967, 21369, 425, 8612, 11557, 2997, 1454, 340, 491, 1348, 48, 365, 4895, 465, 314, 699, 7835, 4900, 14, 267, 446, 428, 674, 446, 9954, 8716, 787, 29818, 737, 4233, 3499, 15802, 14, 267, 446, 22613, 446, 9954, 8716, 787, 29818, 315, 413, 3499, 15802, 14, 267, 3415, 26, 788, 16976, 297, 283, 51, 674, 418, 267, 849, 26, 283, 51, 674, 7, 339, 5791, 63, 1200, 63, 1450, 26, 267, 1369, 26, 267, 446, 961, 365, 314, 5062, 2784, 1947, 14, 2900, 3380, 315, 282, 4350, 1172, 314, 2011, 17591, 1947, 14, 199, 199, 2344, 199, 199, 8918, 275, 408, 819, 446, 536, 26, 2494, 5013, 2784, 8386, 2897, 367, 699, 7835, 413, 39, 436, 1616, 39, 4382, 272, 3762, 26, 272, 446, 1819, 3519, 63, 1200, 63, 7436, 272, 11802, 63, 2108, 3519, 63, 1200, 63, 7436, 26, 489, 6246, 26, 7370, 1819, 3519, 63, 4269, 7820, 489, 3434, 26, 7370, 1819, 3519, 63, 2473, 7820, 489, 2505, 26, 7370, 1819, 3519, 63, 2060, 7820, 489, 1083, 26, 2955, 489, 3384, 63, 1562, 63, 17, 71, 26, 1616, 14, 11085, 14, 6996, 14, 2333, 489, 3384, 63, 1562, 63, 709, 71, 26, 1616, 14, 11085, 14, 1797, 14 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 334, 67, 9, 14894, 12, 28076, 12, 3277, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 199, 3, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 2344, 199, 2162, 2290, 5013, 7220, 6551, 4309, 446, 699, 7835, 413, 39, 436, 1616, 39, 2897, 199, 2344, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 2247, 8981, 936, 421, 199, 8948, 275, 1449, 199, 199, 578, 26, 11802, 63, 2108, 3519, 63, 1200, 63, 7436, 199, 199, 3612, 63, 1802, 26, 28076, 6566, 2290, 15453, 5013, 7220, 6551, 4309, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 15742, 14, 18533, 8935, 199, 1023, 63, 3270, 26, 283, 18, 14, 23, 7, 199, 2502, 26, 28076, 2622, 11682, 8593, 67, 1047, 73, 24, 647, 9, 665, 2753, 13, 4853, 5969, 32, 25830, 14, 957, 30, 199, 1802, 26, 199, 13, 15453, 6566, 17548, 5013, 7220, 6551, 4309, 367, 699, 7835, 413, 39, 436, 1616, 39, 3531, 2287, 14, 199, 199, 1419, 26, 272, 1083, 26, 267, 1369, 26, 267, 446, 2434, 402, 9075, 1202, 370, 7908, 314, 3217, 14, 267, 446, 1083, 8350, 641, 1163, 2202, 4066, 465, 314, 675, 402, 282, 2955, 3531, 2287, 12, 1314, 911, 1570, 314, 1083, 370, 2955, 14, 267, 446, 4438, 894, 446, 8051, 370, 5627, 314, 6509, 20, 4438, 894, 3217, 14, 267, 446, 8722, 446, 8051, 370, 5627, 8386, 367, 1314, 949, 2897, 365, 4224, 701, 849, 14, 267, 446, 19064, 446, 10162, 506, 1202, 370, 3332, 376, 3531, 2287, 4799, 26821, 14, 267, 446, 2955, 446, 8051, 370, 5627, 26125, 8386, 543, 2955, 1183, 17659, 6509, 20, 7149, 14, 267, 3415, 26, 788, 23983, 297, 283, 9285, 297, 283, 10801, 297, 283, 1986, 418, 267, 1415, 26, 2549, 339, 3384, 63, 1562, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 3531, 2287, 367, 314, 413, 39, 2784, 14, 267, 1415, 26, 2549, 339, 3384, 63, 1562, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 3531, 2287, 367, 314, 1616, 39, 2784, 14, 267, 1415, 26, 2549, 339, 6303, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 413, 30271, 37, 4804, 846, 17581, 14, 267, 1415, 26, 2549, 339, 6303, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 1616, 30271, 37, 4804, 846, 17581, 14, 267, 1415, 26, 2549, 339, 10391, 63, 1562, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 22708, 2784, 2287, 370, 3222, 14593, 734, 402, 314, 2257, 2784, 14, 267, 1415, 26, 2549, 339, 10391, 63, 1562, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 22708, 2784, 2287, 370, 3222, 14593, 734, 402, 314, 2257, 2784, 14, 267, 1415, 26, 2549, 339, 28270, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 14212, 6266, 2250, 12008, 367, 413, 30271, 37, 12, 491, 285, 3199, 3644, 1568, 626, 282, 2784, 4113, 883, 27754, 14, 267, 446, 9498, 506, 8932, 2419, 503, 4472, 370, 24970, 2783, 14, 267, 849, 26, 283, 27607, 7, 339, 28270, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 14212, 6266, 2250, 12008, 367, 1616, 30271, 37, 12, 491, 285, 3199, 3644, 1568, 626, 282, 2784, 4113, 883, 27754, 14, 267, 446, 9498, 506, 8932, 2419, 503, 4472, 370, 24970, 2783, 14, 267, 849, 26, 283, 27607, 7, 339, 6715, 63, 28620, 26, 267, 1369, 26, 267, 446, 3820, 402, 7149, 367, 2881, 536, 8037, 14, 339, 6715, 63, 1733, 63, 9756, 26, 267, 1369, 26, 267, 446, 3820, 402, 10237, 2754, 14006, 14, 339, 23119, 63, 632, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 699, 7835, 818, 367, 413, 30271, 37, 2897, 14, 267, 3415, 26, 788, 7472, 48, 13202, 297, 283, 748, 34, 297, 283, 44, 1348, 48, 418, 267, 849, 26, 283, 7472, 48, 13202, 7, 339, 23119, 63, 632, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 699, 7835, 818, 367, 1616, 30271, 37, 2897, 14, 267, 3415, 26, 788, 7472, 48, 13202, 297, 283, 748, 34, 297, 283, 44, 1348, 48, 418, 267, 849, 26, 283, 7472, 48, 13202, 7, 339, 1127, 1850, 63, 17, 71, 26, 267, 1369, 26, 267, 446, 10967, 21369, 425, 8612, 11557, 2997, 1454, 340, 491, 1348, 48, 365, 4895, 465, 314, 699, 7835, 4900, 14, 267, 446, 428, 674, 446, 9954, 8716, 787, 29818, 737, 4233, 3499, 15802, 14, 267, 446, 22613, 446, 9954, 8716, 787, 29818, 315, 413, 3499, 15802, 14, 267, 3415, 26, 788, 16976, 297, 283, 51, 674, 418, 267, 849, 26, 283, 51, 674, 7, 339, 1127, 1850, 63, 709, 71, 26, 267, 1369, 26, 267, 446, 10967, 21369, 425, 8612, 11557, 2997, 1454, 340, 491, 1348, 48, 365, 4895, 465, 314, 699, 7835, 4900, 14, 267, 446, 428, 674, 446, 9954, 8716, 787, 29818, 737, 4233, 3499, 15802, 14, 267, 446, 22613, 446, 9954, 8716, 787, 29818, 315, 413, 3499, 15802, 14, 267, 3415, 26, 788, 16976, 297, 283, 51, 674, 418, 267, 849, 26, 283, 51, 674, 7, 339, 5791, 63, 1200, 63, 1450, 26, 267, 1369, 26, 267, 446, 961, 365, 314, 5062, 2784, 1947, 14, 2900, 3380, 315, 282, 4350, 1172, 314, 2011, 17591, 1947, 14, 199, 199, 2344, 199, 199, 8918, 275, 408, 819, 446, 536, 26, 2494, 5013, 2784, 8386, 2897, 367, 699, 7835, 413, 39, 436, 1616, 39, 4382, 272, 3762, 26, 272, 446, 1819, 3519, 63, 1200, 63, 7436, 272, 11802, 63, 2108, 3519, 63, 1200, 63, 7436, 26, 489, 6246, 26, 7370, 1819, 3519, 63, 4269, 7820, 489, 3434, 26, 7370, 1819, 3519, 63, 2473, 7820, 489, 2505, 26, 7370, 1819, 3519, 63, 2060, 7820, 489, 1083, 26, 2955, 489, 3384, 63, 1562, 63, 17, 71, 26, 1616, 14, 11085, 14, 6996, 14, 2333, 489, 3384, 63, 1562, 63, 709, 71, 26, 1616, 14, 11085, 14, 1797, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
csmart/jockey-yum
setup.py
1
1204
#!/usr/bin/env python # (c) 2007 Canonical Ltd. # Author: Martin Pitt <martin.pitt@ubuntu.com> # This script needs python-distutils-extra, an extension to the standard # distutils which provides i18n, icon support, etc. # https://launchpad.net/python-distutils-extra from glob import glob from distutils.version import StrictVersion try: import DistUtilsExtra.auto except ImportError: import sys print >> sys.stderr, 'To build Jockey you need https://launchpad.net/python-distutils-extra' sys.exit(1) assert StrictVersion(DistUtilsExtra.auto.__version__) >= '2.4', 'needs DistUtilsExtra.auto >= 2.4' DistUtilsExtra.auto.setup( name='jockey', version='0.9.3', description='UI for managing third-party and non-free drivers', url='https://launchpad.net/jockey', license='GPL v2 or later', author='Martin Pitt', author_email='martin.pitt@ubuntu.com', data_files = [ ('share/jockey', ['backend/jockey-backend']), ('share/jockey', ['gtk/jockey-gtk.ui']), # bug in DistUtilsExtra.auto 2.2 ('share/jockey', glob('kde/*.ui')), # don't use pykdeuic4 ], scripts = ['gtk/jockey-gtk', 'kde/jockey-kde', 'text/jockey-text'], )
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 334, 67, 9, 10219, 6855, 7174, 12126, 14, 199, 3, 6529, 26, 603, 26788, 510, 390, 84, 665, 77, 26788, 14, 80, 390, 84, 32, 21151, 14, 957, 30, 199, 199, 3, 961, 2884, 4839, 2366, 13, 13350, 13, 2911, 12, 376, 3329, 370, 314, 4465, 199, 3, 7065, 1314, 6571, 284, 1085, 78, 12, 7016, 2291, 12, 5423, 14, 199, 3, 4178, 921, 9850, 6226, 14, 846, 15, 1548, 13, 13350, 13, 2911, 199, 199, 504, 5739, 492, 5739, 199, 504, 7065, 14, 1023, 492, 23052, 3353, 199, 199, 893, 26, 272, 492, 10113, 7535, 7426, 14, 2495, 199, 2590, 3545, 26, 272, 492, 984, 272, 870, 4331, 984, 14, 3083, 12, 283, 1378, 1900, 1603, 766, 14655, 1265, 1929, 4178, 921, 9850, 6226, 14, 846, 15, 1548, 13, 13350, 13, 2911, 7, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 479, 23052, 3353, 8, 12012, 7535, 7426, 14, 2495, 855, 1023, 3368, 2356, 283, 18, 14, 20, 297, 283, 10065, 10113, 7535, 7426, 14, 2495, 2356, 499, 14, 20, 7, 199, 199, 12012, 7535, 7426, 14, 2495, 14, 2758, 8, 272, 536, 534, 743, 346, 14655, 297, 272, 1015, 534, 16, 14, 25, 14, 19, 297, 272, 1369, 534, 6379, 367, 28453, 10919, 13, 7522, 436, 2222, 13, 4624, 19016, 297, 272, 1166, 534, 2859, 921, 9850, 6226, 14, 846, 15, 743, 346, 14655, 297, 272, 4190, 534, 12006, 373, 18, 503, 2945, 297, 272, 4132, 534, 45, 26788, 510, 390, 84, 297, 272, 4132, 63, 2123, 534, 77, 26788, 14, 80, 390, 84, 32, 21151, 14, 957, 297, 339, 666, 63, 1725, 275, 359, 267, 661, 6251, 15, 743, 346, 14655, 297, 788, 4620, 15, 743, 346, 14655, 13, 4620, 3815, 267, 661, 6251, 15, 743, 346, 14655, 297, 788, 12275, 15, 743, 346, 14655, 13, 12275, 14, 1907, 3815, 327, 6519, 315, 10113, 7535, 7426, 14, 2495, 499, 14, 18, 267, 661, 6251, 15, 743, 346, 14655, 297, 5739, 360, 29461, 20362, 1907, 3855, 327, 2793, 1133, 675, 1134, 29461, 85, 530, 20, 267, 2156, 272, 10554, 275, 788, 12275, 15, 743, 346, 14655, 13, 12275, 297, 283, 29461, 15, 743, 346, 14655, 13, 29461, 297, 283, 505, 15, 743, 346, 14655, 13, 505, 995, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 334, 67, 9, 10219, 6855, 7174, 12126, 14, 199, 3, 6529, 26, 603, 26788, 510, 390, 84, 665, 77, 26788, 14, 80, 390, 84, 32, 21151, 14, 957, 30, 199, 199, 3, 961, 2884, 4839, 2366, 13, 13350, 13, 2911, 12, 376, 3329, 370, 314, 4465, 199, 3, 7065, 1314, 6571, 284, 1085, 78, 12, 7016, 2291, 12, 5423, 14, 199, 3, 4178, 921, 9850, 6226, 14, 846, 15, 1548, 13, 13350, 13, 2911, 199, 199, 504, 5739, 492, 5739, 199, 504, 7065, 14, 1023, 492, 23052, 3353, 199, 199, 893, 26, 272, 492, 10113, 7535, 7426, 14, 2495, 199, 2590, 3545, 26, 272, 492, 984, 272, 870, 4331, 984, 14, 3083, 12, 283, 1378, 1900, 1603, 766, 14655, 1265, 1929, 4178, 921, 9850, 6226, 14, 846, 15, 1548, 13, 13350, 13, 2911, 7, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 479, 23052, 3353, 8, 12012, 7535, 7426, 14, 2495, 855, 1023, 3368, 2356, 283, 18, 14, 20, 297, 283, 10065, 10113, 7535, 7426, 14, 2495, 2356, 499, 14, 20, 7, 199, 199, 12012, 7535, 7426, 14, 2495, 14, 2758, 8, 272, 536, 534, 743, 346, 14655, 297, 272, 1015, 534, 16, 14, 25, 14, 19, 297, 272, 1369, 534, 6379, 367, 28453, 10919, 13, 7522, 436, 2222, 13, 4624, 19016, 297, 272, 1166, 534, 2859, 921, 9850, 6226, 14, 846, 15, 743, 346, 14655, 297, 272, 4190, 534, 12006, 373, 18, 503, 2945, 297, 272, 4132, 534, 45, 26788, 510, 390, 84, 297, 272, 4132, 63, 2123, 534, 77, 26788, 14, 80, 390, 84, 32, 21151, 14, 957, 297, 339, 666, 63, 1725, 275, 359, 267, 661, 6251, 15, 743, 346, 14655, 297, 788, 4620, 15, 743, 346, 14655, 13, 4620, 3815, 267, 661, 6251, 15, 743, 346, 14655, 297, 788, 12275, 15, 743, 346, 14655, 13, 12275, 14, 1907, 3815, 327, 6519, 315, 10113, 7535, 7426, 14, 2495, 499, 14, 18, 267, 661, 6251, 15, 743, 346, 14655, 297, 5739, 360, 29461, 20362, 1907, 3855, 327, 2793, 1133, 675, 1134, 29461, 85, 530, 20, 267, 2156, 272, 10554, 275, 788, 12275, 15, 743, 346, 14655, 13, 12275, 297, 283, 29461, 15, 743, 346, 14655, 13, 29461, 297, 283, 505, 15, 743, 346, 14655, 13, 505, 995, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MarsSnail/gyp_tools
pylib/gyp/MSVSToolFile.py
2736
1804
# Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Visual Studio project reader/writer.""" import gyp.common import gyp.easy_xml as easy_xml class Writer(object): """Visual Studio XML tool file writer.""" def __init__(self, tool_file_path, name): """Initializes the tool file. Args: tool_file_path: Path to the tool file. name: Name of the tool file. """ self.tool_file_path = tool_file_path self.name = name self.rules_section = ['Rules'] def AddCustomBuildRule(self, name, cmd, description, additional_dependencies, outputs, extensions): """Adds a rule to the tool file. Args: name: Name of the rule. description: Description of the rule. cmd: Command line of the rule. additional_dependencies: other files which may trigger the rule. outputs: outputs of the rule. extensions: extensions handled by the rule. """ rule = ['CustomBuildRule', {'Name': name, 'ExecutionDescription': description, 'CommandLine': cmd, 'Outputs': ';'.join(outputs), 'FileExtensions': ';'.join(extensions), 'AdditionalDependencies': ';'.join(additional_dependencies) }] self.rules_section.append(rule) def WriteIfChanged(self): """Writes the tool file.""" content = ['VisualStudioToolFile', {'Version': '8.00', 'Name': self.name }, self.rules_section ] easy_xml.WriteXmlIfChanged(content, self.tool_file_path, encoding="Windows-1252")
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 15039, 13225, 2199, 7002, 15, 5491, 1041, 199, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 13581, 63, 1652, 465, 8837, 63, 1652, 421, 199, 533, 24441, 8, 785, 304, 523, 408, 15039, 13225, 4692, 4744, 570, 7060, 1041, 819, 347, 636, 826, 721, 277, 12, 4744, 63, 493, 63, 515, 12, 536, 304, 272, 408, 23489, 314, 4744, 570, 14, 339, 3033, 26, 489, 4744, 63, 493, 63, 515, 26, 6912, 370, 314, 4744, 570, 14, 489, 536, 26, 2812, 402, 314, 4744, 570, 14, 272, 408, 272, 291, 14, 3557, 63, 493, 63, 515, 275, 4744, 63, 493, 63, 515, 272, 291, 14, 354, 275, 536, 272, 291, 14, 4423, 63, 2792, 275, 788, 12920, 418, 819, 347, 2654, 7223, 3425, 5065, 8, 277, 12, 536, 12, 2088, 12, 1369, 12, 586, 4722, 63, 5714, 12, 586, 4704, 12, 5478, 304, 272, 408, 14995, 282, 2332, 370, 314, 4744, 570, 14, 339, 3033, 26, 489, 536, 26, 2812, 402, 314, 2332, 14, 489, 1369, 26, 11994, 402, 314, 2332, 14, 489, 2088, 26, 5817, 1004, 402, 314, 2332, 14, 489, 4722, 63, 5714, 26, 1163, 1584, 1314, 1443, 6804, 314, 2332, 14, 489, 4704, 26, 4704, 402, 314, 2332, 14, 489, 5478, 26, 5478, 8860, 701, 314, 2332, 14, 272, 408, 272, 2332, 275, 788, 7223, 3425, 5065, 297, 288, 791, 985, 356, 536, 12, 1467, 283, 11310, 5831, 356, 1369, 12, 1467, 283, 16926, 356, 2088, 12, 1467, 283, 18669, 356, 30955, 904, 8, 4467, 395, 1467, 283, 1173, 10597, 356, 30955, 904, 8, 5359, 395, 1467, 283, 31780, 356, 326, 30955, 904, 8, 8460, 63, 5714, 9, 288, 14877, 272, 291, 14, 4423, 63, 2792, 14, 740, 8, 2200, 9, 819, 347, 6990, 3917, 6970, 8, 277, 304, 272, 408, 20908, 314, 4744, 570, 1041, 272, 1564, 275, 788, 15039, 21025, 5157, 1173, 297, 2049, 791, 3353, 356, 283, 24, 14, 383, 297, 355, 283, 985, 356, 291, 14, 354, 2049, 1660, 2049, 291, 14, 4423, 63, 2792, 2049, 1622, 272, 8837, 63, 1652, 14, 3534, 8672, 3917, 6970, 8, 1317, 12, 291, 14, 3557, 63, 493, 63, 515, 12, 3044, 2644, 628, 8647, 13, 19364, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 15039, 13225, 2199, 7002, 15, 5491, 1041, 199, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 13581, 63, 1652, 465, 8837, 63, 1652, 421, 199, 533, 24441, 8, 785, 304, 523, 408, 15039, 13225, 4692, 4744, 570, 7060, 1041, 819, 347, 636, 826, 721, 277, 12, 4744, 63, 493, 63, 515, 12, 536, 304, 272, 408, 23489, 314, 4744, 570, 14, 339, 3033, 26, 489, 4744, 63, 493, 63, 515, 26, 6912, 370, 314, 4744, 570, 14, 489, 536, 26, 2812, 402, 314, 4744, 570, 14, 272, 408, 272, 291, 14, 3557, 63, 493, 63, 515, 275, 4744, 63, 493, 63, 515, 272, 291, 14, 354, 275, 536, 272, 291, 14, 4423, 63, 2792, 275, 788, 12920, 418, 819, 347, 2654, 7223, 3425, 5065, 8, 277, 12, 536, 12, 2088, 12, 1369, 12, 586, 4722, 63, 5714, 12, 586, 4704, 12, 5478, 304, 272, 408, 14995, 282, 2332, 370, 314, 4744, 570, 14, 339, 3033, 26, 489, 536, 26, 2812, 402, 314, 2332, 14, 489, 1369, 26, 11994, 402, 314, 2332, 14, 489, 2088, 26, 5817, 1004, 402, 314, 2332, 14, 489, 4722, 63, 5714, 26, 1163, 1584, 1314, 1443, 6804, 314, 2332, 14, 489, 4704, 26, 4704, 402, 314, 2332, 14, 489, 5478, 26, 5478, 8860, 701, 314, 2332, 14, 272, 408, 272, 2332, 275, 788, 7223, 3425, 5065, 297, 288, 791, 985, 356, 536, 12, 1467, 283, 11310, 5831, 356, 1369, 12, 1467, 283, 16926, 356, 2088, 12, 1467, 283, 18669, 356, 30955, 904, 8, 4467, 395, 1467, 283, 1173, 10597, 356, 30955, 904, 8, 5359, 395, 1467, 283, 31780, 356, 326, 30955, 904, 8, 8460, 63, 5714, 9, 288, 14877, 272, 291, 14, 4423, 63, 2792, 14, 740, 8, 2200, 9, 819, 347, 6990, 3917, 6970, 8, 277, 304, 272, 408, 20908, 314, 4744, 570, 1041, 272, 1564, 275, 788, 15039, 21025, 5157, 1173, 297, 2049, 791, 3353, 356, 283, 24, 14, 383, 297, 355, 283, 985, 356, 291, 14, 354, 2049, 1660, 2049, 291, 14, 4423, 63, 2792, 2049, 1622, 272, 8837, 63, 1652, 14, 3534, 8672, 3917, 6970, 8, 1317, 12, 291, 14, 3557, 63, 493, 63, 515, 12, 3044, 2644, 628, 8647, 13, 19364, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
gersolar/stations
stations_configuration/settings.py
1
5198
# Only Celery settings for stations project. #import djcelery #djcelery.setup_loader() #BROKER_TRANSPORT = 'amqplib' #BROKER_URL = 'django://' ##CELERY_RESULT_BACKEND = 'database' #CELERY_DEFAULT_QUEUE = "default" #CELERY_QUEUES = { # "default": { # "binding_key": "task.#", # }, # "mailer": { # "binding_key": "task.#", # }, #} #CELERY_ROUTES = {'downloader.tasks.check_email_schedule': {'queue': 'mailer'}} #CELERY_TIMEZONE = 'UTC' #CELERY_CONCURRENCY = 7 # Django settings for stations project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'stations.sqlite3', } } # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # In a Windows environment this must be set to your system time zone. TIME_ZONE = 'UTC' # 'America/Buenos_Aires' # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-us' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale. USE_L10N = True # If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = '' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = '' # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( # Put strings here, like "/home/html/static" or "C:/www/django/static". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) # Make this unique, and don't share it with anybody. SECRET_KEY = 'fax%_3d9oshwed$!3s)jdn876jpj#5u&amp;50m$6naau#&amp;=zpyn%0' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( 'sslify.middleware.SSLifyMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) ROOT_URLCONF = 'stations_configuration.urls' # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'stations_configuration.wsgi.application' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'polymorphic', 'django.contrib.contenttypes', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: 'django.contrib.admindocs', 'stations', ) # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error when DEBUG=False. # See http://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, } } TEMPLATE_DIRS='templates'
mit
[ 3, 5972, 445, 19028, 2202, 367, 410, 1298, 2199, 14, 199, 199, 3, 646, 366, 74, 23593, 199, 199, 3, 18256, 23593, 14, 2758, 63, 3422, 342, 421, 199, 3, 21111, 19972, 63, 12191, 3657, 275, 283, 455, 15202, 773, 7, 199, 3, 21111, 19972, 63, 2632, 275, 283, 1176, 22399, 199, 199, 309, 30922, 63, 9517, 63, 18145, 275, 283, 4659, 7, 199, 3, 30922, 63, 3472, 63, 15125, 275, 298, 885, 2, 199, 3, 30922, 63, 10526, 9318, 275, 469, 199, 3, 198, 2, 885, 582, 469, 199, 3, 198, 198, 2, 9140, 63, 498, 582, 298, 1765, 14, 3, 401, 199, 3, 198, 1386, 199, 3, 198, 2, 391, 3566, 582, 469, 199, 3, 198, 198, 2, 9140, 63, 498, 582, 298, 1765, 14, 3, 401, 199, 3, 198, 1386, 199, 3, 93, 199, 199, 3, 30922, 63, 14999, 654, 275, 791, 22846, 14, 5054, 14, 1074, 63, 2123, 63, 7211, 356, 791, 1825, 356, 283, 391, 3566, 18620, 199, 199, 3, 30922, 63, 4961, 15353, 275, 283, 11288, 7, 199, 3, 30922, 63, 1864, 7013, 24861, 275, 1520, 199, 199, 3, 5634, 2202, 367, 410, 1298, 2199, 14, 199, 199, 5287, 275, 715, 199, 7433, 63, 5287, 275, 10990, 199, 199, 14288, 51, 275, 334, 199, 198, 3, 661, 14398, 2812, 297, 283, 12695, 63, 2123, 32, 2694, 14, 957, 659, 199, 9, 199, 199, 20600, 3960, 275, 29948, 51, 199, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 199, 198, 7, 2339, 356, 283, 270, 1298, 14, 10659, 19, 297, 272, 789, 199, 93, 199, 199, 3, 10111, 900, 5718, 367, 642, 12096, 14, 8802, 2370, 883, 506, 1911, 2348, 26, 199, 3, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 1296, 63, 1618, 63, 3903, 63, 13325, 63, 991, 63, 354, 199, 3, 22160, 440, 1006, 3415, 1443, 506, 2808, 641, 1006, 17406, 10460, 14, 199, 3, 1010, 282, 5417, 3734, 642, 1471, 506, 663, 370, 2195, 2656, 900, 5718, 14, 199, 4961, 63, 15353, 275, 283, 11288, 7, 327, 283, 8841, 15, 1713, 287, 736, 63, 28960, 470, 7, 199, 199, 3, 8466, 1233, 367, 642, 12096, 14, 2900, 3415, 883, 506, 1911, 2348, 26, 199, 3, 1455, 921, 1544, 14, 73, 1085, 2753, 29514, 14, 957, 15, 2975, 15, 3671, 13, 14227, 14, 1360, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 199, 199, 7917, 63, 998, 275, 413, 199, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 1852, 2005, 5323, 12270, 880, 465, 440, 199, 3, 370, 2248, 314, 10757, 6279, 2072, 28540, 14, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 440, 1475, 10831, 12, 5579, 436, 199, 3, 1704, 31276, 7182, 370, 314, 1453, 5867, 14, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 440, 675, 7137, 13, 14600, 29297, 14, 199, 4701, 63, 14226, 275, 715, 199, 199, 3, 24964, 10036, 931, 370, 314, 2082, 626, 911, 10266, 922, 13, 19044, 1584, 14, 199, 3, 5679, 26, 3286, 4219, 15, 4603, 15, 4603, 14, 22277, 4646, 14, 957, 15, 4603, 6687, 199, 13669, 63, 5441, 275, 2125, 199, 199, 3, 2851, 626, 10022, 314, 5898, 19733, 687, 31460, 63, 5441, 14, 4155, 3238, 370, 675, 282, 199, 3, 8520, 14457, 14, 199, 3, 6058, 26, 298, 1014, 921, 4603, 14, 22277, 4646, 14, 957, 15, 4603, 10665, 298, 1014, 921, 2694, 14, 957, 15, 4603, 6687, 199, 13669, 63, 2632, 275, 2125, 199, 199, 3, 24964, 931, 370, 314, 2082, 2955, 1584, 1077, 506, 13736, 370, 14, 199, 3, 7529, 1133, 5324, 7003, 315, 642, 2082, 28225, 27, 3877, 2195, 2955, 1584, 199, 3, 315, 8686, 7, 298, 1986, 6687, 24799, 436, 315, 27815, 9472, 63, 14455, 14, 199, 3, 5679, 26, 3286, 4219, 15, 4603, 15, 4603, 14, 22277, 4646, 14, 957, 15, 1986, 6687, 199, 10449, 63, 5441, 275, 2125, 199, 199, 3, 2851, 2403, 367, 2955, 1584, 14, 199, 3, 5679, 26, 298, 1014, 921, 4603, 14, 22277, 4646, 14, 957, 15, 1986, 6687, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 199, 3, 10961, 9918, 402, 2955, 1584, 199, 10449, 9472, 63, 14455, 275, 334, 199, 198, 3, 16280, 3326, 2348, 12, 2839, 3286, 4219, 15, 1360, 15, 1986, 2, 503, 298, 35, 11254, 1544, 15, 1176, 15, 1986, 1674, 199, 198, 3, 16763, 675, 7568, 20275, 12, 2755, 641, 5417, 14, 199, 198, 3, 7529, 1133, 19459, 370, 675, 3679, 3792, 12, 440, 3847, 3792, 14, 199, 9, 199, 199, 3, 3820, 402, 11569, 3992, 626, 5715, 4212, 370, 2342, 2955, 1584, 315, 199, 3, 7750, 9918, 14, 199, 10449, 9472, 63, 27087, 3960, 275, 334, 199, 198, 5121, 858, 14, 2828, 14, 18373, 14, 26677, 14, 17521, 11791, 297, 199, 198, 5121, 858, 14, 2828, 14, 18373, 14, 26677, 14, 2640, 13752, 11791, 297, 199, 3, 198, 5121, 858, 14, 2828, 14, 18373, 14, 26677, 14, 2698, 6408, 11791, 297, 199, 9, 199, 199, 3, 4155, 642, 3747, 12, 436, 2793, 1133, 8663, 652, 543, 1263, 2030, 14, 199, 12961, 63, 3078, 275, 283, 667, 88, 5, 63, 19, 68, 25, 22267, 24084, 4, 1, 19, 83, 9, 74, 4272, 14690, 11538, 74, 3, 21, 85, 6, 5282, 27, 1400, 77, 4, 22, 78, 2158, 85, 3, 6, 5282, 27, 29, 90, 647, 78, 5, 16, 7, 199, 199, 3, 3820, 402, 28041, 626, 5715, 4212, 370, 492, 7009, 687, 7750, 5274, 14, 199, 7433, 63, 7405, 3960, 275, 334, 199, 198, 5121, 858, 14, 1160, 14, 16370, 14, 11381, 14, 5455, 297, 199, 198, 5121, 858, 14, 1160, 14, 16370, 14, 571, 63, 12629, 14, 5455, 297, 199, 3, 198, 283, 1176, 14, 1160, 14, 16370, 14, 14488, 14, 5455, 297, 199, 9, 199, 199, 19987, 63, 13748, 275, 334, 199, 198, 1159, 83, 8209, 14, 5754, 14, 5413, 2021, 6608, 297, 199, 198, 5121, 858, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 199, 198, 5121, 858 ]
[ 5972, 445, 19028, 2202, 367, 410, 1298, 2199, 14, 199, 199, 3, 646, 366, 74, 23593, 199, 199, 3, 18256, 23593, 14, 2758, 63, 3422, 342, 421, 199, 3, 21111, 19972, 63, 12191, 3657, 275, 283, 455, 15202, 773, 7, 199, 3, 21111, 19972, 63, 2632, 275, 283, 1176, 22399, 199, 199, 309, 30922, 63, 9517, 63, 18145, 275, 283, 4659, 7, 199, 3, 30922, 63, 3472, 63, 15125, 275, 298, 885, 2, 199, 3, 30922, 63, 10526, 9318, 275, 469, 199, 3, 198, 2, 885, 582, 469, 199, 3, 198, 198, 2, 9140, 63, 498, 582, 298, 1765, 14, 3, 401, 199, 3, 198, 1386, 199, 3, 198, 2, 391, 3566, 582, 469, 199, 3, 198, 198, 2, 9140, 63, 498, 582, 298, 1765, 14, 3, 401, 199, 3, 198, 1386, 199, 3, 93, 199, 199, 3, 30922, 63, 14999, 654, 275, 791, 22846, 14, 5054, 14, 1074, 63, 2123, 63, 7211, 356, 791, 1825, 356, 283, 391, 3566, 18620, 199, 199, 3, 30922, 63, 4961, 15353, 275, 283, 11288, 7, 199, 3, 30922, 63, 1864, 7013, 24861, 275, 1520, 199, 199, 3, 5634, 2202, 367, 410, 1298, 2199, 14, 199, 199, 5287, 275, 715, 199, 7433, 63, 5287, 275, 10990, 199, 199, 14288, 51, 275, 334, 199, 198, 3, 661, 14398, 2812, 297, 283, 12695, 63, 2123, 32, 2694, 14, 957, 659, 199, 9, 199, 199, 20600, 3960, 275, 29948, 51, 199, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 199, 198, 7, 2339, 356, 283, 270, 1298, 14, 10659, 19, 297, 272, 789, 199, 93, 199, 199, 3, 10111, 900, 5718, 367, 642, 12096, 14, 8802, 2370, 883, 506, 1911, 2348, 26, 199, 3, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 1296, 63, 1618, 63, 3903, 63, 13325, 63, 991, 63, 354, 199, 3, 22160, 440, 1006, 3415, 1443, 506, 2808, 641, 1006, 17406, 10460, 14, 199, 3, 1010, 282, 5417, 3734, 642, 1471, 506, 663, 370, 2195, 2656, 900, 5718, 14, 199, 4961, 63, 15353, 275, 283, 11288, 7, 327, 283, 8841, 15, 1713, 287, 736, 63, 28960, 470, 7, 199, 199, 3, 8466, 1233, 367, 642, 12096, 14, 2900, 3415, 883, 506, 1911, 2348, 26, 199, 3, 1455, 921, 1544, 14, 73, 1085, 2753, 29514, 14, 957, 15, 2975, 15, 3671, 13, 14227, 14, 1360, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 199, 199, 7917, 63, 998, 275, 413, 199, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 1852, 2005, 5323, 12270, 880, 465, 440, 199, 3, 370, 2248, 314, 10757, 6279, 2072, 28540, 14, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 440, 1475, 10831, 12, 5579, 436, 199, 3, 1704, 31276, 7182, 370, 314, 1453, 5867, 14, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 440, 675, 7137, 13, 14600, 29297, 14, 199, 4701, 63, 14226, 275, 715, 199, 199, 3, 24964, 10036, 931, 370, 314, 2082, 626, 911, 10266, 922, 13, 19044, 1584, 14, 199, 3, 5679, 26, 3286, 4219, 15, 4603, 15, 4603, 14, 22277, 4646, 14, 957, 15, 4603, 6687, 199, 13669, 63, 5441, 275, 2125, 199, 199, 3, 2851, 626, 10022, 314, 5898, 19733, 687, 31460, 63, 5441, 14, 4155, 3238, 370, 675, 282, 199, 3, 8520, 14457, 14, 199, 3, 6058, 26, 298, 1014, 921, 4603, 14, 22277, 4646, 14, 957, 15, 4603, 10665, 298, 1014, 921, 2694, 14, 957, 15, 4603, 6687, 199, 13669, 63, 2632, 275, 2125, 199, 199, 3, 24964, 931, 370, 314, 2082, 2955, 1584, 1077, 506, 13736, 370, 14, 199, 3, 7529, 1133, 5324, 7003, 315, 642, 2082, 28225, 27, 3877, 2195, 2955, 1584, 199, 3, 315, 8686, 7, 298, 1986, 6687, 24799, 436, 315, 27815, 9472, 63, 14455, 14, 199, 3, 5679, 26, 3286, 4219, 15, 4603, 15, 4603, 14, 22277, 4646, 14, 957, 15, 1986, 6687, 199, 10449, 63, 5441, 275, 2125, 199, 199, 3, 2851, 2403, 367, 2955, 1584, 14, 199, 3, 5679, 26, 298, 1014, 921, 4603, 14, 22277, 4646, 14, 957, 15, 1986, 6687, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 199, 3, 10961, 9918, 402, 2955, 1584, 199, 10449, 9472, 63, 14455, 275, 334, 199, 198, 3, 16280, 3326, 2348, 12, 2839, 3286, 4219, 15, 1360, 15, 1986, 2, 503, 298, 35, 11254, 1544, 15, 1176, 15, 1986, 1674, 199, 198, 3, 16763, 675, 7568, 20275, 12, 2755, 641, 5417, 14, 199, 198, 3, 7529, 1133, 19459, 370, 675, 3679, 3792, 12, 440, 3847, 3792, 14, 199, 9, 199, 199, 3, 3820, 402, 11569, 3992, 626, 5715, 4212, 370, 2342, 2955, 1584, 315, 199, 3, 7750, 9918, 14, 199, 10449, 9472, 63, 27087, 3960, 275, 334, 199, 198, 5121, 858, 14, 2828, 14, 18373, 14, 26677, 14, 17521, 11791, 297, 199, 198, 5121, 858, 14, 2828, 14, 18373, 14, 26677, 14, 2640, 13752, 11791, 297, 199, 3, 198, 5121, 858, 14, 2828, 14, 18373, 14, 26677, 14, 2698, 6408, 11791, 297, 199, 9, 199, 199, 3, 4155, 642, 3747, 12, 436, 2793, 1133, 8663, 652, 543, 1263, 2030, 14, 199, 12961, 63, 3078, 275, 283, 667, 88, 5, 63, 19, 68, 25, 22267, 24084, 4, 1, 19, 83, 9, 74, 4272, 14690, 11538, 74, 3, 21, 85, 6, 5282, 27, 1400, 77, 4, 22, 78, 2158, 85, 3, 6, 5282, 27, 29, 90, 647, 78, 5, 16, 7, 199, 199, 3, 3820, 402, 28041, 626, 5715, 4212, 370, 492, 7009, 687, 7750, 5274, 14, 199, 7433, 63, 7405, 3960, 275, 334, 199, 198, 5121, 858, 14, 1160, 14, 16370, 14, 11381, 14, 5455, 297, 199, 198, 5121, 858, 14, 1160, 14, 16370, 14, 571, 63, 12629, 14, 5455, 297, 199, 3, 198, 283, 1176, 14, 1160, 14, 16370, 14, 14488, 14, 5455, 297, 199, 9, 199, 199, 19987, 63, 13748, 275, 334, 199, 198, 1159, 83, 8209, 14, 5754, 14, 5413, 2021, 6608, 297, 199, 198, 5121, 858, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 199, 198, 5121, 858, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ujenmr/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, 1419, 14, 362, 360, 22288, 30208, 735, 288, 3242, 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,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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 ]
gram526/VTK
Filters/Hybrid/Testing/Python/WarpPolyData.py
20
6369
#!/usr/bin/env python import vtk from vtk.test import Testing from vtk.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() # this example tests the warping of PolyData using thin plate splines # and with grid transforms using different interpolation modes # create a rendering window renWin = vtk.vtkRenderWindow() renWin.SetSize(600,300) sphere = vtk.vtkSphereSource() sphere.SetThetaResolution(20) sphere.SetPhiResolution(20) ap = vtk.vtkPolyDataNormals() ap.SetInputConnection(sphere.GetOutputPort()) #--------------------------- # thin plate spline transform spoints = vtk.vtkPoints() spoints.SetNumberOfPoints(10) spoints.SetPoint(0,0.000,0.000,0.500) spoints.SetPoint(1,0.000,0.000,-0.500) spoints.SetPoint(2,0.433,0.000,0.250) spoints.SetPoint(3,0.433,0.000,-0.250) spoints.SetPoint(4,-0.000,0.433,0.250) spoints.SetPoint(5,-0.000,0.433,-0.250) spoints.SetPoint(6,-0.433,-0.000,0.250) spoints.SetPoint(7,-0.433,-0.000,-0.250) spoints.SetPoint(8,0.000,-0.433,0.250) spoints.SetPoint(9,0.000,-0.433,-0.250) tpoints = vtk.vtkPoints() tpoints.SetNumberOfPoints(10) tpoints.SetPoint(0,0.000,0.000,0.800) tpoints.SetPoint(1,0.000,0.000,-0.200) tpoints.SetPoint(2,0.433,0.000,0.350) tpoints.SetPoint(3,0.433,0.000,-0.150) tpoints.SetPoint(4,-0.000,0.233,0.350) tpoints.SetPoint(5,-0.000,0.433,-0.150) tpoints.SetPoint(6,-0.433,-0.000,0.350) tpoints.SetPoint(7,-0.433,-0.000,-0.150) tpoints.SetPoint(8,0.000,-0.233,0.350) tpoints.SetPoint(9,0.000,-0.433,-0.150) thin = vtk.vtkThinPlateSplineTransform() thin.SetSourceLandmarks(spoints) thin.SetTargetLandmarks(tpoints) thin.SetBasisToR2LogR() # thin Inverse t1 = vtk.vtkGeneralTransform() t1.SetInput(thin) f11 = vtk.vtkTransformPolyDataFilter() f11.SetInputConnection(ap.GetOutputPort()) f11.SetTransform(t1) m11 = vtk.vtkDataSetMapper() m11.SetInputConnection(f11.GetOutputPort()) a11 = vtk.vtkActor() a11.SetMapper(m11) a11.RotateY(90) a11.GetProperty().SetColor(1,0,0) #[a11 GetProperty] SetRepresentationToWireframe ren11 = vtk.vtkRenderer() ren11.SetViewport(0.0,0.5,0.25,1.0) ren11.ResetCamera(-0.5,0.5,-0.5,0.5,-1,1) ren11.AddActor(a11) renWin.AddRenderer(ren11) # inverse thin plate spline transform f12 = vtk.vtkTransformPolyDataFilter() f12.SetInputConnection(ap.GetOutputPort()) f12.SetTransform(t1.GetInverse()) m12 = vtk.vtkDataSetMapper() m12.SetInputConnection(f12.GetOutputPort()) a12 = vtk.vtkActor() a12.SetMapper(m12) a12.RotateY(90) a12.GetProperty().SetColor(0.9,0.9,0) #[a12 GetProperty] SetRepresentationToWireframe ren12 = vtk.vtkRenderer() ren12.SetViewport(0.0,0.0,0.25,0.5) ren12.ResetCamera(-0.5,0.5,-0.5,0.5,-1,1) ren12.AddActor(a12) renWin.AddRenderer(ren12) #-------------------------- # grid transform, cubic interpolation gridTrans = vtk.vtkTransformToGrid() gridTrans.SetInput(t1) gridTrans.SetGridOrigin(-1.5,-1.5,-1.5) gridTrans.SetGridExtent(0,60,0,60,0,60) gridTrans.SetGridSpacing(0.05,0.05,0.05) t2 = vtk.vtkGridTransform() t2.SetDisplacementGridConnection(gridTrans.GetOutputPort()) t2.SetInterpolationModeToCubic() f21 = vtk.vtkTransformPolyDataFilter() f21.SetInputConnection(ap.GetOutputPort()) f21.SetTransform(t2) m21 = vtk.vtkDataSetMapper() m21.SetInputConnection(f21.GetOutputPort()) a21 = vtk.vtkActor() a21.SetMapper(m21) a21.RotateY(90) a21.GetProperty().SetColor(1,0,0) #[a21 GetProperty] SetRepresentationToWireframe ren21 = vtk.vtkRenderer() ren21.SetViewport(0.25,0.5,0.50,1.0) ren21.ResetCamera(-0.5,0.5,-0.5,0.5,-1,1) ren21.AddActor(a21) renWin.AddRenderer(ren21) # inverse f22 = vtk.vtkTransformPolyDataFilter() f22.SetInputConnection(ap.GetOutputPort()) f22.SetTransform(t2.GetInverse()) m22 = vtk.vtkDataSetMapper() m22.SetInputConnection(f22.GetOutputPort()) a22 = vtk.vtkActor() a22.SetMapper(m22) a22.RotateY(90) a22.GetProperty().SetColor(0.9,0.9,0) #[a22 GetProperty] SetRepresentationToWireframe ren22 = vtk.vtkRenderer() ren22.SetViewport(0.25,0.0,0.50,0.5) ren22.ResetCamera(-0.5,0.5,-0.5,0.5,-1,1) ren22.AddActor(a22) renWin.AddRenderer(ren22) #-------------------------- # grid transform, linear t3 = vtk.vtkGridTransform() t3.SetDisplacementGridConnection(gridTrans.GetOutputPort()) t3.SetInterpolationModeToLinear() f31 = vtk.vtkTransformPolyDataFilter() f31.SetInputConnection(ap.GetOutputPort()) f31.SetTransform(t3) m31 = vtk.vtkDataSetMapper() m31.SetInputConnection(f31.GetOutputPort()) a31 = vtk.vtkActor() a31.SetMapper(m31) a31.RotateY(90) a31.GetProperty().SetColor(1,0,0) #[a31 GetProperty] SetRepresentationToWireframe ren31 = vtk.vtkRenderer() ren31.SetViewport(0.50,0.5,0.75,1.0) ren31.ResetCamera(-0.5,0.5,-0.5,0.5,-1,1) ren31.AddActor(a31) renWin.AddRenderer(ren31) # inverse f32 = vtk.vtkTransformPolyDataFilter() f32.SetInputConnection(ap.GetOutputPort()) f32.SetTransform(t3.GetInverse()) m32 = vtk.vtkDataSetMapper() m32.SetInputConnection(f32.GetOutputPort()) a32 = vtk.vtkActor() a32.SetMapper(m32) a32.RotateY(90) a32.GetProperty().SetColor(0.9,0.9,0) #[a32 GetProperty] SetRepresentationToWireframe ren32 = vtk.vtkRenderer() ren32.SetViewport(0.5,0.0,0.75,0.5) ren32.ResetCamera(-0.5,0.5,-0.5,0.5,-1,1) ren32.AddActor(a32) renWin.AddRenderer(ren32) #-------------------------- # grid transform, nearest t4 = vtk.vtkGridTransform() t4.SetDisplacementGridConnection(gridTrans.GetOutputPort()) t4.SetInterpolationModeToNearestNeighbor() t4.SetInverseTolerance(0.05) f41 = vtk.vtkTransformPolyDataFilter() f41.SetInputConnection(ap.GetOutputPort()) f41.SetTransform(t4) m41 = vtk.vtkDataSetMapper() m41.SetInputConnection(f41.GetOutputPort()) a41 = vtk.vtkActor() a41.SetMapper(m41) a41.RotateY(90) a41.GetProperty().SetColor(1,0,0) #[a41 GetProperty] SetRepresentationToWireframe ren41 = vtk.vtkRenderer() ren41.SetViewport(0.75,0.5,1.0,1.0) ren41.ResetCamera(-0.5,0.5,-0.5,0.5,-1,1) ren41.AddActor(a41) renWin.AddRenderer(ren41) #inverse f42 = vtk.vtkTransformPolyDataFilter() f42.SetInputConnection(ap.GetOutputPort()) f42.SetTransform(t4.GetInverse()) m42 = vtk.vtkDataSetMapper() m42.SetInputConnection(f42.GetOutputPort()) a42 = vtk.vtkActor() a42.SetMapper(m42) a42.RotateY(90) a42.GetProperty().SetColor(0.9,0.9,0) #[a42 GetProperty] SetRepresentationToWireframe ren42 = vtk.vtkRenderer() ren42.SetViewport(0.75,0.0,1.0,0.5) ren42.ResetCamera(-0.5,0.5,-0.5,0.5,-1,1) ren42.AddActor(a42) renWin.AddRenderer(ren42) t1.RotateX(-100) t1.PostMultiply() t1.RotateX(+100) renWin.Render() # --- end of script --
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 646, 11144, 199, 504, 11144, 14, 396, 492, 11940, 199, 504, 11144, 14, 1974, 14, 9923, 492, 11144, 25702, 6405, 199, 8156, 43, 63, 3998, 63, 5441, 275, 11144, 25702, 6405, 342, 199, 199, 3, 642, 2893, 2295, 314, 3429, 4073, 402, 16869, 1451, 1808, 30758, 299, 750, 2249, 1278, 199, 3, 436, 543, 6068, 18501, 1808, 3365, 14046, 12404, 199, 3, 1218, 282, 14066, 4353, 199, 828, 8886, 275, 11144, 14, 11919, 9216, 4301, 342, 199, 828, 8886, 14, 1084, 2320, 8, 6683, 12, 5863, 9, 199, 14980, 275, 11144, 14, 11919, 22385, 2980, 342, 199, 14980, 14, 1084, 2719, 1841, 18508, 8, 1165, 9, 199, 14980, 14, 1084, 5663, 73, 18508, 8, 1165, 9, 199, 439, 275, 11144, 14, 11919, 12747, 1451, 6241, 83, 342, 199, 439, 14, 32195, 8, 14980, 14, 30810, 1012, 199, 32152, 13715, 199, 3, 30758, 299, 750, 30213, 5793, 199, 83, 3438, 275, 11144, 14, 11919, 10225, 342, 199, 83, 3438, 14, 1084, 16030, 10225, 8, 709, 9, 199, 83, 3438, 14, 1084, 3428, 8, 16, 12, 16, 14, 1493, 12, 16, 14, 1493, 12, 16, 14, 5783, 9, 199, 83, 3438, 14, 1084, 3428, 8, 17, 12, 16, 14, 1493, 12, 16, 14, 1493, 3057, 16, 14, 5783, 9, 199, 83, 3438, 14, 1084, 3428, 8, 18, 12, 16, 14, 23404, 12, 16, 14, 1493, 12, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 19, 12, 16, 14, 23404, 12, 16, 14, 1493, 3057, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 20, 3057, 16, 14, 1493, 12, 16, 14, 23404, 12, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 21, 3057, 16, 14, 1493, 12, 16, 14, 23404, 3057, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 22, 3057, 16, 14, 23404, 3057, 16, 14, 1493, 12, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 23, 3057, 16, 14, 23404, 3057, 16, 14, 1493, 3057, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 24, 12, 16, 14, 1493, 3057, 16, 14, 23404, 12, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 25, 12, 16, 14, 1493, 3057, 16, 14, 23404, 3057, 16, 14, 7991, 9, 199, 84, 3438, 275, 11144, 14, 11919, 10225, 342, 199, 84, 3438, 14, 1084, 16030, 10225, 8, 709, 9, 199, 84, 3438, 14, 1084, 3428, 8, 16, 12, 16, 14, 1493, 12, 16, 14, 1493, 12, 16, 14, 6718, 9, 199, 84, 3438, 14, 1084, 3428, 8, 17, 12, 16, 14, 1493, 12, 16, 14, 1493, 3057, 16, 14, 1840, 9, 199, 84, 3438, 14, 1084, 3428, 8, 18, 12, 16, 14, 23404, 12, 16, 14, 1493, 12, 16, 14, 13595, 9, 199, 84, 3438, 14, 1084, 3428, 8, 19, 12, 16, 14, 23404, 12, 16, 14, 1493, 3057, 16, 14, 8251, 9, 199, 84, 3438, 14, 1084, 3428, 8, 20, 3057, 16, 14, 1493, 12, 16, 14, 10034, 12, 16, 14, 13595, 9, 199, 84, 3438, 14, 1084, 3428, 8, 21, 3057, 16, 14, 1493, 12, 16, 14, 23404, 3057, 16, 14, 8251, 9, 199, 84, 3438, 14, 1084, 3428, 8, 22, 3057, 16, 14, 23404, 3057, 16, 14, 1493, 12, 16, 14, 13595, 9, 199, 84, 3438, 14, 1084, 3428, 8, 23, 3057, 16, 14, 23404, 3057, 16, 14, 1493, 3057, 16, 14, 8251, 9, 199, 84, 3438, 14, 1084, 3428, 8, 24, 12, 16, 14, 1493, 3057, 16, 14, 10034, 12, 16, 14, 13595, 9, 199, 84, 3438, 14, 1084, 3428, 8, 25, 12, 16, 14, 1493, 3057, 16, 14, 23404, 3057, 16, 14, 8251, 9, 199, 24474, 275, 11144, 14, 11919, 2719, 262, 29020, 27558, 6939, 342, 199, 24474, 14, 1084, 2980, 44, 460, 10375, 8, 83, 3438, 9, 199, 24474, 14, 1084, 4277, 44, 460, 10375, 8, 84, 3438, 9, 199, 24474, 14, 1084, 34, 4864, 1378, 50, 18, 2445, 50, 342, 199, 3, 221, 30758, 1010, 2077, 199, 84, 17, 275, 11144, 14, 11919, 14109, 6939, 342, 199, 84, 17, 14, 24029, 8, 24474, 9, 199, 70, 845, 275, 11144, 14, 11919, 6939, 12747, 1451, 4131, 342, 199, 70, 845, 14, 32195, 8, 439, 14, 30810, 1012, 199, 70, 845, 14, 1084, 6939, 8, 84, 17, 9, 199, 77, 845, 275, 11144, 14, 11919, 30720, 11880, 342, 199, 77, 845, 14, 32195, 8, 70, 845, 14, 30810, 1012, 199, 65, 845, 275, 11144, 14, 11919, 12258, 342, 199, 65, 845, 14, 1084, 11880, 8, 77, 845, 9, 199, 65, 845, 14, 32638, 57, 8, 2710, 9, 199, 65, 845, 14, 22845, 1252, 1084, 4117, 8, 17, 12, 16, 12, 16, 9, 199, 3, 59, 65, 845, 2372, 3697, 61, 2494, 20609, 1378, 55, 73, 1121, 1186, 199, 828, 845, 275, 11144, 14, 11919, 11355, 342, 199, 828, 845, 14, 1084, 2768, 719, 8, 16, 14, 16, 12, 16, 14, 21, 12, 16, 14, 821, 12, 17, 14, 16, 9, 199, 828, 845, 14, 9637, 18425, 2801, 16, 14, 21, 12, 16, 14, 21, 3057, 16, 14, 21, 12, 16, 14, 21, 3057, 17, 12, 17, 9, 199, 828, 845, 14, 1123, 12258, 8, 65, 845, 9, 199, 828, 8886, 14, 1123, 11355, 8, 828, 845, 9, 199, 3, 11484, 30758, 299, 750, 30213, 5793, 199, 70, 713, 275, 11144, 14, 11919, 6939, 12747, 1451, 4131, 342, 199, 70, 713, 14, 32195, 8, 439, 14, 30810, 1012, 199, 70, 713, 14, 1084, 6939, 8, 84, 17, 14, 1002, 28274, 1012, 199, 77, 713, 275, 11144, 14, 11919, 30720, 11880, 342, 199, 77, 713, 14, 32195, 8, 70, 713, 14, 30810, 1012, 199, 65, 713, 275, 11144, 14, 11919, 12258, 342, 199, 65, 713, 14, 1084, 11880, 8, 77, 713, 9, 199, 65, 713, 14, 32638, 57, 8, 2710, 9, 199, 65, 713, 14, 22845, 1252, 1084, 4117, 8, 16, 14, 25, 12, 16, 14, 25, 12, 16, 9, 199, 3, 59, 65, 713, 2372, 3697, 61, 2494, 20609, 1378, 55, 73, 1121, 1186, 199, 828, 713, 275, 11144, 14, 11919, 11355, 342, 199, 828, 713, 14, 1084, 2768, 719, 8, 16, 14, 16, 12, 16, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 646, 11144, 199, 504, 11144, 14, 396, 492, 11940, 199, 504, 11144, 14, 1974, 14, 9923, 492, 11144, 25702, 6405, 199, 8156, 43, 63, 3998, 63, 5441, 275, 11144, 25702, 6405, 342, 199, 199, 3, 642, 2893, 2295, 314, 3429, 4073, 402, 16869, 1451, 1808, 30758, 299, 750, 2249, 1278, 199, 3, 436, 543, 6068, 18501, 1808, 3365, 14046, 12404, 199, 3, 1218, 282, 14066, 4353, 199, 828, 8886, 275, 11144, 14, 11919, 9216, 4301, 342, 199, 828, 8886, 14, 1084, 2320, 8, 6683, 12, 5863, 9, 199, 14980, 275, 11144, 14, 11919, 22385, 2980, 342, 199, 14980, 14, 1084, 2719, 1841, 18508, 8, 1165, 9, 199, 14980, 14, 1084, 5663, 73, 18508, 8, 1165, 9, 199, 439, 275, 11144, 14, 11919, 12747, 1451, 6241, 83, 342, 199, 439, 14, 32195, 8, 14980, 14, 30810, 1012, 199, 32152, 13715, 199, 3, 30758, 299, 750, 30213, 5793, 199, 83, 3438, 275, 11144, 14, 11919, 10225, 342, 199, 83, 3438, 14, 1084, 16030, 10225, 8, 709, 9, 199, 83, 3438, 14, 1084, 3428, 8, 16, 12, 16, 14, 1493, 12, 16, 14, 1493, 12, 16, 14, 5783, 9, 199, 83, 3438, 14, 1084, 3428, 8, 17, 12, 16, 14, 1493, 12, 16, 14, 1493, 3057, 16, 14, 5783, 9, 199, 83, 3438, 14, 1084, 3428, 8, 18, 12, 16, 14, 23404, 12, 16, 14, 1493, 12, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 19, 12, 16, 14, 23404, 12, 16, 14, 1493, 3057, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 20, 3057, 16, 14, 1493, 12, 16, 14, 23404, 12, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 21, 3057, 16, 14, 1493, 12, 16, 14, 23404, 3057, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 22, 3057, 16, 14, 23404, 3057, 16, 14, 1493, 12, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 23, 3057, 16, 14, 23404, 3057, 16, 14, 1493, 3057, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 24, 12, 16, 14, 1493, 3057, 16, 14, 23404, 12, 16, 14, 7991, 9, 199, 83, 3438, 14, 1084, 3428, 8, 25, 12, 16, 14, 1493, 3057, 16, 14, 23404, 3057, 16, 14, 7991, 9, 199, 84, 3438, 275, 11144, 14, 11919, 10225, 342, 199, 84, 3438, 14, 1084, 16030, 10225, 8, 709, 9, 199, 84, 3438, 14, 1084, 3428, 8, 16, 12, 16, 14, 1493, 12, 16, 14, 1493, 12, 16, 14, 6718, 9, 199, 84, 3438, 14, 1084, 3428, 8, 17, 12, 16, 14, 1493, 12, 16, 14, 1493, 3057, 16, 14, 1840, 9, 199, 84, 3438, 14, 1084, 3428, 8, 18, 12, 16, 14, 23404, 12, 16, 14, 1493, 12, 16, 14, 13595, 9, 199, 84, 3438, 14, 1084, 3428, 8, 19, 12, 16, 14, 23404, 12, 16, 14, 1493, 3057, 16, 14, 8251, 9, 199, 84, 3438, 14, 1084, 3428, 8, 20, 3057, 16, 14, 1493, 12, 16, 14, 10034, 12, 16, 14, 13595, 9, 199, 84, 3438, 14, 1084, 3428, 8, 21, 3057, 16, 14, 1493, 12, 16, 14, 23404, 3057, 16, 14, 8251, 9, 199, 84, 3438, 14, 1084, 3428, 8, 22, 3057, 16, 14, 23404, 3057, 16, 14, 1493, 12, 16, 14, 13595, 9, 199, 84, 3438, 14, 1084, 3428, 8, 23, 3057, 16, 14, 23404, 3057, 16, 14, 1493, 3057, 16, 14, 8251, 9, 199, 84, 3438, 14, 1084, 3428, 8, 24, 12, 16, 14, 1493, 3057, 16, 14, 10034, 12, 16, 14, 13595, 9, 199, 84, 3438, 14, 1084, 3428, 8, 25, 12, 16, 14, 1493, 3057, 16, 14, 23404, 3057, 16, 14, 8251, 9, 199, 24474, 275, 11144, 14, 11919, 2719, 262, 29020, 27558, 6939, 342, 199, 24474, 14, 1084, 2980, 44, 460, 10375, 8, 83, 3438, 9, 199, 24474, 14, 1084, 4277, 44, 460, 10375, 8, 84, 3438, 9, 199, 24474, 14, 1084, 34, 4864, 1378, 50, 18, 2445, 50, 342, 199, 3, 221, 30758, 1010, 2077, 199, 84, 17, 275, 11144, 14, 11919, 14109, 6939, 342, 199, 84, 17, 14, 24029, 8, 24474, 9, 199, 70, 845, 275, 11144, 14, 11919, 6939, 12747, 1451, 4131, 342, 199, 70, 845, 14, 32195, 8, 439, 14, 30810, 1012, 199, 70, 845, 14, 1084, 6939, 8, 84, 17, 9, 199, 77, 845, 275, 11144, 14, 11919, 30720, 11880, 342, 199, 77, 845, 14, 32195, 8, 70, 845, 14, 30810, 1012, 199, 65, 845, 275, 11144, 14, 11919, 12258, 342, 199, 65, 845, 14, 1084, 11880, 8, 77, 845, 9, 199, 65, 845, 14, 32638, 57, 8, 2710, 9, 199, 65, 845, 14, 22845, 1252, 1084, 4117, 8, 17, 12, 16, 12, 16, 9, 199, 3, 59, 65, 845, 2372, 3697, 61, 2494, 20609, 1378, 55, 73, 1121, 1186, 199, 828, 845, 275, 11144, 14, 11919, 11355, 342, 199, 828, 845, 14, 1084, 2768, 719, 8, 16, 14, 16, 12, 16, 14, 21, 12, 16, 14, 821, 12, 17, 14, 16, 9, 199, 828, 845, 14, 9637, 18425, 2801, 16, 14, 21, 12, 16, 14, 21, 3057, 16, 14, 21, 12, 16, 14, 21, 3057, 17, 12, 17, 9, 199, 828, 845, 14, 1123, 12258, 8, 65, 845, 9, 199, 828, 8886, 14, 1123, 11355, 8, 828, 845, 9, 199, 3, 11484, 30758, 299, 750, 30213, 5793, 199, 70, 713, 275, 11144, 14, 11919, 6939, 12747, 1451, 4131, 342, 199, 70, 713, 14, 32195, 8, 439, 14, 30810, 1012, 199, 70, 713, 14, 1084, 6939, 8, 84, 17, 14, 1002, 28274, 1012, 199, 77, 713, 275, 11144, 14, 11919, 30720, 11880, 342, 199, 77, 713, 14, 32195, 8, 70, 713, 14, 30810, 1012, 199, 65, 713, 275, 11144, 14, 11919, 12258, 342, 199, 65, 713, 14, 1084, 11880, 8, 77, 713, 9, 199, 65, 713, 14, 32638, 57, 8, 2710, 9, 199, 65, 713, 14, 22845, 1252, 1084, 4117, 8, 16, 14, 25, 12, 16, 14, 25, 12, 16, 9, 199, 3, 59, 65, 713, 2372, 3697, 61, 2494, 20609, 1378, 55, 73, 1121, 1186, 199, 828, 713, 275, 11144, 14, 11919, 11355, 342, 199, 828, 713, 14, 1084, 2768, 719, 8, 16, 14, 16, 12, 16, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chrisseto/modular-odm
tests/test_foreign.py
4
1849
#!/usr/bin/env python # encoding: utf-8 from nose.tools import * from tests.base import ModularOdmTestCase, TestObject from modularodm import fields class TestForeignList(ModularOdmTestCase): def define_objects(self): class Foo(TestObject): _id = fields.IntegerField() bars = fields.ForeignField('bar', list=True) class Bar(TestObject): _id = fields.IntegerField() return Foo, Bar def set_up_objects(self): self.foo = self.Foo(_id=1) self.bars = [] for idx in range(5): self.bars.append(self.Bar(_id=idx)) self.bars[idx].save() self.foo.bars = self.bars self.foo.save() def test_get_item(self): assert_equal(self.bars[2], self.foo.bars[2]) def test_get_slice(self): assert_equal(self.bars[:3], list(self.foo.bars[:3])) def test_get_slice_extended(self): assert_equal(self.bars[::-1], list(self.foo.bars[::-1])) class TestAbstractForeignList(ModularOdmTestCase): def define_objects(self): class Foo(TestObject): _id = fields.IntegerField() bars = fields.AbstractForeignField(list=True) class Bar(TestObject): _id = fields.IntegerField() return Foo, Bar def set_up_objects(self): self.foo = self.Foo(_id=1) self.bars = [] for idx in range(5): self.bars.append(self.Bar(_id=idx)) self.bars[idx].save() self.foo.bars = self.bars self.foo.save() def test_get_item(self): assert_equal(self.bars[2], self.foo.bars[2]) def test_get_slice(self): assert_equal(self.bars[:3], list(self.foo.bars[:3])) def test_get_slice_extended(self): assert_equal(self.bars[::-1], list(self.foo.bars[::-1]))
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 421, 199, 504, 11354, 14, 2537, 492, 627, 199, 199, 504, 2295, 14, 1095, 492, 22035, 2238, 47, 6428, 1746, 12, 1379, 1692, 199, 199, 504, 3413, 2238, 364, 77, 492, 1504, 421, 199, 533, 1379, 20931, 1296, 8, 9871, 2238, 47, 6428, 1746, 304, 339, 347, 5627, 63, 1462, 8, 277, 304, 398, 1021, 8024, 8, 774, 1692, 304, 288, 485, 344, 275, 1504, 14, 3901, 342, 288, 29130, 275, 1504, 14, 20931, 792, 360, 1700, 297, 769, 29, 549, 9, 398, 1021, 12377, 8, 774, 1692, 304, 288, 485, 344, 275, 1504, 14, 3901, 342, 398, 372, 8024, 12, 12377, 339, 347, 663, 63, 384, 63, 1462, 8, 277, 304, 398, 291, 14, 1421, 275, 291, 14, 5686, 1547, 344, 29, 17, 9, 398, 291, 14, 16264, 275, 942, 267, 367, 4280, 315, 1425, 8, 21, 304, 288, 291, 14, 16264, 14, 740, 8, 277, 14, 5281, 1547, 344, 29, 2996, 430, 288, 291, 14, 16264, 59, 2996, 1055, 2117, 342, 398, 291, 14, 1421, 14, 16264, 275, 291, 14, 16264, 267, 291, 14, 1421, 14, 2117, 342, 339, 347, 511, 63, 362, 63, 1053, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 59, 18, 467, 291, 14, 1421, 14, 16264, 59, 18, 566, 339, 347, 511, 63, 362, 63, 5224, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 1491, 19, 467, 769, 8, 277, 14, 1421, 14, 16264, 1491, 19, 2459, 339, 347, 511, 63, 362, 63, 5224, 63, 10525, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 14172, 17, 467, 769, 8, 277, 14, 1421, 14, 16264, 14172, 17, 2459, 421, 199, 533, 1379, 8458, 20931, 1296, 8, 9871, 2238, 47, 6428, 1746, 304, 339, 347, 5627, 63, 1462, 8, 277, 304, 398, 1021, 8024, 8, 774, 1692, 304, 288, 485, 344, 275, 1504, 14, 3901, 342, 288, 29130, 275, 1504, 14, 8458, 20931, 792, 8, 513, 29, 549, 9, 398, 1021, 12377, 8, 774, 1692, 304, 288, 485, 344, 275, 1504, 14, 3901, 342, 398, 372, 8024, 12, 12377, 339, 347, 663, 63, 384, 63, 1462, 8, 277, 304, 398, 291, 14, 1421, 275, 291, 14, 5686, 1547, 344, 29, 17, 9, 398, 291, 14, 16264, 275, 942, 267, 367, 4280, 315, 1425, 8, 21, 304, 288, 291, 14, 16264, 14, 740, 8, 277, 14, 5281, 1547, 344, 29, 2996, 430, 288, 291, 14, 16264, 59, 2996, 1055, 2117, 342, 398, 291, 14, 1421, 14, 16264, 275, 291, 14, 16264, 267, 291, 14, 1421, 14, 2117, 342, 339, 347, 511, 63, 362, 63, 1053, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 59, 18, 467, 291, 14, 1421, 14, 16264, 59, 18, 566, 339, 347, 511, 63, 362, 63, 5224, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 1491, 19, 467, 769, 8, 277, 14, 1421, 14, 16264, 1491, 19, 2459, 339, 347, 511, 63, 362, 63, 5224, 63, 10525, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 14172, 17, 467, 769, 8, 277, 14, 1421, 14, 16264, 14172, 17, 2459, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 421, 199, 504, 11354, 14, 2537, 492, 627, 199, 199, 504, 2295, 14, 1095, 492, 22035, 2238, 47, 6428, 1746, 12, 1379, 1692, 199, 199, 504, 3413, 2238, 364, 77, 492, 1504, 421, 199, 533, 1379, 20931, 1296, 8, 9871, 2238, 47, 6428, 1746, 304, 339, 347, 5627, 63, 1462, 8, 277, 304, 398, 1021, 8024, 8, 774, 1692, 304, 288, 485, 344, 275, 1504, 14, 3901, 342, 288, 29130, 275, 1504, 14, 20931, 792, 360, 1700, 297, 769, 29, 549, 9, 398, 1021, 12377, 8, 774, 1692, 304, 288, 485, 344, 275, 1504, 14, 3901, 342, 398, 372, 8024, 12, 12377, 339, 347, 663, 63, 384, 63, 1462, 8, 277, 304, 398, 291, 14, 1421, 275, 291, 14, 5686, 1547, 344, 29, 17, 9, 398, 291, 14, 16264, 275, 942, 267, 367, 4280, 315, 1425, 8, 21, 304, 288, 291, 14, 16264, 14, 740, 8, 277, 14, 5281, 1547, 344, 29, 2996, 430, 288, 291, 14, 16264, 59, 2996, 1055, 2117, 342, 398, 291, 14, 1421, 14, 16264, 275, 291, 14, 16264, 267, 291, 14, 1421, 14, 2117, 342, 339, 347, 511, 63, 362, 63, 1053, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 59, 18, 467, 291, 14, 1421, 14, 16264, 59, 18, 566, 339, 347, 511, 63, 362, 63, 5224, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 1491, 19, 467, 769, 8, 277, 14, 1421, 14, 16264, 1491, 19, 2459, 339, 347, 511, 63, 362, 63, 5224, 63, 10525, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 14172, 17, 467, 769, 8, 277, 14, 1421, 14, 16264, 14172, 17, 2459, 421, 199, 533, 1379, 8458, 20931, 1296, 8, 9871, 2238, 47, 6428, 1746, 304, 339, 347, 5627, 63, 1462, 8, 277, 304, 398, 1021, 8024, 8, 774, 1692, 304, 288, 485, 344, 275, 1504, 14, 3901, 342, 288, 29130, 275, 1504, 14, 8458, 20931, 792, 8, 513, 29, 549, 9, 398, 1021, 12377, 8, 774, 1692, 304, 288, 485, 344, 275, 1504, 14, 3901, 342, 398, 372, 8024, 12, 12377, 339, 347, 663, 63, 384, 63, 1462, 8, 277, 304, 398, 291, 14, 1421, 275, 291, 14, 5686, 1547, 344, 29, 17, 9, 398, 291, 14, 16264, 275, 942, 267, 367, 4280, 315, 1425, 8, 21, 304, 288, 291, 14, 16264, 14, 740, 8, 277, 14, 5281, 1547, 344, 29, 2996, 430, 288, 291, 14, 16264, 59, 2996, 1055, 2117, 342, 398, 291, 14, 1421, 14, 16264, 275, 291, 14, 16264, 267, 291, 14, 1421, 14, 2117, 342, 339, 347, 511, 63, 362, 63, 1053, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 59, 18, 467, 291, 14, 1421, 14, 16264, 59, 18, 566, 339, 347, 511, 63, 362, 63, 5224, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 1491, 19, 467, 769, 8, 277, 14, 1421, 14, 16264, 1491, 19, 2459, 339, 347, 511, 63, 362, 63, 5224, 63, 10525, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 16264, 14172, 17, 467, 769, 8, 277, 14, 1421, 14, 16264, 14172, 17, 2459, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ycl2045/nova-master
nova/api/openstack/compute/plugins/v3/keypairs.py
10
6309
# Copyright 2011 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Keypair management extension.""" import webob import webob.exc from nova.api.openstack.compute.schemas.v3 import keypairs from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api import validation from nova.compute import api as compute_api from nova import exception from nova.openstack.common.gettextutils import _ ALIAS = 'keypairs' authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS) soft_authorize = extensions.soft_extension_authorizer('compute', 'v3:' + ALIAS) class KeypairController(object): """Keypair API controller for the OpenStack API.""" def __init__(self): self.api = compute_api.KeypairAPI() def _filter_keypair(self, keypair, **attrs): clean = { 'name': keypair.name, 'public_key': keypair.public_key, 'fingerprint': keypair.fingerprint, } for attr in attrs: clean[attr] = keypair[attr] return clean @extensions.expected_errors((400, 409, 413)) @wsgi.response(201) @validation.schema(keypairs.create) def create(self, req, body): """Create or import keypair. Sending name will generate a key and return private_key and fingerprint. You can send a public_key to add an existing ssh key params: keypair object with: name (required) - string public_key (optional) - string """ context = req.environ['nova.context'] authorize(context, action='create') params = body['keypair'] name = params['name'] try: if 'public_key' in params: keypair = self.api.import_key_pair(context, context.user_id, name, params['public_key']) keypair = self._filter_keypair(keypair, user_id=True) else: keypair, private_key = self.api.create_key_pair( context, context.user_id, name) keypair = self._filter_keypair(keypair, user_id=True) keypair['private_key'] = private_key return {'keypair': keypair} except exception.KeypairLimitExceeded: msg = _("Quota exceeded, too many key pairs.") raise webob.exc.HTTPRequestEntityTooLarge( explanation=msg, headers={'Retry-After': 0}) except exception.InvalidKeypair as exc: raise webob.exc.HTTPBadRequest(explanation=exc.format_message()) except exception.KeyPairExists as exc: raise webob.exc.HTTPConflict(explanation=exc.format_message()) @wsgi.response(204) @extensions.expected_errors(404) def delete(self, req, id): """Delete a keypair with a given name.""" context = req.environ['nova.context'] authorize(context, action='delete') try: self.api.delete_key_pair(context, context.user_id, id) except exception.KeypairNotFound: raise webob.exc.HTTPNotFound() @extensions.expected_errors(404) def show(self, req, id): """Return data for the given key name.""" context = req.environ['nova.context'] authorize(context, action='show') try: keypair = self.api.get_key_pair(context, context.user_id, id) except exception.KeypairNotFound: raise webob.exc.HTTPNotFound() return {'keypair': self._filter_keypair(keypair)} @extensions.expected_errors(()) def index(self, req): """List of keypairs for a user.""" context = req.environ['nova.context'] authorize(context, action='index') key_pairs = self.api.get_key_pairs(context, context.user_id) rval = [] for key_pair in key_pairs: rval.append({'keypair': self._filter_keypair(key_pair)}) return {'keypairs': rval} class Controller(wsgi.Controller): def _add_key_name(self, req, servers): for server in servers: db_server = req.get_db_instance(server['id']) # server['id'] is guaranteed to be in the cache due to # the core API adding it in its 'show'/'detail' methods. server['key_name'] = db_server['key_name'] def _show(self, req, resp_obj): if 'server' in resp_obj.obj: server = resp_obj.obj['server'] self._add_key_name(req, [server]) @wsgi.extends def show(self, req, resp_obj, id): context = req.environ['nova.context'] if soft_authorize(context): self._show(req, resp_obj) @wsgi.extends def detail(self, req, resp_obj): context = req.environ['nova.context'] if 'servers' in resp_obj.obj and soft_authorize(context): servers = resp_obj.obj['servers'] self._add_key_name(req, servers) class Keypairs(extensions.V3APIExtensionBase): """Keypair Support.""" name = "Keypairs" alias = ALIAS version = 1 def get_resources(self): resources = [ extensions.ResourceExtension('keypairs', KeypairController())] return resources def get_controller_extensions(self): controller = Controller() extension = extensions.ControllerExtension(self, 'servers', controller) return [extension] # use nova.api.extensions.server.extensions entry point to modify # server create kwargs def server_create(self, server_dict, create_kwargs): create_kwargs['key_name'] = server_dict.get('key_name')
apache-2.0
[ 3, 1898, 7760, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 1197, 3852, 10041, 3329, 1041, 199, 199, 646, 14568, 199, 646, 14568, 14, 2804, 199, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 9482, 14, 86, 19, 492, 790, 7322, 199, 504, 5913, 14, 1246, 14, 8512, 492, 5478, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 14, 1246, 492, 6411, 199, 504, 5913, 14, 3357, 492, 2986, 465, 4526, 63, 1246, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 8512, 14, 2330, 14, 5152, 1208, 492, 485, 421, 199, 12644, 275, 283, 30825, 7, 199, 14204, 275, 5478, 14, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 86, 19, 4881, 435, 437, 2673, 1179, 9, 199, 4617, 63, 14204, 275, 5478, 14, 4617, 63, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 86, 19, 4881, 435, 437, 2673, 1179, 9, 421, 199, 533, 2606, 3852, 7506, 8, 785, 304, 339, 408, 1197, 3852, 3261, 7614, 367, 314, 14260, 3261, 1041, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1246, 275, 4526, 63, 1246, 14, 1197, 3852, 3735, 342, 339, 347, 485, 1541, 63, 19263, 8, 277, 12, 23911, 12, 1011, 3288, 304, 267, 3633, 275, 469, 288, 283, 354, 356, 23911, 14, 354, 12, 288, 283, 3455, 63, 498, 356, 23911, 14, 3455, 63, 498, 12, 288, 283, 15077, 356, 23911, 14, 15077, 12, 288, 789, 267, 367, 1921, 315, 3290, 26, 288, 3633, 59, 962, 61, 275, 23911, 59, 962, 61, 267, 372, 3633, 339, 768, 5359, 14, 2062, 63, 2550, 1332, 5303, 12, 21292, 12, 841, 969, 430, 272, 768, 6508, 14, 1310, 8, 1797, 9, 272, 768, 6136, 14, 3629, 8, 30825, 14, 981, 9, 272, 347, 1218, 8, 277, 12, 2648, 12, 2396, 304, 267, 408, 2499, 503, 492, 23911, 14, 398, 428, 3219, 536, 911, 3550, 282, 790, 436, 372, 5726, 63, 498, 267, 436, 18020, 14, 398, 2047, 883, 3222, 282, 4575, 63, 498, 370, 1050, 376, 3411, 8635, 790, 398, 1862, 26, 23911, 909, 543, 26, 288, 536, 334, 2427, 9, 446, 1059, 288, 4575, 63, 498, 334, 4144, 9, 446, 1059, 267, 408, 398, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 12, 1595, 534, 981, 358, 398, 1862, 275, 2396, 459, 19263, 418, 267, 536, 275, 1862, 459, 354, 418, 398, 862, 26, 288, 340, 283, 3455, 63, 498, 7, 315, 1862, 26, 355, 23911, 275, 291, 14, 1246, 14, 646, 63, 498, 63, 3852, 8, 1100, 12, 6343, 1067, 14, 751, 63, 344, 12, 536, 12, 6343, 1862, 459, 3455, 63, 498, 1105, 355, 23911, 275, 291, 423, 1541, 63, 19263, 8, 19263, 12, 922, 63, 344, 29, 549, 9, 288, 587, 26, 355, 23911, 12, 5726, 63, 498, 275, 291, 14, 1246, 14, 981, 63, 498, 63, 3852, 8, 490, 1067, 12, 1067, 14, 751, 63, 344, 12, 536, 9, 355, 23911, 275, 291, 423, 1541, 63, 19263, 8, 19263, 12, 922, 63, 344, 29, 549, 9, 355, 23911, 459, 4239, 63, 498, 418, 275, 5726, 63, 498, 953, 372, 791, 19263, 356, 23911, 93, 398, 871, 1919, 14, 1197, 3852, 8407, 24748, 26, 288, 1499, 275, 3824, 17610, 22007, 12, 4634, 5002, 790, 6342, 2685, 288, 746, 14568, 14, 2804, 14, 21053, 7302, 13749, 17149, 8, 717, 17531, 29, 1328, 12, 717, 2323, 3713, 12989, 13, 10881, 356, 378, 1552, 267, 871, 1919, 14, 3364, 1197, 3852, 465, 3178, 26, 288, 746, 14568, 14, 2804, 14, 21070, 8, 15228, 29, 2804, 14, 908, 63, 1188, 1012, 267, 871, 1919, 14, 1197, 12882, 7965, 465, 3178, 26, 288, 746, 14568, 14, 2804, 14, 2856, 15919, 8, 15228, 29, 2804, 14, 908, 63, 1188, 1012, 339, 768, 6508, 14, 1310, 8, 6686, 9, 272, 768, 5359, 14, 2062, 63, 2550, 8, 5188, 9, 272, 347, 3145, 8, 277, 12, 2648, 12, 1305, 304, 267, 408, 5392, 282, 23911, 543, 282, 1627, 536, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 12, 1595, 534, 1807, 358, 267, 862, 26, 288, 291, 14, 1246, 14, 1807, 63, 498, 63, 3852, 8, 1100, 12, 1067, 14, 751, 63, 344, 12, 1305, 9, 267, 871, 1919, 14, 1197, 3852, 4667, 26, 288, 746, 14568, 14, 2804, 14, 26553, 342, 339, 768, 5359, 14, 2062, 63, 2550, 8, 5188, 9, 272, 347, 2498, 8, 277, 12, 2648, 12, 1305, 304, 267, 408, 1767, 666, 367, 314, 1627, 790, 536, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 12, 1595, 534, 2384, 358, 398, 862, 26, 288, 23911, 275, 291, 14, 1246, 14, 362, 63, 498, 63, 3852, 8, 1100, 12, 1067, 14, 751, 63, 344, 12, 1305, 9, 267, 871, 1919, 14, 1197, 3852, 4667, 26, 288, 746, 14568, 14, 2804, 14, 26553, 342, 267, 372, 791, 19263, 356, 291, 423, 1541, 63, 19263, 8, 19263, 6769, 339, 768, 5359, 14, 2062, 63, 2550, 30812, 272, 347, 1478, 8, 277, 12, 2648, 304, 267, 408, 1296, 402, 790, 7322, 367, 282, 922, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 12, 1595, 534, 1080, 358, 267, 790, 63, 7322, 275, 291, 14, 1246, 14, 362, 63 ]
[ 1898, 7760, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 1197, 3852, 10041, 3329, 1041, 199, 199, 646, 14568, 199, 646, 14568, 14, 2804, 199, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 9482, 14, 86, 19, 492, 790, 7322, 199, 504, 5913, 14, 1246, 14, 8512, 492, 5478, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 14, 1246, 492, 6411, 199, 504, 5913, 14, 3357, 492, 2986, 465, 4526, 63, 1246, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 8512, 14, 2330, 14, 5152, 1208, 492, 485, 421, 199, 12644, 275, 283, 30825, 7, 199, 14204, 275, 5478, 14, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 86, 19, 4881, 435, 437, 2673, 1179, 9, 199, 4617, 63, 14204, 275, 5478, 14, 4617, 63, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 86, 19, 4881, 435, 437, 2673, 1179, 9, 421, 199, 533, 2606, 3852, 7506, 8, 785, 304, 339, 408, 1197, 3852, 3261, 7614, 367, 314, 14260, 3261, 1041, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1246, 275, 4526, 63, 1246, 14, 1197, 3852, 3735, 342, 339, 347, 485, 1541, 63, 19263, 8, 277, 12, 23911, 12, 1011, 3288, 304, 267, 3633, 275, 469, 288, 283, 354, 356, 23911, 14, 354, 12, 288, 283, 3455, 63, 498, 356, 23911, 14, 3455, 63, 498, 12, 288, 283, 15077, 356, 23911, 14, 15077, 12, 288, 789, 267, 367, 1921, 315, 3290, 26, 288, 3633, 59, 962, 61, 275, 23911, 59, 962, 61, 267, 372, 3633, 339, 768, 5359, 14, 2062, 63, 2550, 1332, 5303, 12, 21292, 12, 841, 969, 430, 272, 768, 6508, 14, 1310, 8, 1797, 9, 272, 768, 6136, 14, 3629, 8, 30825, 14, 981, 9, 272, 347, 1218, 8, 277, 12, 2648, 12, 2396, 304, 267, 408, 2499, 503, 492, 23911, 14, 398, 428, 3219, 536, 911, 3550, 282, 790, 436, 372, 5726, 63, 498, 267, 436, 18020, 14, 398, 2047, 883, 3222, 282, 4575, 63, 498, 370, 1050, 376, 3411, 8635, 790, 398, 1862, 26, 23911, 909, 543, 26, 288, 536, 334, 2427, 9, 446, 1059, 288, 4575, 63, 498, 334, 4144, 9, 446, 1059, 267, 408, 398, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 12, 1595, 534, 981, 358, 398, 1862, 275, 2396, 459, 19263, 418, 267, 536, 275, 1862, 459, 354, 418, 398, 862, 26, 288, 340, 283, 3455, 63, 498, 7, 315, 1862, 26, 355, 23911, 275, 291, 14, 1246, 14, 646, 63, 498, 63, 3852, 8, 1100, 12, 6343, 1067, 14, 751, 63, 344, 12, 536, 12, 6343, 1862, 459, 3455, 63, 498, 1105, 355, 23911, 275, 291, 423, 1541, 63, 19263, 8, 19263, 12, 922, 63, 344, 29, 549, 9, 288, 587, 26, 355, 23911, 12, 5726, 63, 498, 275, 291, 14, 1246, 14, 981, 63, 498, 63, 3852, 8, 490, 1067, 12, 1067, 14, 751, 63, 344, 12, 536, 9, 355, 23911, 275, 291, 423, 1541, 63, 19263, 8, 19263, 12, 922, 63, 344, 29, 549, 9, 355, 23911, 459, 4239, 63, 498, 418, 275, 5726, 63, 498, 953, 372, 791, 19263, 356, 23911, 93, 398, 871, 1919, 14, 1197, 3852, 8407, 24748, 26, 288, 1499, 275, 3824, 17610, 22007, 12, 4634, 5002, 790, 6342, 2685, 288, 746, 14568, 14, 2804, 14, 21053, 7302, 13749, 17149, 8, 717, 17531, 29, 1328, 12, 717, 2323, 3713, 12989, 13, 10881, 356, 378, 1552, 267, 871, 1919, 14, 3364, 1197, 3852, 465, 3178, 26, 288, 746, 14568, 14, 2804, 14, 21070, 8, 15228, 29, 2804, 14, 908, 63, 1188, 1012, 267, 871, 1919, 14, 1197, 12882, 7965, 465, 3178, 26, 288, 746, 14568, 14, 2804, 14, 2856, 15919, 8, 15228, 29, 2804, 14, 908, 63, 1188, 1012, 339, 768, 6508, 14, 1310, 8, 6686, 9, 272, 768, 5359, 14, 2062, 63, 2550, 8, 5188, 9, 272, 347, 3145, 8, 277, 12, 2648, 12, 1305, 304, 267, 408, 5392, 282, 23911, 543, 282, 1627, 536, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 12, 1595, 534, 1807, 358, 267, 862, 26, 288, 291, 14, 1246, 14, 1807, 63, 498, 63, 3852, 8, 1100, 12, 1067, 14, 751, 63, 344, 12, 1305, 9, 267, 871, 1919, 14, 1197, 3852, 4667, 26, 288, 746, 14568, 14, 2804, 14, 26553, 342, 339, 768, 5359, 14, 2062, 63, 2550, 8, 5188, 9, 272, 347, 2498, 8, 277, 12, 2648, 12, 1305, 304, 267, 408, 1767, 666, 367, 314, 1627, 790, 536, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 12, 1595, 534, 2384, 358, 398, 862, 26, 288, 23911, 275, 291, 14, 1246, 14, 362, 63, 498, 63, 3852, 8, 1100, 12, 1067, 14, 751, 63, 344, 12, 1305, 9, 267, 871, 1919, 14, 1197, 3852, 4667, 26, 288, 746, 14568, 14, 2804, 14, 26553, 342, 267, 372, 791, 19263, 356, 291, 423, 1541, 63, 19263, 8, 19263, 6769, 339, 768, 5359, 14, 2062, 63, 2550, 30812, 272, 347, 1478, 8, 277, 12, 2648, 304, 267, 408, 1296, 402, 790, 7322, 367, 282, 922, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 12, 1595, 534, 1080, 358, 267, 790, 63, 7322, 275, 291, 14, 1246, 14, 362, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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import test_support import pwd class PwdTest(unittest.TestCase): def test_values(self): entries = pwd.getpwall() entriesbyname = {} entriesbyuid = {} for e in entries: self.assertEqual(len(e), 7) self.assertEqual(e[0], e.pw_name) self.assert_(isinstance(e.pw_name, basestring)) self.assertEqual(e[1], e.pw_passwd) self.assert_(isinstance(e.pw_passwd, basestring)) self.assertEqual(e[2], e.pw_uid) self.assert_(isinstance(e.pw_uid, int)) self.assertEqual(e[3], e.pw_gid) self.assert_(isinstance(e.pw_gid, int)) self.assertEqual(e[4], e.pw_gecos) self.assert_(isinstance(e.pw_gecos, basestring)) self.assertEqual(e[5], e.pw_dir) self.assert_(isinstance(e.pw_dir, basestring)) self.assertEqual(e[6], e.pw_shell) self.assert_(isinstance(e.pw_shell, basestring)) # The following won't work, because of duplicate entries # for one uid # self.assertEqual(pwd.getpwuid(e.pw_uid), e) # instead of this collect all entries for one uid # and check afterwards entriesbyname.setdefault(e.pw_name, []).append(e) entriesbyuid.setdefault(e.pw_uid, []).append(e) if len(entries) > 1000: # Huge passwd file (NIS?) -- skip the rest return # check whether the entry returned by getpwuid() # for each uid is among those from getpwall() for this uid for e in entries: if not e[0] or e[0] == '+': continue # skip NIS entries etc. self.assert_(pwd.getpwnam(e.pw_name) in entriesbyname[e.pw_name]) self.assert_(pwd.getpwuid(e.pw_uid) in entriesbyuid[e.pw_uid]) def test_errors(self): self.assertRaises(TypeError, pwd.getpwuid) self.assertRaises(TypeError, pwd.getpwnam) self.assertRaises(TypeError, pwd.getpwall, 42) # try to get some errors bynames = {} byuids = {} for (n, p, u, g, gecos, d, s) in pwd.getpwall(): bynames[n] = u byuids[u] = n allnames = bynames.keys() namei = 0 fakename = allnames[namei] while fakename in bynames: chars = list(fakename) for i in xrange(len(chars)): if chars[i] == 'z': chars[i] = 'A' break elif chars[i] == 'Z': continue else: chars[i] = chr(ord(chars[i]) + 1) break else: namei = namei + 1 try: fakename = allnames[namei] except IndexError: # should never happen... if so, just forget it break fakename = ''.join(chars) self.assertRaises(KeyError, pwd.getpwnam, fakename) # Choose a non-existent uid. fakeuid = 4127 while fakeuid in byuids: fakeuid = (fakeuid * 3) % 0x10000 self.assertRaises(KeyError, pwd.getpwuid, fakeuid) def test_main(): test_support.run_unittest(PwdTest) if __name__ == "__main__": test_main()
apache-2.0
[ 646, 2882, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 646, 14374, 199, 199, 533, 510, 2989, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 1459, 8, 277, 304, 267, 4811, 275, 14374, 14, 362, 80, 7567, 342, 267, 4811, 24810, 275, 1052, 267, 4811, 991, 1535, 275, 1052, 398, 367, 325, 315, 4811, 26, 288, 291, 14, 629, 8, 552, 8, 69, 395, 1520, 9, 288, 291, 14, 629, 8, 69, 59, 16, 467, 325, 14, 8796, 63, 354, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 354, 12, 7116, 430, 288, 291, 14, 629, 8, 69, 59, 17, 467, 325, 14, 8796, 63, 12671, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 12671, 12, 7116, 430, 288, 291, 14, 629, 8, 69, 59, 18, 467, 325, 14, 8796, 63, 1535, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 1535, 12, 1109, 430, 288, 291, 14, 629, 8, 69, 59, 19, 467, 325, 14, 8796, 63, 8787, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 8787, 12, 1109, 430, 288, 291, 14, 629, 8, 69, 59, 20, 467, 325, 14, 8796, 63, 303, 5197, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 303, 5197, 12, 7116, 430, 288, 291, 14, 629, 8, 69, 59, 21, 467, 325, 14, 8796, 63, 694, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 694, 12, 7116, 430, 288, 291, 14, 629, 8, 69, 59, 22, 467, 325, 14, 8796, 63, 5641, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 5641, 12, 7116, 430, 953, 327, 710, 2569, 7859, 1133, 1736, 12, 2952, 402, 9250, 4811, 288, 327, 367, 1373, 1747, 288, 327, 259, 291, 14, 629, 8, 14258, 14, 362, 8796, 1535, 8, 69, 14, 8796, 63, 1535, 395, 325, 9, 288, 327, 3140, 402, 642, 8775, 1006, 4811, 367, 1373, 1747, 288, 327, 436, 1104, 26982, 288, 4811, 24810, 14, 5486, 8, 69, 14, 8796, 63, 354, 12, 15364, 740, 8, 69, 9, 288, 4811, 991, 1535, 14, 5486, 8, 69, 14, 8796, 63, 1535, 12, 15364, 740, 8, 69, 9, 398, 340, 822, 8, 3189, 9, 690, 5198, 26, 221, 327, 869, 17730, 15081, 570, 334, 46, 1311, 17076, 1553, 3372, 314, 4618, 288, 372, 398, 327, 1104, 3775, 314, 2397, 2138, 701, 664, 8796, 1535, 342, 267, 327, 367, 1924, 1747, 365, 16885, 5204, 687, 664, 80, 7567, 342, 367, 642, 1747, 267, 367, 325, 315, 4811, 26, 288, 340, 440, 325, 59, 16, 61, 503, 325, 59, 16, 61, 508, 6681, 356, 355, 1980, 327, 3372, 653, 1311, 4811, 5423, 14, 288, 291, 14, 479, 2531, 14258, 14, 362, 80, 3501, 455, 8, 69, 14, 8796, 63, 354, 9, 315, 4811, 24810, 59, 69, 14, 8796, 63, 354, 566, 288, 291, 14, 479, 2531, 14258, 14, 362, 8796, 1535, 8, 69, 14, 8796, 63, 1535, 9, 315, 4811, 991, 1535, 59, 69, 14, 8796, 63, 1535, 566, 339, 347, 511, 63, 2550, 8, 277, 304, 267, 291, 14, 1855, 8, 4333, 12, 14374, 14, 362, 8796, 1535, 9, 267, 291, 14, 1855, 8, 4333, 12, 14374, 14, 362, 80, 3501, 455, 9, 267, 291, 14, 1855, 8, 4333, 12, 14374, 14, 362, 80, 7567, 12, 5685, 9, 398, 327, 862, 370, 664, 2005, 2552, 267, 701, 1247, 275, 1052, 267, 701, 27637, 275, 1052, 267, 367, 334, 78, 12, 299, 12, 399, 12, 486, 12, 2312, 5197, 12, 366, 12, 308, 9, 315, 14374, 14, 362, 80, 7567, 837, 288, 701, 1247, 59, 78, 61, 275, 399, 288, 701, 27637, 59, 85, 61, 275, 302, 398, 1006, 1247, 275, 701, 1247, 14, 1612, 342, 267, 536, 73, 275, 378, 267, 1433, 917, 313, 275, 1006, 1247, 59, 354, 73, 61, 267, 1830, 1433, 917, 313, 315, 701, 1247, 26, 288, 8365, 275, 769, 8, 667, 917, 313, 9, 288, 367, 284, 315, 4945, 8, 552, 8, 6574, 2298, 355, 340, 8365, 59, 73, 61, 508, 283, 90, 356, 490, 8365, 59, 73, 61, 275, 283, 33, 7, 490, 2059, 355, 916, 8365, 59, 73, 61, 508, 283, 58, 356, 490, 1980, 355, 587, 26, 490, 8365, 59, 73, 61, 275, 8678, 8, 2181, 8, 6574, 59, 73, 566, 435, 413, 9, 490, 2059, 288, 587, 26, 355, 536, 73, 275, 536, 73, 435, 413, 355, 862, 26, 490, 1433, 917, 313, 275, 1006, 1247, 59, 354, 73, 61, 355, 871, 7888, 26, 490, 327, 1077, 7078, 5992, 1396, 340, 880, 12, 2951, 19459, 652, 490, 2059, 288, 1433, 917, 313, 275, 6522, 904, 8, 6574, 9, 398, 291, 14, 1855, 8, 10230, 12, 14374, 14, 362, 80, 3501, 455, 12, 1433, 917, 313, 9, 398, 327, 29826, 282, 2222, 13, 15025, 1747, 14, 267, 4026, 1535, 275, 841, 4195, 267, 1830, 4026, 1535, 315, 701, 27637, 26, 288, 4026, 1535, 275, 334, 3183, 1535, 627, 650, 9, 450, 378, 88, 9943, 398, 291, 14, 1855, 8, 10230, 12, 14374, 14, 362, 8796, 1535, 12, 4026, 1535, 9, 199, 199, 318, 511, 63, 973, 837, 272, 511, 63, 4058, 14, 1065, 63, 2796, 8, 32701, 774, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 511, 63, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2882, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 646, 14374, 199, 199, 533, 510, 2989, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 1459, 8, 277, 304, 267, 4811, 275, 14374, 14, 362, 80, 7567, 342, 267, 4811, 24810, 275, 1052, 267, 4811, 991, 1535, 275, 1052, 398, 367, 325, 315, 4811, 26, 288, 291, 14, 629, 8, 552, 8, 69, 395, 1520, 9, 288, 291, 14, 629, 8, 69, 59, 16, 467, 325, 14, 8796, 63, 354, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 354, 12, 7116, 430, 288, 291, 14, 629, 8, 69, 59, 17, 467, 325, 14, 8796, 63, 12671, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 12671, 12, 7116, 430, 288, 291, 14, 629, 8, 69, 59, 18, 467, 325, 14, 8796, 63, 1535, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 1535, 12, 1109, 430, 288, 291, 14, 629, 8, 69, 59, 19, 467, 325, 14, 8796, 63, 8787, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 8787, 12, 1109, 430, 288, 291, 14, 629, 8, 69, 59, 20, 467, 325, 14, 8796, 63, 303, 5197, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 303, 5197, 12, 7116, 430, 288, 291, 14, 629, 8, 69, 59, 21, 467, 325, 14, 8796, 63, 694, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 694, 12, 7116, 430, 288, 291, 14, 629, 8, 69, 59, 22, 467, 325, 14, 8796, 63, 5641, 9, 288, 291, 14, 479, 2531, 6074, 8, 69, 14, 8796, 63, 5641, 12, 7116, 430, 953, 327, 710, 2569, 7859, 1133, 1736, 12, 2952, 402, 9250, 4811, 288, 327, 367, 1373, 1747, 288, 327, 259, 291, 14, 629, 8, 14258, 14, 362, 8796, 1535, 8, 69, 14, 8796, 63, 1535, 395, 325, 9, 288, 327, 3140, 402, 642, 8775, 1006, 4811, 367, 1373, 1747, 288, 327, 436, 1104, 26982, 288, 4811, 24810, 14, 5486, 8, 69, 14, 8796, 63, 354, 12, 15364, 740, 8, 69, 9, 288, 4811, 991, 1535, 14, 5486, 8, 69, 14, 8796, 63, 1535, 12, 15364, 740, 8, 69, 9, 398, 340, 822, 8, 3189, 9, 690, 5198, 26, 221, 327, 869, 17730, 15081, 570, 334, 46, 1311, 17076, 1553, 3372, 314, 4618, 288, 372, 398, 327, 1104, 3775, 314, 2397, 2138, 701, 664, 8796, 1535, 342, 267, 327, 367, 1924, 1747, 365, 16885, 5204, 687, 664, 80, 7567, 342, 367, 642, 1747, 267, 367, 325, 315, 4811, 26, 288, 340, 440, 325, 59, 16, 61, 503, 325, 59, 16, 61, 508, 6681, 356, 355, 1980, 327, 3372, 653, 1311, 4811, 5423, 14, 288, 291, 14, 479, 2531, 14258, 14, 362, 80, 3501, 455, 8, 69, 14, 8796, 63, 354, 9, 315, 4811, 24810, 59, 69, 14, 8796, 63, 354, 566, 288, 291, 14, 479, 2531, 14258, 14, 362, 8796, 1535, 8, 69, 14, 8796, 63, 1535, 9, 315, 4811, 991, 1535, 59, 69, 14, 8796, 63, 1535, 566, 339, 347, 511, 63, 2550, 8, 277, 304, 267, 291, 14, 1855, 8, 4333, 12, 14374, 14, 362, 8796, 1535, 9, 267, 291, 14, 1855, 8, 4333, 12, 14374, 14, 362, 80, 3501, 455, 9, 267, 291, 14, 1855, 8, 4333, 12, 14374, 14, 362, 80, 7567, 12, 5685, 9, 398, 327, 862, 370, 664, 2005, 2552, 267, 701, 1247, 275, 1052, 267, 701, 27637, 275, 1052, 267, 367, 334, 78, 12, 299, 12, 399, 12, 486, 12, 2312, 5197, 12, 366, 12, 308, 9, 315, 14374, 14, 362, 80, 7567, 837, 288, 701, 1247, 59, 78, 61, 275, 399, 288, 701, 27637, 59, 85, 61, 275, 302, 398, 1006, 1247, 275, 701, 1247, 14, 1612, 342, 267, 536, 73, 275, 378, 267, 1433, 917, 313, 275, 1006, 1247, 59, 354, 73, 61, 267, 1830, 1433, 917, 313, 315, 701, 1247, 26, 288, 8365, 275, 769, 8, 667, 917, 313, 9, 288, 367, 284, 315, 4945, 8, 552, 8, 6574, 2298, 355, 340, 8365, 59, 73, 61, 508, 283, 90, 356, 490, 8365, 59, 73, 61, 275, 283, 33, 7, 490, 2059, 355, 916, 8365, 59, 73, 61, 508, 283, 58, 356, 490, 1980, 355, 587, 26, 490, 8365, 59, 73, 61, 275, 8678, 8, 2181, 8, 6574, 59, 73, 566, 435, 413, 9, 490, 2059, 288, 587, 26, 355, 536, 73, 275, 536, 73, 435, 413, 355, 862, 26, 490, 1433, 917, 313, 275, 1006, 1247, 59, 354, 73, 61, 355, 871, 7888, 26, 490, 327, 1077, 7078, 5992, 1396, 340, 880, 12, 2951, 19459, 652, 490, 2059, 288, 1433, 917, 313, 275, 6522, 904, 8, 6574, 9, 398, 291, 14, 1855, 8, 10230, 12, 14374, 14, 362, 80, 3501, 455, 12, 1433, 917, 313, 9, 398, 327, 29826, 282, 2222, 13, 15025, 1747, 14, 267, 4026, 1535, 275, 841, 4195, 267, 1830, 4026, 1535, 315, 701, 27637, 26, 288, 4026, 1535, 275, 334, 3183, 1535, 627, 650, 9, 450, 378, 88, 9943, 398, 291, 14, 1855, 8, 10230, 12, 14374, 14, 362, 8796, 1535, 12, 4026, 1535, 9, 199, 199, 318, 511, 63, 973, 837, 272, 511, 63, 4058, 14, 1065, 63, 2796, 8, 32701, 774, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 511, 63, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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AND.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_table) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_table)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_table)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='mac-iceland', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Table decoding_table = ( u'\x00' # 0x00 -> CONTROL CHARACTER u'\x01' # 0x01 -> CONTROL CHARACTER u'\x02' # 0x02 -> CONTROL CHARACTER u'\x03' # 0x03 -> CONTROL CHARACTER u'\x04' # 0x04 -> CONTROL CHARACTER u'\x05' # 0x05 -> CONTROL CHARACTER u'\x06' # 0x06 -> CONTROL CHARACTER u'\x07' # 0x07 -> CONTROL CHARACTER u'\x08' # 0x08 -> CONTROL CHARACTER u'\t' # 0x09 -> CONTROL CHARACTER u'\n' # 0x0A -> CONTROL CHARACTER u'\x0b' # 0x0B -> CONTROL CHARACTER u'\x0c' # 0x0C -> CONTROL CHARACTER u'\r' # 0x0D -> CONTROL CHARACTER u'\x0e' # 0x0E -> CONTROL CHARACTER u'\x0f' # 0x0F -> CONTROL CHARACTER u'\x10' # 0x10 -> CONTROL CHARACTER u'\x11' # 0x11 -> CONTROL CHARACTER u'\x12' # 0x12 -> CONTROL CHARACTER u'\x13' # 0x13 -> CONTROL CHARACTER u'\x14' # 0x14 -> CONTROL CHARACTER u'\x15' # 0x15 -> CONTROL CHARACTER u'\x16' # 0x16 -> CONTROL CHARACTER u'\x17' # 0x17 -> CONTROL CHARACTER u'\x18' # 0x18 -> CONTROL CHARACTER u'\x19' # 0x19 -> CONTROL CHARACTER u'\x1a' # 0x1A -> CONTROL CHARACTER u'\x1b' # 0x1B -> CONTROL CHARACTER u'\x1c' # 0x1C -> CONTROL CHARACTER u'\x1d' # 0x1D -> CONTROL CHARACTER u'\x1e' # 0x1E -> CONTROL CHARACTER u'\x1f' # 0x1F -> CONTROL CHARACTER u' ' # 0x20 -> SPACE u'!' # 0x21 -> EXCLAMATION MARK u'"' # 0x22 -> QUOTATION MARK u'#' # 0x23 -> NUMBER SIGN u'$' # 0x24 -> DOLLAR SIGN u'%' # 0x25 -> PERCENT SIGN u'&' # 0x26 -> AMPERSAND u"'" # 0x27 -> APOSTROPHE u'(' # 0x28 -> LEFT PARENTHESIS u')' # 0x29 -> RIGHT PARENTHESIS u'*' # 0x2A -> ASTERISK u'+' # 0x2B -> PLUS SIGN u',' # 0x2C -> COMMA u'-' # 0x2D -> HYPHEN-MINUS u'.' # 0x2E -> FULL STOP u'/' # 0x2F -> SOLIDUS u'0' # 0x30 -> DIGIT ZERO u'1' # 0x31 -> DIGIT ONE u'2' # 0x32 -> DIGIT TWO u'3' # 0x33 -> DIGIT THREE u'4' # 0x34 -> DIGIT FOUR u'5' # 0x35 -> DIGIT FIVE u'6' # 0x36 -> DIGIT SIX u'7' # 0x37 -> DIGIT SEVEN u'8' # 0x38 -> DIGIT EIGHT u'9' # 0x39 -> DIGIT NINE u':' # 0x3A -> COLON u';' # 0x3B -> SEMICOLON u'<' # 0x3C -> LESS-THAN SIGN u'=' # 0x3D -> EQUALS SIGN u'>' # 0x3E -> GREATER-THAN SIGN u'?' # 0x3F -> QUESTION MARK u'@' # 0x40 -> COMMERCIAL AT u'A' # 0x41 -> LATIN CAPITAL LETTER A u'B' # 0x42 -> LATIN CAPITAL LETTER B u'C' # 0x43 -> LATIN CAPITAL LETTER C u'D' # 0x44 -> LATIN CAPITAL LETTER D u'E' # 0x45 -> LATIN CAPITAL LETTER E u'F' # 0x46 -> LATIN CAPITAL LETTER F u'G' # 0x47 -> LATIN CAPITAL LETTER G u'H' # 0x48 -> LATIN CAPITAL LETTER H u'I' # 0x49 -> LATIN CAPITAL LETTER I u'J' # 0x4A -> LATIN CAPITAL LETTER J u'K' # 0x4B -> LATIN CAPITAL LETTER K u'L' # 0x4C -> LATIN CAPITAL LETTER L u'M' # 0x4D -> LATIN CAPITAL LETTER M u'N' # 0x4E -> LATIN CAPITAL LETTER N u'O' # 0x4F -> LATIN CAPITAL LETTER O u'P' # 0x50 -> LATIN CAPITAL LETTER P u'Q' # 0x51 -> LATIN CAPITAL LETTER Q u'R' # 0x52 -> LATIN CAPITAL LETTER R u'S' # 0x53 -> LATIN CAPITAL LETTER S u'T' # 0x54 -> LATIN CAPITAL LETTER T u'U' # 0x55 -> LATIN CAPITAL LETTER U u'V' # 0x56 -> LATIN CAPITAL LETTER V u'W' # 0x57 -> LATIN CAPITAL LETTER W u'X' # 0x58 -> LATIN CAPITAL LETTER X u'Y' # 0x59 -> LATIN CAPITAL LETTER Y u'Z' # 0x5A -> LATIN CAPITAL LETTER Z u'[' # 0x5B -> LEFT SQUARE BRACKET u'\\' # 0x5C -> REVERSE SOLIDUS u']' # 0x5D -> RIGHT SQUARE BRACKET u'^' # 0x5E -> CIRCUMFLEX ACCENT u'_' # 0x5F -> LOW LINE u'`' # 0x60 -> GRAVE ACCENT u'a' # 0x61 -> LATIN SMALL LETTER A u'b' # 0x62 -> LATIN SMALL LETTER B u'c' # 0x63 -> LATIN SMALL LETTER C u'd' # 0x64 -> LATIN SMALL LETTER D u'e' # 0x65 -> LATIN SMALL LETTER E u'f' # 0x66 -> LATIN SMALL LETTER F u'g' # 0x67 -> LATIN SMALL LETTER G u'h' # 0x68 -> LATIN SMALL LETTER H u'i' # 0x69 -> LATIN SMALL LETTER I u'j' # 0x6A -> LATIN SMALL LETTER J u'k' # 0x6B -> LATIN SMALL LETTER K u'l' # 0x6C -> LATIN SMALL LETTER L u'm' # 0x6D -> LATIN SMALL LETTER M u'n' # 0x6E -> LATIN SMALL LETTER N u'o' # 0x6F -> LATIN SMALL LETTER O u'p' # 0x70 -> LATIN SMALL LETTER P u'q' # 0x71 -> LATIN SMALL LETTER Q u'r' # 0x72 -> LATIN SMALL LETTER R u's' # 0x73 -> LATIN SMALL LETTER S u't' # 0x74 -> LATIN SMALL LETTER T u'u' # 0x75 -> LATIN SMALL LETTER U u'v' # 0x76 -> LATIN SMALL LETTER V u'w' # 0x77 -> LATIN SMALL LETTER W u'x' # 0x78 -> LATIN SMALL LETTER X u'y' # 0x79 -> LATIN SMALL LETTER Y u'z' # 0x7A -> LATIN SMALL LETTER Z u'{' # 0x7B -> LEFT CURLY BRACKET u'|' # 0x7C -> VERTICAL LINE u'}' # 0x7D -> RIGHT CURLY BRACKET u'~' # 0x7E -> TILDE u'\x7f' # 0x7F -> CONTROL CHARACTER u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS u'\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE u'\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE u'\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS u'\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE u'\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE u'\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS u'\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE u'\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE u'\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE u'\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE u'\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX u'\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS u'\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE u'\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE u'\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX u'\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS u'\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE u'\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE u'\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS u'\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE u'\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE u'\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE u'\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS u'\xdd' # 0xA0 -> LATIN CAPITAL LETTER Y WITH ACUTE u'\xb0' # 0xA1 -> DEGREE SIGN u'\xa2' # 0xA2 -> CENT SIGN u'\xa3' # 0xA3 -> POUND SIGN u'\xa7' # 0xA4 -> SECTION SIGN u'\u2022' # 0xA5 -> BULLET u'\xb6' # 0xA6 -> PILCROW SIGN u'\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S u'\xae' # 0xA8 -> REGISTERED SIGN u'\xa9' # 0xA9 -> COPYRIGHT SIGN u'\u2122' # 0xAA -> TRADE MARK SIGN u'\xb4' # 0xAB -> ACUTE ACCENT u'\xa8' # 0xAC -> DIAERESIS u'\u2260' # 0xAD -> NOT EQUAL TO u'\xc6' # 0xAE -> LATIN CAPITAL LETTER AE u'\xd8' # 0xAF -> LATIN CAPITAL LETTER O WITH STROKE u'\u221e' # 0xB0 -> INFINITY u'\xb1' # 0xB1 -> PLUS-MINUS SIGN u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO u'\xa5' # 0xB4 -> YEN SIGN u'\xb5' # 0xB5 -> MICRO SIGN u'\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL u'\u2211' # 0xB7 -> N-ARY SUMMATION u'\u220f' # 0xB8 -> N-ARY PRODUCT u'\u03c0' # 0xB9 -> GREEK SMALL LETTER PI u'\u222b' # 0xBA -> INTEGRAL u'\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR u'\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR u'\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA u'\xe6' # 0xBE -> LATIN SMALL LETTER AE u'\xf8' # 0xBF -> LATIN SMALL LETTER O WITH STROKE u'\xbf' # 0xC0 -> INVERTED QUESTION MARK u'\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK u'\xac' # 0xC2 -> NOT SIGN u'\u221a' # 0xC3 -> SQUARE ROOT u'\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK u'\u2248' # 0xC5 -> ALMOST EQUAL TO u'\u2206' # 0xC6 -> INCREMENT u'\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK u'\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK u'\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS u'\xa0' # 0xCA -> NO-BREAK SPACE u'\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE u'\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE u'\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE u'\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE u'\u0153' # 0xCF -> LATIN SMALL LIGATURE OE u'\u2013' # 0xD0 -> EN DASH u'\u2014' # 0xD1 -> EM DASH u'\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK u'\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK u'\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK u'\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK u'\xf7' # 0xD6 -> DIVISION SIGN u'\u25ca' # 0xD7 -> LOZENGE u'\xff' # 0xD8 -> LATIN SMALL LETTER Y WITH DIAERESIS u'\u0178' # 0xD9 -> LATIN CAPITAL LETTER Y WITH DIAERESIS u'\u2044' # 0xDA -> FRACTION SLASH u'\u20ac' # 0xDB -> EURO SIGN u'\xd0' # 0xDC -> LATIN CAPITAL LETTER ETH u'\xf0' # 0xDD -> LATIN SMALL LETTER ETH u'\xde' # 0xDE -> LATIN CAPITAL LETTER THORN u'\xfe' # 0xDF -> LATIN SMALL LETTER THORN u'\xfd' # 0xE0 -> LATIN SMALL LETTER Y WITH ACUTE u'\xb7' # 0xE1 -> MIDDLE DOT u'\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK u'\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK u'\u2030' # 0xE4 -> PER MILLE SIGN u'\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX u'\xca' # 0xE6 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX u'\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE u'\xcb' # 0xE8 -> LATIN CAPITAL LETTER E WITH DIAERESIS u'\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE u'\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE u'\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX u'\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS u'\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE u'\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX u'\uf8ff' # 0xF0 -> Apple logo u'\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE u'\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE u'\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX u'\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE u'\u0131' # 0xF5 -> LATIN SMALL LETTER DOTLESS I u'\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT u'\u02dc' # 0xF7 -> SMALL TILDE u'\xaf' # 0xF8 -> MACRON u'\u02d8' # 0xF9 -> BREVE u'\u02d9' # 0xFA -> DOT ABOVE u'\u02da' # 0xFB -> RING ABOVE u'\xb8' # 0xFC -> CEDILLA u'\u02dd' # 0xFD -> DOUBLE ACUTE ACCENT u'\u02db' # 0xFE -> OGONEK u'\u02c7' # 0xFF -> CARON ) ### Encoding table encoding_table=codecs.charmap_build(decoding_table)
gpl-2.0
[ 624, 2018, 17660, 12340, 13732, 4497, 63, 1885, 9688, 4046, 687, 283, 32362, 15, 27839, 4149, 15, 31683, 15, 948, 2901, 3649, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 3088, 13, 1885, 9688, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 8098, 9502, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 8098, 9502, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 8098, 9502, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 8098, 9502, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 8098, 9502, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 8098, 9502, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 8098, 9502, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 8098, 9502, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 8098, 9502, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8098, 9502, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 8098, 9502, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 8098, 9502, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 8098, 9502, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 8098, 9502, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 8098, 9502, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 8098, 9502, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 8098, 9502, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 8098, 9502, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 8098, 9502, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 8098, 9502, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 8098, 9502, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 8098, 9502, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 399, 7, 17, 7, 263, 327, 221, 378, 88, 2192, 1035, 7298, 13051, 272, 399 ]
[ 2018, 17660, 12340, 13732, 4497, 63, 1885, 9688, 4046, 687, 283, 32362, 15, 27839, 4149, 15, 31683, 15, 948, 2901, 3649, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 3088, 13, 1885, 9688, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 8098, 9502, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 8098, 9502, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 8098, 9502, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 8098, 9502, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 8098, 9502, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 8098, 9502, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 8098, 9502, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 8098, 9502, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 8098, 9502, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8098, 9502, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 8098, 9502, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 8098, 9502, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 8098, 9502, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 8098, 9502, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 8098, 9502, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 8098, 9502, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 8098, 9502, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 8098, 9502, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 8098, 9502, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 8098, 9502, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 8098, 9502, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 8098, 9502, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 399, 7, 17, 7, 263, 327, 221, 378, 88, 2192, 1035, 7298, 13051, 272, 399, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
alertby/mbed
workspace_tools/host_tests/rtc_auto.py
122
2052
""" mbed SDK Copyright (c) 2011-2013 ARM Limited 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 re from time import time, strftime, gmtime class RTCTest(): PATTERN_RTC_VALUE = "\[(\d+)\] \[(\d+-\d+-\d+ \d+:\d+:\d+ [AaPpMm]{2})\]" re_detect_rtc_value = re.compile(PATTERN_RTC_VALUE) def test(self, selftest): test_result = True start = time() sec_prev = 0 for i in range(0, 5): # Timeout changed from default: we need to wait longer for some boards to start-up c = selftest.mbed.serial_readline(timeout=10) if c is None: return selftest.RESULT_IO_SERIAL selftest.notify(c.strip()) delta = time() - start m = self.re_detect_rtc_value.search(c) if m and len(m.groups()): sec = int(m.groups()[0]) time_str = m.groups()[1] correct_time_str = strftime("%Y-%m-%d %H:%M:%S %p", gmtime(float(sec))) single_result = time_str == correct_time_str and sec > 0 and sec > sec_prev test_result = test_result and single_result result_msg = "OK" if single_result else "FAIL" selftest.notify("HOST: [%s] [%s] received time %+d sec after %.2f sec... %s"% (sec, time_str, sec - sec_prev, delta, result_msg)) sec_prev = sec else: test_result = False break start = time() return selftest.RESULT_SUCCESS if test_result else selftest.RESULT_FAILURE
apache-2.0
[ 624, 199, 3665, 15610, 199, 7384, 334, 67, 9, 7760, 13, 6965, 27155, 23954, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 199, 646, 295, 199, 504, 900, 492, 900, 12, 14053, 12, 486, 8180, 199, 199, 533, 820, 5708, 774, 837, 272, 31467, 7689, 63, 50, 5708, 63, 7041, 275, 1867, 59, 2961, 68, 13439, 61, 30257, 2961, 68, 11, 2696, 68, 11, 2696, 68, 11, 971, 68, 11, 3427, 68, 11, 3427, 68, 11, 359, 33, 65, 48, 80, 28171, 8194, 18, 30446, 8480, 272, 295, 63, 13552, 63, 23392, 63, 585, 275, 295, 14, 2014, 8, 10764, 63, 50, 5708, 63, 7041, 9, 339, 347, 511, 8, 277, 12, 291, 396, 304, 267, 511, 63, 1099, 275, 715, 267, 1343, 275, 900, 342, 267, 6513, 63, 5701, 275, 378, 267, 367, 284, 315, 1425, 8, 16, 12, 959, 304, 288, 327, 12878, 2896, 687, 849, 26, 781, 1929, 370, 3618, 8088, 367, 2005, 1234, 5596, 370, 1343, 13, 384, 288, 286, 275, 291, 396, 14, 3665, 14, 2171, 63, 6407, 8, 2593, 29, 709, 9, 288, 340, 286, 365, 488, 26, 355, 372, 291, 396, 14, 9517, 63, 2090, 63, 19637, 288, 291, 396, 14, 6814, 8, 67, 14, 1913, 1012, 288, 5762, 275, 900, 342, 446, 1343, 288, 333, 275, 291, 14, 264, 63, 13552, 63, 23392, 63, 585, 14, 1733, 8, 67, 9, 288, 340, 333, 436, 822, 8, 77, 14, 2634, 5109, 355, 6513, 275, 1109, 8, 77, 14, 2634, 3430, 16, 566, 355, 900, 63, 495, 275, 333, 14, 2634, 3430, 17, 61, 355, 3211, 63, 521, 63, 495, 275, 14053, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 450, 80, 401, 486, 8180, 8, 1609, 8, 3321, 1724, 355, 2849, 63, 1099, 275, 900, 63, 495, 508, 3211, 63, 521, 63, 495, 436, 6513, 690, 378, 436, 6513, 690, 6513, 63, 5701, 355, 511, 63, 1099, 275, 511, 63, 1099, 436, 2849, 63, 1099, 355, 754, 63, 1328, 275, 298, 3593, 2, 340, 2849, 63, 1099, 587, 298, 8784, 2, 355, 291, 396, 14, 6814, 480, 5449, 26, 8978, 83, 61, 8978, 83, 61, 3086, 900, 450, 11, 68, 6513, 2410, 10536, 18, 70, 6513, 1396, 450, 83, 6808, 334, 3321, 12, 900, 63, 495, 12, 6513, 446, 6513, 63, 5701, 12, 5762, 12, 754, 63, 1328, 430, 355, 6513, 63, 5701, 275, 6513, 288, 587, 26, 355, 511, 63, 1099, 275, 756, 355, 2059, 288, 1343, 275, 900, 342, 267, 372, 291, 396, 14, 9517, 63, 12779, 340, 511, 63, 1099, 587, 291, 396, 14, 9517, 63, 13989, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3665, 15610, 199, 7384, 334, 67, 9, 7760, 13, 6965, 27155, 23954, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 199, 646, 295, 199, 504, 900, 492, 900, 12, 14053, 12, 486, 8180, 199, 199, 533, 820, 5708, 774, 837, 272, 31467, 7689, 63, 50, 5708, 63, 7041, 275, 1867, 59, 2961, 68, 13439, 61, 30257, 2961, 68, 11, 2696, 68, 11, 2696, 68, 11, 971, 68, 11, 3427, 68, 11, 3427, 68, 11, 359, 33, 65, 48, 80, 28171, 8194, 18, 30446, 8480, 272, 295, 63, 13552, 63, 23392, 63, 585, 275, 295, 14, 2014, 8, 10764, 63, 50, 5708, 63, 7041, 9, 339, 347, 511, 8, 277, 12, 291, 396, 304, 267, 511, 63, 1099, 275, 715, 267, 1343, 275, 900, 342, 267, 6513, 63, 5701, 275, 378, 267, 367, 284, 315, 1425, 8, 16, 12, 959, 304, 288, 327, 12878, 2896, 687, 849, 26, 781, 1929, 370, 3618, 8088, 367, 2005, 1234, 5596, 370, 1343, 13, 384, 288, 286, 275, 291, 396, 14, 3665, 14, 2171, 63, 6407, 8, 2593, 29, 709, 9, 288, 340, 286, 365, 488, 26, 355, 372, 291, 396, 14, 9517, 63, 2090, 63, 19637, 288, 291, 396, 14, 6814, 8, 67, 14, 1913, 1012, 288, 5762, 275, 900, 342, 446, 1343, 288, 333, 275, 291, 14, 264, 63, 13552, 63, 23392, 63, 585, 14, 1733, 8, 67, 9, 288, 340, 333, 436, 822, 8, 77, 14, 2634, 5109, 355, 6513, 275, 1109, 8, 77, 14, 2634, 3430, 16, 566, 355, 900, 63, 495, 275, 333, 14, 2634, 3430, 17, 61, 355, 3211, 63, 521, 63, 495, 275, 14053, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 450, 80, 401, 486, 8180, 8, 1609, 8, 3321, 1724, 355, 2849, 63, 1099, 275, 900, 63, 495, 508, 3211, 63, 521, 63, 495, 436, 6513, 690, 378, 436, 6513, 690, 6513, 63, 5701, 355, 511, 63, 1099, 275, 511, 63, 1099, 436, 2849, 63, 1099, 355, 754, 63, 1328, 275, 298, 3593, 2, 340, 2849, 63, 1099, 587, 298, 8784, 2, 355, 291, 396, 14, 6814, 480, 5449, 26, 8978, 83, 61, 8978, 83, 61, 3086, 900, 450, 11, 68, 6513, 2410, 10536, 18, 70, 6513, 1396, 450, 83, 6808, 334, 3321, 12, 900, 63, 495, 12, 6513, 446, 6513, 63, 5701, 12, 5762, 12, 754, 63, 1328, 430, 355, 6513, 63, 5701, 275, 6513, 288, 587, 26, 355, 511, 63, 1099, 275, 756, 355, 2059, 288, 1343, 275, 900, 342, 267, 372, 291, 396, 14, 9517, 63, 12779, 340, 511, 63, 1099, 587, 291, 396, 14, 9517, 63, 13989, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
m8ttyB/socorro
webapp-django/crashstats/supersearch/tests/test_utils.py
3
1142
import datetime from nose.tools import eq_ from django.utils.timezone import utc from crashstats.crashstats.tests.test_views import BaseTestViews from crashstats.topcrashers.views import get_date_boundaries class TestDateBoundaries(BaseTestViews): def test_get_date_boundaries(self): # Simple test. start, end = get_date_boundaries({ 'date': [ '>2010-03-01T12:12:12', '<=2010-03-10T00:00:00', ] }) eq_( start, datetime.datetime(2010, 3, 1, 12, 12, 12).replace(tzinfo=utc) ) eq_(end, datetime.datetime(2010, 3, 10).replace(tzinfo=utc)) # Test with messy dates. start, end = get_date_boundaries({ 'date': [ '>2010-03-01T12:12:12', '>2009-01-01T12:12:12', '<2010-03-11T00:00:00', '<=2010-03-10T00:00:00', ] }) eq_( start, datetime.datetime(2009, 1, 1, 12, 12, 12).replace(tzinfo=utc) ) eq_(end, datetime.datetime(2010, 3, 11).replace(tzinfo=utc))
mpl-2.0
[ 646, 2197, 199, 199, 504, 11354, 14, 2537, 492, 3850, 63, 199, 199, 504, 1639, 14, 1208, 14, 7145, 492, 19314, 199, 199, 504, 12420, 3200, 14, 14807, 3200, 14, 2219, 14, 396, 63, 4196, 492, 3523, 774, 21180, 199, 504, 12420, 3200, 14, 2119, 14807, 1192, 14, 4196, 492, 664, 63, 602, 63, 27505, 421, 199, 533, 1379, 2506, 8934, 3433, 8, 23170, 21180, 304, 272, 347, 511, 63, 362, 63, 602, 63, 27505, 8, 277, 304, 267, 327, 5870, 511, 14, 267, 1343, 12, 1284, 275, 664, 63, 602, 63, 27505, 2561, 288, 283, 602, 356, 359, 355, 12696, 6542, 13, 1644, 13, 614, 52, 713, 26, 713, 26, 713, 297, 355, 2650, 29, 6542, 13, 1644, 13, 709, 52, 383, 26, 383, 26, 383, 297, 288, 1622, 267, 3828, 267, 3850, 2531, 288, 1343, 12, 288, 2197, 14, 2083, 8, 6542, 12, 650, 12, 413, 12, 3144, 12, 3144, 12, 3144, 680, 1814, 8, 9374, 29, 5834, 9, 267, 776, 267, 3850, 2531, 500, 12, 2197, 14, 2083, 8, 6542, 12, 650, 12, 1616, 680, 1814, 8, 9374, 29, 5834, 430, 398, 327, 1379, 543, 15634, 89, 10831, 14, 267, 1343, 12, 1284, 275, 664, 63, 602, 63, 27505, 2561, 288, 283, 602, 356, 359, 355, 12696, 6542, 13, 1644, 13, 614, 52, 713, 26, 713, 26, 713, 297, 355, 12696, 8664, 13, 614, 13, 614, 52, 713, 26, 713, 26, 713, 297, 355, 2650, 6542, 13, 1644, 13, 845, 52, 383, 26, 383, 26, 383, 297, 355, 2650, 29, 6542, 13, 1644, 13, 709, 52, 383, 26, 383, 26, 383, 297, 288, 1622, 267, 3828, 267, 3850, 2531, 288, 1343, 12, 288, 2197, 14, 2083, 8, 8664, 12, 413, 12, 413, 12, 3144, 12, 3144, 12, 3144, 680, 1814, 8, 9374, 29, 5834, 9, 267, 776, 267, 3850, 2531, 500, 12, 2197, 14, 2083, 8, 6542, 12, 650, 12, 4119, 680, 1814, 8, 9374, 29, 5834, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 199, 199, 504, 11354, 14, 2537, 492, 3850, 63, 199, 199, 504, 1639, 14, 1208, 14, 7145, 492, 19314, 199, 199, 504, 12420, 3200, 14, 14807, 3200, 14, 2219, 14, 396, 63, 4196, 492, 3523, 774, 21180, 199, 504, 12420, 3200, 14, 2119, 14807, 1192, 14, 4196, 492, 664, 63, 602, 63, 27505, 421, 199, 533, 1379, 2506, 8934, 3433, 8, 23170, 21180, 304, 272, 347, 511, 63, 362, 63, 602, 63, 27505, 8, 277, 304, 267, 327, 5870, 511, 14, 267, 1343, 12, 1284, 275, 664, 63, 602, 63, 27505, 2561, 288, 283, 602, 356, 359, 355, 12696, 6542, 13, 1644, 13, 614, 52, 713, 26, 713, 26, 713, 297, 355, 2650, 29, 6542, 13, 1644, 13, 709, 52, 383, 26, 383, 26, 383, 297, 288, 1622, 267, 3828, 267, 3850, 2531, 288, 1343, 12, 288, 2197, 14, 2083, 8, 6542, 12, 650, 12, 413, 12, 3144, 12, 3144, 12, 3144, 680, 1814, 8, 9374, 29, 5834, 9, 267, 776, 267, 3850, 2531, 500, 12, 2197, 14, 2083, 8, 6542, 12, 650, 12, 1616, 680, 1814, 8, 9374, 29, 5834, 430, 398, 327, 1379, 543, 15634, 89, 10831, 14, 267, 1343, 12, 1284, 275, 664, 63, 602, 63, 27505, 2561, 288, 283, 602, 356, 359, 355, 12696, 6542, 13, 1644, 13, 614, 52, 713, 26, 713, 26, 713, 297, 355, 12696, 8664, 13, 614, 13, 614, 52, 713, 26, 713, 26, 713, 297, 355, 2650, 6542, 13, 1644, 13, 845, 52, 383, 26, 383, 26, 383, 297, 355, 2650, 29, 6542, 13, 1644, 13, 709, 52, 383, 26, 383, 26, 383, 297, 288, 1622, 267, 3828, 267, 3850, 2531, 288, 1343, 12, 288, 2197, 14, 2083, 8, 8664, 12, 413, 12, 413, 12, 3144, 12, 3144, 12, 3144, 680, 1814, 8, 9374, 29, 5834, 9, 267, 776, 267, 3850, 2531, 500, 12, 2197, 14, 2083, 8, 6542, 12, 650, 12, 4119, 680, 1814, 8, 9374, 29, 5834, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
ojengwa/grr
client/client_actions/standard.py
2
20847
#!/usr/bin/env python """Standard actions that happen on the client.""" import cStringIO as StringIO import ctypes import gzip import hashlib import os import platform import socket import sys import time import zlib import psutil import logging from grr.client import actions from grr.client import client_utils_common from grr.client import vfs from grr.client.client_actions import tempfiles from grr.lib import config_lib from grr.lib import flags from grr.lib import rdfvalue from grr.lib import utils from grr.lib.rdfvalues import crypto # We do not send larger buffers than this: MAX_BUFFER_SIZE = 640 * 1024 class ReadBuffer(actions.ActionPlugin): """Reads a buffer from a file and returns it to a server callback.""" in_rdfvalue = rdfvalue.BufferReference out_rdfvalue = rdfvalue.BufferReference def Run(self, args): """Reads a buffer on the client and sends it to the server.""" # Make sure we limit the size of our output if args.length > MAX_BUFFER_SIZE: raise RuntimeError("Can not read buffers this large.") try: fd = vfs.VFSOpen(args.pathspec, progress_callback=self.Progress) fd.Seek(args.offset) offset = fd.Tell() data = fd.Read(args.length) except (IOError, OSError), e: self.SetStatus(rdfvalue.GrrStatus.ReturnedStatus.IOERROR, e) return # Now return the data to the server self.SendReply(offset=offset, data=data, length=len(data), pathspec=fd.pathspec) HASH_CACHE = utils.FastStore(100) class TransferBuffer(actions.ActionPlugin): """Reads a buffer from a file and returns it to the server efficiently.""" in_rdfvalue = rdfvalue.BufferReference out_rdfvalue = rdfvalue.BufferReference def Run(self, args): """Reads a buffer on the client and sends it to the server.""" # Make sure we limit the size of our output if args.length > MAX_BUFFER_SIZE: raise RuntimeError("Can not read buffers this large.") data = vfs.ReadVFS(args.pathspec, args.offset, args.length, progress_callback=self.Progress) result = rdfvalue.DataBlob( data=zlib.compress(data), compression=rdfvalue.DataBlob.CompressionType.ZCOMPRESSION) digest = hashlib.sha256(data).digest() # Ensure that the buffer is counted against this response. Check network # send limit. self.ChargeBytesToSession(len(data)) # Now return the data to the server into the special TransferStore well # known flow. self.grr_worker.SendReply( result, session_id=rdfvalue.SessionID(flow_name="TransferStore")) # Now report the hash of this blob to our flow as well as the offset and # length. self.SendReply(offset=args.offset, length=len(data), data=digest) class HashBuffer(actions.ActionPlugin): """Hash a buffer from a file and returns it to the server efficiently.""" in_rdfvalue = rdfvalue.BufferReference out_rdfvalue = rdfvalue.BufferReference def Run(self, args): """Reads a buffer on the client and sends it to the server.""" # Make sure we limit the size of our output if args.length > MAX_BUFFER_SIZE: raise RuntimeError("Can not read buffers this large.") data = vfs.ReadVFS(args.pathspec, args.offset, args.length) digest = hashlib.sha256(data).digest() # Now report the hash of this blob to our flow as well as the offset and # length. self.SendReply(offset=args.offset, length=len(data), data=digest) class CopyPathToFile(actions.ActionPlugin): """Copy contents of a pathspec to a file on disk.""" in_rdfvalue = rdfvalue.CopyPathToFileRequest out_rdfvalue = rdfvalue.CopyPathToFileRequest BLOCK_SIZE = 10 * 1024 * 1024 def _Copy(self, dest_fd): """Copy from VFS to file until no more data or self.length is reached. Args: dest_fd: file object to write to Returns: self.written: bytes written """ while self.written < self.length: to_read = min(self.length - self.written, self.BLOCK_SIZE) data = self.src_fd.read(to_read) if not data: break dest_fd.write(data) self.written += len(data) # Send heartbeats for long files. self.Progress() return self.written def Run(self, args): """Read from a VFS file and write to a GRRTempFile on disk. If file writing doesn't complete files won't be cleaned up. Args: args: see CopyPathToFile in jobs.proto """ self.src_fd = vfs.VFSOpen(args.src_path, progress_callback=self.Progress) self.src_fd.Seek(args.offset) offset = self.src_fd.Tell() self.length = args.length or (1024 ** 4) # 1 TB self.written = 0 suffix = ".gz" if args.gzip_output else "" self.dest_fd = tempfiles.CreateGRRTempFile(directory=args.dest_dir, lifetime=args.lifetime, suffix=suffix) self.dest_file = self.dest_fd.name with self.dest_fd: if args.gzip_output: gzip_fd = gzip.GzipFile(self.dest_file, "wb", 9, self.dest_fd) # Gzip filehandle needs its own close method called with gzip_fd: self._Copy(gzip_fd) else: self._Copy(self.dest_fd) pathspec_out = rdfvalue.PathSpec( path=self.dest_file, pathtype=rdfvalue.PathSpec.PathType.OS) self.SendReply(offset=offset, length=self.written, src_path=args.src_path, dest_dir=args.dest_dir, dest_path=pathspec_out, gzip_output=args.gzip_output) class ListDirectory(ReadBuffer): """Lists all the files in a directory.""" in_rdfvalue = rdfvalue.ListDirRequest out_rdfvalue = rdfvalue.StatEntry def Run(self, args): """Lists a directory.""" try: directory = vfs.VFSOpen(args.pathspec, progress_callback=self.Progress) except (IOError, OSError), e: self.SetStatus(rdfvalue.GrrStatus.ReturnedStatus.IOERROR, e) return files = list(directory.ListFiles()) files.sort(key=lambda x: x.pathspec.path) for response in files: self.SendReply(response) class IteratedListDirectory(actions.IteratedAction): """Lists a directory as an iterator.""" in_rdfvalue = rdfvalue.ListDirRequest out_rdfvalue = rdfvalue.StatEntry def Iterate(self, request, client_state): """Restores its way through the directory using an Iterator.""" try: fd = vfs.VFSOpen(request.pathspec, progress_callback=self.Progress) except (IOError, OSError), e: self.SetStatus(rdfvalue.GrrStatus.ReturnedStatus.IOERROR, e) return files = list(fd.ListFiles()) files.sort(key=lambda x: x.pathspec.path) index = client_state.get("index", 0) length = request.iterator.number for response in files[index:index + length]: self.SendReply(response) # Update the state client_state["index"] = index + length class SuspendableListDirectory(actions.SuspendableAction): """Lists a directory as a suspendable client action.""" in_rdfvalue = rdfvalue.ListDirRequest out_rdfvalue = rdfvalue.StatEntry def Iterate(self): try: fd = vfs.VFSOpen(self.request.pathspec, progress_callback=self.Progress) except (IOError, OSError), e: self.SetStatus(rdfvalue.GrrStatus.ReturnedStatus.IOERROR, e) return length = self.request.iterator.number for group in utils.Grouper(fd.ListFiles(), length): for response in group: self.SendReply(response) self.Suspend() class StatFile(ListDirectory): """Sends a StatResponse for a single file.""" in_rdfvalue = rdfvalue.ListDirRequest out_rdfvalue = rdfvalue.StatEntry def Run(self, args): """Sends a StatResponse for a single file.""" try: fd = vfs.VFSOpen(args.pathspec, progress_callback=self.Progress) res = fd.Stat() self.SendReply(res) except (IOError, OSError), e: self.SetStatus(rdfvalue.GrrStatus.ReturnedStatus.IOERROR, e) return class ExecuteCommand(actions.ActionPlugin): """Executes one of the predefined commands.""" in_rdfvalue = rdfvalue.ExecuteRequest out_rdfvalue = rdfvalue.ExecuteResponse def Run(self, command): """Run.""" cmd = command.cmd args = command.args time_limit = command.time_limit res = client_utils_common.Execute(cmd, args, time_limit) (stdout, stderr, status, time_used) = res # Limit output to 10MB so our response doesn't get too big. stdout = stdout[:10 * 1024 * 1024] stderr = stderr[:10 * 1024 * 1024] result = rdfvalue.ExecuteResponse( request=command, stdout=stdout, stderr=stderr, exit_status=status, # We have to return microseconds. time_used=int(1e6 * time_used)) self.SendReply(result) class ExecuteBinaryCommand(actions.ActionPlugin): """Executes a command from a passed in binary. Obviously this is a dangerous function, it provides for arbitrary code exec by the server running as root/SYSTEM. This is protected by the CONFIG[PrivateKeys.executable_signing_private_key], which should be stored offline and well protected. This method can be utilized as part of an autoupdate mechanism if necessary. NOTE: If the binary is too large to fit inside a single request, the request will have the more_data flag enabled, indicating more data is coming. """ in_rdfvalue = rdfvalue.ExecuteBinaryRequest out_rdfvalue = rdfvalue.ExecuteBinaryResponse suffix = "" def WriteBlobToFile(self, request, suffix=""): """Writes the blob to a file and returns its path.""" lifetime = 0 # Only set the lifetime thread on the last chunk written. if not request.more_data: lifetime = request.time_limit # Keep the file for at least 5 seconds after execution. if lifetime > 0: lifetime += 5 # First chunk truncates the file, later chunks append. if request.offset == 0: mode = "w+b" else: mode = "r+b" temp_file = tempfiles.CreateGRRTempFile(filename=request.write_path, suffix=suffix, mode=mode) with temp_file: path = temp_file.name temp_file.seek(0, 2) if temp_file.tell() != request.offset: raise IOError("Chunks out of order Error.") # Write the new chunk. temp_file.write(request.executable.data) return path def CleanUp(self, path): """Removes the temp file.""" try: if os.path.exists(path): os.remove(path) except (OSError, IOError), e: logging.info("Failed to remove temporary file %s. Err: %s", path, e) def Run(self, args): """Run.""" # Verify the executable blob. args.executable.Verify(config_lib.CONFIG[ "Client.executable_signing_public_key"]) path = self.WriteBlobToFile(args, self.suffix) # Only actually run the file on the last chunk. if not args.more_data: self.ProcessFile(path, args) self.CleanUp(path) def ProcessFile(self, path, args): res = client_utils_common.Execute(path, args.args, args.time_limit, bypass_whitelist=True) (stdout, stderr, status, time_used) = res # Limit output to 10MB so our response doesn't get too big. stdout = stdout[:10 * 1024 * 1024] stderr = stderr[:10 * 1024 * 1024] result = rdfvalue.ExecuteBinaryResponse( stdout=stdout, stderr=stderr, exit_status=status, # We have to return microseconds. time_used=int(1e6 * time_used)) self.SendReply(result) class ExecutePython(actions.ActionPlugin): """Executes python code with exec. Obviously this is a dangerous function, it provides for arbitrary code exec by the server running as root/SYSTEM. This is protected by CONFIG[PrivateKeys.executable_signing_private_key], which should be stored offline and well protected. """ in_rdfvalue = rdfvalue.ExecutePythonRequest out_rdfvalue = rdfvalue.ExecutePythonResponse def Run(self, args): """Run.""" time_start = time.time() class StdOutHook(object): def __init__(self, buf): self.buf = buf def write(self, text): self.buf.write(text) args.python_code.Verify(config_lib.CONFIG[ "Client.executable_signing_public_key"]) # The execed code can assign to this variable if it wants to return data. logging.debug("exec for python code %s", args.python_code.data[0:100]) context = globals().copy() context["py_args"] = args.py_args.ToDict() context["magic_return_str"] = "" # Export the Progress function to allow python hacks to call it. context["Progress"] = self.Progress stdout = StringIO.StringIO() with utils.Stubber(sys, "stdout", StdOutHook(stdout)): exec(args.python_code.data, context) # pylint: disable=exec-used stdout_output = stdout.getvalue() magic_str_output = context.get("magic_return_str") if stdout_output and magic_str_output: output = "Stdout: %s\nMagic Str:%s\n" % (stdout_output, magic_str_output) else: output = stdout_output or magic_str_output time_used = time.time() - time_start # We have to return microseconds. result = rdfvalue.ExecutePythonResponse( time_used=int(1e6 * time_used), return_val=utils.SmartStr(output)) self.SendReply(result) class Segfault(actions.ActionPlugin): """This action is just for debugging. It induces a segfault.""" in_rdfvalue = None out_rdfvalue = None def Run(self, unused_args): """Does the segfaulting.""" if flags.FLAGS.debug: logging.warning("Segfault action requested :(") print ctypes.cast(1, ctypes.POINTER(ctypes.c_void_p)).contents else: logging.warning("Segfault requested but not running in debug mode.") class ListProcesses(actions.ActionPlugin): """This action lists all the processes running on a machine.""" in_rdfvalue = None out_rdfvalue = rdfvalue.Process def Run(self, unused_arg): # psutil will cause an active loop on Windows 2000 if platform.system() == "Windows" and platform.version().startswith("5.0"): raise RuntimeError("ListProcesses not supported on Windows 2000") for proc in psutil.process_iter(): response = rdfvalue.Process() process_fields = ["pid", "ppid", "name", "exe", "username", "terminal"] for field in process_fields: try: value = getattr(proc, field) if value is None: continue if callable(value): value = value() if not isinstance(value, (int, long)): value = utils.SmartUnicode(value) setattr(response, field, value) except (psutil.NoSuchProcess, psutil.AccessDenied, AttributeError): pass try: for arg in proc.cmdline(): response.cmdline.append(utils.SmartUnicode(arg)) except (psutil.NoSuchProcess, psutil.AccessDenied): pass try: response.nice = proc.nice() except (psutil.NoSuchProcess, psutil.AccessDenied): pass try: # Not available on Windows. if hasattr(proc, "uids"): (response.real_uid, response.effective_uid, response.saved_uid) = proc.uids() (response.real_gid, response.effective_gid, response.saved_gid) = proc.gids() except (psutil.NoSuchProcess, psutil.AccessDenied): pass try: response.ctime = long(proc.create_time() * 1e6) response.status = str(proc.status()) except (psutil.NoSuchProcess, psutil.AccessDenied): pass try: # Not available on OSX. if hasattr(proc, "cwd"): response.cwd = utils.SmartUnicode(proc.cwd()) except (psutil.NoSuchProcess, psutil.AccessDenied): pass try: response.num_threads = proc.num_threads() except (psutil.NoSuchProcess, psutil.AccessDenied, RuntimeError): pass try: (response.user_cpu_time, response.system_cpu_time) = proc.cpu_times() # This is very time consuming so we do not collect cpu_percent here. # response.cpu_percent = proc.get_cpu_percent() except (psutil.NoSuchProcess, psutil.AccessDenied): pass try: response.RSS_size, response.VMS_size = proc.memory_info() response.memory_percent = proc.memory_percent() except (psutil.NoSuchProcess, psutil.AccessDenied): pass # Due to a bug in psutil, this function is disabled for now # (https://github.com/giampaolo/psutil/issues/340) # try: # for f in proc.open_files(): # response.open_files.append(utils.SmartUnicode(f.path)) # except (psutil.NoSuchProcess, psutil.AccessDenied): # pass try: for c in proc.connections(): conn = response.connections.Append(family=c.family, type=c.type, pid=proc.pid) try: conn.state = c.status except ValueError: logging.info("Encountered unknown connection status (%s).", c.status) try: conn.local_address.ip, conn.local_address.port = c.laddr # Could be in state LISTEN. if c.raddr: conn.remote_address.ip, conn.remote_address.port = c.raddr except AttributeError: conn.local_address.ip, conn.local_address.port = c.local_address # Could be in state LISTEN. if c.remote_address: (conn.remote_address.ip, conn.remote_address.port) = c.remote_address except (psutil.NoSuchProcess, psutil.AccessDenied): pass self.SendReply(response) # Reading information here is slow so we heartbeat between processes. self.Progress() class SendFile(actions.ActionPlugin): """This action encrypts and sends a file to a remote listener.""" in_rdfvalue = rdfvalue.SendFileRequest out_rdfvalue = rdfvalue.StatEntry BLOCK_SIZE = 1024 * 1024 * 10 # 10 MB def Send(self, sock, msg): totalsent = 0 n = len(msg) while totalsent < n: sent = sock.send(msg[totalsent:]) if sent == 0: raise RuntimeError("socket connection broken") totalsent += sent def Run(self, args): """Run.""" # Open the file. fd = vfs.VFSOpen(args.pathspec, progress_callback=self.Progress) if args.address_family == rdfvalue.NetworkAddress.Family.INET: family = socket.AF_INET elif args.address_family == rdfvalue.NetworkAddress.Family.INET6: family = socket.AF_INET6 else: raise RuntimeError("Socket address family not supported.") s = socket.socket(family, socket.SOCK_STREAM) try: s.connect((args.host, args.port)) except socket.error as e: raise RuntimeError(str(e)) cipher = crypto.AES128CBCCipher(args.key, args.iv, crypto.Cipher.OP_ENCRYPT) while True: data = fd.read(self.BLOCK_SIZE) if not data: break self.Send(s, cipher.Update(data)) # Send heartbeats for long files. self.Progress() self.Send(s, cipher.Final()) s.close() self.SendReply(fd.Stat()) class StatFS(actions.ActionPlugin): """Call os.statvfs for a given list of paths. OS X and Linux only. Note that a statvfs call for a network filesystem (e.g. NFS) that is unavailable, e.g. due to no network, will result in the call blocking. """ in_rdfvalue = rdfvalue.StatFSRequest out_rdfvalue = rdfvalue.Volume def Run(self, args): if platform.system() == "Windows": raise RuntimeError("os.statvfs not available on Windows") for path in args.path_list: try: fd = vfs.VFSOpen(rdfvalue.PathSpec(path=path, pathtype=args.pathtype), progress_callback=self.Progress) st = fd.StatFS() mount_point = fd.GetMountPoint() except (IOError, OSError), e: self.SetStatus(rdfvalue.GrrStatus.ReturnedStatus.IOERROR, e) continue unix = rdfvalue.UnixVolume(mount_point=mount_point) # On linux pre 2.6 kernels don't have frsize, so we fall back to bsize. # The actual_available_allocation_units attribute is set to blocks # available to the unprivileged user, root may have some additional # reserved space. result = rdfvalue.Volume(bytes_per_sector=(st.f_frsize or st.f_bsize), sectors_per_allocation_unit=1, total_allocation_units=st.f_blocks, actual_available_allocation_units=st.f_bavail, unix=unix) self.SendReply(result)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 9232, 5445, 626, 5992, 641, 314, 1890, 1041, 421, 199, 646, 15073, 465, 5228, 199, 646, 5577, 199, 646, 11756, 199, 646, 8337, 199, 646, 747, 199, 646, 4298, 199, 646, 2838, 199, 646, 984, 199, 646, 900, 199, 646, 12472, 421, 199, 646, 22214, 199, 199, 646, 2050, 199, 199, 504, 31118, 14, 1258, 492, 5445, 199, 504, 31118, 14, 1258, 492, 1890, 63, 1208, 63, 2330, 199, 504, 31118, 14, 1258, 492, 31628, 199, 504, 31118, 14, 1258, 14, 1258, 63, 3723, 492, 2388, 1725, 199, 504, 31118, 14, 773, 492, 1101, 63, 773, 199, 504, 31118, 14, 773, 492, 3285, 199, 504, 31118, 14, 773, 492, 18148, 585, 199, 504, 31118, 14, 773, 492, 3778, 199, 504, 31118, 14, 773, 14, 17120, 1459, 492, 13230, 421, 199, 3, 2136, 886, 440, 3222, 12142, 19383, 2419, 642, 26, 199, 4283, 63, 10960, 63, 4305, 275, 5049, 16, 627, 6619, 421, 199, 533, 5574, 3299, 8, 3723, 14, 3310, 5061, 304, 523, 408, 23614, 282, 3335, 687, 282, 570, 436, 2529, 652, 370, 282, 1654, 3233, 1041, 523, 315, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 523, 734, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 819, 347, 3378, 8, 277, 12, 1249, 304, 272, 408, 23614, 282, 3335, 641, 314, 1890, 436, 16178, 652, 370, 314, 1654, 1041, 272, 327, 4155, 3238, 781, 2304, 314, 1568, 402, 4154, 1072, 272, 340, 1249, 14, 1267, 690, 9141, 63, 10960, 63, 4305, 26, 489, 746, 6064, 480, 6049, 440, 1586, 19383, 642, 7031, 2685, 339, 862, 26, 489, 6111, 275, 31628, 14, 32364, 4118, 897, 8, 589, 14, 515, 1650, 12, 6696, 63, 3058, 29, 277, 14, 11504, 9, 2541, 6111, 14, 19168, 8, 589, 14, 2743, 9, 489, 3268, 275, 6111, 14, 52, 1697, 342, 2541, 666, 275, 6111, 14, 3284, 8, 589, 14, 1267, 9, 339, 871, 334, 13760, 12, 6440, 395, 325, 26, 489, 291, 14, 1084, 3694, 8, 17120, 585, 14, 39, 9734, 3694, 14, 28239, 3694, 14, 2090, 3170, 12, 325, 9, 489, 372, 339, 327, 7356, 372, 314, 666, 370, 314, 1654, 272, 291, 14, 6795, 14166, 8, 2743, 29, 2743, 12, 666, 29, 576, 12, 673, 2582, 29, 552, 8, 576, 395, 931, 1650, 29, 2592, 14, 515, 1650, 9, 421, 199, 14395, 63, 8677, 275, 3778, 14, 16976, 5502, 8, 1960, 9, 421, 199, 533, 27507, 3299, 8, 3723, 14, 3310, 5061, 304, 523, 408, 23614, 282, 3335, 687, 282, 570, 436, 2529, 652, 370, 314, 1654, 30427, 1041, 523, 315, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 523, 734, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 819, 347, 3378, 8, 277, 12, 1249, 304, 272, 408, 23614, 282, 3335, 641, 314, 1890, 436, 16178, 652, 370, 314, 1654, 1041, 272, 327, 4155, 3238, 781, 2304, 314, 1568, 402, 4154, 1072, 272, 340, 1249, 14, 1267, 690, 9141, 63, 10960, 63, 4305, 26, 489, 746, 6064, 480, 6049, 440, 1586, 19383, 642, 7031, 2685, 339, 666, 275, 31628, 14, 3284, 54, 7079, 8, 589, 14, 515, 1650, 12, 1249, 14, 2743, 12, 1249, 14, 1267, 12, 2432, 6696, 63, 3058, 29, 277, 14, 11504, 9, 272, 754, 275, 18148, 585, 14, 1451, 16799, 8, 267, 666, 29, 15371, 14, 6447, 8, 576, 395, 267, 10291, 29, 17120, 585, 14, 1451, 16799, 14, 25551, 804, 14, 58, 30193, 9, 339, 10017, 275, 8337, 14, 4835, 3912, 8, 576, 680, 5671, 342, 339, 327, 7523, 626, 314, 3335, 365, 31662, 6169, 642, 1177, 14, 2670, 2784, 272, 327, 3222, 2304, 14, 272, 291, 14, 31539, 5571, 1378, 4434, 8, 552, 8, 576, 430, 339, 327, 7356, 372, 314, 666, 370, 314, 1654, 1901, 314, 4539, 27507, 5502, 5521, 272, 327, 6040, 6369, 14, 272, 291, 14, 2587, 82, 63, 6599, 14, 6795, 14166, 8, 267, 754, 12, 2351, 63, 344, 29, 17120, 585, 14, 4434, 998, 8, 1659, 63, 354, 628, 11761, 5502, 2237, 339, 327, 7356, 3622, 314, 2631, 402, 642, 9182, 370, 4154, 6369, 465, 5521, 465, 314, 3268, 436, 272, 327, 2582, 14, 272, 291, 14, 6795, 14166, 8, 2743, 29, 589, 14, 2743, 12, 2582, 29, 552, 8, 576, 395, 673, 666, 29, 5671, 9, 421, 199, 533, 16101, 3299, 8, 3723, 14, 3310, 5061, 304, 523, 408, 3476, 282, 3335, 687, 282, 570, 436, 2529, 652, 370, 314, 1654, 30427, 1041, 523, 315, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 523, 734, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 819, 347, 3378, 8, 277, 12, 1249, 304, 272, 408, 23614, 282, 3335, 641, 314, 1890, 436, 16178, 652, 370, 314, 1654, 1041, 272, 327, 4155, 3238, 781, 2304, 314, 1568, 402, 4154, 1072, 272, 340, 1249, 14, 1267, 690, 9141, 63, 10960, 63, 4305, 26, 489, 746, 6064, 480, 6049, 440, 1586, 19383, 642, 7031, 2685, 339, 666, 275, 31628, 14, 3284, 54, 7079, 8, 589, 14, 515, 1650, 12, 1249, 14, 2743, 12, 1249, 14, 1267, 9, 339, 10017, 275, 8337, 14, 4835, 3912, 8, 576, 680, 5671, 342, 339, 327, 7356, 3622, 314, 2631, 402, 642, 9182, 370, 4154, 6369, 465, 5521, 465, 314, 3268, 436, 272, 327, 2582, 14, 272, 291, 14, 6795, 14166, 8, 2743, 29, 589, 14, 2743, 12, 2582, 29, 552, 8, 576, 395, 673, 666, 29, 5671, 9, 421, 199, 533, 11247, 21271, 1173, 8, 3723, 14, 3310, 5061, 304, 523, 408, 5116, 4072, 402, 282, 931, 1650, 370, 282, 570, 641, 4543, 1041, 523, 315, 63, 17120, 585, 275, 18148, 585, 14, 5116, 21271, 1173, 2017, 523, 734, 63, 17120, 585, 275, 18148, 585, 14, 5116, 21271, 1173, 2017, 819, 8068, 63, 4305, 275, 1616, 627, 6619, 627, 6619, 819, 347, 485, 5116, 8, 277, 12, 2053, 63, 2592, 304, 272, 408, 5116, 687, 812, 7079, 370, 570, 5133, 949, 1655, 666, 503, 291, 14, 1267, 365, 13075, 14, 339, 3033, 26, 489, 2053, 63, 2592, 26, 570, 909, 370, 2218, 370, 272, 1803, 26, 489, 291, 14, 8938, 26, 2783, 5313, 272, 408, 272, 1830, 291, 14, 8938, 665, 291, 14, 1267, 26, 489 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 624, 9232, 5445, 626, 5992, 641, 314, 1890, 1041, 421, 199, 646, 15073, 465, 5228, 199, 646, 5577, 199, 646, 11756, 199, 646, 8337, 199, 646, 747, 199, 646, 4298, 199, 646, 2838, 199, 646, 984, 199, 646, 900, 199, 646, 12472, 421, 199, 646, 22214, 199, 199, 646, 2050, 199, 199, 504, 31118, 14, 1258, 492, 5445, 199, 504, 31118, 14, 1258, 492, 1890, 63, 1208, 63, 2330, 199, 504, 31118, 14, 1258, 492, 31628, 199, 504, 31118, 14, 1258, 14, 1258, 63, 3723, 492, 2388, 1725, 199, 504, 31118, 14, 773, 492, 1101, 63, 773, 199, 504, 31118, 14, 773, 492, 3285, 199, 504, 31118, 14, 773, 492, 18148, 585, 199, 504, 31118, 14, 773, 492, 3778, 199, 504, 31118, 14, 773, 14, 17120, 1459, 492, 13230, 421, 199, 3, 2136, 886, 440, 3222, 12142, 19383, 2419, 642, 26, 199, 4283, 63, 10960, 63, 4305, 275, 5049, 16, 627, 6619, 421, 199, 533, 5574, 3299, 8, 3723, 14, 3310, 5061, 304, 523, 408, 23614, 282, 3335, 687, 282, 570, 436, 2529, 652, 370, 282, 1654, 3233, 1041, 523, 315, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 523, 734, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 819, 347, 3378, 8, 277, 12, 1249, 304, 272, 408, 23614, 282, 3335, 641, 314, 1890, 436, 16178, 652, 370, 314, 1654, 1041, 272, 327, 4155, 3238, 781, 2304, 314, 1568, 402, 4154, 1072, 272, 340, 1249, 14, 1267, 690, 9141, 63, 10960, 63, 4305, 26, 489, 746, 6064, 480, 6049, 440, 1586, 19383, 642, 7031, 2685, 339, 862, 26, 489, 6111, 275, 31628, 14, 32364, 4118, 897, 8, 589, 14, 515, 1650, 12, 6696, 63, 3058, 29, 277, 14, 11504, 9, 2541, 6111, 14, 19168, 8, 589, 14, 2743, 9, 489, 3268, 275, 6111, 14, 52, 1697, 342, 2541, 666, 275, 6111, 14, 3284, 8, 589, 14, 1267, 9, 339, 871, 334, 13760, 12, 6440, 395, 325, 26, 489, 291, 14, 1084, 3694, 8, 17120, 585, 14, 39, 9734, 3694, 14, 28239, 3694, 14, 2090, 3170, 12, 325, 9, 489, 372, 339, 327, 7356, 372, 314, 666, 370, 314, 1654, 272, 291, 14, 6795, 14166, 8, 2743, 29, 2743, 12, 666, 29, 576, 12, 673, 2582, 29, 552, 8, 576, 395, 931, 1650, 29, 2592, 14, 515, 1650, 9, 421, 199, 14395, 63, 8677, 275, 3778, 14, 16976, 5502, 8, 1960, 9, 421, 199, 533, 27507, 3299, 8, 3723, 14, 3310, 5061, 304, 523, 408, 23614, 282, 3335, 687, 282, 570, 436, 2529, 652, 370, 314, 1654, 30427, 1041, 523, 315, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 523, 734, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 819, 347, 3378, 8, 277, 12, 1249, 304, 272, 408, 23614, 282, 3335, 641, 314, 1890, 436, 16178, 652, 370, 314, 1654, 1041, 272, 327, 4155, 3238, 781, 2304, 314, 1568, 402, 4154, 1072, 272, 340, 1249, 14, 1267, 690, 9141, 63, 10960, 63, 4305, 26, 489, 746, 6064, 480, 6049, 440, 1586, 19383, 642, 7031, 2685, 339, 666, 275, 31628, 14, 3284, 54, 7079, 8, 589, 14, 515, 1650, 12, 1249, 14, 2743, 12, 1249, 14, 1267, 12, 2432, 6696, 63, 3058, 29, 277, 14, 11504, 9, 272, 754, 275, 18148, 585, 14, 1451, 16799, 8, 267, 666, 29, 15371, 14, 6447, 8, 576, 395, 267, 10291, 29, 17120, 585, 14, 1451, 16799, 14, 25551, 804, 14, 58, 30193, 9, 339, 10017, 275, 8337, 14, 4835, 3912, 8, 576, 680, 5671, 342, 339, 327, 7523, 626, 314, 3335, 365, 31662, 6169, 642, 1177, 14, 2670, 2784, 272, 327, 3222, 2304, 14, 272, 291, 14, 31539, 5571, 1378, 4434, 8, 552, 8, 576, 430, 339, 327, 7356, 372, 314, 666, 370, 314, 1654, 1901, 314, 4539, 27507, 5502, 5521, 272, 327, 6040, 6369, 14, 272, 291, 14, 2587, 82, 63, 6599, 14, 6795, 14166, 8, 267, 754, 12, 2351, 63, 344, 29, 17120, 585, 14, 4434, 998, 8, 1659, 63, 354, 628, 11761, 5502, 2237, 339, 327, 7356, 3622, 314, 2631, 402, 642, 9182, 370, 4154, 6369, 465, 5521, 465, 314, 3268, 436, 272, 327, 2582, 14, 272, 291, 14, 6795, 14166, 8, 2743, 29, 589, 14, 2743, 12, 2582, 29, 552, 8, 576, 395, 673, 666, 29, 5671, 9, 421, 199, 533, 16101, 3299, 8, 3723, 14, 3310, 5061, 304, 523, 408, 3476, 282, 3335, 687, 282, 570, 436, 2529, 652, 370, 314, 1654, 30427, 1041, 523, 315, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 523, 734, 63, 17120, 585, 275, 18148, 585, 14, 3299, 5083, 819, 347, 3378, 8, 277, 12, 1249, 304, 272, 408, 23614, 282, 3335, 641, 314, 1890, 436, 16178, 652, 370, 314, 1654, 1041, 272, 327, 4155, 3238, 781, 2304, 314, 1568, 402, 4154, 1072, 272, 340, 1249, 14, 1267, 690, 9141, 63, 10960, 63, 4305, 26, 489, 746, 6064, 480, 6049, 440, 1586, 19383, 642, 7031, 2685, 339, 666, 275, 31628, 14, 3284, 54, 7079, 8, 589, 14, 515, 1650, 12, 1249, 14, 2743, 12, 1249, 14, 1267, 9, 339, 10017, 275, 8337, 14, 4835, 3912, 8, 576, 680, 5671, 342, 339, 327, 7356, 3622, 314, 2631, 402, 642, 9182, 370, 4154, 6369, 465, 5521, 465, 314, 3268, 436, 272, 327, 2582, 14, 272, 291, 14, 6795, 14166, 8, 2743, 29, 589, 14, 2743, 12, 2582, 29, 552, 8, 576, 395, 673, 666, 29, 5671, 9, 421, 199, 533, 11247, 21271, 1173, 8, 3723, 14, 3310, 5061, 304, 523, 408, 5116, 4072, 402, 282, 931, 1650, 370, 282, 570, 641, 4543, 1041, 523, 315, 63, 17120, 585, 275, 18148, 585, 14, 5116, 21271, 1173, 2017, 523, 734, 63, 17120, 585, 275, 18148, 585, 14, 5116, 21271, 1173, 2017, 819, 8068, 63, 4305, 275, 1616, 627, 6619, 627, 6619, 819, 347, 485, 5116, 8, 277, 12, 2053, 63, 2592, 304, 272, 408, 5116, 687, 812, 7079, 370, 570, 5133, 949, 1655, 666, 503, 291, 14, 1267, 365, 13075, 14, 339, 3033, 26, 489, 2053, 63, 2592, 26, 570, 909, 370, 2218, 370, 272, 1803, 26, 489, 291, 14, 8938, 26, 2783, 5313, 272, 408, 272, 1830, 291, 14, 8938, 665, 291, 14, 1267, 26, 489, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
taiyuanfang/gyp
test/win/gyptest-cl-buffer-security-check.py
344
1612
#!/usr/bin/env python # Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ Make sure buffer security check setting is extracted properly. """ import TestGyp import sys if sys.platform == 'win32': test = TestGyp.TestGyp(formats=['msvs', 'ninja']) CHDIR = 'compiler-flags' test.run_gyp('buffer-security-check.gyp', chdir=CHDIR) test.build('buffer-security-check.gyp', chdir=CHDIR) def GetDisassemblyOfMain(exe): # The standard library uses buffer security checks independent of our # buffer security settings, so we extract just our code (i.e. main()) to # check against. full_path = test.built_file_path(exe, chdir=CHDIR) output = test.run_dumpbin('/disasm', full_path) result = [] in_main = False for line in output.splitlines(): if line == '_main:': in_main = True elif in_main: # Disassembly of next function starts. if line.startswith('_'): break result.append(line) return '\n'.join(result) # Buffer security checks are on by default, make sure security_cookie # appears in the disassembly of our code. if 'security_cookie' not in GetDisassemblyOfMain('test_bsc_unset.exe'): test.fail_test() # Explicitly on. if 'security_cookie' not in GetDisassemblyOfMain('test_bsc_on.exe'): test.fail_test() # Explicitly off, shouldn't be a reference to the security cookie. if 'security_cookie' in GetDisassemblyOfMain('test_bsc_off.exe'): test.fail_test() test.pass_test()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 5483, 3238, 3335, 6391, 1104, 4260, 365, 12509, 7684, 14, 199, 624, 199, 199, 646, 25688, 199, 199, 646, 984, 199, 199, 692, 984, 14, 3246, 508, 283, 2676, 708, 356, 523, 511, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 8338, 297, 283, 8675, 1105, 819, 6624, 3022, 275, 283, 5772, 13, 2469, 7, 523, 511, 14, 1065, 63, 6179, 360, 2738, 13, 4416, 13, 1074, 14, 6179, 297, 13097, 29, 30285, 9, 523, 511, 14, 1506, 360, 2738, 13, 4416, 13, 1074, 14, 6179, 297, 13097, 29, 30285, 9, 819, 347, 2372, 2825, 17828, 3466, 6756, 8, 5803, 304, 272, 327, 710, 4465, 3555, 4440, 3335, 6391, 5920, 12717, 402, 4154, 272, 327, 3335, 6391, 2202, 12, 880, 781, 5536, 2951, 4154, 1233, 334, 73, 14, 69, 14, 2446, 1012, 370, 272, 327, 1104, 6169, 14, 272, 2615, 63, 515, 275, 511, 14, 11730, 63, 493, 63, 515, 8, 5803, 12, 13097, 29, 30285, 9, 272, 1072, 275, 511, 14, 1065, 63, 2724, 1393, 2336, 2297, 11374, 297, 2615, 63, 515, 9, 272, 754, 275, 942, 272, 315, 63, 973, 275, 756, 272, 367, 1004, 315, 1072, 14, 7644, 837, 489, 340, 1004, 508, 2513, 973, 25156, 267, 315, 63, 973, 275, 715, 489, 916, 315, 63, 973, 26, 267, 327, 5289, 17828, 402, 2163, 805, 9174, 14, 267, 340, 1004, 14, 2460, 30018, 881, 2059, 267, 754, 14, 740, 8, 604, 9, 272, 372, 1557, 78, 1370, 904, 8, 1099, 9, 819, 327, 26661, 6391, 5920, 787, 641, 701, 849, 12, 1852, 3238, 6391, 63, 5306, 523, 327, 11337, 315, 314, 2153, 17828, 402, 4154, 1233, 14, 523, 340, 283, 4416, 63, 5306, 7, 440, 315, 2372, 2825, 17828, 3466, 6756, 360, 396, 63, 66, 551, 63, 16787, 14, 5803, 735, 272, 511, 14, 1633, 63, 396, 342, 819, 327, 23872, 590, 641, 14, 523, 340, 283, 4416, 63, 5306, 7, 440, 315, 2372, 2825, 17828, 3466, 6756, 360, 396, 63, 66, 551, 63, 265, 14, 5803, 735, 272, 511, 14, 1633, 63, 396, 342, 819, 327, 23872, 590, 2331, 12, 9296, 1133, 506, 282, 3659, 370, 314, 6391, 5494, 14, 523, 340, 283, 4416, 63, 5306, 7, 315, 2372, 2825, 17828, 3466, 6756, 360, 396, 63, 66, 551, 63, 1997, 14, 5803, 735, 272, 511, 14, 1633, 63, 396, 342, 819, 511, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 5483, 3238, 3335, 6391, 1104, 4260, 365, 12509, 7684, 14, 199, 624, 199, 199, 646, 25688, 199, 199, 646, 984, 199, 199, 692, 984, 14, 3246, 508, 283, 2676, 708, 356, 523, 511, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 8338, 297, 283, 8675, 1105, 819, 6624, 3022, 275, 283, 5772, 13, 2469, 7, 523, 511, 14, 1065, 63, 6179, 360, 2738, 13, 4416, 13, 1074, 14, 6179, 297, 13097, 29, 30285, 9, 523, 511, 14, 1506, 360, 2738, 13, 4416, 13, 1074, 14, 6179, 297, 13097, 29, 30285, 9, 819, 347, 2372, 2825, 17828, 3466, 6756, 8, 5803, 304, 272, 327, 710, 4465, 3555, 4440, 3335, 6391, 5920, 12717, 402, 4154, 272, 327, 3335, 6391, 2202, 12, 880, 781, 5536, 2951, 4154, 1233, 334, 73, 14, 69, 14, 2446, 1012, 370, 272, 327, 1104, 6169, 14, 272, 2615, 63, 515, 275, 511, 14, 11730, 63, 493, 63, 515, 8, 5803, 12, 13097, 29, 30285, 9, 272, 1072, 275, 511, 14, 1065, 63, 2724, 1393, 2336, 2297, 11374, 297, 2615, 63, 515, 9, 272, 754, 275, 942, 272, 315, 63, 973, 275, 756, 272, 367, 1004, 315, 1072, 14, 7644, 837, 489, 340, 1004, 508, 2513, 973, 25156, 267, 315, 63, 973, 275, 715, 489, 916, 315, 63, 973, 26, 267, 327, 5289, 17828, 402, 2163, 805, 9174, 14, 267, 340, 1004, 14, 2460, 30018, 881, 2059, 267, 754, 14, 740, 8, 604, 9, 272, 372, 1557, 78, 1370, 904, 8, 1099, 9, 819, 327, 26661, 6391, 5920, 787, 641, 701, 849, 12, 1852, 3238, 6391, 63, 5306, 523, 327, 11337, 315, 314, 2153, 17828, 402, 4154, 1233, 14, 523, 340, 283, 4416, 63, 5306, 7, 440, 315, 2372, 2825, 17828, 3466, 6756, 360, 396, 63, 66, 551, 63, 16787, 14, 5803, 735, 272, 511, 14, 1633, 63, 396, 342, 819, 327, 23872, 590, 641, 14, 523, 340, 283, 4416, 63, 5306, 7, 440, 315, 2372, 2825, 17828, 3466, 6756, 360, 396, 63, 66, 551, 63, 265, 14, 5803, 735, 272, 511, 14, 1633, 63, 396, 342, 819, 327, 23872, 590, 2331, 12, 9296, 1133, 506, 282, 3659, 370, 314, 6391, 5494, 14, 523, 340, 283, 4416, 63, 5306, 7, 315, 2372, 2825, 17828, 3466, 6756, 360, 396, 63, 66, 551, 63, 1997, 14, 5803, 735, 272, 511, 14, 1633, 63, 396, 342, 819, 511, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
40223135/40223135-
static/Brython3.1.1-20150328-091302/Lib/multiprocessing/__init__.py
693
6866
# # Package analogous to 'threading.py' but using processes # # multiprocessing/__init__.py # # This package is intended to duplicate the functionality (and much of # the API) of threading.py but uses processes instead of threads. A # subpackage 'multiprocessing.dummy' has the same API but is a simple # wrapper for 'threading'. # # Try calling `multiprocessing.doc.main()` to read the html # documentation in a webbrowser. # # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # __version__ = '0.70a1' __all__ = [ 'Process', 'current_process', 'active_children', 'freeze_support', 'Manager', 'Pipe', 'cpu_count', 'log_to_stderr', 'get_logger', 'allow_connection_pickling', 'BufferTooShort', 'TimeoutError', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Condition', 'Event', 'Barrier', 'Queue', 'SimpleQueue', 'JoinableQueue', 'Pool', 'Value', 'Array', 'RawValue', 'RawArray', 'SUBDEBUG', 'SUBWARNING', ] __author__ = 'R. Oudkerk (r.m.oudkerk@gmail.com)' # # Imports # import os import sys from multiprocessing.process import Process, current_process, active_children from multiprocessing.util import SUBDEBUG, SUBWARNING # # Exceptions # class ProcessError(Exception): pass class BufferTooShort(ProcessError): pass class TimeoutError(ProcessError): pass class AuthenticationError(ProcessError): pass import _multiprocessing # # Definitions not depending on native semaphores # def Manager(): ''' Returns a manager associated with a running server process The managers methods such as `Lock()`, `Condition()` and `Queue()` can be used to create shared objects. ''' from multiprocessing.managers import SyncManager m = SyncManager() m.start() return m #brython fix me #def Pipe(duplex=True): # ''' # Returns two connection object connected by a pipe # ''' # from multiprocessing.connection import Pipe # return Pipe(duplex) def cpu_count(): ''' Returns the number of CPUs in the system ''' if sys.platform == 'win32': try: num = int(os.environ['NUMBER_OF_PROCESSORS']) except (ValueError, KeyError): num = 0 elif 'bsd' in sys.platform or sys.platform == 'darwin': comm = '/sbin/sysctl -n hw.ncpu' if sys.platform == 'darwin': comm = '/usr' + comm try: with os.popen(comm) as p: num = int(p.read()) except ValueError: num = 0 else: try: num = os.sysconf('SC_NPROCESSORS_ONLN') except (ValueError, OSError, AttributeError): num = 0 if num >= 1: return num else: raise NotImplementedError('cannot determine number of cpus') def freeze_support(): ''' Check whether this is a fake forked process in a frozen executable. If so then run code specified by commandline and exit. ''' if sys.platform == 'win32' and getattr(sys, 'frozen', False): from multiprocessing.forking import freeze_support freeze_support() def get_logger(): ''' Return package logger -- if it does not already exist then it is created ''' from multiprocessing.util import get_logger return get_logger() def log_to_stderr(level=None): ''' Turn on logging and add a handler which prints to stderr ''' from multiprocessing.util import log_to_stderr return log_to_stderr(level) #brython fix me #def allow_connection_pickling(): # ''' # Install support for sending connections and sockets between processes # ''' # # This is undocumented. In previous versions of multiprocessing # # its only effect was to make socket objects inheritable on Windows. # import multiprocessing.connection # # Definitions depending on native semaphores # def Lock(): ''' Returns a non-recursive lock object ''' from multiprocessing.synchronize import Lock return Lock() def RLock(): ''' Returns a recursive lock object ''' from multiprocessing.synchronize import RLock return RLock() def Condition(lock=None): ''' Returns a condition object ''' from multiprocessing.synchronize import Condition return Condition(lock) def Semaphore(value=1): ''' Returns a semaphore object ''' from multiprocessing.synchronize import Semaphore return Semaphore(value) def BoundedSemaphore(value=1): ''' Returns a bounded semaphore object ''' from multiprocessing.synchronize import BoundedSemaphore return BoundedSemaphore(value) def Event(): ''' Returns an event object ''' from multiprocessing.synchronize import Event return Event() def Barrier(parties, action=None, timeout=None): ''' Returns a barrier object ''' from multiprocessing.synchronize import Barrier return Barrier(parties, action, timeout) def Queue(maxsize=0): ''' Returns a queue object ''' from multiprocessing.queues import Queue return Queue(maxsize) def JoinableQueue(maxsize=0): ''' Returns a queue object ''' from multiprocessing.queues import JoinableQueue return JoinableQueue(maxsize) def SimpleQueue(): ''' Returns a queue object ''' from multiprocessing.queues import SimpleQueue return SimpleQueue() def Pool(processes=None, initializer=None, initargs=(), maxtasksperchild=None): ''' Returns a process pool object ''' from multiprocessing.pool import Pool return Pool(processes, initializer, initargs, maxtasksperchild) def RawValue(typecode_or_type, *args): ''' Returns a shared object ''' from multiprocessing.sharedctypes import RawValue return RawValue(typecode_or_type, *args) def RawArray(typecode_or_type, size_or_initializer): ''' Returns a shared array ''' from multiprocessing.sharedctypes import RawArray return RawArray(typecode_or_type, size_or_initializer) def Value(typecode_or_type, *args, lock=True): ''' Returns a synchronized shared object ''' from multiprocessing.sharedctypes import Value return Value(typecode_or_type, *args, lock=lock) def Array(typecode_or_type, size_or_initializer, *, lock=True): ''' Returns a synchronized shared array ''' from multiprocessing.sharedctypes import Array return Array(typecode_or_type, size_or_initializer, lock=lock) # # # if sys.platform == 'win32': def set_executable(executable): ''' Sets the path to a python.exe or pythonw.exe binary used to run child processes on Windows instead of sys.executable. Useful for people embedding Python. ''' from multiprocessing.forking import set_executable set_executable(executable) __all__ += ['set_executable']
gpl-3.0
[ 3, 199, 3, 15665, 20439, 1785, 370, 283, 12562, 14, 647, 7, 1325, 1808, 10358, 199, 3, 199, 3, 12866, 22128, 826, 4343, 647, 199, 3, 199, 3, 961, 2559, 365, 11619, 370, 9250, 314, 9330, 334, 460, 8298, 402, 199, 3, 314, 3261, 9, 402, 5796, 14, 647, 1325, 4440, 10358, 3140, 402, 7183, 14, 221, 437, 199, 3, 1007, 2491, 283, 25725, 14, 5869, 7, 965, 314, 2011, 3261, 1325, 365, 282, 3486, 199, 3, 4975, 367, 283, 12562, 1370, 199, 3, 199, 3, 7649, 6358, 658, 25725, 14, 1301, 14, 973, 11995, 370, 1586, 314, 3517, 199, 3, 3794, 315, 282, 781, 29063, 14, 199, 3, 199, 3, 199, 3, 1898, 334, 67, 9, 8315, 13, 9300, 12, 820, 593, 1181, 2570, 75, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 3, 199, 199, 363, 1023, 363, 275, 283, 16, 14, 2760, 65, 17, 7, 199, 199, 363, 452, 363, 275, 359, 272, 283, 3498, 297, 283, 1818, 63, 1412, 297, 283, 2682, 63, 3223, 297, 283, 18459, 63, 4058, 297, 272, 283, 2988, 297, 283, 11867, 297, 283, 3541, 63, 835, 297, 283, 793, 63, 475, 63, 3083, 297, 283, 362, 63, 2921, 297, 272, 283, 3306, 63, 2105, 63, 24773, 297, 283, 3299, 13749, 10039, 297, 283, 19382, 297, 272, 283, 6432, 297, 283, 30550, 297, 283, 26574, 297, 283, 8781, 26574, 297, 283, 9558, 297, 272, 283, 2390, 297, 283, 5281, 10742, 297, 283, 3737, 297, 283, 3184, 3737, 297, 283, 13005, 461, 3737, 297, 283, 5453, 297, 272, 283, 1110, 297, 283, 3836, 297, 283, 7963, 1110, 297, 283, 7963, 3836, 297, 283, 6348, 5287, 297, 283, 6348, 9171, 297, 272, 1622, 199, 199, 363, 2502, 363, 275, 283, 50, 14, 593, 1181, 2570, 75, 334, 82, 14, 77, 14, 810, 68, 2570, 75, 32, 6799, 14, 957, 3171, 199, 199, 3, 199, 3, 24339, 199, 3, 199, 199, 646, 747, 199, 646, 984, 199, 199, 504, 12866, 14, 1412, 492, 7132, 12, 1453, 63, 1412, 12, 4702, 63, 3223, 199, 504, 12866, 14, 1974, 492, 7605, 5287, 12, 7605, 9171, 199, 199, 3, 199, 3, 24873, 199, 3, 199, 199, 533, 7132, 547, 8, 1726, 304, 272, 986, 199, 199, 533, 26661, 13749, 10039, 8, 19148, 304, 272, 986, 199, 199, 533, 31886, 8, 19148, 304, 272, 986, 199, 199, 533, 15995, 547, 8, 19148, 304, 272, 986, 199, 199, 646, 485, 25725, 199, 199, 3, 199, 3, 22659, 852, 440, 10298, 641, 5438, 542, 16502, 470, 199, 3, 199, 199, 318, 13537, 837, 272, 1449, 272, 1803, 282, 5256, 4568, 543, 282, 3879, 1654, 2112, 339, 710, 19680, 3102, 4066, 465, 658, 6432, 342, 3559, 658, 9558, 11995, 436, 658, 3737, 11995, 272, 883, 506, 1202, 370, 1218, 5709, 2251, 14, 272, 1449, 272, 687, 12866, 14, 16259, 492, 22407, 2988, 272, 333, 275, 22407, 2988, 342, 272, 333, 14, 928, 342, 272, 372, 333, 199, 199, 3, 66, 23196, 5325, 562, 199, 3, 318, 16850, 8, 68, 26646, 29, 549, 304, 199, 3, 259, 1449, 199, 3, 259, 1803, 2877, 1950, 909, 8539, 701, 282, 5200, 199, 3, 259, 1449, 199, 3, 259, 687, 12866, 14, 2105, 492, 16850, 199, 3, 259, 372, 16850, 8, 68, 26646, 9, 199, 199, 318, 5033, 63, 835, 837, 272, 1449, 272, 1803, 314, 1329, 402, 28504, 315, 314, 2656, 272, 1449, 272, 340, 984, 14, 3246, 508, 283, 2676, 708, 356, 267, 862, 26, 288, 1967, 275, 1109, 8, 736, 14, 2314, 459, 9190, 63, 3359, 63, 10494, 4149, 1105, 267, 871, 334, 3393, 12, 4067, 304, 288, 1967, 275, 378, 272, 916, 283, 15746, 7, 315, 984, 14, 3246, 503, 984, 14, 3246, 508, 283, 13245, 356, 267, 1923, 275, 1994, 21457, 15, 1274, 8077, 446, 78, 12073, 14, 78, 3541, 7, 267, 340, 984, 14, 3246, 508, 283, 13245, 356, 288, 1923, 275, 1994, 2647, 7, 435, 1923, 267, 862, 26, 288, 543, 747, 14, 12207, 8, 1404, 9, 465, 299, 26, 355, 1967, 275, 1109, 8, 80, 14, 739, 1012, 267, 871, 1722, 26, 288, 1967, 275, 378, 272, 587, 26, 267, 862, 26, 288, 1967, 275, 747, 14, 1274, 2190, 360, 5153, 63, 46, 10494, 4149, 63, 615, 44, 46, 358, 267, 871, 334, 3393, 12, 6440, 12, 4281, 304, 288, 1967, 275, 378, 339, 340, 1967, 2356, 413, 26, 267, 372, 1967, 272, 587, 26, 267, 746, 4279, 360, 11250, 6705, 1329, 402, 24174, 358, 199, 199, 318, 22778, 63, 4058, 837, 272, 1449, 272, 2670, 3775, 642, 365, 282, 4026, 14926, 379, 2112, 315, 282, 8101, 7286, 14, 272, 982, 880, 2066, 1255, 1233, 2013, 701, 28279, 436, 4458, 14, 272, 1449, 272, 340, 984, 14, 3246, 508, 283, 2676, 708, 7, 436, 2519, 8, 1274, 12, 283, 11202, 297, 756, 304, 267, 687, 12866, 14, 11796, 316, 492, 22778, 63, 4058, 267, 22778, 63, 4058, 342, 199, 199, 318, 664, 63, 2921, 837, 272, 1449, 272, 1432, 2559, 2512, 1553, 340, 652, 1630, 440, 2575, 2187, 2066, 652, 365, 2737, 272, 1449, 272, 687, 12866, 14, 1974, 492, 664, 63, 2921, 272, 372, 664, 63, 2921, 342, 199, 199, 318, 943, 63, 475, 63, 3083, 8, 1896, 29, 403, 304, 272, 1449, 272, 16147, 641, 2050, 436, 1050, 282, 3016, 1314, 14767, 370, 4635, 272, 1449, 272, 687, 12866, 14, 1974, 492, 943, 63, 475, 63, 3083, 272, 372, 943, 63, 475, 63, 3083, 8, 1896, 9, 199, 199, 3, 66, 23196, 5325, 562, 199, 3, 318, 2040, 63, 2105, 63, 24773, 837, 199, 3, 259, 1449, 199, 3, 259, 13276, 2291, 367, 10209, 6947, 436, 18772, 3382, 10358, 199, 3, 259, 1449, 199, 3, 259, 327, 961, 365, 625, 29383, 14, 221, 1010, 4136, 5459, 402, 12866, 199, 3, 259, 327, 2399, 1454, 7763, 1990, 370, 1852, 2838, 2251, 8287, 461, 641, 5417, 14, 199, 3, 259, 492, 12866, 14, 2105, 199, 199, 3, 199, 3, 22659, 852, 10298, 641, 5438, 542, 16502, 470, 199, 3, 199, 199, 318, 15536, 837, 272, 1449, 272, 1803, 282, 2222, 13, 9931, 4650, 909, 272, 1449, 272, 687, 12866, 14, 26252, 492, 15536, 272, 372, 15536, 342, 199, 199 ]
[ 199, 3, 15665, 20439, 1785, 370, 283, 12562, 14, 647, 7, 1325, 1808, 10358, 199, 3, 199, 3, 12866, 22128, 826, 4343, 647, 199, 3, 199, 3, 961, 2559, 365, 11619, 370, 9250, 314, 9330, 334, 460, 8298, 402, 199, 3, 314, 3261, 9, 402, 5796, 14, 647, 1325, 4440, 10358, 3140, 402, 7183, 14, 221, 437, 199, 3, 1007, 2491, 283, 25725, 14, 5869, 7, 965, 314, 2011, 3261, 1325, 365, 282, 3486, 199, 3, 4975, 367, 283, 12562, 1370, 199, 3, 199, 3, 7649, 6358, 658, 25725, 14, 1301, 14, 973, 11995, 370, 1586, 314, 3517, 199, 3, 3794, 315, 282, 781, 29063, 14, 199, 3, 199, 3, 199, 3, 1898, 334, 67, 9, 8315, 13, 9300, 12, 820, 593, 1181, 2570, 75, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 3, 199, 199, 363, 1023, 363, 275, 283, 16, 14, 2760, 65, 17, 7, 199, 199, 363, 452, 363, 275, 359, 272, 283, 3498, 297, 283, 1818, 63, 1412, 297, 283, 2682, 63, 3223, 297, 283, 18459, 63, 4058, 297, 272, 283, 2988, 297, 283, 11867, 297, 283, 3541, 63, 835, 297, 283, 793, 63, 475, 63, 3083, 297, 283, 362, 63, 2921, 297, 272, 283, 3306, 63, 2105, 63, 24773, 297, 283, 3299, 13749, 10039, 297, 283, 19382, 297, 272, 283, 6432, 297, 283, 30550, 297, 283, 26574, 297, 283, 8781, 26574, 297, 283, 9558, 297, 272, 283, 2390, 297, 283, 5281, 10742, 297, 283, 3737, 297, 283, 3184, 3737, 297, 283, 13005, 461, 3737, 297, 283, 5453, 297, 272, 283, 1110, 297, 283, 3836, 297, 283, 7963, 1110, 297, 283, 7963, 3836, 297, 283, 6348, 5287, 297, 283, 6348, 9171, 297, 272, 1622, 199, 199, 363, 2502, 363, 275, 283, 50, 14, 593, 1181, 2570, 75, 334, 82, 14, 77, 14, 810, 68, 2570, 75, 32, 6799, 14, 957, 3171, 199, 199, 3, 199, 3, 24339, 199, 3, 199, 199, 646, 747, 199, 646, 984, 199, 199, 504, 12866, 14, 1412, 492, 7132, 12, 1453, 63, 1412, 12, 4702, 63, 3223, 199, 504, 12866, 14, 1974, 492, 7605, 5287, 12, 7605, 9171, 199, 199, 3, 199, 3, 24873, 199, 3, 199, 199, 533, 7132, 547, 8, 1726, 304, 272, 986, 199, 199, 533, 26661, 13749, 10039, 8, 19148, 304, 272, 986, 199, 199, 533, 31886, 8, 19148, 304, 272, 986, 199, 199, 533, 15995, 547, 8, 19148, 304, 272, 986, 199, 199, 646, 485, 25725, 199, 199, 3, 199, 3, 22659, 852, 440, 10298, 641, 5438, 542, 16502, 470, 199, 3, 199, 199, 318, 13537, 837, 272, 1449, 272, 1803, 282, 5256, 4568, 543, 282, 3879, 1654, 2112, 339, 710, 19680, 3102, 4066, 465, 658, 6432, 342, 3559, 658, 9558, 11995, 436, 658, 3737, 11995, 272, 883, 506, 1202, 370, 1218, 5709, 2251, 14, 272, 1449, 272, 687, 12866, 14, 16259, 492, 22407, 2988, 272, 333, 275, 22407, 2988, 342, 272, 333, 14, 928, 342, 272, 372, 333, 199, 199, 3, 66, 23196, 5325, 562, 199, 3, 318, 16850, 8, 68, 26646, 29, 549, 304, 199, 3, 259, 1449, 199, 3, 259, 1803, 2877, 1950, 909, 8539, 701, 282, 5200, 199, 3, 259, 1449, 199, 3, 259, 687, 12866, 14, 2105, 492, 16850, 199, 3, 259, 372, 16850, 8, 68, 26646, 9, 199, 199, 318, 5033, 63, 835, 837, 272, 1449, 272, 1803, 314, 1329, 402, 28504, 315, 314, 2656, 272, 1449, 272, 340, 984, 14, 3246, 508, 283, 2676, 708, 356, 267, 862, 26, 288, 1967, 275, 1109, 8, 736, 14, 2314, 459, 9190, 63, 3359, 63, 10494, 4149, 1105, 267, 871, 334, 3393, 12, 4067, 304, 288, 1967, 275, 378, 272, 916, 283, 15746, 7, 315, 984, 14, 3246, 503, 984, 14, 3246, 508, 283, 13245, 356, 267, 1923, 275, 1994, 21457, 15, 1274, 8077, 446, 78, 12073, 14, 78, 3541, 7, 267, 340, 984, 14, 3246, 508, 283, 13245, 356, 288, 1923, 275, 1994, 2647, 7, 435, 1923, 267, 862, 26, 288, 543, 747, 14, 12207, 8, 1404, 9, 465, 299, 26, 355, 1967, 275, 1109, 8, 80, 14, 739, 1012, 267, 871, 1722, 26, 288, 1967, 275, 378, 272, 587, 26, 267, 862, 26, 288, 1967, 275, 747, 14, 1274, 2190, 360, 5153, 63, 46, 10494, 4149, 63, 615, 44, 46, 358, 267, 871, 334, 3393, 12, 6440, 12, 4281, 304, 288, 1967, 275, 378, 339, 340, 1967, 2356, 413, 26, 267, 372, 1967, 272, 587, 26, 267, 746, 4279, 360, 11250, 6705, 1329, 402, 24174, 358, 199, 199, 318, 22778, 63, 4058, 837, 272, 1449, 272, 2670, 3775, 642, 365, 282, 4026, 14926, 379, 2112, 315, 282, 8101, 7286, 14, 272, 982, 880, 2066, 1255, 1233, 2013, 701, 28279, 436, 4458, 14, 272, 1449, 272, 340, 984, 14, 3246, 508, 283, 2676, 708, 7, 436, 2519, 8, 1274, 12, 283, 11202, 297, 756, 304, 267, 687, 12866, 14, 11796, 316, 492, 22778, 63, 4058, 267, 22778, 63, 4058, 342, 199, 199, 318, 664, 63, 2921, 837, 272, 1449, 272, 1432, 2559, 2512, 1553, 340, 652, 1630, 440, 2575, 2187, 2066, 652, 365, 2737, 272, 1449, 272, 687, 12866, 14, 1974, 492, 664, 63, 2921, 272, 372, 664, 63, 2921, 342, 199, 199, 318, 943, 63, 475, 63, 3083, 8, 1896, 29, 403, 304, 272, 1449, 272, 16147, 641, 2050, 436, 1050, 282, 3016, 1314, 14767, 370, 4635, 272, 1449, 272, 687, 12866, 14, 1974, 492, 943, 63, 475, 63, 3083, 272, 372, 943, 63, 475, 63, 3083, 8, 1896, 9, 199, 199, 3, 66, 23196, 5325, 562, 199, 3, 318, 2040, 63, 2105, 63, 24773, 837, 199, 3, 259, 1449, 199, 3, 259, 13276, 2291, 367, 10209, 6947, 436, 18772, 3382, 10358, 199, 3, 259, 1449, 199, 3, 259, 327, 961, 365, 625, 29383, 14, 221, 1010, 4136, 5459, 402, 12866, 199, 3, 259, 327, 2399, 1454, 7763, 1990, 370, 1852, 2838, 2251, 8287, 461, 641, 5417, 14, 199, 3, 259, 492, 12866, 14, 2105, 199, 199, 3, 199, 3, 22659, 852, 10298, 641, 5438, 542, 16502, 470, 199, 3, 199, 199, 318, 15536, 837, 272, 1449, 272, 1803, 282, 2222, 13, 9931, 4650, 909, 272, 1449, 272, 687, 12866, 14, 26252, 492, 15536, 272, 372, 15536, 342, 199, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
valentin-krasontovitsch/ansible
lib/ansible/modules/network/enos/enos_config.py
42
11179
#!/usr/bin/python # -*- coding: utf-8 -*- # # (C) 2017 Red Hat Inc. # Copyright (C) 2017 Lenovo. # # GNU General Public License v3.0+ # # 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. # # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # # Module to configure Lenovo Switches. # Lenovo Networking # from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = """ --- module: enos_config version_added: "2.5" author: "Anil Kumar Muraleedharan (@amuraleedhar)" short_description: Manage Lenovo ENOS configuration sections description: - Lenovo ENOS configurations use a simple block indent file syntax for segmenting configuration into sections. This module provides an implementation for working with ENOS configuration sections in a deterministic way. extends_documentation_fragment: enos notes: - Tested against ENOS 8.4.1 options: lines: description: - The ordered set of commands that should be configured in the section. The commands must be the exact same commands as found in the device running-config. Be sure to note the configuration command syntax as some commands are automatically modified by the device config parser. aliases: ['commands'] parents: description: - The ordered set of parents that uniquely identify the section the commands should be checked against. If the parents argument is omitted, the commands are checked against the set of top level or global commands. src: description: - Specifies the source path to the file that contains the configuration or configuration template to load. The path to the source file can either be the full path on the Ansible control host or a relative path from the playbook or role root directory. This argument is mutually exclusive with I(lines), I(parents). before: description: - The ordered set of commands to push on to the command stack if a change needs to be made. This allows the playbook designer the opportunity to perform configuration commands prior to pushing any changes without affecting how the set of commands are matched against the system. after: description: - The ordered set of commands to append to the end of the command stack if a change needs to be made. Just like with I(before) this allows the playbook designer to append a set of commands to be executed after the command set. match: description: - Instructs the module on the way to perform the matching of the set of commands against the current device config. If match is set to I(line), commands are matched line by line. If match is set to I(strict), command lines are matched with respect to position. If match is set to I(exact), command lines must be an equal match. Finally, if match is set to I(none), the module will not attempt to compare the source configuration with the running configuration on the remote device. default: line choices: ['line', 'strict', 'exact', 'none'] replace: description: - Instructs the module on the way to perform the configuration on the device. If the replace argument is set to I(line) then the modified lines are pushed to the device in configuration mode. If the replace argument is set to I(block) then the entire command block is pushed to the device in configuration mode if any line is not correct. default: line choices: ['line', 'block', 'config'] config: description: - The module, by default, will connect to the remote device and retrieve the current running-config to use as a base for comparing against the contents of source. There are times when it is not desirable to have the task get the current running-config for every task in a playbook. The I(config) argument allows the implementer to pass in the configuration to use as the base config for comparison. backup: description: - This argument will cause the module to create a full backup of the current C(running-config) from the remote device before any changes are made. If the C(backup_options) value is not given, the backup file is written to the C(backup) folder in the playbook root directory. If the directory does not exist, it is created. type: bool default: 'no' comment: description: - Allows a commit description to be specified to be included when the configuration is committed. If the configuration is not changed or committed, this argument is ignored. default: 'configured by enos_config' admin: description: - Enters into administration configuration mode for making config changes to the device. type: bool default: 'no' backup_options: description: - This is a dict object containing configurable options related to backup file path. The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set to I(no) this option will be silently ignored. suboptions: filename: description: - The filename to be used to store the backup configuration. If the the filename is not given it will be generated based on the hostname, current time and date in format defined by <hostname>_config.<current-date>@<current-time> dir_path: description: - This option provides the path ending with directory name in which the backup configuration file will be stored. If the directory does not exist it will be first created and the filename is either the value of C(filename) or default filename as described in C(filename) options description. If the path value is not given in that case a I(backup) directory will be created in the current working directory and backup configuration will be copied in C(filename) within I(backup) directory. type: path type: dict version_added: "2.8" """ EXAMPLES = """ - name: configure top level configuration enos_config: "lines: hostname {{ inventory_hostname }}" - name: configure interface settings enos_config: lines: - enable - ip ospf enable parents: interface ip 13 - name: load a config from disk and replace the current config enos_config: src: config.cfg backup: yes - name: configurable backup path enos_config: src: config.cfg backup: yes backup_options: filename: backup.cfg dir_path: /home/user """ RETURN = """ updates: description: The set of commands that will be pushed to the remote device returned: Only when lines is specified. type: list sample: ['...', '...'] backup_path: description: The full path to the backup file returned: when backup is yes type: str sample: /playbooks/ansible/backup/enos01.2016-07-16@22:28:34 """ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.enos.enos import load_config, get_config from ansible.module_utils.network.enos.enos import enos_argument_spec from ansible.module_utils.network.enos.enos import check_args from ansible.module_utils.network.common.config import NetworkConfig, dumps DEFAULT_COMMIT_COMMENT = 'configured by enos_config' def get_running_config(module): contents = module.params['config'] if not contents: contents = get_config(module) return NetworkConfig(indent=1, contents=contents) def get_candidate(module): candidate = NetworkConfig(indent=1) if module.params['src']: candidate.load(module.params['src']) elif module.params['lines']: parents = module.params['parents'] or list() candidate.add(module.params['lines'], parents=parents) return candidate def run(module, result): match = module.params['match'] replace = module.params['replace'] replace_config = replace == 'config' path = module.params['parents'] comment = module.params['comment'] admin = module.params['admin'] check_mode = module.check_mode candidate = get_candidate(module) if match != 'none' and replace != 'config': contents = get_running_config(module) configobj = NetworkConfig(contents=contents, indent=1) commands = candidate.difference(configobj, path=path, match=match, replace=replace) else: commands = candidate.items if commands: commands = dumps(commands, 'commands').split('\n') if any((module.params['lines'], module.params['src'])): if module.params['before']: commands[:0] = module.params['before'] if module.params['after']: commands.extend(module.params['after']) result['commands'] = commands diff = load_config(module, commands) if diff: result['diff'] = dict(prepared=diff) result['changed'] = True def main(): """main entry point for module execution """ backup_spec = dict( filename=dict(), dir_path=dict(type='path') ) argument_spec = dict( src=dict(type='path'), lines=dict(aliases=['commands'], type='list'), parents=dict(type='list'), before=dict(type='list'), after=dict(type='list'), match=dict(default='line', choices=['line', 'strict', 'exact', 'none']), replace=dict(default='line', choices=['line', 'block', 'config']), config=dict(), backup=dict(type='bool', default=False), backup_options=dict(type='dict', options=backup_spec), comment=dict(default=DEFAULT_COMMIT_COMMENT), admin=dict(type='bool', default=False) ) argument_spec.update(enos_argument_spec) mutually_exclusive = [('lines', 'src'), ('parents', 'src')] required_if = [('match', 'strict', ['lines']), ('match', 'exact', ['lines']), ('replace', 'block', ['lines']), ('replace', 'config', ['src'])] module = AnsibleModule(argument_spec=argument_spec, mutually_exclusive=mutually_exclusive, required_if=required_if, supports_check_mode=True) warnings = list() check_args(module, warnings) result = dict(changed=False, warnings=warnings) if module.params['backup']: result['__backup__'] = get_config(module) run(module, result) module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 334, 35, 9, 9708, 9572, 13002, 3277, 14, 199, 3, 1898, 334, 35, 9, 9708, 15757, 31445, 14, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 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, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 3, 199, 3, 5673, 370, 7908, 15757, 31445, 17711, 397, 14, 199, 3, 15757, 31445, 7220, 316, 199, 3, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 655, 736, 63, 888, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 2502, 26, 298, 2493, 382, 1804, 453, 285, 603, 300, 1895, 379, 8210, 290, 8593, 455, 300, 1895, 379, 8210, 2924, 199, 3612, 63, 1802, 26, 14944, 15757, 31445, 662, 23141, 2897, 10189, 199, 1802, 26, 523, 446, 15757, 31445, 662, 23141, 13422, 675, 282, 3486, 1853, 4363, 570, 6302, 272, 367, 8135, 316, 2897, 1901, 10189, 14, 221, 961, 859, 6571, 272, 376, 4514, 367, 6449, 543, 662, 23141, 2897, 10189, 315, 272, 282, 25286, 4340, 14, 199, 11036, 63, 9970, 63, 7677, 26, 655, 736, 199, 5983, 26, 523, 446, 30568, 6169, 662, 23141, 1695, 14, 20, 14, 17, 199, 1419, 26, 523, 2385, 26, 272, 1369, 26, 489, 446, 710, 7741, 663, 402, 3718, 626, 1077, 506, 7526, 315, 314, 267, 3420, 14, 221, 710, 3718, 1471, 506, 314, 5835, 2011, 3718, 465, 1911, 267, 315, 314, 2243, 3879, 13, 888, 14, 221, 6423, 3238, 370, 5317, 314, 2897, 267, 1414, 6302, 465, 2005, 3718, 787, 5847, 6042, 701, 314, 267, 2243, 1101, 1798, 14, 272, 5481, 26, 788, 4405, 418, 523, 8623, 26, 272, 1369, 26, 489, 446, 710, 7741, 663, 402, 8623, 626, 28727, 10405, 314, 3420, 267, 314, 3718, 1077, 506, 7923, 6169, 14, 221, 982, 314, 8623, 1423, 267, 365, 11684, 12, 314, 3718, 787, 7923, 6169, 314, 663, 402, 2746, 267, 2166, 503, 2288, 3718, 14, 523, 2928, 26, 272, 1369, 26, 489, 446, 11015, 314, 1350, 931, 370, 314, 570, 626, 3509, 314, 2897, 267, 503, 2897, 1978, 370, 2248, 14, 221, 710, 931, 370, 314, 1350, 570, 883, 267, 1902, 506, 314, 2615, 931, 641, 314, 2622, 3304, 1591, 503, 282, 3847, 267, 931, 687, 314, 15695, 503, 4719, 1738, 2082, 14, 221, 961, 1423, 365, 267, 16108, 13914, 543, 473, 8, 1278, 395, 473, 8, 8859, 680, 523, 2544, 26, 272, 1369, 26, 489, 446, 710, 7741, 663, 402, 3718, 370, 6675, 641, 370, 314, 1414, 3464, 340, 267, 282, 1570, 4839, 370, 506, 6326, 14, 221, 961, 6127, 314, 15695, 12899, 281, 267, 314, 30914, 370, 5147, 2897, 3718, 6791, 370, 6675, 316, 267, 1263, 4493, 1928, 12787, 316, 4212, 314, 663, 402, 3718, 787, 7838, 267, 6169, 314, 2656, 14, 523, 2410, 26, 272, 1369, 26, 489, 446, 710, 7741, 663, 402, 3718, 370, 5666, 370, 314, 1284, 402, 314, 1414, 267, 3464, 340, 282, 1570, 4839, 370, 506, 6326, 14, 221, 13870, 2839, 543, 473, 8, 5182, 9, 642, 267, 6127, 314, 15695, 12899, 281, 370, 5666, 282, 663, 402, 3718, 370, 506, 267, 7934, 2410, 314, 1414, 663, 14, 523, 1336, 26, 272, 1369, 26, 489, 446, 1010, 23253, 314, 859, 641, 314, 4340, 370, 5147, 314, 4877, 402, 267, 314, 663, 402, 3718, 6169, 314, 1453, 2243, 1101, 14, 221, 982, 267, 1336, 365, 663, 370, 473, 8, 604, 395, 3718, 787, 7838, 1004, 701, 1004, 14, 221, 982, 267, 1336, 365, 663, 370, 473, 8, 4768, 395, 1414, 2385, 787, 7838, 543, 14021, 267, 370, 3421, 14, 221, 982, 1336, 365, 663, 370, 473, 8, 7327, 395, 1414, 2385, 267, 1471, 506, 376, 4472, 1336, 14, 221, 19177, 12, 340, 1336, 365, 663, 370, 473, 8, 3592, 395, 314, 267, 859, 911, 440, 7427, 370, 6540, 314, 1350, 2897, 543, 267, 314, 3879, 2897, 641, 314, 3982, 2243, 14, 272, 849, 26, 1004, 272, 3415, 26, 788, 604, 297, 283, 4768, 297, 283, 7327, 297, 283, 3592, 418, 523, 3350, 26, 272, 1369, 26, 489, 446, 1010, 23253, 314, 859, 641, 314, 4340, 370, 5147, 314, 2897, 267, 641, 314, 2243, 14, 221, 982, 314, 3350, 1423, 365, 663, 370, 473, 8, 604, 9, 2066, 267, 314, 6042, 2385, 787, 22319, 370, 314, 2243, 315, 2897, 267, 818, 14, 221, 982, 314, 3350, 1423, 365, 663, 370, 473, 8, 1457, 9, 2066, 314, 8039, 267, 1414, 1853, 365, 22319, 370, 314, 2243, 315, 2897, 818, 340, 1263, 267, 1004, 365, 440, 3211, 14, 272, 849, 26, 1004, 272, 3415, 26, 788, 604, 297, 283, 1457, 297, 283, 888, 418, 523, 1101, 26, 272, 1369, 26, 489, 446, 710, 859, 12, 701, 849, 12, 911, 4907, 370, 314, 3982, 2243, 436, 267, 8044, 314, 1453, 3879, 13, 888, 370, 675, 465, 282, 1300, 367, 20234, 267, 6169, 314, 4072, 402, 1350, 14, 221, 6006, 787, 5431, 1380, 652, 365, 440, 267, 477, 338, 6842, 370, 1172, 314, 2120, 664, 314, 1453, 3879, 13, 888, 367, 267, 4036, 2120, 315, 282, 15695, 14, 221, 710, 473, 8, 888, 9, 1423, 6127, 314, 267, 2456, 28826, 370, 986, 315, 314, 2897, 370, 675, 465, 314, 1300, 267, 1101, 367, 9132, 14, 523, 6902, 26, 272, 1369, 26, 489, 446, 961, 1423, 911, 7675, 314, 859, 370, 1218, 282, 2615, 6902, 402, 267, 314, 1453, 445, 8, 5720, 13, 888, 9, 687, 314, 3982 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 334, 35, 9, 9708, 9572, 13002, 3277, 14, 199, 3, 1898, 334, 35, 9, 9708, 15757, 31445, 14, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 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, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 3, 199, 3, 5673, 370, 7908, 15757, 31445, 17711, 397, 14, 199, 3, 15757, 31445, 7220, 316, 199, 3, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 655, 736, 63, 888, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 2502, 26, 298, 2493, 382, 1804, 453, 285, 603, 300, 1895, 379, 8210, 290, 8593, 455, 300, 1895, 379, 8210, 2924, 199, 3612, 63, 1802, 26, 14944, 15757, 31445, 662, 23141, 2897, 10189, 199, 1802, 26, 523, 446, 15757, 31445, 662, 23141, 13422, 675, 282, 3486, 1853, 4363, 570, 6302, 272, 367, 8135, 316, 2897, 1901, 10189, 14, 221, 961, 859, 6571, 272, 376, 4514, 367, 6449, 543, 662, 23141, 2897, 10189, 315, 272, 282, 25286, 4340, 14, 199, 11036, 63, 9970, 63, 7677, 26, 655, 736, 199, 5983, 26, 523, 446, 30568, 6169, 662, 23141, 1695, 14, 20, 14, 17, 199, 1419, 26, 523, 2385, 26, 272, 1369, 26, 489, 446, 710, 7741, 663, 402, 3718, 626, 1077, 506, 7526, 315, 314, 267, 3420, 14, 221, 710, 3718, 1471, 506, 314, 5835, 2011, 3718, 465, 1911, 267, 315, 314, 2243, 3879, 13, 888, 14, 221, 6423, 3238, 370, 5317, 314, 2897, 267, 1414, 6302, 465, 2005, 3718, 787, 5847, 6042, 701, 314, 267, 2243, 1101, 1798, 14, 272, 5481, 26, 788, 4405, 418, 523, 8623, 26, 272, 1369, 26, 489, 446, 710, 7741, 663, 402, 8623, 626, 28727, 10405, 314, 3420, 267, 314, 3718, 1077, 506, 7923, 6169, 14, 221, 982, 314, 8623, 1423, 267, 365, 11684, 12, 314, 3718, 787, 7923, 6169, 314, 663, 402, 2746, 267, 2166, 503, 2288, 3718, 14, 523, 2928, 26, 272, 1369, 26, 489, 446, 11015, 314, 1350, 931, 370, 314, 570, 626, 3509, 314, 2897, 267, 503, 2897, 1978, 370, 2248, 14, 221, 710, 931, 370, 314, 1350, 570, 883, 267, 1902, 506, 314, 2615, 931, 641, 314, 2622, 3304, 1591, 503, 282, 3847, 267, 931, 687, 314, 15695, 503, 4719, 1738, 2082, 14, 221, 961, 1423, 365, 267, 16108, 13914, 543, 473, 8, 1278, 395, 473, 8, 8859, 680, 523, 2544, 26, 272, 1369, 26, 489, 446, 710, 7741, 663, 402, 3718, 370, 6675, 641, 370, 314, 1414, 3464, 340, 267, 282, 1570, 4839, 370, 506, 6326, 14, 221, 961, 6127, 314, 15695, 12899, 281, 267, 314, 30914, 370, 5147, 2897, 3718, 6791, 370, 6675, 316, 267, 1263, 4493, 1928, 12787, 316, 4212, 314, 663, 402, 3718, 787, 7838, 267, 6169, 314, 2656, 14, 523, 2410, 26, 272, 1369, 26, 489, 446, 710, 7741, 663, 402, 3718, 370, 5666, 370, 314, 1284, 402, 314, 1414, 267, 3464, 340, 282, 1570, 4839, 370, 506, 6326, 14, 221, 13870, 2839, 543, 473, 8, 5182, 9, 642, 267, 6127, 314, 15695, 12899, 281, 370, 5666, 282, 663, 402, 3718, 370, 506, 267, 7934, 2410, 314, 1414, 663, 14, 523, 1336, 26, 272, 1369, 26, 489, 446, 1010, 23253, 314, 859, 641, 314, 4340, 370, 5147, 314, 4877, 402, 267, 314, 663, 402, 3718, 6169, 314, 1453, 2243, 1101, 14, 221, 982, 267, 1336, 365, 663, 370, 473, 8, 604, 395, 3718, 787, 7838, 1004, 701, 1004, 14, 221, 982, 267, 1336, 365, 663, 370, 473, 8, 4768, 395, 1414, 2385, 787, 7838, 543, 14021, 267, 370, 3421, 14, 221, 982, 1336, 365, 663, 370, 473, 8, 7327, 395, 1414, 2385, 267, 1471, 506, 376, 4472, 1336, 14, 221, 19177, 12, 340, 1336, 365, 663, 370, 473, 8, 3592, 395, 314, 267, 859, 911, 440, 7427, 370, 6540, 314, 1350, 2897, 543, 267, 314, 3879, 2897, 641, 314, 3982, 2243, 14, 272, 849, 26, 1004, 272, 3415, 26, 788, 604, 297, 283, 4768, 297, 283, 7327, 297, 283, 3592, 418, 523, 3350, 26, 272, 1369, 26, 489, 446, 1010, 23253, 314, 859, 641, 314, 4340, 370, 5147, 314, 2897, 267, 641, 314, 2243, 14, 221, 982, 314, 3350, 1423, 365, 663, 370, 473, 8, 604, 9, 2066, 267, 314, 6042, 2385, 787, 22319, 370, 314, 2243, 315, 2897, 267, 818, 14, 221, 982, 314, 3350, 1423, 365, 663, 370, 473, 8, 1457, 9, 2066, 314, 8039, 267, 1414, 1853, 365, 22319, 370, 314, 2243, 315, 2897, 818, 340, 1263, 267, 1004, 365, 440, 3211, 14, 272, 849, 26, 1004, 272, 3415, 26, 788, 604, 297, 283, 1457, 297, 283, 888, 418, 523, 1101, 26, 272, 1369, 26, 489, 446, 710, 859, 12, 701, 849, 12, 911, 4907, 370, 314, 3982, 2243, 436, 267, 8044, 314, 1453, 3879, 13, 888, 370, 675, 465, 282, 1300, 367, 20234, 267, 6169, 314, 4072, 402, 1350, 14, 221, 6006, 787, 5431, 1380, 652, 365, 440, 267, 477, 338, 6842, 370, 1172, 314, 2120, 664, 314, 1453, 3879, 13, 888, 367, 267, 4036, 2120, 315, 282, 15695, 14, 221, 710, 473, 8, 888, 9, 1423, 6127, 314, 267, 2456, 28826, 370, 986, 315, 314, 2897, 370, 675, 465, 314, 1300, 267, 1101, 367, 9132, 14, 523, 6902, 26, 272, 1369, 26, 489, 446, 961, 1423, 911, 7675, 314, 859, 370, 1218, 282, 2615, 6902, 402, 267, 314, 1453, 445, 8, 5720, 13, 888, 9, 687, 314, 3982, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lizardsystem/lizard-measure
lizard_measure/migrations/0010_auto__del_score__del_measuringrod__del_field_measurestatusmoment_is_pl.py
1
23606
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Deleting model 'Score' db.delete_table('lizard_measure_score') # Deleting model 'MeasuringRod' db.delete_table('lizard_measure_measuringrod') # Deleting field 'MeasureStatusMoment.is_planning' db.delete_column('lizard_measure_measurestatusmoment', 'is_planning') # Deleting field 'MeasureStatusMoment.date' db.delete_column('lizard_measure_measurestatusmoment', 'date') # Adding field 'MeasureStatusMoment.planning_date' db.add_column('lizard_measure_measurestatusmoment', 'planning_date', self.gf('django.db.models.fields.DateField')(null=True, blank=True), keep_default=False) # Adding field 'MeasureStatusMoment.realisation_date' db.add_column('lizard_measure_measurestatusmoment', 'realisation_date', self.gf('django.db.models.fields.DateField')(null=True, blank=True), keep_default=False) # Deleting field 'Measure.total_costs' db.delete_column('lizard_measure_measure', 'total_costs') # Adding field 'Measure.valid' db.add_column('lizard_measure_measure', 'valid', self.gf('django.db.models.fields.NullBooleanField')(default=False, null=True, blank=True), keep_default=False) # Adding field 'Measure.geom' db.add_column('lizard_measure_measure', 'geom', self.gf('django.contrib.gis.db.models.fields.GeometryField')(null=True, blank=True), keep_default=False) def backwards(self, orm): # Adding model 'Score' db.create_table('lizard_measure_score', ( ('gep', self.gf('django.db.models.fields.FloatField')(null=True, blank=True)), ('area_ident', self.gf('django.db.models.fields.CharField')(max_length=32, null=True, blank=True)), ('ascending', self.gf('django.db.models.fields.NullBooleanField')(null=True, blank=True)), ('mep', self.gf('django.db.models.fields.FloatField')(null=True, blank=True)), ('measuring_rod', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['lizard_measure.MeasuringRod'])), ('limit_bad_insufficient', self.gf('django.db.models.fields.FloatField')(null=True, blank=True)), ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('area', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['lizard_area.Area'], null=True, blank=True)), ('target_2027', self.gf('django.db.models.fields.FloatField')(null=True, blank=True)), ('limit_insufficient_moderate', self.gf('django.db.models.fields.FloatField')(null=True, blank=True)), ('target_2015', self.gf('django.db.models.fields.FloatField')(null=True, blank=True)), )) db.send_create_signal('lizard_measure', ['Score']) # Adding model 'MeasuringRod' db.create_table('lizard_measure_measuringrod', ( ('group', self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True)), ('sign', self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True)), ('sub_measuring_rod', self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True)), ('measuring_rod', self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True)), ('id', self.gf('django.db.models.fields.IntegerField')(primary_key=True)), ('unit', self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True)), )) db.send_create_signal('lizard_measure', ['MeasuringRod']) # Adding field 'MeasureStatusMoment.is_planning' db.add_column('lizard_measure_measurestatusmoment', 'is_planning', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) # Adding field 'MeasureStatusMoment.date' db.add_column('lizard_measure_measurestatusmoment', 'date', self.gf('django.db.models.fields.DateField')(null=True, blank=True), keep_default=False) # Deleting field 'MeasureStatusMoment.planning_date' db.delete_column('lizard_measure_measurestatusmoment', 'planning_date') # Deleting field 'MeasureStatusMoment.realisation_date' db.delete_column('lizard_measure_measurestatusmoment', 'realisation_date') # Adding field 'Measure.total_costs' db.add_column('lizard_measure_measure', 'total_costs', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True), keep_default=False) # Deleting field 'Measure.valid' db.delete_column('lizard_measure_measure', 'valid') # Deleting field 'Measure.geom' db.delete_column('lizard_measure_measure', 'geom') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'lizard_area.area': { 'Meta': {'ordering': "('name',)", 'object_name': 'Area', '_ormbases': ['lizard_area.Communique']}, 'area_class': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'communique_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['lizard_area.Communique']", 'unique': 'True', 'primary_key': 'True'}), 'data_administrator': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_area.DataAdministrator']"}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_area.Area']", 'null': 'True', 'blank': 'True'}) }, 'lizard_area.communique': { 'Meta': {'object_name': 'Communique', '_ormbases': ['lizard_geo.GeoObject']}, 'code': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.TextField', [], {'default': "''"}), 'geoobject_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['lizard_geo.GeoObject']", 'unique': 'True', 'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}) }, 'lizard_area.dataadministrator': { 'Meta': {'object_name': 'DataAdministrator'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}) }, 'lizard_geo.geoobject': { 'Meta': {'object_name': 'GeoObject'}, 'geo_object_group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_geo.GeoObjectGroup']"}), 'geometry': ('django.contrib.gis.db.models.fields.GeometryField', [], {}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ident': ('django.db.models.fields.CharField', [], {'max_length': '80'}) }, 'lizard_geo.geoobjectgroup': { 'Meta': {'object_name': 'GeoObjectGroup'}, 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}), 'source_log': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, 'lizard_measure.fundingorganization': { 'Meta': {'object_name': 'FundingOrganization'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'measure': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_measure.Measure']"}), 'organization': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_measure.Organization']"}), 'percentage': ('django.db.models.fields.FloatField', [], {}) }, 'lizard_measure.krwstatus': { 'Meta': {'object_name': 'KRWStatus'}, 'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'}), 'description': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'valid': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}) }, 'lizard_measure.krwwatertype': { 'Meta': {'object_name': 'KRWWatertype'}, 'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'}), 'description': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), 'group': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'valid': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}) }, 'lizard_measure.measure': { 'Meta': {'ordering': "('id',)", 'object_name': 'Measure'}, 'aggregation_type': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'areas': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'area_measure_set'", 'blank': 'True', 'to': "orm['lizard_area.Area']"}), 'categories': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['lizard_measure.MeasureCategory']", 'symmetrical': 'False', 'blank': 'True'}), 'datetime_in_source': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}), 'executive': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'executive_measure_set'", 'null': 'True', 'to': "orm['lizard_measure.Organization']"}), 'exploitation_costs': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'funding_organizations': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['lizard_measure.Organization']", 'through': "orm['lizard_measure.FundingOrganization']", 'symmetrical': 'False'}), 'geom': ('django.contrib.gis.db.models.fields.GeometryField', [], {'null': 'True', 'blank': 'True'}), 'geometry': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_geo.GeoObject']", 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ident': ('django.db.models.fields.CharField', [], {'max_length': '64', 'unique': 'True', 'null': 'True', 'blank': 'True'}), 'import_raw': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'import_source': ('django.db.models.fields.IntegerField', [], {'default': '3'}), 'initiator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'initiator_measure_set'", 'null': 'True', 'to': "orm['lizard_measure.Organization']"}), 'investment_costs': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'is_KRW_measure': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}), 'is_indicator': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'measure_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_measure.MeasureType']"}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_measure.Measure']", 'null': 'True', 'blank': 'True'}), 'period': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_measure.MeasurePeriod']", 'null': 'True', 'blank': 'True'}), 'read_only': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'responsible_department': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'status_moments': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['lizard_measure.MeasureStatus']", 'through': "orm['lizard_measure.MeasureStatusMoment']", 'symmetrical': 'False'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), 'unit': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_measure.Unit']"}), 'valid': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), 'value': ('django.db.models.fields.FloatField', [], {}), 'waterbodies': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['lizard_measure.WaterBody']", 'symmetrical': 'False', 'blank': 'True'}) }, 'lizard_measure.measurecategory': { 'Meta': {'object_name': 'MeasureCategory'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}), 'valid': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}) }, 'lizard_measure.measureperiod': { 'Meta': {'ordering': "('start_date', 'end_date')", 'object_name': 'MeasurePeriod'}, 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'end_date': ('django.db.models.fields.DateField', [], {}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'start_date': ('django.db.models.fields.DateField', [], {}), 'valid': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}) }, 'lizard_measure.measurestatus': { 'Meta': {'ordering': "('-value',)", 'object_name': 'MeasureStatus'}, 'color': ('lizard_map.models.ColorField', [], {'max_length': '8'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}), 'valid': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'value': ('django.db.models.fields.FloatField', [], {'default': '0.0'}) }, 'lizard_measure.measurestatusmoment': { 'Meta': {'ordering': "('measure__id', 'status__value')", 'object_name': 'MeasureStatusMoment'}, 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'exploitation_expenditure': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'investment_expenditure': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'measure': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_measure.Measure']"}), 'planning_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'realisation_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_measure.MeasureStatus']"}) }, 'lizard_measure.measuretype': { 'Meta': {'ordering': "('code',)", 'object_name': 'MeasureType'}, 'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'combined_name': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.TextField', [], {}), 'group': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), 'harmonisation': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'klass': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), 'subcategory': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), 'units': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['lizard_measure.Unit']", 'symmetrical': 'False', 'blank': 'True'}), 'valid': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}) }, 'lizard_measure.organization': { 'Meta': {'ordering': "('description',)", 'unique_together': "(('source', 'code'),)", 'object_name': 'Organization'}, 'code': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), 'group': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'source': ('django.db.models.fields.IntegerField', [], {'default': '5'}), 'valid': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}) }, 'lizard_measure.steeringparameter': { 'Meta': {'object_name': 'SteeringParameter'}, 'area': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_area.Area']"}), 'fews_parameter': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'target_maximum': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'target_minimum': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) }, 'lizard_measure.unit': { 'Meta': {'object_name': 'Unit'}, 'code': ('django.db.models.fields.CharField', [], {'max_length': '20', 'unique': 'True', 'null': 'True', 'blank': 'True'}), 'conversion_factor': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'dimension': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}), 'group': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'valid': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}) }, 'lizard_measure.waterbody': { 'Meta': {'object_name': 'WaterBody'}, 'area': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_area.Area']", 'null': 'True', 'blank': 'True'}), 'area_ident': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'krw_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_measure.KRWStatus']", 'null': 'True', 'blank': 'True'}), 'krw_watertype': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['lizard_measure.KRWWatertype']", 'null': 'True', 'blank': 'True'}) } } complete_apps = ['lizard_measure']
gpl-3.0
[ 3, 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 15920, 1402, 283, 12642, 7, 267, 1592, 14, 1807, 63, 1224, 360, 19030, 1005, 63, 9580, 63, 3397, 358, 398, 327, 15920, 1402, 283, 1352, 305, 4039, 50, 364, 7, 267, 1592, 14, 1807, 63, 1224, 360, 19030, 1005, 63, 9580, 63, 19116, 4039, 19402, 358, 398, 327, 15920, 901, 283, 18611, 3694, 3716, 434, 14, 374, 63, 1168, 11495, 7, 267, 1592, 14, 1807, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 1205, 17282, 297, 283, 374, 63, 1168, 11495, 358, 398, 327, 15920, 901, 283, 18611, 3694, 3716, 434, 14, 602, 7, 267, 1592, 14, 1807, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 1205, 17282, 297, 283, 602, 358, 398, 327, 12934, 901, 283, 18611, 3694, 3716, 434, 14, 1168, 11495, 63, 602, 7, 267, 1592, 14, 525, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 1205, 17282, 297, 283, 1168, 11495, 63, 602, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 7533, 2307, 29, 549, 12, 4596, 29, 549, 395, 4215, 63, 885, 29, 797, 9, 398, 327, 12934, 901, 283, 18611, 3694, 3716, 434, 14, 3093, 19914, 63, 602, 7, 267, 1592, 14, 525, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 1205, 17282, 297, 283, 3093, 19914, 63, 602, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 7533, 2307, 29, 549, 12, 4596, 29, 549, 395, 4215, 63, 885, 29, 797, 9, 398, 327, 15920, 901, 283, 18611, 14, 2923, 63, 25432, 7, 267, 1592, 14, 1807, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 297, 283, 2923, 63, 25432, 358, 398, 327, 12934, 901, 283, 18611, 14, 1078, 7, 267, 1592, 14, 525, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 297, 283, 1078, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 29068, 7533, 885, 29, 797, 12, 2973, 29, 549, 12, 4596, 29, 549, 395, 4215, 63, 885, 29, 797, 9, 398, 327, 12934, 901, 283, 18611, 14, 6481, 7, 267, 1592, 14, 525, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 297, 283, 6481, 297, 291, 14, 7102, 360, 1176, 14, 2828, 14, 5668, 14, 697, 14, 992, 14, 955, 14, 6831, 792, 7533, 2307, 29, 549, 12, 4596, 29, 549, 395, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 12934, 1402, 283, 12642, 7, 267, 1592, 14, 981, 63, 1224, 360, 19030, 1005, 63, 9580, 63, 3397, 297, 334, 288, 661, 303, 80, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 6789, 63, 5425, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 708, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 10125, 3219, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 29068, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 278, 80, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 19116, 4039, 63, 19402, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 19030, 1005, 63, 9580, 14, 1352, 305, 4039, 50, 364, 16607, 288, 661, 3097, 63, 4087, 63, 3617, 12983, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 6789, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 19030, 1005, 63, 6789, 14, 11043, 995, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1375, 63, 4999, 23, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 3097, 63, 3617, 12983, 63, 632, 1866, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1375, 63, 7806, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 19030, 1005, 63, 9580, 297, 788, 12642, 1105, 398, 327, 12934, 1402, 283, 1352, 305, 4039, 50, 364, 7, 267, 1592, 14, 981, 63, 1224, 360, 19030, 1005, 63, 9580, 63, 19116, 4039, 19402, 297, 334, 288, 661, 923, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1037, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 954, 63, 19116, 4039, 63, 19402, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 19116, 4039, 63, 19402, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 3248, 297, 291, 14, 7102, 360, 1176, 14, 697, 14 ]
[ 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 15920, 1402, 283, 12642, 7, 267, 1592, 14, 1807, 63, 1224, 360, 19030, 1005, 63, 9580, 63, 3397, 358, 398, 327, 15920, 1402, 283, 1352, 305, 4039, 50, 364, 7, 267, 1592, 14, 1807, 63, 1224, 360, 19030, 1005, 63, 9580, 63, 19116, 4039, 19402, 358, 398, 327, 15920, 901, 283, 18611, 3694, 3716, 434, 14, 374, 63, 1168, 11495, 7, 267, 1592, 14, 1807, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 1205, 17282, 297, 283, 374, 63, 1168, 11495, 358, 398, 327, 15920, 901, 283, 18611, 3694, 3716, 434, 14, 602, 7, 267, 1592, 14, 1807, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 1205, 17282, 297, 283, 602, 358, 398, 327, 12934, 901, 283, 18611, 3694, 3716, 434, 14, 1168, 11495, 63, 602, 7, 267, 1592, 14, 525, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 1205, 17282, 297, 283, 1168, 11495, 63, 602, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 7533, 2307, 29, 549, 12, 4596, 29, 549, 395, 4215, 63, 885, 29, 797, 9, 398, 327, 12934, 901, 283, 18611, 3694, 3716, 434, 14, 3093, 19914, 63, 602, 7, 267, 1592, 14, 525, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 1205, 17282, 297, 283, 3093, 19914, 63, 602, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 7533, 2307, 29, 549, 12, 4596, 29, 549, 395, 4215, 63, 885, 29, 797, 9, 398, 327, 15920, 901, 283, 18611, 14, 2923, 63, 25432, 7, 267, 1592, 14, 1807, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 297, 283, 2923, 63, 25432, 358, 398, 327, 12934, 901, 283, 18611, 14, 1078, 7, 267, 1592, 14, 525, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 297, 283, 1078, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 29068, 7533, 885, 29, 797, 12, 2973, 29, 549, 12, 4596, 29, 549, 395, 4215, 63, 885, 29, 797, 9, 398, 327, 12934, 901, 283, 18611, 14, 6481, 7, 267, 1592, 14, 525, 63, 2301, 360, 19030, 1005, 63, 9580, 63, 9580, 297, 283, 6481, 297, 291, 14, 7102, 360, 1176, 14, 2828, 14, 5668, 14, 697, 14, 992, 14, 955, 14, 6831, 792, 7533, 2307, 29, 549, 12, 4596, 29, 549, 395, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 12934, 1402, 283, 12642, 7, 267, 1592, 14, 981, 63, 1224, 360, 19030, 1005, 63, 9580, 63, 3397, 297, 334, 288, 661, 303, 80, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 6789, 63, 5425, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 708, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 10125, 3219, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 29068, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 278, 80, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 19116, 4039, 63, 19402, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 19030, 1005, 63, 9580, 14, 1352, 305, 4039, 50, 364, 16607, 288, 661, 3097, 63, 4087, 63, 3617, 12983, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 6789, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 19030, 1005, 63, 6789, 14, 11043, 995, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1375, 63, 4999, 23, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 3097, 63, 3617, 12983, 63, 632, 1866, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1375, 63, 7806, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 19030, 1005, 63, 9580, 297, 788, 12642, 1105, 398, 327, 12934, 1402, 283, 1352, 305, 4039, 50, 364, 7, 267, 1592, 14, 981, 63, 1224, 360, 19030, 1005, 63, 9580, 63, 19116, 4039, 19402, 297, 334, 288, 661, 923, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1037, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 954, 63, 19116, 4039, 63, 19402, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 19116, 4039, 63, 19402, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3933, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 3248, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
konrad/kufpybio
kufpybiotools/generate_igr_gff.py
1
1881
#!/usr/bin/env python __description__ = "" __author__ = "Konrad Foerstner <konrad@foerstner.org>" __copyright__ = "2013 by Konrad Foerstner <konrad@foerstner.org>" __license__ = "ISC license" __email__ = "konrad@foerstner.org" __version__ = "" import argparse import csv import sys sys.path.append(".") from kufpybio.gff3 import Gff3Parser, Gff3Entry from kufpybio.gene import Gene from kufpybio.igrfinder import IGRFinder parser = argparse.ArgumentParser(description=__description__) parser.add_argument("gff_file", type=argparse.FileType("r")) parser.add_argument("output_file", type=argparse.FileType("w")) parser.add_argument("--margin", type=int, default=0) parser.add_argument("--plus_only", default=False, action="store_true") args = parser.parse_args() # Build gene list gene_list = [] gff_parser = Gff3Parser() region_entry = None for entry in gff_parser.entries(args.gff_file): if entry.feature == "region": region_entry = entry continue gene_list.append(Gene( entry.seq_id, "", "", entry.start, entry.end, entry.strand)) # Find IGRs and generate GFF file igr_finder = IGRFinder() args.output_file.write("##gff-version 3\n") strands = ["+", "-"] if args.plus_only is True: strands = ["+"] for start, end in igr_finder.find_igrs(gene_list, region_entry.end): start = start + args.margin end = end - args.margin if end <= start: continue for strand in strands: gff3_entry = Gff3Entry({ "seq_id" : region_entry.seq_id, "source" : "IGR", "feature" : "IGR", "start" : start, "end" : end, "score" : ".", "strand" : strand, "phase" : ".", "attributes" : "ID=IGR_%s_%s_to_%s" % ( region_entry.seq_id, start, end)}) args.output_file.write(str(gff3_entry) + "\n")
isc
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 363, 1802, 363, 275, 3087, 199, 363, 2502, 363, 275, 298, 43, 265, 9525, 481, 79, 281, 270, 1372, 665, 75, 265, 9525, 32, 545, 281, 270, 1372, 14, 1308, 4335, 199, 363, 7307, 363, 275, 298, 6965, 701, 1804, 265, 9525, 481, 79, 281, 270, 1372, 665, 75, 265, 9525, 32, 545, 281, 270, 1372, 14, 1308, 4335, 199, 363, 1682, 363, 275, 298, 25806, 4190, 2, 199, 363, 2123, 363, 275, 298, 75, 265, 9525, 32, 545, 281, 270, 1372, 14, 1308, 2, 199, 363, 1023, 363, 275, 3087, 199, 199, 646, 7534, 199, 646, 7392, 199, 646, 984, 199, 1274, 14, 515, 14, 740, 15857, 199, 504, 1022, 1286, 647, 17614, 14, 71, 556, 19, 492, 598, 556, 19, 2842, 12, 598, 556, 19, 3900, 199, 504, 1022, 1286, 647, 17614, 14, 10654, 492, 598, 6349, 199, 504, 1022, 1286, 647, 17614, 14, 528, 82, 11681, 492, 473, 3975, 11791, 199, 199, 2087, 275, 7534, 14, 10730, 8, 1802, 18971, 1802, 3368, 199, 2087, 14, 525, 63, 2094, 480, 71, 556, 63, 493, 401, 730, 29, 18978, 14, 20683, 480, 82, 2237, 199, 2087, 14, 525, 63, 2094, 480, 1199, 63, 493, 401, 730, 29, 18978, 14, 20683, 480, 87, 2237, 199, 2087, 14, 525, 63, 2094, 6739, 9650, 401, 730, 29, 442, 12, 849, 29, 16, 9, 199, 2087, 14, 525, 63, 2094, 6739, 6666, 63, 2118, 401, 849, 29, 797, 12, 1595, 628, 1617, 63, 2052, 531, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 3, 6516, 15599, 769, 199, 10654, 63, 513, 275, 942, 199, 71, 556, 63, 2087, 275, 598, 556, 19, 2842, 342, 199, 4551, 63, 2373, 275, 488, 199, 509, 2397, 315, 486, 556, 63, 2087, 14, 3189, 8, 589, 14, 71, 556, 63, 493, 304, 272, 340, 2397, 14, 4445, 508, 298, 4551, 582, 267, 4897, 63, 2373, 275, 2397, 267, 1980, 272, 15599, 63, 513, 14, 740, 8, 39, 6349, 8, 267, 2397, 14, 3610, 63, 344, 12, 4873, 4873, 2397, 14, 928, 12, 2397, 14, 500, 12, 267, 2397, 14, 30964, 430, 199, 3, 6668, 473, 3975, 83, 436, 3550, 598, 1665, 570, 199, 528, 82, 63, 11681, 275, 473, 3975, 11791, 342, 199, 589, 14, 1199, 63, 493, 14, 952, 480, 309, 71, 556, 13, 1023, 650, 60, 78, 531, 199, 199, 495, 5915, 275, 2097, 22758, 3905, 937, 199, 692, 1249, 14, 6666, 63, 2118, 365, 715, 26, 272, 620, 5915, 275, 2097, 11, 937, 199, 199, 509, 1343, 12, 1284, 315, 284, 2587, 63, 11681, 14, 1623, 63, 528, 2393, 8, 10654, 63, 513, 12, 4897, 63, 2373, 14, 500, 304, 272, 1343, 275, 1343, 435, 1249, 14, 9650, 272, 1284, 275, 1284, 446, 1249, 14, 9650, 272, 340, 1284, 2695, 1343, 26, 267, 1980, 272, 367, 620, 460, 315, 620, 5915, 26, 267, 486, 556, 19, 63, 2373, 275, 598, 556, 19, 3900, 2561, 288, 298, 3610, 63, 344, 2, 520, 4897, 63, 2373, 14, 3610, 63, 344, 12, 288, 298, 1365, 2, 520, 298, 1277, 50, 401, 288, 298, 4445, 2, 520, 298, 1277, 50, 401, 288, 298, 928, 2, 520, 1343, 12, 288, 298, 500, 2, 520, 1284, 12, 288, 298, 3397, 2, 520, 3680, 401, 288, 298, 30964, 2, 520, 620, 460, 12, 288, 298, 6971, 2, 520, 3680, 401, 288, 298, 2987, 2, 520, 298, 998, 29, 1277, 50, 4970, 83, 4970, 83, 63, 475, 4970, 83, 2, 450, 334, 490, 4897, 63, 2373, 14, 3610, 63, 344, 12, 1343, 12, 1284, 11466, 267, 1249, 14, 1199, 63, 493, 14, 952, 8, 495, 8, 71, 556, 19, 63, 2373, 9, 435, 1867, 78, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 363, 1802, 363, 275, 3087, 199, 363, 2502, 363, 275, 298, 43, 265, 9525, 481, 79, 281, 270, 1372, 665, 75, 265, 9525, 32, 545, 281, 270, 1372, 14, 1308, 4335, 199, 363, 7307, 363, 275, 298, 6965, 701, 1804, 265, 9525, 481, 79, 281, 270, 1372, 665, 75, 265, 9525, 32, 545, 281, 270, 1372, 14, 1308, 4335, 199, 363, 1682, 363, 275, 298, 25806, 4190, 2, 199, 363, 2123, 363, 275, 298, 75, 265, 9525, 32, 545, 281, 270, 1372, 14, 1308, 2, 199, 363, 1023, 363, 275, 3087, 199, 199, 646, 7534, 199, 646, 7392, 199, 646, 984, 199, 1274, 14, 515, 14, 740, 15857, 199, 504, 1022, 1286, 647, 17614, 14, 71, 556, 19, 492, 598, 556, 19, 2842, 12, 598, 556, 19, 3900, 199, 504, 1022, 1286, 647, 17614, 14, 10654, 492, 598, 6349, 199, 504, 1022, 1286, 647, 17614, 14, 528, 82, 11681, 492, 473, 3975, 11791, 199, 199, 2087, 275, 7534, 14, 10730, 8, 1802, 18971, 1802, 3368, 199, 2087, 14, 525, 63, 2094, 480, 71, 556, 63, 493, 401, 730, 29, 18978, 14, 20683, 480, 82, 2237, 199, 2087, 14, 525, 63, 2094, 480, 1199, 63, 493, 401, 730, 29, 18978, 14, 20683, 480, 87, 2237, 199, 2087, 14, 525, 63, 2094, 6739, 9650, 401, 730, 29, 442, 12, 849, 29, 16, 9, 199, 2087, 14, 525, 63, 2094, 6739, 6666, 63, 2118, 401, 849, 29, 797, 12, 1595, 628, 1617, 63, 2052, 531, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 3, 6516, 15599, 769, 199, 10654, 63, 513, 275, 942, 199, 71, 556, 63, 2087, 275, 598, 556, 19, 2842, 342, 199, 4551, 63, 2373, 275, 488, 199, 509, 2397, 315, 486, 556, 63, 2087, 14, 3189, 8, 589, 14, 71, 556, 63, 493, 304, 272, 340, 2397, 14, 4445, 508, 298, 4551, 582, 267, 4897, 63, 2373, 275, 2397, 267, 1980, 272, 15599, 63, 513, 14, 740, 8, 39, 6349, 8, 267, 2397, 14, 3610, 63, 344, 12, 4873, 4873, 2397, 14, 928, 12, 2397, 14, 500, 12, 267, 2397, 14, 30964, 430, 199, 3, 6668, 473, 3975, 83, 436, 3550, 598, 1665, 570, 199, 528, 82, 63, 11681, 275, 473, 3975, 11791, 342, 199, 589, 14, 1199, 63, 493, 14, 952, 480, 309, 71, 556, 13, 1023, 650, 60, 78, 531, 199, 199, 495, 5915, 275, 2097, 22758, 3905, 937, 199, 692, 1249, 14, 6666, 63, 2118, 365, 715, 26, 272, 620, 5915, 275, 2097, 11, 937, 199, 199, 509, 1343, 12, 1284, 315, 284, 2587, 63, 11681, 14, 1623, 63, 528, 2393, 8, 10654, 63, 513, 12, 4897, 63, 2373, 14, 500, 304, 272, 1343, 275, 1343, 435, 1249, 14, 9650, 272, 1284, 275, 1284, 446, 1249, 14, 9650, 272, 340, 1284, 2695, 1343, 26, 267, 1980, 272, 367, 620, 460, 315, 620, 5915, 26, 267, 486, 556, 19, 63, 2373, 275, 598, 556, 19, 3900, 2561, 288, 298, 3610, 63, 344, 2, 520, 4897, 63, 2373, 14, 3610, 63, 344, 12, 288, 298, 1365, 2, 520, 298, 1277, 50, 401, 288, 298, 4445, 2, 520, 298, 1277, 50, 401, 288, 298, 928, 2, 520, 1343, 12, 288, 298, 500, 2, 520, 1284, 12, 288, 298, 3397, 2, 520, 3680, 401, 288, 298, 30964, 2, 520, 620, 460, 12, 288, 298, 6971, 2, 520, 3680, 401, 288, 298, 2987, 2, 520, 298, 998, 29, 1277, 50, 4970, 83, 4970, 83, 63, 475, 4970, 83, 2, 450, 334, 490, 4897, 63, 2373, 14, 3610, 63, 344, 12, 1343, 12, 1284, 11466, 267, 1249, 14, 1199, 63, 493, 14, 952, 8, 495, 8, 71, 556, 19, 63, 2373, 9, 435, 1867, 78, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Panaetius/woipv
src/models/train_model.py
1
20953
import tensorflow as tf from tensorflow.python.client import timeline from tensorflow.python import debug as tf_debug import os import time from datetime import datetime import numpy as np from model import WoipvModel, NetworkType from mscoco_input import MSCOCOInputProducer FLAGS = tf.app.flags.FLAGS tf.app.flags.DEFINE_string('train_dir', '/training/woipv_train', """Directory where to write event logs """ """and checkpoint.""") tf.app.flags.DEFINE_integer('max_steps', 1000000, """Number of batches to run.""") tf.app.flags.DEFINE_boolean('log_device_placement', False, """Whether to log device placement.""") class Config(object): path = "%s/../../data/processed/MSCOCO/" % os.path.dirname( os.path.realpath(__file__)) chkpt_path = "%s/../../models/transfer_chkpt/" % os.path.dirname( os.path.realpath(__file__)) num_examples_per_epoch = 72000 num_epochs_per_decay = 3 is_training = True num_classes = 90 initial_learning_rate = 1e-4 learning_rate_decay_factor = 0.25 width = 600 height = 600 min_box_size = 10 rcnn_cls_loss_weight = 95.0 / (256) rcnn_reg_loss_weight = 0.005 rpn_cls_loss_weight = 2.0 rpn_reg_loss_weight = 25.0 dropout_prob = 0.5 weight_decay = 0.0001 net = NetworkType.PRETRAINED pretrained_checkpoint_path = "%s/../../models/pretrained/"% os.path.dirname( os.path.realpath(__file__)) pretrained_checkpoint_meta = "ResNet-L50.meta" restore_from_chkpt = False resnet_34_variables_to_restore = ['first_layer/weights:0', 'first_layer/Variable:0', 'first_layer/Variable_1:0', 'first_layer/Variable_2:0', 'first_layer/Variable_3:0', 'reslayer_64_0/sub1/weights:0', 'reslayer_64_0/sub1/Variable:0', 'reslayer_64_0/sub1/Variable_1:0', 'reslayer_64_0/sub1/Variable_2:0', 'reslayer_64_0/sub1/Variable_3:0', 'reslayer_64_0/sub2/weights:0', 'reslayer_64_0/sub2/Variable:0', 'reslayer_64_0/sub2/Variable_1:0', 'reslayer_64_0/sub2/Variable_2:0', 'reslayer_64_0/sub2/Variable_3:0', 'reslayer_64_1/sub1/weights:0', 'reslayer_64_1/sub1/Variable:0', 'reslayer_64_1/sub1/Variable_1:0', 'reslayer_64_1/sub1/Variable_2:0', 'reslayer_64_1/sub1/Variable_3:0', 'reslayer_64_1/sub2/weights:0', 'reslayer_64_1/sub2/Variable:0', 'reslayer_64_1/sub2/Variable_1:0', 'reslayer_64_1/sub2/Variable_2:0', 'reslayer_64_1/sub2/Variable_3:0', 'reslayer_64_2/sub1/weights:0', 'reslayer_64_2/sub1/Variable:0', 'reslayer_64_2/sub1/Variable_1:0', 'reslayer_64_2/sub1/Variable_2:0', 'reslayer_64_2/sub1/Variable_3:0', 'reslayer_64_2/sub2/weights:0', 'reslayer_64_2/sub2/Variable:0', 'reslayer_64_2/sub2/Variable_1:0', 'reslayer_64_2/sub2/Variable_2:0', 'reslayer_64_2/sub2/Variable_3:0', 'reslayer_downsample_128/sub1/weights:0', 'reslayer_downsample_128/sub1/Variable:0', 'reslayer_downsample_128/sub1/Variable_1:0', 'reslayer_downsample_128/sub1/Variable_2:0', 'reslayer_downsample_128/sub1/Variable_3:0', 'reslayer_downsample_128/sub2/weights:0', 'reslayer_downsample_128/sub2/Variable:0', 'reslayer_downsample_128/sub2/Variable_1:0', 'reslayer_downsample_128/sub2/Variable_2:0', 'reslayer_downsample_128/sub2/Variable_3:0', 'reslayer_128_0/sub1/weights:0', 'reslayer_128_0/sub1/Variable:0', 'reslayer_128_0/sub1/Variable_1:0', 'reslayer_128_0/sub1/Variable_2:0', 'reslayer_128_0/sub1/Variable_3:0', 'reslayer_128_0/sub2/weights:0', 'reslayer_128_0/sub2/Variable:0', 'reslayer_128_0/sub2/Variable_1:0', 'reslayer_128_0/sub2/Variable_2:0', 'reslayer_128_0/sub2/Variable_3:0', 'reslayer_128_1/sub1/weights:0', 'reslayer_128_1/sub1/Variable:0', 'reslayer_128_1/sub1/Variable_1:0', 'reslayer_128_1/sub1/Variable_2:0', 'reslayer_128_1/sub1/Variable_3:0', 'reslayer_128_1/sub2/weights:0', 'reslayer_128_1/sub2/Variable:0', 'reslayer_128_1/sub2/Variable_1:0', 'reslayer_128_1/sub2/Variable_2:0', 'reslayer_128_1/sub2/Variable_3:0', 'reslayer_128_2/sub1/weights:0', 'reslayer_128_2/sub1/Variable:0', 'reslayer_128_2/sub1/Variable_1:0', 'reslayer_128_2/sub1/Variable_2:0', 'reslayer_128_2/sub1/Variable_3:0', 'reslayer_128_2/sub2/weights:0', 'reslayer_128_2/sub2/Variable:0', 'reslayer_128_2/sub2/Variable_1:0', 'reslayer_128_2/sub2/Variable_2:0', 'reslayer_128_2/sub2/Variable_3:0', 'reslayer_downsample_256/sub1/weights:0', 'reslayer_downsample_256/sub1/Variable:0', 'reslayer_downsample_256/sub1/Variable_1:0', 'reslayer_downsample_256/sub1/Variable_2:0', 'reslayer_downsample_256/sub1/Variable_3:0', 'reslayer_downsample_256/sub2/weights:0', 'reslayer_downsample_256/sub2/Variable:0', 'reslayer_downsample_256/sub2/Variable_1:0', 'reslayer_downsample_256/sub2/Variable_2:0', 'reslayer_downsample_256/sub2/Variable_3:0', 'reslayer_256_0/sub1/weights:0', 'reslayer_256_0/sub1/Variable:0', 'reslayer_256_0/sub1/Variable_1:0', 'reslayer_256_0/sub1/Variable_2:0', 'reslayer_256_0/sub1/Variable_3:0', 'reslayer_256_0/sub2/weights:0', 'reslayer_256_0/sub2/Variable:0', 'reslayer_256_0/sub2/Variable_1:0', 'reslayer_256_0/sub2/Variable_2:0', 'reslayer_256_0/sub2/Variable_3:0', 'reslayer_256_1/sub1/weights:0', 'reslayer_256_1/sub1/Variable:0', 'reslayer_256_1/sub1/Variable_1:0', 'reslayer_256_1/sub1/Variable_2:0', 'reslayer_256_1/sub1/Variable_3:0', 'reslayer_256_1/sub2/weights:0', 'reslayer_256_1/sub2/Variable:0', 'reslayer_256_1/sub2/Variable_1:0', 'reslayer_256_1/sub2/Variable_2:0', 'reslayer_256_1/sub2/Variable_3:0', 'reslayer_256_2/sub1/weights:0', 'reslayer_256_2/sub1/Variable:0', 'reslayer_256_2/sub1/Variable_1:0', 'reslayer_256_2/sub1/Variable_2:0', 'reslayer_256_2/sub1/Variable_3:0', 'reslayer_256_2/sub2/weights:0', 'reslayer_256_2/sub2/Variable:0', 'reslayer_256_2/sub2/Variable_1:0', 'reslayer_256_2/sub2/Variable_2:0', 'reslayer_256_2/sub2/Variable_3:0', 'reslayer_256_3/sub1/weights:0', 'reslayer_256_3/sub1/Variable:0', 'reslayer_256_3/sub1/Variable_1:0', 'reslayer_256_3/sub1/Variable_2:0', 'reslayer_256_3/sub1/Variable_3:0', 'reslayer_256_3/sub2/weights:0', 'reslayer_256_3/sub2/Variable:0', 'reslayer_256_3/sub2/Variable_1:0', 'reslayer_256_3/sub2/Variable_2:0', 'reslayer_256_3/sub2/Variable_3:0', 'reslayer_256_4/sub1/weights:0', 'reslayer_256_4/sub1/Variable:0', 'reslayer_256_4/sub1/Variable_1:0', 'reslayer_256_4/sub1/Variable_2:0', 'reslayer_256_4/sub1/Variable_3:0', 'reslayer_256_4/sub2/weights:0', 'reslayer_256_4/sub2/Variable:0', 'reslayer_256_4/sub2/Variable_1:0', 'reslayer_256_4/sub2/Variable_2:0', 'reslayer_256_4/sub2/Variable_3:0', 'reslayer_downsample_512/sub1/weights:0', 'reslayer_downsample_512/sub1/Variable:0', 'reslayer_downsample_512/sub1/Variable_1:0', 'reslayer_downsample_512/sub1/Variable_2:0', 'reslayer_downsample_512/sub1/Variable_3:0', 'reslayer_downsample_512/sub2/weights:0', 'reslayer_downsample_512/sub2/Variable:0', 'reslayer_downsample_512/sub2/Variable_1:0', 'reslayer_downsample_512/sub2/Variable_2:0', 'reslayer_downsample_512/sub2/Variable_3:0', 'reslayer_512_0/sub1/weights:0', 'reslayer_512_0/sub1/Variable:0', 'reslayer_512_0/sub1/Variable_1:0', 'reslayer_512_0/sub1/Variable_2:0', 'reslayer_512_0/sub1/Variable_3:0', 'reslayer_512_0/sub2/weights:0', 'reslayer_512_0/sub2/Variable:0', 'reslayer_512_0/sub2/Variable_1:0', 'reslayer_512_0/sub2/Variable_2:0', 'reslayer_512_0/sub2/Variable_3:0', 'reslayer_512_1/sub1/weights:0', 'reslayer_512_1/sub1/Variable:0', 'reslayer_512_1/sub1/Variable_1:0', 'reslayer_512_1/sub1/Variable_2:0', 'reslayer_512_1/sub1/Variable_3:0', 'reslayer_512_1/sub2/weights:0', 'reslayer_512_1/sub2/Variable:0', 'reslayer_512_1/sub2/Variable_1:0', 'reslayer_512_1/sub2/Variable_2:0', 'reslayer_512_1/sub2/Variable_3:0'] resnet_50_variables_to_restore = ['first_layer/weights:0', 'first_layer/Variable:0', 'first_layer/Variable_1:0', 'first_layer/Variable_2:0', 'first_layer/Variable_3:0', 'reslayer_64_0/sub1/weights:0', 'reslayer_64_0/sub1/Variable:0', 'reslayer_64_0/sub1/Variable_1:0', 'reslayer_64_0/sub1/Variable_2:0', 'reslayer_64_0/sub1/Variable_3:0', 'reslayer_64_0/sub2/weights:0', 'reslayer_64_0/sub2/Variable:0', 'reslayer_64_0/sub2/Variable_1:0', 'reslayer_64_0/sub2/Variable_2:0', 'reslayer_64_0/sub2/Variable_3:0', 'reslayer_64_1/sub1/weights:0', 'reslayer_64_1/sub1/Variable:0', 'reslayer_64_1/sub1/Variable_1:0', 'reslayer_64_1/sub1/Variable_2:0', 'reslayer_64_1/sub1/Variable_3:0', 'reslayer_64_1/sub2/weights:0', 'reslayer_64_1/sub2/Variable:0', 'reslayer_64_1/sub2/Variable_1:0', 'reslayer_64_1/sub2/Variable_2:0', 'reslayer_64_1/sub2/Variable_3:0', 'reslayer_64_2/sub1/weights:0', 'reslayer_64_2/sub1/Variable:0', 'reslayer_64_2/sub1/Variable_1:0', 'reslayer_64_2/sub1/Variable_2:0', 'reslayer_64_2/sub1/Variable_3:0', 'reslayer_64_2/sub2/weights:0', 'reslayer_64_2/sub2/Variable:0', 'reslayer_64_2/sub2/Variable_1:0', 'reslayer_64_2/sub2/Variable_2:0', 'reslayer_64_2/sub2/Variable_3:0', 'reslayer_downsample_128/sub1/weights:0', 'reslayer_downsample_128/sub1/Variable:0', 'reslayer_downsample_128/sub1/Variable_1:0', 'reslayer_downsample_128/sub1/Variable_2:0', 'reslayer_downsample_128/sub1/Variable_3:0', 'reslayer_downsample_128/sub2/weights:0', 'reslayer_downsample_128/sub2/Variable:0', 'reslayer_downsample_128/sub2/Variable_1:0', 'reslayer_downsample_128/sub2/Variable_2:0', 'reslayer_downsample_128/sub2/Variable_3:0', 'reslayer_128_0/sub1/weights:0', 'reslayer_128_0/sub1/Variable:0', 'reslayer_128_0/sub1/Variable_1:0', 'reslayer_128_0/sub1/Variable_2:0', 'reslayer_128_0/sub1/Variable_3:0', 'reslayer_128_0/sub2/weights:0', 'reslayer_128_0/sub2/Variable:0', 'reslayer_128_0/sub2/Variable_1:0', 'reslayer_128_0/sub2/Variable_2:0', 'reslayer_128_0/sub2/Variable_3:0', 'reslayer_128_1/sub1/weights:0', 'reslayer_128_1/sub1/Variable:0', 'reslayer_128_1/sub1/Variable_1:0', 'reslayer_128_1/sub1/Variable_2:0', 'reslayer_128_1/sub1/Variable_3:0', 'reslayer_128_1/sub2/weights:0', 'reslayer_128_1/sub2/Variable:0', 'reslayer_128_1/sub2/Variable_1:0', 'reslayer_128_1/sub2/Variable_2:0', 'reslayer_128_1/sub2/Variable_3:0', 'reslayer_128_2/sub1/weights:0', 'reslayer_128_2/sub1/Variable:0', 'reslayer_128_2/sub1/Variable_1:0', 'reslayer_128_2/sub1/Variable_2:0', 'reslayer_128_2/sub1/Variable_3:0', 'reslayer_128_2/sub2/weights:0', 'reslayer_128_2/sub2/Variable:0', 'reslayer_128_2/sub2/Variable_1:0', 'reslayer_128_2/sub2/Variable_2:0', 'reslayer_128_2/sub2/Variable_3:0', 'reslayer_downsample_256/sub1/weights:0', 'reslayer_downsample_256/sub1/Variable:0', 'reslayer_downsample_256/sub1/Variable_1:0', 'reslayer_downsample_256/sub1/Variable_2:0', 'reslayer_downsample_256/sub1/Variable_3:0', 'reslayer_downsample_256/sub2/weights:0', 'reslayer_downsample_256/sub2/Variable:0', 'reslayer_downsample_256/sub2/Variable_1:0', 'reslayer_downsample_256/sub2/Variable_2:0', 'reslayer_downsample_256/sub2/Variable_3:0', 'reslayer_256_0/sub1/weights:0', 'reslayer_256_0/sub1/Variable:0', 'reslayer_256_0/sub1/Variable_1:0', 'reslayer_256_0/sub1/Variable_2:0', 'reslayer_256_0/sub1/Variable_3:0', 'reslayer_256_0/sub2/weights:0', 'reslayer_256_0/sub2/Variable:0', 'reslayer_256_0/sub2/Variable_1:0', 'reslayer_256_0/sub2/Variable_2:0', 'reslayer_256_0/sub2/Variable_3:0', 'reslayer_256_1/sub1/weights:0', 'reslayer_256_1/sub1/Variable:0', 'reslayer_256_1/sub1/Variable_1:0', 'reslayer_256_1/sub1/Variable_2:0', 'reslayer_256_1/sub1/Variable_3:0', 'reslayer_256_1/sub2/weights:0', 'reslayer_256_1/sub2/Variable:0', 'reslayer_256_1/sub2/Variable_1:0', 'reslayer_256_1/sub2/Variable_2:0', 'reslayer_256_1/sub2/Variable_3:0', 'reslayer_256_2/sub1/weights:0', 'reslayer_256_2/sub1/Variable:0', 'reslayer_256_2/sub1/Variable_1:0', 'reslayer_256_2/sub1/Variable_2:0', 'reslayer_256_2/sub1/Variable_3:0', 'reslayer_256_2/sub2/weights:0', 'reslayer_256_2/sub2/Variable:0', 'reslayer_256_2/sub2/Variable_1:0', 'reslayer_256_2/sub2/Variable_2:0', 'reslayer_256_2/sub2/Variable_3:0', 'reslayer_256_3/sub1/weights:0', 'reslayer_256_3/sub1/Variable:0', 'reslayer_256_3/sub1/Variable_1:0', 'reslayer_256_3/sub1/Variable_2:0', 'reslayer_256_3/sub1/Variable_3:0', 'reslayer_256_3/sub2/weights:0', 'reslayer_256_3/sub2/Variable:0', 'reslayer_256_3/sub2/Variable_1:0', 'reslayer_256_3/sub2/Variable_2:0', 'reslayer_256_3/sub2/Variable_3:0', 'reslayer_256_4/sub1/weights:0', 'reslayer_256_4/sub1/Variable:0', 'reslayer_256_4/sub1/Variable_1:0', 'reslayer_256_4/sub1/Variable_2:0', 'reslayer_256_4/sub1/Variable_3:0', 'reslayer_256_4/sub2/weights:0', 'reslayer_256_4/sub2/Variable:0', 'reslayer_256_4/sub2/Variable_1:0', 'reslayer_256_4/sub2/Variable_2:0', 'reslayer_256_4/sub2/Variable_3:0', 'reslayer_downsample_512/sub1/weights:0', 'reslayer_downsample_512/sub1/Variable:0', 'reslayer_downsample_512/sub1/Variable_1:0', 'reslayer_downsample_512/sub1/Variable_2:0', 'reslayer_downsample_512/sub1/Variable_3:0', 'reslayer_downsample_512/sub2/weights:0', 'reslayer_downsample_512/sub2/Variable:0', 'reslayer_downsample_512/sub2/Variable_1:0', 'reslayer_downsample_512/sub2/Variable_2:0', 'reslayer_downsample_512/sub2/Variable_3:0', 'reslayer_512_0/sub1/weights:0', 'reslayer_512_0/sub1/Variable:0', 'reslayer_512_0/sub1/Variable_1:0', 'reslayer_512_0/sub1/Variable_2:0', 'reslayer_512_0/sub1/Variable_3:0', 'reslayer_512_0/sub2/weights:0', 'reslayer_512_0/sub2/Variable:0', 'reslayer_512_0/sub2/Variable_1:0', 'reslayer_512_0/sub2/Variable_2:0', 'reslayer_512_0/sub2/Variable_3:0', 'reslayer_512_1/sub1/weights:0', 'reslayer_512_1/sub1/Variable:0', 'reslayer_512_1/sub1/Variable_1:0', 'reslayer_512_1/sub1/Variable_2:0', 'reslayer_512_1/sub1/Variable_3:0', 'reslayer_512_1/sub2/weights:0', 'reslayer_512_1/sub2/Variable:0', 'reslayer_512_1/sub2/Variable_1:0', 'reslayer_512_1/sub2/Variable_2:0', 'reslayer_512_1/sub2/Variable_3:0'] graph = tf.Graph() def train(): """Train ip5wke for a number of steps.""" print("Building graph %.3f" % time.time()) cfg = Config() with cfg.graph.as_default(): # Get images and labels for ip5wke. input_producer = MSCOCOInputProducer(cfg) images, categories, bboxes = input_producer.inputs() model = WoipvModel(cfg) config = tf.ConfigProto(log_device_placement=FLAGS.log_device_placement) config.gpu_options.allow_growth = True sess = tf.Session(config=config) conv_output = None if cfg.net == NetworkType.PRETRAINED: print("restoring pretrained model") new_saver = tf.train.import_meta_graph(cfg.pretrained_checkpoint_path + cfg.pretrained_checkpoint_meta, input_map={'images': images}) new_saver.restore(sess, tf.train.latest_checkpoint(cfg.pretrained_checkpoint_path)) conv_output = cfg.graph.get_tensor_by_name('scale4/block6/Relu:0') print(conv_output) global_step = tf.Variable(0, trainable=False, name="global_step") # Build a Graph that computes the logits predictions from the # inference model. class_scores, region_scores, rpn_class_scores, rpn_region_scores, \ proposed_boxes = \ model.inference(images, conv_output) # Calculate loss. loss, rcn_accuracy, rpn_accuracy = model.loss(class_scores, region_scores, rpn_class_scores, rpn_region_scores, categories, bboxes, proposed_boxes, images) # Build a Graph that trains the model with one batch of examples and # updates the model parameters. train_op = model.train(loss, global_step) # Create a saver. saver = tf.train.Saver(tf.global_variables(), write_version=tf.train.SaverDef.V2) # Build the summary operation based on the TF collection of Summaries. summary_op = tf.summary.merge_all() # Build an initialization operation to run below. init = tf.global_variables_initializer() # Start running operations on the Graph. print("Running init %.3f" % time.time()) # sess = tf_debug.LocalCLIDebugWrapperSession(sess) sess.run(init) if cfg.restore_from_chkpt: # restore variables (for transfer learning) print("Restoring checkpoint for transfer learning %.3f" % time.time()) ckpt = tf.train.get_checkpoint_state(cfg.chkpt_path) ckpt_name = os.path.basename(ckpt.model_checkpoint_path) if self.net == NetworkType.RESNET34: variables_to_restore = self.resnet_34_variables_to_restore elif self.net == NetworkType.RESNET50: variables_to_restore = self.resnet_50_variables_to_restore variables_to_restore = [v for v in tf.global_variables() if v.name in cfg.variables_to_restore] chkpt_saver = tf.train.Saver(variables_to_restore, write_version=tf.train.SaverDef.V2) chkpt_saver.restore(sess, ckpt.model_checkpoint_path) print("checkpoint restored %.3f" % time.time()) # Start the queue runners. coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(sess=sess, coord=coord) summary_writer = tf.summary.FileWriter(FLAGS.train_dir, sess.graph) # run_metadata = tf.RunMetadata() print("Started training %.3f" % time.time()) for step in range(FLAGS.max_steps): start_time = time.time() _, loss_value = sess.run([train_op, loss]) # options=tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE), # run_metadata=run_metadata) duration = time.time() - start_time assert not np.isnan(loss_value), 'Model diverged with loss = NaN' #tf.contrib.tfprof.model_analyzer.print_model_analysis( # tf.get_default_graph(), # run_meta=run_metadata, # tfprof_options={ # 'max_depth': 10000, # 'min_bytes': 1, # Only >=1 # 'min_micros': 1, # Only >=1 # 'min_params': 0, # 'min_float_ops': 0, # 'device_regexes': ['.*'], # 'order_by': 'name', # 'account_type_regexes': ['.*'], # 'start_name_regexes': ['.*'], # 'trim_name_regexes': [], # 'show_name_regexes': ['.*'], # 'hide_name_regexes': [], # 'account_displayed_op_only': True, # 'select': ['micros'], # 'viz': False, # 'dump_to_file': '' # }) #return if step % 50 == 0: examples_per_sec = 1.0 / duration sec_per_batch = float(duration) # correct_prediction = tf.equal(tf.argmax(logits, 1), # tf.cast(labels, tf.int64)) # accuracy = tf.reduce_mean(tf.cast(correct_prediction, # tf.float32)) # train_acc = sess.run(accuracy) # tf.summary.scalar('accuracy', accuracy) # trace = timeline.Timeline(step_stats=run_metadata.step_stats) # trace_file = open('timeline.ctf.json', 'w') # trace_file.write(trace.generate_chrome_trace_format(show_memory=True)) # trace_file.close() rcn_acc, rpn_acc = sess.run([rcn_accuracy, rpn_accuracy]) format_str = ('%s: step %d, loss = %.2f, rcn_accuracy = %.3f ' ' rpn_acc = %.3f (%.1f examples/sec; %.3f ' 'sec/batch)') print(format_str % (datetime.now(), step, loss_value, rcn_acc, rpn_acc, examples_per_sec, sec_per_batch)) summary_str = sess.run(summary_op) summary_writer.add_summary(summary_str, step) # Save the model checkpoint periodically. if step % 1000 == 0 or (step + 1) == FLAGS.max_steps: checkpoint_path = os.path.join(FLAGS.train_dir, 'model.ckpt') saver.save(sess, checkpoint_path, global_step=step) # When done, ask the threads to stop. coord.request_stop() # Wait for threads to finish. coord.join(threads) # noinspection PyUnusedLocal def main(argv=None): if tf.gfile.Exists(FLAGS.train_dir): tf.gfile.DeleteRecursively(FLAGS.train_dir) tf.gfile.MakeDirs(FLAGS.train_dir) train() if __name__ == '__main__': tf.app.run()
mit
[ 646, 3228, 465, 2833, 202, 199, 504, 3228, 14, 1548, 14, 1258, 492, 20780, 202, 199, 504, 3228, 14, 1548, 492, 3105, 465, 2833, 63, 1757, 202, 199, 646, 747, 202, 199, 646, 900, 202, 199, 504, 2197, 492, 2197, 202, 199, 646, 2680, 465, 980, 2999, 199, 504, 1402, 492, 644, 79, 4774, 1685, 12, 7220, 804, 202, 199, 504, 6605, 331, 331, 63, 1210, 492, 14282, 1439, 1439, 3205, 15532, 2999, 199, 4831, 275, 2833, 14, 571, 14, 2469, 14, 4831, 2999, 199, 3249, 14, 571, 14, 2469, 14, 14603, 63, 875, 360, 2834, 63, 694, 297, 1994, 7588, 15, 2027, 4774, 63, 2834, 297, 202, 2574, 408, 6231, 2382, 370, 2218, 1566, 9610, 408, 202, 2574, 408, 460, 9997, 24887, 202, 199, 3249, 14, 571, 14, 2469, 14, 14603, 63, 4115, 360, 988, 63, 5895, 297, 19492, 12, 15372, 408, 3259, 402, 19593, 370, 1255, 24887, 202, 199, 3249, 14, 571, 14, 2469, 14, 14603, 63, 4871, 360, 793, 63, 1782, 63, 16748, 297, 756, 12, 15372, 408, 26625, 370, 943, 2243, 22286, 24887, 2999, 199, 533, 4094, 8, 785, 304, 1128, 931, 275, 2071, 83, 15, 9707, 576, 15, 7292, 15, 3053, 1439, 1439, 6687, 450, 747, 14, 515, 14, 3475, 8, 1675, 747, 14, 515, 14, 11091, 3460, 493, 8964, 1128, 26979, 541, 63, 515, 275, 2071, 83, 15, 9707, 992, 15, 9609, 63, 14823, 541, 6687, 450, 747, 14, 515, 14, 3475, 8, 1675, 747, 14, 515, 14, 11091, 3460, 493, 8964, 1128, 1967, 63, 8589, 63, 529, 63, 7367, 275, 1520, 8269, 1128, 1967, 63, 13161, 63, 529, 63, 16889, 275, 650, 1128, 365, 63, 7588, 275, 715, 1128, 1967, 63, 2888, 275, 9137, 1128, 2536, 63, 10546, 63, 1866, 275, 413, 69, 13, 20, 1128, 9328, 63, 1866, 63, 16889, 63, 4778, 275, 378, 14, 821, 1128, 3462, 275, 11624, 1128, 4569, 275, 11624, 1128, 1748, 63, 1977, 63, 890, 275, 1616, 1128, 4819, 4411, 63, 1886, 63, 4358, 63, 3463, 275, 16102, 14, 16, 1182, 334, 3912, 9, 1128, 4819, 4411, 63, 1135, 63, 4358, 63, 3463, 275, 378, 14, 7972, 1128, 519, 4812, 63, 1886, 63, 4358, 63, 3463, 275, 499, 14, 16, 1128, 519, 4812, 63, 1135, 63, 4358, 63, 3463, 275, 5661, 14, 16, 1128, 19795, 63, 6101, 275, 378, 14, 21, 1128, 5401, 63, 16889, 275, 378, 14, 4183, 1128, 1851, 275, 7220, 804, 14, 3311, 775, 21715, 1149, 1128, 876, 23782, 63, 10109, 63, 515, 275, 2071, 83, 15, 9707, 992, 15, 657, 23782, 6687, 5, 747, 14, 515, 14, 3475, 8, 1675, 747, 14, 515, 14, 11091, 3460, 493, 8964, 1128, 876, 23782, 63, 10109, 63, 2024, 275, 298, 1322, 2480, 13, 44, 1400, 14, 2024, 2, 1128, 9066, 63, 504, 63, 14823, 541, 275, 756, 1128, 522, 846, 63, 1082, 63, 3669, 63, 475, 63, 8011, 275, 788, 2246, 63, 1897, 15, 4916, 26, 16, 297, 283, 2246, 63, 1897, 15, 2773, 26, 16, 297, 283, 2246, 63, 1897, 15, 2773, 63, 17, 26, 16, 297, 283, 2246, 63, 1897, 15, 2773, 63, 18, 26, 16, 297, 283, 2246, 63, 1897, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 17, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 17, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 17, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 17, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 17, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 18, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 18, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 18, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 18, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 18, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 17, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 17, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 17, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 17, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 17, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 18, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 18, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 18, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 18, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 18, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 17, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 17, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 17, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 17, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 17, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 18, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 18, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 18, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 18, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 18, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 68, 23311, 865, 63, 3933, 15, 954, 17, 15, 4916 ]
[ 3228, 465, 2833, 202, 199, 504, 3228, 14, 1548, 14, 1258, 492, 20780, 202, 199, 504, 3228, 14, 1548, 492, 3105, 465, 2833, 63, 1757, 202, 199, 646, 747, 202, 199, 646, 900, 202, 199, 504, 2197, 492, 2197, 202, 199, 646, 2680, 465, 980, 2999, 199, 504, 1402, 492, 644, 79, 4774, 1685, 12, 7220, 804, 202, 199, 504, 6605, 331, 331, 63, 1210, 492, 14282, 1439, 1439, 3205, 15532, 2999, 199, 4831, 275, 2833, 14, 571, 14, 2469, 14, 4831, 2999, 199, 3249, 14, 571, 14, 2469, 14, 14603, 63, 875, 360, 2834, 63, 694, 297, 1994, 7588, 15, 2027, 4774, 63, 2834, 297, 202, 2574, 408, 6231, 2382, 370, 2218, 1566, 9610, 408, 202, 2574, 408, 460, 9997, 24887, 202, 199, 3249, 14, 571, 14, 2469, 14, 14603, 63, 4115, 360, 988, 63, 5895, 297, 19492, 12, 15372, 408, 3259, 402, 19593, 370, 1255, 24887, 202, 199, 3249, 14, 571, 14, 2469, 14, 14603, 63, 4871, 360, 793, 63, 1782, 63, 16748, 297, 756, 12, 15372, 408, 26625, 370, 943, 2243, 22286, 24887, 2999, 199, 533, 4094, 8, 785, 304, 1128, 931, 275, 2071, 83, 15, 9707, 576, 15, 7292, 15, 3053, 1439, 1439, 6687, 450, 747, 14, 515, 14, 3475, 8, 1675, 747, 14, 515, 14, 11091, 3460, 493, 8964, 1128, 26979, 541, 63, 515, 275, 2071, 83, 15, 9707, 992, 15, 9609, 63, 14823, 541, 6687, 450, 747, 14, 515, 14, 3475, 8, 1675, 747, 14, 515, 14, 11091, 3460, 493, 8964, 1128, 1967, 63, 8589, 63, 529, 63, 7367, 275, 1520, 8269, 1128, 1967, 63, 13161, 63, 529, 63, 16889, 275, 650, 1128, 365, 63, 7588, 275, 715, 1128, 1967, 63, 2888, 275, 9137, 1128, 2536, 63, 10546, 63, 1866, 275, 413, 69, 13, 20, 1128, 9328, 63, 1866, 63, 16889, 63, 4778, 275, 378, 14, 821, 1128, 3462, 275, 11624, 1128, 4569, 275, 11624, 1128, 1748, 63, 1977, 63, 890, 275, 1616, 1128, 4819, 4411, 63, 1886, 63, 4358, 63, 3463, 275, 16102, 14, 16, 1182, 334, 3912, 9, 1128, 4819, 4411, 63, 1135, 63, 4358, 63, 3463, 275, 378, 14, 7972, 1128, 519, 4812, 63, 1886, 63, 4358, 63, 3463, 275, 499, 14, 16, 1128, 519, 4812, 63, 1135, 63, 4358, 63, 3463, 275, 5661, 14, 16, 1128, 19795, 63, 6101, 275, 378, 14, 21, 1128, 5401, 63, 16889, 275, 378, 14, 4183, 1128, 1851, 275, 7220, 804, 14, 3311, 775, 21715, 1149, 1128, 876, 23782, 63, 10109, 63, 515, 275, 2071, 83, 15, 9707, 992, 15, 657, 23782, 6687, 5, 747, 14, 515, 14, 3475, 8, 1675, 747, 14, 515, 14, 11091, 3460, 493, 8964, 1128, 876, 23782, 63, 10109, 63, 2024, 275, 298, 1322, 2480, 13, 44, 1400, 14, 2024, 2, 1128, 9066, 63, 504, 63, 14823, 541, 275, 756, 1128, 522, 846, 63, 1082, 63, 3669, 63, 475, 63, 8011, 275, 788, 2246, 63, 1897, 15, 4916, 26, 16, 297, 283, 2246, 63, 1897, 15, 2773, 26, 16, 297, 283, 2246, 63, 1897, 15, 2773, 63, 17, 26, 16, 297, 283, 2246, 63, 1897, 15, 2773, 63, 18, 26, 16, 297, 283, 2246, 63, 1897, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 17, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 17, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 17, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 17, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 17, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 18, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 18, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 18, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 18, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 16, 15, 954, 18, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 17, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 17, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 17, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 17, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 17, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 18, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 18, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 18, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 18, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 17, 15, 954, 18, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 17, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 17, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 17, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 17, 15, 2773, 63, 18, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 17, 15, 2773, 63, 19, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 18, 15, 4916, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 18, 15, 2773, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 18, 15, 2773, 63, 17, 26, 16, 297, 283, 470, 1897, 63, 772, 63, 18, 15, 954, 18, 15, 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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 ]
ininex/geofire-python
resource/lib/python2.7/site-packages/gcloud/bigquery/client.py
3
10779
# Copyright 2015 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. """Client for interacting with the Google BigQuery API.""" from gcloud.client import JSONClient from gcloud.bigquery.connection import Connection from gcloud.bigquery.dataset import Dataset from gcloud.bigquery.job import CopyJob from gcloud.bigquery.job import ExtractTableToStorageJob from gcloud.bigquery.job import LoadTableFromStorageJob from gcloud.bigquery.job import QueryJob from gcloud.bigquery.query import QueryResults class Client(JSONClient): """Client to bundle configuration needed for API requests. :type project: str :param project: the project which the client acts on behalf of. Will be passed when creating a dataset / job. If not passed, falls back to the default inferred from the environment. :type credentials: :class:`oauth2client.client.OAuth2Credentials` or :class:`NoneType` :param credentials: The OAuth2 Credentials to use for the connection owned by this client. If not passed (and if no ``http`` object is passed), falls back to the default inferred from the environment. :type http: :class:`httplib2.Http` or class that defines ``request()``. :param http: An optional HTTP object to make requests. If not passed, an ``http`` object is created that is bound to the ``credentials`` for the current object. """ _connection_class = Connection def list_datasets(self, include_all=False, max_results=None, page_token=None): """List datasets for the project associated with this client. See: https://cloud.google.com/bigquery/docs/reference/v2/datasets/list :type include_all: boolean :param include_all: True if results include hidden datasets. :type max_results: int :param max_results: maximum number of datasets to return, If not passed, defaults to a value set by the API. :type page_token: str :param page_token: opaque marker for the next "page" of datasets. If not passed, the API will return the first page of datasets. :rtype: tuple, (list, str) :returns: list of :class:`gcloud.bigquery.dataset.Dataset`, plus a "next page token" string: if the token is not None, indicates that more datasets can be retrieved with another call (pass that value as ``page_token``). """ params = {} if include_all: params['all'] = True if max_results is not None: params['maxResults'] = max_results if page_token is not None: params['pageToken'] = page_token path = '/projects/%s/datasets' % (self.project,) resp = self.connection.api_request(method='GET', path=path, query_params=params) datasets = [Dataset.from_api_repr(resource, self) for resource in resp.get('datasets', ())] return datasets, resp.get('nextPageToken') def dataset(self, dataset_name): """Construct a dataset bound to this client. :type dataset_name: str :param dataset_name: Name of the dataset. :rtype: :class:`gcloud.bigquery.dataset.Dataset` :returns: a new ``Dataset`` instance """ return Dataset(dataset_name, client=self) def job_from_resource(self, resource): """Detect correct job type from resource and instantiate. :type resource: dict :param resource: one job resource from API response :rtype: One of: :class:`gcloud.bigquery.job.LoadTableFromStorageJob`, :class:`gcloud.bigquery.job.CopyJob`, :class:`gcloud.bigquery.job.ExtractTableToStorageJob`, :class:`gcloud.bigquery.job.QueryJob`, :class:`gcloud.bigquery.job.RunSyncQueryJob` :returns: the job instance, constructed via the resource """ config = resource['configuration'] if 'load' in config: return LoadTableFromStorageJob.from_api_repr(resource, self) elif 'copy' in config: return CopyJob.from_api_repr(resource, self) elif 'extract' in config: return ExtractTableToStorageJob.from_api_repr(resource, self) elif 'query' in config: return QueryJob.from_api_repr(resource, self) raise ValueError('Cannot parse job resource') def list_jobs(self, max_results=None, page_token=None, all_users=None, state_filter=None): """List jobs for the project associated with this client. See: https://cloud.google.com/bigquery/docs/reference/v2/jobs/list :type max_results: int :param max_results: maximum number of jobs to return, If not passed, defaults to a value set by the API. :type page_token: str :param page_token: opaque marker for the next "page" of jobs. If not passed, the API will return the first page of jobs. :type all_users: boolean :param all_users: if true, include jobs owned by all users in the project. :type state_filter: str :param state_filter: if passed, include only jobs matching the given state. One of * ``"done"`` * ``"pending"`` * ``"running"`` :rtype: tuple, (list, str) :returns: list of job instances, plus a "next page token" string: if the token is not ``None``, indicates that more jobs can be retrieved with another call, passing that value as ``page_token``). """ params = {'projection': 'full'} if max_results is not None: params['maxResults'] = max_results if page_token is not None: params['pageToken'] = page_token if all_users is not None: params['allUsers'] = all_users if state_filter is not None: params['stateFilter'] = state_filter path = '/projects/%s/jobs' % (self.project,) resp = self.connection.api_request(method='GET', path=path, query_params=params) jobs = [self.job_from_resource(resource) for resource in resp['jobs']] return jobs, resp.get('nextPageToken') def load_table_from_storage(self, job_name, destination, *source_uris): """Construct a job for loading data into a table from CloudStorage. See: https://cloud.google.com/bigquery/docs/reference/v2/jobs#configuration.load :type job_name: str :param job_name: Name of the job. :type destination: :class:`gcloud.bigquery.table.Table` :param destination: Table into which data is to be loaded. :type source_uris: sequence of string :param source_uris: URIs of data files to be loaded; in format ``gs://<bucket_name>/<object_name_or_glob>``. :rtype: :class:`gcloud.bigquery.job.LoadTableFromStorageJob` :returns: a new ``LoadTableFromStorageJob`` instance """ return LoadTableFromStorageJob(job_name, destination, source_uris, client=self) def copy_table(self, job_name, destination, *sources): """Construct a job for copying one or more tables into another table. See: https://cloud.google.com/bigquery/docs/reference/v2/jobs#configuration.copy :type job_name: str :param job_name: Name of the job. :type destination: :class:`gcloud.bigquery.table.Table` :param destination: Table into which data is to be copied. :type sources: sequence of :class:`gcloud.bigquery.table.Table` :param sources: tables to be copied. :rtype: :class:`gcloud.bigquery.job.CopyJob` :returns: a new ``CopyJob`` instance """ return CopyJob(job_name, destination, sources, client=self) def extract_table_to_storage(self, job_name, source, *destination_uris): """Construct a job for extracting a table into Cloud Storage files. See: https://cloud.google.com/bigquery/docs/reference/v2/jobs#configuration.extract :type job_name: str :param job_name: Name of the job. :type source: :class:`gcloud.bigquery.table.Table` :param source: table to be extracted. :type destination_uris: sequence of string :param destination_uris: URIs of CloudStorage file(s) into which table data is to be extracted; in format ``gs://<bucket_name>/<object_name_or_glob>``. :rtype: :class:`gcloud.bigquery.job.ExtractTableToStorageJob` :returns: a new ``ExtractTableToStorageJob`` instance """ return ExtractTableToStorageJob(job_name, source, destination_uris, client=self) def run_async_query(self, job_name, query): """Construct a job for running a SQL query asynchronously. See: https://cloud.google.com/bigquery/docs/reference/v2/jobs#configuration.query :type job_name: str :param job_name: Name of the job. :type query: str :param query: SQL query to be executed :rtype: :class:`gcloud.bigquery.job.QueryJob` :returns: a new ``QueryJob`` instance """ return QueryJob(job_name, query, client=self) def run_sync_query(self, query): """Run a SQL query synchronously. :type query: str :param query: SQL query to be executed :rtype: :class:`gcloud.bigquery.query.QueryResults` :returns: a new ``QueryResults`` instance """ return QueryResults(query, client=self)
mit
[ 3, 1898, 6900, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 624, 3041, 367, 17232, 316, 543, 314, 4475, 13123, 3227, 3261, 1041, 421, 199, 504, 486, 4091, 14, 1258, 492, 4840, 3041, 199, 504, 486, 4091, 14, 23256, 14, 2105, 492, 8113, 199, 504, 486, 4091, 14, 23256, 14, 5214, 492, 20284, 199, 504, 486, 4091, 14, 23256, 14, 2423, 492, 11247, 6694, 199, 504, 486, 4091, 14, 23256, 14, 2423, 492, 12892, 3186, 1378, 6408, 6694, 199, 504, 486, 4091, 14, 23256, 14, 2423, 492, 7190, 3186, 2532, 6408, 6694, 199, 504, 486, 4091, 14, 23256, 14, 2423, 492, 8133, 6694, 199, 504, 486, 4091, 14, 23256, 14, 1131, 492, 8133, 6579, 421, 199, 533, 6810, 8, 6243, 3041, 304, 272, 408, 3041, 370, 8844, 2897, 4346, 367, 3261, 4145, 14, 339, 520, 466, 2199, 26, 620, 272, 520, 635, 2199, 26, 314, 2199, 1314, 314, 1890, 17795, 641, 506, 10220, 402, 14, 12823, 506, 490, 3032, 1380, 6425, 282, 4789, 1182, 3906, 14, 221, 982, 440, 3032, 12, 490, 26945, 1771, 370, 314, 849, 22515, 687, 314, 3734, 14, 339, 520, 466, 6235, 26, 520, 533, 1705, 6126, 18, 1258, 14, 1258, 14, 12906, 18, 13428, 64, 503, 2432, 520, 533, 1705, 26855, 64, 272, 520, 635, 6235, 26, 710, 11715, 18, 23934, 370, 675, 367, 314, 1950, 717, 23191, 701, 642, 1890, 14, 982, 440, 3032, 334, 460, 340, 949, 1124, 1014, 1040, 717, 909, 365, 3032, 395, 26945, 1771, 370, 314, 849, 22515, 717, 687, 314, 3734, 14, 339, 520, 466, 1455, 26, 520, 533, 1705, 12942, 18, 14, 5779, 64, 503, 1021, 626, 7890, 1124, 1069, 28566, 272, 520, 635, 1455, 26, 1626, 2716, 3101, 909, 370, 1852, 4145, 14, 982, 440, 3032, 12, 376, 326, 1124, 1014, 1040, 909, 365, 2737, 626, 365, 3914, 370, 314, 326, 1124, 6942, 1040, 367, 314, 1453, 909, 14, 272, 408, 339, 485, 2105, 63, 533, 275, 8113, 339, 347, 769, 63, 12281, 8, 277, 12, 2387, 63, 452, 29, 797, 12, 1390, 63, 2604, 29, 403, 12, 1993, 2034, 63, 1418, 29, 403, 304, 267, 408, 1296, 13148, 367, 314, 2199, 4568, 543, 642, 1890, 14, 398, 1666, 26, 267, 4178, 921, 4091, 14, 3098, 14, 957, 15, 23256, 15, 4757, 15, 4443, 15, 86, 18, 15, 12281, 15, 513, 398, 520, 466, 2387, 63, 452, 26, 5046, 267, 520, 635, 2387, 63, 452, 26, 715, 340, 2058, 2387, 8752, 13148, 14, 398, 520, 466, 1390, 63, 2604, 26, 1109, 267, 520, 635, 1390, 63, 2604, 26, 5696, 1329, 402, 13148, 370, 372, 12, 982, 440, 1169, 3032, 12, 4243, 370, 282, 574, 663, 701, 314, 3261, 14, 398, 520, 466, 2034, 63, 1418, 26, 620, 267, 520, 635, 2034, 63, 1418, 26, 15058, 3608, 367, 314, 2163, 298, 1606, 2, 402, 13148, 14, 982, 2574, 440, 3032, 12, 314, 3261, 911, 372, 314, 1642, 2034, 402, 2574, 13148, 14, 398, 520, 4500, 26, 2008, 12, 334, 513, 12, 620, 9, 267, 520, 5808, 26, 769, 402, 520, 533, 1705, 71, 4091, 14, 23256, 14, 5214, 14, 9271, 3559, 12254, 282, 2116, 298, 2184, 2034, 1526, 2, 1059, 26, 221, 340, 314, 1526, 365, 440, 488, 12, 2116, 9126, 626, 1655, 13148, 883, 506, 12396, 543, 4573, 2116, 1240, 334, 1529, 626, 574, 465, 1124, 1606, 63, 1418, 20008, 267, 408, 267, 1862, 275, 1052, 398, 340, 2387, 63, 452, 26, 288, 1862, 459, 452, 418, 275, 715, 398, 340, 1390, 63, 2604, 365, 440, 488, 26, 288, 1862, 459, 988, 6579, 418, 275, 1390, 63, 2604, 398, 340, 2034, 63, 1418, 365, 440, 488, 26, 288, 1862, 459, 1606, 3264, 418, 275, 2034, 63, 1418, 398, 931, 275, 1994, 6776, 3149, 83, 15, 12281, 7, 450, 334, 277, 14, 1715, 4258, 267, 3085, 275, 291, 14, 2105, 14, 1246, 63, 1069, 8, 765, 534, 2970, 297, 931, 29, 515, 12, 5644, 1827, 63, 1162, 29, 1162, 9, 267, 13148, 275, 359, 9271, 14, 504, 63, 1246, 63, 2722, 8, 1927, 12, 291, 9, 490, 367, 2073, 315, 3085, 14, 362, 360, 12281, 297, 334, 10524, 267, 372, 13148, 12, 3085, 14, 362, 360, 2184, 3276, 3264, 358, 339, 347, 4789, 8, 277, 12, 4789, 63, 354, 304, 267, 408, 11493, 282, 4789, 3914, 370, 642, 1890, 14, 398, 520, 466, 4789, 63, 354, 26, 620, 267, 520, 635, 4789, 63, 354, 26, 2812, 402, 314, 4789, 14, 398, 520, 4500, 26, 520, 533, 1705, 71, 4091, 14, 23256, 14, 5214, 14, 9271, 64, 267, 520, 5808, 26, 282, 892, 1124, 9271, 1040, 1256, 267, 408, 267, 372, 20284, 8, 5214, 63, 354, 12, 1890, 29, 277, 9, 339, 347, 3906, 63, 504, 63, 1927, 8, 277, 12, 2073, 304, 267, 408, 20064, 3211, 3906, 730, 687, 2073, 436, 17321, 14, 398, 520, 466, 2073, 26, 1211, 267, 520, 635, 2073, 26, 1373, 3906, 2073, 687, 3261, 1177, 398, 520, 4500, 26, 7309, 402, 26, 355, 520, 533, 1705, 71, 4091, 14, 23256, 14, 2423, 14, 6200, 3186, 2532, 6408, 6694, 3559, 355, 520, 533, 1705, 71, 4091, 14, 23256, 14, 2423, 14, 5116, 6694, 3559, 355, 520, 533, 1705, 71, 4091, 14, 23256, 14, 2423, 14, 12147, 3186, 1378, 6408, 6694, 3559, 355, 520, 533, 1705, 71, 4091, 14, 23256, 14, 2423, 14, 3227, 6694, 3559, 355, 520, 533, 1705, 71, 4091, 14, 23256, 14, 2423, 14 ]
[ 1898, 6900, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 624, 3041, 367, 17232, 316, 543, 314, 4475, 13123, 3227, 3261, 1041, 421, 199, 504, 486, 4091, 14, 1258, 492, 4840, 3041, 199, 504, 486, 4091, 14, 23256, 14, 2105, 492, 8113, 199, 504, 486, 4091, 14, 23256, 14, 5214, 492, 20284, 199, 504, 486, 4091, 14, 23256, 14, 2423, 492, 11247, 6694, 199, 504, 486, 4091, 14, 23256, 14, 2423, 492, 12892, 3186, 1378, 6408, 6694, 199, 504, 486, 4091, 14, 23256, 14, 2423, 492, 7190, 3186, 2532, 6408, 6694, 199, 504, 486, 4091, 14, 23256, 14, 2423, 492, 8133, 6694, 199, 504, 486, 4091, 14, 23256, 14, 1131, 492, 8133, 6579, 421, 199, 533, 6810, 8, 6243, 3041, 304, 272, 408, 3041, 370, 8844, 2897, 4346, 367, 3261, 4145, 14, 339, 520, 466, 2199, 26, 620, 272, 520, 635, 2199, 26, 314, 2199, 1314, 314, 1890, 17795, 641, 506, 10220, 402, 14, 12823, 506, 490, 3032, 1380, 6425, 282, 4789, 1182, 3906, 14, 221, 982, 440, 3032, 12, 490, 26945, 1771, 370, 314, 849, 22515, 687, 314, 3734, 14, 339, 520, 466, 6235, 26, 520, 533, 1705, 6126, 18, 1258, 14, 1258, 14, 12906, 18, 13428, 64, 503, 2432, 520, 533, 1705, 26855, 64, 272, 520, 635, 6235, 26, 710, 11715, 18, 23934, 370, 675, 367, 314, 1950, 717, 23191, 701, 642, 1890, 14, 982, 440, 3032, 334, 460, 340, 949, 1124, 1014, 1040, 717, 909, 365, 3032, 395, 26945, 1771, 370, 314, 849, 22515, 717, 687, 314, 3734, 14, 339, 520, 466, 1455, 26, 520, 533, 1705, 12942, 18, 14, 5779, 64, 503, 1021, 626, 7890, 1124, 1069, 28566, 272, 520, 635, 1455, 26, 1626, 2716, 3101, 909, 370, 1852, 4145, 14, 982, 440, 3032, 12, 376, 326, 1124, 1014, 1040, 909, 365, 2737, 626, 365, 3914, 370, 314, 326, 1124, 6942, 1040, 367, 314, 1453, 909, 14, 272, 408, 339, 485, 2105, 63, 533, 275, 8113, 339, 347, 769, 63, 12281, 8, 277, 12, 2387, 63, 452, 29, 797, 12, 1390, 63, 2604, 29, 403, 12, 1993, 2034, 63, 1418, 29, 403, 304, 267, 408, 1296, 13148, 367, 314, 2199, 4568, 543, 642, 1890, 14, 398, 1666, 26, 267, 4178, 921, 4091, 14, 3098, 14, 957, 15, 23256, 15, 4757, 15, 4443, 15, 86, 18, 15, 12281, 15, 513, 398, 520, 466, 2387, 63, 452, 26, 5046, 267, 520, 635, 2387, 63, 452, 26, 715, 340, 2058, 2387, 8752, 13148, 14, 398, 520, 466, 1390, 63, 2604, 26, 1109, 267, 520, 635, 1390, 63, 2604, 26, 5696, 1329, 402, 13148, 370, 372, 12, 982, 440, 1169, 3032, 12, 4243, 370, 282, 574, 663, 701, 314, 3261, 14, 398, 520, 466, 2034, 63, 1418, 26, 620, 267, 520, 635, 2034, 63, 1418, 26, 15058, 3608, 367, 314, 2163, 298, 1606, 2, 402, 13148, 14, 982, 2574, 440, 3032, 12, 314, 3261, 911, 372, 314, 1642, 2034, 402, 2574, 13148, 14, 398, 520, 4500, 26, 2008, 12, 334, 513, 12, 620, 9, 267, 520, 5808, 26, 769, 402, 520, 533, 1705, 71, 4091, 14, 23256, 14, 5214, 14, 9271, 3559, 12254, 282, 2116, 298, 2184, 2034, 1526, 2, 1059, 26, 221, 340, 314, 1526, 365, 440, 488, 12, 2116, 9126, 626, 1655, 13148, 883, 506, 12396, 543, 4573, 2116, 1240, 334, 1529, 626, 574, 465, 1124, 1606, 63, 1418, 20008, 267, 408, 267, 1862, 275, 1052, 398, 340, 2387, 63, 452, 26, 288, 1862, 459, 452, 418, 275, 715, 398, 340, 1390, 63, 2604, 365, 440, 488, 26, 288, 1862, 459, 988, 6579, 418, 275, 1390, 63, 2604, 398, 340, 2034, 63, 1418, 365, 440, 488, 26, 288, 1862, 459, 1606, 3264, 418, 275, 2034, 63, 1418, 398, 931, 275, 1994, 6776, 3149, 83, 15, 12281, 7, 450, 334, 277, 14, 1715, 4258, 267, 3085, 275, 291, 14, 2105, 14, 1246, 63, 1069, 8, 765, 534, 2970, 297, 931, 29, 515, 12, 5644, 1827, 63, 1162, 29, 1162, 9, 267, 13148, 275, 359, 9271, 14, 504, 63, 1246, 63, 2722, 8, 1927, 12, 291, 9, 490, 367, 2073, 315, 3085, 14, 362, 360, 12281, 297, 334, 10524, 267, 372, 13148, 12, 3085, 14, 362, 360, 2184, 3276, 3264, 358, 339, 347, 4789, 8, 277, 12, 4789, 63, 354, 304, 267, 408, 11493, 282, 4789, 3914, 370, 642, 1890, 14, 398, 520, 466, 4789, 63, 354, 26, 620, 267, 520, 635, 4789, 63, 354, 26, 2812, 402, 314, 4789, 14, 398, 520, 4500, 26, 520, 533, 1705, 71, 4091, 14, 23256, 14, 5214, 14, 9271, 64, 267, 520, 5808, 26, 282, 892, 1124, 9271, 1040, 1256, 267, 408, 267, 372, 20284, 8, 5214, 63, 354, 12, 1890, 29, 277, 9, 339, 347, 3906, 63, 504, 63, 1927, 8, 277, 12, 2073, 304, 267, 408, 20064, 3211, 3906, 730, 687, 2073, 436, 17321, 14, 398, 520, 466, 2073, 26, 1211, 267, 520, 635, 2073, 26, 1373, 3906, 2073, 687, 3261, 1177, 398, 520, 4500, 26, 7309, 402, 26, 355, 520, 533, 1705, 71, 4091, 14, 23256, 14, 2423, 14, 6200, 3186, 2532, 6408, 6694, 3559, 355, 520, 533, 1705, 71, 4091, 14, 23256, 14, 2423, 14, 5116, 6694, 3559, 355, 520, 533, 1705, 71, 4091, 14, 23256, 14, 2423, 14, 12147, 3186, 1378, 6408, 6694, 3559, 355, 520, 533, 1705, 71, 4091, 14, 23256, 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 ]
jakobmoss/tsa
utils/makeweights.py
1
2350
# -*- coding: utf-8 -*- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Time Series Analysis -- Generate statistical weigts from scatter # # Author: Jakob Rørsted Mosumgaard # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ############################################################################### # Modules ############################################################################### from __future__ import print_function, with_statement, division import numpy as np import bottleneck as bn ############################################################################### # Functions ############################################################################### def genweight(datname, dpath, wpath): """ Combine time series with statistical weights calculated from scatter Arguments: - `datname`: Identifier of data file - `dpath` : Path to data file (time series). - `wpath` : Path to scatter file (with same time points!) """ # Pretty print print('Generating weights for {0} !'.format(dpath)) # Load data and weights t, d = np.loadtxt(dpath, unpack=True) tt, sig = np.loadtxt(wpath, unpack=True) # Check that times are indeed the same tdif = t - tt if tdif.any() != 0: print('Error! Not the same time points! Quitting!') exit() # Moving variance (Hans: M = 50 - 100) M = 70 movstd = bn.move_std(sig, M, min_count=1) movvar = np.square(movstd) # Remove first point x = 1 t = t[x:] d = d[x:] movvar = movvar[x:] # Calculate weights from scatter (1 / variance) w = np.divide(1.0, movvar) # Save outfile = star + '_with-weights.txt' np.savetxt(outfile, np.transpose([t, d, w]), fmt='%.15e', delimiter='\t') # Done! print('Done!\n') ############################################################################### # Script ############################################################################### if __name__ == "__main__": # Definitions datdir = '../../data/' ext = '.txt' append = '-high' # Run for star 1 star = 'star01' genweight(star, datdir + star + ext, star + append + ext) # Run for star 2 star = 'star02' genweight(star, datdir + star + ext, star + append + ext)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 18294, 30642, 9753, 22935, 94, 199, 3, 4703, 12403, 21916, 1553, 7958, 8753, 270, 2652, 781, 528, 1086, 687, 28618, 199, 3, 199, 3, 6529, 26, 1603, 1151, 2873, 820, 31087, 2393, 471, 603, 736, 453, 5294, 1005, 199, 3, 18294, 30642, 9753, 22935, 94, 199, 199, 11490, 199, 3, 18167, 199, 11490, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 543, 63, 6242, 12, 4629, 199, 646, 2680, 465, 980, 199, 646, 5888, 27412, 465, 21847, 421, 199, 11490, 199, 3, 17471, 199, 11490, 199, 318, 3805, 3463, 8, 4616, 354, 12, 366, 515, 12, 336, 515, 304, 272, 408, 272, 26353, 900, 6779, 543, 8753, 270, 2652, 4931, 12950, 687, 28618, 339, 7628, 26, 272, 446, 658, 4616, 354, 8340, 23285, 402, 666, 570, 272, 446, 658, 68, 515, 64, 221, 520, 6912, 370, 666, 570, 334, 521, 6779, 680, 272, 446, 658, 87, 515, 64, 221, 520, 6912, 370, 28618, 570, 334, 1045, 2011, 900, 4501, 21866, 272, 408, 339, 327, 31651, 870, 272, 870, 360, 29244, 4931, 367, 469, 16, 93, 8546, 1370, 908, 8, 68, 515, 430, 339, 327, 7190, 666, 436, 4931, 272, 307, 12, 366, 275, 980, 14, 27992, 8, 68, 515, 12, 7787, 29, 549, 9, 272, 13638, 12, 5259, 275, 980, 14, 27992, 8, 87, 515, 12, 7787, 29, 549, 9, 339, 327, 2670, 626, 5431, 787, 31043, 379, 314, 2011, 272, 307, 7330, 275, 307, 446, 13638, 272, 340, 307, 7330, 14, 1629, 342, 1137, 378, 26, 267, 870, 360, 547, 1, 2832, 314, 2011, 900, 4501, 1, 1413, 4993, 1337, 10916, 267, 4458, 342, 339, 327, 3930, 4007, 11773, 334, 40, 796, 26, 603, 275, 5238, 446, 2948, 9, 272, 603, 275, 10045, 272, 26524, 1516, 275, 21847, 14, 1185, 63, 1516, 8, 4093, 12, 603, 12, 1748, 63, 835, 29, 17, 9, 272, 26524, 1391, 275, 980, 14, 9646, 8, 14469, 1516, 9, 339, 327, 5852, 1642, 2376, 272, 671, 275, 413, 272, 307, 275, 307, 59, 88, 2938, 272, 366, 275, 366, 59, 88, 2938, 272, 26524, 1391, 275, 26524, 1391, 59, 88, 2938, 339, 327, 12707, 4931, 687, 28618, 334, 17, 1182, 11773, 9, 272, 336, 275, 980, 14, 16081, 8, 17, 14, 16, 12, 26524, 1391, 9, 339, 327, 11063, 272, 4386, 275, 14664, 435, 2513, 1045, 13, 4916, 14, 2424, 7, 272, 980, 14, 23374, 386, 400, 8, 4984, 12, 980, 14, 10483, 779, 84, 12, 366, 12, 336, 2522, 7104, 9569, 14, 1046, 69, 297, 11172, 17115, 84, 358, 339, 327, 23541, 1, 272, 870, 360, 10759, 12525, 78, 358, 421, 199, 11490, 199, 3, 14914, 199, 11490, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 327, 22659, 852, 272, 6394, 694, 275, 283, 9707, 576, 4805, 272, 1599, 275, 1987, 2424, 7, 272, 5666, 275, 2475, 6260, 7, 339, 327, 3378, 367, 14664, 413, 272, 14664, 275, 283, 7848, 614, 7, 272, 3805, 3463, 8, 7848, 12, 6394, 694, 435, 14664, 435, 1599, 12, 14664, 435, 5666, 435, 1599, 9, 339, 327, 3378, 367, 14664, 499, 272, 14664, 275, 283, 7848, 996, 7, 272, 3805, 3463, 8, 7848, 12, 6394, 694, 435, 14664, 435, 1599, 12, 14664, 435, 5666, 435, 1599, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 18294, 30642, 9753, 22935, 94, 199, 3, 4703, 12403, 21916, 1553, 7958, 8753, 270, 2652, 781, 528, 1086, 687, 28618, 199, 3, 199, 3, 6529, 26, 1603, 1151, 2873, 820, 31087, 2393, 471, 603, 736, 453, 5294, 1005, 199, 3, 18294, 30642, 9753, 22935, 94, 199, 199, 11490, 199, 3, 18167, 199, 11490, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 543, 63, 6242, 12, 4629, 199, 646, 2680, 465, 980, 199, 646, 5888, 27412, 465, 21847, 421, 199, 11490, 199, 3, 17471, 199, 11490, 199, 318, 3805, 3463, 8, 4616, 354, 12, 366, 515, 12, 336, 515, 304, 272, 408, 272, 26353, 900, 6779, 543, 8753, 270, 2652, 4931, 12950, 687, 28618, 339, 7628, 26, 272, 446, 658, 4616, 354, 8340, 23285, 402, 666, 570, 272, 446, 658, 68, 515, 64, 221, 520, 6912, 370, 666, 570, 334, 521, 6779, 680, 272, 446, 658, 87, 515, 64, 221, 520, 6912, 370, 28618, 570, 334, 1045, 2011, 900, 4501, 21866, 272, 408, 339, 327, 31651, 870, 272, 870, 360, 29244, 4931, 367, 469, 16, 93, 8546, 1370, 908, 8, 68, 515, 430, 339, 327, 7190, 666, 436, 4931, 272, 307, 12, 366, 275, 980, 14, 27992, 8, 68, 515, 12, 7787, 29, 549, 9, 272, 13638, 12, 5259, 275, 980, 14, 27992, 8, 87, 515, 12, 7787, 29, 549, 9, 339, 327, 2670, 626, 5431, 787, 31043, 379, 314, 2011, 272, 307, 7330, 275, 307, 446, 13638, 272, 340, 307, 7330, 14, 1629, 342, 1137, 378, 26, 267, 870, 360, 547, 1, 2832, 314, 2011, 900, 4501, 1, 1413, 4993, 1337, 10916, 267, 4458, 342, 339, 327, 3930, 4007, 11773, 334, 40, 796, 26, 603, 275, 5238, 446, 2948, 9, 272, 603, 275, 10045, 272, 26524, 1516, 275, 21847, 14, 1185, 63, 1516, 8, 4093, 12, 603, 12, 1748, 63, 835, 29, 17, 9, 272, 26524, 1391, 275, 980, 14, 9646, 8, 14469, 1516, 9, 339, 327, 5852, 1642, 2376, 272, 671, 275, 413, 272, 307, 275, 307, 59, 88, 2938, 272, 366, 275, 366, 59, 88, 2938, 272, 26524, 1391, 275, 26524, 1391, 59, 88, 2938, 339, 327, 12707, 4931, 687, 28618, 334, 17, 1182, 11773, 9, 272, 336, 275, 980, 14, 16081, 8, 17, 14, 16, 12, 26524, 1391, 9, 339, 327, 11063, 272, 4386, 275, 14664, 435, 2513, 1045, 13, 4916, 14, 2424, 7, 272, 980, 14, 23374, 386, 400, 8, 4984, 12, 980, 14, 10483, 779, 84, 12, 366, 12, 336, 2522, 7104, 9569, 14, 1046, 69, 297, 11172, 17115, 84, 358, 339, 327, 23541, 1, 272, 870, 360, 10759, 12525, 78, 358, 421, 199, 11490, 199, 3, 14914, 199, 11490, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 327, 22659, 852, 272, 6394, 694, 275, 283, 9707, 576, 4805, 272, 1599, 275, 1987, 2424, 7, 272, 5666, 275, 2475, 6260, 7, 339, 327, 3378, 367, 14664, 413, 272, 14664, 275, 283, 7848, 614, 7, 272, 3805, 3463, 8, 7848, 12, 6394, 694, 435, 14664, 435, 1599, 12, 14664, 435, 5666, 435, 1599, 9, 339, 327, 3378, 367, 14664, 499, 272, 14664, 275, 283, 7848, 996, 7, 272, 3805, 3463, 8, 7848, 12, 6394, 694, 435, 14664, 435, 1599, 12, 14664, 435, 5666, 435, 1599, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
erstis-go-botting/sexy-bot
misc.py
1
1888
import os #checks if settings.ini should be generated. if not given universe, username and password it will generate a settings.ini with the default account #This settings_generator will only work for universe 82 if the flag argument is given als True(to make sure that universe 82 is intended) def settings_generator(universe = 82, username = 'defaultName', password = 'defaultPassword', flag=False): path = os.path.normcase('settings/settings.ini') if (os.path.isfile('settings/settings.ini')): print("settings file found, stopping now.") return if (universe == 82 and not(flag)) or (username == 'defaultName') or (password == 'defaultPassword'): print("Not all fields specified, fallback on default configuration") universe = 82 username = 'defaultName' password = 'defaultPassword' if not (os.path.isdir('settings')): os.makedir('settings') with open(path,'w') as foo: foo.write('[credentials]\nuniverse = '+ str(universe) +'\npassword = '+password+'\nusername = '+username) print("Settings.ini generated") def force_settings_generator(universe = 82, username = 'defaultName', password = 'defaultPassword', flag=False): path = os.path.normcase('settings/settings.ini') if not (os.path.isfile('settings/settings.ini')): settings_generator(universe, username, password, flag) return if (universe == 82 and not(flag)) or (username == 'defaultName') or (password == 'defaultPassword'): print("Not all fields specified, fallback on default configuration") universe = 82 username = 'defaultName' password = 'defaultPassword' with open(path,'w') as foo: foo.write('[credentials]\nuniverse = '+ str(universe) +'\npassword = '+password+'\nusername = '+username) print("Settings.ini generated") #settings_generator()
mit
[ 646, 747, 199, 199, 3, 8625, 340, 2202, 14, 2730, 1077, 506, 4046, 14, 340, 440, 1627, 15439, 2077, 12, 3434, 436, 2505, 652, 911, 3550, 282, 2202, 14, 2730, 543, 314, 849, 2933, 199, 3, 2765, 2202, 63, 4679, 911, 1454, 1736, 367, 15439, 2077, 18051, 340, 314, 3305, 1423, 365, 1627, 741, 83, 715, 8, 475, 1852, 3238, 626, 15439, 2077, 18051, 365, 11619, 9, 199, 199, 318, 2202, 63, 4679, 8, 30519, 275, 18051, 12, 3434, 275, 283, 885, 985, 297, 2505, 275, 283, 885, 6139, 297, 3305, 29, 797, 304, 272, 931, 275, 747, 14, 515, 14, 21288, 360, 1751, 15, 1751, 14, 2730, 358, 272, 340, 334, 736, 14, 515, 14, 6292, 360, 1751, 15, 1751, 14, 2730, 8109, 267, 870, 480, 1751, 570, 1911, 12, 23599, 3063, 2685, 267, 372, 272, 340, 334, 30519, 508, 18051, 436, 440, 8, 4173, 430, 503, 334, 2473, 508, 283, 885, 985, 358, 503, 334, 2060, 508, 283, 885, 6139, 735, 267, 870, 480, 1763, 1006, 1504, 2013, 12, 9567, 641, 849, 2897, 531, 267, 15439, 2077, 275, 18051, 267, 3434, 275, 283, 885, 985, 7, 267, 2505, 275, 283, 885, 6139, 7, 272, 340, 440, 334, 736, 14, 515, 14, 6027, 360, 1751, 8109, 267, 747, 14, 1875, 694, 360, 1751, 358, 272, 543, 1551, 8, 515, 2584, 87, 358, 465, 3925, 26, 267, 3925, 14, 952, 11894, 6942, 7272, 78, 30519, 275, 6681, 620, 8, 30519, 9, 435, 1154, 78, 2060, 275, 6681, 2060, 19192, 78, 2473, 275, 6681, 2473, 9, 267, 870, 480, 5268, 14, 2730, 4046, 531, 199, 199, 318, 3542, 63, 1751, 63, 4679, 8, 30519, 275, 18051, 12, 3434, 275, 283, 885, 985, 297, 2505, 275, 283, 885, 6139, 297, 3305, 29, 797, 304, 272, 931, 275, 747, 14, 515, 14, 21288, 360, 1751, 15, 1751, 14, 2730, 358, 272, 340, 440, 334, 736, 14, 515, 14, 6292, 360, 1751, 15, 1751, 14, 2730, 8109, 267, 2202, 63, 4679, 8, 30519, 12, 3434, 12, 2505, 12, 3305, 9, 267, 372, 272, 340, 334, 30519, 508, 18051, 436, 440, 8, 4173, 430, 503, 334, 2473, 508, 283, 885, 985, 358, 503, 334, 2060, 508, 283, 885, 6139, 735, 267, 870, 480, 1763, 1006, 1504, 2013, 12, 9567, 641, 849, 2897, 531, 267, 15439, 2077, 275, 18051, 267, 3434, 275, 283, 885, 985, 7, 267, 2505, 275, 283, 885, 6139, 7, 272, 543, 1551, 8, 515, 2584, 87, 358, 465, 3925, 26, 267, 3925, 14, 952, 11894, 6942, 7272, 78, 30519, 275, 6681, 620, 8, 30519, 9, 435, 1154, 78, 2060, 275, 6681, 2060, 19192, 78, 2473, 275, 6681, 2473, 9, 267, 870, 480, 5268, 14, 2730, 4046, 531, 421, 199, 3, 1751, 63, 4679, 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 ]
[ 747, 199, 199, 3, 8625, 340, 2202, 14, 2730, 1077, 506, 4046, 14, 340, 440, 1627, 15439, 2077, 12, 3434, 436, 2505, 652, 911, 3550, 282, 2202, 14, 2730, 543, 314, 849, 2933, 199, 3, 2765, 2202, 63, 4679, 911, 1454, 1736, 367, 15439, 2077, 18051, 340, 314, 3305, 1423, 365, 1627, 741, 83, 715, 8, 475, 1852, 3238, 626, 15439, 2077, 18051, 365, 11619, 9, 199, 199, 318, 2202, 63, 4679, 8, 30519, 275, 18051, 12, 3434, 275, 283, 885, 985, 297, 2505, 275, 283, 885, 6139, 297, 3305, 29, 797, 304, 272, 931, 275, 747, 14, 515, 14, 21288, 360, 1751, 15, 1751, 14, 2730, 358, 272, 340, 334, 736, 14, 515, 14, 6292, 360, 1751, 15, 1751, 14, 2730, 8109, 267, 870, 480, 1751, 570, 1911, 12, 23599, 3063, 2685, 267, 372, 272, 340, 334, 30519, 508, 18051, 436, 440, 8, 4173, 430, 503, 334, 2473, 508, 283, 885, 985, 358, 503, 334, 2060, 508, 283, 885, 6139, 735, 267, 870, 480, 1763, 1006, 1504, 2013, 12, 9567, 641, 849, 2897, 531, 267, 15439, 2077, 275, 18051, 267, 3434, 275, 283, 885, 985, 7, 267, 2505, 275, 283, 885, 6139, 7, 272, 340, 440, 334, 736, 14, 515, 14, 6027, 360, 1751, 8109, 267, 747, 14, 1875, 694, 360, 1751, 358, 272, 543, 1551, 8, 515, 2584, 87, 358, 465, 3925, 26, 267, 3925, 14, 952, 11894, 6942, 7272, 78, 30519, 275, 6681, 620, 8, 30519, 9, 435, 1154, 78, 2060, 275, 6681, 2060, 19192, 78, 2473, 275, 6681, 2473, 9, 267, 870, 480, 5268, 14, 2730, 4046, 531, 199, 199, 318, 3542, 63, 1751, 63, 4679, 8, 30519, 275, 18051, 12, 3434, 275, 283, 885, 985, 297, 2505, 275, 283, 885, 6139, 297, 3305, 29, 797, 304, 272, 931, 275, 747, 14, 515, 14, 21288, 360, 1751, 15, 1751, 14, 2730, 358, 272, 340, 440, 334, 736, 14, 515, 14, 6292, 360, 1751, 15, 1751, 14, 2730, 8109, 267, 2202, 63, 4679, 8, 30519, 12, 3434, 12, 2505, 12, 3305, 9, 267, 372, 272, 340, 334, 30519, 508, 18051, 436, 440, 8, 4173, 430, 503, 334, 2473, 508, 283, 885, 985, 358, 503, 334, 2060, 508, 283, 885, 6139, 735, 267, 870, 480, 1763, 1006, 1504, 2013, 12, 9567, 641, 849, 2897, 531, 267, 15439, 2077, 275, 18051, 267, 3434, 275, 283, 885, 985, 7, 267, 2505, 275, 283, 885, 6139, 7, 272, 543, 1551, 8, 515, 2584, 87, 358, 465, 3925, 26, 267, 3925, 14, 952, 11894, 6942, 7272, 78, 30519, 275, 6681, 620, 8, 30519, 9, 435, 1154, 78, 2060, 275, 6681, 2060, 19192, 78, 2473, 275, 6681, 2473, 9, 267, 870, 480, 5268, 14, 2730, 4046, 531, 421, 199, 3, 1751, 63, 4679, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cainmatt/django
tests/template_tests/syntax_tests/test_autoescape.py
337
5575
from django.template import TemplateSyntaxError from django.test import SimpleTestCase from django.utils.safestring import mark_safe from ..utils import SafeClass, UnsafeClass, setup class AutoescapeTagTests(SimpleTestCase): @setup({'autoescape-tag01': '{% autoescape off %}hello{% endautoescape %}'}) def test_autoescape_tag01(self): output = self.engine.render_to_string('autoescape-tag01') self.assertEqual(output, 'hello') @setup({'autoescape-tag02': '{% autoescape off %}{{ first }}{% endautoescape %}'}) def test_autoescape_tag02(self): output = self.engine.render_to_string('autoescape-tag02', {'first': '<b>hello</b>'}) self.assertEqual(output, '<b>hello</b>') @setup({'autoescape-tag03': '{% autoescape on %}{{ first }}{% endautoescape %}'}) def test_autoescape_tag03(self): output = self.engine.render_to_string('autoescape-tag03', {'first': '<b>hello</b>'}) self.assertEqual(output, '&lt;b&gt;hello&lt;/b&gt;') # Autoescape disabling and enabling nest in a predictable way. @setup({'autoescape-tag04': '{% autoescape off %}' '{{ first }} {% autoescape on %}{{ first }}{% endautoescape %}{% endautoescape %}'}) def test_autoescape_tag04(self): output = self.engine.render_to_string('autoescape-tag04', {'first': '<a>'}) self.assertEqual(output, '<a> &lt;a&gt;') @setup({'autoescape-tag05': '{% autoescape on %}{{ first }}{% endautoescape %}'}) def test_autoescape_tag05(self): output = self.engine.render_to_string('autoescape-tag05', {'first': '<b>first</b>'}) self.assertEqual(output, '&lt;b&gt;first&lt;/b&gt;') # Strings (ASCII or unicode) already marked as "safe" are not # auto-escaped @setup({'autoescape-tag06': '{{ first }}'}) def test_autoescape_tag06(self): output = self.engine.render_to_string('autoescape-tag06', {'first': mark_safe('<b>first</b>')}) self.assertEqual(output, '<b>first</b>') @setup({'autoescape-tag07': '{% autoescape on %}{{ first }}{% endautoescape %}'}) def test_autoescape_tag07(self): output = self.engine.render_to_string('autoescape-tag07', {'first': mark_safe('<b>Apple</b>')}) self.assertEqual(output, '<b>Apple</b>') @setup({'autoescape-tag08': r'{% autoescape on %}' r'{{ var|default_if_none:" endquote\" hah" }}{% endautoescape %}'}) def test_autoescape_tag08(self): """ Literal string arguments to filters, if used in the result, are safe. """ output = self.engine.render_to_string('autoescape-tag08', {"var": None}) self.assertEqual(output, ' endquote" hah') # Objects which return safe strings as their __str__ method # won't get double-escaped. @setup({'autoescape-tag09': r'{{ unsafe }}'}) def test_autoescape_tag09(self): output = self.engine.render_to_string('autoescape-tag09', {'unsafe': UnsafeClass()}) self.assertEqual(output, 'you &amp; me') @setup({'autoescape-tag10': r'{{ safe }}'}) def test_autoescape_tag10(self): output = self.engine.render_to_string('autoescape-tag10', {'safe': SafeClass()}) self.assertEqual(output, 'you &gt; me') @setup({'autoescape-filtertag01': '{{ first }}{% filter safe %}{{ first }} x<y{% endfilter %}'}) def test_autoescape_filtertag01(self): """ The "safe" and "escape" filters cannot work due to internal implementation details (fortunately, the (no)autoescape block tags can be used in those cases) """ with self.assertRaises(TemplateSyntaxError): self.engine.render_to_string('autoescape-filtertag01', {'first': '<a>'}) @setup({'autoescape-ifequal01': '{% ifequal var "this & that" %}yes{% endifequal %}'}) def test_autoescape_ifequal01(self): """ ifequal compares unescaped vales. """ output = self.engine.render_to_string('autoescape-ifequal01', {'var': 'this & that'}) self.assertEqual(output, 'yes') # Arguments to filters are 'safe' and manipulate their input unescaped. @setup({'autoescape-filters01': '{{ var|cut:"&" }}'}) def test_autoescape_filters01(self): output = self.engine.render_to_string('autoescape-filters01', {'var': 'this & that'}) self.assertEqual(output, 'this that') @setup({'autoescape-filters02': '{{ var|join:" & " }}'}) def test_autoescape_filters02(self): output = self.engine.render_to_string('autoescape-filters02', {'var': ('Tom', 'Dick', 'Harry')}) self.assertEqual(output, 'Tom & Dick & Harry') @setup({'autoescape-literals01': '{{ "this & that" }}'}) def test_autoescape_literals01(self): """ Literal strings are safe. """ output = self.engine.render_to_string('autoescape-literals01') self.assertEqual(output, 'this & that') @setup({'autoescape-stringiterations01': '{% for l in var %}{{ l }},{% endfor %}'}) def test_autoescape_stringiterations01(self): """ Iterating over strings outputs safe characters. """ output = self.engine.render_to_string('autoescape-stringiterations01', {'var': 'K&R'}) self.assertEqual(output, 'K,&amp;,R,') @setup({'autoescape-lookup01': '{{ var.key }}'}) def test_autoescape_lookup01(self): """ Escape requirement survives lookup. """ output = self.engine.render_to_string('autoescape-lookup01', {'var': {'key': 'this & that'}}) self.assertEqual(output, 'this &amp; that')
bsd-3-clause
[ 504, 1639, 14, 1160, 492, 17762, 199, 504, 1639, 14, 396, 492, 24424, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 199, 504, 2508, 1208, 492, 14969, 2543, 12, 15254, 6504, 2543, 12, 3272, 421, 199, 533, 9195, 3765, 1931, 2925, 8, 17968, 304, 339, 768, 2758, 3252, 15818, 13, 1450, 614, 356, 12100, 19102, 2331, 3674, 5006, 3996, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 614, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 614, 358, 267, 291, 14, 629, 8, 1199, 12, 283, 5006, 358, 339, 768, 2758, 3252, 15818, 13, 1450, 996, 356, 12100, 19102, 2331, 17337, 1642, 20104, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 996, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 996, 297, 791, 2246, 356, 2650, 66, 30, 5006, 1108, 66, 30, 3071, 267, 291, 14, 629, 8, 1199, 12, 2650, 66, 30, 5006, 1108, 66, 5971, 339, 768, 2758, 3252, 15818, 13, 1450, 1644, 356, 12100, 19102, 641, 17337, 1642, 20104, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 1644, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 1644, 297, 791, 2246, 356, 2650, 66, 30, 5006, 1108, 66, 30, 3071, 267, 291, 14, 629, 8, 1199, 12, 7673, 4116, 27, 66, 6, 3308, 27, 5006, 6, 4116, 22352, 66, 6, 3308, 10784, 339, 327, 9195, 3765, 30723, 436, 29310, 10715, 315, 282, 12610, 461, 4340, 14, 272, 768, 2758, 3252, 15818, 13, 1450, 966, 356, 12100, 19102, 2331, 25509, 267, 11400, 1642, 3586, 7749, 19102, 641, 17337, 1642, 20104, 1284, 15818, 12760, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 966, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 966, 297, 791, 2246, 356, 2650, 65, 30, 3071, 267, 291, 14, 629, 8, 1199, 12, 2650, 65, 30, 1253, 4116, 27, 65, 6, 3308, 10784, 339, 768, 2758, 3252, 15818, 13, 1450, 1717, 356, 12100, 19102, 641, 17337, 1642, 20104, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 1717, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 1717, 297, 791, 2246, 356, 2650, 66, 30, 2246, 1108, 66, 30, 3071, 267, 291, 14, 629, 8, 1199, 12, 7673, 4116, 27, 66, 6, 3308, 27, 2246, 6, 4116, 22352, 66, 6, 3308, 10784, 339, 327, 24361, 334, 12292, 503, 2649, 9, 2575, 11584, 465, 298, 3489, 2, 787, 440, 272, 327, 2599, 13, 13572, 272, 768, 2758, 3252, 15818, 13, 1450, 1690, 356, 11400, 1642, 29281, 272, 347, 511, 63, 15818, 63, 1450, 1690, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 1690, 297, 791, 2246, 356, 2216, 63, 3489, 4827, 66, 30, 2246, 1108, 66, 5971, 1552, 267, 291, 14, 629, 8, 1199, 12, 2650, 66, 30, 2246, 1108, 66, 5971, 339, 768, 2758, 3252, 15818, 13, 1450, 1780, 356, 12100, 19102, 641, 17337, 1642, 20104, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 1780, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 1780, 297, 791, 2246, 356, 2216, 63, 3489, 4827, 66, 30, 25051, 1108, 66, 5971, 1552, 267, 291, 14, 629, 8, 1199, 12, 2650, 66, 30, 25051, 1108, 66, 5971, 339, 768, 2758, 3252, 15818, 13, 1450, 2036, 356, 519, 7, 3996, 19102, 641, 25509, 267, 519, 7, 3638, 2729, 92, 885, 63, 692, 63, 3592, 5424, 1284, 3513, 4451, 394, 11326, 2, 20104, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 2036, 8, 277, 304, 267, 408, 267, 18271, 1059, 2368, 370, 4766, 12, 340, 1202, 315, 314, 754, 12, 787, 5048, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 2036, 297, 2420, 1391, 582, 488, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 1284, 3513, 2, 394, 11326, 358, 339, 327, 26794, 1314, 372, 5048, 3326, 465, 3932, 636, 495, 363, 1083, 272, 327, 7859, 1133, 664, 4270, 13, 13572, 14, 272, 768, 2758, 3252, 15818, 13, 1450, 1643, 356, 519, 7, 3638, 19293, 29281, 272, 347, 511, 63, 15818, 63, 1450, 1643, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 1643, 297, 791, 14242, 356, 15254, 6504, 2543, 22804, 267, 291, 14, 629, 8, 1199, 12, 283, 13297, 1253, 5282, 27, 562, 358, 339, 768, 2758, 3252, 15818, 13, 1450, 709, 356, 519, 7, 3638, 5048, 29281, 272, 347, 511, 63, 15818, 63, 1450, 709, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 709, 297, 791, 3489, 356, 14969, 2543, 22804, 267, 291, 14, 629, 8, 1199, 12, 283, 13297, 1253, 3308, 27, 562, 358, 339, 768, 2758, 3252, 15818, 13, 1541, 1450, 614, 356, 11400, 1642, 20104, 2457, 5048, 17337, 1642, 3586, 671, 28, 89, 3996, 1284, 1541, 17776, 272, 347, 511, 63, 15818, 63, 1541, 1450, 614, 8, 277, 304, 267, 408, 267, 710, 298, 3489, 2, 436, 298, 3765, 2, 4766, 3913, 1736, 7037, 370, 5007, 267, 4514, 2436, 334, 21839, 12, 314, 334, 889, 9, 15818, 1853, 267, 3762, 883, 506, 1202, 315, 5204, 5560, 9, 267, 408, 267, 543, 291, 14, 1855, 8, 20837, 304, 288, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1541, 1450, 614, 297, 791, 2246, 356, 2650, 65, 30, 3071, 339, 768, 2758, 3252, 15818, 13, 692, 1452, 614, 356, 12100, 340, 1452, 2729, 298, 3749, 1253, 626, 2, 3674, 5066, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 15818, 63, 692, 1452, 614, 8, 277, 304, 267, 408, 267, 340, 1452, 30827, 625, 13572, 373, 7098, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63 ]
[ 1639, 14, 1160, 492, 17762, 199, 504, 1639, 14, 396, 492, 24424, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 199, 504, 2508, 1208, 492, 14969, 2543, 12, 15254, 6504, 2543, 12, 3272, 421, 199, 533, 9195, 3765, 1931, 2925, 8, 17968, 304, 339, 768, 2758, 3252, 15818, 13, 1450, 614, 356, 12100, 19102, 2331, 3674, 5006, 3996, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 614, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 614, 358, 267, 291, 14, 629, 8, 1199, 12, 283, 5006, 358, 339, 768, 2758, 3252, 15818, 13, 1450, 996, 356, 12100, 19102, 2331, 17337, 1642, 20104, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 996, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 996, 297, 791, 2246, 356, 2650, 66, 30, 5006, 1108, 66, 30, 3071, 267, 291, 14, 629, 8, 1199, 12, 2650, 66, 30, 5006, 1108, 66, 5971, 339, 768, 2758, 3252, 15818, 13, 1450, 1644, 356, 12100, 19102, 641, 17337, 1642, 20104, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 1644, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 1644, 297, 791, 2246, 356, 2650, 66, 30, 5006, 1108, 66, 30, 3071, 267, 291, 14, 629, 8, 1199, 12, 7673, 4116, 27, 66, 6, 3308, 27, 5006, 6, 4116, 22352, 66, 6, 3308, 10784, 339, 327, 9195, 3765, 30723, 436, 29310, 10715, 315, 282, 12610, 461, 4340, 14, 272, 768, 2758, 3252, 15818, 13, 1450, 966, 356, 12100, 19102, 2331, 25509, 267, 11400, 1642, 3586, 7749, 19102, 641, 17337, 1642, 20104, 1284, 15818, 12760, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 966, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 966, 297, 791, 2246, 356, 2650, 65, 30, 3071, 267, 291, 14, 629, 8, 1199, 12, 2650, 65, 30, 1253, 4116, 27, 65, 6, 3308, 10784, 339, 768, 2758, 3252, 15818, 13, 1450, 1717, 356, 12100, 19102, 641, 17337, 1642, 20104, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 1717, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 1717, 297, 791, 2246, 356, 2650, 66, 30, 2246, 1108, 66, 30, 3071, 267, 291, 14, 629, 8, 1199, 12, 7673, 4116, 27, 66, 6, 3308, 27, 2246, 6, 4116, 22352, 66, 6, 3308, 10784, 339, 327, 24361, 334, 12292, 503, 2649, 9, 2575, 11584, 465, 298, 3489, 2, 787, 440, 272, 327, 2599, 13, 13572, 272, 768, 2758, 3252, 15818, 13, 1450, 1690, 356, 11400, 1642, 29281, 272, 347, 511, 63, 15818, 63, 1450, 1690, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 1690, 297, 791, 2246, 356, 2216, 63, 3489, 4827, 66, 30, 2246, 1108, 66, 5971, 1552, 267, 291, 14, 629, 8, 1199, 12, 2650, 66, 30, 2246, 1108, 66, 5971, 339, 768, 2758, 3252, 15818, 13, 1450, 1780, 356, 12100, 19102, 641, 17337, 1642, 20104, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 1780, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 1780, 297, 791, 2246, 356, 2216, 63, 3489, 4827, 66, 30, 25051, 1108, 66, 5971, 1552, 267, 291, 14, 629, 8, 1199, 12, 2650, 66, 30, 25051, 1108, 66, 5971, 339, 768, 2758, 3252, 15818, 13, 1450, 2036, 356, 519, 7, 3996, 19102, 641, 25509, 267, 519, 7, 3638, 2729, 92, 885, 63, 692, 63, 3592, 5424, 1284, 3513, 4451, 394, 11326, 2, 20104, 1284, 15818, 17776, 272, 347, 511, 63, 15818, 63, 1450, 2036, 8, 277, 304, 267, 408, 267, 18271, 1059, 2368, 370, 4766, 12, 340, 1202, 315, 314, 754, 12, 787, 5048, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 2036, 297, 2420, 1391, 582, 488, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 1284, 3513, 2, 394, 11326, 358, 339, 327, 26794, 1314, 372, 5048, 3326, 465, 3932, 636, 495, 363, 1083, 272, 327, 7859, 1133, 664, 4270, 13, 13572, 14, 272, 768, 2758, 3252, 15818, 13, 1450, 1643, 356, 519, 7, 3638, 19293, 29281, 272, 347, 511, 63, 15818, 63, 1450, 1643, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 1643, 297, 791, 14242, 356, 15254, 6504, 2543, 22804, 267, 291, 14, 629, 8, 1199, 12, 283, 13297, 1253, 5282, 27, 562, 358, 339, 768, 2758, 3252, 15818, 13, 1450, 709, 356, 519, 7, 3638, 5048, 29281, 272, 347, 511, 63, 15818, 63, 1450, 709, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1450, 709, 297, 791, 3489, 356, 14969, 2543, 22804, 267, 291, 14, 629, 8, 1199, 12, 283, 13297, 1253, 3308, 27, 562, 358, 339, 768, 2758, 3252, 15818, 13, 1541, 1450, 614, 356, 11400, 1642, 20104, 2457, 5048, 17337, 1642, 3586, 671, 28, 89, 3996, 1284, 1541, 17776, 272, 347, 511, 63, 15818, 63, 1541, 1450, 614, 8, 277, 304, 267, 408, 267, 710, 298, 3489, 2, 436, 298, 3765, 2, 4766, 3913, 1736, 7037, 370, 5007, 267, 4514, 2436, 334, 21839, 12, 314, 334, 889, 9, 15818, 1853, 267, 3762, 883, 506, 1202, 315, 5204, 5560, 9, 267, 408, 267, 543, 291, 14, 1855, 8, 20837, 304, 288, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 15818, 13, 1541, 1450, 614, 297, 791, 2246, 356, 2650, 65, 30, 3071, 339, 768, 2758, 3252, 15818, 13, 692, 1452, 614, 356, 12100, 340, 1452, 2729, 298, 3749, 1253, 626, 2, 3674, 5066, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 15818, 63, 692, 1452, 614, 8, 277, 304, 267, 408, 267, 340, 1452, 30827, 625, 13572, 373, 7098, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
ActiveState/code
recipes/Python/275366_Email_address_leech/recipe-275366.py
1
1624
import re def test(): text = \ ''' You can contact us at myname@server.site.com or at yourname AT server DOT site DOT com. Also at o u r n a m e @ s e r v e r dot s i t e dot c o m and t.h.e.i.r.n.a.m.e at server dot s/i/t/e DOT COM. ''' for email in emailLeech(text): print email DOMAINS = ["com","edu","net","org","gov","us"] #.. and so on FLAGS = re.IGNORECASE | re.VERBOSE AT = r'(?: @ | \b A \s* T \b)' ADDRESSPART = r'\b (?: \w+ | \w (?:(?:\s+|\W) \w)*) \b' DOMAIN = r'(?:%s)' % '|'.join(["(?:\s*|\W)".join(domain) for domain in DOMAINS]) NONWORD = re.compile(r'\W+') DOT_REGEX = re.compile(r'(?: \. | \b D \s* O \s* T \b)', FLAGS) EMAIL_REGEX = re.compile( (r'(?P<name>%s) \W* %s \W*' % (ADDRESSPART,AT)) + r'(?P<site>(?: %s \W* %s \W*)+)' % (ADDRESSPART, DOT_REGEX.pattern) + r'(?P<domain>%s)' % DOMAIN, FLAGS) def emailLeech(text): ''' An iterator over recognized email addresses within text''' while (True): match = EMAIL_REGEX.search(text) if not match: break parts = [match.group("name")] + \ DOT_REGEX.split(match.group("site")) + \ [match.group("domain")] # discard non word chars parts = [NONWORD.sub('',part) for part in parts] # discard all empty parts and make lowercase parts = [part.lower() for part in parts if len(part)>0] # join the parts yield "%s@%s.%s" % (parts[0], '.'.join(parts[1:-1]), parts[-1]) text = text[match.end():] if __name__ == '__main__': test()
mit
[ 646, 295, 199, 199, 318, 511, 837, 272, 1318, 275, 971, 267, 1449, 2047, 883, 8966, 2739, 737, 3002, 354, 32, 1000, 14, 2124, 14, 957, 288, 503, 737, 612, 79, 21121, 15059, 1654, 15854, 4770, 15854, 2414, 14, 288, 6121, 737, 312, 399, 519, 302, 282, 333, 325, 768, 308, 325, 519, 373, 325, 519, 6308, 308, 284, 307, 325, 6308, 286, 312, 333, 288, 436, 307, 14, 72, 14, 69, 14, 73, 14, 82, 14, 78, 14, 65, 14, 77, 14, 69, 737, 1654, 6308, 308, 15, 73, 15, 84, 15, 69, 15854, 18877, 14, 267, 1449, 272, 367, 3031, 315, 3031, 44, 1024, 335, 8, 505, 304, 870, 3031, 13359, 199, 7378, 51, 275, 2097, 957, 2266, 8654, 2266, 846, 2266, 1308, 2266, 16294, 2266, 527, 937, 327, 703, 436, 880, 641, 199, 199, 4831, 275, 295, 14, 15434, 1204, 295, 14, 16075, 199, 199, 619, 275, 519, 20459, 768, 1204, 971, 66, 437, 971, 83, 10, 377, 971, 66, 3171, 199, 12368, 14848, 275, 519, 1154, 66, 16697, 971, 87, 11, 1204, 971, 87, 16697, 15840, 83, 11, 6113, 55, 9, 971, 87, 3342, 9, 971, 66, 7, 199, 7378, 275, 519, 10120, 2689, 83, 3171, 450, 21590, 904, 5234, 15840, 83, 10, 6113, 55, 30351, 904, 8, 2261, 9, 367, 2881, 315, 15265, 51, 566, 199, 199, 13887, 5172, 275, 295, 14, 2014, 8, 82, 1154, 55, 13854, 199, 13203, 63, 10710, 275, 295, 14, 2014, 8, 82, 20459, 971, 14, 1204, 971, 66, 577, 971, 83, 10, 593, 971, 83, 10, 377, 971, 66, 3196, 12846, 9, 199, 10089, 63, 10710, 275, 295, 14, 2014, 8, 272, 334, 82, 10120, 48, 28, 354, 6598, 83, 9, 971, 55, 10, 450, 83, 971, 55, 10223, 450, 334, 12368, 14848, 12, 619, 430, 435, 1362, 519, 10120, 48, 28, 2124, 30, 5169, 450, 83, 971, 55, 10, 450, 83, 971, 55, 10, 6393, 3171, 450, 334, 12368, 14848, 12, 15854, 63, 10710, 14, 3401, 9, 435, 1362, 519, 10120, 48, 28, 2261, 6598, 83, 3171, 450, 15265, 12, 12846, 9, 1169, 199, 199, 318, 3031, 44, 1024, 335, 8, 505, 304, 272, 1449, 1626, 6122, 1806, 18054, 3031, 7149, 4453, 1318, 2344, 272, 1830, 334, 549, 304, 267, 1336, 275, 32320, 63, 10710, 14, 1733, 8, 505, 9, 267, 340, 440, 1336, 26, 2059, 267, 4184, 275, 359, 1431, 14, 923, 480, 354, 11323, 435, 971, 355, 15854, 63, 10710, 14, 1294, 8, 1431, 14, 923, 480, 2124, 2237, 435, 971, 355, 359, 1431, 14, 923, 480, 2261, 11323, 267, 327, 16895, 2222, 4349, 8365, 267, 4184, 275, 359, 13887, 5172, 14, 954, 8594, 2064, 9, 367, 1777, 315, 4184, 61, 267, 327, 16895, 1006, 2701, 4184, 436, 1852, 12141, 267, 4184, 275, 359, 2064, 14, 2325, 342, 367, 1777, 315, 4184, 340, 822, 8, 2064, 13032, 16, 61, 267, 327, 4263, 314, 4184, 267, 1995, 2071, 83, 19437, 83, 4111, 83, 2, 450, 334, 4181, 59, 16, 467, 15671, 904, 8, 4181, 59, 17, 6809, 17, 2522, 4184, 1988, 17, 566, 267, 1318, 275, 1318, 59, 1431, 14, 500, 837, 61, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 511, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 295, 199, 199, 318, 511, 837, 272, 1318, 275, 971, 267, 1449, 2047, 883, 8966, 2739, 737, 3002, 354, 32, 1000, 14, 2124, 14, 957, 288, 503, 737, 612, 79, 21121, 15059, 1654, 15854, 4770, 15854, 2414, 14, 288, 6121, 737, 312, 399, 519, 302, 282, 333, 325, 768, 308, 325, 519, 373, 325, 519, 6308, 308, 284, 307, 325, 6308, 286, 312, 333, 288, 436, 307, 14, 72, 14, 69, 14, 73, 14, 82, 14, 78, 14, 65, 14, 77, 14, 69, 737, 1654, 6308, 308, 15, 73, 15, 84, 15, 69, 15854, 18877, 14, 267, 1449, 272, 367, 3031, 315, 3031, 44, 1024, 335, 8, 505, 304, 870, 3031, 13359, 199, 7378, 51, 275, 2097, 957, 2266, 8654, 2266, 846, 2266, 1308, 2266, 16294, 2266, 527, 937, 327, 703, 436, 880, 641, 199, 199, 4831, 275, 295, 14, 15434, 1204, 295, 14, 16075, 199, 199, 619, 275, 519, 20459, 768, 1204, 971, 66, 437, 971, 83, 10, 377, 971, 66, 3171, 199, 12368, 14848, 275, 519, 1154, 66, 16697, 971, 87, 11, 1204, 971, 87, 16697, 15840, 83, 11, 6113, 55, 9, 971, 87, 3342, 9, 971, 66, 7, 199, 7378, 275, 519, 10120, 2689, 83, 3171, 450, 21590, 904, 5234, 15840, 83, 10, 6113, 55, 30351, 904, 8, 2261, 9, 367, 2881, 315, 15265, 51, 566, 199, 199, 13887, 5172, 275, 295, 14, 2014, 8, 82, 1154, 55, 13854, 199, 13203, 63, 10710, 275, 295, 14, 2014, 8, 82, 20459, 971, 14, 1204, 971, 66, 577, 971, 83, 10, 593, 971, 83, 10, 377, 971, 66, 3196, 12846, 9, 199, 10089, 63, 10710, 275, 295, 14, 2014, 8, 272, 334, 82, 10120, 48, 28, 354, 6598, 83, 9, 971, 55, 10, 450, 83, 971, 55, 10223, 450, 334, 12368, 14848, 12, 619, 430, 435, 1362, 519, 10120, 48, 28, 2124, 30, 5169, 450, 83, 971, 55, 10, 450, 83, 971, 55, 10, 6393, 3171, 450, 334, 12368, 14848, 12, 15854, 63, 10710, 14, 3401, 9, 435, 1362, 519, 10120, 48, 28, 2261, 6598, 83, 3171, 450, 15265, 12, 12846, 9, 1169, 199, 199, 318, 3031, 44, 1024, 335, 8, 505, 304, 272, 1449, 1626, 6122, 1806, 18054, 3031, 7149, 4453, 1318, 2344, 272, 1830, 334, 549, 304, 267, 1336, 275, 32320, 63, 10710, 14, 1733, 8, 505, 9, 267, 340, 440, 1336, 26, 2059, 267, 4184, 275, 359, 1431, 14, 923, 480, 354, 11323, 435, 971, 355, 15854, 63, 10710, 14, 1294, 8, 1431, 14, 923, 480, 2124, 2237, 435, 971, 355, 359, 1431, 14, 923, 480, 2261, 11323, 267, 327, 16895, 2222, 4349, 8365, 267, 4184, 275, 359, 13887, 5172, 14, 954, 8594, 2064, 9, 367, 1777, 315, 4184, 61, 267, 327, 16895, 1006, 2701, 4184, 436, 1852, 12141, 267, 4184, 275, 359, 2064, 14, 2325, 342, 367, 1777, 315, 4184, 340, 822, 8, 2064, 13032, 16, 61, 267, 327, 4263, 314, 4184, 267, 1995, 2071, 83, 19437, 83, 4111, 83, 2, 450, 334, 4181, 59, 16, 467, 15671, 904, 8, 4181, 59, 17, 6809, 17, 2522, 4184, 1988, 17, 566, 267, 1318, 275, 1318, 59, 1431, 14, 500, 837, 61, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 511, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0 ]
mosdef-hub/foyer
foyer/tests/test_forcefield_parameters.py
1
10029
import numpy as np import pytest from foyer import Forcefield, forcefields from foyer.exceptions import MissingForceError, MissingParametersError from foyer.forcefield import get_available_forcefield_loaders from foyer.tests.base_test import BaseTest from foyer.tests.utils import get_fn @pytest.mark.skipif( condition="load_GAFF" not in map(lambda func: func.__name__, get_available_forcefield_loaders()), reason="GAFF Plugin is not installed", ) class TestForcefieldParameters(BaseTest): @pytest.fixture(scope="session") def gaff(self): return forcefields.load_GAFF() def test_gaff_missing_group(self, gaff): with pytest.raises(ValueError): gaff.get_parameters("missing", key=[]) def test_gaff_non_string_keys(self, gaff): with pytest.raises(TypeError): gaff.get_parameters("atoms", key=1) def test_gaff_bond_parameters_gaff(self, gaff): bond_params = gaff.get_parameters("harmonic_bonds", ["br", "ca"]) assert np.isclose(bond_params["length"], 0.19079) assert np.isclose(bond_params["k"], 219827.36) def test_gaff_bond_params_reversed(self, gaff): assert gaff.get_parameters( "harmonic_bonds", ["ca", "br"] ) == gaff.get_parameters("harmonic_bonds", ["ca", "br"]) def test_gaff_missing_bond_parameters(self, gaff): with pytest.raises(MissingParametersError): gaff.get_parameters("harmonic_bonds", ["str1", "str2"]) def test_gaff_angle_parameters(self, gaff): angle_params = gaff.get_parameters("harmonic_angles", ["f", "c1", "f"]) assert np.allclose( [angle_params["theta"], angle_params["k"]], [3.141592653589793, 487.0176], ) def test_gaff_angle_parameters_reversed(self, gaff): assert np.allclose( list( gaff.get_parameters( "harmonic_angles", ["f", "c2", "ha"] ).values() ), list( gaff.get_parameters( "harmonic_angles", ["ha", "c2", "f"] ).values() ), ) def test_gaff_missing_angle_parameters(self, gaff): with pytest.raises(MissingParametersError): gaff.get_parameters("harmonic_angles", ["1", "2", "3"]) def test_gaff_periodic_proper_parameters(self, gaff): periodic_proper_params = gaff.get_parameters( "periodic_propers", ["c3", "c", "sh", "hs"] ) assert np.allclose(periodic_proper_params["periodicity"], [2.0, 1.0]) assert np.allclose( periodic_proper_params["k"], [9.414, 5.4392000000000005] ) assert np.allclose( periodic_proper_params["phase"], [3.141592653589793, 3.141592653589793], ) def test_gaff_periodic_proper_parameters_reversed(self, gaff): assert np.allclose( list( gaff.get_parameters( "periodic_propers", ["c3", "c", "sh", "hs"] ).values() ), list( gaff.get_parameters( "periodic_propers", ["hs", "sh", "c", "c3"] ).values() ), ) def test_gaff_periodic_improper_parameters(self, gaff): periodic_improper_params = gaff.get_parameters( "periodic_impropers", ["c", "", "o", "o"] ) assert np.allclose(periodic_improper_params["periodicity"], [2.0]) assert np.allclose(periodic_improper_params["k"], [4.6024]) assert np.allclose( periodic_improper_params["phase"], [3.141592653589793] ) def test_gaff_periodic_improper_parameters_reversed(self, gaff): assert np.allclose( list( gaff.get_parameters( "periodic_impropers", ["c", "", "o", "o"] ).values() ), list( gaff.get_parameters( "periodic_impropers", ["c", "o", "", "o"] ).values() ), ) def test_gaff_proper_params_missing(self, gaff): with pytest.raises(MissingParametersError): gaff.get_parameters("periodic_impropers", ["a", "b", "c", "d"]) def test_gaff_scaling_factors(self, gaff): assert gaff.lj14scale == 0.5 assert np.isclose(gaff.coulomb14scale, 0.833333333) def test_opls_get_parameters_atoms(self, oplsaa): atom_params = oplsaa.get_parameters("atoms", "opls_145") assert atom_params["sigma"] == 0.355 assert atom_params["epsilon"] == 0.29288 def test_opls_get_parameters_atoms_list(self, oplsaa): atom_params = oplsaa.get_parameters("atoms", ["opls_145"]) assert atom_params["sigma"] == 0.355 assert atom_params["epsilon"] == 0.29288 def test_opls_get_parameters_atom_class(self, oplsaa): atom_params = oplsaa.get_parameters( "atoms", "CA", keys_are_atom_classes=True ) assert atom_params["sigma"] == 0.355 assert atom_params["epsilon"] == 0.29288 def test_opls_get_parameters_bonds(self, oplsaa): bond_params = oplsaa.get_parameters( "harmonic_bonds", ["opls_760", "opls_145"] ) assert bond_params["length"] == 0.146 assert bond_params["k"] == 334720.0 def test_opls_get_parameters_bonds_reversed(self, oplsaa): assert np.allclose( list( oplsaa.get_parameters( "harmonic_bonds", ["opls_760", "opls_145"] ).values() ), list( oplsaa.get_parameters( "harmonic_bonds", ["opls_145", "opls_760"] ).values() ), ) def test_opls_get_parameters_bonds_atom_classes_reversed(self, oplsaa): assert np.allclose( list( oplsaa.get_parameters( "harmonic_bonds", ["C_2", "O_2"], True ).values() ), list( oplsaa.get_parameters( "harmonic_bonds", ["O_2", "C_2"], True ).values() ), ) def test_opls_get_parameters_angle(self, oplsaa): angle_params = oplsaa.get_parameters( "harmonic_angles", ["opls_166", "opls_772", "opls_167"] ) assert np.allclose( [angle_params["theta"], angle_params["k"]], [2.0943950239, 585.76] ) def test_opls_get_parameters_angle_reversed(self, oplsaa): assert np.allclose( list( oplsaa.get_parameters( "harmonic_angles", ["opls_166", "opls_772", "opls_167"] ).values() ), list( oplsaa.get_parameters( "harmonic_angles", ["opls_167", "opls_772", "opls_166"] ).values() ), ) def test_opls_get_parameters_angle_atom_classes(self, oplsaa): angle_params = oplsaa.get_parameters( "harmonic_angles", ["CA", "C_2", "CA"], keys_are_atom_classes=True ) assert np.allclose( [angle_params["theta"], angle_params["k"]], [2.09439510239, 711.28] ) def test_opls_get_parameters_angle_atom_classes_reversed(self, oplsaa): assert np.allclose( list( oplsaa.get_parameters( "harmonic_angles", ["CA", "C", "O"], keys_are_atom_classes=True, ).values() ), list( oplsaa.get_parameters( "harmonic_angles", ["O", "C", "CA"], keys_are_atom_classes=True, ).values() ), ) def test_opls_get_parameters_rb_proper(self, oplsaa): proper_params = oplsaa.get_parameters( "rb_propers", ["opls_215", "opls_215", "opls_235", "opls_269"] ) assert np.allclose( [ proper_params["c0"], proper_params["c1"], proper_params["c2"], proper_params["c3"], proper_params["c4"], proper_params["c5"], ], [2.28446, 0.0, -2.28446, 0.0, 0.0, 0.0], ) def test_get_parameters_rb_proper_reversed(self, oplsaa): assert np.allclose( list( oplsaa.get_parameters( "rb_propers", ["opls_215", "opls_215", "opls_235", "opls_269"], ).values() ), list( oplsaa.get_parameters( "rb_propers", ["opls_269", "opls_235", "opls_215", "opls_215"], ).values() ), ) def test_opls_get_parameters_wildcard(self, oplsaa): proper_params = oplsaa.get_parameters( "rb_propers", ["", "opls_235", "opls_544", ""] ) assert np.allclose( [ proper_params["c0"], proper_params["c1"], proper_params["c2"], proper_params["c3"], proper_params["c4"], proper_params["c5"], ], [30.334, 0.0, -30.334, 0.0, 0.0, 0.0], ) def test_opls_missing_force(self, oplsaa): with pytest.raises(MissingForceError): oplsaa.get_parameters("periodic_propers", key=["a", "b", "c", "d"]) def test_opls_scaling_factors(self, oplsaa): assert oplsaa.lj14scale == 0.5 assert oplsaa.coulomb14scale == 0.5 def test_missing_scaling_factors(self): ff = Forcefield(forcefield_files=(get_fn("validate_customtypes.xml"))) with pytest.raises(AttributeError): assert ff.lj14scale with pytest.raises(AttributeError): assert ff.coulomb14scale
mit
[ 646, 2680, 465, 980, 199, 646, 4613, 199, 199, 504, 7090, 23009, 492, 18771, 698, 12, 3542, 955, 199, 504, 7090, 23009, 14, 3924, 492, 15626, 13606, 547, 12, 15626, 5976, 547, 199, 504, 7090, 23009, 14, 3990, 698, 492, 664, 63, 4561, 63, 3990, 698, 63, 16370, 199, 504, 7090, 23009, 14, 2219, 14, 1095, 63, 396, 492, 3523, 774, 199, 504, 7090, 23009, 14, 2219, 14, 1208, 492, 664, 63, 2324, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 272, 5558, 628, 912, 63, 9741, 1665, 2, 272, 440, 315, 2341, 8, 2734, 2562, 26, 2562, 855, 354, 3108, 664, 63, 4561, 63, 3990, 698, 63, 16370, 4000, 272, 4499, 628, 9741, 1665, 11349, 365, 440, 4903, 401, 199, 9, 199, 533, 1379, 13606, 698, 5976, 8, 23170, 304, 272, 768, 4462, 14, 5997, 8, 2645, 628, 1730, 531, 272, 347, 486, 9181, 8, 277, 304, 267, 372, 3542, 955, 14, 912, 63, 9741, 1665, 342, 339, 347, 511, 63, 5294, 556, 63, 4752, 63, 923, 8, 277, 12, 486, 9181, 304, 267, 543, 4613, 14, 3536, 8, 3393, 304, 288, 486, 9181, 14, 362, 63, 3214, 480, 4752, 401, 790, 14285, 339, 347, 511, 63, 5294, 556, 63, 2865, 63, 875, 63, 1612, 8, 277, 12, 486, 9181, 304, 267, 543, 4613, 14, 3536, 8, 4333, 304, 288, 486, 9181, 14, 362, 63, 3214, 480, 11521, 401, 790, 29, 17, 9, 339, 347, 511, 63, 5294, 556, 63, 21410, 63, 3214, 63, 5294, 556, 8, 277, 12, 486, 9181, 304, 267, 23119, 63, 1162, 275, 486, 9181, 14, 362, 63, 3214, 480, 8210, 16082, 63, 27816, 401, 2097, 3289, 401, 298, 696, 3135, 267, 702, 980, 14, 31899, 8, 21410, 63, 1162, 905, 1267, 2255, 378, 14, 1167, 19000, 9, 267, 702, 980, 14, 31899, 8, 21410, 63, 1162, 905, 75, 2255, 499, 10905, 1465, 14, 1344, 9, 339, 347, 511, 63, 5294, 556, 63, 21410, 63, 1162, 63, 13501, 8, 277, 12, 486, 9181, 304, 267, 702, 486, 9181, 14, 362, 63, 3214, 8, 288, 298, 8210, 16082, 63, 27816, 401, 2097, 696, 401, 298, 3289, 937, 267, 776, 508, 486, 9181, 14, 362, 63, 3214, 480, 8210, 16082, 63, 27816, 401, 2097, 696, 401, 298, 3289, 3135, 339, 347, 511, 63, 5294, 556, 63, 4752, 63, 21410, 63, 3214, 8, 277, 12, 486, 9181, 304, 267, 543, 4613, 14, 3536, 8, 7718, 5976, 547, 304, 288, 486, 9181, 14, 362, 63, 3214, 480, 8210, 16082, 63, 27816, 401, 2097, 495, 17, 401, 298, 495, 18, 3135, 339, 347, 511, 63, 5294, 556, 63, 4593, 63, 3214, 8, 277, 12, 486, 9181, 304, 267, 9324, 63, 1162, 275, 486, 9181, 14, 362, 63, 3214, 480, 8210, 16082, 63, 13162, 401, 2097, 70, 401, 298, 67, 17, 401, 298, 70, 3135, 267, 702, 980, 14, 7520, 8, 288, 359, 4593, 63, 1162, 905, 9337, 2255, 9324, 63, 1162, 905, 75, 18396, 288, 359, 19, 14, 1079, 9327, 1479, 7920, 1407, 26153, 12, 841, 1555, 14, 614, 2114, 467, 267, 776, 339, 347, 511, 63, 5294, 556, 63, 4593, 63, 3214, 63, 13501, 8, 277, 12, 486, 9181, 304, 267, 702, 980, 14, 7520, 8, 288, 769, 8, 355, 486, 9181, 14, 362, 63, 3214, 8, 490, 298, 8210, 16082, 63, 13162, 401, 2097, 70, 401, 298, 67, 18, 401, 298, 2411, 937, 355, 7092, 1459, 342, 288, 2318, 288, 769, 8, 355, 486, 9181, 14, 362, 63, 3214, 8, 490, 298, 8210, 16082, 63, 13162, 401, 2097, 2411, 401, 298, 67, 18, 401, 298, 70, 937, 355, 7092, 1459, 342, 288, 2318, 267, 776, 339, 347, 511, 63, 5294, 556, 63, 4752, 63, 4593, 63, 3214, 8, 277, 12, 486, 9181, 304, 267, 543, 4613, 14, 3536, 8, 7718, 5976, 547, 304, 288, 486, 9181, 14, 362, 63, 3214, 480, 8210, 16082, 63, 13162, 401, 2097, 17, 401, 298, 18, 401, 298, 19, 3135, 339, 347, 511, 63, 5294, 556, 63, 20339, 63, 28314, 63, 3214, 8, 277, 12, 486, 9181, 304, 267, 18745, 63, 28314, 63, 1162, 275, 486, 9181, 14, 362, 63, 3214, 8, 288, 298, 20339, 63, 28314, 83, 401, 2097, 67, 19, 401, 298, 67, 401, 298, 609, 401, 298, 4213, 937, 267, 776, 267, 702, 980, 14, 7520, 8, 20339, 63, 28314, 63, 1162, 905, 529, 2308, 328, 3690, 2255, 359, 18, 14, 16, 12, 413, 14, 16, 566, 267, 702, 980, 14, 7520, 8, 288, 18745, 63, 28314, 63, 1162, 905, 75, 2255, 359, 25, 14, 25250, 12, 959, 14, 20, 14042, 3607, 15646, 61, 267, 776, 267, 702, 980, 14, 7520, 8, 288, 18745, 63, 28314, 63, 1162, 905, 6971, 2255, 288, 359, 19, 14, 1079, 9327, 1479, 7920, 1407, 26153, 12, 650, 14, 1079, 9327, 1479, 7920, 1407, 26153, 467, 267, 776, 339, 347, 511, 63, 5294, 556, 63, 20339, 63, 28314, 63, 3214, 63, 13501, 8, 277, 12, 486, 9181, 304, 267, 702, 980, 14, 7520, 8, 288, 769, 8, 355, 486, 9181, 14, 362, 63, 3214, 8, 490, 298, 20339, 63, 28314, 83, 401, 2097, 67, 19, 401, 298, 67, 401, 298, 609, 401, 298, 4213, 937, 355, 7092, 1459, 342, 288, 2318, 288, 769, 8, 355, 486, 9181, 14, 362, 63, 3214, 8, 490, 298, 20339, 63, 28314, 83, 401, 2097, 4213, 401, 298, 609, 401, 298, 67, 401, 298, 67, 19, 937, 355, 7092, 1459, 342, 288, 2318, 267, 776, 339, 347, 511, 63, 5294, 556, 63, 20339, 63, 3236, 9198, 63, 3214, 8, 277, 12, 486, 9181, 304, 267, 18745, 63, 3236, 9198, 63, 1162, 275, 486, 9181, 14, 362, 63, 3214, 8, 288, 298, 20339, 63, 3236, 9198, 83, 401, 2097, 67, 401, 4873, 298, 79, 401, 298, 79, 937, 267, 776, 267, 702, 980, 14, 7520, 8, 20339, 63, 3236, 9198, 63, 1162, 905, 529, 2308, 328, 3690, 2255, 359, 18, 14, 16, 566, 267, 702, 980, 14, 7520, 8, 20339, 63, 3236, 9198, 63, 1162, 905, 75, 2255, 359, 20, 14, 22, 5284, 566, 267, 702, 980, 14, 7520, 8, 288, 18745, 63, 3236, 9198, 63, 1162, 905, 6971, 2255, 359, 19, 14, 1079, 9327, 1479, 7920, 1407, 26153, 61, 267, 776, 339, 347 ]
[ 2680, 465, 980, 199, 646, 4613, 199, 199, 504, 7090, 23009, 492, 18771, 698, 12, 3542, 955, 199, 504, 7090, 23009, 14, 3924, 492, 15626, 13606, 547, 12, 15626, 5976, 547, 199, 504, 7090, 23009, 14, 3990, 698, 492, 664, 63, 4561, 63, 3990, 698, 63, 16370, 199, 504, 7090, 23009, 14, 2219, 14, 1095, 63, 396, 492, 3523, 774, 199, 504, 7090, 23009, 14, 2219, 14, 1208, 492, 664, 63, 2324, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 272, 5558, 628, 912, 63, 9741, 1665, 2, 272, 440, 315, 2341, 8, 2734, 2562, 26, 2562, 855, 354, 3108, 664, 63, 4561, 63, 3990, 698, 63, 16370, 4000, 272, 4499, 628, 9741, 1665, 11349, 365, 440, 4903, 401, 199, 9, 199, 533, 1379, 13606, 698, 5976, 8, 23170, 304, 272, 768, 4462, 14, 5997, 8, 2645, 628, 1730, 531, 272, 347, 486, 9181, 8, 277, 304, 267, 372, 3542, 955, 14, 912, 63, 9741, 1665, 342, 339, 347, 511, 63, 5294, 556, 63, 4752, 63, 923, 8, 277, 12, 486, 9181, 304, 267, 543, 4613, 14, 3536, 8, 3393, 304, 288, 486, 9181, 14, 362, 63, 3214, 480, 4752, 401, 790, 14285, 339, 347, 511, 63, 5294, 556, 63, 2865, 63, 875, 63, 1612, 8, 277, 12, 486, 9181, 304, 267, 543, 4613, 14, 3536, 8, 4333, 304, 288, 486, 9181, 14, 362, 63, 3214, 480, 11521, 401, 790, 29, 17, 9, 339, 347, 511, 63, 5294, 556, 63, 21410, 63, 3214, 63, 5294, 556, 8, 277, 12, 486, 9181, 304, 267, 23119, 63, 1162, 275, 486, 9181, 14, 362, 63, 3214, 480, 8210, 16082, 63, 27816, 401, 2097, 3289, 401, 298, 696, 3135, 267, 702, 980, 14, 31899, 8, 21410, 63, 1162, 905, 1267, 2255, 378, 14, 1167, 19000, 9, 267, 702, 980, 14, 31899, 8, 21410, 63, 1162, 905, 75, 2255, 499, 10905, 1465, 14, 1344, 9, 339, 347, 511, 63, 5294, 556, 63, 21410, 63, 1162, 63, 13501, 8, 277, 12, 486, 9181, 304, 267, 702, 486, 9181, 14, 362, 63, 3214, 8, 288, 298, 8210, 16082, 63, 27816, 401, 2097, 696, 401, 298, 3289, 937, 267, 776, 508, 486, 9181, 14, 362, 63, 3214, 480, 8210, 16082, 63, 27816, 401, 2097, 696, 401, 298, 3289, 3135, 339, 347, 511, 63, 5294, 556, 63, 4752, 63, 21410, 63, 3214, 8, 277, 12, 486, 9181, 304, 267, 543, 4613, 14, 3536, 8, 7718, 5976, 547, 304, 288, 486, 9181, 14, 362, 63, 3214, 480, 8210, 16082, 63, 27816, 401, 2097, 495, 17, 401, 298, 495, 18, 3135, 339, 347, 511, 63, 5294, 556, 63, 4593, 63, 3214, 8, 277, 12, 486, 9181, 304, 267, 9324, 63, 1162, 275, 486, 9181, 14, 362, 63, 3214, 480, 8210, 16082, 63, 13162, 401, 2097, 70, 401, 298, 67, 17, 401, 298, 70, 3135, 267, 702, 980, 14, 7520, 8, 288, 359, 4593, 63, 1162, 905, 9337, 2255, 9324, 63, 1162, 905, 75, 18396, 288, 359, 19, 14, 1079, 9327, 1479, 7920, 1407, 26153, 12, 841, 1555, 14, 614, 2114, 467, 267, 776, 339, 347, 511, 63, 5294, 556, 63, 4593, 63, 3214, 63, 13501, 8, 277, 12, 486, 9181, 304, 267, 702, 980, 14, 7520, 8, 288, 769, 8, 355, 486, 9181, 14, 362, 63, 3214, 8, 490, 298, 8210, 16082, 63, 13162, 401, 2097, 70, 401, 298, 67, 18, 401, 298, 2411, 937, 355, 7092, 1459, 342, 288, 2318, 288, 769, 8, 355, 486, 9181, 14, 362, 63, 3214, 8, 490, 298, 8210, 16082, 63, 13162, 401, 2097, 2411, 401, 298, 67, 18, 401, 298, 70, 937, 355, 7092, 1459, 342, 288, 2318, 267, 776, 339, 347, 511, 63, 5294, 556, 63, 4752, 63, 4593, 63, 3214, 8, 277, 12, 486, 9181, 304, 267, 543, 4613, 14, 3536, 8, 7718, 5976, 547, 304, 288, 486, 9181, 14, 362, 63, 3214, 480, 8210, 16082, 63, 13162, 401, 2097, 17, 401, 298, 18, 401, 298, 19, 3135, 339, 347, 511, 63, 5294, 556, 63, 20339, 63, 28314, 63, 3214, 8, 277, 12, 486, 9181, 304, 267, 18745, 63, 28314, 63, 1162, 275, 486, 9181, 14, 362, 63, 3214, 8, 288, 298, 20339, 63, 28314, 83, 401, 2097, 67, 19, 401, 298, 67, 401, 298, 609, 401, 298, 4213, 937, 267, 776, 267, 702, 980, 14, 7520, 8, 20339, 63, 28314, 63, 1162, 905, 529, 2308, 328, 3690, 2255, 359, 18, 14, 16, 12, 413, 14, 16, 566, 267, 702, 980, 14, 7520, 8, 288, 18745, 63, 28314, 63, 1162, 905, 75, 2255, 359, 25, 14, 25250, 12, 959, 14, 20, 14042, 3607, 15646, 61, 267, 776, 267, 702, 980, 14, 7520, 8, 288, 18745, 63, 28314, 63, 1162, 905, 6971, 2255, 288, 359, 19, 14, 1079, 9327, 1479, 7920, 1407, 26153, 12, 650, 14, 1079, 9327, 1479, 7920, 1407, 26153, 467, 267, 776, 339, 347, 511, 63, 5294, 556, 63, 20339, 63, 28314, 63, 3214, 63, 13501, 8, 277, 12, 486, 9181, 304, 267, 702, 980, 14, 7520, 8, 288, 769, 8, 355, 486, 9181, 14, 362, 63, 3214, 8, 490, 298, 20339, 63, 28314, 83, 401, 2097, 67, 19, 401, 298, 67, 401, 298, 609, 401, 298, 4213, 937, 355, 7092, 1459, 342, 288, 2318, 288, 769, 8, 355, 486, 9181, 14, 362, 63, 3214, 8, 490, 298, 20339, 63, 28314, 83, 401, 2097, 4213, 401, 298, 609, 401, 298, 67, 401, 298, 67, 19, 937, 355, 7092, 1459, 342, 288, 2318, 267, 776, 339, 347, 511, 63, 5294, 556, 63, 20339, 63, 3236, 9198, 63, 3214, 8, 277, 12, 486, 9181, 304, 267, 18745, 63, 3236, 9198, 63, 1162, 275, 486, 9181, 14, 362, 63, 3214, 8, 288, 298, 20339, 63, 3236, 9198, 83, 401, 2097, 67, 401, 4873, 298, 79, 401, 298, 79, 937, 267, 776, 267, 702, 980, 14, 7520, 8, 20339, 63, 3236, 9198, 63, 1162, 905, 529, 2308, 328, 3690, 2255, 359, 18, 14, 16, 566, 267, 702, 980, 14, 7520, 8, 20339, 63, 3236, 9198, 63, 1162, 905, 75, 2255, 359, 20, 14, 22, 5284, 566, 267, 702, 980, 14, 7520, 8, 288, 18745, 63, 3236, 9198, 63, 1162, 905, 6971, 2255, 359, 19, 14, 1079, 9327, 1479, 7920, 1407, 26153, 61, 267, 776, 339, 347, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kamilmowinski/nao_gesture
scripts/nao.py
2
1999
#!/usr/bin/env python import rospy import math from naoqi import ALProxy from my_kinnect.msg import NaoCoords class NaoMonkey: PART = { 'LShoulder': ['LShoulderPitch', 'LShoulderRoll'], 'RShoulder': ['RShoulderPitch', 'RShoulderRoll'], 'LElbow': ['LElbowYaw', 'LElbowRoll'], 'RElbow': ['RElbowYaw', 'RElbowRoll'], 'Head': ['HeadYaw', 'HeadPitch'], } LIMITS = { 'Head': [[-2.0, 2.0], [-0.67, 0.51]], 'LShoulder': [[-2.0, 2.0], [-0.31, 1.32]], 'RShoulder': [[-2.0, 2.0], [-1.32, 0.31]], 'LElbow': [[-2.0, 2.0], [-1.54, -0.03]], 'RElbow': [[-2.0, 2.0], [0.03, 1.54]], } def __init__(self): rospy.init_node('nao_mykinect', anonymous=True) self.listener = rospy.Subscriber('nao', NaoCoords, self.move) ip = rospy.get_param('~ip', '10.104.16.141') port = int(rospy.get_param('~port', '9559')) self.al = ALProxy("ALAutonomousLife", ip, port) self.postureProxy = ALProxy("ALRobotPosture", ip, port) self.motionProxy = ALProxy("ALMotion", ip, port) self.al.setState("disabled") for part in ["Head", "LArm", "RArm"]: self.motionProxy.setStiffnesses(part, 1.0) rospy.loginfo(self.motionProxy.getSummary()) def move(self, coords): part = coords.Part.data angles1 = coords.Angles1 angles2 = coords.Angles2 angles = [float(angles1.data), float(angles2.data)] speed = 1.0 if part not in NaoMonkey.PART: error_msg = 'Wat? I Do not have ' + str(part) rospy.loginfo(error_msg) return if len(NaoMonkey.PART[part]) != len(angles): error_msg = 'Wat? What shall i do with rest joint?' rospy.loginfo(error_msg) return angles = map(lambda x: float(x)*math.pi/180.0, angles) for limit, angle in zip(NaoMonkey.LIMITS[part], angles): if angle < limit[0] or angle > limit[1]: error_msg = 'Wat? Limits man!' rospy.loginfo(error_msg) self.motionProxy.setAngles(NaoMonkey.PART[part], angles, speed); if __name__ == '__main__': try: NaoMonkey() rospy.spin() except rospy.ROSInterruptException: pass
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 646, 21848, 199, 646, 3473, 199, 504, 302, 8035, 23104, 492, 12112, 4936, 199, 504, 3002, 63, 19269, 78, 449, 14, 1328, 492, 653, 8035, 29734, 421, 199, 533, 653, 8035, 6671, 498, 26, 199, 198, 14848, 275, 469, 507, 198, 7, 5296, 526, 348, 424, 356, 788, 5296, 526, 348, 424, 48, 9414, 297, 283, 5296, 526, 348, 424, 24363, 995, 507, 198, 7, 15062, 526, 348, 424, 356, 788, 15062, 526, 348, 424, 48, 9414, 297, 283, 15062, 526, 348, 424, 24363, 995, 507, 198, 7, 906, 6374, 583, 356, 788, 906, 6374, 583, 57, 10084, 297, 283, 906, 6374, 583, 24363, 995, 507, 198, 7, 907, 6374, 583, 356, 788, 907, 6374, 583, 57, 10084, 297, 283, 907, 6374, 583, 24363, 995, 507, 198, 7, 11664, 356, 788, 11664, 57, 10084, 297, 283, 11664, 48, 9414, 995, 199, 198, 93, 199, 198, 13387, 51, 275, 469, 507, 198, 7, 11664, 356, 27291, 18, 14, 16, 12, 499, 14, 16, 467, 5243, 16, 14, 1822, 12, 378, 14, 2869, 2365, 507, 198, 7, 5296, 526, 348, 424, 356, 27291, 18, 14, 16, 12, 499, 14, 16, 467, 5243, 16, 14, 2192, 12, 413, 14, 708, 2365, 507, 198, 7, 15062, 526, 348, 424, 356, 27291, 18, 14, 16, 12, 499, 14, 16, 467, 5243, 17, 14, 708, 12, 378, 14, 2192, 2365, 507, 198, 7, 906, 6374, 583, 356, 27291, 18, 14, 16, 12, 499, 14, 16, 467, 5243, 17, 14, 1477, 12, 446, 16, 14, 1644, 2365, 507, 198, 7, 907, 6374, 583, 356, 27291, 18, 14, 16, 12, 499, 14, 16, 467, 359, 16, 14, 1644, 12, 413, 14, 1477, 2365, 199, 198, 93, 421, 198, 318, 636, 826, 721, 277, 304, 507, 198, 4796, 647, 14, 826, 63, 932, 360, 3540, 79, 63, 1662, 19269, 449, 297, 16535, 29, 549, 9, 2742, 198, 277, 14, 9799, 275, 21848, 14, 28638, 360, 3540, 79, 297, 653, 8035, 29734, 12, 291, 14, 1185, 9, 355, 3384, 275, 21848, 14, 362, 63, 635, 21114, 711, 297, 283, 709, 14, 6785, 14, 975, 14, 12735, 358, 507, 198, 719, 275, 1109, 8, 4796, 647, 14, 362, 63, 635, 21114, 719, 297, 283, 25, 17257, 1333, 2742, 198, 277, 14, 279, 275, 12112, 4936, 480, 748, 23570, 30671, 7376, 22637, 401, 3384, 12, 1844, 9, 507, 198, 277, 14, 1932, 608, 4936, 275, 12112, 4936, 480, 748, 21823, 6564, 608, 401, 3384, 12, 1844, 9, 507, 198, 277, 14, 15335, 4936, 275, 12112, 4936, 480, 748, 24875, 401, 3384, 12, 1844, 9, 9068, 198, 277, 14, 279, 14, 409, 2223, 480, 7011, 531, 507, 198, 509, 1777, 315, 2097, 11664, 401, 298, 44, 1596, 77, 401, 298, 50, 1596, 77, 6229, 686, 198, 277, 14, 15335, 4936, 14, 409, 51, 29119, 17775, 874, 8, 2064, 12, 413, 14, 16, 9, 507, 198, 4796, 647, 14, 793, 815, 8, 277, 14, 15335, 4936, 14, 362, 10407, 1012, 421, 198, 318, 4057, 8, 277, 12, 13259, 304, 507, 198, 2064, 275, 13259, 14, 8416, 14, 576, 507, 198, 13162, 17, 275, 13259, 14, 2493, 27033, 17, 507, 198, 13162, 18, 275, 13259, 14, 2493, 27033, 18, 507, 198, 13162, 275, 359, 1609, 8, 13162, 17, 14, 576, 395, 2069, 8, 13162, 18, 14, 576, 1874, 507, 198, 7625, 275, 413, 14, 16, 507, 198, 692, 1777, 440, 315, 653, 8035, 6671, 498, 14, 14848, 26, 686, 198, 705, 63, 1328, 275, 283, 55, 292, 31, 473, 4226, 440, 1172, 283, 435, 620, 8, 2064, 9, 686, 198, 4796, 647, 14, 793, 815, 8, 705, 63, 1328, 9, 686, 198, 1107, 507, 198, 692, 822, 8, 46, 8035, 6671, 498, 14, 14848, 59, 2064, 566, 1137, 822, 8, 13162, 304, 686, 198, 705, 63, 1328, 275, 283, 55, 292, 31, 14791, 10989, 284, 886, 543, 4618, 22211, 14069, 686, 198, 4796, 647, 14, 793, 815, 8, 705, 63, 1328, 9, 686, 198, 1107, 507, 198, 13162, 275, 2341, 8, 2734, 671, 26, 2069, 8, 88, 3342, 3442, 14, 1038, 15, 7663, 14, 16, 12, 22597, 9, 507, 198, 509, 2304, 12, 9324, 315, 3482, 8, 46, 8035, 6671, 498, 14, 13387, 51, 59, 2064, 467, 22597, 304, 686, 198, 692, 9324, 665, 2304, 59, 16, 61, 503, 9324, 690, 2304, 59, 17, 2189, 1585, 198, 705, 63, 1328, 275, 283, 55, 292, 31, 14620, 1405, 2169, 11213, 1585, 198, 4796, 647, 14, 793, 815, 8, 705, 63, 1328, 9, 507, 198, 277, 14, 15335, 4936, 14, 409, 2493, 27033, 8, 46, 8035, 6671, 498, 14, 14848, 59, 2064, 467, 22597, 12, 8112, 2736, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 199, 198, 893, 26, 507, 198, 46, 8035, 6671, 498, 342, 507, 198, 4796, 647, 14, 14809, 342, 199, 198, 2590, 21848, 14, 1092, 51, 10647, 1726, 26, 507, 198, 1529, 198, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 646, 21848, 199, 646, 3473, 199, 504, 302, 8035, 23104, 492, 12112, 4936, 199, 504, 3002, 63, 19269, 78, 449, 14, 1328, 492, 653, 8035, 29734, 421, 199, 533, 653, 8035, 6671, 498, 26, 199, 198, 14848, 275, 469, 507, 198, 7, 5296, 526, 348, 424, 356, 788, 5296, 526, 348, 424, 48, 9414, 297, 283, 5296, 526, 348, 424, 24363, 995, 507, 198, 7, 15062, 526, 348, 424, 356, 788, 15062, 526, 348, 424, 48, 9414, 297, 283, 15062, 526, 348, 424, 24363, 995, 507, 198, 7, 906, 6374, 583, 356, 788, 906, 6374, 583, 57, 10084, 297, 283, 906, 6374, 583, 24363, 995, 507, 198, 7, 907, 6374, 583, 356, 788, 907, 6374, 583, 57, 10084, 297, 283, 907, 6374, 583, 24363, 995, 507, 198, 7, 11664, 356, 788, 11664, 57, 10084, 297, 283, 11664, 48, 9414, 995, 199, 198, 93, 199, 198, 13387, 51, 275, 469, 507, 198, 7, 11664, 356, 27291, 18, 14, 16, 12, 499, 14, 16, 467, 5243, 16, 14, 1822, 12, 378, 14, 2869, 2365, 507, 198, 7, 5296, 526, 348, 424, 356, 27291, 18, 14, 16, 12, 499, 14, 16, 467, 5243, 16, 14, 2192, 12, 413, 14, 708, 2365, 507, 198, 7, 15062, 526, 348, 424, 356, 27291, 18, 14, 16, 12, 499, 14, 16, 467, 5243, 17, 14, 708, 12, 378, 14, 2192, 2365, 507, 198, 7, 906, 6374, 583, 356, 27291, 18, 14, 16, 12, 499, 14, 16, 467, 5243, 17, 14, 1477, 12, 446, 16, 14, 1644, 2365, 507, 198, 7, 907, 6374, 583, 356, 27291, 18, 14, 16, 12, 499, 14, 16, 467, 359, 16, 14, 1644, 12, 413, 14, 1477, 2365, 199, 198, 93, 421, 198, 318, 636, 826, 721, 277, 304, 507, 198, 4796, 647, 14, 826, 63, 932, 360, 3540, 79, 63, 1662, 19269, 449, 297, 16535, 29, 549, 9, 2742, 198, 277, 14, 9799, 275, 21848, 14, 28638, 360, 3540, 79, 297, 653, 8035, 29734, 12, 291, 14, 1185, 9, 355, 3384, 275, 21848, 14, 362, 63, 635, 21114, 711, 297, 283, 709, 14, 6785, 14, 975, 14, 12735, 358, 507, 198, 719, 275, 1109, 8, 4796, 647, 14, 362, 63, 635, 21114, 719, 297, 283, 25, 17257, 1333, 2742, 198, 277, 14, 279, 275, 12112, 4936, 480, 748, 23570, 30671, 7376, 22637, 401, 3384, 12, 1844, 9, 507, 198, 277, 14, 1932, 608, 4936, 275, 12112, 4936, 480, 748, 21823, 6564, 608, 401, 3384, 12, 1844, 9, 507, 198, 277, 14, 15335, 4936, 275, 12112, 4936, 480, 748, 24875, 401, 3384, 12, 1844, 9, 9068, 198, 277, 14, 279, 14, 409, 2223, 480, 7011, 531, 507, 198, 509, 1777, 315, 2097, 11664, 401, 298, 44, 1596, 77, 401, 298, 50, 1596, 77, 6229, 686, 198, 277, 14, 15335, 4936, 14, 409, 51, 29119, 17775, 874, 8, 2064, 12, 413, 14, 16, 9, 507, 198, 4796, 647, 14, 793, 815, 8, 277, 14, 15335, 4936, 14, 362, 10407, 1012, 421, 198, 318, 4057, 8, 277, 12, 13259, 304, 507, 198, 2064, 275, 13259, 14, 8416, 14, 576, 507, 198, 13162, 17, 275, 13259, 14, 2493, 27033, 17, 507, 198, 13162, 18, 275, 13259, 14, 2493, 27033, 18, 507, 198, 13162, 275, 359, 1609, 8, 13162, 17, 14, 576, 395, 2069, 8, 13162, 18, 14, 576, 1874, 507, 198, 7625, 275, 413, 14, 16, 507, 198, 692, 1777, 440, 315, 653, 8035, 6671, 498, 14, 14848, 26, 686, 198, 705, 63, 1328, 275, 283, 55, 292, 31, 473, 4226, 440, 1172, 283, 435, 620, 8, 2064, 9, 686, 198, 4796, 647, 14, 793, 815, 8, 705, 63, 1328, 9, 686, 198, 1107, 507, 198, 692, 822, 8, 46, 8035, 6671, 498, 14, 14848, 59, 2064, 566, 1137, 822, 8, 13162, 304, 686, 198, 705, 63, 1328, 275, 283, 55, 292, 31, 14791, 10989, 284, 886, 543, 4618, 22211, 14069, 686, 198, 4796, 647, 14, 793, 815, 8, 705, 63, 1328, 9, 686, 198, 1107, 507, 198, 13162, 275, 2341, 8, 2734, 671, 26, 2069, 8, 88, 3342, 3442, 14, 1038, 15, 7663, 14, 16, 12, 22597, 9, 507, 198, 509, 2304, 12, 9324, 315, 3482, 8, 46, 8035, 6671, 498, 14, 13387, 51, 59, 2064, 467, 22597, 304, 686, 198, 692, 9324, 665, 2304, 59, 16, 61, 503, 9324, 690, 2304, 59, 17, 2189, 1585, 198, 705, 63, 1328, 275, 283, 55, 292, 31, 14620, 1405, 2169, 11213, 1585, 198, 4796, 647, 14, 793, 815, 8, 705, 63, 1328, 9, 507, 198, 277, 14, 15335, 4936, 14, 409, 2493, 27033, 8, 46, 8035, 6671, 498, 14, 14848, 59, 2064, 467, 22597, 12, 8112, 2736, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 199, 198, 893, 26, 507, 198, 46, 8035, 6671, 498, 342, 507, 198, 4796, 647, 14, 14809, 342, 199, 198, 2590, 21848, 14, 1092, 51, 10647, 1726, 26, 507, 198, 1529, 198, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
piosz/test-infra
gubernator/pb_glance_test.py
36
1815
# Copyright 2016 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import unittest import pb_glance def tostr(data): if isinstance(data, list): return ''.join(c if isinstance(c, str) else chr(c) for c in data) return data class PBGlanceTest(unittest.TestCase): def expect(self, data, expected, types=None): result = pb_glance.parse_protobuf(tostr(data), types) self.assertEqual(result, expected) def test_basic(self): self.expect( [0, 1, # varint 0, 0x96, 1, # multi-byte varint (1<<3)|1, 'abcdefgh', # 64-bit (2<<3)|2, 5, 'value', # length-delimited (string) (3<<3)|5, 'abcd', # 32-bit ], { 0: [1, 150], 1: ['abcdefgh'], 2: ['value'], 3: ['abcd'], }) def test_embedded(self): self.expect([2, 2, 3<<3, 1], {0: [{3: [1]}]}, {0: {}}) def test_field_names(self): self.expect([2, 2, 'hi'], {'greeting': ['hi']}, {0: 'greeting'}) def test_embedded_names(self): self.expect( [2, 4, (3<<3)|2, 2, 'hi'], {'msg': [{'greeting': ['hi']}]}, {0: {'name': 'msg', 3: 'greeting'}})
apache-2.0
[ 3, 1898, 7800, 710, 28723, 6642, 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, 646, 2882, 199, 199, 646, 10446, 63, 18773, 421, 199, 318, 370, 495, 8, 576, 304, 272, 340, 1228, 8, 576, 12, 769, 304, 267, 372, 6522, 904, 8, 67, 340, 1228, 8, 67, 12, 620, 9, 587, 8678, 8, 67, 9, 367, 286, 315, 666, 9, 272, 372, 666, 421, 199, 533, 510, 34, 17541, 554, 774, 8, 2796, 14, 1746, 304, 272, 347, 4282, 8, 277, 12, 666, 12, 1420, 12, 2943, 29, 403, 304, 267, 754, 275, 10446, 63, 18773, 14, 1122, 63, 7204, 8, 475, 495, 8, 576, 395, 2943, 9, 267, 291, 14, 629, 8, 1099, 12, 1420, 9, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 291, 14, 4921, 8, 288, 359, 16, 12, 413, 12, 8295, 327, 2729, 442, 1467, 378, 12, 378, 88, 2534, 12, 413, 12, 3322, 327, 3510, 13, 4414, 2729, 442, 1467, 334, 17, 8999, 19, 8636, 17, 12, 283, 16238, 297, 221, 327, 5049, 13, 2075, 1467, 334, 18, 8999, 19, 8636, 18, 12, 959, 12, 283, 585, 297, 221, 327, 2582, 13, 25672, 334, 875, 9, 1467, 334, 19, 8999, 19, 8636, 21, 12, 283, 13591, 297, 420, 327, 4337, 13, 2075, 288, 2156, 288, 469, 355, 378, 26, 359, 17, 12, 14711, 467, 355, 413, 26, 788, 16238, 995, 355, 499, 26, 788, 585, 995, 355, 650, 26, 788, 13591, 995, 288, 3828, 339, 347, 511, 63, 18757, 8, 277, 304, 267, 291, 14, 4921, 779, 18, 12, 499, 12, 650, 8999, 19, 12, 413, 467, 469, 16, 26, 8910, 19, 26, 359, 17, 9420, 13888, 469, 16, 26, 1052, 1552, 339, 347, 511, 63, 698, 63, 1247, 8, 277, 304, 267, 291, 14, 4921, 779, 18, 12, 499, 12, 283, 5812, 995, 791, 71, 23457, 356, 788, 5812, 14949, 469, 16, 26, 283, 71, 23457, 3071, 339, 347, 511, 63, 18757, 63, 1247, 8, 277, 304, 267, 291, 14, 4921, 8, 288, 359, 18, 12, 841, 12, 334, 19, 8999, 19, 8636, 18, 12, 499, 12, 283, 5812, 995, 288, 791, 1328, 356, 9016, 71, 23457, 356, 788, 5812, 418, 11049, 1386, 288, 469, 16, 26, 791, 354, 356, 283, 1328, 297, 650, 26, 283, 71, 23457, 936, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 7800, 710, 28723, 6642, 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, 646, 2882, 199, 199, 646, 10446, 63, 18773, 421, 199, 318, 370, 495, 8, 576, 304, 272, 340, 1228, 8, 576, 12, 769, 304, 267, 372, 6522, 904, 8, 67, 340, 1228, 8, 67, 12, 620, 9, 587, 8678, 8, 67, 9, 367, 286, 315, 666, 9, 272, 372, 666, 421, 199, 533, 510, 34, 17541, 554, 774, 8, 2796, 14, 1746, 304, 272, 347, 4282, 8, 277, 12, 666, 12, 1420, 12, 2943, 29, 403, 304, 267, 754, 275, 10446, 63, 18773, 14, 1122, 63, 7204, 8, 475, 495, 8, 576, 395, 2943, 9, 267, 291, 14, 629, 8, 1099, 12, 1420, 9, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 291, 14, 4921, 8, 288, 359, 16, 12, 413, 12, 8295, 327, 2729, 442, 1467, 378, 12, 378, 88, 2534, 12, 413, 12, 3322, 327, 3510, 13, 4414, 2729, 442, 1467, 334, 17, 8999, 19, 8636, 17, 12, 283, 16238, 297, 221, 327, 5049, 13, 2075, 1467, 334, 18, 8999, 19, 8636, 18, 12, 959, 12, 283, 585, 297, 221, 327, 2582, 13, 25672, 334, 875, 9, 1467, 334, 19, 8999, 19, 8636, 21, 12, 283, 13591, 297, 420, 327, 4337, 13, 2075, 288, 2156, 288, 469, 355, 378, 26, 359, 17, 12, 14711, 467, 355, 413, 26, 788, 16238, 995, 355, 499, 26, 788, 585, 995, 355, 650, 26, 788, 13591, 995, 288, 3828, 339, 347, 511, 63, 18757, 8, 277, 304, 267, 291, 14, 4921, 779, 18, 12, 499, 12, 650, 8999, 19, 12, 413, 467, 469, 16, 26, 8910, 19, 26, 359, 17, 9420, 13888, 469, 16, 26, 1052, 1552, 339, 347, 511, 63, 698, 63, 1247, 8, 277, 304, 267, 291, 14, 4921, 779, 18, 12, 499, 12, 283, 5812, 995, 791, 71, 23457, 356, 788, 5812, 14949, 469, 16, 26, 283, 71, 23457, 3071, 339, 347, 511, 63, 18757, 63, 1247, 8, 277, 304, 267, 291, 14, 4921, 8, 288, 359, 18, 12, 841, 12, 334, 19, 8999, 19, 8636, 18, 12, 499, 12, 283, 5812, 995, 288, 791, 1328, 356, 9016, 71, 23457, 356, 788, 5812, 418, 11049, 1386, 288, 469, 16, 26, 791, 354, 356, 283, 1328, 297, 650, 26, 283, 71, 23457, 936, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
vismartltd/edx-platform
common/test/acceptance/pages/lms/open_response.py
165
4579
""" Open-ended response in the courseware. """ from bok_choy.page_object import PageObject from bok_choy.promise import EmptyPromise from .rubric import RubricPage class OpenResponsePage(PageObject): """ Open-ended response in the courseware. """ url = None def is_browser_on_page(self): return self.q(css='div.xmodule_CombinedOpenEndedModule').present @property def assessment_type(self): """ Return the type of assessment currently active. Options are "self", "ai", or "peer" """ labels = self.q(css='section#combined-open-ended-status>div.statusitem-current').text if len(labels) < 1: self.warning("Could not find assessment type label") # Provide some tolerance to UI changes label_compare = labels[0].lower().strip() if 'self' in label_compare: return 'self' elif 'ai' in label_compare: return 'ai' elif 'peer' in label_compare: return 'peer' else: raise ValueError("Unexpected assessment type: '{0}'".format(label_compare)) @property def prompt(self): """ Return an HTML string representing the essay prompt. """ prompt_css = "section.open-ended-child>div.prompt" prompts = self.q(css=prompt_css).map(lambda el: el.get_attribute('innerHTML').strip()).results if len(prompts) == 0: self.warning("Could not find essay prompt on page.") return "" elif len(prompts) > 1: self.warning("Multiple essay prompts found on page; using the first one.") return prompts[0] @property def rubric(self): """ Return a `RubricPage` for a self-assessment problem. If no rubric is available, raises a `BrokenPromise` exception. """ rubric = RubricPage(self.browser) rubric.wait_for_page() return rubric @property def written_feedback(self): """ Return the written feedback from the grader (if any). If no feedback available, returns None. """ feedback = self.q(css='div.written-feedback').text if len(feedback) > 0: return feedback[0] else: return None @property def alert_message(self): """ Alert message displayed to the user. """ alerts = self.q(css="div.open-ended-alert").text if len(alerts) < 1: return "" else: return alerts[0] @property def grader_status(self): """ Status message from the grader. If not present, return an empty string. """ status_list = self.q(css='div.grader-status').text if len(status_list) < 1: self.warning("No grader status found") return "" elif len(status_list) > 1: self.warning("Multiple grader statuses found; returning the first one") return status_list[0] def set_response(self, response_str): """ Input a response to the prompt. """ input_css = "textarea.short-form-response" self.q(css=input_css).fill(response_str) def save_response(self): """ Save the response for later submission. """ self.q(css='input.save-button').first.click() EmptyPromise( lambda: 'save' in self.alert_message.lower(), "Status message saved" ).fulfill() def submit_response(self): """ Submit a response for grading. """ self.q(css='input.submit-button').first.click() # modal dialog confirmation self.q(css='button.ok-button').first.click() # Ensure that the submission completes self._wait_for_submitted(self.assessment_type) def _wait_for_submitted(self, assessment_type): """ Wait for the submission to complete. `assessment_type` is either 'self', 'ai', or 'peer' """ if assessment_type == 'self': RubricPage(self.browser).wait_for_page() elif assessment_type == 'ai' or assessment_type == "peer": EmptyPromise( lambda: self.grader_status != 'Unanswered', "Problem status is no longer 'unanswered'" ).fulfill() else: self.warning("Unrecognized assessment type '{0}'".format(assessment_type)) EmptyPromise(lambda: True, "Unrecognized assessment type").fulfill()
agpl-3.0
[ 624, 199, 4299, 13, 8960, 1177, 315, 314, 20736, 14, 199, 624, 199, 199, 504, 330, 745, 63, 2239, 89, 14, 1606, 63, 785, 492, 10331, 1692, 199, 504, 330, 745, 63, 2239, 89, 14, 12741, 572, 492, 9630, 32303, 199, 504, 1275, 21586, 492, 820, 17147, 3276, 421, 199, 533, 3232, 2364, 3276, 8, 3276, 1692, 304, 272, 408, 272, 3232, 13, 8960, 1177, 315, 314, 20736, 14, 272, 408, 339, 1166, 275, 488, 339, 347, 365, 63, 5750, 63, 265, 63, 1606, 8, 277, 304, 267, 372, 291, 14, 81, 8, 3919, 534, 3015, 14, 14293, 63, 26444, 4299, 32615, 2377, 1959, 1881, 339, 768, 1829, 272, 347, 28273, 63, 466, 8, 277, 304, 267, 408, 267, 1432, 314, 730, 402, 28273, 5544, 4702, 14, 267, 8394, 787, 298, 277, 401, 298, 5789, 401, 503, 298, 7866, 2, 267, 408, 267, 3628, 275, 291, 14, 81, 8, 3919, 534, 2792, 3, 17583, 13, 1490, 13, 8960, 13, 1205, 30, 3015, 14, 3736, 85, 338, 563, 13, 1818, 1959, 505, 398, 340, 822, 8, 3512, 9, 665, 413, 26, 288, 291, 14, 3764, 480, 6531, 440, 2342, 28273, 730, 1768, 531, 398, 327, 22896, 2005, 13464, 370, 14041, 4493, 267, 1768, 63, 5785, 275, 3628, 59, 16, 1055, 2325, 1252, 1913, 342, 398, 340, 283, 277, 7, 315, 1768, 63, 5785, 26, 288, 372, 283, 277, 7, 267, 916, 283, 5789, 7, 315, 1768, 63, 5785, 26, 288, 372, 283, 5789, 7, 267, 916, 283, 7866, 7, 315, 1768, 63, 5785, 26, 288, 372, 283, 7866, 7, 267, 587, 26, 288, 746, 1722, 480, 8708, 28273, 730, 26, 5041, 16, 30366, 908, 8, 1302, 63, 5785, 430, 339, 768, 1829, 272, 347, 8457, 8, 277, 304, 267, 408, 267, 1432, 376, 4163, 1059, 6144, 314, 325, 385, 1187, 8457, 14, 267, 408, 267, 8457, 63, 3919, 275, 298, 2792, 14, 1490, 13, 8960, 13, 1739, 30, 3015, 14, 7650, 2, 267, 29951, 275, 291, 14, 81, 8, 3919, 29, 7650, 63, 3919, 680, 1130, 8, 2734, 579, 26, 579, 14, 362, 63, 3215, 360, 26502, 1959, 1913, 8801, 2604, 398, 340, 822, 8, 496, 311, 1086, 9, 508, 378, 26, 288, 291, 14, 3764, 480, 6531, 440, 2342, 325, 385, 1187, 8457, 641, 2034, 2685, 288, 372, 3087, 398, 916, 822, 8, 496, 311, 1086, 9, 690, 413, 26, 288, 291, 14, 3764, 480, 8433, 325, 385, 1187, 29951, 1911, 641, 2034, 27, 1808, 314, 1642, 1373, 2685, 398, 372, 29951, 59, 16, 61, 339, 768, 1829, 272, 347, 519, 17147, 8, 277, 304, 267, 408, 267, 1432, 282, 658, 50, 17147, 3276, 64, 367, 282, 291, 13, 17452, 5160, 14, 267, 982, 949, 519, 17147, 365, 2808, 12, 6534, 282, 658, 30509, 32303, 64, 1919, 14, 267, 408, 267, 519, 17147, 275, 820, 17147, 3276, 8, 277, 14, 5750, 9, 267, 519, 17147, 14, 2573, 63, 509, 63, 1606, 342, 267, 372, 519, 17147, 339, 768, 1829, 272, 347, 5313, 63, 13485, 8, 277, 304, 267, 408, 267, 1432, 314, 5313, 17145, 687, 314, 27741, 334, 692, 1263, 680, 267, 982, 949, 17145, 2808, 12, 2529, 488, 14, 267, 408, 267, 17145, 275, 291, 14, 81, 8, 3919, 534, 3015, 14, 8938, 13, 13485, 1959, 505, 398, 340, 822, 8, 13485, 9, 690, 378, 26, 288, 372, 17145, 59, 16, 61, 267, 587, 26, 288, 372, 488, 339, 768, 1829, 272, 347, 10459, 63, 1188, 8, 277, 304, 267, 408, 267, 25762, 1245, 9080, 370, 314, 922, 14, 267, 408, 267, 31529, 275, 291, 14, 81, 8, 3919, 628, 3015, 14, 1490, 13, 8960, 13, 9241, 3471, 505, 398, 340, 822, 8, 24501, 9, 665, 413, 26, 288, 372, 3087, 267, 587, 26, 288, 372, 31529, 59, 16, 61, 339, 768, 1829, 272, 347, 27741, 63, 1205, 8, 277, 304, 267, 408, 267, 9795, 1245, 687, 314, 27741, 14, 267, 982, 440, 3451, 12, 372, 376, 2701, 1059, 14, 267, 408, 267, 2004, 63, 513, 275, 291, 14, 81, 8, 3919, 534, 3015, 14, 17556, 13, 1205, 1959, 505, 398, 340, 822, 8, 1205, 63, 513, 9, 665, 413, 26, 288, 291, 14, 3764, 480, 1944, 27741, 2004, 1911, 531, 288, 372, 3087, 398, 916, 822, 8, 1205, 63, 513, 9, 690, 413, 26, 288, 291, 14, 3764, 480, 8433, 27741, 24498, 1911, 27, 8152, 314, 1642, 1373, 531, 398, 372, 2004, 63, 513, 59, 16, 61, 339, 347, 663, 63, 1310, 8, 277, 12, 1177, 63, 495, 304, 267, 408, 267, 6924, 282, 1177, 370, 314, 8457, 14, 267, 408, 267, 1324, 63, 3919, 275, 298, 20895, 14, 3612, 13, 964, 13, 1310, 2, 267, 291, 14, 81, 8, 3919, 29, 1210, 63, 3919, 680, 4498, 8, 1310, 63, 495, 9, 339, 347, 3354, 63, 1310, 8, 277, 304, 267, 408, 267, 11063, 314, 1177, 367, 2945, 13071, 14, 267, 408, 267, 291, 14, 81, 8, 3919, 534, 1210, 14, 2117, 13, 3887, 1959, 2246, 14, 4891, 342, 267, 9630, 32303, 8, 288, 2400, 26, 283, 2117, 7, 315, 291, 14, 9241, 63, 1188, 14, 2325, 1062, 288, 298, 3694, 1245, 6290, 2, 267, 7092, 13499, 22503, 342, 339, 347, 11482, 63, 1310, 8, 277, 304, 267, 408, 267, 28295, 282, 1177, 367, 22815, 14, 267, 408, 267, 291, 14, 81, 8, 3919, 534, 1210, 14, 7275, 13, 3887, 1959, 2246, 14, 4891, 342, 398, 327, 21698, 9592, 18791, 267, 291, 14, 81, 8, 3919, 534, 3887, 14, 745, 13, 3887, 1959, 2246, 14, 4891, 342, 398, 327, 7523, 626, 314, 13071, 29672, 267, 291, 423, 2573, 63, 509, 63, 23736, 8, 277, 14, 17452, 63, 466, 9, 339, 347, 485, 2573, 63, 509, 63, 23736, 8, 277, 12, 28273, 63, 466, 304, 267, 408, 267, 13144, 367, 314, 13071, 370, 4890, 14, 267, 658, 17452, 63, 466, 64, 365, 1902, 283, 277, 297, 283, 5789, 297, 503, 283, 7866, 7, 267, 408, 267, 340, 28273, 63, 466, 508, 283, 277, 356, 288, 820, 17147, 3276, 8, 277, 14, 5750, 680, 2573, 63, 509, 63, 1606, 342, 398, 916, 28273, 63, 466, 508, 283, 5789, 7, 503, 28273, 63, 466, 508, 298, 7866, 582, 288, 9630, 32303, 8, 355, 2400, 26 ]
[ 199, 4299, 13, 8960, 1177, 315, 314, 20736, 14, 199, 624, 199, 199, 504, 330, 745, 63, 2239, 89, 14, 1606, 63, 785, 492, 10331, 1692, 199, 504, 330, 745, 63, 2239, 89, 14, 12741, 572, 492, 9630, 32303, 199, 504, 1275, 21586, 492, 820, 17147, 3276, 421, 199, 533, 3232, 2364, 3276, 8, 3276, 1692, 304, 272, 408, 272, 3232, 13, 8960, 1177, 315, 314, 20736, 14, 272, 408, 339, 1166, 275, 488, 339, 347, 365, 63, 5750, 63, 265, 63, 1606, 8, 277, 304, 267, 372, 291, 14, 81, 8, 3919, 534, 3015, 14, 14293, 63, 26444, 4299, 32615, 2377, 1959, 1881, 339, 768, 1829, 272, 347, 28273, 63, 466, 8, 277, 304, 267, 408, 267, 1432, 314, 730, 402, 28273, 5544, 4702, 14, 267, 8394, 787, 298, 277, 401, 298, 5789, 401, 503, 298, 7866, 2, 267, 408, 267, 3628, 275, 291, 14, 81, 8, 3919, 534, 2792, 3, 17583, 13, 1490, 13, 8960, 13, 1205, 30, 3015, 14, 3736, 85, 338, 563, 13, 1818, 1959, 505, 398, 340, 822, 8, 3512, 9, 665, 413, 26, 288, 291, 14, 3764, 480, 6531, 440, 2342, 28273, 730, 1768, 531, 398, 327, 22896, 2005, 13464, 370, 14041, 4493, 267, 1768, 63, 5785, 275, 3628, 59, 16, 1055, 2325, 1252, 1913, 342, 398, 340, 283, 277, 7, 315, 1768, 63, 5785, 26, 288, 372, 283, 277, 7, 267, 916, 283, 5789, 7, 315, 1768, 63, 5785, 26, 288, 372, 283, 5789, 7, 267, 916, 283, 7866, 7, 315, 1768, 63, 5785, 26, 288, 372, 283, 7866, 7, 267, 587, 26, 288, 746, 1722, 480, 8708, 28273, 730, 26, 5041, 16, 30366, 908, 8, 1302, 63, 5785, 430, 339, 768, 1829, 272, 347, 8457, 8, 277, 304, 267, 408, 267, 1432, 376, 4163, 1059, 6144, 314, 325, 385, 1187, 8457, 14, 267, 408, 267, 8457, 63, 3919, 275, 298, 2792, 14, 1490, 13, 8960, 13, 1739, 30, 3015, 14, 7650, 2, 267, 29951, 275, 291, 14, 81, 8, 3919, 29, 7650, 63, 3919, 680, 1130, 8, 2734, 579, 26, 579, 14, 362, 63, 3215, 360, 26502, 1959, 1913, 8801, 2604, 398, 340, 822, 8, 496, 311, 1086, 9, 508, 378, 26, 288, 291, 14, 3764, 480, 6531, 440, 2342, 325, 385, 1187, 8457, 641, 2034, 2685, 288, 372, 3087, 398, 916, 822, 8, 496, 311, 1086, 9, 690, 413, 26, 288, 291, 14, 3764, 480, 8433, 325, 385, 1187, 29951, 1911, 641, 2034, 27, 1808, 314, 1642, 1373, 2685, 398, 372, 29951, 59, 16, 61, 339, 768, 1829, 272, 347, 519, 17147, 8, 277, 304, 267, 408, 267, 1432, 282, 658, 50, 17147, 3276, 64, 367, 282, 291, 13, 17452, 5160, 14, 267, 982, 949, 519, 17147, 365, 2808, 12, 6534, 282, 658, 30509, 32303, 64, 1919, 14, 267, 408, 267, 519, 17147, 275, 820, 17147, 3276, 8, 277, 14, 5750, 9, 267, 519, 17147, 14, 2573, 63, 509, 63, 1606, 342, 267, 372, 519, 17147, 339, 768, 1829, 272, 347, 5313, 63, 13485, 8, 277, 304, 267, 408, 267, 1432, 314, 5313, 17145, 687, 314, 27741, 334, 692, 1263, 680, 267, 982, 949, 17145, 2808, 12, 2529, 488, 14, 267, 408, 267, 17145, 275, 291, 14, 81, 8, 3919, 534, 3015, 14, 8938, 13, 13485, 1959, 505, 398, 340, 822, 8, 13485, 9, 690, 378, 26, 288, 372, 17145, 59, 16, 61, 267, 587, 26, 288, 372, 488, 339, 768, 1829, 272, 347, 10459, 63, 1188, 8, 277, 304, 267, 408, 267, 25762, 1245, 9080, 370, 314, 922, 14, 267, 408, 267, 31529, 275, 291, 14, 81, 8, 3919, 628, 3015, 14, 1490, 13, 8960, 13, 9241, 3471, 505, 398, 340, 822, 8, 24501, 9, 665, 413, 26, 288, 372, 3087, 267, 587, 26, 288, 372, 31529, 59, 16, 61, 339, 768, 1829, 272, 347, 27741, 63, 1205, 8, 277, 304, 267, 408, 267, 9795, 1245, 687, 314, 27741, 14, 267, 982, 440, 3451, 12, 372, 376, 2701, 1059, 14, 267, 408, 267, 2004, 63, 513, 275, 291, 14, 81, 8, 3919, 534, 3015, 14, 17556, 13, 1205, 1959, 505, 398, 340, 822, 8, 1205, 63, 513, 9, 665, 413, 26, 288, 291, 14, 3764, 480, 1944, 27741, 2004, 1911, 531, 288, 372, 3087, 398, 916, 822, 8, 1205, 63, 513, 9, 690, 413, 26, 288, 291, 14, 3764, 480, 8433, 27741, 24498, 1911, 27, 8152, 314, 1642, 1373, 531, 398, 372, 2004, 63, 513, 59, 16, 61, 339, 347, 663, 63, 1310, 8, 277, 12, 1177, 63, 495, 304, 267, 408, 267, 6924, 282, 1177, 370, 314, 8457, 14, 267, 408, 267, 1324, 63, 3919, 275, 298, 20895, 14, 3612, 13, 964, 13, 1310, 2, 267, 291, 14, 81, 8, 3919, 29, 1210, 63, 3919, 680, 4498, 8, 1310, 63, 495, 9, 339, 347, 3354, 63, 1310, 8, 277, 304, 267, 408, 267, 11063, 314, 1177, 367, 2945, 13071, 14, 267, 408, 267, 291, 14, 81, 8, 3919, 534, 1210, 14, 2117, 13, 3887, 1959, 2246, 14, 4891, 342, 267, 9630, 32303, 8, 288, 2400, 26, 283, 2117, 7, 315, 291, 14, 9241, 63, 1188, 14, 2325, 1062, 288, 298, 3694, 1245, 6290, 2, 267, 7092, 13499, 22503, 342, 339, 347, 11482, 63, 1310, 8, 277, 304, 267, 408, 267, 28295, 282, 1177, 367, 22815, 14, 267, 408, 267, 291, 14, 81, 8, 3919, 534, 1210, 14, 7275, 13, 3887, 1959, 2246, 14, 4891, 342, 398, 327, 21698, 9592, 18791, 267, 291, 14, 81, 8, 3919, 534, 3887, 14, 745, 13, 3887, 1959, 2246, 14, 4891, 342, 398, 327, 7523, 626, 314, 13071, 29672, 267, 291, 423, 2573, 63, 509, 63, 23736, 8, 277, 14, 17452, 63, 466, 9, 339, 347, 485, 2573, 63, 509, 63, 23736, 8, 277, 12, 28273, 63, 466, 304, 267, 408, 267, 13144, 367, 314, 13071, 370, 4890, 14, 267, 658, 17452, 63, 466, 64, 365, 1902, 283, 277, 297, 283, 5789, 297, 503, 283, 7866, 7, 267, 408, 267, 340, 28273, 63, 466, 508, 283, 277, 356, 288, 820, 17147, 3276, 8, 277, 14, 5750, 680, 2573, 63, 509, 63, 1606, 342, 398, 916, 28273, 63, 466, 508, 283, 5789, 7, 503, 28273, 63, 466, 508, 298, 7866, 582, 288, 9630, 32303, 8, 355, 2400, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
WeichenXu123/spark
examples/src/main/python/ml/min_hash_lsh_example.py
52
3222
# # 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. # """ An example demonstrating MinHashLSH. Run with: bin/spark-submit examples/src/main/python/ml/min_hash_lsh_example.py """ from __future__ import print_function # $example on$ from pyspark.ml.feature import MinHashLSH from pyspark.ml.linalg import Vectors from pyspark.sql.functions import col # $example off$ from pyspark.sql import SparkSession if __name__ == "__main__": spark = SparkSession \ .builder \ .appName("MinHashLSHExample") \ .getOrCreate() # $example on$ dataA = [(0, Vectors.sparse(6, [0, 1, 2], [1.0, 1.0, 1.0]),), (1, Vectors.sparse(6, [2, 3, 4], [1.0, 1.0, 1.0]),), (2, Vectors.sparse(6, [0, 2, 4], [1.0, 1.0, 1.0]),)] dfA = spark.createDataFrame(dataA, ["id", "features"]) dataB = [(3, Vectors.sparse(6, [1, 3, 5], [1.0, 1.0, 1.0]),), (4, Vectors.sparse(6, [2, 3, 5], [1.0, 1.0, 1.0]),), (5, Vectors.sparse(6, [1, 2, 4], [1.0, 1.0, 1.0]),)] dfB = spark.createDataFrame(dataB, ["id", "features"]) key = Vectors.sparse(6, [1, 3], [1.0, 1.0]) mh = MinHashLSH(inputCol="features", outputCol="hashes", numHashTables=5) model = mh.fit(dfA) # Feature Transformation print("The hashed dataset where hashed values are stored in the column 'hashes':") model.transform(dfA).show() # Compute the locality sensitive hashes for the input rows, then perform approximate # similarity join. # We could avoid computing hashes by passing in the already-transformed dataset, e.g. # `model.approxSimilarityJoin(transformedA, transformedB, 0.6)` print("Approximately joining dfA and dfB on distance smaller than 0.6:") model.approxSimilarityJoin(dfA, dfB, 0.6, distCol="JaccardDistance")\ .select(col("datasetA.id").alias("idA"), col("datasetB.id").alias("idB"), col("JaccardDistance")).show() # Compute the locality sensitive hashes for the input rows, then perform approximate nearest # neighbor search. # We could avoid computing hashes by passing in the already-transformed dataset, e.g. # `model.approxNearestNeighbors(transformedA, key, 2)` # It may return less than 2 rows when not enough approximate near-neighbor candidates are # found. print("Approximately searching dfA for 2 nearest neighbors of the key:") model.approxNearestNeighbors(dfA, key, 2).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, 624, 199, 2493, 2893, 23789, 495, 1958, 10195, 3476, 44, 3234, 14, 199, 2540, 543, 26, 523, 2517, 15, 9852, 13, 7275, 7251, 15, 2164, 15, 973, 15, 1548, 15, 757, 15, 827, 63, 2227, 63, 23025, 63, 2694, 14, 647, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3, 2672, 2694, 641, 4, 199, 504, 15847, 14, 757, 14, 4445, 492, 10195, 3476, 44, 3234, 199, 504, 15847, 14, 757, 14, 10096, 492, 812, 9177, 199, 504, 15847, 14, 3009, 14, 5777, 492, 1048, 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, 971, 267, 1275, 5649, 971, 267, 1275, 571, 985, 480, 4649, 3476, 44, 3234, 9846, 531, 971, 267, 1275, 30457, 2499, 342, 339, 327, 2672, 2694, 641, 4, 272, 666, 33, 275, 3842, 16, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 16, 12, 413, 12, 499, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 395, 1467, 334, 17, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 18, 12, 650, 12, 841, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 395, 1467, 334, 18, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 16, 12, 499, 12, 841, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 1874, 272, 4051, 33, 275, 15442, 14, 25482, 8, 576, 33, 12, 2097, 344, 401, 298, 3179, 3135, 339, 666, 34, 275, 3842, 19, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 17, 12, 650, 12, 959, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 395, 1467, 334, 20, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 18, 12, 650, 12, 959, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 395, 1467, 334, 21, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 17, 12, 499, 12, 841, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 1874, 272, 4051, 34, 275, 15442, 14, 25482, 8, 576, 34, 12, 2097, 344, 401, 298, 3179, 3135, 339, 790, 275, 812, 9177, 14, 4421, 8, 22, 12, 359, 17, 12, 650, 467, 359, 17, 14, 16, 12, 413, 14, 16, 566, 339, 333, 72, 275, 10195, 3476, 44, 3234, 8, 1210, 2001, 628, 3179, 401, 1072, 2001, 628, 12428, 401, 1967, 3476, 18845, 29, 21, 9, 272, 1402, 275, 333, 72, 14, 3269, 8, 1587, 33, 9, 339, 327, 13407, 6266, 1869, 272, 870, 480, 1918, 19871, 4789, 2382, 19871, 1338, 787, 5489, 315, 314, 2763, 283, 12428, 356, 531, 272, 1402, 14, 4711, 8, 1587, 33, 680, 2384, 342, 339, 327, 8354, 314, 2257, 1209, 18423, 14647, 367, 314, 1324, 4730, 12, 2066, 5147, 19917, 272, 327, 22838, 4263, 14, 272, 327, 2136, 4293, 5126, 17226, 14647, 701, 9476, 315, 314, 2575, 13, 20209, 4789, 12, 325, 14, 71, 14, 272, 327, 658, 1238, 14, 16815, 7467, 13093, 13005, 8, 20209, 33, 12, 14834, 34, 12, 378, 14, 22, 12544, 272, 870, 480, 13117, 8221, 6897, 590, 4263, 316, 4051, 33, 436, 4051, 34, 641, 6033, 12700, 2419, 378, 14, 22, 9107, 272, 1402, 14, 16815, 7467, 13093, 13005, 8, 1587, 33, 12, 4051, 34, 12, 378, 14, 22, 12, 2917, 2001, 628, 42, 5470, 1005, 10076, 27681, 267, 1275, 2416, 8, 761, 480, 5214, 33, 14, 344, 3471, 3620, 480, 344, 33, 1288, 355, 1048, 480, 5214, 34, 14, 344, 3471, 3620, 480, 344, 34, 1288, 355, 1048, 480, 42, 5470, 1005, 10076, 21688, 2384, 342, 339, 327, 8354, 314, 2257, 1209, 18423, 14647, 367, 314, 1324, 4730, 12, 2066, 5147, 19917, 17173, 272, 327, 15503, 2754, 14, 272, 327, 2136, 4293, 5126, 17226, 14647, 701, 9476, 315, 314, 2575, 13, 20209, 4789, 12, 325, 14, 71, 14, 272, 327, 658, 1238, 14, 16815, 4698, 9540, 20011, 8, 20209, 33, 12, 790, 12, 499, 12544, 272, 327, 2779, 1443, 372, 6656, 2419, 499, 4730, 1380, 440, 8321, 19917, 17429, 13, 13881, 15101, 787, 272, 327, 1911, 14, 272, 870, 480, 13117, 8221, 6897, 590, 18112, 4051, 33, 367, 499, 17173, 15845, 402, 314, 790, 9107, 272, 1402, 14, 16815, 4698, 9540, 20011, 8, 1587, 33, 12, 790, 12, 499, 680, 2384, 342, 339, 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 ]
[ 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, 624, 199, 2493, 2893, 23789, 495, 1958, 10195, 3476, 44, 3234, 14, 199, 2540, 543, 26, 523, 2517, 15, 9852, 13, 7275, 7251, 15, 2164, 15, 973, 15, 1548, 15, 757, 15, 827, 63, 2227, 63, 23025, 63, 2694, 14, 647, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3, 2672, 2694, 641, 4, 199, 504, 15847, 14, 757, 14, 4445, 492, 10195, 3476, 44, 3234, 199, 504, 15847, 14, 757, 14, 10096, 492, 812, 9177, 199, 504, 15847, 14, 3009, 14, 5777, 492, 1048, 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, 971, 267, 1275, 5649, 971, 267, 1275, 571, 985, 480, 4649, 3476, 44, 3234, 9846, 531, 971, 267, 1275, 30457, 2499, 342, 339, 327, 2672, 2694, 641, 4, 272, 666, 33, 275, 3842, 16, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 16, 12, 413, 12, 499, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 395, 1467, 334, 17, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 18, 12, 650, 12, 841, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 395, 1467, 334, 18, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 16, 12, 499, 12, 841, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 1874, 272, 4051, 33, 275, 15442, 14, 25482, 8, 576, 33, 12, 2097, 344, 401, 298, 3179, 3135, 339, 666, 34, 275, 3842, 19, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 17, 12, 650, 12, 959, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 395, 1467, 334, 20, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 18, 12, 650, 12, 959, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 395, 1467, 334, 21, 12, 812, 9177, 14, 4421, 8, 22, 12, 359, 17, 12, 499, 12, 841, 467, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 2522, 1874, 272, 4051, 34, 275, 15442, 14, 25482, 8, 576, 34, 12, 2097, 344, 401, 298, 3179, 3135, 339, 790, 275, 812, 9177, 14, 4421, 8, 22, 12, 359, 17, 12, 650, 467, 359, 17, 14, 16, 12, 413, 14, 16, 566, 339, 333, 72, 275, 10195, 3476, 44, 3234, 8, 1210, 2001, 628, 3179, 401, 1072, 2001, 628, 12428, 401, 1967, 3476, 18845, 29, 21, 9, 272, 1402, 275, 333, 72, 14, 3269, 8, 1587, 33, 9, 339, 327, 13407, 6266, 1869, 272, 870, 480, 1918, 19871, 4789, 2382, 19871, 1338, 787, 5489, 315, 314, 2763, 283, 12428, 356, 531, 272, 1402, 14, 4711, 8, 1587, 33, 680, 2384, 342, 339, 327, 8354, 314, 2257, 1209, 18423, 14647, 367, 314, 1324, 4730, 12, 2066, 5147, 19917, 272, 327, 22838, 4263, 14, 272, 327, 2136, 4293, 5126, 17226, 14647, 701, 9476, 315, 314, 2575, 13, 20209, 4789, 12, 325, 14, 71, 14, 272, 327, 658, 1238, 14, 16815, 7467, 13093, 13005, 8, 20209, 33, 12, 14834, 34, 12, 378, 14, 22, 12544, 272, 870, 480, 13117, 8221, 6897, 590, 4263, 316, 4051, 33, 436, 4051, 34, 641, 6033, 12700, 2419, 378, 14, 22, 9107, 272, 1402, 14, 16815, 7467, 13093, 13005, 8, 1587, 33, 12, 4051, 34, 12, 378, 14, 22, 12, 2917, 2001, 628, 42, 5470, 1005, 10076, 27681, 267, 1275, 2416, 8, 761, 480, 5214, 33, 14, 344, 3471, 3620, 480, 344, 33, 1288, 355, 1048, 480, 5214, 34, 14, 344, 3471, 3620, 480, 344, 34, 1288, 355, 1048, 480, 42, 5470, 1005, 10076, 21688, 2384, 342, 339, 327, 8354, 314, 2257, 1209, 18423, 14647, 367, 314, 1324, 4730, 12, 2066, 5147, 19917, 17173, 272, 327, 15503, 2754, 14, 272, 327, 2136, 4293, 5126, 17226, 14647, 701, 9476, 315, 314, 2575, 13, 20209, 4789, 12, 325, 14, 71, 14, 272, 327, 658, 1238, 14, 16815, 4698, 9540, 20011, 8, 20209, 33, 12, 790, 12, 499, 12544, 272, 327, 2779, 1443, 372, 6656, 2419, 499, 4730, 1380, 440, 8321, 19917, 17429, 13, 13881, 15101, 787, 272, 327, 1911, 14, 272, 870, 480, 13117, 8221, 6897, 590, 18112, 4051, 33, 367, 499, 17173, 15845, 402, 314, 790, 9107, 272, 1402, 14, 16815, 4698, 9540, 20011, 8, 1587, 33, 12, 790, 12, 499, 680, 2384, 342, 339, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
a2ultimate/ultimate-league-app
src/ultimate/utils/google_api.py
2
7829
from datetime import datetime import dateutil.parser import httplib2 import logging from django.conf import settings from django.utils.timezone import make_aware from googleapiclient.discovery import build from oauth2client.service_account import ServiceAccountCredentials logger = logging.getLogger('a2u.email_groups') class GoogleAppsApi: http = None service = None def __init__(self): credentials_file = getattr(settings, 'GOOGLE_APPS_API_CREDENTIALS_FILE', False) scopes = getattr(settings, 'GOOGLE_APPS_API_SCOPES', False) account = getattr(settings, 'GOOGLE_APPS_API_ACCOUNT', False) if credentials_file and scopes and account: credentials = ServiceAccountCredentials.from_json_keyfile_name( credentials_file, scopes=scopes) credentials._kwargs['sub'] = account self.http = httplib2.Http() self.http = credentials.authorize(self.http) def prepare_group_for_sync(self, group_name, group_id=None, group_email_address=None, force=False): logger.debug('Preparing group "{}" for sync...'.format(group_name)) if force: self.delete_group(group_id=group_id, group_email_address=group_email_address) else: self.remove_all_group_members( group_id=group_id, group_email_address=group_email_address, group_name=group_name) return self.get_or_create_group( group_email_address=group_email_address, group_name=group_name) # TODO need paging for when you have over 200 groups def get_or_create_group(self, group_email_address, group_name=''): logger.debug(' Getting or creating group {}...'.format(group_email_address)) service = build('admin', 'directory_v1', http=self.http, cache_discovery=False) groups_response = None target_group = None try: logger.debug(' Looking for existing group...') groups_response = service.groups().list(customer='my_customer', domain='lists.annarborultimate.org', query='email={}'.format(group_email_address)).execute(http=self.http) except Exception as e: return None if groups_response and groups_response.get('groups'): for group in groups_response.get('groups'): if group.get('email') == group_email_address: logger.debug(' Group found!') target_group = group # couldn't find group, create it if not target_group: logger.debug(' Group not found...creating {}...'.format(group_email_address)) body = { 'email': group_email_address, } if group_name: body.update({ 'name': group_name, }) try: target_group = service.groups().insert(body=body).execute(http=self.http) logger.debug(' Success!') except Exception as e: logger.debug(' Failure!') return None group_id = target_group.get('id', None) return group_id def delete_group(self, group_id=None, group_email_address=None): logger.debug(' Deleting existing group...') service = build('admin', 'directory_v1', http=self.http, cache_discovery=False) if group_email_address and not group_id: try: groups_response = service.groups().list(customer='my_customer', domain='lists.annarborultimate.org', query='email={}'.format(group_email_address)).execute(http=self.http) if groups_response and groups_response.get('groups'): for group in groups_response.get('groups'): if group.get('email') == group_email_address: group_id = group.get('id', None) except Exception as e: return False if group_id: try: service.groups().delete(groupKey=group_id).execute(http=self.http) logger.debug(' Success!') except Exception as e: logger.debug(' Failure!') return False return True def remove_all_group_members(self, group_id=None, group_email_address=None, group_name=None): logger.debug(' Removing all members from {}...'.format(group_email_address)) service = build('admin', 'directory_v1', http=self.http, cache_discovery=False) if group_email_address and not group_id: try: groups_response = service.groups().list(customer='my_customer', domain='lists.annarborultimate.org', query='email={}'.format(group_email_address)).execute(http=self.http) if groups_response and groups_response.get('groups'): for group in groups_response.get('groups'): if group.get('email') == group_email_address: group_id = group.get('id', None) except Exception as e: logger.debug(' Group could not be found') return False if group_id: try: members_response = service.members().list(groupKey=group_id).execute(http=self.http) if members_response and members_response.get('members'): for member in members_response.get('members'): member_id = member.get('id', None) service.members().delete(groupKey=group_id, memberKey=member_id).execute(http=self.http) except Exception as e: logger.debug(' Group could not be found') return False logger.debug(' Done') def add_group_member(self, email_address, group_id=None, group_email_address=None, group_name=None): logger.debug('Adding {} to {}...'.format(email_address, group_email_address or 'group')) service = build('admin', 'directory_v1', http=self.http, cache_discovery=False) body = { 'email': email_address, 'role': 'MEMBER' } response = False # look for group if not group_id and group_email_address: group_id = self.get_or_create_group( group_email_address=group_email_address, group_name=group_name) if group_id: try: response = service.members().insert(groupKey=group_id, body=body).execute(http=self.http) logger.debug(' Success!') except: logger.debug(' Failure!') return False return response def get_calendar_events(self, calendar_id, since, until): service = build(serviceName='calendar', version='v3', http=self.http, cache_discovery=False) since = (datetime.utcnow().replace(hour=0, minute=0, second=0, microsecond=0) - since).isoformat('T') + 'Z' until = (datetime.utcnow().replace(hour=0, minute=0, second=0, microsecond=0) + until).isoformat('T') + 'Z' try: events_response = service.events().list( calendarId=calendar_id, orderBy='startTime', singleEvents=True, timeMin=since, timeMax=until, ).execute(http=self.http) except Exception as e: return None events = [] for event in events_response['items']: events.append({ 'summary': event.get('summary'), 'start': dateutil.parser.parse(event['start']['dateTime']), 'end': event['end']['dateTime'], 'location': event.get('location'), 'description': event.get('description'), }) return events
bsd-3-clause
[ 504, 2197, 492, 2197, 199, 646, 22208, 14, 2087, 199, 646, 8809, 18, 199, 646, 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 14, 7145, 492, 1852, 63, 14600, 199, 199, 504, 6233, 25661, 14, 14859, 492, 1900, 199, 504, 9725, 18, 1258, 14, 1364, 63, 2048, 492, 7591, 6009, 13428, 199, 199, 2921, 275, 2050, 14, 5572, 360, 65, 18, 85, 14, 2123, 63, 2634, 358, 421, 199, 533, 4475, 2640, 83, 7394, 26, 272, 1455, 275, 488, 272, 2435, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 6235, 63, 493, 275, 2519, 8, 1751, 12, 283, 24243, 63, 14219, 63, 3735, 63, 30553, 8246, 51, 63, 3817, 297, 756, 9, 267, 14570, 275, 2519, 8, 1751, 12, 283, 24243, 63, 14219, 63, 3735, 63, 15901, 48, 654, 297, 756, 9, 267, 2933, 275, 2519, 8, 1751, 12, 283, 24243, 63, 14219, 63, 3735, 63, 18928, 297, 756, 9, 398, 340, 6235, 63, 493, 436, 14570, 436, 2933, 26, 288, 6235, 275, 7591, 6009, 13428, 14, 504, 63, 1001, 63, 21856, 63, 354, 8, 355, 6235, 63, 493, 12, 14570, 29, 14129, 9, 953, 6235, 423, 958, 459, 954, 418, 275, 2933, 953, 291, 14, 1014, 275, 8809, 18, 14, 5779, 342, 288, 291, 14, 1014, 275, 6235, 14, 14204, 8, 277, 14, 1014, 9, 339, 347, 9275, 63, 923, 63, 509, 63, 5186, 8, 277, 12, 1572, 63, 354, 12, 1572, 63, 344, 29, 403, 12, 1572, 63, 2123, 63, 1562, 29, 403, 12, 3542, 29, 797, 304, 267, 2512, 14, 1757, 360, 2398, 462, 316, 1572, 28168, 367, 7604, 1396, 1370, 908, 8, 923, 63, 354, 430, 398, 340, 3542, 26, 288, 291, 14, 1807, 63, 923, 8, 923, 63, 344, 29, 923, 63, 344, 12, 1572, 63, 2123, 63, 1562, 29, 923, 63, 2123, 63, 1562, 9, 267, 587, 26, 288, 291, 14, 2168, 63, 452, 63, 923, 63, 6334, 8, 355, 1572, 63, 344, 29, 923, 63, 344, 12, 355, 1572, 63, 2123, 63, 1562, 29, 923, 63, 2123, 63, 1562, 12, 355, 1572, 63, 354, 29, 923, 63, 354, 9, 398, 372, 291, 14, 362, 63, 269, 63, 981, 63, 923, 8, 288, 1572, 63, 2123, 63, 1562, 29, 923, 63, 2123, 63, 1562, 12, 1572, 63, 354, 29, 923, 63, 354, 9, 339, 327, 3254, 1929, 299, 7407, 367, 1380, 1265, 1172, 1806, 1926, 4652, 272, 347, 664, 63, 269, 63, 981, 63, 923, 8, 277, 12, 1572, 63, 2123, 63, 1562, 12, 1572, 63, 354, 9280, 267, 2512, 14, 1757, 360, 221, 20703, 503, 6425, 1572, 1052, 1396, 1370, 908, 8, 923, 63, 2123, 63, 1562, 430, 398, 2435, 275, 1900, 360, 2113, 297, 283, 3619, 63, 86, 17, 297, 1455, 29, 277, 14, 1014, 12, 2581, 63, 14859, 29, 797, 9, 398, 4652, 63, 1310, 275, 488, 267, 1347, 63, 923, 275, 488, 398, 862, 26, 288, 2512, 14, 1757, 360, 259, 12077, 316, 367, 3411, 1572, 15103, 288, 4652, 63, 1310, 275, 2435, 14, 2634, 1252, 513, 8, 10178, 534, 1662, 63, 10178, 297, 2881, 534, 6717, 14, 1189, 10325, 269, 1141, 17684, 14, 1308, 297, 1827, 534, 2123, 27244, 908, 8, 923, 63, 2123, 63, 1562, 4992, 2526, 8, 1014, 29, 277, 14, 1014, 9, 267, 871, 2186, 465, 325, 26, 288, 372, 488, 398, 340, 4652, 63, 1310, 436, 4652, 63, 1310, 14, 362, 360, 2634, 735, 288, 367, 1572, 315, 4652, 63, 1310, 14, 362, 360, 2634, 735, 355, 340, 1572, 14, 362, 360, 2123, 358, 508, 1572, 63, 2123, 63, 1562, 26, 490, 2512, 14, 1757, 360, 259, 5611, 1911, 10916, 490, 1347, 63, 923, 275, 1572, 398, 327, 21554, 1133, 2342, 1572, 12, 1218, 652, 267, 340, 440, 1347, 63, 923, 26, 288, 2512, 14, 1757, 360, 259, 5611, 440, 1911, 1396, 20358, 1052, 1396, 1370, 908, 8, 923, 63, 2123, 63, 1562, 430, 953, 2396, 275, 469, 283, 2123, 356, 1572, 63, 2123, 63, 1562, 12, 789, 288, 340, 1572, 63, 354, 26, 355, 2396, 14, 873, 2561, 283, 354, 356, 1572, 63, 354, 12, 3828, 953, 862, 26, 355, 1347, 63, 923, 275, 2435, 14, 2634, 1252, 3176, 8, 2030, 29, 2030, 680, 2526, 8, 1014, 29, 277, 14, 1014, 9, 355, 2512, 14, 1757, 360, 259, 22318, 10916, 288, 871, 2186, 465, 325, 26, 355, 2512, 14, 1757, 360, 259, 20367, 10916, 355, 372, 488, 398, 1572, 63, 344, 275, 1347, 63, 923, 14, 362, 360, 344, 297, 488, 9, 398, 372, 1572, 63, 344, 339, 347, 3145, 63, 923, 8, 277, 12, 1572, 63, 344, 29, 403, 12, 1572, 63, 2123, 63, 1562, 29, 403, 304, 267, 2512, 14, 1757, 360, 221, 15920, 3411, 1572, 15103, 398, 2435, 275, 1900, 360, 2113, 297, 283, 3619, 63, 86, 17, 297, 1455, 29, 277, 14, 1014, 12, 2581, 63, 14859, 29, 797, 9, 398, 340, 1572, 63, 2123, 63, 1562, 436, 440, 1572, 63, 344, 26, 288, 862, 26, 355, 4652, 63, 1310, 275, 2435, 14, 2634, 1252, 513, 8, 10178, 534, 1662, 63, 10178, 297, 2881, 534, 6717, 14, 1189, 10325, 269, 1141, 17684, 14, 1308, 297, 1827, 534, 2123, 27244, 908, 8, 923, 63, 2123, 63, 1562, 4992, 2526, 8, 1014, 29, 277, 14, 1014, 9, 2234, 340, 4652, 63, 1310, 436, 4652, 63, 1310, 14, 362, 360, 2634, 735, 490, 367, 1572, 315, 4652, 63, 1310, 14, 362, 360, 2634, 735, 717, 340, 1572, 14, 362, 360, 2123, 358, 508, 1572, 63, 2123, 63, 1562, 26, 1169, 1572, 63, 344, 275, 1572, 14, 362, 360, 344, 297, 488, 9, 288, 871, 2186, 465, 325, 26, 355, 372, 756, 398, 340, 1572, 63, 344, 26, 288, 862, 26, 355, 2435, 14, 2634, 1252, 1807, 8, 923, 1197, 29, 923, 63, 344, 680, 2526, 8, 1014, 29, 277, 14, 1014, 9, 355, 2512, 14, 1757, 360, 259, 22318, 10916, 288, 871, 2186, 465, 325, 26, 355, 2512, 14, 1757, 360, 259, 20367, 10916, 355, 372, 756, 398, 372, 715, 339, 347, 2813, 63, 452, 63, 923, 63, 6334, 8, 277, 12, 1572, 63, 344, 29, 403, 12, 1572, 63, 2123, 63, 1562, 29, 403, 12, 1572, 63, 354 ]
[ 2197, 492, 2197, 199, 646, 22208, 14, 2087, 199, 646, 8809, 18, 199, 646, 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 14, 7145, 492, 1852, 63, 14600, 199, 199, 504, 6233, 25661, 14, 14859, 492, 1900, 199, 504, 9725, 18, 1258, 14, 1364, 63, 2048, 492, 7591, 6009, 13428, 199, 199, 2921, 275, 2050, 14, 5572, 360, 65, 18, 85, 14, 2123, 63, 2634, 358, 421, 199, 533, 4475, 2640, 83, 7394, 26, 272, 1455, 275, 488, 272, 2435, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 6235, 63, 493, 275, 2519, 8, 1751, 12, 283, 24243, 63, 14219, 63, 3735, 63, 30553, 8246, 51, 63, 3817, 297, 756, 9, 267, 14570, 275, 2519, 8, 1751, 12, 283, 24243, 63, 14219, 63, 3735, 63, 15901, 48, 654, 297, 756, 9, 267, 2933, 275, 2519, 8, 1751, 12, 283, 24243, 63, 14219, 63, 3735, 63, 18928, 297, 756, 9, 398, 340, 6235, 63, 493, 436, 14570, 436, 2933, 26, 288, 6235, 275, 7591, 6009, 13428, 14, 504, 63, 1001, 63, 21856, 63, 354, 8, 355, 6235, 63, 493, 12, 14570, 29, 14129, 9, 953, 6235, 423, 958, 459, 954, 418, 275, 2933, 953, 291, 14, 1014, 275, 8809, 18, 14, 5779, 342, 288, 291, 14, 1014, 275, 6235, 14, 14204, 8, 277, 14, 1014, 9, 339, 347, 9275, 63, 923, 63, 509, 63, 5186, 8, 277, 12, 1572, 63, 354, 12, 1572, 63, 344, 29, 403, 12, 1572, 63, 2123, 63, 1562, 29, 403, 12, 3542, 29, 797, 304, 267, 2512, 14, 1757, 360, 2398, 462, 316, 1572, 28168, 367, 7604, 1396, 1370, 908, 8, 923, 63, 354, 430, 398, 340, 3542, 26, 288, 291, 14, 1807, 63, 923, 8, 923, 63, 344, 29, 923, 63, 344, 12, 1572, 63, 2123, 63, 1562, 29, 923, 63, 2123, 63, 1562, 9, 267, 587, 26, 288, 291, 14, 2168, 63, 452, 63, 923, 63, 6334, 8, 355, 1572, 63, 344, 29, 923, 63, 344, 12, 355, 1572, 63, 2123, 63, 1562, 29, 923, 63, 2123, 63, 1562, 12, 355, 1572, 63, 354, 29, 923, 63, 354, 9, 398, 372, 291, 14, 362, 63, 269, 63, 981, 63, 923, 8, 288, 1572, 63, 2123, 63, 1562, 29, 923, 63, 2123, 63, 1562, 12, 1572, 63, 354, 29, 923, 63, 354, 9, 339, 327, 3254, 1929, 299, 7407, 367, 1380, 1265, 1172, 1806, 1926, 4652, 272, 347, 664, 63, 269, 63, 981, 63, 923, 8, 277, 12, 1572, 63, 2123, 63, 1562, 12, 1572, 63, 354, 9280, 267, 2512, 14, 1757, 360, 221, 20703, 503, 6425, 1572, 1052, 1396, 1370, 908, 8, 923, 63, 2123, 63, 1562, 430, 398, 2435, 275, 1900, 360, 2113, 297, 283, 3619, 63, 86, 17, 297, 1455, 29, 277, 14, 1014, 12, 2581, 63, 14859, 29, 797, 9, 398, 4652, 63, 1310, 275, 488, 267, 1347, 63, 923, 275, 488, 398, 862, 26, 288, 2512, 14, 1757, 360, 259, 12077, 316, 367, 3411, 1572, 15103, 288, 4652, 63, 1310, 275, 2435, 14, 2634, 1252, 513, 8, 10178, 534, 1662, 63, 10178, 297, 2881, 534, 6717, 14, 1189, 10325, 269, 1141, 17684, 14, 1308, 297, 1827, 534, 2123, 27244, 908, 8, 923, 63, 2123, 63, 1562, 4992, 2526, 8, 1014, 29, 277, 14, 1014, 9, 267, 871, 2186, 465, 325, 26, 288, 372, 488, 398, 340, 4652, 63, 1310, 436, 4652, 63, 1310, 14, 362, 360, 2634, 735, 288, 367, 1572, 315, 4652, 63, 1310, 14, 362, 360, 2634, 735, 355, 340, 1572, 14, 362, 360, 2123, 358, 508, 1572, 63, 2123, 63, 1562, 26, 490, 2512, 14, 1757, 360, 259, 5611, 1911, 10916, 490, 1347, 63, 923, 275, 1572, 398, 327, 21554, 1133, 2342, 1572, 12, 1218, 652, 267, 340, 440, 1347, 63, 923, 26, 288, 2512, 14, 1757, 360, 259, 5611, 440, 1911, 1396, 20358, 1052, 1396, 1370, 908, 8, 923, 63, 2123, 63, 1562, 430, 953, 2396, 275, 469, 283, 2123, 356, 1572, 63, 2123, 63, 1562, 12, 789, 288, 340, 1572, 63, 354, 26, 355, 2396, 14, 873, 2561, 283, 354, 356, 1572, 63, 354, 12, 3828, 953, 862, 26, 355, 1347, 63, 923, 275, 2435, 14, 2634, 1252, 3176, 8, 2030, 29, 2030, 680, 2526, 8, 1014, 29, 277, 14, 1014, 9, 355, 2512, 14, 1757, 360, 259, 22318, 10916, 288, 871, 2186, 465, 325, 26, 355, 2512, 14, 1757, 360, 259, 20367, 10916, 355, 372, 488, 398, 1572, 63, 344, 275, 1347, 63, 923, 14, 362, 360, 344, 297, 488, 9, 398, 372, 1572, 63, 344, 339, 347, 3145, 63, 923, 8, 277, 12, 1572, 63, 344, 29, 403, 12, 1572, 63, 2123, 63, 1562, 29, 403, 304, 267, 2512, 14, 1757, 360, 221, 15920, 3411, 1572, 15103, 398, 2435, 275, 1900, 360, 2113, 297, 283, 3619, 63, 86, 17, 297, 1455, 29, 277, 14, 1014, 12, 2581, 63, 14859, 29, 797, 9, 398, 340, 1572, 63, 2123, 63, 1562, 436, 440, 1572, 63, 344, 26, 288, 862, 26, 355, 4652, 63, 1310, 275, 2435, 14, 2634, 1252, 513, 8, 10178, 534, 1662, 63, 10178, 297, 2881, 534, 6717, 14, 1189, 10325, 269, 1141, 17684, 14, 1308, 297, 1827, 534, 2123, 27244, 908, 8, 923, 63, 2123, 63, 1562, 4992, 2526, 8, 1014, 29, 277, 14, 1014, 9, 2234, 340, 4652, 63, 1310, 436, 4652, 63, 1310, 14, 362, 360, 2634, 735, 490, 367, 1572, 315, 4652, 63, 1310, 14, 362, 360, 2634, 735, 717, 340, 1572, 14, 362, 360, 2123, 358, 508, 1572, 63, 2123, 63, 1562, 26, 1169, 1572, 63, 344, 275, 1572, 14, 362, 360, 344, 297, 488, 9, 288, 871, 2186, 465, 325, 26, 355, 372, 756, 398, 340, 1572, 63, 344, 26, 288, 862, 26, 355, 2435, 14, 2634, 1252, 1807, 8, 923, 1197, 29, 923, 63, 344, 680, 2526, 8, 1014, 29, 277, 14, 1014, 9, 355, 2512, 14, 1757, 360, 259, 22318, 10916, 288, 871, 2186, 465, 325, 26, 355, 2512, 14, 1757, 360, 259, 20367, 10916, 355, 372, 756, 398, 372, 715, 339, 347, 2813, 63, 452, 63, 923, 63, 6334, 8, 277, 12, 1572, 63, 344, 29, 403, 12, 1572, 63, 2123, 63, 1562, 29, 403, 12, 1572, 63, 354, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Rapportus/ansible-modules-extras
cloud/vmware/vmware_dns_config.py
75
3970
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2015, Joseph Callen <jcallen () csc.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: vmware_dns_config short_description: Manage VMware ESXi DNS Configuration description: - Manage VMware ESXi DNS Configuration version_added: 2.0 author: "Joseph Callen (@jcpowermac)" notes: - Tested on vSphere 5.5 requirements: - "python >= 2.6" - PyVmomi options: change_hostname_to: description: - The hostname that an ESXi host should be changed to. required: True domainname: description: - The domain the ESXi host should be apart of. required: True dns_servers: description: - The DNS servers that the host should be configured to use. required: True extends_documentation_fragment: vmware.documentation ''' EXAMPLES = ''' # Example vmware_dns_config command from Ansible Playbooks - name: Configure ESXi hostname and DNS servers local_action: module: vmware_dns_config hostname: esxi_hostname username: root password: your_password change_hostname_to: esx01 domainname: foo.org dns_servers: - 8.8.8.8 - 8.8.4.4 ''' try: from pyVmomi import vim, vmodl HAS_PYVMOMI = True except ImportError: HAS_PYVMOMI = False def configure_dns(host_system, hostname, domainname, dns_servers): changed = False host_config_manager = host_system.configManager host_network_system = host_config_manager.networkSystem config = host_network_system.dnsConfig config.dhcp = False if config.address != dns_servers: config.address = dns_servers changed = True if config.domainName != domainname: config.domainName = domainname changed = True if config.hostName != hostname: config.hostName = hostname changed = True if changed: host_network_system.UpdateDnsConfig(config) return changed def main(): argument_spec = vmware_argument_spec() argument_spec.update(dict(change_hostname_to=dict(required=True, type='str'), domainname=dict(required=True, type='str'), dns_servers=dict(required=True, type='list'))) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False) if not HAS_PYVMOMI: module.fail_json(msg='pyvmomi is required for this module') change_hostname_to = module.params['change_hostname_to'] domainname = module.params['domainname'] dns_servers = module.params['dns_servers'] try: content = connect_to_api(module) host = get_all_objs(content, [vim.HostSystem]) if not host: module.fail_json(msg="Unable to locate Physical Host.") host_system = host.keys()[0] changed = configure_dns(host_system, change_hostname_to, domainname, dns_servers) module.exit_json(changed=changed) except vmodl.RuntimeFault as runtime_fault: module.fail_json(msg=runtime_fault.msg) except vmodl.MethodFault as method_fault: module.fail_json(msg=method_fault.msg) except Exception as e: module.fail_json(msg=str(e)) from ansible.module_utils.vmware import * from ansible.module_utils.basic import * if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 1603, 3362, 838, 445, 7670, 665, 74, 915, 552, 6248, 28308, 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, 8948, 275, 1449, 199, 2595, 199, 578, 26, 19365, 63, 5797, 63, 888, 199, 3612, 63, 1802, 26, 14944, 27391, 10427, 14828, 10237, 11595, 199, 1802, 26, 272, 446, 14944, 27391, 10427, 14828, 10237, 11595, 199, 1023, 63, 3270, 26, 499, 14, 16, 199, 2502, 26, 298, 42, 3362, 838, 445, 7670, 8593, 22760, 5652, 3088, 2924, 199, 5983, 26, 272, 446, 30568, 641, 373, 22385, 959, 14, 21, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 1611, 54, 28603, 199, 1419, 26, 272, 1570, 63, 4269, 63, 475, 26, 267, 1369, 26, 288, 446, 710, 6246, 626, 376, 10427, 14828, 1591, 1077, 506, 2896, 370, 14, 267, 1415, 26, 715, 272, 2881, 354, 26, 267, 1369, 26, 288, 446, 710, 2881, 314, 10427, 14828, 1591, 1077, 506, 29430, 402, 14, 267, 1415, 26, 715, 272, 6715, 63, 5871, 26, 267, 1369, 26, 288, 446, 710, 10237, 8037, 626, 314, 1591, 1077, 506, 7526, 370, 675, 14, 267, 1415, 26, 715, 199, 11036, 63, 9970, 63, 7677, 26, 19365, 14, 9970, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5679, 19365, 63, 5797, 63, 888, 1414, 687, 2622, 16527, 8858, 199, 13, 536, 26, 15453, 10427, 14828, 6246, 436, 10237, 8037, 523, 2257, 63, 1287, 26, 272, 859, 26, 19365, 63, 5797, 63, 888, 272, 6246, 26, 9455, 6865, 63, 4269, 272, 3434, 26, 1738, 272, 2505, 26, 2195, 63, 2060, 272, 1570, 63, 4269, 63, 475, 26, 9455, 88, 614, 272, 2881, 354, 26, 3925, 14, 1308, 272, 6715, 63, 5871, 26, 267, 446, 1695, 14, 24, 14, 24, 14, 24, 267, 446, 1695, 14, 24, 14, 20, 14, 20, 199, 2344, 199, 893, 26, 272, 687, 1134, 54, 28603, 492, 6695, 12, 373, 1494, 76, 272, 7509, 63, 4521, 54, 2679, 10709, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 4521, 54, 2679, 10709, 275, 756, 421, 199, 318, 7908, 63, 5797, 8, 1102, 63, 2253, 12, 6246, 12, 2881, 354, 12, 6715, 63, 5871, 304, 339, 2896, 275, 756, 272, 1591, 63, 888, 63, 2609, 275, 1591, 63, 2253, 14, 888, 2988, 272, 1591, 63, 1200, 63, 2253, 275, 1591, 63, 888, 63, 2609, 14, 1200, 3989, 272, 1101, 275, 1591, 63, 1200, 63, 2253, 14, 5797, 2028, 339, 1101, 14, 10801, 275, 756, 339, 340, 1101, 14, 1562, 1137, 6715, 63, 5871, 26, 267, 1101, 14, 1562, 275, 6715, 63, 5871, 267, 2896, 275, 715, 272, 340, 1101, 14, 2261, 985, 1137, 2881, 354, 26, 267, 1101, 14, 2261, 985, 275, 2881, 354, 267, 2896, 275, 715, 272, 340, 1101, 14, 1102, 985, 1137, 6246, 26, 267, 1101, 14, 1102, 985, 275, 6246, 267, 2896, 275, 715, 272, 340, 2896, 26, 267, 1591, 63, 1200, 63, 2253, 14, 4152, 27664, 2028, 8, 888, 9, 339, 372, 2896, 421, 199, 318, 2446, 837, 339, 1423, 63, 1650, 275, 19365, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 807, 8, 1461, 63, 4269, 63, 475, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 659, 586, 2881, 354, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 659, 586, 6715, 63, 5871, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 513, 7058, 339, 859, 275, 6953, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 12, 5171, 63, 1074, 63, 632, 29, 797, 9, 339, 340, 440, 7509, 63, 4521, 54, 2679, 10709, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 647, 86, 28603, 365, 1415, 367, 642, 859, 358, 339, 1570, 63, 4269, 63, 475, 275, 859, 14, 1162, 459, 1461, 63, 4269, 63, 475, 418, 272, 2881, 354, 275, 859, 14, 1162, 459, 2261, 354, 418, 272, 6715, 63, 5871, 275, 859, 14, 1162, 459, 5797, 63, 5871, 418, 272, 862, 26, 267, 1564, 275, 4907, 63, 475, 63, 1246, 8, 578, 9, 267, 1591, 275, 664, 63, 452, 63, 8718, 8, 1317, 12, 359, 16361, 14, 4965, 3989, 566, 267, 340, 440, 1591, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 6005, 370, 16592, 24309, 7476, 10891, 2685, 267, 1591, 63, 2253, 275, 1591, 14, 1612, 3430, 16, 61, 267, 2896, 275, 7908, 63, 5797, 8, 1102, 63, 2253, 12, 1570, 63, 4269, 63, 475, 12, 2881, 354, 12, 6715, 63, 5871, 9, 267, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 9, 272, 871, 373, 1494, 76, 14, 14357, 16665, 465, 8836, 63, 1879, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 7726, 63, 1879, 14, 1328, 9, 272, 871, 373, 1494, 76, 14, 3767, 16665, 465, 1083, 63, 1879, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 765, 63, 1879, 14, 1328, 9, 272, 871, 2186, 465, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 495, 8, 69, 430, 421, 199, 504, 3242, 14, 578, 63, 1208, 14, 18970, 492, 627, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 199 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 1603, 3362, 838, 445, 7670, 665, 74, 915, 552, 6248, 28308, 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, 8948, 275, 1449, 199, 2595, 199, 578, 26, 19365, 63, 5797, 63, 888, 199, 3612, 63, 1802, 26, 14944, 27391, 10427, 14828, 10237, 11595, 199, 1802, 26, 272, 446, 14944, 27391, 10427, 14828, 10237, 11595, 199, 1023, 63, 3270, 26, 499, 14, 16, 199, 2502, 26, 298, 42, 3362, 838, 445, 7670, 8593, 22760, 5652, 3088, 2924, 199, 5983, 26, 272, 446, 30568, 641, 373, 22385, 959, 14, 21, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 1611, 54, 28603, 199, 1419, 26, 272, 1570, 63, 4269, 63, 475, 26, 267, 1369, 26, 288, 446, 710, 6246, 626, 376, 10427, 14828, 1591, 1077, 506, 2896, 370, 14, 267, 1415, 26, 715, 272, 2881, 354, 26, 267, 1369, 26, 288, 446, 710, 2881, 314, 10427, 14828, 1591, 1077, 506, 29430, 402, 14, 267, 1415, 26, 715, 272, 6715, 63, 5871, 26, 267, 1369, 26, 288, 446, 710, 10237, 8037, 626, 314, 1591, 1077, 506, 7526, 370, 675, 14, 267, 1415, 26, 715, 199, 11036, 63, 9970, 63, 7677, 26, 19365, 14, 9970, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5679, 19365, 63, 5797, 63, 888, 1414, 687, 2622, 16527, 8858, 199, 13, 536, 26, 15453, 10427, 14828, 6246, 436, 10237, 8037, 523, 2257, 63, 1287, 26, 272, 859, 26, 19365, 63, 5797, 63, 888, 272, 6246, 26, 9455, 6865, 63, 4269, 272, 3434, 26, 1738, 272, 2505, 26, 2195, 63, 2060, 272, 1570, 63, 4269, 63, 475, 26, 9455, 88, 614, 272, 2881, 354, 26, 3925, 14, 1308, 272, 6715, 63, 5871, 26, 267, 446, 1695, 14, 24, 14, 24, 14, 24, 267, 446, 1695, 14, 24, 14, 20, 14, 20, 199, 2344, 199, 893, 26, 272, 687, 1134, 54, 28603, 492, 6695, 12, 373, 1494, 76, 272, 7509, 63, 4521, 54, 2679, 10709, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 4521, 54, 2679, 10709, 275, 756, 421, 199, 318, 7908, 63, 5797, 8, 1102, 63, 2253, 12, 6246, 12, 2881, 354, 12, 6715, 63, 5871, 304, 339, 2896, 275, 756, 272, 1591, 63, 888, 63, 2609, 275, 1591, 63, 2253, 14, 888, 2988, 272, 1591, 63, 1200, 63, 2253, 275, 1591, 63, 888, 63, 2609, 14, 1200, 3989, 272, 1101, 275, 1591, 63, 1200, 63, 2253, 14, 5797, 2028, 339, 1101, 14, 10801, 275, 756, 339, 340, 1101, 14, 1562, 1137, 6715, 63, 5871, 26, 267, 1101, 14, 1562, 275, 6715, 63, 5871, 267, 2896, 275, 715, 272, 340, 1101, 14, 2261, 985, 1137, 2881, 354, 26, 267, 1101, 14, 2261, 985, 275, 2881, 354, 267, 2896, 275, 715, 272, 340, 1101, 14, 1102, 985, 1137, 6246, 26, 267, 1101, 14, 1102, 985, 275, 6246, 267, 2896, 275, 715, 272, 340, 2896, 26, 267, 1591, 63, 1200, 63, 2253, 14, 4152, 27664, 2028, 8, 888, 9, 339, 372, 2896, 421, 199, 318, 2446, 837, 339, 1423, 63, 1650, 275, 19365, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 807, 8, 1461, 63, 4269, 63, 475, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 659, 586, 2881, 354, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 659, 586, 6715, 63, 5871, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 513, 7058, 339, 859, 275, 6953, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 12, 5171, 63, 1074, 63, 632, 29, 797, 9, 339, 340, 440, 7509, 63, 4521, 54, 2679, 10709, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 647, 86, 28603, 365, 1415, 367, 642, 859, 358, 339, 1570, 63, 4269, 63, 475, 275, 859, 14, 1162, 459, 1461, 63, 4269, 63, 475, 418, 272, 2881, 354, 275, 859, 14, 1162, 459, 2261, 354, 418, 272, 6715, 63, 5871, 275, 859, 14, 1162, 459, 5797, 63, 5871, 418, 272, 862, 26, 267, 1564, 275, 4907, 63, 475, 63, 1246, 8, 578, 9, 267, 1591, 275, 664, 63, 452, 63, 8718, 8, 1317, 12, 359, 16361, 14, 4965, 3989, 566, 267, 340, 440, 1591, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 6005, 370, 16592, 24309, 7476, 10891, 2685, 267, 1591, 63, 2253, 275, 1591, 14, 1612, 3430, 16, 61, 267, 2896, 275, 7908, 63, 5797, 8, 1102, 63, 2253, 12, 1570, 63, 4269, 63, 475, 12, 2881, 354, 12, 6715, 63, 5871, 9, 267, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 9, 272, 871, 373, 1494, 76, 14, 14357, 16665, 465, 8836, 63, 1879, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 7726, 63, 1879, 14, 1328, 9, 272, 871, 373, 1494, 76, 14, 3767, 16665, 465, 1083, 63, 1879, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 765, 63, 1879, 14, 1328, 9, 272, 871, 2186, 465, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 495, 8, 69, 430, 421, 199, 504, 3242, 14, 578, 63, 1208, 14, 18970, 492, 627, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ecell/ecell3
ecell/pyecell/ecell/analysis/PathwayProxy.py
1
13263
#!/usr/bin/env python #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # # This file is part of the E-Cell System # # Copyright (C) 1996-2016 Keio University # Copyright (C) 2008-2016 RIKEN # Copyright (C) 2005-2009 The Molecular Sciences Institute # #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # # # E-Cell System 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. # # E-Cell System 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 E-Cell System -- see the file COPYING. # If not, write to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # #END_HEADER """ A program for handling and defining a pathway. This program is the extension package for E-Cell System Version 3. """ __program__ = 'PathwayProxy' __version__ = '1.0' __author__ = 'Kazunari Kaizu <kaizu@sfc.keio.ac.jp>' __coyright__ = '' __license__ = '' import ecell.eml from ecell.ecssupport import * from ecell.analysis.util import createVariableReferenceFullID import copy import numpy class PathwayProxy: def __init__( self, anEmlSupport, processList=None ): ''' anEmlSupport: Eml support object processList: (list) a list of process full path ''' self.theEmlSupport = anEmlSupport if processList: self.setProcessList( processList ) else: self.setProcessList( [] ) # end of __init__ def setProcessList( self, processList ): ''' set and detect a pathway processList: (list) a list of process full ID ''' # check the existence of processes, # and create relatedVariableList self.__processList = [] self.__variableList = [] for processFullID in processList: # if not self.theEmlSupport.isEntityExist( processFullID ): # continue self.__processList.append( processFullID ) try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) if self.__variableList.count( fullIDString ) == 0: self.__variableList.append( fullIDString ) self.__processList.sort() self.__variableList.sort() # end of setProcessList def getProcessList( self ): ''' return processList ''' return copy.copy( self.__processList ) # end of getProcessList def addProcess( self, processFullID ): ''' add a process to the pathway processFullID: (str) a process full ID ''' if not self.__processList.count( processFullID ) == 0: return # elif not ecell.eml.Eml.isEntityExist( processFullID ): # return # add process self.__processList.append( processFullID ) self.__processList.sort() # update the related variable list try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: return for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) if self.__variableList.count( fullIDString ) == 0: self.__variableList.append( fullIDString ) self.__variableList.sort() # end of addProcess def removeProcess( self, processIndexList ): ''' remove processes from the pathway processIndexList: (list) a list of indices of processes ''' indexList = copy.copy( processIndexList ) indexList.sort() indexList.reverse() removedProcessList = [] for i in indexList: if len( self.__processList ) > i: removedProcessList.append( self.__processList.pop( i ) ) removedVariableList = [] for processFullID in removedProcessList: # if not ecell.eml.Eml.isEntityExist( self.theEmlSupport, processFullID ): # continue try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) if removedVariableList.count( fullIDString ) == 0: removedVariableList.append( fullIDString ) for processFullID in self.__processList: # if not self.theEmlSupport.isEntityExist( processFullID ): # continue try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) if not removedVariableList.count( fullIDString ) == 0: removedVariableList.remove( fullIDString ) for variableFullID in removedVariableList: self.__variableList.remove( variableFullID ) # end of removeProcess def take( self, processIndexList ): ''' create and return a sub-pathway processIndexList: (list) a list of indices of processes return PathwayProxy ''' processList = [] for i in processIndexList: if len( self.__processList ) > i: processList.append( self.__processList[ i ] ) subPathway = PathwayProxy( self.theEmlSupport, processList ) return subPathway # end of removeProcess def getVariableList( self ): ''' return relatedVariableList ''' return copy.copy( self.__variableList ) # end of getVariableList def removeVariable( self, variableIndexList ): ''' remove variables from the pathway variableIndexList: (list) a list of indices of variables ''' indexList = copy.copy( variableIndexList ) indexList.sort() indexList.reverse() for i in indexList: if len( self.__variableList ) > i: self.__variableList.pop( i ) # end of removeVariable def addVariable( self, variableFullID ): ''' recover a removed variable to the pathway variableFullID: (str) a variable full ID ''' if not self.__variableList.count( variableFullID ) == 0: return 1 # elif not ecell.eml.Eml.isEntityExist( variableFullID ): # return 0 for processFullID in self.__processList: try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = fullID[ 1 ] + ':' + fullID[ 2 ] if fullIDString == variableFullID: self.__variableList.append( variableFullID ) self.__variableList.sort() return 1 return 0 # end of addProcess def getIncidentMatrix( self, mode=0 ): ''' create the incident matrix (array) mode: (0 or 1) 0 means that only the \'write\' variables are checked. 0 is set as default. return incidentMatrix ''' incidentMatrix = numpy.zeros( ( len( self.__variableList ), len( self.__processList ) ) ) for j in range( len( self.__processList ) ): processFullID = self.__processList[ j ] try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) try: i = self.__variableList.index( fullIDString ) except ValueError: # should some warning message be showed? continue if mode: if len( aVariableReference ) > 2: coeff = int( aVariableReference[ 2 ] ) if coeff != 0: incidentMatrix[ i ][ j ] = 1 else: incidentMatrix[ i ][ j ] = 1 return incidentMatrix # end of getIncidentMatrix def getStoichiometryMatrix( self ): ''' create the stoichiometry matrix (array) return stoichiometryMatrix ''' stoichiometryMatrix = numpy.zeros( ( len( self.__variableList ), len( self.__processList ) ), float ) for j in range( len( self.__processList ) ): processFullID = self.__processList[ j ] try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) try: i = self.__variableList.index( fullIDString ) except ValueError: # should some warning message be showed? continue if len( aVariableReference ) > 2: coeff = int( aVariableReference[ 2 ] ) if coeff != 0: stoichiometryMatrix[ i ][ j ] += coeff return stoichiometryMatrix # end of getStoichiometryMatrix def getReversibilityList( self ): ''' check and return the reversibilities (isReversible) for processes default value is 0, irreversible return reversibilityList ''' reversibilityList = [] for processFullID in self.__processList: propertyList = self.theEmlSupport.getEntityPropertyList( processFullID ) if propertyList.count( 'isReversible' ) != 0: # isReversible is handled as float isReversible = float( self.theEmlSupport.getEntityProperty( processFullID + ':isReversible' )[ 0 ] ) reversibilityList.append( int( isReversible ) ) else: # default value, irreversible reversibilityList.append( 0 ) return reversibilityList # end of getReversibilityList # end of PathwayProxy if __name__ == '__main__': from emlsupport import EmlSupport import sys import os def main( filename ): anEmlSupport = EmlSupport( filename ) pathwayProxy = anEmlSupport.createPathwayProxy() print 'process list =' print pathwayProxy.getProcessList() print 'related variable list =' print pathwayProxy.getVariableList() print 'incident matrix =' print pathwayProxy.getIncidentMatrix() print 'stoichiometry matrix =' print pathwayProxy.getStoichiometryMatrix() print 'reversibility list =' print pathwayProxy.getReversibilityList() # end of main if len( sys.argv ) > 1: main( sys.argv[ 1 ] ) else: filename = '../../../../doc/samples/Heinrich/Heinrich.eml' main( os.path.abspath( filename ) )
lgpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 447, 199, 3, 199, 3, 755, 961, 570, 365, 1777, 402, 314, 662, 13, 8108, 6187, 199, 3, 199, 3, 755, 1898, 334, 35, 9, 31347, 13, 9261, 25645, 2308, 15904, 199, 3, 755, 1898, 334, 35, 9, 9079, 13, 9261, 820, 41, 6945, 199, 3, 755, 1898, 334, 35, 9, 11811, 13, 8664, 710, 3930, 10251, 2238, 16578, 25231, 1010, 25585, 199, 3, 199, 3, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 447, 199, 3, 199, 3, 199, 3, 662, 13, 8108, 6187, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 662, 13, 8108, 6187, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 199, 3, 844, 3180, 543, 662, 13, 8108, 6187, 1553, 1937, 314, 570, 9685, 14, 199, 3, 982, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 446, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 3, 221, 199, 3, 3902, 63, 7311, 199, 199, 624, 199, 33, 2240, 367, 7252, 436, 12669, 282, 931, 3316, 14, 199, 2765, 2240, 365, 314, 3329, 2559, 367, 662, 13, 8108, 6187, 3394, 650, 14, 199, 624, 199, 199, 363, 6815, 363, 275, 283, 2042, 3316, 4936, 7, 199, 363, 1023, 363, 275, 283, 17, 14, 16, 7, 199, 363, 2502, 363, 275, 283, 43, 4651, 324, 759, 1804, 65, 565, 85, 665, 7351, 565, 85, 32, 83, 3003, 14, 415, 2308, 14, 645, 14, 11538, 3524, 199, 363, 331, 89, 1019, 363, 275, 2125, 199, 363, 1682, 363, 275, 2125, 421, 199, 646, 325, 3890, 14, 69, 757, 199, 504, 325, 3890, 14, 825, 385, 384, 719, 492, 627, 199, 504, 325, 3890, 14, 10466, 14, 1974, 492, 1218, 2773, 5083, 9042, 998, 199, 199, 646, 1331, 199, 199, 646, 2680, 421, 199, 533, 6912, 3316, 4936, 26, 339, 347, 636, 826, 721, 291, 12, 376, 37, 757, 11532, 12, 2112, 1296, 29, 403, 3461, 267, 1449, 267, 376, 37, 757, 11532, 26, 662, 757, 2291, 909, 267, 2112, 1296, 26, 334, 513, 9, 282, 769, 402, 2112, 2615, 931, 267, 1449, 398, 291, 14, 1589, 37, 757, 11532, 275, 376, 37, 757, 11532, 398, 340, 2112, 1296, 26, 288, 291, 14, 409, 3498, 1296, 8, 2112, 1296, 776, 267, 587, 26, 288, 291, 14, 409, 3498, 1296, 8, 942, 776, 339, 327, 1284, 402, 636, 826, 363, 2378, 347, 663, 3498, 1296, 8, 291, 12, 2112, 1296, 3461, 267, 1449, 267, 663, 436, 9696, 282, 931, 3316, 267, 2112, 1296, 26, 334, 513, 9, 282, 769, 402, 2112, 2615, 2870, 267, 1449, 398, 327, 1104, 314, 23780, 402, 10358, 12, 267, 327, 436, 1218, 4048, 27995, 267, 291, 855, 1412, 1296, 275, 942, 267, 291, 855, 1975, 1296, 275, 942, 398, 367, 2112, 9042, 998, 315, 2112, 1296, 26, 1467, 199, 3, 3322, 340, 440, 291, 14, 1589, 37, 757, 11532, 14, 374, 7302, 6439, 8, 2112, 9042, 998, 3461, 199, 3, 4483, 1980, 953, 291, 855, 1412, 1296, 14, 740, 8, 2112, 9042, 998, 776, 7846, 862, 26, 355, 282, 2773, 5083, 1296, 275, 291, 14, 1589, 37, 757, 11532, 14, 362, 7302, 3697, 8, 2112, 9042, 998, 435, 7596, 2773, 5083, 1296, 7, 776, 953, 871, 4281, 12, 325, 26, 355, 1980, 7846, 367, 282, 2773, 5083, 315, 282, 2773, 5083, 1296, 26, 355, 2615, 998, 275, 1218, 2773, 5083, 9042, 998, 8, 282, 2773, 5083, 59, 413, 2156, 2112, 9042, 998, 776, 355, 2615, 998, 1558, 275, 325, 3890, 14, 825, 385, 384, 719, 14, 981, 9042, 998, 1558, 8, 2615, 998, 776, 2234, 340, 291, 855, 1975, 1296, 14, 835, 8, 2615, 998, 1558, 776, 508, 378, 26, 490, 291, 855, 1975, 1296, 14, 740, 8, 2615, 998, 1558, 776, 398, 291, 855, 1412, 1296, 14, 3191, 342, 267, 291, 855, 1975, 1296, 14, 3191, 342, 339, 327, 1284, 402, 663, 3498, 1296, 2378, 347, 664, 3498, 1296, 8, 291, 3461, 267, 1449, 267, 372, 2112, 1296, 267, 1449, 398, 372, 1331, 14, 1574, 8, 291, 855, 1412, 1296, 776, 339, 327, 1284, 402, 664, 3498, 1296, 1362, 339, 347, 1050, 3498, 8, 291, 12, 2112, 9042, 998, 3461, 267, 1449, 267, 1050, 282, 2112, 370, 314, 931, 3316, 267, 2112, 9042, 998, 26, 334, 495, 9, 282, 2112, 2615, 2870, 267, 1449, 398, 340, 440, 291, 855, 1412, 1296, 14, 835, 8, 2112, 9042, 998, 776, 508, 378, 26, 288, 372, 199, 3, 263, 916, 440, 325, 3890, 14, 69, 757, 14, 37, 757, 14, 374, 7302, 6439, 8, 2112, 9042, 998, 3461, 199, 3, 3322, 372, 398, 327, 1050, 2112, 267, 291, 855, 1412, 1296, 14, 740, 8, 2112, 9042, 998, 776, 267, 291, 855, 1412, 1296, 14, 3191, 342, 398, 327, 1678, 314, 4048, 1750, 769, 267, 862, 26, 288, 282, 2773, 5083, 1296, 275, 291, 14, 1589, 37, 757, 11532, 14, 362, 7302, 3697, 8, 2112, 9042, 998, 435, 7596, 2773, 5083, 1296, 7, 776, 398, 871, 4281, 12, 325, 26, 288, 372, 2728, 367, 282, 2773, 5083, 315, 282, 2773, 5083, 1296, 26, 288, 2615, 998, 275, 1218, 2773, 5083, 9042, 998, 8, 282, 2773, 5083, 59, 413, 2156, 2112, 9042, 998, 776, 288, 2615, 998, 1558, 275, 325, 3890, 14, 825, 385, 384, 719, 14, 981, 9042, 998, 1558, 8, 2615, 998, 776, 953, 340, 291, 855 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 447, 199, 3, 199, 3, 755, 961, 570, 365, 1777, 402, 314, 662, 13, 8108, 6187, 199, 3, 199, 3, 755, 1898, 334, 35, 9, 31347, 13, 9261, 25645, 2308, 15904, 199, 3, 755, 1898, 334, 35, 9, 9079, 13, 9261, 820, 41, 6945, 199, 3, 755, 1898, 334, 35, 9, 11811, 13, 8664, 710, 3930, 10251, 2238, 16578, 25231, 1010, 25585, 199, 3, 199, 3, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 25131, 447, 199, 3, 199, 3, 199, 3, 662, 13, 8108, 6187, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 662, 13, 8108, 6187, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 199, 3, 844, 3180, 543, 662, 13, 8108, 6187, 1553, 1937, 314, 570, 9685, 14, 199, 3, 982, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 446, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 3, 221, 199, 3, 3902, 63, 7311, 199, 199, 624, 199, 33, 2240, 367, 7252, 436, 12669, 282, 931, 3316, 14, 199, 2765, 2240, 365, 314, 3329, 2559, 367, 662, 13, 8108, 6187, 3394, 650, 14, 199, 624, 199, 199, 363, 6815, 363, 275, 283, 2042, 3316, 4936, 7, 199, 363, 1023, 363, 275, 283, 17, 14, 16, 7, 199, 363, 2502, 363, 275, 283, 43, 4651, 324, 759, 1804, 65, 565, 85, 665, 7351, 565, 85, 32, 83, 3003, 14, 415, 2308, 14, 645, 14, 11538, 3524, 199, 363, 331, 89, 1019, 363, 275, 2125, 199, 363, 1682, 363, 275, 2125, 421, 199, 646, 325, 3890, 14, 69, 757, 199, 504, 325, 3890, 14, 825, 385, 384, 719, 492, 627, 199, 504, 325, 3890, 14, 10466, 14, 1974, 492, 1218, 2773, 5083, 9042, 998, 199, 199, 646, 1331, 199, 199, 646, 2680, 421, 199, 533, 6912, 3316, 4936, 26, 339, 347, 636, 826, 721, 291, 12, 376, 37, 757, 11532, 12, 2112, 1296, 29, 403, 3461, 267, 1449, 267, 376, 37, 757, 11532, 26, 662, 757, 2291, 909, 267, 2112, 1296, 26, 334, 513, 9, 282, 769, 402, 2112, 2615, 931, 267, 1449, 398, 291, 14, 1589, 37, 757, 11532, 275, 376, 37, 757, 11532, 398, 340, 2112, 1296, 26, 288, 291, 14, 409, 3498, 1296, 8, 2112, 1296, 776, 267, 587, 26, 288, 291, 14, 409, 3498, 1296, 8, 942, 776, 339, 327, 1284, 402, 636, 826, 363, 2378, 347, 663, 3498, 1296, 8, 291, 12, 2112, 1296, 3461, 267, 1449, 267, 663, 436, 9696, 282, 931, 3316, 267, 2112, 1296, 26, 334, 513, 9, 282, 769, 402, 2112, 2615, 2870, 267, 1449, 398, 327, 1104, 314, 23780, 402, 10358, 12, 267, 327, 436, 1218, 4048, 27995, 267, 291, 855, 1412, 1296, 275, 942, 267, 291, 855, 1975, 1296, 275, 942, 398, 367, 2112, 9042, 998, 315, 2112, 1296, 26, 1467, 199, 3, 3322, 340, 440, 291, 14, 1589, 37, 757, 11532, 14, 374, 7302, 6439, 8, 2112, 9042, 998, 3461, 199, 3, 4483, 1980, 953, 291, 855, 1412, 1296, 14, 740, 8, 2112, 9042, 998, 776, 7846, 862, 26, 355, 282, 2773, 5083, 1296, 275, 291, 14, 1589, 37, 757, 11532, 14, 362, 7302, 3697, 8, 2112, 9042, 998, 435, 7596, 2773, 5083, 1296, 7, 776, 953, 871, 4281, 12, 325, 26, 355, 1980, 7846, 367, 282, 2773, 5083, 315, 282, 2773, 5083, 1296, 26, 355, 2615, 998, 275, 1218, 2773, 5083, 9042, 998, 8, 282, 2773, 5083, 59, 413, 2156, 2112, 9042, 998, 776, 355, 2615, 998, 1558, 275, 325, 3890, 14, 825, 385, 384, 719, 14, 981, 9042, 998, 1558, 8, 2615, 998, 776, 2234, 340, 291, 855, 1975, 1296, 14, 835, 8, 2615, 998, 1558, 776, 508, 378, 26, 490, 291, 855, 1975, 1296, 14, 740, 8, 2615, 998, 1558, 776, 398, 291, 855, 1412, 1296, 14, 3191, 342, 267, 291, 855, 1975, 1296, 14, 3191, 342, 339, 327, 1284, 402, 663, 3498, 1296, 2378, 347, 664, 3498, 1296, 8, 291, 3461, 267, 1449, 267, 372, 2112, 1296, 267, 1449, 398, 372, 1331, 14, 1574, 8, 291, 855, 1412, 1296, 776, 339, 327, 1284, 402, 664, 3498, 1296, 1362, 339, 347, 1050, 3498, 8, 291, 12, 2112, 9042, 998, 3461, 267, 1449, 267, 1050, 282, 2112, 370, 314, 931, 3316, 267, 2112, 9042, 998, 26, 334, 495, 9, 282, 2112, 2615, 2870, 267, 1449, 398, 340, 440, 291, 855, 1412, 1296, 14, 835, 8, 2112, 9042, 998, 776, 508, 378, 26, 288, 372, 199, 3, 263, 916, 440, 325, 3890, 14, 69, 757, 14, 37, 757, 14, 374, 7302, 6439, 8, 2112, 9042, 998, 3461, 199, 3, 3322, 372, 398, 327, 1050, 2112, 267, 291, 855, 1412, 1296, 14, 740, 8, 2112, 9042, 998, 776, 267, 291, 855, 1412, 1296, 14, 3191, 342, 398, 327, 1678, 314, 4048, 1750, 769, 267, 862, 26, 288, 282, 2773, 5083, 1296, 275, 291, 14, 1589, 37, 757, 11532, 14, 362, 7302, 3697, 8, 2112, 9042, 998, 435, 7596, 2773, 5083, 1296, 7, 776, 398, 871, 4281, 12, 325, 26, 288, 372, 2728, 367, 282, 2773, 5083, 315, 282, 2773, 5083, 1296, 26, 288, 2615, 998, 275, 1218, 2773, 5083, 9042, 998, 8, 282, 2773, 5083, 59, 413, 2156, 2112, 9042, 998, 776, 288, 2615, 998, 1558, 275, 325, 3890, 14, 825, 385, 384, 719, 14, 981, 9042, 998, 1558, 8, 2615, 998, 776, 953, 340, 291, 855, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pymedusa/Medusa
ext/boto/pyami/scriptbase.py
153
1427
import os import sys from boto.utils import ShellCommand, get_ts import boto import boto.utils class ScriptBase(object): def __init__(self, config_file=None): self.instance_id = boto.config.get('Instance', 'instance-id', 'default') self.name = self.__class__.__name__ self.ts = get_ts() if config_file: boto.config.read(config_file) def notify(self, subject, body=''): boto.utils.notify(subject, body) def mkdir(self, path): if not os.path.isdir(path): try: os.mkdir(path) except: boto.log.error('Error creating directory: %s' % path) def umount(self, path): if os.path.ismount(path): self.run('umount %s' % path) def run(self, command, notify=True, exit_on_error=False, cwd=None): self.last_command = ShellCommand(command, cwd=cwd) if self.last_command.status != 0: boto.log.error('Error running command: "%s". Output: "%s"' % (command, self.last_command.output)) if notify: self.notify('Error encountered', 'Error running the following command:\n\t%s\n\nCommand output:\n\t%s' % \ (command, self.last_command.output)) if exit_on_error: sys.exit(-1) return self.last_command.status def main(self): pass
gpl-3.0
[ 646, 747, 199, 646, 984, 199, 504, 6055, 14, 1208, 492, 24599, 3110, 12, 664, 63, 1086, 199, 646, 6055, 199, 646, 6055, 14, 1208, 199, 199, 533, 14914, 1563, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1101, 63, 493, 29, 403, 304, 267, 291, 14, 842, 63, 344, 275, 6055, 14, 888, 14, 362, 360, 3244, 297, 283, 842, 13, 344, 297, 283, 885, 358, 267, 291, 14, 354, 275, 291, 855, 533, 4914, 354, 363, 267, 291, 14, 1086, 275, 664, 63, 1086, 342, 267, 340, 1101, 63, 493, 26, 288, 6055, 14, 888, 14, 739, 8, 888, 63, 493, 9, 339, 347, 11705, 8, 277, 12, 5420, 12, 2396, 9280, 267, 6055, 14, 1208, 14, 6814, 8, 5875, 12, 2396, 9, 339, 347, 20366, 8, 277, 12, 931, 304, 267, 340, 440, 747, 14, 515, 14, 6027, 8, 515, 304, 288, 862, 26, 355, 747, 14, 8215, 8, 515, 9, 288, 871, 26, 355, 6055, 14, 793, 14, 705, 360, 547, 6425, 2082, 26, 450, 83, 7, 450, 931, 9, 339, 347, 399, 3956, 8, 277, 12, 931, 304, 267, 340, 747, 14, 515, 14, 374, 3956, 8, 515, 304, 288, 291, 14, 1065, 360, 453, 79, 638, 450, 83, 7, 450, 931, 9, 339, 347, 1255, 8, 277, 12, 1414, 12, 11705, 29, 549, 12, 4458, 63, 265, 63, 705, 29, 797, 12, 8288, 29, 403, 304, 267, 291, 14, 2019, 63, 1531, 275, 24599, 3110, 8, 1531, 12, 8288, 29, 6525, 9, 267, 340, 291, 14, 2019, 63, 1531, 14, 1205, 1137, 378, 26, 288, 6055, 14, 793, 14, 705, 360, 547, 3879, 1414, 26, 2071, 83, 1674, 7242, 26, 2071, 83, 4507, 450, 334, 1531, 12, 291, 14, 2019, 63, 1531, 14, 1199, 430, 288, 340, 11705, 26, 355, 291, 14, 6814, 360, 547, 14556, 297, 1169, 283, 547, 3879, 314, 2569, 1414, 3427, 78, 60, 84, 5, 83, 60, 78, 60, 78, 3110, 1072, 3427, 78, 60, 84, 5, 83, 7, 450, 971, 1169, 334, 1531, 12, 291, 14, 2019, 63, 1531, 14, 1199, 430, 288, 340, 4458, 63, 265, 63, 705, 26, 355, 984, 14, 2224, 2801, 17, 9, 267, 372, 291, 14, 2019, 63, 1531, 14, 1205, 339, 347, 2446, 8, 277, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 504, 6055, 14, 1208, 492, 24599, 3110, 12, 664, 63, 1086, 199, 646, 6055, 199, 646, 6055, 14, 1208, 199, 199, 533, 14914, 1563, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1101, 63, 493, 29, 403, 304, 267, 291, 14, 842, 63, 344, 275, 6055, 14, 888, 14, 362, 360, 3244, 297, 283, 842, 13, 344, 297, 283, 885, 358, 267, 291, 14, 354, 275, 291, 855, 533, 4914, 354, 363, 267, 291, 14, 1086, 275, 664, 63, 1086, 342, 267, 340, 1101, 63, 493, 26, 288, 6055, 14, 888, 14, 739, 8, 888, 63, 493, 9, 339, 347, 11705, 8, 277, 12, 5420, 12, 2396, 9280, 267, 6055, 14, 1208, 14, 6814, 8, 5875, 12, 2396, 9, 339, 347, 20366, 8, 277, 12, 931, 304, 267, 340, 440, 747, 14, 515, 14, 6027, 8, 515, 304, 288, 862, 26, 355, 747, 14, 8215, 8, 515, 9, 288, 871, 26, 355, 6055, 14, 793, 14, 705, 360, 547, 6425, 2082, 26, 450, 83, 7, 450, 931, 9, 339, 347, 399, 3956, 8, 277, 12, 931, 304, 267, 340, 747, 14, 515, 14, 374, 3956, 8, 515, 304, 288, 291, 14, 1065, 360, 453, 79, 638, 450, 83, 7, 450, 931, 9, 339, 347, 1255, 8, 277, 12, 1414, 12, 11705, 29, 549, 12, 4458, 63, 265, 63, 705, 29, 797, 12, 8288, 29, 403, 304, 267, 291, 14, 2019, 63, 1531, 275, 24599, 3110, 8, 1531, 12, 8288, 29, 6525, 9, 267, 340, 291, 14, 2019, 63, 1531, 14, 1205, 1137, 378, 26, 288, 6055, 14, 793, 14, 705, 360, 547, 3879, 1414, 26, 2071, 83, 1674, 7242, 26, 2071, 83, 4507, 450, 334, 1531, 12, 291, 14, 2019, 63, 1531, 14, 1199, 430, 288, 340, 11705, 26, 355, 291, 14, 6814, 360, 547, 14556, 297, 1169, 283, 547, 3879, 314, 2569, 1414, 3427, 78, 60, 84, 5, 83, 60, 78, 60, 78, 3110, 1072, 3427, 78, 60, 84, 5, 83, 7, 450, 971, 1169, 334, 1531, 12, 291, 14, 2019, 63, 1531, 14, 1199, 430, 288, 340, 4458, 63, 265, 63, 705, 26, 355, 984, 14, 2224, 2801, 17, 9, 267, 372, 291, 14, 2019, 63, 1531, 14, 1205, 339, 347, 2446, 8, 277, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
Ichag/odoo
addons/hr_expense/report/__init__.py
380
1071
# -*- 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 hr_expense_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 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, 16140, 63, 16886, 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, 32768, 32768, 32768, 32768, 32768, 32768, 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, 16140, 63, 16886, 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, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
AydinSakar/node-gyp
gyp/pylib/gyp/xcode_emulation.py
65
42931
# Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ This module contains classes that help to emulate xcodebuild behavior on top of other build systems, such as make and ninja. """ import gyp.common import os.path import re import shlex import subprocess import sys from gyp.common import GypError class XcodeSettings(object): """A class that understands the gyp 'xcode_settings' object.""" # Populated lazily by _SdkPath(). Shared by all XcodeSettings, so cached # at class-level for efficiency. _sdk_path_cache = {} def __init__(self, spec): self.spec = spec # Per-target 'xcode_settings' are pushed down into configs earlier by gyp. # This means self.xcode_settings[config] always contains all settings # for that config -- the per-target settings as well. Settings that are # the same for all configs are implicitly per-target settings. self.xcode_settings = {} configs = spec['configurations'] for configname, config in configs.iteritems(): self.xcode_settings[configname] = config.get('xcode_settings', {}) # This is only non-None temporarily during the execution of some methods. self.configname = None # Used by _AdjustLibrary to match .a and .dylib entries in libraries. self.library_re = re.compile(r'^lib([^/]+)\.(a|dylib)$') def _Settings(self): assert self.configname return self.xcode_settings[self.configname] def _Test(self, test_key, cond_key, default): return self._Settings().get(test_key, default) == cond_key def _Appendf(self, lst, test_key, format_str, default=None): if test_key in self._Settings(): lst.append(format_str % str(self._Settings()[test_key])) elif default: lst.append(format_str % str(default)) def _WarnUnimplemented(self, test_key): if test_key in self._Settings(): print 'Warning: Ignoring not yet implemented key "%s".' % test_key def _IsBundle(self): return int(self.spec.get('mac_bundle', 0)) != 0 def GetFrameworkVersion(self): """Returns the framework version of the current target. Only valid for bundles.""" assert self._IsBundle() return self.GetPerTargetSetting('FRAMEWORK_VERSION', default='A') def GetWrapperExtension(self): """Returns the bundle extension (.app, .framework, .plugin, etc). Only valid for bundles.""" assert self._IsBundle() if self.spec['type'] in ('loadable_module', 'shared_library'): default_wrapper_extension = { 'loadable_module': 'bundle', 'shared_library': 'framework', }[self.spec['type']] wrapper_extension = self.GetPerTargetSetting( 'WRAPPER_EXTENSION', default=default_wrapper_extension) return '.' + self.spec.get('product_extension', wrapper_extension) elif self.spec['type'] == 'executable': return '.app' else: assert False, "Don't know extension for '%s', target '%s'" % ( self.spec['type'], self.spec['target_name']) def GetProductName(self): """Returns PRODUCT_NAME.""" return self.spec.get('product_name', self.spec['target_name']) def GetFullProductName(self): """Returns FULL_PRODUCT_NAME.""" if self._IsBundle(): return self.GetWrapperName() else: return self._GetStandaloneBinaryPath() def GetWrapperName(self): """Returns the directory name of the bundle represented by this target. Only valid for bundles.""" assert self._IsBundle() return self.GetProductName() + self.GetWrapperExtension() def GetBundleContentsFolderPath(self): """Returns the qualified path to the bundle's contents folder. E.g. Chromium.app/Contents or Foo.bundle/Versions/A. Only valid for bundles.""" assert self._IsBundle() if self.spec['type'] == 'shared_library': return os.path.join( self.GetWrapperName(), 'Versions', self.GetFrameworkVersion()) else: # loadable_modules have a 'Contents' folder like executables. return os.path.join(self.GetWrapperName(), 'Contents') def GetBundleResourceFolder(self): """Returns the qualified path to the bundle's resource folder. E.g. Chromium.app/Contents/Resources. Only valid for bundles.""" assert self._IsBundle() return os.path.join(self.GetBundleContentsFolderPath(), 'Resources') def GetBundlePlistPath(self): """Returns the qualified path to the bundle's plist file. E.g. Chromium.app/Contents/Info.plist. Only valid for bundles.""" assert self._IsBundle() if self.spec['type'] in ('executable', 'loadable_module'): return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist') else: return os.path.join(self.GetBundleContentsFolderPath(), 'Resources', 'Info.plist') def GetProductType(self): """Returns the PRODUCT_TYPE of this target.""" if self._IsBundle(): return { 'executable': 'com.apple.product-type.application', 'loadable_module': 'com.apple.product-type.bundle', 'shared_library': 'com.apple.product-type.framework', }[self.spec['type']] else: return { 'executable': 'com.apple.product-type.tool', 'loadable_module': 'com.apple.product-type.library.dynamic', 'shared_library': 'com.apple.product-type.library.dynamic', 'static_library': 'com.apple.product-type.library.static', }[self.spec['type']] def GetMachOType(self): """Returns the MACH_O_TYPE of this target.""" # Weird, but matches Xcode. if not self._IsBundle() and self.spec['type'] == 'executable': return '' return { 'executable': 'mh_execute', 'static_library': 'staticlib', 'shared_library': 'mh_dylib', 'loadable_module': 'mh_bundle', }[self.spec['type']] def _GetBundleBinaryPath(self): """Returns the name of the bundle binary of by this target. E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles.""" assert self._IsBundle() if self.spec['type'] in ('shared_library'): path = self.GetBundleContentsFolderPath() elif self.spec['type'] in ('executable', 'loadable_module'): path = os.path.join(self.GetBundleContentsFolderPath(), 'MacOS') return os.path.join(path, self.GetExecutableName()) def _GetStandaloneExecutableSuffix(self): if 'product_extension' in self.spec: return '.' + self.spec['product_extension'] return { 'executable': '', 'static_library': '.a', 'shared_library': '.dylib', 'loadable_module': '.so', }[self.spec['type']] def _GetStandaloneExecutablePrefix(self): return self.spec.get('product_prefix', { 'executable': '', 'static_library': 'lib', 'shared_library': 'lib', # Non-bundled loadable_modules are called foo.so for some reason # (that is, .so and no prefix) with the xcode build -- match that. 'loadable_module': '', }[self.spec['type']]) def _GetStandaloneBinaryPath(self): """Returns the name of the non-bundle binary represented by this target. E.g. hello_world. Only valid for non-bundles.""" assert not self._IsBundle() assert self.spec['type'] in ( 'executable', 'shared_library', 'static_library', 'loadable_module'), ( 'Unexpected type %s' % self.spec['type']) target = self.spec['target_name'] if self.spec['type'] == 'static_library': if target[:3] == 'lib': target = target[3:] elif self.spec['type'] in ('loadable_module', 'shared_library'): if target[:3] == 'lib': target = target[3:] target_prefix = self._GetStandaloneExecutablePrefix() target = self.spec.get('product_name', target) target_ext = self._GetStandaloneExecutableSuffix() return target_prefix + target + target_ext def GetExecutableName(self): """Returns the executable name of the bundle represented by this target. E.g. Chromium.""" if self._IsBundle(): return self.spec.get('product_name', self.spec['target_name']) else: return self._GetStandaloneBinaryPath() def GetExecutablePath(self): """Returns the directory name of the bundle represented by this target. E.g. Chromium.app/Contents/MacOS/Chromium.""" if self._IsBundle(): return self._GetBundleBinaryPath() else: return self._GetStandaloneBinaryPath() def _GetSdkVersionInfoItem(self, sdk, infoitem): job = subprocess.Popen(['xcodebuild', '-version', '-sdk', sdk, infoitem], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out = job.communicate()[0] if job.returncode != 0: sys.stderr.write(out + '\n') raise GypError('Error %d running xcodebuild' % job.returncode) return out.rstrip('\n') def _SdkPath(self): sdk_root = self.GetPerTargetSetting('SDKROOT', default='macosx') if sdk_root not in XcodeSettings._sdk_path_cache: XcodeSettings._sdk_path_cache[sdk_root] = self._GetSdkVersionInfoItem( sdk_root, 'Path') return XcodeSettings._sdk_path_cache[sdk_root] def _AppendPlatformVersionMinFlags(self, lst): self._Appendf(lst, 'MACOSX_DEPLOYMENT_TARGET', '-mmacosx-version-min=%s') if 'IPHONEOS_DEPLOYMENT_TARGET' in self._Settings(): # TODO: Implement this better? sdk_path_basename = os.path.basename(self._SdkPath()) if sdk_path_basename.lower().startswith('iphonesimulator'): self._Appendf(lst, 'IPHONEOS_DEPLOYMENT_TARGET', '-mios-simulator-version-min=%s') else: self._Appendf(lst, 'IPHONEOS_DEPLOYMENT_TARGET', '-miphoneos-version-min=%s') def GetCflags(self, configname): """Returns flags that need to be added to .c, .cc, .m, and .mm compilations.""" # This functions (and the similar ones below) do not offer complete # emulation of all xcode_settings keys. They're implemented on demand. self.configname = configname cflags = [] sdk_root = self._SdkPath() if 'SDKROOT' in self._Settings(): cflags.append('-isysroot %s' % sdk_root) if self._Test('CLANG_WARN_CONSTANT_CONVERSION', 'YES', default='NO'): cflags.append('-Wconstant-conversion') if self._Test('GCC_CHAR_IS_UNSIGNED_CHAR', 'YES', default='NO'): cflags.append('-funsigned-char') if self._Test('GCC_CW_ASM_SYNTAX', 'YES', default='YES'): cflags.append('-fasm-blocks') if 'GCC_DYNAMIC_NO_PIC' in self._Settings(): if self._Settings()['GCC_DYNAMIC_NO_PIC'] == 'YES': cflags.append('-mdynamic-no-pic') else: pass # TODO: In this case, it depends on the target. xcode passes # mdynamic-no-pic by default for executable and possibly static lib # according to mento if self._Test('GCC_ENABLE_PASCAL_STRINGS', 'YES', default='YES'): cflags.append('-mpascal-strings') self._Appendf(cflags, 'GCC_OPTIMIZATION_LEVEL', '-O%s', default='s') if self._Test('GCC_GENERATE_DEBUGGING_SYMBOLS', 'YES', default='YES'): dbg_format = self._Settings().get('DEBUG_INFORMATION_FORMAT', 'dwarf') if dbg_format == 'dwarf': cflags.append('-gdwarf-2') elif dbg_format == 'stabs': raise NotImplementedError('stabs debug format is not supported yet.') elif dbg_format == 'dwarf-with-dsym': cflags.append('-gdwarf-2') else: raise NotImplementedError('Unknown debug format %s' % dbg_format) if self._Test('GCC_SYMBOLS_PRIVATE_EXTERN', 'YES', default='NO'): cflags.append('-fvisibility=hidden') if self._Test('GCC_TREAT_WARNINGS_AS_ERRORS', 'YES', default='NO'): cflags.append('-Werror') if self._Test('GCC_WARN_ABOUT_MISSING_NEWLINE', 'YES', default='NO'): cflags.append('-Wnewline-eof') self._AppendPlatformVersionMinFlags(cflags) # TODO: if self._Test('COPY_PHASE_STRIP', 'YES', default='NO'): self._WarnUnimplemented('COPY_PHASE_STRIP') self._WarnUnimplemented('GCC_DEBUGGING_SYMBOLS') self._WarnUnimplemented('GCC_ENABLE_OBJC_EXCEPTIONS') # TODO: This is exported correctly, but assigning to it is not supported. self._WarnUnimplemented('MACH_O_TYPE') self._WarnUnimplemented('PRODUCT_TYPE') archs = self._Settings().get('ARCHS', ['i386']) if len(archs) != 1: # TODO: Supporting fat binaries will be annoying. self._WarnUnimplemented('ARCHS') archs = ['i386'] cflags.append('-arch ' + archs[0]) if archs[0] in ('i386', 'x86_64'): if self._Test('GCC_ENABLE_SSE3_EXTENSIONS', 'YES', default='NO'): cflags.append('-msse3') if self._Test('GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS', 'YES', default='NO'): cflags.append('-mssse3') # Note 3rd 's'. if self._Test('GCC_ENABLE_SSE41_EXTENSIONS', 'YES', default='NO'): cflags.append('-msse4.1') if self._Test('GCC_ENABLE_SSE42_EXTENSIONS', 'YES', default='NO'): cflags.append('-msse4.2') cflags += self._Settings().get('WARNING_CFLAGS', []) config = self.spec['configurations'][self.configname] framework_dirs = config.get('mac_framework_dirs', []) for directory in framework_dirs: cflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root)) self.configname = None return cflags def GetCflagsC(self, configname): """Returns flags that need to be added to .c, and .m compilations.""" self.configname = configname cflags_c = [] self._Appendf(cflags_c, 'GCC_C_LANGUAGE_STANDARD', '-std=%s') cflags_c += self._Settings().get('OTHER_CFLAGS', []) self.configname = None return cflags_c def GetCflagsCC(self, configname): """Returns flags that need to be added to .cc, and .mm compilations.""" self.configname = configname cflags_cc = [] clang_cxx_language_standard = self._Settings().get( 'CLANG_CXX_LANGUAGE_STANDARD') # Note: Don't make c++0x to c++11 so that c++0x can be used with older # clangs that don't understand c++11 yet (like Xcode 4.2's). if clang_cxx_language_standard: cflags_cc.append('-std=%s' % clang_cxx_language_standard) self._Appendf(cflags_cc, 'CLANG_CXX_LIBRARY', '-stdlib=%s') if self._Test('GCC_ENABLE_CPP_RTTI', 'NO', default='YES'): cflags_cc.append('-fno-rtti') if self._Test('GCC_ENABLE_CPP_EXCEPTIONS', 'NO', default='YES'): cflags_cc.append('-fno-exceptions') if self._Test('GCC_INLINES_ARE_PRIVATE_EXTERN', 'YES', default='NO'): cflags_cc.append('-fvisibility-inlines-hidden') if self._Test('GCC_THREADSAFE_STATICS', 'NO', default='YES'): cflags_cc.append('-fno-threadsafe-statics') # Note: This flag is a no-op for clang, it only has an effect for gcc. if self._Test('GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO', 'NO', default='YES'): cflags_cc.append('-Wno-invalid-offsetof') other_ccflags = [] for flag in self._Settings().get('OTHER_CPLUSPLUSFLAGS', ['$(inherited)']): # TODO: More general variable expansion. Missing in many other places too. if flag in ('$inherited', '$(inherited)', '${inherited}'): flag = '$OTHER_CFLAGS' if flag in ('$OTHER_CFLAGS', '$(OTHER_CFLAGS)', '${OTHER_CFLAGS}'): other_ccflags += self._Settings().get('OTHER_CFLAGS', []) else: other_ccflags.append(flag) cflags_cc += other_ccflags self.configname = None return cflags_cc def _AddObjectiveCGarbageCollectionFlags(self, flags): gc_policy = self._Settings().get('GCC_ENABLE_OBJC_GC', 'unsupported') if gc_policy == 'supported': flags.append('-fobjc-gc') elif gc_policy == 'required': flags.append('-fobjc-gc-only') def GetCflagsObjC(self, configname): """Returns flags that need to be added to .m compilations.""" self.configname = configname cflags_objc = [] self._AddObjectiveCGarbageCollectionFlags(cflags_objc) self.configname = None return cflags_objc def GetCflagsObjCC(self, configname): """Returns flags that need to be added to .mm compilations.""" self.configname = configname cflags_objcc = [] self._AddObjectiveCGarbageCollectionFlags(cflags_objcc) if self._Test('GCC_OBJC_CALL_CXX_CDTORS', 'YES', default='NO'): cflags_objcc.append('-fobjc-call-cxx-cdtors') self.configname = None return cflags_objcc def GetInstallNameBase(self): """Return DYLIB_INSTALL_NAME_BASE for this target.""" # Xcode sets this for shared_libraries, and for nonbundled loadable_modules. if (self.spec['type'] != 'shared_library' and (self.spec['type'] != 'loadable_module' or self._IsBundle())): return None install_base = self.GetPerTargetSetting( 'DYLIB_INSTALL_NAME_BASE', default='/Library/Frameworks' if self._IsBundle() else '/usr/local/lib') return install_base def _StandardizePath(self, path): """Do :standardizepath processing for path.""" # I'm not quite sure what :standardizepath does. Just call normpath(), # but don't let @executable_path/../foo collapse to foo. if '/' in path: prefix, rest = '', path if path.startswith('@'): prefix, rest = path.split('/', 1) rest = os.path.normpath(rest) # :standardizepath path = os.path.join(prefix, rest) return path def GetInstallName(self): """Return LD_DYLIB_INSTALL_NAME for this target.""" # Xcode sets this for shared_libraries, and for nonbundled loadable_modules. if (self.spec['type'] != 'shared_library' and (self.spec['type'] != 'loadable_module' or self._IsBundle())): return None default_install_name = \ '$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)' install_name = self.GetPerTargetSetting( 'LD_DYLIB_INSTALL_NAME', default=default_install_name) # Hardcode support for the variables used in chromium for now, to # unblock people using the make build. if '$' in install_name: assert install_name in ('$(DYLIB_INSTALL_NAME_BASE:standardizepath)/' '$(WRAPPER_NAME)/$(PRODUCT_NAME)', default_install_name), ( 'Variables in LD_DYLIB_INSTALL_NAME are not generally supported ' 'yet in target \'%s\' (got \'%s\')' % (self.spec['target_name'], install_name)) install_name = install_name.replace( '$(DYLIB_INSTALL_NAME_BASE:standardizepath)', self._StandardizePath(self.GetInstallNameBase())) if self._IsBundle(): # These are only valid for bundles, hence the |if|. install_name = install_name.replace( '$(WRAPPER_NAME)', self.GetWrapperName()) install_name = install_name.replace( '$(PRODUCT_NAME)', self.GetProductName()) else: assert '$(WRAPPER_NAME)' not in install_name assert '$(PRODUCT_NAME)' not in install_name install_name = install_name.replace( '$(EXECUTABLE_PATH)', self.GetExecutablePath()) return install_name def _MapLinkerFlagFilename(self, ldflag, gyp_to_build_path): """Checks if ldflag contains a filename and if so remaps it from gyp-directory-relative to build-directory-relative.""" # This list is expanded on demand. # They get matched as: # -exported_symbols_list file # -Wl,exported_symbols_list file # -Wl,exported_symbols_list,file LINKER_FILE = '(\S+)' WORD = '\S+' linker_flags = [ ['-exported_symbols_list', LINKER_FILE], # Needed for NaCl. ['-unexported_symbols_list', LINKER_FILE], ['-reexported_symbols_list', LINKER_FILE], ['-sectcreate', WORD, WORD, LINKER_FILE], # Needed for remoting. ] for flag_pattern in linker_flags: regex = re.compile('(?:-Wl,)?' + '[ ,]'.join(flag_pattern)) m = regex.match(ldflag) if m: ldflag = ldflag[:m.start(1)] + gyp_to_build_path(m.group(1)) + \ ldflag[m.end(1):] # Required for ffmpeg (no idea why they don't use LIBRARY_SEARCH_PATHS, # TODO(thakis): Update ffmpeg.gyp): if ldflag.startswith('-L'): ldflag = '-L' + gyp_to_build_path(ldflag[len('-L'):]) return ldflag def GetLdflags(self, configname, product_dir, gyp_to_build_path): """Returns flags that need to be passed to the linker. Args: configname: The name of the configuration to get ld flags for. product_dir: The directory where products such static and dynamic libraries are placed. This is added to the library search path. gyp_to_build_path: A function that converts paths relative to the current gyp file to paths relative to the build direcotry. """ self.configname = configname ldflags = [] # The xcode build is relative to a gyp file's directory, and OTHER_LDFLAGS # can contain entries that depend on this. Explicitly absolutify these. for ldflag in self._Settings().get('OTHER_LDFLAGS', []): ldflags.append(self._MapLinkerFlagFilename(ldflag, gyp_to_build_path)) if self._Test('DEAD_CODE_STRIPPING', 'YES', default='NO'): ldflags.append('-Wl,-dead_strip') if self._Test('PREBINDING', 'YES', default='NO'): ldflags.append('-Wl,-prebind') self._Appendf( ldflags, 'DYLIB_COMPATIBILITY_VERSION', '-compatibility_version %s') self._Appendf( ldflags, 'DYLIB_CURRENT_VERSION', '-current_version %s') self._AppendPlatformVersionMinFlags(ldflags) if 'SDKROOT' in self._Settings(): ldflags.append('-isysroot ' + self._SdkPath()) for library_path in self._Settings().get('LIBRARY_SEARCH_PATHS', []): ldflags.append('-L' + gyp_to_build_path(library_path)) if 'ORDER_FILE' in self._Settings(): ldflags.append('-Wl,-order_file ' + '-Wl,' + gyp_to_build_path( self._Settings()['ORDER_FILE'])) archs = self._Settings().get('ARCHS', ['i386']) if len(archs) != 1: # TODO: Supporting fat binaries will be annoying. self._WarnUnimplemented('ARCHS') archs = ['i386'] ldflags.append('-arch ' + archs[0]) # Xcode adds the product directory by default. ldflags.append('-L' + product_dir) install_name = self.GetInstallName() if install_name: ldflags.append('-install_name ' + install_name.replace(' ', r'\ ')) for rpath in self._Settings().get('LD_RUNPATH_SEARCH_PATHS', []): ldflags.append('-Wl,-rpath,' + rpath) config = self.spec['configurations'][self.configname] framework_dirs = config.get('mac_framework_dirs', []) for directory in framework_dirs: ldflags.append('-F' + directory.replace('$(SDKROOT)', self._SdkPath())) self.configname = None return ldflags def GetLibtoolflags(self, configname): """Returns flags that need to be passed to the static linker. Args: configname: The name of the configuration to get ld flags for. """ self.configname = configname libtoolflags = [] for libtoolflag in self._Settings().get('OTHER_LDFLAGS', []): libtoolflags.append(libtoolflag) # TODO(thakis): ARCHS? self.configname = None return libtoolflags def GetPerTargetSettings(self): """Gets a list of all the per-target settings. This will only fetch keys whose values are the same across all configurations.""" first_pass = True result = {} for configname in sorted(self.xcode_settings.keys()): if first_pass: result = dict(self.xcode_settings[configname]) first_pass = False else: for key, value in self.xcode_settings[configname].iteritems(): if key not in result: continue elif result[key] != value: del result[key] return result def GetPerTargetSetting(self, setting, default=None): """Tries to get xcode_settings.setting from spec. Assumes that the setting has the same value in all configurations and throws otherwise.""" first_pass = True result = None for configname in sorted(self.xcode_settings.keys()): if first_pass: result = self.xcode_settings[configname].get(setting, None) first_pass = False else: assert result == self.xcode_settings[configname].get(setting, None), ( "Expected per-target setting for '%s', got per-config setting " "(target %s)" % (setting, spec['target_name'])) if result is None: return default return result def _GetStripPostbuilds(self, configname, output_binary, quiet): """Returns a list of shell commands that contain the shell commands neccessary to strip this target's binary. These should be run as postbuilds before the actual postbuilds run.""" self.configname = configname result = [] if (self._Test('DEPLOYMENT_POSTPROCESSING', 'YES', default='NO') and self._Test('STRIP_INSTALLED_PRODUCT', 'YES', default='NO')): default_strip_style = 'debugging' if self._IsBundle(): default_strip_style = 'non-global' elif self.spec['type'] == 'executable': default_strip_style = 'all' strip_style = self._Settings().get('STRIP_STYLE', default_strip_style) strip_flags = { 'all': '', 'non-global': '-x', 'debugging': '-S', }[strip_style] explicit_strip_flags = self._Settings().get('STRIPFLAGS', '') if explicit_strip_flags: strip_flags += ' ' + _NormalizeEnvVarReferences(explicit_strip_flags) if not quiet: result.append('echo STRIP\\(%s\\)' % self.spec['target_name']) result.append('strip %s %s' % (strip_flags, output_binary)) self.configname = None return result def _GetDebugInfoPostbuilds(self, configname, output, output_binary, quiet): """Returns a list of shell commands that contain the shell commands neccessary to massage this target's debug information. These should be run as postbuilds before the actual postbuilds run.""" self.configname = configname # For static libraries, no dSYMs are created. result = [] if (self._Test('GCC_GENERATE_DEBUGGING_SYMBOLS', 'YES', default='YES') and self._Test( 'DEBUG_INFORMATION_FORMAT', 'dwarf-with-dsym', default='dwarf') and self.spec['type'] != 'static_library'): if not quiet: result.append('echo DSYMUTIL\\(%s\\)' % self.spec['target_name']) result.append('dsymutil %s -o %s' % (output_binary, output + '.dSYM')) self.configname = None return result def GetTargetPostbuilds(self, configname, output, output_binary, quiet=False): """Returns a list of shell commands that contain the shell commands to run as postbuilds for this target, before the actual postbuilds.""" # dSYMs need to build before stripping happens. return ( self._GetDebugInfoPostbuilds(configname, output, output_binary, quiet) + self._GetStripPostbuilds(configname, output_binary, quiet)) def _AdjustLibrary(self, library): if library.endswith('.framework'): l = '-framework ' + os.path.splitext(os.path.basename(library))[0] else: m = self.library_re.match(library) if m: l = '-l' + m.group(1) else: l = library return l.replace('$(SDKROOT)', self._SdkPath()) def AdjustLibraries(self, libraries): """Transforms entries like 'Cocoa.framework' in libraries into entries like '-framework Cocoa', 'libcrypto.dylib' into '-lcrypto', etc. """ libraries = [ self._AdjustLibrary(library) for library in libraries] return libraries class MacPrefixHeader(object): """A class that helps with emulating Xcode's GCC_PREFIX_HEADER feature. This feature consists of several pieces: * If GCC_PREFIX_HEADER is present, all compilations in that project get an additional |-include path_to_prefix_header| cflag. * If GCC_PRECOMPILE_PREFIX_HEADER is present too, then the prefix header is instead compiled, and all other compilations in the project get an additional |-include path_to_compiled_header| instead. + Compiled prefix headers have the extension gch. There is one gch file for every language used in the project (c, cc, m, mm), since gch files for different languages aren't compatible. + gch files themselves are built with the target's normal cflags, but they obviously don't get the |-include| flag. Instead, they need a -x flag that describes their language. + All o files in the target need to depend on the gch file, to make sure it's built before any o file is built. This class helps with some of these tasks, but it needs help from the build system for writing dependencies to the gch files, for writing build commands for the gch files, and for figuring out the location of the gch files. """ def __init__(self, xcode_settings, gyp_path_to_build_path, gyp_path_to_build_output): """If xcode_settings is None, all methods on this class are no-ops. Args: gyp_path_to_build_path: A function that takes a gyp-relative path, and returns a path relative to the build directory. gyp_path_to_build_output: A function that takes a gyp-relative path and a language code ('c', 'cc', 'm', or 'mm'), and that returns a path to where the output of precompiling that path for that language should be placed (without the trailing '.gch'). """ # This doesn't support per-configuration prefix headers. Good enough # for now. self.header = None self.compile_headers = False if xcode_settings: self.header = xcode_settings.GetPerTargetSetting('GCC_PREFIX_HEADER') self.compile_headers = xcode_settings.GetPerTargetSetting( 'GCC_PRECOMPILE_PREFIX_HEADER', default='NO') != 'NO' self.compiled_headers = {} if self.header: if self.compile_headers: for lang in ['c', 'cc', 'm', 'mm']: self.compiled_headers[lang] = gyp_path_to_build_output( self.header, lang) self.header = gyp_path_to_build_path(self.header) def GetInclude(self, lang): """Gets the cflags to include the prefix header for language |lang|.""" if self.compile_headers and lang in self.compiled_headers: return '-include %s' % self.compiled_headers[lang] elif self.header: return '-include %s' % self.header else: return '' def _Gch(self, lang): """Returns the actual file name of the prefix header for language |lang|.""" assert self.compile_headers return self.compiled_headers[lang] + '.gch' def GetObjDependencies(self, sources, objs): """Given a list of source files and the corresponding object files, returns a list of (source, object, gch) tuples, where |gch| is the build-directory relative path to the gch file each object file depends on. |compilable[i]| has to be the source file belonging to |objs[i]|.""" if not self.header or not self.compile_headers: return [] result = [] for source, obj in zip(sources, objs): ext = os.path.splitext(source)[1] lang = { '.c': 'c', '.cpp': 'cc', '.cc': 'cc', '.cxx': 'cc', '.m': 'm', '.mm': 'mm', }.get(ext, None) if lang: result.append((source, obj, self._Gch(lang))) return result def GetPchBuildCommands(self): """Returns [(path_to_gch, language_flag, language, header)]. |path_to_gch| and |header| are relative to the build directory. """ if not self.header or not self.compile_headers: return [] return [ (self._Gch('c'), '-x c-header', 'c', self.header), (self._Gch('cc'), '-x c++-header', 'cc', self.header), (self._Gch('m'), '-x objective-c-header', 'm', self.header), (self._Gch('mm'), '-x objective-c++-header', 'mm', self.header), ] def MergeGlobalXcodeSettingsToSpec(global_dict, spec): """Merges the global xcode_settings dictionary into each configuration of the target represented by spec. For keys that are both in the global and the local xcode_settings dict, the local key gets precendence. """ # The xcode generator special-cases global xcode_settings and does something # that amounts to merging in the global xcode_settings into each local # xcode_settings dict. global_xcode_settings = global_dict.get('xcode_settings', {}) for config in spec['configurations'].values(): if 'xcode_settings' in config: new_settings = global_xcode_settings.copy() new_settings.update(config['xcode_settings']) config['xcode_settings'] = new_settings def IsMacBundle(flavor, spec): """Returns if |spec| should be treated as a bundle. Bundles are directories with a certain subdirectory structure, instead of just a single file. Bundle rules do not produce a binary but also package resources into that directory.""" is_mac_bundle = (int(spec.get('mac_bundle', 0)) != 0 and flavor == 'mac') if is_mac_bundle: assert spec['type'] != 'none', ( 'mac_bundle targets cannot have type none (target "%s")' % spec['target_name']) return is_mac_bundle def GetMacBundleResources(product_dir, xcode_settings, resources): """Yields (output, resource) pairs for every resource in |resources|. Only call this for mac bundle targets. Args: product_dir: Path to the directory containing the output bundle, relative to the build directory. xcode_settings: The XcodeSettings of the current target. resources: A list of bundle resources, relative to the build directory. """ dest = os.path.join(product_dir, xcode_settings.GetBundleResourceFolder()) for res in resources: output = dest # The make generator doesn't support it, so forbid it everywhere # to keep the generators more interchangable. assert ' ' not in res, ( "Spaces in resource filenames not supported (%s)" % res) # Split into (path,file). res_parts = os.path.split(res) # Now split the path into (prefix,maybe.lproj). lproj_parts = os.path.split(res_parts[0]) # If the resource lives in a .lproj bundle, add that to the destination. if lproj_parts[1].endswith('.lproj'): output = os.path.join(output, lproj_parts[1]) output = os.path.join(output, res_parts[1]) # Compiled XIB files are referred to by .nib. if output.endswith('.xib'): output = output[0:-3] + 'nib' yield output, res def GetMacInfoPlist(product_dir, xcode_settings, gyp_path_to_build_path): """Returns (info_plist, dest_plist, defines, extra_env), where: * |info_plist| is the sourc plist path, relative to the build directory, * |dest_plist| is the destination plist path, relative to the build directory, * |defines| is a list of preprocessor defines (empty if the plist shouldn't be preprocessed, * |extra_env| is a dict of env variables that should be exported when invoking |mac_tool copy-info-plist|. Only call this for mac bundle targets. Args: product_dir: Path to the directory containing the output bundle, relative to the build directory. xcode_settings: The XcodeSettings of the current target. gyp_to_build_path: A function that converts paths relative to the current gyp file to paths relative to the build direcotry. """ info_plist = xcode_settings.GetPerTargetSetting('INFOPLIST_FILE') if not info_plist: return None, None, [], {} # The make generator doesn't support it, so forbid it everywhere # to keep the generators more interchangable. assert ' ' not in info_plist, ( "Spaces in Info.plist filenames not supported (%s)" % info_plist) info_plist = gyp_path_to_build_path(info_plist) # If explicitly set to preprocess the plist, invoke the C preprocessor and # specify any defines as -D flags. if xcode_settings.GetPerTargetSetting( 'INFOPLIST_PREPROCESS', default='NO') == 'YES': # Create an intermediate file based on the path. defines = shlex.split(xcode_settings.GetPerTargetSetting( 'INFOPLIST_PREPROCESSOR_DEFINITIONS', default='')) else: defines = [] dest_plist = os.path.join(product_dir, xcode_settings.GetBundlePlistPath()) extra_env = xcode_settings.GetPerTargetSettings() return info_plist, dest_plist, defines, extra_env def _GetXcodeEnv(xcode_settings, built_products_dir, srcroot, configuration, additional_settings=None): """Return the environment variables that Xcode would set. See http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW153 for a full list. Args: xcode_settings: An XcodeSettings object. If this is None, this function returns an empty dict. built_products_dir: Absolute path to the built products dir. srcroot: Absolute path to the source root. configuration: The build configuration name. additional_settings: An optional dict with more values to add to the result. """ if not xcode_settings: return {} # This function is considered a friend of XcodeSettings, so let it reach into # its implementation details. spec = xcode_settings.spec # These are filled in on a as-needed basis. env = { 'BUILT_PRODUCTS_DIR' : built_products_dir, 'CONFIGURATION' : configuration, 'PRODUCT_NAME' : xcode_settings.GetProductName(), # See /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX\ Product\ Types.xcspec for FULL_PRODUCT_NAME 'SRCROOT' : srcroot, 'SOURCE_ROOT': '${SRCROOT}', # This is not true for static libraries, but currently the env is only # written for bundles: 'TARGET_BUILD_DIR' : built_products_dir, 'TEMP_DIR' : '${TMPDIR}', } if xcode_settings.GetPerTargetSetting('SDKROOT'): env['SDKROOT'] = xcode_settings._SdkPath() else: env['SDKROOT'] = '' if spec['type'] in ( 'executable', 'static_library', 'shared_library', 'loadable_module'): env['EXECUTABLE_NAME'] = xcode_settings.GetExecutableName() env['EXECUTABLE_PATH'] = xcode_settings.GetExecutablePath() env['FULL_PRODUCT_NAME'] = xcode_settings.GetFullProductName() mach_o_type = xcode_settings.GetMachOType() if mach_o_type: env['MACH_O_TYPE'] = mach_o_type env['PRODUCT_TYPE'] = xcode_settings.GetProductType() if xcode_settings._IsBundle(): env['CONTENTS_FOLDER_PATH'] = \ xcode_settings.GetBundleContentsFolderPath() env['UNLOCALIZED_RESOURCES_FOLDER_PATH'] = \ xcode_settings.GetBundleResourceFolder() env['INFOPLIST_PATH'] = xcode_settings.GetBundlePlistPath() env['WRAPPER_NAME'] = xcode_settings.GetWrapperName() install_name = xcode_settings.GetInstallName() if install_name: env['LD_DYLIB_INSTALL_NAME'] = install_name install_name_base = xcode_settings.GetInstallNameBase() if install_name_base: env['DYLIB_INSTALL_NAME_BASE'] = install_name_base if not additional_settings: additional_settings = {} else: # Flatten lists to strings. for k in additional_settings: if not isinstance(additional_settings[k], str): additional_settings[k] = ' '.join(additional_settings[k]) additional_settings.update(env) for k in additional_settings: additional_settings[k] = _NormalizeEnvVarReferences(additional_settings[k]) return additional_settings def _NormalizeEnvVarReferences(str): """Takes a string containing variable references in the form ${FOO}, $(FOO), or $FOO, and returns a string with all variable references in the form ${FOO}. """ # $FOO -> ${FOO} str = re.sub(r'\$([a-zA-Z_][a-zA-Z0-9_]*)', r'${\1}', str) # $(FOO) -> ${FOO} matches = re.findall(r'(\$\(([a-zA-Z0-9\-_]+)\))', str) for match in matches: to_replace, variable = match assert '$(' not in match, '$($(FOO)) variables not supported: ' + match str = str.replace(to_replace, '${' + variable + '}') return str def ExpandEnvVars(string, expansions): """Expands ${VARIABLES}, $(VARIABLES), and $VARIABLES in string per the expansions list. If the variable expands to something that references another variable, this variable is expanded as well if it's in env -- until no variables present in env are left.""" for k, v in reversed(expansions): string = string.replace('${' + k + '}', v) string = string.replace('$(' + k + ')', v) string = string.replace('$' + k, v) return string def _TopologicallySortedEnvVarKeys(env): """Takes a dict |env| whose values are strings that can refer to other keys, for example env['foo'] = '$(bar) and $(baz)'. Returns a list L of all keys of env such that key2 is after key1 in L if env[key2] refers to env[key1]. Throws an Exception in case of dependency cycles. """ # Since environment variables can refer to other variables, the evaluation # order is important. Below is the logic to compute the dependency graph # and sort it. regex = re.compile(r'\$\{([a-zA-Z0-9\-_]+)\}') def GetEdges(node): # Use a definition of edges such that user_of_variable -> used_varible. # This happens to be easier in this case, since a variable's # definition contains all variables it references in a single string. # We can then reverse the result of the topological sort at the end. # Since: reverse(topsort(DAG)) = topsort(reverse_edges(DAG)) matches = set([v for v in regex.findall(env[node]) if v in env]) for dependee in matches: assert '${' not in dependee, 'Nested variables not supported: ' + dependee return matches try: # Topologically sort, and then reverse, because we used an edge definition # that's inverted from the expected result of this function (see comment # above). order = gyp.common.TopologicallySorted(env.keys(), GetEdges) order.reverse() return order except gyp.common.CycleError, e: raise GypError( 'Xcode environment variables are cyclically dependent: ' + str(e.nodes)) def GetSortedXcodeEnv(xcode_settings, built_products_dir, srcroot, configuration, additional_settings=None): env = _GetXcodeEnv(xcode_settings, built_products_dir, srcroot, configuration, additional_settings) return [(key, env[key]) for key in _TopologicallySortedEnvVarKeys(env)] def GetSpecPostbuildCommands(spec, quiet=False): """Returns the list of postbuilds explicitly defined on |spec|, in a form executable by a shell.""" postbuilds = [] for postbuild in spec.get('postbuilds', []): if not quiet: postbuilds.append('echo POSTBUILD\\(%s\\) %s' % ( spec['target_name'], postbuild['postbuild_name'])) postbuilds.append(gyp.common.EncodePOSIXShellList(postbuild['action'])) return postbuilds
mit
[ 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 2765, 859, 3509, 3992, 626, 1720, 370, 31102, 13592, 1506, 5953, 641, 2746, 402, 199, 1848, 1900, 10460, 12, 4066, 465, 1852, 436, 14822, 14, 199, 624, 199, 199, 646, 4902, 14, 2330, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 16701, 199, 646, 3873, 199, 646, 984, 199, 504, 4902, 14, 2330, 492, 18151, 199, 199, 533, 10602, 5268, 8, 785, 304, 523, 408, 33, 1021, 626, 1334, 26580, 314, 4902, 283, 8701, 63, 1751, 7, 909, 1041, 819, 327, 13244, 8097, 29667, 3444, 701, 485, 30897, 2042, 1252, 23752, 701, 1006, 10602, 5268, 12, 880, 6328, 523, 327, 737, 1021, 13, 1896, 367, 25978, 14, 523, 485, 9277, 63, 515, 63, 1637, 275, 1052, 819, 347, 636, 826, 721, 277, 12, 3158, 304, 272, 291, 14, 1650, 275, 3158, 339, 327, 3492, 13, 1375, 283, 8701, 63, 1751, 7, 787, 22319, 3224, 1901, 11585, 14119, 701, 4902, 14, 272, 327, 961, 4910, 291, 14, 8701, 63, 1751, 59, 888, 61, 3544, 3509, 1006, 2202, 272, 327, 367, 626, 1101, 1553, 314, 1126, 13, 1375, 2202, 465, 5521, 14, 13303, 626, 787, 272, 327, 314, 2011, 367, 1006, 11585, 787, 19796, 1126, 13, 1375, 2202, 14, 272, 291, 14, 8701, 63, 1751, 275, 1052, 272, 11585, 275, 3158, 459, 10057, 418, 272, 367, 20273, 12, 1101, 315, 11585, 14, 4611, 837, 489, 291, 14, 8701, 63, 1751, 59, 20377, 61, 275, 1101, 14, 362, 360, 8701, 63, 1751, 297, 5009, 339, 327, 961, 365, 1454, 2222, 13, 403, 22256, 5309, 314, 6451, 402, 2005, 3102, 14, 272, 291, 14, 20377, 275, 488, 339, 327, 8051, 701, 485, 17977, 7424, 370, 1336, 1275, 65, 436, 1275, 22305, 4811, 315, 8363, 14, 272, 291, 14, 4342, 63, 264, 275, 295, 14, 2014, 8, 82, 4289, 773, 7059, 15251, 31477, 8, 65, 92, 22305, 9, 9988, 819, 347, 485, 5268, 8, 277, 304, 272, 702, 291, 14, 20377, 272, 372, 291, 14, 8701, 63, 1751, 59, 277, 14, 20377, 61, 819, 347, 485, 774, 8, 277, 12, 511, 63, 498, 12, 9288, 63, 498, 12, 849, 304, 272, 372, 291, 423, 5268, 1252, 362, 8, 396, 63, 498, 12, 849, 9, 508, 9288, 63, 498, 819, 347, 485, 8310, 70, 8, 277, 12, 9877, 12, 511, 63, 498, 12, 1475, 63, 495, 12, 849, 29, 403, 304, 272, 340, 511, 63, 498, 315, 291, 423, 5268, 837, 489, 9877, 14, 740, 8, 908, 63, 495, 450, 620, 8, 277, 423, 5268, 3430, 396, 63, 498, 2459, 272, 916, 849, 26, 489, 9877, 14, 740, 8, 908, 63, 495, 450, 620, 8, 885, 430, 819, 347, 485, 22673, 1358, 13825, 8, 277, 12, 511, 63, 498, 304, 272, 340, 511, 63, 498, 315, 291, 423, 5268, 837, 489, 870, 283, 3849, 26, 20489, 6854, 440, 5966, 6366, 790, 2071, 83, 24217, 450, 511, 63, 498, 819, 347, 485, 1831, 12320, 8, 277, 304, 272, 372, 1109, 8, 277, 14, 1650, 14, 362, 360, 3088, 63, 6469, 297, 378, 430, 1137, 378, 819, 347, 2372, 16442, 3353, 8, 277, 304, 272, 408, 3407, 314, 10059, 1015, 402, 314, 1453, 1347, 14, 5972, 1686, 367, 272, 27206, 1041, 272, 702, 291, 423, 1831, 12320, 342, 272, 372, 291, 14, 1002, 2623, 4277, 7776, 360, 12683, 8406, 63, 4612, 297, 849, 534, 33, 358, 819, 347, 2372, 4590, 6382, 8, 277, 304, 272, 408, 3407, 314, 8844, 3329, 17048, 571, 12, 1275, 4857, 12, 1275, 2718, 12, 5423, 680, 221, 5972, 272, 1686, 367, 27206, 1041, 272, 702, 291, 423, 1831, 12320, 342, 272, 340, 291, 14, 1650, 459, 466, 418, 315, 661, 20722, 63, 578, 297, 283, 5555, 63, 4342, 735, 489, 849, 63, 5029, 63, 3435, 275, 469, 267, 283, 20722, 63, 578, 356, 283, 6469, 297, 267, 283, 5555, 63, 4342, 356, 283, 4857, 297, 489, 28439, 277, 14, 1650, 459, 466, 6538, 489, 4975, 63, 3435, 275, 291, 14, 1002, 2623, 4277, 7776, 8, 881, 283, 23824, 4227, 63, 15498, 297, 849, 29, 885, 63, 5029, 63, 3435, 9, 489, 372, 7815, 435, 291, 14, 1650, 14, 362, 360, 2558, 63, 3435, 297, 4975, 63, 3435, 9, 272, 916, 291, 14, 1650, 459, 466, 418, 508, 283, 5904, 356, 489, 372, 1987, 571, 7, 272, 587, 26, 489, 702, 756, 12, 298, 16932, 1133, 5715, 3329, 367, 1543, 83, 297, 1347, 1543, 83, 4065, 450, 334, 881, 291, 14, 1650, 459, 466, 995, 291, 14, 1650, 459, 1375, 63, 354, 1105, 819, 347, 2372, 5884, 985, 8, 277, 304, 272, 408, 3407, 3611, 13461, 63, 2339, 1041, 272, 372, 291, 14, 1650, 14, 362, 360, 2558, 63, 354, 297, 291, 14, 1650, 459, 1375, 63, 354, 1105, 819, 347, 2372, 9042, 5884, 985, 8, 277, 304, 272, 408, 3407, 18530, 63, 14853, 63, 2339, 1041, 272, 340, 291, 423, 1831, 12320, 837, 489, 372, 291, 14, 1002, 4590, 985, 342, 272, 587, 26, 489, 372, 291, 423, 1002, 18736, 10636, 6636, 2042, 342, 819, 347, 2372, 4590, 985, 8, 277, 304, 272, 408, 3407, 314, 2082, 536, 402, 314, 8844, 11159, 701, 642, 1347, 14, 272, 5972, 1686, 367, 27206, 1041, 272, 702, 291, 423, 1831, 12320, 342, 272, 372, 291, 14, 1002, 5884, 985, 342, 435, 291, 14, 1002, 4590, 6382, 342, 819, 347, 2372, 12320, 11383, 7850, 2042, 8, 277, 304, 272, 408, 3407, 314, 12313, 931, 370, 314, 8844, 1159, 4072, 4922, 14, 662, 14, 71, 14, 272, 12051, 14, 571, 15, 11383, 503, 8024, 14, 6469, 15, 21167, 15, 33, 14, 5972, 1686, 367, 27206, 1041, 272, 702, 291, 423, 1831, 12320, 342, 272, 340, 291, 14, 1650, 459, 466, 418, 508, 283, 5555, 63, 4342, 356, 489, 372, 747, 14, 515, 14, 904, 8, 881, 291, 14, 1002, 4590, 985, 1062, 283, 21167, 297, 291, 14, 1002, 16442, 3353, 1012, 272, 587, 26, 489, 327, 32519, 63, 3112, 1172, 282, 283, 11383, 7, 4922, 2839, 31172 ]
[ 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 2765, 859, 3509, 3992, 626, 1720, 370, 31102, 13592, 1506, 5953, 641, 2746, 402, 199, 1848, 1900, 10460, 12, 4066, 465, 1852, 436, 14822, 14, 199, 624, 199, 199, 646, 4902, 14, 2330, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 16701, 199, 646, 3873, 199, 646, 984, 199, 504, 4902, 14, 2330, 492, 18151, 199, 199, 533, 10602, 5268, 8, 785, 304, 523, 408, 33, 1021, 626, 1334, 26580, 314, 4902, 283, 8701, 63, 1751, 7, 909, 1041, 819, 327, 13244, 8097, 29667, 3444, 701, 485, 30897, 2042, 1252, 23752, 701, 1006, 10602, 5268, 12, 880, 6328, 523, 327, 737, 1021, 13, 1896, 367, 25978, 14, 523, 485, 9277, 63, 515, 63, 1637, 275, 1052, 819, 347, 636, 826, 721, 277, 12, 3158, 304, 272, 291, 14, 1650, 275, 3158, 339, 327, 3492, 13, 1375, 283, 8701, 63, 1751, 7, 787, 22319, 3224, 1901, 11585, 14119, 701, 4902, 14, 272, 327, 961, 4910, 291, 14, 8701, 63, 1751, 59, 888, 61, 3544, 3509, 1006, 2202, 272, 327, 367, 626, 1101, 1553, 314, 1126, 13, 1375, 2202, 465, 5521, 14, 13303, 626, 787, 272, 327, 314, 2011, 367, 1006, 11585, 787, 19796, 1126, 13, 1375, 2202, 14, 272, 291, 14, 8701, 63, 1751, 275, 1052, 272, 11585, 275, 3158, 459, 10057, 418, 272, 367, 20273, 12, 1101, 315, 11585, 14, 4611, 837, 489, 291, 14, 8701, 63, 1751, 59, 20377, 61, 275, 1101, 14, 362, 360, 8701, 63, 1751, 297, 5009, 339, 327, 961, 365, 1454, 2222, 13, 403, 22256, 5309, 314, 6451, 402, 2005, 3102, 14, 272, 291, 14, 20377, 275, 488, 339, 327, 8051, 701, 485, 17977, 7424, 370, 1336, 1275, 65, 436, 1275, 22305, 4811, 315, 8363, 14, 272, 291, 14, 4342, 63, 264, 275, 295, 14, 2014, 8, 82, 4289, 773, 7059, 15251, 31477, 8, 65, 92, 22305, 9, 9988, 819, 347, 485, 5268, 8, 277, 304, 272, 702, 291, 14, 20377, 272, 372, 291, 14, 8701, 63, 1751, 59, 277, 14, 20377, 61, 819, 347, 485, 774, 8, 277, 12, 511, 63, 498, 12, 9288, 63, 498, 12, 849, 304, 272, 372, 291, 423, 5268, 1252, 362, 8, 396, 63, 498, 12, 849, 9, 508, 9288, 63, 498, 819, 347, 485, 8310, 70, 8, 277, 12, 9877, 12, 511, 63, 498, 12, 1475, 63, 495, 12, 849, 29, 403, 304, 272, 340, 511, 63, 498, 315, 291, 423, 5268, 837, 489, 9877, 14, 740, 8, 908, 63, 495, 450, 620, 8, 277, 423, 5268, 3430, 396, 63, 498, 2459, 272, 916, 849, 26, 489, 9877, 14, 740, 8, 908, 63, 495, 450, 620, 8, 885, 430, 819, 347, 485, 22673, 1358, 13825, 8, 277, 12, 511, 63, 498, 304, 272, 340, 511, 63, 498, 315, 291, 423, 5268, 837, 489, 870, 283, 3849, 26, 20489, 6854, 440, 5966, 6366, 790, 2071, 83, 24217, 450, 511, 63, 498, 819, 347, 485, 1831, 12320, 8, 277, 304, 272, 372, 1109, 8, 277, 14, 1650, 14, 362, 360, 3088, 63, 6469, 297, 378, 430, 1137, 378, 819, 347, 2372, 16442, 3353, 8, 277, 304, 272, 408, 3407, 314, 10059, 1015, 402, 314, 1453, 1347, 14, 5972, 1686, 367, 272, 27206, 1041, 272, 702, 291, 423, 1831, 12320, 342, 272, 372, 291, 14, 1002, 2623, 4277, 7776, 360, 12683, 8406, 63, 4612, 297, 849, 534, 33, 358, 819, 347, 2372, 4590, 6382, 8, 277, 304, 272, 408, 3407, 314, 8844, 3329, 17048, 571, 12, 1275, 4857, 12, 1275, 2718, 12, 5423, 680, 221, 5972, 272, 1686, 367, 27206, 1041, 272, 702, 291, 423, 1831, 12320, 342, 272, 340, 291, 14, 1650, 459, 466, 418, 315, 661, 20722, 63, 578, 297, 283, 5555, 63, 4342, 735, 489, 849, 63, 5029, 63, 3435, 275, 469, 267, 283, 20722, 63, 578, 356, 283, 6469, 297, 267, 283, 5555, 63, 4342, 356, 283, 4857, 297, 489, 28439, 277, 14, 1650, 459, 466, 6538, 489, 4975, 63, 3435, 275, 291, 14, 1002, 2623, 4277, 7776, 8, 881, 283, 23824, 4227, 63, 15498, 297, 849, 29, 885, 63, 5029, 63, 3435, 9, 489, 372, 7815, 435, 291, 14, 1650, 14, 362, 360, 2558, 63, 3435, 297, 4975, 63, 3435, 9, 272, 916, 291, 14, 1650, 459, 466, 418, 508, 283, 5904, 356, 489, 372, 1987, 571, 7, 272, 587, 26, 489, 702, 756, 12, 298, 16932, 1133, 5715, 3329, 367, 1543, 83, 297, 1347, 1543, 83, 4065, 450, 334, 881, 291, 14, 1650, 459, 466, 995, 291, 14, 1650, 459, 1375, 63, 354, 1105, 819, 347, 2372, 5884, 985, 8, 277, 304, 272, 408, 3407, 3611, 13461, 63, 2339, 1041, 272, 372, 291, 14, 1650, 14, 362, 360, 2558, 63, 354, 297, 291, 14, 1650, 459, 1375, 63, 354, 1105, 819, 347, 2372, 9042, 5884, 985, 8, 277, 304, 272, 408, 3407, 18530, 63, 14853, 63, 2339, 1041, 272, 340, 291, 423, 1831, 12320, 837, 489, 372, 291, 14, 1002, 4590, 985, 342, 272, 587, 26, 489, 372, 291, 423, 1002, 18736, 10636, 6636, 2042, 342, 819, 347, 2372, 4590, 985, 8, 277, 304, 272, 408, 3407, 314, 2082, 536, 402, 314, 8844, 11159, 701, 642, 1347, 14, 272, 5972, 1686, 367, 27206, 1041, 272, 702, 291, 423, 1831, 12320, 342, 272, 372, 291, 14, 1002, 5884, 985, 342, 435, 291, 14, 1002, 4590, 6382, 342, 819, 347, 2372, 12320, 11383, 7850, 2042, 8, 277, 304, 272, 408, 3407, 314, 12313, 931, 370, 314, 8844, 1159, 4072, 4922, 14, 662, 14, 71, 14, 272, 12051, 14, 571, 15, 11383, 503, 8024, 14, 6469, 15, 21167, 15, 33, 14, 5972, 1686, 367, 27206, 1041, 272, 702, 291, 423, 1831, 12320, 342, 272, 340, 291, 14, 1650, 459, 466, 418, 508, 283, 5555, 63, 4342, 356, 489, 372, 747, 14, 515, 14, 904, 8, 881, 291, 14, 1002, 4590, 985, 1062, 283, 21167, 297, 291, 14, 1002, 16442, 3353, 1012, 272, 587, 26, 489, 327, 32519, 63, 3112, 1172, 282, 283, 11383, 7, 4922, 2839, 31172, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
BayanGroup/ansible
lib/ansible/utils/module_docs_fragments/mysql.py
18
2735
# -*- coding: utf-8 -*- # Copyright (c) 2015 Jonathan Mainguy <jon@soh.re> # # 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/>. class ModuleDocFragment(object): # Standard mysql documentation fragment DOCUMENTATION = ''' options: login_user: description: - The username used to authenticate with required: false default: null login_password: description: - The password used to authenticate with required: false default: null login_host: description: - Host running the database required: false default: localhost login_port: description: - Port of the MySQL server. Requires login_host be defined as other then localhost if login_port is used required: false default: 3306 login_unix_socket: description: - The path to a Unix domain socket for local connections required: false default: null config_file: description: - Specify a config file from which user and password are to be read required: false default: '~/.my.cnf' version_added: "2.0" ssl_ca: required: false default: null version_added: "2.0" description: - The path to a Certificate Authority (CA) certificate. This option, if used, must specify the same certificate as used by the server. ssl_cert: required: false default: null version_added: "2.0" description: - The path to a client public key certificate. ssl_key: required: false default: null version_added: "2.0" description: - The path to the client private key. requirements: - MySQLdb notes: - Requires the MySQLdb Python package on the remote host. For Ubuntu, this is as easy as apt-get install python-mysqldb. (See M(apt).) For CentOS/Fedora, this is as easy as yum install MySQL-python. (See M(yum).) - Both C(login_password) and C(login_user) are required when you are passing credentials. If none are present, the module will attempt to read the credentials from C(~/.my.cnf), and finally fall back to using the MySQL default login of 'root' with no password. '''
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 6900, 1603, 265, 1619, 290, 16593, 14659, 89, 665, 74, 265, 32, 1152, 72, 14, 264, 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, 421, 199, 533, 5673, 3768, 11080, 8, 785, 304, 339, 327, 9739, 12896, 3794, 7956, 272, 29970, 2594, 275, 1449, 199, 1419, 26, 523, 4676, 63, 751, 26, 272, 1369, 26, 489, 446, 710, 3434, 1202, 370, 12895, 543, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 4676, 63, 2060, 26, 272, 1369, 26, 489, 446, 710, 2505, 1202, 370, 12895, 543, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 4676, 63, 1102, 26, 272, 1369, 26, 489, 446, 10891, 3879, 314, 3050, 272, 1415, 26, 3055, 272, 849, 26, 11667, 523, 4676, 63, 719, 26, 272, 1369, 26, 489, 446, 10977, 402, 314, 11200, 1654, 14, 15127, 4676, 63, 1102, 506, 3247, 465, 1163, 2066, 11667, 340, 4676, 63, 719, 365, 1202, 272, 1415, 26, 3055, 272, 849, 26, 650, 11363, 523, 4676, 63, 11864, 63, 3450, 26, 272, 1369, 26, 489, 446, 710, 931, 370, 282, 13074, 2881, 2838, 367, 2257, 6947, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 1101, 63, 493, 26, 272, 1369, 26, 489, 446, 13327, 282, 1101, 570, 687, 1314, 922, 436, 2505, 787, 370, 506, 1586, 272, 1415, 26, 3055, 272, 849, 26, 17352, 8083, 1662, 14, 23600, 7, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 523, 6149, 63, 696, 26, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 272, 1369, 26, 489, 446, 710, 931, 370, 282, 12904, 3590, 3822, 334, 3263, 9, 5897, 14, 961, 945, 12, 340, 1202, 12, 1471, 4165, 314, 2011, 5897, 465, 1202, 701, 314, 1654, 14, 523, 6149, 63, 4736, 26, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 272, 1369, 26, 489, 446, 710, 931, 370, 282, 1890, 4575, 790, 5897, 14, 523, 6149, 63, 498, 26, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 272, 1369, 26, 489, 446, 710, 931, 370, 314, 1890, 5726, 790, 14, 199, 7538, 26, 2043, 446, 25709, 199, 5983, 26, 2043, 446, 15127, 314, 25709, 2018, 2559, 641, 314, 3982, 1591, 14, 2104, 31631, 12, 642, 1362, 365, 465, 8837, 465, 20932, 13, 362, 3907, 2366, 13, 8644, 697, 14, 334, 9295, 603, 8, 6182, 680, 9, 2104, 30610, 3100, 15, 38, 379, 11131, 12, 642, 1362, 365, 465, 8837, 465, 24717, 3907, 11200, 13, 1548, 14, 334, 9295, 603, 8, 22108, 680, 9, 2043, 446, 17650, 445, 8, 2886, 63, 2060, 9, 436, 445, 8, 2886, 63, 751, 9, 787, 1415, 1380, 1265, 787, 1362, 9476, 6235, 14, 982, 7179, 787, 3451, 12, 314, 859, 911, 7427, 370, 1586, 1362, 314, 6235, 687, 445, 26428, 8083, 1662, 14, 23600, 395, 436, 3753, 11264, 1771, 370, 1808, 314, 11200, 1362, 849, 4676, 402, 283, 1231, 7, 543, 949, 2505, 14, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 6900, 1603, 265, 1619, 290, 16593, 14659, 89, 665, 74, 265, 32, 1152, 72, 14, 264, 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, 421, 199, 533, 5673, 3768, 11080, 8, 785, 304, 339, 327, 9739, 12896, 3794, 7956, 272, 29970, 2594, 275, 1449, 199, 1419, 26, 523, 4676, 63, 751, 26, 272, 1369, 26, 489, 446, 710, 3434, 1202, 370, 12895, 543, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 4676, 63, 2060, 26, 272, 1369, 26, 489, 446, 710, 2505, 1202, 370, 12895, 543, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 4676, 63, 1102, 26, 272, 1369, 26, 489, 446, 10891, 3879, 314, 3050, 272, 1415, 26, 3055, 272, 849, 26, 11667, 523, 4676, 63, 719, 26, 272, 1369, 26, 489, 446, 10977, 402, 314, 11200, 1654, 14, 15127, 4676, 63, 1102, 506, 3247, 465, 1163, 2066, 11667, 340, 4676, 63, 719, 365, 1202, 272, 1415, 26, 3055, 272, 849, 26, 650, 11363, 523, 4676, 63, 11864, 63, 3450, 26, 272, 1369, 26, 489, 446, 710, 931, 370, 282, 13074, 2881, 2838, 367, 2257, 6947, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 1101, 63, 493, 26, 272, 1369, 26, 489, 446, 13327, 282, 1101, 570, 687, 1314, 922, 436, 2505, 787, 370, 506, 1586, 272, 1415, 26, 3055, 272, 849, 26, 17352, 8083, 1662, 14, 23600, 7, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 523, 6149, 63, 696, 26, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 272, 1369, 26, 489, 446, 710, 931, 370, 282, 12904, 3590, 3822, 334, 3263, 9, 5897, 14, 961, 945, 12, 340, 1202, 12, 1471, 4165, 314, 2011, 5897, 465, 1202, 701, 314, 1654, 14, 523, 6149, 63, 4736, 26, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 272, 1369, 26, 489, 446, 710, 931, 370, 282, 1890, 4575, 790, 5897, 14, 523, 6149, 63, 498, 26, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 272, 1369, 26, 489, 446, 710, 931, 370, 314, 1890, 5726, 790, 14, 199, 7538, 26, 2043, 446, 25709, 199, 5983, 26, 2043, 446, 15127, 314, 25709, 2018, 2559, 641, 314, 3982, 1591, 14, 2104, 31631, 12, 642, 1362, 365, 465, 8837, 465, 20932, 13, 362, 3907, 2366, 13, 8644, 697, 14, 334, 9295, 603, 8, 6182, 680, 9, 2104, 30610, 3100, 15, 38, 379, 11131, 12, 642, 1362, 365, 465, 8837, 465, 24717, 3907, 11200, 13, 1548, 14, 334, 9295, 603, 8, 22108, 680, 9, 2043, 446, 17650, 445, 8, 2886, 63, 2060, 9, 436, 445, 8, 2886, 63, 751, 9, 787, 1415, 1380, 1265, 787, 1362, 9476, 6235, 14, 982, 7179, 787, 3451, 12, 314, 859, 911, 7427, 370, 1586, 1362, 314, 6235, 687, 445, 26428, 8083, 1662, 14, 23600, 395, 436, 3753, 11264, 1771, 370, 1808, 314, 11200, 1362, 849, 4676, 402, 283, 1231, 7, 543, 949, 2505, 14, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mmilaprat/policycompass-services
apps/metricsmanager/api.py
2
5677
import json from django.core.exceptions import ValidationError from django import shortcuts from rest_framework.views import APIView from rest_framework.reverse import reverse from rest_framework.response import Response from rest_framework.permissions import IsAuthenticatedOrReadOnly from rest_framework import generics, status from policycompass_services import permissions from .serializers import * from .normalization import get_normalizers from . import formula, services class MetricsBase(APIView): def get(self, request, format=None): """ :type request: Request :param request: :return: """ result = { "Metrics": reverse('metrics-create-list', request=request), "Normalizer": reverse('normalizers-list', request=request), "Calculator": reverse('calculate-dataset', request=request) } return Response(result) class FormulasValidate(APIView): def get(self, request): if "formula" not in request.QUERY_PARAMS: return Response({"formula": "Can not be empty"}, status=status.HTTP_400_BAD_REQUEST) if "variables" not in request.QUERY_PARAMS: return Response({"variables": "Can not be empty"}, status=status.HTTP_400_BAD_REQUEST) formula_str = request.QUERY_PARAMS["formula"] try: variables = json.loads(request.QUERY_PARAMS["variables"]) except ValueError as e: return Response( {"variables": "Unable to parse json: {}".format(e)}, status=status.HTTP_400_BAD_REQUEST) try: variables = formula.validate_variables(variables) formula.validate_formula(formula_str, variables) except ValidationError as e: return Response(e.error_dict, status=status.HTTP_400_BAD_REQUEST) return Response(status=status.HTTP_204_NO_CONTENT) class NormalizersList(APIView): def get(self, request): normalizers = get_normalizers().values() serializer = NormalizerSerializer(normalizers, many=True) return Response(serializer.data) class MetricsCreate(generics.ListCreateAPIView): model = Metric serializer_class = MetricSerializer paginate_by = 10 paginate_by_param = 'page_size' permission_classes = IsAuthenticatedOrReadOnly, def pre_save(self, obj): obj.creator_path = self.request.user.resource_path class MetricsDetail(generics.RetrieveUpdateDestroyAPIView): model = Metric serializer_class = MetricSerializer permission_classes = permissions.IsCreatorOrReadOnly, class DatasetCalculateView(APIView): permission_classes = IsAuthenticatedOrReadOnly, def post(self, request): """ Compute a new dataset from a given formula and mappings. Example data: { "title": "Some test", "formula": "0.5 * norm(__1__, 0, 100) + 0.5 * norm(__2__, 0, 200)", "datasets": [ { "variable": "__1__", "dataset": 1, }, { "variable": "__1__", "dataset": 1, } ], "indicator_id": 0, "unit_id": 0, } """ # check resquest data serializer = CalculateSerializer(data=request.DATA, files=request.FILES) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) data = serializer.object try: formula.validate_formula(data["formula"], data["datasets"]) data = services.validate_operationalize(data) except ValidationError as e: return Response(e.error_dict, status=status.HTTP_400_BAD_REQUEST) creator_path = self.request.user.resource_path dataset_id = services.compute_dataset( creator_path=creator_path, **data) return Response({ "dataset": { "id": dataset_id } }) class MetriscOperationalize(APIView): permission_classes = IsAuthenticatedOrReadOnly, def post(self, request, metrics_id: int): """ Compute a new dataset from a given metric and mappings for variables. Example data: { "title" : "Some test", "datasets": [ { "variable": "__1__", "dataset": 1, } ], "unit_id": 0, } """ # check if metric exists metric = shortcuts.get_object_or_404(Metric, pk=metrics_id) # check resquest data serializer = OperationalizeSerializer(data=request.DATA, files=request.FILES) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) data = serializer.object try: data = services.validate_operationalize(data) except ValidationError as e: return Response(e.error_dict, status=status.HTTP_400_BAD_REQUEST) creator_path = self.request.user.resource_path dataset_id = services.compute_dataset( creator_path=creator_path, formula=metric.formula, indicator_id=metric.indicator_id, metric_id=metric.pk, **data) return Response({ "dataset": { "id": dataset_id } })
agpl-3.0
[ 646, 2022, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 492, 3974, 12946, 199, 504, 4618, 63, 4857, 14, 4196, 492, 3261, 2768, 199, 504, 4618, 63, 4857, 14, 4471, 492, 3837, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 504, 4618, 63, 4857, 14, 6060, 492, 6596, 30871, 2844, 22210, 199, 504, 4618, 63, 4857, 492, 1519, 2932, 12, 2004, 199, 199, 504, 4592, 863, 405, 63, 5950, 492, 3443, 199, 199, 504, 1275, 12844, 492, 627, 199, 504, 1275, 22384, 492, 664, 63, 3302, 6315, 199, 504, 1275, 492, 15723, 12, 8500, 421, 199, 533, 10072, 11818, 1563, 8, 25778, 304, 272, 347, 664, 8, 277, 12, 1056, 12, 1475, 29, 403, 304, 267, 408, 267, 520, 466, 1056, 26, 4784, 267, 520, 635, 1056, 26, 267, 520, 1107, 26, 267, 408, 267, 754, 275, 469, 288, 298, 17213, 582, 3837, 360, 6759, 13, 981, 13, 513, 297, 1056, 29, 1069, 395, 288, 298, 6241, 1793, 582, 3837, 360, 3302, 6315, 13, 513, 297, 1056, 29, 1069, 395, 288, 298, 20000, 582, 3837, 360, 12063, 13, 5214, 297, 1056, 29, 1069, 9, 267, 789, 398, 372, 7232, 8, 1099, 9, 421, 199, 533, 8204, 32646, 12584, 8, 25778, 304, 272, 347, 664, 8, 277, 12, 1056, 304, 267, 340, 298, 16798, 2, 440, 315, 1056, 14, 11938, 63, 17978, 26, 288, 372, 7232, 6333, 16798, 582, 298, 6049, 440, 506, 2701, 6018, 1169, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 340, 298, 3669, 2, 440, 315, 1056, 14, 11938, 63, 17978, 26, 288, 372, 7232, 6333, 3669, 582, 298, 6049, 440, 506, 2701, 6018, 1169, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 15723, 63, 495, 275, 1056, 14, 11938, 63, 17978, 905, 16798, 937, 267, 862, 26, 288, 2860, 275, 2022, 14, 3640, 8, 1069, 14, 11938, 63, 17978, 905, 3669, 3135, 267, 871, 1722, 465, 325, 26, 288, 372, 7232, 8, 355, 2420, 3669, 582, 298, 6005, 370, 2198, 2022, 26, 8352, 908, 8, 69, 16658, 355, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 862, 26, 288, 2860, 275, 15723, 14, 3502, 63, 3669, 8, 3669, 9, 288, 15723, 14, 3502, 63, 16798, 8, 16798, 63, 495, 12, 2860, 9, 267, 871, 8505, 465, 325, 26, 288, 372, 7232, 8, 69, 14, 705, 63, 807, 12, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 372, 7232, 8, 1205, 29, 1205, 14, 2856, 63, 6686, 63, 2826, 63, 9663, 9, 421, 199, 533, 11514, 6315, 1296, 8, 25778, 304, 272, 347, 664, 8, 277, 12, 1056, 304, 267, 3293, 6315, 275, 664, 63, 3302, 6315, 1252, 1459, 342, 267, 9146, 275, 11514, 1793, 7299, 8, 3302, 6315, 12, 5002, 29, 549, 9, 267, 372, 7232, 8, 8349, 14, 576, 9, 421, 199, 533, 10072, 11818, 2499, 8, 2038, 2932, 14, 1296, 2499, 25778, 304, 272, 1402, 275, 22465, 272, 9146, 63, 533, 275, 22465, 7299, 272, 9881, 23043, 63, 991, 275, 1616, 272, 9881, 23043, 63, 991, 63, 635, 275, 283, 1606, 63, 890, 7, 272, 4983, 63, 2888, 275, 6596, 30871, 2844, 22210, 12, 339, 347, 876, 63, 2117, 8, 277, 12, 1559, 304, 267, 1559, 14, 9986, 63, 515, 275, 291, 14, 1069, 14, 751, 14, 1927, 63, 515, 421, 199, 533, 10072, 11818, 8064, 8, 2038, 2932, 14, 15310, 4152, 14704, 25778, 304, 272, 1402, 275, 22465, 272, 9146, 63, 533, 275, 22465, 7299, 272, 4983, 63, 2888, 275, 3443, 14, 1831, 17523, 2844, 22210, 12, 421, 199, 533, 20284, 14860, 2768, 8, 25778, 304, 272, 4983, 63, 2888, 275, 6596, 30871, 2844, 22210, 12, 339, 347, 2963, 8, 277, 12, 1056, 304, 267, 408, 267, 8354, 282, 892, 4789, 687, 282, 1627, 15723, 436, 13546, 14, 398, 5679, 666, 26, 398, 469, 881, 298, 1213, 582, 298, 7700, 511, 401, 881, 298, 16798, 582, 298, 16, 14, 21, 627, 6316, 3460, 17, 3108, 378, 12, 2948, 9, 435, 378, 14, 21, 627, 6316, 3460, 18, 3108, 378, 12, 1926, 4186, 881, 298, 12281, 582, 359, 288, 469, 1598, 298, 1975, 582, 4396, 17, 13915, 1598, 298, 5214, 582, 413, 12, 288, 1660, 288, 469, 1598, 298, 1975, 582, 4396, 17, 13915, 1598, 298, 5214, 582, 413, 12, 288, 789, 881, 2156, 881, 298, 15785, 63, 344, 582, 378, 12, 881, 298, 3248, 63, 344, 582, 378, 12, 267, 789, 267, 408, 398, 327, 1104, 522, 613, 666, 267, 9146, 275, 12707, 7299, 8, 576, 29, 1069, 14, 3998, 12, 1460, 1584, 29, 1069, 14, 9472, 9, 398, 340, 440, 9146, 14, 374, 63, 1078, 837, 288, 372, 7232, 8, 8349, 14, 2550, 12, 1169, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 267, 666, 275, 9146, 14, 785, 398, 862, 26, 288, 15723, 14, 3502, 63, 16798, 8, 576, 905, 16798, 2255, 666, 905, 12281, 3135, 288, 666, 275, 8500, 14, 3502, 63, 5735, 279, 794, 8, 576, 9, 267, 871, 8505, 465, 325, 26, 288, 372, 7232, 8, 69, 14, 705, 63, 807, 12, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 14875, 63, 515, 275, 291, 14, 1069, 14, 751, 14, 1927, 63, 515, 267, 4789, 63, 344, 275, 8500, 14, 3357, 63, 5214, 8, 288, 14875, 63, 515, 29, 9986, 63, 515, 12, 288, 1011, 576, 9, 398, 372, 7232, 2561, 288, 298, 5214, 582, 469, 355, 298, 344, 582, 4789, 63, 344, 288, 789, 267, 3828, 421, 199, 533, 10072, 322, 551, 31998, 794, 8, 25778, 304, 272, 4983, 63, 2888, 275, 6596, 30871, 2844, 22210, 12, 339, 347, 2963, 8, 277, 12, 1056, 12, 7186, 63, 344, 26, 1109, 304, 267, 408, 267, 8354, 282, 892, 4789, 687, 282, 1627, 6370, 436, 13546, 367, 2860, 14, 398, 5679, 666, 26, 398, 469, 881, 298, 1213, 2, 520, 298, 7700, 511, 401, 881, 298, 12281, 582, 359, 288, 469, 1598, 298, 1975, 582, 4396, 17, 13915, 1598, 298, 5214, 582, 413, 12, 288, 789, 881, 2156, 881, 298, 3248, 63, 344, 582, 378, 12, 267 ]
[ 2022, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 492, 3974, 12946, 199, 504, 4618, 63, 4857, 14, 4196, 492, 3261, 2768, 199, 504, 4618, 63, 4857, 14, 4471, 492, 3837, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 504, 4618, 63, 4857, 14, 6060, 492, 6596, 30871, 2844, 22210, 199, 504, 4618, 63, 4857, 492, 1519, 2932, 12, 2004, 199, 199, 504, 4592, 863, 405, 63, 5950, 492, 3443, 199, 199, 504, 1275, 12844, 492, 627, 199, 504, 1275, 22384, 492, 664, 63, 3302, 6315, 199, 504, 1275, 492, 15723, 12, 8500, 421, 199, 533, 10072, 11818, 1563, 8, 25778, 304, 272, 347, 664, 8, 277, 12, 1056, 12, 1475, 29, 403, 304, 267, 408, 267, 520, 466, 1056, 26, 4784, 267, 520, 635, 1056, 26, 267, 520, 1107, 26, 267, 408, 267, 754, 275, 469, 288, 298, 17213, 582, 3837, 360, 6759, 13, 981, 13, 513, 297, 1056, 29, 1069, 395, 288, 298, 6241, 1793, 582, 3837, 360, 3302, 6315, 13, 513, 297, 1056, 29, 1069, 395, 288, 298, 20000, 582, 3837, 360, 12063, 13, 5214, 297, 1056, 29, 1069, 9, 267, 789, 398, 372, 7232, 8, 1099, 9, 421, 199, 533, 8204, 32646, 12584, 8, 25778, 304, 272, 347, 664, 8, 277, 12, 1056, 304, 267, 340, 298, 16798, 2, 440, 315, 1056, 14, 11938, 63, 17978, 26, 288, 372, 7232, 6333, 16798, 582, 298, 6049, 440, 506, 2701, 6018, 1169, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 340, 298, 3669, 2, 440, 315, 1056, 14, 11938, 63, 17978, 26, 288, 372, 7232, 6333, 3669, 582, 298, 6049, 440, 506, 2701, 6018, 1169, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 15723, 63, 495, 275, 1056, 14, 11938, 63, 17978, 905, 16798, 937, 267, 862, 26, 288, 2860, 275, 2022, 14, 3640, 8, 1069, 14, 11938, 63, 17978, 905, 3669, 3135, 267, 871, 1722, 465, 325, 26, 288, 372, 7232, 8, 355, 2420, 3669, 582, 298, 6005, 370, 2198, 2022, 26, 8352, 908, 8, 69, 16658, 355, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 862, 26, 288, 2860, 275, 15723, 14, 3502, 63, 3669, 8, 3669, 9, 288, 15723, 14, 3502, 63, 16798, 8, 16798, 63, 495, 12, 2860, 9, 267, 871, 8505, 465, 325, 26, 288, 372, 7232, 8, 69, 14, 705, 63, 807, 12, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 372, 7232, 8, 1205, 29, 1205, 14, 2856, 63, 6686, 63, 2826, 63, 9663, 9, 421, 199, 533, 11514, 6315, 1296, 8, 25778, 304, 272, 347, 664, 8, 277, 12, 1056, 304, 267, 3293, 6315, 275, 664, 63, 3302, 6315, 1252, 1459, 342, 267, 9146, 275, 11514, 1793, 7299, 8, 3302, 6315, 12, 5002, 29, 549, 9, 267, 372, 7232, 8, 8349, 14, 576, 9, 421, 199, 533, 10072, 11818, 2499, 8, 2038, 2932, 14, 1296, 2499, 25778, 304, 272, 1402, 275, 22465, 272, 9146, 63, 533, 275, 22465, 7299, 272, 9881, 23043, 63, 991, 275, 1616, 272, 9881, 23043, 63, 991, 63, 635, 275, 283, 1606, 63, 890, 7, 272, 4983, 63, 2888, 275, 6596, 30871, 2844, 22210, 12, 339, 347, 876, 63, 2117, 8, 277, 12, 1559, 304, 267, 1559, 14, 9986, 63, 515, 275, 291, 14, 1069, 14, 751, 14, 1927, 63, 515, 421, 199, 533, 10072, 11818, 8064, 8, 2038, 2932, 14, 15310, 4152, 14704, 25778, 304, 272, 1402, 275, 22465, 272, 9146, 63, 533, 275, 22465, 7299, 272, 4983, 63, 2888, 275, 3443, 14, 1831, 17523, 2844, 22210, 12, 421, 199, 533, 20284, 14860, 2768, 8, 25778, 304, 272, 4983, 63, 2888, 275, 6596, 30871, 2844, 22210, 12, 339, 347, 2963, 8, 277, 12, 1056, 304, 267, 408, 267, 8354, 282, 892, 4789, 687, 282, 1627, 15723, 436, 13546, 14, 398, 5679, 666, 26, 398, 469, 881, 298, 1213, 582, 298, 7700, 511, 401, 881, 298, 16798, 582, 298, 16, 14, 21, 627, 6316, 3460, 17, 3108, 378, 12, 2948, 9, 435, 378, 14, 21, 627, 6316, 3460, 18, 3108, 378, 12, 1926, 4186, 881, 298, 12281, 582, 359, 288, 469, 1598, 298, 1975, 582, 4396, 17, 13915, 1598, 298, 5214, 582, 413, 12, 288, 1660, 288, 469, 1598, 298, 1975, 582, 4396, 17, 13915, 1598, 298, 5214, 582, 413, 12, 288, 789, 881, 2156, 881, 298, 15785, 63, 344, 582, 378, 12, 881, 298, 3248, 63, 344, 582, 378, 12, 267, 789, 267, 408, 398, 327, 1104, 522, 613, 666, 267, 9146, 275, 12707, 7299, 8, 576, 29, 1069, 14, 3998, 12, 1460, 1584, 29, 1069, 14, 9472, 9, 398, 340, 440, 9146, 14, 374, 63, 1078, 837, 288, 372, 7232, 8, 8349, 14, 2550, 12, 1169, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 267, 666, 275, 9146, 14, 785, 398, 862, 26, 288, 15723, 14, 3502, 63, 16798, 8, 576, 905, 16798, 2255, 666, 905, 12281, 3135, 288, 666, 275, 8500, 14, 3502, 63, 5735, 279, 794, 8, 576, 9, 267, 871, 8505, 465, 325, 26, 288, 372, 7232, 8, 69, 14, 705, 63, 807, 12, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 14875, 63, 515, 275, 291, 14, 1069, 14, 751, 14, 1927, 63, 515, 267, 4789, 63, 344, 275, 8500, 14, 3357, 63, 5214, 8, 288, 14875, 63, 515, 29, 9986, 63, 515, 12, 288, 1011, 576, 9, 398, 372, 7232, 2561, 288, 298, 5214, 582, 469, 355, 298, 344, 582, 4789, 63, 344, 288, 789, 267, 3828, 421, 199, 533, 10072, 322, 551, 31998, 794, 8, 25778, 304, 272, 4983, 63, 2888, 275, 6596, 30871, 2844, 22210, 12, 339, 347, 2963, 8, 277, 12, 1056, 12, 7186, 63, 344, 26, 1109, 304, 267, 408, 267, 8354, 282, 892, 4789, 687, 282, 1627, 6370, 436, 13546, 367, 2860, 14, 398, 5679, 666, 26, 398, 469, 881, 298, 1213, 2, 520, 298, 7700, 511, 401, 881, 298, 12281, 582, 359, 288, 469, 1598, 298, 1975, 582, 4396, 17, 13915, 1598, 298, 5214, 582, 413, 12, 288, 789, 881, 2156, 881, 298, 3248, 63, 344, 582, 378, 12, 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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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 ]
yosukesuzuki/let-me-notify
project/kay/management/gae_bulkloader.py
10
125396
#!/usr/bin/env python # # Copyright 2007 Google 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. # """Imports data over HTTP. Usage: %(arg0)s [flags] --debug Show debugging information. (Optional) --app_id=<string> Application ID of endpoint (Optional for *.appspot.com) --auth_domain=<domain> The auth domain to use for logging in and for UserProperties. (Default: gmail.com) --bandwidth_limit=<int> The maximum number of bytes per second for the aggregate transfer of data to the server. Bursts may exceed this, but overall transfer rate is restricted to this rate. (Default 250000) --batch_size=<int> Number of Entity objects to include in each post to the URL endpoint. The more data per row/Entity, the smaller the batch size should be. (Default 10) --config_file=<path> File containing Model and Loader definitions. (Required unless --dump or --restore are used) --db_filename=<path> Specific progress database to write to, or to resume from. If not supplied, then a new database will be started, named: bulkloader-progress-TIMESTAMP. The special filename "skip" may be used to simply skip reading/writing any progress information. --download Export entities to a file. --dry_run Do not execute any remote_api calls. --dump Use zero-configuration dump format. --email=<string> The username to use. Will prompt if omitted. --exporter_opts=<string> A string to pass to the Exporter.initialize method. --filename=<path> Path to the file to import. (Required) --has_header Skip the first row of the input. --http_limit=<int> The maximum numer of HTTP requests per second to send to the server. (Default: 8) --kind=<string> Name of the Entity object kind to put in the datastore. (Required) --loader_opts=<string> A string to pass to the Loader.initialize method. --log_file=<path> File to write bulkloader logs. If not supplied then a new log file will be created, named: bulkloader-log-TIMESTAMP. --map Map an action across datastore entities. --mapper_opts=<string> A string to pass to the Mapper.Initialize method. --num_threads=<int> Number of threads to use for uploading entities (Default 10) --passin Read the login password from stdin. --restore Restore from zero-configuration dump format. --result_db_filename=<path> Result database to write to for downloads. --rps_limit=<int> The maximum number of records per second to transfer to the server. (Default: 20) --url=<string> URL endpoint to post to for importing data. (Required) The exit status will be 0 on success, non-zero on import failure. Works with the remote_api mix-in library for google.appengine.ext.remote_api. Please look there for documentation about how to setup the server side. Example: %(arg0)s --url=http://app.appspot.com/remote_api --kind=Model \ --filename=data.csv --config_file=loader_config.py """ import csv import errno import getopt import getpass import imp import logging import os import Queue import re import shutil import signal import StringIO import sys import threading import time import traceback import urllib2 import urlparse from google.appengine.datastore import entity_pb from google.appengine.api import apiproxy_stub_map from google.appengine.api import datastore from google.appengine.api import datastore_errors from google.appengine.datastore import datastore_pb from google.appengine.ext import db from google.appengine.ext import key_range as key_range_module from google.appengine.ext.db import polymodel from google.appengine.ext.remote_api import remote_api_stub from google.appengine.ext.remote_api import throttle as remote_api_throttle from google.appengine.runtime import apiproxy_errors from google.appengine.tools import adaptive_thread_pool from google.appengine.tools import appengine_rpc from google.appengine.tools.requeue import ReQueue try: import sqlite3 except ImportError: pass logger = logging.getLogger('google.appengine.tools.bulkloader') KeyRange = key_range_module.KeyRange DEFAULT_THREAD_COUNT = 10 DEFAULT_BATCH_SIZE = 10 DEFAULT_DOWNLOAD_BATCH_SIZE = 100 DEFAULT_QUEUE_SIZE = DEFAULT_THREAD_COUNT * 10 _THREAD_SHOULD_EXIT = '_THREAD_SHOULD_EXIT' STATE_READ = 0 STATE_SENDING = 1 STATE_SENT = 2 STATE_NOT_SENT = 3 STATE_GETTING = 1 STATE_GOT = 2 STATE_ERROR = 3 DATA_CONSUMED_TO_HERE = 'DATA_CONSUMED_TO_HERE' INITIAL_BACKOFF = 1.0 BACKOFF_FACTOR = 2.0 DEFAULT_BANDWIDTH_LIMIT = 250000 DEFAULT_RPS_LIMIT = 20 DEFAULT_REQUEST_LIMIT = 8 MAXIMUM_INCREASE_DURATION = 5.0 MAXIMUM_HOLD_DURATION = 12.0 def ImportStateMessage(state): """Converts a numeric state identifier to a status message.""" return ({ STATE_READ: 'Batch read from file.', STATE_SENDING: 'Sending batch to server.', STATE_SENT: 'Batch successfully sent.', STATE_NOT_SENT: 'Error while sending batch.' }[state]) def ExportStateMessage(state): """Converts a numeric state identifier to a status message.""" return ({ STATE_READ: 'Batch read from file.', STATE_GETTING: 'Fetching batch from server', STATE_GOT: 'Batch successfully fetched.', STATE_ERROR: 'Error while fetching batch' }[state]) def MapStateMessage(state): """Converts a numeric state identifier to a status message.""" return ({ STATE_READ: 'Batch read from file.', STATE_GETTING: 'Querying for batch from server', STATE_GOT: 'Batch successfully fetched.', STATE_ERROR: 'Error while fetching or mapping.' }[state]) def ExportStateName(state): """Converts a numeric state identifier to a string.""" return ({ STATE_READ: 'READ', STATE_GETTING: 'GETTING', STATE_GOT: 'GOT', STATE_ERROR: 'NOT_GOT' }[state]) def ImportStateName(state): """Converts a numeric state identifier to a string.""" return ({ STATE_READ: 'READ', STATE_GETTING: 'SENDING', STATE_GOT: 'SENT', STATE_NOT_SENT: 'NOT_SENT' }[state]) class Error(Exception): """Base-class for exceptions in this module.""" class MissingPropertyError(Error): """An expected field is missing from an entity, and no default was given.""" class FatalServerError(Error): """An unrecoverable error occurred while posting data to the server.""" class ResumeError(Error): """Error while trying to resume a partial upload.""" class ConfigurationError(Error): """Error in configuration options.""" class AuthenticationError(Error): """Error while trying to authenticate with the server.""" class FileNotFoundError(Error): """A filename passed in by the user refers to a non-existent input file.""" class FileNotReadableError(Error): """A filename passed in by the user refers to a non-readable input file.""" class FileExistsError(Error): """A filename passed in by the user refers to an existing output file.""" class FileNotWritableError(Error): """A filename passed in by the user refers to a non-writable output file.""" class BadStateError(Error): """A work item in an unexpected state was encountered.""" class KeyRangeError(Error): """An error during construction of a KeyRangeItem.""" class FieldSizeLimitError(Error): """The csv module tried to read a field larger than the size limit.""" def __init__(self, limit): self.message = """ A field in your CSV input file has exceeded the current limit of %d. You can raise this limit by adding the following lines to your config file: import csv csv.field_size_limit(new_limit) where new_limit is number larger than the size in bytes of the largest field in your CSV. """ % limit Error.__init__(self, self.message) class NameClashError(Error): """A name clash occurred while trying to alias old method names.""" def __init__(self, old_name, new_name, klass): Error.__init__(self, old_name, new_name, klass) self.old_name = old_name self.new_name = new_name self.klass = klass def GetCSVGeneratorFactory(kind, csv_filename, batch_size, csv_has_header, openfile=open, create_csv_reader=csv.reader): """Return a factory that creates a CSV-based UploadWorkItem generator. Args: kind: The kind of the entities being uploaded. csv_filename: File on disk containing CSV data. batch_size: Maximum number of CSV rows to stash into an UploadWorkItem. csv_has_header: Whether to skip the first row of the CSV. openfile: Used for dependency injection. create_csv_reader: Used for dependency injection. Returns: A callable (accepting the Progress Queue and Progress Generators as input) which creates the UploadWorkItem generator. """ loader = Loader.RegisteredLoader(kind) loader._Loader__openfile = openfile loader._Loader__create_csv_reader = create_csv_reader record_generator = loader.generate_records(csv_filename) def CreateGenerator(request_manager, progress_queue, progress_generator): """Initialize a UploadWorkItem generator. Args: request_manager: A RequestManager instance. progress_queue: A ProgressQueue instance to send progress information. progress_generator: A generator of progress information or None. Returns: An UploadWorkItemGenerator instance. """ return UploadWorkItemGenerator(request_manager, progress_queue, progress_generator, record_generator, csv_has_header, batch_size) return CreateGenerator class UploadWorkItemGenerator(object): """Reads rows from a row generator and generates UploadWorkItems.""" def __init__(self, request_manager, progress_queue, progress_generator, record_generator, skip_first, batch_size): """Initialize a WorkItemGenerator. Args: request_manager: A RequestManager instance with which to associate WorkItems. progress_queue: A progress queue with which to associate WorkItems. progress_generator: A generator of progress information. record_generator: A generator of data records. skip_first: Whether to skip the first data record. batch_size: The number of data records per WorkItem. """ self.request_manager = request_manager self.progress_queue = progress_queue self.progress_generator = progress_generator self.reader = record_generator self.skip_first = skip_first self.batch_size = batch_size self.line_number = 1 self.column_count = None self.read_rows = [] self.row_count = 0 self.xfer_count = 0 def _AdvanceTo(self, line): """Advance the reader to the given line. Args: line: A line number to advance to. """ while self.line_number < line: self.reader.next() self.line_number += 1 self.row_count += 1 self.xfer_count += 1 def _ReadRows(self, key_start, key_end): """Attempts to read and encode rows [key_start, key_end]. The encoded rows are stored in self.read_rows. Args: key_start: The starting line number. key_end: The ending line number. Raises: StopIteration: if the reader runs out of rows ResumeError: if there are an inconsistent number of columns. """ assert self.line_number == key_start self.read_rows = [] while self.line_number <= key_end: row = self.reader.next() self.row_count += 1 if self.column_count is None: self.column_count = len(row) else: if self.column_count != len(row): raise ResumeError('Column count mismatch, %d: %s' % (self.column_count, str(row))) self.read_rows.append((self.line_number, row)) self.line_number += 1 def _MakeItem(self, key_start, key_end, rows, progress_key=None): """Makes a UploadWorkItem containing the given rows, with the given keys. Args: key_start: The start key for the UploadWorkItem. key_end: The end key for the UploadWorkItem. rows: A list of the rows for the UploadWorkItem. progress_key: The progress key for the UploadWorkItem Returns: An UploadWorkItem instance for the given batch. """ assert rows item = UploadWorkItem(self.request_manager, self.progress_queue, rows, key_start, key_end, progress_key=progress_key) return item def Batches(self): """Reads from the record_generator and generates UploadWorkItems. Yields: Instances of class UploadWorkItem Raises: ResumeError: If the progress database and data file indicate a different number of rows. """ if self.skip_first: logger.info('Skipping header line.') try: self.reader.next() except StopIteration: return exhausted = False self.line_number = 1 self.column_count = None logger.info('Starting import; maximum %d entities per post', self.batch_size) state = None if self.progress_generator: for progress_key, state, key_start, key_end in self.progress_generator: if key_start: try: self._AdvanceTo(key_start) self._ReadRows(key_start, key_end) yield self._MakeItem(key_start, key_end, self.read_rows, progress_key=progress_key) except StopIteration: logger.error('Mismatch between data file and progress database') raise ResumeError( 'Mismatch between data file and progress database') elif state == DATA_CONSUMED_TO_HERE: try: self._AdvanceTo(key_end + 1) except StopIteration: state = None if self.progress_generator is None or state == DATA_CONSUMED_TO_HERE: while not exhausted: key_start = self.line_number key_end = self.line_number + self.batch_size - 1 try: self._ReadRows(key_start, key_end) except StopIteration: exhausted = True key_end = self.line_number - 1 if key_start <= key_end: yield self._MakeItem(key_start, key_end, self.read_rows) class CSVGenerator(object): """Reads a CSV file and generates data records.""" def __init__(self, csv_filename, openfile=open, create_csv_reader=csv.reader): """Initializes a CSV generator. Args: csv_filename: File on disk containing CSV data. openfile: Used for dependency injection of 'open'. create_csv_reader: Used for dependency injection of 'csv.reader'. """ self.csv_filename = csv_filename self.openfile = openfile self.create_csv_reader = create_csv_reader def Records(self): """Reads the CSV data file and generates row records. Yields: Lists of strings Raises: ResumeError: If the progress database and data file indicate a different number of rows. """ csv_file = self.openfile(self.csv_filename, 'rb') reader = self.create_csv_reader(csv_file, skipinitialspace=True) try: for record in reader: yield record except csv.Error, e: if e.args and e.args[0].startswith('field larger than field limit'): limit = e.args[1] raise FieldSizeLimitError(limit) else: raise class KeyRangeItemGenerator(object): """Generates ranges of keys to download. Reads progress information from the progress database and creates KeyRangeItem objects corresponding to incompletely downloaded parts of an export. """ def __init__(self, request_manager, kind, progress_queue, progress_generator, key_range_item_factory): """Initialize the KeyRangeItemGenerator. Args: request_manager: A RequestManager instance. kind: The kind of entities being transferred. progress_queue: A queue used for tracking progress information. progress_generator: A generator of prior progress information, or None if there is no prior status. key_range_item_factory: A factory to produce KeyRangeItems. """ self.request_manager = request_manager self.kind = kind self.row_count = 0 self.xfer_count = 0 self.progress_queue = progress_queue self.progress_generator = progress_generator self.key_range_item_factory = key_range_item_factory def Batches(self): """Iterate through saved progress information. Yields: KeyRangeItem instances corresponding to undownloaded key ranges. """ if self.progress_generator is not None: for progress_key, state, key_start, key_end in self.progress_generator: if state is not None and state != STATE_GOT and key_start is not None: key_start = ParseKey(key_start) key_end = ParseKey(key_end) key_range = KeyRange(key_start=key_start, key_end=key_end) result = self.key_range_item_factory(self.request_manager, self.progress_queue, self.kind, key_range, progress_key=progress_key, state=STATE_READ) yield result else: key_range = KeyRange() yield self.key_range_item_factory(self.request_manager, self.progress_queue, self.kind, key_range) class DownloadResult(object): """Holds the result of an entity download.""" def __init__(self, continued, direction, keys, entities): self.continued = continued self.direction = direction self.keys = keys self.entities = entities self.count = len(keys) assert self.count == len(entities) assert direction in (key_range_module.KeyRange.ASC, key_range_module.KeyRange.DESC) if self.count > 0: if direction == key_range_module.KeyRange.ASC: self.key_start = keys[0] self.key_end = keys[-1] else: self.key_start = keys[-1] self.key_end = keys[0] def Entities(self): """Returns the list of entities for this result in key order.""" if self.direction == key_range_module.KeyRange.ASC: return list(self.entities) else: result = list(self.entities) result.reverse() return result def __str__(self): return 'continued = %s\n%s' % ( str(self.continued), '\n'.join(str(self.entities))) class _WorkItem(adaptive_thread_pool.WorkItem): """Holds a description of a unit of upload or download work.""" def __init__(self, progress_queue, key_start, key_end, state_namer, state=STATE_READ, progress_key=None): """Initialize the _WorkItem instance. Args: progress_queue: A queue used for tracking progress information. key_start: The start key of the work item. key_end: The end key of the work item. state_namer: Function to describe work item states. state: The initial state of the work item. progress_key: If this WorkItem represents state from a prior run, then this will be the key within the progress database. """ adaptive_thread_pool.WorkItem.__init__(self, '[%s-%s]' % (key_start, key_end)) self.progress_queue = progress_queue self.state_namer = state_namer self.state = state self.progress_key = progress_key self.progress_event = threading.Event() self.key_start = key_start self.key_end = key_end self.error = None self.traceback = None def _TransferItem(self, thread_pool): raise NotImplementedError() def SetError(self): """Sets the error and traceback information for this thread. This must be called from an exception handler. """ if not self.error: exc_info = sys.exc_info() self.error = exc_info[1] self.traceback = exc_info[2] def PerformWork(self, thread_pool): """Perform the work of this work item and report the results. Args: thread_pool: An AdaptiveThreadPool instance. Returns: A tuple (status, instruction) of the work status and an instruction for the ThreadGate. """ status = adaptive_thread_pool.WorkItem.FAILURE instruction = adaptive_thread_pool.ThreadGate.DECREASE try: self.MarkAsTransferring() try: transfer_time = self._TransferItem(thread_pool) if transfer_time is None: status = adaptive_thread_pool.WorkItem.RETRY instruction = adaptive_thread_pool.ThreadGate.HOLD else: logger.debug('[%s] %s Transferred %d entities in %0.1f seconds', threading.currentThread().getName(), self, self.count, transfer_time) sys.stdout.write('.') sys.stdout.flush() status = adaptive_thread_pool.WorkItem.SUCCESS if transfer_time <= MAXIMUM_INCREASE_DURATION: instruction = adaptive_thread_pool.ThreadGate.INCREASE elif transfer_time <= MAXIMUM_HOLD_DURATION: instruction = adaptive_thread_pool.ThreadGate.HOLD except (db.InternalError, db.NotSavedError, db.Timeout, db.TransactionFailedError, apiproxy_errors.OverQuotaError, apiproxy_errors.DeadlineExceededError, apiproxy_errors.ApplicationError), e: status = adaptive_thread_pool.WorkItem.RETRY logger.exception('Retrying on non-fatal datastore error: %s', e) except urllib2.HTTPError, e: http_status = e.code if http_status == 403 or (http_status >= 500 and http_status < 600): status = adaptive_thread_pool.WorkItem.RETRY logger.exception('Retrying on non-fatal HTTP error: %d %s', http_status, e.msg) else: self.SetError() status = adaptive_thread_pool.WorkItem.FAILURE except urllib2.URLError, e: if IsURLErrorFatal(e): self.SetError() status = adaptive_thread_pool.WorkItem.FAILURE else: status = adaptive_thread_pool.WorkItem.RETRY logger.exception('Retrying on non-fatal URL error: %s', e.reason) finally: if status == adaptive_thread_pool.WorkItem.SUCCESS: self.MarkAsTransferred() else: self.MarkAsError() return (status, instruction) def _AssertInState(self, *states): """Raises an Error if the state of this range is not in states.""" if not self.state in states: raise BadStateError('%s:%s not in %s' % (str(self), self.state_namer(self.state), map(self.state_namer, states))) def _AssertProgressKey(self): """Raises an Error if the progress key is None.""" if self.progress_key is None: raise BadStateError('%s: Progress key is missing' % str(self)) def MarkAsRead(self): """Mark this _WorkItem as read, updating the progress database.""" self._AssertInState(STATE_READ) self._StateTransition(STATE_READ, blocking=True) def MarkAsTransferring(self): """Mark this _WorkItem as transferring, updating the progress database.""" self._AssertInState(STATE_READ, STATE_ERROR) self._AssertProgressKey() self._StateTransition(STATE_GETTING, blocking=True) def MarkAsTransferred(self): """Mark this _WorkItem as transferred, updating the progress database.""" raise NotImplementedError() def MarkAsError(self): """Mark this _WorkItem as failed, updating the progress database.""" self._AssertInState(STATE_GETTING) self._AssertProgressKey() self._StateTransition(STATE_ERROR, blocking=True) def _StateTransition(self, new_state, blocking=False): """Transition the work item to a new state, storing progress information. Args: new_state: The state to transition to. blocking: Whether to block for the progress thread to acknowledge the transition. """ assert not self.progress_event.isSet() self.state = new_state self.progress_queue.put(self) if blocking: self.progress_event.wait() self.progress_event.clear() class UploadWorkItem(_WorkItem): """Holds a unit of uploading work. A UploadWorkItem represents a number of entities that need to be uploaded to Google App Engine. These entities are encoded in the "content" field of the UploadWorkItem, and will be POST'd as-is to the server. The entities are identified by a range of numeric keys, inclusively. In the case of a resumption of an upload, or a replay to correct errors, these keys must be able to identify the same set of entities. Note that keys specify a range. The entities do not have to sequentially fill the entire range, they must simply bound a range of valid keys. """ def __init__(self, request_manager, progress_queue, rows, key_start, key_end, progress_key=None): """Initialize the UploadWorkItem instance. Args: request_manager: A RequestManager instance. progress_queue: A queue used for tracking progress information. rows: A list of pairs of a line number and a list of column values key_start: The (numeric) starting key, inclusive. key_end: The (numeric) ending key, inclusive. progress_key: If this UploadWorkItem represents state from a prior run, then this will be the key within the progress database. """ _WorkItem.__init__(self, progress_queue, key_start, key_end, ImportStateName, state=STATE_READ, progress_key=progress_key) assert isinstance(key_start, (int, long)) assert isinstance(key_end, (int, long)) assert key_start <= key_end self.request_manager = request_manager self.rows = rows self.content = None self.count = len(rows) def __str__(self): return '[%s-%s]' % (self.key_start, self.key_end) def _TransferItem(self, thread_pool, get_time=time.time): """Transfers the entities associated with an item. Args: thread_pool: An AdaptiveThreadPool instance. get_time: Used for dependency injection. """ t = get_time() if not self.content: self.content = self.request_manager.EncodeContent(self.rows) try: self.request_manager.PostEntities(self.content) except: raise return get_time() - t def MarkAsTransferred(self): """Mark this UploadWorkItem as sucessfully-sent to the server.""" self._AssertInState(STATE_SENDING) self._AssertProgressKey() self._StateTransition(STATE_SENT, blocking=False) def GetImplementationClass(kind_or_class_key): """Returns the implementation class for a given kind or class key. Args: kind_or_class_key: A kind string or a tuple of kind strings. Return: A db.Model subclass for the given kind or class key. """ if isinstance(kind_or_class_key, tuple): try: implementation_class = polymodel._class_map[kind_or_class_key] except KeyError: raise db.KindError('No implementation for class \'%s\'' % kind_or_class_key) else: implementation_class = db.class_for_kind(kind_or_class_key) return implementation_class def KeyLEQ(key1, key2): """Compare two keys for less-than-or-equal-to. All keys with numeric ids come before all keys with names. None represents an unbounded end-point so it is both greater and less than any other key. Args: key1: An int or datastore.Key instance. key2: An int or datastore.Key instance. Returns: True if key1 <= key2 """ if key1 is None or key2 is None: return True return key1 <= key2 class KeyRangeItem(_WorkItem): """Represents an item of work that scans over a key range. A KeyRangeItem object represents holds a KeyRange and has an associated state: STATE_READ, STATE_GETTING, STATE_GOT, and STATE_ERROR. - STATE_READ indicates the range ready to be downloaded by a worker thread. - STATE_GETTING indicates the range is currently being downloaded. - STATE_GOT indicates that the range was successfully downloaded - STATE_ERROR indicates that an error occurred during the last download attempt KeyRangeItems not in the STATE_GOT state are stored in the progress database. When a piece of KeyRangeItem work is downloaded, the download may cover only a portion of the range. In this case, the old KeyRangeItem is removed from the progress database and ranges covering the undownloaded range are generated and stored as STATE_READ in the export progress database. """ def __init__(self, request_manager, progress_queue, kind, key_range, progress_key=None, state=STATE_READ): """Initialize a KeyRangeItem object. Args: request_manager: A RequestManager instance. progress_queue: A queue used for tracking progress information. kind: The kind of entities for this range. key_range: A KeyRange instance for this work item. progress_key: The key for this range within the progress database. state: The initial state of this range. """ _WorkItem.__init__(self, progress_queue, key_range.key_start, key_range.key_end, ExportStateName, state=state, progress_key=progress_key) self.request_manager = request_manager self.kind = kind self.key_range = key_range self.download_result = None self.count = 0 self.key_start = key_range.key_start self.key_end = key_range.key_end def __str__(self): return str(self.key_range) def __repr__(self): return self.__str__() def MarkAsTransferred(self): """Mark this KeyRangeItem as transferred, updating the progress database.""" pass def Process(self, download_result, thread_pool, batch_size, new_state=STATE_GOT): """Mark this KeyRangeItem as success, updating the progress database. Process will split this KeyRangeItem based on the content of download_result and adds the unfinished ranges to the work queue. Args: download_result: A DownloadResult instance. thread_pool: An AdaptiveThreadPool instance. batch_size: The number of entities to transfer per request. new_state: The state to transition the completed range to. """ self._AssertInState(STATE_GETTING) self._AssertProgressKey() self.download_result = download_result self.count = len(download_result.keys) if download_result.continued: self._FinishedRange()._StateTransition(new_state, blocking=True) self._AddUnfinishedRanges(thread_pool, batch_size) else: self._StateTransition(new_state, blocking=True) def _FinishedRange(self): """Returns the range completed by the download_result. Returns: A KeyRangeItem representing a completed range. """ assert self.download_result is not None if self.key_range.direction == key_range_module.KeyRange.ASC: key_start = self.key_range.key_start if self.download_result.continued: key_end = self.download_result.key_end else: key_end = self.key_range.key_end else: key_end = self.key_range.key_end if self.download_result.continued: key_start = self.download_result.key_start else: key_start = self.key_range.key_start key_range = KeyRange(key_start=key_start, key_end=key_end, direction=self.key_range.direction) result = self.__class__(self.request_manager, self.progress_queue, self.kind, key_range, progress_key=self.progress_key, state=self.state) result.download_result = self.download_result result.count = self.count return result def _SplitAndAddRanges(self, thread_pool, batch_size): """Split the key range [key_start, key_end] into a list of ranges.""" if self.download_result.direction == key_range_module.KeyRange.ASC: key_range = KeyRange( key_start=self.download_result.key_end, key_end=self.key_range.key_end, include_start=False) else: key_range = KeyRange( key_start=self.key_range.key_start, key_end=self.download_result.key_start, include_end=False) if thread_pool.QueuedItemCount() > 2 * thread_pool.num_threads(): ranges = [key_range] else: ranges = key_range.split_range(batch_size=batch_size) for key_range in ranges: key_range_item = self.__class__(self.request_manager, self.progress_queue, self.kind, key_range) key_range_item.MarkAsRead() thread_pool.SubmitItem(key_range_item, block=True) def _AddUnfinishedRanges(self, thread_pool, batch_size): """Adds incomplete KeyRanges to the thread_pool. Args: thread_pool: An AdaptiveThreadPool instance. batch_size: The number of entities to transfer per request. Returns: A list of KeyRanges representing incomplete datastore key ranges. Raises: KeyRangeError: if this key range has already been completely transferred. """ assert self.download_result is not None if self.download_result.continued: self._SplitAndAddRanges(thread_pool, batch_size) else: raise KeyRangeError('No unfinished part of key range.') class DownloadItem(KeyRangeItem): """A KeyRangeItem for downloading key ranges.""" def _TransferItem(self, thread_pool, get_time=time.time): """Transfers the entities associated with an item.""" t = get_time() download_result = self.request_manager.GetEntities(self) transfer_time = get_time() - t self.Process(download_result, thread_pool, self.request_manager.batch_size) return transfer_time class MapperItem(KeyRangeItem): """A KeyRangeItem for mapping over key ranges.""" def _TransferItem(self, thread_pool, get_time=time.time): t = get_time() download_result = self.request_manager.GetEntities(self) transfer_time = get_time() - t mapper = self.request_manager.GetMapper() try: mapper.batch_apply(download_result.Entities()) except MapperRetry: return None self.Process(download_result, thread_pool, self.request_manager.batch_size) return transfer_time class RequestManager(object): """A class which wraps a connection to the server.""" def __init__(self, app_id, host_port, url_path, kind, throttle, batch_size, secure, email, passin, dry_run=False): """Initialize a RequestManager object. Args: app_id: String containing the application id for requests. host_port: String containing the "host:port" pair; the port is optional. url_path: partial URL (path) to post entity data to. kind: Kind of the Entity records being posted. throttle: A Throttle instance. batch_size: The number of entities to transfer per request. secure: Use SSL when communicating with server. email: If not none, the username to log in with. passin: If True, the password will be read from standard in. """ self.app_id = app_id self.host_port = host_port self.host = host_port.split(':')[0] if url_path and url_path[0] != '/': url_path = '/' + url_path self.url_path = url_path self.kind = kind self.throttle = throttle self.batch_size = batch_size self.secure = secure self.authenticated = False self.auth_called = False self.parallel_download = True self.email = email self.passin = passin self.mapper = None self.dry_run = dry_run if self.dry_run: logger.info('Running in dry run mode, skipping remote_api setup') return logger.debug('Configuring remote_api. url_path = %s, ' 'servername = %s' % (url_path, host_port)) def CookieHttpRpcServer(*args, **kwargs): kwargs['save_cookies'] = True kwargs['account_type'] = 'HOSTED_OR_GOOGLE' return appengine_rpc.HttpRpcServer(*args, **kwargs) remote_api_stub.ConfigureRemoteDatastore( app_id, url_path, self.AuthFunction, servername=host_port, rpc_server_factory=CookieHttpRpcServer, secure=self.secure) remote_api_throttle.ThrottleRemoteDatastore(self.throttle) logger.debug('Bulkloader using app_id: %s', os.environ['APPLICATION_ID']) def Authenticate(self): """Invoke authentication if necessary.""" logger.info('Connecting to %s%s', self.host_port, self.url_path) if self.dry_run: self.authenticated = True return remote_api_stub.MaybeInvokeAuthentication() self.authenticated = True def AuthFunction(self, raw_input_fn=raw_input, password_input_fn=getpass.getpass): """Prompts the user for a username and password. Caches the results the first time it is called and returns the same result every subsequent time. Args: raw_input_fn: Used for dependency injection. password_input_fn: Used for dependency injection. Returns: A pair of the username and password. """ if self.email: email = self.email else: print 'Please enter login credentials for %s' % ( self.host) email = raw_input_fn('Email: ') if email: password_prompt = 'Password for %s: ' % email if self.passin: password = raw_input_fn(password_prompt) else: password = password_input_fn(password_prompt) else: password = None self.auth_called = True return (email, password) def EncodeContent(self, rows, loader=None): """Encodes row data to the wire format. Args: rows: A list of pairs of a line number and a list of column values. loader: Used for dependency injection. Returns: A list of datastore.Entity instances. Raises: ConfigurationError: if no loader is defined for self.kind """ if not loader: try: loader = Loader.RegisteredLoader(self.kind) except KeyError: logger.error('No Loader defined for kind %s.' % self.kind) raise ConfigurationError('No Loader defined for kind %s.' % self.kind) entities = [] for line_number, values in rows: key = loader.generate_key(line_number, values) if isinstance(key, datastore.Key): parent = key.parent() key = key.name() else: parent = None entity = loader.create_entity(values, key_name=key, parent=parent) def ToEntity(entity): if isinstance(entity, db.Model): return entity._populate_entity() else: return entity if isinstance(entity, list): entities.extend(map(ToEntity, entity)) elif entity: entities.append(ToEntity(entity)) return entities def PostEntities(self, entities): """Posts Entity records to a remote endpoint over HTTP. Args: entities: A list of datastore entities. """ if self.dry_run: return datastore.Put(entities) def _QueryForPbs(self, query): """Perform the given query and return a list of entity_pb's.""" try: query_pb = query._ToPb(limit=self.batch_size) result_pb = datastore_pb.QueryResult() apiproxy_stub_map.MakeSyncCall('datastore_v3', 'RunQuery', query_pb, result_pb) next_pb = datastore_pb.NextRequest() next_pb.set_count(self.batch_size) next_pb.mutable_cursor().CopyFrom(result_pb.cursor()) result_pb = datastore_pb.QueryResult() apiproxy_stub_map.MakeSyncCall('datastore_v3', 'Next', next_pb, result_pb) return result_pb.result_list() except apiproxy_errors.ApplicationError, e: raise datastore._ToDatastoreError(e) def GetEntities(self, key_range_item, key_factory=datastore.Key): """Gets Entity records from a remote endpoint over HTTP. Args: key_range_item: Range of keys to get. key_factory: Used for dependency injection. Returns: A DownloadResult instance. Raises: ConfigurationError: if no Exporter is defined for self.kind """ keys = [] entities = [] if self.parallel_download: query = key_range_item.key_range.make_directed_datastore_query(self.kind) try: results = self._QueryForPbs(query) except datastore_errors.NeedIndexError: logger.info('%s: No descending index on __key__, ' 'performing serial download', self.kind) self.parallel_download = False if not self.parallel_download: key_range_item.key_range.direction = key_range_module.KeyRange.ASC query = key_range_item.key_range.make_ascending_datastore_query(self.kind) results = self._QueryForPbs(query) size = len(results) for entity in results: key = key_factory() key._Key__reference = entity.key() entities.append(entity) keys.append(key) continued = (size == self.batch_size) key_range_item.count = size return DownloadResult(continued, key_range_item.key_range.direction, keys, entities) def GetMapper(self): """Returns a mapper for the registered kind. Returns: A Mapper instance. Raises: ConfigurationError: if no Mapper is defined for self.kind """ if not self.mapper: try: self.mapper = Mapper.RegisteredMapper(self.kind) except KeyError: logger.error('No Mapper defined for kind %s.' % self.kind) raise ConfigurationError('No Mapper defined for kind %s.' % self.kind) return self.mapper def InterruptibleSleep(sleep_time): """Puts thread to sleep, checking this threads exit_flag twice a second. Args: sleep_time: Time to sleep. """ slept = 0.0 epsilon = .0001 thread = threading.currentThread() while slept < sleep_time - epsilon: remaining = sleep_time - slept this_sleep_time = min(remaining, 0.5) time.sleep(this_sleep_time) slept += this_sleep_time if thread.exit_flag: return class _ThreadBase(threading.Thread): """Provide some basic features for the threads used in the uploader. This abstract base class is used to provide some common features: * Flag to ask thread to exit as soon as possible. * Record exit/error status for the primary thread to pick up. * Capture exceptions and record them for pickup. * Some basic logging of thread start/stop. * All threads are "daemon" threads. * Friendly names for presenting to users. Concrete sub-classes must implement PerformWork(). Either self.NAME should be set or GetFriendlyName() be overridden to return a human-friendly name for this thread. The run() method starts the thread and prints start/exit messages. self.exit_flag is intended to signal that this thread should exit when it gets the chance. PerformWork() should check self.exit_flag whenever it has the opportunity to exit gracefully. """ def __init__(self): threading.Thread.__init__(self) self.setDaemon(True) self.exit_flag = False self.error = None self.traceback = None def run(self): """Perform the work of the thread.""" logger.debug('[%s] %s: started', self.getName(), self.__class__.__name__) try: self.PerformWork() except: self.SetError() logger.exception('[%s] %s:', self.getName(), self.__class__.__name__) logger.debug('[%s] %s: exiting', self.getName(), self.__class__.__name__) def SetError(self): """Sets the error and traceback information for this thread. This must be called from an exception handler. """ if not self.error: exc_info = sys.exc_info() self.error = exc_info[1] self.traceback = exc_info[2] def PerformWork(self): """Perform the thread-specific work.""" raise NotImplementedError() def CheckError(self): """If an error is present, then log it.""" if self.error: logger.error('Error in %s: %s', self.GetFriendlyName(), self.error) if self.traceback: logger.debug(''.join(traceback.format_exception(self.error.__class__, self.error, self.traceback))) def GetFriendlyName(self): """Returns a human-friendly description of the thread.""" if hasattr(self, 'NAME'): return self.NAME return 'unknown thread' non_fatal_error_codes = set([errno.EAGAIN, errno.ENETUNREACH, errno.ENETRESET, errno.ECONNRESET, errno.ETIMEDOUT, errno.EHOSTUNREACH]) def IsURLErrorFatal(error): """Returns False if the given URLError may be from a transient failure. Args: error: A urllib2.URLError instance. """ assert isinstance(error, urllib2.URLError) if not hasattr(error, 'reason'): return True if not isinstance(error.reason[0], int): return True return error.reason[0] not in non_fatal_error_codes class DataSourceThread(_ThreadBase): """A thread which reads WorkItems and pushes them into queue. This thread will read/consume WorkItems from a generator (produced by the generator factory). These WorkItems will then be pushed into the thread_pool. Note that reading will block if/when the thread_pool becomes full. Information on content consumed from the generator will be pushed into the progress_queue. """ NAME = 'data source thread' def __init__(self, request_manager, thread_pool, progress_queue, workitem_generator_factory, progress_generator_factory): """Initialize the DataSourceThread instance. Args: request_manager: A RequestManager instance. thread_pool: An AdaptiveThreadPool instance. progress_queue: A queue used for tracking progress information. workitem_generator_factory: A factory that creates a WorkItem generator progress_generator_factory: A factory that creates a generator which produces prior progress status, or None if there is no prior status to use. """ _ThreadBase.__init__(self) self.request_manager = request_manager self.thread_pool = thread_pool self.progress_queue = progress_queue self.workitem_generator_factory = workitem_generator_factory self.progress_generator_factory = progress_generator_factory self.entity_count = 0 def PerformWork(self): """Performs the work of a DataSourceThread.""" if self.progress_generator_factory: progress_gen = self.progress_generator_factory() else: progress_gen = None content_gen = self.workitem_generator_factory(self.request_manager, self.progress_queue, progress_gen) self.xfer_count = 0 self.read_count = 0 self.read_all = False for item in content_gen.Batches(): item.MarkAsRead() while not self.exit_flag: try: self.thread_pool.SubmitItem(item, block=True, timeout=1.0) self.entity_count += item.count break except Queue.Full: pass if self.exit_flag: break if not self.exit_flag: self.read_all = True self.read_count = content_gen.row_count self.xfer_count = content_gen.xfer_count def _RunningInThread(thread): """Return True if we are running within the specified thread.""" return threading.currentThread().getName() == thread.getName() class _Database(object): """Base class for database connections in this module. The table is created by a primary thread (the python main thread) but all future lookups and updates are performed by a secondary thread. """ SIGNATURE_TABLE_NAME = 'bulkloader_database_signature' def __init__(self, db_filename, create_table, signature, index=None, commit_periodicity=100): """Initialize the _Database instance. Args: db_filename: The sqlite3 file to use for the database. create_table: A string containing the SQL table creation command. signature: A string identifying the important invocation options, used to make sure we are not using an old database. index: An optional string to create an index for the database. commit_periodicity: Number of operations between database commits. """ self.db_filename = db_filename logger.info('Opening database: %s', db_filename) self.primary_conn = sqlite3.connect(db_filename, isolation_level=None) self.primary_thread = threading.currentThread() self.secondary_conn = None self.secondary_thread = None self.operation_count = 0 self.commit_periodicity = commit_periodicity try: self.primary_conn.execute(create_table) except sqlite3.OperationalError, e: if 'already exists' not in e.message: raise if index: try: self.primary_conn.execute(index) except sqlite3.OperationalError, e: if 'already exists' not in e.message: raise self.existing_table = False signature_cursor = self.primary_conn.cursor() create_signature = """ create table %s ( value TEXT not null) """ % _Database.SIGNATURE_TABLE_NAME try: self.primary_conn.execute(create_signature) self.primary_conn.cursor().execute( 'insert into %s (value) values (?)' % _Database.SIGNATURE_TABLE_NAME, (signature,)) except sqlite3.OperationalError, e: if 'already exists' not in e.message: logger.exception('Exception creating table:') raise else: self.existing_table = True signature_cursor.execute( 'select * from %s' % _Database.SIGNATURE_TABLE_NAME) (result,) = signature_cursor.fetchone() if result and result != signature: logger.error('Database signature mismatch:\n\n' 'Found:\n' '%s\n\n' 'Expecting:\n' '%s\n', result, signature) raise ResumeError('Database signature mismatch: %s != %s' % ( signature, result)) def ThreadComplete(self): """Finalize any operations the secondary thread has performed. The database aggregates lots of operations into a single commit, and this method is used to commit any pending operations as the thread is about to shut down. """ if self.secondary_conn: self._MaybeCommit(force_commit=True) def _MaybeCommit(self, force_commit=False): """Periodically commit changes into the SQLite database. Committing every operation is quite expensive, and slows down the operation of the script. Thus, we only commit after every N operations, as determined by the self.commit_periodicity value. Optionally, the caller can force a commit. Args: force_commit: Pass True in order for a commit to occur regardless of the current operation count. """ self.operation_count += 1 if force_commit or (self.operation_count % self.commit_periodicity) == 0: self.secondary_conn.commit() def _OpenSecondaryConnection(self): """Possibly open a database connection for the secondary thread. If the connection is not open (for the calling thread, which is assumed to be the unique secondary thread), then open it. We also open a couple cursors for later use (and reuse). """ if self.secondary_conn: return assert not _RunningInThread(self.primary_thread) self.secondary_thread = threading.currentThread() self.secondary_conn = sqlite3.connect(self.db_filename) self.insert_cursor = self.secondary_conn.cursor() self.update_cursor = self.secondary_conn.cursor() zero_matcher = re.compile(r'\x00') zero_one_matcher = re.compile(r'\x00\x01') def KeyStr(key): """Returns a string to represent a key, preserving ordering. Unlike datastore.Key.__str__(), we have the property: key1 < key2 ==> KeyStr(key1) < KeyStr(key2) The key string is constructed from the key path as follows: (1) Strings are prepended with ':' and numeric id's are padded to 20 digits. (2) Any null characters (u'\0') present are replaced with u'\0\1' (3) The sequence u'\0\0' is used to separate each component of the path. (1) assures that names and ids compare properly, while (2) and (3) enforce the part-by-part comparison of pieces of the path. Args: key: A datastore.Key instance. Returns: A string representation of the key, which preserves ordering. """ assert isinstance(key, datastore.Key) path = key.to_path() out_path = [] for part in path: if isinstance(part, (int, long)): part = '%020d' % part else: part = ':%s' % part out_path.append(zero_matcher.sub(u'\0\1', part)) out_str = u'\0\0'.join(out_path) return out_str def StrKey(key_str): """The inverse of the KeyStr function. Args: key_str: A string in the range of KeyStr. Returns: A datastore.Key instance k, such that KeyStr(k) == key_str. """ parts = key_str.split(u'\0\0') for i in xrange(len(parts)): if parts[i][0] == ':': part = parts[i][1:] part = zero_one_matcher.sub(u'\0', part) parts[i] = part else: parts[i] = int(parts[i]) return datastore.Key.from_path(*parts) class ResultDatabase(_Database): """Persistently record all the entities downloaded during an export. The entities are held in the database by their unique datastore key in order to avoid duplication if an export is restarted. """ def __init__(self, db_filename, signature, commit_periodicity=1): """Initialize a ResultDatabase object. Args: db_filename: The name of the SQLite database to use. signature: A string identifying the important invocation options, used to make sure we are not using an old database. commit_periodicity: How many operations to perform between commits. """ self.complete = False create_table = ('create table result (\n' 'id BLOB primary key,\n' 'value BLOB not null)') _Database.__init__(self, db_filename, create_table, signature, commit_periodicity=commit_periodicity) if self.existing_table: cursor = self.primary_conn.cursor() cursor.execute('select count(*) from result') self.existing_count = int(cursor.fetchone()[0]) else: self.existing_count = 0 self.count = self.existing_count def _StoreEntity(self, entity_id, entity): """Store an entity in the result database. Args: entity_id: A datastore.Key for the entity. entity: The entity to store. Returns: True if this entities is not already present in the result database. """ assert _RunningInThread(self.secondary_thread) assert isinstance(entity_id, datastore.Key), ( 'expected a datastore.Key, got a %s' % entity_id.__class__.__name__) key_str = buffer(KeyStr(entity_id).encode('utf-8')) self.insert_cursor.execute( 'select count(*) from result where id = ?', (key_str,)) already_present = self.insert_cursor.fetchone()[0] result = True if already_present: result = False self.insert_cursor.execute('delete from result where id = ?', (key_str,)) else: self.count += 1 value = entity.Encode() self.insert_cursor.execute( 'insert into result (id, value) values (?, ?)', (key_str, buffer(value))) return result def StoreEntities(self, keys, entities): """Store a group of entities in the result database. Args: keys: A list of entity keys. entities: A list of entities. Returns: The number of new entities stored in the result database. """ self._OpenSecondaryConnection() t = time.time() count = 0 for entity_id, entity in zip(keys, entities): if self._StoreEntity(entity_id, entity): count += 1 logger.debug('%s insert: delta=%.3f', self.db_filename, time.time() - t) logger.debug('Entities transferred total: %s', self.count) self._MaybeCommit() return count def ResultsComplete(self): """Marks the result database as containing complete results.""" self.complete = True def AllEntities(self): """Yields all pairs of (id, value) from the result table.""" conn = sqlite3.connect(self.db_filename, isolation_level=None) cursor = conn.cursor() cursor.execute( 'select id, value from result order by id') for unused_entity_id, entity in cursor: entity_proto = entity_pb.EntityProto(contents=entity) yield datastore.Entity._FromPb(entity_proto) class _ProgressDatabase(_Database): """Persistently record all progress information during an upload. This class wraps a very simple SQLite database which records each of the relevant details from a chunk of work. If the loader is resumed, then data is replayed out of the database. """ def __init__(self, db_filename, sql_type, py_type, signature, commit_periodicity=100): """Initialize the ProgressDatabase instance. Args: db_filename: The name of the SQLite database to use. sql_type: A string of the SQL type to use for entity keys. py_type: The python type of entity keys. signature: A string identifying the important invocation options, used to make sure we are not using an old database. commit_periodicity: How many operations to perform between commits. """ self.prior_key_end = None create_table = ('create table progress (\n' 'id integer primary key autoincrement,\n' 'state integer not null,\n' 'key_start %s,\n' 'key_end %s)' % (sql_type, sql_type)) self.py_type = py_type index = 'create index i_state on progress (state)' _Database.__init__(self, db_filename, create_table, signature, index=index, commit_periodicity=commit_periodicity) def UseProgressData(self): """Returns True if the database has progress information. Note there are two basic cases for progress information: 1) All saved records indicate a successful upload. In this case, we need to skip everything transmitted so far and then send the rest. 2) Some records for incomplete transfer are present. These need to be sent again, and then we resume sending after all the successful data. Returns: True: if the database has progress information. Raises: ResumeError: if there is an error retrieving rows from the database. """ assert _RunningInThread(self.primary_thread) cursor = self.primary_conn.cursor() cursor.execute('select count(*) from progress') row = cursor.fetchone() if row is None: raise ResumeError('Cannot retrieve progress information from database.') return row[0] != 0 def StoreKeys(self, key_start, key_end): """Record a new progress record, returning a key for later updates. The specified progress information will be persisted into the database. A unique key will be returned that identifies this progress state. The key is later used to (quickly) update this record. For the progress resumption to proceed properly, calls to StoreKeys MUST specify monotonically increasing key ranges. This will result in a database whereby the ID, KEY_START, and KEY_END rows are all increasing (rather than having ranges out of order). NOTE: the above precondition is NOT tested by this method (since it would imply an additional table read or two on each invocation). Args: key_start: The starting key of the WorkItem (inclusive) key_end: The end key of the WorkItem (inclusive) Returns: A string to later be used as a unique key to update this state. """ self._OpenSecondaryConnection() assert _RunningInThread(self.secondary_thread) assert (not key_start) or isinstance(key_start, self.py_type), ( '%s is a %s, %s expected %s' % (key_start, key_start.__class__, self.__class__.__name__, self.py_type)) assert (not key_end) or isinstance(key_end, self.py_type), ( '%s is a %s, %s expected %s' % (key_end, key_end.__class__, self.__class__.__name__, self.py_type)) assert KeyLEQ(key_start, key_end), '%s not less than %s' % ( repr(key_start), repr(key_end)) self.insert_cursor.execute( 'insert into progress (state, key_start, key_end) values (?, ?, ?)', (STATE_READ, unicode(key_start), unicode(key_end))) progress_key = self.insert_cursor.lastrowid self._MaybeCommit() return progress_key def UpdateState(self, key, new_state): """Update a specified progress record with new information. Args: key: The key for this progress record, returned from StoreKeys new_state: The new state to associate with this progress record. """ self._OpenSecondaryConnection() assert _RunningInThread(self.secondary_thread) assert isinstance(new_state, int) self.update_cursor.execute('update progress set state=? where id=?', (new_state, key)) self._MaybeCommit() def DeleteKey(self, progress_key): """Delete the entities with the given key from the result database.""" self._OpenSecondaryConnection() assert _RunningInThread(self.secondary_thread) t = time.time() self.insert_cursor.execute( 'delete from progress where rowid = ?', (progress_key,)) logger.debug('delete: delta=%.3f', time.time() - t) self._MaybeCommit() def GetProgressStatusGenerator(self): """Get a generator which yields progress information. The returned generator will yield a series of 4-tuples that specify progress information about a prior run of the uploader. The 4-tuples have the following values: progress_key: The unique key to later update this record with new progress information. state: The last state saved for this progress record. key_start: The starting key of the items for uploading (inclusive). key_end: The ending key of the items for uploading (inclusive). After all incompletely-transferred records are provided, then one more 4-tuple will be generated: None DATA_CONSUMED_TO_HERE: A unique string value indicating this record is being provided. None key_end: An integer value specifying the last data source key that was handled by the previous run of the uploader. The caller should begin uploading records which occur after key_end. Yields: Four-tuples of (progress_key, state, key_start, key_end) """ conn = sqlite3.connect(self.db_filename, isolation_level=None) cursor = conn.cursor() cursor.execute('select max(key_end) from progress') result = cursor.fetchone() if result is not None: key_end = result[0] else: logger.debug('No rows in progress database.') return self.prior_key_end = key_end cursor.execute( 'select id, state, key_start, key_end from progress' ' where state != ?' ' order by id', (STATE_SENT,)) rows = cursor.fetchall() for row in rows: if row is None: break progress_key, state, key_start, key_end = row yield progress_key, state, key_start, key_end yield None, DATA_CONSUMED_TO_HERE, None, key_end def ProgressDatabase(db_filename, signature): """Returns a database to store upload progress information.""" return _ProgressDatabase(db_filename, 'INTEGER', int, signature) class ExportProgressDatabase(_ProgressDatabase): """A database to store download progress information.""" def __init__(self, db_filename, signature): """Initialize an ExportProgressDatabase.""" _ProgressDatabase.__init__(self, db_filename, 'TEXT', datastore.Key, signature, commit_periodicity=1) def UseProgressData(self): """Check if the progress database contains progress data. Returns: True: if the database contains progress data. """ return self.existing_table class StubProgressDatabase(object): """A stub implementation of ProgressDatabase which does nothing.""" def UseProgressData(self): """Whether the stub database has progress information (it doesn't).""" return False def StoreKeys(self, unused_key_start, unused_key_end): """Pretend to store a key in the stub database.""" return 'fake-key' def UpdateState(self, unused_key, unused_new_state): """Pretend to update the state of a progress item.""" pass def ThreadComplete(self): """Finalize operations on the stub database (i.e. do nothing).""" pass class _ProgressThreadBase(_ThreadBase): """A thread which records progress information for the upload process. The progress information is stored into the provided progress database. This class is not responsible for replaying a prior run's progress information out of the database. Separate mechanisms must be used to resume a prior upload attempt. """ NAME = 'progress tracking thread' def __init__(self, progress_queue, progress_db): """Initialize the ProgressTrackerThread instance. Args: progress_queue: A Queue used for tracking progress information. progress_db: The database for tracking progress information; should be an instance of ProgressDatabase. """ _ThreadBase.__init__(self) self.progress_queue = progress_queue self.db = progress_db self.entities_transferred = 0 def EntitiesTransferred(self): """Return the total number of unique entities transferred.""" return self.entities_transferred def UpdateProgress(self, item): """Updates the progress information for the given item. Args: item: A work item whose new state will be recorded """ raise NotImplementedError() def WorkFinished(self): """Performs final actions after the entity transfer is complete.""" raise NotImplementedError() def PerformWork(self): """Performs the work of a ProgressTrackerThread.""" while not self.exit_flag: try: item = self.progress_queue.get(block=True, timeout=1.0) except Queue.Empty: continue if item == _THREAD_SHOULD_EXIT: break if item.state == STATE_READ and item.progress_key is None: item.progress_key = self.db.StoreKeys(item.key_start, item.key_end) else: assert item.progress_key is not None self.UpdateProgress(item) item.progress_event.set() self.progress_queue.task_done() self.db.ThreadComplete() class ProgressTrackerThread(_ProgressThreadBase): """A thread which records progress information for the upload process. The progress information is stored into the provided progress database. This class is not responsible for replaying a prior run's progress information out of the database. Separate mechanisms must be used to resume a prior upload attempt. """ NAME = 'progress tracking thread' def __init__(self, progress_queue, progress_db): """Initialize the ProgressTrackerThread instance. Args: progress_queue: A Queue used for tracking progress information. progress_db: The database for tracking progress information; should be an instance of ProgressDatabase. """ _ProgressThreadBase.__init__(self, progress_queue, progress_db) def UpdateProgress(self, item): """Update the state of the given WorkItem. Args: item: A WorkItem instance. """ self.db.UpdateState(item.progress_key, item.state) if item.state == STATE_SENT: self.entities_transferred += item.count def WorkFinished(self): """Performs final actions after the entity transfer is complete.""" pass class ExportProgressThread(_ProgressThreadBase): """A thread to record progress information and write record data for exports. The progress information is stored into a provided progress database. Exported results are stored in the result database and dumped to an output file at the end of the download. """ def __init__(self, kind, progress_queue, progress_db, result_db): """Initialize the ExportProgressThread instance. Args: kind: The kind of entities being stored in the database. progress_queue: A Queue used for tracking progress information. progress_db: The database for tracking progress information; should be an instance of ProgressDatabase. result_db: The database for holding exported entities; should be an instance of ResultDatabase. """ _ProgressThreadBase.__init__(self, progress_queue, progress_db) self.kind = kind self.existing_count = result_db.existing_count self.result_db = result_db def EntitiesTransferred(self): """Return the total number of unique entities transferred.""" return self.result_db.count def WorkFinished(self): """Write the contents of the result database.""" exporter = Exporter.RegisteredExporter(self.kind) exporter.output_entities(self.result_db.AllEntities()) def UpdateProgress(self, item): """Update the state of the given KeyRangeItem. Args: item: A KeyRange instance. """ if item.state == STATE_GOT: count = self.result_db.StoreEntities(item.download_result.keys, item.download_result.entities) self.db.DeleteKey(item.progress_key) self.entities_transferred += count else: self.db.UpdateState(item.progress_key, item.state) class MapperProgressThread(_ProgressThreadBase): """A thread to record progress information for maps over the datastore.""" def __init__(self, kind, progress_queue, progress_db): """Initialize the MapperProgressThread instance. Args: kind: The kind of entities being stored in the database. progress_queue: A Queue used for tracking progress information. progress_db: The database for tracking progress information; should be an instance of ProgressDatabase. """ _ProgressThreadBase.__init__(self, progress_queue, progress_db) self.kind = kind self.mapper = Mapper.RegisteredMapper(self.kind) def EntitiesTransferred(self): """Return the total number of unique entities transferred.""" return self.entities_transferred def WorkFinished(self): """Perform actions after map is complete.""" pass def UpdateProgress(self, item): """Update the state of the given KeyRangeItem. Args: item: A KeyRange instance. """ if item.state == STATE_GOT: self.entities_transferred += item.count self.db.DeleteKey(item.progress_key) else: self.db.UpdateState(item.progress_key, item.state) def ParseKey(key_string): """Turn a key stored in the database into a Key or None. Args: key_string: The string representation of a Key. Returns: A datastore.Key instance or None """ if not key_string: return None if key_string == 'None': return None return datastore.Key(encoded=key_string) def Validate(value, typ): """Checks that value is non-empty and of the right type. Args: value: any value typ: a type or tuple of types Raises: ValueError: if value is None or empty. TypeError: if it's not the given type. """ if not value: raise ValueError('Value should not be empty; received %s.' % value) elif not isinstance(value, typ): raise TypeError('Expected a %s, but received %s (a %s).' % (typ, value, value.__class__)) def CheckFile(filename): """Check that the given file exists and can be opened for reading. Args: filename: The name of the file. Raises: FileNotFoundError: if the given filename is not found FileNotReadableError: if the given filename is not readable. """ if not os.path.exists(filename): raise FileNotFoundError('%s: file not found' % filename) elif not os.access(filename, os.R_OK): raise FileNotReadableError('%s: file not readable' % filename) class Loader(object): """A base class for creating datastore entities from input data. To add a handler for bulk loading a new entity kind into your datastore, write a subclass of this class that calls Loader.__init__ from your class's __init__. If you need to run extra code to convert entities from the input data, create new properties, or otherwise modify the entities before they're inserted, override handle_entity. See the create_entity method for the creation of entities from the (parsed) input data. """ __loaders = {} kind = None __properties = None def __init__(self, kind, properties): """Constructor. Populates this Loader's kind and properties map. Args: kind: a string containing the entity kind that this loader handles properties: list of (name, converter) tuples. This is used to automatically convert the input columns into properties. The converter should be a function that takes one argument, a string value from the input file, and returns a correctly typed property value that should be inserted. The tuples in this list should match the columns in your input file, in order. For example: [('name', str), ('id_number', int), ('email', datastore_types.Email), ('user', users.User), ('birthdate', lambda x: datetime.datetime.fromtimestamp(float(x))), ('description', datastore_types.Text), ] """ Validate(kind, (basestring, tuple)) self.kind = kind self.__openfile = open self.__create_csv_reader = csv.reader GetImplementationClass(kind) Validate(properties, list) for name, fn in properties: Validate(name, basestring) assert callable(fn), ( 'Conversion function %s for property %s is not callable.' % (fn, name)) self.__properties = properties @staticmethod def RegisterLoader(loader): """Register loader and the Loader instance for its kind. Args: loader: A Loader instance. """ Loader.__loaders[loader.kind] = loader def alias_old_names(self): """Aliases method names so that Loaders defined with old names work.""" aliases = ( ('CreateEntity', 'create_entity'), ('HandleEntity', 'handle_entity'), ('GenerateKey', 'generate_key'), ) for old_name, new_name in aliases: setattr(Loader, old_name, getattr(Loader, new_name)) if hasattr(self.__class__, old_name) and not ( getattr(self.__class__, old_name).im_func == getattr(Loader, new_name).im_func): if hasattr(self.__class__, new_name) and not ( getattr(self.__class__, new_name).im_func == getattr(Loader, new_name).im_func): raise NameClashError(old_name, new_name, self.__class__) setattr(self, new_name, getattr(self, old_name)) def create_entity(self, values, key_name=None, parent=None): """Creates a entity from a list of property values. Args: values: list/tuple of str key_name: if provided, the name for the (single) resulting entity parent: A datastore.Key instance for the parent, or None Returns: list of db.Model The returned entities are populated with the property values from the argument, converted to native types using the properties map given in the constructor, and passed through handle_entity. They're ready to be inserted. Raises: AssertionError: if the number of values doesn't match the number of properties in the properties map. ValueError: if any element of values is None or empty. TypeError: if values is not a list or tuple. """ Validate(values, (list, tuple)) assert len(values) == len(self.__properties), ( 'Expected %d columns, found %d.' % (len(self.__properties), len(values))) model_class = GetImplementationClass(self.kind) properties = { 'key_name': key_name, 'parent': parent, } for (name, converter), val in zip(self.__properties, values): if converter is bool and val.lower() in ('0', 'false', 'no'): val = False properties[name] = converter(val) entity = model_class(**properties) entities = self.handle_entity(entity) if entities: if not isinstance(entities, (list, tuple)): entities = [entities] for entity in entities: if not isinstance(entity, db.Model): raise TypeError('Expected a db.Model, received %s (a %s).' % (entity, entity.__class__)) return entities def generate_key(self, i, values): """Generates a key_name to be used in creating the underlying object. The default implementation returns None. This method can be overridden to control the key generation for uploaded entities. The value returned should be None (to use a server generated numeric key), or a string which neither starts with a digit nor has the form __*__ (see http://code.google.com/appengine/docs/python/datastore/keysandentitygroups.html), or a datastore.Key instance. If you generate your own string keys, keep in mind: 1. The key name for each entity must be unique. 2. If an entity of the same kind and key already exists in the datastore, it will be overwritten. Args: i: Number corresponding to this object (assume it's run in a loop, this is your current count. values: list/tuple of str. Returns: A string to be used as the key_name for an entity. """ return None def handle_entity(self, entity): """Subclasses can override this to add custom entity conversion code. This is called for each entity, after its properties are populated from the input but before it is stored. Subclasses can override this to add custom entity handling code. The entity to be inserted should be returned. If multiple entities should be inserted, return a list of entities. If no entities should be inserted, return None or []. Args: entity: db.Model Returns: db.Model or list of db.Model """ return entity def initialize(self, filename, loader_opts): """Performs initialization and validation of the input file. This implementation checks that the input file exists and can be opened for reading. Args: filename: The string given as the --filename flag argument. loader_opts: The string given as the --loader_opts flag argument. """ CheckFile(filename) def finalize(self): """Performs finalization actions after the upload completes.""" pass def generate_records(self, filename): """Subclasses can override this to add custom data input code. This method must yield fixed-length lists of strings. The default implementation uses csv.reader to read CSV rows from filename. Args: filename: The string input for the --filename option. Yields: Lists of strings. """ csv_generator = CSVGenerator(filename, openfile=self.__openfile, create_csv_reader=self.__create_csv_reader ).Records() return csv_generator @staticmethod def RegisteredLoaders(): """Returns a dict of the Loader instances that have been created.""" return dict(Loader.__loaders) @staticmethod def RegisteredLoader(kind): """Returns the loader instance for the given kind if it exists.""" return Loader.__loaders[kind] class RestoreThread(_ThreadBase): """A thread to read saved entity_pbs from sqlite3.""" NAME = 'RestoreThread' _ENTITIES_DONE = 'Entities Done' def __init__(self, queue, filename): _ThreadBase.__init__(self) self.queue = queue self.filename = filename def PerformWork(self): db_conn = sqlite3.connect(self.filename) cursor = db_conn.cursor() cursor.execute('select id, value from result') for entity_id, value in cursor: self.queue.put([entity_id, value], block=True) self.queue.put(RestoreThread._ENTITIES_DONE, block=True) class RestoreLoader(Loader): """A Loader which imports protobuffers from a file.""" def __init__(self, kind, app_id): self.kind = kind self.app_id = app_id def initialize(self, filename, loader_opts): CheckFile(filename) self.queue = Queue.Queue(1000) restore_thread = RestoreThread(self.queue, filename) restore_thread.start() def generate_records(self, filename): while True: record = self.queue.get(block=True) if id(record) == id(RestoreThread._ENTITIES_DONE): break yield record def create_entity(self, values, key_name=None, parent=None): def convert_key(key, app_id): path = key.to_path() kwargs = {'_app_id_namespace': app_id} return db.Key.from_path(*path,**kwargs) import copy key = StrKey(unicode(values[0], 'utf-8')) entity_proto = entity_pb.EntityProto(contents=str(values[1])) entity_proto.mutable_key().CopyFrom(key._Key__reference) entity = datastore.Entity._FromPb(entity_proto) new_entity = copy.copy(entity) for k,v in entity.iteritems(): if isinstance(v, db.Key): new_entity[k] = convert_key(v, self.app_id) if isinstance(v, list): new_list = [] for item in v: if isinstance(item, db.Key): new_list.append(convert_key(item, self.app_id)) else: new_list.append(item) new_entity[k] = new_list return new_entity class Exporter(object): """A base class for serializing datastore entities. To add a handler for exporting an entity kind from your datastore, write a subclass of this class that calls Exporter.__init__ from your class's __init__. If you need to run extra code to convert entities from the input data, create new properties, or otherwise modify the entities before they're inserted, override handle_entity. See the output_entities method for the writing of data from entities. """ __exporters = {} kind = None __properties = None def __init__(self, kind, properties): """Constructor. Populates this Exporters's kind and properties map. Args: kind: a string containing the entity kind that this exporter handles properties: list of (name, converter, default) tuples. This is used to automatically convert the entities to strings. The converter should be a function that takes one argument, a property value of the appropriate type, and returns a str or unicode. The default is a string to be used if the property is not present, or None to fail with an error if the property is missing. For example: [('name', str, None), ('id_number', str, None), ('email', str, ''), ('user', str, None), ('birthdate', lambda x: str(datetime.datetime.fromtimestamp(float(x))), None), ('description', str, ''), ] """ Validate(kind, basestring) self.kind = kind GetImplementationClass(kind) Validate(properties, list) for name, fn, default in properties: Validate(name, basestring) assert callable(fn), ( 'Conversion function %s for property %s is not callable.' % ( fn, name)) if default: Validate(default, basestring) self.__properties = properties @staticmethod def RegisterExporter(exporter): """Register exporter and the Exporter instance for its kind. Args: exporter: A Exporter instance. """ Exporter.__exporters[exporter.kind] = exporter def __ExtractProperties(self, entity): """Converts an entity into a list of string values. Args: entity: An entity to extract the properties from. Returns: A list of the properties of the entity. Raises: MissingPropertyError: if an expected field on the entity is missing. """ encoding = [] for name, fn, default in self.__properties: try: encoding.append(fn(entity[name])) except AttributeError: if default is None: raise MissingPropertyError(name) else: encoding.append(default) return encoding def __EncodeEntity(self, entity): """Convert the given entity into CSV string. Args: entity: The entity to encode. Returns: A CSV string. """ output = StringIO.StringIO() writer = csv.writer(output, lineterminator='') writer.writerow(self.__ExtractProperties(entity)) return output.getvalue() def __SerializeEntity(self, entity): """Creates a string representation of an entity. Args: entity: The entity to serialize. Returns: A serialized representation of an entity. """ encoding = self.__EncodeEntity(entity) if not isinstance(encoding, unicode): encoding = unicode(encoding, 'utf-8') encoding = encoding.encode('utf-8') return encoding def output_entities(self, entity_generator): """Outputs the downloaded entities. This implementation writes CSV. Args: entity_generator: A generator that yields the downloaded entities in key order. """ CheckOutputFile(self.output_filename) output_file = open(self.output_filename, 'w') logger.debug('Export complete, writing to file') output_file.writelines(self.__SerializeEntity(entity) + '\n' for entity in entity_generator) def initialize(self, filename, exporter_opts): """Performs initialization and validation of the output file. This implementation checks that the input file exists and can be opened for writing. Args: filename: The string given as the --filename flag argument. exporter_opts: The string given as the --exporter_opts flag argument. """ CheckOutputFile(filename) self.output_filename = filename def finalize(self): """Performs finalization actions after the download completes.""" pass @staticmethod def RegisteredExporters(): """Returns a dictionary of the exporter instances that have been created.""" return dict(Exporter.__exporters) @staticmethod def RegisteredExporter(kind): """Returns an exporter instance for the given kind if it exists.""" return Exporter.__exporters[kind] class DumpExporter(Exporter): """An exporter which dumps protobuffers to a file.""" def __init__(self, kind, result_db_filename): self.kind = kind self.result_db_filename = result_db_filename def output_entities(self, entity_generator): shutil.copyfile(self.result_db_filename, self.output_filename) class MapperRetry(Error): """An exception that indicates a non-fatal error during mapping.""" class Mapper(object): """A base class for serializing datastore entities. To add a handler for exporting an entity kind from your datastore, write a subclass of this class that calls Mapper.__init__ from your class's __init__. You need to implement to batch_apply or apply method on your subclass for the map to do anything. """ __mappers = {} kind = None def __init__(self, kind): """Constructor. Populates this Mappers's kind. Args: kind: a string containing the entity kind that this mapper handles """ Validate(kind, basestring) self.kind = kind GetImplementationClass(kind) @staticmethod def RegisterMapper(mapper): """Register mapper and the Mapper instance for its kind. Args: mapper: A Mapper instance. """ Mapper.__mappers[mapper.kind] = mapper def initialize(self, mapper_opts): """Performs initialization. Args: mapper_opts: The string given as the --mapper_opts flag argument. """ pass def finalize(self): """Performs finalization actions after the download completes.""" pass def apply(self, entity): print 'Default map function doing nothing to %s' % entity def batch_apply(self, entities): for entity in entities: self.apply(entity) @staticmethod def RegisteredMappers(): """Returns a dictionary of the mapper instances that have been created.""" return dict(Mapper.__mappers) @staticmethod def RegisteredMapper(kind): """Returns an mapper instance for the given kind if it exists.""" return Mapper.__mappers[kind] class QueueJoinThread(threading.Thread): """A thread that joins a queue and exits. Queue joins do not have a timeout. To simulate a queue join with timeout, run this thread and join it with a timeout. """ def __init__(self, queue): """Initialize a QueueJoinThread. Args: queue: The queue for this thread to join. """ threading.Thread.__init__(self) assert isinstance(queue, (Queue.Queue, ReQueue)) self.queue = queue def run(self): """Perform the queue join in this thread.""" self.queue.join() def InterruptibleQueueJoin(queue, thread_local, thread_pool, queue_join_thread_factory=QueueJoinThread, check_workers=True): """Repeatedly joins the given ReQueue or Queue.Queue with short timeout. Between each timeout on the join, worker threads are checked. Args: queue: A Queue.Queue or ReQueue instance. thread_local: A threading.local instance which indicates interrupts. thread_pool: An AdaptiveThreadPool instance. queue_join_thread_factory: Used for dependency injection. check_workers: Whether to interrupt the join on worker death. Returns: True unless the queue join is interrupted by SIGINT or worker death. """ thread = queue_join_thread_factory(queue) thread.start() while True: thread.join(timeout=.5) if not thread.isAlive(): return True if thread_local.shut_down: logger.debug('Queue join interrupted') return False if check_workers: for worker_thread in thread_pool.Threads(): if not worker_thread.isAlive(): return False def ShutdownThreads(data_source_thread, thread_pool): """Shuts down the worker and data source threads. Args: data_source_thread: A running DataSourceThread instance. thread_pool: An AdaptiveThreadPool instance with workers registered. """ logger.info('An error occurred. Shutting down...') data_source_thread.exit_flag = True thread_pool.Shutdown() data_source_thread.join(timeout=3.0) if data_source_thread.isAlive(): logger.warn('%s hung while trying to exit', data_source_thread.GetFriendlyName()) class BulkTransporterApp(object): """Class to wrap bulk transport application functionality.""" def __init__(self, arg_dict, input_generator_factory, throttle, progress_db, progresstrackerthread_factory, max_queue_size=DEFAULT_QUEUE_SIZE, request_manager_factory=RequestManager, datasourcethread_factory=DataSourceThread, progress_queue_factory=Queue.Queue, thread_pool_factory=adaptive_thread_pool.AdaptiveThreadPool): """Instantiate a BulkTransporterApp. Uploads or downloads data to or from application using HTTP requests. When run, the class will spin up a number of threads to read entities from the data source, pass those to a number of worker threads for sending to the application, and track all of the progress in a small database in case an error or pause/termination requires a restart/resumption of the upload process. Args: arg_dict: Dictionary of command line options. input_generator_factory: A factory that creates a WorkItem generator. throttle: A Throttle instance. progress_db: The database to use for replaying/recording progress. progresstrackerthread_factory: Used for dependency injection. max_queue_size: Maximum size of the queues before they should block. request_manager_factory: Used for dependency injection. datasourcethread_factory: Used for dependency injection. progress_queue_factory: Used for dependency injection. thread_pool_factory: Used for dependency injection. """ self.app_id = arg_dict['app_id'] self.post_url = arg_dict['url'] self.kind = arg_dict['kind'] self.batch_size = arg_dict['batch_size'] self.input_generator_factory = input_generator_factory self.num_threads = arg_dict['num_threads'] self.email = arg_dict['email'] self.passin = arg_dict['passin'] self.dry_run = arg_dict['dry_run'] self.throttle = throttle self.progress_db = progress_db self.progresstrackerthread_factory = progresstrackerthread_factory self.max_queue_size = max_queue_size self.request_manager_factory = request_manager_factory self.datasourcethread_factory = datasourcethread_factory self.progress_queue_factory = progress_queue_factory self.thread_pool_factory = thread_pool_factory (scheme, self.host_port, self.url_path, unused_query, unused_fragment) = urlparse.urlsplit(self.post_url) self.secure = (scheme == 'https') def Run(self): """Perform the work of the BulkTransporterApp. Raises: AuthenticationError: If authentication is required and fails. Returns: Error code suitable for sys.exit, e.g. 0 on success, 1 on failure. """ self.error = False thread_pool = self.thread_pool_factory( self.num_threads, queue_size=self.max_queue_size) self.throttle.Register(threading.currentThread()) threading.currentThread().exit_flag = False progress_queue = self.progress_queue_factory(self.max_queue_size) request_manager = self.request_manager_factory(self.app_id, self.host_port, self.url_path, self.kind, self.throttle, self.batch_size, self.secure, self.email, self.passin, self.dry_run) try: request_manager.Authenticate() except Exception, e: self.error = True if not isinstance(e, urllib2.HTTPError) or ( e.code != 302 and e.code != 401): logger.exception('Exception during authentication') raise AuthenticationError() if (request_manager.auth_called and not request_manager.authenticated): self.error = True raise AuthenticationError('Authentication failed') for thread in thread_pool.Threads(): self.throttle.Register(thread) self.progress_thread = self.progresstrackerthread_factory( progress_queue, self.progress_db) if self.progress_db.UseProgressData(): logger.debug('Restarting upload using progress database') progress_generator_factory = self.progress_db.GetProgressStatusGenerator else: progress_generator_factory = None self.data_source_thread = ( self.datasourcethread_factory(request_manager, thread_pool, progress_queue, self.input_generator_factory, progress_generator_factory)) thread_local = threading.local() thread_local.shut_down = False def Interrupt(unused_signum, unused_frame): """Shutdown gracefully in response to a signal.""" thread_local.shut_down = True self.error = True signal.signal(signal.SIGINT, Interrupt) self.progress_thread.start() self.data_source_thread.start() while not thread_local.shut_down: self.data_source_thread.join(timeout=0.25) if self.data_source_thread.isAlive(): for thread in list(thread_pool.Threads()) + [self.progress_thread]: if not thread.isAlive(): logger.info('Unexpected thread death: %s', thread.getName()) thread_local.shut_down = True self.error = True break else: break def _Join(ob, msg): logger.debug('Waiting for %s...', msg) if isinstance(ob, threading.Thread): ob.join(timeout=3.0) if ob.isAlive(): logger.debug('Joining %s failed', ob) else: logger.debug('... done.') elif isinstance(ob, (Queue.Queue, ReQueue)): if not InterruptibleQueueJoin(ob, thread_local, thread_pool): ShutdownThreads(self.data_source_thread, thread_pool) else: ob.join() logger.debug('... done.') if self.data_source_thread.error or thread_local.shut_down: ShutdownThreads(self.data_source_thread, thread_pool) else: _Join(thread_pool.requeue, 'worker threads to finish') thread_pool.Shutdown() thread_pool.JoinThreads() thread_pool.CheckErrors() print '' if self.progress_thread.isAlive(): InterruptibleQueueJoin(progress_queue, thread_local, thread_pool, check_workers=False) else: logger.warn('Progress thread exited prematurely') progress_queue.put(_THREAD_SHOULD_EXIT) _Join(self.progress_thread, 'progress_thread to terminate') self.progress_thread.CheckError() if not thread_local.shut_down: self.progress_thread.WorkFinished() self.data_source_thread.CheckError() return self.ReportStatus() def ReportStatus(self): """Display a message reporting the final status of the transfer.""" raise NotImplementedError() class BulkUploaderApp(BulkTransporterApp): """Class to encapsulate bulk uploader functionality.""" def __init__(self, *args, **kwargs): BulkTransporterApp.__init__(self, *args, **kwargs) def ReportStatus(self): """Display a message reporting the final status of the transfer.""" total_up, duration = self.throttle.TotalTransferred( remote_api_throttle.BANDWIDTH_UP) s_total_up, unused_duration = self.throttle.TotalTransferred( remote_api_throttle.HTTPS_BANDWIDTH_UP) total_up += s_total_up total = total_up logger.info('%d entites total, %d previously transferred', self.data_source_thread.read_count, self.data_source_thread.xfer_count) transfer_count = self.progress_thread.EntitiesTransferred() logger.info('%d entities (%d bytes) transferred in %.1f seconds', transfer_count, total, duration) if (self.data_source_thread.read_all and transfer_count + self.data_source_thread.xfer_count >= self.data_source_thread.read_count): logger.info('All entities successfully transferred') return 0 else: logger.info('Some entities not successfully transferred') return 1 class BulkDownloaderApp(BulkTransporterApp): """Class to encapsulate bulk downloader functionality.""" def __init__(self, *args, **kwargs): BulkTransporterApp.__init__(self, *args, **kwargs) def ReportStatus(self): """Display a message reporting the final status of the transfer.""" total_down, duration = self.throttle.TotalTransferred( remote_api_throttle.BANDWIDTH_DOWN) s_total_down, unused_duration = self.throttle.TotalTransferred( remote_api_throttle.HTTPS_BANDWIDTH_DOWN) total_down += s_total_down total = total_down existing_count = self.progress_thread.existing_count xfer_count = self.progress_thread.EntitiesTransferred() logger.info('Have %d entities, %d previously transferred', xfer_count, existing_count) logger.info('%d entities (%d bytes) transferred in %.1f seconds', xfer_count, total, duration) if self.error: return 1 else: return 0 class BulkMapperApp(BulkTransporterApp): """Class to encapsulate bulk map functionality.""" def __init__(self, *args, **kwargs): BulkTransporterApp.__init__(self, *args, **kwargs) def ReportStatus(self): """Display a message reporting the final status of the transfer.""" total_down, duration = self.throttle.TotalTransferred( remote_api_throttle.BANDWIDTH_DOWN) s_total_down, unused_duration = self.throttle.TotalTransferred( remote_api_throttle.HTTPS_BANDWIDTH_DOWN) total_down += s_total_down total = total_down xfer_count = self.progress_thread.EntitiesTransferred() logger.info('The following may be inaccurate if any mapper tasks ' 'encountered errors and had to be retried.') logger.info('Applied mapper to %s entities.', xfer_count) logger.info('%s entities (%s bytes) transferred in %.1f seconds', xfer_count, total, duration) if self.error: return 1 else: return 0 def PrintUsageExit(code): """Prints usage information and exits with a status code. Args: code: Status code to pass to sys.exit() after displaying usage information. """ print __doc__ % {'arg0': sys.argv[0]} sys.stdout.flush() sys.stderr.flush() sys.exit(code) REQUIRED_OPTION = object() FLAG_SPEC = ['debug', 'help', 'url=', 'filename=', 'batch_size=', 'kind=', 'num_threads=', 'bandwidth_limit=', 'rps_limit=', 'http_limit=', 'db_filename=', 'app_id=', 'config_file=', 'has_header', 'csv_has_header', 'auth_domain=', 'result_db_filename=', 'download', 'loader_opts=', 'exporter_opts=', 'log_file=', 'mapper_opts=', 'email=', 'passin', 'map', 'dry_run', 'dump', 'restore', ] def ParseArguments(argv, die_fn=lambda: PrintUsageExit(1)): """Parses command-line arguments. Prints out a help message if -h or --help is supplied. Args: argv: List of command-line arguments. die_fn: Function to invoke to end the program. Returns: A dictionary containing the value of command-line options. """ opts, unused_args = getopt.getopt( argv[1:], 'h', FLAG_SPEC) arg_dict = {} arg_dict['url'] = REQUIRED_OPTION arg_dict['filename'] = None arg_dict['config_file'] = None arg_dict['kind'] = None arg_dict['batch_size'] = None arg_dict['num_threads'] = DEFAULT_THREAD_COUNT arg_dict['bandwidth_limit'] = DEFAULT_BANDWIDTH_LIMIT arg_dict['rps_limit'] = DEFAULT_RPS_LIMIT arg_dict['http_limit'] = DEFAULT_REQUEST_LIMIT arg_dict['db_filename'] = None arg_dict['app_id'] = '' arg_dict['auth_domain'] = 'gmail.com' arg_dict['has_header'] = False arg_dict['result_db_filename'] = None arg_dict['download'] = False arg_dict['loader_opts'] = None arg_dict['exporter_opts'] = None arg_dict['debug'] = False arg_dict['log_file'] = None arg_dict['email'] = None arg_dict['passin'] = False arg_dict['mapper_opts'] = None arg_dict['map'] = False arg_dict['dry_run'] = False arg_dict['dump'] = False arg_dict['restore'] = False def ExpandFilename(filename): """Expand shell variables and ~usernames in filename.""" return os.path.expandvars(os.path.expanduser(filename)) for option, value in opts: if option == '--debug': arg_dict['debug'] = True elif option in ('-h', '--help'): PrintUsageExit(0) elif option == '--url': arg_dict['url'] = value elif option == '--filename': arg_dict['filename'] = ExpandFilename(value) elif option == '--batch_size': arg_dict['batch_size'] = int(value) elif option == '--kind': arg_dict['kind'] = value elif option == '--num_threads': arg_dict['num_threads'] = int(value) elif option == '--bandwidth_limit': arg_dict['bandwidth_limit'] = int(value) elif option == '--rps_limit': arg_dict['rps_limit'] = int(value) elif option == '--http_limit': arg_dict['http_limit'] = int(value) elif option == '--db_filename': arg_dict['db_filename'] = ExpandFilename(value) elif option == '--app_id': arg_dict['app_id'] = value elif option == '--config_file': arg_dict['config_file'] = ExpandFilename(value) elif option == '--auth_domain': arg_dict['auth_domain'] = value elif option == '--has_header': arg_dict['has_header'] = True elif option == '--csv_has_header': print >>sys.stderr, ('--csv_has_header is deprecated, please use ' '--has_header.') arg_dict['has_header'] = True elif option == '--result_db_filename': arg_dict['result_db_filename'] = ExpandFilename(value) elif option == '--download': arg_dict['download'] = True elif option == '--loader_opts': arg_dict['loader_opts'] = value elif option == '--exporter_opts': arg_dict['exporter_opts'] = value elif option == '--log_file': arg_dict['log_file'] = ExpandFilename(value) elif option == '--email': arg_dict['email'] = value elif option == '--passin': arg_dict['passin'] = True elif option == '--map': arg_dict['map'] = True elif option == '--mapper_opts': arg_dict['mapper_opts'] = value elif option == '--dry_run': arg_dict['dry_run'] = True elif option == '--dump': arg_dict['dump'] = True elif option == '--restore': arg_dict['restore'] = True return ProcessArguments(arg_dict, die_fn=die_fn) def ThrottleLayout(bandwidth_limit, http_limit, rps_limit): """Return a dictionary indicating the throttle options.""" bulkloader_limits = dict(remote_api_throttle.NO_LIMITS) bulkloader_limits.update({ remote_api_throttle.BANDWIDTH_UP: bandwidth_limit, remote_api_throttle.BANDWIDTH_DOWN: bandwidth_limit, remote_api_throttle.REQUESTS: http_limit, remote_api_throttle.HTTPS_BANDWIDTH_UP: bandwidth_limit, remote_api_throttle.HTTPS_BANDWIDTH_DOWN: bandwidth_limit, remote_api_throttle.HTTPS_REQUESTS: http_limit, remote_api_throttle.ENTITIES_FETCHED: rps_limit, remote_api_throttle.ENTITIES_MODIFIED: rps_limit, }) return bulkloader_limits def CheckOutputFile(filename): """Check that the given file does not exist and can be opened for writing. Args: filename: The name of the file. Raises: FileExistsError: if the given filename is not found FileNotWritableError: if the given filename is not readable. """ full_path = os.path.abspath(filename) if os.path.exists(full_path): raise FileExistsError('%s: output file exists' % filename) elif not os.access(os.path.dirname(full_path), os.W_OK): raise FileNotWritableError( '%s: not writable' % os.path.dirname(full_path)) def LoadConfig(config_file_name, exit_fn=sys.exit): """Loads a config file and registers any Loader classes present. Args: config_file_name: The name of the configuration file. exit_fn: Used for dependency injection. """ if config_file_name: config_file = open(config_file_name, 'r') try: bulkloader_config = imp.load_module( 'bulkloader_config', config_file, config_file_name, ('', 'r', imp.PY_SOURCE)) sys.modules['bulkloader_config'] = bulkloader_config if hasattr(bulkloader_config, 'loaders'): for cls in bulkloader_config.loaders: Loader.RegisterLoader(cls()) if hasattr(bulkloader_config, 'exporters'): for cls in bulkloader_config.exporters: Exporter.RegisterExporter(cls()) if hasattr(bulkloader_config, 'mappers'): for cls in bulkloader_config.mappers: Mapper.RegisterMapper(cls()) except NameError, e: m = re.search(r"[^']*'([^']*)'.*", str(e)) if m.groups() and m.group(1) == 'Loader': print >>sys.stderr, """ The config file format has changed and you appear to be using an old-style config file. Please make the following changes: 1. At the top of the file, add this: from google.appengine.tools.bulkloader import Loader 2. For each of your Loader subclasses add the following at the end of the __init__ definitioion: self.alias_old_names() 3. At the bottom of the file, add this: loaders = [MyLoader1,...,MyLoaderN] Where MyLoader1,...,MyLoaderN are the Loader subclasses you want the bulkloader to have access to. """ exit_fn(1) else: raise except Exception, e: if isinstance(e, NameClashError) or 'bulkloader_config' in vars() and ( hasattr(bulkloader_config, 'bulkloader') and isinstance(e, bulkloader_config.bulkloader.NameClashError)): print >> sys.stderr, ( 'Found both %s and %s while aliasing old names on %s.'% (e.old_name, e.new_name, e.klass)) exit_fn(1) else: raise def GetArgument(kwargs, name, die_fn): """Get the value of the key name in kwargs, or die with die_fn. Args: kwargs: A dictionary containing the options for the bulkloader. name: The name of a bulkloader option. die_fn: The function to call to exit the program. Returns: The value of kwargs[name] is name in kwargs """ if name in kwargs: return kwargs[name] else: print >>sys.stderr, '%s argument required' % name die_fn() def _MakeSignature(app_id=None, url=None, kind=None, db_filename=None, perform_map=None, download=None, has_header=None, result_db_filename=None, dump=None, restore=None): """Returns a string that identifies the important options for the database.""" if download: result_db_line = 'result_db: %s' % result_db_filename else: result_db_line = '' return u""" app_id: %s url: %s kind: %s download: %s map: %s dump: %s restore: %s progress_db: %s has_header: %s %s """ % (app_id, url, kind, download, perform_map, dump, restore, db_filename, has_header, result_db_line) def ProcessArguments(arg_dict, die_fn=lambda: sys.exit(1)): """Processes non command-line input arguments. Args: arg_dict: Dictionary containing the values of bulkloader options. die_fn: Function to call in case of an error during argument processing. Returns: A dictionary of bulkloader options. """ app_id = GetArgument(arg_dict, 'app_id', die_fn) url = GetArgument(arg_dict, 'url', die_fn) dump = GetArgument(arg_dict, 'dump', die_fn) restore = GetArgument(arg_dict, 'restore', die_fn) filename = GetArgument(arg_dict, 'filename', die_fn) batch_size = GetArgument(arg_dict, 'batch_size', die_fn) kind = GetArgument(arg_dict, 'kind', die_fn) db_filename = GetArgument(arg_dict, 'db_filename', die_fn) config_file = GetArgument(arg_dict, 'config_file', die_fn) result_db_filename = GetArgument(arg_dict, 'result_db_filename', die_fn) download = GetArgument(arg_dict, 'download', die_fn) log_file = GetArgument(arg_dict, 'log_file', die_fn) perform_map = GetArgument(arg_dict, 'map', die_fn) errors = [] if batch_size is None: if download or perform_map: arg_dict['batch_size'] = DEFAULT_DOWNLOAD_BATCH_SIZE else: arg_dict['batch_size'] = DEFAULT_BATCH_SIZE elif batch_size <= 0: errors.append('batch_size must be at least 1') if db_filename is None: arg_dict['db_filename'] = time.strftime( 'bulkloader-progress-%Y%m%d.%H%M%S.sql3') if result_db_filename is None: arg_dict['result_db_filename'] = time.strftime( 'bulkloader-results-%Y%m%d.%H%M%S.sql3') if log_file is None: arg_dict['log_file'] = time.strftime('bulkloader-log-%Y%m%d.%H%M%S') required = '%s argument required' if config_file is None and not dump and not restore: errors.append('One of --config_file, --dump, or --restore is required') if url is REQUIRED_OPTION: errors.append(required % 'url') if not filename and not perform_map: errors.append(required % 'filename') if kind is None: if download or map: errors.append('kind argument required for this operation') elif not dump and not restore: errors.append( 'kind argument required unless --dump or --restore is specified') if not app_id: if url and url is not REQUIRED_OPTION: (unused_scheme, host_port, unused_url_path, unused_query, unused_fragment) = urlparse.urlsplit(url) suffix_idx = host_port.find('.appspot.com') if suffix_idx > -1: arg_dict['app_id'] = host_port[:suffix_idx] elif host_port.split(':')[0].endswith('google.com'): arg_dict['app_id'] = host_port.split('.')[0] else: errors.append('app_id argument required for non appspot.com domains') if errors: print >>sys.stderr, '\n'.join(errors) die_fn() return arg_dict def ParseKind(kind): if kind and kind[0] == '(' and kind[-1] == ')': return tuple(kind[1:-1].split(',')) else: return kind def _PerformBulkload(arg_dict, check_file=CheckFile, check_output_file=CheckOutputFile): """Runs the bulkloader, given the command line options. Args: arg_dict: Dictionary of bulkloader options. check_file: Used for dependency injection. check_output_file: Used for dependency injection. Returns: An exit code. Raises: ConfigurationError: if inconsistent options are passed. """ app_id = arg_dict['app_id'] url = arg_dict['url'] filename = arg_dict['filename'] batch_size = arg_dict['batch_size'] kind = arg_dict['kind'] num_threads = arg_dict['num_threads'] bandwidth_limit = arg_dict['bandwidth_limit'] rps_limit = arg_dict['rps_limit'] http_limit = arg_dict['http_limit'] db_filename = arg_dict['db_filename'] config_file = arg_dict['config_file'] auth_domain = arg_dict['auth_domain'] has_header = arg_dict['has_header'] download = arg_dict['download'] result_db_filename = arg_dict['result_db_filename'] loader_opts = arg_dict['loader_opts'] exporter_opts = arg_dict['exporter_opts'] mapper_opts = arg_dict['mapper_opts'] email = arg_dict['email'] passin = arg_dict['passin'] perform_map = arg_dict['map'] dump = arg_dict['dump'] restore = arg_dict['restore'] os.environ['AUTH_DOMAIN'] = auth_domain kind = ParseKind(kind) if not dump and not restore: check_file(config_file) if download and perform_map: logger.error('--download and --map are mutually exclusive.') if download or dump: check_output_file(filename) elif not perform_map: check_file(filename) if dump: Exporter.RegisterExporter(DumpExporter(kind, result_db_filename)) elif restore: Loader.RegisterLoader(RestoreLoader(kind, app_id)) else: LoadConfig(config_file) os.environ['APPLICATION_ID'] = app_id throttle_layout = ThrottleLayout(bandwidth_limit, http_limit, rps_limit) logger.info('Throttling transfers:') logger.info('Bandwidth: %s bytes/second', bandwidth_limit) logger.info('HTTP connections: %s/second', http_limit) logger.info('Entities inserted/fetched/modified: %s/second', rps_limit) throttle = remote_api_throttle.Throttle(layout=throttle_layout) signature = _MakeSignature(app_id=app_id, url=url, kind=kind, db_filename=db_filename, download=download, perform_map=perform_map, has_header=has_header, result_db_filename=result_db_filename, dump=dump, restore=restore) max_queue_size = max(DEFAULT_QUEUE_SIZE, 3 * num_threads + 5) if db_filename == 'skip': progress_db = StubProgressDatabase() elif not download and not perform_map and not dump: progress_db = ProgressDatabase(db_filename, signature) else: progress_db = ExportProgressDatabase(db_filename, signature) return_code = 1 if not download and not perform_map and not dump: loader = Loader.RegisteredLoader(kind) try: loader.initialize(filename, loader_opts) workitem_generator_factory = GetCSVGeneratorFactory( kind, filename, batch_size, has_header) app = BulkUploaderApp(arg_dict, workitem_generator_factory, throttle, progress_db, ProgressTrackerThread, max_queue_size, RequestManager, DataSourceThread, Queue.Queue) try: return_code = app.Run() except AuthenticationError: logger.info('Authentication Failed') finally: loader.finalize() elif not perform_map: result_db = ResultDatabase(result_db_filename, signature) exporter = Exporter.RegisteredExporter(kind) try: exporter.initialize(filename, exporter_opts) def KeyRangeGeneratorFactory(request_manager, progress_queue, progress_gen): return KeyRangeItemGenerator(request_manager, kind, progress_queue, progress_gen, DownloadItem) def ExportProgressThreadFactory(progress_queue, progress_db): return ExportProgressThread(kind, progress_queue, progress_db, result_db) app = BulkDownloaderApp(arg_dict, KeyRangeGeneratorFactory, throttle, progress_db, ExportProgressThreadFactory, 0, RequestManager, DataSourceThread, Queue.Queue) try: return_code = app.Run() except AuthenticationError: logger.info('Authentication Failed') finally: exporter.finalize() elif not download: mapper = Mapper.RegisteredMapper(kind) try: mapper.initialize(mapper_opts) def KeyRangeGeneratorFactory(request_manager, progress_queue, progress_gen): return KeyRangeItemGenerator(request_manager, kind, progress_queue, progress_gen, MapperItem) def MapperProgressThreadFactory(progress_queue, progress_db): return MapperProgressThread(kind, progress_queue, progress_db) app = BulkMapperApp(arg_dict, KeyRangeGeneratorFactory, throttle, progress_db, MapperProgressThreadFactory, 0, RequestManager, DataSourceThread, Queue.Queue) try: return_code = app.Run() except AuthenticationError: logger.info('Authentication Failed') finally: mapper.finalize() return return_code def SetupLogging(arg_dict): """Sets up logging for the bulkloader. Args: arg_dict: Dictionary mapping flag names to their arguments. """ format = '[%(levelname)-8s %(asctime)s %(filename)s] %(message)s' debug = arg_dict['debug'] log_file = arg_dict['log_file'] logger.setLevel(logging.DEBUG) logger.propagate = False file_handler = logging.FileHandler(log_file, 'w') file_handler.setLevel(logging.DEBUG) file_formatter = logging.Formatter(format) file_handler.setFormatter(file_formatter) logger.addHandler(file_handler) console = logging.StreamHandler() level = logging.INFO if debug: level = logging.DEBUG console.setLevel(level) console_format = '[%(levelname)-8s] %(message)s' formatter = logging.Formatter(console_format) console.setFormatter(formatter) logger.addHandler(console) logger.info('Logging to %s', log_file) remote_api_throttle.logger.setLevel(level) remote_api_throttle.logger.addHandler(file_handler) remote_api_throttle.logger.addHandler(console) appengine_rpc.logger.setLevel(logging.WARN) adaptive_thread_pool.logger.setLevel(logging.DEBUG) adaptive_thread_pool.logger.addHandler(console) adaptive_thread_pool.logger.addHandler(file_handler) adaptive_thread_pool.logger.propagate = False def Run(arg_dict): """Sets up and runs the bulkloader, given the options as keyword arguments. Args: arg_dict: Dictionary of bulkloader options Returns: An exit code. """ arg_dict = ProcessArguments(arg_dict) SetupLogging(arg_dict) return _PerformBulkload(arg_dict) def main(argv): """Runs the importer from the command line.""" arg_dict = ParseArguments(argv) errors = ['%s argument required' % key for (key, value) in arg_dict.iteritems() if value is REQUIRED_OPTION] if errors: print >>sys.stderr, '\n'.join(errors) PrintUsageExit(1) SetupLogging(arg_dict) return _PerformBulkload(arg_dict) if __name__ == '__main__': sys.exit(main(sys.argv))
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 10219, 4475, 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, 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, 624, 32447, 666, 1806, 3101, 14, 199, 199, 7692, 26, 523, 2818, 1273, 16, 9, 83, 359, 2469, 61, 339, 1553, 1757, 463, 12968, 10201, 2556, 14, 334, 7012, 9, 272, 1553, 571, 63, 344, 18987, 875, 30, 755, 13515, 2870, 402, 6037, 334, 7012, 367, 1169, 23588, 571, 15185, 14, 957, 9, 272, 1553, 1178, 63, 2261, 18987, 2261, 30, 221, 710, 1790, 2881, 370, 675, 367, 2050, 315, 436, 367, 1169, 2876, 8516, 14, 334, 2698, 26, 29712, 14, 957, 9, 272, 1553, 18358, 63, 3097, 18987, 442, 30, 710, 5696, 1329, 402, 2783, 1126, 3499, 367, 314, 1169, 9531, 9307, 402, 666, 370, 314, 1654, 14, 699, 300, 10329, 1169, 1443, 24068, 642, 12, 1325, 20347, 9307, 6634, 365, 1169, 15297, 370, 642, 6634, 14, 334, 2698, 5661, 993, 9, 272, 1553, 2912, 63, 890, 18987, 442, 30, 420, 4860, 402, 17680, 2251, 370, 2387, 315, 1924, 2963, 370, 1169, 314, 2851, 6037, 14, 710, 1655, 666, 1126, 1962, 15, 7302, 12, 314, 1169, 12700, 314, 3522, 1568, 1077, 506, 14, 334, 2698, 1616, 9, 272, 1553, 888, 63, 493, 18987, 515, 30, 259, 3814, 3035, 5822, 436, 22865, 10269, 14, 1169, 334, 8030, 7444, 1553, 2724, 503, 1553, 8011, 787, 1202, 9, 272, 1553, 697, 63, 1501, 18987, 515, 30, 259, 20411, 6696, 3050, 370, 2218, 370, 12, 503, 370, 1169, 14604, 687, 14, 982, 440, 6841, 12, 2066, 282, 892, 3050, 1169, 911, 506, 8239, 12, 4310, 26, 1169, 13137, 3422, 13, 5734, 13, 20277, 14, 1169, 710, 4539, 1788, 298, 2759, 2, 1443, 506, 1202, 370, 9329, 1169, 3372, 7664, 15, 14827, 1263, 6696, 2556, 14, 272, 1553, 4249, 4519, 20220, 9045, 370, 282, 570, 14, 272, 1553, 10481, 63, 1065, 5185, 4226, 440, 5341, 1263, 3982, 63, 1246, 4882, 14, 272, 1553, 2724, 8295, 3645, 4697, 13, 4758, 5461, 1475, 14, 272, 1553, 2123, 18987, 875, 30, 263, 710, 3434, 370, 675, 14, 12823, 8457, 340, 11684, 14, 272, 1553, 30305, 63, 3291, 18987, 875, 30, 1169, 437, 1059, 370, 986, 370, 314, 7910, 3968, 14, 8489, 1083, 14, 272, 1553, 1501, 18987, 515, 30, 755, 6912, 370, 314, 570, 370, 492, 14, 334, 8030, 9, 272, 1553, 1989, 63, 1291, 3322, 8232, 314, 1642, 1962, 402, 314, 1324, 14, 272, 1553, 1014, 63, 3097, 18987, 442, 30, 420, 710, 5696, 10330, 82, 402, 3101, 4145, 1126, 3499, 370, 1169, 3222, 370, 314, 1654, 14, 334, 2698, 26, 1695, 9, 272, 1553, 5091, 18987, 875, 30, 260, 2812, 402, 314, 17680, 909, 4928, 370, 5324, 315, 314, 1169, 12007, 14, 334, 8030, 9, 272, 1553, 3422, 63, 3291, 18987, 875, 30, 221, 437, 1059, 370, 986, 370, 314, 22865, 14, 8489, 1083, 14, 272, 1553, 793, 63, 493, 18987, 515, 30, 755, 3814, 370, 2218, 13137, 3422, 9610, 14, 221, 982, 440, 6841, 1169, 2066, 282, 892, 943, 570, 911, 506, 2737, 12, 4310, 26, 1169, 13137, 3422, 13, 793, 13, 20277, 14, 272, 1553, 1130, 7861, 9672, 376, 1595, 9371, 12007, 9045, 14, 272, 1553, 7153, 63, 3291, 18987, 875, 30, 221, 437, 1059, 370, 986, 370, 314, 9672, 529, 14, 9345, 1083, 14, 272, 1553, 1507, 63, 6962, 18987, 442, 30, 258, 4860, 402, 7183, 370, 675, 367, 24349, 9045, 1169, 334, 2698, 1616, 9, 272, 1553, 1529, 262, 4483, 5574, 314, 4676, 2505, 687, 9009, 14, 272, 1553, 8011, 5185, 22379, 687, 4697, 13, 4758, 5461, 1475, 14, 272, 1553, 1099, 63, 697, 63, 1501, 18987, 515, 30, 1169, 10695, 3050, 370, 2218, 370, 367, 28242, 14, 272, 1553, 82, 1190, 63, 3097, 18987, 442, 30, 755, 710, 5696, 1329, 402, 5767, 1126, 3499, 370, 1169, 9307, 370, 314, 1654, 14, 334, 2698, 26, 3388, 9, 272, 1553, 633, 18987, 875, 30, 3515, 2851, 6037, 370, 2963, 370, 367, 16306, 666, 14, 1169, 334, 8030, 9, 199, 199, 1918, 4458, 2004, 911, 506, 378, 641, 3182, 12, 2222, 13, 4262, 641, 492, 5988, 14, 199, 199, 25348, 543, 314, 3982, 63, 1246, 13667, 13, 262, 3555, 367, 6233, 14, 15358, 14, 832, 14, 3846, 63, 1246, 14, 199, 8254, 3648, 2337, 367, 3794, 3595, 4212, 370, 3272, 314, 1654, 5366, 14, 199, 199, 9846, 26, 199, 199, 2840, 1273, 16, 9, 83, 1553, 633, 29, 1014, 921, 571, 14, 571, 15185, 14, 957, 15, 3846, 63, 1246, 1553, 5091, 29, 1685, 971, 199, 1553, 1501, 29, 576, 14, 4737, 1553, 888, 63, 493, 29, 3422, 63, 888, 14, 647, 199, 199, 624, 4388, 199, 646, 7392, 199, 646, 7554, 199, 646, 12733, 199, 646, 18354, 199, 646, 1742, 199, 646, 2050, 199, 646, 747, 199, 646, 10703, 199, 646, 295, 199, 646, 5145, 199, 646, 4673, 199, 646, 5228, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 646, 5190, 199, 646, 4011, 18, 199, 646, 7097, 199, 199, 504, 6233, 14, 15358, 14, 11450, 492, 4642, 63, 3317, 199, 199, 504, 6233, 14, 15358, 14, 1246, 492, 2986, 3280, 63, 5811, 63, 1130, 199, 504, 6233, 14, 15358, 14, 1246, 492, 12007, 199, 504, 6233, 14, 15358, 14, 1246, 492, 12007, 63, 2550, 199, 504, 6233, 14, 15358, 14, 11450, 492, 12007, 63, 3317, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 199, 504, 6233, 14, 15358, 14, 832, 492, 790 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 10219, 4475, 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, 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, 624, 32447, 666, 1806, 3101, 14, 199, 199, 7692, 26, 523, 2818, 1273, 16, 9, 83, 359, 2469, 61, 339, 1553, 1757, 463, 12968, 10201, 2556, 14, 334, 7012, 9, 272, 1553, 571, 63, 344, 18987, 875, 30, 755, 13515, 2870, 402, 6037, 334, 7012, 367, 1169, 23588, 571, 15185, 14, 957, 9, 272, 1553, 1178, 63, 2261, 18987, 2261, 30, 221, 710, 1790, 2881, 370, 675, 367, 2050, 315, 436, 367, 1169, 2876, 8516, 14, 334, 2698, 26, 29712, 14, 957, 9, 272, 1553, 18358, 63, 3097, 18987, 442, 30, 710, 5696, 1329, 402, 2783, 1126, 3499, 367, 314, 1169, 9531, 9307, 402, 666, 370, 314, 1654, 14, 699, 300, 10329, 1169, 1443, 24068, 642, 12, 1325, 20347, 9307, 6634, 365, 1169, 15297, 370, 642, 6634, 14, 334, 2698, 5661, 993, 9, 272, 1553, 2912, 63, 890, 18987, 442, 30, 420, 4860, 402, 17680, 2251, 370, 2387, 315, 1924, 2963, 370, 1169, 314, 2851, 6037, 14, 710, 1655, 666, 1126, 1962, 15, 7302, 12, 314, 1169, 12700, 314, 3522, 1568, 1077, 506, 14, 334, 2698, 1616, 9, 272, 1553, 888, 63, 493, 18987, 515, 30, 259, 3814, 3035, 5822, 436, 22865, 10269, 14, 1169, 334, 8030, 7444, 1553, 2724, 503, 1553, 8011, 787, 1202, 9, 272, 1553, 697, 63, 1501, 18987, 515, 30, 259, 20411, 6696, 3050, 370, 2218, 370, 12, 503, 370, 1169, 14604, 687, 14, 982, 440, 6841, 12, 2066, 282, 892, 3050, 1169, 911, 506, 8239, 12, 4310, 26, 1169, 13137, 3422, 13, 5734, 13, 20277, 14, 1169, 710, 4539, 1788, 298, 2759, 2, 1443, 506, 1202, 370, 9329, 1169, 3372, 7664, 15, 14827, 1263, 6696, 2556, 14, 272, 1553, 4249, 4519, 20220, 9045, 370, 282, 570, 14, 272, 1553, 10481, 63, 1065, 5185, 4226, 440, 5341, 1263, 3982, 63, 1246, 4882, 14, 272, 1553, 2724, 8295, 3645, 4697, 13, 4758, 5461, 1475, 14, 272, 1553, 2123, 18987, 875, 30, 263, 710, 3434, 370, 675, 14, 12823, 8457, 340, 11684, 14, 272, 1553, 30305, 63, 3291, 18987, 875, 30, 1169, 437, 1059, 370, 986, 370, 314, 7910, 3968, 14, 8489, 1083, 14, 272, 1553, 1501, 18987, 515, 30, 755, 6912, 370, 314, 570, 370, 492, 14, 334, 8030, 9, 272, 1553, 1989, 63, 1291, 3322, 8232, 314, 1642, 1962, 402, 314, 1324, 14, 272, 1553, 1014, 63, 3097, 18987, 442, 30, 420, 710, 5696, 10330, 82, 402, 3101, 4145, 1126, 3499, 370, 1169, 3222, 370, 314, 1654, 14, 334, 2698, 26, 1695, 9, 272, 1553, 5091, 18987, 875, 30, 260, 2812, 402, 314, 17680, 909, 4928, 370, 5324, 315, 314, 1169, 12007, 14, 334, 8030, 9, 272, 1553, 3422, 63, 3291, 18987, 875, 30, 221, 437, 1059, 370, 986, 370, 314, 22865, 14, 8489, 1083, 14, 272, 1553, 793, 63, 493, 18987, 515, 30, 755, 3814, 370, 2218, 13137, 3422, 9610, 14, 221, 982, 440, 6841, 1169, 2066, 282, 892, 943, 570, 911, 506, 2737, 12, 4310, 26, 1169, 13137, 3422, 13, 793, 13, 20277, 14, 272, 1553, 1130, 7861, 9672, 376, 1595, 9371, 12007, 9045, 14, 272, 1553, 7153, 63, 3291, 18987, 875, 30, 221, 437, 1059, 370, 986, 370, 314, 9672, 529, 14, 9345, 1083, 14, 272, 1553, 1507, 63, 6962, 18987, 442, 30, 258, 4860, 402, 7183, 370, 675, 367, 24349, 9045, 1169, 334, 2698, 1616, 9, 272, 1553, 1529, 262, 4483, 5574, 314, 4676, 2505, 687, 9009, 14, 272, 1553, 8011, 5185, 22379, 687, 4697, 13, 4758, 5461, 1475, 14, 272, 1553, 1099, 63, 697, 63, 1501, 18987, 515, 30, 1169, 10695, 3050, 370, 2218, 370, 367, 28242, 14, 272, 1553, 82, 1190, 63, 3097, 18987, 442, 30, 755, 710, 5696, 1329, 402, 5767, 1126, 3499, 370, 1169, 9307, 370, 314, 1654, 14, 334, 2698, 26, 3388, 9, 272, 1553, 633, 18987, 875, 30, 3515, 2851, 6037, 370, 2963, 370, 367, 16306, 666, 14, 1169, 334, 8030, 9, 199, 199, 1918, 4458, 2004, 911, 506, 378, 641, 3182, 12, 2222, 13, 4262, 641, 492, 5988, 14, 199, 199, 25348, 543, 314, 3982, 63, 1246, 13667, 13, 262, 3555, 367, 6233, 14, 15358, 14, 832, 14, 3846, 63, 1246, 14, 199, 8254, 3648, 2337, 367, 3794, 3595, 4212, 370, 3272, 314, 1654, 5366, 14, 199, 199, 9846, 26, 199, 199, 2840, 1273, 16, 9, 83, 1553, 633, 29, 1014, 921, 571, 14, 571, 15185, 14, 957, 15, 3846, 63, 1246, 1553, 5091, 29, 1685, 971, 199, 1553, 1501, 29, 576, 14, 4737, 1553, 888, 63, 493, 29, 3422, 63, 888, 14, 647, 199, 199, 624, 4388, 199, 646, 7392, 199, 646, 7554, 199, 646, 12733, 199, 646, 18354, 199, 646, 1742, 199, 646, 2050, 199, 646, 747, 199, 646, 10703, 199, 646, 295, 199, 646, 5145, 199, 646, 4673, 199, 646, 5228, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 646, 5190, 199, 646, 4011, 18, 199, 646, 7097, 199, 199, 504, 6233, 14, 15358, 14, 11450, 492, 4642, 63, 3317, 199, 199, 504, 6233, 14, 15358, 14, 1246, 492, 2986, 3280, 63, 5811, 63, 1130, 199, 504, 6233, 14, 15358, 14, 1246, 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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 ]
adieu/allbuttonspressed
docutils/parsers/rst/languages/eo.py
6
3808
# $Id: eo.py 6460 2010-10-29 22:18:44Z milde $ # Author: Marcelo Huerta San Martin <richieadler@users.sourceforge.net> # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please # read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. """ Esperanto-language mappings for language-dependent features of reStructuredText. """ __docformat__ = 'reStructuredText' directives = { # language-dependent: fixed u'atentu': 'attention', u'zorgu': 'caution', u'dangxero': 'danger', u'dan\u011dero': 'danger', u'eraro': 'error', u'spuro': 'hint', u'grava': 'important', u'noto': 'note', u'helpeto': 'tip', u'averto': 'warning', u'admono': 'admonition', u'flankteksto': 'sidebar', u'temo': 'topic', u'linea-bloko': 'line-block', u'analizota-literalo': 'parsed-literal', u'rubriko': 'rubric', u'epigrafo': 'epigraph', u'elstarajxoj': 'highlights', u'elstara\u0135oj': 'highlights', u'ekstera-citajxo': 'pull-quote', u'ekstera-cita\u0135o': 'pull-quote', u'kombinajxo': 'compound', u'kombina\u0135o': 'compound', u'tekstingo': 'container', u'enhavilo': 'container', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', u'tabelo': 'table', u'tabelo-vdk': 'csv-table', # "valoroj disigitaj per komoj" u'tabelo-csv': 'csv-table', u'tabelo-lista': 'list-table', u'meta': 'meta', 'math (translation required)': 'math', #'imagemap': 'imagemap', u'bildo': 'image', u'figuro': 'figure', u'inkludi': 'include', u'senanaliza': 'raw', u'anstatauxi': 'replace', u'anstata\u016di': 'replace', u'unicode': 'unicode', u'dato': 'date', u'klaso': 'class', u'rolo': 'role', u'preterlasita-rolo': 'default-role', u'titolo': 'title', u'enhavo': 'contents', u'seknum': 'sectnum', u'sekcia-numerado': 'sectnum', u'kapsekcio': 'header', u'piedsekcio': 'footer', #'footnotes': 'footnotes', #'citations': 'citations', u'celaj-notoj': 'target-notes', u'restructuredtext-test-directive': 'restructuredtext-test-directive'} """Esperanto name to registered (in directives/__init__.py) directive name mapping.""" roles = { # language-dependent: fixed u'mallongigo': 'abbreviation', u'mall': 'abbreviation', u'komenclitero': 'acronym', u'kl': 'acronym', u'indekso': 'index', u'i': 'index', u'subskribo': 'subscript', u'sub': 'subscript', u'supraskribo': 'superscript', u'sup': 'superscript', u'titola-referenco': 'title-reference', u'titolo': 'title-reference', u't': 'title-reference', u'pep-referenco': 'pep-reference', u'pep': 'pep-reference', u'rfc-referenco': 'rfc-reference', u'rfc': 'rfc-reference', u'emfazo': 'emphasis', u'forta': 'strong', u'litera': 'literal', 'math (translation required)': 'math', u'nomita-referenco': 'named-reference', u'nenomita-referenco': 'anonymous-reference', u'piednota-referenco': 'footnote-reference', u'citajxo-referenco': 'citation-reference', u'cita\u0135o-referenco': 'citation-reference', u'anstatauxa-referenco': 'substitution-reference', u'anstata\u016da-referenco': 'substitution-reference', u'celo': 'target', u'uri-referenco': 'uri-reference', u'uri': 'uri-reference', u'url': 'uri-reference', u'senanaliza': 'raw', } """Mapping of Esperanto role names to canonical role names for interpreted text. """
bsd-3-clause
[ 3, 2672, 1304, 26, 28545, 14, 647, 5049, 2259, 7129, 13, 709, 13, 1398, 6928, 26, 1085, 26, 1602, 58, 333, 24446, 2672, 199, 3, 6529, 26, 16794, 301, 320, 869, 14262, 502, 29359, 603, 26788, 665, 10399, 1873, 350, 1435, 32, 3707, 14, 22943, 14, 846, 30, 199, 3, 1898, 26, 961, 859, 965, 2757, 15090, 315, 314, 4575, 2881, 14, 199, 199, 3, 7053, 2637, 13546, 787, 336, 14628, 14, 221, 21467, 9689, 282, 892, 7761, 12, 8749, 199, 3, 1586, 665, 1014, 921, 27114, 14, 7646, 14, 846, 15, 4757, 15, 21232, 15, 73, 1085, 78, 14, 1360, 10827, 221, 16853, 1584, 1471, 506, 199, 3, 14598, 367, 1924, 2637, 26, 1373, 315, 18382, 15, 13209, 12, 314, 1163, 315, 199, 3, 18382, 15, 11531, 15, 8332, 15, 13209, 14, 199, 199, 624, 199, 21658, 529, 290, 475, 13, 3671, 13546, 367, 2637, 13, 7106, 4534, 402, 199, 264, 27486, 1872, 14, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 7, 421, 199, 23216, 275, 469, 489, 327, 2637, 13, 7106, 26, 6317, 489, 399, 7, 323, 343, 85, 356, 283, 22393, 297, 489, 399, 7, 90, 1308, 85, 356, 283, 696, 2206, 297, 489, 399, 5121, 621, 88, 3478, 356, 283, 68, 12974, 297, 489, 399, 5121, 290, 60, 85, 13059, 271, 293, 356, 283, 68, 12974, 297, 489, 399, 7, 281, 285, 79, 356, 283, 705, 297, 489, 399, 1159, 3165, 293, 356, 283, 6479, 297, 489, 399, 7, 926, 3042, 356, 283, 19559, 297, 489, 399, 7, 1397, 79, 356, 283, 4610, 297, 489, 399, 7, 30586, 321, 475, 356, 283, 8996, 297, 489, 399, 7, 28396, 475, 356, 283, 3764, 297, 489, 399, 7, 350, 19758, 356, 283, 350, 31722, 297, 489, 399, 7, 70, 1983, 266, 75, 14308, 356, 283, 27372, 297, 489, 399, 1133, 69, 573, 356, 283, 5746, 297, 489, 399, 7, 604, 65, 13, 25913, 7697, 356, 283, 604, 13, 1457, 297, 489, 399, 7, 290, 279, 565, 12041, 13, 8939, 79, 356, 283, 6751, 13, 8939, 297, 489, 399, 7, 82, 456, 322, 7697, 356, 283, 21586, 297, 489, 399, 7, 1545, 528, 345, 545, 356, 283, 1545, 528, 3255, 297, 489, 399, 7, 352, 7848, 9091, 15987, 74, 356, 283, 14337, 83, 297, 489, 399, 7, 352, 7848, 65, 60, 85, 614, 1276, 79, 74, 356, 283, 14337, 83, 297, 489, 399, 7, 5711, 1597, 345, 13, 14422, 9091, 15987, 356, 283, 9302, 13, 3513, 297, 489, 399, 7, 5711, 1597, 345, 13, 14422, 65, 60, 85, 614, 1276, 79, 356, 283, 9302, 13, 3513, 297, 489, 399, 7, 75, 676, 1393, 9091, 15987, 356, 283, 15278, 297, 489, 399, 7, 75, 676, 1393, 65, 60, 85, 614, 1276, 79, 356, 283, 15278, 297, 489, 399, 1133, 5711, 270, 316, 79, 356, 283, 3600, 297, 489, 399, 7, 287, 4425, 320, 356, 283, 3600, 297, 489, 17384, 16069, 356, 283, 16069, 297, 489, 17384, 7096, 356, 283, 16069, 297, 489, 17384, 667, 81, 356, 283, 16069, 297, 489, 399, 1133, 7570, 320, 356, 283, 1224, 297, 489, 399, 1133, 7570, 320, 13, 86, 6341, 356, 283, 4737, 13, 1224, 297, 327, 298, 637, 269, 79, 74, 487, 338, 3187, 9091, 1126, 20817, 573, 74, 2, 489, 399, 1133, 7570, 320, 13, 4737, 356, 283, 4737, 13, 1224, 297, 489, 399, 1133, 7570, 320, 13, 513, 65, 356, 283, 513, 13, 1224, 297, 489, 399, 6704, 1841, 356, 283, 2024, 297, 489, 283, 3442, 334, 6893, 1415, 11862, 283, 3442, 297, 489, 17384, 1569, 1130, 356, 283, 1569, 1130, 297, 489, 399, 7, 66, 668, 79, 356, 283, 1569, 297, 489, 399, 7, 592, 9129, 356, 283, 8941, 297, 489, 399, 7, 2292, 10836, 328, 356, 283, 2613, 297, 489, 399, 1159, 287, 290, 279, 565, 65, 356, 283, 1773, 297, 489, 399, 7, 290, 270, 419, 2521, 73, 356, 283, 1814, 297, 489, 399, 7, 290, 270, 419, 60, 85, 10882, 328, 356, 283, 1814, 297, 489, 399, 7, 2975, 356, 283, 2975, 297, 489, 399, 5121, 11318, 356, 283, 602, 297, 489, 399, 7, 9503, 305, 79, 356, 283, 533, 297, 489, 399, 7, 293, 320, 356, 283, 3756, 297, 489, 399, 7, 26499, 12536, 21492, 13, 293, 320, 356, 283, 885, 13, 3756, 297, 489, 399, 1133, 24308, 320, 356, 283, 1213, 297, 489, 399, 7, 287, 72, 1214, 79, 356, 283, 4407, 297, 489, 399, 1159, 5711, 1507, 356, 283, 8519, 1507, 297, 489, 399, 1159, 5711, 16521, 13, 10563, 345, 1117, 356, 283, 8519, 1507, 297, 489, 399, 7, 75, 19111, 75, 10377, 356, 283, 1291, 297, 489, 399, 7, 1038, 379, 261, 75, 10377, 356, 283, 12781, 297, 489, 17384, 11407, 5983, 356, 283, 11407, 5983, 297, 489, 17384, 14422, 1298, 356, 283, 14422, 1298, 297, 489, 399, 7, 301, 416, 74, 13, 1397, 79, 74, 356, 283, 1375, 13, 5983, 297, 489, 399, 3984, 26305, 13, 396, 13, 15047, 356, 283, 26854, 13, 396, 13, 15047, 936, 199, 624, 21658, 529, 290, 475, 536, 370, 7264, 334, 262, 13502, 22128, 826, 4343, 647, 9, 13613, 536, 199, 4745, 1041, 199, 199, 8050, 275, 469, 272, 327, 2637, 13, 7106, 26, 6317, 272, 399, 6704, 452, 951, 528, 79, 356, 283, 371, 30369, 297, 272, 399, 6704, 452, 356, 283, 371, 30369, 297, 272, 399, 7, 75, 1377, 78, 2764, 24208, 356, 283, 645, 2641, 12828, 297, 272, 399, 7, 9503, 356, 283, 645, 2641, 12828, 297, 272, 399, 7, 262, 271, 75, 1152, 356, 283, 1080, 297, 272, 399, 7, 73, 356, 283, 1080, 297, 272, 399, 1159, 456, 1339, 322, 656, 356, 283, 30907, 297, 272, 399, 1159, 456, 356, 283, 30907, 297, 272, 399, 1159, 384, 82, 813, 322, 656, 356, 283, 4792, 1579, 297, 272, 399, 1159, 384, 356, 283, 4792, 1579, 297, 272, 399, 1133, 390, 22205, 13, 264, 1485, 331, 356, 283, 1213, 13, 4443, 297, 272, 399, 1133, 24308, 320, 356, 283, 1213, 13, 4443, 297, 272, 399, 1133, 356, 283, 1213, 13, 4443, 297, 272, 399, 7, 12636, 13, 264, 1485, 331, 356, 283, 12636, 13, 4443, 297, 272, 399, 7, 12636, 356, 283 ]
[ 2672, 1304, 26, 28545, 14, 647, 5049, 2259, 7129, 13, 709, 13, 1398, 6928, 26, 1085, 26, 1602, 58, 333, 24446, 2672, 199, 3, 6529, 26, 16794, 301, 320, 869, 14262, 502, 29359, 603, 26788, 665, 10399, 1873, 350, 1435, 32, 3707, 14, 22943, 14, 846, 30, 199, 3, 1898, 26, 961, 859, 965, 2757, 15090, 315, 314, 4575, 2881, 14, 199, 199, 3, 7053, 2637, 13546, 787, 336, 14628, 14, 221, 21467, 9689, 282, 892, 7761, 12, 8749, 199, 3, 1586, 665, 1014, 921, 27114, 14, 7646, 14, 846, 15, 4757, 15, 21232, 15, 73, 1085, 78, 14, 1360, 10827, 221, 16853, 1584, 1471, 506, 199, 3, 14598, 367, 1924, 2637, 26, 1373, 315, 18382, 15, 13209, 12, 314, 1163, 315, 199, 3, 18382, 15, 11531, 15, 8332, 15, 13209, 14, 199, 199, 624, 199, 21658, 529, 290, 475, 13, 3671, 13546, 367, 2637, 13, 7106, 4534, 402, 199, 264, 27486, 1872, 14, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 7, 421, 199, 23216, 275, 469, 489, 327, 2637, 13, 7106, 26, 6317, 489, 399, 7, 323, 343, 85, 356, 283, 22393, 297, 489, 399, 7, 90, 1308, 85, 356, 283, 696, 2206, 297, 489, 399, 5121, 621, 88, 3478, 356, 283, 68, 12974, 297, 489, 399, 5121, 290, 60, 85, 13059, 271, 293, 356, 283, 68, 12974, 297, 489, 399, 7, 281, 285, 79, 356, 283, 705, 297, 489, 399, 1159, 3165, 293, 356, 283, 6479, 297, 489, 399, 7, 926, 3042, 356, 283, 19559, 297, 489, 399, 7, 1397, 79, 356, 283, 4610, 297, 489, 399, 7, 30586, 321, 475, 356, 283, 8996, 297, 489, 399, 7, 28396, 475, 356, 283, 3764, 297, 489, 399, 7, 350, 19758, 356, 283, 350, 31722, 297, 489, 399, 7, 70, 1983, 266, 75, 14308, 356, 283, 27372, 297, 489, 399, 1133, 69, 573, 356, 283, 5746, 297, 489, 399, 7, 604, 65, 13, 25913, 7697, 356, 283, 604, 13, 1457, 297, 489, 399, 7, 290, 279, 565, 12041, 13, 8939, 79, 356, 283, 6751, 13, 8939, 297, 489, 399, 7, 82, 456, 322, 7697, 356, 283, 21586, 297, 489, 399, 7, 1545, 528, 345, 545, 356, 283, 1545, 528, 3255, 297, 489, 399, 7, 352, 7848, 9091, 15987, 74, 356, 283, 14337, 83, 297, 489, 399, 7, 352, 7848, 65, 60, 85, 614, 1276, 79, 74, 356, 283, 14337, 83, 297, 489, 399, 7, 5711, 1597, 345, 13, 14422, 9091, 15987, 356, 283, 9302, 13, 3513, 297, 489, 399, 7, 5711, 1597, 345, 13, 14422, 65, 60, 85, 614, 1276, 79, 356, 283, 9302, 13, 3513, 297, 489, 399, 7, 75, 676, 1393, 9091, 15987, 356, 283, 15278, 297, 489, 399, 7, 75, 676, 1393, 65, 60, 85, 614, 1276, 79, 356, 283, 15278, 297, 489, 399, 1133, 5711, 270, 316, 79, 356, 283, 3600, 297, 489, 399, 7, 287, 4425, 320, 356, 283, 3600, 297, 489, 17384, 16069, 356, 283, 16069, 297, 489, 17384, 7096, 356, 283, 16069, 297, 489, 17384, 667, 81, 356, 283, 16069, 297, 489, 399, 1133, 7570, 320, 356, 283, 1224, 297, 489, 399, 1133, 7570, 320, 13, 86, 6341, 356, 283, 4737, 13, 1224, 297, 327, 298, 637, 269, 79, 74, 487, 338, 3187, 9091, 1126, 20817, 573, 74, 2, 489, 399, 1133, 7570, 320, 13, 4737, 356, 283, 4737, 13, 1224, 297, 489, 399, 1133, 7570, 320, 13, 513, 65, 356, 283, 513, 13, 1224, 297, 489, 399, 6704, 1841, 356, 283, 2024, 297, 489, 283, 3442, 334, 6893, 1415, 11862, 283, 3442, 297, 489, 17384, 1569, 1130, 356, 283, 1569, 1130, 297, 489, 399, 7, 66, 668, 79, 356, 283, 1569, 297, 489, 399, 7, 592, 9129, 356, 283, 8941, 297, 489, 399, 7, 2292, 10836, 328, 356, 283, 2613, 297, 489, 399, 1159, 287, 290, 279, 565, 65, 356, 283, 1773, 297, 489, 399, 7, 290, 270, 419, 2521, 73, 356, 283, 1814, 297, 489, 399, 7, 290, 270, 419, 60, 85, 10882, 328, 356, 283, 1814, 297, 489, 399, 7, 2975, 356, 283, 2975, 297, 489, 399, 5121, 11318, 356, 283, 602, 297, 489, 399, 7, 9503, 305, 79, 356, 283, 533, 297, 489, 399, 7, 293, 320, 356, 283, 3756, 297, 489, 399, 7, 26499, 12536, 21492, 13, 293, 320, 356, 283, 885, 13, 3756, 297, 489, 399, 1133, 24308, 320, 356, 283, 1213, 297, 489, 399, 7, 287, 72, 1214, 79, 356, 283, 4407, 297, 489, 399, 1159, 5711, 1507, 356, 283, 8519, 1507, 297, 489, 399, 1159, 5711, 16521, 13, 10563, 345, 1117, 356, 283, 8519, 1507, 297, 489, 399, 7, 75, 19111, 75, 10377, 356, 283, 1291, 297, 489, 399, 7, 1038, 379, 261, 75, 10377, 356, 283, 12781, 297, 489, 17384, 11407, 5983, 356, 283, 11407, 5983, 297, 489, 17384, 14422, 1298, 356, 283, 14422, 1298, 297, 489, 399, 7, 301, 416, 74, 13, 1397, 79, 74, 356, 283, 1375, 13, 5983, 297, 489, 399, 3984, 26305, 13, 396, 13, 15047, 356, 283, 26854, 13, 396, 13, 15047, 936, 199, 624, 21658, 529, 290, 475, 536, 370, 7264, 334, 262, 13502, 22128, 826, 4343, 647, 9, 13613, 536, 199, 4745, 1041, 199, 199, 8050, 275, 469, 272, 327, 2637, 13, 7106, 26, 6317, 272, 399, 6704, 452, 951, 528, 79, 356, 283, 371, 30369, 297, 272, 399, 6704, 452, 356, 283, 371, 30369, 297, 272, 399, 7, 75, 1377, 78, 2764, 24208, 356, 283, 645, 2641, 12828, 297, 272, 399, 7, 9503, 356, 283, 645, 2641, 12828, 297, 272, 399, 7, 262, 271, 75, 1152, 356, 283, 1080, 297, 272, 399, 7, 73, 356, 283, 1080, 297, 272, 399, 1159, 456, 1339, 322, 656, 356, 283, 30907, 297, 272, 399, 1159, 456, 356, 283, 30907, 297, 272, 399, 1159, 384, 82, 813, 322, 656, 356, 283, 4792, 1579, 297, 272, 399, 1159, 384, 356, 283, 4792, 1579, 297, 272, 399, 1133, 390, 22205, 13, 264, 1485, 331, 356, 283, 1213, 13, 4443, 297, 272, 399, 1133, 24308, 320, 356, 283, 1213, 13, 4443, 297, 272, 399, 1133, 356, 283, 1213, 13, 4443, 297, 272, 399, 7, 12636, 13, 264, 1485, 331, 356, 283, 12636, 13, 4443, 297, 272, 399, 7, 12636, 356, 283, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Syralist/pixels_clock
clock.py
1
3227
# -*- coding: utf-8 -*- import pygame, led, sys, os, random, csv import smbus from pygame.locals import * from led.PixelEventHandler import * from time import gmtime, strftime """ A very simple arcade shooter demo :) """ random.seed() BLACK = pygame.Color(0,0,0) WHITE = pygame.Color(255, 255, 255) RED = pygame.Color(255, 0, 0) GREEN = pygame.Color(0, 255, 0) adress = 0x48 LM75 = smbus.SMBus(1) # detect if a serial/USB port is given as argument hasSerialPortParameter = ( sys.argv.__len__() > 1 ) # use 90 x 20 matrix when no usb port for real display provided fallbackSize = ( 90, 20 ) if hasSerialPortParameter: serialPort = sys.argv[1] print "INITIALIZING WITH USB-PORT: " + serialPort ledDisplay = led.teensy.TeensyDisplay(serialPort, fallbackSize) else: print "INITIALIZING WITH SERVER DISPLAY AND SIMULATOR." ledDisplay = led.dsclient.DisplayServerClientDisplay('localhost', 8123, fallbackSize) # use same size for sim and real LED panel size = ledDisplay.size() simDisplay = led.sim.SimDisplay(size) screen = pygame.Surface(size) gamestate = 0 #1=alive; 0=dead def main(): pygame.init() pygame.font.init() clock = pygame.time.Clock() pygame.joystick.init() gameover = False # Initialize first joystick if pygame.joystick.get_count() > 0: stick = pygame.joystick.Joystick(0) stick.init() global gamestate scored = False # Clear event list before starting the game pygame.event.clear() while not gameover: # Process event queue for pgevent in pygame.event.get(): if pgevent.type == QUIT: pygame.quit() sys.exit() event = process_event(pgevent) # End the game if event.button == EXIT: gameover = True # Keypresses on keyboard and joystick axis motions / button presses elif event.type == PUSH: # Movements if event.button == UP: pass elif event.button == DOWN: pass elif event.button == RIGHT: pass elif event.button == LEFT: pass # Tower selection elif event.button == B2: pass # Tower placement elif event.button == P1: gameover = True # Only on Keyboard elif pgevent.type == KEYDOWN and pgevent.key == K_ESCAPE: gameover = True screen.fill(BLACK) font = pygame.font.SysFont("Arial", 12) text1 = font.render(strftime("%H:%M:%S"), 0, RED) text1pos = text1.get_rect() text1pos.midtop = (screen.get_rect().centerx, -1) screen.blit(text1,text1pos) try: temp = LM75.read_byte(adress) except: temp = -1 text2 = font.render("T: "+str(temp)+"'C", 0, GREEN) text2pos = text2.get_rect() text2pos.midbottom = (screen.get_rect().centerx, 23) screen.blit(text2,text2pos) simDisplay.update(screen) ledDisplay.update(screen) clock.tick(10) main()
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 9193, 12, 29239, 12, 984, 12, 747, 12, 2196, 12, 7392, 199, 646, 4383, 5610, 199, 504, 9193, 14, 9350, 492, 627, 199, 504, 29239, 14, 14383, 2390, 2461, 492, 627, 199, 504, 900, 492, 486, 8180, 12, 14053, 199, 199, 624, 437, 7437, 3486, 601, 9490, 930, 79, 351, 14779, 32428, 199, 624, 199, 199, 2355, 14, 5176, 342, 199, 199, 23113, 275, 9193, 14, 4117, 8, 16, 12, 16, 12, 16, 9, 199, 18817, 275, 9193, 14, 4117, 8, 2299, 12, 5450, 12, 5450, 9, 199, 7387, 275, 9193, 14, 4117, 8, 2299, 12, 378, 12, 378, 9, 199, 22501, 275, 9193, 14, 4117, 8, 16, 12, 5450, 12, 378, 9, 199, 199, 350, 753, 275, 378, 88, 2006, 199, 25526, 2194, 275, 4383, 5610, 14, 4029, 12106, 8, 17, 9, 199, 199, 3, 9696, 340, 282, 3012, 15, 19919, 1844, 365, 1627, 465, 1423, 199, 1989, 3571, 4313, 4720, 275, 334, 984, 14, 3020, 855, 552, 4533, 690, 413, 776, 199, 199, 3, 675, 9137, 671, 3388, 3634, 1380, 949, 27923, 1844, 367, 3363, 2929, 2741, 199, 10538, 2320, 275, 334, 9137, 12, 3388, 776, 199, 199, 692, 965, 3571, 4313, 4720, 26, 272, 3012, 4313, 275, 984, 14, 3020, 59, 17, 61, 272, 870, 298, 13768, 5357, 1206, 1663, 28655, 13, 3657, 26, 298, 435, 3012, 4313, 272, 29239, 7687, 275, 29239, 14, 25076, 1786, 14, 6301, 287, 1786, 7687, 8, 2171, 4313, 12, 9567, 2320, 9, 199, 2836, 26, 272, 870, 298, 13768, 5357, 1206, 1663, 23578, 7587, 11625, 2401, 428, 1469, 1293, 6467, 2122, 272, 29239, 7687, 275, 29239, 14, 68, 551, 864, 14, 7687, 3120, 3041, 7687, 360, 5967, 297, 1695, 4288, 12, 9567, 2320, 9, 199, 199, 3, 675, 2011, 1568, 367, 4389, 436, 3363, 491, 1149, 12748, 199, 890, 275, 29239, 7687, 14, 890, 342, 199, 5206, 7687, 275, 29239, 14, 5206, 14, 7467, 7687, 8, 890, 9, 199, 5410, 275, 9193, 14, 16923, 8, 890, 9, 199, 5097, 929, 275, 378, 327, 17, 29, 9631, 27, 378, 29, 10957, 421, 199, 318, 2446, 837, 272, 9193, 14, 826, 342, 272, 9193, 14, 4246, 14, 826, 342, 272, 12516, 275, 9193, 14, 521, 14, 17387, 342, 272, 9193, 14, 26729, 18043, 14, 826, 342, 339, 9219, 1883, 275, 756, 2286, 327, 11578, 1642, 5225, 89, 18043, 272, 340, 9193, 14, 26729, 18043, 14, 362, 63, 835, 342, 690, 378, 26, 267, 29404, 275, 9193, 14, 26729, 18043, 14, 5691, 89, 18043, 8, 16, 9, 267, 29404, 14, 826, 342, 2286, 2288, 9219, 929, 339, 27748, 581, 275, 756, 272, 327, 14836, 1566, 769, 2544, 6617, 314, 9219, 272, 9193, 14, 1430, 14, 3584, 342, 339, 1830, 440, 9219, 1883, 26, 398, 327, 7132, 1566, 4126, 267, 367, 299, 303, 782, 315, 9193, 14, 1430, 14, 362, 837, 288, 340, 299, 303, 782, 14, 466, 508, 7813, 649, 26, 355, 9193, 14, 10589, 342, 355, 984, 14, 2224, 342, 953, 1566, 275, 2112, 63, 1430, 8, 80, 303, 782, 9, 953, 327, 9599, 314, 9219, 288, 340, 1566, 14, 3887, 508, 3651, 649, 26, 355, 9219, 1883, 275, 715, 953, 327, 2606, 80, 4357, 641, 18716, 436, 5225, 89, 18043, 3114, 1303, 852, 1182, 5528, 299, 4357, 288, 916, 1566, 14, 466, 508, 510, 14527, 26, 355, 327, 14171, 1470, 355, 340, 1566, 14, 3887, 508, 7215, 26, 490, 986, 355, 916, 1566, 14, 3887, 508, 10163, 26, 490, 986, 355, 916, 1566, 14, 3887, 508, 7052, 26, 490, 986, 355, 916, 1566, 14, 3887, 508, 6578, 26, 490, 986, 2234, 327, 377, 3891, 7267, 288, 916, 1566, 14, 3887, 508, 699, 18, 26, 355, 986, 2234, 327, 377, 3891, 22286, 288, 916, 1566, 14, 3887, 508, 510, 17, 26, 355, 9219, 1883, 275, 715, 953, 327, 5972, 641, 2606, 3576, 288, 916, 299, 303, 782, 14, 466, 508, 9301, 8819, 436, 299, 303, 782, 14, 498, 508, 1804, 63, 28879, 26, 355, 9219, 1883, 275, 715, 398, 6426, 14, 4498, 8, 23113, 9, 267, 5023, 275, 9193, 14, 4246, 14, 11319, 6986, 480, 33, 1383, 401, 3144, 9, 267, 1318, 17, 275, 5023, 14, 3352, 8, 6205, 3647, 40, 2689, 45, 2689, 51, 1288, 378, 12, 23443, 9, 267, 1318, 17, 1712, 275, 1318, 17, 14, 362, 63, 1201, 342, 267, 1318, 17, 1712, 14, 8523, 2119, 275, 334, 5410, 14, 362, 63, 1201, 1252, 4218, 88, 12, 446, 17, 9, 267, 6426, 14, 15574, 8, 505, 17, 12, 505, 17, 1712, 9, 267, 862, 26, 288, 2388, 275, 491, 45, 2194, 14, 739, 63, 4414, 8, 350, 753, 9, 267, 871, 26, 288, 2388, 275, 446, 17, 267, 1318, 18, 275, 5023, 14, 3352, 480, 52, 26, 7210, 495, 8, 808, 6393, 4507, 35, 401, 378, 12, 598, 14824, 9, 267, 1318, 18, 1712, 275, 1318, 18, 14, 362, 63, 1201, 342, 267, 1318, 18, 1712, 14, 8523, 8305, 275, 334, 5410, 14, 362, 63, 1201, 1252, 4218, 88, 12, 6546, 9, 267, 6426, 14, 15574, 8, 505, 18, 12, 505, 18, 1712, 9, 398, 4389, 7687, 14, 873, 8, 5410, 9, 267, 29239, 7687, 14, 873, 8, 5410, 9, 398, 12516, 14, 8284, 8, 709, 9, 199, 199, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 9193, 12, 29239, 12, 984, 12, 747, 12, 2196, 12, 7392, 199, 646, 4383, 5610, 199, 504, 9193, 14, 9350, 492, 627, 199, 504, 29239, 14, 14383, 2390, 2461, 492, 627, 199, 504, 900, 492, 486, 8180, 12, 14053, 199, 199, 624, 437, 7437, 3486, 601, 9490, 930, 79, 351, 14779, 32428, 199, 624, 199, 199, 2355, 14, 5176, 342, 199, 199, 23113, 275, 9193, 14, 4117, 8, 16, 12, 16, 12, 16, 9, 199, 18817, 275, 9193, 14, 4117, 8, 2299, 12, 5450, 12, 5450, 9, 199, 7387, 275, 9193, 14, 4117, 8, 2299, 12, 378, 12, 378, 9, 199, 22501, 275, 9193, 14, 4117, 8, 16, 12, 5450, 12, 378, 9, 199, 199, 350, 753, 275, 378, 88, 2006, 199, 25526, 2194, 275, 4383, 5610, 14, 4029, 12106, 8, 17, 9, 199, 199, 3, 9696, 340, 282, 3012, 15, 19919, 1844, 365, 1627, 465, 1423, 199, 1989, 3571, 4313, 4720, 275, 334, 984, 14, 3020, 855, 552, 4533, 690, 413, 776, 199, 199, 3, 675, 9137, 671, 3388, 3634, 1380, 949, 27923, 1844, 367, 3363, 2929, 2741, 199, 10538, 2320, 275, 334, 9137, 12, 3388, 776, 199, 199, 692, 965, 3571, 4313, 4720, 26, 272, 3012, 4313, 275, 984, 14, 3020, 59, 17, 61, 272, 870, 298, 13768, 5357, 1206, 1663, 28655, 13, 3657, 26, 298, 435, 3012, 4313, 272, 29239, 7687, 275, 29239, 14, 25076, 1786, 14, 6301, 287, 1786, 7687, 8, 2171, 4313, 12, 9567, 2320, 9, 199, 2836, 26, 272, 870, 298, 13768, 5357, 1206, 1663, 23578, 7587, 11625, 2401, 428, 1469, 1293, 6467, 2122, 272, 29239, 7687, 275, 29239, 14, 68, 551, 864, 14, 7687, 3120, 3041, 7687, 360, 5967, 297, 1695, 4288, 12, 9567, 2320, 9, 199, 199, 3, 675, 2011, 1568, 367, 4389, 436, 3363, 491, 1149, 12748, 199, 890, 275, 29239, 7687, 14, 890, 342, 199, 5206, 7687, 275, 29239, 14, 5206, 14, 7467, 7687, 8, 890, 9, 199, 5410, 275, 9193, 14, 16923, 8, 890, 9, 199, 5097, 929, 275, 378, 327, 17, 29, 9631, 27, 378, 29, 10957, 421, 199, 318, 2446, 837, 272, 9193, 14, 826, 342, 272, 9193, 14, 4246, 14, 826, 342, 272, 12516, 275, 9193, 14, 521, 14, 17387, 342, 272, 9193, 14, 26729, 18043, 14, 826, 342, 339, 9219, 1883, 275, 756, 2286, 327, 11578, 1642, 5225, 89, 18043, 272, 340, 9193, 14, 26729, 18043, 14, 362, 63, 835, 342, 690, 378, 26, 267, 29404, 275, 9193, 14, 26729, 18043, 14, 5691, 89, 18043, 8, 16, 9, 267, 29404, 14, 826, 342, 2286, 2288, 9219, 929, 339, 27748, 581, 275, 756, 272, 327, 14836, 1566, 769, 2544, 6617, 314, 9219, 272, 9193, 14, 1430, 14, 3584, 342, 339, 1830, 440, 9219, 1883, 26, 398, 327, 7132, 1566, 4126, 267, 367, 299, 303, 782, 315, 9193, 14, 1430, 14, 362, 837, 288, 340, 299, 303, 782, 14, 466, 508, 7813, 649, 26, 355, 9193, 14, 10589, 342, 355, 984, 14, 2224, 342, 953, 1566, 275, 2112, 63, 1430, 8, 80, 303, 782, 9, 953, 327, 9599, 314, 9219, 288, 340, 1566, 14, 3887, 508, 3651, 649, 26, 355, 9219, 1883, 275, 715, 953, 327, 2606, 80, 4357, 641, 18716, 436, 5225, 89, 18043, 3114, 1303, 852, 1182, 5528, 299, 4357, 288, 916, 1566, 14, 466, 508, 510, 14527, 26, 355, 327, 14171, 1470, 355, 340, 1566, 14, 3887, 508, 7215, 26, 490, 986, 355, 916, 1566, 14, 3887, 508, 10163, 26, 490, 986, 355, 916, 1566, 14, 3887, 508, 7052, 26, 490, 986, 355, 916, 1566, 14, 3887, 508, 6578, 26, 490, 986, 2234, 327, 377, 3891, 7267, 288, 916, 1566, 14, 3887, 508, 699, 18, 26, 355, 986, 2234, 327, 377, 3891, 22286, 288, 916, 1566, 14, 3887, 508, 510, 17, 26, 355, 9219, 1883, 275, 715, 953, 327, 5972, 641, 2606, 3576, 288, 916, 299, 303, 782, 14, 466, 508, 9301, 8819, 436, 299, 303, 782, 14, 498, 508, 1804, 63, 28879, 26, 355, 9219, 1883, 275, 715, 398, 6426, 14, 4498, 8, 23113, 9, 267, 5023, 275, 9193, 14, 4246, 14, 11319, 6986, 480, 33, 1383, 401, 3144, 9, 267, 1318, 17, 275, 5023, 14, 3352, 8, 6205, 3647, 40, 2689, 45, 2689, 51, 1288, 378, 12, 23443, 9, 267, 1318, 17, 1712, 275, 1318, 17, 14, 362, 63, 1201, 342, 267, 1318, 17, 1712, 14, 8523, 2119, 275, 334, 5410, 14, 362, 63, 1201, 1252, 4218, 88, 12, 446, 17, 9, 267, 6426, 14, 15574, 8, 505, 17, 12, 505, 17, 1712, 9, 267, 862, 26, 288, 2388, 275, 491, 45, 2194, 14, 739, 63, 4414, 8, 350, 753, 9, 267, 871, 26, 288, 2388, 275, 446, 17, 267, 1318, 18, 275, 5023, 14, 3352, 480, 52, 26, 7210, 495, 8, 808, 6393, 4507, 35, 401, 378, 12, 598, 14824, 9, 267, 1318, 18, 1712, 275, 1318, 18, 14, 362, 63, 1201, 342, 267, 1318, 18, 1712, 14, 8523, 8305, 275, 334, 5410, 14, 362, 63, 1201, 1252, 4218, 88, 12, 6546, 9, 267, 6426, 14, 15574, 8, 505, 18, 12, 505, 18, 1712, 9, 398, 4389, 7687, 14, 873, 8, 5410, 9, 267, 29239, 7687, 14, 873, 8, 5410, 9, 398, 12516, 14, 8284, 8, 709, 9, 199, 199, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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