repo_name
stringlengths 6
100
| path
stringlengths 4
294
| copies
stringclasses 981
values | size
stringlengths 4
6
| content
stringlengths 606
896k
| license
stringclasses 15
values | input_ids
listlengths 1.02k
1.02k
| labels
listlengths 1.02k
1.02k
| attention_mask
listlengths 1.02k
1.02k
|
|---|---|---|---|---|---|---|---|---|
quizlet/grpc
|
src/python/grpcio_tests/tests/unit/resources.py
|
10
|
1267
|
# Copyright 2015 gRPC 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.
"""Constants and functions for data used in interoperability testing."""
import os
import pkg_resources
_ROOT_CERTIFICATES_RESOURCE_PATH = 'credentials/ca.pem'
_PRIVATE_KEY_RESOURCE_PATH = 'credentials/server1.key'
_CERTIFICATE_CHAIN_RESOURCE_PATH = 'credentials/server1.pem'
def test_root_certificates():
return pkg_resources.resource_string(__name__,
_ROOT_CERTIFICATES_RESOURCE_PATH)
def private_key():
return pkg_resources.resource_string(__name__, _PRIVATE_KEY_RESOURCE_PATH)
def certificate_chain():
return pkg_resources.resource_string(__name__,
_CERTIFICATE_CHAIN_RESOURCE_PATH)
|
apache-2.0
|
[
3,
1898,
6900,
30700,
11462,
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,
624,
22185,
436,
3423,
367,
666,
1202,
315,
4661,
9198,
3616,
5343,
1041,
199,
199,
646,
747,
199,
199,
646,
5496,
63,
4435,
199,
199,
63,
5441,
63,
11163,
14456,
16601,
63,
14110,
63,
3243,
275,
283,
6942,
15,
696,
14,
13102,
7,
199,
63,
18748,
63,
3078,
63,
14110,
63,
3243,
275,
283,
6942,
15,
1000,
17,
14,
498,
7,
199,
63,
11163,
29321,
63,
25256,
63,
14110,
63,
3243,
275,
283,
6942,
15,
1000,
17,
14,
13102,
7,
421,
199,
318,
511,
63,
1231,
63,
16159,
837,
272,
372,
5496,
63,
4435,
14,
1927,
63,
875,
3460,
354,
3108,
1460,
485,
5441,
63,
11163,
14456,
16601,
63,
14110,
63,
3243,
9,
421,
199,
318,
5726,
63,
498,
837,
272,
372,
5496,
63,
4435,
14,
1927,
63,
875,
3460,
354,
3108,
485,
18748,
63,
3078,
63,
14110,
63,
3243,
9,
421,
199,
318,
5897,
63,
4429,
837,
272,
372,
5496,
63,
4435,
14,
1927,
63,
875,
3460,
354,
3108,
1460,
485,
11163,
29321,
63,
25256,
63,
14110,
63,
3243,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6900,
30700,
11462,
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,
624,
22185,
436,
3423,
367,
666,
1202,
315,
4661,
9198,
3616,
5343,
1041,
199,
199,
646,
747,
199,
199,
646,
5496,
63,
4435,
199,
199,
63,
5441,
63,
11163,
14456,
16601,
63,
14110,
63,
3243,
275,
283,
6942,
15,
696,
14,
13102,
7,
199,
63,
18748,
63,
3078,
63,
14110,
63,
3243,
275,
283,
6942,
15,
1000,
17,
14,
498,
7,
199,
63,
11163,
29321,
63,
25256,
63,
14110,
63,
3243,
275,
283,
6942,
15,
1000,
17,
14,
13102,
7,
421,
199,
318,
511,
63,
1231,
63,
16159,
837,
272,
372,
5496,
63,
4435,
14,
1927,
63,
875,
3460,
354,
3108,
1460,
485,
5441,
63,
11163,
14456,
16601,
63,
14110,
63,
3243,
9,
421,
199,
318,
5726,
63,
498,
837,
272,
372,
5496,
63,
4435,
14,
1927,
63,
875,
3460,
354,
3108,
485,
18748,
63,
3078,
63,
14110,
63,
3243,
9,
421,
199,
318,
5897,
63,
4429,
837,
272,
372,
5496,
63,
4435,
14,
1927,
63,
875,
3460,
354,
3108,
1460,
485,
11163,
29321,
63,
25256,
63,
14110,
63,
3243,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
pedrobaeza/OpenUpgrade
|
addons/purchase/migrations/8.0.1.1/post-migration.py
|
7
|
7140
|
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier, Stefan Rijnhart
# Copyright (C) 2014 Camptocamp SA
# (C) 2014 Therp BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import logging
from openerp.openupgrade import openupgrade, openupgrade_80
from openerp import pooler, SUPERUSER_ID as uid
logger = logging.getLogger('OpenUpgrade.purchase')
def create_workitem_picking(cr, uid, pool):
"""
Recover workitems missing in migration.
:param cr: Database cursor
:param uid: User Id
:param pool: Database pool
"""
pool = pooler.get_pool(cr.dbname)
pol_obj = pool['purchase.order.line']
# Activity
cr.execute(
"""SELECT id FROM wkf_activity WHERE name = %s AND action = %s""",
('picking', 'action_picking_create()'))
res = cr.fetchone()
wkf_activity = res and res[0]
# Get the not shipped moves linked to any Purchase Order
cr.execute(
"""SELECT purchase_line_id
FROM stock_move
WHERE purchase_line_id is not null
AND state != %s""",
('done',))
for res in cr.fetchall():
pol = pol_obj.browse(cr, uid, res[0])
# Instance
cr.execute(
"""SELECT id
FROM wkf_instance
WHERE res_id = %s AND res_type = %s""",
(pol.order_id.id, 'purchase.order'))
res3 = cr.fetchone()
wkf_instance = res3 and res3[0]
# Create workItem
cr.execute(
"""SELECT id
FROM wkf_workitem
WHERE act_id = %s AND inst_id = %s""" % (
wkf_activity, wkf_instance))
res2 = cr.fetchone()
wkf_workitem = res2 and res2[0]
if not wkf_workitem:
cr.execute(
"""INSERT INTO wkf_workitem (act_id, inst_id, state)
VALUES (%s, %s, %s)""",
(wkf_activity, wkf_instance, 'complete',))
def migrate_product_supply_method(cr):
"""
Procurements of products: change the supply_method for the matching route
Buy -> Buy Rule
:param cr: Database cursor
"""
pool = pooler.get_pool(cr.dbname)
template_obj = pool['product.template']
mto_route_id = pool['ir.model.data'].get_object_reference(
cr, uid, 'purchase', 'route_warehouse0_buy')[1]
procure_method_legacy = openupgrade.get_legacy_name('supply_method')
if mto_route_id:
product_ids = []
cr.execute("""SELECT id FROM product_template WHERE %s = %%s""" % (
procure_method_legacy), ('buy',))
product_ids = [res[0] for res in cr.fetchall()]
template_obj.write(
cr, uid, product_ids, {'route_ids': [(4, mto_route_id)]})
def migrate_procurement_order(cr):
"""
On procurements, purchase_id is replaced by purchase_line_id. We should be
able to match most purchase lines because they got the procurement's
move_id as their move_dest_id. Fallback on product_id, for presumably the
manually created procurements without a related move from a sale or
production order.
In Odoo 8.0, stock moves generated for the procurement (moves from the
supplier or production location to stock) are also recorded on the
procurement. For purchase procurements, gather them here.
"""
openupgrade.logged_query(
cr,
"""
UPDATE procurement_order proc
SET purchase_line_id = pol.id
FROM purchase_order_line pol
WHERE proc.{purchase_id} = pol.order_id
AND pol.{move_dest_id} IS NOT NULL
AND pol.{move_dest_id} = proc.move_dest_id
""".format(
purchase_id=openupgrade.get_legacy_name('purchase_id'),
move_dest_id=openupgrade.get_legacy_name('move_dest_id')))
openupgrade.logged_query(
cr,
"""
UPDATE procurement_order proc
SET purchase_line_id = pol.id
FROM purchase_order_line pol
WHERE proc.{purchase_id} = pol.order_id
AND proc.purchase_line_id IS NULL
AND pol.product_id = proc.product_id
AND pol.id NOT IN (
SELECT purchase_line_id
FROM procurement_order
WHERE purchase_line_id IS NOT NULL)
""".format(
purchase_id=openupgrade.get_legacy_name('purchase_id')))
# Warn about dangling procurements
cr.execute(
"""
SELECT count(*) FROM procurement_order
WHERE purchase_line_id IS NULL
AND {purchase_id} IS NOT NULL
AND state NOT IN ('done', 'exception')
""".format(
purchase_id=openupgrade.get_legacy_name('purchase_id')))
count = cr.fetchone()[0]
if count:
logger.warning(
"Failed to match the purchase order line for %s running "
"procurements.", count)
# Populate the moves generated from purchase procurements (the move_ids
# field on the procurement order)
openupgrade.logged_query(
cr,
"""
UPDATE stock_move sm
SET procurement_id = proc.id
FROM procurement_order proc
WHERE proc.purchase_line_id = sm.purchase_line_id
AND sm.purchase_line_id IS NOT NULL
""")
def migrate_stock_warehouse(cr, pool):
"""Enable purchasing on all warehouses. This will trigger the creation
of the purchase procurement rule"""
warehouse_obj = pool['stock.warehouse']
warehouse_ids = warehouse_obj.search(cr, uid, [])
warehouse_obj.write(
cr, uid, warehouse_ids, {'buy_to_resupply': True})
if len(warehouse_ids) > 1:
openupgrade.message(
cr, 'purchase', False, False,
"Purchasing is now enabled on all your warehouses. If this is "
"not appropriate, disable the option 'Purchase to resupply this "
"Warehouse' on the warehouse settings. You need to have 'Manage "
"Push and Pull inventory flows' checked on your user record in "
"order to access this setting.")
@openupgrade.migrate()
def migrate(cr, version):
pool = pooler.get_pool(cr.dbname)
create_workitem_picking(cr, uid, pool)
migrate_product_supply_method(cr)
migrate_procurement_order(cr)
migrate_stock_warehouse(cr, pool)
openupgrade_80.set_message_last_post(cr, uid, pool, ['purchase.order'])
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
6529,
26,
598,
310,
87,
287,
699,
65,
1631,
4446,
12,
17854,
12269,
820,
7879,
29199,
580,
199,
3,
259,
1898,
334,
35,
9,
6927,
24569,
475,
20290,
13950,
199,
3,
4519,
334,
35,
9,
6927,
377,
2523,
80,
699,
54,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
646,
2050,
199,
504,
5166,
14,
1490,
9375,
492,
1551,
9375,
12,
1551,
9375,
63,
1257,
199,
504,
5166,
492,
1115,
79,
1435,
12,
12824,
63,
998,
465,
1747,
199,
199,
2921,
275,
2050,
14,
5572,
360,
4299,
19217,
14,
9533,
358,
421,
199,
318,
1218,
63,
800,
1053,
63,
11463,
8,
1556,
12,
1747,
12,
4203,
304,
272,
408,
272,
799,
5899,
1736,
1744,
4124,
315,
8367,
14,
272,
520,
635,
2467,
26,
8692,
3920,
272,
520,
635,
1747,
26,
2876,
15418,
272,
520,
635,
4203,
26,
8692,
4203,
272,
408,
339,
4203,
275,
1115,
79,
1435,
14,
362,
63,
2293,
8,
1556,
14,
13238,
9,
272,
3708,
63,
1113,
275,
4203,
459,
9533,
14,
1648,
14,
604,
418,
339,
327,
21885,
272,
2467,
14,
2526,
8,
267,
408,
4859,
1305,
4442,
32727,
63,
8240,
6038,
536,
275,
450,
83,
2401,
1595,
275,
450,
83,
7208,
267,
661,
11463,
297,
283,
1287,
63,
11463,
63,
981,
342,
1333,
272,
522,
275,
2467,
14,
11591,
342,
272,
32727,
63,
8240,
275,
522,
436,
522,
59,
16,
61,
339,
327,
2372,
314,
440,
15924,
1915,
14569,
10632,
370,
1263,
23177,
6703,
9240,
272,
2467,
14,
2526,
8,
267,
408,
4859,
15932,
63,
604,
63,
344,
267,
4442,
10952,
63,
1185,
267,
6038,
15932,
63,
604,
63,
344,
365,
440,
2973,
267,
2401,
1174,
1137,
450,
83,
7208,
267,
661,
4456,
16829,
272,
367,
522,
315,
2467,
14,
10174,
837,
267,
3708,
275,
3708,
63,
1113,
14,
4570,
8,
1556,
12,
1747,
12,
522,
59,
16,
566,
398,
327,
10066,
267,
2467,
14,
2526,
8,
288,
408,
4859,
1305,
288,
4442,
32727,
63,
842,
288,
6038,
522,
63,
344,
275,
450,
83,
2401,
522,
63,
466,
275,
450,
83,
7208,
288,
334,
2515,
14,
1648,
63,
344,
14,
344,
12,
283,
9533,
14,
1648,
1333,
267,
522,
19,
275,
2467,
14,
11591,
342,
267,
32727,
63,
842,
275,
522,
19,
436,
522,
19,
59,
16,
61,
398,
327,
2790,
1736,
2081,
267,
2467,
14,
2526,
8,
288,
408,
4859,
1305,
288,
4442,
32727,
63,
800,
1053,
288,
6038,
2454,
63,
344,
275,
450,
83,
2401,
2727,
63,
344,
275,
450,
83,
624,
450,
334,
355,
32727,
63,
8240,
12,
32727,
63,
842,
430,
267,
522,
18,
275,
2467,
14,
11591,
342,
267,
32727,
63,
800,
1053,
275,
522,
18,
436,
522,
18,
59,
16,
61,
267,
340,
440,
32727,
63,
800,
1053,
26,
288,
2467,
14,
2526,
8,
355,
408,
10258,
12872,
32727,
63,
800,
1053,
334,
2442,
63,
344,
12,
2727,
63,
344,
12,
1174,
9,
355,
13992,
4366,
83,
12,
450,
83,
12,
450,
83,
9,
7208,
355,
334,
14947,
70,
63,
8240,
12,
32727,
63,
842,
12,
283,
4883,
16829,
421,
199,
318,
12810,
63,
2558,
63,
8621,
590,
63,
765,
8,
1556,
304,
272,
408,
272,
29625,
608,
1470,
402,
7585,
26,
1570,
314,
17169,
63,
765,
367,
314,
4877,
7475,
272,
4779,
89,
1035,
4779,
89,
11949,
272,
520,
635,
2467,
26,
8692,
3920,
272,
408,
272,
4203,
275,
1115,
79,
1435,
14,
362,
63,
2293,
8,
1556,
14,
13238,
9,
272,
1978,
63,
1113,
275,
4203,
459,
2558,
14,
1160,
418,
339,
333,
475,
63,
4449,
63,
344,
275,
4203,
459,
723,
14,
1238,
14,
576,
2278,
362,
63,
785,
63,
4443,
8,
267,
2467,
12,
1747,
12,
283,
9533,
297,
283,
4449,
63,
12806,
16,
63,
31240,
5832,
17,
61,
339,
6499,
608,
63,
765,
63,
10000,
275,
1551,
9375,
14,
362,
63,
10000,
63,
354,
360,
8621,
590,
63,
765,
358,
272,
340,
333,
475,
63,
4449,
63,
344,
26,
267,
3336,
63,
1580,
275,
942,
267,
2467,
14,
2526,
4852,
4859,
1305,
4442,
3336,
63,
1160,
6038,
450,
83,
275,
11539,
83,
624,
450,
334,
288,
6499,
608,
63,
765,
63,
10000,
395,
661,
31240,
16829,
267,
3336,
63,
1580,
275,
359,
470,
59,
16,
61,
367,
522,
315,
2467,
14,
10174,
5106,
398,
1978,
63,
1113,
14,
952,
8,
288,
2467,
12,
1747,
12,
3336,
63,
1580,
12,
791,
4449,
63,
1580,
356,
3842,
20,
12,
333,
475,
63,
4449,
63,
344,
1874,
1552,
421,
199,
318,
12810,
63,
18546,
63,
1648,
8,
1556,
304,
272,
408,
272,
4068,
6499,
608,
1470,
12,
15932,
63,
344,
365,
8717,
701,
15932,
63,
604,
63,
344,
14,
2136,
1077,
506,
272,
7688,
370,
1336,
4750,
15932,
2385,
2952,
2985,
4788,
314,
16214,
1159,
272,
4057,
63,
344,
465,
3932,
4057,
63,
2614,
63,
344,
14,
481,
5421,
641,
3336,
63,
344,
12,
367,
25210,
453,
6665,
314,
272,
10250,
2737,
6499,
608,
1470,
1928,
282,
4048,
4057,
687,
282,
13590,
503,
272,
9920,
1865,
14,
339,
1010,
28935,
1695,
14,
16,
12,
10952,
14569,
4046,
367,
314,
16214,
334,
4912,
687,
314,
272,
23700,
503,
9920,
2909,
370,
10952,
9,
787,
2597,
18894
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
6529,
26,
598,
310,
87,
287,
699,
65,
1631,
4446,
12,
17854,
12269,
820,
7879,
29199,
580,
199,
3,
259,
1898,
334,
35,
9,
6927,
24569,
475,
20290,
13950,
199,
3,
4519,
334,
35,
9,
6927,
377,
2523,
80,
699,
54,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
646,
2050,
199,
504,
5166,
14,
1490,
9375,
492,
1551,
9375,
12,
1551,
9375,
63,
1257,
199,
504,
5166,
492,
1115,
79,
1435,
12,
12824,
63,
998,
465,
1747,
199,
199,
2921,
275,
2050,
14,
5572,
360,
4299,
19217,
14,
9533,
358,
421,
199,
318,
1218,
63,
800,
1053,
63,
11463,
8,
1556,
12,
1747,
12,
4203,
304,
272,
408,
272,
799,
5899,
1736,
1744,
4124,
315,
8367,
14,
272,
520,
635,
2467,
26,
8692,
3920,
272,
520,
635,
1747,
26,
2876,
15418,
272,
520,
635,
4203,
26,
8692,
4203,
272,
408,
339,
4203,
275,
1115,
79,
1435,
14,
362,
63,
2293,
8,
1556,
14,
13238,
9,
272,
3708,
63,
1113,
275,
4203,
459,
9533,
14,
1648,
14,
604,
418,
339,
327,
21885,
272,
2467,
14,
2526,
8,
267,
408,
4859,
1305,
4442,
32727,
63,
8240,
6038,
536,
275,
450,
83,
2401,
1595,
275,
450,
83,
7208,
267,
661,
11463,
297,
283,
1287,
63,
11463,
63,
981,
342,
1333,
272,
522,
275,
2467,
14,
11591,
342,
272,
32727,
63,
8240,
275,
522,
436,
522,
59,
16,
61,
339,
327,
2372,
314,
440,
15924,
1915,
14569,
10632,
370,
1263,
23177,
6703,
9240,
272,
2467,
14,
2526,
8,
267,
408,
4859,
15932,
63,
604,
63,
344,
267,
4442,
10952,
63,
1185,
267,
6038,
15932,
63,
604,
63,
344,
365,
440,
2973,
267,
2401,
1174,
1137,
450,
83,
7208,
267,
661,
4456,
16829,
272,
367,
522,
315,
2467,
14,
10174,
837,
267,
3708,
275,
3708,
63,
1113,
14,
4570,
8,
1556,
12,
1747,
12,
522,
59,
16,
566,
398,
327,
10066,
267,
2467,
14,
2526,
8,
288,
408,
4859,
1305,
288,
4442,
32727,
63,
842,
288,
6038,
522,
63,
344,
275,
450,
83,
2401,
522,
63,
466,
275,
450,
83,
7208,
288,
334,
2515,
14,
1648,
63,
344,
14,
344,
12,
283,
9533,
14,
1648,
1333,
267,
522,
19,
275,
2467,
14,
11591,
342,
267,
32727,
63,
842,
275,
522,
19,
436,
522,
19,
59,
16,
61,
398,
327,
2790,
1736,
2081,
267,
2467,
14,
2526,
8,
288,
408,
4859,
1305,
288,
4442,
32727,
63,
800,
1053,
288,
6038,
2454,
63,
344,
275,
450,
83,
2401,
2727,
63,
344,
275,
450,
83,
624,
450,
334,
355,
32727,
63,
8240,
12,
32727,
63,
842,
430,
267,
522,
18,
275,
2467,
14,
11591,
342,
267,
32727,
63,
800,
1053,
275,
522,
18,
436,
522,
18,
59,
16,
61,
267,
340,
440,
32727,
63,
800,
1053,
26,
288,
2467,
14,
2526,
8,
355,
408,
10258,
12872,
32727,
63,
800,
1053,
334,
2442,
63,
344,
12,
2727,
63,
344,
12,
1174,
9,
355,
13992,
4366,
83,
12,
450,
83,
12,
450,
83,
9,
7208,
355,
334,
14947,
70,
63,
8240,
12,
32727,
63,
842,
12,
283,
4883,
16829,
421,
199,
318,
12810,
63,
2558,
63,
8621,
590,
63,
765,
8,
1556,
304,
272,
408,
272,
29625,
608,
1470,
402,
7585,
26,
1570,
314,
17169,
63,
765,
367,
314,
4877,
7475,
272,
4779,
89,
1035,
4779,
89,
11949,
272,
520,
635,
2467,
26,
8692,
3920,
272,
408,
272,
4203,
275,
1115,
79,
1435,
14,
362,
63,
2293,
8,
1556,
14,
13238,
9,
272,
1978,
63,
1113,
275,
4203,
459,
2558,
14,
1160,
418,
339,
333,
475,
63,
4449,
63,
344,
275,
4203,
459,
723,
14,
1238,
14,
576,
2278,
362,
63,
785,
63,
4443,
8,
267,
2467,
12,
1747,
12,
283,
9533,
297,
283,
4449,
63,
12806,
16,
63,
31240,
5832,
17,
61,
339,
6499,
608,
63,
765,
63,
10000,
275,
1551,
9375,
14,
362,
63,
10000,
63,
354,
360,
8621,
590,
63,
765,
358,
272,
340,
333,
475,
63,
4449,
63,
344,
26,
267,
3336,
63,
1580,
275,
942,
267,
2467,
14,
2526,
4852,
4859,
1305,
4442,
3336,
63,
1160,
6038,
450,
83,
275,
11539,
83,
624,
450,
334,
288,
6499,
608,
63,
765,
63,
10000,
395,
661,
31240,
16829,
267,
3336,
63,
1580,
275,
359,
470,
59,
16,
61,
367,
522,
315,
2467,
14,
10174,
5106,
398,
1978,
63,
1113,
14,
952,
8,
288,
2467,
12,
1747,
12,
3336,
63,
1580,
12,
791,
4449,
63,
1580,
356,
3842,
20,
12,
333,
475,
63,
4449,
63,
344,
1874,
1552,
421,
199,
318,
12810,
63,
18546,
63,
1648,
8,
1556,
304,
272,
408,
272,
4068,
6499,
608,
1470,
12,
15932,
63,
344,
365,
8717,
701,
15932,
63,
604,
63,
344,
14,
2136,
1077,
506,
272,
7688,
370,
1336,
4750,
15932,
2385,
2952,
2985,
4788,
314,
16214,
1159,
272,
4057,
63,
344,
465,
3932,
4057,
63,
2614,
63,
344,
14,
481,
5421,
641,
3336,
63,
344,
12,
367,
25210,
453,
6665,
314,
272,
10250,
2737,
6499,
608,
1470,
1928,
282,
4048,
4057,
687,
282,
13590,
503,
272,
9920,
1865,
14,
339,
1010,
28935,
1695,
14,
16,
12,
10952,
14569,
4046,
367,
314,
16214,
334,
4912,
687,
314,
272,
23700,
503,
9920,
2909,
370,
10952,
9,
787,
2597,
18894,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
waytai/django
|
tests/migrations/test_loader.py
|
165
|
13346
|
from __future__ import unicode_literals
from unittest import skipIf
from django.db import connection, connections
from django.db.migrations.exceptions import AmbiguityError, NodeNotFoundError
from django.db.migrations.loader import MigrationLoader
from django.db.migrations.recorder import MigrationRecorder
from django.test import TestCase, modify_settings, override_settings
from django.utils import six
class RecorderTests(TestCase):
"""
Tests recording migrations as applied or not.
"""
def test_apply(self):
"""
Tests marking migrations as applied/unapplied.
"""
recorder = MigrationRecorder(connection)
self.assertEqual(
set((x, y) for (x, y) in recorder.applied_migrations() if x == "myapp"),
set(),
)
recorder.record_applied("myapp", "0432_ponies")
self.assertEqual(
set((x, y) for (x, y) in recorder.applied_migrations() if x == "myapp"),
{("myapp", "0432_ponies")},
)
# That should not affect records of another database
recorder_other = MigrationRecorder(connections['other'])
self.assertEqual(
set((x, y) for (x, y) in recorder_other.applied_migrations() if x == "myapp"),
set(),
)
recorder.record_unapplied("myapp", "0432_ponies")
self.assertEqual(
set((x, y) for (x, y) in recorder.applied_migrations() if x == "myapp"),
set(),
)
class LoaderTests(TestCase):
"""
Tests the disk and database loader, and running through migrations
in memory.
"""
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
@modify_settings(INSTALLED_APPS={'append': 'basic'})
def test_load(self):
"""
Makes sure the loader can load the migrations for the test apps,
and then render them out to a new Apps.
"""
# Load and test the plan
migration_loader = MigrationLoader(connection)
self.assertEqual(
migration_loader.graph.forwards_plan(("migrations", "0002_second")),
[
("migrations", "0001_initial"),
("migrations", "0002_second"),
],
)
# Now render it out!
project_state = migration_loader.project_state(("migrations", "0002_second"))
self.assertEqual(len(project_state.models), 2)
author_state = project_state.models["migrations", "author"]
self.assertEqual(
[x for x, y in author_state.fields],
["id", "name", "slug", "age", "rating"]
)
book_state = project_state.models["migrations", "book"]
self.assertEqual(
[x for x, y in book_state.fields],
["id", "author"]
)
# Ensure we've included unmigrated apps in there too
self.assertIn("basic", project_state.real_apps)
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_unmigdep"})
def test_load_unmigrated_dependency(self):
"""
Makes sure the loader can load migrations with a dependency on an unmigrated app.
"""
# Load and test the plan
migration_loader = MigrationLoader(connection)
self.assertEqual(
migration_loader.graph.forwards_plan(("migrations", "0001_initial")),
[
('contenttypes', '0001_initial'),
('auth', '0001_initial'),
("migrations", "0001_initial"),
],
)
# Now render it out!
project_state = migration_loader.project_state(("migrations", "0001_initial"))
self.assertEqual(len([m for a, m in project_state.models if a == "migrations"]), 1)
book_state = project_state.models["migrations", "book"]
self.assertEqual(
[x for x, y in book_state.fields],
["id", "user"]
)
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_run_before"})
def test_run_before(self):
"""
Makes sure the loader uses Migration.run_before.
"""
# Load and test the plan
migration_loader = MigrationLoader(connection)
self.assertEqual(
migration_loader.graph.forwards_plan(("migrations", "0002_second")),
[
("migrations", "0001_initial"),
("migrations", "0003_third"),
("migrations", "0002_second"),
],
)
@override_settings(MIGRATION_MODULES={
"migrations": "migrations.test_migrations_first",
"migrations2": "migrations2.test_migrations_2_first",
})
@modify_settings(INSTALLED_APPS={'append': 'migrations2'})
def test_first(self):
"""
Makes sure the '__first__' migrations build correctly.
"""
migration_loader = MigrationLoader(connection)
self.assertEqual(
migration_loader.graph.forwards_plan(("migrations", "second")),
[
("migrations", "thefirst"),
("migrations2", "0001_initial"),
("migrations2", "0002_second"),
("migrations", "second"),
],
)
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
def test_name_match(self):
"Tests prefix name matching"
migration_loader = MigrationLoader(connection)
self.assertEqual(
migration_loader.get_migration_by_prefix("migrations", "0001").name,
"0001_initial",
)
with self.assertRaises(AmbiguityError):
migration_loader.get_migration_by_prefix("migrations", "0")
with self.assertRaises(KeyError):
migration_loader.get_migration_by_prefix("migrations", "blarg")
def test_load_import_error(self):
with override_settings(MIGRATION_MODULES={"migrations": "import_error_package"}):
with self.assertRaises(ImportError):
MigrationLoader(connection)
def test_load_module_file(self):
with override_settings(MIGRATION_MODULES={"migrations": "migrations.faulty_migrations.file"}):
loader = MigrationLoader(connection)
self.assertIn(
"migrations", loader.unmigrated_apps,
"App with migrations module file not in unmigrated apps."
)
@skipIf(six.PY2, "PY2 doesn't load empty dirs.")
def test_load_empty_dir(self):
with override_settings(MIGRATION_MODULES={"migrations": "migrations.faulty_migrations.namespace"}):
loader = MigrationLoader(connection)
self.assertIn(
"migrations", loader.unmigrated_apps,
"App missing __init__.py in migrations module not in unmigrated apps."
)
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed"})
def test_loading_squashed(self):
"Tests loading a squashed migration"
migration_loader = MigrationLoader(connection)
recorder = MigrationRecorder(connection)
# Loading with nothing applied should just give us the one node
self.assertEqual(
len([x for x in migration_loader.graph.nodes if x[0] == "migrations"]),
1,
)
# However, fake-apply one migration and it should now use the old two
recorder.record_applied("migrations", "0001_initial")
migration_loader.build_graph()
self.assertEqual(
len([x for x in migration_loader.graph.nodes if x[0] == "migrations"]),
2,
)
recorder.flush()
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed_complex"})
def test_loading_squashed_complex(self):
"Tests loading a complex set of squashed migrations"
loader = MigrationLoader(connection)
recorder = MigrationRecorder(connection)
def num_nodes():
plan = set(loader.graph.forwards_plan(('migrations', '7_auto')))
return len(plan - loader.applied_migrations)
# Empty database: use squashed migration
loader.build_graph()
self.assertEqual(num_nodes(), 5)
# Starting at 1 or 2 should use the squashed migration too
recorder.record_applied("migrations", "1_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 4)
recorder.record_applied("migrations", "2_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 3)
# However, starting at 3 to 5 cannot use the squashed migration
recorder.record_applied("migrations", "3_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 4)
recorder.record_applied("migrations", "4_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 3)
# Starting at 5 to 7 we are passed the squashed migrations
recorder.record_applied("migrations", "5_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 2)
recorder.record_applied("migrations", "6_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 1)
recorder.record_applied("migrations", "7_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 0)
recorder.flush()
@override_settings(MIGRATION_MODULES={
"app1": "migrations.test_migrations_squashed_complex_multi_apps.app1",
"app2": "migrations.test_migrations_squashed_complex_multi_apps.app2",
})
@modify_settings(INSTALLED_APPS={'append': [
"migrations.test_migrations_squashed_complex_multi_apps.app1",
"migrations.test_migrations_squashed_complex_multi_apps.app2",
]})
def test_loading_squashed_complex_multi_apps(self):
loader = MigrationLoader(connection)
loader.build_graph()
plan = set(loader.graph.forwards_plan(('app1', '4_auto')))
expected_plan = {
('app1', '4_auto'),
('app1', '2_squashed_3'),
('app2', '1_squashed_2'),
('app1', '1_auto')
}
self.assertEqual(plan, expected_plan)
@override_settings(MIGRATION_MODULES={
"app1": "migrations.test_migrations_squashed_complex_multi_apps.app1",
"app2": "migrations.test_migrations_squashed_complex_multi_apps.app2",
})
@modify_settings(INSTALLED_APPS={'append': [
"migrations.test_migrations_squashed_complex_multi_apps.app1",
"migrations.test_migrations_squashed_complex_multi_apps.app2",
]})
def test_loading_squashed_complex_multi_apps_partially_applied(self):
loader = MigrationLoader(connection)
recorder = MigrationRecorder(connection)
recorder.record_applied('app1', '1_auto')
recorder.record_applied('app1', '2_auto')
loader.build_graph()
plan = set(loader.graph.forwards_plan(('app1', '4_auto')))
plan = plan - loader.applied_migrations
expected_plan = {
('app1', '4_auto'),
('app1', '3_auto'),
('app2', '1_squashed_2'),
}
self.assertEqual(plan, expected_plan)
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed_erroneous"})
def test_loading_squashed_erroneous(self):
"Tests loading a complex but erroneous set of squashed migrations"
loader = MigrationLoader(connection)
recorder = MigrationRecorder(connection)
def num_nodes():
plan = set(loader.graph.forwards_plan(('migrations', '7_auto')))
return len(plan - loader.applied_migrations)
# Empty database: use squashed migration
loader.build_graph()
self.assertEqual(num_nodes(), 5)
# Starting at 1 or 2 should use the squashed migration too
recorder.record_applied("migrations", "1_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 4)
recorder.record_applied("migrations", "2_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 3)
# However, starting at 3 or 4 we'd need to use non-existing migrations
msg = ("Migration migrations.6_auto depends on nonexistent node ('migrations', '5_auto'). "
"Django tried to replace migration migrations.5_auto with any of "
"[migrations.3_squashed_5] but wasn't able to because some of the replaced "
"migrations are already applied.")
recorder.record_applied("migrations", "3_auto")
with self.assertRaisesMessage(NodeNotFoundError, msg):
loader.build_graph()
recorder.record_applied("migrations", "4_auto")
with self.assertRaisesMessage(NodeNotFoundError, msg):
loader.build_graph()
# Starting at 5 to 7 we are passed the squashed migrations
recorder.record_applied("migrations", "5_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 2)
recorder.record_applied("migrations", "6_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 1)
recorder.record_applied("migrations", "7_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 0)
recorder.flush()
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
2882,
492,
3372,
3917,
199,
199,
504,
1639,
14,
697,
492,
1950,
12,
6947,
199,
504,
1639,
14,
697,
14,
7685,
14,
3924,
492,
437,
887,
528,
24180,
547,
12,
5013,
10870,
199,
504,
1639,
14,
697,
14,
7685,
14,
3422,
492,
12090,
5455,
199,
504,
1639,
14,
697,
14,
7685,
14,
27733,
492,
12090,
497,
16940,
199,
504,
1639,
14,
396,
492,
7640,
12,
2811,
63,
1751,
12,
4278,
63,
1751,
199,
504,
1639,
14,
1208,
492,
3816,
421,
199,
533,
799,
16940,
2925,
8,
1746,
304,
272,
408,
272,
6496,
20952,
6180,
465,
6781,
503,
440,
14,
272,
408,
339,
347,
511,
63,
4998,
8,
277,
304,
267,
408,
267,
6496,
31318,
6180,
465,
6781,
15,
324,
17250,
14,
267,
408,
267,
295,
16940,
275,
12090,
497,
16940,
8,
2105,
9,
267,
291,
14,
629,
8,
288,
663,
1332,
88,
12,
612,
9,
367,
334,
88,
12,
612,
9,
315,
295,
16940,
14,
17250,
63,
7685,
342,
340,
671,
508,
298,
1662,
571,
1288,
288,
663,
1062,
267,
776,
267,
295,
16940,
14,
3059,
63,
17250,
480,
1662,
571,
401,
298,
17436,
63,
678,
1500,
531,
267,
291,
14,
629,
8,
288,
663,
1332,
88,
12,
612,
9,
367,
334,
88,
12,
612,
9,
315,
295,
16940,
14,
17250,
63,
7685,
342,
340,
671,
508,
298,
1662,
571,
1288,
288,
469,
480,
1662,
571,
401,
298,
17436,
63,
678,
1500,
25988,
267,
776,
267,
327,
10314,
1077,
440,
12787,
5767,
402,
4573,
3050,
267,
295,
16940,
63,
1848,
275,
12090,
497,
16940,
8,
7995,
459,
1848,
1105,
267,
291,
14,
629,
8,
288,
663,
1332,
88,
12,
612,
9,
367,
334,
88,
12,
612,
9,
315,
295,
16940,
63,
1848,
14,
17250,
63,
7685,
342,
340,
671,
508,
298,
1662,
571,
1288,
288,
663,
1062,
267,
776,
267,
295,
16940,
14,
3059,
63,
324,
17250,
480,
1662,
571,
401,
298,
17436,
63,
678,
1500,
531,
267,
291,
14,
629,
8,
288,
663,
1332,
88,
12,
612,
9,
367,
334,
88,
12,
612,
9,
315,
295,
16940,
14,
17250,
63,
7685,
342,
340,
671,
508,
298,
1662,
571,
1288,
288,
663,
1062,
267,
776,
421,
199,
533,
22865,
2925,
8,
1746,
304,
272,
408,
272,
6496,
314,
4543,
436,
3050,
5077,
12,
436,
3879,
4012,
6180,
272,
315,
4402,
14,
272,
408,
339,
768,
4415,
63,
1751,
8,
22487,
23743,
63,
21194,
8871,
7685,
582,
298,
7685,
14,
396,
63,
7685,
5984,
272,
768,
8951,
63,
1751,
8,
15942,
63,
14219,
3713,
740,
356,
283,
4316,
3071,
272,
347,
511,
63,
912,
8,
277,
304,
267,
408,
267,
23365,
3238,
314,
5077,
883,
2248,
314,
6180,
367,
314,
511,
8686,
12,
267,
436,
2066,
3795,
3062,
734,
370,
282,
892,
4693,
83,
14,
267,
408,
267,
327,
7190,
436,
511,
314,
8683,
267,
8367,
63,
3422,
275,
12090,
5455,
8,
2105,
9,
267,
291,
14,
629,
8,
288,
8367,
63,
3422,
14,
2180,
14,
19159,
63,
5140,
9313,
7685,
401,
298,
9425,
63,
4375,
8150,
288,
359,
355,
1689,
7685,
401,
298,
4183,
63,
2747,
1288,
355,
1689,
7685,
401,
298,
9425,
63,
4375,
1288,
288,
2156,
267,
776,
267,
327,
7356,
3795,
652,
734,
1,
267,
2199,
63,
929,
275,
8367,
63,
3422,
14,
1715,
63,
929,
9313,
7685,
401,
298,
9425,
63,
4375,
2237,
267,
291,
14,
629,
8,
552,
8,
1715,
63,
929,
14,
992,
395,
499,
9,
398,
4132,
63,
929,
275,
2199,
63,
929,
14,
992,
905,
7685,
401,
298,
2502,
937,
267,
291,
14,
629,
8,
288,
359,
88,
367,
671,
12,
612,
315,
4132,
63,
929,
14,
955,
467,
288,
2097,
344,
401,
298,
354,
401,
298,
5464,
401,
298,
474,
401,
298,
10417,
937,
267,
776,
398,
6719,
63,
929,
275,
2199,
63,
929,
14,
992,
905,
7685,
401,
298,
2706,
937,
267,
291,
14,
629,
8,
288,
359,
88,
367,
671,
12,
612,
315,
6719,
63,
929,
14,
955,
467,
288,
2097,
344,
401,
298,
2502,
937,
267,
776,
398,
327,
7523,
781,
9064,
5120,
625,
31544,
8686,
315,
2337,
4634,
267,
291,
14,
4080,
480,
4316,
401,
2199,
63,
929,
14,
3093,
63,
5181,
9,
339,
768,
4415,
63,
1751,
8,
22487,
23743,
63,
21194,
8871,
7685,
582,
298,
7685,
14,
396,
63,
7685,
63,
324,
4071,
2601,
5984,
272,
347,
511,
63,
912,
63,
324,
31544,
63,
8575,
8,
277,
304,
267,
408,
267,
23365,
3238,
314,
5077,
883,
2248,
6180,
543,
282,
5936,
641,
376,
625,
31544,
1145,
14,
267,
408,
267,
327,
7190,
436,
511,
314,
8683,
267,
8367,
63,
3422,
275,
12090,
5455,
8,
2105,
9,
267,
291,
14,
629,
8,
288,
8367,
63,
3422,
14,
2180,
14,
19159,
63,
5140,
9313,
7685,
401,
298,
4183,
63,
2747,
8150,
288,
359,
355,
661,
10778,
297,
283,
4183,
63,
2747,
659,
355,
661,
1178,
297,
283,
4183,
63,
2747,
659,
355,
1689,
7685,
401,
298,
4183,
63,
2747,
1288,
288,
2156,
267,
776,
267,
327,
7356,
3795,
652,
734,
1,
267,
2199,
63,
929,
275,
8367,
63,
3422,
14,
1715,
63,
929,
9313,
7685,
401,
298,
4183,
63,
2747,
2237,
267,
291,
14,
629,
8,
552,
779,
77,
367,
282,
12,
333,
315,
2199,
63,
929,
14,
992,
340,
282,
508,
298,
7685,
10252,
413,
9,
398,
6719,
63,
929,
275,
2199,
63,
929,
14,
992,
905,
7685,
401,
298,
2706,
937,
267,
291,
14,
629,
8,
288,
359,
88,
367,
671,
12,
612,
315,
6719,
63,
929,
14,
955,
467,
288,
2097,
344,
401,
298,
751,
937,
267,
776,
339,
768,
4415,
63,
1751,
8,
22487,
23743,
63,
21194,
8871,
7685,
582,
298,
7685,
14,
396,
63,
7685,
63,
1065,
63,
5182,
5984,
272,
347,
511,
63,
1065,
63,
5182,
8,
277,
304,
267,
408,
267,
23365,
3238,
314,
5077,
4440,
12090,
14,
1065,
63,
5182,
14,
267,
408,
267,
327,
7190,
436,
511,
314,
8683,
267,
8367,
63,
3422,
275,
12090,
5455,
8,
2105,
9,
267,
291,
14,
629,
8,
288,
8367,
63,
3422,
14,
2180,
14,
19159,
63,
5140,
9313,
7685,
401,
298,
9425,
63,
4375,
8150,
288,
359,
355,
1689,
7685,
401,
298,
4183,
63
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
2882,
492,
3372,
3917,
199,
199,
504,
1639,
14,
697,
492,
1950,
12,
6947,
199,
504,
1639,
14,
697,
14,
7685,
14,
3924,
492,
437,
887,
528,
24180,
547,
12,
5013,
10870,
199,
504,
1639,
14,
697,
14,
7685,
14,
3422,
492,
12090,
5455,
199,
504,
1639,
14,
697,
14,
7685,
14,
27733,
492,
12090,
497,
16940,
199,
504,
1639,
14,
396,
492,
7640,
12,
2811,
63,
1751,
12,
4278,
63,
1751,
199,
504,
1639,
14,
1208,
492,
3816,
421,
199,
533,
799,
16940,
2925,
8,
1746,
304,
272,
408,
272,
6496,
20952,
6180,
465,
6781,
503,
440,
14,
272,
408,
339,
347,
511,
63,
4998,
8,
277,
304,
267,
408,
267,
6496,
31318,
6180,
465,
6781,
15,
324,
17250,
14,
267,
408,
267,
295,
16940,
275,
12090,
497,
16940,
8,
2105,
9,
267,
291,
14,
629,
8,
288,
663,
1332,
88,
12,
612,
9,
367,
334,
88,
12,
612,
9,
315,
295,
16940,
14,
17250,
63,
7685,
342,
340,
671,
508,
298,
1662,
571,
1288,
288,
663,
1062,
267,
776,
267,
295,
16940,
14,
3059,
63,
17250,
480,
1662,
571,
401,
298,
17436,
63,
678,
1500,
531,
267,
291,
14,
629,
8,
288,
663,
1332,
88,
12,
612,
9,
367,
334,
88,
12,
612,
9,
315,
295,
16940,
14,
17250,
63,
7685,
342,
340,
671,
508,
298,
1662,
571,
1288,
288,
469,
480,
1662,
571,
401,
298,
17436,
63,
678,
1500,
25988,
267,
776,
267,
327,
10314,
1077,
440,
12787,
5767,
402,
4573,
3050,
267,
295,
16940,
63,
1848,
275,
12090,
497,
16940,
8,
7995,
459,
1848,
1105,
267,
291,
14,
629,
8,
288,
663,
1332,
88,
12,
612,
9,
367,
334,
88,
12,
612,
9,
315,
295,
16940,
63,
1848,
14,
17250,
63,
7685,
342,
340,
671,
508,
298,
1662,
571,
1288,
288,
663,
1062,
267,
776,
267,
295,
16940,
14,
3059,
63,
324,
17250,
480,
1662,
571,
401,
298,
17436,
63,
678,
1500,
531,
267,
291,
14,
629,
8,
288,
663,
1332,
88,
12,
612,
9,
367,
334,
88,
12,
612,
9,
315,
295,
16940,
14,
17250,
63,
7685,
342,
340,
671,
508,
298,
1662,
571,
1288,
288,
663,
1062,
267,
776,
421,
199,
533,
22865,
2925,
8,
1746,
304,
272,
408,
272,
6496,
314,
4543,
436,
3050,
5077,
12,
436,
3879,
4012,
6180,
272,
315,
4402,
14,
272,
408,
339,
768,
4415,
63,
1751,
8,
22487,
23743,
63,
21194,
8871,
7685,
582,
298,
7685,
14,
396,
63,
7685,
5984,
272,
768,
8951,
63,
1751,
8,
15942,
63,
14219,
3713,
740,
356,
283,
4316,
3071,
272,
347,
511,
63,
912,
8,
277,
304,
267,
408,
267,
23365,
3238,
314,
5077,
883,
2248,
314,
6180,
367,
314,
511,
8686,
12,
267,
436,
2066,
3795,
3062,
734,
370,
282,
892,
4693,
83,
14,
267,
408,
267,
327,
7190,
436,
511,
314,
8683,
267,
8367,
63,
3422,
275,
12090,
5455,
8,
2105,
9,
267,
291,
14,
629,
8,
288,
8367,
63,
3422,
14,
2180,
14,
19159,
63,
5140,
9313,
7685,
401,
298,
9425,
63,
4375,
8150,
288,
359,
355,
1689,
7685,
401,
298,
4183,
63,
2747,
1288,
355,
1689,
7685,
401,
298,
9425,
63,
4375,
1288,
288,
2156,
267,
776,
267,
327,
7356,
3795,
652,
734,
1,
267,
2199,
63,
929,
275,
8367,
63,
3422,
14,
1715,
63,
929,
9313,
7685,
401,
298,
9425,
63,
4375,
2237,
267,
291,
14,
629,
8,
552,
8,
1715,
63,
929,
14,
992,
395,
499,
9,
398,
4132,
63,
929,
275,
2199,
63,
929,
14,
992,
905,
7685,
401,
298,
2502,
937,
267,
291,
14,
629,
8,
288,
359,
88,
367,
671,
12,
612,
315,
4132,
63,
929,
14,
955,
467,
288,
2097,
344,
401,
298,
354,
401,
298,
5464,
401,
298,
474,
401,
298,
10417,
937,
267,
776,
398,
6719,
63,
929,
275,
2199,
63,
929,
14,
992,
905,
7685,
401,
298,
2706,
937,
267,
291,
14,
629,
8,
288,
359,
88,
367,
671,
12,
612,
315,
6719,
63,
929,
14,
955,
467,
288,
2097,
344,
401,
298,
2502,
937,
267,
776,
398,
327,
7523,
781,
9064,
5120,
625,
31544,
8686,
315,
2337,
4634,
267,
291,
14,
4080,
480,
4316,
401,
2199,
63,
929,
14,
3093,
63,
5181,
9,
339,
768,
4415,
63,
1751,
8,
22487,
23743,
63,
21194,
8871,
7685,
582,
298,
7685,
14,
396,
63,
7685,
63,
324,
4071,
2601,
5984,
272,
347,
511,
63,
912,
63,
324,
31544,
63,
8575,
8,
277,
304,
267,
408,
267,
23365,
3238,
314,
5077,
883,
2248,
6180,
543,
282,
5936,
641,
376,
625,
31544,
1145,
14,
267,
408,
267,
327,
7190,
436,
511,
314,
8683,
267,
8367,
63,
3422,
275,
12090,
5455,
8,
2105,
9,
267,
291,
14,
629,
8,
288,
8367,
63,
3422,
14,
2180,
14,
19159,
63,
5140,
9313,
7685,
401,
298,
4183,
63,
2747,
8150,
288,
359,
355,
661,
10778,
297,
283,
4183,
63,
2747,
659,
355,
661,
1178,
297,
283,
4183,
63,
2747,
659,
355,
1689,
7685,
401,
298,
4183,
63,
2747,
1288,
288,
2156,
267,
776,
267,
327,
7356,
3795,
652,
734,
1,
267,
2199,
63,
929,
275,
8367,
63,
3422,
14,
1715,
63,
929,
9313,
7685,
401,
298,
4183,
63,
2747,
2237,
267,
291,
14,
629,
8,
552,
779,
77,
367,
282,
12,
333,
315,
2199,
63,
929,
14,
992,
340,
282,
508,
298,
7685,
10252,
413,
9,
398,
6719,
63,
929,
275,
2199,
63,
929,
14,
992,
905,
7685,
401,
298,
2706,
937,
267,
291,
14,
629,
8,
288,
359,
88,
367,
671,
12,
612,
315,
6719,
63,
929,
14,
955,
467,
288,
2097,
344,
401,
298,
751,
937,
267,
776,
339,
768,
4415,
63,
1751,
8,
22487,
23743,
63,
21194,
8871,
7685,
582,
298,
7685,
14,
396,
63,
7685,
63,
1065,
63,
5182,
5984,
272,
347,
511,
63,
1065,
63,
5182,
8,
277,
304,
267,
408,
267,
23365,
3238,
314,
5077,
4440,
12090,
14,
1065,
63,
5182,
14,
267,
408,
267,
327,
7190,
436,
511,
314,
8683,
267,
8367,
63,
3422,
275,
12090,
5455,
8,
2105,
9,
267,
291,
14,
629,
8,
288,
8367,
63,
3422,
14,
2180,
14,
19159,
63,
5140,
9313,
7685,
401,
298,
9425,
63,
4375,
8150,
288,
359,
355,
1689,
7685,
401,
298,
4183,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,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
flask/lib/python2.7/site-packages/sqlalchemy/orm/base.py
|
33
|
14668
|
# orm/base.py
# Copyright (C) 2005-2017 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""Constants and rudimental functions used throughout the ORM.
"""
from .. import util, inspection, exc as sa_exc
from ..sql import expression
from . import exc
import operator
PASSIVE_NO_RESULT = util.symbol(
'PASSIVE_NO_RESULT',
"""Symbol returned by a loader callable or other attribute/history
retrieval operation when a value could not be determined, based
on loader callable flags.
"""
)
ATTR_WAS_SET = util.symbol(
'ATTR_WAS_SET',
"""Symbol returned by a loader callable to indicate the
retrieved value, or values, were assigned to their attributes
on the target object.
"""
)
ATTR_EMPTY = util.symbol(
'ATTR_EMPTY',
"""Symbol used internally to indicate an attribute had no callable."""
)
NO_VALUE = util.symbol(
'NO_VALUE',
"""Symbol which may be placed as the 'previous' value of an attribute,
indicating no value was loaded for an attribute when it was modified,
and flags indicated we were not to load it.
"""
)
NEVER_SET = util.symbol(
'NEVER_SET',
"""Symbol which may be placed as the 'previous' value of an attribute
indicating that the attribute had not been assigned to previously.
"""
)
NO_CHANGE = util.symbol(
"NO_CHANGE",
"""No callables or SQL should be emitted on attribute access
and no state should change
""", canonical=0
)
CALLABLES_OK = util.symbol(
"CALLABLES_OK",
"""Loader callables can be fired off if a value
is not present.
""", canonical=1
)
SQL_OK = util.symbol(
"SQL_OK",
"""Loader callables can emit SQL at least on scalar value attributes.""",
canonical=2
)
RELATED_OBJECT_OK = util.symbol(
"RELATED_OBJECT_OK",
"""Callables can use SQL to load related objects as well
as scalar value attributes.
""", canonical=4
)
INIT_OK = util.symbol(
"INIT_OK",
"""Attributes should be initialized with a blank
value (None or an empty collection) upon get, if no other
value can be obtained.
""", canonical=8
)
NON_PERSISTENT_OK = util.symbol(
"NON_PERSISTENT_OK",
"""Callables can be emitted if the parent is not persistent.""",
canonical=16
)
LOAD_AGAINST_COMMITTED = util.symbol(
"LOAD_AGAINST_COMMITTED",
"""Callables should use committed values as primary/foreign keys during a
load.
""", canonical=32
)
NO_AUTOFLUSH = util.symbol(
"NO_AUTOFLUSH",
"""Loader callables should disable autoflush.""",
canonical=64
)
# pre-packaged sets of flags used as inputs
PASSIVE_OFF = util.symbol(
"PASSIVE_OFF",
"Callables can be emitted in all cases.",
canonical=(RELATED_OBJECT_OK | NON_PERSISTENT_OK |
INIT_OK | CALLABLES_OK | SQL_OK)
)
PASSIVE_RETURN_NEVER_SET = util.symbol(
"PASSIVE_RETURN_NEVER_SET",
"""PASSIVE_OFF ^ INIT_OK""",
canonical=PASSIVE_OFF ^ INIT_OK
)
PASSIVE_NO_INITIALIZE = util.symbol(
"PASSIVE_NO_INITIALIZE",
"PASSIVE_RETURN_NEVER_SET ^ CALLABLES_OK",
canonical=PASSIVE_RETURN_NEVER_SET ^ CALLABLES_OK
)
PASSIVE_NO_FETCH = util.symbol(
"PASSIVE_NO_FETCH",
"PASSIVE_OFF ^ SQL_OK",
canonical=PASSIVE_OFF ^ SQL_OK
)
PASSIVE_NO_FETCH_RELATED = util.symbol(
"PASSIVE_NO_FETCH_RELATED",
"PASSIVE_OFF ^ RELATED_OBJECT_OK",
canonical=PASSIVE_OFF ^ RELATED_OBJECT_OK
)
PASSIVE_ONLY_PERSISTENT = util.symbol(
"PASSIVE_ONLY_PERSISTENT",
"PASSIVE_OFF ^ NON_PERSISTENT_OK",
canonical=PASSIVE_OFF ^ NON_PERSISTENT_OK
)
DEFAULT_MANAGER_ATTR = '_sa_class_manager'
DEFAULT_STATE_ATTR = '_sa_instance_state'
_INSTRUMENTOR = ('mapper', 'instrumentor')
EXT_CONTINUE = util.symbol('EXT_CONTINUE')
EXT_STOP = util.symbol('EXT_STOP')
ONETOMANY = util.symbol(
'ONETOMANY',
"""Indicates the one-to-many direction for a :func:`.relationship`.
This symbol is typically used by the internals but may be exposed within
certain API features.
""")
MANYTOONE = util.symbol(
'MANYTOONE',
"""Indicates the many-to-one direction for a :func:`.relationship`.
This symbol is typically used by the internals but may be exposed within
certain API features.
""")
MANYTOMANY = util.symbol(
'MANYTOMANY',
"""Indicates the many-to-many direction for a :func:`.relationship`.
This symbol is typically used by the internals but may be exposed within
certain API features.
""")
NOT_EXTENSION = util.symbol(
'NOT_EXTENSION',
"""Symbol indicating an :class:`InspectionAttr` that's
not part of sqlalchemy.ext.
Is assigned to the :attr:`.InspectionAttr.extension_type`
attibute.
""")
_never_set = frozenset([NEVER_SET])
_none_set = frozenset([None, NEVER_SET, PASSIVE_NO_RESULT])
_SET_DEFERRED_EXPIRED = util.symbol("SET_DEFERRED_EXPIRED")
_DEFER_FOR_STATE = util.symbol("DEFER_FOR_STATE")
def _generative(*assertions):
"""Mark a method as generative, e.g. method-chained."""
@util.decorator
def generate(fn, *args, **kw):
self = args[0]._clone()
for assertion in assertions:
assertion(self, fn.__name__)
fn(self, *args[1:], **kw)
return self
return generate
# these can be replaced by sqlalchemy.ext.instrumentation
# if augmented class instrumentation is enabled.
def manager_of_class(cls):
return cls.__dict__.get(DEFAULT_MANAGER_ATTR, None)
instance_state = operator.attrgetter(DEFAULT_STATE_ATTR)
instance_dict = operator.attrgetter('__dict__')
def instance_str(instance):
"""Return a string describing an instance."""
return state_str(instance_state(instance))
def state_str(state):
"""Return a string describing an instance via its InstanceState."""
if state is None:
return "None"
else:
return '<%s at 0x%x>' % (state.class_.__name__, id(state.obj()))
def state_class_str(state):
"""Return a string describing an instance's class via its
InstanceState.
"""
if state is None:
return "None"
else:
return '<%s>' % (state.class_.__name__, )
def attribute_str(instance, attribute):
return instance_str(instance) + "." + attribute
def state_attribute_str(state, attribute):
return state_str(state) + "." + attribute
def object_mapper(instance):
"""Given an object, return the primary Mapper associated with the object
instance.
Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError`
if no mapping is configured.
This function is available via the inspection system as::
inspect(instance).mapper
Using the inspection system will raise
:class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is
not part of a mapping.
"""
return object_state(instance).mapper
def object_state(instance):
"""Given an object, return the :class:`.InstanceState`
associated with the object.
Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError`
if no mapping is configured.
Equivalent functionality is available via the :func:`.inspect`
function as::
inspect(instance)
Using the inspection system will raise
:class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is
not part of a mapping.
"""
state = _inspect_mapped_object(instance)
if state is None:
raise exc.UnmappedInstanceError(instance)
else:
return state
@inspection._inspects(object)
def _inspect_mapped_object(instance):
try:
return instance_state(instance)
# TODO: whats the py-2/3 syntax to catch two
# different kinds of exceptions at once ?
except exc.UnmappedClassError:
return None
except exc.NO_STATE:
return None
def _class_to_mapper(class_or_mapper):
insp = inspection.inspect(class_or_mapper, False)
if insp is not None:
return insp.mapper
else:
raise exc.UnmappedClassError(class_or_mapper)
def _mapper_or_none(entity):
"""Return the :class:`.Mapper` for the given class or None if the
class is not mapped.
"""
insp = inspection.inspect(entity, False)
if insp is not None:
return insp.mapper
else:
return None
def _is_mapped_class(entity):
"""Return True if the given object is a mapped class,
:class:`.Mapper`, or :class:`.AliasedClass`.
"""
insp = inspection.inspect(entity, False)
return insp is not None and \
not insp.is_clause_element and \
(
insp.is_mapper or insp.is_aliased_class
)
def _attr_as_key(attr):
if hasattr(attr, 'key'):
return attr.key
else:
return expression._column_as_key(attr)
def _orm_columns(entity):
insp = inspection.inspect(entity, False)
if hasattr(insp, 'selectable') and hasattr(insp.selectable, 'c'):
return [c for c in insp.selectable.c]
else:
return [entity]
def _is_aliased_class(entity):
insp = inspection.inspect(entity, False)
return insp is not None and \
getattr(insp, "is_aliased_class", False)
def _entity_descriptor(entity, key):
"""Return a class attribute given an entity and string name.
May return :class:`.InstrumentedAttribute` or user-defined
attribute.
"""
insp = inspection.inspect(entity)
if insp.is_selectable:
description = entity
entity = insp.c
elif insp.is_aliased_class:
entity = insp.entity
description = entity
elif hasattr(insp, "mapper"):
description = entity = insp.mapper.class_
else:
description = entity
try:
return getattr(entity, key)
except AttributeError:
raise sa_exc.InvalidRequestError(
"Entity '%s' has no property '%s'" %
(description, key)
)
_state_mapper = util.dottedgetter('manager.mapper')
@inspection._inspects(type)
def _inspect_mapped_class(class_, configure=False):
try:
class_manager = manager_of_class(class_)
if not class_manager.is_mapped:
return None
mapper = class_manager.mapper
except exc.NO_STATE:
return None
else:
if configure and mapper._new_mappers:
mapper._configure_all()
return mapper
def class_mapper(class_, configure=True):
"""Given a class, return the primary :class:`.Mapper` associated
with the key.
Raises :exc:`.UnmappedClassError` if no mapping is configured
on the given class, or :exc:`.ArgumentError` if a non-class
object is passed.
Equivalent functionality is available via the :func:`.inspect`
function as::
inspect(some_mapped_class)
Using the inspection system will raise
:class:`sqlalchemy.exc.NoInspectionAvailable` if the class is not mapped.
"""
mapper = _inspect_mapped_class(class_, configure=configure)
if mapper is None:
if not isinstance(class_, type):
raise sa_exc.ArgumentError(
"Class object expected, got '%r'." % (class_, ))
raise exc.UnmappedClassError(class_)
else:
return mapper
class InspectionAttr(object):
"""A base class applied to all ORM objects that can be returned
by the :func:`.inspect` function.
The attributes defined here allow the usage of simple boolean
checks to test basic facts about the object returned.
While the boolean checks here are basically the same as using
the Python isinstance() function, the flags here can be used without
the need to import all of these classes, and also such that
the SQLAlchemy class system can change while leaving the flags
here intact for forwards-compatibility.
"""
__slots__ = ()
is_selectable = False
"""Return True if this object is an instance of :class:`.Selectable`."""
is_aliased_class = False
"""True if this object is an instance of :class:`.AliasedClass`."""
is_instance = False
"""True if this object is an instance of :class:`.InstanceState`."""
is_mapper = False
"""True if this object is an instance of :class:`.Mapper`."""
is_property = False
"""True if this object is an instance of :class:`.MapperProperty`."""
is_attribute = False
"""True if this object is a Python :term:`descriptor`.
This can refer to one of many types. Usually a
:class:`.QueryableAttribute` which handles attributes events on behalf
of a :class:`.MapperProperty`. But can also be an extension type
such as :class:`.AssociationProxy` or :class:`.hybrid_property`.
The :attr:`.InspectionAttr.extension_type` will refer to a constant
identifying the specific subtype.
.. seealso::
:attr:`.Mapper.all_orm_descriptors`
"""
is_clause_element = False
"""True if this object is an instance of :class:`.ClauseElement`."""
extension_type = NOT_EXTENSION
"""The extension type, if any.
Defaults to :data:`.interfaces.NOT_EXTENSION`
.. versionadded:: 0.8.0
.. seealso::
:data:`.HYBRID_METHOD`
:data:`.HYBRID_PROPERTY`
:data:`.ASSOCIATION_PROXY`
"""
class InspectionAttrInfo(InspectionAttr):
"""Adds the ``.info`` attribute to :class:`.InspectionAttr`.
The rationale for :class:`.InspectionAttr` vs. :class:`.InspectionAttrInfo`
is that the former is compatible as a mixin for classes that specify
``__slots__``; this is essentially an implementation artifact.
"""
@util.memoized_property
def info(self):
"""Info dictionary associated with the object, allowing user-defined
data to be associated with this :class:`.InspectionAttr`.
The dictionary is generated when first accessed. Alternatively,
it can be specified as a constructor argument to the
:func:`.column_property`, :func:`.relationship`, or :func:`.composite`
functions.
.. versionadded:: 0.8 Added support for .info to all
:class:`.MapperProperty` subclasses.
.. versionchanged:: 1.0.0 :attr:`.MapperProperty.info` is also
available on extension types via the
:attr:`.InspectionAttrInfo.info` attribute, so that it can apply
to a wider variety of ORM and extension constructs.
.. seealso::
:attr:`.QueryableAttribute.info`
:attr:`.SchemaItem.info`
"""
return {}
class _MappedAttribute(object):
"""Mixin for attributes which should be replaced by mapper-assigned
attributes.
"""
__slots__ = ()
|
apache-2.0
|
[
3,
9813,
15,
1095,
14,
647,
199,
3,
1898,
334,
35,
9,
11811,
13,
10680,
314,
14303,
11462,
436,
8417,
199,
3,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
624,
22185,
436,
519,
14525,
434,
279,
3423,
1202,
23088,
314,
23383,
14,
199,
199,
624,
199,
199,
504,
2508,
492,
4884,
12,
5261,
10303,
12,
3178,
465,
2937,
63,
2804,
199,
504,
2508,
3009,
492,
3965,
199,
504,
1275,
492,
3178,
199,
646,
4182,
199,
199,
29634,
63,
2826,
63,
9517,
275,
4884,
14,
5155,
8,
272,
283,
29634,
63,
2826,
63,
9517,
297,
272,
408,
8169,
2138,
701,
282,
5077,
4550,
503,
1163,
2225,
15,
5570,
272,
27157,
3439,
1380,
282,
574,
4293,
440,
506,
12037,
12,
4079,
272,
641,
5077,
4550,
3285,
14,
272,
408,
199,
9,
199,
199,
5280,
63,
55,
1179,
63,
3597,
275,
4884,
14,
5155,
8,
272,
283,
5280,
63,
55,
1179,
63,
3597,
297,
272,
408,
8169,
2138,
701,
282,
5077,
4550,
370,
6623,
314,
272,
12396,
574,
12,
503,
1338,
12,
4898,
7943,
370,
3932,
3004,
272,
641,
314,
1347,
909,
14,
272,
408,
199,
9,
199,
199,
5280,
63,
13993,
275,
4884,
14,
5155,
8,
272,
283,
5280,
63,
13993,
297,
272,
408,
8169,
1202,
14448,
370,
6623,
376,
2225,
10530,
949,
4550,
1041,
199,
9,
199,
199,
2826,
63,
7041,
275,
4884,
14,
5155,
8,
272,
283,
2826,
63,
7041,
297,
272,
408,
8169,
1314,
1443,
506,
15090,
465,
314,
283,
6352,
7,
574,
402,
376,
2225,
12,
272,
9297,
949,
574,
1990,
6511,
367,
376,
2225,
1380,
652,
1990,
6042,
12,
272,
436,
3285,
22141,
781,
4898,
440,
370,
2248,
652,
14,
272,
408,
199,
9,
199,
199,
6388,
2111,
63,
3597,
275,
4884,
14,
5155,
8,
272,
283,
6388,
2111,
63,
3597,
297,
272,
408,
8169,
1314,
1443,
506,
15090,
465,
314,
283,
6352,
7,
574,
402,
376,
2225,
272,
9297,
626,
314,
2225,
10530,
440,
2757,
7943,
370,
10889,
14,
272,
408,
199,
9,
199,
199,
2826,
63,
16062,
275,
4884,
14,
5155,
8,
272,
298,
2826,
63,
16062,
401,
272,
408,
1944,
28041,
503,
5385,
1077,
506,
19515,
641,
2225,
2879,
272,
436,
949,
1174,
1077,
1570,
272,
10327,
11358,
29,
16,
199,
9,
199,
199,
11978,
17041,
63,
3593,
275,
4884,
14,
5155,
8,
272,
298,
11978,
17041,
63,
3593,
401,
272,
408,
5455,
28041,
883,
506,
31974,
2331,
340,
282,
574,
272,
365,
440,
3451,
14,
272,
10327,
11358,
29,
17,
199,
9,
199,
199,
4657,
63,
3593,
275,
4884,
14,
5155,
8,
272,
298,
4657,
63,
3593,
401,
272,
408,
5455,
28041,
883,
8689,
5385,
737,
5210,
641,
6917,
574,
3004,
17129,
272,
11358,
29,
18,
199,
9,
199,
199,
13604,
6989,
63,
9868,
63,
3593,
275,
4884,
14,
5155,
8,
272,
298,
13604,
6989,
63,
9868,
63,
3593,
401,
272,
408,
2176,
5921,
883,
675,
5385,
370,
2248,
4048,
2251,
465,
5521,
272,
465,
6917,
574,
3004,
14,
272,
10327,
11358,
29,
20,
199,
9,
199,
199,
8727,
63,
3593,
275,
4884,
14,
5155,
8,
272,
298,
8727,
63,
3593,
401,
272,
408,
5379,
1077,
506,
10038,
543,
282,
4596,
272,
574,
334,
403,
503,
376,
2701,
3245,
9,
12188,
664,
12,
340,
949,
1163,
272,
574,
883,
506,
15884,
14,
272,
10327,
11358,
29,
24,
199,
9,
199,
199,
13887,
63,
4227,
29367,
1309,
63,
3593,
275,
4884,
14,
5155,
8,
272,
298,
13887,
63,
4227,
29367,
1309,
63,
3593,
401,
272,
408,
2176,
5921,
883,
506,
19515,
340,
314,
1676,
365,
440,
16149,
17129,
272,
11358,
29,
975,
199,
9,
199,
199,
7405,
63,
1254,
33,
7834,
63,
5378,
20779,
1149,
275,
4884,
14,
5155,
8,
272,
298,
7405,
63,
1254,
33,
7834,
63,
5378,
20779,
1149,
401,
272,
408,
2176,
5921,
1077,
675,
27659,
1338,
465,
5062,
15,
6846,
2883,
5309,
282,
272,
2248,
14,
272,
10327,
11358,
29,
708,
199,
9,
199,
199,
2826,
63,
13883,
32762,
275,
4884,
14,
5155,
8,
272,
298,
2826,
63,
13883,
32762,
401,
272,
408,
5455,
28041,
1077,
3507,
2599,
4939,
17129,
272,
11358,
29,
772,
199,
9,
199,
199,
3,
876,
13,
2491,
68,
5951,
402,
3285,
1202,
465,
4153,
199,
29634,
63,
7517,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
7517,
401,
272,
298,
2176,
5921,
883,
506,
19515,
315,
1006,
5560,
4765,
272,
11358,
2687,
13604,
6989,
63,
9868,
63,
3593,
1204,
11214,
63,
4227,
29367,
1309,
63,
3593,
1204,
2049,
20199,
63,
3593,
1204,
24251,
17041,
63,
3593,
1204,
5385,
63,
3593,
9,
199,
9,
199,
29634,
63,
9677,
63,
6388,
2111,
63,
3597,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
9677,
63,
6388,
2111,
63,
3597,
401,
272,
408,
29634,
63,
7517,
7167,
20199,
63,
3593,
7208,
272,
11358,
29,
29634,
63,
7517,
7167,
20199,
63,
3593,
199,
9,
199,
29634,
63,
2826,
63,
13768,
11025,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
2826,
63,
13768,
11025,
401,
272,
298,
29634,
63,
9677,
63,
6388,
2111,
63,
3597,
7167,
24251,
17041,
63,
3593,
401,
272,
11358,
29,
29634,
63,
9677,
63,
6388,
2111,
63,
3597,
7167,
24251,
17041,
63,
3593,
199,
9,
199,
29634,
63,
2826,
63,
32097,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
2826,
63,
32097,
401,
272,
298,
29634,
63,
7517,
7167,
5385,
63,
3593,
401,
272,
11358,
29,
29634,
63,
7517,
7167,
5385,
63,
3593,
199,
9,
199,
29634,
63,
2826,
63,
32097,
63,
13604,
6989,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
2826,
63,
32097,
63,
13604,
6989,
401,
272,
298,
29634,
63,
7517,
7167,
820,
2901,
6989,
63,
9868,
63,
3593,
401,
272,
11358,
29,
29634,
63,
7517,
7167,
820,
2901,
6989,
63,
9868,
63,
3593,
199,
9,
199,
29634,
63,
10452,
63,
4227,
29367,
1309,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
10452,
63,
4227,
29367,
1309,
401,
272,
298,
29634,
63,
7517,
7167,
11214,
63,
4227,
29367,
1309,
63,
3593,
401,
272,
11358,
29,
29634,
63
] |
[
9813,
15,
1095,
14,
647,
199,
3,
1898,
334,
35,
9,
11811,
13,
10680,
314,
14303,
11462,
436,
8417,
199,
3,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
624,
22185,
436,
519,
14525,
434,
279,
3423,
1202,
23088,
314,
23383,
14,
199,
199,
624,
199,
199,
504,
2508,
492,
4884,
12,
5261,
10303,
12,
3178,
465,
2937,
63,
2804,
199,
504,
2508,
3009,
492,
3965,
199,
504,
1275,
492,
3178,
199,
646,
4182,
199,
199,
29634,
63,
2826,
63,
9517,
275,
4884,
14,
5155,
8,
272,
283,
29634,
63,
2826,
63,
9517,
297,
272,
408,
8169,
2138,
701,
282,
5077,
4550,
503,
1163,
2225,
15,
5570,
272,
27157,
3439,
1380,
282,
574,
4293,
440,
506,
12037,
12,
4079,
272,
641,
5077,
4550,
3285,
14,
272,
408,
199,
9,
199,
199,
5280,
63,
55,
1179,
63,
3597,
275,
4884,
14,
5155,
8,
272,
283,
5280,
63,
55,
1179,
63,
3597,
297,
272,
408,
8169,
2138,
701,
282,
5077,
4550,
370,
6623,
314,
272,
12396,
574,
12,
503,
1338,
12,
4898,
7943,
370,
3932,
3004,
272,
641,
314,
1347,
909,
14,
272,
408,
199,
9,
199,
199,
5280,
63,
13993,
275,
4884,
14,
5155,
8,
272,
283,
5280,
63,
13993,
297,
272,
408,
8169,
1202,
14448,
370,
6623,
376,
2225,
10530,
949,
4550,
1041,
199,
9,
199,
199,
2826,
63,
7041,
275,
4884,
14,
5155,
8,
272,
283,
2826,
63,
7041,
297,
272,
408,
8169,
1314,
1443,
506,
15090,
465,
314,
283,
6352,
7,
574,
402,
376,
2225,
12,
272,
9297,
949,
574,
1990,
6511,
367,
376,
2225,
1380,
652,
1990,
6042,
12,
272,
436,
3285,
22141,
781,
4898,
440,
370,
2248,
652,
14,
272,
408,
199,
9,
199,
199,
6388,
2111,
63,
3597,
275,
4884,
14,
5155,
8,
272,
283,
6388,
2111,
63,
3597,
297,
272,
408,
8169,
1314,
1443,
506,
15090,
465,
314,
283,
6352,
7,
574,
402,
376,
2225,
272,
9297,
626,
314,
2225,
10530,
440,
2757,
7943,
370,
10889,
14,
272,
408,
199,
9,
199,
199,
2826,
63,
16062,
275,
4884,
14,
5155,
8,
272,
298,
2826,
63,
16062,
401,
272,
408,
1944,
28041,
503,
5385,
1077,
506,
19515,
641,
2225,
2879,
272,
436,
949,
1174,
1077,
1570,
272,
10327,
11358,
29,
16,
199,
9,
199,
199,
11978,
17041,
63,
3593,
275,
4884,
14,
5155,
8,
272,
298,
11978,
17041,
63,
3593,
401,
272,
408,
5455,
28041,
883,
506,
31974,
2331,
340,
282,
574,
272,
365,
440,
3451,
14,
272,
10327,
11358,
29,
17,
199,
9,
199,
199,
4657,
63,
3593,
275,
4884,
14,
5155,
8,
272,
298,
4657,
63,
3593,
401,
272,
408,
5455,
28041,
883,
8689,
5385,
737,
5210,
641,
6917,
574,
3004,
17129,
272,
11358,
29,
18,
199,
9,
199,
199,
13604,
6989,
63,
9868,
63,
3593,
275,
4884,
14,
5155,
8,
272,
298,
13604,
6989,
63,
9868,
63,
3593,
401,
272,
408,
2176,
5921,
883,
675,
5385,
370,
2248,
4048,
2251,
465,
5521,
272,
465,
6917,
574,
3004,
14,
272,
10327,
11358,
29,
20,
199,
9,
199,
199,
8727,
63,
3593,
275,
4884,
14,
5155,
8,
272,
298,
8727,
63,
3593,
401,
272,
408,
5379,
1077,
506,
10038,
543,
282,
4596,
272,
574,
334,
403,
503,
376,
2701,
3245,
9,
12188,
664,
12,
340,
949,
1163,
272,
574,
883,
506,
15884,
14,
272,
10327,
11358,
29,
24,
199,
9,
199,
199,
13887,
63,
4227,
29367,
1309,
63,
3593,
275,
4884,
14,
5155,
8,
272,
298,
13887,
63,
4227,
29367,
1309,
63,
3593,
401,
272,
408,
2176,
5921,
883,
506,
19515,
340,
314,
1676,
365,
440,
16149,
17129,
272,
11358,
29,
975,
199,
9,
199,
199,
7405,
63,
1254,
33,
7834,
63,
5378,
20779,
1149,
275,
4884,
14,
5155,
8,
272,
298,
7405,
63,
1254,
33,
7834,
63,
5378,
20779,
1149,
401,
272,
408,
2176,
5921,
1077,
675,
27659,
1338,
465,
5062,
15,
6846,
2883,
5309,
282,
272,
2248,
14,
272,
10327,
11358,
29,
708,
199,
9,
199,
199,
2826,
63,
13883,
32762,
275,
4884,
14,
5155,
8,
272,
298,
2826,
63,
13883,
32762,
401,
272,
408,
5455,
28041,
1077,
3507,
2599,
4939,
17129,
272,
11358,
29,
772,
199,
9,
199,
199,
3,
876,
13,
2491,
68,
5951,
402,
3285,
1202,
465,
4153,
199,
29634,
63,
7517,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
7517,
401,
272,
298,
2176,
5921,
883,
506,
19515,
315,
1006,
5560,
4765,
272,
11358,
2687,
13604,
6989,
63,
9868,
63,
3593,
1204,
11214,
63,
4227,
29367,
1309,
63,
3593,
1204,
2049,
20199,
63,
3593,
1204,
24251,
17041,
63,
3593,
1204,
5385,
63,
3593,
9,
199,
9,
199,
29634,
63,
9677,
63,
6388,
2111,
63,
3597,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
9677,
63,
6388,
2111,
63,
3597,
401,
272,
408,
29634,
63,
7517,
7167,
20199,
63,
3593,
7208,
272,
11358,
29,
29634,
63,
7517,
7167,
20199,
63,
3593,
199,
9,
199,
29634,
63,
2826,
63,
13768,
11025,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
2826,
63,
13768,
11025,
401,
272,
298,
29634,
63,
9677,
63,
6388,
2111,
63,
3597,
7167,
24251,
17041,
63,
3593,
401,
272,
11358,
29,
29634,
63,
9677,
63,
6388,
2111,
63,
3597,
7167,
24251,
17041,
63,
3593,
199,
9,
199,
29634,
63,
2826,
63,
32097,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
2826,
63,
32097,
401,
272,
298,
29634,
63,
7517,
7167,
5385,
63,
3593,
401,
272,
11358,
29,
29634,
63,
7517,
7167,
5385,
63,
3593,
199,
9,
199,
29634,
63,
2826,
63,
32097,
63,
13604,
6989,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
2826,
63,
32097,
63,
13604,
6989,
401,
272,
298,
29634,
63,
7517,
7167,
820,
2901,
6989,
63,
9868,
63,
3593,
401,
272,
11358,
29,
29634,
63,
7517,
7167,
820,
2901,
6989,
63,
9868,
63,
3593,
199,
9,
199,
29634,
63,
10452,
63,
4227,
29367,
1309,
275,
4884,
14,
5155,
8,
272,
298,
29634,
63,
10452,
63,
4227,
29367,
1309,
401,
272,
298,
29634,
63,
7517,
7167,
11214,
63,
4227,
29367,
1309,
63,
3593,
401,
272,
11358,
29,
29634,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
camallen/aggregation
|
experimental/condor/animal_EM.py
|
2
|
7334
|
#!/usr/bin/env python
__author__ = 'greghines'
import numpy as np
import os
import pymongo
import sys
import cPickle as pickle
import bisect
import csv
import matplotlib.pyplot as plt
import random
import math
import urllib
import matplotlib.cbook as cbook
def index(a, x):
'Locate the leftmost value exactly equal to x'
i = bisect.bisect_left(a, x)
if i != len(a) and a[i] == x:
return i
raise ValueError
if os.path.exists("/home/ggdhines"):
sys.path.append("/home/ggdhines/PycharmProjects/reduction/experimental/clusteringAlg")
sys.path.append("/home/ggdhines/PycharmProjects/reduction/experimental/classifier")
else:
sys.path.append("/home/greg/github/reduction/experimental/clusteringAlg")
sys.path.append("/home/greg/github/reduction/experimental/classifier")
#from divisiveDBSCAN import DivisiveDBSCAN
from divisiveDBSCAN_multi import DivisiveDBSCAN
from divisiveKmeans import DivisiveKmeans
from iterativeEM import IterativeEM
if os.path.exists("/home/ggdhines"):
base_directory = "/home/ggdhines"
else:
base_directory = "/home/greg"
client = pymongo.MongoClient()
db = client['condor_2014-11-23']
classification_collection = db["condor_classifications"]
subject_collection = db["condor_subjects"]
big_userList = []
big_subjectList = []
animal_count = 0
f = open(base_directory+"/Databases/condor_ibcc.csv","wb")
f.write("a,b,c\n")
alreadyDone = []
animals_in_image = {}
animal_index = -1
global_user_list = []
animal_to_image = []
zooniverse_list = []
condor_votes = {}
animal_votes = {}
#subject_vote = {}
results = []
to_sample_from = list(subject_collection.find({"state":"complete"}))
to_sample_from2 = list(subject_collection.find({"classification_count":1,"state":"active"}))
votes = []
sample = random.sample(to_sample_from,100)
#sample.extend(random.sample(to_sample_from2,1000))
# for subject_index,subject in enumerate(sample):
# print "== " + str(subject_index)
# zooniverse_id = subject["zooniverse_id"]
# for user_index,classification in enumerate(classification_collection.find({"subjects.zooniverse_id":zooniverse_id})):
# if "user_name" in classification:
# user = classification["user_name"]
# else:
# user = classification["user_ip"]
#
# try:
# tt = index(big_userList,user)
# except ValueError:
# bisect.insort(big_userList,user)
for subject_index,subject in enumerate(sample):
print subject_index
zooniverse_id = subject["zooniverse_id"]
annotation_list = []
user_list = []
animal_list = []
#local_users = []
for user_index,classification in enumerate(classification_collection.find({"subjects.zooniverse_id":zooniverse_id})):
try:
mark_index = [ann.keys() for ann in classification["annotations"]].index(["marks",])
markings = classification["annotations"][mark_index].values()[0]
if "user_name" in classification:
user = classification["user_name"]
else:
user = classification["user_ip"]
found_condor = False
for animal in markings.values():
scale = 1.875
x = scale*float(animal["x"])
y = scale*float(animal["y"])
animal_type = animal["animal"]
if not(animal_type in ["carcassOrScale","carcass"]):
annotation_list.append((x,y))
#print annotation_list
user_list.append(user)
animal_list.append(animal_type)
if not(user in global_user_list):
global_user_list.append(user)
#local_users.append(user)
if animal_type == "condor":
found_condor = True
except (ValueError,KeyError):
pass
#if there were any markings on the image, use divisive kmeans to cluster the points so that each
#cluster represents an image
if annotation_list != []:
user_identified,clusters = DivisiveKmeans(3).fit2(annotation_list,user_list,debug=True)
#fix split clusters if necessary
if user_identified != []:
user_identified,clusters = DivisiveKmeans(3).__fix__(user_identified,clusters,annotation_list,user_list,200)
for center,c in zip(user_identified,clusters):
animal_index += 1
#animal_votes.append([])
animal_to_image.append(zooniverse_id)
if not(zooniverse_id in animals_in_image):
animals_in_image[zooniverse_id] = [animal_index]
else:
animals_in_image[zooniverse_id].append(animal_index)
results.append((zooniverse_id,center))
for pt in c:
pt_index = annotation_list.index(pt)
user_index = global_user_list.index(user_list[pt_index])
animal_type = animal_list[annotation_list.index(pt)]
if animal_type == "condor":
votes.append((user_index,animal_index,1))
if not(animal_index in animal_votes):
animal_votes[animal_index] = [1]
else:
animal_votes[animal_index].append(1)
else:
votes.append((user_index,animal_index,0))
if not(animal_index in animal_votes):
animal_votes[animal_index] = [0]
else:
animal_votes[animal_index].append(0)
print "=====---"
#print votes
classify = IterativeEM()
classify.__classify__(votes)
most_likely = classify.__getMostLikely__()
estimates = classify.__getEstimates__()
X = []
Y = []
X2 = []
Y2 = []
#for subject_index,zooniverse_id in enumerate(big_subjectList):
for ii in range(animal_index):
x = np.mean(animal_votes[ii])
y = estimates[ii][1]
X.append(x)
Y.append(y)
if math.fabs(x-y) > 0.3:
zooniverse_id,(centerX,centerY) = results[ii]
print x,y
subject = subject_collection.find_one({"zooniverse_id":zooniverse_id})
url = subject["location"]["standard"]
slash_index = url.rfind("/")
object_id = url[slash_index+1:]
if not(os.path.isfile(base_directory+"/Databases/condors/images/"+object_id)):
urllib.urlretrieve (url, base_directory+"/Databases/condors/images/"+object_id)
image_file = cbook.get_sample_data(base_directory+"/Databases/condors/images/"+object_id)
image = plt.imread(image_file)
fig, ax = plt.subplots()
im = ax.imshow(image)
plt.plot([centerX,],[centerY,],'o')
plt.show()
# #if ((x < 0.5) and (y > 0.5)) or ((x > 0.5) and (y < 0.5)):
# subject = subject_collection.find_one({"zooniverse_id":zooniverse_id})
# print x,y
# print subject["location"]["standard"]
# #print most_likely[subject_index],estimates[subject_index],np.mean(subject_vote[zooniverse_id])
#else:
# print estimates[subject_index],0
plt.plot(X,Y,'.',color="blue")
plt.plot(X2,Y2,'.',color="red")
plt.xlim((-0.05,1.05))
plt.ylim((-0.05,1.05))
plt.show()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
363,
2502,
363,
275,
283,
3939,
72,
3746,
7,
199,
646,
2680,
465,
980,
199,
646,
747,
199,
646,
21878,
199,
646,
984,
199,
646,
17572,
465,
5927,
199,
646,
19063,
199,
646,
7392,
199,
646,
8027,
14,
13563,
465,
4488,
199,
646,
2196,
199,
646,
3473,
199,
646,
4011,
199,
646,
8027,
14,
67,
2706,
465,
286,
2706,
421,
199,
318,
1478,
8,
65,
12,
671,
304,
272,
283,
3040,
323,
314,
29971,
574,
8840,
4472,
370,
671,
7,
272,
284,
275,
19063,
14,
23247,
63,
3039,
8,
65,
12,
671,
9,
272,
340,
284,
1137,
822,
8,
65,
9,
436,
282,
59,
73,
61,
508,
671,
26,
267,
372,
284,
272,
746,
1722,
199,
199,
692,
747,
14,
515,
14,
2444,
4769,
4219,
15,
2721,
7821,
3746,
2349,
272,
984,
14,
515,
14,
740,
4769,
4219,
15,
2721,
7821,
3746,
15,
2713,
1560,
77,
24286,
15,
22508,
15,
18924,
15,
25802,
28846,
531,
272,
984,
14,
515,
14,
740,
4769,
4219,
15,
2721,
7821,
3746,
15,
2713,
1560,
77,
24286,
15,
22508,
15,
18924,
15,
14720,
531,
199,
2836,
26,
272,
984,
14,
515,
14,
740,
4769,
4219,
15,
3939,
15,
5031,
15,
22508,
15,
18924,
15,
25802,
28846,
531,
272,
984,
14,
515,
14,
740,
4769,
4219,
15,
3939,
15,
5031,
15,
22508,
15,
18924,
15,
14720,
531,
199,
3,
504,
487,
433,
3398,
2846,
24078,
492,
3757,
433,
3398,
2846,
24078,
199,
504,
487,
433,
3398,
2846,
24078,
63,
3029,
492,
3757,
433,
3398,
2846,
24078,
199,
504,
487,
433,
3398,
43,
11579,
492,
3757,
433,
3398,
43,
11579,
199,
504,
4826,
857,
2769,
492,
473,
2967,
857,
2769,
199,
199,
692,
747,
14,
515,
14,
2444,
4769,
4219,
15,
2721,
7821,
3746,
2349,
272,
1300,
63,
3619,
275,
3286,
4219,
15,
2721,
7821,
3746,
2,
199,
2836,
26,
272,
1300,
63,
3619,
275,
3286,
4219,
15,
3939,
2,
199,
199,
1258,
275,
21878,
14,
20393,
3041,
342,
199,
697,
275,
1890,
459,
2067,
269,
63,
7280,
13,
845,
13,
1789,
418,
199,
14368,
63,
3627,
275,
1592,
905,
2067,
269,
63,
14368,
83,
937,
199,
5875,
63,
3627,
275,
1592,
905,
2067,
269,
63,
25660,
937,
6905,
199,
5076,
63,
751,
1296,
275,
942,
199,
5076,
63,
5875,
1296,
275,
942,
199,
290,
7265,
63,
835,
275,
378,
199,
199,
70,
275,
1551,
8,
1095,
63,
3619,
24792,
7243,
83,
15,
2067,
269,
63,
1892,
2055,
14,
4737,
2266,
6603,
531,
199,
70,
14,
952,
480,
65,
12,
66,
12,
67,
60,
78,
531,
199,
14039,
10759,
275,
942,
199,
22019,
2551,
63,
262,
63,
1569,
275,
1052,
199,
290,
7265,
63,
1080,
275,
446,
17,
199,
2966,
63,
751,
63,
513,
275,
942,
199,
290,
7265,
63,
475,
63,
1569,
275,
942,
199,
18070,
265,
73,
2077,
63,
513,
275,
942,
199,
2067,
269,
63,
16660,
275,
1052,
199,
290,
7265,
63,
16660,
275,
1052,
199,
3,
5875,
63,
14317,
275,
1052,
199,
2604,
275,
942,
199,
199,
475,
63,
3271,
63,
504,
275,
769,
8,
5875,
63,
3627,
14,
1623,
6333,
929,
5122,
4883,
3570,
430,
199,
475,
63,
3271,
63,
504,
18,
275,
769,
8,
5875,
63,
3627,
14,
1623,
6333,
14368,
63,
835,
582,
17,
4589,
929,
5122,
2682,
3570,
430,
199,
199,
16660,
275,
942,
199,
199,
3271,
275,
2196,
14,
3271,
8,
475,
63,
3271,
63,
504,
12,
1960,
9,
199,
3,
3271,
14,
2880,
8,
2355,
14,
3271,
8,
475,
63,
3271,
63,
504,
18,
12,
5279,
430,
199,
3,
367,
5420,
63,
1080,
12,
5875,
315,
3874,
8,
3271,
304,
199,
3,
258,
870,
298,
389,
298,
435,
620,
8,
5875,
63,
1080,
9,
199,
3,
258,
1315,
79,
265,
73,
2077,
63,
344,
275,
5420,
905,
18070,
265,
73,
2077,
63,
344,
937,
199,
3,
258,
367,
922,
63,
1080,
12,
14368,
315,
3874,
8,
14368,
63,
3627,
14,
1623,
6333,
25660,
14,
18070,
265,
73,
2077,
63,
344,
582,
18070,
265,
73,
2077,
63,
344,
1552,
304,
199,
3,
260,
340,
298,
751,
63,
354,
2,
315,
12505,
26,
199,
3,
3777,
922,
275,
12505,
905,
751,
63,
354,
937,
199,
3,
260,
587,
26,
199,
3,
3777,
922,
275,
12505,
905,
751,
63,
711,
937,
199,
3,
199,
3,
260,
862,
26,
199,
3,
3777,
13638,
275,
1478,
8,
5076,
63,
751,
1296,
12,
751,
9,
199,
3,
260,
871,
1722,
26,
199,
3,
3777,
19063,
14,
262,
3191,
8,
5076,
63,
751,
1296,
12,
751,
9,
6905,
199,
509,
5420,
63,
1080,
12,
5875,
315,
3874,
8,
3271,
304,
272,
870,
5420,
63,
1080,
272,
1315,
79,
265,
73,
2077,
63,
344,
275,
5420,
905,
18070,
265,
73,
2077,
63,
344,
937,
339,
11262,
63,
513,
275,
942,
272,
922,
63,
513,
275,
942,
272,
376,
7265,
63,
513,
275,
942,
272,
327,
1832,
63,
3707,
275,
942,
339,
367,
922,
63,
1080,
12,
14368,
315,
3874,
8,
14368,
63,
3627,
14,
1623,
6333,
25660,
14,
18070,
265,
73,
2077,
63,
344,
582,
18070,
265,
73,
2077,
63,
344,
1552,
304,
267,
862,
26,
288,
2216,
63,
1080,
275,
359,
1189,
14,
1612,
342,
367,
21172,
315,
12505,
905,
11270,
937,
1055,
1080,
5234,
10375,
401,
566,
288,
2216,
780,
275,
12505,
905,
11270,
9210,
1657,
63,
1080,
1055,
1459,
3430,
16,
61,
953,
340,
298,
751,
63,
354,
2,
315,
12505,
26,
355,
922,
275,
12505,
905,
751,
63,
354,
937,
288,
587,
26,
355,
922,
275,
12505,
905,
751,
63,
711,
937,
288,
1911,
63,
2067,
269,
275,
756,
953,
367,
376,
7265,
315,
2216,
780,
14,
1459,
837,
355,
4666,
275,
413,
14,
13357,
355,
671,
275,
4666,
10,
1609,
8,
290,
7265,
905,
88,
3135,
355,
612,
275,
4666,
10,
1609,
8,
290,
7265,
905,
89,
3135,
2234,
376,
7265,
63,
466,
275,
376,
7265,
905,
290,
7265,
937,
355,
340,
440,
8,
290,
7265,
63,
466,
315,
2097,
7007,
67,
405,
2844,
9944,
2266,
7007,
67,
405,
21473,
490,
11262,
63,
513,
14,
740,
1332,
88,
12,
89,
430,
490,
327,
1361,
11262,
63,
513,
490,
922,
63,
513,
14,
740,
8,
751,
9
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
363,
2502,
363,
275,
283,
3939,
72,
3746,
7,
199,
646,
2680,
465,
980,
199,
646,
747,
199,
646,
21878,
199,
646,
984,
199,
646,
17572,
465,
5927,
199,
646,
19063,
199,
646,
7392,
199,
646,
8027,
14,
13563,
465,
4488,
199,
646,
2196,
199,
646,
3473,
199,
646,
4011,
199,
646,
8027,
14,
67,
2706,
465,
286,
2706,
421,
199,
318,
1478,
8,
65,
12,
671,
304,
272,
283,
3040,
323,
314,
29971,
574,
8840,
4472,
370,
671,
7,
272,
284,
275,
19063,
14,
23247,
63,
3039,
8,
65,
12,
671,
9,
272,
340,
284,
1137,
822,
8,
65,
9,
436,
282,
59,
73,
61,
508,
671,
26,
267,
372,
284,
272,
746,
1722,
199,
199,
692,
747,
14,
515,
14,
2444,
4769,
4219,
15,
2721,
7821,
3746,
2349,
272,
984,
14,
515,
14,
740,
4769,
4219,
15,
2721,
7821,
3746,
15,
2713,
1560,
77,
24286,
15,
22508,
15,
18924,
15,
25802,
28846,
531,
272,
984,
14,
515,
14,
740,
4769,
4219,
15,
2721,
7821,
3746,
15,
2713,
1560,
77,
24286,
15,
22508,
15,
18924,
15,
14720,
531,
199,
2836,
26,
272,
984,
14,
515,
14,
740,
4769,
4219,
15,
3939,
15,
5031,
15,
22508,
15,
18924,
15,
25802,
28846,
531,
272,
984,
14,
515,
14,
740,
4769,
4219,
15,
3939,
15,
5031,
15,
22508,
15,
18924,
15,
14720,
531,
199,
3,
504,
487,
433,
3398,
2846,
24078,
492,
3757,
433,
3398,
2846,
24078,
199,
504,
487,
433,
3398,
2846,
24078,
63,
3029,
492,
3757,
433,
3398,
2846,
24078,
199,
504,
487,
433,
3398,
43,
11579,
492,
3757,
433,
3398,
43,
11579,
199,
504,
4826,
857,
2769,
492,
473,
2967,
857,
2769,
199,
199,
692,
747,
14,
515,
14,
2444,
4769,
4219,
15,
2721,
7821,
3746,
2349,
272,
1300,
63,
3619,
275,
3286,
4219,
15,
2721,
7821,
3746,
2,
199,
2836,
26,
272,
1300,
63,
3619,
275,
3286,
4219,
15,
3939,
2,
199,
199,
1258,
275,
21878,
14,
20393,
3041,
342,
199,
697,
275,
1890,
459,
2067,
269,
63,
7280,
13,
845,
13,
1789,
418,
199,
14368,
63,
3627,
275,
1592,
905,
2067,
269,
63,
14368,
83,
937,
199,
5875,
63,
3627,
275,
1592,
905,
2067,
269,
63,
25660,
937,
6905,
199,
5076,
63,
751,
1296,
275,
942,
199,
5076,
63,
5875,
1296,
275,
942,
199,
290,
7265,
63,
835,
275,
378,
199,
199,
70,
275,
1551,
8,
1095,
63,
3619,
24792,
7243,
83,
15,
2067,
269,
63,
1892,
2055,
14,
4737,
2266,
6603,
531,
199,
70,
14,
952,
480,
65,
12,
66,
12,
67,
60,
78,
531,
199,
14039,
10759,
275,
942,
199,
22019,
2551,
63,
262,
63,
1569,
275,
1052,
199,
290,
7265,
63,
1080,
275,
446,
17,
199,
2966,
63,
751,
63,
513,
275,
942,
199,
290,
7265,
63,
475,
63,
1569,
275,
942,
199,
18070,
265,
73,
2077,
63,
513,
275,
942,
199,
2067,
269,
63,
16660,
275,
1052,
199,
290,
7265,
63,
16660,
275,
1052,
199,
3,
5875,
63,
14317,
275,
1052,
199,
2604,
275,
942,
199,
199,
475,
63,
3271,
63,
504,
275,
769,
8,
5875,
63,
3627,
14,
1623,
6333,
929,
5122,
4883,
3570,
430,
199,
475,
63,
3271,
63,
504,
18,
275,
769,
8,
5875,
63,
3627,
14,
1623,
6333,
14368,
63,
835,
582,
17,
4589,
929,
5122,
2682,
3570,
430,
199,
199,
16660,
275,
942,
199,
199,
3271,
275,
2196,
14,
3271,
8,
475,
63,
3271,
63,
504,
12,
1960,
9,
199,
3,
3271,
14,
2880,
8,
2355,
14,
3271,
8,
475,
63,
3271,
63,
504,
18,
12,
5279,
430,
199,
3,
367,
5420,
63,
1080,
12,
5875,
315,
3874,
8,
3271,
304,
199,
3,
258,
870,
298,
389,
298,
435,
620,
8,
5875,
63,
1080,
9,
199,
3,
258,
1315,
79,
265,
73,
2077,
63,
344,
275,
5420,
905,
18070,
265,
73,
2077,
63,
344,
937,
199,
3,
258,
367,
922,
63,
1080,
12,
14368,
315,
3874,
8,
14368,
63,
3627,
14,
1623,
6333,
25660,
14,
18070,
265,
73,
2077,
63,
344,
582,
18070,
265,
73,
2077,
63,
344,
1552,
304,
199,
3,
260,
340,
298,
751,
63,
354,
2,
315,
12505,
26,
199,
3,
3777,
922,
275,
12505,
905,
751,
63,
354,
937,
199,
3,
260,
587,
26,
199,
3,
3777,
922,
275,
12505,
905,
751,
63,
711,
937,
199,
3,
199,
3,
260,
862,
26,
199,
3,
3777,
13638,
275,
1478,
8,
5076,
63,
751,
1296,
12,
751,
9,
199,
3,
260,
871,
1722,
26,
199,
3,
3777,
19063,
14,
262,
3191,
8,
5076,
63,
751,
1296,
12,
751,
9,
6905,
199,
509,
5420,
63,
1080,
12,
5875,
315,
3874,
8,
3271,
304,
272,
870,
5420,
63,
1080,
272,
1315,
79,
265,
73,
2077,
63,
344,
275,
5420,
905,
18070,
265,
73,
2077,
63,
344,
937,
339,
11262,
63,
513,
275,
942,
272,
922,
63,
513,
275,
942,
272,
376,
7265,
63,
513,
275,
942,
272,
327,
1832,
63,
3707,
275,
942,
339,
367,
922,
63,
1080,
12,
14368,
315,
3874,
8,
14368,
63,
3627,
14,
1623,
6333,
25660,
14,
18070,
265,
73,
2077,
63,
344,
582,
18070,
265,
73,
2077,
63,
344,
1552,
304,
267,
862,
26,
288,
2216,
63,
1080,
275,
359,
1189,
14,
1612,
342,
367,
21172,
315,
12505,
905,
11270,
937,
1055,
1080,
5234,
10375,
401,
566,
288,
2216,
780,
275,
12505,
905,
11270,
9210,
1657,
63,
1080,
1055,
1459,
3430,
16,
61,
953,
340,
298,
751,
63,
354,
2,
315,
12505,
26,
355,
922,
275,
12505,
905,
751,
63,
354,
937,
288,
587,
26,
355,
922,
275,
12505,
905,
751,
63,
711,
937,
288,
1911,
63,
2067,
269,
275,
756,
953,
367,
376,
7265,
315,
2216,
780,
14,
1459,
837,
355,
4666,
275,
413,
14,
13357,
355,
671,
275,
4666,
10,
1609,
8,
290,
7265,
905,
88,
3135,
355,
612,
275,
4666,
10,
1609,
8,
290,
7265,
905,
89,
3135,
2234,
376,
7265,
63,
466,
275,
376,
7265,
905,
290,
7265,
937,
355,
340,
440,
8,
290,
7265,
63,
466,
315,
2097,
7007,
67,
405,
2844,
9944,
2266,
7007,
67,
405,
21473,
490,
11262,
63,
513,
14,
740,
1332,
88,
12,
89,
430,
490,
327,
1361,
11262,
63,
513,
490,
922,
63,
513,
14,
740,
8,
751,
9,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
SlimRemix/android_external_chromium_org
|
tools/perf/measurements/timeline_controller.py
|
29
|
3494
|
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from measurements import smooth_gesture_util
from telemetry.core.platform import tracing_category_filter
from telemetry.core.platform import tracing_options
from telemetry.timeline.model import TimelineModel
from telemetry.page.actions import action_runner
from telemetry.web_perf import timeline_interaction_record as tir_module
RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions'
class TimelineController(object):
def __init__(self):
super(TimelineController, self).__init__()
self.trace_categories = None
self._model = None
self._renderer_process = None
self._smooth_records = []
self._interaction = None
def SetUp(self, page, tab):
"""Starts gathering timeline data.
"""
# Resets these member variables incase this object is reused.
self._model = None
self._renderer_process = None
if not tab.browser.platform.tracing_controller.IsChromeTracingSupported(
tab.browser):
raise Exception('Not supported')
category_filter = tracing_category_filter.TracingCategoryFilter(
filter_string=self.trace_categories)
for delay in page.GetSyntheticDelayCategories():
category_filter.AddSyntheticDelay(delay)
options = tracing_options.TracingOptions()
options.enable_chrome_trace = True
tab.browser.platform.tracing_controller.Start(options, category_filter)
def Start(self, tab):
# Start the smooth marker for all actions.
runner = action_runner.ActionRunner(tab)
self._interaction = runner.BeginInteraction(
RUN_SMOOTH_ACTIONS, is_smooth=True)
def Stop(self, tab):
# End the smooth marker for all actions.
self._interaction.End()
# Stop tracing.
timeline_data = tab.browser.platform.tracing_controller.Stop()
self._model = TimelineModel(timeline_data)
self._renderer_process = self._model.GetRendererProcessFromTabId(tab.id)
renderer_thread = self.model.GetRendererThreadFromTabId(tab.id)
run_smooth_actions_record = None
self._smooth_records = []
for event in renderer_thread.async_slices:
if not tir_module.IsTimelineInteractionRecord(event.name):
continue
r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
if r.label == RUN_SMOOTH_ACTIONS:
assert run_smooth_actions_record is None, (
'TimelineController cannot issue more than 1 %s record' %
RUN_SMOOTH_ACTIONS)
run_smooth_actions_record = r
elif r.is_smooth:
self._smooth_records.append(
smooth_gesture_util.GetAdjustedInteractionIfContainGesture(
self.model, r))
# If there is no other smooth records, we make measurements on time range
# marked by timeline_controller itself.
# TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that
# page sets are responsible for issueing the markers themselves.
if len(self._smooth_records) == 0 and run_smooth_actions_record:
self._smooth_records = [run_smooth_actions_record]
def CleanUp(self, tab):
if tab.browser.platform.tracing_controller.is_tracing_running:
tab.browser.platform.tracing_controller.Stop()
@property
def model(self):
return self._model
@property
def renderer_process(self):
return self._renderer_process
@property
def smooth_records(self):
return self._smooth_records
|
bsd-3-clause
|
[
3,
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
504,
32619,
492,
19608,
63,
3199,
608,
63,
1974,
199,
199,
504,
17298,
14,
1018,
14,
3246,
492,
23465,
63,
3710,
63,
1541,
199,
504,
17298,
14,
1018,
14,
3246,
492,
23465,
63,
1419,
199,
504,
17298,
14,
19369,
14,
1238,
492,
4703,
604,
1685,
199,
504,
17298,
14,
1606,
14,
3723,
492,
1595,
63,
5933,
199,
504,
17298,
14,
2520,
63,
9452,
492,
20780,
63,
21679,
63,
3059,
465,
3367,
82,
63,
578,
421,
199,
9390,
63,
51,
2679,
22949,
63,
25194,
275,
283,
2540,
51,
11607,
2422,
9303,
7,
421,
199,
533,
4703,
604,
7506,
8,
785,
304,
523,
347,
636,
826,
721,
277,
304,
272,
1613,
8,
27097,
7506,
12,
291,
2843,
826,
4533,
272,
291,
14,
3446,
63,
8906,
275,
488,
272,
291,
423,
1238,
275,
488,
272,
291,
423,
12471,
63,
1412,
275,
488,
272,
291,
423,
19169,
63,
6502,
275,
942,
272,
291,
423,
21679,
275,
488,
819,
347,
2494,
1721,
8,
277,
12,
2034,
12,
5174,
304,
272,
408,
32142,
13082,
316,
20780,
666,
14,
339,
408,
272,
327,
799,
2193,
3520,
3653,
2860,
315,
2546,
642,
909,
365,
24826,
14,
272,
291,
423,
1238,
275,
488,
272,
291,
423,
12471,
63,
1412,
275,
488,
272,
340,
440,
5174,
14,
5750,
14,
3246,
14,
21635,
63,
5538,
14,
1831,
18083,
2437,
4477,
10682,
8,
489,
5174,
14,
5750,
304,
489,
746,
2186,
360,
1763,
3748,
358,
272,
4637,
63,
1541,
275,
23465,
63,
3710,
63,
1541,
14,
2437,
4477,
7841,
4131,
8,
267,
2457,
63,
875,
29,
277,
14,
3446,
63,
8906,
9,
272,
367,
7339,
315,
2034,
14,
17526,
1236,
21231,
10796,
28731,
837,
489,
4637,
63,
1541,
14,
1123,
17746,
21231,
10796,
8,
5814,
9,
272,
1511,
275,
23465,
63,
1419,
14,
2437,
4477,
4558,
342,
272,
1511,
14,
4296,
63,
9887,
63,
3446,
275,
715,
272,
5174,
14,
5750,
14,
3246,
14,
21635,
63,
5538,
14,
3162,
8,
1419,
12,
4637,
63,
1541,
9,
819,
347,
7707,
8,
277,
12,
5174,
304,
272,
327,
7707,
314,
19608,
3608,
367,
1006,
5445,
14,
272,
7876,
275,
1595,
63,
5933,
14,
3310,
7446,
8,
2902,
9,
272,
291,
423,
21679,
275,
7876,
14,
5595,
31900,
8,
267,
21277,
63,
51,
2679,
22949,
63,
25194,
12,
365,
63,
19169,
29,
549,
9,
819,
347,
8015,
8,
277,
12,
5174,
304,
272,
327,
9599,
314,
19608,
3608,
367,
1006,
5445,
14,
272,
291,
423,
21679,
14,
3005,
342,
272,
327,
8015,
23465,
14,
272,
20780,
63,
576,
275,
5174,
14,
5750,
14,
3246,
14,
21635,
63,
5538,
14,
6293,
342,
272,
291,
423,
1238,
275,
4703,
604,
1685,
8,
19369,
63,
576,
9,
272,
291,
423,
12471,
63,
1412,
275,
291,
423,
1238,
14,
1002,
11355,
3498,
2532,
7690,
1304,
8,
2902,
14,
344,
9,
272,
11889,
63,
2671,
275,
291,
14,
1238,
14,
1002,
11355,
4436,
2532,
7690,
1304,
8,
2902,
14,
344,
9,
339,
1255,
63,
19169,
63,
3723,
63,
3059,
275,
488,
272,
291,
423,
19169,
63,
6502,
275,
942,
272,
367,
1566,
315,
11889,
63,
2671,
14,
4146,
63,
14865,
26,
489,
340,
440,
3367,
82,
63,
578,
14,
1831,
27097,
31900,
5433,
8,
1430,
14,
354,
304,
267,
1980,
489,
519,
275,
3367,
82,
63,
578,
14,
27097,
31900,
5433,
14,
2532,
12807,
2390,
8,
1430,
9,
489,
340,
519,
14,
1302,
508,
21277,
63,
51,
2679,
22949,
63,
25194,
26,
267,
702,
1255,
63,
19169,
63,
3723,
63,
3059,
365,
488,
12,
334,
881,
283,
27097,
7506,
3913,
4976,
1655,
2419,
413,
450,
83,
2777,
7,
450,
881,
21277,
63,
51,
2679,
22949,
63,
25194,
9,
267,
1255,
63,
19169,
63,
3723,
63,
3059,
275,
519,
489,
916,
519,
14,
374,
63,
19169,
26,
267,
291,
423,
19169,
63,
6502,
14,
740,
8,
881,
19608,
63,
3199,
608,
63,
1974,
14,
1002,
2767,
74,
7274,
31900,
3917,
31266,
39,
597,
608,
8,
288,
291,
14,
1238,
12,
519,
430,
339,
327,
982,
2337,
365,
949,
1163,
19608,
5767,
12,
781,
1852,
32619,
641,
900,
1425,
272,
327,
11584,
701,
20780,
63,
5538,
6337,
14,
272,
327,
3254,
8,
7439,
2753,
85,
28695,
304,
1380,
2467,
1266,
14,
957,
15,
9803,
10699,
365,
11584,
6317,
12,
7704,
3238,
626,
272,
327,
2034,
5951,
787,
17845,
367,
4976,
316,
314,
14327,
17279,
14,
272,
340,
822,
8,
277,
423,
19169,
63,
6502,
9,
508,
378,
436,
1255,
63,
19169,
63,
3723,
63,
3059,
26,
489,
291,
423,
19169,
63,
6502,
275,
359,
1065,
63,
19169,
63,
3723,
63,
3059,
61,
8330,
347,
12762,
1721,
8,
277,
12,
5174,
304,
272,
340,
5174,
14,
5750,
14,
3246,
14,
21635,
63,
5538,
14,
374,
63,
21635,
63,
5720,
26,
489,
5174,
14,
5750,
14,
3246,
14,
21635,
63,
5538,
14,
6293,
342,
819,
768,
1829,
523,
347,
1402,
8,
277,
304,
272,
372,
291,
423,
1238,
819,
768,
1829,
523,
347,
11889,
63,
1412,
8,
277,
304,
272,
372,
291,
423,
12471,
63,
1412,
819,
768,
1829,
523,
347,
19608,
63,
6502,
8,
277,
304,
272,
372,
291,
423,
19169,
63,
6502,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
504,
32619,
492,
19608,
63,
3199,
608,
63,
1974,
199,
199,
504,
17298,
14,
1018,
14,
3246,
492,
23465,
63,
3710,
63,
1541,
199,
504,
17298,
14,
1018,
14,
3246,
492,
23465,
63,
1419,
199,
504,
17298,
14,
19369,
14,
1238,
492,
4703,
604,
1685,
199,
504,
17298,
14,
1606,
14,
3723,
492,
1595,
63,
5933,
199,
504,
17298,
14,
2520,
63,
9452,
492,
20780,
63,
21679,
63,
3059,
465,
3367,
82,
63,
578,
421,
199,
9390,
63,
51,
2679,
22949,
63,
25194,
275,
283,
2540,
51,
11607,
2422,
9303,
7,
421,
199,
533,
4703,
604,
7506,
8,
785,
304,
523,
347,
636,
826,
721,
277,
304,
272,
1613,
8,
27097,
7506,
12,
291,
2843,
826,
4533,
272,
291,
14,
3446,
63,
8906,
275,
488,
272,
291,
423,
1238,
275,
488,
272,
291,
423,
12471,
63,
1412,
275,
488,
272,
291,
423,
19169,
63,
6502,
275,
942,
272,
291,
423,
21679,
275,
488,
819,
347,
2494,
1721,
8,
277,
12,
2034,
12,
5174,
304,
272,
408,
32142,
13082,
316,
20780,
666,
14,
339,
408,
272,
327,
799,
2193,
3520,
3653,
2860,
315,
2546,
642,
909,
365,
24826,
14,
272,
291,
423,
1238,
275,
488,
272,
291,
423,
12471,
63,
1412,
275,
488,
272,
340,
440,
5174,
14,
5750,
14,
3246,
14,
21635,
63,
5538,
14,
1831,
18083,
2437,
4477,
10682,
8,
489,
5174,
14,
5750,
304,
489,
746,
2186,
360,
1763,
3748,
358,
272,
4637,
63,
1541,
275,
23465,
63,
3710,
63,
1541,
14,
2437,
4477,
7841,
4131,
8,
267,
2457,
63,
875,
29,
277,
14,
3446,
63,
8906,
9,
272,
367,
7339,
315,
2034,
14,
17526,
1236,
21231,
10796,
28731,
837,
489,
4637,
63,
1541,
14,
1123,
17746,
21231,
10796,
8,
5814,
9,
272,
1511,
275,
23465,
63,
1419,
14,
2437,
4477,
4558,
342,
272,
1511,
14,
4296,
63,
9887,
63,
3446,
275,
715,
272,
5174,
14,
5750,
14,
3246,
14,
21635,
63,
5538,
14,
3162,
8,
1419,
12,
4637,
63,
1541,
9,
819,
347,
7707,
8,
277,
12,
5174,
304,
272,
327,
7707,
314,
19608,
3608,
367,
1006,
5445,
14,
272,
7876,
275,
1595,
63,
5933,
14,
3310,
7446,
8,
2902,
9,
272,
291,
423,
21679,
275,
7876,
14,
5595,
31900,
8,
267,
21277,
63,
51,
2679,
22949,
63,
25194,
12,
365,
63,
19169,
29,
549,
9,
819,
347,
8015,
8,
277,
12,
5174,
304,
272,
327,
9599,
314,
19608,
3608,
367,
1006,
5445,
14,
272,
291,
423,
21679,
14,
3005,
342,
272,
327,
8015,
23465,
14,
272,
20780,
63,
576,
275,
5174,
14,
5750,
14,
3246,
14,
21635,
63,
5538,
14,
6293,
342,
272,
291,
423,
1238,
275,
4703,
604,
1685,
8,
19369,
63,
576,
9,
272,
291,
423,
12471,
63,
1412,
275,
291,
423,
1238,
14,
1002,
11355,
3498,
2532,
7690,
1304,
8,
2902,
14,
344,
9,
272,
11889,
63,
2671,
275,
291,
14,
1238,
14,
1002,
11355,
4436,
2532,
7690,
1304,
8,
2902,
14,
344,
9,
339,
1255,
63,
19169,
63,
3723,
63,
3059,
275,
488,
272,
291,
423,
19169,
63,
6502,
275,
942,
272,
367,
1566,
315,
11889,
63,
2671,
14,
4146,
63,
14865,
26,
489,
340,
440,
3367,
82,
63,
578,
14,
1831,
27097,
31900,
5433,
8,
1430,
14,
354,
304,
267,
1980,
489,
519,
275,
3367,
82,
63,
578,
14,
27097,
31900,
5433,
14,
2532,
12807,
2390,
8,
1430,
9,
489,
340,
519,
14,
1302,
508,
21277,
63,
51,
2679,
22949,
63,
25194,
26,
267,
702,
1255,
63,
19169,
63,
3723,
63,
3059,
365,
488,
12,
334,
881,
283,
27097,
7506,
3913,
4976,
1655,
2419,
413,
450,
83,
2777,
7,
450,
881,
21277,
63,
51,
2679,
22949,
63,
25194,
9,
267,
1255,
63,
19169,
63,
3723,
63,
3059,
275,
519,
489,
916,
519,
14,
374,
63,
19169,
26,
267,
291,
423,
19169,
63,
6502,
14,
740,
8,
881,
19608,
63,
3199,
608,
63,
1974,
14,
1002,
2767,
74,
7274,
31900,
3917,
31266,
39,
597,
608,
8,
288,
291,
14,
1238,
12,
519,
430,
339,
327,
982,
2337,
365,
949,
1163,
19608,
5767,
12,
781,
1852,
32619,
641,
900,
1425,
272,
327,
11584,
701,
20780,
63,
5538,
6337,
14,
272,
327,
3254,
8,
7439,
2753,
85,
28695,
304,
1380,
2467,
1266,
14,
957,
15,
9803,
10699,
365,
11584,
6317,
12,
7704,
3238,
626,
272,
327,
2034,
5951,
787,
17845,
367,
4976,
316,
314,
14327,
17279,
14,
272,
340,
822,
8,
277,
423,
19169,
63,
6502,
9,
508,
378,
436,
1255,
63,
19169,
63,
3723,
63,
3059,
26,
489,
291,
423,
19169,
63,
6502,
275,
359,
1065,
63,
19169,
63,
3723,
63,
3059,
61,
8330,
347,
12762,
1721,
8,
277,
12,
5174,
304,
272,
340,
5174,
14,
5750,
14,
3246,
14,
21635,
63,
5538,
14,
374,
63,
21635,
63,
5720,
26,
489,
5174,
14,
5750,
14,
3246,
14,
21635,
63,
5538,
14,
6293,
342,
819,
768,
1829,
523,
347,
1402,
8,
277,
304,
272,
372,
291,
423,
1238,
819,
768,
1829,
523,
347,
11889,
63,
1412,
8,
277,
304,
272,
372,
291,
423,
12471,
63,
1412,
819,
768,
1829,
523,
347,
19608,
63,
6502,
8,
277,
304,
272,
372,
291,
423,
19169,
63,
6502,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
patilsangram/erpnext
|
erpnext/patches/v4_0/update_user_properties.py
|
119
|
1879
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
import frappe.permissions
import frappe.defaults
def execute():
frappe.reload_doc("core", "doctype", "docfield")
frappe.reload_doc("hr", "doctype", "employee")
set_print_email_permissions()
migrate_user_properties_to_user_permissions()
frappe.clear_cache()
def migrate_user_properties_to_user_permissions():
for d in frappe.db.sql("""select parent, defkey, defvalue from tabDefaultValue
where parent not in ('__global', '__default')""", as_dict=True):
df = frappe.db.sql("""select options from tabDocField
where fieldname=%s and fieldtype='Link'""", d.defkey, as_dict=True)
if df:
frappe.db.sql("""update tabDefaultValue
set defkey=%s, parenttype='User Permission'
where defkey=%s and
parent not in ('__global', '__default')""", (df[0].options, d.defkey))
def set_print_email_permissions():
# reset Page perms
from frappe.core.page.permission_manager.permission_manager import reset
reset("Page")
reset("Report")
if "allow_print" not in frappe.db.get_table_columns("DocType"):
return
# patch to move print, email into DocPerm
# NOTE: allow_print and allow_email are misnamed. They were used to hide print / hide email
for doctype, hide_print, hide_email in frappe.db.sql("""select name, ifnull(allow_print, 0), ifnull(allow_email, 0)
from `tabDocType` where ifnull(issingle, 0)=0 and ifnull(istable, 0)=0 and
(ifnull(allow_print, 0)=0 or ifnull(allow_email, 0)=0)"""):
if not hide_print:
frappe.db.sql("""update `tabDocPerm` set `print`=1
where permlevel=0 and `read`=1 and parent=%s""", doctype)
if not hide_email:
frappe.db.sql("""update `tabDocPerm` set `email`=1
where permlevel=0 and `read`=1 and parent=%s""", doctype)
|
gpl-3.0
|
[
3,
1898,
334,
67,
9,
6900,
12,
481,
5034,
19215,
29053,
14,
12126,
14,
436,
23212,
199,
3,
844,
26,
1664,
1696,
1684,
844,
373,
19,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
6950,
199,
646,
6950,
14,
6060,
199,
646,
6950,
14,
4322,
199,
199,
318,
5341,
837,
199,
198,
9098,
14,
9233,
63,
1301,
480,
1018,
401,
298,
6356,
401,
298,
1301,
698,
531,
199,
198,
9098,
14,
9233,
63,
1301,
480,
6271,
401,
298,
6356,
401,
298,
10103,
531,
421,
198,
409,
63,
1361,
63,
2123,
63,
6060,
342,
199,
198,
8462,
63,
751,
63,
3282,
63,
475,
63,
751,
63,
6060,
342,
421,
198,
9098,
14,
3584,
63,
1637,
342,
199,
199,
318,
12810,
63,
751,
63,
3282,
63,
475,
63,
751,
63,
6060,
837,
199,
198,
509,
366,
315,
6950,
14,
697,
14,
3009,
4852,
2416,
1676,
12,
347,
498,
12,
347,
585,
687,
5174,
2698,
1110,
507,
198,
4509,
1676,
440,
315,
25038,
2966,
297,
2560,
885,
358,
7208,
465,
63,
807,
29,
549,
304,
507,
198,
1587,
275,
6950,
14,
697,
14,
3009,
4852,
2416,
1511,
687,
5174,
3768,
792,
686,
198,
4509,
18887,
2458,
83,
436,
901,
466,
534,
3834,
7,
7208,
366,
14,
318,
498,
12,
465,
63,
807,
29,
549,
9,
2742,
198,
692,
4051,
26,
686,
198,
9098,
14,
697,
14,
3009,
4852,
873,
5174,
2698,
1110,
1585,
198,
409,
347,
498,
2458,
83,
12,
1676,
466,
534,
1899,
8779,
7,
1585,
198,
4509,
347,
498,
2458,
83,
436,
1585,
198,
1708,
440,
315,
25038,
2966,
297,
2560,
885,
358,
7208,
334,
1587,
59,
16,
1055,
1419,
12,
366,
14,
318,
498,
430,
199,
199,
318,
663,
63,
1361,
63,
2123,
63,
6060,
837,
199,
198,
3,
5305,
10331,
17340,
199,
198,
504,
6950,
14,
1018,
14,
1606,
14,
5693,
63,
2609,
14,
5693,
63,
2609,
492,
5305,
199,
198,
3958,
480,
3276,
531,
199,
198,
3958,
480,
7457,
531,
421,
198,
692,
298,
3306,
63,
1361,
2,
440,
315,
6950,
14,
697,
14,
362,
63,
1224,
63,
3406,
480,
3768,
804,
2349,
507,
198,
1107,
421,
198,
3,
3371,
370,
4057,
870,
12,
3031,
1901,
5454,
23554,
199,
198,
3,
6944,
26,
2040,
63,
1361,
436,
2040,
63,
2123,
787,
3201,
4579,
14,
9322,
4898,
1202,
370,
13714,
870,
1182,
13714,
3031,
199,
198,
509,
13265,
12,
13714,
63,
1361,
12,
13714,
63,
2123,
315,
6950,
14,
697,
14,
3009,
4852,
2416,
536,
12,
340,
2307,
8,
3306,
63,
1361,
12,
378,
395,
340,
2307,
8,
3306,
63,
2123,
12,
378,
9,
507,
198,
504,
658,
2902,
3768,
804,
64,
2382,
340,
2307,
8,
374,
4780,
12,
378,
23397,
16,
436,
340,
2307,
8,
631,
461,
12,
378,
23397,
16,
436,
507,
198,
8,
692,
2307,
8,
3306,
63,
1361,
12,
378,
23397,
16,
503,
340,
2307,
8,
3306,
63,
2123,
12,
378,
23397,
16,
9471,
304,
2742,
198,
692,
440,
13714,
63,
1361,
26,
686,
198,
9098,
14,
697,
14,
3009,
4852,
873,
658,
2902,
3768,
23554,
64,
663,
658,
1361,
64,
29,
17,
1585,
198,
4509,
10869,
1896,
29,
16,
436,
658,
739,
64,
29,
17,
436,
1676,
2458,
83,
7208,
13265,
9,
2742,
198,
692,
440,
13714,
63,
2123,
26,
686,
198,
9098,
14,
697,
14,
3009,
4852,
873,
658,
2902,
3768,
23554,
64,
663,
658,
2123,
64,
29,
17,
1585,
198,
4509,
10869,
1896,
29,
16,
436,
658,
739,
64,
29,
17,
436,
1676,
2458,
83,
7208,
13265,
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
] |
[
1898,
334,
67,
9,
6900,
12,
481,
5034,
19215,
29053,
14,
12126,
14,
436,
23212,
199,
3,
844,
26,
1664,
1696,
1684,
844,
373,
19,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
6950,
199,
646,
6950,
14,
6060,
199,
646,
6950,
14,
4322,
199,
199,
318,
5341,
837,
199,
198,
9098,
14,
9233,
63,
1301,
480,
1018,
401,
298,
6356,
401,
298,
1301,
698,
531,
199,
198,
9098,
14,
9233,
63,
1301,
480,
6271,
401,
298,
6356,
401,
298,
10103,
531,
421,
198,
409,
63,
1361,
63,
2123,
63,
6060,
342,
199,
198,
8462,
63,
751,
63,
3282,
63,
475,
63,
751,
63,
6060,
342,
421,
198,
9098,
14,
3584,
63,
1637,
342,
199,
199,
318,
12810,
63,
751,
63,
3282,
63,
475,
63,
751,
63,
6060,
837,
199,
198,
509,
366,
315,
6950,
14,
697,
14,
3009,
4852,
2416,
1676,
12,
347,
498,
12,
347,
585,
687,
5174,
2698,
1110,
507,
198,
4509,
1676,
440,
315,
25038,
2966,
297,
2560,
885,
358,
7208,
465,
63,
807,
29,
549,
304,
507,
198,
1587,
275,
6950,
14,
697,
14,
3009,
4852,
2416,
1511,
687,
5174,
3768,
792,
686,
198,
4509,
18887,
2458,
83,
436,
901,
466,
534,
3834,
7,
7208,
366,
14,
318,
498,
12,
465,
63,
807,
29,
549,
9,
2742,
198,
692,
4051,
26,
686,
198,
9098,
14,
697,
14,
3009,
4852,
873,
5174,
2698,
1110,
1585,
198,
409,
347,
498,
2458,
83,
12,
1676,
466,
534,
1899,
8779,
7,
1585,
198,
4509,
347,
498,
2458,
83,
436,
1585,
198,
1708,
440,
315,
25038,
2966,
297,
2560,
885,
358,
7208,
334,
1587,
59,
16,
1055,
1419,
12,
366,
14,
318,
498,
430,
199,
199,
318,
663,
63,
1361,
63,
2123,
63,
6060,
837,
199,
198,
3,
5305,
10331,
17340,
199,
198,
504,
6950,
14,
1018,
14,
1606,
14,
5693,
63,
2609,
14,
5693,
63,
2609,
492,
5305,
199,
198,
3958,
480,
3276,
531,
199,
198,
3958,
480,
7457,
531,
421,
198,
692,
298,
3306,
63,
1361,
2,
440,
315,
6950,
14,
697,
14,
362,
63,
1224,
63,
3406,
480,
3768,
804,
2349,
507,
198,
1107,
421,
198,
3,
3371,
370,
4057,
870,
12,
3031,
1901,
5454,
23554,
199,
198,
3,
6944,
26,
2040,
63,
1361,
436,
2040,
63,
2123,
787,
3201,
4579,
14,
9322,
4898,
1202,
370,
13714,
870,
1182,
13714,
3031,
199,
198,
509,
13265,
12,
13714,
63,
1361,
12,
13714,
63,
2123,
315,
6950,
14,
697,
14,
3009,
4852,
2416,
536,
12,
340,
2307,
8,
3306,
63,
1361,
12,
378,
395,
340,
2307,
8,
3306,
63,
2123,
12,
378,
9,
507,
198,
504,
658,
2902,
3768,
804,
64,
2382,
340,
2307,
8,
374,
4780,
12,
378,
23397,
16,
436,
340,
2307,
8,
631,
461,
12,
378,
23397,
16,
436,
507,
198,
8,
692,
2307,
8,
3306,
63,
1361,
12,
378,
23397,
16,
503,
340,
2307,
8,
3306,
63,
2123,
12,
378,
23397,
16,
9471,
304,
2742,
198,
692,
440,
13714,
63,
1361,
26,
686,
198,
9098,
14,
697,
14,
3009,
4852,
873,
658,
2902,
3768,
23554,
64,
663,
658,
1361,
64,
29,
17,
1585,
198,
4509,
10869,
1896,
29,
16,
436,
658,
739,
64,
29,
17,
436,
1676,
2458,
83,
7208,
13265,
9,
2742,
198,
692,
440,
13714,
63,
2123,
26,
686,
198,
9098,
14,
697,
14,
3009,
4852,
873,
658,
2902,
3768,
23554,
64,
663,
658,
2123,
64,
29,
17,
1585,
198,
4509,
10869,
1896,
29,
16,
436,
658,
739,
64,
29,
17,
436,
1676,
2458,
83,
7208,
13265,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
zerkrx/zerkbox
|
lib/chardet/cli/chardetect.py
|
198
|
2738
|
#!/usr/bin/env python
"""
Script which takes one or more file paths and reports on their detected
encodings
Example::
% chardetect somefile someotherfile
somefile: windows-1252 with confidence 0.5
someotherfile: ascii with confidence 1.0
If no paths are provided, it takes its input from stdin.
"""
from __future__ import absolute_import, print_function, unicode_literals
import argparse
import sys
from chardet import __version__
from chardet.compat import PY2
from chardet.universaldetector import UniversalDetector
def description_of(lines, name='stdin'):
"""
Return a string describing the probable encoding of a file or
list of strings.
:param lines: The lines to get the encoding of.
:type lines: Iterable of bytes
:param name: Name of file or collection of lines
:type name: str
"""
u = UniversalDetector()
for line in lines:
line = bytearray(line)
u.feed(line)
# shortcut out of the loop to save reading further - particularly useful if we read a BOM.
if u.done:
break
u.close()
result = u.result
if PY2:
name = name.decode(sys.getfilesystemencoding(), 'ignore')
if result['encoding']:
return '{0}: {1} with confidence {2}'.format(name, result['encoding'],
result['confidence'])
else:
return '{0}: no result'.format(name)
def main(argv=None):
"""
Handles command line arguments and gets things started.
:param argv: List of arguments, as if specified on the command-line.
If None, ``sys.argv[1:]`` is used instead.
:type argv: list of str
"""
# Get command line arguments
parser = argparse.ArgumentParser(
description="Takes one or more file paths and reports their detected \
encodings")
parser.add_argument('input',
help='File whose encoding we would like to determine. \
(default: stdin)',
type=argparse.FileType('rb'), nargs='*',
default=[sys.stdin if PY2 else sys.stdin.buffer])
parser.add_argument('--version', action='version',
version='%(prog)s {0}'.format(__version__))
args = parser.parse_args(argv)
for f in args.input:
if f.isatty():
print("You are running chardetect interactively. Press " +
"CTRL-D twice at the start of a blank line to signal the " +
"end of your input. If you want help, run chardetect " +
"--help\n", file=sys.stderr)
print(description_of(f, f.name))
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
624,
199,
5229,
1314,
6181,
1373,
503,
1655,
570,
3792,
436,
13924,
641,
3932,
10501,
199,
21138,
199,
199,
9846,
447,
339,
450,
1495,
13552,
2005,
493,
2005,
1848,
493,
272,
2005,
493,
26,
10061,
13,
19364,
543,
15197,
378,
14,
21,
272,
2005,
1848,
493,
26,
13294,
543,
15197,
413,
14,
16,
199,
199,
3917,
949,
3792,
787,
2741,
12,
652,
6181,
2399,
1324,
687,
9009,
14,
199,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
870,
63,
1593,
12,
2649,
63,
5955,
199,
199,
646,
7534,
199,
646,
984,
199,
199,
504,
28470,
492,
636,
1023,
363,
199,
504,
28470,
14,
5819,
492,
7843,
18,
199,
504,
28470,
14,
24866,
19401,
492,
29347,
24402,
421,
199,
318,
1369,
63,
1618,
8,
1278,
12,
536,
534,
6626,
735,
272,
408,
272,
1432,
282,
1059,
13660,
314,
5128,
461,
2644,
402,
282,
570,
503,
272,
769,
402,
3326,
14,
339,
520,
635,
2385,
26,
710,
2385,
370,
664,
314,
2644,
402,
14,
272,
520,
466,
2385,
26,
19937,
402,
2783,
272,
520,
635,
536,
26,
2812,
402,
570,
503,
3245,
402,
2385,
272,
520,
466,
536,
26,
620,
272,
408,
272,
399,
275,
29347,
24402,
342,
272,
367,
1004,
315,
2385,
26,
267,
1004,
275,
11640,
8,
604,
9,
267,
399,
14,
3871,
8,
604,
9,
267,
327,
17522,
734,
402,
314,
4438,
370,
3354,
7664,
9848,
446,
6770,
590,
2997,
340,
781,
1586,
282,
17720,
14,
267,
340,
399,
14,
4456,
26,
288,
2059,
272,
399,
14,
1600,
342,
272,
754,
275,
399,
14,
1099,
272,
340,
7843,
18,
26,
267,
536,
275,
536,
14,
2708,
8,
1274,
14,
23462,
32255,
1062,
283,
4247,
358,
272,
340,
754,
459,
2991,
2565,
267,
372,
5041,
16,
9160,
469,
17,
93,
543,
15197,
469,
18,
5285,
908,
8,
354,
12,
754,
459,
2991,
995,
9349,
754,
459,
13969,
1105,
272,
587,
26,
267,
372,
5041,
16,
9160,
949,
754,
1370,
908,
8,
354,
9,
421,
199,
318,
2446,
8,
3020,
29,
403,
304,
272,
408,
272,
23873,
1414,
1004,
2368,
436,
7545,
7645,
8239,
14,
339,
520,
635,
9238,
26,
3820,
402,
2368,
12,
465,
340,
2013,
641,
314,
1414,
13,
604,
14,
326,
982,
488,
12,
1124,
1274,
14,
3020,
59,
17,
2938,
1040,
365,
1202,
3140,
14,
272,
520,
466,
9238,
26,
769,
402,
620,
272,
408,
272,
327,
2372,
1414,
1004,
2368,
272,
1798,
275,
7534,
14,
10730,
8,
267,
1369,
628,
32488,
1373,
503,
1655,
570,
3792,
436,
13924,
3932,
10501,
971,
2151,
14134,
531,
272,
1798,
14,
525,
63,
2094,
360,
1210,
297,
717,
1720,
534,
1173,
7447,
2644,
781,
3955,
2839,
370,
6705,
14,
971,
2892,
334,
885,
26,
9009,
3196,
717,
730,
29,
18978,
14,
20683,
360,
4848,
659,
9237,
534,
7693,
717,
849,
1524,
1274,
14,
6626,
340,
7843,
18,
587,
984,
14,
6626,
14,
2738,
566,
272,
1798,
14,
525,
63,
2094,
4517,
1023,
297,
1595,
534,
1023,
297,
717,
1015,
29342,
6595,
9,
83,
469,
16,
5285,
908,
3460,
1023,
8964,
272,
1249,
275,
1798,
14,
1122,
63,
589,
8,
3020,
9,
339,
367,
289,
315,
1249,
14,
1210,
26,
267,
340,
289,
14,
21122,
837,
288,
870,
480,
5556,
787,
3879,
1495,
13552,
315,
2967,
67,
9462,
14,
23583,
298,
435,
2116,
298,
22584,
13,
36,
13373,
737,
314,
1343,
402,
282,
4596,
1004,
370,
4673,
314,
298,
435,
2116,
298,
500,
402,
2195,
1324,
14,
982,
1265,
2934,
1720,
12,
1255,
1495,
13552,
298,
435,
2116,
4320,
3437,
60,
78,
401,
570,
29,
1274,
14,
3083,
9,
267,
870,
8,
1802,
63,
1618,
8,
70,
12,
289,
14,
354,
430,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
624,
199,
5229,
1314,
6181,
1373,
503,
1655,
570,
3792,
436,
13924,
641,
3932,
10501,
199,
21138,
199,
199,
9846,
447,
339,
450,
1495,
13552,
2005,
493,
2005,
1848,
493,
272,
2005,
493,
26,
10061,
13,
19364,
543,
15197,
378,
14,
21,
272,
2005,
1848,
493,
26,
13294,
543,
15197,
413,
14,
16,
199,
199,
3917,
949,
3792,
787,
2741,
12,
652,
6181,
2399,
1324,
687,
9009,
14,
199,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
870,
63,
1593,
12,
2649,
63,
5955,
199,
199,
646,
7534,
199,
646,
984,
199,
199,
504,
28470,
492,
636,
1023,
363,
199,
504,
28470,
14,
5819,
492,
7843,
18,
199,
504,
28470,
14,
24866,
19401,
492,
29347,
24402,
421,
199,
318,
1369,
63,
1618,
8,
1278,
12,
536,
534,
6626,
735,
272,
408,
272,
1432,
282,
1059,
13660,
314,
5128,
461,
2644,
402,
282,
570,
503,
272,
769,
402,
3326,
14,
339,
520,
635,
2385,
26,
710,
2385,
370,
664,
314,
2644,
402,
14,
272,
520,
466,
2385,
26,
19937,
402,
2783,
272,
520,
635,
536,
26,
2812,
402,
570,
503,
3245,
402,
2385,
272,
520,
466,
536,
26,
620,
272,
408,
272,
399,
275,
29347,
24402,
342,
272,
367,
1004,
315,
2385,
26,
267,
1004,
275,
11640,
8,
604,
9,
267,
399,
14,
3871,
8,
604,
9,
267,
327,
17522,
734,
402,
314,
4438,
370,
3354,
7664,
9848,
446,
6770,
590,
2997,
340,
781,
1586,
282,
17720,
14,
267,
340,
399,
14,
4456,
26,
288,
2059,
272,
399,
14,
1600,
342,
272,
754,
275,
399,
14,
1099,
272,
340,
7843,
18,
26,
267,
536,
275,
536,
14,
2708,
8,
1274,
14,
23462,
32255,
1062,
283,
4247,
358,
272,
340,
754,
459,
2991,
2565,
267,
372,
5041,
16,
9160,
469,
17,
93,
543,
15197,
469,
18,
5285,
908,
8,
354,
12,
754,
459,
2991,
995,
9349,
754,
459,
13969,
1105,
272,
587,
26,
267,
372,
5041,
16,
9160,
949,
754,
1370,
908,
8,
354,
9,
421,
199,
318,
2446,
8,
3020,
29,
403,
304,
272,
408,
272,
23873,
1414,
1004,
2368,
436,
7545,
7645,
8239,
14,
339,
520,
635,
9238,
26,
3820,
402,
2368,
12,
465,
340,
2013,
641,
314,
1414,
13,
604,
14,
326,
982,
488,
12,
1124,
1274,
14,
3020,
59,
17,
2938,
1040,
365,
1202,
3140,
14,
272,
520,
466,
9238,
26,
769,
402,
620,
272,
408,
272,
327,
2372,
1414,
1004,
2368,
272,
1798,
275,
7534,
14,
10730,
8,
267,
1369,
628,
32488,
1373,
503,
1655,
570,
3792,
436,
13924,
3932,
10501,
971,
2151,
14134,
531,
272,
1798,
14,
525,
63,
2094,
360,
1210,
297,
717,
1720,
534,
1173,
7447,
2644,
781,
3955,
2839,
370,
6705,
14,
971,
2892,
334,
885,
26,
9009,
3196,
717,
730,
29,
18978,
14,
20683,
360,
4848,
659,
9237,
534,
7693,
717,
849,
1524,
1274,
14,
6626,
340,
7843,
18,
587,
984,
14,
6626,
14,
2738,
566,
272,
1798,
14,
525,
63,
2094,
4517,
1023,
297,
1595,
534,
1023,
297,
717,
1015,
29342,
6595,
9,
83,
469,
16,
5285,
908,
3460,
1023,
8964,
272,
1249,
275,
1798,
14,
1122,
63,
589,
8,
3020,
9,
339,
367,
289,
315,
1249,
14,
1210,
26,
267,
340,
289,
14,
21122,
837,
288,
870,
480,
5556,
787,
3879,
1495,
13552,
315,
2967,
67,
9462,
14,
23583,
298,
435,
2116,
298,
22584,
13,
36,
13373,
737,
314,
1343,
402,
282,
4596,
1004,
370,
4673,
314,
298,
435,
2116,
298,
500,
402,
2195,
1324,
14,
982,
1265,
2934,
1720,
12,
1255,
1495,
13552,
298,
435,
2116,
4320,
3437,
60,
78,
401,
570,
29,
1274,
14,
3083,
9,
267,
870,
8,
1802,
63,
1618,
8,
70,
12,
289,
14,
354,
430,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
fabioz/Pydev
|
plugins/org.python.pydev.jython/Lib/email/mime/audio.py
|
414
|
2683
|
# Copyright (C) 2001-2006 Python Software Foundation
# Author: Anthony Baxter
# Contact: email-sig@python.org
"""Class representing audio/* type MIME documents."""
__all__ = ['MIMEAudio']
import sndhdr
from cStringIO import StringIO
from email import encoders
from email.mime.nonmultipart import MIMENonMultipart
_sndhdr_MIMEmap = {'au' : 'basic',
'wav' :'x-wav',
'aiff':'x-aiff',
'aifc':'x-aiff',
}
# There are others in sndhdr that don't have MIME types. :(
# Additional ones to be added to sndhdr? midi, mp3, realaudio, wma??
def _whatsnd(data):
"""Try to identify a sound file type.
sndhdr.what() has a pretty cruddy interface, unfortunately. This is why
we re-do it here. It would be easier to reverse engineer the Unix 'file'
command and use the standard 'magic' file, as shipped with a modern Unix.
"""
hdr = data[:512]
fakefile = StringIO(hdr)
for testfn in sndhdr.tests:
res = testfn(hdr, fakefile)
if res is not None:
return _sndhdr_MIMEmap.get(res[0])
return None
class MIMEAudio(MIMENonMultipart):
"""Class for generating audio/* MIME documents."""
def __init__(self, _audiodata, _subtype=None,
_encoder=encoders.encode_base64, **_params):
"""Create an audio/* type MIME document.
_audiodata is a string containing the raw audio data. If this data
can be decoded by the standard Python `sndhdr' module, then the
subtype will be automatically included in the Content-Type header.
Otherwise, you can specify the specific audio subtype via the
_subtype parameter. If _subtype is not given, and no subtype can be
guessed, a TypeError is raised.
_encoder is a function which will perform the actual encoding for
transport of the image data. It takes one argument, which is this
Image instance. It should use get_payload() and set_payload() to
change the payload to the encoded form. It should also add any
Content-Transfer-Encoding or other headers to the message as
necessary. The default encoding is Base64.
Any additional keyword arguments are passed to the base class
constructor, which turns them into parameters on the Content-Type
header.
"""
if _subtype is None:
_subtype = _whatsnd(_audiodata)
if _subtype is None:
raise TypeError('Could not find audio MIME subtype')
MIMENonMultipart.__init__(self, 'audio', _subtype, **_params)
self.set_payload(_audiodata)
_encoder(self)
|
epl-1.0
|
[
3,
1898,
334,
35,
9,
12521,
13,
7968,
2018,
2290,
2752,
199,
3,
6529,
26,
1626,
898,
89,
699,
1219,
351,
199,
3,
18684,
26,
3031,
13,
4093,
32,
1548,
14,
1308,
199,
199,
624,
2543,
6144,
10491,
6331,
730,
14735,
8247,
1041,
199,
199,
363,
452,
363,
275,
788,
17057,
15484,
418,
199,
199,
646,
308,
977,
11244,
199,
199,
504,
15073,
492,
5228,
199,
504,
3031,
492,
10295,
83,
199,
504,
3031,
14,
7626,
14,
2865,
10123,
492,
603,
1469,
742,
265,
27242,
4388,
201,
199,
63,
83,
977,
11244,
63,
17057,
1130,
275,
791,
3844,
7,
221,
520,
283,
4316,
297,
673,
283,
19118,
7,
520,
7,
88,
13,
19118,
297,
673,
283,
5789,
556,
5242,
88,
13,
5789,
556,
297,
673,
283,
65,
25040,
5242,
88,
13,
5789,
556,
297,
673,
789,
199,
199,
3,
6006,
787,
11789,
315,
308,
977,
11244,
626,
2793,
1133,
1172,
14735,
2943,
14,
520,
8,
199,
3,
10961,
7869,
370,
506,
3483,
370,
308,
977,
11244,
31,
333,
9897,
12,
6118,
19,
12,
3363,
8130,
12,
336,
391,
10674,
199,
318,
485,
2191,
1956,
977,
8,
576,
304,
272,
408,
12357,
370,
10405,
282,
20453,
570,
730,
14,
339,
308,
977,
11244,
14,
10058,
342,
965,
282,
7268,
2467,
8615,
89,
3217,
12,
625,
21839,
14,
221,
961,
365,
10842,
272,
781,
295,
13,
1117,
652,
2348,
14,
221,
2779,
3955,
506,
14905,
370,
3837,
6869,
281,
314,
13074,
283,
493,
7,
272,
1414,
436,
675,
314,
4465,
283,
11523,
7,
570,
12,
465,
15924,
1915,
543,
282,
818,
11641,
13074,
14,
272,
408,
272,
15260,
275,
666,
1491,
7736,
61,
272,
4026,
493,
275,
5228,
8,
11244,
9,
272,
367,
511,
2324,
315,
308,
977,
11244,
14,
2219,
26,
267,
522,
275,
511,
2324,
8,
11244,
12,
4026,
493,
9,
267,
340,
522,
365,
440,
488,
26,
288,
372,
485,
83,
977,
11244,
63,
17057,
1130,
14,
362,
8,
470,
59,
16,
566,
272,
372,
488,
4388,
201,
199,
533,
14735,
15484,
8,
45,
1469,
742,
265,
27242,
304,
272,
408,
2543,
367,
12999,
10491,
6331,
14735,
8247,
1041,
339,
347,
636,
826,
721,
277,
12,
485,
23577,
22971,
12,
485,
10512,
29,
403,
12,
326,
485,
9347,
29,
9347,
83,
14,
2143,
63,
1095,
772,
12,
29666,
1162,
304,
267,
408,
2499,
376,
10491,
6331,
730,
14735,
2213,
14,
398,
485,
23577,
22971,
365,
282,
1059,
3035,
314,
3066,
10491,
666,
14,
221,
982,
642,
666,
267,
883,
506,
11203,
701,
314,
4465,
2018,
658,
83,
977,
11244,
7,
859,
12,
2066,
314,
267,
15686,
911,
506,
5847,
5120,
315,
314,
6646,
13,
804,
1406,
14,
267,
6630,
12,
1265,
883,
4165,
221,
314,
2488,
10491,
15686,
4799,
314,
267,
485,
10512,
2725,
14,
221,
982,
485,
10512,
365,
440,
1627,
12,
436,
949,
15686,
883,
506,
267,
29950,
12,
282,
3146,
365,
4915,
14,
398,
485,
9347,
365,
282,
805,
1314,
911,
5147,
314,
3503,
2644,
367,
267,
7773,
402,
314,
1834,
666,
14,
221,
2779,
6181,
1373,
1423,
12,
1314,
365,
642,
267,
6047,
1256,
14,
221,
2779,
1077,
675,
664,
63,
4749,
342,
436,
663,
63,
4749,
342,
370,
267,
1570,
314,
4886,
370,
314,
5737,
1824,
14,
221,
2779,
1077,
2597,
1050,
1263,
267,
6646,
13,
11761,
13,
7630,
503,
1163,
2323,
370,
314,
1245,
465,
267,
5784,
14,
221,
710,
849,
2644,
365,
3523,
772,
14,
398,
6184,
4722,
4252,
2368,
787,
3032,
370,
314,
1300,
1021,
267,
3787,
12,
1314,
25449,
3062,
1901,
2633,
641,
314,
6646,
13,
804,
267,
1406,
14,
267,
408,
267,
340,
485,
10512,
365,
488,
26,
288,
485,
10512,
275,
485,
2191,
1956,
977,
1547,
23577,
22971,
9,
267,
340,
485,
10512,
365,
488,
26,
288,
746,
3146,
360,
6531,
440,
2342,
10491,
14735,
15686,
358,
267,
603,
1469,
742,
265,
27242,
855,
826,
721,
277,
12,
283,
8130,
297,
485,
10512,
12,
29666,
1162,
9,
267,
291,
14,
409,
63,
4749,
1547,
23577,
22971,
9,
267,
485,
9347,
8,
277,
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
] |
[
1898,
334,
35,
9,
12521,
13,
7968,
2018,
2290,
2752,
199,
3,
6529,
26,
1626,
898,
89,
699,
1219,
351,
199,
3,
18684,
26,
3031,
13,
4093,
32,
1548,
14,
1308,
199,
199,
624,
2543,
6144,
10491,
6331,
730,
14735,
8247,
1041,
199,
199,
363,
452,
363,
275,
788,
17057,
15484,
418,
199,
199,
646,
308,
977,
11244,
199,
199,
504,
15073,
492,
5228,
199,
504,
3031,
492,
10295,
83,
199,
504,
3031,
14,
7626,
14,
2865,
10123,
492,
603,
1469,
742,
265,
27242,
4388,
201,
199,
63,
83,
977,
11244,
63,
17057,
1130,
275,
791,
3844,
7,
221,
520,
283,
4316,
297,
673,
283,
19118,
7,
520,
7,
88,
13,
19118,
297,
673,
283,
5789,
556,
5242,
88,
13,
5789,
556,
297,
673,
283,
65,
25040,
5242,
88,
13,
5789,
556,
297,
673,
789,
199,
199,
3,
6006,
787,
11789,
315,
308,
977,
11244,
626,
2793,
1133,
1172,
14735,
2943,
14,
520,
8,
199,
3,
10961,
7869,
370,
506,
3483,
370,
308,
977,
11244,
31,
333,
9897,
12,
6118,
19,
12,
3363,
8130,
12,
336,
391,
10674,
199,
318,
485,
2191,
1956,
977,
8,
576,
304,
272,
408,
12357,
370,
10405,
282,
20453,
570,
730,
14,
339,
308,
977,
11244,
14,
10058,
342,
965,
282,
7268,
2467,
8615,
89,
3217,
12,
625,
21839,
14,
221,
961,
365,
10842,
272,
781,
295,
13,
1117,
652,
2348,
14,
221,
2779,
3955,
506,
14905,
370,
3837,
6869,
281,
314,
13074,
283,
493,
7,
272,
1414,
436,
675,
314,
4465,
283,
11523,
7,
570,
12,
465,
15924,
1915,
543,
282,
818,
11641,
13074,
14,
272,
408,
272,
15260,
275,
666,
1491,
7736,
61,
272,
4026,
493,
275,
5228,
8,
11244,
9,
272,
367,
511,
2324,
315,
308,
977,
11244,
14,
2219,
26,
267,
522,
275,
511,
2324,
8,
11244,
12,
4026,
493,
9,
267,
340,
522,
365,
440,
488,
26,
288,
372,
485,
83,
977,
11244,
63,
17057,
1130,
14,
362,
8,
470,
59,
16,
566,
272,
372,
488,
4388,
201,
199,
533,
14735,
15484,
8,
45,
1469,
742,
265,
27242,
304,
272,
408,
2543,
367,
12999,
10491,
6331,
14735,
8247,
1041,
339,
347,
636,
826,
721,
277,
12,
485,
23577,
22971,
12,
485,
10512,
29,
403,
12,
326,
485,
9347,
29,
9347,
83,
14,
2143,
63,
1095,
772,
12,
29666,
1162,
304,
267,
408,
2499,
376,
10491,
6331,
730,
14735,
2213,
14,
398,
485,
23577,
22971,
365,
282,
1059,
3035,
314,
3066,
10491,
666,
14,
221,
982,
642,
666,
267,
883,
506,
11203,
701,
314,
4465,
2018,
658,
83,
977,
11244,
7,
859,
12,
2066,
314,
267,
15686,
911,
506,
5847,
5120,
315,
314,
6646,
13,
804,
1406,
14,
267,
6630,
12,
1265,
883,
4165,
221,
314,
2488,
10491,
15686,
4799,
314,
267,
485,
10512,
2725,
14,
221,
982,
485,
10512,
365,
440,
1627,
12,
436,
949,
15686,
883,
506,
267,
29950,
12,
282,
3146,
365,
4915,
14,
398,
485,
9347,
365,
282,
805,
1314,
911,
5147,
314,
3503,
2644,
367,
267,
7773,
402,
314,
1834,
666,
14,
221,
2779,
6181,
1373,
1423,
12,
1314,
365,
642,
267,
6047,
1256,
14,
221,
2779,
1077,
675,
664,
63,
4749,
342,
436,
663,
63,
4749,
342,
370,
267,
1570,
314,
4886,
370,
314,
5737,
1824,
14,
221,
2779,
1077,
2597,
1050,
1263,
267,
6646,
13,
11761,
13,
7630,
503,
1163,
2323,
370,
314,
1245,
465,
267,
5784,
14,
221,
710,
849,
2644,
365,
3523,
772,
14,
398,
6184,
4722,
4252,
2368,
787,
3032,
370,
314,
1300,
1021,
267,
3787,
12,
1314,
25449,
3062,
1901,
2633,
641,
314,
6646,
13,
804,
267,
1406,
14,
267,
408,
267,
340,
485,
10512,
365,
488,
26,
288,
485,
10512,
275,
485,
2191,
1956,
977,
1547,
23577,
22971,
9,
267,
340,
485,
10512,
365,
488,
26,
288,
746,
3146,
360,
6531,
440,
2342,
10491,
14735,
15686,
358,
267,
603,
1469,
742,
265,
27242,
855,
826,
721,
277,
12,
283,
8130,
297,
485,
10512,
12,
29666,
1162,
9,
267,
291,
14,
409,
63,
4749,
1547,
23577,
22971,
9,
267,
485,
9347,
8,
277,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
paulmadore/Eric-IDE
|
6-6.0.9/eric/Helpviewer/Bookmarks/BookmarksImporters/HtmlImporter.py
|
2
|
3356
|
# -*- coding: utf-8 -*-
# Copyright (c) 2012 - 2015 Detlev Offenbach <detlev@die-offenbachs.de>
#
"""
Module implementing an importer for HTML bookmark files.
"""
from __future__ import unicode_literals
import os
from PyQt5.QtCore import QCoreApplication, QDate, Qt
from .BookmarksImporter import BookmarksImporter
import UI.PixmapCache
def getImporterInfo(id):
"""
Module function to get information for the given HTML source id.
@param id id of the browser ("chrome" or "chromium")
@return tuple with an icon (QPixmap), readable name (string), name of
the default bookmarks file (string), an info text (string),
a prompt (string) and the default directory of the bookmarks file
(string)
@exception ValueError raised to indicate an invalid browser ID
"""
if id == "html":
return (
UI.PixmapCache.getPixmap("html.png"),
"HTML Netscape Bookmarks",
QCoreApplication.translate(
"HtmlImporter",
"HTML Netscape Bookmarks") + " (*.htm *.html)",
QCoreApplication.translate(
"HtmlImporter",
"""You can import bookmarks from any browser that supports"""
""" HTML exporting. This file has usually the extension"""
""" .htm or .html."""),
QCoreApplication.translate(
"HtmlImporter",
"""Please choose the file to begin importing bookmarks."""),
"",
)
else:
raise ValueError("Unsupported browser ID given ({0}).".format(id))
class HtmlImporter(BookmarksImporter):
"""
Class implementing the HTML bookmarks importer.
"""
def __init__(self, id="", parent=None):
"""
Constructor
@param id source ID (string)
@param parent reference to the parent object (QObject)
"""
super(HtmlImporter, self).__init__(id, parent)
self.__fileName = ""
self.__inFile = None
def setPath(self, path):
"""
Public method to set the path of the bookmarks file or directory.
@param path bookmarks file or directory (string)
"""
self.__fileName = path
def open(self):
"""
Public method to open the bookmarks file.
@return flag indicating success (boolean)
"""
if not os.path.exists(self.__fileName):
self._error = True
self._errorString = self.tr("File '{0}' does not exist.")\
.format(self.__fileName)
return False
return True
def importedBookmarks(self):
"""
Public method to get the imported bookmarks.
@return imported bookmarks (BookmarkNode)
"""
from ..BookmarkNode import BookmarkNode
from ..NsHtmlReader import NsHtmlReader
reader = NsHtmlReader()
importRootNode = reader.read(self.__fileName)
importRootNode.setType(BookmarkNode.Folder)
if self._id == "html":
importRootNode.title = self.tr("HTML Import")
else:
importRootNode.title = self.tr("Imported {0}")\
.format(QDate.currentDate().toString(Qt.SystemLocaleShortDate))
return importRootNode
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
334,
67,
9,
6029,
446,
6900,
577,
386,
6972,
28856,
287,
31983,
665,
271,
1118,
86,
32,
15130,
13,
1997,
287,
31983,
83,
14,
271,
30,
199,
3,
199,
199,
624,
199,
2377,
18234,
376,
13479,
367,
4163,
23799,
1584,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
747,
199,
199,
504,
14084,
21,
14,
10901,
492,
1413,
29263,
12,
1413,
2506,
12,
3959,
199,
199,
504,
1275,
8696,
10375,
18484,
492,
8944,
10375,
18484,
199,
199,
646,
14041,
14,
16049,
4437,
421,
199,
318,
664,
18484,
2354,
8,
344,
304,
272,
408,
272,
5673,
805,
370,
664,
2556,
367,
314,
1627,
4163,
1350,
1305,
14,
2286,
768,
635,
1305,
1305,
402,
314,
7042,
1689,
9887,
2,
503,
298,
13211,
531,
272,
768,
1107,
2008,
543,
376,
7016,
334,
49,
16049,
395,
12701,
536,
334,
875,
395,
536,
402,
267,
314,
849,
32410,
570,
334,
875,
395,
376,
2256,
1318,
334,
875,
395,
267,
282,
8457,
334,
875,
9,
436,
314,
849,
2082,
402,
314,
32410,
570,
267,
334,
875,
9,
272,
768,
1971,
1722,
4915,
370,
6623,
376,
3866,
7042,
2870,
272,
408,
272,
340,
1305,
508,
298,
1360,
582,
267,
372,
334,
288,
14041,
14,
16049,
4437,
14,
362,
16049,
480,
1360,
14,
4524,
1288,
288,
298,
4943,
20433,
8944,
10375,
401,
288,
1413,
29263,
14,
5275,
8,
355,
298,
12957,
18484,
401,
355,
298,
4943,
20433,
8944,
10375,
531,
435,
298,
334,
4856,
15575,
23588,
1360,
4186,
288,
1413,
29263,
14,
5275,
8,
355,
298,
12957,
18484,
401,
355,
408,
5556,
883,
492,
32410,
687,
1263,
7042,
626,
5171,
624,
355,
408,
4163,
4843,
316,
14,
961,
570,
965,
9987,
314,
3329,
624,
355,
408,
1275,
15575,
503,
1275,
1360,
1041,
395,
288,
1413,
29263,
14,
5275,
8,
355,
298,
12957,
18484,
401,
355,
408,
8254,
11496,
314,
570,
370,
5386,
16306,
32410,
1041,
395,
288,
4873,
267,
776,
272,
587,
26,
267,
746,
1722,
480,
12647,
7042,
2870,
1627,
11459,
16,
21385,
1674,
908,
8,
344,
430,
421,
199,
533,
20880,
18484,
8,
8696,
10375,
18484,
304,
272,
408,
272,
8089,
18234,
314,
4163,
32410,
13479,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1305,
8772,
1676,
29,
403,
304,
267,
408,
267,
20297,
2728,
768,
635,
1305,
1350,
2870,
334,
875,
9,
267,
768,
635,
1676,
3659,
370,
314,
1676,
909,
334,
32260,
9,
267,
408,
267,
1613,
8,
12957,
18484,
12,
291,
2843,
826,
721,
344,
12,
1676,
9,
2728,
291,
855,
15450,
275,
3087,
267,
291,
855,
262,
1173,
275,
488,
2286,
347,
663,
2042,
8,
277,
12,
931,
304,
267,
408,
267,
1684,
1083,
370,
663,
314,
931,
402,
314,
32410,
570,
503,
2082,
14,
2728,
768,
635,
931,
32410,
570,
503,
2082,
334,
875,
9,
267,
408,
267,
291,
855,
15450,
275,
931,
2286,
347,
1551,
8,
277,
304,
267,
408,
267,
1684,
1083,
370,
1551,
314,
32410,
570,
14,
2728,
768,
1107,
3305,
9297,
3182,
334,
4871,
9,
267,
408,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
277,
855,
15450,
304,
288,
291,
423,
705,
275,
715,
288,
291,
423,
705,
1558,
275,
291,
14,
454,
480,
1173,
5041,
16,
6834,
1630,
440,
2187,
2685,
60,
355,
1275,
908,
8,
277,
855,
15450,
9,
288,
372,
756,
267,
372,
715,
2286,
347,
8439,
8696,
10375,
8,
277,
304,
267,
408,
267,
1684,
1083,
370,
664,
314,
8439,
32410,
14,
2728,
768,
1107,
8439,
32410,
334,
8696,
1657,
1716,
9,
267,
408,
267,
687,
2508,
8696,
1657,
1716,
492,
8944,
1657,
1716,
267,
687,
2508,
2438,
12957,
5929,
492,
653,
83,
12957,
5929,
2728,
7002,
275,
653,
83,
12957,
5929,
342,
267,
492,
6405,
1716,
275,
7002,
14,
739,
8,
277,
855,
15450,
9,
2728,
492,
6405,
1716,
14,
409,
804,
8,
8696,
1657,
1716,
14,
7850,
9,
267,
340,
291,
423,
344,
508,
298,
1360,
582,
288,
492,
6405,
1716,
14,
1213,
275,
291,
14,
454,
480,
4943,
3161,
531,
267,
587,
26,
288,
492,
6405,
1716,
14,
1213,
275,
291,
14,
454,
480,
8499,
1376,
469,
16,
15412,
60,
355,
1275,
908,
8,
49,
2506,
14,
1818,
2506,
1252,
16695,
8,
4238,
14,
3989,
20342,
10039,
2506,
430,
267,
372,
492,
6405,
1716,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
1898,
334,
67,
9,
6029,
446,
6900,
577,
386,
6972,
28856,
287,
31983,
665,
271,
1118,
86,
32,
15130,
13,
1997,
287,
31983,
83,
14,
271,
30,
199,
3,
199,
199,
624,
199,
2377,
18234,
376,
13479,
367,
4163,
23799,
1584,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
747,
199,
199,
504,
14084,
21,
14,
10901,
492,
1413,
29263,
12,
1413,
2506,
12,
3959,
199,
199,
504,
1275,
8696,
10375,
18484,
492,
8944,
10375,
18484,
199,
199,
646,
14041,
14,
16049,
4437,
421,
199,
318,
664,
18484,
2354,
8,
344,
304,
272,
408,
272,
5673,
805,
370,
664,
2556,
367,
314,
1627,
4163,
1350,
1305,
14,
2286,
768,
635,
1305,
1305,
402,
314,
7042,
1689,
9887,
2,
503,
298,
13211,
531,
272,
768,
1107,
2008,
543,
376,
7016,
334,
49,
16049,
395,
12701,
536,
334,
875,
395,
536,
402,
267,
314,
849,
32410,
570,
334,
875,
395,
376,
2256,
1318,
334,
875,
395,
267,
282,
8457,
334,
875,
9,
436,
314,
849,
2082,
402,
314,
32410,
570,
267,
334,
875,
9,
272,
768,
1971,
1722,
4915,
370,
6623,
376,
3866,
7042,
2870,
272,
408,
272,
340,
1305,
508,
298,
1360,
582,
267,
372,
334,
288,
14041,
14,
16049,
4437,
14,
362,
16049,
480,
1360,
14,
4524,
1288,
288,
298,
4943,
20433,
8944,
10375,
401,
288,
1413,
29263,
14,
5275,
8,
355,
298,
12957,
18484,
401,
355,
298,
4943,
20433,
8944,
10375,
531,
435,
298,
334,
4856,
15575,
23588,
1360,
4186,
288,
1413,
29263,
14,
5275,
8,
355,
298,
12957,
18484,
401,
355,
408,
5556,
883,
492,
32410,
687,
1263,
7042,
626,
5171,
624,
355,
408,
4163,
4843,
316,
14,
961,
570,
965,
9987,
314,
3329,
624,
355,
408,
1275,
15575,
503,
1275,
1360,
1041,
395,
288,
1413,
29263,
14,
5275,
8,
355,
298,
12957,
18484,
401,
355,
408,
8254,
11496,
314,
570,
370,
5386,
16306,
32410,
1041,
395,
288,
4873,
267,
776,
272,
587,
26,
267,
746,
1722,
480,
12647,
7042,
2870,
1627,
11459,
16,
21385,
1674,
908,
8,
344,
430,
421,
199,
533,
20880,
18484,
8,
8696,
10375,
18484,
304,
272,
408,
272,
8089,
18234,
314,
4163,
32410,
13479,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1305,
8772,
1676,
29,
403,
304,
267,
408,
267,
20297,
2728,
768,
635,
1305,
1350,
2870,
334,
875,
9,
267,
768,
635,
1676,
3659,
370,
314,
1676,
909,
334,
32260,
9,
267,
408,
267,
1613,
8,
12957,
18484,
12,
291,
2843,
826,
721,
344,
12,
1676,
9,
2728,
291,
855,
15450,
275,
3087,
267,
291,
855,
262,
1173,
275,
488,
2286,
347,
663,
2042,
8,
277,
12,
931,
304,
267,
408,
267,
1684,
1083,
370,
663,
314,
931,
402,
314,
32410,
570,
503,
2082,
14,
2728,
768,
635,
931,
32410,
570,
503,
2082,
334,
875,
9,
267,
408,
267,
291,
855,
15450,
275,
931,
2286,
347,
1551,
8,
277,
304,
267,
408,
267,
1684,
1083,
370,
1551,
314,
32410,
570,
14,
2728,
768,
1107,
3305,
9297,
3182,
334,
4871,
9,
267,
408,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
277,
855,
15450,
304,
288,
291,
423,
705,
275,
715,
288,
291,
423,
705,
1558,
275,
291,
14,
454,
480,
1173,
5041,
16,
6834,
1630,
440,
2187,
2685,
60,
355,
1275,
908,
8,
277,
855,
15450,
9,
288,
372,
756,
267,
372,
715,
2286,
347,
8439,
8696,
10375,
8,
277,
304,
267,
408,
267,
1684,
1083,
370,
664,
314,
8439,
32410,
14,
2728,
768,
1107,
8439,
32410,
334,
8696,
1657,
1716,
9,
267,
408,
267,
687,
2508,
8696,
1657,
1716,
492,
8944,
1657,
1716,
267,
687,
2508,
2438,
12957,
5929,
492,
653,
83,
12957,
5929,
2728,
7002,
275,
653,
83,
12957,
5929,
342,
267,
492,
6405,
1716,
275,
7002,
14,
739,
8,
277,
855,
15450,
9,
2728,
492,
6405,
1716,
14,
409,
804,
8,
8696,
1657,
1716,
14,
7850,
9,
267,
340,
291,
423,
344,
508,
298,
1360,
582,
288,
492,
6405,
1716,
14,
1213,
275,
291,
14,
454,
480,
4943,
3161,
531,
267,
587,
26,
288,
492,
6405,
1716,
14,
1213,
275,
291,
14,
454,
480,
8499,
1376,
469,
16,
15412,
60,
355,
1275,
908,
8,
49,
2506,
14,
1818,
2506,
1252,
16695,
8,
4238,
14,
3989,
20342,
10039,
2506,
430,
267,
372,
492,
6405,
1716,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
xHeliotrope/injustice_dropper
|
env/lib/python3.4/site-packages/django/contrib/sessions/backends/base.py
|
99
|
11451
|
from __future__ import unicode_literals
import base64
import logging
import string
from datetime import datetime, timedelta
from django.conf import settings
from django.contrib.sessions.exceptions import SuspiciousSession
from django.core.exceptions import SuspiciousOperation
from django.utils import timezone
from django.utils.crypto import (
constant_time_compare, get_random_string, salted_hmac,
)
from django.utils.encoding import force_bytes, force_text
from django.utils.module_loading import import_string
# session_key should not be case sensitive because some backends can store it
# on case insensitive file systems.
VALID_KEY_CHARS = string.ascii_lowercase + string.digits
class CreateError(Exception):
"""
Used internally as a consistent exception type to catch from save (see the
docstring for SessionBase.save() for details).
"""
pass
class SessionBase(object):
"""
Base class for all Session classes.
"""
TEST_COOKIE_NAME = 'testcookie'
TEST_COOKIE_VALUE = 'worked'
def __init__(self, session_key=None):
self._session_key = session_key
self.accessed = False
self.modified = False
self.serializer = import_string(settings.SESSION_SERIALIZER)
def __contains__(self, key):
return key in self._session
def __getitem__(self, key):
return self._session[key]
def __setitem__(self, key, value):
self._session[key] = value
self.modified = True
def __delitem__(self, key):
del self._session[key]
self.modified = True
def get(self, key, default=None):
return self._session.get(key, default)
def pop(self, key, *args):
self.modified = self.modified or key in self._session
return self._session.pop(key, *args)
def setdefault(self, key, value):
if key in self._session:
return self._session[key]
else:
self.modified = True
self._session[key] = value
return value
def set_test_cookie(self):
self[self.TEST_COOKIE_NAME] = self.TEST_COOKIE_VALUE
def test_cookie_worked(self):
return self.get(self.TEST_COOKIE_NAME) == self.TEST_COOKIE_VALUE
def delete_test_cookie(self):
del self[self.TEST_COOKIE_NAME]
def _hash(self, value):
key_salt = "django.contrib.sessions" + self.__class__.__name__
return salted_hmac(key_salt, value).hexdigest()
def encode(self, session_dict):
"Returns the given session dictionary serialized and encoded as a string."
serialized = self.serializer().dumps(session_dict)
hash = self._hash(serialized)
return base64.b64encode(hash.encode() + b":" + serialized).decode('ascii')
def decode(self, session_data):
encoded_data = base64.b64decode(force_bytes(session_data))
try:
# could produce ValueError if there is no ':'
hash, serialized = encoded_data.split(b':', 1)
expected_hash = self._hash(serialized)
if not constant_time_compare(hash.decode(), expected_hash):
raise SuspiciousSession("Session data corrupted")
else:
return self.serializer().loads(serialized)
except Exception as e:
# ValueError, SuspiciousOperation, unpickling exceptions. If any of
# these happen, just return an empty dictionary (an empty session).
if isinstance(e, SuspiciousOperation):
logger = logging.getLogger('django.security.%s' %
e.__class__.__name__)
logger.warning(force_text(e))
return {}
def update(self, dict_):
self._session.update(dict_)
self.modified = True
def has_key(self, key):
return key in self._session
def keys(self):
return self._session.keys()
def values(self):
return self._session.values()
def items(self):
return self._session.items()
def iterkeys(self):
return self._session.iterkeys()
def itervalues(self):
return self._session.itervalues()
def iteritems(self):
return self._session.iteritems()
def clear(self):
# To avoid unnecessary persistent storage accesses, we set up the
# internals directly (loading data wastes time, since we are going to
# set it to an empty dict anyway).
self._session_cache = {}
self.accessed = True
self.modified = True
def is_empty(self):
"Returns True when there is no session_key and the session is empty"
try:
return not bool(self._session_key) and not self._session_cache
except AttributeError:
return True
def _get_new_session_key(self):
"Returns session key that isn't being used."
while True:
session_key = get_random_string(32, VALID_KEY_CHARS)
if not self.exists(session_key):
break
return session_key
def _get_or_create_session_key(self):
if self._session_key is None:
self._session_key = self._get_new_session_key()
return self._session_key
def _get_session_key(self):
return self._session_key
session_key = property(_get_session_key)
def _get_session(self, no_load=False):
"""
Lazily loads session from storage (unless "no_load" is True, when only
an empty dict is stored) and stores it in the current instance.
"""
self.accessed = True
try:
return self._session_cache
except AttributeError:
if self.session_key is None or no_load:
self._session_cache = {}
else:
self._session_cache = self.load()
return self._session_cache
_session = property(_get_session)
def get_expiry_age(self, **kwargs):
"""Get the number of seconds until the session expires.
Optionally, this function accepts `modification` and `expiry` keyword
arguments specifying the modification and expiry of the session.
"""
try:
modification = kwargs['modification']
except KeyError:
modification = timezone.now()
# Make the difference between "expiry=None passed in kwargs" and
# "expiry not passed in kwargs", in order to guarantee not to trigger
# self.load() when expiry is provided.
try:
expiry = kwargs['expiry']
except KeyError:
expiry = self.get('_session_expiry')
if not expiry: # Checks both None and 0 cases
return settings.SESSION_COOKIE_AGE
if not isinstance(expiry, datetime):
return expiry
delta = expiry - modification
return delta.days * 86400 + delta.seconds
def get_expiry_date(self, **kwargs):
"""Get session the expiry date (as a datetime object).
Optionally, this function accepts `modification` and `expiry` keyword
arguments specifying the modification and expiry of the session.
"""
try:
modification = kwargs['modification']
except KeyError:
modification = timezone.now()
# Same comment as in get_expiry_age
try:
expiry = kwargs['expiry']
except KeyError:
expiry = self.get('_session_expiry')
if isinstance(expiry, datetime):
return expiry
if not expiry: # Checks both None and 0 cases
expiry = settings.SESSION_COOKIE_AGE
return modification + timedelta(seconds=expiry)
def set_expiry(self, value):
"""
Sets a custom expiration for the session. ``value`` can be an integer,
a Python ``datetime`` or ``timedelta`` object or ``None``.
If ``value`` is an integer, the session will expire after that many
seconds of inactivity. If set to ``0`` then the session will expire on
browser close.
If ``value`` is a ``datetime`` or ``timedelta`` object, the session
will expire at that specific future time.
If ``value`` is ``None``, the session uses the global session expiry
policy.
"""
if value is None:
# Remove any custom expiration for this session.
try:
del self['_session_expiry']
except KeyError:
pass
return
if isinstance(value, timedelta):
value = timezone.now() + value
self['_session_expiry'] = value
def get_expire_at_browser_close(self):
"""
Returns ``True`` if the session is set to expire when the browser
closes, and ``False`` if there's an expiry date. Use
``get_expiry_date()`` or ``get_expiry_age()`` to find the actual expiry
date/age, if there is one.
"""
if self.get('_session_expiry') is None:
return settings.SESSION_EXPIRE_AT_BROWSER_CLOSE
return self.get('_session_expiry') == 0
def flush(self):
"""
Removes the current session data from the database and regenerates the
key.
"""
self.clear()
self.delete()
self._session_key = None
def cycle_key(self):
"""
Creates a new session key, whilst retaining the current session data.
"""
data = self._session_cache
key = self.session_key
self.create()
self._session_cache = data
self.delete(key)
# Methods that child classes must implement.
def exists(self, session_key):
"""
Returns True if the given session_key already exists.
"""
raise NotImplementedError('subclasses of SessionBase must provide an exists() method')
def create(self):
"""
Creates a new session instance. Guaranteed to create a new object with
a unique key and will have saved the result once (with empty data)
before the method returns.
"""
raise NotImplementedError('subclasses of SessionBase must provide a create() method')
def save(self, must_create=False):
"""
Saves the session data. If 'must_create' is True, a new session object
is created (otherwise a CreateError exception is raised). Otherwise,
save() can update an existing object with the same key.
"""
raise NotImplementedError('subclasses of SessionBase must provide a save() method')
def delete(self, session_key=None):
"""
Deletes the session data under this key. If the key is None, the
current session key value is used.
"""
raise NotImplementedError('subclasses of SessionBase must provide a delete() method')
def load(self):
"""
Loads the session data and returns a dictionary.
"""
raise NotImplementedError('subclasses of SessionBase must provide a load() method')
@classmethod
def clear_expired(cls):
"""
Remove expired sessions from the session store.
If this operation isn't possible on a given backend, it should raise
NotImplementedError. If it isn't necessary, because the backend has
a built-in expiration mechanism, it should be a no-op.
"""
raise NotImplementedError('This backend does not support clear_expired().')
|
mit
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
1300,
772,
199,
646,
2050,
199,
646,
1059,
199,
504,
2197,
492,
2197,
12,
6871,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
11676,
14,
3924,
492,
428,
28651,
4434,
199,
504,
1639,
14,
1018,
14,
3924,
492,
428,
28651,
6044,
199,
504,
1639,
14,
1208,
492,
7137,
199,
504,
1639,
14,
1208,
14,
10316,
492,
334,
272,
4413,
63,
521,
63,
5785,
12,
664,
63,
2355,
63,
875,
12,
18641,
471,
63,
18537,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2394,
12,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
578,
63,
8786,
492,
492,
63,
875,
199,
199,
3,
2351,
63,
498,
1077,
440,
506,
1930,
18423,
2952,
2005,
14745,
883,
3877,
652,
199,
3,
641,
1930,
27845,
570,
10460,
14,
199,
5600,
63,
3078,
63,
16326,
275,
1059,
14,
4371,
63,
21636,
435,
1059,
14,
7022,
421,
199,
533,
2790,
547,
8,
1726,
304,
272,
408,
272,
8051,
14448,
465,
282,
12137,
1919,
730,
370,
8579,
687,
3354,
334,
3239,
314,
272,
9214,
367,
8596,
1563,
14,
2117,
342,
367,
2436,
680,
272,
408,
272,
986,
421,
199,
533,
8596,
1563,
8,
785,
304,
272,
408,
272,
3523,
1021,
367,
1006,
8596,
3992,
14,
272,
408,
272,
7393,
63,
13665,
63,
2339,
275,
283,
396,
5306,
7,
272,
7393,
63,
13665,
63,
7041,
275,
283,
800,
379,
7,
339,
347,
636,
826,
721,
277,
12,
2351,
63,
498,
29,
403,
304,
267,
291,
423,
1730,
63,
498,
275,
2351,
63,
498,
267,
291,
14,
29433,
275,
756,
267,
291,
14,
5540,
275,
756,
267,
291,
14,
8349,
275,
492,
63,
875,
8,
1751,
14,
12763,
63,
19637,
5357,
540,
9,
339,
347,
636,
6134,
721,
277,
12,
790,
304,
267,
372,
790,
315,
291,
423,
1730,
339,
347,
636,
6095,
721,
277,
12,
790,
304,
267,
372,
291,
423,
1730,
59,
498,
61,
339,
347,
636,
8617,
721,
277,
12,
790,
12,
574,
304,
267,
291,
423,
1730,
59,
498,
61,
275,
574,
267,
291,
14,
5540,
275,
715,
339,
347,
636,
13228,
721,
277,
12,
790,
304,
267,
2150,
291,
423,
1730,
59,
498,
61,
267,
291,
14,
5540,
275,
715,
339,
347,
664,
8,
277,
12,
790,
12,
849,
29,
403,
304,
267,
372,
291,
423,
1730,
14,
362,
8,
498,
12,
849,
9,
339,
347,
4560,
8,
277,
12,
790,
12,
627,
589,
304,
267,
291,
14,
5540,
275,
291,
14,
5540,
503,
790,
315,
291,
423,
1730,
267,
372,
291,
423,
1730,
14,
1935,
8,
498,
12,
627,
589,
9,
339,
347,
29408,
8,
277,
12,
790,
12,
574,
304,
267,
340,
790,
315,
291,
423,
1730,
26,
288,
372,
291,
423,
1730,
59,
498,
61,
267,
587,
26,
288,
291,
14,
5540,
275,
715,
288,
291,
423,
1730,
59,
498,
61,
275,
574,
288,
372,
574,
339,
347,
663,
63,
396,
63,
5306,
8,
277,
304,
267,
291,
59,
277,
14,
2864,
63,
13665,
63,
2339,
61,
275,
291,
14,
2864,
63,
13665,
63,
7041,
339,
347,
511,
63,
5306,
63,
800,
379,
8,
277,
304,
267,
372,
291,
14,
362,
8,
277,
14,
2864,
63,
13665,
63,
2339,
9,
508,
291,
14,
2864,
63,
13665,
63,
7041,
339,
347,
3145,
63,
396,
63,
5306,
8,
277,
304,
267,
2150,
291,
59,
277,
14,
2864,
63,
13665,
63,
2339,
61,
339,
347,
485,
2227,
8,
277,
12,
574,
304,
267,
790,
63,
12597,
275,
298,
1176,
14,
2828,
14,
11676,
2,
435,
291,
855,
533,
4914,
354,
363,
267,
372,
18641,
471,
63,
18537,
8,
498,
63,
12597,
12,
574,
680,
11453,
342,
339,
347,
3752,
8,
277,
12,
2351,
63,
807,
304,
267,
298,
3407,
314,
1627,
2351,
2600,
6380,
436,
5737,
465,
282,
1059,
2122,
267,
6380,
275,
291,
14,
8349,
1252,
4180,
8,
1730,
63,
807,
9,
267,
2631,
275,
291,
423,
2227,
8,
8397,
9,
267,
372,
1300,
772,
14,
66,
772,
2143,
8,
2227,
14,
2143,
342,
435,
330,
5122,
435,
6380,
680,
2708,
360,
4371,
358,
339,
347,
4849,
8,
277,
12,
2351,
63,
576,
304,
267,
5737,
63,
576,
275,
1300,
772,
14,
66,
772,
2708,
8,
3990,
63,
2394,
8,
1730,
63,
576,
430,
267,
862,
26,
288,
327,
4293,
7389,
1722,
340,
2337,
365,
949,
10871,
288,
2631,
12,
6380,
275,
5737,
63,
576,
14,
1294,
8,
66,
356,
297,
413,
9,
288,
1420,
63,
2227,
275,
291,
423,
2227,
8,
8397,
9,
288,
340,
440,
4413,
63,
521,
63,
5785,
8,
2227,
14,
2708,
1062,
1420,
63,
2227,
304,
355,
746,
428,
28651,
4434,
480,
4434,
666,
1970,
15692,
531,
288,
587,
26,
355,
372,
291,
14,
8349,
1252,
3640,
8,
8397,
9,
267,
871,
2186,
465,
325,
26,
288,
327,
1722,
12,
428,
28651,
6044,
12,
625,
24773,
4967,
14,
982,
1263,
402,
288,
327,
3520,
5992,
12,
2951,
372,
376,
2701,
2600,
334,
290,
2701,
2351,
680,
288,
340,
1228,
8,
69,
12,
428,
28651,
6044,
304,
355,
2512,
275,
2050,
14,
5572,
360,
1176,
14,
4416,
4111,
83,
7,
450,
717,
325,
855,
533,
4914,
354,
3368,
355,
2512,
14,
3764,
8,
3990,
63,
505,
8,
69,
430,
288,
372,
1052,
339,
347,
1678,
8,
277,
12,
1211,
7822,
267,
291,
423,
1730,
14,
873,
8,
807,
4602,
267,
291,
14,
5540,
275,
715,
339,
347,
965,
63,
498,
8,
277,
12,
790,
304,
267,
372,
790,
315,
291,
423,
1730,
339,
347,
2883,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
1612,
342,
339,
347,
1338,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
1459,
342,
339,
347,
2974,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
1744,
342,
339,
347,
25706,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
16007,
342,
339,
347,
24451,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
13012,
342,
339,
347,
10849,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
4611,
342,
339,
347,
5436,
8,
277,
304,
267,
327,
4005,
5126,
23361,
16149,
4887,
1066,
5804,
12,
781,
663,
1536,
314,
267,
327,
5007,
83
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
1300,
772,
199,
646,
2050,
199,
646,
1059,
199,
504,
2197,
492,
2197,
12,
6871,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
11676,
14,
3924,
492,
428,
28651,
4434,
199,
504,
1639,
14,
1018,
14,
3924,
492,
428,
28651,
6044,
199,
504,
1639,
14,
1208,
492,
7137,
199,
504,
1639,
14,
1208,
14,
10316,
492,
334,
272,
4413,
63,
521,
63,
5785,
12,
664,
63,
2355,
63,
875,
12,
18641,
471,
63,
18537,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2394,
12,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
578,
63,
8786,
492,
492,
63,
875,
199,
199,
3,
2351,
63,
498,
1077,
440,
506,
1930,
18423,
2952,
2005,
14745,
883,
3877,
652,
199,
3,
641,
1930,
27845,
570,
10460,
14,
199,
5600,
63,
3078,
63,
16326,
275,
1059,
14,
4371,
63,
21636,
435,
1059,
14,
7022,
421,
199,
533,
2790,
547,
8,
1726,
304,
272,
408,
272,
8051,
14448,
465,
282,
12137,
1919,
730,
370,
8579,
687,
3354,
334,
3239,
314,
272,
9214,
367,
8596,
1563,
14,
2117,
342,
367,
2436,
680,
272,
408,
272,
986,
421,
199,
533,
8596,
1563,
8,
785,
304,
272,
408,
272,
3523,
1021,
367,
1006,
8596,
3992,
14,
272,
408,
272,
7393,
63,
13665,
63,
2339,
275,
283,
396,
5306,
7,
272,
7393,
63,
13665,
63,
7041,
275,
283,
800,
379,
7,
339,
347,
636,
826,
721,
277,
12,
2351,
63,
498,
29,
403,
304,
267,
291,
423,
1730,
63,
498,
275,
2351,
63,
498,
267,
291,
14,
29433,
275,
756,
267,
291,
14,
5540,
275,
756,
267,
291,
14,
8349,
275,
492,
63,
875,
8,
1751,
14,
12763,
63,
19637,
5357,
540,
9,
339,
347,
636,
6134,
721,
277,
12,
790,
304,
267,
372,
790,
315,
291,
423,
1730,
339,
347,
636,
6095,
721,
277,
12,
790,
304,
267,
372,
291,
423,
1730,
59,
498,
61,
339,
347,
636,
8617,
721,
277,
12,
790,
12,
574,
304,
267,
291,
423,
1730,
59,
498,
61,
275,
574,
267,
291,
14,
5540,
275,
715,
339,
347,
636,
13228,
721,
277,
12,
790,
304,
267,
2150,
291,
423,
1730,
59,
498,
61,
267,
291,
14,
5540,
275,
715,
339,
347,
664,
8,
277,
12,
790,
12,
849,
29,
403,
304,
267,
372,
291,
423,
1730,
14,
362,
8,
498,
12,
849,
9,
339,
347,
4560,
8,
277,
12,
790,
12,
627,
589,
304,
267,
291,
14,
5540,
275,
291,
14,
5540,
503,
790,
315,
291,
423,
1730,
267,
372,
291,
423,
1730,
14,
1935,
8,
498,
12,
627,
589,
9,
339,
347,
29408,
8,
277,
12,
790,
12,
574,
304,
267,
340,
790,
315,
291,
423,
1730,
26,
288,
372,
291,
423,
1730,
59,
498,
61,
267,
587,
26,
288,
291,
14,
5540,
275,
715,
288,
291,
423,
1730,
59,
498,
61,
275,
574,
288,
372,
574,
339,
347,
663,
63,
396,
63,
5306,
8,
277,
304,
267,
291,
59,
277,
14,
2864,
63,
13665,
63,
2339,
61,
275,
291,
14,
2864,
63,
13665,
63,
7041,
339,
347,
511,
63,
5306,
63,
800,
379,
8,
277,
304,
267,
372,
291,
14,
362,
8,
277,
14,
2864,
63,
13665,
63,
2339,
9,
508,
291,
14,
2864,
63,
13665,
63,
7041,
339,
347,
3145,
63,
396,
63,
5306,
8,
277,
304,
267,
2150,
291,
59,
277,
14,
2864,
63,
13665,
63,
2339,
61,
339,
347,
485,
2227,
8,
277,
12,
574,
304,
267,
790,
63,
12597,
275,
298,
1176,
14,
2828,
14,
11676,
2,
435,
291,
855,
533,
4914,
354,
363,
267,
372,
18641,
471,
63,
18537,
8,
498,
63,
12597,
12,
574,
680,
11453,
342,
339,
347,
3752,
8,
277,
12,
2351,
63,
807,
304,
267,
298,
3407,
314,
1627,
2351,
2600,
6380,
436,
5737,
465,
282,
1059,
2122,
267,
6380,
275,
291,
14,
8349,
1252,
4180,
8,
1730,
63,
807,
9,
267,
2631,
275,
291,
423,
2227,
8,
8397,
9,
267,
372,
1300,
772,
14,
66,
772,
2143,
8,
2227,
14,
2143,
342,
435,
330,
5122,
435,
6380,
680,
2708,
360,
4371,
358,
339,
347,
4849,
8,
277,
12,
2351,
63,
576,
304,
267,
5737,
63,
576,
275,
1300,
772,
14,
66,
772,
2708,
8,
3990,
63,
2394,
8,
1730,
63,
576,
430,
267,
862,
26,
288,
327,
4293,
7389,
1722,
340,
2337,
365,
949,
10871,
288,
2631,
12,
6380,
275,
5737,
63,
576,
14,
1294,
8,
66,
356,
297,
413,
9,
288,
1420,
63,
2227,
275,
291,
423,
2227,
8,
8397,
9,
288,
340,
440,
4413,
63,
521,
63,
5785,
8,
2227,
14,
2708,
1062,
1420,
63,
2227,
304,
355,
746,
428,
28651,
4434,
480,
4434,
666,
1970,
15692,
531,
288,
587,
26,
355,
372,
291,
14,
8349,
1252,
3640,
8,
8397,
9,
267,
871,
2186,
465,
325,
26,
288,
327,
1722,
12,
428,
28651,
6044,
12,
625,
24773,
4967,
14,
982,
1263,
402,
288,
327,
3520,
5992,
12,
2951,
372,
376,
2701,
2600,
334,
290,
2701,
2351,
680,
288,
340,
1228,
8,
69,
12,
428,
28651,
6044,
304,
355,
2512,
275,
2050,
14,
5572,
360,
1176,
14,
4416,
4111,
83,
7,
450,
717,
325,
855,
533,
4914,
354,
3368,
355,
2512,
14,
3764,
8,
3990,
63,
505,
8,
69,
430,
288,
372,
1052,
339,
347,
1678,
8,
277,
12,
1211,
7822,
267,
291,
423,
1730,
14,
873,
8,
807,
4602,
267,
291,
14,
5540,
275,
715,
339,
347,
965,
63,
498,
8,
277,
12,
790,
304,
267,
372,
790,
315,
291,
423,
1730,
339,
347,
2883,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
1612,
342,
339,
347,
1338,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
1459,
342,
339,
347,
2974,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
1744,
342,
339,
347,
25706,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
16007,
342,
339,
347,
24451,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
13012,
342,
339,
347,
10849,
8,
277,
304,
267,
372,
291,
423,
1730,
14,
4611,
342,
339,
347,
5436,
8,
277,
304,
267,
327,
4005,
5126,
23361,
16149,
4887,
1066,
5804,
12,
781,
663,
1536,
314,
267,
327,
5007,
83,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
sjehutch/mywebappscripts
|
FuzzLists/fuzz_list_generating_code/numeric_fuzz_lists.py
|
4
|
1864
|
import random
import sys
#Generate a random large integer
print random.randrange(0,100000000000000000000000000000)
#Generate a random large float with and without a random large decimal
print random.uniform(0.0,39873285793487643.29357)
print random.uniform(0.0,39873285793487643.2935743967439860376894768945)
#Generate a large negative integer
print random.randrange(-1,-324235436436346353543646,-1)
#Generate a large negative float
print random.uniform(-1.0,-39873285793487643.274809)
#Generate a random hexadecimal number
lst=[random.choice('0123456789abcdef') for i in xrange(30)]
x=''.join(lst)
x='0x'+x
print x
#Largest Python integer
print sys.maxint
print sys.maxint+1
#Smallest Python integer
print -sys.maxsize-2
#Largest Python Float
print sys.float_info.max
print sys.float_info.max+1
#Integer rep of float in memory (This one's by Max)
print int('0'+'1'*8+'0'*23,2)
#Smallest Python float
print sys.float_info.min
#Explicit 'L' and explicit 'B' tagged on at the end
print '79228162514264337593543950336L'
print '79228162514264337593543950336l'
print '79228162514264337593543950336B'
#Different types of infinity :)
print float('inf')
print 'Infinity'
print '-Infinity'
#Not a number
print 'NaN'
#Largest unsigned integers - 8,16,32 and 64 bit
print '255\n65535\n4294967295\n18446744073709551615\n'
#Largest unsigned integers - 8,16,32 and 64 bit PLUS 1
print '256\n65536\n4294967296\n18446744073709551616\n'
#Largest signed integers - 8,16,32 and 64 bit
print '127\n32767\n2147483647\n9223372036854775807\n'
#Largest signed integers - 8,16,32 and 64 bit PLUS 1
print '128\n32768\n2147483648\n9223372036854775808\n'
#Smallest signed integers - 8,16,32 and 64 bit
print '-128\n-32768\n-2147483648\n-9223372036854775808\n'
#Smallest signed integers - 8,16,32 and 64 bit PLUS 1
print '-129\n-32769\n-2147483649\n-9223372036854775809\n'
|
mit
|
[
646,
2196,
199,
646,
984,
199,
199,
3,
6864,
221,
282,
2196,
7031,
3000,
199,
1361,
2196,
14,
20539,
8,
16,
12,
17,
9409,
3607,
5345,
9,
199,
199,
3,
6864,
282,
2196,
7031,
2069,
543,
436,
1928,
282,
2196,
7031,
6107,
199,
1361,
2196,
14,
8830,
8,
16,
14,
16,
12,
1355,
1555,
12870,
14003,
1082,
1555,
14637,
14,
1398,
13155,
9,
199,
1361,
2196,
14,
8830,
8,
16,
14,
16,
12,
1355,
1555,
12870,
14003,
1082,
1555,
14637,
14,
1398,
1276,
1342,
1355,
10393,
1355,
14832,
11452,
12128,
2114,
1407,
2322,
9,
199,
199,
3,
6864,
282,
7031,
6946,
3000,
199,
1361,
2196,
14,
20539,
2801,
17,
3057,
708,
2260,
1276,
2824,
772,
1344,
12583,
1276,
1276,
2824,
11387,
3057,
17,
9,
199,
199,
3,
6864,
282,
7031,
6946,
2069,
199,
1361,
2196,
14,
8830,
2801,
17,
14,
16,
3057,
1355,
1555,
12870,
14003,
1082,
1555,
14637,
14,
9014,
11782,
9,
199,
199,
3,
6864,
282,
2196,
20379,
1329,
199,
6916,
1524,
2355,
14,
5095,
360,
11371,
10678,
358,
367,
284,
315,
4945,
8,
1216,
1874,
199,
88,
534,
1370,
904,
8,
6916,
9,
199,
88,
534,
16,
88,
6828,
88,
199,
1361,
671,
199,
199,
3,
44,
285,
3199,
2018,
3000,
199,
1361,
984,
14,
21411,
199,
1361,
984,
14,
21411,
11,
17,
199,
199,
3,
51,
2174,
14899,
2018,
3000,
199,
1361,
446,
1274,
14,
13634,
13,
18,
199,
199,
3,
44,
285,
3199,
2018,
11140,
199,
1361,
984,
14,
1609,
63,
815,
14,
988,
199,
1361,
984,
14,
1609,
63,
815,
14,
988,
11,
17,
199,
199,
3,
2674,
1833,
402,
2069,
315,
4402,
334,
2765,
1373,
1159,
701,
8228,
9,
199,
1361,
1109,
360,
16,
30269,
17,
16804,
24,
4786,
16,
16804,
1789,
12,
18,
9,
199,
199,
3,
51,
2174,
14899,
2018,
2069,
199,
1361,
984,
14,
1609,
63,
815,
14,
827,
199,
199,
3,
26090,
283,
44,
7,
436,
5027,
283,
34,
7,
20018,
641,
737,
314,
1284,
199,
1361,
283,
1965,
12048,
975,
27223,
9408,
11062,
1427,
12967,
30304,
12135,
44,
7,
199,
1361,
283,
1965,
12048,
975,
27223,
9408,
11062,
1427,
12967,
30304,
12135,
76,
7,
199,
1361,
283,
1965,
12048,
975,
27223,
9408,
11062,
1427,
12967,
30304,
12135,
34,
7,
199,
199,
3,
31409,
2943,
402,
23573,
32428,
199,
1361,
2069,
360,
4904,
358,
199,
1361,
283,
14660,
7,
199,
1361,
2475,
14660,
7,
199,
199,
3,
1763,
282,
1329,
199,
1361,
283,
14300,
7,
199,
199,
3,
44,
285,
3199,
7381,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
199,
1361,
283,
2299,
60,
78,
26439,
60,
78,
31844,
11405,
60,
78,
1085,
1602,
10393,
12641,
1401,
1643,
1229,
32614,
60,
78,
7,
199,
199,
3,
44,
285,
3199,
7381,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
18807,
413,
199,
1361,
283,
3912,
60,
78,
10027,
1344,
60,
78,
31844,
11700,
60,
78,
1085,
1602,
10393,
12641,
1401,
1643,
1229,
975,
975,
60,
78,
7,
199,
199,
3,
44,
285,
3199,
10514,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
199,
1361,
283,
4195,
60,
78,
11754,
1822,
60,
78,
22519,
8557,
60,
78,
23861,
32417,
11369,
60,
78,
7,
199,
199,
3,
44,
285,
3199,
10514,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
18807,
413,
199,
1361,
283,
3933,
60,
78,
708,
14408,
60,
78,
22519,
10552,
60,
78,
23861,
32417,
11292,
60,
78,
7,
199,
199,
3,
51,
2174,
14899,
10514,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
199,
1361,
2475,
3933,
60,
78,
13,
708,
14408,
60,
78,
13,
22519,
10552,
60,
78,
13,
23861,
32417,
11292,
60,
78,
7,
199,
199,
3,
51,
2174,
14899,
10514,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
18807,
413,
199,
1361,
2475,
7263,
60,
78,
13,
11754,
1876,
60,
78,
13,
22519,
11228,
60,
78,
13,
23861,
32417,
11782,
60,
78,
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
] |
[
2196,
199,
646,
984,
199,
199,
3,
6864,
221,
282,
2196,
7031,
3000,
199,
1361,
2196,
14,
20539,
8,
16,
12,
17,
9409,
3607,
5345,
9,
199,
199,
3,
6864,
282,
2196,
7031,
2069,
543,
436,
1928,
282,
2196,
7031,
6107,
199,
1361,
2196,
14,
8830,
8,
16,
14,
16,
12,
1355,
1555,
12870,
14003,
1082,
1555,
14637,
14,
1398,
13155,
9,
199,
1361,
2196,
14,
8830,
8,
16,
14,
16,
12,
1355,
1555,
12870,
14003,
1082,
1555,
14637,
14,
1398,
1276,
1342,
1355,
10393,
1355,
14832,
11452,
12128,
2114,
1407,
2322,
9,
199,
199,
3,
6864,
282,
7031,
6946,
3000,
199,
1361,
2196,
14,
20539,
2801,
17,
3057,
708,
2260,
1276,
2824,
772,
1344,
12583,
1276,
1276,
2824,
11387,
3057,
17,
9,
199,
199,
3,
6864,
282,
7031,
6946,
2069,
199,
1361,
2196,
14,
8830,
2801,
17,
14,
16,
3057,
1355,
1555,
12870,
14003,
1082,
1555,
14637,
14,
9014,
11782,
9,
199,
199,
3,
6864,
282,
2196,
20379,
1329,
199,
6916,
1524,
2355,
14,
5095,
360,
11371,
10678,
358,
367,
284,
315,
4945,
8,
1216,
1874,
199,
88,
534,
1370,
904,
8,
6916,
9,
199,
88,
534,
16,
88,
6828,
88,
199,
1361,
671,
199,
199,
3,
44,
285,
3199,
2018,
3000,
199,
1361,
984,
14,
21411,
199,
1361,
984,
14,
21411,
11,
17,
199,
199,
3,
51,
2174,
14899,
2018,
3000,
199,
1361,
446,
1274,
14,
13634,
13,
18,
199,
199,
3,
44,
285,
3199,
2018,
11140,
199,
1361,
984,
14,
1609,
63,
815,
14,
988,
199,
1361,
984,
14,
1609,
63,
815,
14,
988,
11,
17,
199,
199,
3,
2674,
1833,
402,
2069,
315,
4402,
334,
2765,
1373,
1159,
701,
8228,
9,
199,
1361,
1109,
360,
16,
30269,
17,
16804,
24,
4786,
16,
16804,
1789,
12,
18,
9,
199,
199,
3,
51,
2174,
14899,
2018,
2069,
199,
1361,
984,
14,
1609,
63,
815,
14,
827,
199,
199,
3,
26090,
283,
44,
7,
436,
5027,
283,
34,
7,
20018,
641,
737,
314,
1284,
199,
1361,
283,
1965,
12048,
975,
27223,
9408,
11062,
1427,
12967,
30304,
12135,
44,
7,
199,
1361,
283,
1965,
12048,
975,
27223,
9408,
11062,
1427,
12967,
30304,
12135,
76,
7,
199,
1361,
283,
1965,
12048,
975,
27223,
9408,
11062,
1427,
12967,
30304,
12135,
34,
7,
199,
199,
3,
31409,
2943,
402,
23573,
32428,
199,
1361,
2069,
360,
4904,
358,
199,
1361,
283,
14660,
7,
199,
1361,
2475,
14660,
7,
199,
199,
3,
1763,
282,
1329,
199,
1361,
283,
14300,
7,
199,
199,
3,
44,
285,
3199,
7381,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
199,
1361,
283,
2299,
60,
78,
26439,
60,
78,
31844,
11405,
60,
78,
1085,
1602,
10393,
12641,
1401,
1643,
1229,
32614,
60,
78,
7,
199,
199,
3,
44,
285,
3199,
7381,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
18807,
413,
199,
1361,
283,
3912,
60,
78,
10027,
1344,
60,
78,
31844,
11700,
60,
78,
1085,
1602,
10393,
12641,
1401,
1643,
1229,
975,
975,
60,
78,
7,
199,
199,
3,
44,
285,
3199,
10514,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
199,
1361,
283,
4195,
60,
78,
11754,
1822,
60,
78,
22519,
8557,
60,
78,
23861,
32417,
11369,
60,
78,
7,
199,
199,
3,
44,
285,
3199,
10514,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
18807,
413,
199,
1361,
283,
3933,
60,
78,
708,
14408,
60,
78,
22519,
10552,
60,
78,
23861,
32417,
11292,
60,
78,
7,
199,
199,
3,
51,
2174,
14899,
10514,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
199,
1361,
2475,
3933,
60,
78,
13,
708,
14408,
60,
78,
13,
22519,
10552,
60,
78,
13,
23861,
32417,
11292,
60,
78,
7,
199,
199,
3,
51,
2174,
14899,
10514,
9446,
446,
1695,
12,
975,
12,
708,
436,
5049,
4546,
18807,
413,
199,
1361,
2475,
7263,
60,
78,
13,
11754,
1876,
60,
78,
13,
22519,
11228,
60,
78,
13,
23861,
32417,
11782,
60,
78,
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,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
0,
0,
0,
0,
0
] |
devcline/mtasa-blue
|
vendor/google-breakpad/src/third_party/protobuf/protobuf/gtest/test/gtest_nc_test.py
|
277
|
3758
|
#!/usr/bin/env python
#
# Copyright 2007, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Negative compilation test for Google Test."""
__author__ = 'wan@google.com (Zhanyong Wan)'
import os
import sys
import unittest
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
if not IS_LINUX:
sys.exit(0) # Negative compilation tests are not supported on Windows & Mac.
class GTestNCTest(unittest.TestCase):
"""Negative compilation test for Google Test."""
def testCompilerError(self):
"""Verifies that erroneous code leads to expected compiler
messages."""
# Defines a list of test specs, where each element is a tuple
# (test name, list of regexes for matching the compiler errors).
test_specs = [
('CANNOT_IGNORE_RUN_ALL_TESTS_RESULT',
[r'ignoring return value']),
('USER_CANNOT_INCLUDE_GTEST_INTERNAL_INL_H',
[r'must not be included except by Google Test itself']),
('CATCHES_DECLARING_SETUP_IN_TEST_FIXTURE_WITH_TYPO',
[r'Setup_should_be_spelled_SetUp']),
('CATCHES_CALLING_SETUP_IN_TEST_WITH_TYPO',
[r'Setup_should_be_spelled_SetUp']),
('CATCHES_DECLARING_SETUP_IN_ENVIRONMENT_WITH_TYPO',
[r'Setup_should_be_spelled_SetUp']),
('CATCHES_CALLING_SETUP_IN_ENVIRONMENT_WITH_TYPO',
[r'Setup_should_be_spelled_SetUp']),
('CATCHES_WRONG_CASE_IN_TYPED_TEST_P',
[r'BarTest.*was not declared']),
('CATCHES_WRONG_CASE_IN_REGISTER_TYPED_TEST_CASE_P',
[r'BarTest.*was not declared']),
('CATCHES_WRONG_CASE_IN_INSTANTIATE_TYPED_TEST_CASE_P',
[r'BarTest.*not declared']),
('CATCHES_INSTANTIATE_TYPED_TESET_CASE_P_WITH_SAME_NAME_PREFIX',
[r'redefinition of.*My.*FooTest']),
('STATIC_ASSERT_TYPE_EQ_IS_NOT_A_TYPE',
[r'StaticAssertTypeEq.* does not name a type']),
('STATIC_ASSERT_TYPE_EQ_WORKS_IN_NAMESPACE',
[r'StaticAssertTypeEq.*int.*const int']),
('STATIC_ASSERT_TYPE_EQ_WORKS_IN_CLASS',
[r'StaticAssertTypeEq.*int.*bool']),
('STATIC_ASSERT_TYPE_EQ_WORKS_IN_FUNCTION',
[r'StaticAssertTypeEq.*const int.*int']),
('SANITY',
None)
]
# TODO(wan@google.com): verify that the test specs are satisfied.
if __name__ == '__main__':
unittest.main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
10219,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
15562,
18653,
511,
367,
4475,
1379,
1041,
199,
199,
363,
2502,
363,
275,
283,
20444,
32,
3098,
14,
957,
334,
12674,
1629,
951,
644,
290,
3171,
199,
199,
646,
747,
199,
646,
984,
199,
646,
2882,
421,
199,
1311,
63,
26030,
275,
747,
14,
354,
508,
283,
9228,
7,
436,
747,
14,
16040,
3430,
16,
61,
508,
283,
14091,
7,
199,
692,
440,
2281,
63,
26030,
26,
523,
984,
14,
2224,
8,
16,
9,
221,
327,
32548,
18653,
2295,
787,
440,
3748,
641,
5417,
1253,
10444,
14,
421,
199,
533,
598,
774,
6389,
774,
8,
2796,
14,
1746,
304,
523,
408,
15562,
18653,
511,
367,
4475,
1379,
1041,
819,
347,
511,
9131,
547,
8,
277,
304,
272,
408,
21168,
626,
2329,
368,
1785,
1233,
27401,
370,
1420,
6365,
272,
3788,
1041,
339,
327,
25022,
282,
769,
402,
511,
15941,
12,
2382,
1924,
1819,
365,
282,
2008,
272,
327,
334,
396,
536,
12,
769,
402,
5163,
397,
367,
4877,
314,
6365,
2552,
680,
272,
511,
63,
7273,
275,
359,
489,
661,
18988,
4609,
63,
11209,
63,
9390,
63,
1761,
63,
7569,
63,
9517,
297,
2126,
359,
82,
7,
1030,
6854,
372,
574,
3815,
2541,
661,
3791,
63,
18988,
4609,
63,
18171,
63,
16151,
63,
17681,
63,
568,
44,
63,
40,
297,
2126,
359,
82,
6704,
833,
440,
506,
5120,
871,
701,
4475,
1379,
6337,
3815,
2541,
661,
35,
8078,
654,
63,
27402,
689,
1206,
63,
20836,
63,
568,
63,
2864,
63,
5192,
52,
3942,
63,
9139,
63,
2099,
1512,
297,
2126,
359,
82,
7,
8555,
63,
5626,
63,
1235,
63,
12325,
76,
1146,
63,
19845,
3815,
2541,
661,
35,
8078,
654,
63,
11978,
1206,
63,
20836,
63,
568,
63,
2864,
63,
9139,
63,
2099,
1512,
297,
2126,
359,
82,
7,
8555,
63,
5626,
63,
1235,
63,
12325,
76,
1146,
63,
19845,
3815,
2541,
661,
35,
8078,
654,
63,
27402,
689,
1206,
63,
20836,
63,
568,
63,
9984,
31168,
4479,
63,
9139,
63,
2099,
1512,
297,
2126,
359,
82,
7,
8555,
63,
5626,
63,
1235,
63,
12325,
76,
1146,
63,
19845,
3815,
2541,
661,
35,
8078,
654,
63,
11978,
1206,
63,
20836,
63,
568,
63,
9984,
31168,
4479,
63,
9139,
63,
2099,
1512,
297,
2126,
359,
82,
7,
8555,
63,
5626,
63,
1235,
63,
12325,
76,
1146,
63,
19845,
3815,
2541,
661,
35,
8078,
654,
63,
6524,
7770,
63,
11320,
63,
568,
63,
7034,
1149,
63,
2864,
63,
48,
297,
2126,
359,
82,
7,
26618,
2795,
10274,
440,
14290,
3815,
2541,
661,
35,
8078,
654,
63,
6524,
7770,
63,
11320,
63,
568,
63,
23986,
63,
7034,
1149,
63,
2864,
63,
11320,
63,
48,
297,
2126,
359,
82,
7,
26618,
2795,
10274,
440,
14290,
3815,
2541,
661,
35,
8078,
654,
63,
6524,
7770,
63,
11320,
63,
568,
63,
7834,
1441,
41,
1951,
63,
7034,
1149,
63,
2864,
63,
11320,
63,
48,
297,
2126,
359,
82,
7,
26618,
2795,
1397,
14290,
3815,
2541,
661,
35,
8078,
654,
63,
7834,
1441,
41,
1951,
63,
7034,
1149,
63,
15472,
775,
63,
11320,
63,
48,
63,
9139,
63,
19935,
63,
2339,
63,
6351,
297,
2126,
359,
82,
3984,
7463,
402,
2795,
5713,
2795,
24676,
3815,
2541,
661,
10449,
63,
24790,
63,
2711,
63,
17420,
63,
1311,
63,
4609,
63,
33,
63,
2711,
297,
2126,
359,
82,
7,
9278,
9699,
804,
19706,
2795,
1630,
440,
536,
282,
730,
3815,
2541,
661,
10449,
63,
24790,
63,
2711,
63,
17420,
63,
8406,
51,
63,
568,
63,
13001,
297,
2126,
359,
82,
7,
9278,
9699,
804,
19706,
2795,
442,
2795,
1297,
1109,
3815,
2541,
661,
10449,
63,
24790,
63,
2711,
63,
17420,
63,
8406,
51,
63,
568,
63,
6885,
297,
2126,
359,
82,
7,
9278,
9699,
804,
19706,
2795,
442,
2795,
2245,
3815,
2541,
661,
10449,
63,
24790,
63,
2711,
63,
17420,
63,
8406,
51,
63,
568,
63,
15476,
297,
2126,
359,
82,
7,
9278,
9699,
804,
19706,
2795,
1297,
1109,
2795,
442,
3815,
2541,
661,
51,
879,
1922,
297,
2126,
488,
9,
489,
1622,
339,
327,
3254,
8,
20444,
32,
3098,
14,
957,
304,
4911,
626,
314,
511,
15941,
787,
23233,
14,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
10219,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
15562,
18653,
511,
367,
4475,
1379,
1041,
199,
199,
363,
2502,
363,
275,
283,
20444,
32,
3098,
14,
957,
334,
12674,
1629,
951,
644,
290,
3171,
199,
199,
646,
747,
199,
646,
984,
199,
646,
2882,
421,
199,
1311,
63,
26030,
275,
747,
14,
354,
508,
283,
9228,
7,
436,
747,
14,
16040,
3430,
16,
61,
508,
283,
14091,
7,
199,
692,
440,
2281,
63,
26030,
26,
523,
984,
14,
2224,
8,
16,
9,
221,
327,
32548,
18653,
2295,
787,
440,
3748,
641,
5417,
1253,
10444,
14,
421,
199,
533,
598,
774,
6389,
774,
8,
2796,
14,
1746,
304,
523,
408,
15562,
18653,
511,
367,
4475,
1379,
1041,
819,
347,
511,
9131,
547,
8,
277,
304,
272,
408,
21168,
626,
2329,
368,
1785,
1233,
27401,
370,
1420,
6365,
272,
3788,
1041,
339,
327,
25022,
282,
769,
402,
511,
15941,
12,
2382,
1924,
1819,
365,
282,
2008,
272,
327,
334,
396,
536,
12,
769,
402,
5163,
397,
367,
4877,
314,
6365,
2552,
680,
272,
511,
63,
7273,
275,
359,
489,
661,
18988,
4609,
63,
11209,
63,
9390,
63,
1761,
63,
7569,
63,
9517,
297,
2126,
359,
82,
7,
1030,
6854,
372,
574,
3815,
2541,
661,
3791,
63,
18988,
4609,
63,
18171,
63,
16151,
63,
17681,
63,
568,
44,
63,
40,
297,
2126,
359,
82,
6704,
833,
440,
506,
5120,
871,
701,
4475,
1379,
6337,
3815,
2541,
661,
35,
8078,
654,
63,
27402,
689,
1206,
63,
20836,
63,
568,
63,
2864,
63,
5192,
52,
3942,
63,
9139,
63,
2099,
1512,
297,
2126,
359,
82,
7,
8555,
63,
5626,
63,
1235,
63,
12325,
76,
1146,
63,
19845,
3815,
2541,
661,
35,
8078,
654,
63,
11978,
1206,
63,
20836,
63,
568,
63,
2864,
63,
9139,
63,
2099,
1512,
297,
2126,
359,
82,
7,
8555,
63,
5626,
63,
1235,
63,
12325,
76,
1146,
63,
19845,
3815,
2541,
661,
35,
8078,
654,
63,
27402,
689,
1206,
63,
20836,
63,
568,
63,
9984,
31168,
4479,
63,
9139,
63,
2099,
1512,
297,
2126,
359,
82,
7,
8555,
63,
5626,
63,
1235,
63,
12325,
76,
1146,
63,
19845,
3815,
2541,
661,
35,
8078,
654,
63,
11978,
1206,
63,
20836,
63,
568,
63,
9984,
31168,
4479,
63,
9139,
63,
2099,
1512,
297,
2126,
359,
82,
7,
8555,
63,
5626,
63,
1235,
63,
12325,
76,
1146,
63,
19845,
3815,
2541,
661,
35,
8078,
654,
63,
6524,
7770,
63,
11320,
63,
568,
63,
7034,
1149,
63,
2864,
63,
48,
297,
2126,
359,
82,
7,
26618,
2795,
10274,
440,
14290,
3815,
2541,
661,
35,
8078,
654,
63,
6524,
7770,
63,
11320,
63,
568,
63,
23986,
63,
7034,
1149,
63,
2864,
63,
11320,
63,
48,
297,
2126,
359,
82,
7,
26618,
2795,
10274,
440,
14290,
3815,
2541,
661,
35,
8078,
654,
63,
6524,
7770,
63,
11320,
63,
568,
63,
7834,
1441,
41,
1951,
63,
7034,
1149,
63,
2864,
63,
11320,
63,
48,
297,
2126,
359,
82,
7,
26618,
2795,
1397,
14290,
3815,
2541,
661,
35,
8078,
654,
63,
7834,
1441,
41,
1951,
63,
7034,
1149,
63,
15472,
775,
63,
11320,
63,
48,
63,
9139,
63,
19935,
63,
2339,
63,
6351,
297,
2126,
359,
82,
3984,
7463,
402,
2795,
5713,
2795,
24676,
3815,
2541,
661,
10449,
63,
24790,
63,
2711,
63,
17420,
63,
1311,
63,
4609,
63,
33,
63,
2711,
297,
2126,
359,
82,
7,
9278,
9699,
804,
19706,
2795,
1630,
440,
536,
282,
730,
3815,
2541,
661,
10449,
63,
24790,
63,
2711,
63,
17420,
63,
8406,
51,
63,
568,
63,
13001,
297,
2126,
359,
82,
7,
9278,
9699,
804,
19706,
2795,
442,
2795,
1297,
1109,
3815,
2541,
661,
10449,
63,
24790,
63,
2711,
63,
17420,
63,
8406,
51,
63,
568,
63,
6885,
297,
2126,
359,
82,
7,
9278,
9699,
804,
19706,
2795,
442,
2795,
2245,
3815,
2541,
661,
10449,
63,
24790,
63,
2711,
63,
17420,
63,
8406,
51,
63,
568,
63,
15476,
297,
2126,
359,
82,
7,
9278,
9699,
804,
19706,
2795,
1297,
1109,
2795,
442,
3815,
2541,
661,
51,
879,
1922,
297,
2126,
488,
9,
489,
1622,
339,
327,
3254,
8,
20444,
32,
3098,
14,
957,
304,
4911,
626,
314,
511,
15941,
787,
23233,
14,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2882,
14,
973,
342,
199,
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,
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# 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': ['deprecated'],
'supported_by': 'certified'}
DOCUMENTATION = '''
---
module: ec2_vpc
short_description: configure AWS virtual private clouds
description:
- Create or terminates AWS virtual private clouds. This module has a dependency on python-boto.
version_added: "1.4"
deprecated:
removed_in: "2.5"
why: Replaced by dedicated modules.
alternative: Use M(ec2_vpc_net) along with supporting modules including M(ec2_vpc_igw), M(ec2_vpc_route_table), M(ec2_vpc_subnet),
M(ec2_vpc_dhcp_option), M(ec2_vpc_nat_gateway), M(ec2_vpc_nacl).
options:
cidr_block:
description:
- "The cidr block representing the VPC, e.g. C(10.0.0.0/16), required when I(state=present)."
instance_tenancy:
description:
- "The supported tenancy options for instances launched into the VPC."
default: "default"
choices: [ "default", "dedicated" ]
dns_support:
description:
- Toggles the "Enable DNS resolution" flag.
type: bool
default: 'yes'
dns_hostnames:
description:
- Toggles the "Enable DNS hostname support for instances" flag.
type: bool
default: 'yes'
subnets:
description:
- 'A dictionary array of subnets to add of the form C({ cidr: ..., az: ... , resource_tags: ... }).'
- Where C(az) is the desired availability zone of the subnet, optional.
- 'Tags C(resource_tags) use dictionary form C({ "Environment":"Dev", "Tier":"Web", ...}), optional.'
- C(resource_tags) see resource_tags for VPC below. The main difference is subnet tags not specified here will be deleted.
- All VPC subnets not in this list will be removed as well.
- As of 1.8, if the subnets parameter is not specified, no existing subnets will be modified.'
vpc_id:
description:
- A VPC id to terminate when I(state=absent).
resource_tags:
description:
- 'A dictionary array of resource tags of the form C({ tag1: value1, tag2: value2 }).
- Tags in this list are used in conjunction with CIDR block to uniquely identify a VPC in lieu of vpc_id. Therefore,
if CIDR/Tag combination does not exist, a new VPC will be created. VPC tags not on this list will be ignored. Prior to 1.7,
specifying a resource tag was optional.'
required: true
version_added: "1.6"
internet_gateway:
description:
- Toggle whether there should be an Internet gateway attached to the VPC.
type: bool
default: 'no'
route_tables:
description:
- >
A dictionary array of route tables to add of the form:
C({ subnets: [172.22.2.0/24, 172.22.3.0/24,], routes: [{ dest: 0.0.0.0/0, gw: igw},], resource_tags: ... }). Where the subnets list is
those subnets the route table should be associated with, and the routes list is a list of routes to be in the table. The special keyword
for the gw of igw specifies that you should the route should go through the internet gateway attached to the VPC. gw also accepts instance-ids,
interface-ids, and vpc-peering-connection-ids in addition igw. resource_tags is optional and uses dictionary form: C({ "Name": "public", ... }).
This module is currently unable to affect the "main" route table due to some limitations in boto, so you must explicitly define the associated
subnets or they will be attached to the main table implicitly. As of 1.8, if the route_tables parameter is not specified, no existing routes
will be modified.
wait:
description:
- Wait for the VPC to be in state 'available' before returning.
type: bool
default: 'no'
wait_timeout:
description:
- How long before wait gives up, in seconds.
default: 300
state:
description:
- Create or terminate the VPC.
required: true
choices: [ "present", "absent" ]
author: "Carson Gee (@carsongee)"
extends_documentation_fragment:
- aws
- ec2
'''
EXAMPLES = '''
# Note: None of these examples set aws_access_key, aws_secret_key, or region.
# It is assumed that their matching environment variables are set.
# Basic creation example:
- ec2_vpc:
state: present
cidr_block: 172.23.0.0/16
resource_tags: { "Environment":"Development" }
region: us-west-2
# Full creation example with subnets and optional availability zones.
# The absence or presence of subnets deletes or creates them respectively.
- ec2_vpc:
state: present
cidr_block: 172.22.0.0/16
resource_tags: { "Environment":"Development" }
subnets:
- cidr: 172.22.1.0/24
az: us-west-2c
resource_tags: { "Environment":"Dev", "Tier" : "Web" }
- cidr: 172.22.2.0/24
az: us-west-2b
resource_tags: { "Environment":"Dev", "Tier" : "App" }
- cidr: 172.22.3.0/24
az: us-west-2a
resource_tags: { "Environment":"Dev", "Tier" : "DB" }
internet_gateway: True
route_tables:
- subnets:
- 172.22.2.0/24
- 172.22.3.0/24
routes:
- dest: 0.0.0.0/0
gw: igw
- subnets:
- 172.22.1.0/24
routes:
- dest: 0.0.0.0/0
gw: igw
region: us-west-2
register: vpc
# Removal of a VPC by id
- ec2_vpc:
state: absent
vpc_id: vpc-aaaaaaa
region: us-west-2
# If you have added elements not managed by this module, e.g. instances, NATs, etc then
# the delete will fail until those dependencies are removed.
'''
from ansible.module_utils.common.removed import removed_module
if __name__ == '__main__':
removed_module()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1898,
26,
2622,
7290,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
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,
6667,
995,
490,
283,
4946,
63,
991,
356,
283,
2247,
8981,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
7062,
18,
63,
11742,
199,
3612,
63,
1802,
26,
7908,
10168,
5791,
5726,
2463,
14577,
199,
1802,
26,
272,
446,
2790,
503,
26751,
10168,
5791,
5726,
2463,
14577,
14,
221,
961,
859,
965,
282,
5936,
641,
2366,
13,
10914,
14,
199,
1023,
63,
3270,
26,
298,
17,
14,
20,
2,
199,
6667,
26,
523,
4829,
63,
262,
26,
298,
18,
14,
21,
2,
523,
10842,
26,
14402,
68,
701,
29711,
4621,
14,
523,
13943,
26,
3645,
603,
8,
825,
18,
63,
11742,
63,
846,
9,
3180,
543,
21038,
4621,
5893,
603,
8,
825,
18,
63,
11742,
63,
528,
87,
395,
603,
8,
825,
18,
63,
11742,
63,
4449,
63,
1224,
395,
603,
8,
825,
18,
63,
11742,
63,
5327,
395,
2049,
603,
8,
825,
18,
63,
11742,
63,
10801,
63,
1422,
395,
603,
8,
825,
18,
63,
11742,
63,
9468,
63,
7019,
395,
603,
8,
825,
18,
63,
11742,
63,
7745,
680,
199,
1419,
26,
523,
16770,
63,
1457,
26,
272,
1369,
26,
489,
446,
298,
1918,
16770,
1853,
6144,
314,
19209,
12,
325,
14,
71,
14,
445,
8,
709,
14,
16,
14,
16,
14,
16,
15,
975,
395,
1415,
1380,
473,
8,
929,
29,
1881,
17617,
523,
1256,
63,
724,
9844,
26,
272,
1369,
26,
489,
446,
298,
1918,
3748,
16685,
9844,
1511,
367,
4454,
27725,
1901,
314,
19209,
2122,
272,
849,
26,
298,
885,
2,
272,
3415,
26,
359,
298,
885,
401,
298,
271,
24489,
2,
1622,
523,
6715,
63,
4058,
26,
272,
1369,
26,
489,
446,
377,
24798,
2978,
314,
298,
6476,
10237,
12401,
2,
3305,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
5066,
7,
523,
6715,
63,
1102,
1247,
26,
272,
1369,
26,
489,
446,
377,
24798,
2978,
314,
298,
6476,
10237,
6246,
2291,
367,
4454,
2,
3305,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
5066,
7,
523,
18709,
26,
272,
1369,
26,
489,
446,
283,
33,
2600,
1625,
402,
18709,
370,
1050,
402,
314,
1824,
445,
2561,
16770,
26,
14263,
24978,
26,
2263,
2360,
2073,
63,
2969,
26,
2263,
789,
28823,
489,
446,
17685,
445,
8,
4651,
9,
365,
314,
6387,
14962,
5718,
402,
314,
6303,
12,
2716,
14,
489,
446,
283,
9440,
445,
8,
1927,
63,
2969,
9,
675,
2600,
1824,
445,
2561,
298,
8263,
5122,
12680,
401,
298,
52,
4446,
5122,
5926,
401,
2263,
8688,
2716,
3530,
489,
446,
445,
8,
1927,
63,
2969,
9,
1937,
2073,
63,
2969,
367,
19209,
5084,
14,
710,
2446,
8865,
365,
6303,
3762,
440,
2013,
2348,
911,
506,
5463,
14,
489,
446,
2900,
19209,
18709,
440,
315,
642,
769,
911,
506,
4829,
465,
5521,
14,
489,
446,
3709,
402,
413,
14,
24,
12,
340,
314,
18709,
2725,
365,
440,
2013,
12,
949,
3411,
18709,
911,
506,
6042,
3530,
523,
12830,
63,
344,
26,
272,
1369,
26,
489,
446,
437,
19209,
1305,
370,
15095,
1380,
473,
8,
929,
29,
5575,
680,
523,
2073,
63,
2969,
26,
272,
1369,
26,
489,
446,
283,
33,
2600,
1625,
402,
2073,
3762,
402,
314,
1824,
445,
2561,
1947,
17,
26,
574,
17,
12,
1947,
18,
26,
574,
18,
789,
680,
489,
446,
25204,
315,
642,
769,
787,
1202,
315,
22888,
543,
29215,
1853,
370,
28727,
10405,
282,
19209,
315,
1212,
16913,
402,
12830,
63,
344,
14,
21039,
12,
267,
340,
29215,
15,
1931,
14665,
1630,
440,
2187,
12,
282,
892,
19209,
911,
506,
2737,
14,
221,
19209,
3762,
440,
641,
642,
769,
911,
506,
5525,
14,
8538,
269,
370,
413,
14,
23,
12,
267,
9176,
282,
2073,
1947,
1990,
2716,
3530,
272,
1415,
26,
2549,
272,
1015,
63,
3270,
26,
298,
17,
14,
22,
2,
523,
21408,
63,
7019,
26,
272,
1369,
26,
489,
446,
377,
19403,
3775,
2337,
1077,
506,
376,
22026,
10391,
10102,
370,
314,
19209,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
889,
7,
523,
7475,
63,
5987,
26,
272,
1369,
26,
489,
446,
690,
267,
437,
2600,
1625,
402,
7475,
6716,
370,
1050,
402,
314,
1824,
26,
267,
445,
2561,
18709,
26,
359,
10419,
14,
1081,
14,
18,
14,
16,
15,
1194,
12,
24911,
14,
1081,
14,
19,
14,
16,
15,
1194,
12,
467,
15777,
26,
8910,
2053,
26,
378,
14,
16,
14,
16,
14,
16,
15,
16,
12,
22192,
26,
284,
8392,
1386,
467,
2073,
63,
2969,
26,
2263,
789,
680,
17685,
314,
18709,
769,
365,
267,
5204,
18709,
314,
7475,
1817,
1077,
506,
4568,
543,
12,
436,
314,
15777,
769,
365,
282,
769,
402,
15777,
370,
506,
315,
314,
1817,
14,
221,
710,
4539,
4252,
267,
367,
314,
22192,
402,
284,
8392,
9314,
626,
1265,
1077,
314,
7475,
1077,
2621,
4012,
314,
21408,
10391,
10102,
370,
314,
19209,
14,
22192,
2597,
11479,
1256,
13,
1580,
12,
267,
3217,
13,
1580,
12,
436,
12830,
13,
7866,
316,
13,
2105,
13,
1580,
315,
10234,
284,
8392,
14,
2073,
63,
2969,
365,
2716,
436,
4440,
2600,
1824,
26,
445,
2561,
298,
985,
582,
298,
3455,
401,
2263,
789,
680,
267,
961,
859,
365,
5544,
17329,
370,
12787,
314,
298,
973,
2,
7475,
1817,
7037,
370,
2005,
4204,
315,
6055,
12,
880,
1265,
1471,
7662,
5627,
314,
4568,
267,
18709,
503,
2985,
911,
506,
10102,
370,
314,
2446,
1817,
19796,
14,
3709,
402,
413,
14,
24,
12,
340,
314,
7475,
63,
5987,
2725,
365,
440,
2013,
12,
949,
3411,
15777,
267,
911,
506,
6042,
14,
523,
3618,
26,
272,
1369,
26,
489,
446,
13144,
367,
314,
19209,
370,
506,
315,
1174,
283,
4561,
7,
2544,
8152,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
889,
7,
523
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1898,
26,
2622,
7290,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
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,
6667,
995,
490,
283,
4946,
63,
991,
356,
283,
2247,
8981,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
7062,
18,
63,
11742,
199,
3612,
63,
1802,
26,
7908,
10168,
5791,
5726,
2463,
14577,
199,
1802,
26,
272,
446,
2790,
503,
26751,
10168,
5791,
5726,
2463,
14577,
14,
221,
961,
859,
965,
282,
5936,
641,
2366,
13,
10914,
14,
199,
1023,
63,
3270,
26,
298,
17,
14,
20,
2,
199,
6667,
26,
523,
4829,
63,
262,
26,
298,
18,
14,
21,
2,
523,
10842,
26,
14402,
68,
701,
29711,
4621,
14,
523,
13943,
26,
3645,
603,
8,
825,
18,
63,
11742,
63,
846,
9,
3180,
543,
21038,
4621,
5893,
603,
8,
825,
18,
63,
11742,
63,
528,
87,
395,
603,
8,
825,
18,
63,
11742,
63,
4449,
63,
1224,
395,
603,
8,
825,
18,
63,
11742,
63,
5327,
395,
2049,
603,
8,
825,
18,
63,
11742,
63,
10801,
63,
1422,
395,
603,
8,
825,
18,
63,
11742,
63,
9468,
63,
7019,
395,
603,
8,
825,
18,
63,
11742,
63,
7745,
680,
199,
1419,
26,
523,
16770,
63,
1457,
26,
272,
1369,
26,
489,
446,
298,
1918,
16770,
1853,
6144,
314,
19209,
12,
325,
14,
71,
14,
445,
8,
709,
14,
16,
14,
16,
14,
16,
15,
975,
395,
1415,
1380,
473,
8,
929,
29,
1881,
17617,
523,
1256,
63,
724,
9844,
26,
272,
1369,
26,
489,
446,
298,
1918,
3748,
16685,
9844,
1511,
367,
4454,
27725,
1901,
314,
19209,
2122,
272,
849,
26,
298,
885,
2,
272,
3415,
26,
359,
298,
885,
401,
298,
271,
24489,
2,
1622,
523,
6715,
63,
4058,
26,
272,
1369,
26,
489,
446,
377,
24798,
2978,
314,
298,
6476,
10237,
12401,
2,
3305,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
5066,
7,
523,
6715,
63,
1102,
1247,
26,
272,
1369,
26,
489,
446,
377,
24798,
2978,
314,
298,
6476,
10237,
6246,
2291,
367,
4454,
2,
3305,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
5066,
7,
523,
18709,
26,
272,
1369,
26,
489,
446,
283,
33,
2600,
1625,
402,
18709,
370,
1050,
402,
314,
1824,
445,
2561,
16770,
26,
14263,
24978,
26,
2263,
2360,
2073,
63,
2969,
26,
2263,
789,
28823,
489,
446,
17685,
445,
8,
4651,
9,
365,
314,
6387,
14962,
5718,
402,
314,
6303,
12,
2716,
14,
489,
446,
283,
9440,
445,
8,
1927,
63,
2969,
9,
675,
2600,
1824,
445,
2561,
298,
8263,
5122,
12680,
401,
298,
52,
4446,
5122,
5926,
401,
2263,
8688,
2716,
3530,
489,
446,
445,
8,
1927,
63,
2969,
9,
1937,
2073,
63,
2969,
367,
19209,
5084,
14,
710,
2446,
8865,
365,
6303,
3762,
440,
2013,
2348,
911,
506,
5463,
14,
489,
446,
2900,
19209,
18709,
440,
315,
642,
769,
911,
506,
4829,
465,
5521,
14,
489,
446,
3709,
402,
413,
14,
24,
12,
340,
314,
18709,
2725,
365,
440,
2013,
12,
949,
3411,
18709,
911,
506,
6042,
3530,
523,
12830,
63,
344,
26,
272,
1369,
26,
489,
446,
437,
19209,
1305,
370,
15095,
1380,
473,
8,
929,
29,
5575,
680,
523,
2073,
63,
2969,
26,
272,
1369,
26,
489,
446,
283,
33,
2600,
1625,
402,
2073,
3762,
402,
314,
1824,
445,
2561,
1947,
17,
26,
574,
17,
12,
1947,
18,
26,
574,
18,
789,
680,
489,
446,
25204,
315,
642,
769,
787,
1202,
315,
22888,
543,
29215,
1853,
370,
28727,
10405,
282,
19209,
315,
1212,
16913,
402,
12830,
63,
344,
14,
21039,
12,
267,
340,
29215,
15,
1931,
14665,
1630,
440,
2187,
12,
282,
892,
19209,
911,
506,
2737,
14,
221,
19209,
3762,
440,
641,
642,
769,
911,
506,
5525,
14,
8538,
269,
370,
413,
14,
23,
12,
267,
9176,
282,
2073,
1947,
1990,
2716,
3530,
272,
1415,
26,
2549,
272,
1015,
63,
3270,
26,
298,
17,
14,
22,
2,
523,
21408,
63,
7019,
26,
272,
1369,
26,
489,
446,
377,
19403,
3775,
2337,
1077,
506,
376,
22026,
10391,
10102,
370,
314,
19209,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
889,
7,
523,
7475,
63,
5987,
26,
272,
1369,
26,
489,
446,
690,
267,
437,
2600,
1625,
402,
7475,
6716,
370,
1050,
402,
314,
1824,
26,
267,
445,
2561,
18709,
26,
359,
10419,
14,
1081,
14,
18,
14,
16,
15,
1194,
12,
24911,
14,
1081,
14,
19,
14,
16,
15,
1194,
12,
467,
15777,
26,
8910,
2053,
26,
378,
14,
16,
14,
16,
14,
16,
15,
16,
12,
22192,
26,
284,
8392,
1386,
467,
2073,
63,
2969,
26,
2263,
789,
680,
17685,
314,
18709,
769,
365,
267,
5204,
18709,
314,
7475,
1817,
1077,
506,
4568,
543,
12,
436,
314,
15777,
769,
365,
282,
769,
402,
15777,
370,
506,
315,
314,
1817,
14,
221,
710,
4539,
4252,
267,
367,
314,
22192,
402,
284,
8392,
9314,
626,
1265,
1077,
314,
7475,
1077,
2621,
4012,
314,
21408,
10391,
10102,
370,
314,
19209,
14,
22192,
2597,
11479,
1256,
13,
1580,
12,
267,
3217,
13,
1580,
12,
436,
12830,
13,
7866,
316,
13,
2105,
13,
1580,
315,
10234,
284,
8392,
14,
2073,
63,
2969,
365,
2716,
436,
4440,
2600,
1824,
26,
445,
2561,
298,
985,
582,
298,
3455,
401,
2263,
789,
680,
267,
961,
859,
365,
5544,
17329,
370,
12787,
314,
298,
973,
2,
7475,
1817,
7037,
370,
2005,
4204,
315,
6055,
12,
880,
1265,
1471,
7662,
5627,
314,
4568,
267,
18709,
503,
2985,
911,
506,
10102,
370,
314,
2446,
1817,
19796,
14,
3709,
402,
413,
14,
24,
12,
340,
314,
7475,
63,
5987,
2725,
365,
440,
2013,
12,
949,
3411,
15777,
267,
911,
506,
6042,
14,
523,
3618,
26,
272,
1369,
26,
489,
446,
13144,
367,
314,
19209,
370,
506,
315,
1174,
283,
4561,
7,
2544,
8152,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
889,
7,
523,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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This module does some pretty
ugly stuff with the Python traceback system in order to achieve tracebacks
with correct line numbers, locals and contents.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import sys
import traceback
from types import TracebackType, CodeType
from jinja2.utils import missing, internal_code
from jinja2.exceptions import TemplateSyntaxError
from jinja2._compat import iteritems, reraise, PY2
# on pypy we can take advantage of transparent proxies
try:
from __pypy__ import tproxy
except ImportError:
tproxy = None
# how does the raise helper look like?
try:
exec("raise TypeError, 'foo'")
except SyntaxError:
raise_helper = 'raise __jinja_exception__[1]'
except TypeError:
raise_helper = 'raise __jinja_exception__[0], __jinja_exception__[1]'
class TracebackFrameProxy(object):
"""Proxies a traceback frame."""
def __init__(self, tb):
self.tb = tb
self._tb_next = None
@property
def tb_next(self):
return self._tb_next
def set_next(self, next):
if tb_set_next is not None:
try:
tb_set_next(self.tb, next and next.tb or None)
except Exception:
# this function can fail due to all the hackery it does
# on various python implementations. We just catch errors
# down and ignore them if necessary.
pass
self._tb_next = next
@property
def is_jinja_frame(self):
return '__jinja_template__' in self.tb.tb_frame.f_globals
def __getattr__(self, name):
return getattr(self.tb, name)
def make_frame_proxy(frame):
proxy = TracebackFrameProxy(frame)
if tproxy is None:
return proxy
def operation_handler(operation, *args, **kwargs):
if operation in ('__getattribute__', '__getattr__'):
return getattr(proxy, args[0])
elif operation == '__setattr__':
proxy.__setattr__(*args, **kwargs)
else:
return getattr(proxy, operation)(*args, **kwargs)
return tproxy(TracebackType, operation_handler)
class ProcessedTraceback(object):
"""Holds a Jinja preprocessed traceback for printing or reraising."""
def __init__(self, exc_type, exc_value, frames):
assert frames, 'no frames for this traceback?'
self.exc_type = exc_type
self.exc_value = exc_value
self.frames = frames
# newly concatenate the frames (which are proxies)
prev_tb = None
for tb in self.frames:
if prev_tb is not None:
prev_tb.set_next(tb)
prev_tb = tb
prev_tb.set_next(None)
def render_as_text(self, limit=None):
"""Return a string with the traceback."""
lines = traceback.format_exception(self.exc_type, self.exc_value,
self.frames[0], limit=limit)
return ''.join(lines).rstrip()
def render_as_html(self, full=False):
"""Return a unicode string with the traceback as rendered HTML."""
from jinja2.debugrenderer import render_traceback
return u'%s\n\n<!--\n%s\n-->' % (
render_traceback(self, full=full),
self.render_as_text().decode('utf-8', 'replace')
)
@property
def is_template_syntax_error(self):
"""`True` if this is a template syntax error."""
return isinstance(self.exc_value, TemplateSyntaxError)
@property
def exc_info(self):
"""Exception info tuple with a proxy around the frame objects."""
return self.exc_type, self.exc_value, self.frames[0]
@property
def standard_exc_info(self):
"""Standard python exc_info for re-raising"""
tb = self.frames[0]
# the frame will be an actual traceback (or transparent proxy) if
# we are on pypy or a python implementation with support for tproxy
if type(tb) is not TracebackType:
tb = tb.tb
return self.exc_type, self.exc_value, tb
def make_traceback(exc_info, source_hint=None):
"""Creates a processed traceback object from the exc_info."""
exc_type, exc_value, tb = exc_info
if isinstance(exc_value, TemplateSyntaxError):
exc_info = translate_syntax_error(exc_value, source_hint)
initial_skip = 0
else:
initial_skip = 1
return translate_exception(exc_info, initial_skip)
def translate_syntax_error(error, source=None):
"""Rewrites a syntax error to please traceback systems."""
error.source = source
error.translated = True
exc_info = (error.__class__, error, None)
filename = error.filename
if filename is None:
filename = '<unknown>'
return fake_exc_info(exc_info, filename, error.lineno)
def translate_exception(exc_info, initial_skip=0):
"""If passed an exc_info it will automatically rewrite the exceptions
all the way down to the correct line numbers and frames.
"""
tb = exc_info[2]
frames = []
# skip some internal frames if wanted
for x in range(initial_skip):
if tb is not None:
tb = tb.tb_next
initial_tb = tb
while tb is not None:
# skip frames decorated with @internalcode. These are internal
# calls we can't avoid and that are useless in template debugging
# output.
if tb.tb_frame.f_code in internal_code:
tb = tb.tb_next
continue
# save a reference to the next frame if we override the current
# one with a faked one.
next = tb.tb_next
# fake template exceptions
template = tb.tb_frame.f_globals.get('__jinja_template__')
if template is not None:
lineno = template.get_corresponding_lineno(tb.tb_lineno)
tb = fake_exc_info(exc_info[:2] + (tb,), template.filename,
lineno)[2]
frames.append(make_frame_proxy(tb))
tb = next
# if we don't have any exceptions in the frames left, we have to
# reraise it unchanged.
# XXX: can we backup here? when could this happen?
if not frames:
reraise(exc_info[0], exc_info[1], exc_info[2])
return ProcessedTraceback(exc_info[0], exc_info[1], frames)
def fake_exc_info(exc_info, filename, lineno):
"""Helper for `translate_exception`."""
exc_type, exc_value, tb = exc_info
# figure the real context out
if tb is not None:
real_locals = tb.tb_frame.f_locals.copy()
ctx = real_locals.get('context')
if ctx:
locals = ctx.get_all()
else:
locals = {}
for name, value in iteritems(real_locals):
if name.startswith('l_') and value is not missing:
locals[name[2:]] = value
# if there is a local called __jinja_exception__, we get
# rid of it to not break the debug functionality.
locals.pop('__jinja_exception__', None)
else:
locals = {}
# assamble fake globals we need
globals = {
'__name__': filename,
'__file__': filename,
'__jinja_exception__': exc_info[:2],
# we don't want to keep the reference to the template around
# to not cause circular dependencies, but we mark it as Jinja
# frame for the ProcessedTraceback
'__jinja_template__': None
}
# and fake the exception
code = compile('\n' * (lineno - 1) + raise_helper, filename, 'exec')
# if it's possible, change the name of the code. This won't work
# on some python environments such as google appengine
try:
if tb is None:
location = 'template'
else:
function = tb.tb_frame.f_code.co_name
if function == 'root':
location = 'top-level template code'
elif function.startswith('block_'):
location = 'block "%s"' % function[6:]
else:
location = 'template'
if PY2:
code = CodeType(0, code.co_nlocals, code.co_stacksize,
code.co_flags, code.co_code, code.co_consts,
code.co_names, code.co_varnames, filename,
location, code.co_firstlineno,
code.co_lnotab, (), ())
else:
code = CodeType(0, code.co_kwonlyargcount,
code.co_nlocals, code.co_stacksize,
code.co_flags, code.co_code, code.co_consts,
code.co_names, code.co_varnames, filename,
location, code.co_firstlineno,
code.co_lnotab, (), ())
except Exception as e:
pass
# execute the code and catch the new traceback
try:
exec(code, globals, locals)
except:
exc_info = sys.exc_info()
new_tb = exc_info[2].tb_next
# return without this frame
return exc_info[:2] + (new_tb,)
def _init_ugly_crap():
"""This function implements a few ugly things so that we can patch the
traceback objects. The function returned allows resetting `tb_next` on
any python traceback object. Do not attempt to use this on non cpython
interpreters
"""
import ctypes
from types import TracebackType
if PY2:
# figure out size of _Py_ssize_t for Python 2:
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int
else:
# platform ssize_t on Python 3
_Py_ssize_t = ctypes.c_ssize_t
# regular python
class _PyObject(ctypes.Structure):
pass
_PyObject._fields_ = [
('ob_refcnt', _Py_ssize_t),
('ob_type', ctypes.POINTER(_PyObject))
]
# python with trace
if hasattr(sys, 'getobjects'):
class _PyObject(ctypes.Structure):
pass
_PyObject._fields_ = [
('_ob_next', ctypes.POINTER(_PyObject)),
('_ob_prev', ctypes.POINTER(_PyObject)),
('ob_refcnt', _Py_ssize_t),
('ob_type', ctypes.POINTER(_PyObject))
]
class _Traceback(_PyObject):
pass
_Traceback._fields_ = [
('tb_next', ctypes.POINTER(_Traceback)),
('tb_frame', ctypes.POINTER(_PyObject)),
('tb_lasti', ctypes.c_int),
('tb_lineno', ctypes.c_int)
]
def tb_set_next(tb, next):
"""Set the tb_next attribute of a traceback object."""
if not (isinstance(tb, TracebackType) and
(next is None or isinstance(next, TracebackType))):
raise TypeError('tb_set_next arguments must be traceback objects')
obj = _Traceback.from_address(id(tb))
if tb.tb_next is not None:
old = _Traceback.from_address(id(tb.tb_next))
old.ob_refcnt -= 1
if next is None:
obj.tb_next = ctypes.POINTER(_Traceback)()
else:
next = _Traceback.from_address(id(next))
next.ob_refcnt += 1
obj.tb_next = ctypes.pointer(next)
return tb_set_next
# try to get a tb_set_next implementation if we don't have transparent
# proxies.
tb_set_next = None
if tproxy is None:
try:
tb_set_next = _init_ugly_crap()
except:
pass
del _init_ugly_crap
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
1757,
272,
32202,
339,
24664,
314,
3105,
3217,
367,
17300,
14,
221,
961,
859,
1630,
2005,
7268,
272,
23761,
8292,
543,
314,
2018,
5190,
2656,
315,
1865,
370,
32194,
5190,
83,
272,
543,
3211,
1004,
5579,
12,
9480,
436,
4072,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
646,
984,
199,
646,
5190,
199,
504,
2943,
492,
15273,
804,
12,
5495,
804,
199,
504,
10321,
18,
14,
1208,
492,
4124,
12,
5007,
63,
600,
199,
504,
10321,
18,
14,
3924,
492,
17762,
199,
504,
10321,
18,
423,
5819,
492,
10849,
12,
24139,
12,
7843,
18,
199,
199,
3,
641,
1134,
647,
781,
883,
5452,
30268,
402,
17265,
14942,
199,
893,
26,
272,
687,
636,
20233,
363,
492,
307,
3280,
199,
2590,
3545,
26,
272,
307,
3280,
275,
488,
421,
199,
3,
4212,
1630,
314,
746,
5922,
3648,
2839,
31,
199,
893,
26,
272,
2146,
480,
3730,
3146,
12,
283,
1421,
9859,
199,
2590,
12053,
26,
272,
746,
63,
3676,
275,
283,
3730,
636,
12264,
63,
1971,
12298,
17,
6616,
199,
2590,
3146,
26,
272,
746,
63,
3676,
275,
283,
3730,
636,
12264,
63,
1971,
12298,
16,
467,
636,
12264,
63,
1971,
12298,
17,
6616,
421,
199,
533,
15273,
3160,
4936,
8,
785,
304,
272,
408,
26689,
1500,
282,
5190,
2787,
1041,
339,
347,
636,
826,
721,
277,
12,
7070,
304,
267,
291,
14,
5842,
275,
7070,
267,
291,
423,
5842,
63,
2184,
275,
488,
339,
768,
1829,
272,
347,
7070,
63,
2184,
8,
277,
304,
267,
372,
291,
423,
5842,
63,
2184,
339,
347,
663,
63,
2184,
8,
277,
12,
2163,
304,
267,
340,
7070,
63,
409,
63,
2184,
365,
440,
488,
26,
288,
862,
26,
355,
7070,
63,
409,
63,
2184,
8,
277,
14,
5842,
12,
2163,
436,
2163,
14,
5842,
503,
488,
9,
288,
871,
2186,
26,
355,
327,
642,
805,
883,
2449,
7037,
370,
1006,
314,
11176,
994,
652,
1630,
355,
327,
641,
7750,
2366,
12591,
14,
221,
2136,
2951,
8579,
2552,
355,
327,
3224,
436,
3686,
3062,
340,
5784,
14,
355,
986,
267,
291,
423,
5842,
63,
2184,
275,
2163,
339,
768,
1829,
272,
347,
365,
63,
12264,
63,
1943,
8,
277,
304,
267,
372,
2560,
12264,
63,
1160,
12217,
315,
291,
14,
5842,
14,
5842,
63,
1943,
14,
70,
63,
8473,
339,
347,
636,
5675,
721,
277,
12,
536,
304,
267,
372,
2519,
8,
277,
14,
5842,
12,
536,
9,
421,
199,
318,
1852,
63,
1943,
63,
3280,
8,
1943,
304,
272,
4566,
275,
15273,
3160,
4936,
8,
1943,
9,
272,
340,
307,
3280,
365,
488,
26,
267,
372,
4566,
272,
347,
3439,
63,
2232,
8,
5735,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
3439,
315,
25038,
18480,
7500,
2560,
5675,
12168,
288,
372,
2519,
8,
3280,
12,
1249,
59,
16,
566,
267,
916,
3439,
508,
2560,
10202,
3706,
288,
4566,
855,
10202,
9308,
589,
12,
1011,
958,
9,
267,
587,
26,
288,
372,
2519,
8,
3280,
12,
3439,
25967,
589,
12,
1011,
958,
9,
272,
372,
307,
3280,
8,
15905,
804,
12,
3439,
63,
2232,
9,
421,
199,
533,
2165,
4234,
15905,
8,
785,
304,
272,
408,
40,
8250,
282,
17300,
876,
7292,
5190,
367,
16116,
503,
295,
345,
11136,
1041,
339,
347,
636,
826,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
585,
12,
11223,
304,
267,
702,
11223,
12,
283,
889,
11223,
367,
642,
5190,
14069,
267,
291,
14,
2804,
63,
466,
275,
3178,
63,
466,
267,
291,
14,
2804,
63,
585,
275,
3178,
63,
585,
267,
291,
14,
8444,
275,
11223,
398,
327,
13903,
24788,
314,
11223,
334,
6777,
787,
14942,
9,
267,
5071,
63,
5842,
275,
488,
267,
367,
7070,
315,
291,
14,
8444,
26,
288,
340,
5071,
63,
5842,
365,
440,
488,
26,
355,
5071,
63,
5842,
14,
409,
63,
2184,
8,
5842,
9,
288,
5071,
63,
5842,
275,
7070,
267,
5071,
63,
5842,
14,
409,
63,
2184,
8,
403,
9,
339,
347,
3795,
63,
305,
63,
505,
8,
277,
12,
2304,
29,
403,
304,
267,
408,
1767,
282,
1059,
543,
314,
5190,
1041,
267,
2385,
275,
5190,
14,
908,
63,
1971,
8,
277,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
5644,
291,
14,
8444,
59,
16,
467,
2304,
29,
3097,
9,
267,
372,
6522,
904,
8,
1278,
680,
6735,
342,
339,
347,
3795,
63,
305,
63,
1360,
8,
277,
12,
2615,
29,
797,
304,
267,
408,
1767,
282,
2649,
1059,
543,
314,
5190,
465,
8018,
4163,
1041,
267,
687,
10321,
18,
14,
1757,
12471,
492,
3795,
63,
6894,
267,
372,
399,
5956,
83,
60,
78,
60,
78,
25273,
60,
78,
5,
83,
60,
78,
306,
3524,
450,
334,
288,
3795,
63,
6894,
8,
277,
12,
2615,
29,
2861,
395,
288,
291,
14,
3352,
63,
305,
63,
505,
1252,
2708,
360,
1624,
13,
24,
297,
283,
1814,
358,
267,
776,
339,
768,
1829,
272,
347,
365,
63,
1160,
63,
7093,
63,
705,
8,
277,
304,
267,
408,
64,
549,
64,
340,
642,
365,
282,
1978,
6302,
1125,
1041,
267,
372,
1228,
8,
277,
14,
2804,
63,
585,
12,
17762,
9,
339,
768,
1829,
272,
347,
3178,
63,
815,
8,
277,
304,
267,
408,
1726,
2256,
2008,
543,
282,
4566,
6818,
314,
2787,
2251,
1041,
267,
372,
291,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
291,
14,
8444,
59,
16,
61,
339,
768,
1829,
272,
347,
4465,
63,
2804,
63,
815,
8,
277,
304,
267,
408,
9232,
2366,
3178,
63,
815,
367,
295,
13,
345,
11136,
624,
267,
7070,
275,
291,
14,
8444,
59,
16,
61,
267,
327,
314,
2787,
911,
506,
376,
3503,
5190,
334,
269,
17265,
4566,
9,
340,
267,
327,
781,
787,
641,
1134,
647,
503,
282,
2366,
4514,
543,
2291,
367,
307,
3280,
267,
340,
730,
8,
5842,
9,
365,
440,
15273,
804,
26,
288,
7070,
275,
7070,
14,
5842,
267,
372,
291,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
7070,
421,
199,
318,
1852,
63,
6894,
8,
2804,
63
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
1757,
272,
32202,
339,
24664,
314,
3105,
3217,
367,
17300,
14,
221,
961,
859,
1630,
2005,
7268,
272,
23761,
8292,
543,
314,
2018,
5190,
2656,
315,
1865,
370,
32194,
5190,
83,
272,
543,
3211,
1004,
5579,
12,
9480,
436,
4072,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
646,
984,
199,
646,
5190,
199,
504,
2943,
492,
15273,
804,
12,
5495,
804,
199,
504,
10321,
18,
14,
1208,
492,
4124,
12,
5007,
63,
600,
199,
504,
10321,
18,
14,
3924,
492,
17762,
199,
504,
10321,
18,
423,
5819,
492,
10849,
12,
24139,
12,
7843,
18,
199,
199,
3,
641,
1134,
647,
781,
883,
5452,
30268,
402,
17265,
14942,
199,
893,
26,
272,
687,
636,
20233,
363,
492,
307,
3280,
199,
2590,
3545,
26,
272,
307,
3280,
275,
488,
421,
199,
3,
4212,
1630,
314,
746,
5922,
3648,
2839,
31,
199,
893,
26,
272,
2146,
480,
3730,
3146,
12,
283,
1421,
9859,
199,
2590,
12053,
26,
272,
746,
63,
3676,
275,
283,
3730,
636,
12264,
63,
1971,
12298,
17,
6616,
199,
2590,
3146,
26,
272,
746,
63,
3676,
275,
283,
3730,
636,
12264,
63,
1971,
12298,
16,
467,
636,
12264,
63,
1971,
12298,
17,
6616,
421,
199,
533,
15273,
3160,
4936,
8,
785,
304,
272,
408,
26689,
1500,
282,
5190,
2787,
1041,
339,
347,
636,
826,
721,
277,
12,
7070,
304,
267,
291,
14,
5842,
275,
7070,
267,
291,
423,
5842,
63,
2184,
275,
488,
339,
768,
1829,
272,
347,
7070,
63,
2184,
8,
277,
304,
267,
372,
291,
423,
5842,
63,
2184,
339,
347,
663,
63,
2184,
8,
277,
12,
2163,
304,
267,
340,
7070,
63,
409,
63,
2184,
365,
440,
488,
26,
288,
862,
26,
355,
7070,
63,
409,
63,
2184,
8,
277,
14,
5842,
12,
2163,
436,
2163,
14,
5842,
503,
488,
9,
288,
871,
2186,
26,
355,
327,
642,
805,
883,
2449,
7037,
370,
1006,
314,
11176,
994,
652,
1630,
355,
327,
641,
7750,
2366,
12591,
14,
221,
2136,
2951,
8579,
2552,
355,
327,
3224,
436,
3686,
3062,
340,
5784,
14,
355,
986,
267,
291,
423,
5842,
63,
2184,
275,
2163,
339,
768,
1829,
272,
347,
365,
63,
12264,
63,
1943,
8,
277,
304,
267,
372,
2560,
12264,
63,
1160,
12217,
315,
291,
14,
5842,
14,
5842,
63,
1943,
14,
70,
63,
8473,
339,
347,
636,
5675,
721,
277,
12,
536,
304,
267,
372,
2519,
8,
277,
14,
5842,
12,
536,
9,
421,
199,
318,
1852,
63,
1943,
63,
3280,
8,
1943,
304,
272,
4566,
275,
15273,
3160,
4936,
8,
1943,
9,
272,
340,
307,
3280,
365,
488,
26,
267,
372,
4566,
272,
347,
3439,
63,
2232,
8,
5735,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
3439,
315,
25038,
18480,
7500,
2560,
5675,
12168,
288,
372,
2519,
8,
3280,
12,
1249,
59,
16,
566,
267,
916,
3439,
508,
2560,
10202,
3706,
288,
4566,
855,
10202,
9308,
589,
12,
1011,
958,
9,
267,
587,
26,
288,
372,
2519,
8,
3280,
12,
3439,
25967,
589,
12,
1011,
958,
9,
272,
372,
307,
3280,
8,
15905,
804,
12,
3439,
63,
2232,
9,
421,
199,
533,
2165,
4234,
15905,
8,
785,
304,
272,
408,
40,
8250,
282,
17300,
876,
7292,
5190,
367,
16116,
503,
295,
345,
11136,
1041,
339,
347,
636,
826,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
585,
12,
11223,
304,
267,
702,
11223,
12,
283,
889,
11223,
367,
642,
5190,
14069,
267,
291,
14,
2804,
63,
466,
275,
3178,
63,
466,
267,
291,
14,
2804,
63,
585,
275,
3178,
63,
585,
267,
291,
14,
8444,
275,
11223,
398,
327,
13903,
24788,
314,
11223,
334,
6777,
787,
14942,
9,
267,
5071,
63,
5842,
275,
488,
267,
367,
7070,
315,
291,
14,
8444,
26,
288,
340,
5071,
63,
5842,
365,
440,
488,
26,
355,
5071,
63,
5842,
14,
409,
63,
2184,
8,
5842,
9,
288,
5071,
63,
5842,
275,
7070,
267,
5071,
63,
5842,
14,
409,
63,
2184,
8,
403,
9,
339,
347,
3795,
63,
305,
63,
505,
8,
277,
12,
2304,
29,
403,
304,
267,
408,
1767,
282,
1059,
543,
314,
5190,
1041,
267,
2385,
275,
5190,
14,
908,
63,
1971,
8,
277,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
5644,
291,
14,
8444,
59,
16,
467,
2304,
29,
3097,
9,
267,
372,
6522,
904,
8,
1278,
680,
6735,
342,
339,
347,
3795,
63,
305,
63,
1360,
8,
277,
12,
2615,
29,
797,
304,
267,
408,
1767,
282,
2649,
1059,
543,
314,
5190,
465,
8018,
4163,
1041,
267,
687,
10321,
18,
14,
1757,
12471,
492,
3795,
63,
6894,
267,
372,
399,
5956,
83,
60,
78,
60,
78,
25273,
60,
78,
5,
83,
60,
78,
306,
3524,
450,
334,
288,
3795,
63,
6894,
8,
277,
12,
2615,
29,
2861,
395,
288,
291,
14,
3352,
63,
305,
63,
505,
1252,
2708,
360,
1624,
13,
24,
297,
283,
1814,
358,
267,
776,
339,
768,
1829,
272,
347,
365,
63,
1160,
63,
7093,
63,
705,
8,
277,
304,
267,
408,
64,
549,
64,
340,
642,
365,
282,
1978,
6302,
1125,
1041,
267,
372,
1228,
8,
277,
14,
2804,
63,
585,
12,
17762,
9,
339,
768,
1829,
272,
347,
3178,
63,
815,
8,
277,
304,
267,
408,
1726,
2256,
2008,
543,
282,
4566,
6818,
314,
2787,
2251,
1041,
267,
372,
291,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
291,
14,
8444,
59,
16,
61,
339,
768,
1829,
272,
347,
4465,
63,
2804,
63,
815,
8,
277,
304,
267,
408,
9232,
2366,
3178,
63,
815,
367,
295,
13,
345,
11136,
624,
267,
7070,
275,
291,
14,
8444,
59,
16,
61,
267,
327,
314,
2787,
911,
506,
376,
3503,
5190,
334,
269,
17265,
4566,
9,
340,
267,
327,
781,
787,
641,
1134,
647,
503,
282,
2366,
4514,
543,
2291,
367,
307,
3280,
267,
340,
730,
8,
5842,
9,
365,
440,
15273,
804,
26,
288,
7070,
275,
7070,
14,
5842,
267,
372,
291,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
7070,
421,
199,
318,
1852,
63,
6894,
8,
2804,
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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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
] |
wunderlins/learning
|
python/django/lib/python2.7/site-packages/pip/_vendor/requests/cookies.py
|
177
|
17387
|
# -*- coding: utf-8 -*-
"""
Compatibility code to be able to use `cookielib.CookieJar` with requests.
requests.utils imports from here, so be careful with imports.
"""
import copy
import time
import calendar
import collections
from .compat import cookielib, urlparse, urlunparse, Morsel
try:
import threading
# grr, pyflakes: this fixes "redefinition of unused 'threading'"
threading
except ImportError:
import dummy_threading as threading
class MockRequest(object):
"""Wraps a `requests.Request` to mimic a `urllib2.Request`.
The code in `cookielib.CookieJar` expects this interface in order to correctly
manage cookie policies, i.e., determine whether a cookie can be set, given the
domains of the request and the cookie.
The original request object is read-only. The client is responsible for collecting
the new headers via `get_new_headers()` and interpreting them appropriately. You
probably want `get_cookie_header`, defined below.
"""
def __init__(self, request):
self._r = request
self._new_headers = {}
self.type = urlparse(self._r.url).scheme
def get_type(self):
return self.type
def get_host(self):
return urlparse(self._r.url).netloc
def get_origin_req_host(self):
return self.get_host()
def get_full_url(self):
# Only return the response's URL if the user hadn't set the Host
# header
if not self._r.headers.get('Host'):
return self._r.url
# If they did set it, retrieve it and reconstruct the expected domain
host = self._r.headers['Host']
parsed = urlparse(self._r.url)
# Reconstruct the URL as we expect it
return urlunparse([
parsed.scheme, host, parsed.path, parsed.params, parsed.query,
parsed.fragment
])
def is_unverifiable(self):
return True
def has_header(self, name):
return name in self._r.headers or name in self._new_headers
def get_header(self, name, default=None):
return self._r.headers.get(name, self._new_headers.get(name, default))
def add_header(self, key, val):
"""cookielib has no legitimate use for this method; add it back if you find one."""
raise NotImplementedError("Cookie headers should be added with add_unredirected_header()")
def add_unredirected_header(self, name, value):
self._new_headers[name] = value
def get_new_headers(self):
return self._new_headers
@property
def unverifiable(self):
return self.is_unverifiable()
@property
def origin_req_host(self):
return self.get_origin_req_host()
@property
def host(self):
return self.get_host()
class MockResponse(object):
"""Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.
...what? Basically, expose the parsed HTTP headers from the server response
the way `cookielib` expects to see them.
"""
def __init__(self, headers):
"""Make a MockResponse for `cookielib` to read.
:param headers: a httplib.HTTPMessage or analogous carrying the headers
"""
self._headers = headers
def info(self):
return self._headers
def getheaders(self, name):
self._headers.getheaders(name)
def extract_cookies_to_jar(jar, request, response):
"""Extract the cookies from the response into a CookieJar.
:param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar)
:param request: our own requests.Request object
:param response: urllib3.HTTPResponse object
"""
if not (hasattr(response, '_original_response') and
response._original_response):
return
# the _original_response field is the wrapped httplib.HTTPResponse object,
req = MockRequest(request)
# pull out the HTTPMessage with the headers and put it in the mock:
res = MockResponse(response._original_response.msg)
jar.extract_cookies(res, req)
def get_cookie_header(jar, request):
"""Produce an appropriate Cookie header string to be sent with `request`, or None."""
r = MockRequest(request)
jar.add_cookie_header(r)
return r.get_new_headers().get('Cookie')
def remove_cookie_by_name(cookiejar, name, domain=None, path=None):
"""Unsets a cookie by name, by default over all domains and paths.
Wraps CookieJar.clear(), is O(n).
"""
clearables = []
for cookie in cookiejar:
if cookie.name != name:
continue
if domain is not None and domain != cookie.domain:
continue
if path is not None and path != cookie.path:
continue
clearables.append((cookie.domain, cookie.path, cookie.name))
for domain, path, name in clearables:
cookiejar.clear(domain, path, name)
class CookieConflictError(RuntimeError):
"""There are two cookies that meet the criteria specified in the cookie jar.
Use .get and .set and include domain and path args in order to be more specific."""
class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
"""Compatibility class; is a cookielib.CookieJar, but exposes a dict
interface.
This is the CookieJar we create by default for requests and sessions that
don't specify one, since some clients may expect response.cookies and
session.cookies to support dict operations.
Requests does not use the dict interface internally; it's just for
compatibility with external client code. All requests code should work
out of the box with externally provided instances of ``CookieJar``, e.g.
``LWPCookieJar`` and ``FileCookieJar``.
Unlike a regular CookieJar, this class is pickleable.
.. warning:: dictionary operations that are normally O(1) may be O(n).
"""
def get(self, name, default=None, domain=None, path=None):
"""Dict-like get() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains.
.. warning:: operation is O(n), not O(1)."""
try:
return self._find_no_duplicates(name, domain, path)
except KeyError:
return default
def set(self, name, value, **kwargs):
"""Dict-like set() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains."""
# support client code that unsets cookies by assignment of a None value:
if value is None:
remove_cookie_by_name(self, name, domain=kwargs.get('domain'), path=kwargs.get('path'))
return
if isinstance(value, Morsel):
c = morsel_to_cookie(value)
else:
c = create_cookie(name, value, **kwargs)
self.set_cookie(c)
return c
def iterkeys(self):
"""Dict-like iterkeys() that returns an iterator of names of cookies
from the jar. See itervalues() and iteritems()."""
for cookie in iter(self):
yield cookie.name
def keys(self):
"""Dict-like keys() that returns a list of names of cookies from the
jar. See values() and items()."""
return list(self.iterkeys())
def itervalues(self):
"""Dict-like itervalues() that returns an iterator of values of cookies
from the jar. See iterkeys() and iteritems()."""
for cookie in iter(self):
yield cookie.value
def values(self):
"""Dict-like values() that returns a list of values of cookies from the
jar. See keys() and items()."""
return list(self.itervalues())
def iteritems(self):
"""Dict-like iteritems() that returns an iterator of name-value tuples
from the jar. See iterkeys() and itervalues()."""
for cookie in iter(self):
yield cookie.name, cookie.value
def items(self):
"""Dict-like items() that returns a list of name-value tuples from the
jar. See keys() and values(). Allows client-code to call
``dict(RequestsCookieJar)`` and get a vanilla python dict of key value
pairs."""
return list(self.iteritems())
def list_domains(self):
"""Utility method to list all the domains in the jar."""
domains = []
for cookie in iter(self):
if cookie.domain not in domains:
domains.append(cookie.domain)
return domains
def list_paths(self):
"""Utility method to list all the paths in the jar."""
paths = []
for cookie in iter(self):
if cookie.path not in paths:
paths.append(cookie.path)
return paths
def multiple_domains(self):
"""Returns True if there are multiple domains in the jar.
Returns False otherwise."""
domains = []
for cookie in iter(self):
if cookie.domain is not None and cookie.domain in domains:
return True
domains.append(cookie.domain)
return False # there is only one domain in jar
def get_dict(self, domain=None, path=None):
"""Takes as an argument an optional domain and path and returns a plain
old Python dict of name-value pairs of cookies that meet the
requirements."""
dictionary = {}
for cookie in iter(self):
if (domain is None or cookie.domain == domain) and (path is None
or cookie.path == path):
dictionary[cookie.name] = cookie.value
return dictionary
def __getitem__(self, name):
"""Dict-like __getitem__() for compatibility with client code. Throws
exception if there are more than one cookie with name. In that case,
use the more explicit get() method instead.
.. warning:: operation is O(n), not O(1)."""
return self._find_no_duplicates(name)
def __setitem__(self, name, value):
"""Dict-like __setitem__ for compatibility with client code. Throws
exception if there is already a cookie of that name in the jar. In that
case, use the more explicit set() method instead."""
self.set(name, value)
def __delitem__(self, name):
"""Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s
``remove_cookie_by_name()``."""
remove_cookie_by_name(self, name)
def set_cookie(self, cookie, *args, **kwargs):
if hasattr(cookie.value, 'startswith') and cookie.value.startswith('"') and cookie.value.endswith('"'):
cookie.value = cookie.value.replace('\\"', '')
return super(RequestsCookieJar, self).set_cookie(cookie, *args, **kwargs)
def update(self, other):
"""Updates this jar with cookies from another CookieJar or dict-like"""
if isinstance(other, cookielib.CookieJar):
for cookie in other:
self.set_cookie(copy.copy(cookie))
else:
super(RequestsCookieJar, self).update(other)
def _find(self, name, domain=None, path=None):
"""Requests uses this method internally to get cookie values. Takes as
args name and optional domain and path. Returns a cookie.value. If
there are conflicting cookies, _find arbitrarily chooses one. See
_find_no_duplicates if you want an exception thrown if there are
conflicting cookies."""
for cookie in iter(self):
if cookie.name == name:
if domain is None or cookie.domain == domain:
if path is None or cookie.path == path:
return cookie.value
raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
def _find_no_duplicates(self, name, domain=None, path=None):
"""Both ``__get_item__`` and ``get`` call this function: it's never
used elsewhere in Requests. Takes as args name and optional domain and
path. Returns a cookie.value. Throws KeyError if cookie is not found
and CookieConflictError if there are multiple cookies that match name
and optionally domain and path."""
toReturn = None
for cookie in iter(self):
if cookie.name == name:
if domain is None or cookie.domain == domain:
if path is None or cookie.path == path:
if toReturn is not None: # if there are multiple cookies that meet passed in criteria
raise CookieConflictError('There are multiple cookies with name, %r' % (name))
toReturn = cookie.value # we will eventually return this as long as no cookie conflict
if toReturn:
return toReturn
raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
def __getstate__(self):
"""Unlike a normal CookieJar, this class is pickleable."""
state = self.__dict__.copy()
# remove the unpickleable RLock object
state.pop('_cookies_lock')
return state
def __setstate__(self, state):
"""Unlike a normal CookieJar, this class is pickleable."""
self.__dict__.update(state)
if '_cookies_lock' not in self.__dict__:
self._cookies_lock = threading.RLock()
def copy(self):
"""Return a copy of this RequestsCookieJar."""
new_cj = RequestsCookieJar()
new_cj.update(self)
return new_cj
def _copy_cookie_jar(jar):
if jar is None:
return None
if hasattr(jar, 'copy'):
# We're dealing with an instance of RequestsCookieJar
return jar.copy()
# We're dealing with a generic CookieJar instance
new_jar = copy.copy(jar)
new_jar.clear()
for cookie in jar:
new_jar.set_cookie(copy.copy(cookie))
return new_jar
def create_cookie(name, value, **kwargs):
"""Make a cookie from underspecified parameters.
By default, the pair of `name` and `value` will be set for the domain ''
and sent on every request (this is sometimes called a "supercookie").
"""
result = dict(
version=0,
name=name,
value=value,
port=None,
domain='',
path='/',
secure=False,
expires=None,
discard=True,
comment=None,
comment_url=None,
rest={'HttpOnly': None},
rfc2109=False,)
badargs = set(kwargs) - set(result)
if badargs:
err = 'create_cookie() got unexpected keyword arguments: %s'
raise TypeError(err % list(badargs))
result.update(kwargs)
result['port_specified'] = bool(result['port'])
result['domain_specified'] = bool(result['domain'])
result['domain_initial_dot'] = result['domain'].startswith('.')
result['path_specified'] = bool(result['path'])
return cookielib.Cookie(**result)
def morsel_to_cookie(morsel):
"""Convert a Morsel object into a Cookie containing the one k/v pair."""
expires = None
if morsel['max-age']:
try:
expires = int(time.time() + int(morsel['max-age']))
except ValueError:
raise TypeError('max-age: %s must be integer' % morsel['max-age'])
elif morsel['expires']:
time_template = '%a, %d-%b-%Y %H:%M:%S GMT'
expires = calendar.timegm(
time.strptime(morsel['expires'], time_template)
)
return create_cookie(
comment=morsel['comment'],
comment_url=bool(morsel['comment']),
discard=False,
domain=morsel['domain'],
expires=expires,
name=morsel.key,
path=morsel['path'],
port=None,
rest={'HttpOnly': morsel['httponly']},
rfc2109=False,
secure=bool(morsel['secure']),
value=morsel.value,
version=morsel['version'] or 0,
)
def cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True):
"""Returns a CookieJar from a key/value dictionary.
:param cookie_dict: Dict of key/values to insert into CookieJar.
:param cookiejar: (optional) A cookiejar to add the cookies to.
:param overwrite: (optional) If False, will not replace cookies
already in the jar with new ones.
"""
if cookiejar is None:
cookiejar = RequestsCookieJar()
if cookie_dict is not None:
names_from_jar = [cookie.name for cookie in cookiejar]
for name in cookie_dict:
if overwrite or (name not in names_from_jar):
cookiejar.set_cookie(create_cookie(name, cookie_dict[name]))
return cookiejar
def merge_cookies(cookiejar, cookies):
"""Add cookies to cookiejar and returns a merged CookieJar.
:param cookiejar: CookieJar object to add the cookies to.
:param cookies: Dictionary or CookieJar object to be added.
"""
if not isinstance(cookiejar, cookielib.CookieJar):
raise ValueError('You can only merge into CookieJar')
if isinstance(cookies, dict):
cookiejar = cookiejar_from_dict(
cookies, cookiejar=cookiejar, overwrite=False)
elif isinstance(cookies, cookielib.CookieJar):
try:
cookiejar.update(cookies)
except AttributeError:
for cookie_in_jar in cookies:
cookiejar.set_cookie(cookie_in_jar)
return cookiejar
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
2404,
5880,
1233,
370,
506,
7688,
370,
675,
658,
5306,
773,
14,
21315,
64,
543,
4145,
14,
199,
199,
6615,
14,
1208,
8925,
687,
2348,
12,
880,
506,
25082,
543,
8925,
14,
199,
624,
199,
199,
646,
1331,
199,
646,
900,
199,
646,
11234,
199,
646,
5055,
199,
504,
1275,
5819,
492,
26234,
12,
7097,
12,
30111,
12,
603,
269,
5891,
199,
199,
893,
26,
272,
492,
5796,
272,
327,
31118,
12,
1134,
29677,
26,
642,
25079,
298,
264,
7463,
402,
9563,
283,
12562,
4065,
272,
5796,
199,
2590,
3545,
26,
272,
492,
7283,
63,
12562,
465,
5796,
421,
199,
533,
4420,
2017,
8,
785,
304,
272,
408,
55,
8146,
282,
658,
6615,
14,
2017,
64,
370,
24102,
530,
282,
658,
4078,
18,
14,
2017,
2313,
339,
710,
1233,
315,
658,
5306,
773,
14,
21315,
64,
14292,
642,
3217,
315,
1865,
370,
6657,
272,
9635,
5494,
14118,
12,
284,
14,
69,
2020,
6705,
3775,
282,
5494,
883,
506,
663,
12,
1627,
314,
272,
14006,
402,
314,
1056,
436,
314,
5494,
14,
339,
710,
3379,
1056,
909,
365,
1586,
13,
2118,
14,
710,
1890,
365,
17845,
367,
32223,
272,
314,
892,
2323,
4799,
658,
362,
63,
1222,
63,
2139,
11995,
436,
6421,
1337,
3062,
22497,
14,
2047,
272,
8646,
2934,
658,
362,
63,
5306,
63,
1291,
3559,
3247,
5084,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
1056,
304,
267,
291,
423,
82,
275,
1056,
267,
291,
423,
1222,
63,
2139,
275,
1052,
267,
291,
14,
466,
275,
7097,
8,
277,
423,
82,
14,
633,
680,
5512,
339,
347,
664,
63,
466,
8,
277,
304,
267,
372,
291,
14,
466,
339,
347,
664,
63,
1102,
8,
277,
304,
267,
372,
7097,
8,
277,
423,
82,
14,
633,
680,
12652,
339,
347,
664,
63,
6493,
63,
2103,
63,
1102,
8,
277,
304,
267,
372,
291,
14,
362,
63,
1102,
342,
339,
347,
664,
63,
2861,
63,
633,
8,
277,
304,
267,
327,
5972,
372,
314,
1177,
1159,
2851,
340,
314,
922,
10530,
78,
1133,
663,
314,
10891,
267,
327,
1406,
267,
340,
440,
291,
423,
82,
14,
2139,
14,
362,
360,
4965,
735,
288,
372,
291,
423,
82,
14,
633,
267,
327,
982,
2985,
8103,
663,
652,
12,
8044,
652,
436,
28462,
314,
1420,
2881,
267,
1591,
275,
291,
423,
82,
14,
2139,
459,
4965,
418,
267,
4565,
275,
7097,
8,
277,
423,
82,
14,
633,
9,
267,
327,
799,
8514,
314,
2851,
465,
781,
4282,
652,
267,
372,
30111,
779,
288,
4565,
14,
5512,
12,
1591,
12,
4565,
14,
515,
12,
4565,
14,
1162,
12,
4565,
14,
1131,
12,
288,
4565,
14,
7677,
267,
4794,
339,
347,
365,
63,
324,
422,
1903,
461,
8,
277,
304,
267,
372,
715,
339,
347,
965,
63,
1291,
8,
277,
12,
536,
304,
267,
372,
536,
315,
291,
423,
82,
14,
2139,
503,
536,
315,
291,
423,
1222,
63,
2139,
339,
347,
664,
63,
1291,
8,
277,
12,
536,
12,
849,
29,
403,
304,
267,
372,
291,
423,
82,
14,
2139,
14,
362,
8,
354,
12,
291,
423,
1222,
63,
2139,
14,
362,
8,
354,
12,
849,
430,
339,
347,
1050,
63,
1291,
8,
277,
12,
790,
12,
1139,
304,
267,
408,
5306,
773,
965,
949,
1026,
6153,
2906,
323,
675,
367,
642,
1083,
27,
1050,
652,
1771,
340,
1265,
2342,
1373,
1041,
267,
746,
4279,
480,
7810,
2323,
1077,
506,
3483,
543,
1050,
63,
324,
264,
12080,
63,
1291,
16060,
339,
347,
1050,
63,
324,
264,
12080,
63,
1291,
8,
277,
12,
536,
12,
574,
304,
267,
291,
423,
1222,
63,
2139,
59,
354,
61,
275,
574,
339,
347,
664,
63,
1222,
63,
2139,
8,
277,
304,
267,
372,
291,
423,
1222,
63,
2139,
339,
768,
1829,
272,
347,
625,
422,
1903,
461,
8,
277,
304,
267,
372,
291,
14,
374,
63,
324,
422,
1903,
461,
342,
339,
768,
1829,
272,
347,
6330,
63,
2103,
63,
1102,
8,
277,
304,
267,
372,
291,
14,
362,
63,
6493,
63,
2103,
63,
1102,
342,
339,
768,
1829,
272,
347,
1591,
8,
277,
304,
267,
372,
291,
14,
362,
63,
1102,
342,
421,
199,
533,
4420,
2364,
8,
785,
304,
272,
408,
55,
8146,
282,
658,
12942,
14,
2856,
2209,
64,
370,
24102,
530,
282,
658,
4078,
14,
525,
815,
633,
2313,
339,
2263,
10058,
31,
10082,
1183,
12,
23705,
314,
4565,
3101,
2323,
687,
314,
1654,
1177,
272,
314,
4340,
658,
5306,
773,
64,
14292,
370,
1937,
3062,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
2323,
304,
267,
408,
5483,
282,
4420,
2364,
367,
658,
5306,
773,
64,
370,
1586,
14,
398,
520,
635,
2323,
26,
282,
8809,
14,
2856,
2209,
503,
20439,
1785,
25176,
316,
314,
2323,
267,
408,
267,
291,
423,
2139,
275,
2323,
339,
347,
2256,
8,
277,
304,
267,
372,
291,
423,
2139,
339,
347,
2312,
16946,
83,
8,
277,
12,
536,
304,
267,
291,
423,
2139,
14,
19958,
83,
8,
354,
9,
421,
199,
318,
5536,
63,
7792,
63,
475,
63,
7338,
8,
7338,
12,
1056,
12,
1177,
304,
272,
408,
12147,
314,
10049,
687,
314,
1177,
1901,
282,
25143,
14,
339,
520,
635,
16290,
26,
26234,
14,
21315,
334,
1397,
20513,
282,
20260,
21315,
9,
272,
520,
635,
1056,
26,
4154,
5705,
4145,
14,
2017,
909,
272,
520,
635,
1177,
26,
4011,
19,
14,
27068,
909,
272,
408,
272,
340,
440,
334,
11161,
8,
1310,
12,
2513,
5043,
63,
1310,
358,
436,
288,
1177,
423,
5043,
63,
1310,
304,
267,
372,
272,
327,
314,
485,
5043,
63,
1310,
901,
365,
314,
8072,
8809,
14,
27068,
909,
12,
272,
2648,
275,
4420,
2017,
8,
1069,
9,
272,
327,
10299,
734,
314,
3101,
2209,
543,
314,
2323,
436,
5324,
652,
315,
314,
1683,
26,
272,
522,
275,
4420,
2364,
8,
1310,
423,
5043,
63,
1310,
14,
1328,
9,
272,
16290,
14,
5005,
63,
7792,
8,
470,
12,
2648,
9,
421,
199,
318,
664,
63,
5306,
63,
1291,
8,
7338,
12,
1056,
304,
272,
408,
24391,
376,
5827,
14798,
1406,
1059,
370,
506,
4847,
543,
658,
1069,
3559,
503,
488,
1041,
272,
519,
275,
4420,
2017,
8,
1069,
9,
272
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
2404,
5880,
1233,
370,
506,
7688,
370,
675,
658,
5306,
773,
14,
21315,
64,
543,
4145,
14,
199,
199,
6615,
14,
1208,
8925,
687,
2348,
12,
880,
506,
25082,
543,
8925,
14,
199,
624,
199,
199,
646,
1331,
199,
646,
900,
199,
646,
11234,
199,
646,
5055,
199,
504,
1275,
5819,
492,
26234,
12,
7097,
12,
30111,
12,
603,
269,
5891,
199,
199,
893,
26,
272,
492,
5796,
272,
327,
31118,
12,
1134,
29677,
26,
642,
25079,
298,
264,
7463,
402,
9563,
283,
12562,
4065,
272,
5796,
199,
2590,
3545,
26,
272,
492,
7283,
63,
12562,
465,
5796,
421,
199,
533,
4420,
2017,
8,
785,
304,
272,
408,
55,
8146,
282,
658,
6615,
14,
2017,
64,
370,
24102,
530,
282,
658,
4078,
18,
14,
2017,
2313,
339,
710,
1233,
315,
658,
5306,
773,
14,
21315,
64,
14292,
642,
3217,
315,
1865,
370,
6657,
272,
9635,
5494,
14118,
12,
284,
14,
69,
2020,
6705,
3775,
282,
5494,
883,
506,
663,
12,
1627,
314,
272,
14006,
402,
314,
1056,
436,
314,
5494,
14,
339,
710,
3379,
1056,
909,
365,
1586,
13,
2118,
14,
710,
1890,
365,
17845,
367,
32223,
272,
314,
892,
2323,
4799,
658,
362,
63,
1222,
63,
2139,
11995,
436,
6421,
1337,
3062,
22497,
14,
2047,
272,
8646,
2934,
658,
362,
63,
5306,
63,
1291,
3559,
3247,
5084,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
1056,
304,
267,
291,
423,
82,
275,
1056,
267,
291,
423,
1222,
63,
2139,
275,
1052,
267,
291,
14,
466,
275,
7097,
8,
277,
423,
82,
14,
633,
680,
5512,
339,
347,
664,
63,
466,
8,
277,
304,
267,
372,
291,
14,
466,
339,
347,
664,
63,
1102,
8,
277,
304,
267,
372,
7097,
8,
277,
423,
82,
14,
633,
680,
12652,
339,
347,
664,
63,
6493,
63,
2103,
63,
1102,
8,
277,
304,
267,
372,
291,
14,
362,
63,
1102,
342,
339,
347,
664,
63,
2861,
63,
633,
8,
277,
304,
267,
327,
5972,
372,
314,
1177,
1159,
2851,
340,
314,
922,
10530,
78,
1133,
663,
314,
10891,
267,
327,
1406,
267,
340,
440,
291,
423,
82,
14,
2139,
14,
362,
360,
4965,
735,
288,
372,
291,
423,
82,
14,
633,
267,
327,
982,
2985,
8103,
663,
652,
12,
8044,
652,
436,
28462,
314,
1420,
2881,
267,
1591,
275,
291,
423,
82,
14,
2139,
459,
4965,
418,
267,
4565,
275,
7097,
8,
277,
423,
82,
14,
633,
9,
267,
327,
799,
8514,
314,
2851,
465,
781,
4282,
652,
267,
372,
30111,
779,
288,
4565,
14,
5512,
12,
1591,
12,
4565,
14,
515,
12,
4565,
14,
1162,
12,
4565,
14,
1131,
12,
288,
4565,
14,
7677,
267,
4794,
339,
347,
365,
63,
324,
422,
1903,
461,
8,
277,
304,
267,
372,
715,
339,
347,
965,
63,
1291,
8,
277,
12,
536,
304,
267,
372,
536,
315,
291,
423,
82,
14,
2139,
503,
536,
315,
291,
423,
1222,
63,
2139,
339,
347,
664,
63,
1291,
8,
277,
12,
536,
12,
849,
29,
403,
304,
267,
372,
291,
423,
82,
14,
2139,
14,
362,
8,
354,
12,
291,
423,
1222,
63,
2139,
14,
362,
8,
354,
12,
849,
430,
339,
347,
1050,
63,
1291,
8,
277,
12,
790,
12,
1139,
304,
267,
408,
5306,
773,
965,
949,
1026,
6153,
2906,
323,
675,
367,
642,
1083,
27,
1050,
652,
1771,
340,
1265,
2342,
1373,
1041,
267,
746,
4279,
480,
7810,
2323,
1077,
506,
3483,
543,
1050,
63,
324,
264,
12080,
63,
1291,
16060,
339,
347,
1050,
63,
324,
264,
12080,
63,
1291,
8,
277,
12,
536,
12,
574,
304,
267,
291,
423,
1222,
63,
2139,
59,
354,
61,
275,
574,
339,
347,
664,
63,
1222,
63,
2139,
8,
277,
304,
267,
372,
291,
423,
1222,
63,
2139,
339,
768,
1829,
272,
347,
625,
422,
1903,
461,
8,
277,
304,
267,
372,
291,
14,
374,
63,
324,
422,
1903,
461,
342,
339,
768,
1829,
272,
347,
6330,
63,
2103,
63,
1102,
8,
277,
304,
267,
372,
291,
14,
362,
63,
6493,
63,
2103,
63,
1102,
342,
339,
768,
1829,
272,
347,
1591,
8,
277,
304,
267,
372,
291,
14,
362,
63,
1102,
342,
421,
199,
533,
4420,
2364,
8,
785,
304,
272,
408,
55,
8146,
282,
658,
12942,
14,
2856,
2209,
64,
370,
24102,
530,
282,
658,
4078,
14,
525,
815,
633,
2313,
339,
2263,
10058,
31,
10082,
1183,
12,
23705,
314,
4565,
3101,
2323,
687,
314,
1654,
1177,
272,
314,
4340,
658,
5306,
773,
64,
14292,
370,
1937,
3062,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
2323,
304,
267,
408,
5483,
282,
4420,
2364,
367,
658,
5306,
773,
64,
370,
1586,
14,
398,
520,
635,
2323,
26,
282,
8809,
14,
2856,
2209,
503,
20439,
1785,
25176,
316,
314,
2323,
267,
408,
267,
291,
423,
2139,
275,
2323,
339,
347,
2256,
8,
277,
304,
267,
372,
291,
423,
2139,
339,
347,
2312,
16946,
83,
8,
277,
12,
536,
304,
267,
291,
423,
2139,
14,
19958,
83,
8,
354,
9,
421,
199,
318,
5536,
63,
7792,
63,
475,
63,
7338,
8,
7338,
12,
1056,
12,
1177,
304,
272,
408,
12147,
314,
10049,
687,
314,
1177,
1901,
282,
25143,
14,
339,
520,
635,
16290,
26,
26234,
14,
21315,
334,
1397,
20513,
282,
20260,
21315,
9,
272,
520,
635,
1056,
26,
4154,
5705,
4145,
14,
2017,
909,
272,
520,
635,
1177,
26,
4011,
19,
14,
27068,
909,
272,
408,
272,
340,
440,
334,
11161,
8,
1310,
12,
2513,
5043,
63,
1310,
358,
436,
288,
1177,
423,
5043,
63,
1310,
304,
267,
372,
272,
327,
314,
485,
5043,
63,
1310,
901,
365,
314,
8072,
8809,
14,
27068,
909,
12,
272,
2648,
275,
4420,
2017,
8,
1069,
9,
272,
327,
10299,
734,
314,
3101,
2209,
543,
314,
2323,
436,
5324,
652,
315,
314,
1683,
26,
272,
522,
275,
4420,
2364,
8,
1310,
423,
5043,
63,
1310,
14,
1328,
9,
272,
16290,
14,
5005,
63,
7792,
8,
470,
12,
2648,
9,
421,
199,
318,
664,
63,
5306,
63,
1291,
8,
7338,
12,
1056,
304,
272,
408,
24391,
376,
5827,
14798,
1406,
1059,
370,
506,
4847,
543,
658,
1069,
3559,
503,
488,
1041,
272,
519,
275,
4420,
2017,
8,
1069,
9,
272,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ChrisAntaki/phantomjs
|
src/qt/qtwebkit/Tools/QueueStatusServer/handlers/statusbubble_unittest.py
|
128
|
2482
|
# Copyright (C) 2010 Google, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Research in Motion Ltd. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import unittest
from handlers.statusbubble import StatusBubble
from model.queues import Queue
class MockAttachment(object):
def __init__(self):
self.id = 1
def status_for_queue(self, queue):
return None
def position_in_queue(self, queue):
return 1
class StatusBubbleTest(unittest.TestCase):
def test_build_bubble(self):
bubble = StatusBubble()
queue = Queue("mac-ews")
attachment = MockAttachment()
bubble_dict = bubble._build_bubble(queue, attachment, 1)
# FIXME: assertDictEqual (in Python 2.7) would be better to use here.
self.assertEqual(bubble_dict["name"], "mac")
self.assertEqual(bubble_dict["attachment_id"], 1)
self.assertEqual(bubble_dict["queue_position"], 1)
self.assertEqual(bubble_dict["state"], "none")
self.assertEqual(bubble_dict["status"], None)
if __name__ == '__main__':
unittest.main()
|
bsd-3-clause
|
[
3,
1898,
334,
35,
9,
7129,
4475,
12,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
259,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
259,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
259,
627,
11443,
314,
536,
402,
26993,
315,
3930,
296,
12126,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
2882,
421,
199,
504,
8297,
14,
1205,
66,
21749,
492,
9795,
34,
21749,
199,
504,
1402,
14,
18849,
492,
10703,
421,
199,
533,
4420,
22662,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
344,
275,
413,
339,
347,
2004,
63,
509,
63,
1825,
8,
277,
12,
4126,
304,
267,
372,
488,
339,
347,
3421,
63,
262,
63,
1825,
8,
277,
12,
4126,
304,
267,
372,
413,
421,
199,
533,
9795,
34,
21749,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
1506,
63,
66,
21749,
8,
277,
304,
267,
330,
21749,
275,
9795,
34,
21749,
342,
267,
4126,
275,
10703,
480,
3088,
13,
546,
83,
531,
267,
12193,
275,
4420,
22662,
342,
267,
330,
21749,
63,
807,
275,
330,
21749,
423,
1506,
63,
66,
21749,
8,
1825,
12,
12193,
12,
413,
9,
267,
327,
7600,
26,
702,
2141,
591,
334,
262,
2018,
499,
14,
23,
9,
3955,
506,
8034,
370,
675,
2348,
14,
267,
291,
14,
629,
8,
66,
21749,
63,
807,
905,
354,
2255,
298,
3088,
531,
267,
291,
14,
629,
8,
66,
21749,
63,
807,
905,
8905,
63,
344,
2255,
413,
9,
267,
291,
14,
629,
8,
66,
21749,
63,
807,
905,
1825,
63,
3124,
2255,
413,
9,
267,
291,
14,
629,
8,
66,
21749,
63,
807,
905,
929,
2255,
298,
3592,
531,
267,
291,
14,
629,
8,
66,
21749,
63,
807,
905,
1205,
2255,
488,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
7129,
4475,
12,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
259,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
259,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
259,
627,
11443,
314,
536,
402,
26993,
315,
3930,
296,
12126,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
2882,
421,
199,
504,
8297,
14,
1205,
66,
21749,
492,
9795,
34,
21749,
199,
504,
1402,
14,
18849,
492,
10703,
421,
199,
533,
4420,
22662,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
344,
275,
413,
339,
347,
2004,
63,
509,
63,
1825,
8,
277,
12,
4126,
304,
267,
372,
488,
339,
347,
3421,
63,
262,
63,
1825,
8,
277,
12,
4126,
304,
267,
372,
413,
421,
199,
533,
9795,
34,
21749,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
1506,
63,
66,
21749,
8,
277,
304,
267,
330,
21749,
275,
9795,
34,
21749,
342,
267,
4126,
275,
10703,
480,
3088,
13,
546,
83,
531,
267,
12193,
275,
4420,
22662,
342,
267,
330,
21749,
63,
807,
275,
330,
21749,
423,
1506,
63,
66,
21749,
8,
1825,
12,
12193,
12,
413,
9,
267,
327,
7600,
26,
702,
2141,
591,
334,
262,
2018,
499,
14,
23,
9,
3955,
506,
8034,
370,
675,
2348,
14,
267,
291,
14,
629,
8,
66,
21749,
63,
807,
905,
354,
2255,
298,
3088,
531,
267,
291,
14,
629,
8,
66,
21749,
63,
807,
905,
8905,
63,
344,
2255,
413,
9,
267,
291,
14,
629,
8,
66,
21749,
63,
807,
905,
1825,
63,
3124,
2255,
413,
9,
267,
291,
14,
629,
8,
66,
21749,
63,
807,
905,
929,
2255,
298,
3592,
531,
267,
291,
14,
629,
8,
66,
21749,
63,
807,
905,
1205,
2255,
488,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
KevinMidboe/statusHandler
|
flask/lib/python3.4/site-packages/pip/commands/uninstall.py
|
798
|
2884
|
from __future__ import absolute_import
import pip
from pip.wheel import WheelCache
from pip.req import InstallRequirement, RequirementSet, parse_requirements
from pip.basecommand import Command
from pip.exceptions import InstallationError
class UninstallCommand(Command):
"""
Uninstall packages.
pip is able to uninstall most installed packages. Known exceptions are:
- Pure distutils packages installed with ``python setup.py install``, which
leave behind no metadata to determine what files were installed.
- Script wrappers installed by ``python setup.py develop``.
"""
name = 'uninstall'
usage = """
%prog [options] <package> ...
%prog [options] -r <requirements file> ..."""
summary = 'Uninstall packages.'
def __init__(self, *args, **kw):
super(UninstallCommand, self).__init__(*args, **kw)
self.cmd_opts.add_option(
'-r', '--requirement',
dest='requirements',
action='append',
default=[],
metavar='file',
help='Uninstall all the packages listed in the given requirements '
'file. This option can be used multiple times.',
)
self.cmd_opts.add_option(
'-y', '--yes',
dest='yes',
action='store_true',
help="Don't ask for confirmation of uninstall deletions.")
self.parser.insert_option_group(0, self.cmd_opts)
def run(self, options, args):
with self._build_session(options) as session:
format_control = pip.index.FormatControl(set(), set())
wheel_cache = WheelCache(options.cache_dir, format_control)
requirement_set = RequirementSet(
build_dir=None,
src_dir=None,
download_dir=None,
isolated=options.isolated_mode,
session=session,
wheel_cache=wheel_cache,
)
for name in args:
requirement_set.add_requirement(
InstallRequirement.from_line(
name, isolated=options.isolated_mode,
wheel_cache=wheel_cache
)
)
for filename in options.requirements:
for req in parse_requirements(
filename,
options=options,
session=session,
wheel_cache=wheel_cache):
requirement_set.add_requirement(req)
if not requirement_set.has_requirements:
raise InstallationError(
'You must give at least one requirement to %(name)s (see '
'"pip help %(name)s")' % dict(name=self.name)
)
requirement_set.uninstall(auto_confirm=options.yes)
|
mit
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
7305,
199,
504,
7305,
14,
11798,
492,
26161,
4437,
199,
504,
7305,
14,
2103,
492,
13276,
17947,
12,
25013,
1084,
12,
2198,
63,
7538,
199,
504,
7305,
14,
1095,
1531,
492,
5817,
199,
504,
7305,
14,
3924,
492,
26866,
547,
421,
199,
533,
1910,
3174,
3110,
8,
3110,
304,
272,
408,
272,
1910,
3174,
6117,
14,
339,
7305,
365,
7688,
370,
22199,
4750,
4903,
6117,
14,
31862,
4967,
787,
26,
339,
446,
510,
608,
7065,
6117,
4903,
543,
1124,
1548,
3272,
14,
647,
3907,
4542,
1314,
489,
10137,
22172,
949,
3341,
370,
6705,
4052,
1584,
4898,
4903,
14,
272,
446,
14914,
17995,
4903,
701,
1124,
1548,
3272,
14,
647,
477,
7549,
4345,
272,
408,
272,
536,
275,
283,
19502,
7,
272,
4503,
275,
408,
489,
450,
6595,
359,
1419,
61,
665,
2491,
30,
2263,
489,
450,
6595,
359,
1419,
61,
446,
82,
665,
7538,
570,
30,
2508,
1041,
272,
6212,
275,
283,
1358,
3174,
6117,
3530,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
1613,
8,
1358,
3174,
3110,
12,
291,
2843,
826,
9308,
589,
12,
1011,
829,
9,
267,
291,
14,
1760,
63,
3291,
14,
525,
63,
1422,
8,
288,
2475,
82,
297,
2850,
12434,
297,
288,
2053,
534,
7538,
297,
288,
1595,
534,
740,
297,
288,
849,
6034,
288,
8214,
534,
493,
297,
288,
1720,
534,
1358,
3174,
1006,
314,
6117,
10532,
315,
314,
1627,
9760,
283,
326,
283,
493,
14,
221,
961,
945,
883,
506,
1202,
3663,
5431,
3130,
267,
776,
267,
291,
14,
1760,
63,
3291,
14,
525,
63,
1422,
8,
288,
2475,
89,
297,
2850,
5066,
297,
288,
2053,
534,
5066,
297,
288,
1595,
534,
1617,
63,
2052,
297,
288,
1720,
628,
16932,
1133,
7198,
367,
18791,
402,
22199,
6070,
852,
2685,
398,
291,
14,
2087,
14,
3176,
63,
1422,
63,
923,
8,
16,
12,
291,
14,
1760,
63,
3291,
9,
339,
347,
1255,
8,
277,
12,
1511,
12,
1249,
304,
267,
543,
291,
423,
1506,
63,
1730,
8,
1419,
9,
465,
2351,
26,
288,
1475,
63,
2785,
275,
7305,
14,
1080,
14,
3484,
3717,
8,
409,
1062,
663,
1012,
288,
9989,
63,
1637,
275,
26161,
4437,
8,
1419,
14,
1637,
63,
694,
12,
1475,
63,
2785,
9,
288,
10685,
63,
409,
275,
25013,
1084,
8,
355,
1900,
63,
694,
29,
403,
12,
355,
2928,
63,
694,
29,
403,
12,
355,
5235,
63,
694,
29,
403,
12,
355,
23348,
29,
1419,
14,
21748,
63,
632,
12,
355,
2351,
29,
1730,
12,
355,
9989,
63,
1637,
29,
11798,
63,
1637,
12,
288,
776,
288,
367,
536,
315,
1249,
26,
355,
10685,
63,
409,
14,
525,
63,
12434,
8,
490,
13276,
17947,
14,
504,
63,
604,
8,
717,
536,
12,
23348,
29,
1419,
14,
21748,
63,
632,
12,
717,
9989,
63,
1637,
29,
11798,
63,
1637,
490,
776,
355,
776,
288,
367,
1788,
315,
1511,
14,
7538,
26,
355,
367,
2648,
315,
2198,
63,
7538,
8,
717,
1788,
12,
717,
1511,
29,
1419,
12,
717,
2351,
29,
1730,
12,
717,
9989,
63,
1637,
29,
11798,
63,
1637,
304,
490,
10685,
63,
409,
14,
525,
63,
12434,
8,
2103,
9,
288,
340,
440,
10685,
63,
409,
14,
1989,
63,
7538,
26,
355,
746,
26866,
547,
8,
490,
283,
5556,
1471,
8120,
737,
5210,
1373,
10685,
370,
2818,
354,
9,
83,
334,
3239,
283,
490,
5522,
9983,
1720,
2818,
354,
9,
83,
32292,
450,
1211,
8,
354,
29,
277,
14,
354,
9,
355,
776,
288,
10685,
63,
409,
14,
19502,
8,
2495,
63,
9548,
29,
1419,
14,
5066,
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
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
7305,
199,
504,
7305,
14,
11798,
492,
26161,
4437,
199,
504,
7305,
14,
2103,
492,
13276,
17947,
12,
25013,
1084,
12,
2198,
63,
7538,
199,
504,
7305,
14,
1095,
1531,
492,
5817,
199,
504,
7305,
14,
3924,
492,
26866,
547,
421,
199,
533,
1910,
3174,
3110,
8,
3110,
304,
272,
408,
272,
1910,
3174,
6117,
14,
339,
7305,
365,
7688,
370,
22199,
4750,
4903,
6117,
14,
31862,
4967,
787,
26,
339,
446,
510,
608,
7065,
6117,
4903,
543,
1124,
1548,
3272,
14,
647,
3907,
4542,
1314,
489,
10137,
22172,
949,
3341,
370,
6705,
4052,
1584,
4898,
4903,
14,
272,
446,
14914,
17995,
4903,
701,
1124,
1548,
3272,
14,
647,
477,
7549,
4345,
272,
408,
272,
536,
275,
283,
19502,
7,
272,
4503,
275,
408,
489,
450,
6595,
359,
1419,
61,
665,
2491,
30,
2263,
489,
450,
6595,
359,
1419,
61,
446,
82,
665,
7538,
570,
30,
2508,
1041,
272,
6212,
275,
283,
1358,
3174,
6117,
3530,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
1613,
8,
1358,
3174,
3110,
12,
291,
2843,
826,
9308,
589,
12,
1011,
829,
9,
267,
291,
14,
1760,
63,
3291,
14,
525,
63,
1422,
8,
288,
2475,
82,
297,
2850,
12434,
297,
288,
2053,
534,
7538,
297,
288,
1595,
534,
740,
297,
288,
849,
6034,
288,
8214,
534,
493,
297,
288,
1720,
534,
1358,
3174,
1006,
314,
6117,
10532,
315,
314,
1627,
9760,
283,
326,
283,
493,
14,
221,
961,
945,
883,
506,
1202,
3663,
5431,
3130,
267,
776,
267,
291,
14,
1760,
63,
3291,
14,
525,
63,
1422,
8,
288,
2475,
89,
297,
2850,
5066,
297,
288,
2053,
534,
5066,
297,
288,
1595,
534,
1617,
63,
2052,
297,
288,
1720,
628,
16932,
1133,
7198,
367,
18791,
402,
22199,
6070,
852,
2685,
398,
291,
14,
2087,
14,
3176,
63,
1422,
63,
923,
8,
16,
12,
291,
14,
1760,
63,
3291,
9,
339,
347,
1255,
8,
277,
12,
1511,
12,
1249,
304,
267,
543,
291,
423,
1506,
63,
1730,
8,
1419,
9,
465,
2351,
26,
288,
1475,
63,
2785,
275,
7305,
14,
1080,
14,
3484,
3717,
8,
409,
1062,
663,
1012,
288,
9989,
63,
1637,
275,
26161,
4437,
8,
1419,
14,
1637,
63,
694,
12,
1475,
63,
2785,
9,
288,
10685,
63,
409,
275,
25013,
1084,
8,
355,
1900,
63,
694,
29,
403,
12,
355,
2928,
63,
694,
29,
403,
12,
355,
5235,
63,
694,
29,
403,
12,
355,
23348,
29,
1419,
14,
21748,
63,
632,
12,
355,
2351,
29,
1730,
12,
355,
9989,
63,
1637,
29,
11798,
63,
1637,
12,
288,
776,
288,
367,
536,
315,
1249,
26,
355,
10685,
63,
409,
14,
525,
63,
12434,
8,
490,
13276,
17947,
14,
504,
63,
604,
8,
717,
536,
12,
23348,
29,
1419,
14,
21748,
63,
632,
12,
717,
9989,
63,
1637,
29,
11798,
63,
1637,
490,
776,
355,
776,
288,
367,
1788,
315,
1511,
14,
7538,
26,
355,
367,
2648,
315,
2198,
63,
7538,
8,
717,
1788,
12,
717,
1511,
29,
1419,
12,
717,
2351,
29,
1730,
12,
717,
9989,
63,
1637,
29,
11798,
63,
1637,
304,
490,
10685,
63,
409,
14,
525,
63,
12434,
8,
2103,
9,
288,
340,
440,
10685,
63,
409,
14,
1989,
63,
7538,
26,
355,
746,
26866,
547,
8,
490,
283,
5556,
1471,
8120,
737,
5210,
1373,
10685,
370,
2818,
354,
9,
83,
334,
3239,
283,
490,
5522,
9983,
1720,
2818,
354,
9,
83,
32292,
450,
1211,
8,
354,
29,
277,
14,
354,
9,
355,
776,
288,
10685,
63,
409,
14,
19502,
8,
2495,
63,
9548,
29,
1419,
14,
5066,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ilya-epifanov/ansible
|
lib/ansible/utils/unicode.py
|
88
|
11283
|
# (c) 2012-2014, Toshio Kuraotmi <a.badger@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from six import string_types, text_type, binary_type, PY3
# to_bytes and to_unicode were written by Toshio Kuratomi for the
# python-kitchen library https://pypi.python.org/pypi/kitchen
# They are licensed in kitchen under the terms of the GPLv2+
# They were copied and modified for use in ansible by Toshio in Jan 2015
# (simply removing the deprecated features)
#: Aliases for the utf-8 codec
_UTF8_ALIASES = frozenset(('utf-8', 'UTF-8', 'utf8', 'UTF8', 'utf_8', 'UTF_8',
'utf', 'UTF', 'u8', 'U8'))
#: Aliases for the latin-1 codec
_LATIN1_ALIASES = frozenset(('latin-1', 'LATIN-1', 'latin1', 'LATIN1',
'latin', 'LATIN', 'l1', 'L1', 'cp819', 'CP819', '8859', 'iso8859-1',
'ISO8859-1', 'iso-8859-1', 'ISO-8859-1'))
# EXCEPTION_CONVERTERS is defined below due to using to_unicode
if PY3:
basestring = (str, bytes)
def to_unicode(obj, encoding='utf-8', errors='replace', nonstring=None):
'''Convert an object into a :class:`unicode` string
:arg obj: Object to convert to a :class:`unicode` string. This should
normally be a byte :class:`str`
:kwarg encoding: What encoding to try converting the byte :class:`str` as.
Defaults to :term:`utf-8`
:kwarg errors: If errors are found while decoding, perform this action.
Defaults to ``replace`` which replaces the invalid bytes with
a character that means the bytes were unable to be decoded. Other
values are the same as the error handling schemes in the `codec base
classes
<http://docs.python.org/library/codecs.html#codec-base-classes>`_.
For instance ``strict`` which raises an exception and ``ignore`` which
simply omits the non-decodable characters.
:kwarg nonstring: How to treat nonstring values. Possible values are:
:simplerepr: Attempt to call the object's "simple representation"
method and return that value. Python-2.3+ has two methods that
try to return a simple representation: :meth:`object.__unicode__`
and :meth:`object.__str__`. We first try to get a usable value
from :meth:`object.__unicode__`. If that fails we try the same
with :meth:`object.__str__`.
:empty: Return an empty :class:`unicode` string
:strict: Raise a :exc:`TypeError`
:passthru: Return the object unchanged
:repr: Attempt to return a :class:`unicode` string of the repr of the
object
Default is ``simplerepr``
:raises TypeError: if :attr:`nonstring` is ``strict`` and
a non-:class:`basestring` object is passed in or if :attr:`nonstring`
is set to an unknown value
:raises UnicodeDecodeError: if :attr:`errors` is ``strict`` and
:attr:`obj` is not decodable using the given encoding
:returns: :class:`unicode` string or the original object depending on the
value of :attr:`nonstring`.
Usually this should be used on a byte :class:`str` but it can take both
byte :class:`str` and :class:`unicode` strings intelligently. Nonstring
objects are handled in different ways depending on the setting of the
:attr:`nonstring` parameter.
The default values of this function are set so as to always return
a :class:`unicode` string and never raise an error when converting from
a byte :class:`str` to a :class:`unicode` string. However, when you do
not pass validly encoded text (or a nonstring object), you may end up with
output that you don't expect. Be sure you understand the requirements of
your data, not just ignore errors by passing it through this function.
'''
# Could use isbasestring/isunicode here but we want this code to be as
# fast as possible
if isinstance(obj, basestring):
if isinstance(obj, text_type):
return obj
if encoding in _UTF8_ALIASES:
return text_type(obj, 'utf-8', errors)
if encoding in _LATIN1_ALIASES:
return text_type(obj, 'latin-1', errors)
return obj.decode(encoding, errors)
if not nonstring:
nonstring = 'simplerepr'
if nonstring == 'empty':
return u''
elif nonstring == 'passthru':
return obj
elif nonstring == 'simplerepr':
try:
simple = obj.__unicode__()
except (AttributeError, UnicodeError):
simple = None
if not simple:
try:
simple = text_type(obj)
except UnicodeError:
try:
simple = obj.__str__()
except (UnicodeError, AttributeError):
simple = u''
if isinstance(simple, binary_type):
return text_type(simple, encoding, errors)
return simple
elif nonstring in ('repr', 'strict'):
obj_repr = repr(obj)
if isinstance(obj_repr, binary_type):
obj_repr = text_type(obj_repr, encoding, errors)
if nonstring == 'repr':
return obj_repr
raise TypeError('to_unicode was given "%(obj)s" which is neither'
' a byte string (str) or a unicode string' %
{'obj': obj_repr.encode(encoding, 'replace')})
raise TypeError('nonstring value, %(param)s, is not set to a valid'
' action' % {'param': nonstring})
def to_bytes(obj, encoding='utf-8', errors='replace', nonstring=None):
'''Convert an object into a byte :class:`str`
:arg obj: Object to convert to a byte :class:`str`. This should normally
be a :class:`unicode` string.
:kwarg encoding: Encoding to use to convert the :class:`unicode` string
into a byte :class:`str`. Defaults to :term:`utf-8`.
:kwarg errors: If errors are found while encoding, perform this action.
Defaults to ``replace`` which replaces the invalid bytes with
a character that means the bytes were unable to be encoded. Other
values are the same as the error handling schemes in the `codec base
classes
<http://docs.python.org/library/codecs.html#codec-base-classes>`_.
For instance ``strict`` which raises an exception and ``ignore`` which
simply omits the non-encodable characters.
:kwarg nonstring: How to treat nonstring values. Possible values are:
:simplerepr: Attempt to call the object's "simple representation"
method and return that value. Python-2.3+ has two methods that
try to return a simple representation: :meth:`object.__unicode__`
and :meth:`object.__str__`. We first try to get a usable value
from :meth:`object.__str__`. If that fails we try the same
with :meth:`object.__unicode__`.
:empty: Return an empty byte :class:`str`
:strict: Raise a :exc:`TypeError`
:passthru: Return the object unchanged
:repr: Attempt to return a byte :class:`str` of the :func:`repr` of the
object
Default is ``simplerepr``.
:raises TypeError: if :attr:`nonstring` is ``strict`` and
a non-:class:`basestring` object is passed in or if :attr:`nonstring`
is set to an unknown value.
:raises UnicodeEncodeError: if :attr:`errors` is ``strict`` and all of the
bytes of :attr:`obj` are unable to be encoded using :attr:`encoding`.
:returns: byte :class:`str` or the original object depending on the value
of :attr:`nonstring`.
.. warning::
If you pass a byte :class:`str` into this function the byte
:class:`str` is returned unmodified. It is **not** re-encoded with
the specified :attr:`encoding`. The easiest way to achieve that is::
to_bytes(to_unicode(text), encoding='utf-8')
The initial :func:`to_unicode` call will ensure text is
a :class:`unicode` string. Then, :func:`to_bytes` will turn that into
a byte :class:`str` with the specified encoding.
Usually, this should be used on a :class:`unicode` string but it can take
either a byte :class:`str` or a :class:`unicode` string intelligently.
Nonstring objects are handled in different ways depending on the setting
of the :attr:`nonstring` parameter.
The default values of this function are set so as to always return a byte
:class:`str` and never raise an error when converting from unicode to
bytes. However, when you do not pass an encoding that can validly encode
the object (or a non-string object), you may end up with output that you
don't expect. Be sure you understand the requirements of your data, not
just ignore errors by passing it through this function.
'''
# Could use isbasestring, isbytestring here but we want this to be as fast
# as possible
if isinstance(obj, basestring):
if isinstance(obj, binary_type):
return obj
return obj.encode(encoding, errors)
if not nonstring:
nonstring = 'simplerepr'
if nonstring == 'empty':
return b''
elif nonstring == 'passthru':
return obj
elif nonstring == 'simplerepr':
try:
simple = binary_type(obj)
except UnicodeError:
try:
simple = obj.__str__()
except (AttributeError, UnicodeError):
simple = None
if not simple:
try:
simple = obj.__unicode__()
except (AttributeError, UnicodeError):
simple = b''
if isinstance(simple, text_type):
simple = simple.encode(encoding, 'replace')
return simple
elif nonstring in ('repr', 'strict'):
try:
obj_repr = obj.__repr__()
except (AttributeError, UnicodeError):
obj_repr = b''
if isinstance(obj_repr, text_type):
obj_repr = obj_repr.encode(encoding, errors)
else:
obj_repr = binary_type(obj_repr)
if nonstring == 'repr':
return obj_repr
raise TypeError('to_bytes was given "%(obj)s" which is neither'
' a unicode string or a byte string (str)' % {'obj': obj_repr})
raise TypeError('nonstring value, %(param)s, is not set to a valid'
' action' % {'param': nonstring})
# force the return value of a function to be unicode. Use with partial to
# ensure that a filter will return unicode values.
def unicode_wrap(func, *args, **kwargs):
return to_unicode(func(*args, **kwargs), nonstring='passthru')
|
gpl-3.0
|
[
3,
334,
67,
9,
6029,
13,
7280,
12,
4005,
609,
2308,
1804,
12417,
357,
2664,
665,
65,
14,
4087,
836,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3816,
492,
1059,
63,
1313,
12,
1318,
63,
466,
12,
3366,
63,
466,
12,
7843,
19,
199,
199,
3,
370,
63,
2394,
436,
370,
63,
2975,
4898,
5313,
701,
4005,
609,
2308,
1804,
300,
4188,
73,
367,
314,
199,
3,
2366,
13,
6065,
24604,
3555,
4178,
921,
17343,
14,
1548,
14,
1308,
15,
17343,
15,
6065,
24604,
199,
3,
9322,
787,
18233,
315,
1022,
9414,
287,
1334,
314,
2895,
402,
314,
14629,
86,
18,
11,
199,
3,
9322,
4898,
8876,
436,
6042,
367,
675,
315,
3242,
701,
4005,
609,
2308,
315,
17474,
6900,
199,
3,
334,
11184,
590,
12881,
314,
5906,
4534,
9,
199,
199,
12573,
15170,
3274,
367,
314,
2774,
13,
24,
9076,
199,
63,
6610,
24,
63,
12644,
654,
275,
9522,
4725,
1624,
13,
24,
297,
283,
6610,
13,
24,
297,
283,
1624,
24,
297,
283,
6610,
24,
297,
283,
1624,
63,
24,
297,
283,
6610,
63,
24,
297,
272,
283,
1624,
297,
283,
6610,
297,
283,
85,
24,
297,
283,
53,
24,
1333,
199,
12573,
15170,
3274,
367,
314,
16899,
13,
17,
9076,
199,
63,
44,
1934,
17,
63,
12644,
654,
275,
9522,
4725,
10378,
13,
17,
297,
283,
44,
1934,
13,
17,
297,
283,
10378,
17,
297,
283,
44,
1934,
17,
297,
272,
283,
10378,
297,
283,
44,
1934,
297,
283,
76,
17,
297,
283,
44,
17,
297,
283,
1850,
27763,
297,
283,
2890,
27763,
297,
283,
4830,
297,
283,
4595,
4830,
13,
17,
297,
272,
283,
7336,
4830,
13,
17,
297,
283,
4595,
13,
4830,
13,
17,
297,
283,
7336,
13,
4830,
13,
17,
1333,
199,
199,
3,
3651,
7177,
1075,
63,
1864,
2111,
1157,
51,
365,
3247,
5084,
7037,
370,
1808,
370,
63,
2975,
199,
199,
692,
7843,
19,
26,
272,
7116,
275,
334,
495,
12,
2783,
9,
199,
199,
318,
370,
63,
2975,
8,
1113,
12,
2644,
534,
1624,
13,
24,
297,
2552,
534,
1814,
297,
2222,
875,
29,
403,
304,
272,
1449,
7306,
376,
909,
1901,
282,
520,
533,
1705,
2975,
64,
1059,
339,
520,
1273,
1559,
26,
6935,
370,
3957,
370,
282,
520,
533,
1705,
2975,
64,
1059,
14,
221,
961,
1077,
267,
12252,
506,
282,
3696,
520,
533,
1705,
495,
64,
272,
520,
12745,
2644,
26,
14791,
2644,
370,
862,
13806,
314,
3696,
520,
533,
1705,
495,
64,
465,
14,
267,
7827,
370,
520,
5125,
1705,
1624,
13,
24,
64,
272,
520,
12745,
2552,
26,
982,
2552,
787,
1911,
1830,
15952,
12,
5147,
642,
1595,
14,
267,
7827,
370,
1124,
1814,
1040,
1314,
19058,
314,
3866,
2783,
543,
267,
282,
4528,
626,
4910,
314,
2783,
4898,
17329,
370,
506,
11203,
14,
221,
5439,
267,
1338,
787,
314,
2011,
465,
314,
1125,
7252,
21149,
315,
314,
658,
9276,
1300,
267,
3992,
267,
665,
1014,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
8933,
14,
1360,
3,
9276,
13,
1095,
13,
2888,
8637,
3754,
267,
2104,
1256,
1124,
4768,
1040,
1314,
6534,
376,
1919,
436,
1124,
4247,
1040,
1314,
267,
9329,
19413,
83,
314,
2222,
13,
271,
7889,
461,
4110,
14,
272,
520,
12745,
2222,
875,
26,
7494,
370,
14312,
2222,
875,
1338,
14,
221,
18558,
1338,
787,
26,
398,
520,
4129,
2722,
26,
23115,
370,
1240,
314,
909,
1159,
298,
4129,
6025,
2,
288,
1083,
436,
372,
626,
574,
14,
221,
2018,
13,
18,
14,
19,
11,
965,
2877,
3102,
626,
288,
862,
370,
372,
282,
3486,
6025,
26,
520,
5247,
1705,
785,
855,
2975,
29341,
288,
436,
520,
5247,
1705,
785,
855,
495,
363,
2313,
221,
2136,
1642,
862,
370,
664,
282,
18025,
574,
288,
687,
520,
5247,
1705,
785,
855,
2975,
363,
2313,
221,
982,
626,
6918,
781,
862,
314,
2011,
288,
543,
520,
5247,
1705,
785,
855,
495,
363,
2313,
267,
520,
1667,
26,
1432,
376,
2701,
520,
533,
1705,
2975,
64,
1059,
267,
520,
4768,
26,
14771,
282,
520,
2804,
1705,
4333,
64,
267,
520,
15534,
270,
6271,
85,
26,
1432,
314,
909,
14874,
267,
520,
2722,
26,
23115,
370,
372,
282,
520,
533,
1705,
2975,
64,
1059,
402,
314,
4700,
402,
314,
288,
909,
398,
3758,
365,
1124,
4129,
2722,
1040,
339,
520,
3536,
3146,
26,
340,
520,
962,
1705,
2865,
875,
64,
365,
1124,
4768,
1040,
436,
267,
282,
2222,
13,
26,
533,
1705,
17628,
64,
909,
365,
3032,
315,
503,
340,
520,
962,
1705,
2865,
875,
64,
267,
365,
663,
370,
376,
5809,
574,
272,
520,
3536,
18965,
26,
340,
520,
962,
1705,
2550,
64,
365,
1124,
4768,
1040,
436,
267,
520,
962,
1705,
1113,
64,
365,
440,
477,
7889,
461,
1808,
314,
1627,
2644,
272,
520,
5808,
26,
520,
533,
1705,
2975,
64,
1059,
503,
314,
3379,
909,
10298,
641,
314,
267,
574,
402,
520,
962,
1705,
2865,
875,
2313,
339,
24612,
642,
1077,
506,
1202,
641,
282,
3696,
520,
533,
1705,
495,
64,
1325,
652,
883,
5452,
3865,
272,
3696,
520,
533,
1705,
495,
64,
436
] |
[
334,
67,
9,
6029,
13,
7280,
12,
4005,
609,
2308,
1804,
12417,
357,
2664,
665,
65,
14,
4087,
836,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3816,
492,
1059,
63,
1313,
12,
1318,
63,
466,
12,
3366,
63,
466,
12,
7843,
19,
199,
199,
3,
370,
63,
2394,
436,
370,
63,
2975,
4898,
5313,
701,
4005,
609,
2308,
1804,
300,
4188,
73,
367,
314,
199,
3,
2366,
13,
6065,
24604,
3555,
4178,
921,
17343,
14,
1548,
14,
1308,
15,
17343,
15,
6065,
24604,
199,
3,
9322,
787,
18233,
315,
1022,
9414,
287,
1334,
314,
2895,
402,
314,
14629,
86,
18,
11,
199,
3,
9322,
4898,
8876,
436,
6042,
367,
675,
315,
3242,
701,
4005,
609,
2308,
315,
17474,
6900,
199,
3,
334,
11184,
590,
12881,
314,
5906,
4534,
9,
199,
199,
12573,
15170,
3274,
367,
314,
2774,
13,
24,
9076,
199,
63,
6610,
24,
63,
12644,
654,
275,
9522,
4725,
1624,
13,
24,
297,
283,
6610,
13,
24,
297,
283,
1624,
24,
297,
283,
6610,
24,
297,
283,
1624,
63,
24,
297,
283,
6610,
63,
24,
297,
272,
283,
1624,
297,
283,
6610,
297,
283,
85,
24,
297,
283,
53,
24,
1333,
199,
12573,
15170,
3274,
367,
314,
16899,
13,
17,
9076,
199,
63,
44,
1934,
17,
63,
12644,
654,
275,
9522,
4725,
10378,
13,
17,
297,
283,
44,
1934,
13,
17,
297,
283,
10378,
17,
297,
283,
44,
1934,
17,
297,
272,
283,
10378,
297,
283,
44,
1934,
297,
283,
76,
17,
297,
283,
44,
17,
297,
283,
1850,
27763,
297,
283,
2890,
27763,
297,
283,
4830,
297,
283,
4595,
4830,
13,
17,
297,
272,
283,
7336,
4830,
13,
17,
297,
283,
4595,
13,
4830,
13,
17,
297,
283,
7336,
13,
4830,
13,
17,
1333,
199,
199,
3,
3651,
7177,
1075,
63,
1864,
2111,
1157,
51,
365,
3247,
5084,
7037,
370,
1808,
370,
63,
2975,
199,
199,
692,
7843,
19,
26,
272,
7116,
275,
334,
495,
12,
2783,
9,
199,
199,
318,
370,
63,
2975,
8,
1113,
12,
2644,
534,
1624,
13,
24,
297,
2552,
534,
1814,
297,
2222,
875,
29,
403,
304,
272,
1449,
7306,
376,
909,
1901,
282,
520,
533,
1705,
2975,
64,
1059,
339,
520,
1273,
1559,
26,
6935,
370,
3957,
370,
282,
520,
533,
1705,
2975,
64,
1059,
14,
221,
961,
1077,
267,
12252,
506,
282,
3696,
520,
533,
1705,
495,
64,
272,
520,
12745,
2644,
26,
14791,
2644,
370,
862,
13806,
314,
3696,
520,
533,
1705,
495,
64,
465,
14,
267,
7827,
370,
520,
5125,
1705,
1624,
13,
24,
64,
272,
520,
12745,
2552,
26,
982,
2552,
787,
1911,
1830,
15952,
12,
5147,
642,
1595,
14,
267,
7827,
370,
1124,
1814,
1040,
1314,
19058,
314,
3866,
2783,
543,
267,
282,
4528,
626,
4910,
314,
2783,
4898,
17329,
370,
506,
11203,
14,
221,
5439,
267,
1338,
787,
314,
2011,
465,
314,
1125,
7252,
21149,
315,
314,
658,
9276,
1300,
267,
3992,
267,
665,
1014,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
8933,
14,
1360,
3,
9276,
13,
1095,
13,
2888,
8637,
3754,
267,
2104,
1256,
1124,
4768,
1040,
1314,
6534,
376,
1919,
436,
1124,
4247,
1040,
1314,
267,
9329,
19413,
83,
314,
2222,
13,
271,
7889,
461,
4110,
14,
272,
520,
12745,
2222,
875,
26,
7494,
370,
14312,
2222,
875,
1338,
14,
221,
18558,
1338,
787,
26,
398,
520,
4129,
2722,
26,
23115,
370,
1240,
314,
909,
1159,
298,
4129,
6025,
2,
288,
1083,
436,
372,
626,
574,
14,
221,
2018,
13,
18,
14,
19,
11,
965,
2877,
3102,
626,
288,
862,
370,
372,
282,
3486,
6025,
26,
520,
5247,
1705,
785,
855,
2975,
29341,
288,
436,
520,
5247,
1705,
785,
855,
495,
363,
2313,
221,
2136,
1642,
862,
370,
664,
282,
18025,
574,
288,
687,
520,
5247,
1705,
785,
855,
2975,
363,
2313,
221,
982,
626,
6918,
781,
862,
314,
2011,
288,
543,
520,
5247,
1705,
785,
855,
495,
363,
2313,
267,
520,
1667,
26,
1432,
376,
2701,
520,
533,
1705,
2975,
64,
1059,
267,
520,
4768,
26,
14771,
282,
520,
2804,
1705,
4333,
64,
267,
520,
15534,
270,
6271,
85,
26,
1432,
314,
909,
14874,
267,
520,
2722,
26,
23115,
370,
372,
282,
520,
533,
1705,
2975,
64,
1059,
402,
314,
4700,
402,
314,
288,
909,
398,
3758,
365,
1124,
4129,
2722,
1040,
339,
520,
3536,
3146,
26,
340,
520,
962,
1705,
2865,
875,
64,
365,
1124,
4768,
1040,
436,
267,
282,
2222,
13,
26,
533,
1705,
17628,
64,
909,
365,
3032,
315,
503,
340,
520,
962,
1705,
2865,
875,
64,
267,
365,
663,
370,
376,
5809,
574,
272,
520,
3536,
18965,
26,
340,
520,
962,
1705,
2550,
64,
365,
1124,
4768,
1040,
436,
267,
520,
962,
1705,
1113,
64,
365,
440,
477,
7889,
461,
1808,
314,
1627,
2644,
272,
520,
5808,
26,
520,
533,
1705,
2975,
64,
1059,
503,
314,
3379,
909,
10298,
641,
314,
267,
574,
402,
520,
962,
1705,
2865,
875,
2313,
339,
24612,
642,
1077,
506,
1202,
641,
282,
3696,
520,
533,
1705,
495,
64,
1325,
652,
883,
5452,
3865,
272,
3696,
520,
533,
1705,
495,
64,
436,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
StamusNetworks/scirius
|
rules/migrations/0031_auto_20150103_1138.py
|
1
|
1083
|
# -*- coding: utf-8 -*-
from django.db import models, migrations
import datetime
class Migration(migrations.Migration):
dependencies = [
('rules', '0030_auto_20150103_1136'),
]
operations = [
migrations.AlterField(
model_name='category',
name='created_date',
field=models.DateTimeField(default=datetime.datetime(2015, 1, 3, 11, 38, 58, 613578), verbose_name=b'date created'),
preserve_default=True,
),
migrations.AlterField(
model_name='sourceatversion',
name='updated_date',
field=models.DateTimeField(default=datetime.datetime(2015, 1, 3, 11, 38, 58, 612794), verbose_name=b'date updated', blank=True),
preserve_default=True,
),
migrations.AlterField(
model_name='sourceupdate',
name='created_date',
field=models.DateTimeField(default=datetime.datetime(2015, 1, 3, 11, 38, 58, 613165), verbose_name=b'date of update', blank=True),
preserve_default=True,
),
]
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
421,
199,
504,
1639,
14,
697,
492,
1709,
12,
6180,
199,
646,
2197,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
5124,
275,
359,
267,
661,
4423,
297,
283,
24281,
63,
2495,
63,
7806,
28399,
63,
845,
1344,
659,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
19275,
8,
288,
1402,
63,
354,
534,
3710,
297,
288,
536,
534,
3966,
63,
602,
297,
288,
901,
29,
992,
14,
4626,
8,
885,
29,
2083,
14,
2083,
8,
7806,
12,
413,
12,
650,
12,
4119,
12,
10448,
12,
13713,
12,
1227,
969,
14992,
395,
3376,
63,
354,
29,
66,
5121,
323,
2737,
659,
288,
11211,
63,
885,
29,
549,
12,
267,
2318,
267,
6180,
14,
19275,
8,
288,
1402,
63,
354,
534,
1365,
292,
1023,
297,
288,
536,
534,
5334,
63,
602,
297,
288,
901,
29,
992,
14,
4626,
8,
885,
29,
2083,
14,
2083,
8,
7806,
12,
413,
12,
650,
12,
4119,
12,
10448,
12,
13713,
12,
1227,
713,
21618,
395,
3376,
63,
354,
29,
66,
5121,
323,
4588,
297,
4596,
29,
549,
395,
288,
11211,
63,
885,
29,
549,
12,
267,
2318,
267,
6180,
14,
19275,
8,
288,
1402,
63,
354,
534,
1365,
873,
297,
288,
536,
534,
3966,
63,
602,
297,
288,
901,
29,
992,
14,
4626,
8,
885,
29,
2083,
14,
2083,
8,
7806,
12,
413,
12,
650,
12,
4119,
12,
10448,
12,
13713,
12,
1227,
969,
10355,
395,
3376,
63,
354,
29,
66,
5121,
323,
402,
1678,
297,
4596,
29,
549,
395,
288,
11211,
63,
885,
29,
549,
12,
267,
2318,
272,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
421,
199,
504,
1639,
14,
697,
492,
1709,
12,
6180,
199,
646,
2197,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
5124,
275,
359,
267,
661,
4423,
297,
283,
24281,
63,
2495,
63,
7806,
28399,
63,
845,
1344,
659,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
19275,
8,
288,
1402,
63,
354,
534,
3710,
297,
288,
536,
534,
3966,
63,
602,
297,
288,
901,
29,
992,
14,
4626,
8,
885,
29,
2083,
14,
2083,
8,
7806,
12,
413,
12,
650,
12,
4119,
12,
10448,
12,
13713,
12,
1227,
969,
14992,
395,
3376,
63,
354,
29,
66,
5121,
323,
2737,
659,
288,
11211,
63,
885,
29,
549,
12,
267,
2318,
267,
6180,
14,
19275,
8,
288,
1402,
63,
354,
534,
1365,
292,
1023,
297,
288,
536,
534,
5334,
63,
602,
297,
288,
901,
29,
992,
14,
4626,
8,
885,
29,
2083,
14,
2083,
8,
7806,
12,
413,
12,
650,
12,
4119,
12,
10448,
12,
13713,
12,
1227,
713,
21618,
395,
3376,
63,
354,
29,
66,
5121,
323,
4588,
297,
4596,
29,
549,
395,
288,
11211,
63,
885,
29,
549,
12,
267,
2318,
267,
6180,
14,
19275,
8,
288,
1402,
63,
354,
534,
1365,
873,
297,
288,
536,
534,
3966,
63,
602,
297,
288,
901,
29,
992,
14,
4626,
8,
885,
29,
2083,
14,
2083,
8,
7806,
12,
413,
12,
650,
12,
4119,
12,
10448,
12,
13713,
12,
1227,
969,
10355,
395,
3376,
63,
354,
29,
66,
5121,
323,
402,
1678,
297,
4596,
29,
549,
395,
288,
11211,
63,
885,
29,
549,
12,
267,
2318,
272,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
peterlauri/django
|
tests/inspectdb/models.py
|
21
|
3075
|
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
class People(models.Model):
name = models.CharField(max_length=255)
parent = models.ForeignKey('self', models.CASCADE)
class Message(models.Model):
from_field = models.ForeignKey(People, models.CASCADE, db_column='from_id')
class PeopleData(models.Model):
people_pk = models.ForeignKey(People, models.CASCADE, primary_key=True)
ssn = models.CharField(max_length=11)
class PeopleMoreData(models.Model):
people_unique = models.ForeignKey(People, models.CASCADE, unique=True)
license = models.CharField(max_length=255)
class DigitsInColumnName(models.Model):
all_digits = models.CharField(max_length=11, db_column='123')
leading_digit = models.CharField(max_length=11, db_column='4extra')
leading_digits = models.CharField(max_length=11, db_column='45extra')
class SpecialName(models.Model):
field = models.IntegerField(db_column='field')
# Underscores
field_field_0 = models.IntegerField(db_column='Field_')
field_field_1 = models.IntegerField(db_column='Field__')
field_field_2 = models.IntegerField(db_column='__field')
# Other chars
prc_x = models.IntegerField(db_column='prc(%) x')
non_ascii = models.IntegerField(db_column='tamaño')
class Meta:
db_table = "inspectdb_special.table name"
class ColumnTypes(models.Model):
id = models.AutoField(primary_key=True)
big_int_field = models.BigIntegerField()
bool_field = models.BooleanField(default=False)
null_bool_field = models.NullBooleanField()
char_field = models.CharField(max_length=10)
null_char_field = models.CharField(max_length=10, blank=True, null=True)
comma_separated_int_field = models.CommaSeparatedIntegerField(max_length=99)
date_field = models.DateField()
date_time_field = models.DateTimeField()
decimal_field = models.DecimalField(max_digits=6, decimal_places=1)
email_field = models.EmailField()
file_field = models.FileField(upload_to="unused")
file_path_field = models.FilePathField()
float_field = models.FloatField()
int_field = models.IntegerField()
gen_ip_adress_field = models.GenericIPAddressField(protocol="ipv4")
pos_int_field = models.PositiveIntegerField()
pos_small_int_field = models.PositiveSmallIntegerField()
slug_field = models.SlugField()
small_int_field = models.SmallIntegerField()
text_field = models.TextField()
time_field = models.TimeField()
url_field = models.URLField()
uuid_field = models.UUIDField()
class UniqueTogether(models.Model):
field1 = models.IntegerField()
field2 = models.CharField(max_length=10)
from_field = models.IntegerField(db_column='from')
non_unique = models.IntegerField(db_column='non__unique_column')
non_unique_0 = models.IntegerField(db_column='non_unique__column')
class Meta:
unique_together = [
('field1', 'field2'),
('from_field', 'field1'),
('non_unique', 'non_unique_0'),
]
|
bsd-3-clause
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
697,
492,
1709,
421,
199,
533,
11379,
7939,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
9,
272,
1676,
275,
1709,
14,
3190,
360,
277,
297,
1709,
14,
10855,
9,
421,
199,
533,
6430,
8,
992,
14,
1685,
304,
272,
687,
63,
698,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
1709,
14,
10855,
12,
1592,
63,
2301,
534,
504,
63,
344,
358,
421,
199,
533,
11379,
7939,
1451,
8,
992,
14,
1685,
304,
272,
13135,
63,
2051,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
1709,
14,
10855,
12,
5062,
63,
498,
29,
549,
9,
272,
308,
5167,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
9,
421,
199,
533,
11379,
7939,
11053,
1451,
8,
992,
14,
1685,
304,
272,
13135,
63,
3235,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
1709,
14,
10855,
12,
3747,
29,
549,
9,
272,
4190,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
9,
421,
199,
533,
22442,
1405,
607,
4547,
985,
8,
992,
14,
1685,
304,
272,
1006,
63,
7022,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
4288,
358,
272,
9186,
63,
8573,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
20,
2911,
358,
272,
9186,
63,
7022,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
2322,
2911,
358,
421,
199,
533,
12568,
985,
8,
992,
14,
1685,
304,
272,
901,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
698,
358,
272,
327,
25010,
7107,
272,
901,
63,
698,
63,
16,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
792,
15452,
272,
901,
63,
698,
63,
17,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
792,
13766,
272,
901,
63,
698,
63,
18,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
363,
698,
358,
272,
327,
5439,
8365,
272,
299,
1195,
63,
88,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
80,
1195,
4042,
9,
671,
358,
272,
2222,
63,
4371,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
502,
391,
22692,
79,
358,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
298,
10955,
697,
63,
6664,
14,
1224,
536,
2,
421,
199,
533,
4996,
4100,
8,
992,
14,
1685,
304,
272,
1305,
275,
1709,
14,
4378,
8,
3327,
63,
498,
29,
549,
9,
272,
7282,
63,
442,
63,
698,
275,
1709,
14,
25175,
342,
272,
2155,
63,
698,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
2973,
63,
2245,
63,
698,
275,
1709,
14,
29068,
342,
272,
1495,
63,
698,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
272,
2973,
63,
1560,
63,
698,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
12,
4596,
29,
549,
12,
2973,
29,
549,
9,
272,
10029,
63,
12794,
63,
442,
63,
698,
275,
1709,
14,
25732,
20727,
3901,
8,
988,
63,
1267,
29,
1020,
9,
272,
1434,
63,
698,
275,
1709,
14,
14071,
342,
272,
1434,
63,
521,
63,
698,
275,
1709,
14,
4626,
342,
272,
6107,
63,
698,
275,
1709,
14,
15975,
8,
988,
63,
7022,
29,
22,
12,
6107,
63,
10696,
29,
17,
9,
272,
3031,
63,
698,
275,
1709,
14,
16577,
342,
272,
570,
63,
698,
275,
1709,
14,
23252,
8,
5064,
63,
475,
628,
8618,
531,
272,
570,
63,
515,
63,
698,
275,
1709,
14,
14225,
792,
342,
272,
2069,
63,
698,
275,
1709,
14,
13019,
342,
272,
1109,
63,
698,
275,
1709,
14,
3901,
342,
272,
3805,
63,
711,
63,
350,
753,
63,
698,
275,
1709,
14,
9417,
26969,
8,
3922,
628,
4774,
20,
531,
272,
2086,
63,
442,
63,
698,
275,
1709,
14,
8591,
342,
272,
2086,
63,
7241,
63,
442,
63,
698,
275,
1709,
14,
25197,
342,
272,
8889,
63,
698,
275,
1709,
14,
17315,
342,
272,
7425,
63,
442,
63,
698,
275,
1709,
14,
14640,
342,
272,
1318,
63,
698,
275,
1709,
14,
6254,
342,
272,
900,
63,
698,
275,
1709,
14,
27115,
342,
272,
1166,
63,
698,
275,
1709,
14,
17363,
342,
272,
5377,
63,
698,
275,
1709,
14,
8757,
792,
342,
421,
199,
533,
18276,
1378,
4920,
8,
992,
14,
1685,
304,
272,
901,
17,
275,
1709,
14,
3901,
342,
272,
901,
18,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
272,
687,
63,
698,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
504,
358,
272,
2222,
63,
3235,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
2865,
363,
3235,
63,
2301,
358,
272,
2222,
63,
3235,
63,
16,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
2865,
63,
3235,
363,
2301,
358,
339,
1021,
6288,
26,
267,
3747,
63,
6314,
275,
359,
288,
661,
698,
17,
297,
283,
698,
18,
659,
288,
661,
504,
63,
698,
297,
283,
698,
17,
659,
288,
661,
2865,
63,
3235,
297,
283,
2865,
63,
3235,
63,
16,
659,
267,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
697,
492,
1709,
421,
199,
533,
11379,
7939,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
9,
272,
1676,
275,
1709,
14,
3190,
360,
277,
297,
1709,
14,
10855,
9,
421,
199,
533,
6430,
8,
992,
14,
1685,
304,
272,
687,
63,
698,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
1709,
14,
10855,
12,
1592,
63,
2301,
534,
504,
63,
344,
358,
421,
199,
533,
11379,
7939,
1451,
8,
992,
14,
1685,
304,
272,
13135,
63,
2051,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
1709,
14,
10855,
12,
5062,
63,
498,
29,
549,
9,
272,
308,
5167,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
9,
421,
199,
533,
11379,
7939,
11053,
1451,
8,
992,
14,
1685,
304,
272,
13135,
63,
3235,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
1709,
14,
10855,
12,
3747,
29,
549,
9,
272,
4190,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
9,
421,
199,
533,
22442,
1405,
607,
4547,
985,
8,
992,
14,
1685,
304,
272,
1006,
63,
7022,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
4288,
358,
272,
9186,
63,
8573,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
20,
2911,
358,
272,
9186,
63,
7022,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
2322,
2911,
358,
421,
199,
533,
12568,
985,
8,
992,
14,
1685,
304,
272,
901,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
698,
358,
272,
327,
25010,
7107,
272,
901,
63,
698,
63,
16,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
792,
15452,
272,
901,
63,
698,
63,
17,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
792,
13766,
272,
901,
63,
698,
63,
18,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
363,
698,
358,
272,
327,
5439,
8365,
272,
299,
1195,
63,
88,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
80,
1195,
4042,
9,
671,
358,
272,
2222,
63,
4371,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
502,
391,
22692,
79,
358,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
298,
10955,
697,
63,
6664,
14,
1224,
536,
2,
421,
199,
533,
4996,
4100,
8,
992,
14,
1685,
304,
272,
1305,
275,
1709,
14,
4378,
8,
3327,
63,
498,
29,
549,
9,
272,
7282,
63,
442,
63,
698,
275,
1709,
14,
25175,
342,
272,
2155,
63,
698,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
2973,
63,
2245,
63,
698,
275,
1709,
14,
29068,
342,
272,
1495,
63,
698,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
272,
2973,
63,
1560,
63,
698,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
12,
4596,
29,
549,
12,
2973,
29,
549,
9,
272,
10029,
63,
12794,
63,
442,
63,
698,
275,
1709,
14,
25732,
20727,
3901,
8,
988,
63,
1267,
29,
1020,
9,
272,
1434,
63,
698,
275,
1709,
14,
14071,
342,
272,
1434,
63,
521,
63,
698,
275,
1709,
14,
4626,
342,
272,
6107,
63,
698,
275,
1709,
14,
15975,
8,
988,
63,
7022,
29,
22,
12,
6107,
63,
10696,
29,
17,
9,
272,
3031,
63,
698,
275,
1709,
14,
16577,
342,
272,
570,
63,
698,
275,
1709,
14,
23252,
8,
5064,
63,
475,
628,
8618,
531,
272,
570,
63,
515,
63,
698,
275,
1709,
14,
14225,
792,
342,
272,
2069,
63,
698,
275,
1709,
14,
13019,
342,
272,
1109,
63,
698,
275,
1709,
14,
3901,
342,
272,
3805,
63,
711,
63,
350,
753,
63,
698,
275,
1709,
14,
9417,
26969,
8,
3922,
628,
4774,
20,
531,
272,
2086,
63,
442,
63,
698,
275,
1709,
14,
8591,
342,
272,
2086,
63,
7241,
63,
442,
63,
698,
275,
1709,
14,
25197,
342,
272,
8889,
63,
698,
275,
1709,
14,
17315,
342,
272,
7425,
63,
442,
63,
698,
275,
1709,
14,
14640,
342,
272,
1318,
63,
698,
275,
1709,
14,
6254,
342,
272,
900,
63,
698,
275,
1709,
14,
27115,
342,
272,
1166,
63,
698,
275,
1709,
14,
17363,
342,
272,
5377,
63,
698,
275,
1709,
14,
8757,
792,
342,
421,
199,
533,
18276,
1378,
4920,
8,
992,
14,
1685,
304,
272,
901,
17,
275,
1709,
14,
3901,
342,
272,
901,
18,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
272,
687,
63,
698,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
504,
358,
272,
2222,
63,
3235,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
2865,
363,
3235,
63,
2301,
358,
272,
2222,
63,
3235,
63,
16,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
2865,
63,
3235,
363,
2301,
358,
339,
1021,
6288,
26,
267,
3747,
63,
6314,
275,
359,
288,
661,
698,
17,
297,
283,
698,
18,
659,
288,
661,
504,
63,
698,
297,
283,
698,
17,
659,
288,
661,
2865,
63,
3235,
297,
283,
2865,
63,
3235,
63,
16,
659,
267,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
gfyoung/scipy
|
scipy/sparse/data.py
|
7
|
12708
|
"""Base class for sparse matrice with a .data attribute
subclasses must provide a _with_data() method that
creates a new matrix with the same sparsity pattern
as self but with a different data array
"""
from __future__ import division, print_function, absolute_import
import numpy as np
from .base import spmatrix, _ufuncs_with_fixed_point_at_zero
from .sputils import isscalarlike, validateaxis
__all__ = []
# TODO implement all relevant operations
# use .data.__methods__() instead of /=, *=, etc.
class _data_matrix(spmatrix):
def __init__(self):
spmatrix.__init__(self)
def _get_dtype(self):
return self.data.dtype
def _set_dtype(self, newtype):
self.data.dtype = newtype
dtype = property(fget=_get_dtype, fset=_set_dtype)
def _deduped_data(self):
if hasattr(self, 'sum_duplicates'):
self.sum_duplicates()
return self.data
def __abs__(self):
return self._with_data(abs(self._deduped_data()))
def _real(self):
return self._with_data(self.data.real)
def _imag(self):
return self._with_data(self.data.imag)
def __neg__(self):
if self.dtype.kind == 'b':
raise NotImplementedError('negating a sparse boolean '
'matrix is not supported')
return self._with_data(-self.data)
def __imul__(self, other): # self *= other
if isscalarlike(other):
self.data *= other
return self
else:
return NotImplemented
def __itruediv__(self, other): # self /= other
if isscalarlike(other):
recip = 1.0 / other
self.data *= recip
return self
else:
return NotImplemented
def astype(self, dtype, casting='unsafe', copy=True):
dtype = np.dtype(dtype)
if self.dtype != dtype:
return self._with_data(
self._deduped_data().astype(dtype, casting=casting, copy=copy),
copy=copy)
elif copy:
return self.copy()
else:
return self
astype.__doc__ = spmatrix.astype.__doc__
def conj(self, copy=True):
if np.issubdtype(self.dtype, np.complexfloating):
return self._with_data(self.data.conj(), copy=copy)
elif copy:
return self.copy()
else:
return self
conj.__doc__ = spmatrix.conj.__doc__
def copy(self):
return self._with_data(self.data.copy(), copy=True)
copy.__doc__ = spmatrix.copy.__doc__
def count_nonzero(self):
return np.count_nonzero(self._deduped_data())
count_nonzero.__doc__ = spmatrix.count_nonzero.__doc__
def power(self, n, dtype=None):
"""
This function performs element-wise power.
Parameters
----------
n : n is a scalar
dtype : If dtype is not specified, the current dtype will be preserved.
"""
if not isscalarlike(n):
raise NotImplementedError("input is not scalar")
data = self._deduped_data()
if dtype is not None:
data = data.astype(dtype)
return self._with_data(data ** n)
###########################
# Multiplication handlers #
###########################
def _mul_scalar(self, other):
return self._with_data(self.data * other)
# Add the numpy unary ufuncs for which func(0) = 0 to _data_matrix.
for npfunc in _ufuncs_with_fixed_point_at_zero:
name = npfunc.__name__
def _create_method(op):
def method(self):
result = op(self._deduped_data())
return self._with_data(result, copy=True)
method.__doc__ = ("Element-wise %s.\n\n"
"See numpy.%s for more information." % (name, name))
method.__name__ = name
return method
setattr(_data_matrix, name, _create_method(npfunc))
def _find_missing_index(ind, n):
for k, a in enumerate(ind):
if k != a:
return k
k += 1
if k < n:
return k
else:
return -1
class _minmax_mixin(object):
"""Mixin for min and max methods.
These are not implemented for dia_matrix, hence the separate class.
"""
def _min_or_max_axis(self, axis, min_or_max):
N = self.shape[axis]
if N == 0:
raise ValueError("zero-size array to reduction operation")
M = self.shape[1 - axis]
mat = self.tocsc() if axis == 0 else self.tocsr()
mat.sum_duplicates()
major_index, value = mat._minor_reduce(min_or_max)
not_full = np.diff(mat.indptr)[major_index] < N
value[not_full] = min_or_max(value[not_full], 0)
mask = value != 0
major_index = np.compress(mask, major_index)
value = np.compress(mask, value)
from . import coo_matrix
if axis == 0:
return coo_matrix((value, (np.zeros(len(value)), major_index)),
dtype=self.dtype, shape=(1, M))
else:
return coo_matrix((value, (major_index, np.zeros(len(value)))),
dtype=self.dtype, shape=(M, 1))
def _min_or_max(self, axis, out, min_or_max):
if out is not None:
raise ValueError(("Sparse matrices do not support "
"an 'out' parameter."))
validateaxis(axis)
if axis is None:
if 0 in self.shape:
raise ValueError("zero-size array to reduction operation")
zero = self.dtype.type(0)
if self.nnz == 0:
return zero
m = min_or_max.reduce(self._deduped_data().ravel())
if self.nnz != np.product(self.shape):
m = min_or_max(zero, m)
return m
if axis < 0:
axis += 2
if (axis == 0) or (axis == 1):
return self._min_or_max_axis(axis, min_or_max)
else:
raise ValueError("axis out of range")
def _arg_min_or_max_axis(self, axis, op, compare):
if self.shape[axis] == 0:
raise ValueError("Can't apply the operation along a zero-sized "
"dimension.")
if axis < 0:
axis += 2
zero = self.dtype.type(0)
mat = self.tocsc() if axis == 0 else self.tocsr()
mat.sum_duplicates()
ret_size, line_size = mat._swap(mat.shape)
ret = np.zeros(ret_size, dtype=int)
nz_lines, = np.nonzero(np.diff(mat.indptr))
for i in nz_lines:
p, q = mat.indptr[i:i + 2]
data = mat.data[p:q]
indices = mat.indices[p:q]
am = op(data)
m = data[am]
if compare(m, zero) or q - p == line_size:
ret[i] = indices[am]
else:
zero_ind = _find_missing_index(indices, line_size)
if m == zero:
ret[i] = min(am, zero_ind)
else:
ret[i] = zero_ind
if axis == 1:
ret = ret.reshape(-1, 1)
return np.asmatrix(ret)
def _arg_min_or_max(self, axis, out, op, compare):
if out is not None:
raise ValueError("Sparse matrices do not support "
"an 'out' parameter.")
validateaxis(axis)
if axis is None:
if 0 in self.shape:
raise ValueError("Can't apply the operation to "
"an empty matrix.")
if self.nnz == 0:
return 0
else:
zero = self.dtype.type(0)
mat = self.tocoo()
mat.sum_duplicates()
am = op(mat.data)
m = mat.data[am]
if compare(m, zero):
return mat.row[am] * mat.shape[1] + mat.col[am]
else:
size = np.product(mat.shape)
if size == mat.nnz:
return am
else:
ind = mat.row * mat.shape[1] + mat.col
zero_ind = _find_missing_index(ind, size)
if m == zero:
return min(zero_ind, am)
else:
return zero_ind
return self._arg_min_or_max_axis(axis, op, compare)
def max(self, axis=None, out=None):
"""
Return the maximum of the matrix or maximum along an axis.
This takes all elements into account, not just the non-zero ones.
Parameters
----------
axis : {-2, -1, 0, 1, None} optional
Axis along which the sum is computed. The default is to
compute the maximum over all the matrix elements, returning
a scalar (i.e. `axis` = `None`).
out : None, optional
This argument is in the signature *solely* for NumPy
compatibility reasons. Do not pass in anything except
for the default value, as this argument is not used.
Returns
-------
amax : coo_matrix or scalar
Maximum of `a`. If `axis` is None, the result is a scalar value.
If `axis` is given, the result is a sparse.coo_matrix of dimension
``a.ndim - 1``.
See Also
--------
min : The minimum value of a sparse matrix along a given axis.
np.matrix.max : NumPy's implementation of 'max' for matrices
"""
return self._min_or_max(axis, out, np.maximum)
def min(self, axis=None, out=None):
"""
Return the minimum of the matrix or maximum along an axis.
This takes all elements into account, not just the non-zero ones.
Parameters
----------
axis : {-2, -1, 0, 1, None} optional
Axis along which the sum is computed. The default is to
compute the minimum over all the matrix elements, returning
a scalar (i.e. `axis` = `None`).
out : None, optional
This argument is in the signature *solely* for NumPy
compatibility reasons. Do not pass in anything except for
the default value, as this argument is not used.
Returns
-------
amin : coo_matrix or scalar
Minimum of `a`. If `axis` is None, the result is a scalar value.
If `axis` is given, the result is a sparse.coo_matrix of dimension
``a.ndim - 1``.
See Also
--------
max : The maximum value of a sparse matrix along a given axis.
np.matrix.min : NumPy's implementation of 'min' for matrices
"""
return self._min_or_max(axis, out, np.minimum)
def argmax(self, axis=None, out=None):
"""Return indices of maximum elements along an axis.
Implicit zero elements are also taken into account. If there are
several maximum values, the index of the first occurrence is returned.
Parameters
----------
axis : {-2, -1, 0, 1, None}, optional
Axis along which the argmax is computed. If None (default), index
of the maximum element in the flatten data is returned.
out : None, optional
This argument is in the signature *solely* for NumPy
compatibility reasons. Do not pass in anything except for
the default value, as this argument is not used.
Returns
-------
ind : np.matrix or int
Indices of maximum elements. If matrix, its size along `axis` is 1.
"""
return self._arg_min_or_max(axis, out, np.argmax, np.greater)
def argmin(self, axis=None, out=None):
"""Return indices of minimum elements along an axis.
Implicit zero elements are also taken into account. If there are
several minimum values, the index of the first occurrence is returned.
Parameters
----------
axis : {-2, -1, 0, 1, None}, optional
Axis along which the argmin is computed. If None (default), index
of the minimum element in the flatten data is returned.
out : None, optional
This argument is in the signature *solely* for NumPy
compatibility reasons. Do not pass in anything except for
the default value, as this argument is not used.
Returns
-------
ind : np.matrix or int
Indices of minimum elements. If matrix, its size along `axis` is 1.
"""
return self._arg_min_or_max(axis, out, np.argmin, np.less)
|
bsd-3-clause
|
[
624,
1563,
1021,
367,
5178,
2530,
322,
301,
543,
282,
1275,
576,
2225,
339,
9180,
1471,
5647,
282,
485,
1045,
63,
576,
342,
1083,
626,
272,
8491,
282,
892,
3634,
543,
314,
2011,
28668,
3677,
3851,
272,
465,
291,
1325,
543,
282,
3365,
666,
1625,
199,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
1275,
1095,
492,
2249,
3642,
12,
485,
18810,
83,
63,
1045,
63,
5964,
63,
1403,
63,
292,
63,
4262,
199,
504,
1275,
681,
1208,
492,
365,
7033,
2930,
12,
4107,
3127,
199,
199,
363,
452,
363,
275,
942,
421,
199,
3,
3254,
5669,
1006,
12082,
5331,
199,
3,
675,
1275,
576,
855,
2474,
4533,
3140,
402,
12257,
12,
9000,
12,
5423,
14,
199,
533,
485,
576,
63,
3642,
8,
27349,
304,
272,
347,
636,
826,
721,
277,
304,
267,
2249,
3642,
855,
826,
721,
277,
9,
339,
347,
485,
362,
63,
2271,
8,
277,
304,
267,
372,
291,
14,
576,
14,
2271,
339,
347,
485,
409,
63,
2271,
8,
277,
12,
892,
466,
304,
267,
291,
14,
576,
14,
2271,
275,
892,
466,
272,
2152,
275,
3324,
8,
27823,
3699,
362,
63,
2271,
12,
289,
409,
3699,
409,
63,
2271,
9,
339,
347,
485,
770,
85,
1915,
63,
576,
8,
277,
304,
267,
340,
2688,
8,
277,
12,
283,
1838,
63,
18563,
735,
288,
291,
14,
1838,
63,
18563,
342,
267,
372,
291,
14,
576,
339,
347,
636,
2101,
721,
277,
304,
267,
372,
291,
423,
1045,
63,
576,
8,
2101,
8,
277,
423,
770,
85,
1915,
63,
576,
4059,
339,
347,
485,
3093,
8,
277,
304,
267,
372,
291,
423,
1045,
63,
576,
8,
277,
14,
576,
14,
3093,
9,
339,
347,
485,
14688,
8,
277,
304,
267,
372,
291,
423,
1045,
63,
576,
8,
277,
14,
576,
14,
14688,
9,
339,
347,
636,
8705,
721,
277,
304,
267,
340,
291,
14,
2271,
14,
5091,
508,
283,
66,
356,
288,
746,
4279,
360,
8705,
1958,
282,
5178,
5046,
283,
4228,
283,
3642,
365,
440,
3748,
358,
267,
372,
291,
423,
1045,
63,
576,
2801,
277,
14,
576,
9,
339,
347,
636,
1017,
348,
721,
277,
12,
1163,
304,
221,
327,
291,
9000,
1163,
267,
340,
365,
7033,
2930,
8,
1848,
304,
288,
291,
14,
576,
9000,
1163,
288,
372,
291,
267,
587,
26,
288,
372,
3784,
339,
347,
636,
390,
431,
3015,
721,
277,
12,
1163,
304,
221,
327,
291,
12257,
1163,
267,
340,
365,
7033,
2930,
8,
1848,
304,
288,
295,
6237,
275,
413,
14,
16,
1182,
1163,
288,
291,
14,
576,
9000,
295,
6237,
288,
372,
291,
267,
587,
26,
288,
372,
3784,
339,
347,
6073,
514,
8,
277,
12,
2152,
12,
22883,
534,
14242,
297,
1331,
29,
549,
304,
267,
2152,
275,
980,
14,
2271,
8,
2271,
9,
267,
340,
291,
14,
2271,
1137,
2152,
26,
288,
372,
291,
423,
1045,
63,
576,
8,
355,
291,
423,
770,
85,
1915,
63,
576,
1252,
6041,
8,
2271,
12,
22883,
29,
2931,
316,
12,
1331,
29,
1574,
395,
355,
1331,
29,
1574,
9,
267,
916,
1331,
26,
288,
372,
291,
14,
1574,
342,
267,
587,
26,
288,
372,
291,
339,
6073,
514,
855,
1301,
363,
275,
2249,
3642,
14,
6041,
855,
1301,
363,
339,
347,
14643,
8,
277,
12,
1331,
29,
549,
304,
267,
340,
980,
14,
374,
954,
2271,
8,
277,
14,
2271,
12,
980,
14,
5254,
7774,
304,
288,
372,
291,
423,
1045,
63,
576,
8,
277,
14,
576,
14,
14765,
1062,
1331,
29,
1574,
9,
267,
916,
1331,
26,
288,
372,
291,
14,
1574,
342,
267,
587,
26,
288,
372,
291,
339,
14643,
855,
1301,
363,
275,
2249,
3642,
14,
14765,
855,
1301,
363,
339,
347,
1331,
8,
277,
304,
267,
372,
291,
423,
1045,
63,
576,
8,
277,
14,
576,
14,
1574,
1062,
1331,
29,
549,
9,
339,
1331,
855,
1301,
363,
275,
2249,
3642,
14,
1574,
855,
1301,
363,
339,
347,
2338,
63,
10262,
8,
277,
304,
267,
372,
980,
14,
835,
63,
10262,
8,
277,
423,
770,
85,
1915,
63,
576,
1012,
339,
2338,
63,
10262,
855,
1301,
363,
275,
2249,
3642,
14,
835,
63,
10262,
855,
1301,
363,
339,
347,
7074,
8,
277,
12,
302,
12,
2152,
29,
403,
304,
267,
408,
267,
961,
805,
18628,
1819,
13,
2605,
7074,
14,
398,
3897,
267,
4143,
267,
302,
520,
302,
365,
282,
6917,
398,
2152,
520,
982,
2152,
365,
440,
2013,
12,
314,
1453,
2152,
911,
506,
17731,
14,
267,
408,
267,
340,
440,
365,
7033,
2930,
8,
78,
304,
288,
746,
4279,
480,
1210,
365,
440,
6917,
531,
398,
666,
275,
291,
423,
770,
85,
1915,
63,
576,
342,
267,
340,
2152,
365,
440,
488,
26,
288,
666,
275,
666,
14,
6041,
8,
2271,
9,
267,
372,
291,
423,
1045,
63,
576,
8,
576,
1011,
302,
9,
339,
11945,
5680,
272,
327,
603,
2092,
1863,
8297,
327,
272,
11945,
5680,
339,
347,
485,
3703,
63,
7033,
8,
277,
12,
1163,
304,
267,
372,
291,
423,
1045,
63,
576,
8,
277,
14,
576,
627,
1163,
9,
421,
199,
3,
2654,
314,
2680,
21603,
399,
9204,
367,
1314,
2562,
8,
16,
9,
275,
378,
370,
485,
576,
63,
3642,
14,
199,
509,
980,
1532,
315,
485,
18810,
83,
63,
1045,
63,
5964,
63,
1403,
63,
292,
63,
4262,
26,
272,
536,
275,
980,
1532,
855,
354,
363,
339,
347,
485,
981,
63,
765,
8,
411,
304,
267,
347,
1083,
8,
277,
304,
288,
754,
275,
1687,
8,
277,
423,
770,
85,
1915,
63,
576,
1012,
288,
372,
291,
423,
1045,
63,
576,
8,
1099,
12,
1331,
29,
549,
9,
398,
1083,
855,
1301,
363,
275,
1689,
2162,
13,
2605,
450,
83,
3134,
78,
60,
78,
2,
2079,
298,
9295,
2680,
4111,
83,
367,
1655,
2556,
2122,
450,
334,
354,
12,
536,
430,
267,
1083,
855,
354,
363,
275,
536,
398,
372,
1083,
339,
5371,
1547,
576,
63,
3642,
12,
536,
12,
485,
981,
63,
765,
8,
1590,
1532,
430,
421,
199,
318,
485,
1623,
63,
4752,
63,
1080,
8,
688,
12,
302,
304,
272,
367,
1022,
12,
282,
315,
3874,
8,
688,
304,
267
] |
[
1563,
1021,
367,
5178,
2530,
322,
301,
543,
282,
1275,
576,
2225,
339,
9180,
1471,
5647,
282,
485,
1045,
63,
576,
342,
1083,
626,
272,
8491,
282,
892,
3634,
543,
314,
2011,
28668,
3677,
3851,
272,
465,
291,
1325,
543,
282,
3365,
666,
1625,
199,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
1275,
1095,
492,
2249,
3642,
12,
485,
18810,
83,
63,
1045,
63,
5964,
63,
1403,
63,
292,
63,
4262,
199,
504,
1275,
681,
1208,
492,
365,
7033,
2930,
12,
4107,
3127,
199,
199,
363,
452,
363,
275,
942,
421,
199,
3,
3254,
5669,
1006,
12082,
5331,
199,
3,
675,
1275,
576,
855,
2474,
4533,
3140,
402,
12257,
12,
9000,
12,
5423,
14,
199,
533,
485,
576,
63,
3642,
8,
27349,
304,
272,
347,
636,
826,
721,
277,
304,
267,
2249,
3642,
855,
826,
721,
277,
9,
339,
347,
485,
362,
63,
2271,
8,
277,
304,
267,
372,
291,
14,
576,
14,
2271,
339,
347,
485,
409,
63,
2271,
8,
277,
12,
892,
466,
304,
267,
291,
14,
576,
14,
2271,
275,
892,
466,
272,
2152,
275,
3324,
8,
27823,
3699,
362,
63,
2271,
12,
289,
409,
3699,
409,
63,
2271,
9,
339,
347,
485,
770,
85,
1915,
63,
576,
8,
277,
304,
267,
340,
2688,
8,
277,
12,
283,
1838,
63,
18563,
735,
288,
291,
14,
1838,
63,
18563,
342,
267,
372,
291,
14,
576,
339,
347,
636,
2101,
721,
277,
304,
267,
372,
291,
423,
1045,
63,
576,
8,
2101,
8,
277,
423,
770,
85,
1915,
63,
576,
4059,
339,
347,
485,
3093,
8,
277,
304,
267,
372,
291,
423,
1045,
63,
576,
8,
277,
14,
576,
14,
3093,
9,
339,
347,
485,
14688,
8,
277,
304,
267,
372,
291,
423,
1045,
63,
576,
8,
277,
14,
576,
14,
14688,
9,
339,
347,
636,
8705,
721,
277,
304,
267,
340,
291,
14,
2271,
14,
5091,
508,
283,
66,
356,
288,
746,
4279,
360,
8705,
1958,
282,
5178,
5046,
283,
4228,
283,
3642,
365,
440,
3748,
358,
267,
372,
291,
423,
1045,
63,
576,
2801,
277,
14,
576,
9,
339,
347,
636,
1017,
348,
721,
277,
12,
1163,
304,
221,
327,
291,
9000,
1163,
267,
340,
365,
7033,
2930,
8,
1848,
304,
288,
291,
14,
576,
9000,
1163,
288,
372,
291,
267,
587,
26,
288,
372,
3784,
339,
347,
636,
390,
431,
3015,
721,
277,
12,
1163,
304,
221,
327,
291,
12257,
1163,
267,
340,
365,
7033,
2930,
8,
1848,
304,
288,
295,
6237,
275,
413,
14,
16,
1182,
1163,
288,
291,
14,
576,
9000,
295,
6237,
288,
372,
291,
267,
587,
26,
288,
372,
3784,
339,
347,
6073,
514,
8,
277,
12,
2152,
12,
22883,
534,
14242,
297,
1331,
29,
549,
304,
267,
2152,
275,
980,
14,
2271,
8,
2271,
9,
267,
340,
291,
14,
2271,
1137,
2152,
26,
288,
372,
291,
423,
1045,
63,
576,
8,
355,
291,
423,
770,
85,
1915,
63,
576,
1252,
6041,
8,
2271,
12,
22883,
29,
2931,
316,
12,
1331,
29,
1574,
395,
355,
1331,
29,
1574,
9,
267,
916,
1331,
26,
288,
372,
291,
14,
1574,
342,
267,
587,
26,
288,
372,
291,
339,
6073,
514,
855,
1301,
363,
275,
2249,
3642,
14,
6041,
855,
1301,
363,
339,
347,
14643,
8,
277,
12,
1331,
29,
549,
304,
267,
340,
980,
14,
374,
954,
2271,
8,
277,
14,
2271,
12,
980,
14,
5254,
7774,
304,
288,
372,
291,
423,
1045,
63,
576,
8,
277,
14,
576,
14,
14765,
1062,
1331,
29,
1574,
9,
267,
916,
1331,
26,
288,
372,
291,
14,
1574,
342,
267,
587,
26,
288,
372,
291,
339,
14643,
855,
1301,
363,
275,
2249,
3642,
14,
14765,
855,
1301,
363,
339,
347,
1331,
8,
277,
304,
267,
372,
291,
423,
1045,
63,
576,
8,
277,
14,
576,
14,
1574,
1062,
1331,
29,
549,
9,
339,
1331,
855,
1301,
363,
275,
2249,
3642,
14,
1574,
855,
1301,
363,
339,
347,
2338,
63,
10262,
8,
277,
304,
267,
372,
980,
14,
835,
63,
10262,
8,
277,
423,
770,
85,
1915,
63,
576,
1012,
339,
2338,
63,
10262,
855,
1301,
363,
275,
2249,
3642,
14,
835,
63,
10262,
855,
1301,
363,
339,
347,
7074,
8,
277,
12,
302,
12,
2152,
29,
403,
304,
267,
408,
267,
961,
805,
18628,
1819,
13,
2605,
7074,
14,
398,
3897,
267,
4143,
267,
302,
520,
302,
365,
282,
6917,
398,
2152,
520,
982,
2152,
365,
440,
2013,
12,
314,
1453,
2152,
911,
506,
17731,
14,
267,
408,
267,
340,
440,
365,
7033,
2930,
8,
78,
304,
288,
746,
4279,
480,
1210,
365,
440,
6917,
531,
398,
666,
275,
291,
423,
770,
85,
1915,
63,
576,
342,
267,
340,
2152,
365,
440,
488,
26,
288,
666,
275,
666,
14,
6041,
8,
2271,
9,
267,
372,
291,
423,
1045,
63,
576,
8,
576,
1011,
302,
9,
339,
11945,
5680,
272,
327,
603,
2092,
1863,
8297,
327,
272,
11945,
5680,
339,
347,
485,
3703,
63,
7033,
8,
277,
12,
1163,
304,
267,
372,
291,
423,
1045,
63,
576,
8,
277,
14,
576,
627,
1163,
9,
421,
199,
3,
2654,
314,
2680,
21603,
399,
9204,
367,
1314,
2562,
8,
16,
9,
275,
378,
370,
485,
576,
63,
3642,
14,
199,
509,
980,
1532,
315,
485,
18810,
83,
63,
1045,
63,
5964,
63,
1403,
63,
292,
63,
4262,
26,
272,
536,
275,
980,
1532,
855,
354,
363,
339,
347,
485,
981,
63,
765,
8,
411,
304,
267,
347,
1083,
8,
277,
304,
288,
754,
275,
1687,
8,
277,
423,
770,
85,
1915,
63,
576,
1012,
288,
372,
291,
423,
1045,
63,
576,
8,
1099,
12,
1331,
29,
549,
9,
398,
1083,
855,
1301,
363,
275,
1689,
2162,
13,
2605,
450,
83,
3134,
78,
60,
78,
2,
2079,
298,
9295,
2680,
4111,
83,
367,
1655,
2556,
2122,
450,
334,
354,
12,
536,
430,
267,
1083,
855,
354,
363,
275,
536,
398,
372,
1083,
339,
5371,
1547,
576,
63,
3642,
12,
536,
12,
485,
981,
63,
765,
8,
1590,
1532,
430,
421,
199,
318,
485,
1623,
63,
4752,
63,
1080,
8,
688,
12,
302,
304,
272,
367,
1022,
12,
282,
315,
3874,
8,
688,
304,
267,
0
] |
[
1,
1,
1,
1,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|
frink/base.py
|
1
|
1800
|
# -*- coding: utf-8 -*-
"""
frink.base
~~~~~~~~~~~~~
BaseModel class
"""
import datetime
from schematics.models import Model
from schematics.types.base import (
StringType, BooleanType, DateTimeType, IntType, UUIDType
)
from schematics.exceptions import ValidationError
# Frink
from .orm import InstanceLayerMixin
from .errors import NotUniqueError
import logging
log = logging.getLogger(__name__)
class BaseModel(Model, InstanceLayerMixin):
# __metaclass__ = ORMMeta # Do this in every model instead
_uniques = []
id = UUIDType()
created_at = DateTimeType(default=datetime.datetime.now)
updated_at = DateTimeType(default=datetime.datetime.now)
def validate(self):
log.debug('VALIDATING')
for field in self._uniques:
log.debug('Validate that {} is unique'.format(field))
if self._data.get(field, None) is None:
raise ValidationError('Unique fields cannot be None ({})'.format(field))
_ = self.query.get_by(column=field, value=self._data.get(field, None))
if _ is not None and _.id != self.id:
raise NotUniqueError('Field `{}` must be unique'.format(field))
return super(BaseModel, self).validate()
def __repr__(self):
if hasattr(self, 'email'):
return u'<{}: {}>'.format(self.__class__.__name__, self.email)
if hasattr(self, 'slug'):
return u'<{}: {}>'.format(self.__class__.__name__, self.slug)
if hasattr(self, 'name'):
return u'<{}: {}>'.format(self.__class__.__name__, self.name)
if hasattr(self, 'id'):
return u'<{}: {}>'.format(self.__class__.__name__, self.id)
return u'<{}: {} object>'.format(self.__class__.__name__, self.__class__.__name__)
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
272,
9513,
2292,
14,
1095,
272,
32202,
94,
272,
3523,
1685,
1021,
199,
624,
199,
199,
646,
2197,
199,
504,
4177,
7769,
14,
992,
492,
5822,
199,
504,
4177,
7769,
14,
1313,
14,
1095,
492,
334,
272,
32654,
12,
9411,
804,
12,
13686,
804,
12,
9805,
804,
12,
11134,
804,
199,
9,
199,
199,
504,
4177,
7769,
14,
3924,
492,
8505,
199,
199,
3,
481,
12465,
199,
504,
1275,
1025,
492,
10066,
5003,
4256,
199,
504,
1275,
2550,
492,
2832,
11427,
547,
199,
199,
646,
2050,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
3523,
1685,
8,
1685,
12,
10066,
5003,
4256,
304,
339,
327,
636,
6577,
363,
275,
1549,
3218,
1841,
221,
327,
4226,
642,
315,
4036,
1402,
3140,
339,
485,
3235,
83,
275,
942,
339,
1305,
275,
11134,
804,
342,
272,
2737,
63,
292,
275,
13686,
804,
8,
885,
29,
2083,
14,
2083,
14,
2131,
9,
272,
4588,
63,
292,
275,
13686,
804,
8,
885,
29,
2083,
14,
2083,
14,
2131,
9,
339,
347,
4107,
8,
277,
304,
267,
943,
14,
1757,
360,
5600,
27186,
358,
267,
367,
901,
315,
291,
423,
3235,
83,
26,
288,
943,
14,
1757,
360,
12584,
626,
1052,
365,
3747,
1370,
908,
8,
698,
430,
288,
340,
291,
423,
576,
14,
362,
8,
698,
12,
488,
9,
365,
488,
26,
355,
746,
8505,
360,
11427,
1504,
3913,
506,
488,
11459,
25885,
908,
8,
698,
430,
288,
485,
275,
291,
14,
1131,
14,
362,
63,
991,
8,
2301,
29,
698,
12,
574,
29,
277,
423,
576,
14,
362,
8,
698,
12,
488,
430,
288,
340,
485,
365,
440,
488,
436,
485,
14,
344,
1137,
291,
14,
344,
26,
355,
746,
2832,
11427,
547,
360,
792,
658,
2440,
64,
1471,
506,
3747,
1370,
908,
8,
698,
430,
267,
372,
1613,
8,
27687,
12,
291,
680,
3502,
342,
339,
347,
636,
2722,
721,
277,
304,
267,
340,
2688,
8,
277,
12,
283,
2123,
735,
288,
372,
399,
7601,
2440,
26,
1052,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
14,
2123,
9,
267,
340,
2688,
8,
277,
12,
283,
5464,
735,
288,
372,
399,
7601,
2440,
26,
1052,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
14,
5464,
9,
267,
340,
2688,
8,
277,
12,
283,
354,
735,
288,
372,
399,
7601,
2440,
26,
1052,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
14,
354,
9,
267,
340,
2688,
8,
277,
12,
283,
344,
735,
288,
372,
399,
7601,
2440,
26,
1052,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
14,
344,
9,
267,
372,
399,
7601,
2440,
26,
1052,
909,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
855,
533,
4914,
354,
3368,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
272,
9513,
2292,
14,
1095,
272,
32202,
94,
272,
3523,
1685,
1021,
199,
624,
199,
199,
646,
2197,
199,
504,
4177,
7769,
14,
992,
492,
5822,
199,
504,
4177,
7769,
14,
1313,
14,
1095,
492,
334,
272,
32654,
12,
9411,
804,
12,
13686,
804,
12,
9805,
804,
12,
11134,
804,
199,
9,
199,
199,
504,
4177,
7769,
14,
3924,
492,
8505,
199,
199,
3,
481,
12465,
199,
504,
1275,
1025,
492,
10066,
5003,
4256,
199,
504,
1275,
2550,
492,
2832,
11427,
547,
199,
199,
646,
2050,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
3523,
1685,
8,
1685,
12,
10066,
5003,
4256,
304,
339,
327,
636,
6577,
363,
275,
1549,
3218,
1841,
221,
327,
4226,
642,
315,
4036,
1402,
3140,
339,
485,
3235,
83,
275,
942,
339,
1305,
275,
11134,
804,
342,
272,
2737,
63,
292,
275,
13686,
804,
8,
885,
29,
2083,
14,
2083,
14,
2131,
9,
272,
4588,
63,
292,
275,
13686,
804,
8,
885,
29,
2083,
14,
2083,
14,
2131,
9,
339,
347,
4107,
8,
277,
304,
267,
943,
14,
1757,
360,
5600,
27186,
358,
267,
367,
901,
315,
291,
423,
3235,
83,
26,
288,
943,
14,
1757,
360,
12584,
626,
1052,
365,
3747,
1370,
908,
8,
698,
430,
288,
340,
291,
423,
576,
14,
362,
8,
698,
12,
488,
9,
365,
488,
26,
355,
746,
8505,
360,
11427,
1504,
3913,
506,
488,
11459,
25885,
908,
8,
698,
430,
288,
485,
275,
291,
14,
1131,
14,
362,
63,
991,
8,
2301,
29,
698,
12,
574,
29,
277,
423,
576,
14,
362,
8,
698,
12,
488,
430,
288,
340,
485,
365,
440,
488,
436,
485,
14,
344,
1137,
291,
14,
344,
26,
355,
746,
2832,
11427,
547,
360,
792,
658,
2440,
64,
1471,
506,
3747,
1370,
908,
8,
698,
430,
267,
372,
1613,
8,
27687,
12,
291,
680,
3502,
342,
339,
347,
636,
2722,
721,
277,
304,
267,
340,
2688,
8,
277,
12,
283,
2123,
735,
288,
372,
399,
7601,
2440,
26,
1052,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
14,
2123,
9,
267,
340,
2688,
8,
277,
12,
283,
5464,
735,
288,
372,
399,
7601,
2440,
26,
1052,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
14,
5464,
9,
267,
340,
2688,
8,
277,
12,
283,
354,
735,
288,
372,
399,
7601,
2440,
26,
1052,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
14,
354,
9,
267,
340,
2688,
8,
277,
12,
283,
344,
735,
288,
372,
399,
7601,
2440,
26,
1052,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
14,
344,
9,
267,
372,
399,
7601,
2440,
26,
1052,
909,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
855,
533,
4914,
354,
3368,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
mne-tools/mne-tools.github.io
|
0.20/_downloads/d179a09c019b9ab5cd45cfa1afebbab5/plot_dipole_orientations.py
|
4
|
10814
|
# -*- coding: utf-8 -*-
"""
.. _tut-dipole-orientations:
The role of dipole orientations in distributed source localization
==================================================================
When performing source localization in a distributed manner
(MNE/dSPM/sLORETA/eLORETA),
the source space is defined as a grid of dipoles that spans a large portion of
the cortex. These dipoles have both a position and an orientation. In this
tutorial, we will look at the various options available to restrict the
orientation of the dipoles and the impact on the resulting source estimate.
See :ref:`inverse_orientation_constraints` for related information.
"""
###############################################################################
# Loading data
# ------------
# Load everything we need to perform source localization on the sample dataset.
import mne
import numpy as np
from mne.datasets import sample
from mne.minimum_norm import make_inverse_operator, apply_inverse
data_path = sample.data_path()
evokeds = mne.read_evokeds(data_path + '/MEG/sample/sample_audvis-ave.fif')
left_auditory = evokeds[0].apply_baseline()
fwd = mne.read_forward_solution(
data_path + '/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif')
mne.convert_forward_solution(fwd, surf_ori=True, copy=False)
noise_cov = mne.read_cov(data_path + '/MEG/sample/sample_audvis-cov.fif')
subject = 'sample'
subjects_dir = data_path + '/subjects'
trans_fname = data_path + '/MEG/sample/sample_audvis_raw-trans.fif'
###############################################################################
# The source space
# ----------------
# Let's start by examining the source space as constructed by the
# :func:`mne.setup_source_space` function. Dipoles are placed along fixed
# intervals on the cortex, determined by the ``spacing`` parameter. The source
# space does not define the orientation for these dipoles.
lh = fwd['src'][0] # Visualize the left hemisphere
verts = lh['rr'] # The vertices of the source space
tris = lh['tris'] # Groups of three vertices that form triangles
dip_pos = lh['rr'][lh['vertno']] # The position of the dipoles
dip_ori = lh['nn'][lh['vertno']]
dip_len = len(dip_pos)
dip_times = [0]
white = (1.0, 1.0, 1.0) # RGB values for a white color
actual_amp = np.ones(dip_len) # misc amp to create Dipole instance
actual_gof = np.ones(dip_len) # misc GOF to create Dipole instance
dipoles = mne.Dipole(dip_times, dip_pos, actual_amp, dip_ori, actual_gof)
trans = mne.read_trans(trans_fname)
fig = mne.viz.create_3d_figure(size=(600, 400), bgcolor=white)
coord_frame = 'mri'
# Plot the cortex
fig = mne.viz.plot_alignment(subject=subject, subjects_dir=subjects_dir,
trans=trans, surfaces='white',
coord_frame=coord_frame, fig=fig)
# Mark the position of the dipoles with small red dots
fig = mne.viz.plot_dipole_locations(dipoles=dipoles, trans=trans,
mode='sphere', subject=subject,
subjects_dir=subjects_dir,
coord_frame=coord_frame,
scale=7e-4, fig=fig)
mne.viz.set_3d_view(figure=fig, azimuth=180, distance=0.25)
###############################################################################
# .. _plot_dipole_orientations_fixed_orientations:
#
# Fixed dipole orientations
# -------------------------
# While the source space defines the position of the dipoles, the inverse
# operator defines the possible orientations of them. One of the options is to
# assign a fixed orientation. Since the neural currents from which MEG and EEG
# signals originate flows mostly perpendicular to the cortex [1]_, restricting
# the orientation of the dipoles accordingly places a useful restriction on the
# source estimate.
#
# By specifying ``fixed=True`` when calling
# :func:`mne.minimum_norm.make_inverse_operator`, the dipole orientations are
# fixed to be orthogonal to the surface of the cortex, pointing outwards. Let's
# visualize this:
fig = mne.viz.create_3d_figure(size=(600, 400))
# Plot the cortex
fig = mne.viz.plot_alignment(subject=subject, subjects_dir=subjects_dir,
trans=trans,
surfaces='white', coord_frame='head', fig=fig)
# Show the dipoles as arrows pointing along the surface normal
fig = mne.viz.plot_dipole_locations(dipoles=dipoles, trans=trans,
mode='arrow', subject=subject,
subjects_dir=subjects_dir,
coord_frame='head',
scale=7e-4, fig=fig)
mne.viz.set_3d_view(figure=fig, azimuth=180, distance=0.1)
###############################################################################
# Restricting the dipole orientations in this manner leads to the following
# source estimate for the sample data:
# Compute the source estimate for the 'left - auditory' condition in the sample
# dataset.
inv = make_inverse_operator(left_auditory.info, fwd, noise_cov, fixed=True)
stc = apply_inverse(left_auditory, inv, pick_ori=None)
# Visualize it at the moment of peak activity.
_, time_max = stc.get_peak(hemi='lh')
brain_fixed = stc.plot(surface='white', subjects_dir=subjects_dir,
initial_time=time_max, time_unit='s', size=(600, 400))
###############################################################################
# The direction of the estimated current is now restricted to two directions:
# inward and outward. In the plot, blue areas indicate current flowing inwards
# and red areas indicate current flowing outwards. Given the curvature of the
# cortex, groups of dipoles tend to point in the same direction: the direction
# of the electromagnetic field picked up by the sensors.
###############################################################################
# .. _plot_dipole_orientations_fLOC_orientations:
#
# Loose dipole orientations
# -------------------------
# Forcing the source dipoles to be strictly orthogonal to the cortex makes the
# source estimate sensitive to the spacing of the dipoles along the cortex,
# since the curvature of the cortex changes within each ~10 square mm patch.
# Furthermore, misalignment of the MEG/EEG and MRI coordinate frames is more
# critical when the source dipole orientations are strictly constrained [2]_.
# To lift the restriction on the orientation of the dipoles, the inverse
# operator has the ability to place not one, but three dipoles at each
# location defined by the source space. These three dipoles are placed
# orthogonally to form a Cartesian coordinate system. Let's visualize this:
fig = mne.viz.create_3d_figure(size=(600, 400))
# Plot the cortex
fig = mne.viz.plot_alignment(subject=subject, subjects_dir=subjects_dir,
trans=trans,
surfaces='white', coord_frame='head', fig=fig)
# Show the three dipoles defined at each location in the source space
fig = mne.viz.plot_alignment(subject=subject, subjects_dir=subjects_dir,
trans=trans, fwd=fwd,
surfaces='white', coord_frame='head', fig=fig)
mne.viz.set_3d_view(figure=fig, azimuth=180, distance=0.1)
###############################################################################
# When computing the source estimate, the activity at each of the three dipoles
# is collapsed into the XYZ components of a single vector, which leads to the
# following source estimate for the sample data:
# Make an inverse operator with loose dipole orientations
inv = make_inverse_operator(left_auditory.info, fwd, noise_cov, fixed=False,
loose=1.0)
# Compute the source estimate, indicate that we want a vector solution
stc = apply_inverse(left_auditory, inv, pick_ori='vector')
# Visualize it at the moment of peak activity.
_, time_max = stc.magnitude().get_peak(hemi='lh')
brain_mag = stc.plot(subjects_dir=subjects_dir, initial_time=time_max,
time_unit='s', size=(600, 400), overlay_alpha=0)
###############################################################################
# .. _plot_dipole_orientations_vLOC_orientations:
#
# Limiting orientations, but not fixing them
# ------------------------------------------
# Often, the best results will be obtained by allowing the dipoles to have
# somewhat free orientation, but not stray too far from a orientation that is
# perpendicular to the cortex. The ``loose`` parameter of the
# :func:`mne.minimum_norm.make_inverse_operator` allows you to specify a value
# between 0 (fixed) and 1 (unrestricted or "free") to indicate the amount the
# orientation is allowed to deviate from the surface normal.
# Set loose to 0.2, the default value
inv = make_inverse_operator(left_auditory.info, fwd, noise_cov, fixed=False,
loose=0.2)
stc = apply_inverse(left_auditory, inv, pick_ori='vector')
# Visualize it at the moment of peak activity.
_, time_max = stc.magnitude().get_peak(hemi='lh')
brain_loose = stc.plot(subjects_dir=subjects_dir, initial_time=time_max,
time_unit='s', size=(600, 400), overlay_alpha=0)
###############################################################################
# Discarding dipole orientation information
# -----------------------------------------
# Often, further analysis of the data does not need information about the
# orientation of the dipoles, but rather their magnitudes. The ``pick_ori``
# parameter of the :func:`mne.minimum_norm.apply_inverse` function allows you
# to specify whether to return the full vector solution (``'vector'``) or
# rather the magnitude of the vectors (``None``, the default) or only the
# activity in the direction perpendicular to the cortex (``'normal'``).
# Only retain vector magnitudes
stc = apply_inverse(left_auditory, inv, pick_ori=None)
# Visualize it at the moment of peak activity.
_, time_max = stc.get_peak(hemi='lh')
brain = stc.plot(surface='white', subjects_dir=subjects_dir,
initial_time=time_max, time_unit='s', size=(600, 400))
###############################################################################
# References
# ----------
# .. [1] Hämäläinen, M. S., Hari, R., Ilmoniemi, R. J., Knuutila, J., &
# Lounasmaa, O. V. "Magnetoencephalography - theory, instrumentation, and
# applications to noninvasive studies of the working human brain", Reviews
# of Modern Physics, 1993. https://doi.org/10.1103/RevModPhys.65.413
#
# .. [2] Lin, F. H., Belliveau, J. W., Dale, A. M., & Hämäläinen, M. S. (2006).
# Distributed current estimates using cortical orientation constraints.
# Human Brain Mapping, 27(1), 1–13. http://doi.org/10.1002/hbm.20155
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
703,
485,
84,
337,
13,
328,
25903,
13,
19676,
1298,
26,
199,
199,
1918,
4719,
402,
487,
25903,
25626,
1298,
315,
1854,
1350,
2257,
2072,
199,
5695,
389,
199,
199,
11423,
19203,
1350,
2257,
2072,
315,
282,
1854,
30800,
199,
8,
45,
6388,
15,
68,
5763,
45,
15,
83,
44,
726,
15808,
15,
69,
44,
726,
15808,
395,
199,
1589,
1350,
4601,
365,
3247,
465,
282,
6068,
402,
487,
555,
2978,
626,
2249,
796,
282,
7031,
18046,
402,
199,
1589,
1970,
3858,
14,
5723,
487,
555,
2978,
1172,
3865,
282,
3421,
436,
376,
16774,
14,
1010,
642,
199,
23561,
12,
781,
911,
3648,
737,
314,
7750,
1511,
2808,
370,
18152,
314,
199,
17001,
402,
314,
487,
555,
2978,
436,
314,
25568,
641,
314,
9183,
1350,
14497,
14,
199,
199,
9295,
520,
1121,
1705,
11668,
63,
17001,
63,
9882,
64,
367,
4048,
2556,
14,
199,
624,
199,
199,
11490,
199,
3,
3835,
5384,
666,
199,
3,
3001,
375,
199,
3,
7190,
8137,
781,
1929,
370,
5147,
1350,
2257,
2072,
641,
314,
2690,
4789,
14,
199,
199,
646,
18250,
199,
646,
2680,
465,
980,
199,
504,
18250,
14,
12281,
492,
2690,
199,
504,
18250,
14,
10700,
63,
4791,
492,
1852,
63,
11668,
63,
3856,
12,
4838,
63,
11668,
199,
199,
576,
63,
515,
275,
2690,
14,
576,
63,
515,
342,
199,
6857,
745,
5923,
275,
18250,
14,
739,
63,
6857,
745,
5923,
8,
576,
63,
515,
435,
1994,
3635,
39,
15,
3271,
15,
3271,
63,
32024,
5068,
13,
811,
14,
25533,
358,
199,
3039,
63,
14274,
1089,
275,
8145,
745,
5923,
59,
16,
1055,
4998,
63,
14232,
342,
199,
27912,
275,
18250,
14,
739,
63,
6688,
63,
14458,
8,
272,
666,
63,
515,
435,
1994,
3635,
39,
15,
3271,
15,
3271,
63,
32024,
5068,
13,
32177,
13,
1024,
71,
13,
15560,
13,
22,
13,
27912,
14,
25533,
358,
199,
22599,
14,
3916,
63,
6688,
63,
14458,
8,
27912,
12,
24802,
63,
16039,
29,
549,
12,
1331,
29,
797,
9,
199,
11838,
63,
8695,
275,
18250,
14,
739,
63,
8695,
8,
576,
63,
515,
435,
1994,
3635,
39,
15,
3271,
15,
3271,
63,
32024,
5068,
13,
8695,
14,
25533,
358,
199,
5875,
275,
283,
3271,
7,
199,
25660,
63,
694,
275,
666,
63,
515,
435,
1994,
25660,
7,
199,
1515,
63,
5252,
275,
666,
63,
515,
435,
1994,
3635,
39,
15,
3271,
15,
3271,
63,
32024,
5068,
63,
1773,
13,
1515,
14,
25533,
7,
199,
199,
11490,
199,
3,
710,
1350,
4601,
199,
3,
10652,
199,
3,
12230,
1159,
1343,
701,
15735,
7969,
314,
1350,
4601,
465,
14701,
701,
314,
199,
3,
520,
1532,
1705,
22599,
14,
2758,
63,
1365,
63,
2638,
64,
805,
14,
3757,
555,
2978,
787,
15090,
3180,
6317,
199,
3,
15802,
641,
314,
1970,
3858,
12,
12037,
701,
314,
1124,
15880,
1040,
2725,
14,
710,
1350,
199,
3,
4601,
1630,
440,
5627,
314,
16774,
367,
3520,
487,
555,
2978,
14,
421,
199,
25514,
275,
31336,
459,
2164,
3488,
16,
61,
221,
327,
14702,
794,
314,
3602,
946,
1292,
80,
1681,
199,
21505,
275,
634,
72,
459,
9734,
418,
221,
327,
710,
14971,
402,
314,
1350,
4601,
199,
599,
83,
275,
634,
72,
459,
599,
83,
418,
221,
327,
25031,
402,
7795,
14971,
626,
1824,
3229,
13162,
199,
21846,
63,
1712,
275,
634,
72,
459,
9734,
3488,
25514,
459,
1884,
889,
6538,
221,
327,
710,
3421,
402,
314,
487,
555,
2978,
199,
21846,
63,
16039,
275,
634,
72,
459,
4411,
3488,
25514,
459,
1884,
889,
6538,
199,
21846,
63,
552,
275,
822,
8,
21846,
63,
1712,
9,
199,
21846,
63,
4508,
275,
359,
16,
61,
199,
7510,
275,
334,
17,
14,
16,
12,
413,
14,
16,
12,
413,
14,
16,
9,
221,
327,
19013,
1338,
367,
282,
10424,
3164,
199,
199,
6514,
63,
5282,
275,
980,
14,
4548,
8,
21846,
63,
552,
9,
221,
327,
18576,
15204,
370,
1218,
3757,
25903,
1256,
199,
6514,
63,
71,
1618,
275,
980,
14,
4548,
8,
21846,
63,
552,
9,
221,
327,
18576,
598,
3359,
370,
1218,
3757,
25903,
1256,
199,
328,
555,
2978,
275,
18250,
14,
1341,
25903,
8,
21846,
63,
4508,
12,
487,
80,
63,
1712,
12,
3503,
63,
5282,
12,
487,
80,
63,
16039,
12,
3503,
63,
71,
1618,
9,
199,
1515,
275,
18250,
14,
739,
63,
1515,
8,
1515,
63,
5252,
9,
199,
199,
592,
275,
18250,
14,
17249,
14,
981,
63,
19,
68,
63,
8941,
8,
890,
2687,
6683,
12,
8290,
395,
12994,
2326,
29,
7510,
9,
199,
7988,
63,
1943,
275,
283,
77,
322,
7,
199,
199,
3,
14794,
314,
1970,
3858,
199,
592,
275,
18250,
14,
17249,
14,
2798,
63,
13699,
8,
5875,
29,
5875,
12,
32446,
63,
694,
29,
25660,
63,
694,
12,
2490,
1752,
29,
1515,
12,
6296,
4309,
534,
7510,
297,
2490,
11021,
63,
1943,
29,
7988,
63,
1943,
12,
6085,
29,
592,
9,
199,
199,
3,
7173,
314,
3421,
402,
314,
487,
555,
2978,
543,
7425,
8992,
21185,
199,
592,
275,
18250,
14,
17249,
14,
2798,
63,
328,
25903,
63,
8022,
8,
328,
555,
2978,
29,
328,
555,
2978,
12,
1752,
29,
1515,
12,
2511,
818,
534,
14980,
297,
5420,
29,
5875,
12,
2511,
32446,
63,
694,
29,
25660,
63,
694,
12,
2511,
11021,
63,
1943,
29,
7988,
63,
1943,
12,
2511,
4666,
29,
23,
69,
13,
20,
12,
6085,
29,
592,
9,
199,
199,
22599,
14,
17249,
14,
409,
63,
19,
68,
63,
1345,
8,
8941,
29,
592,
12,
24978,
26720,
29,
7663,
12,
6033,
29,
16,
14,
821,
9,
199,
199,
11490,
199,
3,
2508,
485,
2798,
63,
328,
25903,
63,
19676,
1298,
63,
5964,
63,
19676,
1298,
26,
199,
3,
199,
3,
18659,
487,
25903,
25626,
1298,
199,
3,
10652,
9960,
199,
3,
22117,
314,
1350,
4601,
7890,
314,
3421,
402,
314,
487,
555,
2978,
12,
314,
11484,
199,
3,
4182,
7890,
314,
3962,
25626,
1298,
402,
3062,
14,
7309,
402,
314,
1511,
365,
370,
199,
3,
5090,
282,
6317,
16774,
14,
9336,
314,
1279,
4889,
1453,
83,
687,
1314,
603,
4680,
436,
662,
4680,
199,
3,
10166,
6330,
323,
30708,
19762,
1126,
897,
5000,
2238,
370,
314,
1970,
3858,
359,
17,
61
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
703,
485,
84,
337,
13,
328,
25903,
13,
19676,
1298,
26,
199,
199,
1918,
4719,
402,
487,
25903,
25626,
1298,
315,
1854,
1350,
2257,
2072,
199,
5695,
389,
199,
199,
11423,
19203,
1350,
2257,
2072,
315,
282,
1854,
30800,
199,
8,
45,
6388,
15,
68,
5763,
45,
15,
83,
44,
726,
15808,
15,
69,
44,
726,
15808,
395,
199,
1589,
1350,
4601,
365,
3247,
465,
282,
6068,
402,
487,
555,
2978,
626,
2249,
796,
282,
7031,
18046,
402,
199,
1589,
1970,
3858,
14,
5723,
487,
555,
2978,
1172,
3865,
282,
3421,
436,
376,
16774,
14,
1010,
642,
199,
23561,
12,
781,
911,
3648,
737,
314,
7750,
1511,
2808,
370,
18152,
314,
199,
17001,
402,
314,
487,
555,
2978,
436,
314,
25568,
641,
314,
9183,
1350,
14497,
14,
199,
199,
9295,
520,
1121,
1705,
11668,
63,
17001,
63,
9882,
64,
367,
4048,
2556,
14,
199,
624,
199,
199,
11490,
199,
3,
3835,
5384,
666,
199,
3,
3001,
375,
199,
3,
7190,
8137,
781,
1929,
370,
5147,
1350,
2257,
2072,
641,
314,
2690,
4789,
14,
199,
199,
646,
18250,
199,
646,
2680,
465,
980,
199,
504,
18250,
14,
12281,
492,
2690,
199,
504,
18250,
14,
10700,
63,
4791,
492,
1852,
63,
11668,
63,
3856,
12,
4838,
63,
11668,
199,
199,
576,
63,
515,
275,
2690,
14,
576,
63,
515,
342,
199,
6857,
745,
5923,
275,
18250,
14,
739,
63,
6857,
745,
5923,
8,
576,
63,
515,
435,
1994,
3635,
39,
15,
3271,
15,
3271,
63,
32024,
5068,
13,
811,
14,
25533,
358,
199,
3039,
63,
14274,
1089,
275,
8145,
745,
5923,
59,
16,
1055,
4998,
63,
14232,
342,
199,
27912,
275,
18250,
14,
739,
63,
6688,
63,
14458,
8,
272,
666,
63,
515,
435,
1994,
3635,
39,
15,
3271,
15,
3271,
63,
32024,
5068,
13,
32177,
13,
1024,
71,
13,
15560,
13,
22,
13,
27912,
14,
25533,
358,
199,
22599,
14,
3916,
63,
6688,
63,
14458,
8,
27912,
12,
24802,
63,
16039,
29,
549,
12,
1331,
29,
797,
9,
199,
11838,
63,
8695,
275,
18250,
14,
739,
63,
8695,
8,
576,
63,
515,
435,
1994,
3635,
39,
15,
3271,
15,
3271,
63,
32024,
5068,
13,
8695,
14,
25533,
358,
199,
5875,
275,
283,
3271,
7,
199,
25660,
63,
694,
275,
666,
63,
515,
435,
1994,
25660,
7,
199,
1515,
63,
5252,
275,
666,
63,
515,
435,
1994,
3635,
39,
15,
3271,
15,
3271,
63,
32024,
5068,
63,
1773,
13,
1515,
14,
25533,
7,
199,
199,
11490,
199,
3,
710,
1350,
4601,
199,
3,
10652,
199,
3,
12230,
1159,
1343,
701,
15735,
7969,
314,
1350,
4601,
465,
14701,
701,
314,
199,
3,
520,
1532,
1705,
22599,
14,
2758,
63,
1365,
63,
2638,
64,
805,
14,
3757,
555,
2978,
787,
15090,
3180,
6317,
199,
3,
15802,
641,
314,
1970,
3858,
12,
12037,
701,
314,
1124,
15880,
1040,
2725,
14,
710,
1350,
199,
3,
4601,
1630,
440,
5627,
314,
16774,
367,
3520,
487,
555,
2978,
14,
421,
199,
25514,
275,
31336,
459,
2164,
3488,
16,
61,
221,
327,
14702,
794,
314,
3602,
946,
1292,
80,
1681,
199,
21505,
275,
634,
72,
459,
9734,
418,
221,
327,
710,
14971,
402,
314,
1350,
4601,
199,
599,
83,
275,
634,
72,
459,
599,
83,
418,
221,
327,
25031,
402,
7795,
14971,
626,
1824,
3229,
13162,
199,
21846,
63,
1712,
275,
634,
72,
459,
9734,
3488,
25514,
459,
1884,
889,
6538,
221,
327,
710,
3421,
402,
314,
487,
555,
2978,
199,
21846,
63,
16039,
275,
634,
72,
459,
4411,
3488,
25514,
459,
1884,
889,
6538,
199,
21846,
63,
552,
275,
822,
8,
21846,
63,
1712,
9,
199,
21846,
63,
4508,
275,
359,
16,
61,
199,
7510,
275,
334,
17,
14,
16,
12,
413,
14,
16,
12,
413,
14,
16,
9,
221,
327,
19013,
1338,
367,
282,
10424,
3164,
199,
199,
6514,
63,
5282,
275,
980,
14,
4548,
8,
21846,
63,
552,
9,
221,
327,
18576,
15204,
370,
1218,
3757,
25903,
1256,
199,
6514,
63,
71,
1618,
275,
980,
14,
4548,
8,
21846,
63,
552,
9,
221,
327,
18576,
598,
3359,
370,
1218,
3757,
25903,
1256,
199,
328,
555,
2978,
275,
18250,
14,
1341,
25903,
8,
21846,
63,
4508,
12,
487,
80,
63,
1712,
12,
3503,
63,
5282,
12,
487,
80,
63,
16039,
12,
3503,
63,
71,
1618,
9,
199,
1515,
275,
18250,
14,
739,
63,
1515,
8,
1515,
63,
5252,
9,
199,
199,
592,
275,
18250,
14,
17249,
14,
981,
63,
19,
68,
63,
8941,
8,
890,
2687,
6683,
12,
8290,
395,
12994,
2326,
29,
7510,
9,
199,
7988,
63,
1943,
275,
283,
77,
322,
7,
199,
199,
3,
14794,
314,
1970,
3858,
199,
592,
275,
18250,
14,
17249,
14,
2798,
63,
13699,
8,
5875,
29,
5875,
12,
32446,
63,
694,
29,
25660,
63,
694,
12,
2490,
1752,
29,
1515,
12,
6296,
4309,
534,
7510,
297,
2490,
11021,
63,
1943,
29,
7988,
63,
1943,
12,
6085,
29,
592,
9,
199,
199,
3,
7173,
314,
3421,
402,
314,
487,
555,
2978,
543,
7425,
8992,
21185,
199,
592,
275,
18250,
14,
17249,
14,
2798,
63,
328,
25903,
63,
8022,
8,
328,
555,
2978,
29,
328,
555,
2978,
12,
1752,
29,
1515,
12,
2511,
818,
534,
14980,
297,
5420,
29,
5875,
12,
2511,
32446,
63,
694,
29,
25660,
63,
694,
12,
2511,
11021,
63,
1943,
29,
7988,
63,
1943,
12,
2511,
4666,
29,
23,
69,
13,
20,
12,
6085,
29,
592,
9,
199,
199,
22599,
14,
17249,
14,
409,
63,
19,
68,
63,
1345,
8,
8941,
29,
592,
12,
24978,
26720,
29,
7663,
12,
6033,
29,
16,
14,
821,
9,
199,
199,
11490,
199,
3,
2508,
485,
2798,
63,
328,
25903,
63,
19676,
1298,
63,
5964,
63,
19676,
1298,
26,
199,
3,
199,
3,
18659,
487,
25903,
25626,
1298,
199,
3,
10652,
9960,
199,
3,
22117,
314,
1350,
4601,
7890,
314,
3421,
402,
314,
487,
555,
2978,
12,
314,
11484,
199,
3,
4182,
7890,
314,
3962,
25626,
1298,
402,
3062,
14,
7309,
402,
314,
1511,
365,
370,
199,
3,
5090,
282,
6317,
16774,
14,
9336,
314,
1279,
4889,
1453,
83,
687,
1314,
603,
4680,
436,
662,
4680,
199,
3,
10166,
6330,
323,
30708,
19762,
1126,
897,
5000,
2238,
370,
314,
1970,
3858,
359,
17,
61,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
afdelgado/askbot
|
askbot/migrations/0096_auto__del_field_repute_question.py
|
17
|
30783
|
# 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 field 'Repute.question'
db.delete_column(u'repute', 'question_id')
def backwards(self, orm):
# Adding field 'Repute.question'
db.add_column(u'repute', 'question', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['askbot.Question'], null=True, blank=True), keep_default=False)
models = {
'askbot.activity': {
'Meta': {'object_name': 'Activity', 'db_table': "u'activity'"},
'active_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'activity_type': ('django.db.models.fields.SmallIntegerField', [], {}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_auditted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
'question_post': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Post']", 'null': 'True'}),
'receiving_users': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'received_activity'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
'recipients': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'incoming_activity'", 'symmetrical': 'False', 'through': "orm['askbot.ActivityAuditStatus']", 'to': "orm['auth.User']"}),
'summary': ('django.db.models.fields.TextField', [], {'default': "''"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
},
'askbot.activityauditstatus': {
'Meta': {'unique_together': "(('user', 'activity'),)", 'object_name': 'ActivityAuditStatus'},
'activity': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Activity']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'status': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
},
'askbot.anonymousanswer': {
'Meta': {'object_name': 'AnonymousAnswer'},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'anonymous_answers'", 'to': "orm['askbot.Question']"}),
'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
'text': ('django.db.models.fields.TextField', [], {}),
'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
},
'askbot.anonymousquestion': {
'Meta': {'object_name': 'AnonymousQuestion'},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
'text': ('django.db.models.fields.TextField', [], {}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
},
'askbot.answer': {
'Meta': {'object_name': 'Answer', 'db_table': "u'answer'"},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'answers'", 'to': "orm['auth.User']"}),
'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_answers'", 'null': 'True', 'to': "orm['auth.User']"}),
'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_answers'", 'null': 'True', 'to': "orm['auth.User']"}),
'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_answers'", 'null': 'True', 'to': "orm['auth.User']"}),
'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'answers'", 'to': "orm['askbot.Question']"}),
'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
},
'askbot.award': {
'Meta': {'object_name': 'Award', 'db_table': "u'award'"},
'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_badge'", 'to': "orm['askbot.BadgeData']"}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_user'", 'to': "orm['auth.User']"})
},
'askbot.badgedata': {
'Meta': {'ordering': "('slug',)", 'object_name': 'BadgeData'},
'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'symmetrical': 'False', 'through': "orm['askbot.Award']", 'to': "orm['auth.User']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'})
},
'askbot.comment': {
'Meta': {'ordering': "('-added_at',)", 'object_name': 'Comment', 'db_table': "u'comment'"},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'comment': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'html': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '2048'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
'offensive_flag_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'comments'", 'to': "orm['auth.User']"})
},
'askbot.emailfeedsetting': {
'Meta': {'object_name': 'EmailFeedSetting'},
'added_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'feed_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
'frequency': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '8'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'reported_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'subscriber': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notification_subscriptions'", 'to': "orm['auth.User']"})
},
'askbot.favoritequestion': {
'Meta': {'object_name': 'FavoriteQuestion', 'db_table': "u'favorite_question'"},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'thread': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Thread']"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_favorite_questions'", 'to': "orm['auth.User']"})
},
'askbot.markedtag': {
'Meta': {'object_name': 'MarkedTag'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['askbot.Tag']"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['auth.User']"})
},
'askbot.post': {
'Meta': {'object_name': 'Post'},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['auth.User']"}),
'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comment_posts'", 'null': 'True', 'to': "orm['askbot.Post']"}),
'post_type': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'self_answer': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'to': "orm['askbot.Answer']"}),
'self_comment': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'to': "orm['askbot.Comment']"}),
'self_question': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'to': "orm['askbot.Question']"}),
'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'thread': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['askbot.Thread']"}),
'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
# "Post-processing" - added manually to add support for URL mapping
'old_question_id': ('django.db.models.fields.PositiveIntegerField', [], {'null': True, 'blank': True, 'default': None, 'unique': 'True'}),
'old_answer_id': ('django.db.models.fields.PositiveIntegerField', [], {'null': True, 'blank': True, 'default': None, 'unique': 'True'}),
'old_comment_id': ('django.db.models.fields.PositiveIntegerField', [], {'null': True, 'blank': True, 'default': None, 'unique': 'True'}),
},
'askbot.postrevision': {
'Meta': {'ordering': "('-revision',)", 'unique_together': "(('answer', 'revision'), ('question', 'revision'))", 'object_name': 'PostRevision'},
'answer': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'revisions'", 'null': 'True', 'to': "orm['askbot.Answer']"}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'postrevisions'", 'to': "orm['auth.User']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'revisions'", 'null': 'True', 'to': "orm['askbot.Question']"}),
'revised_at': ('django.db.models.fields.DateTimeField', [], {}),
'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
'revision_type': ('django.db.models.fields.SmallIntegerField', [], {}),
'summary': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}),
'tagnames': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '125', 'blank': 'True'}),
'text': ('django.db.models.fields.TextField', [], {}),
'title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '300', 'blank': 'True'})
},
'askbot.question': {
'Meta': {'object_name': 'Question', 'db_table': "u'question'"},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'questions'", 'to': "orm['auth.User']"}),
'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_questions'", 'null': 'True', 'to': "orm['auth.User']"}),
'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_questions'", 'null': 'True', 'to': "orm['auth.User']"}),
'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_questions'", 'null': 'True', 'to': "orm['auth.User']"}),
'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'thread': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'questions'", 'unique': 'True', 'to': "orm['askbot.Thread']"}),
'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
},
'askbot.questionview': {
'Meta': {'object_name': 'QuestionView'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'viewed'", 'to': "orm['askbot.Question']"}),
'when': ('django.db.models.fields.DateTimeField', [], {}),
'who': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'question_views'", 'to': "orm['auth.User']"})
},
'askbot.repute': {
'Meta': {'object_name': 'Repute', 'db_table': "u'repute'"},
'comment': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'negative': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'positive': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'question_post': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Post']", 'null': 'True', 'blank': 'True'}),
'reputation': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
'reputation_type': ('django.db.models.fields.SmallIntegerField', [], {}),
'reputed_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
},
'askbot.tag': {
'Meta': {'ordering': "('-used_count', 'name')", 'object_name': 'Tag', 'db_table': "u'tag'"},
'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['auth.User']"}),
'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['auth.User']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
},
'askbot.thread': {
'Meta': {'object_name': 'Thread'},
'accepted_answer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Answer']", 'null': 'True', 'blank': 'True'}),
'answer_accepted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'answer_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'close_reason': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'closed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'closed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
'favorited_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'unused_favorite_threads'", 'symmetrical': 'False', 'through': "orm['askbot.FavoriteQuestion']", 'to': "orm['auth.User']"}),
'favourite_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'followed_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'followed_threads'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'unused_last_active_in_threads'", 'to': "orm['auth.User']"}),
'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'threads'", 'symmetrical': 'False', 'to': "orm['askbot.Tag']"}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
'view_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
},
'askbot.vote': {
'Meta': {'unique_together': "(('user', 'voted_post'),)", 'object_name': 'Vote', 'db_table': "u'vote'"},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['auth.User']"}),
'vote': ('django.db.models.fields.SmallIntegerField', [], {}),
'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'voted_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'post_votes'", 'to': "orm['askbot.Post']"})
},
'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'},
'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'avatar_type': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
'bronze': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'consecutive_days_visit_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'country': ('django_countries.fields.CountryField', [], {'max_length': '2', 'blank': 'True'}),
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
'display_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
'email_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'gold': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'gravatar': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'ignored_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'interesting_tags': ('django.db.models.fields.TextField', [], {'blank': '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'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'new_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}),
'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
'seen_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'show_country': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'silver': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'status': ('django.db.models.fields.CharField', [], {'default': "'w'", 'max_length': '2'}),
'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'}),
'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
},
'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'})
}
}
complete_apps = ['askbot']
|
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,
901,
283,
6875,
938,
14,
4790,
7,
267,
1592,
14,
1807,
63,
2301,
8,
85,
3984,
80,
938,
297,
283,
4790,
63,
344,
358,
2378,
347,
8552,
8,
277,
12,
9813,
304,
2728,
327,
12934,
901,
283,
6875,
938,
14,
4790,
7,
267,
1592,
14,
525,
63,
2301,
8,
85,
3984,
80,
938,
297,
283,
4790,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
475,
29,
1025,
459,
20963,
14,
16778,
995,
2973,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
2378,
1709,
275,
469,
267,
283,
20963,
14,
8240,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
14350,
297,
283,
697,
63,
1224,
356,
298,
85,
7,
8240,
15208,
288,
283,
2682,
63,
292,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
8240,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
14640,
297,
990,
8613,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10778,
14,
11282,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
374,
63,
14274,
471,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
785,
63,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
8613,
288,
283,
4790,
63,
1932,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
20963,
14,
6564,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
24890,
316,
63,
3707,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
2407,
63,
354,
356,
3546,
9226,
63,
8240,
4662,
283,
10247,
356,
283,
797,
297,
283,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6097,
288,
283,
18323,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
2407,
63,
354,
356,
3546,
15994,
63,
8240,
4662,
283,
10247,
356,
283,
797,
297,
283,
8304,
356,
298,
1025,
459,
20963,
14,
14350,
23601,
3694,
6256,
283,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6097,
288,
283,
4705,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
297,
990,
791,
885,
356,
17172,
5593,
288,
283,
751,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
13687,
267,
1660,
267,
283,
20963,
14,
8240,
14274,
1205,
356,
469,
288,
283,
3396,
356,
791,
3235,
63,
6314,
356,
9510,
751,
297,
283,
8240,
9878,
283,
785,
63,
354,
356,
283,
14350,
23601,
3694,
2267,
288,
283,
8240,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
20963,
14,
14350,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
1205,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
14640,
297,
990,
791,
885,
356,
283,
16,
1604,
288,
283,
751,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
13687,
267,
1660,
267,
283,
20963,
14,
12628,
5934,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
23902,
19104,
2267,
288,
283,
3270,
63,
292,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2502,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
711,
63,
2697,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
26969,
297,
990,
791,
988,
63,
1267,
356,
283,
1046,
1604,
288,
283,
4790,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
2407,
63,
354,
356,
3546,
12628,
63,
13379,
4662,
283,
475,
356,
298,
1025,
459,
20963,
14,
16778,
6097,
288,
283,
1730,
63,
498,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
2167,
1604,
288,
283,
4705,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
7663,
1604,
288,
283,
505,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
297,
990,
8613,
288,
283,
6797,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
3071,
267,
1660,
267,
283,
20963,
14,
12628,
4790,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
23902,
16778,
2267,
288,
283,
3270,
63,
292,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2502,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
711,
63,
2697
] |
[
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,
901,
283,
6875,
938,
14,
4790,
7,
267,
1592,
14,
1807,
63,
2301,
8,
85,
3984,
80,
938,
297,
283,
4790,
63,
344,
358,
2378,
347,
8552,
8,
277,
12,
9813,
304,
2728,
327,
12934,
901,
283,
6875,
938,
14,
4790,
7,
267,
1592,
14,
525,
63,
2301,
8,
85,
3984,
80,
938,
297,
283,
4790,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
475,
29,
1025,
459,
20963,
14,
16778,
995,
2973,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
2378,
1709,
275,
469,
267,
283,
20963,
14,
8240,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
14350,
297,
283,
697,
63,
1224,
356,
298,
85,
7,
8240,
15208,
288,
283,
2682,
63,
292,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
8240,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
14640,
297,
990,
8613,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10778,
14,
11282,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
374,
63,
14274,
471,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
785,
63,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
8613,
288,
283,
4790,
63,
1932,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
20963,
14,
6564,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
24890,
316,
63,
3707,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
2407,
63,
354,
356,
3546,
9226,
63,
8240,
4662,
283,
10247,
356,
283,
797,
297,
283,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6097,
288,
283,
18323,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
2407,
63,
354,
356,
3546,
15994,
63,
8240,
4662,
283,
10247,
356,
283,
797,
297,
283,
8304,
356,
298,
1025,
459,
20963,
14,
14350,
23601,
3694,
6256,
283,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6097,
288,
283,
4705,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
297,
990,
791,
885,
356,
17172,
5593,
288,
283,
751,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
13687,
267,
1660,
267,
283,
20963,
14,
8240,
14274,
1205,
356,
469,
288,
283,
3396,
356,
791,
3235,
63,
6314,
356,
9510,
751,
297,
283,
8240,
9878,
283,
785,
63,
354,
356,
283,
14350,
23601,
3694,
2267,
288,
283,
8240,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
20963,
14,
14350,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
1205,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
14640,
297,
990,
791,
885,
356,
283,
16,
1604,
288,
283,
751,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
13687,
267,
1660,
267,
283,
20963,
14,
12628,
5934,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
23902,
19104,
2267,
288,
283,
3270,
63,
292,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2502,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
711,
63,
2697,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
26969,
297,
990,
791,
988,
63,
1267,
356,
283,
1046,
1604,
288,
283,
4790,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
2407,
63,
354,
356,
3546,
12628,
63,
13379,
4662,
283,
475,
356,
298,
1025,
459,
20963,
14,
16778,
6097,
288,
283,
1730,
63,
498,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
2167,
1604,
288,
283,
4705,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
7663,
1604,
288,
283,
505,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
297,
990,
8613,
288,
283,
6797,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
3071,
267,
1660,
267,
283,
20963,
14,
12628,
4790,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
23902,
16778,
2267,
288,
283,
3270,
63,
292,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2502,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
711,
63,
2697,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
rbu/ansible-modules-extras
|
network/citrix/netscaler.py
|
15
|
5051
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Ansible module to manage Citrix NetScaler entities
(c) 2013, Nandor Sivok <nandor@gawker.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: netscaler
version_added: "1.1"
short_description: Manages Citrix NetScaler entities
description:
- Manages Citrix NetScaler server and service entities.
options:
nsc_host:
description:
- hostname or ip of your netscaler
required: true
default: null
aliases: []
nsc_protocol:
description:
- protocol used to access netscaler
required: false
default: https
aliases: []
user:
description:
- username
required: true
default: null
aliases: []
password:
description:
- password
required: true
default: null
aliases: []
action:
description:
- the action you want to perform on the entity
required: false
default: disable
choices: ["enable", "disable"]
aliases: []
name:
description:
- name of the entity
required: true
default: hostname
aliases: []
type:
description:
- type of the entity
required: false
default: server
choices: ["server", "service"]
aliases: []
validate_certs:
description:
- If C(no), SSL certificates for the target url will not be validated. This should only be used
on personally controlled sites using self-signed certificates.
required: false
default: 'yes'
choices: ['yes', 'no']
requirements: [ "urllib", "urllib2" ]
author: Nandor Sivok
'''
EXAMPLES = '''
# Disable the server
ansible host -m netscaler -a "nsc_host=nsc.example.com user=apiuser password=apipass"
# Enable the server
ansible host -m netscaler -a "nsc_host=nsc.example.com user=apiuser password=apipass action=enable"
# Disable the service local:8080
ansible host -m netscaler -a "nsc_host=nsc.example.com user=apiuser password=apipass name=local:8080 type=service action=disable"
'''
import base64
import socket
class netscaler(object):
_nitro_base_url = '/nitro/v1/'
def __init__(self, module):
self.module = module
def http_request(self, api_endpoint, data_json={}):
request_url = self._nsc_protocol + '://' + self._nsc_host + self._nitro_base_url + api_endpoint
data_json = urllib.urlencode(data_json)
if not len(data_json):
data_json = None
auth = base64.encodestring('%s:%s' % (self._nsc_user, self._nsc_pass)).replace('\n', '').strip()
headers = {
'Authorization': 'Basic %s' % auth,
'Content-Type' : 'application/x-www-form-urlencoded',
}
response, info = fetch_url(self.module, request_url, data=data_json, headers=headers)
return json.load(response)
def prepare_request(self, action):
resp = self.http_request(
'config',
{
"object":
{
"params": {"action": action},
self._type: {"name": self._name}
}
}
)
return resp
def core(module):
n = netscaler(module)
n._nsc_host = module.params.get('nsc_host')
n._nsc_user = module.params.get('user')
n._nsc_pass = module.params.get('password')
n._nsc_protocol = module.params.get('nsc_protocol')
n._name = module.params.get('name')
n._type = module.params.get('type')
action = module.params.get('action')
r = n.prepare_request(action)
return r['errorcode'], r
def main():
module = AnsibleModule(
argument_spec = dict(
nsc_host = dict(required=True),
nsc_protocol = dict(default='https'),
user = dict(required=True),
password = dict(required=True),
action = dict(default='enable', choices=['enable','disable']),
name = dict(default=socket.gethostname()),
type = dict(default='server', choices=['service', 'server']),
validate_certs=dict(default='yes', type='bool'),
)
)
rc = 0
try:
rc, result = core(module)
except Exception, e:
module.fail_json(msg=str(e))
if rc != 0:
module.fail_json(rc=rc, msg=result)
else:
result['changed'] = True
module.exit_json(**result)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.urls import *
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
10047,
859,
370,
9635,
445,
390,
1904,
5365,
24274,
9045,
199,
8,
67,
9,
6171,
12,
653,
460,
269,
428,
1003,
745,
665,
78,
460,
269,
32,
5294,
87,
2570,
14,
957,
30,
199,
199,
2765,
570,
365,
1777,
402,
2622,
199,
199,
10047,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
390,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
1589,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
8,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
199,
10047,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
7911,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
31461,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
17732,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
199,
5556,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
21632,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
624,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
26067,
199,
1023,
63,
3270,
26,
298,
17,
14,
17,
2,
199,
3612,
63,
1802,
26,
21612,
445,
390,
1904,
5365,
24274,
9045,
199,
1802,
26,
1362,
446,
21612,
445,
390,
1904,
5365,
24274,
1654,
436,
2435,
9045,
14,
199,
1419,
26,
523,
302,
551,
63,
1102,
26,
272,
1369,
26,
489,
446,
6246,
503,
3384,
402,
2195,
26067,
272,
1415,
26,
2549,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
302,
551,
63,
3922,
26,
272,
1369,
26,
489,
446,
4113,
1202,
370,
2879,
26067,
272,
1415,
26,
3055,
272,
849,
26,
4178,
272,
5481,
26,
942,
523,
922,
26,
272,
1369,
26,
489,
446,
3434,
272,
1415,
26,
2549,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
2505,
26,
272,
1369,
26,
489,
446,
2505,
272,
1415,
26,
2549,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
1595,
26,
272,
1369,
26,
489,
446,
314,
1595,
1265,
2934,
370,
5147,
641,
314,
4642,
272,
1415,
26,
3055,
272,
849,
26,
3507,
272,
3415,
26,
2097,
4296,
401,
298,
5993,
937,
272,
5481,
26,
942,
523,
536,
26,
272,
1369,
26,
489,
446,
536,
402,
314,
4642,
272,
1415,
26,
2549,
272,
849,
26,
6246,
272,
5481,
26,
942,
523,
730,
26,
272,
1369,
26,
489,
446,
730,
402,
314,
4642,
272,
1415,
26,
3055,
272,
849,
26,
1654,
272,
3415,
26,
2097,
1000,
401,
298,
1364,
937,
272,
5481,
26,
942,
523,
4107,
63,
8356,
26,
272,
1369,
26,
489,
446,
982,
445,
8,
889,
395,
7799,
14512,
367,
314,
1347,
1166,
911,
440,
506,
16468,
14,
961,
1077,
1454,
506,
1202,
267,
641,
4954,
1183,
22284,
15424,
1808,
291,
13,
1737,
14512,
14,
272,
1415,
26,
3055,
272,
849,
26,
283,
5066,
7,
272,
3415,
26,
788,
5066,
297,
283,
889,
418,
199,
199,
7538,
26,
359,
298,
4078,
401,
298,
4078,
18,
2,
1622,
199,
2502,
26,
653,
460,
269,
428,
1003,
745,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
17534,
314,
1654,
199,
4853,
1591,
446,
77,
26067,
446,
65,
298,
78,
551,
63,
1102,
29,
78,
551,
14,
2694,
14,
957,
922,
29,
1246,
751,
2505,
29,
439,
711,
405,
2,
199,
199,
3,
12030,
314,
1654,
199,
4853,
1591,
446,
77,
26067,
446,
65,
298,
78,
551,
63,
1102,
29,
78,
551,
14,
2694,
14,
957,
922,
29,
1246,
751,
2505,
29,
439,
711,
405,
1595,
29,
4296,
2,
199,
199,
3,
17534,
314,
2435,
2257,
26,
15844,
199,
4853,
1591,
446,
77,
26067,
446,
65,
298,
78,
551,
63,
1102,
29,
78,
551,
14,
2694,
14,
957,
922,
29,
1246,
751,
2505,
29,
439,
711,
405,
536,
29,
1832,
26,
15844,
730,
29,
1364,
1595,
29,
5993,
2,
199,
2344,
421,
199,
646,
1300,
772,
199,
646,
2838,
421,
199,
533,
26067,
8,
785,
304,
339,
485,
18893,
63,
1095,
63,
633,
275,
1994,
18893,
15,
86,
17,
4805,
339,
347,
636,
826,
721,
277,
12,
859,
304,
267,
291,
14,
578,
275,
859,
339,
347,
1455,
63,
1069,
8,
277,
12,
2986,
63,
6520,
12,
666,
63,
1001,
16420,
267,
1056,
63,
633,
275,
291,
423,
78,
551,
63,
3922,
435,
283,
22399,
435,
291,
423,
78,
551,
63,
1102,
435,
291,
423,
18893,
63,
1095,
63,
633,
435,
2986,
63,
6520,
398,
666,
63,
1001,
275,
4011,
14,
10738,
8,
576,
63,
1001,
9,
267,
340,
440,
822,
8,
576,
63,
1001,
304,
288,
666,
63,
1001,
275,
488,
398,
1790,
275,
1300,
772,
14,
2143,
875,
3508,
83,
2689,
83,
7,
450,
334,
277,
423,
78,
551,
63,
751,
12,
291,
423,
78,
551,
63,
1529,
4992,
1814,
2258,
78,
297,
12548,
1913,
342,
267,
2323,
275,
469,
288,
283,
11626,
356,
283,
6845,
450,
83,
7,
450,
1790,
12,
288,
283,
2714,
13,
804,
7,
520,
283,
3578,
15,
88,
13,
1544,
13,
964,
13,
21886,
297,
267,
789,
398,
1177,
12,
2256,
275,
5267,
63,
633,
8,
277,
14,
578,
12,
1056,
63,
633,
12,
666,
29,
576,
63,
1001,
12,
2323,
29,
2139,
9,
398,
372,
2022,
14,
912,
8,
1310,
9,
339,
347,
9275,
63,
1069,
8,
277,
12,
1595,
304,
267,
3085,
275,
291,
14,
1014,
63,
1069,
8,
288,
283,
888,
297,
288,
469,
355,
298,
785,
582,
355,
469,
490,
298,
1162,
582,
2420,
1287,
582,
1595,
1386,
490,
291,
423,
466,
26,
2420,
354,
582,
291,
423,
354,
93,
355,
789,
288,
789,
267,
776,
398,
372,
3085,
421,
199,
318,
6170,
8,
578,
304,
272,
302,
275,
26067,
8,
578,
9,
272,
302,
423,
78,
551,
63,
1102,
275,
859,
14,
1162,
14,
362,
360,
78,
551,
63,
1102,
358,
272,
302,
423,
78,
551,
63,
751,
275,
859,
14,
1162,
14,
362,
360,
751,
358,
272,
302,
423,
78,
551,
63,
1529,
275,
859,
14,
1162,
14,
362,
360,
2060,
358,
272,
302,
423,
78,
551,
63,
3922,
275,
859,
14
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
10047,
859,
370,
9635,
445,
390,
1904,
5365,
24274,
9045,
199,
8,
67,
9,
6171,
12,
653,
460,
269,
428,
1003,
745,
665,
78,
460,
269,
32,
5294,
87,
2570,
14,
957,
30,
199,
199,
2765,
570,
365,
1777,
402,
2622,
199,
199,
10047,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
390,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
1589,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
8,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
199,
10047,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
7911,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
31461,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
17732,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
199,
5556,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
21632,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
624,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
26067,
199,
1023,
63,
3270,
26,
298,
17,
14,
17,
2,
199,
3612,
63,
1802,
26,
21612,
445,
390,
1904,
5365,
24274,
9045,
199,
1802,
26,
1362,
446,
21612,
445,
390,
1904,
5365,
24274,
1654,
436,
2435,
9045,
14,
199,
1419,
26,
523,
302,
551,
63,
1102,
26,
272,
1369,
26,
489,
446,
6246,
503,
3384,
402,
2195,
26067,
272,
1415,
26,
2549,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
302,
551,
63,
3922,
26,
272,
1369,
26,
489,
446,
4113,
1202,
370,
2879,
26067,
272,
1415,
26,
3055,
272,
849,
26,
4178,
272,
5481,
26,
942,
523,
922,
26,
272,
1369,
26,
489,
446,
3434,
272,
1415,
26,
2549,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
2505,
26,
272,
1369,
26,
489,
446,
2505,
272,
1415,
26,
2549,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
1595,
26,
272,
1369,
26,
489,
446,
314,
1595,
1265,
2934,
370,
5147,
641,
314,
4642,
272,
1415,
26,
3055,
272,
849,
26,
3507,
272,
3415,
26,
2097,
4296,
401,
298,
5993,
937,
272,
5481,
26,
942,
523,
536,
26,
272,
1369,
26,
489,
446,
536,
402,
314,
4642,
272,
1415,
26,
2549,
272,
849,
26,
6246,
272,
5481,
26,
942,
523,
730,
26,
272,
1369,
26,
489,
446,
730,
402,
314,
4642,
272,
1415,
26,
3055,
272,
849,
26,
1654,
272,
3415,
26,
2097,
1000,
401,
298,
1364,
937,
272,
5481,
26,
942,
523,
4107,
63,
8356,
26,
272,
1369,
26,
489,
446,
982,
445,
8,
889,
395,
7799,
14512,
367,
314,
1347,
1166,
911,
440,
506,
16468,
14,
961,
1077,
1454,
506,
1202,
267,
641,
4954,
1183,
22284,
15424,
1808,
291,
13,
1737,
14512,
14,
272,
1415,
26,
3055,
272,
849,
26,
283,
5066,
7,
272,
3415,
26,
788,
5066,
297,
283,
889,
418,
199,
199,
7538,
26,
359,
298,
4078,
401,
298,
4078,
18,
2,
1622,
199,
2502,
26,
653,
460,
269,
428,
1003,
745,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
17534,
314,
1654,
199,
4853,
1591,
446,
77,
26067,
446,
65,
298,
78,
551,
63,
1102,
29,
78,
551,
14,
2694,
14,
957,
922,
29,
1246,
751,
2505,
29,
439,
711,
405,
2,
199,
199,
3,
12030,
314,
1654,
199,
4853,
1591,
446,
77,
26067,
446,
65,
298,
78,
551,
63,
1102,
29,
78,
551,
14,
2694,
14,
957,
922,
29,
1246,
751,
2505,
29,
439,
711,
405,
1595,
29,
4296,
2,
199,
199,
3,
17534,
314,
2435,
2257,
26,
15844,
199,
4853,
1591,
446,
77,
26067,
446,
65,
298,
78,
551,
63,
1102,
29,
78,
551,
14,
2694,
14,
957,
922,
29,
1246,
751,
2505,
29,
439,
711,
405,
536,
29,
1832,
26,
15844,
730,
29,
1364,
1595,
29,
5993,
2,
199,
2344,
421,
199,
646,
1300,
772,
199,
646,
2838,
421,
199,
533,
26067,
8,
785,
304,
339,
485,
18893,
63,
1095,
63,
633,
275,
1994,
18893,
15,
86,
17,
4805,
339,
347,
636,
826,
721,
277,
12,
859,
304,
267,
291,
14,
578,
275,
859,
339,
347,
1455,
63,
1069,
8,
277,
12,
2986,
63,
6520,
12,
666,
63,
1001,
16420,
267,
1056,
63,
633,
275,
291,
423,
78,
551,
63,
3922,
435,
283,
22399,
435,
291,
423,
78,
551,
63,
1102,
435,
291,
423,
18893,
63,
1095,
63,
633,
435,
2986,
63,
6520,
398,
666,
63,
1001,
275,
4011,
14,
10738,
8,
576,
63,
1001,
9,
267,
340,
440,
822,
8,
576,
63,
1001,
304,
288,
666,
63,
1001,
275,
488,
398,
1790,
275,
1300,
772,
14,
2143,
875,
3508,
83,
2689,
83,
7,
450,
334,
277,
423,
78,
551,
63,
751,
12,
291,
423,
78,
551,
63,
1529,
4992,
1814,
2258,
78,
297,
12548,
1913,
342,
267,
2323,
275,
469,
288,
283,
11626,
356,
283,
6845,
450,
83,
7,
450,
1790,
12,
288,
283,
2714,
13,
804,
7,
520,
283,
3578,
15,
88,
13,
1544,
13,
964,
13,
21886,
297,
267,
789,
398,
1177,
12,
2256,
275,
5267,
63,
633,
8,
277,
14,
578,
12,
1056,
63,
633,
12,
666,
29,
576,
63,
1001,
12,
2323,
29,
2139,
9,
398,
372,
2022,
14,
912,
8,
1310,
9,
339,
347,
9275,
63,
1069,
8,
277,
12,
1595,
304,
267,
3085,
275,
291,
14,
1014,
63,
1069,
8,
288,
283,
888,
297,
288,
469,
355,
298,
785,
582,
355,
469,
490,
298,
1162,
582,
2420,
1287,
582,
1595,
1386,
490,
291,
423,
466,
26,
2420,
354,
582,
291,
423,
354,
93,
355,
789,
288,
789,
267,
776,
398,
372,
3085,
421,
199,
318,
6170,
8,
578,
304,
272,
302,
275,
26067,
8,
578,
9,
272,
302,
423,
78,
551,
63,
1102,
275,
859,
14,
1162,
14,
362,
360,
78,
551,
63,
1102,
358,
272,
302,
423,
78,
551,
63,
751,
275,
859,
14,
1162,
14,
362,
360,
751,
358,
272,
302,
423,
78,
551,
63,
1529,
275,
859,
14,
1162,
14,
362,
360,
2060,
358,
272,
302,
423,
78,
551,
63,
3922,
275,
859,
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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django.core.exceptions import ImproperlyConfigured
from django.db.backends.sqlite3.base import (
Database, DatabaseWrapper as SQLiteDatabaseWrapper, SQLiteCursorWrapper,
)
from django.utils import six
from .client import SpatiaLiteClient
from .features import DatabaseFeatures
from .introspection import SpatiaLiteIntrospection
from .operations import SpatiaLiteOperations
from .schema import SpatialiteSchemaEditor
class DatabaseWrapper(SQLiteDatabaseWrapper):
SchemaEditorClass = SpatialiteSchemaEditor
# Classes instantiated in __init__().
client_class = SpatiaLiteClient
features_class = DatabaseFeatures
introspection_class = SpatiaLiteIntrospection
ops_class = SpatiaLiteOperations
def __init__(self, *args, **kwargs):
# Before we get too far, make sure pysqlite 2.5+ is installed.
if Database.version_info < (2, 5, 0):
raise ImproperlyConfigured('Only versions of pysqlite 2.5+ are '
'compatible with SpatiaLite and GeoDjango.')
# Trying to find the location of the SpatiaLite library.
# Here we are figuring out the path to the SpatiaLite library
# (`libspatialite`). If it's not in the system library path (e.g., it
# cannot be found by `ctypes.util.find_library`), then it may be set
# manually in the settings via the `SPATIALITE_LIBRARY_PATH` setting.
self.spatialite_lib = getattr(settings, 'SPATIALITE_LIBRARY_PATH',
find_library('spatialite'))
if not self.spatialite_lib:
raise ImproperlyConfigured('Unable to locate the SpatiaLite library. '
'Make sure it is in your library path, or set '
'SPATIALITE_LIBRARY_PATH in your settings.'
)
super(DatabaseWrapper, self).__init__(*args, **kwargs)
def get_new_connection(self, conn_params):
conn = super(DatabaseWrapper, self).get_new_connection(conn_params)
# Enabling extension loading on the SQLite connection.
try:
conn.enable_load_extension(True)
except AttributeError:
raise ImproperlyConfigured(
'The pysqlite library does not support C extension loading. '
'Both SQLite and pysqlite must be configured to allow '
'the loading of extensions to use SpatiaLite.')
# Loading the SpatiaLite library extension on the connection, and returning
# the created cursor.
cur = conn.cursor(factory=SQLiteCursorWrapper)
try:
cur.execute("SELECT load_extension(%s)", (self.spatialite_lib,))
except Exception as msg:
new_msg = (
'Unable to load the SpatiaLite library extension '
'"%s" because: %s') % (self.spatialite_lib, msg)
six.reraise(ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2])
cur.close()
return conn
def prepare_database(self):
super(DatabaseWrapper, self).prepare_database()
# Check if spatial metadata have been initialized in the database
with self.cursor() as cursor:
cursor.execute("PRAGMA table_info(geometry_columns);")
if cursor.fetchall() == []:
arg = "1" if self.features.supports_initspatialmetadata_in_one_transaction else ""
cursor.execute("SELECT InitSpatialMetaData(%s)" % arg)
|
bsd-3-clause
|
[
646,
984,
199,
504,
5577,
14,
1974,
492,
2342,
63,
4342,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
697,
14,
7765,
14,
10659,
19,
14,
1095,
492,
334,
272,
8692,
12,
8692,
4590,
465,
19245,
7243,
4590,
12,
19245,
8993,
4590,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
3816,
199,
199,
504,
1275,
1258,
492,
25177,
3041,
199,
504,
1275,
3179,
492,
8692,
10807,
199,
504,
1275,
21627,
492,
25177,
30516,
199,
504,
1275,
8170,
492,
25177,
12929,
199,
504,
1275,
3629,
492,
13423,
1175,
6700,
10423,
421,
199,
533,
8692,
4590,
8,
4657,
1175,
7243,
4590,
304,
272,
13268,
10423,
2543,
275,
13423,
1175,
6700,
10423,
272,
327,
27939,
17544,
315,
636,
826,
31261,
272,
1890,
63,
533,
275,
25177,
3041,
272,
4534,
63,
533,
275,
8692,
10807,
272,
1109,
14254,
63,
533,
275,
25177,
30516,
272,
4156,
63,
533,
275,
25177,
12929,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
327,
21467,
781,
664,
4634,
12474,
12,
1852,
3238,
10382,
29498,
499,
14,
21,
11,
365,
4903,
14,
267,
340,
8692,
14,
1023,
63,
815,
665,
334,
18,
12,
959,
12,
378,
304,
288,
746,
11897,
360,
5903,
5459,
402,
10382,
29498,
499,
14,
21,
11,
787,
283,
4318,
283,
6490,
543,
25177,
436,
8875,
9323,
2659,
398,
327,
7649,
316,
370,
2342,
314,
2909,
402,
314,
25177,
3555,
14,
267,
327,
11842,
781,
787,
6085,
4039,
734,
314,
931,
370,
314,
25177,
3555,
267,
327,
13493,
773,
25873,
14963,
982,
652,
1159,
440,
315,
314,
2656,
3555,
931,
334,
69,
14,
71,
2020,
652,
267,
327,
3913,
506,
1911,
701,
658,
9798,
14,
1974,
14,
1623,
63,
4342,
29984,
2066,
652,
1443,
506,
663,
267,
327,
10250,
315,
314,
2202,
4799,
314,
658,
51,
2805,
4938,
4427,
63,
16983,
63,
3243,
64,
4260,
14,
267,
291,
14,
25873,
63,
773,
275,
2519,
8,
1751,
12,
283,
51,
2805,
4938,
4427,
63,
16983,
63,
3243,
297,
4228,
2342,
63,
4342,
360,
25873,
1333,
267,
340,
440,
291,
14,
25873,
63,
773,
26,
288,
746,
11897,
360,
6005,
370,
16592,
314,
25177,
3555,
14,
283,
4318,
283,
5483,
3238,
652,
365,
315,
2195,
3555,
931,
12,
503,
663,
283,
4318,
283,
51,
2805,
4938,
4427,
63,
16983,
63,
3243,
315,
2195,
2202,
3530,
4318,
776,
267,
1613,
8,
7243,
4590,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
664,
63,
1222,
63,
2105,
8,
277,
12,
2557,
63,
1162,
304,
267,
2557,
275,
1613,
8,
7243,
4590,
12,
291,
680,
362,
63,
1222,
63,
2105,
8,
1631,
63,
1162,
9,
267,
327,
3447,
14744,
3329,
8697,
641,
314,
19245,
1950,
14,
267,
862,
26,
288,
2557,
14,
4296,
63,
912,
63,
3435,
8,
549,
9,
267,
871,
4281,
26,
288,
746,
11897,
8,
355,
283,
1918,
10382,
29498,
3555,
1630,
440,
2291,
445,
3329,
8697,
14,
283,
355,
283,
18088,
19245,
436,
10382,
29498,
1471,
506,
7526,
370,
2040,
283,
355,
283,
1589,
8697,
402,
5478,
370,
675,
25177,
2659,
267,
327,
3835,
5384,
314,
25177,
3555,
3329,
641,
314,
1950,
12,
436,
8152,
267,
327,
314,
2737,
3920,
14,
267,
1094,
275,
2557,
14,
3937,
8,
3702,
29,
4657,
1175,
8993,
4590,
9,
267,
862,
26,
288,
1094,
14,
2526,
480,
4859,
2248,
63,
3435,
4042,
83,
4186,
334,
277,
14,
25873,
63,
773,
4641,
267,
871,
2186,
465,
1499,
26,
288,
892,
63,
1328,
275,
334,
355,
283,
6005,
370,
2248,
314,
25177,
3555,
3329,
283,
355,
18253,
83,
2,
2952,
26,
450,
83,
358,
450,
334,
277,
14,
25873,
63,
773,
12,
1499,
9,
288,
3816,
14,
20614,
8,
8499,
10951,
12,
11897,
8,
1222,
63,
1328,
395,
984,
14,
2804,
63,
815,
3430,
18,
566,
267,
1094,
14,
1600,
342,
267,
372,
2557,
339,
347,
9275,
63,
4659,
8,
277,
304,
267,
1613,
8,
7243,
4590,
12,
291,
680,
6726,
63,
4659,
342,
267,
327,
2670,
340,
11469,
3341,
1172,
2757,
10038,
315,
314,
3050,
267,
543,
291,
14,
3937,
342,
465,
3920,
26,
288,
3920,
14,
2526,
480,
3311,
1254,
2054,
1817,
63,
815,
8,
7660,
63,
3406,
2736,
531,
288,
340,
3920,
14,
10174,
342,
508,
18410,
355,
1680,
275,
298,
17,
2,
340,
291,
14,
3179,
14,
9823,
63,
826,
11679,
2343,
63,
262,
63,
368,
63,
5945,
587,
3087,
355,
3920,
14,
2526,
480,
4859,
21026,
18075,
25285,
4042,
83,
2924,
450,
1680,
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
] |
[
984,
199,
504,
5577,
14,
1974,
492,
2342,
63,
4342,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
697,
14,
7765,
14,
10659,
19,
14,
1095,
492,
334,
272,
8692,
12,
8692,
4590,
465,
19245,
7243,
4590,
12,
19245,
8993,
4590,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
3816,
199,
199,
504,
1275,
1258,
492,
25177,
3041,
199,
504,
1275,
3179,
492,
8692,
10807,
199,
504,
1275,
21627,
492,
25177,
30516,
199,
504,
1275,
8170,
492,
25177,
12929,
199,
504,
1275,
3629,
492,
13423,
1175,
6700,
10423,
421,
199,
533,
8692,
4590,
8,
4657,
1175,
7243,
4590,
304,
272,
13268,
10423,
2543,
275,
13423,
1175,
6700,
10423,
272,
327,
27939,
17544,
315,
636,
826,
31261,
272,
1890,
63,
533,
275,
25177,
3041,
272,
4534,
63,
533,
275,
8692,
10807,
272,
1109,
14254,
63,
533,
275,
25177,
30516,
272,
4156,
63,
533,
275,
25177,
12929,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
327,
21467,
781,
664,
4634,
12474,
12,
1852,
3238,
10382,
29498,
499,
14,
21,
11,
365,
4903,
14,
267,
340,
8692,
14,
1023,
63,
815,
665,
334,
18,
12,
959,
12,
378,
304,
288,
746,
11897,
360,
5903,
5459,
402,
10382,
29498,
499,
14,
21,
11,
787,
283,
4318,
283,
6490,
543,
25177,
436,
8875,
9323,
2659,
398,
327,
7649,
316,
370,
2342,
314,
2909,
402,
314,
25177,
3555,
14,
267,
327,
11842,
781,
787,
6085,
4039,
734,
314,
931,
370,
314,
25177,
3555,
267,
327,
13493,
773,
25873,
14963,
982,
652,
1159,
440,
315,
314,
2656,
3555,
931,
334,
69,
14,
71,
2020,
652,
267,
327,
3913,
506,
1911,
701,
658,
9798,
14,
1974,
14,
1623,
63,
4342,
29984,
2066,
652,
1443,
506,
663,
267,
327,
10250,
315,
314,
2202,
4799,
314,
658,
51,
2805,
4938,
4427,
63,
16983,
63,
3243,
64,
4260,
14,
267,
291,
14,
25873,
63,
773,
275,
2519,
8,
1751,
12,
283,
51,
2805,
4938,
4427,
63,
16983,
63,
3243,
297,
4228,
2342,
63,
4342,
360,
25873,
1333,
267,
340,
440,
291,
14,
25873,
63,
773,
26,
288,
746,
11897,
360,
6005,
370,
16592,
314,
25177,
3555,
14,
283,
4318,
283,
5483,
3238,
652,
365,
315,
2195,
3555,
931,
12,
503,
663,
283,
4318,
283,
51,
2805,
4938,
4427,
63,
16983,
63,
3243,
315,
2195,
2202,
3530,
4318,
776,
267,
1613,
8,
7243,
4590,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
664,
63,
1222,
63,
2105,
8,
277,
12,
2557,
63,
1162,
304,
267,
2557,
275,
1613,
8,
7243,
4590,
12,
291,
680,
362,
63,
1222,
63,
2105,
8,
1631,
63,
1162,
9,
267,
327,
3447,
14744,
3329,
8697,
641,
314,
19245,
1950,
14,
267,
862,
26,
288,
2557,
14,
4296,
63,
912,
63,
3435,
8,
549,
9,
267,
871,
4281,
26,
288,
746,
11897,
8,
355,
283,
1918,
10382,
29498,
3555,
1630,
440,
2291,
445,
3329,
8697,
14,
283,
355,
283,
18088,
19245,
436,
10382,
29498,
1471,
506,
7526,
370,
2040,
283,
355,
283,
1589,
8697,
402,
5478,
370,
675,
25177,
2659,
267,
327,
3835,
5384,
314,
25177,
3555,
3329,
641,
314,
1950,
12,
436,
8152,
267,
327,
314,
2737,
3920,
14,
267,
1094,
275,
2557,
14,
3937,
8,
3702,
29,
4657,
1175,
8993,
4590,
9,
267,
862,
26,
288,
1094,
14,
2526,
480,
4859,
2248,
63,
3435,
4042,
83,
4186,
334,
277,
14,
25873,
63,
773,
4641,
267,
871,
2186,
465,
1499,
26,
288,
892,
63,
1328,
275,
334,
355,
283,
6005,
370,
2248,
314,
25177,
3555,
3329,
283,
355,
18253,
83,
2,
2952,
26,
450,
83,
358,
450,
334,
277,
14,
25873,
63,
773,
12,
1499,
9,
288,
3816,
14,
20614,
8,
8499,
10951,
12,
11897,
8,
1222,
63,
1328,
395,
984,
14,
2804,
63,
815,
3430,
18,
566,
267,
1094,
14,
1600,
342,
267,
372,
2557,
339,
347,
9275,
63,
4659,
8,
277,
304,
267,
1613,
8,
7243,
4590,
12,
291,
680,
6726,
63,
4659,
342,
267,
327,
2670,
340,
11469,
3341,
1172,
2757,
10038,
315,
314,
3050,
267,
543,
291,
14,
3937,
342,
465,
3920,
26,
288,
3920,
14,
2526,
480,
3311,
1254,
2054,
1817,
63,
815,
8,
7660,
63,
3406,
2736,
531,
288,
340,
3920,
14,
10174,
342,
508,
18410,
355,
1680,
275,
298,
17,
2,
340,
291,
14,
3179,
14,
9823,
63,
826,
11679,
2343,
63,
262,
63,
368,
63,
5945,
587,
3087,
355,
3920,
14,
2526,
480,
4859,
21026,
18075,
25285,
4042,
83,
2924,
450,
1680,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
keyurpatel076/MissionPlannerGit
|
packages/IronPython.StdLib.2.7.4/content/Lib/encodings/mac_centeuro.py
|
593
|
14358
|
""" Python Character Mapping Codec mac_centeuro generated from 'MAPPINGS/VENDORS/APPLE/CENTEURO.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-centeuro',
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'\u0100' # 0x81 -> LATIN CAPITAL LETTER A WITH MACRON
u'\u0101' # 0x82 -> LATIN SMALL LETTER A WITH MACRON
u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
u'\u0104' # 0x84 -> LATIN CAPITAL LETTER A WITH OGONEK
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'\u0105' # 0x88 -> LATIN SMALL LETTER A WITH OGONEK
u'\u010c' # 0x89 -> LATIN CAPITAL LETTER C WITH CARON
u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
u'\u010d' # 0x8B -> LATIN SMALL LETTER C WITH CARON
u'\u0106' # 0x8C -> LATIN CAPITAL LETTER C WITH ACUTE
u'\u0107' # 0x8D -> LATIN SMALL LETTER C WITH ACUTE
u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
u'\u0179' # 0x8F -> LATIN CAPITAL LETTER Z WITH ACUTE
u'\u017a' # 0x90 -> LATIN SMALL LETTER Z WITH ACUTE
u'\u010e' # 0x91 -> LATIN CAPITAL LETTER D WITH CARON
u'\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
u'\u010f' # 0x93 -> LATIN SMALL LETTER D WITH CARON
u'\u0112' # 0x94 -> LATIN CAPITAL LETTER E WITH MACRON
u'\u0113' # 0x95 -> LATIN SMALL LETTER E WITH MACRON
u'\u0116' # 0x96 -> LATIN CAPITAL LETTER E WITH DOT ABOVE
u'\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
u'\u0117' # 0x98 -> LATIN SMALL LETTER E WITH DOT ABOVE
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'\u011a' # 0x9D -> LATIN CAPITAL LETTER E WITH CARON
u'\u011b' # 0x9E -> LATIN SMALL LETTER E WITH CARON
u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
u'\u2020' # 0xA0 -> DAGGER
u'\xb0' # 0xA1 -> DEGREE SIGN
u'\u0118' # 0xA2 -> LATIN CAPITAL LETTER E WITH OGONEK
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'\u0119' # 0xAB -> LATIN SMALL LETTER E WITH OGONEK
u'\xa8' # 0xAC -> DIAERESIS
u'\u2260' # 0xAD -> NOT EQUAL TO
u'\u0123' # 0xAE -> LATIN SMALL LETTER G WITH CEDILLA
u'\u012e' # 0xAF -> LATIN CAPITAL LETTER I WITH OGONEK
u'\u012f' # 0xB0 -> LATIN SMALL LETTER I WITH OGONEK
u'\u012a' # 0xB1 -> LATIN CAPITAL LETTER I WITH MACRON
u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
u'\u012b' # 0xB4 -> LATIN SMALL LETTER I WITH MACRON
u'\u0136' # 0xB5 -> LATIN CAPITAL LETTER K WITH CEDILLA
u'\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
u'\u2211' # 0xB7 -> N-ARY SUMMATION
u'\u0142' # 0xB8 -> LATIN SMALL LETTER L WITH STROKE
u'\u013b' # 0xB9 -> LATIN CAPITAL LETTER L WITH CEDILLA
u'\u013c' # 0xBA -> LATIN SMALL LETTER L WITH CEDILLA
u'\u013d' # 0xBB -> LATIN CAPITAL LETTER L WITH CARON
u'\u013e' # 0xBC -> LATIN SMALL LETTER L WITH CARON
u'\u0139' # 0xBD -> LATIN CAPITAL LETTER L WITH ACUTE
u'\u013a' # 0xBE -> LATIN SMALL LETTER L WITH ACUTE
u'\u0145' # 0xBF -> LATIN CAPITAL LETTER N WITH CEDILLA
u'\u0146' # 0xC0 -> LATIN SMALL LETTER N WITH CEDILLA
u'\u0143' # 0xC1 -> LATIN CAPITAL LETTER N WITH ACUTE
u'\xac' # 0xC2 -> NOT SIGN
u'\u221a' # 0xC3 -> SQUARE ROOT
u'\u0144' # 0xC4 -> LATIN SMALL LETTER N WITH ACUTE
u'\u0147' # 0xC5 -> LATIN CAPITAL LETTER N WITH CARON
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'\u0148' # 0xCB -> LATIN SMALL LETTER N WITH CARON
u'\u0150' # 0xCC -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
u'\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
u'\u0151' # 0xCE -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
u'\u014c' # 0xCF -> LATIN CAPITAL LETTER O WITH MACRON
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'\u014d' # 0xD8 -> LATIN SMALL LETTER O WITH MACRON
u'\u0154' # 0xD9 -> LATIN CAPITAL LETTER R WITH ACUTE
u'\u0155' # 0xDA -> LATIN SMALL LETTER R WITH ACUTE
u'\u0158' # 0xDB -> LATIN CAPITAL LETTER R WITH CARON
u'\u2039' # 0xDC -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
u'\u203a' # 0xDD -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
u'\u0159' # 0xDE -> LATIN SMALL LETTER R WITH CARON
u'\u0156' # 0xDF -> LATIN CAPITAL LETTER R WITH CEDILLA
u'\u0157' # 0xE0 -> LATIN SMALL LETTER R WITH CEDILLA
u'\u0160' # 0xE1 -> LATIN CAPITAL LETTER S WITH CARON
u'\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
u'\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
u'\u0161' # 0xE4 -> LATIN SMALL LETTER S WITH CARON
u'\u015a' # 0xE5 -> LATIN CAPITAL LETTER S WITH ACUTE
u'\u015b' # 0xE6 -> LATIN SMALL LETTER S WITH ACUTE
u'\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
u'\u0164' # 0xE8 -> LATIN CAPITAL LETTER T WITH CARON
u'\u0165' # 0xE9 -> LATIN SMALL LETTER T WITH CARON
u'\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
u'\u017d' # 0xEB -> LATIN CAPITAL LETTER Z WITH CARON
u'\u017e' # 0xEC -> LATIN SMALL LETTER Z WITH CARON
u'\u016a' # 0xED -> LATIN CAPITAL LETTER U WITH MACRON
u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
u'\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
u'\u016b' # 0xF0 -> LATIN SMALL LETTER U WITH MACRON
u'\u016e' # 0xF1 -> LATIN CAPITAL LETTER U WITH RING ABOVE
u'\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
u'\u016f' # 0xF3 -> LATIN SMALL LETTER U WITH RING ABOVE
u'\u0170' # 0xF4 -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
u'\u0171' # 0xF5 -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
u'\u0172' # 0xF6 -> LATIN CAPITAL LETTER U WITH OGONEK
u'\u0173' # 0xF7 -> LATIN SMALL LETTER U WITH OGONEK
u'\xdd' # 0xF8 -> LATIN CAPITAL LETTER Y WITH ACUTE
u'\xfd' # 0xF9 -> LATIN SMALL LETTER Y WITH ACUTE
u'\u0137' # 0xFA -> LATIN SMALL LETTER K WITH CEDILLA
u'\u017b' # 0xFB -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
u'\u0141' # 0xFC -> LATIN CAPITAL LETTER L WITH STROKE
u'\u017c' # 0xFD -> LATIN SMALL LETTER Z WITH DOT ABOVE
u'\u0122' # 0xFE -> LATIN CAPITAL LETTER G WITH CEDILLA
u'\u02c7' # 0xFF -> CARON
)
### Encoding table
encoding_table=codecs.charmap_build(decoding_table)
|
gpl-3.0
|
[
624,
2018,
17660,
12340,
13732,
4497,
63,
2497,
266,
9129,
4046,
687,
283,
32362,
15,
27839,
4149,
15,
31683,
15,
17349,
23539,
1092,
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,
2497,
266,
9129,
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
] |
[
2018,
17660,
12340,
13732,
4497,
63,
2497,
266,
9129,
4046,
687,
283,
32362,
15,
27839,
4149,
15,
31683,
15,
17349,
23539,
1092,
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,
2497,
266,
9129,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
double-y/django
|
tests/gis_tests/gdal_tests/test_geom.py
|
256
|
20748
|
import json
import unittest
from binascii import b2a_hex
from unittest import skipUnless
from django.contrib.gis.gdal import HAS_GDAL
from django.utils.six.moves import range
from ..test_data import TestDataMixin
try:
from django.utils.six.moves import cPickle as pickle
except ImportError:
import pickle
if HAS_GDAL:
from django.contrib.gis.gdal import (OGRGeometry, OGRGeomType,
GDALException, OGRIndexError, SpatialReference, CoordTransform,
GDAL_VERSION)
@skipUnless(HAS_GDAL, "GDAL is required")
class OGRGeomTest(unittest.TestCase, TestDataMixin):
"This tests the OGR Geometry."
def test_geomtype(self):
"Testing OGRGeomType object."
# OGRGeomType should initialize on all these inputs.
OGRGeomType(1)
OGRGeomType(7)
OGRGeomType('point')
OGRGeomType('GeometrycollectioN')
OGRGeomType('LINearrING')
OGRGeomType('Unknown')
# Should throw TypeError on this input
self.assertRaises(GDALException, OGRGeomType, 23)
self.assertRaises(GDALException, OGRGeomType, 'fooD')
self.assertRaises(GDALException, OGRGeomType, 9)
# Equivalence can take strings, ints, and other OGRGeomTypes
self.assertEqual(OGRGeomType(1), OGRGeomType(1))
self.assertEqual(OGRGeomType(7), 'GeometryCollection')
self.assertEqual(OGRGeomType('point'), 'POINT')
self.assertNotEqual(OGRGeomType('point'), 2)
self.assertEqual(OGRGeomType('unknown'), 0)
self.assertEqual(OGRGeomType(6), 'MULtiPolyGON')
self.assertEqual(OGRGeomType(1), OGRGeomType('point'))
self.assertNotEqual(OGRGeomType('POINT'), OGRGeomType(6))
# Testing the Django field name equivalent property.
self.assertEqual('PointField', OGRGeomType('Point').django)
self.assertEqual('GeometryField', OGRGeomType('Geometry').django)
self.assertEqual('GeometryField', OGRGeomType('Unknown').django)
self.assertIsNone(OGRGeomType('none').django)
# 'Geometry' initialization implies an unknown geometry type.
gt = OGRGeomType('Geometry')
self.assertEqual(0, gt.num)
self.assertEqual('Unknown', gt.name)
def test_geomtype_25d(self):
"Testing OGRGeomType object with 25D types."
wkb25bit = OGRGeomType.wkb25bit
self.assertEqual(OGRGeomType(wkb25bit + 1), 'Point25D')
self.assertEqual(OGRGeomType('MultiLineString25D'), (5 + wkb25bit))
self.assertEqual('GeometryCollectionField', OGRGeomType('GeometryCollection25D').django)
def test_wkt(self):
"Testing WKT output."
for g in self.geometries.wkt_out:
geom = OGRGeometry(g.wkt)
self.assertEqual(g.wkt, geom.wkt)
def test_ewkt(self):
"Testing EWKT input/output."
for ewkt_val in ('POINT (1 2 3)', 'LINEARRING (0 0,1 1,2 1,0 0)'):
# First with ewkt output when no SRID in EWKT
self.assertEqual(ewkt_val, OGRGeometry(ewkt_val).ewkt)
# No test consumption with an SRID specified.
ewkt_val = 'SRID=4326;%s' % ewkt_val
geom = OGRGeometry(ewkt_val)
self.assertEqual(ewkt_val, geom.ewkt)
self.assertEqual(4326, geom.srs.srid)
def test_gml(self):
"Testing GML output."
for g in self.geometries.wkt_out:
geom = OGRGeometry(g.wkt)
exp_gml = g.gml
if GDAL_VERSION >= (1, 8):
# In GDAL 1.8, the non-conformant GML tag <gml:GeometryCollection> was
# replaced with <gml:MultiGeometry>.
exp_gml = exp_gml.replace('GeometryCollection', 'MultiGeometry')
self.assertEqual(exp_gml, geom.gml)
def test_hex(self):
"Testing HEX input/output."
for g in self.geometries.hex_wkt:
geom1 = OGRGeometry(g.wkt)
self.assertEqual(g.hex.encode(), geom1.hex)
# Constructing w/HEX
geom2 = OGRGeometry(g.hex)
self.assertEqual(geom1, geom2)
def test_wkb(self):
"Testing WKB input/output."
for g in self.geometries.hex_wkt:
geom1 = OGRGeometry(g.wkt)
wkb = geom1.wkb
self.assertEqual(b2a_hex(wkb).upper(), g.hex.encode())
# Constructing w/WKB.
geom2 = OGRGeometry(wkb)
self.assertEqual(geom1, geom2)
def test_json(self):
"Testing GeoJSON input/output."
for g in self.geometries.json_geoms:
geom = OGRGeometry(g.wkt)
if not hasattr(g, 'not_equal'):
# Loading jsons to prevent decimal differences
self.assertEqual(json.loads(g.json), json.loads(geom.json))
self.assertEqual(json.loads(g.json), json.loads(geom.geojson))
self.assertEqual(OGRGeometry(g.wkt), OGRGeometry(geom.json))
# Test input with some garbage content (but valid json) (#15529)
geom = OGRGeometry('{"type": "Point", "coordinates": [ 100.0, 0.0 ], "other": "<test>"}')
self.assertIsInstance(geom, OGRGeometry)
def test_points(self):
"Testing Point objects."
OGRGeometry('POINT(0 0)')
for p in self.geometries.points:
if not hasattr(p, 'z'): # No 3D
pnt = OGRGeometry(p.wkt)
self.assertEqual(1, pnt.geom_type)
self.assertEqual('POINT', pnt.geom_name)
self.assertEqual(p.x, pnt.x)
self.assertEqual(p.y, pnt.y)
self.assertEqual((p.x, p.y), pnt.tuple)
def test_multipoints(self):
"Testing MultiPoint objects."
for mp in self.geometries.multipoints:
mgeom1 = OGRGeometry(mp.wkt) # First one from WKT
self.assertEqual(4, mgeom1.geom_type)
self.assertEqual('MULTIPOINT', mgeom1.geom_name)
mgeom2 = OGRGeometry('MULTIPOINT') # Creating empty multipoint
mgeom3 = OGRGeometry('MULTIPOINT')
for g in mgeom1:
mgeom2.add(g) # adding each point from the multipoints
mgeom3.add(g.wkt) # should take WKT as well
self.assertEqual(mgeom1, mgeom2) # they should equal
self.assertEqual(mgeom1, mgeom3)
self.assertEqual(mp.coords, mgeom2.coords)
self.assertEqual(mp.n_p, mgeom2.point_count)
def test_linestring(self):
"Testing LineString objects."
prev = OGRGeometry('POINT(0 0)')
for ls in self.geometries.linestrings:
linestr = OGRGeometry(ls.wkt)
self.assertEqual(2, linestr.geom_type)
self.assertEqual('LINESTRING', linestr.geom_name)
self.assertEqual(ls.n_p, linestr.point_count)
self.assertEqual(ls.coords, linestr.tuple)
self.assertEqual(linestr, OGRGeometry(ls.wkt))
self.assertNotEqual(linestr, prev)
self.assertRaises(OGRIndexError, linestr.__getitem__, len(linestr))
prev = linestr
# Testing the x, y properties.
x = [tmpx for tmpx, tmpy in ls.coords]
y = [tmpy for tmpx, tmpy in ls.coords]
self.assertEqual(x, linestr.x)
self.assertEqual(y, linestr.y)
def test_multilinestring(self):
"Testing MultiLineString objects."
prev = OGRGeometry('POINT(0 0)')
for mls in self.geometries.multilinestrings:
mlinestr = OGRGeometry(mls.wkt)
self.assertEqual(5, mlinestr.geom_type)
self.assertEqual('MULTILINESTRING', mlinestr.geom_name)
self.assertEqual(mls.n_p, mlinestr.point_count)
self.assertEqual(mls.coords, mlinestr.tuple)
self.assertEqual(mlinestr, OGRGeometry(mls.wkt))
self.assertNotEqual(mlinestr, prev)
prev = mlinestr
for ls in mlinestr:
self.assertEqual(2, ls.geom_type)
self.assertEqual('LINESTRING', ls.geom_name)
self.assertRaises(OGRIndexError, mlinestr.__getitem__, len(mlinestr))
def test_linearring(self):
"Testing LinearRing objects."
prev = OGRGeometry('POINT(0 0)')
for rr in self.geometries.linearrings:
lr = OGRGeometry(rr.wkt)
# self.assertEqual(101, lr.geom_type.num)
self.assertEqual('LINEARRING', lr.geom_name)
self.assertEqual(rr.n_p, len(lr))
self.assertEqual(lr, OGRGeometry(rr.wkt))
self.assertNotEqual(lr, prev)
prev = lr
def test_polygons(self):
"Testing Polygon objects."
# Testing `from_bbox` class method
bbox = (-180, -90, 180, 90)
p = OGRGeometry.from_bbox(bbox)
self.assertEqual(bbox, p.extent)
prev = OGRGeometry('POINT(0 0)')
for p in self.geometries.polygons:
poly = OGRGeometry(p.wkt)
self.assertEqual(3, poly.geom_type)
self.assertEqual('POLYGON', poly.geom_name)
self.assertEqual(p.n_p, poly.point_count)
self.assertEqual(p.n_i + 1, len(poly))
# Testing area & centroid.
self.assertAlmostEqual(p.area, poly.area, 9)
x, y = poly.centroid.tuple
self.assertAlmostEqual(p.centroid[0], x, 9)
self.assertAlmostEqual(p.centroid[1], y, 9)
# Testing equivalence
self.assertEqual(poly, OGRGeometry(p.wkt))
self.assertNotEqual(poly, prev)
if p.ext_ring_cs:
ring = poly[0]
self.assertEqual(p.ext_ring_cs, ring.tuple)
self.assertEqual(p.ext_ring_cs, poly[0].tuple)
self.assertEqual(len(p.ext_ring_cs), ring.point_count)
for r in poly:
self.assertEqual('LINEARRING', r.geom_name)
def test_closepolygons(self):
"Testing closing Polygon objects."
# Both rings in this geometry are not closed.
poly = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5), (1 1, 2 1, 2 2, 2 1))')
self.assertEqual(8, poly.point_count)
with self.assertRaises(GDALException):
poly.centroid
poly.close_rings()
self.assertEqual(10, poly.point_count) # Two closing points should've been added
self.assertEqual(OGRGeometry('POINT(2.5 2.5)'), poly.centroid)
def test_multipolygons(self):
"Testing MultiPolygon objects."
OGRGeometry('POINT(0 0)')
for mp in self.geometries.multipolygons:
mpoly = OGRGeometry(mp.wkt)
self.assertEqual(6, mpoly.geom_type)
self.assertEqual('MULTIPOLYGON', mpoly.geom_name)
if mp.valid:
self.assertEqual(mp.n_p, mpoly.point_count)
self.assertEqual(mp.num_geom, len(mpoly))
self.assertRaises(OGRIndexError, mpoly.__getitem__, len(mpoly))
for p in mpoly:
self.assertEqual('POLYGON', p.geom_name)
self.assertEqual(3, p.geom_type)
self.assertEqual(mpoly.wkt, OGRGeometry(mp.wkt).wkt)
def test_srs(self):
"Testing OGR Geometries with Spatial Reference objects."
for mp in self.geometries.multipolygons:
# Creating a geometry w/spatial reference
sr = SpatialReference('WGS84')
mpoly = OGRGeometry(mp.wkt, sr)
self.assertEqual(sr.wkt, mpoly.srs.wkt)
# Ensuring that SRS is propagated to clones.
klone = mpoly.clone()
self.assertEqual(sr.wkt, klone.srs.wkt)
# Ensuring all children geometries (polygons and their rings) all
# return the assigned spatial reference as well.
for poly in mpoly:
self.assertEqual(sr.wkt, poly.srs.wkt)
for ring in poly:
self.assertEqual(sr.wkt, ring.srs.wkt)
# Ensuring SRS propagate in topological ops.
a = OGRGeometry(self.geometries.topology_geoms[0].wkt_a, sr)
b = OGRGeometry(self.geometries.topology_geoms[0].wkt_b, sr)
diff = a.difference(b)
union = a.union(b)
self.assertEqual(sr.wkt, diff.srs.wkt)
self.assertEqual(sr.srid, union.srs.srid)
# Instantiating w/an integer SRID
mpoly = OGRGeometry(mp.wkt, 4326)
self.assertEqual(4326, mpoly.srid)
mpoly.srs = SpatialReference(4269)
self.assertEqual(4269, mpoly.srid)
self.assertEqual('NAD83', mpoly.srs.name)
# Incrementing through the multipolygon after the spatial reference
# has been re-assigned.
for poly in mpoly:
self.assertEqual(mpoly.srs.wkt, poly.srs.wkt)
poly.srs = 32140
for ring in poly:
# Changing each ring in the polygon
self.assertEqual(32140, ring.srs.srid)
self.assertEqual('NAD83 / Texas South Central', ring.srs.name)
ring.srs = str(SpatialReference(4326)) # back to WGS84
self.assertEqual(4326, ring.srs.srid)
# Using the `srid` property.
ring.srid = 4322
self.assertEqual('WGS 72', ring.srs.name)
self.assertEqual(4322, ring.srid)
def test_srs_transform(self):
"Testing transform()."
orig = OGRGeometry('POINT (-104.609 38.255)', 4326)
trans = OGRGeometry('POINT (992385.4472045 481455.4944650)', 2774)
# Using an srid, a SpatialReference object, and a CoordTransform object
# or transformations.
t1, t2, t3 = orig.clone(), orig.clone(), orig.clone()
t1.transform(trans.srid)
t2.transform(SpatialReference('EPSG:2774'))
ct = CoordTransform(SpatialReference('WGS84'), SpatialReference(2774))
t3.transform(ct)
# Testing use of the `clone` keyword.
k1 = orig.clone()
k2 = k1.transform(trans.srid, clone=True)
self.assertEqual(k1, orig)
self.assertNotEqual(k1, k2)
prec = 3
for p in (t1, t2, t3, k2):
self.assertAlmostEqual(trans.x, p.x, prec)
self.assertAlmostEqual(trans.y, p.y, prec)
def test_transform_dim(self):
"Testing coordinate dimension is the same on transformed geometries."
ls_orig = OGRGeometry('LINESTRING(-104.609 38.255)', 4326)
ls_trans = OGRGeometry('LINESTRING(992385.4472045 481455.4944650)', 2774)
prec = 3
ls_orig.transform(ls_trans.srs)
# Making sure the coordinate dimension is still 2D.
self.assertEqual(2, ls_orig.coord_dim)
self.assertAlmostEqual(ls_trans.x[0], ls_orig.x[0], prec)
self.assertAlmostEqual(ls_trans.y[0], ls_orig.y[0], prec)
def test_difference(self):
"Testing difference()."
for i in range(len(self.geometries.topology_geoms)):
a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
d1 = OGRGeometry(self.geometries.diff_geoms[i].wkt)
d2 = a.difference(b)
self.assertEqual(d1, d2)
self.assertEqual(d1, a - b) # __sub__ is difference operator
a -= b # testing __isub__
self.assertEqual(d1, a)
def test_intersection(self):
"Testing intersects() and intersection()."
for i in range(len(self.geometries.topology_geoms)):
a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
i1 = OGRGeometry(self.geometries.intersect_geoms[i].wkt)
self.assertTrue(a.intersects(b))
i2 = a.intersection(b)
self.assertEqual(i1, i2)
self.assertEqual(i1, a & b) # __and__ is intersection operator
a &= b # testing __iand__
self.assertEqual(i1, a)
def test_symdifference(self):
"Testing sym_difference()."
for i in range(len(self.geometries.topology_geoms)):
a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
d1 = OGRGeometry(self.geometries.sdiff_geoms[i].wkt)
d2 = a.sym_difference(b)
self.assertEqual(d1, d2)
self.assertEqual(d1, a ^ b) # __xor__ is symmetric difference operator
a ^= b # testing __ixor__
self.assertEqual(d1, a)
def test_union(self):
"Testing union()."
for i in range(len(self.geometries.topology_geoms)):
a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
u1 = OGRGeometry(self.geometries.union_geoms[i].wkt)
u2 = a.union(b)
self.assertEqual(u1, u2)
self.assertEqual(u1, a | b) # __or__ is union operator
a |= b # testing __ior__
self.assertEqual(u1, a)
def test_add(self):
"Testing GeometryCollection.add()."
# Can't insert a Point into a MultiPolygon.
mp = OGRGeometry('MultiPolygon')
pnt = OGRGeometry('POINT(5 23)')
self.assertRaises(GDALException, mp.add, pnt)
# GeometryCollection.add may take an OGRGeometry (if another collection
# of the same type all child geoms will be added individually) or WKT.
for mp in self.geometries.multipolygons:
mpoly = OGRGeometry(mp.wkt)
mp1 = OGRGeometry('MultiPolygon')
mp2 = OGRGeometry('MultiPolygon')
mp3 = OGRGeometry('MultiPolygon')
for poly in mpoly:
mp1.add(poly) # Adding a geometry at a time
mp2.add(poly.wkt) # Adding WKT
mp3.add(mpoly) # Adding a MultiPolygon's entire contents at once.
for tmp in (mp1, mp2, mp3):
self.assertEqual(mpoly, tmp)
def test_extent(self):
"Testing `extent` property."
# The xmin, ymin, xmax, ymax of the MultiPoint should be returned.
mp = OGRGeometry('MULTIPOINT(5 23, 0 0, 10 50)')
self.assertEqual((0.0, 0.0, 10.0, 50.0), mp.extent)
# Testing on the 'real world' Polygon.
poly = OGRGeometry(self.geometries.polygons[3].wkt)
ring = poly.shell
x, y = ring.x, ring.y
xmin, ymin = min(x), min(y)
xmax, ymax = max(x), max(y)
self.assertEqual((xmin, ymin, xmax, ymax), poly.extent)
def test_25D(self):
"Testing 2.5D geometries."
pnt_25d = OGRGeometry('POINT(1 2 3)')
self.assertEqual('Point25D', pnt_25d.geom_type.name)
self.assertEqual(3.0, pnt_25d.z)
self.assertEqual(3, pnt_25d.coord_dim)
ls_25d = OGRGeometry('LINESTRING(1 1 1,2 2 2,3 3 3)')
self.assertEqual('LineString25D', ls_25d.geom_type.name)
self.assertEqual([1.0, 2.0, 3.0], ls_25d.z)
self.assertEqual(3, ls_25d.coord_dim)
def test_pickle(self):
"Testing pickle support."
g1 = OGRGeometry('LINESTRING(1 1 1,2 2 2,3 3 3)', 'WGS84')
g2 = pickle.loads(pickle.dumps(g1))
self.assertEqual(g1, g2)
self.assertEqual(4326, g2.srs.srid)
self.assertEqual(g1.srs.wkt, g2.srs.wkt)
def test_ogrgeometry_transform_workaround(self):
"Testing coordinate dimensions on geometries after transformation."
# A bug in GDAL versions prior to 1.7 changes the coordinate
# dimension of a geometry after it has been transformed.
# This test ensures that the bug workarounds employed within
# `OGRGeometry.transform` indeed work.
wkt_2d = "MULTILINESTRING ((0 0,1 1,2 2))"
wkt_3d = "MULTILINESTRING ((0 0 0,1 1 1,2 2 2))"
srid = 4326
# For both the 2D and 3D MultiLineString, ensure _both_ the dimension
# of the collection and the component LineString have the expected
# coordinate dimension after transform.
geom = OGRGeometry(wkt_2d, srid)
geom.transform(srid)
self.assertEqual(2, geom.coord_dim)
self.assertEqual(2, geom[0].coord_dim)
self.assertEqual(wkt_2d, geom.wkt)
geom = OGRGeometry(wkt_3d, srid)
geom.transform(srid)
self.assertEqual(3, geom.coord_dim)
self.assertEqual(3, geom[0].coord_dim)
self.assertEqual(wkt_3d, geom.wkt)
def test_equivalence_regression(self):
"Testing equivalence methods with non-OGRGeometry instances."
self.assertIsNotNone(OGRGeometry('POINT(0 0)'))
self.assertNotEqual(OGRGeometry('LINESTRING(0 0, 1 1)'), 3)
|
bsd-3-clause
|
[
646,
2022,
199,
646,
2882,
199,
504,
14755,
492,
330,
18,
65,
63,
4097,
199,
504,
2882,
492,
3372,
5524,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
492,
7509,
63,
17835,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
1425,
199,
199,
504,
2508,
396,
63,
576,
492,
1379,
1451,
4256,
199,
199,
893,
26,
272,
687,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
17572,
465,
5927,
199,
2590,
3545,
26,
272,
492,
5927,
421,
199,
692,
7509,
63,
17835,
26,
272,
687,
1639,
14,
2828,
14,
5668,
14,
11600,
492,
334,
17275,
6831,
12,
25756,
12,
267,
15801,
1726,
12,
10904,
12129,
12,
24324,
12,
1849,
2181,
6939,
12,
267,
15801,
63,
4612,
9,
421,
199,
32,
11278,
8,
13533,
63,
17835,
12,
298,
17835,
365,
1415,
531,
199,
533,
10904,
13427,
774,
8,
2796,
14,
1746,
12,
1379,
1451,
4256,
304,
272,
298,
2765,
2295,
314,
10904,
10579,
2122,
339,
347,
511,
63,
6481,
466,
8,
277,
304,
267,
298,
9029,
25756,
909,
2122,
398,
327,
25756,
1077,
8265,
641,
1006,
3520,
4153,
14,
267,
25756,
8,
17,
9,
267,
25756,
8,
23,
9,
267,
25756,
360,
1403,
358,
267,
25756,
360,
6831,
761,
10251,
4538,
46,
358,
267,
25756,
360,
6143,
2210,
82,
1206,
358,
267,
25756,
360,
5912,
358,
398,
327,
7719,
7978,
3146,
641,
642,
1324,
267,
291,
14,
1855,
8,
17835,
1726,
12,
25756,
12,
6546,
9,
267,
291,
14,
1855,
8,
17835,
1726,
12,
25756,
12,
283,
1421,
36,
358,
267,
291,
14,
1855,
8,
17835,
1726,
12,
25756,
12,
1749,
9,
398,
327,
662,
22810,
883,
5452,
3326,
12,
14526,
12,
436,
1163,
10904,
13427,
4100,
267,
291,
14,
629,
8,
17275,
22702,
8,
17,
395,
25756,
8,
17,
430,
267,
291,
14,
629,
8,
17275,
22702,
8,
23,
395,
283,
6831,
7768,
358,
267,
291,
14,
629,
8,
17275,
22702,
360,
1403,
659,
283,
7217,
358,
267,
291,
14,
7418,
8,
17275,
22702,
360,
1403,
659,
499,
9,
267,
291,
14,
629,
8,
17275,
22702,
360,
5187,
659,
378,
9,
267,
291,
14,
629,
8,
17275,
22702,
8,
22,
395,
283,
45,
1293,
280,
12747,
22340,
358,
267,
291,
14,
629,
8,
17275,
22702,
8,
17,
395,
25756,
360,
1403,
1333,
267,
291,
14,
7418,
8,
17275,
22702,
360,
7217,
659,
25756,
8,
22,
430,
398,
327,
11940,
314,
5634,
901,
536,
7353,
3324,
14,
267,
291,
14,
629,
360,
3428,
792,
297,
25756,
360,
3428,
1959,
1176,
9,
267,
291,
14,
629,
360,
6831,
792,
297,
25756,
360,
6831,
1959,
1176,
9,
267,
291,
14,
629,
360,
6831,
792,
297,
25756,
360,
5912,
1959,
1176,
9,
267,
291,
14,
7702,
8,
17275,
22702,
360,
3592,
1959,
1176,
9,
398,
327,
283,
6831,
7,
11097,
22660,
376,
5809,
3400,
730,
14,
267,
16484,
275,
25756,
360,
6831,
358,
267,
291,
14,
629,
8,
16,
12,
16484,
14,
1507,
9,
267,
291,
14,
629,
360,
5912,
297,
16484,
14,
354,
9,
339,
347,
511,
63,
6481,
466,
63,
821,
68,
8,
277,
304,
267,
298,
9029,
25756,
909,
543,
5661,
36,
2943,
2122,
267,
24249,
821,
2075,
275,
25756,
14,
18914,
821,
2075,
267,
291,
14,
629,
8,
17275,
22702,
8,
18914,
821,
2075,
435,
413,
395,
283,
3428,
821,
36,
358,
267,
291,
14,
629,
8,
17275,
22702,
360,
3947,
22134,
821,
36,
659,
334,
21,
435,
24249,
821,
2075,
430,
267,
291,
14,
629,
360,
6831,
7768,
792,
297,
25756,
360,
6831,
7768,
821,
36,
1959,
1176,
9,
339,
347,
511,
63,
11412,
8,
277,
304,
267,
298,
9029,
22561,
1072,
2122,
267,
367,
486,
315,
291,
14,
21626,
14,
11412,
63,
548,
26,
288,
9671,
275,
24220,
8,
71,
14,
11412,
9,
288,
291,
14,
629,
8,
71,
14,
11412,
12,
9671,
14,
11412,
9,
339,
347,
511,
63,
546,
5973,
8,
277,
304,
267,
298,
9029,
662,
55,
12362,
1324,
15,
1199,
2122,
267,
367,
325,
11412,
63,
637,
315,
661,
7217,
334,
17,
499,
650,
3196,
283,
6174,
1920,
1206,
334,
16,
378,
12,
17,
413,
12,
18,
413,
12,
16,
378,
9,
735,
288,
327,
7758,
543,
325,
11412,
1072,
1380,
949,
22425,
315,
662,
55,
12362,
288,
291,
14,
629,
8,
546,
5973,
63,
637,
12,
24220,
8,
546,
5973,
63,
637,
680,
546,
5973,
9,
288,
327,
3091,
511,
13447,
15052,
543,
376,
22425,
2013,
14,
288,
325,
11412,
63,
637,
275,
283,
5943,
998,
29,
17948,
27,
5,
83,
7,
450,
325,
11412,
63,
637,
288,
9671,
275,
24220,
8,
546,
5973,
63,
637,
9,
288,
291,
14,
629,
8,
546,
5973,
63,
637,
12,
9671,
14,
546,
5973,
9,
288,
291,
14,
629,
8,
17948,
12,
9671,
14,
12722,
14,
10498,
9,
339,
347,
511,
63,
18594,
8,
277,
304,
267,
298,
9029,
598,
1698,
1072,
2122,
267,
367,
486,
315,
291,
14,
21626,
14,
11412,
63,
548,
26,
288,
9671,
275,
24220,
8,
71,
14,
11412,
9,
288,
1437,
63,
18594,
275,
486,
14,
18594,
288,
340,
15801,
63,
4612,
2356,
334,
17,
12,
1695,
304,
355,
327,
1010,
15801,
413,
14,
24,
12,
314,
2222,
13,
388,
964,
867,
598,
1698,
1947,
221,
665,
18594,
26,
6831,
7768,
30,
1990,
355,
327,
8717,
543,
665,
18594,
26,
3947,
6831,
10827,
355,
1437,
63,
18594,
275,
1437,
63,
18594,
14,
1814,
360,
6831,
7768,
297,
283,
3947,
6831,
358,
288,
291,
14,
629,
8,
1474,
63,
18594,
12,
9671,
14,
18594,
9,
339,
347,
511,
63,
4097,
8,
277,
304,
267,
298,
9029,
29467,
1324,
15,
1199,
2122,
267,
367,
486,
315,
291,
14,
21626,
14,
4097,
63,
11412,
26,
288,
9671,
17,
275,
24220,
8,
71,
14,
11412,
9,
288,
291,
14,
629,
8,
71,
14,
4097,
14,
2143,
1062,
9671,
17,
14,
4097,
9,
288,
327,
9215,
316,
336,
15,
21377,
288,
9671,
18,
275,
24220,
8,
71,
14,
4097,
9,
288,
291,
14,
629,
8,
6481,
17,
12,
9671,
18,
9,
339,
347,
511,
63,
18914,
8,
277,
304,
267,
298,
9029,
644,
12780,
1324,
15,
1199,
2122,
267,
367,
486,
315,
291,
14,
21626,
14,
4097,
63,
11412,
26,
288,
9671,
17,
275,
24220,
8
] |
[
2022,
199,
646,
2882,
199,
504,
14755,
492,
330,
18,
65,
63,
4097,
199,
504,
2882,
492,
3372,
5524,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
492,
7509,
63,
17835,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
1425,
199,
199,
504,
2508,
396,
63,
576,
492,
1379,
1451,
4256,
199,
199,
893,
26,
272,
687,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
17572,
465,
5927,
199,
2590,
3545,
26,
272,
492,
5927,
421,
199,
692,
7509,
63,
17835,
26,
272,
687,
1639,
14,
2828,
14,
5668,
14,
11600,
492,
334,
17275,
6831,
12,
25756,
12,
267,
15801,
1726,
12,
10904,
12129,
12,
24324,
12,
1849,
2181,
6939,
12,
267,
15801,
63,
4612,
9,
421,
199,
32,
11278,
8,
13533,
63,
17835,
12,
298,
17835,
365,
1415,
531,
199,
533,
10904,
13427,
774,
8,
2796,
14,
1746,
12,
1379,
1451,
4256,
304,
272,
298,
2765,
2295,
314,
10904,
10579,
2122,
339,
347,
511,
63,
6481,
466,
8,
277,
304,
267,
298,
9029,
25756,
909,
2122,
398,
327,
25756,
1077,
8265,
641,
1006,
3520,
4153,
14,
267,
25756,
8,
17,
9,
267,
25756,
8,
23,
9,
267,
25756,
360,
1403,
358,
267,
25756,
360,
6831,
761,
10251,
4538,
46,
358,
267,
25756,
360,
6143,
2210,
82,
1206,
358,
267,
25756,
360,
5912,
358,
398,
327,
7719,
7978,
3146,
641,
642,
1324,
267,
291,
14,
1855,
8,
17835,
1726,
12,
25756,
12,
6546,
9,
267,
291,
14,
1855,
8,
17835,
1726,
12,
25756,
12,
283,
1421,
36,
358,
267,
291,
14,
1855,
8,
17835,
1726,
12,
25756,
12,
1749,
9,
398,
327,
662,
22810,
883,
5452,
3326,
12,
14526,
12,
436,
1163,
10904,
13427,
4100,
267,
291,
14,
629,
8,
17275,
22702,
8,
17,
395,
25756,
8,
17,
430,
267,
291,
14,
629,
8,
17275,
22702,
8,
23,
395,
283,
6831,
7768,
358,
267,
291,
14,
629,
8,
17275,
22702,
360,
1403,
659,
283,
7217,
358,
267,
291,
14,
7418,
8,
17275,
22702,
360,
1403,
659,
499,
9,
267,
291,
14,
629,
8,
17275,
22702,
360,
5187,
659,
378,
9,
267,
291,
14,
629,
8,
17275,
22702,
8,
22,
395,
283,
45,
1293,
280,
12747,
22340,
358,
267,
291,
14,
629,
8,
17275,
22702,
8,
17,
395,
25756,
360,
1403,
1333,
267,
291,
14,
7418,
8,
17275,
22702,
360,
7217,
659,
25756,
8,
22,
430,
398,
327,
11940,
314,
5634,
901,
536,
7353,
3324,
14,
267,
291,
14,
629,
360,
3428,
792,
297,
25756,
360,
3428,
1959,
1176,
9,
267,
291,
14,
629,
360,
6831,
792,
297,
25756,
360,
6831,
1959,
1176,
9,
267,
291,
14,
629,
360,
6831,
792,
297,
25756,
360,
5912,
1959,
1176,
9,
267,
291,
14,
7702,
8,
17275,
22702,
360,
3592,
1959,
1176,
9,
398,
327,
283,
6831,
7,
11097,
22660,
376,
5809,
3400,
730,
14,
267,
16484,
275,
25756,
360,
6831,
358,
267,
291,
14,
629,
8,
16,
12,
16484,
14,
1507,
9,
267,
291,
14,
629,
360,
5912,
297,
16484,
14,
354,
9,
339,
347,
511,
63,
6481,
466,
63,
821,
68,
8,
277,
304,
267,
298,
9029,
25756,
909,
543,
5661,
36,
2943,
2122,
267,
24249,
821,
2075,
275,
25756,
14,
18914,
821,
2075,
267,
291,
14,
629,
8,
17275,
22702,
8,
18914,
821,
2075,
435,
413,
395,
283,
3428,
821,
36,
358,
267,
291,
14,
629,
8,
17275,
22702,
360,
3947,
22134,
821,
36,
659,
334,
21,
435,
24249,
821,
2075,
430,
267,
291,
14,
629,
360,
6831,
7768,
792,
297,
25756,
360,
6831,
7768,
821,
36,
1959,
1176,
9,
339,
347,
511,
63,
11412,
8,
277,
304,
267,
298,
9029,
22561,
1072,
2122,
267,
367,
486,
315,
291,
14,
21626,
14,
11412,
63,
548,
26,
288,
9671,
275,
24220,
8,
71,
14,
11412,
9,
288,
291,
14,
629,
8,
71,
14,
11412,
12,
9671,
14,
11412,
9,
339,
347,
511,
63,
546,
5973,
8,
277,
304,
267,
298,
9029,
662,
55,
12362,
1324,
15,
1199,
2122,
267,
367,
325,
11412,
63,
637,
315,
661,
7217,
334,
17,
499,
650,
3196,
283,
6174,
1920,
1206,
334,
16,
378,
12,
17,
413,
12,
18,
413,
12,
16,
378,
9,
735,
288,
327,
7758,
543,
325,
11412,
1072,
1380,
949,
22425,
315,
662,
55,
12362,
288,
291,
14,
629,
8,
546,
5973,
63,
637,
12,
24220,
8,
546,
5973,
63,
637,
680,
546,
5973,
9,
288,
327,
3091,
511,
13447,
15052,
543,
376,
22425,
2013,
14,
288,
325,
11412,
63,
637,
275,
283,
5943,
998,
29,
17948,
27,
5,
83,
7,
450,
325,
11412,
63,
637,
288,
9671,
275,
24220,
8,
546,
5973,
63,
637,
9,
288,
291,
14,
629,
8,
546,
5973,
63,
637,
12,
9671,
14,
546,
5973,
9,
288,
291,
14,
629,
8,
17948,
12,
9671,
14,
12722,
14,
10498,
9,
339,
347,
511,
63,
18594,
8,
277,
304,
267,
298,
9029,
598,
1698,
1072,
2122,
267,
367,
486,
315,
291,
14,
21626,
14,
11412,
63,
548,
26,
288,
9671,
275,
24220,
8,
71,
14,
11412,
9,
288,
1437,
63,
18594,
275,
486,
14,
18594,
288,
340,
15801,
63,
4612,
2356,
334,
17,
12,
1695,
304,
355,
327,
1010,
15801,
413,
14,
24,
12,
314,
2222,
13,
388,
964,
867,
598,
1698,
1947,
221,
665,
18594,
26,
6831,
7768,
30,
1990,
355,
327,
8717,
543,
665,
18594,
26,
3947,
6831,
10827,
355,
1437,
63,
18594,
275,
1437,
63,
18594,
14,
1814,
360,
6831,
7768,
297,
283,
3947,
6831,
358,
288,
291,
14,
629,
8,
1474,
63,
18594,
12,
9671,
14,
18594,
9,
339,
347,
511,
63,
4097,
8,
277,
304,
267,
298,
9029,
29467,
1324,
15,
1199,
2122,
267,
367,
486,
315,
291,
14,
21626,
14,
4097,
63,
11412,
26,
288,
9671,
17,
275,
24220,
8,
71,
14,
11412,
9,
288,
291,
14,
629,
8,
71,
14,
4097,
14,
2143,
1062,
9671,
17,
14,
4097,
9,
288,
327,
9215,
316,
336,
15,
21377,
288,
9671,
18,
275,
24220,
8,
71,
14,
4097,
9,
288,
291,
14,
629,
8,
6481,
17,
12,
9671,
18,
9,
339,
347,
511,
63,
18914,
8,
277,
304,
267,
298,
9029,
644,
12780,
1324,
15,
1199,
2122,
267,
367,
486,
315,
291,
14,
21626,
14,
4097,
63,
11412,
26,
288,
9671,
17,
275,
24220,
8,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
wildtetris/python-social-auth
|
social/backends/linkedin.py
|
46
|
3776
|
"""
LinkedIn OAuth1 and OAuth2 backend, docs at:
http://psa.matiasaguirre.net/docs/backends/linkedin.html
"""
from social.backends.oauth import BaseOAuth1, BaseOAuth2
class BaseLinkedinAuth(object):
EXTRA_DATA = [('id', 'id'),
('first-name', 'first_name', True),
('last-name', 'last_name', True),
('firstName', 'first_name', True),
('lastName', 'last_name', True)]
USER_DETAILS = 'https://api.linkedin.com/v1/people/~:({0})'
def get_user_details(self, response):
"""Return user details from Linkedin account"""
fullname, first_name, last_name = self.get_user_names(
first_name=response['firstName'],
last_name=response['lastName']
)
email = response.get('emailAddress', '')
return {'username': first_name + last_name,
'fullname': fullname,
'first_name': first_name,
'last_name': last_name,
'email': email}
def user_details_url(self):
# use set() since LinkedIn fails when values are duplicated
fields_selectors = list(set(['first-name', 'id', 'last-name'] +
self.setting('FIELD_SELECTORS', [])))
# user sort to ease the tests URL mocking
fields_selectors.sort()
fields_selectors = ','.join(fields_selectors)
return self.USER_DETAILS.format(fields_selectors)
def user_data_headers(self):
lang = self.setting('FORCE_PROFILE_LANGUAGE')
if lang:
return {
'Accept-Language': lang if lang is not True
else self.strategy.get_language()
}
class LinkedinOAuth(BaseLinkedinAuth, BaseOAuth1):
"""Linkedin OAuth authentication backend"""
name = 'linkedin'
SCOPE_SEPARATOR = '+'
AUTHORIZATION_URL = 'https://www.linkedin.com/uas/oauth/authenticate'
REQUEST_TOKEN_URL = 'https://api.linkedin.com/uas/oauth/requestToken'
ACCESS_TOKEN_URL = 'https://api.linkedin.com/uas/oauth/accessToken'
def user_data(self, access_token, *args, **kwargs):
"""Return user data provided"""
return self.get_json(
self.user_details_url(),
params={'format': 'json'},
auth=self.oauth_auth(access_token),
headers=self.user_data_headers()
)
def unauthorized_token(self):
"""Makes first request to oauth. Returns an unauthorized Token."""
scope = self.get_scope() or ''
if scope:
scope = '?scope=' + self.SCOPE_SEPARATOR.join(scope)
return self.request(self.REQUEST_TOKEN_URL + scope,
params=self.request_token_extra_arguments(),
auth=self.oauth_auth()).text
class LinkedinOAuth2(BaseLinkedinAuth, BaseOAuth2):
name = 'linkedin-oauth2'
SCOPE_SEPARATOR = ' '
AUTHORIZATION_URL = 'https://www.linkedin.com/uas/oauth2/authorization'
ACCESS_TOKEN_URL = 'https://www.linkedin.com/uas/oauth2/accessToken'
ACCESS_TOKEN_METHOD = 'POST'
REDIRECT_STATE = False
def user_data(self, access_token, *args, **kwargs):
return self.get_json(
self.user_details_url(),
params={'oauth2_access_token': access_token,
'format': 'json'},
headers=self.user_data_headers()
)
def request_access_token(self, *args, **kwargs):
# LinkedIn expects a POST request with querystring parameters, despite
# the spec http://tools.ietf.org/html/rfc6749#section-4.1.3
kwargs['params'] = kwargs.pop('data')
return super(LinkedinOAuth2, self).request_access_token(
*args, **kwargs
)
|
bsd-3-clause
|
[
624,
199,
26748,
607,
11715,
17,
436,
11715,
18,
4865,
12,
9149,
737,
26,
272,
1455,
921,
1190,
65,
14,
391,
280,
305,
643,
85,
723,
264,
14,
846,
15,
4757,
15,
7765,
15,
12751,
262,
14,
1360,
199,
624,
199,
504,
20295,
14,
7765,
14,
6126,
492,
3523,
12906,
17,
12,
3523,
12906,
18,
421,
199,
533,
3523,
26748,
262,
2817,
8,
785,
304,
272,
3651,
13954,
63,
3998,
275,
4274,
344,
297,
283,
344,
659,
2116,
661,
2246,
13,
354,
297,
283,
2246,
63,
354,
297,
715,
395,
2116,
661,
2019,
13,
354,
297,
283,
2019,
63,
354,
297,
715,
395,
2116,
661,
2246,
985,
297,
283,
2246,
63,
354,
297,
715,
395,
2116,
661,
2019,
985,
297,
283,
2019,
63,
354,
297,
715,
1874,
272,
13044,
63,
25081,
51,
275,
283,
2859,
921,
1246,
14,
12751,
262,
14,
957,
15,
86,
17,
15,
13562,
22500,
26,
2561,
16,
29668,
339,
347,
664,
63,
751,
63,
5087,
8,
277,
12,
1177,
304,
267,
408,
1767,
922,
2436,
687,
10967,
379,
262,
2933,
624,
267,
11064,
12,
1642,
63,
354,
12,
2061,
63,
354,
275,
291,
14,
362,
63,
751,
63,
1247,
8,
288,
1642,
63,
354,
29,
1310,
459,
2246,
985,
995,
288,
2061,
63,
354,
29,
1310,
459,
2019,
985,
418,
267,
776,
267,
3031,
275,
1177,
14,
362,
360,
2123,
1476,
297,
4074,
267,
372,
791,
2473,
356,
1642,
63,
354,
435,
2061,
63,
354,
12,
355,
283,
9930,
356,
11064,
12,
355,
283,
2246,
63,
354,
356,
1642,
63,
354,
12,
355,
283,
2019,
63,
354,
356,
2061,
63,
354,
12,
355,
283,
2123,
356,
3031,
93,
339,
347,
922,
63,
5087,
63,
633,
8,
277,
304,
267,
327,
675,
663,
342,
3967,
10967,
379,
607,
6918,
1380,
1338,
787,
21747,
267,
1504,
63,
6662,
83,
275,
769,
8,
409,
2941,
2246,
13,
354,
297,
283,
344,
297,
283,
2019,
13,
354,
418,
435,
1816,
291,
14,
6031,
360,
8609,
63,
4859,
4149,
297,
942,
1724,
267,
327,
922,
4069,
370,
325,
482,
314,
2295,
2851,
1683,
316,
267,
1504,
63,
6662,
83,
14,
3191,
342,
267,
1504,
63,
6662,
83,
275,
12814,
904,
8,
955,
63,
6662,
83,
9,
267,
372,
291,
14,
3791,
63,
25081,
51,
14,
908,
8,
955,
63,
6662,
83,
9,
339,
347,
922,
63,
576,
63,
2139,
8,
277,
304,
267,
6339,
275,
291,
14,
6031,
360,
27240,
63,
16632,
63,
13947,
358,
267,
340,
6339,
26,
288,
372,
469,
355,
283,
8422,
13,
8493,
356,
6339,
340,
6339,
365,
440,
715,
3147,
587,
291,
14,
8590,
14,
362,
63,
3671,
342,
288,
789,
421,
199,
533,
10967,
379,
262,
12906,
8,
1563,
26748,
262,
2817,
12,
3523,
12906,
17,
304,
272,
408,
26748,
262,
11715,
6299,
4865,
624,
272,
536,
275,
283,
12751,
262,
7,
272,
428,
1439,
1510,
63,
15828,
275,
20246,
272,
7560,
7123,
2594,
63,
2632,
275,
283,
2859,
921,
1544,
14,
12751,
262,
14,
957,
15,
85,
305,
15,
6126,
15,
13975,
7,
272,
31325,
63,
8803,
63,
2632,
275,
283,
2859,
921,
1246,
14,
12751,
262,
14,
957,
15,
85,
305,
15,
6126,
15,
1069,
3264,
7,
272,
437,
10203,
63,
8803,
63,
2632,
275,
283,
2859,
921,
1246,
14,
12751,
262,
14,
957,
15,
85,
305,
15,
6126,
15,
2732,
3264,
7,
339,
347,
922,
63,
576,
8,
277,
12,
2879,
63,
1418,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
1767,
922,
666,
2741,
624,
267,
372,
291,
14,
362,
63,
1001,
8,
288,
291,
14,
751,
63,
5087,
63,
633,
1062,
288,
1862,
3713,
908,
356,
283,
1001,
2267,
288,
1790,
29,
277,
14,
6126,
63,
1178,
8,
2732,
63,
1418,
395,
288,
2323,
29,
277,
14,
751,
63,
576,
63,
2139,
342,
267,
776,
339,
347,
625,
11497,
63,
1418,
8,
277,
304,
267,
408,
27142,
1642,
1056,
370,
9725,
14,
1803,
376,
625,
11497,
8767,
1041,
267,
4194,
275,
291,
14,
362,
63,
2645,
342,
503,
2125,
267,
340,
4194,
26,
288,
4194,
275,
8720,
2645,
534,
435,
291,
14,
17998,
63,
15828,
14,
904,
8,
2645,
9,
267,
372,
291,
14,
1069,
8,
277,
14,
6780,
63,
8803,
63,
2632,
435,
4194,
12,
1169,
1862,
29,
277,
14,
1069,
63,
1418,
63,
2911,
63,
4958,
1062,
1169,
1790,
29,
277,
14,
6126,
63,
1178,
8801,
505,
421,
199,
533,
10967,
379,
262,
12906,
18,
8,
1563,
26748,
262,
2817,
12,
3523,
12906,
18,
304,
272,
536,
275,
283,
12751,
262,
13,
6126,
18,
7,
272,
428,
1439,
1510,
63,
15828,
275,
283,
283,
272,
7560,
7123,
2594,
63,
2632,
275,
283,
2859,
921,
1544,
14,
12751,
262,
14,
957,
15,
85,
305,
15,
6126,
18,
15,
15846,
7,
272,
437,
10203,
63,
8803,
63,
2632,
275,
283,
2859,
921,
1544,
14,
12751,
262,
14,
957,
15,
85,
305,
15,
6126,
18,
15,
2732,
3264,
7,
272,
437,
10203,
63,
8803,
63,
9977,
275,
283,
4030,
7,
272,
820,
7458,
4168,
63,
6689,
275,
756,
339,
347,
922,
63,
576,
8,
277,
12,
2879,
63,
1418,
12,
627,
589,
12,
1011,
958,
304,
267,
372,
291,
14,
362,
63,
1001,
8,
288,
291,
14,
751,
63,
5087,
63,
633,
1062,
288,
1862,
3713,
6126,
18,
63,
2732,
63,
1418,
356,
2879,
63,
1418,
12,
490,
283,
908,
356,
283,
1001,
2267,
288,
2323,
29,
277,
14,
751,
63,
576,
63,
2139,
342,
267,
776,
339,
347,
1056,
63,
2732,
63,
1418,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
327,
10967,
379,
607,
14292,
282,
8761,
1056,
543,
1827,
875,
2633,
12,
477,
681,
1175,
267,
327,
314,
3158,
1455,
921,
2537,
14,
15799,
14,
1308,
15,
1360,
15,
8973,
10393,
25,
3,
2792,
13,
20,
14,
17,
14,
19,
267,
2074,
459,
1162,
418,
275,
2074,
14,
1935,
360,
576,
358,
267,
372,
1613,
8,
26748,
262,
12906,
18,
12,
291,
680,
1069,
63,
2732,
63,
1418,
8,
288,
627,
589,
12,
1011,
958,
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
] |
[
199,
26748,
607,
11715,
17,
436,
11715,
18,
4865,
12,
9149,
737,
26,
272,
1455,
921,
1190,
65,
14,
391,
280,
305,
643,
85,
723,
264,
14,
846,
15,
4757,
15,
7765,
15,
12751,
262,
14,
1360,
199,
624,
199,
504,
20295,
14,
7765,
14,
6126,
492,
3523,
12906,
17,
12,
3523,
12906,
18,
421,
199,
533,
3523,
26748,
262,
2817,
8,
785,
304,
272,
3651,
13954,
63,
3998,
275,
4274,
344,
297,
283,
344,
659,
2116,
661,
2246,
13,
354,
297,
283,
2246,
63,
354,
297,
715,
395,
2116,
661,
2019,
13,
354,
297,
283,
2019,
63,
354,
297,
715,
395,
2116,
661,
2246,
985,
297,
283,
2246,
63,
354,
297,
715,
395,
2116,
661,
2019,
985,
297,
283,
2019,
63,
354,
297,
715,
1874,
272,
13044,
63,
25081,
51,
275,
283,
2859,
921,
1246,
14,
12751,
262,
14,
957,
15,
86,
17,
15,
13562,
22500,
26,
2561,
16,
29668,
339,
347,
664,
63,
751,
63,
5087,
8,
277,
12,
1177,
304,
267,
408,
1767,
922,
2436,
687,
10967,
379,
262,
2933,
624,
267,
11064,
12,
1642,
63,
354,
12,
2061,
63,
354,
275,
291,
14,
362,
63,
751,
63,
1247,
8,
288,
1642,
63,
354,
29,
1310,
459,
2246,
985,
995,
288,
2061,
63,
354,
29,
1310,
459,
2019,
985,
418,
267,
776,
267,
3031,
275,
1177,
14,
362,
360,
2123,
1476,
297,
4074,
267,
372,
791,
2473,
356,
1642,
63,
354,
435,
2061,
63,
354,
12,
355,
283,
9930,
356,
11064,
12,
355,
283,
2246,
63,
354,
356,
1642,
63,
354,
12,
355,
283,
2019,
63,
354,
356,
2061,
63,
354,
12,
355,
283,
2123,
356,
3031,
93,
339,
347,
922,
63,
5087,
63,
633,
8,
277,
304,
267,
327,
675,
663,
342,
3967,
10967,
379,
607,
6918,
1380,
1338,
787,
21747,
267,
1504,
63,
6662,
83,
275,
769,
8,
409,
2941,
2246,
13,
354,
297,
283,
344,
297,
283,
2019,
13,
354,
418,
435,
1816,
291,
14,
6031,
360,
8609,
63,
4859,
4149,
297,
942,
1724,
267,
327,
922,
4069,
370,
325,
482,
314,
2295,
2851,
1683,
316,
267,
1504,
63,
6662,
83,
14,
3191,
342,
267,
1504,
63,
6662,
83,
275,
12814,
904,
8,
955,
63,
6662,
83,
9,
267,
372,
291,
14,
3791,
63,
25081,
51,
14,
908,
8,
955,
63,
6662,
83,
9,
339,
347,
922,
63,
576,
63,
2139,
8,
277,
304,
267,
6339,
275,
291,
14,
6031,
360,
27240,
63,
16632,
63,
13947,
358,
267,
340,
6339,
26,
288,
372,
469,
355,
283,
8422,
13,
8493,
356,
6339,
340,
6339,
365,
440,
715,
3147,
587,
291,
14,
8590,
14,
362,
63,
3671,
342,
288,
789,
421,
199,
533,
10967,
379,
262,
12906,
8,
1563,
26748,
262,
2817,
12,
3523,
12906,
17,
304,
272,
408,
26748,
262,
11715,
6299,
4865,
624,
272,
536,
275,
283,
12751,
262,
7,
272,
428,
1439,
1510,
63,
15828,
275,
20246,
272,
7560,
7123,
2594,
63,
2632,
275,
283,
2859,
921,
1544,
14,
12751,
262,
14,
957,
15,
85,
305,
15,
6126,
15,
13975,
7,
272,
31325,
63,
8803,
63,
2632,
275,
283,
2859,
921,
1246,
14,
12751,
262,
14,
957,
15,
85,
305,
15,
6126,
15,
1069,
3264,
7,
272,
437,
10203,
63,
8803,
63,
2632,
275,
283,
2859,
921,
1246,
14,
12751,
262,
14,
957,
15,
85,
305,
15,
6126,
15,
2732,
3264,
7,
339,
347,
922,
63,
576,
8,
277,
12,
2879,
63,
1418,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
1767,
922,
666,
2741,
624,
267,
372,
291,
14,
362,
63,
1001,
8,
288,
291,
14,
751,
63,
5087,
63,
633,
1062,
288,
1862,
3713,
908,
356,
283,
1001,
2267,
288,
1790,
29,
277,
14,
6126,
63,
1178,
8,
2732,
63,
1418,
395,
288,
2323,
29,
277,
14,
751,
63,
576,
63,
2139,
342,
267,
776,
339,
347,
625,
11497,
63,
1418,
8,
277,
304,
267,
408,
27142,
1642,
1056,
370,
9725,
14,
1803,
376,
625,
11497,
8767,
1041,
267,
4194,
275,
291,
14,
362,
63,
2645,
342,
503,
2125,
267,
340,
4194,
26,
288,
4194,
275,
8720,
2645,
534,
435,
291,
14,
17998,
63,
15828,
14,
904,
8,
2645,
9,
267,
372,
291,
14,
1069,
8,
277,
14,
6780,
63,
8803,
63,
2632,
435,
4194,
12,
1169,
1862,
29,
277,
14,
1069,
63,
1418,
63,
2911,
63,
4958,
1062,
1169,
1790,
29,
277,
14,
6126,
63,
1178,
8801,
505,
421,
199,
533,
10967,
379,
262,
12906,
18,
8,
1563,
26748,
262,
2817,
12,
3523,
12906,
18,
304,
272,
536,
275,
283,
12751,
262,
13,
6126,
18,
7,
272,
428,
1439,
1510,
63,
15828,
275,
283,
283,
272,
7560,
7123,
2594,
63,
2632,
275,
283,
2859,
921,
1544,
14,
12751,
262,
14,
957,
15,
85,
305,
15,
6126,
18,
15,
15846,
7,
272,
437,
10203,
63,
8803,
63,
2632,
275,
283,
2859,
921,
1544,
14,
12751,
262,
14,
957,
15,
85,
305,
15,
6126,
18,
15,
2732,
3264,
7,
272,
437,
10203,
63,
8803,
63,
9977,
275,
283,
4030,
7,
272,
820,
7458,
4168,
63,
6689,
275,
756,
339,
347,
922,
63,
576,
8,
277,
12,
2879,
63,
1418,
12,
627,
589,
12,
1011,
958,
304,
267,
372,
291,
14,
362,
63,
1001,
8,
288,
291,
14,
751,
63,
5087,
63,
633,
1062,
288,
1862,
3713,
6126,
18,
63,
2732,
63,
1418,
356,
2879,
63,
1418,
12,
490,
283,
908,
356,
283,
1001,
2267,
288,
2323,
29,
277,
14,
751,
63,
576,
63,
2139,
342,
267,
776,
339,
347,
1056,
63,
2732,
63,
1418,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
327,
10967,
379,
607,
14292,
282,
8761,
1056,
543,
1827,
875,
2633,
12,
477,
681,
1175,
267,
327,
314,
3158,
1455,
921,
2537,
14,
15799,
14,
1308,
15,
1360,
15,
8973,
10393,
25,
3,
2792,
13,
20,
14,
17,
14,
19,
267,
2074,
459,
1162,
418,
275,
2074,
14,
1935,
360,
576,
358,
267,
372,
1613,
8,
26748,
262,
12906,
18,
12,
291,
680,
1069,
63,
2732,
63,
1418,
8,
288,
627,
589,
12,
1011,
958,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
franek/weboob
|
modules/cappedtv/backend.py
|
1
|
2351
|
# -*- coding: utf-8 -*-
# Copyright(C) 2012 Lord
#
# This module is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
from __future__ import with_statement
from weboob.capabilities.video import ICapVideo, BaseVideo
from weboob.capabilities.collection import ICapCollection, CollectionNotFound
from weboob.tools.backend import BaseBackend
from .browser import CappedBrowser, CappedVideo
__all__ = ['CappedBackend']
class CappedBackend(BaseBackend, ICapVideo, ICapCollection):
NAME = 'cappedtv'
MAINTAINER = u'Lord'
EMAIL = 'lord@lordtoniok.com'
VERSION = '0.f'
DESCRIPTION = 'Capped.tv demoscene website'
LICENSE = 'WTFPLv2'
BROWSER = CappedBrowser
def get_video(self, _id):
with self.browser:
return self.browser.get_video(_id)
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=None, max_results=None):
with self.browser:
return self.browser.search_videos(pattern)
def fill_video(self, video, fields):
if fields != ['thumbnail']:
with self.browser:
video = self.browser.get_video(CappedVideo.id2url(video.id), video)
if 'thumbnail' in fields and video.thumbnail:
with self.browser:
video.thumbnail.data = self.browser.readurl(video.thumbnail.url)
return video
def iter_resources(self, objs, split_path):
if BaseVideo in objs:
collection = self.get_collection(objs, split_path)
if collection.path_level == 0:
yield self.get_collection(objs, [u'latest'])
if collection.split_path == [u'latest']:
for video in self.browser.latest_videos():
yield video
def validate_collection(self, objs, collection):
if collection.path_level == 0:
return
if BaseVideo in objs and collection.split_path == [u'latest']:
collection.title = u'Latest CappedTV videos'
return
raise CollectionNotFound(collection.split_path)
OBJECTS = {CappedVideo: fill_video}
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
8,
35,
9,
6029,
491,
2181,
199,
3,
199,
3,
961,
859,
365,
2867,
2032,
14,
2779,
12477,
1928,
1263,
3750,
12,
370,
199,
3,
314,
13675,
8211,
701,
3964,
4179,
14,
2047,
883,
3604,
652,
199,
3,
436,
15,
269,
2811,
652,
1334,
314,
2895,
402,
314,
4226,
14791,
710,
481,
10112,
2047,
644,
867,
199,
3,
4005,
1684,
844,
12,
3394,
499,
12,
465,
3267,
701,
428,
455,
28673,
301,
1391,
14,
1666,
199,
3,
1455,
921,
21660,
14,
18070,
89,
14,
1308,
15,
87,
3249,
1168,
15,
16188,
1206,
367,
1655,
2436,
14,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
504,
29896,
14,
10732,
14,
3722,
492,
473,
9155,
9166,
12,
3523,
9166,
199,
504,
29896,
14,
10732,
14,
3627,
492,
473,
9155,
7768,
12,
18003,
4667,
199,
504,
29896,
14,
2537,
14,
4620,
492,
3523,
8447,
199,
504,
1275,
5750,
492,
22516,
1915,
11930,
12,
22516,
1915,
9166,
421,
199,
363,
452,
363,
275,
788,
9155,
1915,
8447,
418,
421,
199,
533,
22516,
1915,
8447,
8,
1563,
8447,
12,
473,
9155,
9166,
12,
473,
9155,
7768,
304,
272,
13637,
275,
283,
2874,
1915,
6993,
7,
272,
4828,
2919,
9021,
540,
275,
399,
7,
44,
2181,
7,
272,
32320,
275,
283,
76,
2181,
32,
76,
2181,
1860,
73,
745,
14,
957,
7,
272,
15945,
275,
283,
16,
14,
70,
7,
272,
17410,
1075,
275,
283,
9155,
1915,
14,
6993,
14779,
10436,
10691,
7,
272,
5113,
275,
283,
55,
6145,
2749,
86,
18,
7,
272,
699,
11415,
3279,
275,
22516,
1915,
11930,
339,
347,
664,
63,
3722,
8,
277,
12,
485,
344,
304,
267,
543,
291,
14,
5750,
26,
288,
372,
291,
14,
5750,
14,
362,
63,
3722,
1547,
344,
9,
339,
347,
2754,
63,
11418,
8,
277,
12,
3851,
12,
4069,
991,
29,
948,
439,
9166,
14,
15962,
63,
907,
906,
54,
7140,
12,
700,
8835,
29,
403,
12,
1390,
63,
2604,
29,
403,
304,
267,
543,
291,
14,
5750,
26,
288,
372,
291,
14,
5750,
14,
1733,
63,
11418,
8,
3401,
9,
339,
347,
5554,
63,
3722,
8,
277,
12,
3991,
12,
1504,
304,
267,
340,
1504,
1137,
788,
8311,
2565,
288,
543,
291,
14,
5750,
26,
355,
3991,
275,
291,
14,
5750,
14,
362,
63,
3722,
8,
9155,
1915,
9166,
14,
344,
18,
633,
8,
3722,
14,
344,
395,
3991,
9,
267,
340,
283,
8311,
7,
315,
1504,
436,
3991,
14,
8311,
26,
288,
543,
291,
14,
5750,
26,
355,
3991,
14,
8311,
14,
576,
275,
291,
14,
5750,
14,
739,
633,
8,
3722,
14,
8311,
14,
633,
9,
398,
372,
3991,
339,
347,
2740,
63,
4435,
8,
277,
12,
13474,
12,
3715,
63,
515,
304,
267,
340,
3523,
9166,
315,
13474,
26,
288,
3245,
275,
291,
14,
362,
63,
3627,
8,
8718,
12,
3715,
63,
515,
9,
288,
340,
3245,
14,
515,
63,
1896,
508,
378,
26,
355,
1995,
291,
14,
362,
63,
3627,
8,
8718,
12,
359,
85,
7,
7410,
1105,
288,
340,
3245,
14,
1294,
63,
515,
508,
359,
85,
7,
7410,
2565,
355,
367,
3991,
315,
291,
14,
5750,
14,
7410,
63,
11418,
837,
490,
1995,
3991,
339,
347,
4107,
63,
3627,
8,
277,
12,
13474,
12,
3245,
304,
267,
340,
3245,
14,
515,
63,
1896,
508,
378,
26,
288,
372,
267,
340,
3523,
9166,
315,
13474,
436,
3245,
14,
1294,
63,
515,
508,
359,
85,
7,
7410,
2565,
288,
3245,
14,
1213,
275,
399,
7,
31438,
22516,
1915,
12764,
22010,
7,
288,
372,
267,
746,
18003,
4667,
8,
3627,
14,
1294,
63,
515,
9,
339,
28652,
5550,
51,
275,
469,
9155,
1915,
9166,
26,
5554,
63,
3722,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
8,
35,
9,
6029,
491,
2181,
199,
3,
199,
3,
961,
859,
365,
2867,
2032,
14,
2779,
12477,
1928,
1263,
3750,
12,
370,
199,
3,
314,
13675,
8211,
701,
3964,
4179,
14,
2047,
883,
3604,
652,
199,
3,
436,
15,
269,
2811,
652,
1334,
314,
2895,
402,
314,
4226,
14791,
710,
481,
10112,
2047,
644,
867,
199,
3,
4005,
1684,
844,
12,
3394,
499,
12,
465,
3267,
701,
428,
455,
28673,
301,
1391,
14,
1666,
199,
3,
1455,
921,
21660,
14,
18070,
89,
14,
1308,
15,
87,
3249,
1168,
15,
16188,
1206,
367,
1655,
2436,
14,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
504,
29896,
14,
10732,
14,
3722,
492,
473,
9155,
9166,
12,
3523,
9166,
199,
504,
29896,
14,
10732,
14,
3627,
492,
473,
9155,
7768,
12,
18003,
4667,
199,
504,
29896,
14,
2537,
14,
4620,
492,
3523,
8447,
199,
504,
1275,
5750,
492,
22516,
1915,
11930,
12,
22516,
1915,
9166,
421,
199,
363,
452,
363,
275,
788,
9155,
1915,
8447,
418,
421,
199,
533,
22516,
1915,
8447,
8,
1563,
8447,
12,
473,
9155,
9166,
12,
473,
9155,
7768,
304,
272,
13637,
275,
283,
2874,
1915,
6993,
7,
272,
4828,
2919,
9021,
540,
275,
399,
7,
44,
2181,
7,
272,
32320,
275,
283,
76,
2181,
32,
76,
2181,
1860,
73,
745,
14,
957,
7,
272,
15945,
275,
283,
16,
14,
70,
7,
272,
17410,
1075,
275,
283,
9155,
1915,
14,
6993,
14779,
10436,
10691,
7,
272,
5113,
275,
283,
55,
6145,
2749,
86,
18,
7,
272,
699,
11415,
3279,
275,
22516,
1915,
11930,
339,
347,
664,
63,
3722,
8,
277,
12,
485,
344,
304,
267,
543,
291,
14,
5750,
26,
288,
372,
291,
14,
5750,
14,
362,
63,
3722,
1547,
344,
9,
339,
347,
2754,
63,
11418,
8,
277,
12,
3851,
12,
4069,
991,
29,
948,
439,
9166,
14,
15962,
63,
907,
906,
54,
7140,
12,
700,
8835,
29,
403,
12,
1390,
63,
2604,
29,
403,
304,
267,
543,
291,
14,
5750,
26,
288,
372,
291,
14,
5750,
14,
1733,
63,
11418,
8,
3401,
9,
339,
347,
5554,
63,
3722,
8,
277,
12,
3991,
12,
1504,
304,
267,
340,
1504,
1137,
788,
8311,
2565,
288,
543,
291,
14,
5750,
26,
355,
3991,
275,
291,
14,
5750,
14,
362,
63,
3722,
8,
9155,
1915,
9166,
14,
344,
18,
633,
8,
3722,
14,
344,
395,
3991,
9,
267,
340,
283,
8311,
7,
315,
1504,
436,
3991,
14,
8311,
26,
288,
543,
291,
14,
5750,
26,
355,
3991,
14,
8311,
14,
576,
275,
291,
14,
5750,
14,
739,
633,
8,
3722,
14,
8311,
14,
633,
9,
398,
372,
3991,
339,
347,
2740,
63,
4435,
8,
277,
12,
13474,
12,
3715,
63,
515,
304,
267,
340,
3523,
9166,
315,
13474,
26,
288,
3245,
275,
291,
14,
362,
63,
3627,
8,
8718,
12,
3715,
63,
515,
9,
288,
340,
3245,
14,
515,
63,
1896,
508,
378,
26,
355,
1995,
291,
14,
362,
63,
3627,
8,
8718,
12,
359,
85,
7,
7410,
1105,
288,
340,
3245,
14,
1294,
63,
515,
508,
359,
85,
7,
7410,
2565,
355,
367,
3991,
315,
291,
14,
5750,
14,
7410,
63,
11418,
837,
490,
1995,
3991,
339,
347,
4107,
63,
3627,
8,
277,
12,
13474,
12,
3245,
304,
267,
340,
3245,
14,
515,
63,
1896,
508,
378,
26,
288,
372,
267,
340,
3523,
9166,
315,
13474,
436,
3245,
14,
1294,
63,
515,
508,
359,
85,
7,
7410,
2565,
288,
3245,
14,
1213,
275,
399,
7,
31438,
22516,
1915,
12764,
22010,
7,
288,
372,
267,
746,
18003,
4667,
8,
3627,
14,
1294,
63,
515,
9,
339,
28652,
5550,
51,
275,
469,
9155,
1915,
9166,
26,
5554,
63,
3722,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
patricklam/signup-sheet
|
signup/views.py
|
1
|
5682
|
import re
from django.shortcuts import render
from signup.models import Slot, Signup, GroupMembership
def has_group(user):
return GroupMembership.objects.filter(watid=user).exists()
def find_group(user):
return GroupMembership.objects.filter(watid=user).first().group_id if has_group(user) else 'None'
def is_member(user, group):
return group == find_group(user)
def can_release(uid, slot, as_superuser):
rv = False
taken = slot.signup_set.exists()
if taken: rv = is_member(uid, slot.signup_set.first().group_id) or as_superuser
return rv
release_re = re.compile('release_([0-9]+)')
request_re = re.compile('request_([0-9]+)')
def index(request):
params = request.POST
uid = request.user.username
as_superuser = request.user.is_superuser and not('fake' in params and params['fake'] != '')
if request.user.is_superuser and 'fakewatid' in params and params['fakewatid'] != '':
uid = params['fakewatid']
slot_list = Slot.objects.all()
info = []
already_have_one = False
for slot in slot_list:
if slot.signup_set.exists() and is_member(uid, slot.signup_set.first().group_id):
already_have_one = True
for key, value in params.iteritems():
rel = release_re.match(key)
if rel:
slot_id = rel.group(1)
slot = Slot.objects.filter(id=slot_id).first()
if (can_release(uid, slot, as_superuser)):
signup_id = slot.signup_set.first().id
Signup.objects.filter(id=signup_id).delete()
already_have_one = False
req = request_re.match(key)
if req:
slot_id = req.group(1)
slot = Slot.objects.filter(id=slot_id).first()
taken = slot.signup_set.exists()
if not taken and not already_have_one and has_group(uid):
Signup(slot=slot, group_id=find_group(uid),
signup_watid=uid).save()
for slot in slot_list:
taken = slot.signup_set.exists()
allowed_options = ''
if can_release(uid, slot, as_superuser):
allowed_options += '<input class="btn btn-default" type="submit" name="release_{0}" value="Release">'.format(slot.id)
if not taken and not already_have_one and has_group(uid):
allowed_options += '<input class="btn btn-default" type="submit" name="request_{0}" value="Request">'.format(slot.id)
info.append((slot,
slot.signup_set.get().str_without_slot() if taken else '',
allowed_options))
context = {'info': info,
'who' : uid,
'effective_who': 'root' if as_superuser else uid,
'asroot': 'checked' if not as_superuser else ''}
return render(request, 'signup/index.html', context)
from datetime import datetime, timedelta
import pytz
import string
import random
def init(request):
if not request.user.is_superuser: return render(request, 'signup/index.html', {})
params = request.POST
msgs = ''
if 'slots' in params and params['slots'] == 'reset':
eastern=pytz.timezone('US/Eastern')
Slot.objects.all().delete()
for d in range(0,3):
for t in range(0,6):
Slot(time=(eastern.localize(datetime(2014,6,18,10,30)) + timedelta(minutes=t*20) + timedelta(days=d*7))).save()
msgs = msgs + "Re-initialized slots.<br />"
if 'groupinfo' in params and len(params['groupinfo']) > 0:
GroupMembership.objects.all().delete()
ext = '.txt'; group_count = 0; student_count = 0
for line in params['groupinfo'].splitlines():
# could also have used a regexp below
if (line.count(':') != 2): continue
group_namet, dummy, users = map(lambda x: x.strip(), line.split(':'))
if (not (group_namet.endswith(ext))): msgs.append('Ignoring line {0}<br>'.format(line)); continue
group_name = group_namet[0:len(group_namet)-len(ext)]
if (dummy != 'Group UW userids'): msgs.append('Ignoring line {0}<br>'.format(line)); continue
user_list = map(lambda x: x.strip(), users.split(','))
group_count = group_count + 1
for user in user_list:
GroupMembership(watid = user, group_id = group_name).save()
student_count = student_count + 1
msgs = msgs + \
'Success! Added {0} groups with {1} students.<br />'.format(group_count,
student_count)
if 'signups' in params:
if (params['signups'] == 'reset'):
Signup.objects.all().delete()
msgs = msgs + 'Cleared signups.<br />'
if (params['signups'] == 'dummy'):
Signup.objects.all().delete()
all_slots = []
for s in Slot.objects.all(): all_slots.append(s)
random.shuffle(all_slots)
all_gms = []
for gm in GroupMembership.objects.all(): all_gms.append(gm)
random.shuffle(all_gms)
for s in range(0,18):
Signup(slot=all_slots[s], group_id=all_gms[s].group_id,
signup_watid=all_gms[s].watid).save()
# also, go through and remove all future refs to group that just got added.
for i in range(s+1, len(all_gms)):
while (i < len(all_gms) and all_gms[s].group_id == all_gms[i].group_id):
all_gms.remove(all_gms[i])
msgs = msgs + 'Populated with dummy signups.<br />'
return render(request, 'signup/init.html', {'msgs': msgs})
|
mit
|
[
646,
295,
199,
504,
1639,
14,
17469,
492,
3795,
199,
504,
2070,
384,
14,
992,
492,
428,
1653,
12,
6632,
384,
12,
5611,
19480,
199,
199,
318,
965,
63,
923,
8,
751,
304,
272,
372,
5611,
19480,
14,
1462,
14,
1541,
8,
758,
5700,
29,
751,
680,
2444,
342,
199,
199,
318,
2342,
63,
923,
8,
751,
304,
272,
372,
5611,
19480,
14,
1462,
14,
1541,
8,
758,
5700,
29,
751,
680,
2246,
1252,
923,
63,
344,
340,
965,
63,
923,
8,
751,
9,
587,
283,
403,
7,
199,
199,
318,
365,
63,
1114,
8,
751,
12,
1572,
304,
272,
372,
1572,
508,
2342,
63,
923,
8,
751,
9,
199,
199,
318,
883,
63,
3221,
8,
1535,
12,
9348,
12,
465,
63,
11434,
304,
272,
4336,
275,
756,
272,
9394,
275,
9348,
14,
19799,
63,
409,
14,
2444,
342,
272,
340,
9394,
26,
4336,
275,
365,
63,
1114,
8,
1535,
12,
9348,
14,
19799,
63,
409,
14,
2246,
1252,
923,
63,
344,
9,
503,
465,
63,
11434,
272,
372,
4336,
199,
199,
3221,
63,
264,
275,
295,
14,
2014,
360,
3221,
63,
779,
16,
13,
25,
2807,
5942,
199,
1069,
63,
264,
275,
295,
14,
2014,
360,
1069,
63,
779,
16,
13,
25,
2807,
5942,
199,
318,
1478,
8,
1069,
304,
272,
1862,
275,
1056,
14,
4030,
272,
1747,
275,
1056,
14,
751,
14,
2473,
272,
465,
63,
11434,
275,
1056,
14,
751,
14,
374,
63,
11434,
436,
440,
360,
3183,
7,
315,
1862,
436,
1862,
459,
3183,
418,
1137,
4074,
272,
340,
1056,
14,
751,
14,
374,
63,
11434,
436,
283,
3183,
758,
5700,
7,
315,
1862,
436,
1862,
459,
3183,
758,
5700,
418,
1137,
8061,
4960,
1747,
275,
1862,
459,
3183,
758,
5700,
418,
272,
9348,
63,
513,
275,
428,
1653,
14,
1462,
14,
452,
342,
272,
2256,
275,
942,
339,
2575,
63,
7804,
63,
368,
275,
756,
272,
367,
9348,
315,
9348,
63,
513,
26,
267,
340,
9348,
14,
19799,
63,
409,
14,
2444,
342,
436,
365,
63,
1114,
8,
1535,
12,
9348,
14,
19799,
63,
409,
14,
2246,
1252,
923,
63,
344,
304,
288,
2575,
63,
7804,
63,
368,
275,
715,
339,
367,
790,
12,
574,
315,
1862,
14,
4611,
837,
267,
4668,
275,
4683,
63,
264,
14,
1431,
8,
498,
9,
267,
340,
4668,
26,
288,
9348,
63,
344,
275,
4668,
14,
923,
8,
17,
9,
288,
9348,
275,
428,
1653,
14,
1462,
14,
1541,
8,
344,
29,
7998,
63,
344,
680,
2246,
342,
288,
340,
334,
2425,
63,
3221,
8,
1535,
12,
9348,
12,
465,
63,
11434,
2298,
8892,
2070,
384,
63,
344,
275,
9348,
14,
19799,
63,
409,
14,
2246,
1252,
344,
355,
6632,
384,
14,
1462,
14,
1541,
8,
344,
29,
19799,
63,
344,
680,
1807,
342,
355,
2575,
63,
7804,
63,
368,
275,
756,
267,
2648,
275,
1056,
63,
264,
14,
1431,
8,
498,
9,
267,
340,
2648,
26,
288,
9348,
63,
344,
275,
2648,
14,
923,
8,
17,
9,
288,
9348,
275,
428,
1653,
14,
1462,
14,
1541,
8,
344,
29,
7998,
63,
344,
680,
2246,
342,
288,
9394,
275,
9348,
14,
19799,
63,
409,
14,
2444,
342,
288,
340,
440,
9394,
436,
440,
2575,
63,
7804,
63,
368,
436,
965,
63,
923,
8,
1535,
304,
355,
6632,
384,
8,
7998,
29,
7998,
12,
1572,
63,
344,
29,
1623,
63,
923,
8,
1535,
395,
2432,
2070,
384,
63,
758,
5700,
29,
1535,
680,
2117,
342,
339,
367,
9348,
315,
9348,
63,
513,
26,
267,
9394,
275,
9348,
14,
19799,
63,
409,
14,
2444,
342,
398,
4370,
63,
1419,
275,
2125,
267,
340,
883,
63,
3221,
8,
1535,
12,
9348,
12,
465,
63,
11434,
304,
7205,
4370,
63,
1419,
847,
2650,
1210,
1021,
628,
9633,
19368,
13,
885,
2,
730,
628,
7275,
2,
536,
628,
3221,
7348,
16,
7063,
574,
628,
9625,
1743,
1370,
908,
8,
7998,
14,
344,
9,
267,
340,
440,
9394,
436,
440,
2575,
63,
7804,
63,
368,
436,
965,
63,
923,
8,
1535,
304,
288,
4370,
63,
1419,
847,
2650,
1210,
1021,
628,
9633,
19368,
13,
885,
2,
730,
628,
7275,
2,
536,
628,
1069,
7348,
16,
7063,
574,
628,
2017,
1743,
1370,
908,
8,
7998,
14,
344,
9,
398,
2256,
14,
740,
1332,
7998,
12,
2151,
9348,
14,
19799,
63,
409,
14,
362,
1252,
495,
63,
7395,
63,
7998,
342,
340,
9394,
587,
3260,
2151,
4370,
63,
1419,
430,
272,
1067,
275,
791,
815,
356,
2256,
12,
19056,
283,
11345,
7,
520,
1747,
12,
2049,
283,
20427,
63,
11345,
356,
283,
1231,
7,
340,
465,
63,
11434,
587,
1747,
12,
19056,
283,
305,
1231,
356,
283,
10718,
7,
340,
440,
465,
63,
11434,
587,
28174,
272,
372,
3795,
8,
1069,
12,
283,
19799,
15,
1080,
14,
1360,
297,
1067,
9,
199,
199,
504,
2197,
492,
2197,
12,
6871,
199,
646,
15444,
199,
646,
1059,
199,
646,
2196,
199,
199,
318,
4205,
8,
1069,
304,
272,
340,
440,
1056,
14,
751,
14,
374,
63,
11434,
26,
372,
3795,
8,
1069,
12,
283,
19799,
15,
1080,
14,
1360,
297,
5009,
339,
1862,
275,
1056,
14,
4030,
272,
17599,
275,
2125,
339,
340,
283,
7257,
7,
315,
1862,
436,
1862,
459,
7257,
418,
508,
283,
3958,
356,
267,
9600,
1203,
29,
21948,
14,
7145,
360,
1668,
15,
32661,
358,
267,
428,
1653,
14,
1462,
14,
452,
1252,
1807,
342,
267,
367,
366,
315,
1425,
8,
16,
12,
19,
304,
288,
367,
307,
315,
1425,
8,
16,
12,
22,
304,
355,
428,
1653,
8,
521,
2687,
69,
24541,
14,
21279,
8,
2083,
8,
7280,
12,
22,
12,
1085,
12,
709,
12,
1216,
430,
435,
6871,
8,
10430,
29,
84,
10,
1165,
9,
435,
6871,
8,
4899,
29,
68,
10,
23,
23261,
2117,
342,
267,
17599,
275,
17599,
435,
298,
497,
13,
12486,
14319,
21455,
3289,
1182,
4335,
339,
340,
283,
923,
815,
7,
315,
1862,
436,
822,
8,
1162,
459,
923,
815,
1105,
690,
378,
26,
267,
5611,
19480,
14,
1462,
14,
452,
1252,
1807,
342,
267,
1599,
275,
1987,
2424,
13619,
1572,
63,
835,
275,
378,
27,
6474,
63,
835,
275,
378,
267,
367,
1004,
315,
1862,
459,
923,
815,
2278,
7644,
837,
288,
327,
4293,
2597,
1172,
1202,
282,
13156,
5084,
288
] |
[
295,
199,
504,
1639,
14,
17469,
492,
3795,
199,
504,
2070,
384,
14,
992,
492,
428,
1653,
12,
6632,
384,
12,
5611,
19480,
199,
199,
318,
965,
63,
923,
8,
751,
304,
272,
372,
5611,
19480,
14,
1462,
14,
1541,
8,
758,
5700,
29,
751,
680,
2444,
342,
199,
199,
318,
2342,
63,
923,
8,
751,
304,
272,
372,
5611,
19480,
14,
1462,
14,
1541,
8,
758,
5700,
29,
751,
680,
2246,
1252,
923,
63,
344,
340,
965,
63,
923,
8,
751,
9,
587,
283,
403,
7,
199,
199,
318,
365,
63,
1114,
8,
751,
12,
1572,
304,
272,
372,
1572,
508,
2342,
63,
923,
8,
751,
9,
199,
199,
318,
883,
63,
3221,
8,
1535,
12,
9348,
12,
465,
63,
11434,
304,
272,
4336,
275,
756,
272,
9394,
275,
9348,
14,
19799,
63,
409,
14,
2444,
342,
272,
340,
9394,
26,
4336,
275,
365,
63,
1114,
8,
1535,
12,
9348,
14,
19799,
63,
409,
14,
2246,
1252,
923,
63,
344,
9,
503,
465,
63,
11434,
272,
372,
4336,
199,
199,
3221,
63,
264,
275,
295,
14,
2014,
360,
3221,
63,
779,
16,
13,
25,
2807,
5942,
199,
1069,
63,
264,
275,
295,
14,
2014,
360,
1069,
63,
779,
16,
13,
25,
2807,
5942,
199,
318,
1478,
8,
1069,
304,
272,
1862,
275,
1056,
14,
4030,
272,
1747,
275,
1056,
14,
751,
14,
2473,
272,
465,
63,
11434,
275,
1056,
14,
751,
14,
374,
63,
11434,
436,
440,
360,
3183,
7,
315,
1862,
436,
1862,
459,
3183,
418,
1137,
4074,
272,
340,
1056,
14,
751,
14,
374,
63,
11434,
436,
283,
3183,
758,
5700,
7,
315,
1862,
436,
1862,
459,
3183,
758,
5700,
418,
1137,
8061,
4960,
1747,
275,
1862,
459,
3183,
758,
5700,
418,
272,
9348,
63,
513,
275,
428,
1653,
14,
1462,
14,
452,
342,
272,
2256,
275,
942,
339,
2575,
63,
7804,
63,
368,
275,
756,
272,
367,
9348,
315,
9348,
63,
513,
26,
267,
340,
9348,
14,
19799,
63,
409,
14,
2444,
342,
436,
365,
63,
1114,
8,
1535,
12,
9348,
14,
19799,
63,
409,
14,
2246,
1252,
923,
63,
344,
304,
288,
2575,
63,
7804,
63,
368,
275,
715,
339,
367,
790,
12,
574,
315,
1862,
14,
4611,
837,
267,
4668,
275,
4683,
63,
264,
14,
1431,
8,
498,
9,
267,
340,
4668,
26,
288,
9348,
63,
344,
275,
4668,
14,
923,
8,
17,
9,
288,
9348,
275,
428,
1653,
14,
1462,
14,
1541,
8,
344,
29,
7998,
63,
344,
680,
2246,
342,
288,
340,
334,
2425,
63,
3221,
8,
1535,
12,
9348,
12,
465,
63,
11434,
2298,
8892,
2070,
384,
63,
344,
275,
9348,
14,
19799,
63,
409,
14,
2246,
1252,
344,
355,
6632,
384,
14,
1462,
14,
1541,
8,
344,
29,
19799,
63,
344,
680,
1807,
342,
355,
2575,
63,
7804,
63,
368,
275,
756,
267,
2648,
275,
1056,
63,
264,
14,
1431,
8,
498,
9,
267,
340,
2648,
26,
288,
9348,
63,
344,
275,
2648,
14,
923,
8,
17,
9,
288,
9348,
275,
428,
1653,
14,
1462,
14,
1541,
8,
344,
29,
7998,
63,
344,
680,
2246,
342,
288,
9394,
275,
9348,
14,
19799,
63,
409,
14,
2444,
342,
288,
340,
440,
9394,
436,
440,
2575,
63,
7804,
63,
368,
436,
965,
63,
923,
8,
1535,
304,
355,
6632,
384,
8,
7998,
29,
7998,
12,
1572,
63,
344,
29,
1623,
63,
923,
8,
1535,
395,
2432,
2070,
384,
63,
758,
5700,
29,
1535,
680,
2117,
342,
339,
367,
9348,
315,
9348,
63,
513,
26,
267,
9394,
275,
9348,
14,
19799,
63,
409,
14,
2444,
342,
398,
4370,
63,
1419,
275,
2125,
267,
340,
883,
63,
3221,
8,
1535,
12,
9348,
12,
465,
63,
11434,
304,
7205,
4370,
63,
1419,
847,
2650,
1210,
1021,
628,
9633,
19368,
13,
885,
2,
730,
628,
7275,
2,
536,
628,
3221,
7348,
16,
7063,
574,
628,
9625,
1743,
1370,
908,
8,
7998,
14,
344,
9,
267,
340,
440,
9394,
436,
440,
2575,
63,
7804,
63,
368,
436,
965,
63,
923,
8,
1535,
304,
288,
4370,
63,
1419,
847,
2650,
1210,
1021,
628,
9633,
19368,
13,
885,
2,
730,
628,
7275,
2,
536,
628,
1069,
7348,
16,
7063,
574,
628,
2017,
1743,
1370,
908,
8,
7998,
14,
344,
9,
398,
2256,
14,
740,
1332,
7998,
12,
2151,
9348,
14,
19799,
63,
409,
14,
362,
1252,
495,
63,
7395,
63,
7998,
342,
340,
9394,
587,
3260,
2151,
4370,
63,
1419,
430,
272,
1067,
275,
791,
815,
356,
2256,
12,
19056,
283,
11345,
7,
520,
1747,
12,
2049,
283,
20427,
63,
11345,
356,
283,
1231,
7,
340,
465,
63,
11434,
587,
1747,
12,
19056,
283,
305,
1231,
356,
283,
10718,
7,
340,
440,
465,
63,
11434,
587,
28174,
272,
372,
3795,
8,
1069,
12,
283,
19799,
15,
1080,
14,
1360,
297,
1067,
9,
199,
199,
504,
2197,
492,
2197,
12,
6871,
199,
646,
15444,
199,
646,
1059,
199,
646,
2196,
199,
199,
318,
4205,
8,
1069,
304,
272,
340,
440,
1056,
14,
751,
14,
374,
63,
11434,
26,
372,
3795,
8,
1069,
12,
283,
19799,
15,
1080,
14,
1360,
297,
5009,
339,
1862,
275,
1056,
14,
4030,
272,
17599,
275,
2125,
339,
340,
283,
7257,
7,
315,
1862,
436,
1862,
459,
7257,
418,
508,
283,
3958,
356,
267,
9600,
1203,
29,
21948,
14,
7145,
360,
1668,
15,
32661,
358,
267,
428,
1653,
14,
1462,
14,
452,
1252,
1807,
342,
267,
367,
366,
315,
1425,
8,
16,
12,
19,
304,
288,
367,
307,
315,
1425,
8,
16,
12,
22,
304,
355,
428,
1653,
8,
521,
2687,
69,
24541,
14,
21279,
8,
2083,
8,
7280,
12,
22,
12,
1085,
12,
709,
12,
1216,
430,
435,
6871,
8,
10430,
29,
84,
10,
1165,
9,
435,
6871,
8,
4899,
29,
68,
10,
23,
23261,
2117,
342,
267,
17599,
275,
17599,
435,
298,
497,
13,
12486,
14319,
21455,
3289,
1182,
4335,
339,
340,
283,
923,
815,
7,
315,
1862,
436,
822,
8,
1162,
459,
923,
815,
1105,
690,
378,
26,
267,
5611,
19480,
14,
1462,
14,
452,
1252,
1807,
342,
267,
1599,
275,
1987,
2424,
13619,
1572,
63,
835,
275,
378,
27,
6474,
63,
835,
275,
378,
267,
367,
1004,
315,
1862,
459,
923,
815,
2278,
7644,
837,
288,
327,
4293,
2597,
1172,
1202,
282,
13156,
5084,
288,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
emonty/ansible
|
lib/ansible/modules/files/stat.py
|
20
|
19092
|
#!/usr/bin/python
# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = r'''
---
module: stat
version_added: "1.3"
short_description: Retrieve file or file system status
description:
- Retrieves facts for a file similar to the Linux/Unix 'stat' command.
- For Windows targets, use the M(win_stat) module instead.
options:
path:
description:
- The full path of the file/object to get the facts of.
type: path
required: true
aliases: [ dest, name ]
follow:
description:
- Whether to follow symlinks.
type: bool
default: no
get_checksum:
description:
- Whether to return a checksum of the file.
type: bool
default: yes
version_added: "1.8"
checksum_algorithm:
description:
- Algorithm to determine checksum of file.
- Will throw an error if the host is unable to use specified algorithm.
- The remote host has to support the hashing method specified, C(md5)
can be unavailable if the host is FIPS-140 compliant.
type: str
choices: [ md5, sha1, sha224, sha256, sha384, sha512 ]
default: sha1
aliases: [ checksum, checksum_algo ]
version_added: "2.0"
get_mime:
description:
- Use file magic and return data about the nature of the file. this uses
the 'file' utility found on most Linux/Unix systems.
- This will add both `mime_type` and 'charset' fields to the return, if possible.
- In Ansible 2.3 this option changed from 'mime' to 'get_mime' and the default changed to 'Yes'.
type: bool
default: yes
aliases: [ mime, mime_type, mime-type ]
version_added: "2.1"
get_attributes:
description:
- Get file attributes using lsattr tool if present.
type: bool
default: yes
aliases: [ attr, attributes ]
version_added: "2.3"
seealso:
- module: file
- module: win_stat
author: Bruce Pennypacker (@bpennypacker)
'''
EXAMPLES = r'''
# Obtain the stats of /etc/foo.conf, and check that the file still belongs
# to 'root'. Fail otherwise.
- stat:
path: /etc/foo.conf
register: st
- fail:
msg: "Whoops! file ownership has changed"
when: st.stat.pw_name != 'root'
# Determine if a path exists and is a symlink. Note that if the path does
# not exist, and we test sym.stat.islnk, it will fail with an error. So
# therefore, we must test whether it is defined.
# Run this to understand the structure, the skipped ones do not pass the
# check performed by 'when'
- stat:
path: /path/to/something
register: sym
- debug:
msg: "islnk isn't defined (path doesn't exist)"
when: sym.stat.islnk is not defined
- debug:
msg: "islnk is defined (path must exist)"
when: sym.stat.islnk is defined
- debug:
msg: "Path exists and is a symlink"
when: sym.stat.islnk is defined and sym.stat.islnk
- debug:
msg: "Path exists and isn't a symlink"
when: sym.stat.islnk is defined and sym.stat.islnk == False
# Determine if a path exists and is a directory. Note that we need to test
# both that p.stat.isdir actually exists, and also that it's set to true.
- stat:
path: /path/to/something
register: p
- debug:
msg: "Path exists and is a directory"
when: p.stat.isdir is defined and p.stat.isdir
# Don't do checksum
- stat:
path: /path/to/myhugefile
get_checksum: no
# Use sha256 to calculate checksum
- stat:
path: /path/to/something
checksum_algorithm: sha256
'''
RETURN = r'''
stat:
description: dictionary containing all the stat data, some platforms might add additional fields
returned: success
type: complex
contains:
exists:
description: If the destination path actually exists or not
returned: success
type: bool
sample: True
path:
description: The full path of the file/object to get the facts of
returned: success and if path exists
type: str
sample: '/path/to/file'
mode:
description: Unix permissions of the file in octal representation as a string
returned: success, path exists and user can read stats
type: str
sample: 1755
isdir:
description: Tells you if the path is a directory
returned: success, path exists and user can read stats
type: bool
sample: False
ischr:
description: Tells you if the path is a character device
returned: success, path exists and user can read stats
type: bool
sample: False
isblk:
description: Tells you if the path is a block device
returned: success, path exists and user can read stats
type: bool
sample: False
isreg:
description: Tells you if the path is a regular file
returned: success, path exists and user can read stats
type: bool
sample: True
isfifo:
description: Tells you if the path is a named pipe
returned: success, path exists and user can read stats
type: bool
sample: False
islnk:
description: Tells you if the path is a symbolic link
returned: success, path exists and user can read stats
type: bool
sample: False
issock:
description: Tells you if the path is a unix domain socket
returned: success, path exists and user can read stats
type: bool
sample: False
uid:
description: Numeric id representing the file owner
returned: success, path exists and user can read stats
type: int
sample: 1003
gid:
description: Numeric id representing the group of the owner
returned: success, path exists and user can read stats
type: int
sample: 1003
size:
description: Size in bytes for a plain file, amount of data for some special files
returned: success, path exists and user can read stats
type: int
sample: 203
inode:
description: Inode number of the path
returned: success, path exists and user can read stats
type: int
sample: 12758
dev:
description: Device the inode resides on
returned: success, path exists and user can read stats
type: int
sample: 33
nlink:
description: Number of links to the inode (hard links)
returned: success, path exists and user can read stats
type: int
sample: 1
atime:
description: Time of last access
returned: success, path exists and user can read stats
type: float
sample: 1424348972.575
mtime:
description: Time of last modification
returned: success, path exists and user can read stats
type: float
sample: 1424348972.575
ctime:
description: Time of last metadata update or creation (depends on OS)
returned: success, path exists and user can read stats
type: float
sample: 1424348972.575
wusr:
description: Tells you if the owner has write permission
returned: success, path exists and user can read stats
type: bool
sample: True
rusr:
description: Tells you if the owner has read permission
returned: success, path exists and user can read stats
type: bool
sample: True
xusr:
description: Tells you if the owner has execute permission
returned: success, path exists and user can read stats
type: bool
sample: True
wgrp:
description: Tells you if the owner's group has write permission
returned: success, path exists and user can read stats
type: bool
sample: False
rgrp:
description: Tells you if the owner's group has read permission
returned: success, path exists and user can read stats
type: bool
sample: True
xgrp:
description: Tells you if the owner's group has execute permission
returned: success, path exists and user can read stats
type: bool
sample: True
woth:
description: Tells you if others have write permission
returned: success, path exists and user can read stats
type: bool
sample: False
roth:
description: Tells you if others have read permission
returned: success, path exists and user can read stats
type: bool
sample: True
xoth:
description: Tells you if others have execute permission
returned: success, path exists and user can read stats
type: bool
sample: True
isuid:
description: Tells you if the invoking user's id matches the owner's id
returned: success, path exists and user can read stats
type: bool
sample: False
isgid:
description: Tells you if the invoking user's group id matches the owner's group id
returned: success, path exists and user can read stats
type: bool
sample: False
lnk_source:
description: Target of the symlink normalized for the remote filesystem
returned: success, path exists and user can read stats and the path is a symbolic link
type: str
sample: /home/foobar/21102015-1445431274-908472971
lnk_target:
description: Target of the symlink. Note that relative paths remain relative
returned: success, path exists and user can read stats and the path is a symbolic link
type: str
sample: ../foobar/21102015-1445431274-908472971
version_added: 2.4
md5:
description: md5 hash of the path; this will be removed in Ansible 2.9 in
favor of the checksum return value
returned: success, path exists and user can read stats and path
supports hashing and md5 is supported
type: str
sample: f88fa92d8cf2eeecf4c0a50ccc96d0c0
checksum:
description: hash of the path
returned: success, path exists, user can read stats, path supports
hashing and supplied checksum algorithm is available
type: str
sample: 50ba294cdf28c0d5bcde25708df53346825a429f
pw_name:
description: User name of owner
returned: success, path exists and user can read stats and installed python supports it
type: str
sample: httpd
gr_name:
description: Group name of owner
returned: success, path exists and user can read stats and installed python supports it
type: str
sample: www-data
mimetype:
description: file magic data or mime-type
returned: success, path exists and user can read stats and
installed python supports it and the `mime` option was true, will
return 'unknown' on error.
type: str
sample: application/pdf; charset=binary
charset:
description: file character set or encoding
returned: success, path exists and user can read stats and
installed python supports it and the `mime` option was true, will
return 'unknown' on error.
type: str
sample: us-ascii
readable:
description: Tells you if the invoking user has the right to read the path
returned: success, path exists and user can read the path
type: bool
sample: False
version_added: 2.2
writeable:
description: Tells you if the invoking user has the right to write the path
returned: success, path exists and user can write the path
type: bool
sample: False
version_added: 2.2
executable:
description: Tells you if the invoking user has execute permission on the path
returned: success, path exists and user can execute the path
type: bool
sample: False
version_added: 2.2
attributes:
description: list of file attributes
returned: success, path exists and user can execute the path
type: list
sample: [ immutable, extent ]
version_added: 2.3
'''
import errno
import grp
import os
import pwd
import stat
# import module snippets
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_bytes
def format_output(module, path, st):
mode = st.st_mode
# back to ansible
output = dict(
exists=True,
path=path,
mode="%04o" % stat.S_IMODE(mode),
isdir=stat.S_ISDIR(mode),
ischr=stat.S_ISCHR(mode),
isblk=stat.S_ISBLK(mode),
isreg=stat.S_ISREG(mode),
isfifo=stat.S_ISFIFO(mode),
islnk=stat.S_ISLNK(mode),
issock=stat.S_ISSOCK(mode),
uid=st.st_uid,
gid=st.st_gid,
size=st.st_size,
inode=st.st_ino,
dev=st.st_dev,
nlink=st.st_nlink,
atime=st.st_atime,
mtime=st.st_mtime,
ctime=st.st_ctime,
wusr=bool(mode & stat.S_IWUSR),
rusr=bool(mode & stat.S_IRUSR),
xusr=bool(mode & stat.S_IXUSR),
wgrp=bool(mode & stat.S_IWGRP),
rgrp=bool(mode & stat.S_IRGRP),
xgrp=bool(mode & stat.S_IXGRP),
woth=bool(mode & stat.S_IWOTH),
roth=bool(mode & stat.S_IROTH),
xoth=bool(mode & stat.S_IXOTH),
isuid=bool(mode & stat.S_ISUID),
isgid=bool(mode & stat.S_ISGID),
)
# Platform dependent flags:
for other in [
# Some Linux
('st_blocks', 'blocks'),
('st_blksize', 'block_size'),
('st_rdev', 'device_type'),
('st_flags', 'flags'),
# Some Berkley based
('st_gen', 'generation'),
('st_birthtime', 'birthtime'),
# RISCOS
('st_ftype', 'file_type'),
('st_attrs', 'attrs'),
('st_obtype', 'object_type'),
# macOS
('st_rsize', 'real_size'),
('st_creator', 'creator'),
('st_type', 'file_type'),
]:
if hasattr(st, other[0]):
output[other[1]] = getattr(st, other[0])
return output
def main():
module = AnsibleModule(
argument_spec=dict(
path=dict(type='path', required=True, aliases=['dest', 'name']),
follow=dict(type='bool', default=False),
get_md5=dict(type='bool', default=False),
get_checksum=dict(type='bool', default=True),
get_mime=dict(type='bool', default=True, aliases=['mime', 'mime_type', 'mime-type']),
get_attributes=dict(type='bool', default=True, aliases=['attr', 'attributes']),
checksum_algorithm=dict(type='str', default='sha1',
choices=['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'],
aliases=['checksum', 'checksum_algo']),
),
supports_check_mode=True,
)
path = module.params.get('path')
b_path = to_bytes(path, errors='surrogate_or_strict')
follow = module.params.get('follow')
get_mime = module.params.get('get_mime')
get_attr = module.params.get('get_attributes')
get_checksum = module.params.get('get_checksum')
checksum_algorithm = module.params.get('checksum_algorithm')
# NOTE: undocumented option since 2.9 to be removed at a later date if possible (3.0+)
# no real reason for keeping other than fear we may break older content.
get_md5 = module.params.get('get_md5')
# main stat data
try:
if follow:
st = os.stat(b_path)
else:
st = os.lstat(b_path)
except OSError as e:
if e.errno == errno.ENOENT:
output = {'exists': False}
module.exit_json(changed=False, stat=output)
module.fail_json(msg=e.strerror)
# process base results
output = format_output(module, path, st)
# resolved permissions
for perm in [('readable', os.R_OK), ('writeable', os.W_OK), ('executable', os.X_OK)]:
output[perm[0]] = os.access(b_path, perm[1])
# symlink info
if output.get('islnk'):
output['lnk_source'] = os.path.realpath(b_path)
output['lnk_target'] = os.readlink(b_path)
try: # user data
pw = pwd.getpwuid(st.st_uid)
output['pw_name'] = pw.pw_name
except (TypeError, KeyError):
pass
try: # group data
grp_info = grp.getgrgid(st.st_gid)
output['gr_name'] = grp_info.gr_name
except (KeyError, ValueError, OverflowError):
pass
# checksums
if output.get('isreg') and output.get('readable'):
# NOTE: see above about get_md5
if get_md5:
# Will fail on FIPS-140 compliant systems
try:
output['md5'] = module.md5(b_path)
except ValueError:
output['md5'] = None
if get_checksum:
output['checksum'] = module.digest_from_file(b_path, checksum_algorithm)
# try to get mime data if requested
if get_mime:
output['mimetype'] = output['charset'] = 'unknown'
mimecmd = module.get_bin_path('file')
if mimecmd:
mimecmd = [mimecmd, '-i', b_path]
try:
rc, out, err = module.run_command(mimecmd)
if rc == 0:
mimetype, charset = out.split(':')[1].split(';')
output['mimetype'] = mimetype.strip()
output['charset'] = charset.split('=')[1].strip()
except Exception:
pass
# try to get attr data
if get_attr:
output['version'] = None
output['attributes'] = []
output['attr_flags'] = ''
out = module.get_file_attributes(b_path)
for x in ('version', 'attributes', 'attr_flags'):
if x in out:
output[x] = out[x]
module.exit_json(changed=False, stat=output)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
3,
1898,
26,
334,
67,
9,
9708,
12,
2622,
7290,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
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,
11989,
3266,
995,
490,
283,
4946,
63,
991,
356,
283,
1018,
936,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
5672,
199,
1023,
63,
3270,
26,
298,
17,
14,
19,
2,
199,
3612,
63,
1802,
26,
13939,
570,
503,
570,
2656,
2004,
199,
1802,
26,
1362,
446,
27940,
9036,
367,
282,
570,
8545,
370,
314,
10130,
15,
21607,
283,
3736,
7,
1414,
14,
1362,
446,
2104,
5417,
4545,
12,
675,
314,
603,
8,
2676,
63,
3736,
9,
859,
3140,
14,
199,
1419,
26,
523,
931,
26,
272,
1369,
26,
489,
446,
710,
2615,
931,
402,
314,
570,
15,
785,
370,
664,
314,
9036,
402,
14,
272,
730,
26,
931,
272,
1415,
26,
2549,
272,
5481,
26,
359,
2053,
12,
536,
1622,
523,
2035,
26,
272,
1369,
26,
489,
446,
7480,
370,
2035,
19891,
14,
272,
730,
26,
2155,
272,
849,
26,
949,
523,
664,
63,
8928,
26,
272,
1369,
26,
489,
446,
7480,
370,
372,
282,
9040,
402,
314,
570,
14,
272,
730,
26,
2155,
272,
849,
26,
9456,
272,
1015,
63,
3270,
26,
298,
17,
14,
24,
2,
523,
9040,
63,
8833,
26,
272,
1369,
26,
489,
446,
23823,
370,
6705,
9040,
402,
570,
14,
489,
446,
12823,
7978,
376,
1125,
340,
314,
1591,
365,
17329,
370,
675,
2013,
5563,
14,
489,
446,
710,
3982,
1591,
965,
370,
2291,
314,
25223,
1083,
2013,
12,
445,
8,
1064,
21,
9,
267,
883,
506,
18735,
340,
314,
1591,
365,
481,
12346,
13,
10037,
1013,
22676,
14,
272,
730,
26,
620,
272,
3415,
26,
359,
6128,
21,
12,
7793,
17,
12,
7793,
8731,
12,
7793,
3912,
12,
7793,
8188,
12,
7793,
7736,
1622,
272,
849,
26,
7793,
17,
272,
5481,
26,
359,
9040,
12,
9040,
63,
21734,
1622,
272,
1015,
63,
3270,
26,
298,
18,
14,
16,
2,
523,
664,
63,
7626,
26,
272,
1369,
26,
489,
446,
3645,
570,
10628,
436,
372,
666,
3595,
314,
302,
1463,
402,
314,
570,
14,
642,
4440,
267,
314,
283,
493,
7,
11420,
1911,
641,
4750,
10130,
15,
21607,
10460,
14,
489,
446,
961,
911,
1050,
3865,
658,
7626,
63,
466,
64,
436,
283,
6043,
7,
1504,
370,
314,
372,
12,
340,
3962,
14,
489,
446,
1010,
2622,
499,
14,
19,
642,
945,
2896,
687,
283,
7626,
7,
370,
283,
362,
63,
7626,
7,
436,
314,
849,
2896,
370,
283,
12555,
1370,
272,
730,
26,
2155,
272,
849,
26,
9456,
272,
5481,
26,
359,
6660,
12,
6660,
63,
466,
12,
6660,
13,
466,
1622,
272,
1015,
63,
3270,
26,
298,
18,
14,
17,
2,
523,
664,
63,
2987,
26,
272,
1369,
26,
489,
446,
2372,
570,
3004,
1808,
9100,
962,
4744,
340,
3451,
14,
272,
730,
26,
2155,
272,
849,
26,
9456,
272,
5481,
26,
359,
1921,
12,
3004,
1622,
272,
1015,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
3239,
12344,
26,
199,
13,
859,
26,
570,
199,
13,
859,
26,
4747,
63,
3736,
199,
2502,
26,
699,
82,
3683,
510,
287,
9745,
1389,
281,
8593,
66,
897,
9745,
1389,
281,
9,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
3,
17985,
877,
314,
5020,
402,
1182,
6839,
15,
1421,
14,
2190,
12,
436,
1104,
626,
314,
570,
5139,
15006,
199,
3,
370,
283,
1231,
1370,
12176,
4257,
14,
199,
13,
5672,
26,
272,
931,
26,
1182,
6839,
15,
1421,
14,
2190,
523,
2274,
26,
410,
199,
13,
2449,
26,
272,
1499,
26,
298,
55,
526,
1483,
1,
570,
12715,
965,
2896,
2,
523,
1380,
26,
410,
14,
3736,
14,
8796,
63,
354,
1137,
283,
1231,
7,
199,
199,
3,
14703,
340,
282,
931,
3495,
436,
365,
282,
15296,
14,
3390,
626,
340,
314,
931,
1630,
199,
3,
440,
2187,
12,
436,
781,
511,
4678,
14,
3736,
14,
374,
6066,
75,
12,
652,
911,
2449,
543,
376,
1125,
14,
2002,
199,
3,
16119,
12,
781,
1471,
511,
3775,
652,
365,
3247,
14,
199,
3,
3378,
642,
370,
20647,
314,
5523,
12,
314,
9645,
7869,
886,
440,
986,
314,
199,
3,
1104,
10585,
701,
283,
6526,
7,
199,
13,
5672,
26,
272,
931,
26,
1182,
515,
15,
475,
15,
10297,
523,
2274,
26,
4678,
199,
199,
13,
3105,
26,
272,
1499,
26,
298,
374,
6066,
75,
5712,
1133,
3247,
334,
515,
3181,
1133,
2187,
2924,
523,
1380,
26,
4678,
14,
3736,
14,
374,
6066,
75,
365,
440,
3247,
199,
199,
13,
3105,
26,
272,
1499,
26,
298,
374,
6066,
75,
365,
3247,
334,
515,
1471,
2187,
2924,
523,
1380,
26,
4678,
14,
3736,
14,
374,
6066,
75,
365,
3247,
199,
199,
13,
3105,
26,
272,
1499,
26,
298,
2042,
3495,
436,
365,
282,
15296,
2,
523,
1380,
26,
4678,
14,
3736,
14,
374,
6066,
75,
365,
3247,
436,
4678,
14,
3736,
14,
374,
6066,
75,
199,
199,
13,
3105,
26,
272,
1499,
26,
298,
2042,
3495,
436,
5712,
1133,
282,
15296,
2,
523,
1380,
26,
4678,
14,
3736,
14,
374,
6066,
75,
365,
3247,
436,
4678,
14,
3736,
14,
374,
6066,
75,
508,
756,
421,
199,
3,
14703,
340,
282,
931,
3495,
436,
365,
282,
2082,
14,
221,
3390,
626,
781,
1929,
370,
511,
199,
3,
3865,
626,
299,
14,
3736,
14,
6027,
5965,
3495,
12,
436,
2597,
626,
652,
1159,
663,
370,
2549,
14,
199,
13,
5672,
26,
272,
931,
26,
1182,
515,
15,
475,
15,
10297,
523,
2274,
26,
299,
199,
13,
3105,
26,
272,
1499,
26,
298,
2042,
3495,
436,
365,
282,
2082,
2,
523,
1380,
26,
299,
14,
3736,
14,
6027,
365,
3247,
436,
299,
14,
3736,
14,
6027,
199,
199,
3,
7529,
1133,
886,
9040,
199,
13,
5672,
26,
272,
931,
26,
1182,
515,
15
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
3,
1898,
26,
334,
67,
9,
9708,
12,
2622,
7290,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
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,
11989,
3266,
995,
490,
283,
4946,
63,
991,
356,
283,
1018,
936,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
5672,
199,
1023,
63,
3270,
26,
298,
17,
14,
19,
2,
199,
3612,
63,
1802,
26,
13939,
570,
503,
570,
2656,
2004,
199,
1802,
26,
1362,
446,
27940,
9036,
367,
282,
570,
8545,
370,
314,
10130,
15,
21607,
283,
3736,
7,
1414,
14,
1362,
446,
2104,
5417,
4545,
12,
675,
314,
603,
8,
2676,
63,
3736,
9,
859,
3140,
14,
199,
1419,
26,
523,
931,
26,
272,
1369,
26,
489,
446,
710,
2615,
931,
402,
314,
570,
15,
785,
370,
664,
314,
9036,
402,
14,
272,
730,
26,
931,
272,
1415,
26,
2549,
272,
5481,
26,
359,
2053,
12,
536,
1622,
523,
2035,
26,
272,
1369,
26,
489,
446,
7480,
370,
2035,
19891,
14,
272,
730,
26,
2155,
272,
849,
26,
949,
523,
664,
63,
8928,
26,
272,
1369,
26,
489,
446,
7480,
370,
372,
282,
9040,
402,
314,
570,
14,
272,
730,
26,
2155,
272,
849,
26,
9456,
272,
1015,
63,
3270,
26,
298,
17,
14,
24,
2,
523,
9040,
63,
8833,
26,
272,
1369,
26,
489,
446,
23823,
370,
6705,
9040,
402,
570,
14,
489,
446,
12823,
7978,
376,
1125,
340,
314,
1591,
365,
17329,
370,
675,
2013,
5563,
14,
489,
446,
710,
3982,
1591,
965,
370,
2291,
314,
25223,
1083,
2013,
12,
445,
8,
1064,
21,
9,
267,
883,
506,
18735,
340,
314,
1591,
365,
481,
12346,
13,
10037,
1013,
22676,
14,
272,
730,
26,
620,
272,
3415,
26,
359,
6128,
21,
12,
7793,
17,
12,
7793,
8731,
12,
7793,
3912,
12,
7793,
8188,
12,
7793,
7736,
1622,
272,
849,
26,
7793,
17,
272,
5481,
26,
359,
9040,
12,
9040,
63,
21734,
1622,
272,
1015,
63,
3270,
26,
298,
18,
14,
16,
2,
523,
664,
63,
7626,
26,
272,
1369,
26,
489,
446,
3645,
570,
10628,
436,
372,
666,
3595,
314,
302,
1463,
402,
314,
570,
14,
642,
4440,
267,
314,
283,
493,
7,
11420,
1911,
641,
4750,
10130,
15,
21607,
10460,
14,
489,
446,
961,
911,
1050,
3865,
658,
7626,
63,
466,
64,
436,
283,
6043,
7,
1504,
370,
314,
372,
12,
340,
3962,
14,
489,
446,
1010,
2622,
499,
14,
19,
642,
945,
2896,
687,
283,
7626,
7,
370,
283,
362,
63,
7626,
7,
436,
314,
849,
2896,
370,
283,
12555,
1370,
272,
730,
26,
2155,
272,
849,
26,
9456,
272,
5481,
26,
359,
6660,
12,
6660,
63,
466,
12,
6660,
13,
466,
1622,
272,
1015,
63,
3270,
26,
298,
18,
14,
17,
2,
523,
664,
63,
2987,
26,
272,
1369,
26,
489,
446,
2372,
570,
3004,
1808,
9100,
962,
4744,
340,
3451,
14,
272,
730,
26,
2155,
272,
849,
26,
9456,
272,
5481,
26,
359,
1921,
12,
3004,
1622,
272,
1015,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
3239,
12344,
26,
199,
13,
859,
26,
570,
199,
13,
859,
26,
4747,
63,
3736,
199,
2502,
26,
699,
82,
3683,
510,
287,
9745,
1389,
281,
8593,
66,
897,
9745,
1389,
281,
9,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
3,
17985,
877,
314,
5020,
402,
1182,
6839,
15,
1421,
14,
2190,
12,
436,
1104,
626,
314,
570,
5139,
15006,
199,
3,
370,
283,
1231,
1370,
12176,
4257,
14,
199,
13,
5672,
26,
272,
931,
26,
1182,
6839,
15,
1421,
14,
2190,
523,
2274,
26,
410,
199,
13,
2449,
26,
272,
1499,
26,
298,
55,
526,
1483,
1,
570,
12715,
965,
2896,
2,
523,
1380,
26,
410,
14,
3736,
14,
8796,
63,
354,
1137,
283,
1231,
7,
199,
199,
3,
14703,
340,
282,
931,
3495,
436,
365,
282,
15296,
14,
3390,
626,
340,
314,
931,
1630,
199,
3,
440,
2187,
12,
436,
781,
511,
4678,
14,
3736,
14,
374,
6066,
75,
12,
652,
911,
2449,
543,
376,
1125,
14,
2002,
199,
3,
16119,
12,
781,
1471,
511,
3775,
652,
365,
3247,
14,
199,
3,
3378,
642,
370,
20647,
314,
5523,
12,
314,
9645,
7869,
886,
440,
986,
314,
199,
3,
1104,
10585,
701,
283,
6526,
7,
199,
13,
5672,
26,
272,
931,
26,
1182,
515,
15,
475,
15,
10297,
523,
2274,
26,
4678,
199,
199,
13,
3105,
26,
272,
1499,
26,
298,
374,
6066,
75,
5712,
1133,
3247,
334,
515,
3181,
1133,
2187,
2924,
523,
1380,
26,
4678,
14,
3736,
14,
374,
6066,
75,
365,
440,
3247,
199,
199,
13,
3105,
26,
272,
1499,
26,
298,
374,
6066,
75,
365,
3247,
334,
515,
1471,
2187,
2924,
523,
1380,
26,
4678,
14,
3736,
14,
374,
6066,
75,
365,
3247,
199,
199,
13,
3105,
26,
272,
1499,
26,
298,
2042,
3495,
436,
365,
282,
15296,
2,
523,
1380,
26,
4678,
14,
3736,
14,
374,
6066,
75,
365,
3247,
436,
4678,
14,
3736,
14,
374,
6066,
75,
199,
199,
13,
3105,
26,
272,
1499,
26,
298,
2042,
3495,
436,
5712,
1133,
282,
15296,
2,
523,
1380,
26,
4678,
14,
3736,
14,
374,
6066,
75,
365,
3247,
436,
4678,
14,
3736,
14,
374,
6066,
75,
508,
756,
421,
199,
3,
14703,
340,
282,
931,
3495,
436,
365,
282,
2082,
14,
221,
3390,
626,
781,
1929,
370,
511,
199,
3,
3865,
626,
299,
14,
3736,
14,
6027,
5965,
3495,
12,
436,
2597,
626,
652,
1159,
663,
370,
2549,
14,
199,
13,
5672,
26,
272,
931,
26,
1182,
515,
15,
475,
15,
10297,
523,
2274,
26,
299,
199,
13,
3105,
26,
272,
1499,
26,
298,
2042,
3495,
436,
365,
282,
2082,
2,
523,
1380,
26,
299,
14,
3736,
14,
6027,
365,
3247,
436,
299,
14,
3736,
14,
6027,
199,
199,
3,
7529,
1133,
886,
9040,
199,
13,
5672,
26,
272,
931,
26,
1182,
515,
15,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Noviat/odoo
|
addons/website_blog/__openerp__.py
|
303
|
1819
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Blogs',
'category': 'Website',
'website': 'https://www.odoo.com/page/blog-engine',
'summary': 'News, Blogs, Announces, Discussions',
'version': '1.0',
'description': """
OpenERP Blog
============
""",
'author': 'OpenERP SA',
'depends': ['knowledge', 'website_mail', 'website_partner'],
'data': [
'data/website_blog_data.xml',
'views/website_blog_views.xml',
'views/website_blog_templates.xml',
'wizard/document_page_show_diff_view.xml',
'security/ir.model.access.csv',
'security/website_blog.xml',
],
'demo': [
'data/website_blog_demo.xml'
],
'test': [
'tests/test_website_blog.yml'
],
'qweb': [
'static/src/xml/*.xml'
],
'installable': True,
'application': True,
}
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
6171,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
91,
272,
283,
354,
356,
283,
34,
7270,
297,
272,
283,
3710,
356,
283,
26354,
297,
272,
283,
7360,
356,
283,
2859,
921,
1544,
14,
22058,
14,
957,
15,
1606,
15,
11486,
13,
3908,
297,
272,
283,
4705,
356,
283,
24730,
12,
699,
7270,
12,
1626,
889,
324,
823,
12,
5289,
67,
527,
1356,
297,
272,
283,
1023,
356,
283,
17,
14,
16,
297,
272,
283,
1802,
356,
408,
199,
25347,
29775,
199,
5769,
398,
10327,
272,
283,
2502,
356,
283,
25347,
13950,
297,
272,
283,
8912,
356,
788,
14996,
14693,
297,
283,
7360,
63,
1198,
297,
283,
7360,
63,
3899,
995,
272,
283,
576,
356,
359,
267,
283,
576,
15,
7360,
63,
11486,
63,
576,
14,
1652,
297,
267,
283,
4196,
15,
7360,
63,
11486,
63,
4196,
14,
1652,
297,
267,
283,
4196,
15,
7360,
63,
11486,
63,
5876,
14,
1652,
297,
267,
283,
9819,
15,
3554,
63,
1606,
63,
2384,
63,
3028,
63,
1345,
14,
1652,
297,
267,
283,
4416,
15,
723,
14,
1238,
14,
2732,
14,
4737,
297,
267,
283,
4416,
15,
7360,
63,
11486,
14,
1652,
297,
272,
2156,
272,
283,
8768,
356,
359,
267,
283,
576,
15,
7360,
63,
11486,
63,
8768,
14,
1652,
7,
272,
2156,
272,
283,
396,
356,
359,
267,
283,
2219,
15,
396,
63,
7360,
63,
11486,
14,
11714,
7,
272,
2156,
272,
283,
22600,
356,
359,
267,
283,
1986,
15,
2164,
15,
1652,
20362,
1652,
7,
272,
2156,
272,
283,
21762,
356,
715,
12,
272,
283,
3578,
356,
715,
12,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
6171,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
91,
272,
283,
354,
356,
283,
34,
7270,
297,
272,
283,
3710,
356,
283,
26354,
297,
272,
283,
7360,
356,
283,
2859,
921,
1544,
14,
22058,
14,
957,
15,
1606,
15,
11486,
13,
3908,
297,
272,
283,
4705,
356,
283,
24730,
12,
699,
7270,
12,
1626,
889,
324,
823,
12,
5289,
67,
527,
1356,
297,
272,
283,
1023,
356,
283,
17,
14,
16,
297,
272,
283,
1802,
356,
408,
199,
25347,
29775,
199,
5769,
398,
10327,
272,
283,
2502,
356,
283,
25347,
13950,
297,
272,
283,
8912,
356,
788,
14996,
14693,
297,
283,
7360,
63,
1198,
297,
283,
7360,
63,
3899,
995,
272,
283,
576,
356,
359,
267,
283,
576,
15,
7360,
63,
11486,
63,
576,
14,
1652,
297,
267,
283,
4196,
15,
7360,
63,
11486,
63,
4196,
14,
1652,
297,
267,
283,
4196,
15,
7360,
63,
11486,
63,
5876,
14,
1652,
297,
267,
283,
9819,
15,
3554,
63,
1606,
63,
2384,
63,
3028,
63,
1345,
14,
1652,
297,
267,
283,
4416,
15,
723,
14,
1238,
14,
2732,
14,
4737,
297,
267,
283,
4416,
15,
7360,
63,
11486,
14,
1652,
297,
272,
2156,
272,
283,
8768,
356,
359,
267,
283,
576,
15,
7360,
63,
11486,
63,
8768,
14,
1652,
7,
272,
2156,
272,
283,
396,
356,
359,
267,
283,
2219,
15,
396,
63,
7360,
63,
11486,
14,
11714,
7,
272,
2156,
272,
283,
22600,
356,
359,
267,
283,
1986,
15,
2164,
15,
1652,
20362,
1652,
7,
272,
2156,
272,
283,
21762,
356,
715,
12,
272,
283,
3578,
356,
715,
12,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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yright 2015 Peter Sprygada <psprygada@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import re
import time
import glob
from ansible.plugins.action.ce import ActionModule as _ActionModule
from ansible.module_utils._text import to_text
from ansible.module_utils.six.moves.urllib.parse import urlsplit
from ansible.utils.vars import merge_hash
PRIVATE_KEYS_RE = re.compile('__.+__')
class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None):
if self._task.args.get('src'):
try:
self._handle_template()
except ValueError as exc:
return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars)
if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module.
# NOTE: If there is a parameter error, _backup key may not be in results.
filepath = self._write_backup(task_vars['inventory_hostname'],
result['__backup__'])
result['backup_path'] = filepath
# strip out any keys that have two leading and two trailing
# underscore characters
for key in result.keys():
if PRIVATE_KEYS_RE.match(key):
del result[key]
return result
def _get_working_path(self):
cwd = self._loader.get_basedir()
if self._task._role is not None:
cwd = self._task._role._role_path
return cwd
def _write_backup(self, host, contents):
backup_path = self._get_working_path() + '/backup'
if not os.path.exists(backup_path):
os.mkdir(backup_path)
for fn in glob.glob('%s/%s*' % (backup_path, host)):
os.remove(fn)
tstamp = time.strftime("%Y-%m-%d@%H:%M:%S", time.localtime(time.time()))
filename = '%s/%s_config.%s' % (backup_path, host, tstamp)
open(filename, 'w').write(contents)
return filename
def _handle_template(self):
src = self._task.args.get('src')
working_path = self._get_working_path()
if os.path.isabs(src) or urlsplit('src').scheme:
source = src
else:
source = self._loader.path_dwim_relative(working_path, 'templates', src)
if not source:
source = self._loader.path_dwim_relative(working_path, src)
if not os.path.exists(source):
raise ValueError('path specified in src not found')
try:
with open(source, 'r') as f:
template_data = to_text(f.read())
except IOError:
return dict(failed=True, msg='unable to load src file')
# Create a template search path in the following order:
# [working_path, self_role_path, dependent_role_paths, dirname(source)]
searchpath = [working_path]
if self._task._role is not None:
searchpath.append(self._task._role._role_path)
if hasattr(self._task, "_block:"):
dep_chain = self._task._block.get_dep_chain()
if dep_chain is not None:
for role in dep_chain:
searchpath.append(role._role_path)
searchpath.append(os.path.dirname(source))
self._templar.environment.loader.searchpath = searchpath
self._task.args['src'] = self._templar.template(template_data)
|
gpl-3.0
|
[
3,
199,
3,
1898,
6900,
22912,
8360,
651,
71,
10641,
665,
80,
681,
651,
71,
10641,
32,
4853,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
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,
295,
199,
646,
900,
199,
646,
5739,
199,
199,
504,
3242,
14,
5265,
14,
1287,
14,
301,
492,
10033,
2377,
465,
485,
3310,
2377,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
505,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
1122,
492,
29596,
199,
504,
3242,
14,
1208,
14,
2936,
492,
5389,
63,
2227,
421,
199,
18748,
63,
17434,
63,
907,
275,
295,
14,
2014,
360,
4343,
11,
13766,
421,
199,
533,
10033,
2377,
1547,
3310,
2377,
304,
339,
347,
1255,
8,
277,
12,
3529,
29,
403,
12,
2120,
63,
2936,
29,
403,
304,
398,
340,
291,
423,
1765,
14,
589,
14,
362,
360,
2164,
735,
288,
862,
26,
355,
291,
423,
2479,
63,
1160,
342,
288,
871,
1722,
465,
3178,
26,
355,
372,
1211,
8,
4892,
29,
549,
12,
1499,
29,
2804,
14,
1188,
9,
398,
754,
275,
1613,
8,
3310,
2377,
12,
291,
680,
1065,
8,
2791,
12,
2120,
63,
2936,
9,
398,
340,
291,
423,
1765,
14,
589,
14,
362,
360,
5751,
358,
436,
754,
14,
362,
10714,
5751,
12168,
288,
327,
2876,
5839,
6902,
436,
949,
1125,
8920,
315,
859,
14,
288,
327,
6944,
26,
982,
2337,
365,
282,
2725,
1125,
12,
485,
5751,
790,
1443,
440,
506,
315,
2058,
14,
288,
9911,
275,
291,
423,
952,
63,
5751,
8,
1765,
63,
2936,
459,
7212,
63,
4269,
995,
5101,
754,
13742,
5751,
363,
1105,
953,
754,
459,
5751,
63,
515,
418,
275,
9911,
398,
327,
6202,
734,
1263,
2883,
626,
1172,
2877,
9186,
436,
2877,
8520,
267,
327,
18888,
4110,
267,
367,
790,
315,
754,
14,
1612,
837,
288,
340,
28644,
1951,
63,
17434,
63,
907,
14,
1431,
8,
498,
304,
355,
2150,
754,
59,
498,
61,
398,
372,
754,
339,
347,
485,
362,
63,
9818,
63,
515,
8,
277,
304,
267,
8288,
275,
291,
423,
3422,
14,
362,
63,
12484,
342,
267,
340,
291,
423,
1765,
423,
3756,
365,
440,
488,
26,
288,
8288,
275,
291,
423,
1765,
423,
3756,
423,
3756,
63,
515,
267,
372,
8288,
339,
347,
485,
952,
63,
5751,
8,
277,
12,
1591,
12,
4072,
304,
267,
6902,
63,
515,
275,
291,
423,
362,
63,
9818,
63,
515,
342,
435,
1994,
5751,
7,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
5751,
63,
515,
304,
288,
747,
14,
8215,
8,
5751,
63,
515,
9,
267,
367,
4325,
315,
5739,
14,
6463,
3508,
83,
3149,
83,
10223,
450,
334,
5751,
63,
515,
12,
1591,
2298,
288,
747,
14,
2168,
8,
2324,
9,
267,
307,
2359,
275,
900,
14,
6205,
3647,
57,
3295,
77,
3295,
68,
19437,
40,
2689,
45,
2689,
51,
401,
900,
14,
15198,
8,
521,
14,
521,
4059,
267,
1788,
275,
1543,
83,
3149,
83,
63,
888,
4111,
83,
7,
450,
334,
5751,
63,
515,
12,
1591,
12,
307,
2359,
9,
267,
1551,
8,
1501,
12,
283,
87,
1959,
952,
8,
4407,
9,
267,
372,
1788,
339,
347,
485,
2479,
63,
1160,
8,
277,
304,
267,
2928,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
2164,
358,
267,
6449,
63,
515,
275,
291,
423,
362,
63,
9818,
63,
515,
342,
398,
340,
747,
14,
515,
14,
17896,
8,
2164,
9,
503,
29596,
360,
2164,
1959,
5512,
26,
288,
1350,
275,
2928,
267,
587,
26,
288,
1350,
275,
291,
423,
3422,
14,
515,
63,
10772,
1017,
63,
6188,
8,
9818,
63,
515,
12,
283,
5876,
297,
2928,
9,
288,
340,
440,
1350,
26,
355,
1350,
275,
291,
423,
3422,
14,
515,
63,
10772,
1017,
63,
6188,
8,
9818,
63,
515,
12,
2928,
9,
398,
340,
440,
747,
14,
515,
14,
2444,
8,
1365,
304,
288,
746,
1722,
360,
515,
2013,
315,
2928,
440,
1911,
358,
398,
862,
26,
288,
543,
1551,
8,
1365,
12,
283,
82,
358,
465,
289,
26,
355,
1978,
63,
576,
275,
370,
63,
505,
8,
70,
14,
739,
1012,
267,
871,
5925,
26,
288,
372,
1211,
8,
4892,
29,
549,
12,
1499,
534,
17200,
370,
2248,
2928,
570,
358,
398,
327,
2790,
282,
1978,
2754,
931,
315,
314,
2569,
1865,
26,
267,
327,
359,
9818,
63,
515,
12,
291,
63,
3756,
63,
515,
12,
11410,
63,
3756,
63,
3771,
12,
9017,
8,
1365,
1874,
267,
2754,
515,
275,
359,
9818,
63,
515,
61,
267,
340,
291,
423,
1765,
423,
3756,
365,
440,
488,
26,
288,
2754,
515,
14,
740,
8,
277,
423,
1765,
423,
3756,
423,
3756,
63,
515,
9,
288,
340,
2688,
8,
277,
423,
1765,
12,
2668,
1457,
26,
2349,
355,
2657,
63,
4429,
275,
291,
423,
1765,
423,
1457,
14,
362,
63,
2601,
63,
4429,
342,
355,
340,
2657,
63,
4429,
365,
440,
488,
26,
490,
367,
4719,
315,
2657,
63,
4429,
26,
717,
2754,
515,
14,
740,
8,
3756,
423,
3756,
63,
515,
9,
267,
2754,
515,
14,
740,
8,
736,
14,
515,
14,
3475,
8,
1365,
430,
267,
291,
423,
26718,
14,
5418
] |
[
199,
3,
1898,
6900,
22912,
8360,
651,
71,
10641,
665,
80,
681,
651,
71,
10641,
32,
4853,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
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,
295,
199,
646,
900,
199,
646,
5739,
199,
199,
504,
3242,
14,
5265,
14,
1287,
14,
301,
492,
10033,
2377,
465,
485,
3310,
2377,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
505,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
1122,
492,
29596,
199,
504,
3242,
14,
1208,
14,
2936,
492,
5389,
63,
2227,
421,
199,
18748,
63,
17434,
63,
907,
275,
295,
14,
2014,
360,
4343,
11,
13766,
421,
199,
533,
10033,
2377,
1547,
3310,
2377,
304,
339,
347,
1255,
8,
277,
12,
3529,
29,
403,
12,
2120,
63,
2936,
29,
403,
304,
398,
340,
291,
423,
1765,
14,
589,
14,
362,
360,
2164,
735,
288,
862,
26,
355,
291,
423,
2479,
63,
1160,
342,
288,
871,
1722,
465,
3178,
26,
355,
372,
1211,
8,
4892,
29,
549,
12,
1499,
29,
2804,
14,
1188,
9,
398,
754,
275,
1613,
8,
3310,
2377,
12,
291,
680,
1065,
8,
2791,
12,
2120,
63,
2936,
9,
398,
340,
291,
423,
1765,
14,
589,
14,
362,
360,
5751,
358,
436,
754,
14,
362,
10714,
5751,
12168,
288,
327,
2876,
5839,
6902,
436,
949,
1125,
8920,
315,
859,
14,
288,
327,
6944,
26,
982,
2337,
365,
282,
2725,
1125,
12,
485,
5751,
790,
1443,
440,
506,
315,
2058,
14,
288,
9911,
275,
291,
423,
952,
63,
5751,
8,
1765,
63,
2936,
459,
7212,
63,
4269,
995,
5101,
754,
13742,
5751,
363,
1105,
953,
754,
459,
5751,
63,
515,
418,
275,
9911,
398,
327,
6202,
734,
1263,
2883,
626,
1172,
2877,
9186,
436,
2877,
8520,
267,
327,
18888,
4110,
267,
367,
790,
315,
754,
14,
1612,
837,
288,
340,
28644,
1951,
63,
17434,
63,
907,
14,
1431,
8,
498,
304,
355,
2150,
754,
59,
498,
61,
398,
372,
754,
339,
347,
485,
362,
63,
9818,
63,
515,
8,
277,
304,
267,
8288,
275,
291,
423,
3422,
14,
362,
63,
12484,
342,
267,
340,
291,
423,
1765,
423,
3756,
365,
440,
488,
26,
288,
8288,
275,
291,
423,
1765,
423,
3756,
423,
3756,
63,
515,
267,
372,
8288,
339,
347,
485,
952,
63,
5751,
8,
277,
12,
1591,
12,
4072,
304,
267,
6902,
63,
515,
275,
291,
423,
362,
63,
9818,
63,
515,
342,
435,
1994,
5751,
7,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
5751,
63,
515,
304,
288,
747,
14,
8215,
8,
5751,
63,
515,
9,
267,
367,
4325,
315,
5739,
14,
6463,
3508,
83,
3149,
83,
10223,
450,
334,
5751,
63,
515,
12,
1591,
2298,
288,
747,
14,
2168,
8,
2324,
9,
267,
307,
2359,
275,
900,
14,
6205,
3647,
57,
3295,
77,
3295,
68,
19437,
40,
2689,
45,
2689,
51,
401,
900,
14,
15198,
8,
521,
14,
521,
4059,
267,
1788,
275,
1543,
83,
3149,
83,
63,
888,
4111,
83,
7,
450,
334,
5751,
63,
515,
12,
1591,
12,
307,
2359,
9,
267,
1551,
8,
1501,
12,
283,
87,
1959,
952,
8,
4407,
9,
267,
372,
1788,
339,
347,
485,
2479,
63,
1160,
8,
277,
304,
267,
2928,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
2164,
358,
267,
6449,
63,
515,
275,
291,
423,
362,
63,
9818,
63,
515,
342,
398,
340,
747,
14,
515,
14,
17896,
8,
2164,
9,
503,
29596,
360,
2164,
1959,
5512,
26,
288,
1350,
275,
2928,
267,
587,
26,
288,
1350,
275,
291,
423,
3422,
14,
515,
63,
10772,
1017,
63,
6188,
8,
9818,
63,
515,
12,
283,
5876,
297,
2928,
9,
288,
340,
440,
1350,
26,
355,
1350,
275,
291,
423,
3422,
14,
515,
63,
10772,
1017,
63,
6188,
8,
9818,
63,
515,
12,
2928,
9,
398,
340,
440,
747,
14,
515,
14,
2444,
8,
1365,
304,
288,
746,
1722,
360,
515,
2013,
315,
2928,
440,
1911,
358,
398,
862,
26,
288,
543,
1551,
8,
1365,
12,
283,
82,
358,
465,
289,
26,
355,
1978,
63,
576,
275,
370,
63,
505,
8,
70,
14,
739,
1012,
267,
871,
5925,
26,
288,
372,
1211,
8,
4892,
29,
549,
12,
1499,
534,
17200,
370,
2248,
2928,
570,
358,
398,
327,
2790,
282,
1978,
2754,
931,
315,
314,
2569,
1865,
26,
267,
327,
359,
9818,
63,
515,
12,
291,
63,
3756,
63,
515,
12,
11410,
63,
3756,
63,
3771,
12,
9017,
8,
1365,
1874,
267,
2754,
515,
275,
359,
9818,
63,
515,
61,
267,
340,
291,
423,
1765,
423,
3756,
365,
440,
488,
26,
288,
2754,
515,
14,
740,
8,
277,
423,
1765,
423,
3756,
423,
3756,
63,
515,
9,
288,
340,
2688,
8,
277,
423,
1765,
12,
2668,
1457,
26,
2349,
355,
2657,
63,
4429,
275,
291,
423,
1765,
423,
1457,
14,
362,
63,
2601,
63,
4429,
342,
355,
340,
2657,
63,
4429,
365,
440,
488,
26,
490,
367,
4719,
315,
2657,
63,
4429,
26,
717,
2754,
515,
14,
740,
8,
3756,
423,
3756,
63,
515,
9,
267,
2754,
515,
14,
740,
8,
736,
14,
515,
14,
3475,
8,
1365,
430,
267,
291,
423,
26718,
14,
5418,
0
]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
1
] |
Seinlin/codeaurora_kernel_msm
|
tools/perf/scripts/python/sched-migration.py
|
11215
|
11670
|
#!/usr/bin/python
#
# Cpu task migration overview toy
#
# Copyright (C) 2010 Frederic Weisbecker <fweisbec@gmail.com>
#
# perf script event handlers have been generated by perf script -g python
#
# This software is distributed under the terms of the GNU General
# Public License ("GPL") version 2 as published by the Free Software
# Foundation.
import os
import sys
from collections import defaultdict
from UserList import UserList
sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
sys.path.append('scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from perf_trace_context import *
from Core import *
from SchedGui import *
threads = { 0 : "idle"}
def thread_name(pid):
return "%s:%d" % (threads[pid], pid)
class RunqueueEventUnknown:
@staticmethod
def color():
return None
def __repr__(self):
return "unknown"
class RunqueueEventSleep:
@staticmethod
def color():
return (0, 0, 0xff)
def __init__(self, sleeper):
self.sleeper = sleeper
def __repr__(self):
return "%s gone to sleep" % thread_name(self.sleeper)
class RunqueueEventWakeup:
@staticmethod
def color():
return (0xff, 0xff, 0)
def __init__(self, wakee):
self.wakee = wakee
def __repr__(self):
return "%s woke up" % thread_name(self.wakee)
class RunqueueEventFork:
@staticmethod
def color():
return (0, 0xff, 0)
def __init__(self, child):
self.child = child
def __repr__(self):
return "new forked task %s" % thread_name(self.child)
class RunqueueMigrateIn:
@staticmethod
def color():
return (0, 0xf0, 0xff)
def __init__(self, new):
self.new = new
def __repr__(self):
return "task migrated in %s" % thread_name(self.new)
class RunqueueMigrateOut:
@staticmethod
def color():
return (0xff, 0, 0xff)
def __init__(self, old):
self.old = old
def __repr__(self):
return "task migrated out %s" % thread_name(self.old)
class RunqueueSnapshot:
def __init__(self, tasks = [0], event = RunqueueEventUnknown()):
self.tasks = tuple(tasks)
self.event = event
def sched_switch(self, prev, prev_state, next):
event = RunqueueEventUnknown()
if taskState(prev_state) == "R" and next in self.tasks \
and prev in self.tasks:
return self
if taskState(prev_state) != "R":
event = RunqueueEventSleep(prev)
next_tasks = list(self.tasks[:])
if prev in self.tasks:
if taskState(prev_state) != "R":
next_tasks.remove(prev)
elif taskState(prev_state) == "R":
next_tasks.append(prev)
if next not in next_tasks:
next_tasks.append(next)
return RunqueueSnapshot(next_tasks, event)
def migrate_out(self, old):
if old not in self.tasks:
return self
next_tasks = [task for task in self.tasks if task != old]
return RunqueueSnapshot(next_tasks, RunqueueMigrateOut(old))
def __migrate_in(self, new, event):
if new in self.tasks:
self.event = event
return self
next_tasks = self.tasks[:] + tuple([new])
return RunqueueSnapshot(next_tasks, event)
def migrate_in(self, new):
return self.__migrate_in(new, RunqueueMigrateIn(new))
def wake_up(self, new):
return self.__migrate_in(new, RunqueueEventWakeup(new))
def wake_up_new(self, new):
return self.__migrate_in(new, RunqueueEventFork(new))
def load(self):
""" Provide the number of tasks on the runqueue.
Don't count idle"""
return len(self.tasks) - 1
def __repr__(self):
ret = self.tasks.__repr__()
ret += self.origin_tostring()
return ret
class TimeSlice:
def __init__(self, start, prev):
self.start = start
self.prev = prev
self.end = start
# cpus that triggered the event
self.event_cpus = []
if prev is not None:
self.total_load = prev.total_load
self.rqs = prev.rqs.copy()
else:
self.rqs = defaultdict(RunqueueSnapshot)
self.total_load = 0
def __update_total_load(self, old_rq, new_rq):
diff = new_rq.load() - old_rq.load()
self.total_load += diff
def sched_switch(self, ts_list, prev, prev_state, next, cpu):
old_rq = self.prev.rqs[cpu]
new_rq = old_rq.sched_switch(prev, prev_state, next)
if old_rq is new_rq:
return
self.rqs[cpu] = new_rq
self.__update_total_load(old_rq, new_rq)
ts_list.append(self)
self.event_cpus = [cpu]
def migrate(self, ts_list, new, old_cpu, new_cpu):
if old_cpu == new_cpu:
return
old_rq = self.prev.rqs[old_cpu]
out_rq = old_rq.migrate_out(new)
self.rqs[old_cpu] = out_rq
self.__update_total_load(old_rq, out_rq)
new_rq = self.prev.rqs[new_cpu]
in_rq = new_rq.migrate_in(new)
self.rqs[new_cpu] = in_rq
self.__update_total_load(new_rq, in_rq)
ts_list.append(self)
if old_rq is not out_rq:
self.event_cpus.append(old_cpu)
self.event_cpus.append(new_cpu)
def wake_up(self, ts_list, pid, cpu, fork):
old_rq = self.prev.rqs[cpu]
if fork:
new_rq = old_rq.wake_up_new(pid)
else:
new_rq = old_rq.wake_up(pid)
if new_rq is old_rq:
return
self.rqs[cpu] = new_rq
self.__update_total_load(old_rq, new_rq)
ts_list.append(self)
self.event_cpus = [cpu]
def next(self, t):
self.end = t
return TimeSlice(t, self)
class TimeSliceList(UserList):
def __init__(self, arg = []):
self.data = arg
def get_time_slice(self, ts):
if len(self.data) == 0:
slice = TimeSlice(ts, TimeSlice(-1, None))
else:
slice = self.data[-1].next(ts)
return slice
def find_time_slice(self, ts):
start = 0
end = len(self.data)
found = -1
searching = True
while searching:
if start == end or start == end - 1:
searching = False
i = (end + start) / 2
if self.data[i].start <= ts and self.data[i].end >= ts:
found = i
end = i
continue
if self.data[i].end < ts:
start = i
elif self.data[i].start > ts:
end = i
return found
def set_root_win(self, win):
self.root_win = win
def mouse_down(self, cpu, t):
idx = self.find_time_slice(t)
if idx == -1:
return
ts = self[idx]
rq = ts.rqs[cpu]
raw = "CPU: %d\n" % cpu
raw += "Last event : %s\n" % rq.event.__repr__()
raw += "Timestamp : %d.%06d\n" % (ts.start / (10 ** 9), (ts.start % (10 ** 9)) / 1000)
raw += "Duration : %6d us\n" % ((ts.end - ts.start) / (10 ** 6))
raw += "Load = %d\n" % rq.load()
for t in rq.tasks:
raw += "%s \n" % thread_name(t)
self.root_win.update_summary(raw)
def update_rectangle_cpu(self, slice, cpu):
rq = slice.rqs[cpu]
if slice.total_load != 0:
load_rate = rq.load() / float(slice.total_load)
else:
load_rate = 0
red_power = int(0xff - (0xff * load_rate))
color = (0xff, red_power, red_power)
top_color = None
if cpu in slice.event_cpus:
top_color = rq.event.color()
self.root_win.paint_rectangle_zone(cpu, color, top_color, slice.start, slice.end)
def fill_zone(self, start, end):
i = self.find_time_slice(start)
if i == -1:
return
for i in xrange(i, len(self.data)):
timeslice = self.data[i]
if timeslice.start > end:
return
for cpu in timeslice.rqs:
self.update_rectangle_cpu(timeslice, cpu)
def interval(self):
if len(self.data) == 0:
return (0, 0)
return (self.data[0].start, self.data[-1].end)
def nr_rectangles(self):
last_ts = self.data[-1]
max_cpu = 0
for cpu in last_ts.rqs:
if cpu > max_cpu:
max_cpu = cpu
return max_cpu
class SchedEventProxy:
def __init__(self):
self.current_tsk = defaultdict(lambda : -1)
self.timeslices = TimeSliceList()
def sched_switch(self, headers, prev_comm, prev_pid, prev_prio, prev_state,
next_comm, next_pid, next_prio):
""" Ensure the task we sched out this cpu is really the one
we logged. Otherwise we may have missed traces """
on_cpu_task = self.current_tsk[headers.cpu]
if on_cpu_task != -1 and on_cpu_task != prev_pid:
print "Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \
(headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid)
threads[prev_pid] = prev_comm
threads[next_pid] = next_comm
self.current_tsk[headers.cpu] = next_pid
ts = self.timeslices.get_time_slice(headers.ts())
ts.sched_switch(self.timeslices, prev_pid, prev_state, next_pid, headers.cpu)
def migrate(self, headers, pid, prio, orig_cpu, dest_cpu):
ts = self.timeslices.get_time_slice(headers.ts())
ts.migrate(self.timeslices, pid, orig_cpu, dest_cpu)
def wake_up(self, headers, comm, pid, success, target_cpu, fork):
if success == 0:
return
ts = self.timeslices.get_time_slice(headers.ts())
ts.wake_up(self.timeslices, pid, target_cpu, fork)
def trace_begin():
global parser
parser = SchedEventProxy()
def trace_end():
app = wx.App(False)
timeslices = parser.timeslices
frame = RootFrame(timeslices, "Migration")
app.MainLoop()
def sched__sched_stat_runtime(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, runtime, vruntime):
pass
def sched__sched_stat_iowait(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, delay):
pass
def sched__sched_stat_sleep(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, delay):
pass
def sched__sched_stat_wait(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, delay):
pass
def sched__sched_process_fork(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
parent_comm, parent_pid, child_comm, child_pid):
pass
def sched__sched_process_wait(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio):
pass
def sched__sched_process_exit(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio):
pass
def sched__sched_process_free(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio):
pass
def sched__sched_migrate_task(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio, orig_cpu,
dest_cpu):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
parser.migrate(headers, pid, prio, orig_cpu, dest_cpu)
def sched__sched_switch(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
prev_comm, prev_pid, prev_prio, prev_state,
next_comm, next_pid, next_prio):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
parser.sched_switch(headers, prev_comm, prev_pid, prev_prio, prev_state,
next_comm, next_pid, next_prio)
def sched__sched_wakeup_new(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio, success,
target_cpu):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
parser.wake_up(headers, comm, pid, success, target_cpu, 1)
def sched__sched_wakeup(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio, success,
target_cpu):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
parser.wake_up(headers, comm, pid, success, target_cpu, 0)
def sched__sched_wait_task(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio):
pass
def sched__sched_kthread_stop_ret(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
ret):
pass
def sched__sched_kthread_stop(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid):
pass
def trace_unhandled(event_name, context, common_cpu, common_secs, common_nsecs,
common_pid, common_comm):
pass
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
445,
3165,
2120,
8367,
23503,
31239,
199,
3,
199,
3,
1898,
334,
35,
9,
7129,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
8582,
2884,
1566,
8297,
1172,
2757,
4046,
701,
8582,
2884,
446,
71,
2366,
199,
3,
199,
3,
961,
2032,
365,
1854,
1334,
314,
2895,
402,
314,
1664,
1696,
199,
3,
1684,
844,
1689,
12006,
531,
1015,
499,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
14,
421,
199,
646,
747,
199,
646,
984,
199,
199,
504,
5055,
492,
10018,
199,
504,
28639,
492,
28639,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
971,
199,
198,
9807,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
1274,
14,
515,
14,
740,
360,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
199,
504,
8582,
63,
3446,
63,
1100,
492,
627,
199,
504,
11672,
492,
627,
199,
504,
428,
1809,
4324,
492,
627,
421,
199,
6962,
275,
469,
378,
520,
298,
12000,
3570,
199,
199,
318,
2462,
63,
354,
8,
3150,
304,
199,
198,
1107,
2071,
83,
2689,
68,
2,
450,
334,
6962,
59,
3150,
467,
4422,
9,
199,
199,
533,
25406,
5912,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
488,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
5187,
2,
199,
199,
533,
25406,
17306,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
26220,
15033,
304,
507,
198,
277,
14,
23042,
15033,
275,
26220,
15033,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
21737,
370,
9435,
2,
450,
2462,
63,
354,
8,
277,
14,
23042,
15033,
9,
199,
199,
533,
25406,
23424,
384,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
21560,
69,
304,
507,
198,
277,
14,
15181,
69,
275,
21560,
69,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
336,
79,
415,
1536,
2,
450,
2462,
63,
354,
8,
277,
14,
15181,
69,
9,
199,
199,
533,
25406,
1858,
75,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
1982,
304,
507,
198,
277,
14,
1739,
275,
1982,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1222,
14926,
379,
2120,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1739,
9,
199,
199,
533,
17664,
26641,
607,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
1949,
16,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
892,
304,
507,
198,
277,
14,
1222,
275,
892,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
315,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1222,
9,
199,
199,
533,
17664,
26641,
2204,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
2269,
304,
507,
198,
277,
14,
1753,
275,
2269,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
734,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1753,
9,
199,
199,
533,
17664,
12038,
26,
199,
198,
318,
636,
826,
721,
277,
12,
6527,
275,
359,
16,
467,
1566,
275,
25406,
5912,
5109,
507,
198,
277,
14,
5054,
275,
2008,
8,
5054,
9,
507,
198,
277,
14,
1430,
275,
1566,
421,
198,
318,
10286,
63,
5656,
8,
277,
12,
5071,
12,
5071,
63,
929,
12,
2163,
304,
507,
198,
1430,
275,
25406,
5912,
342,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
2,
436,
2163,
315,
291,
14,
5054,
971,
686,
198,
460,
5071,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
686,
198,
1430,
275,
25406,
17306,
8,
5701,
9,
2742,
198,
2184,
63,
5054,
275,
769,
8,
277,
14,
5054,
1491,
566,
507,
198,
692,
5071,
315,
291,
14,
5054,
26,
686,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
1585,
198,
2184,
63,
5054,
14,
2168,
8,
5701,
9,
507,
198,
4164,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
582,
686,
198,
2184,
63,
5054,
14,
740,
8,
5701,
9,
2742,
198,
692,
2163,
440,
315,
2163,
63,
5054,
26,
686,
198,
2184,
63,
5054,
14,
740,
8,
2184,
9,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
548,
8,
277,
12,
2269,
304,
507,
198,
692,
2269,
440,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
359,
1765,
367,
2120,
315,
291,
14,
5054,
340,
2120,
1137,
2269,
61,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
17664,
26641,
2204,
8,
1753,
430,
421,
198,
318,
636,
8462,
63,
262,
8,
277,
12,
892,
12,
1566,
304,
507,
198,
692,
892,
315,
291,
14,
5054,
26,
686,
198,
277,
14,
1430,
275,
1566,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
291,
14,
5054,
5873,
435,
2008,
779,
1222,
566,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
262,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12,
17664,
26641,
607,
8,
1222,
430,
421,
198,
318,
21560,
63,
384,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
445,
3165,
2120,
8367,
23503,
31239,
199,
3,
199,
3,
1898,
334,
35,
9,
7129,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
8582,
2884,
1566,
8297,
1172,
2757,
4046,
701,
8582,
2884,
446,
71,
2366,
199,
3,
199,
3,
961,
2032,
365,
1854,
1334,
314,
2895,
402,
314,
1664,
1696,
199,
3,
1684,
844,
1689,
12006,
531,
1015,
499,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
14,
421,
199,
646,
747,
199,
646,
984,
199,
199,
504,
5055,
492,
10018,
199,
504,
28639,
492,
28639,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
971,
199,
198,
9807,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
1274,
14,
515,
14,
740,
360,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
199,
504,
8582,
63,
3446,
63,
1100,
492,
627,
199,
504,
11672,
492,
627,
199,
504,
428,
1809,
4324,
492,
627,
421,
199,
6962,
275,
469,
378,
520,
298,
12000,
3570,
199,
199,
318,
2462,
63,
354,
8,
3150,
304,
199,
198,
1107,
2071,
83,
2689,
68,
2,
450,
334,
6962,
59,
3150,
467,
4422,
9,
199,
199,
533,
25406,
5912,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
488,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
5187,
2,
199,
199,
533,
25406,
17306,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
26220,
15033,
304,
507,
198,
277,
14,
23042,
15033,
275,
26220,
15033,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
21737,
370,
9435,
2,
450,
2462,
63,
354,
8,
277,
14,
23042,
15033,
9,
199,
199,
533,
25406,
23424,
384,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
21560,
69,
304,
507,
198,
277,
14,
15181,
69,
275,
21560,
69,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
336,
79,
415,
1536,
2,
450,
2462,
63,
354,
8,
277,
14,
15181,
69,
9,
199,
199,
533,
25406,
1858,
75,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
1982,
304,
507,
198,
277,
14,
1739,
275,
1982,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1222,
14926,
379,
2120,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1739,
9,
199,
199,
533,
17664,
26641,
607,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
1949,
16,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
892,
304,
507,
198,
277,
14,
1222,
275,
892,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
315,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1222,
9,
199,
199,
533,
17664,
26641,
2204,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
2269,
304,
507,
198,
277,
14,
1753,
275,
2269,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
734,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1753,
9,
199,
199,
533,
17664,
12038,
26,
199,
198,
318,
636,
826,
721,
277,
12,
6527,
275,
359,
16,
467,
1566,
275,
25406,
5912,
5109,
507,
198,
277,
14,
5054,
275,
2008,
8,
5054,
9,
507,
198,
277,
14,
1430,
275,
1566,
421,
198,
318,
10286,
63,
5656,
8,
277,
12,
5071,
12,
5071,
63,
929,
12,
2163,
304,
507,
198,
1430,
275,
25406,
5912,
342,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
2,
436,
2163,
315,
291,
14,
5054,
971,
686,
198,
460,
5071,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
686,
198,
1430,
275,
25406,
17306,
8,
5701,
9,
2742,
198,
2184,
63,
5054,
275,
769,
8,
277,
14,
5054,
1491,
566,
507,
198,
692,
5071,
315,
291,
14,
5054,
26,
686,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
1585,
198,
2184,
63,
5054,
14,
2168,
8,
5701,
9,
507,
198,
4164,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
582,
686,
198,
2184,
63,
5054,
14,
740,
8,
5701,
9,
2742,
198,
692,
2163,
440,
315,
2163,
63,
5054,
26,
686,
198,
2184,
63,
5054,
14,
740,
8,
2184,
9,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
548,
8,
277,
12,
2269,
304,
507,
198,
692,
2269,
440,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
359,
1765,
367,
2120,
315,
291,
14,
5054,
340,
2120,
1137,
2269,
61,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
17664,
26641,
2204,
8,
1753,
430,
421,
198,
318,
636,
8462,
63,
262,
8,
277,
12,
892,
12,
1566,
304,
507,
198,
692,
892,
315,
291,
14,
5054,
26,
686,
198,
277,
14,
1430,
275,
1566,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
291,
14,
5054,
5873,
435,
2008,
779,
1222,
566,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
262,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12,
17664,
26641,
607,
8,
1222,
430,
421,
198,
318,
21560,
63,
384,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
Victordeleon/os-data-importers
|
eu-structural-funds/tests/processors/test_sniff_and_cast.py
|
1
|
9580
|
"""Unit-tests for the `sniff_and_cast` processor."""
from datetime import date, datetime
from decimal import Decimal
from math import floor
from jsontableschema.types import DateType, NumberType
from pytest import fixture, mark, raises
from collections import UserList
from common.config import (
NUMBER_FORMATS,
DATE_FORMATS,
SNIFFER_SAMPLE_SIZE,
SNIFFER_MAX_FAILURE_RATIO
)
from common.processors.sniff_and_cast import (
extract_data_sample,
concatenate_data_sample,
cast_values,
update_field_types,
DateSniffer,
select_sniffer,
NumberSniffer,
get_casters,
CasterNotFound
)
# Sample extraction and concatenation
# -----------------------------------------------------------------------------
@fixture(scope='function')
def resource():
def generator():
for i in range(2):
yield {'foo': i, 'bar': i}
return generator()
# noinspection PyShadowingNames
def test_extract_data_sample_returns_correct_resource_rows(resource):
sample, left_over = extract_data_sample(resource, sample_size=1)
assert sample == [{'foo': 0, 'bar': 0}]
assert list(left_over) == [{'foo': 1, 'bar': 1}]
# noinspection PyShadowingNames
def test_concatenate_sample_returns_original_resource(resource):
sample, left_over = extract_data_sample(resource, sample_size=1)
original_resource = [{'foo': 0, 'bar': 0}, {'foo': 1, 'bar': 1}]
list(concatenate_data_sample(sample, left_over)) == original_resource
# Row casting
# -----------------------------------------------------------------------------
_CASTERS = {'number': NumberType(), 'date': DateType()}
def test_cast_values_returns_correct_types_on_valid_values():
good_values_in = {'number': '9,999.99', 'date': '1999-01-01'}
good_values_out = {'number': Decimal('9999.99'), 'date': date(1999, 1, 1)}
assert cast_values(good_values_in, _CASTERS) == good_values_out
def test_cast_values_returns_none_and_warns_on_invalid_value(caplog):
bad_value_in = {'date': 'bad date'}
bad_value_out = {'date': None}
assert cast_values(bad_value_in, _CASTERS) == bad_value_out
assert caplog.records()[0].levelname == 'WARNING'
def test_cast_values_issues_warning_if_data_field_not_in_schema(caplog):
bad_field_in = {'foo': 'bar'}
assert cast_values(bad_field_in, _CASTERS, row_index=0) == bad_field_in
assert caplog.records()[0].levelname == 'WARNING'
def test_cast_values_that_are_already_casted_returns_identical_row():
casted_values_in = {'date': date(1999, 1, 1), 'number': Decimal(1.2)}
casted_values_out = {'date': date(1999, 1, 1), 'number': Decimal(1.2)}
assert cast_values(casted_values_in, _CASTERS,
row_index=0) == casted_values_out
# Datapackage mutation
# -----------------------------------------------------------------------------
_ORIGINAL_DATAPACKAGE = {
'resources': [
{
'schema': {
'fields': [
{'name': 'total_amount', 'type': 'type'},
{'name': 'starting_date', 'type': 'string'}
]
}
}
]
}
_MUTATED_DATAPACKAGE = {
'resources': [
{
'schema': {
'fields': [
{'name': 'total_amount', 'type': 'number'},
{'name': 'starting_date', 'type': 'date'}
]
}
}
]
}
def test_update_field_types_toggles_datapackage_field_types_correctly():
assert update_field_types(_ORIGINAL_DATAPACKAGE) == _MUTATED_DATAPACKAGE
# Sample generators
# -----------------------------------------------------------------------------
class _BaseGenerator(UserList):
"""A dummy data sample generator."""
@classmethod
def load(cls, field_type, format, **kwargs):
return {
'date': _DateGenerator,
'number': _NumberGenerator
}[field_type](format, **kwargs)
def __init__(self, format,
nb_rows=SNIFFER_SAMPLE_SIZE,
nb_bad_rows=0,
nb_empty_rows=0):
self.nb_rows = nb_rows
self.nb_empty_rows = nb_empty_rows
self.nb_bad_rows = nb_bad_rows
self.nb_good_rows = nb_rows - nb_bad_rows - nb_empty_rows
self.format = format
super(_BaseGenerator, self).__init__(self.rows)
@property
def rows(self):
for _ in range(self.nb_empty_rows):
yield {'foo': ''}
for _ in range(self.nb_bad_rows):
yield {'foo': 'bad row'}
for _ in range(self.nb_good_rows):
yield {'foo': str(self)}
class _NumberGenerator(_BaseGenerator):
value = 123456.78
def __str__(self):
template = '123{groupChar}456{decimalChar}78'
return template.format(**self.format)
class _DateGenerator(_BaseGenerator):
value = date(2000, 1, 1)
def __str__(self):
template = self.format['format'][4:]
return datetime(2000, 1, 1).strftime(template)
def _prepare(field_type, format, **kwargs):
field = {'name': 'foo', 'type': field_type}
datapackage = {'resources': [{'schema': {'fields': [field]}}]}
sample_rows = _BaseGenerator.load(field_type, format, **kwargs)
return datapackage, sample_rows
# Ready-made casters
# -----------------------------------------------------------------------------
def test_select_sniffer_returns_the_correct_sniffer_class():
assert select_sniffer({'type': 'date'}) == DateSniffer
assert select_sniffer({'type': 'number'}) == NumberSniffer
# Sniffing success
# -----------------------------------------------------------------------------
@mark.parametrize('format', DATE_FORMATS)
def test_get_caster_returns_valid_caster_from_good_date_samples(format):
datapackage, sample_rows = _prepare('date', format)
casters = get_casters(datapackage, sample_rows)
assert casters['foo'].cast(str(sample_rows)) == sample_rows.value
@mark.parametrize('format', NUMBER_FORMATS)
def test_get_caster_returns_valid_caster_from_good_number_samples(format):
datapackage, sample_rows = _prepare('number', format)
casters = get_casters(datapackage, sample_rows)
result = casters['foo'].cast(str(sample_rows))
assert abs(float(result) - sample_rows.value) < 0.0001
# Sniffing failure
# -----------------------------------------------------------------------------
_TOO_MANY_BAD_ROWS = floor(SNIFFER_SAMPLE_SIZE * SNIFFER_MAX_FAILURE_RATIO) + 1
@mark.parametrize('format', DATE_FORMATS)
def test_get_caster_raises_caster_not_found_from_bad_date_samples(format):
datapackage, bad_sample_rows = _prepare('date', format,
nb_bad_rows=_TOO_MANY_BAD_ROWS)
with raises(CasterNotFound):
get_casters(datapackage, bad_sample_rows)
@mark.parametrize('format', NUMBER_FORMATS)
def test_get_caster_raises_caster_not_found_from_bad_number_samples(format):
datapackage, bad_sample_rows = _prepare('number', format,
nb_bad_rows=_TOO_MANY_BAD_ROWS)
with raises(CasterNotFound):
get_casters(datapackage, bad_sample_rows)
# Sniffing with empty values in the sample
# -----------------------------------------------------------------------------
@mark.parametrize('format', DATE_FORMATS)
def test_get_caster_fails_with_too_many_empty_sample_values(format):
datapackage, just_enough_empty_samples_to_fail = _prepare(
'date', format,
nb_bad_rows=_TOO_MANY_BAD_ROWS - 1,
nb_empty_rows=floor(1 / SNIFFER_MAX_FAILURE_RATIO + 1)
)
with raises(CasterNotFound):
get_casters(datapackage, just_enough_empty_samples_to_fail)
# Pre-casting and post-casting checks
# -----------------------------------------------------------------------------
number_field = {
'name': 'foo',
'type': 'number',
'decimalChar': '.',
'groupChar': ','
}
sample_resources = [
{'foo': 'bar'},
{'foo': 'baz'}
]
number_sniffer = NumberSniffer(number_field, sample_resources, 0)
# noinspection PyProtectedMember
def test_has_two_many_decimal_chars():
assert not number_sniffer._pre_cast_checks_ok('1.2.3')
assert number_sniffer._pre_cast_checks_ok('1.2')
# noinspection PyProtectedMember
def test_group_char_comes_after_decimal_char():
assert number_sniffer._pre_cast_checks_ok('1,234.567')
assert not number_sniffer._pre_cast_checks_ok('1.234,567')
# noinspection PyProtectedMember
def test_has_more_than_two_decimals():
assert not number_sniffer._post_cast_check_ok(1.233)
assert number_sniffer._post_cast_check_ok(1.2)
# noinspection PyProtectedMember
def test_pre_and_post_checks_with_corner_cases():
assert number_sniffer._pre_cast_checks_ok('')
assert number_sniffer._pre_cast_checks_ok(None)
assert number_sniffer._post_cast_check_ok(None)
assert number_sniffer._post_cast_check_ok(1)
# Casting currencies
# -----------------------------------------------------------------------------
_VALID_RAW_CURRENCIES = [
'1090141.18',
'€ 1090141.18',
'€1090141.18',
'1090141.18 €',
'1090141.18€',
'€ 1,090,141.18',
]
currency_field = {
'name': 'foo',
'type': 'number',
'decimalChar': '.',
'groupChar': ',',
'format': 'currency'
}
currency_sniffer = NumberSniffer(currency_field, sample_resources, 0)
currency_caster = currency_sniffer.get_caster()
@mark.parametrize('value', _VALID_RAW_CURRENCIES)
def test_number_sniffer_on_values_with_currency_units(value):
assert currency_caster.cast(value)
|
mit
|
[
624,
5072,
13,
2219,
367,
314,
658,
5167,
15126,
63,
460,
63,
2931,
64,
12495,
1041,
199,
199,
504,
2197,
492,
1434,
12,
2197,
199,
504,
6107,
492,
6345,
199,
504,
3473,
492,
19841,
199,
504,
2022,
1224,
3629,
14,
1313,
492,
6148,
804,
12,
4860,
804,
199,
504,
4613,
492,
10949,
12,
2216,
12,
6534,
199,
504,
5055,
492,
28639,
199,
199,
504,
2863,
14,
888,
492,
334,
272,
18122,
63,
14019,
12,
272,
30131,
63,
14019,
12,
272,
428,
16730,
1665,
540,
63,
15827,
63,
4305,
12,
272,
428,
16730,
1665,
540,
63,
4283,
63,
13989,
63,
26566,
199,
9,
199,
504,
2863,
14,
10547,
14,
5167,
15126,
63,
460,
63,
2931,
492,
334,
272,
5536,
63,
576,
63,
3271,
12,
272,
24788,
63,
576,
63,
3271,
12,
272,
9106,
63,
1459,
12,
272,
1678,
63,
698,
63,
1313,
12,
272,
6148,
51,
8445,
1260,
12,
272,
3504,
63,
5167,
73,
1260,
12,
272,
4860,
51,
8445,
1260,
12,
272,
664,
63,
9765,
878,
12,
272,
445,
2311,
4667,
199,
9,
421,
199,
3,
15227,
19967,
436,
28207,
199,
3,
13722,
199,
199,
32,
5997,
8,
2645,
534,
1593,
358,
199,
318,
2073,
837,
272,
347,
4306,
837,
267,
367,
284,
315,
1425,
8,
18,
304,
288,
1995,
791,
1421,
356,
284,
12,
283,
1700,
356,
284,
93,
339,
372,
4306,
342,
421,
199,
3,
30870,
1611,
23574,
316,
5866,
199,
318,
511,
63,
5005,
63,
576,
63,
3271,
63,
5808,
63,
4525,
63,
1927,
63,
3838,
8,
1927,
304,
272,
2690,
12,
3602,
63,
1883,
275,
5536,
63,
576,
63,
3271,
8,
1927,
12,
2690,
63,
890,
29,
17,
9,
272,
702,
2690,
508,
9016,
1421,
356,
378,
12,
283,
1700,
356,
378,
11049,
272,
702,
769,
8,
3039,
63,
1883,
9,
508,
9016,
1421,
356,
413,
12,
283,
1700,
356,
413,
11049,
421,
199,
3,
30870,
1611,
23574,
316,
5866,
199,
318,
511,
63,
13433,
63,
3271,
63,
5808,
63,
5043,
63,
1927,
8,
1927,
304,
272,
2690,
12,
3602,
63,
1883,
275,
5536,
63,
576,
63,
3271,
8,
1927,
12,
2690,
63,
890,
29,
17,
9,
272,
3379,
63,
1927,
275,
9016,
1421,
356,
378,
12,
283,
1700,
356,
378,
1386,
791,
1421,
356,
413,
12,
283,
1700,
356,
413,
11049,
272,
769,
8,
13433,
63,
576,
63,
3271,
8,
3271,
12,
3602,
63,
1883,
430,
508,
3379,
63,
1927,
421,
199,
3,
15231,
22883,
199,
3,
13722,
199,
199,
63,
18898,
3960,
275,
791,
1955,
356,
4860,
804,
1062,
283,
602,
356,
6148,
804,
12737,
421,
199,
318,
511,
63,
2931,
63,
1459,
63,
5808,
63,
4525,
63,
1313,
63,
265,
63,
1078,
63,
1459,
837,
272,
6954,
63,
1459,
63,
262,
275,
791,
1955,
356,
283,
25,
12,
5637,
14,
1020,
297,
283,
602,
356,
283,
16278,
13,
614,
13,
614,
936,
272,
6954,
63,
1459,
63,
548,
275,
791,
1955,
356,
6345,
360,
5008,
14,
1020,
659,
283,
602,
356,
1434,
8,
16278,
12,
413,
12,
413,
6769,
272,
702,
9106,
63,
1459,
8,
8302,
63,
1459,
63,
262,
12,
485,
18898,
3960,
9,
508,
6954,
63,
1459,
63,
548,
421,
199,
318,
511,
63,
2931,
63,
1459,
63,
5808,
63,
3592,
63,
460,
63,
19811,
63,
265,
63,
3197,
63,
585,
8,
2874,
793,
304,
272,
4875,
63,
585,
63,
262,
275,
791,
602,
356,
283,
4087,
1434,
936,
272,
4875,
63,
585,
63,
548,
275,
791,
602,
356,
488,
93,
272,
702,
9106,
63,
1459,
8,
4087,
63,
585,
63,
262,
12,
485,
18898,
3960,
9,
508,
4875,
63,
585,
63,
548,
272,
702,
32297,
14,
6502,
3430,
16,
1055,
20056,
508,
283,
9171,
7,
421,
199,
318,
511,
63,
2931,
63,
1459,
63,
10115,
63,
3764,
63,
692,
63,
576,
63,
698,
63,
1397,
63,
262,
63,
3629,
8,
2874,
793,
304,
272,
4875,
63,
698,
63,
262,
275,
791,
1421,
356,
283,
1700,
936,
272,
702,
9106,
63,
1459,
8,
4087,
63,
698,
63,
262,
12,
485,
18898,
3960,
12,
1962,
63,
1080,
29,
16,
9,
508,
4875,
63,
698,
63,
262,
272,
702,
32297,
14,
6502,
3430,
16,
1055,
20056,
508,
283,
9171,
7,
421,
199,
318,
511,
63,
2931,
63,
1459,
63,
9099,
63,
1530,
63,
14039,
63,
9765,
471,
63,
5808,
63,
14576,
63,
1143,
837,
272,
14984,
471,
63,
1459,
63,
262,
275,
791,
602,
356,
1434,
8,
16278,
12,
413,
12,
413,
395,
283,
1955,
356,
6345,
8,
17,
14,
18,
6769,
272,
14984,
471,
63,
1459,
63,
548,
275,
791,
602,
356,
1434,
8,
16278,
12,
413,
12,
413,
395,
283,
1955,
356,
6345,
8,
17,
14,
18,
6769,
272,
702,
9106,
63,
1459,
8,
9765,
471,
63,
1459,
63,
262,
12,
485,
18898,
3960,
12,
2432,
1962,
63,
1080,
29,
16,
9,
508,
14984,
471,
63,
1459,
63,
548,
421,
199,
3,
3918,
2491,
31083,
199,
3,
13722,
199,
199,
63,
20332,
13384,
63,
6521,
1282,
3099,
2962,
275,
469,
272,
283,
4435,
356,
359,
267,
469,
288,
283,
3629,
356,
469,
355,
283,
955,
356,
359,
490,
791,
354,
356,
283,
2923,
63,
4606,
297,
283,
466,
356,
283,
466,
2267,
490,
791,
354,
356,
283,
15769,
63,
602,
297,
283,
466,
356,
283,
875,
936,
355,
1622,
288,
789,
267,
789,
272,
1622,
199,
93,
199,
199,
63,
25890,
6989,
63,
6521,
1282,
3099,
2962,
275,
469,
272,
283,
4435,
356,
359,
267,
469,
288,
283,
3629,
356,
469,
355,
283,
955,
356,
359,
490,
791,
354,
356,
283,
2923,
63,
4606,
297,
283,
466,
356,
283,
1955,
2267,
490,
791,
354,
356,
283,
15769,
63,
602,
297,
283,
466,
356,
283,
602,
936,
355,
1622,
288,
789,
267,
789,
272,
1622,
199,
93,
421,
199,
318,
511,
63,
873,
63,
698,
63,
1313,
63,
475,
2721,
2978,
63,
576,
2491,
63,
698,
63,
1313,
63,
4525,
590,
837,
272,
702,
1678,
63,
698,
63,
1313,
1547,
20332,
13384,
63,
6521,
1282,
3099,
2962,
9,
508,
485,
25890,
6989,
63,
6521,
1282,
3099,
2962,
421,
199,
3,
15227,
16952,
199,
3,
13722,
199,
199,
533,
485,
1563,
7599,
8,
1899,
1296,
304,
272,
408,
33,
7283,
666,
2690,
4306,
1041,
339,
768,
3744
] |
[
5072,
13,
2219,
367,
314,
658,
5167,
15126,
63,
460,
63,
2931,
64,
12495,
1041,
199,
199,
504,
2197,
492,
1434,
12,
2197,
199,
504,
6107,
492,
6345,
199,
504,
3473,
492,
19841,
199,
504,
2022,
1224,
3629,
14,
1313,
492,
6148,
804,
12,
4860,
804,
199,
504,
4613,
492,
10949,
12,
2216,
12,
6534,
199,
504,
5055,
492,
28639,
199,
199,
504,
2863,
14,
888,
492,
334,
272,
18122,
63,
14019,
12,
272,
30131,
63,
14019,
12,
272,
428,
16730,
1665,
540,
63,
15827,
63,
4305,
12,
272,
428,
16730,
1665,
540,
63,
4283,
63,
13989,
63,
26566,
199,
9,
199,
504,
2863,
14,
10547,
14,
5167,
15126,
63,
460,
63,
2931,
492,
334,
272,
5536,
63,
576,
63,
3271,
12,
272,
24788,
63,
576,
63,
3271,
12,
272,
9106,
63,
1459,
12,
272,
1678,
63,
698,
63,
1313,
12,
272,
6148,
51,
8445,
1260,
12,
272,
3504,
63,
5167,
73,
1260,
12,
272,
4860,
51,
8445,
1260,
12,
272,
664,
63,
9765,
878,
12,
272,
445,
2311,
4667,
199,
9,
421,
199,
3,
15227,
19967,
436,
28207,
199,
3,
13722,
199,
199,
32,
5997,
8,
2645,
534,
1593,
358,
199,
318,
2073,
837,
272,
347,
4306,
837,
267,
367,
284,
315,
1425,
8,
18,
304,
288,
1995,
791,
1421,
356,
284,
12,
283,
1700,
356,
284,
93,
339,
372,
4306,
342,
421,
199,
3,
30870,
1611,
23574,
316,
5866,
199,
318,
511,
63,
5005,
63,
576,
63,
3271,
63,
5808,
63,
4525,
63,
1927,
63,
3838,
8,
1927,
304,
272,
2690,
12,
3602,
63,
1883,
275,
5536,
63,
576,
63,
3271,
8,
1927,
12,
2690,
63,
890,
29,
17,
9,
272,
702,
2690,
508,
9016,
1421,
356,
378,
12,
283,
1700,
356,
378,
11049,
272,
702,
769,
8,
3039,
63,
1883,
9,
508,
9016,
1421,
356,
413,
12,
283,
1700,
356,
413,
11049,
421,
199,
3,
30870,
1611,
23574,
316,
5866,
199,
318,
511,
63,
13433,
63,
3271,
63,
5808,
63,
5043,
63,
1927,
8,
1927,
304,
272,
2690,
12,
3602,
63,
1883,
275,
5536,
63,
576,
63,
3271,
8,
1927,
12,
2690,
63,
890,
29,
17,
9,
272,
3379,
63,
1927,
275,
9016,
1421,
356,
378,
12,
283,
1700,
356,
378,
1386,
791,
1421,
356,
413,
12,
283,
1700,
356,
413,
11049,
272,
769,
8,
13433,
63,
576,
63,
3271,
8,
3271,
12,
3602,
63,
1883,
430,
508,
3379,
63,
1927,
421,
199,
3,
15231,
22883,
199,
3,
13722,
199,
199,
63,
18898,
3960,
275,
791,
1955,
356,
4860,
804,
1062,
283,
602,
356,
6148,
804,
12737,
421,
199,
318,
511,
63,
2931,
63,
1459,
63,
5808,
63,
4525,
63,
1313,
63,
265,
63,
1078,
63,
1459,
837,
272,
6954,
63,
1459,
63,
262,
275,
791,
1955,
356,
283,
25,
12,
5637,
14,
1020,
297,
283,
602,
356,
283,
16278,
13,
614,
13,
614,
936,
272,
6954,
63,
1459,
63,
548,
275,
791,
1955,
356,
6345,
360,
5008,
14,
1020,
659,
283,
602,
356,
1434,
8,
16278,
12,
413,
12,
413,
6769,
272,
702,
9106,
63,
1459,
8,
8302,
63,
1459,
63,
262,
12,
485,
18898,
3960,
9,
508,
6954,
63,
1459,
63,
548,
421,
199,
318,
511,
63,
2931,
63,
1459,
63,
5808,
63,
3592,
63,
460,
63,
19811,
63,
265,
63,
3197,
63,
585,
8,
2874,
793,
304,
272,
4875,
63,
585,
63,
262,
275,
791,
602,
356,
283,
4087,
1434,
936,
272,
4875,
63,
585,
63,
548,
275,
791,
602,
356,
488,
93,
272,
702,
9106,
63,
1459,
8,
4087,
63,
585,
63,
262,
12,
485,
18898,
3960,
9,
508,
4875,
63,
585,
63,
548,
272,
702,
32297,
14,
6502,
3430,
16,
1055,
20056,
508,
283,
9171,
7,
421,
199,
318,
511,
63,
2931,
63,
1459,
63,
10115,
63,
3764,
63,
692,
63,
576,
63,
698,
63,
1397,
63,
262,
63,
3629,
8,
2874,
793,
304,
272,
4875,
63,
698,
63,
262,
275,
791,
1421,
356,
283,
1700,
936,
272,
702,
9106,
63,
1459,
8,
4087,
63,
698,
63,
262,
12,
485,
18898,
3960,
12,
1962,
63,
1080,
29,
16,
9,
508,
4875,
63,
698,
63,
262,
272,
702,
32297,
14,
6502,
3430,
16,
1055,
20056,
508,
283,
9171,
7,
421,
199,
318,
511,
63,
2931,
63,
1459,
63,
9099,
63,
1530,
63,
14039,
63,
9765,
471,
63,
5808,
63,
14576,
63,
1143,
837,
272,
14984,
471,
63,
1459,
63,
262,
275,
791,
602,
356,
1434,
8,
16278,
12,
413,
12,
413,
395,
283,
1955,
356,
6345,
8,
17,
14,
18,
6769,
272,
14984,
471,
63,
1459,
63,
548,
275,
791,
602,
356,
1434,
8,
16278,
12,
413,
12,
413,
395,
283,
1955,
356,
6345,
8,
17,
14,
18,
6769,
272,
702,
9106,
63,
1459,
8,
9765,
471,
63,
1459,
63,
262,
12,
485,
18898,
3960,
12,
2432,
1962,
63,
1080,
29,
16,
9,
508,
14984,
471,
63,
1459,
63,
548,
421,
199,
3,
3918,
2491,
31083,
199,
3,
13722,
199,
199,
63,
20332,
13384,
63,
6521,
1282,
3099,
2962,
275,
469,
272,
283,
4435,
356,
359,
267,
469,
288,
283,
3629,
356,
469,
355,
283,
955,
356,
359,
490,
791,
354,
356,
283,
2923,
63,
4606,
297,
283,
466,
356,
283,
466,
2267,
490,
791,
354,
356,
283,
15769,
63,
602,
297,
283,
466,
356,
283,
875,
936,
355,
1622,
288,
789,
267,
789,
272,
1622,
199,
93,
199,
199,
63,
25890,
6989,
63,
6521,
1282,
3099,
2962,
275,
469,
272,
283,
4435,
356,
359,
267,
469,
288,
283,
3629,
356,
469,
355,
283,
955,
356,
359,
490,
791,
354,
356,
283,
2923,
63,
4606,
297,
283,
466,
356,
283,
1955,
2267,
490,
791,
354,
356,
283,
15769,
63,
602,
297,
283,
466,
356,
283,
602,
936,
355,
1622,
288,
789,
267,
789,
272,
1622,
199,
93,
421,
199,
318,
511,
63,
873,
63,
698,
63,
1313,
63,
475,
2721,
2978,
63,
576,
2491,
63,
698,
63,
1313,
63,
4525,
590,
837,
272,
702,
1678,
63,
698,
63,
1313,
1547,
20332,
13384,
63,
6521,
1282,
3099,
2962,
9,
508,
485,
25890,
6989,
63,
6521,
1282,
3099,
2962,
421,
199,
3,
15227,
16952,
199,
3,
13722,
199,
199,
533,
485,
1563,
7599,
8,
1899,
1296,
304,
272,
408,
33,
7283,
666,
2690,
4306,
1041,
339,
768,
3744,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
eusoubrasileiro/fatiando
|
cookbook/grid_interpolate.py
|
3
|
1845
|
"""
Gridding: Grid irregularly sampled data.
"""
from fatiando import gridder, utils
from fatiando.vis import mpl
# Generate random points
area = (-2, 2, -2, 2)
x, y = gridder.scatter(area, n=200, seed=0)
# And calculate 2D Gaussians on these points as sample data
def data(x, y):
return (utils.gaussian2d(x, y, -0.6, -1)
- utils.gaussian2d(x, y, 1.5, 1.5))
z = data(x, y)
shape = (100, 100)
# First, we need to know the real data at the grid points
grdx, grdy = gridder.regular(area, shape)
grdz = data(grdx, grdy)
mpl.figure()
mpl.subplot(2, 2, 1)
mpl.axis('scaled')
mpl.title("True grid data")
mpl.plot(x, y, '.k', label='Data points')
mpl.contourf(grdx, grdy, grdz, shape, 50)
mpl.colorbar()
mpl.legend(loc='lower right', numpoints=1)
# Use the default interpolation (cubic)
grdx, grdy, grdz = gridder.interp(x, y, z, shape)
mpl.subplot(2, 2, 2)
mpl.axis('scaled')
mpl.title("Interpolated using cubic minimum-curvature")
mpl.plot(x, y, '.k', label='Data points')
mpl.contourf(grdx, grdy, grdz, shape, 50)
mpl.colorbar()
mpl.legend(loc='lower right', numpoints=1)
# Use the nearest neighbors interpolation
grdx, grdy, grdz = gridder.interp(x, y, z, shape, algorithm='nearest')
mpl.subplot(2, 2, 3)
mpl.axis('scaled')
mpl.title("Interpolated using nearest neighbors")
mpl.plot(x, y, '.k', label='Data points')
mpl.contourf(grdx, grdy, grdz, shape, 50)
mpl.colorbar()
mpl.legend(loc='lower right', numpoints=1)
# interp doesn't extrapolates the data by default. Lets see what happens if we
# enable extrapolation
grdx, grdy, grdz = gridder.interp(x, y, z, shape, extrapolate=True)
mpl.subplot(2, 2, 4)
mpl.axis('scaled')
mpl.title("Interpolated with extrapolation")
mpl.plot(x, y, '.k', label='Data points')
mpl.contourf(grdx, grdy, grdz, shape, 50)
mpl.colorbar()
mpl.legend(loc='lower right', numpoints=1)
mpl.show()
|
bsd-3-clause
|
[
624,
199,
39,
322,
617,
316,
26,
16386,
8190,
7898,
590,
24914,
666,
14,
199,
624,
199,
504,
1433,
280,
22066,
492,
6068,
424,
12,
3778,
199,
504,
1433,
280,
22066,
14,
5068,
492,
22513,
199,
199,
3,
7958,
2196,
4501,
199,
6789,
275,
5868,
18,
12,
499,
12,
446,
18,
12,
499,
9,
199,
88,
12,
612,
275,
6068,
424,
14,
13512,
8,
6789,
12,
302,
29,
1840,
12,
6347,
29,
16,
9,
199,
3,
6061,
8671,
499,
36,
9647,
17759,
796,
641,
3520,
4501,
465,
2690,
666,
421,
199,
318,
666,
8,
88,
12,
612,
304,
272,
372,
334,
1208,
14,
22911,
18,
68,
8,
88,
12,
612,
12,
446,
16,
14,
22,
12,
446,
17,
9,
288,
446,
3778,
14,
22911,
18,
68,
8,
88,
12,
612,
12,
413,
14,
21,
12,
413,
14,
21,
430,
199,
90,
275,
666,
8,
88,
12,
612,
9,
199,
199,
1392,
275,
334,
1960,
12,
2948,
9,
199,
199,
3,
7758,
12,
781,
1929,
370,
5715,
314,
3363,
666,
737,
314,
6068,
4501,
199,
2587,
8373,
12,
486,
6883,
89,
275,
6068,
424,
14,
7898,
8,
6789,
12,
2215,
9,
199,
2587,
17019,
275,
666,
8,
2587,
8373,
12,
486,
6883,
89,
9,
199,
2421,
14,
8941,
342,
199,
2421,
14,
13334,
8,
18,
12,
499,
12,
413,
9,
199,
2421,
14,
3127,
360,
15120,
358,
199,
2421,
14,
1213,
480,
549,
6068,
666,
531,
199,
2421,
14,
2798,
8,
88,
12,
612,
12,
1987,
75,
297,
1768,
534,
1451,
4501,
358,
199,
2421,
14,
17798,
70,
8,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
12,
2215,
12,
5238,
9,
199,
2421,
14,
30995,
342,
199,
2421,
14,
10231,
8,
2102,
534,
2325,
2451,
297,
302,
1220,
79,
13141,
29,
17,
9,
199,
199,
3,
3645,
314,
849,
14046,
334,
18455,
530,
9,
199,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
275,
6068,
424,
14,
14252,
8,
88,
12,
612,
12,
1315,
12,
2215,
9,
199,
2421,
14,
13334,
8,
18,
12,
499,
12,
499,
9,
199,
2421,
14,
3127,
360,
15120,
358,
199,
2421,
14,
1213,
480,
22713,
972,
1808,
22217,
530,
7481,
13,
895,
86,
1463,
531,
199,
2421,
14,
2798,
8,
88,
12,
612,
12,
1987,
75,
297,
1768,
534,
1451,
4501,
358,
199,
2421,
14,
17798,
70,
8,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
12,
2215,
12,
5238,
9,
199,
2421,
14,
30995,
342,
199,
2421,
14,
10231,
8,
2102,
534,
2325,
2451,
297,
302,
1220,
79,
13141,
29,
17,
9,
199,
199,
3,
3645,
314,
17173,
15845,
14046,
199,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
275,
6068,
424,
14,
14252,
8,
88,
12,
612,
12,
1315,
12,
2215,
12,
5563,
534,
16615,
358,
199,
2421,
14,
13334,
8,
18,
12,
499,
12,
650,
9,
199,
2421,
14,
3127,
360,
15120,
358,
199,
2421,
14,
1213,
480,
22713,
972,
1808,
17173,
15845,
531,
199,
2421,
14,
2798,
8,
88,
12,
612,
12,
1987,
75,
297,
1768,
534,
1451,
4501,
358,
199,
2421,
14,
17798,
70,
8,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
12,
2215,
12,
5238,
9,
199,
2421,
14,
30995,
342,
199,
2421,
14,
10231,
8,
2102,
534,
2325,
2451,
297,
302,
1220,
79,
13141,
29,
17,
9,
199,
199,
3,
23716,
3181,
1133,
31964,
393,
2335,
314,
666,
701,
849,
14,
491,
8716,
1937,
4052,
10986,
340,
781,
199,
3,
4756,
31964,
10410,
199,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
275,
6068,
424,
14,
14252,
8,
88,
12,
612,
12,
1315,
12,
2215,
12,
31964,
16288,
29,
549,
9,
199,
2421,
14,
13334,
8,
18,
12,
499,
12,
841,
9,
199,
2421,
14,
3127,
360,
15120,
358,
199,
2421,
14,
1213,
480,
22713,
972,
543,
31964,
10410,
531,
199,
2421,
14,
2798,
8,
88,
12,
612,
12,
1987,
75,
297,
1768,
534,
1451,
4501,
358,
199,
2421,
14,
17798,
70,
8,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
12,
2215,
12,
5238,
9,
199,
2421,
14,
30995,
342,
199,
2421,
14,
10231,
8,
2102,
534,
2325,
2451,
297,
302,
1220,
79,
13141,
29,
17,
9,
199,
199,
2421,
14,
2384,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
39,
322,
617,
316,
26,
16386,
8190,
7898,
590,
24914,
666,
14,
199,
624,
199,
504,
1433,
280,
22066,
492,
6068,
424,
12,
3778,
199,
504,
1433,
280,
22066,
14,
5068,
492,
22513,
199,
199,
3,
7958,
2196,
4501,
199,
6789,
275,
5868,
18,
12,
499,
12,
446,
18,
12,
499,
9,
199,
88,
12,
612,
275,
6068,
424,
14,
13512,
8,
6789,
12,
302,
29,
1840,
12,
6347,
29,
16,
9,
199,
3,
6061,
8671,
499,
36,
9647,
17759,
796,
641,
3520,
4501,
465,
2690,
666,
421,
199,
318,
666,
8,
88,
12,
612,
304,
272,
372,
334,
1208,
14,
22911,
18,
68,
8,
88,
12,
612,
12,
446,
16,
14,
22,
12,
446,
17,
9,
288,
446,
3778,
14,
22911,
18,
68,
8,
88,
12,
612,
12,
413,
14,
21,
12,
413,
14,
21,
430,
199,
90,
275,
666,
8,
88,
12,
612,
9,
199,
199,
1392,
275,
334,
1960,
12,
2948,
9,
199,
199,
3,
7758,
12,
781,
1929,
370,
5715,
314,
3363,
666,
737,
314,
6068,
4501,
199,
2587,
8373,
12,
486,
6883,
89,
275,
6068,
424,
14,
7898,
8,
6789,
12,
2215,
9,
199,
2587,
17019,
275,
666,
8,
2587,
8373,
12,
486,
6883,
89,
9,
199,
2421,
14,
8941,
342,
199,
2421,
14,
13334,
8,
18,
12,
499,
12,
413,
9,
199,
2421,
14,
3127,
360,
15120,
358,
199,
2421,
14,
1213,
480,
549,
6068,
666,
531,
199,
2421,
14,
2798,
8,
88,
12,
612,
12,
1987,
75,
297,
1768,
534,
1451,
4501,
358,
199,
2421,
14,
17798,
70,
8,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
12,
2215,
12,
5238,
9,
199,
2421,
14,
30995,
342,
199,
2421,
14,
10231,
8,
2102,
534,
2325,
2451,
297,
302,
1220,
79,
13141,
29,
17,
9,
199,
199,
3,
3645,
314,
849,
14046,
334,
18455,
530,
9,
199,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
275,
6068,
424,
14,
14252,
8,
88,
12,
612,
12,
1315,
12,
2215,
9,
199,
2421,
14,
13334,
8,
18,
12,
499,
12,
499,
9,
199,
2421,
14,
3127,
360,
15120,
358,
199,
2421,
14,
1213,
480,
22713,
972,
1808,
22217,
530,
7481,
13,
895,
86,
1463,
531,
199,
2421,
14,
2798,
8,
88,
12,
612,
12,
1987,
75,
297,
1768,
534,
1451,
4501,
358,
199,
2421,
14,
17798,
70,
8,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
12,
2215,
12,
5238,
9,
199,
2421,
14,
30995,
342,
199,
2421,
14,
10231,
8,
2102,
534,
2325,
2451,
297,
302,
1220,
79,
13141,
29,
17,
9,
199,
199,
3,
3645,
314,
17173,
15845,
14046,
199,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
275,
6068,
424,
14,
14252,
8,
88,
12,
612,
12,
1315,
12,
2215,
12,
5563,
534,
16615,
358,
199,
2421,
14,
13334,
8,
18,
12,
499,
12,
650,
9,
199,
2421,
14,
3127,
360,
15120,
358,
199,
2421,
14,
1213,
480,
22713,
972,
1808,
17173,
15845,
531,
199,
2421,
14,
2798,
8,
88,
12,
612,
12,
1987,
75,
297,
1768,
534,
1451,
4501,
358,
199,
2421,
14,
17798,
70,
8,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
12,
2215,
12,
5238,
9,
199,
2421,
14,
30995,
342,
199,
2421,
14,
10231,
8,
2102,
534,
2325,
2451,
297,
302,
1220,
79,
13141,
29,
17,
9,
199,
199,
3,
23716,
3181,
1133,
31964,
393,
2335,
314,
666,
701,
849,
14,
491,
8716,
1937,
4052,
10986,
340,
781,
199,
3,
4756,
31964,
10410,
199,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
275,
6068,
424,
14,
14252,
8,
88,
12,
612,
12,
1315,
12,
2215,
12,
31964,
16288,
29,
549,
9,
199,
2421,
14,
13334,
8,
18,
12,
499,
12,
841,
9,
199,
2421,
14,
3127,
360,
15120,
358,
199,
2421,
14,
1213,
480,
22713,
972,
543,
31964,
10410,
531,
199,
2421,
14,
2798,
8,
88,
12,
612,
12,
1987,
75,
297,
1768,
534,
1451,
4501,
358,
199,
2421,
14,
17798,
70,
8,
2587,
8373,
12,
486,
6883,
89,
12,
486,
6883,
90,
12,
2215,
12,
5238,
9,
199,
2421,
14,
30995,
342,
199,
2421,
14,
10231,
8,
2102,
534,
2325,
2451,
297,
302,
1220,
79,
13141,
29,
17,
9,
199,
199,
2421,
14,
2384,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
Titan-C/scikit-learn
|
examples/linear_model/plot_ols.py
|
74
|
2047
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
=========================================================
Linear Regression Example
=========================================================
This example uses the only the first feature of the `diabetes` dataset, in
order to illustrate a two-dimensional plot of this regression technique. The
straight line can be seen in the plot, showing how linear regression attempts
to draw a straight line that will best minimize the residual sum of squares
between the observed responses in the dataset, and the responses predicted by
the linear approximation.
The coefficients, the residual sum of squares and the variance score are also
calculated.
"""
print(__doc__)
# Code source: Jaques Grobler
# License: BSD 3 clause
import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model
from sklearn.metrics import mean_squared_error, r2_score
# Load the diabetes dataset
diabetes = datasets.load_diabetes()
# Use only one feature
diabetes_X = diabetes.data[:, np.newaxis, 2]
# Split the data into training/testing sets
diabetes_X_train = diabetes_X[:-20]
diabetes_X_test = diabetes_X[-20:]
# Split the targets into training/testing sets
diabetes_y_train = diabetes.target[:-20]
diabetes_y_test = diabetes.target[-20:]
# Create linear regression object
regr = linear_model.LinearRegression()
# Train the model using the training sets
regr.fit(diabetes_X_train, diabetes_y_train)
# Make predictions using the testing set
diabetes_y_pred = regr.predict(diabetes_X_test)
# The coefficients
print('Coefficients: \n', regr.coef_)
# The mean squared error
print("Mean squared error: %.2f"
% mean_squared_error(diabetes_y_test, diabetes_y_pred))
# Explained variance score: 1 is perfect prediction
print('Variance score: %.2f' % r2_score(diabetes_y_test, diabetes_y_pred))
# Plot outputs
plt.scatter(diabetes_X_test, diabetes_y_test, color='black')
plt.plot(diabetes_X_test, diabetes_y_pred, color='blue', linewidth=3)
plt.xticks(())
plt.yticks(())
plt.show()
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
12813,
15495,
199,
10608,
13262,
5679,
199,
12813,
15495,
199,
2765,
2893,
4440,
314,
1454,
314,
1642,
3878,
402,
314,
658,
328,
26290,
64,
4789,
12,
315,
199,
1648,
370,
22907,
11409,
323,
282,
2877,
13,
13014,
5137,
402,
642,
10864,
32414,
14,
710,
199,
14183,
1070,
1004,
883,
506,
6775,
315,
314,
5137,
12,
21207,
4212,
7798,
10864,
12454,
199,
475,
5954,
282,
23669,
1004,
626,
911,
5526,
24720,
314,
16731,
3089,
402,
26170,
199,
13007,
314,
20802,
9320,
315,
314,
4789,
12,
436,
314,
9320,
14746,
701,
199,
1589,
7798,
22772,
14,
199,
199,
1918,
12343,
12,
314,
16731,
3089,
402,
26170,
436,
314,
11773,
5396,
787,
2597,
199,
13494,
972,
14,
199,
199,
624,
199,
1361,
3460,
1301,
3368,
421,
199,
3,
5495,
1350,
26,
1603,
65,
19658,
598,
293,
830,
82,
199,
3,
844,
26,
6289,
650,
8502,
421,
199,
646,
8027,
14,
13563,
465,
4488,
199,
646,
2680,
465,
980,
199,
504,
6357,
492,
13148,
12,
7798,
63,
1238,
199,
504,
6357,
14,
6759,
492,
4615,
63,
12973,
63,
705,
12,
519,
18,
63,
3397,
199,
199,
3,
7190,
314,
487,
26290,
4789,
199,
328,
26290,
275,
13148,
14,
912,
63,
328,
26290,
342,
421,
199,
3,
3645,
1454,
1373,
3878,
199,
328,
26290,
63,
56,
275,
487,
26290,
14,
576,
3981,
980,
14,
14483,
12,
499,
61,
199,
199,
3,
11740,
314,
666,
1901,
6093,
15,
4776,
5951,
199,
328,
26290,
63,
56,
63,
2834,
275,
487,
26290,
63,
56,
4439,
1165,
61,
199,
328,
26290,
63,
56,
63,
396,
275,
487,
26290,
63,
56,
1988,
1165,
2938,
199,
199,
3,
11740,
314,
4545,
1901,
6093,
15,
4776,
5951,
199,
328,
26290,
63,
89,
63,
2834,
275,
487,
26290,
14,
1375,
4439,
1165,
61,
199,
328,
26290,
63,
89,
63,
396,
275,
487,
26290,
14,
1375,
1988,
1165,
2938,
199,
199,
3,
2790,
7798,
10864,
909,
199,
1135,
82,
275,
7798,
63,
1238,
14,
10608,
13013,
342,
199,
199,
3,
16732,
314,
1402,
1808,
314,
6093,
5951,
199,
1135,
82,
14,
3269,
8,
328,
26290,
63,
56,
63,
2834,
12,
487,
26290,
63,
89,
63,
2834,
9,
199,
199,
3,
4155,
7914,
1808,
314,
5343,
663,
199,
328,
26290,
63,
89,
63,
5991,
275,
1295,
82,
14,
6892,
8,
328,
26290,
63,
56,
63,
396,
9,
199,
199,
3,
710,
12343,
199,
1361,
360,
967,
21069,
83,
26,
971,
78,
297,
1295,
82,
14,
8009,
4602,
199,
3,
710,
4615,
20478,
1125,
199,
1361,
480,
14825,
20478,
1125,
26,
10536,
18,
70,
2,
489,
450,
4615,
63,
12973,
63,
705,
8,
328,
26290,
63,
89,
63,
396,
12,
487,
26290,
63,
89,
63,
5991,
430,
199,
3,
7910,
23918,
11773,
5396,
26,
413,
365,
23668,
12044,
199,
1361,
360,
31805,
5396,
26,
10536,
18,
70,
7,
450,
519,
18,
63,
3397,
8,
328,
26290,
63,
89,
63,
396,
12,
487,
26290,
63,
89,
63,
5991,
430,
199,
199,
3,
14794,
4704,
199,
6003,
14,
13512,
8,
328,
26290,
63,
56,
63,
396,
12,
487,
26290,
63,
89,
63,
396,
12,
221,
3164,
534,
8399,
358,
199,
6003,
14,
2798,
8,
328,
26290,
63,
56,
63,
396,
12,
487,
26290,
63,
89,
63,
5991,
12,
3164,
534,
6304,
297,
21213,
29,
19,
9,
199,
199,
6003,
14,
26217,
30812,
199,
6003,
14,
30588,
30812,
199,
199,
6003,
14,
2384,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
12813,
15495,
199,
10608,
13262,
5679,
199,
12813,
15495,
199,
2765,
2893,
4440,
314,
1454,
314,
1642,
3878,
402,
314,
658,
328,
26290,
64,
4789,
12,
315,
199,
1648,
370,
22907,
11409,
323,
282,
2877,
13,
13014,
5137,
402,
642,
10864,
32414,
14,
710,
199,
14183,
1070,
1004,
883,
506,
6775,
315,
314,
5137,
12,
21207,
4212,
7798,
10864,
12454,
199,
475,
5954,
282,
23669,
1004,
626,
911,
5526,
24720,
314,
16731,
3089,
402,
26170,
199,
13007,
314,
20802,
9320,
315,
314,
4789,
12,
436,
314,
9320,
14746,
701,
199,
1589,
7798,
22772,
14,
199,
199,
1918,
12343,
12,
314,
16731,
3089,
402,
26170,
436,
314,
11773,
5396,
787,
2597,
199,
13494,
972,
14,
199,
199,
624,
199,
1361,
3460,
1301,
3368,
421,
199,
3,
5495,
1350,
26,
1603,
65,
19658,
598,
293,
830,
82,
199,
3,
844,
26,
6289,
650,
8502,
421,
199,
646,
8027,
14,
13563,
465,
4488,
199,
646,
2680,
465,
980,
199,
504,
6357,
492,
13148,
12,
7798,
63,
1238,
199,
504,
6357,
14,
6759,
492,
4615,
63,
12973,
63,
705,
12,
519,
18,
63,
3397,
199,
199,
3,
7190,
314,
487,
26290,
4789,
199,
328,
26290,
275,
13148,
14,
912,
63,
328,
26290,
342,
421,
199,
3,
3645,
1454,
1373,
3878,
199,
328,
26290,
63,
56,
275,
487,
26290,
14,
576,
3981,
980,
14,
14483,
12,
499,
61,
199,
199,
3,
11740,
314,
666,
1901,
6093,
15,
4776,
5951,
199,
328,
26290,
63,
56,
63,
2834,
275,
487,
26290,
63,
56,
4439,
1165,
61,
199,
328,
26290,
63,
56,
63,
396,
275,
487,
26290,
63,
56,
1988,
1165,
2938,
199,
199,
3,
11740,
314,
4545,
1901,
6093,
15,
4776,
5951,
199,
328,
26290,
63,
89,
63,
2834,
275,
487,
26290,
14,
1375,
4439,
1165,
61,
199,
328,
26290,
63,
89,
63,
396,
275,
487,
26290,
14,
1375,
1988,
1165,
2938,
199,
199,
3,
2790,
7798,
10864,
909,
199,
1135,
82,
275,
7798,
63,
1238,
14,
10608,
13013,
342,
199,
199,
3,
16732,
314,
1402,
1808,
314,
6093,
5951,
199,
1135,
82,
14,
3269,
8,
328,
26290,
63,
56,
63,
2834,
12,
487,
26290,
63,
89,
63,
2834,
9,
199,
199,
3,
4155,
7914,
1808,
314,
5343,
663,
199,
328,
26290,
63,
89,
63,
5991,
275,
1295,
82,
14,
6892,
8,
328,
26290,
63,
56,
63,
396,
9,
199,
199,
3,
710,
12343,
199,
1361,
360,
967,
21069,
83,
26,
971,
78,
297,
1295,
82,
14,
8009,
4602,
199,
3,
710,
4615,
20478,
1125,
199,
1361,
480,
14825,
20478,
1125,
26,
10536,
18,
70,
2,
489,
450,
4615,
63,
12973,
63,
705,
8,
328,
26290,
63,
89,
63,
396,
12,
487,
26290,
63,
89,
63,
5991,
430,
199,
3,
7910,
23918,
11773,
5396,
26,
413,
365,
23668,
12044,
199,
1361,
360,
31805,
5396,
26,
10536,
18,
70,
7,
450,
519,
18,
63,
3397,
8,
328,
26290,
63,
89,
63,
396,
12,
487,
26290,
63,
89,
63,
5991,
430,
199,
199,
3,
14794,
4704,
199,
6003,
14,
13512,
8,
328,
26290,
63,
56,
63,
396,
12,
487,
26290,
63,
89,
63,
396,
12,
221,
3164,
534,
8399,
358,
199,
6003,
14,
2798,
8,
328,
26290,
63,
56,
63,
396,
12,
487,
26290,
63,
89,
63,
5991,
12,
3164,
534,
6304,
297,
21213,
29,
19,
9,
199,
199,
6003,
14,
26217,
30812,
199,
6003,
14,
30588,
30812,
199,
199,
6003,
14,
2384,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
trenttong/QEMU-TRACE
|
scripts/tracetool/backend/stderr.py
|
94
|
1162
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Stderr built-in backend.
"""
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
__maintainer__ = "Stefan Hajnoczi"
__email__ = "stefanha@linux.vnet.ibm.com"
from tracetool import out
PUBLIC = True
def c(events):
pass
def h(events):
out('#include <stdio.h>',
'#include "trace/control.h"',
'',
)
for e in events:
argnames = ", ".join(e.args.names())
if len(e.args) > 0:
argnames = ", " + argnames
out('static inline void trace_%(name)s(%(args)s)',
'{',
' bool _state = trace_event_get_state(%(event_id)s);',
' if (_state) {',
' fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argnames)s);',
' }',
'}',
name = e.name,
args = e.args,
event_id = "TRACE_" + e.name.upper(),
fmt = e.fmt.rstrip("\n"),
argnames = argnames,
)
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
933,
2303,
6137,
13,
262,
4865,
14,
199,
624,
199,
199,
363,
2502,
363,
258,
275,
298,
44,
10836,
13676,
83,
812,
382,
8143,
3042,
665,
29792,
8143,
3042,
32,
645,
14,
384,
67,
14,
8654,
4335,
199,
363,
7307,
363,
221,
275,
298,
7384,
6029,
12,
491,
10836,
13676,
83,
812,
382,
8143,
3042,
665,
29792,
8143,
3042,
32,
645,
14,
384,
67,
14,
8654,
4335,
199,
363,
1682,
363,
259,
275,
298,
12006,
1015,
499,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
2,
199,
199,
363,
26665,
363,
275,
298,
26696,
12269,
869,
9091,
23507,
16079,
2,
199,
363,
2123,
363,
420,
275,
298,
1597,
12269,
2411,
32,
5135,
14,
86,
846,
14,
19870,
14,
957,
2,
421,
199,
504,
3307,
3557,
492,
734,
421,
199,
19476,
275,
715,
421,
199,
318,
286,
8,
4368,
304,
272,
986,
199,
199,
318,
394,
8,
4368,
304,
272,
734,
7863,
2613,
665,
32011,
14,
72,
4206,
267,
3943,
2613,
298,
3446,
15,
2785,
14,
72,
6949,
267,
3260,
267,
776,
339,
367,
325,
315,
4474,
26,
267,
1680,
1247,
275,
3872,
3680,
904,
8,
69,
14,
589,
14,
1247,
1012,
267,
340,
822,
8,
69,
14,
589,
9,
690,
378,
26,
288,
1680,
1247,
275,
3872,
298,
435,
1680,
1247,
398,
734,
360,
1986,
8308,
2309,
3307,
20892,
354,
9,
83,
12473,
589,
9,
83,
3196,
288,
5041,
297,
288,
283,
259,
2155,
485,
929,
275,
3307,
63,
1430,
63,
362,
63,
929,
12473,
1430,
63,
344,
9,
83,
27853,
288,
283,
259,
340,
6110,
929,
9,
469,
297,
288,
283,
263,
289,
19139,
8,
3083,
12,
11792,
354,
9,
83,
298,
2818,
5045,
9,
83,
9926,
78,
2,
2818,
1273,
1247,
9,
83,
27853,
288,
283,
259,
789,
297,
288,
283,
7293,
288,
536,
275,
325,
14,
354,
12,
288,
1249,
275,
325,
14,
589,
12,
288,
1566,
63,
344,
275,
298,
20112,
12172,
435,
325,
14,
354,
14,
4142,
1062,
288,
7104,
275,
325,
14,
5045,
14,
6735,
4582,
78,
1288,
288,
1680,
1247,
275,
1680,
1247,
12,
288,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
933,
2303,
6137,
13,
262,
4865,
14,
199,
624,
199,
199,
363,
2502,
363,
258,
275,
298,
44,
10836,
13676,
83,
812,
382,
8143,
3042,
665,
29792,
8143,
3042,
32,
645,
14,
384,
67,
14,
8654,
4335,
199,
363,
7307,
363,
221,
275,
298,
7384,
6029,
12,
491,
10836,
13676,
83,
812,
382,
8143,
3042,
665,
29792,
8143,
3042,
32,
645,
14,
384,
67,
14,
8654,
4335,
199,
363,
1682,
363,
259,
275,
298,
12006,
1015,
499,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
2,
199,
199,
363,
26665,
363,
275,
298,
26696,
12269,
869,
9091,
23507,
16079,
2,
199,
363,
2123,
363,
420,
275,
298,
1597,
12269,
2411,
32,
5135,
14,
86,
846,
14,
19870,
14,
957,
2,
421,
199,
504,
3307,
3557,
492,
734,
421,
199,
19476,
275,
715,
421,
199,
318,
286,
8,
4368,
304,
272,
986,
199,
199,
318,
394,
8,
4368,
304,
272,
734,
7863,
2613,
665,
32011,
14,
72,
4206,
267,
3943,
2613,
298,
3446,
15,
2785,
14,
72,
6949,
267,
3260,
267,
776,
339,
367,
325,
315,
4474,
26,
267,
1680,
1247,
275,
3872,
3680,
904,
8,
69,
14,
589,
14,
1247,
1012,
267,
340,
822,
8,
69,
14,
589,
9,
690,
378,
26,
288,
1680,
1247,
275,
3872,
298,
435,
1680,
1247,
398,
734,
360,
1986,
8308,
2309,
3307,
20892,
354,
9,
83,
12473,
589,
9,
83,
3196,
288,
5041,
297,
288,
283,
259,
2155,
485,
929,
275,
3307,
63,
1430,
63,
362,
63,
929,
12473,
1430,
63,
344,
9,
83,
27853,
288,
283,
259,
340,
6110,
929,
9,
469,
297,
288,
283,
263,
289,
19139,
8,
3083,
12,
11792,
354,
9,
83,
298,
2818,
5045,
9,
83,
9926,
78,
2,
2818,
1273,
1247,
9,
83,
27853,
288,
283,
259,
789,
297,
288,
283,
7293,
288,
536,
275,
325,
14,
354,
12,
288,
1249,
275,
325,
14,
589,
12,
288,
1566,
63,
344,
275,
298,
20112,
12172,
435,
325,
14,
354,
14,
4142,
1062,
288,
7104,
275,
325,
14,
5045,
14,
6735,
4582,
78,
1288,
288,
1680,
1247,
275,
1680,
1247,
12,
288,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tkw1536/DataAnalytics
|
DataAnalytics/grouping.py
|
1
|
1709
|
import numpy as np
def group_indexes_by(data, group):
"""
groups the indexes of an array.
data: Array of which the indexes should be sorted
group: Array of functions that should return if an item belongs to a group.
"""
# create an array of groups
groups = [[] for g in group]
# iterate through the data
for j, d in enumerate(data):
# and through the groups
for i, g in enumerate(group):
if g(d):
groups[i].append(j)
return groups
def make_group_order(data, group):
"""
Groups the indexes of an array and returns one array with indexes on a per-group basis.
data: Array of which the indexes should be sorted
group: Array of functions that should return if an item belongs to a group.
"""
# make groups
groups = group_indexes_by(data, group)
# create a new array of groups
go = []
# add all of them
for g in groups:
go += g
# return the list of groups
return go
def make_labels(groups, group_labels=None):
"""
Makes labels and new group mappings.
groups: List of groups.
group_labels: Labels for the groups. Optional.
"""
# we do not have group labels
newgroups = sorted(list(set(groups)))
# make new group identifiers
pgroups = np.array(
list(
map(
lambda g:newgroups.index(g),
groups
)
)
)
if group_labels == None:
# if we do not have labels, use the group id as a label
plabels = list(map(str, newgroups))
else:
plabels = group_labels
return (pgroups, plabels)
|
mit
|
[
646,
2680,
465,
980,
199,
199,
318,
1572,
63,
10116,
63,
991,
8,
576,
12,
1572,
304,
272,
408,
267,
4652,
314,
10507,
402,
376,
1625,
14,
398,
666,
26,
8725,
402,
1314,
314,
10507,
1077,
506,
3355,
267,
1572,
26,
8725,
402,
3423,
626,
1077,
372,
340,
376,
1242,
15006,
370,
282,
1572,
14,
272,
408,
339,
327,
1218,
376,
1625,
402,
4652,
272,
4652,
275,
3474,
61,
367,
486,
315,
1572,
61,
339,
327,
13974,
4012,
314,
666,
272,
367,
1335,
12,
366,
315,
3874,
8,
576,
304,
267,
327,
436,
4012,
314,
4652,
267,
367,
284,
12,
486,
315,
3874,
8,
923,
304,
288,
340,
486,
8,
68,
304,
355,
4652,
59,
73,
1055,
740,
8,
74,
9,
339,
372,
4652,
199,
199,
318,
1852,
63,
923,
63,
1648,
8,
576,
12,
1572,
304,
272,
408,
267,
25031,
314,
10507,
402,
376,
1625,
436,
2529,
1373,
1625,
543,
10507,
641,
282,
1126,
13,
923,
5597,
14,
398,
666,
26,
8725,
402,
1314,
314,
10507,
1077,
506,
3355,
267,
1572,
26,
8725,
402,
3423,
626,
1077,
372,
340,
376,
1242,
15006,
370,
282,
1572,
14,
272,
408,
339,
327,
1852,
4652,
272,
4652,
275,
1572,
63,
10116,
63,
991,
8,
576,
12,
1572,
9,
339,
327,
1218,
282,
892,
1625,
402,
4652,
272,
2621,
275,
942,
339,
327,
1050,
1006,
402,
3062,
272,
367,
486,
315,
4652,
26,
267,
2621,
847,
486,
339,
327,
372,
314,
769,
402,
4652,
272,
372,
2621,
199,
199,
318,
1852,
63,
3512,
8,
2634,
12,
1572,
63,
3512,
29,
403,
304,
272,
408,
267,
23365,
3628,
436,
892,
1572,
13546,
14,
398,
4652,
26,
3820,
402,
4652,
14,
4960,
1572,
63,
3512,
26,
10354,
83,
367,
314,
4652,
14,
4879,
14,
272,
408,
339,
327,
781,
886,
440,
1172,
1572,
3628,
272,
892,
2634,
275,
3355,
8,
513,
8,
409,
8,
2634,
1724,
339,
327,
1852,
892,
1572,
14154,
272,
299,
2634,
275,
980,
14,
1144,
8,
267,
769,
8,
288,
2341,
8,
355,
2400,
486,
26,
1222,
2634,
14,
1080,
8,
71,
395,
355,
4652,
288,
776,
267,
776,
272,
776,
339,
340,
1572,
63,
3512,
508,
488,
26,
267,
327,
340,
781,
886,
440,
1172,
3628,
12,
675,
314,
1572,
1305,
465,
282,
1768,
267,
299,
3512,
275,
769,
8,
1130,
8,
495,
12,
892,
2634,
430,
272,
587,
26,
267,
299,
3512,
275,
1572,
63,
3512,
339,
372,
334,
80,
2634,
12,
299,
3512,
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
] |
[
2680,
465,
980,
199,
199,
318,
1572,
63,
10116,
63,
991,
8,
576,
12,
1572,
304,
272,
408,
267,
4652,
314,
10507,
402,
376,
1625,
14,
398,
666,
26,
8725,
402,
1314,
314,
10507,
1077,
506,
3355,
267,
1572,
26,
8725,
402,
3423,
626,
1077,
372,
340,
376,
1242,
15006,
370,
282,
1572,
14,
272,
408,
339,
327,
1218,
376,
1625,
402,
4652,
272,
4652,
275,
3474,
61,
367,
486,
315,
1572,
61,
339,
327,
13974,
4012,
314,
666,
272,
367,
1335,
12,
366,
315,
3874,
8,
576,
304,
267,
327,
436,
4012,
314,
4652,
267,
367,
284,
12,
486,
315,
3874,
8,
923,
304,
288,
340,
486,
8,
68,
304,
355,
4652,
59,
73,
1055,
740,
8,
74,
9,
339,
372,
4652,
199,
199,
318,
1852,
63,
923,
63,
1648,
8,
576,
12,
1572,
304,
272,
408,
267,
25031,
314,
10507,
402,
376,
1625,
436,
2529,
1373,
1625,
543,
10507,
641,
282,
1126,
13,
923,
5597,
14,
398,
666,
26,
8725,
402,
1314,
314,
10507,
1077,
506,
3355,
267,
1572,
26,
8725,
402,
3423,
626,
1077,
372,
340,
376,
1242,
15006,
370,
282,
1572,
14,
272,
408,
339,
327,
1852,
4652,
272,
4652,
275,
1572,
63,
10116,
63,
991,
8,
576,
12,
1572,
9,
339,
327,
1218,
282,
892,
1625,
402,
4652,
272,
2621,
275,
942,
339,
327,
1050,
1006,
402,
3062,
272,
367,
486,
315,
4652,
26,
267,
2621,
847,
486,
339,
327,
372,
314,
769,
402,
4652,
272,
372,
2621,
199,
199,
318,
1852,
63,
3512,
8,
2634,
12,
1572,
63,
3512,
29,
403,
304,
272,
408,
267,
23365,
3628,
436,
892,
1572,
13546,
14,
398,
4652,
26,
3820,
402,
4652,
14,
4960,
1572,
63,
3512,
26,
10354,
83,
367,
314,
4652,
14,
4879,
14,
272,
408,
339,
327,
781,
886,
440,
1172,
1572,
3628,
272,
892,
2634,
275,
3355,
8,
513,
8,
409,
8,
2634,
1724,
339,
327,
1852,
892,
1572,
14154,
272,
299,
2634,
275,
980,
14,
1144,
8,
267,
769,
8,
288,
2341,
8,
355,
2400,
486,
26,
1222,
2634,
14,
1080,
8,
71,
395,
355,
4652,
288,
776,
267,
776,
272,
776,
339,
340,
1572,
63,
3512,
508,
488,
26,
267,
327,
340,
781,
886,
440,
1172,
3628,
12,
675,
314,
1572,
1305,
465,
282,
1768,
267,
299,
3512,
275,
769,
8,
1130,
8,
495,
12,
892,
2634,
430,
272,
587,
26,
267,
299,
3512,
275,
1572,
63,
3512,
339,
372,
334,
80,
2634,
12,
299,
3512,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
sillvan/hyperspy
|
doc/user_guide/conf.py
|
2
|
9753
|
# -*- coding: utf-8 -*-
#
# HyperSpy User Guide documentation build configuration file, created by
# sphinx-quickstart on Wed Feb 29 15:14:48 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
sys.path.append('../../')
sys.path.append(os.path.abspath('../sphinxext'))
from hyperspy import Release
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.autodoc',
'gen_rst',
'numpydoc',
'matplotlib.sphinxext.only_directives',
'sphinx.ext.intersphinx',
'sphinx.ext.pngmath',
'sphinx.ext.autosummary',
'ipython_console_highlighting'] # , 'rst2pdf.pdfbuilder']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'HyperSpy User Guide [Draft]'
copyright = u'2011-2013, The HyperSpy Developers'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = Release.version
# The full version, including alpha/beta/rc tags.
release = Release.version
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = "HyperSpy User Guide v%s" % Release.version
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'HyperSpyUserGuidedoc'
# -- Options for LaTeX output --------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'HyperSpyUserGuide.tex', u'HyperSpy User Guide',
u'The HyperSpy Developers', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
latex_logo = '_static/hyperspy_logo.png'
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'hyperspyuserguide', u'HyperSpy User Guide Documentation',
[u'The HyperSpy Developers'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'HyperSpyUserGuide', u'HyperSpy User Guide Documentation',
u'The HyperSpy Developers', 'HyperSpyUserGuide', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# -- Options for Epub output ---------------------------------------------
# Bibliographic Dublin Core info.
epub_title = u'HyperSpy User Guide'
epub_author = u'The HyperSpy Developers'
epub_publisher = u'he HyperSpy Developers'
epub_copyright = u'2011-2013, he HyperSpy Developers'
# The language of the text. It defaults to the language option
# or en if the language is not set.
#epub_language = ''
# The scheme of the identifier. Typical schemes are ISBN or URL.
#epub_scheme = ''
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#epub_identifier = ''
# A unique identification for the text.
#epub_uid = ''
# A tuple containing the cover image and cover page html template filenames.
#epub_cover = ()
# HTML files that should be inserted before the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_pre_files = []
# HTML files shat should be inserted after the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_post_files = []
# A list of files that should not be packed into the epub file.
#epub_exclude_files = []
# The depth of the table of contents in toc.ncx.
#epub_tocdepth = 3
# Allow duplicate toc entries.
#epub_tocdup = True
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'hyperspyweb': ('http://hyperspy.org/', None)}
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
21344,
51,
647,
2876,
15423,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
644,
379,
21141,
7349,
4114,
26,
1079,
26,
2006,
6029,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
3035,
2935,
14,
199,
3,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
199,
646,
747,
199,
1274,
14,
515,
14,
740,
360,
9707,
358,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
4832,
24592,
8008,
832,
1333,
199,
199,
504,
10342,
15252,
492,
17646,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
11016,
18964,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
5478,
199,
3,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
832,
24915,
503,
2195,
3537,
7869,
14,
199,
5359,
275,
359,
272,
283,
8008,
14,
832,
14,
28056,
297,
272,
283,
2268,
63,
8332,
297,
272,
283,
4714,
1301,
297,
272,
283,
16440,
14,
8008,
832,
14,
2118,
63,
23216,
297,
272,
283,
8008,
14,
832,
14,
1058,
8008,
297,
272,
283,
8008,
14,
832,
14,
4524,
3442,
297,
272,
283,
8008,
14,
832,
14,
29764,
29309,
297,
272,
283,
22691,
63,
6614,
63,
14337,
316,
418,
221,
327,
2360,
283,
8332,
18,
5607,
14,
5607,
5649,
418,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
13,
4093,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
1715,
275,
399,
7,
18727,
51,
647,
2876,
15423,
359,
18332,
6616,
199,
7307,
275,
399,
7,
8128,
13,
6965,
12,
710,
21344,
51,
647,
23493,
7,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
1023,
275,
17646,
14,
1023,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
17646,
14,
1023,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
4044,
1506,
418,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
8247,
14,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
63,
1593,
63,
25510,
275,
715,
199,
199,
3,
982,
2549,
12,
314,
1453,
859,
536,
911,
506,
20247,
370,
1006,
1369,
199,
3,
4137,
16194,
334,
10180,
465,
2508,
805,
32469,
199,
3,
525,
63,
578,
63,
1247,
275,
715,
199,
199,
3,
982,
2549,
12,
3420,
2502,
436,
28966,
13502,
911,
506,
9164,
315,
314,
199,
3,
1072,
14,
9322,
787,
5525,
701,
849,
14,
199,
3,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
11016,
8684,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
199,
1360,
63,
7915,
275,
283,
885,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
3,
1360,
63,
7915,
63,
515,
275,
942,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
1360,
63,
1213,
275,
298,
18727,
51,
647,
2876,
15423,
373,
5,
83
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
21344,
51,
647,
2876,
15423,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
644,
379,
21141,
7349,
4114,
26,
1079,
26,
2006,
6029,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
3035,
2935,
14,
199,
3,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
199,
646,
747,
199,
1274,
14,
515,
14,
740,
360,
9707,
358,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
4832,
24592,
8008,
832,
1333,
199,
199,
504,
10342,
15252,
492,
17646,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
11016,
18964,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
5478,
199,
3,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
832,
24915,
503,
2195,
3537,
7869,
14,
199,
5359,
275,
359,
272,
283,
8008,
14,
832,
14,
28056,
297,
272,
283,
2268,
63,
8332,
297,
272,
283,
4714,
1301,
297,
272,
283,
16440,
14,
8008,
832,
14,
2118,
63,
23216,
297,
272,
283,
8008,
14,
832,
14,
1058,
8008,
297,
272,
283,
8008,
14,
832,
14,
4524,
3442,
297,
272,
283,
8008,
14,
832,
14,
29764,
29309,
297,
272,
283,
22691,
63,
6614,
63,
14337,
316,
418,
221,
327,
2360,
283,
8332,
18,
5607,
14,
5607,
5649,
418,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
13,
4093,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
1715,
275,
399,
7,
18727,
51,
647,
2876,
15423,
359,
18332,
6616,
199,
7307,
275,
399,
7,
8128,
13,
6965,
12,
710,
21344,
51,
647,
23493,
7,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
1023,
275,
17646,
14,
1023,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
17646,
14,
1023,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
4044,
1506,
418,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
8247,
14,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
63,
1593,
63,
25510,
275,
715,
199,
199,
3,
982,
2549,
12,
314,
1453,
859,
536,
911,
506,
20247,
370,
1006,
1369,
199,
3,
4137,
16194,
334,
10180,
465,
2508,
805,
32469,
199,
3,
525,
63,
578,
63,
1247,
275,
715,
199,
199,
3,
982,
2549,
12,
3420,
2502,
436,
28966,
13502,
911,
506,
9164,
315,
314,
199,
3,
1072,
14,
9322,
787,
5525,
701,
849,
14,
199,
3,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
11016,
8684,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
199,
1360,
63,
7915,
275,
283,
885,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
3,
1360,
63,
7915,
63,
515,
275,
942,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
1360,
63,
1213,
275,
298,
18727,
51,
647,
2876,
15423,
373,
5,
83,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
EssaAlshammri/django-by-example
|
online-shop/myshop/payment/signals.py
|
1
|
1219
|
from io import BytesIO
import weasyprint
from django.conf import settings
from django.core.mail import EmailMessage
from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
from paypal.standard.ipn.signals import valid_ipn_received
from paypal.standard.models import ST_PP_COMPLETED
from orders.models import Order
def payment_notification(sender, **kwargs):
ipn_obj = sender
if ipn_obj.payment_status == ST_PP_COMPLETED:
order = get_object_or_404(Order, id=ipn_obj.invoice)
order.paid = True
order.save()
subject = 'My Shop - Invoice no. {}'.format(order.id)
message = 'Please, find the attached invoice for your recent purchase.'
email = EmailMessage(subject, message, 'admin@myshop.com', [order.email])
html = render_to_string('orders/order/pdf.html', {'order': order})
out = BytesIO()
stylesheets=[weasyprint.CSS(settings.STATIC_ROOT + 'css/pdf.css')]
weasyprint.HTML(string=html).write_pdf(out, stylesheets=stylesheets)
email.attach('order_{}.pdf'.format(order.id), out.getvalue(), 'application/pdf')
email.send()
valid_ipn_received.connect(payment_notification)
|
mit
|
[
504,
5890,
492,
11808,
199,
199,
646,
781,
5660,
1361,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
1198,
492,
11426,
2209,
199,
504,
1639,
14,
17469,
492,
664,
63,
785,
63,
269,
63,
5188,
199,
504,
1639,
14,
1160,
14,
3422,
492,
3795,
63,
475,
63,
875,
199,
504,
691,
22006,
14,
6807,
14,
711,
78,
14,
10458,
492,
1686,
63,
711,
78,
63,
9226,
199,
504,
691,
22006,
14,
6807,
14,
992,
492,
4384,
63,
7701,
63,
12558,
18348,
199,
199,
504,
15460,
14,
992,
492,
9240,
421,
199,
318,
11628,
63,
6761,
8,
8114,
12,
1011,
958,
304,
272,
3384,
78,
63,
1113,
275,
8904,
272,
340,
3384,
78,
63,
1113,
14,
7948,
63,
1205,
508,
4384,
63,
7701,
63,
12558,
18348,
26,
267,
1865,
275,
664,
63,
785,
63,
269,
63,
5188,
8,
4738,
12,
1305,
29,
711,
78,
63,
1113,
14,
5404,
9,
267,
1865,
14,
16555,
275,
715,
267,
1865,
14,
2117,
342,
267,
5420,
275,
283,
5713,
5244,
411,
446,
19868,
949,
14,
9499,
908,
8,
1648,
14,
344,
9,
267,
1245,
275,
283,
8254,
12,
2342,
314,
10102,
8485,
367,
2195,
8058,
15932,
3530,
267,
3031,
275,
11426,
2209,
8,
5875,
12,
1245,
12,
283,
2113,
32,
23726,
13376,
14,
957,
297,
359,
1648,
14,
2123,
566,
267,
3517,
275,
3795,
63,
475,
63,
875,
360,
14387,
15,
1648,
15,
5607,
14,
1360,
297,
791,
1648,
356,
1865,
1552,
267,
734,
275,
11808,
342,
267,
3449,
24376,
1524,
1129,
5660,
1361,
14,
14391,
8,
1751,
14,
10449,
63,
5441,
435,
283,
3919,
15,
5607,
14,
3919,
5440,
267,
781,
5660,
1361,
14,
4943,
8,
875,
29,
1360,
680,
952,
63,
5607,
8,
548,
12,
3449,
24376,
29,
15479,
83,
9,
267,
3031,
14,
5040,
360,
1648,
24306,
14,
5607,
1370,
908,
8,
1648,
14,
344,
395,
734,
14,
7150,
1062,
283,
3578,
15,
5607,
358,
267,
3031,
14,
2254,
342,
199,
199,
1078,
63,
711,
78,
63,
9226,
14,
2242,
8,
7948,
63,
6761,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
5890,
492,
11808,
199,
199,
646,
781,
5660,
1361,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
1198,
492,
11426,
2209,
199,
504,
1639,
14,
17469,
492,
664,
63,
785,
63,
269,
63,
5188,
199,
504,
1639,
14,
1160,
14,
3422,
492,
3795,
63,
475,
63,
875,
199,
504,
691,
22006,
14,
6807,
14,
711,
78,
14,
10458,
492,
1686,
63,
711,
78,
63,
9226,
199,
504,
691,
22006,
14,
6807,
14,
992,
492,
4384,
63,
7701,
63,
12558,
18348,
199,
199,
504,
15460,
14,
992,
492,
9240,
421,
199,
318,
11628,
63,
6761,
8,
8114,
12,
1011,
958,
304,
272,
3384,
78,
63,
1113,
275,
8904,
272,
340,
3384,
78,
63,
1113,
14,
7948,
63,
1205,
508,
4384,
63,
7701,
63,
12558,
18348,
26,
267,
1865,
275,
664,
63,
785,
63,
269,
63,
5188,
8,
4738,
12,
1305,
29,
711,
78,
63,
1113,
14,
5404,
9,
267,
1865,
14,
16555,
275,
715,
267,
1865,
14,
2117,
342,
267,
5420,
275,
283,
5713,
5244,
411,
446,
19868,
949,
14,
9499,
908,
8,
1648,
14,
344,
9,
267,
1245,
275,
283,
8254,
12,
2342,
314,
10102,
8485,
367,
2195,
8058,
15932,
3530,
267,
3031,
275,
11426,
2209,
8,
5875,
12,
1245,
12,
283,
2113,
32,
23726,
13376,
14,
957,
297,
359,
1648,
14,
2123,
566,
267,
3517,
275,
3795,
63,
475,
63,
875,
360,
14387,
15,
1648,
15,
5607,
14,
1360,
297,
791,
1648,
356,
1865,
1552,
267,
734,
275,
11808,
342,
267,
3449,
24376,
1524,
1129,
5660,
1361,
14,
14391,
8,
1751,
14,
10449,
63,
5441,
435,
283,
3919,
15,
5607,
14,
3919,
5440,
267,
781,
5660,
1361,
14,
4943,
8,
875,
29,
1360,
680,
952,
63,
5607,
8,
548,
12,
3449,
24376,
29,
15479,
83,
9,
267,
3031,
14,
5040,
360,
1648,
24306,
14,
5607,
1370,
908,
8,
1648,
14,
344,
395,
734,
14,
7150,
1062,
283,
3578,
15,
5607,
358,
267,
3031,
14,
2254,
342,
199,
199,
1078,
63,
711,
78,
63,
9226,
14,
2242,
8,
7948,
63,
6761,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_tables.py
|
15
|
4648
|
# Copyright 2015 Cisco Systems, 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.
#
"""Cisco N1kv ML2 driver tables
Revision ID: 589f9237ca0e
Revises: 51c54792158e
Create Date: 2014-08-13 13:31:43.537460
"""
# revision identifiers, used by Alembic.
revision = '589f9237ca0e'
down_revision = '51c54792158e'
from alembic import op
import sqlalchemy as sa
network_profile_type = sa.Enum('vlan', 'vxlan',
name='network_profile_type')
profile_type = sa.Enum('network', 'policy', name='profile_type')
def upgrade():
op.create_table(
'cisco_ml2_n1kv_policy_profiles',
sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('vsm_ip', sa.String(length=16), nullable=False),
sa.PrimaryKeyConstraint('id', 'vsm_ip'),
)
op.create_table(
'cisco_ml2_n1kv_network_profiles',
sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('segment_type', network_profile_type, nullable=False),
sa.Column('segment_range', sa.String(length=255), nullable=True),
sa.Column('multicast_ip_index', sa.Integer(), nullable=True),
sa.Column('multicast_ip_range', sa.String(length=255), nullable=True),
sa.Column('sub_type', sa.String(length=255), nullable=True),
sa.Column('physical_network', sa.String(length=255), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
op.create_table(
'cisco_ml2_n1kv_port_bindings',
sa.Column('port_id', sa.String(length=36), nullable=False),
sa.Column('profile_id', sa.String(length=36), nullable=False),
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('port_id'),
)
op.create_table(
'cisco_ml2_n1kv_network_bindings',
sa.Column('network_id', sa.String(length=36), nullable=False),
sa.Column('network_type', sa.String(length=32), nullable=False),
sa.Column('segmentation_id', sa.Integer(), autoincrement=False),
sa.Column('profile_id', sa.String(length=36), nullable=False),
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
ondelete='CASCADE'),
sa.ForeignKeyConstraint(['profile_id'],
['cisco_ml2_n1kv_network_profiles.id']),
sa.PrimaryKeyConstraint('network_id')
)
op.create_table(
'cisco_ml2_n1kv_vxlan_allocations',
sa.Column('vxlan_id', sa.Integer(), autoincrement=False,
nullable=False),
sa.Column('allocated', sa.Boolean(), nullable=False),
sa.Column('network_profile_id', sa.String(length=36), nullable=False),
sa.ForeignKeyConstraint(['network_profile_id'],
['cisco_ml2_n1kv_network_profiles.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('vxlan_id')
)
op.create_table(
'cisco_ml2_n1kv_vlan_allocations',
sa.Column('physical_network', sa.String(length=64), nullable=False),
sa.Column('vlan_id', sa.Integer(), autoincrement=False,
nullable=False),
sa.Column('allocated', sa.Boolean(), autoincrement=False,
nullable=False),
sa.Column('network_profile_id', sa.String(length=36), nullable=False),
sa.ForeignKeyConstraint(['network_profile_id'],
['cisco_ml2_n1kv_network_profiles.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('physical_network', 'vlan_id')
)
op.create_table(
'cisco_ml2_n1kv_profile_bindings',
sa.Column('profile_type', profile_type, nullable=True),
sa.Column('tenant_id', sa.String(length=36), nullable=False,
server_default='tenant_id_not_set'),
sa.Column('profile_id', sa.String(length=36), nullable=False),
sa.PrimaryKeyConstraint('tenant_id', 'profile_id')
)
|
apache-2.0
|
[
3,
1898,
6900,
28356,
15285,
12,
3277,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
3,
199,
199,
624,
17540,
653,
17,
11475,
28007,
18,
5253,
6716,
199,
199,
12714,
2870,
26,
959,
1407,
70,
2942,
1401,
696,
16,
69,
199,
497,
433,
874,
26,
8026,
67,
1477,
1965,
7842,
24,
69,
199,
2499,
6148,
26,
6927,
13,
2036,
13,
969,
4944,
26,
2192,
26,
2824,
14,
2481,
1342,
2259,
199,
199,
624,
199,
199,
3,
6974,
14154,
12,
1202,
701,
6832,
20596,
14,
199,
5792,
275,
283,
32502,
70,
2942,
1401,
696,
16,
69,
7,
199,
2110,
63,
5792,
275,
283,
2869,
67,
1477,
1965,
7842,
24,
69,
7,
421,
199,
504,
30960,
20596,
492,
1687,
199,
646,
8335,
465,
2937,
199,
199,
1200,
63,
2913,
63,
466,
275,
2937,
14,
5081,
360,
7175,
297,
283,
18843,
1502,
297,
3044,
536,
534,
1200,
63,
2913,
63,
466,
358,
199,
2913,
63,
466,
275,
2937,
14,
5081,
360,
1200,
297,
283,
3185,
297,
536,
534,
2913,
63,
466,
358,
421,
199,
318,
10754,
837,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
3185,
63,
11225,
297,
267,
2937,
14,
4547,
360,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
354,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
3122,
77,
63,
711,
297,
2937,
14,
1558,
8,
1267,
29,
975,
395,
7854,
29,
797,
395,
267,
2937,
14,
29457,
8463,
360,
344,
297,
283,
3122,
77,
63,
711,
659,
272,
776,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
1200,
63,
11225,
297,
267,
2937,
14,
4547,
360,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
354,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
9255,
63,
466,
297,
2784,
63,
2913,
63,
466,
12,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
9255,
63,
1842,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
549,
395,
267,
2937,
14,
4547,
360,
23797,
63,
711,
63,
1080,
297,
2937,
14,
2674,
1062,
7854,
29,
549,
395,
267,
2937,
14,
4547,
360,
23797,
63,
711,
63,
1842,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
549,
395,
267,
2937,
14,
4547,
360,
954,
63,
466,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
549,
395,
267,
2937,
14,
4547,
360,
15020,
63,
1200,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
549,
395,
267,
2937,
14,
29457,
8463,
360,
344,
659,
272,
776,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
719,
63,
10880,
297,
267,
2937,
14,
4547,
360,
719,
63,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
2913,
63,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
3190,
8463,
2941,
719,
63,
344,
995,
788,
5203,
14,
344,
995,
16549,
534,
10855,
659,
267,
2937,
14,
29457,
8463,
360,
719,
63,
344,
659,
272,
776,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
1200,
63,
10880,
297,
267,
2937,
14,
4547,
360,
1200,
63,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
1200,
63,
466,
297,
2937,
14,
1558,
8,
1267,
29,
708,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
26926,
63,
344,
297,
2937,
14,
2674,
1062,
32497,
29,
797,
395,
267,
2937,
14,
4547,
360,
2913,
63,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
3190,
8463,
2941,
1200,
63,
344,
995,
788,
7642,
14,
344,
995,
1816,
16549,
534,
10855,
659,
267,
2937,
14,
3190,
8463,
2941,
2913,
63,
344,
995,
1816,
788,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
1200,
63,
11225,
14,
344,
3815,
267,
2937,
14,
29457,
8463,
360,
1200,
63,
344,
358,
272,
776,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
18843,
1502,
63,
279,
8022,
297,
267,
2937,
14,
4547,
360,
18843,
1502,
63,
344,
297,
2937,
14,
2674,
1062,
32497,
29,
797,
12,
2116,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
19570,
297,
2937,
14,
4082,
1062,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
1200,
63,
2913,
63,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
3190,
8463,
2941,
1200,
63,
2913,
63,
344,
995,
1816,
788,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
1200,
63,
11225,
14,
344,
995,
1816,
16549,
534,
10855,
659,
267,
2937,
14,
29457,
8463,
360,
18843,
1502,
63,
344,
358,
272,
776,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
7175,
63,
279,
8022,
297,
267,
2937,
14,
4547,
360,
15020,
63,
1200,
297,
2937,
14,
1558,
8,
1267
] |
[
1898,
6900,
28356,
15285,
12,
3277,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
3,
199,
199,
624,
17540,
653,
17,
11475,
28007,
18,
5253,
6716,
199,
199,
12714,
2870,
26,
959,
1407,
70,
2942,
1401,
696,
16,
69,
199,
497,
433,
874,
26,
8026,
67,
1477,
1965,
7842,
24,
69,
199,
2499,
6148,
26,
6927,
13,
2036,
13,
969,
4944,
26,
2192,
26,
2824,
14,
2481,
1342,
2259,
199,
199,
624,
199,
199,
3,
6974,
14154,
12,
1202,
701,
6832,
20596,
14,
199,
5792,
275,
283,
32502,
70,
2942,
1401,
696,
16,
69,
7,
199,
2110,
63,
5792,
275,
283,
2869,
67,
1477,
1965,
7842,
24,
69,
7,
421,
199,
504,
30960,
20596,
492,
1687,
199,
646,
8335,
465,
2937,
199,
199,
1200,
63,
2913,
63,
466,
275,
2937,
14,
5081,
360,
7175,
297,
283,
18843,
1502,
297,
3044,
536,
534,
1200,
63,
2913,
63,
466,
358,
199,
2913,
63,
466,
275,
2937,
14,
5081,
360,
1200,
297,
283,
3185,
297,
536,
534,
2913,
63,
466,
358,
421,
199,
318,
10754,
837,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
3185,
63,
11225,
297,
267,
2937,
14,
4547,
360,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
354,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
3122,
77,
63,
711,
297,
2937,
14,
1558,
8,
1267,
29,
975,
395,
7854,
29,
797,
395,
267,
2937,
14,
29457,
8463,
360,
344,
297,
283,
3122,
77,
63,
711,
659,
272,
776,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
1200,
63,
11225,
297,
267,
2937,
14,
4547,
360,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
354,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
9255,
63,
466,
297,
2784,
63,
2913,
63,
466,
12,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
9255,
63,
1842,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
549,
395,
267,
2937,
14,
4547,
360,
23797,
63,
711,
63,
1080,
297,
2937,
14,
2674,
1062,
7854,
29,
549,
395,
267,
2937,
14,
4547,
360,
23797,
63,
711,
63,
1842,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
549,
395,
267,
2937,
14,
4547,
360,
954,
63,
466,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
549,
395,
267,
2937,
14,
4547,
360,
15020,
63,
1200,
297,
2937,
14,
1558,
8,
1267,
29,
2299,
395,
7854,
29,
549,
395,
267,
2937,
14,
29457,
8463,
360,
344,
659,
272,
776,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
719,
63,
10880,
297,
267,
2937,
14,
4547,
360,
719,
63,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
2913,
63,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
3190,
8463,
2941,
719,
63,
344,
995,
788,
5203,
14,
344,
995,
16549,
534,
10855,
659,
267,
2937,
14,
29457,
8463,
360,
719,
63,
344,
659,
272,
776,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
1200,
63,
10880,
297,
267,
2937,
14,
4547,
360,
1200,
63,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
1200,
63,
466,
297,
2937,
14,
1558,
8,
1267,
29,
708,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
26926,
63,
344,
297,
2937,
14,
2674,
1062,
32497,
29,
797,
395,
267,
2937,
14,
4547,
360,
2913,
63,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
3190,
8463,
2941,
1200,
63,
344,
995,
788,
7642,
14,
344,
995,
1816,
16549,
534,
10855,
659,
267,
2937,
14,
3190,
8463,
2941,
2913,
63,
344,
995,
1816,
788,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
1200,
63,
11225,
14,
344,
3815,
267,
2937,
14,
29457,
8463,
360,
1200,
63,
344,
358,
272,
776,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
18843,
1502,
63,
279,
8022,
297,
267,
2937,
14,
4547,
360,
18843,
1502,
63,
344,
297,
2937,
14,
2674,
1062,
32497,
29,
797,
12,
2116,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
19570,
297,
2937,
14,
4082,
1062,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
1200,
63,
2913,
63,
344,
297,
2937,
14,
1558,
8,
1267,
29,
1344,
395,
7854,
29,
797,
395,
267,
2937,
14,
3190,
8463,
2941,
1200,
63,
2913,
63,
344,
995,
1816,
788,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
1200,
63,
11225,
14,
344,
995,
1816,
16549,
534,
10855,
659,
267,
2937,
14,
29457,
8463,
360,
18843,
1502,
63,
344,
358,
272,
776,
339,
1687,
14,
981,
63,
1224,
8,
267,
283,
19597,
63,
757,
18,
63,
78,
17,
11475,
63,
7175,
63,
279,
8022,
297,
267,
2937,
14,
4547,
360,
15020,
63,
1200,
297,
2937,
14,
1558,
8,
1267,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
senttech/OctoPrint
|
src/octoprint/server/views.py
|
2
|
37190
|
# coding=utf-8
from __future__ import absolute_import, division, print_function
__author__ = "Gina Häußge <osd@foosel.net>"
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
import os
import datetime
from collections import defaultdict
from flask import request, g, url_for, make_response, render_template, send_from_directory, redirect, abort
import octoprint.plugin
from octoprint.server import app, userManager, pluginManager, gettext, \
debug, LOCALES, VERSION, DISPLAY_VERSION, UI_API_KEY, BRANCH, preemptiveCache, \
NOT_MODIFIED
from octoprint.settings import settings
from octoprint.filemanager import get_all_extensions
import re
import base64
from . import util
import logging
_logger = logging.getLogger(__name__)
_templates = None
_plugin_names = None
_plugin_vars = None
_valid_id_re = re.compile("[a-z_]+")
_valid_div_re = re.compile("[a-zA-Z_-]+")
def _preemptive_unless(base_url=None, additional_unless=None):
if base_url is None:
base_url = request.url_root
disabled_for_root = not settings().getBoolean(["devel", "cache", "preemptive"]) \
or base_url in settings().get(["server", "preemptiveCache", "exceptions"]) \
or not (base_url.startswith("http://") or base_url.startswith("https://"))
recording_disabled = request.headers.get("X-Preemptive-Record", "yes") == "no"
if callable(additional_unless):
return recording_disabled or disabled_for_root or additional_unless()
else:
return recording_disabled or disabled_for_root
def _preemptive_data(key, path=None, base_url=None, data=None, additional_request_data=None):
if path is None:
path = request.path
if base_url is None:
base_url = request.url_root
d = dict(path=path,
base_url=base_url,
query_string="l10n={}".format(g.locale.language if g.locale else "en"))
if key != "_default":
d["plugin"] = key
# add data if we have any
if data is not None:
try:
if callable(data):
data = data()
if data:
if "query_string" in data:
data["query_string"] = "l10n={}&{}".format(g.locale.language, data["query_string"])
d.update(data)
except:
_logger.exception("Error collecting data for preemptive cache from plugin {}".format(key))
# add additional request data if we have any
if callable(additional_request_data):
try:
ard = additional_request_data()
if ard:
d.update(dict(
_additional_request_data=ard
))
except:
_logger.exception("Error retrieving additional data for preemptive cache from plugin {}".format(key))
return d
def _cache_key(ui, url=None, locale=None, additional_key_data=None):
if url is None:
url = request.base_url
if locale is None:
locale = g.locale.language if g.locale else "en"
k = "ui:{}:{}:{}".format(ui, url, locale)
if callable(additional_key_data):
try:
ak = additional_key_data()
if ak:
# we have some additional key components, let's attach them
if not isinstance(ak, (list, tuple)):
ak = [ak]
k = "{}:{}".format(k, ":".join(ak))
except:
_logger.exception("Error while trying to retrieve additional cache key parts for ui {}".format(ui))
return k
def _valid_status_for_cache(status_code):
return 200 <= status_code < 400
@app.route("/cached.gif")
def in_cache():
url = request.base_url.replace("/cached.gif", "/")
path = request.path.replace("/cached.gif", "/")
base_url = request.url_root
# select view from plugins and fall back on default view if no plugin will handle it
ui_plugins = pluginManager.get_implementations(octoprint.plugin.UiPlugin,
sorting_context="UiPlugin.on_ui_render")
for plugin in ui_plugins:
if plugin.will_handle_ui(request):
ui = plugin._identifier
key = _cache_key(plugin._identifier,
url=url,
additional_key_data=plugin.get_ui_additional_key_data_for_cache)
unless = _preemptive_unless(url, additional_unless=plugin.get_ui_preemptive_caching_additional_unless)
data = _preemptive_data(plugin._identifier,
path=path,
base_url=base_url,
data=plugin.get_ui_data_for_preemptive_caching,
additional_request_data=plugin.get_ui_additional_request_data_for_preemptive_caching)
break
else:
ui = "_default"
key = _cache_key("_default", url=url)
unless = _preemptive_unless(url)
data = _preemptive_data("_default", path=path, base_url=base_url)
response = make_response(bytes(base64.b64decode("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")))
response.headers["Content-Type"] = "image/gif"
if unless or not preemptiveCache.has_record(data, root=path):
_logger.info("Preemptive cache not active for path {}, ui {} and data {!r}, signaling as cached".format(path, ui, data))
return response
elif util.flask.is_in_cache(key):
_logger.info("Found path {} in cache (key: {}), signaling as cached".format(path, key))
return response
elif util.flask.is_cache_bypassed(key):
_logger.info("Path {} was bypassed from cache (key: {}), signaling as cached".format(path, key))
return response
else:
_logger.debug("Path {} not yet cached (key: {}), signaling as missing".format(path, key))
return abort(404)
@app.route("/")
def index():
global _templates, _plugin_names, _plugin_vars
preemptive_cache_enabled = settings().getBoolean(["devel", "cache", "preemptive"])
# helper to check if wizards are active
def wizard_active(templates):
return templates is not None and bool(templates["wizard"]["order"])
# we force a refresh if the client forces one or if we have wizards cached
force_refresh = util.flask.cache_check_headers() or "_refresh" in request.values or wizard_active(_templates)
# if we need to refresh our template cache or it's not yet set, process it
if force_refresh or _templates is None or _plugin_names is None or _plugin_vars is None:
_templates, _plugin_names, _plugin_vars = _process_templates()
now = datetime.datetime.utcnow()
render_kwargs = _get_render_kwargs(_templates, _plugin_names, _plugin_vars, now)
def get_preemptively_cached_view(key, view, data=None, additional_request_data=None, additional_unless=None):
if (data is None and additional_request_data is None) or g.locale is None:
return view
d = _preemptive_data(key, data=data, additional_request_data=additional_request_data)
def unless():
return _preemptive_unless(base_url=request.url_root, additional_unless=additional_unless)
# finally decorate our view
return util.flask.preemptively_cached(cache=preemptiveCache,
data=d,
unless=unless)(view)
def get_cached_view(key, view, additional_key_data=None, additional_files=None, custom_files=None, custom_etag=None, custom_lastmodified=None):
def cache_key():
return _cache_key(key, additional_key_data=additional_key_data)
def check_etag_and_lastmodified():
files = collect_files()
lastmodified = compute_lastmodified(files)
lastmodified_ok = util.flask.check_lastmodified(lastmodified)
etag_ok = util.flask.check_etag(compute_etag(files=files,
lastmodified=lastmodified,
additional=cache_key()))
return lastmodified_ok and etag_ok
def validate_cache(cached):
etag_different = compute_etag(additional=cache_key()) != cached.get_etag()[0]
return force_refresh or etag_different
def collect_files():
if callable(custom_files):
try:
files = custom_files()
if files:
return files
except:
_logger.exception("Error while trying to retrieve tracked files for plugin {}".format(key))
templates = _get_all_templates()
assets = _get_all_assets()
translations = _get_all_translationfiles(g.locale.language if g.locale else "en",
"messages")
files = templates + assets + translations
if callable(additional_files):
try:
af = additional_files()
if af:
files += af
except:
_logger.exception("Error while trying to retrieve additional tracked files for plugin {}".format(key))
return sorted(set(files))
def compute_lastmodified(files=None):
if callable(custom_lastmodified):
try:
lastmodified = custom_lastmodified()
if lastmodified:
return lastmodified
except:
_logger.exception("Error while trying to retrieve custom LastModified value for plugin {}".format(key))
if files is None:
files = collect_files()
return _compute_date(files)
def compute_etag(files=None, lastmodified=None, additional=None):
if callable(custom_etag):
try:
etag = custom_etag()
if etag:
return etag
except:
_logger.exception("Error while trying to retrieve custom ETag value for plugin {}".format(key))
if files is None:
files = collect_files()
if lastmodified is None:
lastmodified = compute_lastmodified(files)
if lastmodified and not isinstance(lastmodified, basestring):
from werkzeug.http import http_date
lastmodified = http_date(lastmodified)
if additional is None:
additional = []
import hashlib
hash = hashlib.sha1()
hash.update(octoprint.__version__)
hash.update(octoprint.server.UI_API_KEY)
hash.update(",".join(sorted(files)))
if lastmodified:
hash.update(lastmodified)
for add in additional:
hash.update(add)
return hash.hexdigest()
decorated_view = view
decorated_view = util.flask.lastmodified(lambda _: compute_lastmodified())(decorated_view)
decorated_view = util.flask.etagged(lambda _: compute_etag(additional=cache_key()))(decorated_view)
decorated_view = util.flask.cached(timeout=-1,
refreshif=validate_cache,
key=cache_key,
unless_response=lambda response: util.flask.cache_check_response_headers(response) or util.flask.cache_check_status_code(response, _valid_status_for_cache))(decorated_view)
decorated_view = util.flask.conditional(check_etag_and_lastmodified, NOT_MODIFIED)(decorated_view)
return decorated_view
def plugin_view(p):
cached = get_cached_view(p._identifier,
p.on_ui_render,
additional_key_data=p.get_ui_additional_key_data_for_cache,
additional_files=p.get_ui_additional_tracked_files,
custom_files=p.get_ui_custom_tracked_files,
custom_etag=p.get_ui_custom_etag,
custom_lastmodified=p.get_ui_custom_lastmodified)
if preemptive_cache_enabled and p.get_ui_preemptive_caching_enabled():
view = get_preemptively_cached_view(p._identifier,
cached,
p.get_ui_data_for_preemptive_caching,
p.get_ui_additional_request_data_for_preemptive_caching,
p.get_ui_preemptive_caching_additional_unless)
else:
view = cached
return view(now, request, render_kwargs)
def default_view():
wizard = wizard_active(_templates)
enable_accesscontrol = userManager.enabled
accesscontrol_active = enable_accesscontrol and userManager.hasBeenCustomized()
render_kwargs.update(dict(
webcamStream=settings().get(["webcam", "stream"]),
enableTemperatureGraph=settings().get(["feature", "temperatureGraph"]),
enableAccessControl=enable_accesscontrol,
accessControlActive=accesscontrol_active,
enableSdSupport=settings().get(["feature", "sdSupport"]),
gcodeMobileThreshold=settings().get(["gcodeViewer", "mobileSizeThreshold"]),
gcodeThreshold=settings().get(["gcodeViewer", "sizeThreshold"]),
wizard=wizard,
now=now,
))
# no plugin took an interest, we'll use the default UI
def make_default_ui():
r = make_response(render_template("index.jinja2", **render_kwargs))
if wizard:
# if we have active wizard dialogs, set non caching headers
r = util.flask.add_non_caching_response_headers(r)
return r
cached = get_cached_view("_default",
make_default_ui)
preemptively_cached = get_preemptively_cached_view("_default",
cached,
dict(),
dict())
return preemptively_cached()
response = None
forced_view = request.headers.get("X-Force-View", None)
if forced_view:
# we have view forced by the preemptive cache
_logger.debug("Forcing rendering of view {}".format(forced_view))
if forced_view != "_default":
plugin = pluginManager.get_plugin_info(forced_view, require_enabled=True)
if plugin is not None and isinstance(plugin.implementation, octoprint.plugin.UiPlugin):
response = plugin_view(plugin.implementation)
else:
response = default_view()
else:
# select view from plugins and fall back on default view if no plugin will handle it
ui_plugins = pluginManager.get_implementations(octoprint.plugin.UiPlugin, sorting_context="UiPlugin.on_ui_render")
for plugin in ui_plugins:
if plugin.will_handle_ui(request):
# plugin claims responsibility, let it render the UI
response = plugin_view(plugin)
if response is not None:
break
else:
_logger.warn("UiPlugin {} returned an empty response".format(plugin._identifier))
else:
response = default_view()
if response is None:
return abort(404)
return response
def _get_render_kwargs(templates, plugin_names, plugin_vars, now):
#~~ a bunch of settings
first_run = settings().getBoolean(["server", "firstRun"])
locales = dict((l.language, dict(language=l.language, display=l.display_name, english=l.english_name)) for l in LOCALES)
extensions = map(lambda ext: ".{}".format(ext), get_all_extensions())
#~~ prepare full set of template vars for rendering
render_kwargs = dict(
debug=debug,
firstRun=first_run,
version=dict(number=VERSION, display=DISPLAY_VERSION, branch=BRANCH),
uiApiKey=UI_API_KEY,
templates=templates,
pluginNames=plugin_names,
locales=locales,
supportedExtensions=extensions
)
render_kwargs.update(plugin_vars)
return render_kwargs
def _process_templates():
enable_accesscontrol = userManager.enabled
first_run = settings().getBoolean(["server", "firstRun"])
enable_gcodeviewer = settings().getBoolean(["gcodeViewer", "enabled"])
enable_timelapse = (settings().get(["webcam", "snapshot"]) and settings().get(["webcam", "ffmpeg"]))
enable_systemmenu = settings().get(["system"]) is not None and settings().get(["system", "actions"]) is not None
preferred_stylesheet = settings().get(["devel", "stylesheet"])
##~~ prepare templates
templates = defaultdict(lambda: dict(order=[], entries=dict()))
# rules for transforming template configs to template entries
template_rules = dict(
navbar=dict(div=lambda x: "navbar_plugin_" + x, template=lambda x: x + "_navbar.jinja2", to_entry=lambda data: data),
sidebar=dict(div=lambda x: "sidebar_plugin_" + x, template=lambda x: x + "_sidebar.jinja2", to_entry=lambda data: (data["name"], data)),
tab=dict(div=lambda x: "tab_plugin_" + x, template=lambda x: x + "_tab.jinja2", to_entry=lambda data: (data["name"], data)),
settings=dict(div=lambda x: "settings_plugin_" + x, template=lambda x: x + "_settings.jinja2", to_entry=lambda data: (data["name"], data)),
usersettings=dict(div=lambda x: "usersettings_plugin_" + x, template=lambda x: x + "_usersettings.jinja2", to_entry=lambda data: (data["name"], data)),
wizard=dict(div=lambda x: "wizard_plugin_" + x, template=lambda x: x + "_wizard.jinja2", to_entry=lambda data: (data["name"], data)),
about=dict(div=lambda x: "about_plugin_" + x, template=lambda x: x + "_about.jinja2", to_entry=lambda data: (data["name"], data)),
generic=dict(template=lambda x: x + ".jinja2", to_entry=lambda data: data)
)
# sorting orders
template_sorting = dict(
navbar=dict(add="prepend", key=None),
sidebar=dict(add="append", key="name"),
tab=dict(add="append", key="name"),
settings=dict(add="custom_append", key="name", custom_add_entries=lambda missing: dict(section_plugins=(gettext("Plugins"), None)), custom_add_order=lambda missing: ["section_plugins"] + missing),
usersettings=dict(add="append", key="name"),
wizard=dict(add="append", key="name", key_extractor=lambda d, k: "0:{}".format(d[0]) if "mandatory" in d[1] and d[1]["mandatory"] else "1:{}".format(d[0])),
about=dict(add="append", key="name"),
generic=dict(add="append", key=None)
)
hooks = pluginManager.get_hooks("octoprint.ui.web.templatetypes")
for name, hook in hooks.items():
try:
result = hook(dict(template_sorting), dict(template_rules))
except:
_logger.exception("Error while retrieving custom template type definitions from plugin {name}".format(**locals()))
else:
if not isinstance(result, list):
continue
for entry in result:
if not isinstance(entry, tuple) or not len(entry) == 3:
continue
key, order, rule = entry
# order defaults
if "add" not in order:
order["add"] = "prepend"
if "key" not in order:
order["key"] = "name"
# rule defaults
if "div" not in rule:
# default div name: <hook plugin>_<template_key>_plugin_<plugin>
div = "{name}_{key}_plugin_".format(**locals())
rule["div"] = lambda x: div + x
if "template" not in rule:
# default template name: <plugin>_plugin_<hook plugin>_<template key>.jinja2
template = "_plugin_{name}_{key}.jinja2".format(**locals())
rule["template"] = lambda x: x + template
if "to_entry" not in rule:
# default to_entry assumes existing "name" property to be used as label for 2-tuple entry data structure (<name>, <properties>)
rule["to_entry"] = lambda data: (data["name"], data)
template_rules["plugin_" + name + "_" + key] = rule
template_sorting["plugin_" + name + "_" + key] = order
template_types = template_rules.keys()
# navbar
templates["navbar"]["entries"] = dict(
settings=dict(template="navbar/settings.jinja2", _div="navbar_settings", styles=["display: none"], data_bind="visible: loginState.isAdmin")
)
if enable_accesscontrol:
templates["navbar"]["entries"]["login"] = dict(template="navbar/login.jinja2", _div="navbar_login", classes=["dropdown"], custom_bindings=False)
if enable_systemmenu:
templates["navbar"]["entries"]["systemmenu"] = dict(template="navbar/systemmenu.jinja2", _div="navbar_systemmenu", styles=["display: none"], classes=["dropdown"], data_bind="visible: loginState.isAdmin", custom_bindings=False)
# sidebar
templates["sidebar"]["entries"]= dict(
connection=(gettext("Connection"), dict(template="sidebar/connection.jinja2", _div="connection", icon="signal", styles_wrapper=["display: none"], data_bind="visible: loginState.isUser")),
state=(gettext("State"), dict(template="sidebar/state.jinja2", _div="state", icon="info-sign")),
files=(gettext("Files"), dict(template="sidebar/files.jinja2", _div="files", icon="list", classes_content=["overflow_visible"], template_header="sidebar/files_header.jinja2"))
)
# tabs
templates["tab"]["entries"] = dict(
temperature=(gettext("Temperature"), dict(template="tabs/temperature.jinja2", _div="temp")),
control=(gettext("Control"), dict(template="tabs/control.jinja2", _div="control")),
terminal=(gettext("Terminal"), dict(template="tabs/terminal.jinja2", _div="term")),
)
if enable_gcodeviewer:
templates["tab"]["entries"]["gcodeviewer"] = (gettext("GCode Viewer"), dict(template="tabs/gcodeviewer.jinja2", _div="gcode"))
if enable_timelapse:
templates["tab"]["entries"]["timelapse"] = (gettext("Timelapse"), dict(template="tabs/timelapse.jinja2", _div="timelapse"))
# settings dialog
templates["settings"]["entries"] = dict(
section_printer=(gettext("Printer"), None),
serial=(gettext("Serial Connection"), dict(template="dialogs/settings/serialconnection.jinja2", _div="settings_serialConnection", custom_bindings=False)),
printerprofiles=(gettext("Printer Profiles"), dict(template="dialogs/settings/printerprofiles.jinja2", _div="settings_printerProfiles", custom_bindings=False)),
temperatures=(gettext("Temperatures"), dict(template="dialogs/settings/temperatures.jinja2", _div="settings_temperature", custom_bindings=False)),
terminalfilters=(gettext("Terminal Filters"), dict(template="dialogs/settings/terminalfilters.jinja2", _div="settings_terminalFilters", custom_bindings=False)),
gcodescripts=(gettext("GCODE Scripts"), dict(template="dialogs/settings/gcodescripts.jinja2", _div="settings_gcodeScripts", custom_bindings=False)),
section_features=(gettext("Features"), None),
features=(gettext("Features"), dict(template="dialogs/settings/features.jinja2", _div="settings_features", custom_bindings=False)),
webcam=(gettext("Webcam & Timelapse"), dict(template="dialogs/settings/webcam.jinja2", _div="settings_webcam", custom_bindings=False)),
gcodevisualizer=(gettext("GCODE Visualizer"), dict(template="dialogs/settings/gcodevisualizer.jinja2", _div="settings_gcodegcodevisualizer", custom_bindings=False)),
api=(gettext("API"), dict(template="dialogs/settings/api.jinja2", _div="settings_api", custom_bindings=False)),
section_octoprint=(gettext("OctoPrint"), None),
folders=(gettext("Folders"), dict(template="dialogs/settings/folders.jinja2", _div="settings_folders", custom_bindings=False)),
appearance=(gettext("Appearance"), dict(template="dialogs/settings/appearance.jinja2", _div="settings_appearance", custom_bindings=False)),
logs=(gettext("Logs"), dict(template="dialogs/settings/logs.jinja2", _div="settings_logs")),
server=(gettext("Server"), dict(template="dialogs/settings/server.jinja2", _div="settings_server", custom_bindings=False)),
)
if enable_accesscontrol:
templates["settings"]["entries"]["accesscontrol"] = (gettext("Access Control"), dict(template="dialogs/settings/accesscontrol.jinja2", _div="settings_users", custom_bindings=False))
# user settings dialog
if enable_accesscontrol:
templates["usersettings"]["entries"] = dict(
access=(gettext("Access"), dict(template="dialogs/usersettings/access.jinja2", _div="usersettings_access", custom_bindings=False)),
interface=(gettext("Interface"), dict(template="dialogs/usersettings/interface.jinja2", _div="usersettings_interface", custom_bindings=False)),
)
# wizard
if first_run:
def custom_insert_order(existing, missing):
if "firstrunstart" in missing:
missing.remove("firstrunstart")
if "firstrunend" in missing:
missing.remove("firstrunend")
return ["firstrunstart"] + existing + missing + ["firstrunend"]
template_sorting["wizard"].update(dict(add="custom_insert", custom_insert_entries=lambda missing: dict(), custom_insert_order=custom_insert_order))
templates["wizard"]["entries"] = dict(
firstrunstart=(gettext("Start"), dict(template="dialogs/wizard/firstrun_start.jinja2", _div="wizard_firstrun_start")),
firstrunend=(gettext("Finish"), dict(template="dialogs/wizard/firstrun_end.jinja2", _div="wizard_firstrun_end")),
)
# about dialog
templates["about"]["entries"] = dict(
about=("About OctoPrint", dict(template="dialogs/about/about.jinja2", _div="about_about", custom_bindings=False)),
license=("OctoPrint License", dict(template="dialogs/about/license.jinja2", _div="about_license", custom_bindings=False)),
thirdparty=("Third Party Licenses", dict(template="dialogs/about/thirdparty.jinja2", _div="about_thirdparty", custom_bindings=False)),
authors=("Authors", dict(template="dialogs/about/authors.jinja2", _div="about_authors", custom_bindings=False)),
changelog=("Changelog", dict(template="dialogs/about/changelog.jinja2", _div="about_changelog", custom_bindings=False)),
supporters=("Supporters", dict(template="dialogs/about/supporters.jinja2", _div="about_sponsors", custom_bindings=False))
)
# extract data from template plugins
template_plugins = pluginManager.get_implementations(octoprint.plugin.TemplatePlugin)
plugin_vars = dict()
plugin_names = set()
seen_wizards = settings().get(["server", "seenWizards"]) if not first_run else dict()
for implementation in template_plugins:
name = implementation._identifier
plugin_names.add(name)
wizard_required = False
wizard_ignored = False
try:
vars = implementation.get_template_vars()
configs = implementation.get_template_configs()
if isinstance(implementation, octoprint.plugin.WizardPlugin):
wizard_required = implementation.is_wizard_required()
wizard_ignored = octoprint.plugin.WizardPlugin.is_wizard_ignored(seen_wizards, implementation)
except:
_logger.exception("Error while retrieving template data for plugin {}, ignoring it".format(name))
continue
if not isinstance(vars, dict):
vars = dict()
if not isinstance(configs, (list, tuple)):
configs = []
for var_name, var_value in vars.items():
plugin_vars["plugin_" + name + "_" + var_name] = var_value
includes = _process_template_configs(name, implementation, configs, template_rules)
if not wizard_required or wizard_ignored:
includes["wizard"] = list()
for t in template_types:
for include in includes[t]:
if t == "navbar" or t == "generic":
data = include
else:
data = include[1]
key = data["_key"]
if "replaces" in data:
key = data["replaces"]
templates[t]["entries"][key] = include
#~~ order internal templates and plugins
# make sure that
# 1) we only have keys in our ordered list that we have entries for and
# 2) we have all entries located somewhere within the order
for t in template_types:
default_order = settings().get(["appearance", "components", "order", t], merged=True, config=dict()) or []
configured_order = settings().get(["appearance", "components", "order", t], merged=True) or []
configured_disabled = settings().get(["appearance", "components", "disabled", t]) or []
# first create the ordered list of all component ids according to the configured order
templates[t]["order"] = [x for x in configured_order if x in templates[t]["entries"] and not x in configured_disabled]
# now append the entries from the default order that are not already in there
templates[t]["order"] += [x for x in default_order if not x in templates[t]["order"] and x in templates[t]["entries"] and not x in configured_disabled]
all_ordered = set(templates[t]["order"])
all_disabled = set(configured_disabled)
# check if anything is missing, if not we are done here
missing_in_order = set(templates[t]["entries"].keys()).difference(all_ordered).difference(all_disabled)
if len(missing_in_order) == 0:
continue
# works with entries that are dicts and entries that are 2-tuples with the
# entry data at index 1
def config_extractor(item, key, default_value=None):
if isinstance(item, dict) and key in item:
return item[key] if key in item else default_value
elif isinstance(item, tuple) and len(item) > 1 and isinstance(item[1], dict) and key in item[1]:
return item[1][key] if key in item[1] else default_value
return default_value
# finally add anything that's not included in our order yet
if template_sorting[t]["key"] is not None:
# we'll use our config extractor as default key extractor
extractor = config_extractor
# if template type provides custom extractor, make sure its exceptions are handled
if "key_extractor" in template_sorting[t] and callable(template_sorting[t]["key_extractor"]):
def create_safe_extractor(extractor):
def f(x, k):
try:
return extractor(x, k)
except:
_logger.exception("Error while extracting sorting keys for template {}".format(t))
return None
return f
extractor = create_safe_extractor(template_sorting[t]["key_extractor"])
sort_key = template_sorting[t]["key"]
def key_func(x):
config = templates[t]["entries"][x]
entry_order = config_extractor(config, "order", default_value=None)
return entry_order is None, entry_order, extractor(config, sort_key)
sorted_missing = sorted(missing_in_order, key=key_func)
else:
def key_func(x):
config = templates[t]["entries"][x]
entry_order = config_extractor(config, "order", default_value=None)
return entry_order is None, entry_order
sorted_missing = sorted(missing_in_order, key=key_func)
if template_sorting[t]["add"] == "prepend":
templates[t]["order"] = sorted_missing + templates[t]["order"]
elif template_sorting[t]["add"] == "append":
templates[t]["order"] += sorted_missing
elif template_sorting[t]["add"] == "custom_prepend" and "custom_add_entries" in template_sorting[t] and "custom_add_order" in template_sorting[t]:
templates[t]["entries"].update(template_sorting[t]["custom_add_entries"](sorted_missing))
templates[t]["order"] = template_sorting[t]["custom_add_order"](sorted_missing) + templates[t]["order"]
elif template_sorting[t]["add"] == "custom_append" and "custom_add_entries" in template_sorting[t] and "custom_add_order" in template_sorting[t]:
templates[t]["entries"].update(template_sorting[t]["custom_add_entries"](sorted_missing))
templates[t]["order"] += template_sorting[t]["custom_add_order"](sorted_missing)
elif template_sorting[t]["add"] == "custom_insert" and "custom_insert_entries" in template_sorting[t] and "custom_insert_order" in template_sorting[t]:
templates[t]["entries"].update(template_sorting[t]["custom_insert_entries"](sorted_missing))
templates[t]["order"] = template_sorting[t]["custom_insert_order"](templates[t]["order"], sorted_missing)
return templates, plugin_names, plugin_vars
def _process_template_configs(name, implementation, configs, rules):
from jinja2.exceptions import TemplateNotFound
counters = defaultdict(lambda: 1)
includes = defaultdict(list)
for config in configs:
if not isinstance(config, dict):
continue
if not "type" in config:
continue
template_type = config["type"]
del config["type"]
if not template_type in rules:
continue
rule = rules[template_type]
data = _process_template_config(name, implementation, rule, config=config, counter=counters[template_type])
if data is None:
continue
includes[template_type].append(rule["to_entry"](data))
counters[template_type] += 1
for template_type in rules:
if len(includes[template_type]) == 0:
# if no template of that type was added by the config, we'll try to use the default template name
rule = rules[template_type]
data = _process_template_config(name, implementation, rule)
if data is not None:
try:
app.jinja_env.get_or_select_template(data["template"])
except TemplateNotFound:
pass
except:
_logger.exception("Error in template {}, not going to include it".format(data["template"]))
else:
includes[template_type].append(rule["to_entry"](data))
return includes
def _process_template_config(name, implementation, rule, config=None, counter=1):
if "mandatory" in rule:
for mandatory in rule["mandatory"]:
if not mandatory in config:
return None
if config is None:
config = dict()
data = dict(config)
if not "suffix" in data and counter > 1:
data["suffix"] = "_%d" % counter
if "div" in data:
data["_div"] = data["div"]
elif "div" in rule:
data["_div"] = rule["div"](name)
if "suffix" in data:
data["_div"] = data["_div"] + data["suffix"]
if not _valid_div_re.match(data["_div"]):
_logger.warn("Template config {} contains invalid div identifier {}, skipping it".format(name, data["_div"]))
return None
if not "template" in data:
data["template"] = rule["template"](name)
if not "name" in data:
data["name"] = implementation._plugin_name
if not "custom_bindings" in data or data["custom_bindings"]:
data_bind = "allowBindings: true"
if "data_bind" in data:
data_bind = data_bind + ", " + data["data_bind"]
data_bind = data_bind.replace("\"", "\\\"")
data["data_bind"] = data_bind
data["_key"] = "plugin_" + name
if "suffix" in data:
data["_key"] += data["suffix"]
return data
@app.route("/robots.txt")
@util.flask.cached(timeout=-1)
def robotsTxt():
return send_from_directory(app.static_folder, "robots.txt")
@app.route("/i18n/<string:locale>/<string:domain>.js")
@util.flask.conditional(lambda: _check_etag_and_lastmodified_for_i18n(), NOT_MODIFIED)
@util.flask.etagged(lambda _: _compute_etag_for_i18n(request.view_args["locale"], request.view_args["domain"]))
@util.flask.lastmodified(lambda _: _compute_date_for_i18n(request.view_args["locale"], request.view_args["domain"]))
def localeJs(locale, domain):
messages = dict()
plural_expr = None
if locale != "en":
messages, plural_expr = _get_translations(locale, domain)
catalog = dict(
messages=messages,
plural_expr=plural_expr,
locale=locale,
domain=domain
)
from flask import Response
return Response(render_template("i18n.js.jinja2", catalog=catalog), content_type="application/x-javascript; charset=utf-8")
@app.route("/plugin_assets/<string:name>/<path:filename>")
def plugin_assets(name, filename):
return redirect(url_for("plugin." + name + ".static", filename=filename))
def _compute_etag_for_i18n(locale, domain, files=None, lastmodified=None):
if files is None:
files = _get_all_translationfiles(locale, domain)
if lastmodified is None:
lastmodified = _compute_date(files)
if lastmodified and not isinstance(lastmodified, basestring):
from werkzeug.http import http_date
lastmodified = http_date(lastmodified)
import hashlib
hash = hashlib.sha1()
hash.update(",".join(sorted(files)))
if lastmodified:
hash.update(lastmodified)
return hash.hexdigest()
def _compute_date_for_i18n(locale, domain):
return _compute_date(_get_all_translationfiles(locale, domain))
def _compute_date(files):
from datetime import datetime
timestamps = map(lambda path: os.stat(path).st_mtime, files) + [0] if files else []
max_timestamp = max(*timestamps) if timestamps else None
if max_timestamp:
# we set the micros to 0 since microseconds are not speced for HTTP
max_timestamp = datetime.fromtimestamp(max_timestamp).replace(microsecond=0)
return max_timestamp
def _check_etag_and_lastmodified_for_i18n():
locale = request.view_args["locale"]
domain = request.view_args["domain"]
etag_ok = util.flask.check_etag(_compute_etag_for_i18n(request.view_args["locale"], request.view_args["domain"]))
lastmodified = _compute_date_for_i18n(locale, domain)
lastmodified_ok = lastmodified is None or util.flask.check_lastmodified(lastmodified)
return etag_ok and lastmodified_ok
def _get_all_templates():
from octoprint.util.jinja import get_all_template_paths
return get_all_template_paths(app.jinja_loader)
def _get_all_assets():
from octoprint.util.jinja import get_all_asset_paths
return get_all_asset_paths(app.jinja_env.assets_environment)
def _get_all_translationfiles(locale, domain):
from flask import _request_ctx_stack
def get_po_path(basedir, locale, domain):
path = os.path.join(basedir, locale)
if not os.path.isdir(path):
return None
path = os.path.join(path, "LC_MESSAGES", "{domain}.po".format(**locals()))
if not os.path.isfile(path):
return None
return path
po_files = []
user_base_path = os.path.join(settings().getBaseFolder("translations"))
user_plugin_path = os.path.join(user_base_path, "_plugins")
# plugin translations
plugins = octoprint.plugin.plugin_manager().enabled_plugins
for name, plugin in plugins.items():
dirs = [os.path.join(user_plugin_path, name), os.path.join(plugin.location, 'translations')]
for dirname in dirs:
if not os.path.isdir(dirname):
continue
po_file = get_po_path(dirname, locale, domain)
if po_file:
po_files.append(po_file)
break
# core translations
ctx = _request_ctx_stack.top
base_path = os.path.join(ctx.app.root_path, "translations")
dirs = [user_base_path, base_path]
for dirname in dirs:
po_file = get_po_path(dirname, locale, domain)
if po_file:
po_files.append(po_file)
break
return po_files
def _get_translations(locale, domain):
from babel.messages.pofile import read_po
from octoprint.util import dict_merge
messages = dict()
plural_expr = None
def messages_from_po(path, locale, domain):
messages = dict()
with file(path) as f:
catalog = read_po(f, locale=locale, domain=domain)
for message in catalog:
message_id = message.id
if isinstance(message_id, (list, tuple)):
message_id = message_id[0]
messages[message_id] = message.string
return messages, catalog.plural_expr
po_files = _get_all_translationfiles(locale, domain)
for po_file in po_files:
po_messages, plural_expr = messages_from_po(po_file, locale, domain)
if po_messages is not None:
messages = dict_merge(messages, po_messages)
return messages, plural_expr
|
agpl-3.0
|
[
3,
2803,
29,
1624,
13,
24,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
199,
363,
2502,
363,
275,
298,
39,
13765,
869,
13733,
85,
128,
254,
303,
665,
736,
68,
32,
1421,
5891,
14,
846,
4335,
199,
363,
1682,
363,
275,
283,
17732,
4265,
1696,
1684,
844,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
643,
1168,
14,
1360,
7,
199,
363,
7307,
363,
275,
298,
7384,
334,
35,
9,
6900,
710,
18365,
79,
5375,
7290,
446,
17646,
68,
1334,
2895,
402,
314,
437,
28863,
19,
844,
2,
199,
199,
646,
747,
199,
646,
2197,
199,
199,
504,
5055,
492,
10018,
199,
504,
7209,
492,
1056,
12,
486,
12,
1166,
63,
509,
12,
1852,
63,
1310,
12,
3795,
63,
1160,
12,
3222,
63,
504,
63,
3619,
12,
4660,
12,
12004,
199,
199,
646,
17162,
411,
672,
14,
2718,
199,
199,
504,
17162,
411,
672,
14,
1000,
492,
1145,
12,
922,
2988,
12,
3589,
2988,
12,
9796,
12,
971,
199,
198,
1757,
12,
20639,
654,
12,
15945,
12,
7587,
11625,
63,
4612,
12,
14041,
63,
3735,
63,
3078,
12,
11713,
20139,
12,
299,
850,
311,
857,
4437,
12,
971,
199,
198,
4609,
63,
30389,
199,
504,
17162,
411,
672,
14,
1751,
492,
2202,
199,
504,
17162,
411,
672,
14,
493,
2609,
492,
664,
63,
452,
63,
5359,
199,
199,
646,
295,
199,
646,
1300,
772,
199,
199,
504,
1275,
492,
4884,
199,
199,
646,
2050,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
63,
5876,
275,
488,
199,
63,
2718,
63,
1247,
275,
488,
199,
63,
2718,
63,
2936,
275,
488,
199,
199,
63,
1078,
63,
344,
63,
264,
275,
295,
14,
2014,
10994,
65,
13,
90,
22155,
531,
199,
63,
1078,
63,
3015,
63,
264,
275,
295,
14,
2014,
10994,
65,
13,
6353,
13,
58,
63,
20253,
531,
199,
199,
318,
485,
657,
2109,
857,
63,
18447,
8,
1095,
63,
633,
29,
403,
12,
4722,
63,
18447,
29,
403,
304,
199,
198,
692,
1300,
63,
633,
365,
488,
26,
507,
198,
1095,
63,
633,
275,
1056,
14,
633,
63,
1231,
421,
198,
7011,
63,
509,
63,
1231,
275,
440,
2202,
1252,
362,
4082,
5234,
27870,
401,
298,
1637,
401,
298,
657,
2109,
857,
3135,
971,
507,
8540,
503,
1300,
63,
633,
315,
2202,
1252,
362,
5234,
1000,
401,
298,
657,
2109,
857,
4437,
401,
298,
3924,
3135,
971,
507,
8540,
503,
440,
334,
1095,
63,
633,
14,
2460,
480,
1014,
921,
531,
503,
1300,
63,
633,
14,
2460,
480,
2859,
921,
2237,
421,
198,
24616,
63,
7011,
275,
1056,
14,
2139,
14,
362,
480,
56,
13,
48,
850,
311,
857,
13,
5433,
401,
298,
5066,
531,
508,
298,
889,
2,
421,
198,
692,
4550,
8,
8460,
63,
18447,
304,
507,
198,
1107,
20952,
63,
7011,
503,
6980,
63,
509,
63,
1231,
503,
4722,
63,
18447,
342,
199,
198,
2836,
26,
507,
198,
1107,
20952,
63,
7011,
503,
6980,
63,
509,
63,
1231,
199,
199,
318,
485,
657,
2109,
857,
63,
576,
8,
498,
12,
931,
29,
403,
12,
1300,
63,
633,
29,
403,
12,
666,
29,
403,
12,
4722,
63,
1069,
63,
576,
29,
403,
304,
199,
198,
692,
931,
365,
488,
26,
507,
198,
515,
275,
1056,
14,
515,
199,
198,
692,
1300,
63,
633,
365,
488,
26,
507,
198,
1095,
63,
633,
275,
1056,
14,
633,
63,
1231,
421,
198,
68,
275,
1211,
8,
515,
29,
515,
12,
507,
260,
1300,
63,
633,
29,
1095,
63,
633,
12,
507,
260,
1827,
63,
875,
628,
76,
709,
78,
7622,
1674,
908,
8,
71,
14,
5508,
14,
3671,
340,
486,
14,
5508,
587,
298,
287,
2237,
421,
198,
692,
790,
1137,
2668,
885,
582,
507,
198,
68,
905,
2718,
937,
275,
790,
421,
198,
3,
1050,
666,
340,
781,
1172,
1263,
199,
198,
692,
666,
365,
440,
488,
26,
507,
198,
893,
26,
686,
198,
692,
4550,
8,
576,
304,
1585,
198,
576,
275,
666,
342,
686,
198,
692,
666,
26,
1585,
198,
692,
298,
1131,
63,
875,
2,
315,
666,
26,
1871,
198,
576,
905,
1131,
63,
875,
937,
275,
298,
76,
709,
78,
7622,
6,
13536,
908,
8,
71,
14,
5508,
14,
3671,
12,
666,
905,
1131,
63,
875,
3135,
1585,
198,
68,
14,
873,
8,
576,
9,
507,
198,
2590,
26,
686,
198,
63,
2921,
14,
1971,
480,
547,
32223,
666,
367,
299,
850,
311,
857,
2581,
687,
3589,
8352,
908,
8,
498,
430,
421,
198,
3,
1050,
4722,
1056,
666,
340,
781,
1172,
1263,
199,
198,
692,
4550,
8,
8460,
63,
1069,
63,
576,
304,
507,
198,
893,
26,
686,
198,
1005,
275,
4722,
63,
1069,
63,
576,
342,
686,
198,
692,
601,
68,
26,
1585,
198,
68,
14,
873,
8,
807,
8,
1871,
198,
63,
8460,
63,
1069,
63,
576,
29,
1005,
1585,
198,
430,
507,
198,
2590,
26,
686,
198,
63,
2921,
14,
1971,
480,
547,
23812,
4722,
666,
367,
299,
850,
311,
857,
2581,
687,
3589,
8352,
908,
8,
498,
430,
421,
198,
1107,
366,
199,
199,
318,
485,
1637,
63,
498,
8,
1907,
12,
1166,
29,
403,
12,
5867,
29,
403,
12,
4722,
63,
498,
63,
576,
29,
403,
304,
199,
198,
692,
1166,
365,
488,
26,
507,
198,
633,
275,
1056,
14,
1095,
63,
633,
199,
198,
692,
5867,
365,
488,
26,
507,
198,
5508,
275,
486,
14,
5508,
14,
3671,
340,
486,
14,
5508,
587,
298,
287,
2,
421,
198,
75,
275,
298,
1907,
29930,
29930,
26,
13536,
908,
8,
1907,
12,
1166,
12,
5867,
9,
199,
198,
692,
4550,
8,
8460,
63,
498,
63,
576,
304,
507,
198,
893,
26,
686,
198,
1151,
275,
4722,
63,
498,
63,
576,
342,
686,
198,
692,
282,
75,
26,
1585,
198,
3,
781,
1172,
2005,
4722,
790,
7323,
12,
4691,
1159,
6554,
3062,
1585,
198,
692,
440,
1228,
8,
1151,
12,
334,
513,
12,
2008,
2298,
1871,
198,
1151,
275,
359,
1151,
61,
1585,
198,
75,
275,
11491,
26,
13536,
908,
8,
75,
12,
7244,
1674,
904,
8,
1151,
430,
507,
198,
2590,
26,
686,
198,
63,
2921,
14,
1971,
480,
547,
1830,
9936,
370,
8044,
4722,
2581,
790,
4184,
367
] |
[
2803,
29,
1624,
13,
24,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
199,
363,
2502,
363,
275,
298,
39,
13765,
869,
13733,
85,
128,
254,
303,
665,
736,
68,
32,
1421,
5891,
14,
846,
4335,
199,
363,
1682,
363,
275,
283,
17732,
4265,
1696,
1684,
844,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
643,
1168,
14,
1360,
7,
199,
363,
7307,
363,
275,
298,
7384,
334,
35,
9,
6900,
710,
18365,
79,
5375,
7290,
446,
17646,
68,
1334,
2895,
402,
314,
437,
28863,
19,
844,
2,
199,
199,
646,
747,
199,
646,
2197,
199,
199,
504,
5055,
492,
10018,
199,
504,
7209,
492,
1056,
12,
486,
12,
1166,
63,
509,
12,
1852,
63,
1310,
12,
3795,
63,
1160,
12,
3222,
63,
504,
63,
3619,
12,
4660,
12,
12004,
199,
199,
646,
17162,
411,
672,
14,
2718,
199,
199,
504,
17162,
411,
672,
14,
1000,
492,
1145,
12,
922,
2988,
12,
3589,
2988,
12,
9796,
12,
971,
199,
198,
1757,
12,
20639,
654,
12,
15945,
12,
7587,
11625,
63,
4612,
12,
14041,
63,
3735,
63,
3078,
12,
11713,
20139,
12,
299,
850,
311,
857,
4437,
12,
971,
199,
198,
4609,
63,
30389,
199,
504,
17162,
411,
672,
14,
1751,
492,
2202,
199,
504,
17162,
411,
672,
14,
493,
2609,
492,
664,
63,
452,
63,
5359,
199,
199,
646,
295,
199,
646,
1300,
772,
199,
199,
504,
1275,
492,
4884,
199,
199,
646,
2050,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
63,
5876,
275,
488,
199,
63,
2718,
63,
1247,
275,
488,
199,
63,
2718,
63,
2936,
275,
488,
199,
199,
63,
1078,
63,
344,
63,
264,
275,
295,
14,
2014,
10994,
65,
13,
90,
22155,
531,
199,
63,
1078,
63,
3015,
63,
264,
275,
295,
14,
2014,
10994,
65,
13,
6353,
13,
58,
63,
20253,
531,
199,
199,
318,
485,
657,
2109,
857,
63,
18447,
8,
1095,
63,
633,
29,
403,
12,
4722,
63,
18447,
29,
403,
304,
199,
198,
692,
1300,
63,
633,
365,
488,
26,
507,
198,
1095,
63,
633,
275,
1056,
14,
633,
63,
1231,
421,
198,
7011,
63,
509,
63,
1231,
275,
440,
2202,
1252,
362,
4082,
5234,
27870,
401,
298,
1637,
401,
298,
657,
2109,
857,
3135,
971,
507,
8540,
503,
1300,
63,
633,
315,
2202,
1252,
362,
5234,
1000,
401,
298,
657,
2109,
857,
4437,
401,
298,
3924,
3135,
971,
507,
8540,
503,
440,
334,
1095,
63,
633,
14,
2460,
480,
1014,
921,
531,
503,
1300,
63,
633,
14,
2460,
480,
2859,
921,
2237,
421,
198,
24616,
63,
7011,
275,
1056,
14,
2139,
14,
362,
480,
56,
13,
48,
850,
311,
857,
13,
5433,
401,
298,
5066,
531,
508,
298,
889,
2,
421,
198,
692,
4550,
8,
8460,
63,
18447,
304,
507,
198,
1107,
20952,
63,
7011,
503,
6980,
63,
509,
63,
1231,
503,
4722,
63,
18447,
342,
199,
198,
2836,
26,
507,
198,
1107,
20952,
63,
7011,
503,
6980,
63,
509,
63,
1231,
199,
199,
318,
485,
657,
2109,
857,
63,
576,
8,
498,
12,
931,
29,
403,
12,
1300,
63,
633,
29,
403,
12,
666,
29,
403,
12,
4722,
63,
1069,
63,
576,
29,
403,
304,
199,
198,
692,
931,
365,
488,
26,
507,
198,
515,
275,
1056,
14,
515,
199,
198,
692,
1300,
63,
633,
365,
488,
26,
507,
198,
1095,
63,
633,
275,
1056,
14,
633,
63,
1231,
421,
198,
68,
275,
1211,
8,
515,
29,
515,
12,
507,
260,
1300,
63,
633,
29,
1095,
63,
633,
12,
507,
260,
1827,
63,
875,
628,
76,
709,
78,
7622,
1674,
908,
8,
71,
14,
5508,
14,
3671,
340,
486,
14,
5508,
587,
298,
287,
2237,
421,
198,
692,
790,
1137,
2668,
885,
582,
507,
198,
68,
905,
2718,
937,
275,
790,
421,
198,
3,
1050,
666,
340,
781,
1172,
1263,
199,
198,
692,
666,
365,
440,
488,
26,
507,
198,
893,
26,
686,
198,
692,
4550,
8,
576,
304,
1585,
198,
576,
275,
666,
342,
686,
198,
692,
666,
26,
1585,
198,
692,
298,
1131,
63,
875,
2,
315,
666,
26,
1871,
198,
576,
905,
1131,
63,
875,
937,
275,
298,
76,
709,
78,
7622,
6,
13536,
908,
8,
71,
14,
5508,
14,
3671,
12,
666,
905,
1131,
63,
875,
3135,
1585,
198,
68,
14,
873,
8,
576,
9,
507,
198,
2590,
26,
686,
198,
63,
2921,
14,
1971,
480,
547,
32223,
666,
367,
299,
850,
311,
857,
2581,
687,
3589,
8352,
908,
8,
498,
430,
421,
198,
3,
1050,
4722,
1056,
666,
340,
781,
1172,
1263,
199,
198,
692,
4550,
8,
8460,
63,
1069,
63,
576,
304,
507,
198,
893,
26,
686,
198,
1005,
275,
4722,
63,
1069,
63,
576,
342,
686,
198,
692,
601,
68,
26,
1585,
198,
68,
14,
873,
8,
807,
8,
1871,
198,
63,
8460,
63,
1069,
63,
576,
29,
1005,
1585,
198,
430,
507,
198,
2590,
26,
686,
198,
63,
2921,
14,
1971,
480,
547,
23812,
4722,
666,
367,
299,
850,
311,
857,
2581,
687,
3589,
8352,
908,
8,
498,
430,
421,
198,
1107,
366,
199,
199,
318,
485,
1637,
63,
498,
8,
1907,
12,
1166,
29,
403,
12,
5867,
29,
403,
12,
4722,
63,
498,
63,
576,
29,
403,
304,
199,
198,
692,
1166,
365,
488,
26,
507,
198,
633,
275,
1056,
14,
1095,
63,
633,
199,
198,
692,
5867,
365,
488,
26,
507,
198,
5508,
275,
486,
14,
5508,
14,
3671,
340,
486,
14,
5508,
587,
298,
287,
2,
421,
198,
75,
275,
298,
1907,
29930,
29930,
26,
13536,
908,
8,
1907,
12,
1166,
12,
5867,
9,
199,
198,
692,
4550,
8,
8460,
63,
498,
63,
576,
304,
507,
198,
893,
26,
686,
198,
1151,
275,
4722,
63,
498,
63,
576,
342,
686,
198,
692,
282,
75,
26,
1585,
198,
3,
781,
1172,
2005,
4722,
790,
7323,
12,
4691,
1159,
6554,
3062,
1585,
198,
692,
440,
1228,
8,
1151,
12,
334,
513,
12,
2008,
2298,
1871,
198,
1151,
275,
359,
1151,
61,
1585,
198,
75,
275,
11491,
26,
13536,
908,
8,
75,
12,
7244,
1674,
904,
8,
1151,
430,
507,
198,
2590,
26,
686,
198,
63,
2921,
14,
1971,
480,
547,
1830,
9936,
370,
8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
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
comandrei/django-haystack
|
haystack/fields.py
|
12
|
13235
|
# encoding: utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
import re
from django.template import Context, loader
from django.utils import datetime_safe, six
from haystack.exceptions import SearchFieldError
from haystack.utils import get_model_ct_tuple
class NOT_PROVIDED:
pass
DATETIME_REGEX = re.compile('^(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})(T|\s+)(?P<hour>\d{2}):(?P<minute>\d{2}):(?P<second>\d{2}).*?$')
# All the SearchFields variants.
class SearchField(object):
"""The base implementation of a search field."""
field_type = None
def __init__(self, model_attr=None, use_template=False, template_name=None,
document=False, indexed=True, stored=True, faceted=False,
default=NOT_PROVIDED, null=False, index_fieldname=None,
facet_class=None, boost=1.0, weight=None):
# Track what the index thinks this field is called.
self.instance_name = None
self.model_attr = model_attr
self.use_template = use_template
self.template_name = template_name
self.document = document
self.indexed = indexed
self.stored = stored
self.faceted = faceted
self._default = default
self.null = null
self.index_fieldname = index_fieldname
self.boost = weight or boost
self.is_multivalued = False
# We supply the facet_class for making it easy to create a faceted
# field based off of this field.
self.facet_class = facet_class
if self.facet_class is None:
self.facet_class = FacetCharField
self.set_instance_name(None)
def set_instance_name(self, instance_name):
self.instance_name = instance_name
if self.index_fieldname is None:
self.index_fieldname = self.instance_name
def has_default(self):
"""Returns a boolean of whether this field has a default value."""
return self._default is not NOT_PROVIDED
@property
def default(self):
"""Returns the default value for the field."""
if callable(self._default):
return self._default()
return self._default
def prepare(self, obj):
"""
Takes data from the provided object and prepares it for storage in the
index.
"""
# Give priority to a template.
if self.use_template:
return self.prepare_template(obj)
elif self.model_attr is not None:
# Check for `__` in the field for looking through the relation.
attrs = self.model_attr.split('__')
current_object = obj
for attr in attrs:
if not hasattr(current_object, attr):
raise SearchFieldError("The model '%s' does not have a model_attr '%s'." % (repr(current_object), attr))
current_object = getattr(current_object, attr, None)
if current_object is None:
if self.has_default():
current_object = self._default
# Fall out of the loop, given any further attempts at
# accesses will fail miserably.
break
elif self.null:
current_object = None
# Fall out of the loop, given any further attempts at
# accesses will fail miserably.
break
else:
raise SearchFieldError("The model '%s' combined with model_attr '%s' returned None, but doesn't allow a default or null value." % (repr(obj), self.model_attr))
if callable(current_object):
return current_object()
return current_object
if self.has_default():
return self.default
else:
return None
def prepare_template(self, obj):
"""
Flattens an object for indexing.
This loads a template
(``search/indexes/{app_label}/{model_name}_{field_name}.txt``) and
returns the result of rendering that template. ``object`` will be in
its context.
"""
if self.instance_name is None and self.template_name is None:
raise SearchFieldError("This field requires either its instance_name variable to be populated or an explicit template_name in order to load the correct template.")
if self.template_name is not None:
template_names = self.template_name
if not isinstance(template_names, (list, tuple)):
template_names = [template_names]
else:
app_label, model_name = get_model_ct_tuple(obj)
template_names = ['search/indexes/%s/%s_%s.txt' % (app_label, model_name, self.instance_name)]
t = loader.select_template(template_names)
return t.render(Context({'object': obj}))
def convert(self, value):
"""
Handles conversion between the data found and the type of the field.
Extending classes should override this method and provide correct
data coercion.
"""
return value
class CharField(SearchField):
field_type = 'string'
def __init__(self, **kwargs):
if kwargs.get('facet_class') is None:
kwargs['facet_class'] = FacetCharField
super(CharField, self).__init__(**kwargs)
def prepare(self, obj):
return self.convert(super(CharField, self).prepare(obj))
def convert(self, value):
if value is None:
return None
return six.text_type(value)
class LocationField(SearchField):
field_type = 'location'
def prepare(self, obj):
from haystack.utils.geo import ensure_point
value = super(LocationField, self).prepare(obj)
if value is None:
return None
pnt = ensure_point(value)
pnt_lng, pnt_lat = pnt.get_coords()
return "%s,%s" % (pnt_lat, pnt_lng)
def convert(self, value):
from haystack.utils.geo import ensure_point, Point
if value is None:
return None
if hasattr(value, 'geom_type'):
value = ensure_point(value)
return value
if isinstance(value, six.string_types):
lat, lng = value.split(',')
elif isinstance(value, (list, tuple)):
# GeoJSON-alike
lat, lng = value[1], value[0]
elif isinstance(value, dict):
lat = value.get('lat', 0)
lng = value.get('lon', 0)
value = Point(float(lng), float(lat))
return value
class NgramField(CharField):
field_type = 'ngram'
def __init__(self, **kwargs):
if kwargs.get('faceted') is True:
raise SearchFieldError("%s can not be faceted." % self.__class__.__name__)
super(NgramField, self).__init__(**kwargs)
class EdgeNgramField(NgramField):
field_type = 'edge_ngram'
class IntegerField(SearchField):
field_type = 'integer'
def __init__(self, **kwargs):
if kwargs.get('facet_class') is None:
kwargs['facet_class'] = FacetIntegerField
super(IntegerField, self).__init__(**kwargs)
def prepare(self, obj):
return self.convert(super(IntegerField, self).prepare(obj))
def convert(self, value):
if value is None:
return None
return int(value)
class FloatField(SearchField):
field_type = 'float'
def __init__(self, **kwargs):
if kwargs.get('facet_class') is None:
kwargs['facet_class'] = FacetFloatField
super(FloatField, self).__init__(**kwargs)
def prepare(self, obj):
return self.convert(super(FloatField, self).prepare(obj))
def convert(self, value):
if value is None:
return None
return float(value)
class DecimalField(SearchField):
field_type = 'string'
def __init__(self, **kwargs):
if kwargs.get('facet_class') is None:
kwargs['facet_class'] = FacetDecimalField
super(DecimalField, self).__init__(**kwargs)
def prepare(self, obj):
return self.convert(super(DecimalField, self).prepare(obj))
def convert(self, value):
if value is None:
return None
return six.text_type(value)
class BooleanField(SearchField):
field_type = 'boolean'
def __init__(self, **kwargs):
if kwargs.get('facet_class') is None:
kwargs['facet_class'] = FacetBooleanField
super(BooleanField, self).__init__(**kwargs)
def prepare(self, obj):
return self.convert(super(BooleanField, self).prepare(obj))
def convert(self, value):
if value is None:
return None
return bool(value)
class DateField(SearchField):
field_type = 'date'
def __init__(self, **kwargs):
if kwargs.get('facet_class') is None:
kwargs['facet_class'] = FacetDateField
super(DateField, self).__init__(**kwargs)
def convert(self, value):
if value is None:
return None
if isinstance(value, six.string_types):
match = DATETIME_REGEX.search(value)
if match:
data = match.groupdict()
return datetime_safe.date(int(data['year']), int(data['month']), int(data['day']))
else:
raise SearchFieldError("Date provided to '%s' field doesn't appear to be a valid date string: '%s'" % (self.instance_name, value))
return value
class DateTimeField(SearchField):
field_type = 'datetime'
def __init__(self, **kwargs):
if kwargs.get('facet_class') is None:
kwargs['facet_class'] = FacetDateTimeField
super(DateTimeField, self).__init__(**kwargs)
def convert(self, value):
if value is None:
return None
if isinstance(value, six.string_types):
match = DATETIME_REGEX.search(value)
if match:
data = match.groupdict()
return datetime_safe.datetime(int(data['year']), int(data['month']), int(data['day']), int(data['hour']), int(data['minute']), int(data['second']))
else:
raise SearchFieldError("Datetime provided to '%s' field doesn't appear to be a valid datetime string: '%s'" % (self.instance_name, value))
return value
class MultiValueField(SearchField):
field_type = 'string'
def __init__(self, **kwargs):
if kwargs.get('facet_class') is None:
kwargs['facet_class'] = FacetMultiValueField
if kwargs.get('use_template') is True:
raise SearchFieldError("'%s' fields can not use templates to prepare their data." % self.__class__.__name__)
super(MultiValueField, self).__init__(**kwargs)
self.is_multivalued = True
def prepare(self, obj):
return self.convert(super(MultiValueField, self).prepare(obj))
def convert(self, value):
if value is None:
return None
return list(value)
class FacetField(SearchField):
"""
``FacetField`` is slightly different than the other fields because it can
work in conjunction with other fields as its data source.
Accepts an optional ``facet_for`` kwarg, which should be the field name
(not ``index_fieldname``) of the field it should pull data from.
"""
instance_name = None
def __init__(self, **kwargs):
handled_kwargs = self.handle_facet_parameters(kwargs)
super(FacetField, self).__init__(**handled_kwargs)
def handle_facet_parameters(self, kwargs):
if kwargs.get('faceted', False):
raise SearchFieldError("FacetField (%s) does not accept the 'faceted' argument." % self.instance_name)
if not kwargs.get('null', True):
raise SearchFieldError("FacetField (%s) does not accept False for the 'null' argument." % self.instance_name)
if not kwargs.get('indexed', True):
raise SearchFieldError("FacetField (%s) does not accept False for the 'indexed' argument." % self.instance_name)
if kwargs.get('facet_class'):
raise SearchFieldError("FacetField (%s) does not accept the 'facet_class' argument." % self.instance_name)
self.facet_for = None
self.facet_class = None
# Make sure the field is nullable.
kwargs['null'] = True
if 'facet_for' in kwargs:
self.facet_for = kwargs['facet_for']
del(kwargs['facet_for'])
return kwargs
def get_facet_for_name(self):
return self.facet_for or self.instance_name
class FacetCharField(FacetField, CharField):
pass
class FacetIntegerField(FacetField, IntegerField):
pass
class FacetFloatField(FacetField, FloatField):
pass
class FacetDecimalField(FacetField, DecimalField):
pass
class FacetBooleanField(FacetField, BooleanField):
pass
class FacetDateField(FacetField, DateField):
pass
class FacetDateTimeField(FacetField, DateTimeField):
pass
class FacetMultiValueField(FacetField, MultiValueField):
pass
|
bsd-3-clause
|
[
3,
2644,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
2649,
63,
5955,
199,
199,
646,
295,
199,
199,
504,
1639,
14,
1160,
492,
9470,
12,
5077,
199,
504,
1639,
14,
1208,
492,
2197,
63,
3489,
12,
3816,
199,
199,
504,
394,
1187,
2340,
14,
3924,
492,
8730,
792,
547,
199,
504,
394,
1187,
2340,
14,
1208,
492,
664,
63,
1238,
63,
319,
63,
2960,
421,
199,
533,
2845,
63,
21403,
1149,
26,
272,
986,
421,
199,
12488,
63,
10710,
275,
295,
14,
2014,
9097,
2229,
48,
28,
3403,
3072,
68,
91,
20,
1552,
13,
2229,
48,
28,
4482,
3072,
68,
91,
18,
1552,
13,
2229,
48,
28,
2977,
3072,
68,
91,
18,
1552,
8,
52,
6113,
83,
8771,
2229,
48,
28,
5180,
3072,
68,
91,
18,
22558,
2229,
48,
28,
10698,
3072,
68,
91,
18,
22558,
2229,
48,
28,
4375,
3072,
68,
91,
18,
21385,
15279,
9988,
421,
199,
3,
2900,
314,
8730,
7304,
21169,
14,
199,
199,
533,
8730,
792,
8,
785,
304,
272,
408,
1918,
1300,
4514,
402,
282,
2754,
901,
1041,
272,
901,
63,
466,
275,
488,
339,
347,
636,
826,
721,
277,
12,
1402,
63,
962,
29,
403,
12,
675,
63,
1160,
29,
797,
12,
1978,
63,
354,
29,
403,
12,
326,
2213,
29,
797,
12,
15235,
29,
549,
12,
5489,
29,
549,
12,
8870,
471,
29,
797,
12,
326,
849,
29,
4609,
63,
21403,
1149,
12,
2973,
29,
797,
12,
1478,
63,
13646,
29,
403,
12,
326,
8870,
84,
63,
533,
29,
403,
12,
20198,
29,
17,
14,
16,
12,
5401,
29,
403,
304,
267,
327,
17507,
4052,
314,
1478,
13516,
83,
642,
901,
365,
2797,
14,
267,
291,
14,
842,
63,
354,
275,
488,
267,
291,
14,
1238,
63,
962,
275,
1402,
63,
962,
267,
291,
14,
1180,
63,
1160,
275,
675,
63,
1160,
267,
291,
14,
1160,
63,
354,
275,
1978,
63,
354,
267,
291,
14,
3554,
275,
2213,
267,
291,
14,
16821,
275,
15235,
267,
291,
14,
16431,
275,
5489,
267,
291,
14,
1409,
471,
275,
8870,
471,
267,
291,
423,
885,
275,
849,
267,
291,
14,
2307,
275,
2973,
267,
291,
14,
1080,
63,
13646,
275,
1478,
63,
13646,
267,
291,
14,
15589,
275,
5401,
503,
20198,
267,
291,
14,
374,
63,
3029,
16611,
275,
756,
398,
327,
2136,
17169,
314,
8870,
84,
63,
533,
367,
10663,
652,
8837,
370,
1218,
282,
8870,
471,
267,
327,
901,
4079,
2331,
402,
642,
901,
14,
267,
291,
14,
24271,
63,
533,
275,
8870,
84,
63,
533,
398,
340,
291,
14,
24271,
63,
533,
365,
488,
26,
288,
291,
14,
24271,
63,
533,
275,
21459,
84,
2183,
398,
291,
14,
409,
63,
842,
63,
354,
8,
403,
9,
339,
347,
663,
63,
842,
63,
354,
8,
277,
12,
1256,
63,
354,
304,
267,
291,
14,
842,
63,
354,
275,
1256,
63,
354,
398,
340,
291,
14,
1080,
63,
13646,
365,
488,
26,
288,
291,
14,
1080,
63,
13646,
275,
291,
14,
842,
63,
354,
339,
347,
965,
63,
885,
8,
277,
304,
267,
408,
3407,
282,
5046,
402,
3775,
642,
901,
965,
282,
849,
574,
1041,
267,
372,
291,
423,
885,
365,
440,
2845,
63,
21403,
1149,
339,
768,
1829,
272,
347,
849,
8,
277,
304,
267,
408,
3407,
314,
849,
574,
367,
314,
901,
1041,
267,
340,
4550,
8,
277,
423,
885,
304,
288,
372,
291,
423,
885,
342,
398,
372,
291,
423,
885,
339,
347,
9275,
8,
277,
12,
1559,
304,
267,
408,
267,
17415,
666,
687,
314,
2741,
909,
436,
876,
27749,
652,
367,
4887,
315,
314,
267,
1478,
14,
267,
408,
267,
327,
25495,
7464,
370,
282,
1978,
14,
267,
340,
291,
14,
1180,
63,
1160,
26,
288,
372,
291,
14,
6726,
63,
1160,
8,
1113,
9,
267,
916,
291,
14,
1238,
63,
962,
365,
440,
488,
26,
288,
327,
2670,
367,
26856,
64,
315,
314,
901,
367,
10023,
4012,
314,
5850,
14,
288,
3290,
275,
291,
14,
1238,
63,
962,
14,
1294,
10714,
358,
288,
1453,
63,
785,
275,
1559,
953,
367,
1921,
315,
3290,
26,
355,
340,
440,
2688,
8,
1818,
63,
785,
12,
1921,
304,
490,
746,
8730,
792,
547,
480,
1918,
1402,
1543,
83,
7,
1630,
440,
1172,
282,
1402,
63,
962,
1543,
83,
16669,
450,
334,
2722,
8,
1818,
63,
785,
395,
1921,
430,
2234,
1453,
63,
785,
275,
2519,
8,
1818,
63,
785,
12,
1921,
12,
488,
9,
2234,
340,
1453,
63,
785,
365,
488,
26,
490,
340,
291,
14,
1989,
63,
885,
837,
717,
1453,
63,
785,
275,
291,
423,
885,
717,
327,
481,
452,
734,
402,
314,
4438,
12,
1627,
1263,
9848,
12454,
737,
717,
327,
1066,
5804,
911,
2449,
10684,
332,
6665,
14,
717,
2059,
490,
916,
291,
14,
2307,
26,
717,
1453,
63,
785,
275,
488,
717,
327,
481,
452,
734,
402,
314,
4438,
12,
1627,
1263,
9848,
12454,
737,
717,
327,
1066,
5804,
911,
2449,
10684,
332,
6665,
14,
717,
2059,
490,
587,
26,
717,
746,
8730,
792,
547,
480,
1918,
1402,
1543,
83,
7,
12149,
543,
1402,
63,
962,
1543,
83,
7,
2138,
488,
12,
1325,
3181,
1133,
2040,
282,
849,
503,
2973,
574,
2122,
450,
334,
2722,
8,
1113,
395,
291,
14,
1238,
63,
962,
430,
953,
340,
4550,
8,
1818,
63,
785,
304,
355,
372,
1453,
63,
785,
342,
953,
372,
1453,
63,
785,
398,
340,
291,
14,
1989,
63,
885,
837,
288,
372,
291,
14,
885,
267,
587,
26,
288,
372,
488,
339,
347,
9275,
63,
1160,
8,
277,
12,
1559,
304,
267,
408,
267,
19005,
32461,
376,
909,
367,
16356,
14,
398,
961,
14404,
282,
1978,
267,
15693,
1733,
15,
10116,
5321,
571,
63,
1302,
16152,
1238,
63,
354,
26738,
698,
63,
354,
5565,
2424,
16580,
436,
267,
2529,
314,
754,
402,
14066,
626,
1978,
14,
1124,
785,
1040,
911,
506,
315,
267,
2399,
1067,
14,
267,
408,
267,
340,
291,
14,
842,
63,
354,
365,
488,
436,
291,
14,
1160,
63,
354,
365,
488,
26,
288,
746,
8730,
792,
547,
480,
2765,
901,
5074,
1902,
2399,
1256,
63,
354,
1750,
370,
506,
16460,
503,
376,
5027,
1978,
63,
354,
315,
1865,
370,
2248,
314
] |
[
2644,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
2649,
63,
5955,
199,
199,
646,
295,
199,
199,
504,
1639,
14,
1160,
492,
9470,
12,
5077,
199,
504,
1639,
14,
1208,
492,
2197,
63,
3489,
12,
3816,
199,
199,
504,
394,
1187,
2340,
14,
3924,
492,
8730,
792,
547,
199,
504,
394,
1187,
2340,
14,
1208,
492,
664,
63,
1238,
63,
319,
63,
2960,
421,
199,
533,
2845,
63,
21403,
1149,
26,
272,
986,
421,
199,
12488,
63,
10710,
275,
295,
14,
2014,
9097,
2229,
48,
28,
3403,
3072,
68,
91,
20,
1552,
13,
2229,
48,
28,
4482,
3072,
68,
91,
18,
1552,
13,
2229,
48,
28,
2977,
3072,
68,
91,
18,
1552,
8,
52,
6113,
83,
8771,
2229,
48,
28,
5180,
3072,
68,
91,
18,
22558,
2229,
48,
28,
10698,
3072,
68,
91,
18,
22558,
2229,
48,
28,
4375,
3072,
68,
91,
18,
21385,
15279,
9988,
421,
199,
3,
2900,
314,
8730,
7304,
21169,
14,
199,
199,
533,
8730,
792,
8,
785,
304,
272,
408,
1918,
1300,
4514,
402,
282,
2754,
901,
1041,
272,
901,
63,
466,
275,
488,
339,
347,
636,
826,
721,
277,
12,
1402,
63,
962,
29,
403,
12,
675,
63,
1160,
29,
797,
12,
1978,
63,
354,
29,
403,
12,
326,
2213,
29,
797,
12,
15235,
29,
549,
12,
5489,
29,
549,
12,
8870,
471,
29,
797,
12,
326,
849,
29,
4609,
63,
21403,
1149,
12,
2973,
29,
797,
12,
1478,
63,
13646,
29,
403,
12,
326,
8870,
84,
63,
533,
29,
403,
12,
20198,
29,
17,
14,
16,
12,
5401,
29,
403,
304,
267,
327,
17507,
4052,
314,
1478,
13516,
83,
642,
901,
365,
2797,
14,
267,
291,
14,
842,
63,
354,
275,
488,
267,
291,
14,
1238,
63,
962,
275,
1402,
63,
962,
267,
291,
14,
1180,
63,
1160,
275,
675,
63,
1160,
267,
291,
14,
1160,
63,
354,
275,
1978,
63,
354,
267,
291,
14,
3554,
275,
2213,
267,
291,
14,
16821,
275,
15235,
267,
291,
14,
16431,
275,
5489,
267,
291,
14,
1409,
471,
275,
8870,
471,
267,
291,
423,
885,
275,
849,
267,
291,
14,
2307,
275,
2973,
267,
291,
14,
1080,
63,
13646,
275,
1478,
63,
13646,
267,
291,
14,
15589,
275,
5401,
503,
20198,
267,
291,
14,
374,
63,
3029,
16611,
275,
756,
398,
327,
2136,
17169,
314,
8870,
84,
63,
533,
367,
10663,
652,
8837,
370,
1218,
282,
8870,
471,
267,
327,
901,
4079,
2331,
402,
642,
901,
14,
267,
291,
14,
24271,
63,
533,
275,
8870,
84,
63,
533,
398,
340,
291,
14,
24271,
63,
533,
365,
488,
26,
288,
291,
14,
24271,
63,
533,
275,
21459,
84,
2183,
398,
291,
14,
409,
63,
842,
63,
354,
8,
403,
9,
339,
347,
663,
63,
842,
63,
354,
8,
277,
12,
1256,
63,
354,
304,
267,
291,
14,
842,
63,
354,
275,
1256,
63,
354,
398,
340,
291,
14,
1080,
63,
13646,
365,
488,
26,
288,
291,
14,
1080,
63,
13646,
275,
291,
14,
842,
63,
354,
339,
347,
965,
63,
885,
8,
277,
304,
267,
408,
3407,
282,
5046,
402,
3775,
642,
901,
965,
282,
849,
574,
1041,
267,
372,
291,
423,
885,
365,
440,
2845,
63,
21403,
1149,
339,
768,
1829,
272,
347,
849,
8,
277,
304,
267,
408,
3407,
314,
849,
574,
367,
314,
901,
1041,
267,
340,
4550,
8,
277,
423,
885,
304,
288,
372,
291,
423,
885,
342,
398,
372,
291,
423,
885,
339,
347,
9275,
8,
277,
12,
1559,
304,
267,
408,
267,
17415,
666,
687,
314,
2741,
909,
436,
876,
27749,
652,
367,
4887,
315,
314,
267,
1478,
14,
267,
408,
267,
327,
25495,
7464,
370,
282,
1978,
14,
267,
340,
291,
14,
1180,
63,
1160,
26,
288,
372,
291,
14,
6726,
63,
1160,
8,
1113,
9,
267,
916,
291,
14,
1238,
63,
962,
365,
440,
488,
26,
288,
327,
2670,
367,
26856,
64,
315,
314,
901,
367,
10023,
4012,
314,
5850,
14,
288,
3290,
275,
291,
14,
1238,
63,
962,
14,
1294,
10714,
358,
288,
1453,
63,
785,
275,
1559,
953,
367,
1921,
315,
3290,
26,
355,
340,
440,
2688,
8,
1818,
63,
785,
12,
1921,
304,
490,
746,
8730,
792,
547,
480,
1918,
1402,
1543,
83,
7,
1630,
440,
1172,
282,
1402,
63,
962,
1543,
83,
16669,
450,
334,
2722,
8,
1818,
63,
785,
395,
1921,
430,
2234,
1453,
63,
785,
275,
2519,
8,
1818,
63,
785,
12,
1921,
12,
488,
9,
2234,
340,
1453,
63,
785,
365,
488,
26,
490,
340,
291,
14,
1989,
63,
885,
837,
717,
1453,
63,
785,
275,
291,
423,
885,
717,
327,
481,
452,
734,
402,
314,
4438,
12,
1627,
1263,
9848,
12454,
737,
717,
327,
1066,
5804,
911,
2449,
10684,
332,
6665,
14,
717,
2059,
490,
916,
291,
14,
2307,
26,
717,
1453,
63,
785,
275,
488,
717,
327,
481,
452,
734,
402,
314,
4438,
12,
1627,
1263,
9848,
12454,
737,
717,
327,
1066,
5804,
911,
2449,
10684,
332,
6665,
14,
717,
2059,
490,
587,
26,
717,
746,
8730,
792,
547,
480,
1918,
1402,
1543,
83,
7,
12149,
543,
1402,
63,
962,
1543,
83,
7,
2138,
488,
12,
1325,
3181,
1133,
2040,
282,
849,
503,
2973,
574,
2122,
450,
334,
2722,
8,
1113,
395,
291,
14,
1238,
63,
962,
430,
953,
340,
4550,
8,
1818,
63,
785,
304,
355,
372,
1453,
63,
785,
342,
953,
372,
1453,
63,
785,
398,
340,
291,
14,
1989,
63,
885,
837,
288,
372,
291,
14,
885,
267,
587,
26,
288,
372,
488,
339,
347,
9275,
63,
1160,
8,
277,
12,
1559,
304,
267,
408,
267,
19005,
32461,
376,
909,
367,
16356,
14,
398,
961,
14404,
282,
1978,
267,
15693,
1733,
15,
10116,
5321,
571,
63,
1302,
16152,
1238,
63,
354,
26738,
698,
63,
354,
5565,
2424,
16580,
436,
267,
2529,
314,
754,
402,
14066,
626,
1978,
14,
1124,
785,
1040,
911,
506,
315,
267,
2399,
1067,
14,
267,
408,
267,
340,
291,
14,
842,
63,
354,
365,
488,
436,
291,
14,
1160,
63,
354,
365,
488,
26,
288,
746,
8730,
792,
547,
480,
2765,
901,
5074,
1902,
2399,
1256,
63,
354,
1750,
370,
506,
16460,
503,
376,
5027,
1978,
63,
354,
315,
1865,
370,
2248,
314,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
exploreodoo/datStruct
|
odoo/addons/hr_payroll_account/hr_payroll_account.py
|
240
|
10840
|
#-*- coding:utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# d$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from datetime import date, datetime, timedelta
from openerp.osv import fields, osv
from openerp.tools import float_compare, float_is_zero
from openerp.tools.translate import _
class hr_payslip(osv.osv):
'''
Pay Slip
'''
_inherit = 'hr.payslip'
_description = 'Pay Slip'
_columns = {
'period_id': fields.many2one('account.period', 'Force Period',states={'draft': [('readonly', False)]}, readonly=True, domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."),
'journal_id': fields.many2one('account.journal', 'Salary Journal',states={'draft': [('readonly', False)]}, readonly=True, required=True),
'move_id': fields.many2one('account.move', 'Accounting Entry', readonly=True, copy=False),
}
def _get_default_journal(self, cr, uid, context=None):
model_data = self.pool.get('ir.model.data')
res = model_data.search(cr, uid, [('name', '=', 'expenses_journal')])
if res:
return model_data.browse(cr, uid, res[0]).res_id
return False
_defaults = {
'journal_id': _get_default_journal,
}
def create(self, cr, uid, vals, context=None):
if context is None:
context = {}
if 'journal_id' in context:
vals.update({'journal_id': context.get('journal_id')})
return super(hr_payslip, self).create(cr, uid, vals, context=context)
def onchange_contract_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None):
contract_obj = self.pool.get('hr.contract')
res = super(hr_payslip, self).onchange_contract_id(cr, uid, ids, date_from=date_from, date_to=date_to, employee_id=employee_id, contract_id=contract_id, context=context)
journal_id = contract_id and contract_obj.browse(cr, uid, contract_id, context=context).journal_id.id or False
res['value'].update({'journal_id': journal_id})
return res
def cancel_sheet(self, cr, uid, ids, context=None):
move_pool = self.pool.get('account.move')
move_ids = []
move_to_cancel = []
for slip in self.browse(cr, uid, ids, context=context):
if slip.move_id:
move_ids.append(slip.move_id.id)
if slip.move_id.state == 'posted':
move_to_cancel.append(slip.move_id.id)
move_pool.button_cancel(cr, uid, move_to_cancel, context=context)
move_pool.unlink(cr, uid, move_ids, context=context)
return super(hr_payslip, self).cancel_sheet(cr, uid, ids, context=context)
def process_sheet(self, cr, uid, ids, context=None):
move_pool = self.pool.get('account.move')
period_pool = self.pool.get('account.period')
precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Payroll')
timenow = time.strftime('%Y-%m-%d')
for slip in self.browse(cr, uid, ids, context=context):
line_ids = []
debit_sum = 0.0
credit_sum = 0.0
if not slip.period_id:
search_periods = period_pool.find(cr, uid, slip.date_to, context=context)
period_id = search_periods[0]
else:
period_id = slip.period_id.id
default_partner_id = slip.employee_id.address_home_id.id
name = _('Payslip of %s') % (slip.employee_id.name)
move = {
'narration': name,
'date': timenow,
'ref': slip.number,
'journal_id': slip.journal_id.id,
'period_id': period_id,
}
for line in slip.details_by_salary_rule_category:
amt = slip.credit_note and -line.total or line.total
if float_is_zero(amt, precision_digits=precision):
continue
partner_id = line.salary_rule_id.register_id.partner_id and line.salary_rule_id.register_id.partner_id.id or default_partner_id
debit_account_id = line.salary_rule_id.account_debit.id
credit_account_id = line.salary_rule_id.account_credit.id
if debit_account_id:
debit_line = (0, 0, {
'name': line.name,
'date': timenow,
'partner_id': (line.salary_rule_id.register_id.partner_id or line.salary_rule_id.account_debit.type in ('receivable', 'payable')) and partner_id or False,
'account_id': debit_account_id,
'journal_id': slip.journal_id.id,
'period_id': period_id,
'debit': amt > 0.0 and amt or 0.0,
'credit': amt < 0.0 and -amt or 0.0,
'analytic_account_id': line.salary_rule_id.analytic_account_id and line.salary_rule_id.analytic_account_id.id or False,
'tax_code_id': line.salary_rule_id.account_tax_id and line.salary_rule_id.account_tax_id.id or False,
'tax_amount': line.salary_rule_id.account_tax_id and amt or 0.0,
})
line_ids.append(debit_line)
debit_sum += debit_line[2]['debit'] - debit_line[2]['credit']
if credit_account_id:
credit_line = (0, 0, {
'name': line.name,
'date': timenow,
'partner_id': (line.salary_rule_id.register_id.partner_id or line.salary_rule_id.account_credit.type in ('receivable', 'payable')) and partner_id or False,
'account_id': credit_account_id,
'journal_id': slip.journal_id.id,
'period_id': period_id,
'debit': amt < 0.0 and -amt or 0.0,
'credit': amt > 0.0 and amt or 0.0,
'analytic_account_id': line.salary_rule_id.analytic_account_id and line.salary_rule_id.analytic_account_id.id or False,
'tax_code_id': line.salary_rule_id.account_tax_id and line.salary_rule_id.account_tax_id.id or False,
'tax_amount': line.salary_rule_id.account_tax_id and amt or 0.0,
})
line_ids.append(credit_line)
credit_sum += credit_line[2]['credit'] - credit_line[2]['debit']
if float_compare(credit_sum, debit_sum, precision_digits=precision) == -1:
acc_id = slip.journal_id.default_credit_account_id.id
if not acc_id:
raise osv.except_osv(_('Configuration Error!'),_('The Expense Journal "%s" has not properly configured the Credit Account!')%(slip.journal_id.name))
adjust_credit = (0, 0, {
'name': _('Adjustment Entry'),
'date': timenow,
'partner_id': False,
'account_id': acc_id,
'journal_id': slip.journal_id.id,
'period_id': period_id,
'debit': 0.0,
'credit': debit_sum - credit_sum,
})
line_ids.append(adjust_credit)
elif float_compare(debit_sum, credit_sum, precision_digits=precision) == -1:
acc_id = slip.journal_id.default_debit_account_id.id
if not acc_id:
raise osv.except_osv(_('Configuration Error!'),_('The Expense Journal "%s" has not properly configured the Debit Account!')%(slip.journal_id.name))
adjust_debit = (0, 0, {
'name': _('Adjustment Entry'),
'date': timenow,
'partner_id': False,
'account_id': acc_id,
'journal_id': slip.journal_id.id,
'period_id': period_id,
'debit': credit_sum - debit_sum,
'credit': 0.0,
})
line_ids.append(adjust_debit)
move.update({'line_id': line_ids})
move_id = move_pool.create(cr, uid, move, context=context)
self.write(cr, uid, [slip.id], {'move_id': move_id, 'period_id' : period_id}, context=context)
if slip.journal_id.entry_posted:
move_pool.post(cr, uid, [move_id], context=context)
return super(hr_payslip, self).process_sheet(cr, uid, [slip.id], context=context)
class hr_salary_rule(osv.osv):
_inherit = 'hr.salary.rule'
_columns = {
'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'),
'account_tax_id':fields.many2one('account.tax.code', 'Tax Code'),
'account_debit': fields.many2one('account.account', 'Debit Account'),
'account_credit': fields.many2one('account.account', 'Credit Account'),
}
class hr_contract(osv.osv):
_inherit = 'hr.contract'
_description = 'Employee Contract'
_columns = {
'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'),
'journal_id': fields.many2one('account.journal', 'Salary Journal'),
}
class hr_payslip_run(osv.osv):
_inherit = 'hr.payslip.run'
_description = 'Payslip Run'
_columns = {
'journal_id': fields.many2one('account.journal', 'Salary Journal', states={'draft': [('readonly', False)]}, readonly=True, required=True),
}
def _get_default_journal(self, cr, uid, context=None):
model_data = self.pool.get('ir.model.data')
res = model_data.search(cr, uid, [('name', '=', 'expenses_journal')])
if res:
return model_data.browse(cr, uid, res[0]).res_id
return False
_defaults = {
'journal_id': _get_default_journal,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
gpl-2.0
|
[
3,
13,
1837,
2803,
26,
1624,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
2900,
5924,
5702,
199,
3,
259,
366,
4,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
3267,
701,
199,
3,
259,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
259,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
646,
900,
199,
504,
2197,
492,
1434,
12,
2197,
12,
6871,
199,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
14,
2537,
492,
2069,
63,
5785,
12,
2069,
63,
374,
63,
4262,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
533,
16140,
63,
25854,
8,
4795,
14,
4795,
304,
272,
1449,
272,
15911,
428,
3587,
272,
1449,
272,
485,
6486,
275,
283,
6271,
14,
25854,
7,
272,
485,
1802,
275,
283,
10517,
428,
3587,
7,
339,
485,
3406,
275,
469,
267,
283,
5191,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
5191,
297,
283,
13606,
16532,
297,
4981,
3713,
7185,
356,
4274,
6753,
297,
756,
26804,
6863,
29,
549,
12,
2881,
11699,
929,
1673,
16137,
1673,
4456,
2665,
1720,
628,
18567,
2701,
370,
675,
314,
6247,
402,
314,
6411,
8,
4232,
18909,
9,
1434,
7651,
267,
283,
7067,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
7067,
297,
283,
27177,
695,
22142,
297,
4981,
3713,
7185,
356,
4274,
6753,
297,
756,
26804,
6863,
29,
549,
12,
1415,
29,
549,
395,
267,
283,
1185,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
1185,
297,
283,
6009,
316,
11855,
297,
6863,
29,
549,
12,
1331,
29,
797,
395,
272,
789,
339,
347,
485,
362,
63,
885,
63,
7067,
8,
277,
12,
2467,
12,
1747,
12,
1067,
29,
403,
304,
267,
1402,
63,
576,
275,
291,
14,
2293,
14,
362,
360,
723,
14,
1238,
14,
576,
358,
267,
522,
275,
1402,
63,
576,
14,
1733,
8,
1556,
12,
1747,
12,
4274,
354,
297,
6291,
283,
16886,
83,
63,
7067,
2023,
267,
340,
522,
26,
288,
372,
1402,
63,
576,
14,
4570,
8,
1556,
12,
1747,
12,
522,
59,
16,
6575,
470,
63,
344,
267,
372,
756,
339,
485,
4322,
275,
469,
267,
283,
7067,
63,
344,
356,
485,
362,
63,
885,
63,
7067,
12,
272,
789,
339,
347,
1218,
8,
277,
12,
2467,
12,
1747,
12,
5322,
12,
1067,
29,
403,
304,
267,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
340,
283,
7067,
63,
344,
7,
315,
1067,
26,
288,
5322,
14,
873,
3252,
7067,
63,
344,
356,
1067,
14,
362,
360,
7067,
63,
344,
22220,
267,
372,
1613,
8,
6271,
63,
25854,
12,
291,
680,
981,
8,
1556,
12,
1747,
12,
5322,
12,
1067,
29,
1100,
9,
339,
347,
20258,
63,
14624,
63,
344,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1434,
63,
504,
12,
1434,
63,
475,
12,
15778,
63,
344,
29,
797,
12,
16077,
63,
344,
29,
797,
12,
1067,
29,
403,
304,
267,
16077,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
6271,
14,
14624,
358,
267,
522,
275,
1613,
8,
6271,
63,
25854,
12,
291,
680,
18128,
63,
14624,
63,
344,
8,
1556,
12,
1747,
12,
2762,
12,
1434,
63,
504,
29,
602,
63,
504,
12,
1434,
63,
475,
29,
602,
63,
475,
12,
15778,
63,
344,
29,
10103,
63,
344,
12,
16077,
63,
344,
29,
14624,
63,
344,
12,
1067,
29,
1100,
9,
267,
9605,
63,
344,
275,
16077,
63,
344,
436,
16077,
63,
1113,
14,
4570,
8,
1556,
12,
1747,
12,
16077,
63,
344,
12,
1067,
29,
1100,
680,
7067,
63,
344,
14,
344,
503,
756,
267,
522,
459,
585,
2278,
873,
3252,
7067,
63,
344,
356,
9605,
63,
344,
1552,
267,
372,
522,
339,
347,
9311,
63,
5069,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
4057,
63,
2293,
275,
291,
14,
2293,
14,
362,
360,
2048,
14,
1185,
358,
267,
4057,
63,
1580,
275,
942,
267,
4057,
63,
475,
63,
6406,
275,
942,
267,
367,
308,
3587,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
304,
288,
340,
308,
3587,
14,
1185,
63,
344,
26,
355,
4057,
63,
1580,
14,
740,
8,
83,
3587,
14,
1185,
63,
344,
14,
344,
9,
355,
340,
308,
3587,
14,
1185,
63,
344,
14,
929,
508,
283,
21760,
356,
490,
4057,
63,
475,
63,
6406,
14,
740,
8,
83,
3587,
14,
1185,
63,
344,
14,
344,
9,
267,
4057,
63,
2293,
14,
3887,
63,
6406,
8,
1556,
12,
1747,
12,
4057,
63,
475,
63,
6406,
12,
1067,
29,
1100,
9,
267,
4057,
63,
2293,
14,
7162,
8,
1556,
12,
1747,
12,
4057,
63,
1580,
12,
1067,
29,
1100,
9,
267,
372,
1613,
8,
6271,
63,
25854,
12,
291,
680,
6406,
63,
5069,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
9,
339,
347,
2112,
63,
5069,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
4057,
63,
2293,
275,
291,
14,
2293,
14,
362,
360,
2048,
14,
1185,
358,
267,
6247,
63,
2293,
275,
291,
14,
2293,
14,
362,
360,
2048,
14,
5191,
358,
267,
7151,
275,
291,
14,
2293,
14,
362,
360
] |
[
13,
1837,
2803,
26,
1624,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
2900,
5924,
5702,
199,
3,
259,
366,
4,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
3267,
701,
199,
3,
259,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
259,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
646,
900,
199,
504,
2197,
492,
1434,
12,
2197,
12,
6871,
199,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
14,
2537,
492,
2069,
63,
5785,
12,
2069,
63,
374,
63,
4262,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
533,
16140,
63,
25854,
8,
4795,
14,
4795,
304,
272,
1449,
272,
15911,
428,
3587,
272,
1449,
272,
485,
6486,
275,
283,
6271,
14,
25854,
7,
272,
485,
1802,
275,
283,
10517,
428,
3587,
7,
339,
485,
3406,
275,
469,
267,
283,
5191,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
5191,
297,
283,
13606,
16532,
297,
4981,
3713,
7185,
356,
4274,
6753,
297,
756,
26804,
6863,
29,
549,
12,
2881,
11699,
929,
1673,
16137,
1673,
4456,
2665,
1720,
628,
18567,
2701,
370,
675,
314,
6247,
402,
314,
6411,
8,
4232,
18909,
9,
1434,
7651,
267,
283,
7067,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
7067,
297,
283,
27177,
695,
22142,
297,
4981,
3713,
7185,
356,
4274,
6753,
297,
756,
26804,
6863,
29,
549,
12,
1415,
29,
549,
395,
267,
283,
1185,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
1185,
297,
283,
6009,
316,
11855,
297,
6863,
29,
549,
12,
1331,
29,
797,
395,
272,
789,
339,
347,
485,
362,
63,
885,
63,
7067,
8,
277,
12,
2467,
12,
1747,
12,
1067,
29,
403,
304,
267,
1402,
63,
576,
275,
291,
14,
2293,
14,
362,
360,
723,
14,
1238,
14,
576,
358,
267,
522,
275,
1402,
63,
576,
14,
1733,
8,
1556,
12,
1747,
12,
4274,
354,
297,
6291,
283,
16886,
83,
63,
7067,
2023,
267,
340,
522,
26,
288,
372,
1402,
63,
576,
14,
4570,
8,
1556,
12,
1747,
12,
522,
59,
16,
6575,
470,
63,
344,
267,
372,
756,
339,
485,
4322,
275,
469,
267,
283,
7067,
63,
344,
356,
485,
362,
63,
885,
63,
7067,
12,
272,
789,
339,
347,
1218,
8,
277,
12,
2467,
12,
1747,
12,
5322,
12,
1067,
29,
403,
304,
267,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
340,
283,
7067,
63,
344,
7,
315,
1067,
26,
288,
5322,
14,
873,
3252,
7067,
63,
344,
356,
1067,
14,
362,
360,
7067,
63,
344,
22220,
267,
372,
1613,
8,
6271,
63,
25854,
12,
291,
680,
981,
8,
1556,
12,
1747,
12,
5322,
12,
1067,
29,
1100,
9,
339,
347,
20258,
63,
14624,
63,
344,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1434,
63,
504,
12,
1434,
63,
475,
12,
15778,
63,
344,
29,
797,
12,
16077,
63,
344,
29,
797,
12,
1067,
29,
403,
304,
267,
16077,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
6271,
14,
14624,
358,
267,
522,
275,
1613,
8,
6271,
63,
25854,
12,
291,
680,
18128,
63,
14624,
63,
344,
8,
1556,
12,
1747,
12,
2762,
12,
1434,
63,
504,
29,
602,
63,
504,
12,
1434,
63,
475,
29,
602,
63,
475,
12,
15778,
63,
344,
29,
10103,
63,
344,
12,
16077,
63,
344,
29,
14624,
63,
344,
12,
1067,
29,
1100,
9,
267,
9605,
63,
344,
275,
16077,
63,
344,
436,
16077,
63,
1113,
14,
4570,
8,
1556,
12,
1747,
12,
16077,
63,
344,
12,
1067,
29,
1100,
680,
7067,
63,
344,
14,
344,
503,
756,
267,
522,
459,
585,
2278,
873,
3252,
7067,
63,
344,
356,
9605,
63,
344,
1552,
267,
372,
522,
339,
347,
9311,
63,
5069,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
4057,
63,
2293,
275,
291,
14,
2293,
14,
362,
360,
2048,
14,
1185,
358,
267,
4057,
63,
1580,
275,
942,
267,
4057,
63,
475,
63,
6406,
275,
942,
267,
367,
308,
3587,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
304,
288,
340,
308,
3587,
14,
1185,
63,
344,
26,
355,
4057,
63,
1580,
14,
740,
8,
83,
3587,
14,
1185,
63,
344,
14,
344,
9,
355,
340,
308,
3587,
14,
1185,
63,
344,
14,
929,
508,
283,
21760,
356,
490,
4057,
63,
475,
63,
6406,
14,
740,
8,
83,
3587,
14,
1185,
63,
344,
14,
344,
9,
267,
4057,
63,
2293,
14,
3887,
63,
6406,
8,
1556,
12,
1747,
12,
4057,
63,
475,
63,
6406,
12,
1067,
29,
1100,
9,
267,
4057,
63,
2293,
14,
7162,
8,
1556,
12,
1747,
12,
4057,
63,
1580,
12,
1067,
29,
1100,
9,
267,
372,
1613,
8,
6271,
63,
25854,
12,
291,
680,
6406,
63,
5069,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
9,
339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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
proxysh/Safejumper-for-Desktop
|
buildlinux/env64/lib/python2.7/site-packages/Crypto/SelfTest/Hash/test_SHA256.py
|
116
|
3663
|
# -*- coding: utf-8 -*-
#
# SelfTest/Hash/test_SHA256.py: Self-test for the SHA-256 hash function
#
# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
#
# ===================================================================
# The contents of this file are dedicated to the public domain. To
# the extent that dedication to the public domain is not available,
# everyone is granted a worldwide, perpetual, royalty-free,
# non-exclusive license to exercise all rights associated with the
# contents of this file for any purpose whatsoever.
# No rights are reserved.
#
# 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.
# ===================================================================
"""Self-test suite for Crypto.Hash.SHA256"""
__revision__ = "$Id$"
import unittest
from Crypto.Util.py3compat import *
class LargeSHA256Test(unittest.TestCase):
def runTest(self):
"""SHA256: 512/520 MiB test"""
from Crypto.Hash import SHA256
zeros = bchr(0x00) * (1024*1024)
h = SHA256.new(zeros)
for i in xrange(511):
h.update(zeros)
# This test vector is from PyCrypto's old testdata.py file.
self.assertEqual('9acca8e8c22201155389f65abbf6bc9723edc7384ead80503839f49dcc56d767', h.hexdigest()) # 512 MiB
for i in xrange(8):
h.update(zeros)
# This test vector is from PyCrypto's old testdata.py file.
self.assertEqual('abf51ad954b246009dfe5a50ecd582fd5b8f1b8b27f30393853c3ef721e7fa6e', h.hexdigest()) # 520 MiB
def get_tests(config={}):
# Test vectors from FIPS PUB 180-2
# This is a list of (expected_result, input[, description]) tuples.
test_data = [
# FIPS PUB 180-2, B.1 - "One-Block Message"
('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad',
'abc'),
# FIPS PUB 180-2, B.2 - "Multi-Block Message"
('248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1',
'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'),
# FIPS PUB 180-2, B.3 - "Long Message"
('cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0',
'a' * 10**6,
'"a" * 10**6'),
# Test for an old PyCrypto bug.
('f7fd017a3c721ce7ff03f3552c0813adcc48b7f33f07e5e2ba71e23ea393d103',
'This message is precisely 55 bytes long, to test a bug.',
'Length = 55 (mod 64)'),
# Example from http://de.wikipedia.org/wiki/Secure_Hash_Algorithm
('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', ''),
('d32b568cd1b96d459e7291ebf4b25d007f275c9f13149beeb782fac0716613f8',
'Franz jagt im komplett verwahrlosten Taxi quer durch Bayern'),
]
from Crypto.Hash import SHA256
from common import make_hash_tests
tests = make_hash_tests(SHA256, "SHA256", test_data,
digest_size=32,
oid="\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01")
if config.get('slow_tests'):
tests += [LargeSHA256Test()]
return tests
if __name__ == '__main__':
import unittest
suite = lambda: unittest.TestSuite(get_tests())
unittest.main(defaultTest='suite')
# vim:set ts=4 sw=4 sts=4 expandtab:
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
221,
23820,
774,
15,
3476,
15,
396,
63,
8461,
3912,
14,
647,
26,
23820,
13,
396,
367,
314,
12002,
13,
3912,
2631,
805,
199,
3,
199,
3,
27694,
315,
9079,
701,
577,
3316,
685,
445,
14,
491,
390,
5193,
605,
836,
665,
68,
29382,
32,
68,
29382,
14,
846,
30,
199,
3,
199,
3,
7819,
389,
199,
3,
710,
4072,
402,
642,
570,
787,
29711,
370,
314,
4575,
2881,
14,
221,
4005,
199,
3,
314,
13675,
626,
477,
21171,
370,
314,
4575,
2881,
365,
440,
2808,
12,
199,
3,
4036,
368,
365,
10009,
282,
6701,
13062,
12,
1126,
321,
1688,
12,
882,
89,
13248,
13,
4624,
12,
199,
3,
2222,
13,
12730,
4190,
370,
26511,
1006,
4481,
4568,
543,
314,
199,
3,
4072,
402,
642,
570,
367,
1263,
12016,
4052,
1152,
5907,
14,
199,
3,
3091,
4481,
787,
4644,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
199,
3,
7168,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
199,
3,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
13229,
14,
1621,
4825,
6461,
7000,
2334,
10610,
1549,
5877,
8164,
199,
3,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
7061,
1621,
1261,
199,
3,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
5738,
1634,
1549,
1621,
199,
3,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
199,
3,
4141,
14,
199,
3,
7819,
389,
199,
199,
624,
12887,
13,
396,
5241,
367,
18855,
14,
3476,
14,
8461,
3912,
624,
199,
199,
363,
5792,
363,
275,
7880,
1304,
17351,
199,
199,
646,
2882,
199,
504,
18855,
14,
9562,
14,
647,
19,
5819,
492,
627,
199,
199,
533,
29095,
8461,
3912,
774,
8,
2796,
14,
1746,
304,
272,
347,
29779,
8,
277,
304,
267,
408,
8461,
3912,
26,
10574,
15,
24224,
603,
17587,
511,
624,
267,
687,
18855,
14,
3476,
492,
12002,
3912,
267,
10136,
275,
330,
10194,
8,
16,
88,
383,
9,
627,
334,
7727,
10,
7727,
9,
398,
394,
275,
12002,
3912,
14,
1222,
8,
4250,
9,
267,
367,
284,
315,
4945,
8,
27176,
304,
288,
394,
14,
873,
8,
4250,
9,
398,
327,
961,
511,
5477,
365,
687,
1611,
17134,
1159,
2269,
511,
576,
14,
647,
570,
14,
267,
291,
14,
629,
360,
25,
645,
696,
24,
69,
24,
67,
1081,
1797,
1046,
2481,
1407,
70,
2182,
371,
4361,
22,
3776,
2576,
1789,
379,
67,
2898,
1349,
69,
350,
1257,
1400,
1703,
1355,
70,
1887,
68,
2055,
1367,
68,
14787,
297,
394,
14,
11453,
1012,
327,
10574,
603,
17587,
398,
367,
284,
315,
4945,
8,
24,
304,
288,
394,
14,
873,
8,
4250,
9,
398,
327,
961,
511,
5477,
365,
687,
1611,
17134,
1159,
2269,
511,
576,
14,
647,
570,
14,
267,
291,
14,
629,
360,
32706,
2869,
350,
31550,
66,
1194,
6683,
25,
68,
771,
21,
65,
1400,
30441,
17760,
2592,
21,
66,
24,
70,
17,
66,
24,
66,
1465,
70,
1216,
1355,
1703,
2481,
67,
19,
2829,
23,
2025,
69,
23,
667,
22,
69,
297,
394,
14,
11453,
1012,
327,
959,
1165,
603,
17587,
199,
199,
318,
664,
63,
2219,
8,
888,
16420,
272,
327,
1379,
11102,
687,
481,
12346,
18787,
13576,
13,
18,
272,
327,
961,
365,
282,
769,
402,
334,
2062,
63,
1099,
12,
1324,
14675,
1369,
566,
6346,
14,
272,
511,
63,
576,
275,
359,
267,
327,
481,
12346,
18787,
13576,
13,
18,
12,
699,
14,
17,
446,
298,
4395,
13,
3142,
6430,
2,
267,
661,
2470,
2277,
975,
4361,
24,
70,
614,
67,
29838,
25250,
10037,
271,
21,
9747,
1081,
1789,
66,
383,
15702,
65,
1355,
2976,
1138,
65,
25,
2894,
24781,
556,
2976,
70,
1840,
1046,
350,
297,
288,
283,
3175,
659,
398,
327,
481,
12346,
18787,
13576,
13,
18,
12,
699,
14,
18,
446,
298,
3947,
13,
3142,
6430,
2,
267,
661,
11242,
68,
22,
65,
2976,
68,
11089,
1703,
66,
24,
69,
21,
67,
996,
1876,
1216,
67,
19,
69,
2259,
1355,
65,
1153,
301,
28976,
772,
556,
9669,
23,
70,
22,
69,
301,
617,
25230,
697,
1690,
67,
17,
297,
288,
283,
3175,
16845,
7778,
318,
318,
303,
70,
3561,
70,
3561,
2056,
7879,
5812,
17421,
7879,
9503,
74,
9503,
3880,
14344,
7530,
10344,
676,
20443,
20443,
81,
659,
398,
327,
481,
12346,
18787,
13576,
13,
18,
12,
699,
14,
19,
446,
298,
9551,
6430,
2,
267,
661,
25193,
2114,
69,
21,
67,
1020,
1079,
4675,
25,
16263,
65,
17,
67,
23,
69,
10681,
68,
2898,
69,
1822,
70,
1085,
1643,
65,
2006,
65,
19180,
1840,
69,
13702,
68,
1355,
19504,
3172,
713,
2866,
16,
297,
288,
283,
65,
7,
627,
1616,
538,
22,
12,
1467,
5522,
65,
2,
627,
1616,
538,
22,
659,
398,
327,
1379,
367,
376,
2269,
1611,
17134,
6519,
14,
267,
661,
70,
23,
2592,
9570,
65,
19,
67,
23,
2025,
301,
23,
556,
1644,
70,
10156,
18,
67,
2036,
969,
350,
2055,
2006,
66,
23,
70,
1153,
70,
1780,
69,
21,
69,
18,
2470,
3172,
69,
1789,
4489,
15490,
68,
8845,
297,
288,
283,
2765,
1245,
365,
28334,
590,
12766,
2783,
1846,
12,
370,
511,
282,
6519,
3130,
288,
283,
4625,
275,
12766,
334,
1494,
5049,
11218,
398,
327,
5679,
687,
1455,
921,
271,
14,
13961,
14,
1308,
15,
6797,
15,
24117,
63,
3476,
63,
11570,
267,
661,
69,
19,
66,
16,
67,
1602,
12877,
3003,
17,
67,
10721,
2756,
4361,
20,
67,
24,
14140,
4675,
30666,
1465,
3624,
2953,
69,
20,
11228,
66,
30391,
696,
20384,
18411,
66,
2277,
2528,
66,
12593,
297,
9929,
398,
661,
68,
708,
66,
15085,
2866,
17,
66,
2534,
68,
28976,
69,
23,
16319,
2871,
70,
20,
66,
821,
68,
8255,
70,
13643,
67,
25,
70,
969,
10721,
19446,
66,
23199,
12668,
1780,
10642,
969,
70,
24,
297,
268,
283,
38,
1312,
90,
1335,
643,
84,
3416,
20817,
575,
6215,
809,
758,
6271,
320,
4081,
30174,
73,
26923,
366,
300,
335,
29434,
27569,
659,
272,
1622,
339,
687,
18855,
14,
3476,
492,
12002,
3912,
272,
687,
2863,
492,
1852,
63,
2227,
63,
2219,
272
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
221,
23820,
774,
15,
3476,
15,
396,
63,
8461,
3912,
14,
647,
26,
23820,
13,
396,
367,
314,
12002,
13,
3912,
2631,
805,
199,
3,
199,
3,
27694,
315,
9079,
701,
577,
3316,
685,
445,
14,
491,
390,
5193,
605,
836,
665,
68,
29382,
32,
68,
29382,
14,
846,
30,
199,
3,
199,
3,
7819,
389,
199,
3,
710,
4072,
402,
642,
570,
787,
29711,
370,
314,
4575,
2881,
14,
221,
4005,
199,
3,
314,
13675,
626,
477,
21171,
370,
314,
4575,
2881,
365,
440,
2808,
12,
199,
3,
4036,
368,
365,
10009,
282,
6701,
13062,
12,
1126,
321,
1688,
12,
882,
89,
13248,
13,
4624,
12,
199,
3,
2222,
13,
12730,
4190,
370,
26511,
1006,
4481,
4568,
543,
314,
199,
3,
4072,
402,
642,
570,
367,
1263,
12016,
4052,
1152,
5907,
14,
199,
3,
3091,
4481,
787,
4644,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
199,
3,
7168,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
199,
3,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
13229,
14,
1621,
4825,
6461,
7000,
2334,
10610,
1549,
5877,
8164,
199,
3,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
7061,
1621,
1261,
199,
3,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
5738,
1634,
1549,
1621,
199,
3,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
199,
3,
4141,
14,
199,
3,
7819,
389,
199,
199,
624,
12887,
13,
396,
5241,
367,
18855,
14,
3476,
14,
8461,
3912,
624,
199,
199,
363,
5792,
363,
275,
7880,
1304,
17351,
199,
199,
646,
2882,
199,
504,
18855,
14,
9562,
14,
647,
19,
5819,
492,
627,
199,
199,
533,
29095,
8461,
3912,
774,
8,
2796,
14,
1746,
304,
272,
347,
29779,
8,
277,
304,
267,
408,
8461,
3912,
26,
10574,
15,
24224,
603,
17587,
511,
624,
267,
687,
18855,
14,
3476,
492,
12002,
3912,
267,
10136,
275,
330,
10194,
8,
16,
88,
383,
9,
627,
334,
7727,
10,
7727,
9,
398,
394,
275,
12002,
3912,
14,
1222,
8,
4250,
9,
267,
367,
284,
315,
4945,
8,
27176,
304,
288,
394,
14,
873,
8,
4250,
9,
398,
327,
961,
511,
5477,
365,
687,
1611,
17134,
1159,
2269,
511,
576,
14,
647,
570,
14,
267,
291,
14,
629,
360,
25,
645,
696,
24,
69,
24,
67,
1081,
1797,
1046,
2481,
1407,
70,
2182,
371,
4361,
22,
3776,
2576,
1789,
379,
67,
2898,
1349,
69,
350,
1257,
1400,
1703,
1355,
70,
1887,
68,
2055,
1367,
68,
14787,
297,
394,
14,
11453,
1012,
327,
10574,
603,
17587,
398,
367,
284,
315,
4945,
8,
24,
304,
288,
394,
14,
873,
8,
4250,
9,
398,
327,
961,
511,
5477,
365,
687,
1611,
17134,
1159,
2269,
511,
576,
14,
647,
570,
14,
267,
291,
14,
629,
360,
32706,
2869,
350,
31550,
66,
1194,
6683,
25,
68,
771,
21,
65,
1400,
30441,
17760,
2592,
21,
66,
24,
70,
17,
66,
24,
66,
1465,
70,
1216,
1355,
1703,
2481,
67,
19,
2829,
23,
2025,
69,
23,
667,
22,
69,
297,
394,
14,
11453,
1012,
327,
959,
1165,
603,
17587,
199,
199,
318,
664,
63,
2219,
8,
888,
16420,
272,
327,
1379,
11102,
687,
481,
12346,
18787,
13576,
13,
18,
272,
327,
961,
365,
282,
769,
402,
334,
2062,
63,
1099,
12,
1324,
14675,
1369,
566,
6346,
14,
272,
511,
63,
576,
275,
359,
267,
327,
481,
12346,
18787,
13576,
13,
18,
12,
699,
14,
17,
446,
298,
4395,
13,
3142,
6430,
2,
267,
661,
2470,
2277,
975,
4361,
24,
70,
614,
67,
29838,
25250,
10037,
271,
21,
9747,
1081,
1789,
66,
383,
15702,
65,
1355,
2976,
1138,
65,
25,
2894,
24781,
556,
2976,
70,
1840,
1046,
350,
297,
288,
283,
3175,
659,
398,
327,
481,
12346,
18787,
13576,
13,
18,
12,
699,
14,
18,
446,
298,
3947,
13,
3142,
6430,
2,
267,
661,
11242,
68,
22,
65,
2976,
68,
11089,
1703,
66,
24,
69,
21,
67,
996,
1876,
1216,
67,
19,
69,
2259,
1355,
65,
1153,
301,
28976,
772,
556,
9669,
23,
70,
22,
69,
301,
617,
25230,
697,
1690,
67,
17,
297,
288,
283,
3175,
16845,
7778,
318,
318,
303,
70,
3561,
70,
3561,
2056,
7879,
5812,
17421,
7879,
9503,
74,
9503,
3880,
14344,
7530,
10344,
676,
20443,
20443,
81,
659,
398,
327,
481,
12346,
18787,
13576,
13,
18,
12,
699,
14,
19,
446,
298,
9551,
6430,
2,
267,
661,
25193,
2114,
69,
21,
67,
1020,
1079,
4675,
25,
16263,
65,
17,
67,
23,
69,
10681,
68,
2898,
69,
1822,
70,
1085,
1643,
65,
2006,
65,
19180,
1840,
69,
13702,
68,
1355,
19504,
3172,
713,
2866,
16,
297,
288,
283,
65,
7,
627,
1616,
538,
22,
12,
1467,
5522,
65,
2,
627,
1616,
538,
22,
659,
398,
327,
1379,
367,
376,
2269,
1611,
17134,
6519,
14,
267,
661,
70,
23,
2592,
9570,
65,
19,
67,
23,
2025,
301,
23,
556,
1644,
70,
10156,
18,
67,
2036,
969,
350,
2055,
2006,
66,
23,
70,
1153,
70,
1780,
69,
21,
69,
18,
2470,
3172,
69,
1789,
4489,
15490,
68,
8845,
297,
288,
283,
2765,
1245,
365,
28334,
590,
12766,
2783,
1846,
12,
370,
511,
282,
6519,
3130,
288,
283,
4625,
275,
12766,
334,
1494,
5049,
11218,
398,
327,
5679,
687,
1455,
921,
271,
14,
13961,
14,
1308,
15,
6797,
15,
24117,
63,
3476,
63,
11570,
267,
661,
69,
19,
66,
16,
67,
1602,
12877,
3003,
17,
67,
10721,
2756,
4361,
20,
67,
24,
14140,
4675,
30666,
1465,
3624,
2953,
69,
20,
11228,
66,
30391,
696,
20384,
18411,
66,
2277,
2528,
66,
12593,
297,
9929,
398,
661,
68,
708,
66,
15085,
2866,
17,
66,
2534,
68,
28976,
69,
23,
16319,
2871,
70,
20,
66,
821,
68,
8255,
70,
13643,
67,
25,
70,
969,
10721,
19446,
66,
23199,
12668,
1780,
10642,
969,
70,
24,
297,
268,
283,
38,
1312,
90,
1335,
643,
84,
3416,
20817,
575,
6215,
809,
758,
6271,
320,
4081,
30174,
73,
26923,
366,
300,
335,
29434,
27569,
659,
272,
1622,
339,
687,
18855,
14,
3476,
492,
12002,
3912,
272,
687,
2863,
492,
1852,
63,
2227,
63,
2219,
272,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Evervolv/android_external_protobuf
|
examples/list_people.py
|
429
|
1135
|
#! /usr/bin/python
# See README.txt for information and build instructions.
import addressbook_pb2
import sys
# Iterates though all people in the AddressBook and prints info about them.
def ListPeople(address_book):
for person in address_book.person:
print "Person ID:", person.id
print " Name:", person.name
if person.HasField('email'):
print " E-mail address:", person.email
for phone_number in person.phone:
if phone_number.type == addressbook_pb2.Person.MOBILE:
print " Mobile phone #:",
elif phone_number.type == addressbook_pb2.Person.HOME:
print " Home phone #:",
elif phone_number.type == addressbook_pb2.Person.WORK:
print " Work phone #:",
print phone_number.number
# Main procedure: Reads the entire address book from a file and prints all
# the information inside.
if len(sys.argv) != 2:
print "Usage:", sys.argv[0], "ADDRESS_BOOK_FILE"
sys.exit(-1)
address_book = addressbook_pb2.AddressBook()
# Read the existing address book.
f = open(sys.argv[1], "rb")
address_book.ParseFromString(f.read())
f.close()
ListPeople(address_book)
|
bsd-3-clause
|
[
3168,
1182,
2647,
15,
1393,
15,
1548,
199,
199,
3,
1666,
27781,
14,
2424,
367,
2556,
436,
1900,
15794,
14,
199,
199,
646,
2287,
2706,
63,
3317,
18,
199,
646,
984,
199,
199,
3,
11953,
2335,
10617,
1006,
13135,
315,
314,
9906,
8696,
436,
14767,
2256,
3595,
3062,
14,
199,
318,
3820,
8070,
7939,
8,
1562,
63,
2706,
304,
523,
367,
4954,
315,
2287,
63,
2706,
14,
5484,
26,
272,
870,
298,
7344,
2870,
6783,
4954,
14,
344,
272,
870,
298,
221,
2812,
6783,
4954,
14,
354,
272,
340,
4954,
14,
19416,
360,
2123,
735,
489,
870,
298,
221,
662,
13,
1198,
2287,
6783,
4954,
14,
2123,
339,
367,
14617,
63,
1955,
315,
4954,
14,
9339,
26,
489,
340,
14617,
63,
1955,
14,
466,
508,
2287,
2706,
63,
3317,
18,
14,
7344,
14,
2679,
34,
8453,
26,
267,
870,
298,
221,
29724,
14617,
6079,
401,
489,
916,
14617,
63,
1955,
14,
466,
508,
2287,
2706,
63,
3317,
18,
14,
7344,
14,
9524,
26,
267,
870,
298,
221,
14621,
14617,
6079,
401,
489,
916,
14617,
63,
1955,
14,
466,
508,
2287,
2706,
63,
3317,
18,
14,
7344,
14,
8406,
26,
267,
870,
298,
221,
9361,
14617,
6079,
401,
489,
870,
14617,
63,
1955,
14,
1955,
199,
199,
3,
11298,
17782,
26,
221,
26129,
314,
8039,
2287,
6719,
687,
282,
570,
436,
14767,
1006,
199,
3,
257,
314,
2556,
6272,
14,
199,
692,
822,
8,
1274,
14,
3020,
9,
1137,
499,
26,
523,
870,
298,
7692,
6783,
984,
14,
3020,
59,
16,
467,
298,
12368,
63,
21155,
63,
3817,
2,
523,
984,
14,
2224,
2801,
17,
9,
199,
199,
1562,
63,
2706,
275,
2287,
2706,
63,
3317,
18,
14,
1476,
8696,
342,
199,
199,
3,
5574,
314,
3411,
2287,
6719,
14,
199,
70,
275,
1551,
8,
1274,
14,
3020,
59,
17,
467,
298,
4848,
531,
199,
1562,
63,
2706,
14,
28685,
8,
70,
14,
739,
1012,
199,
70,
14,
1600,
342,
199,
199,
1296,
8070,
7939,
8,
1562,
63,
2706,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1182,
2647,
15,
1393,
15,
1548,
199,
199,
3,
1666,
27781,
14,
2424,
367,
2556,
436,
1900,
15794,
14,
199,
199,
646,
2287,
2706,
63,
3317,
18,
199,
646,
984,
199,
199,
3,
11953,
2335,
10617,
1006,
13135,
315,
314,
9906,
8696,
436,
14767,
2256,
3595,
3062,
14,
199,
318,
3820,
8070,
7939,
8,
1562,
63,
2706,
304,
523,
367,
4954,
315,
2287,
63,
2706,
14,
5484,
26,
272,
870,
298,
7344,
2870,
6783,
4954,
14,
344,
272,
870,
298,
221,
2812,
6783,
4954,
14,
354,
272,
340,
4954,
14,
19416,
360,
2123,
735,
489,
870,
298,
221,
662,
13,
1198,
2287,
6783,
4954,
14,
2123,
339,
367,
14617,
63,
1955,
315,
4954,
14,
9339,
26,
489,
340,
14617,
63,
1955,
14,
466,
508,
2287,
2706,
63,
3317,
18,
14,
7344,
14,
2679,
34,
8453,
26,
267,
870,
298,
221,
29724,
14617,
6079,
401,
489,
916,
14617,
63,
1955,
14,
466,
508,
2287,
2706,
63,
3317,
18,
14,
7344,
14,
9524,
26,
267,
870,
298,
221,
14621,
14617,
6079,
401,
489,
916,
14617,
63,
1955,
14,
466,
508,
2287,
2706,
63,
3317,
18,
14,
7344,
14,
8406,
26,
267,
870,
298,
221,
9361,
14617,
6079,
401,
489,
870,
14617,
63,
1955,
14,
1955,
199,
199,
3,
11298,
17782,
26,
221,
26129,
314,
8039,
2287,
6719,
687,
282,
570,
436,
14767,
1006,
199,
3,
257,
314,
2556,
6272,
14,
199,
692,
822,
8,
1274,
14,
3020,
9,
1137,
499,
26,
523,
870,
298,
7692,
6783,
984,
14,
3020,
59,
16,
467,
298,
12368,
63,
21155,
63,
3817,
2,
523,
984,
14,
2224,
2801,
17,
9,
199,
199,
1562,
63,
2706,
275,
2287,
2706,
63,
3317,
18,
14,
1476,
8696,
342,
199,
199,
3,
5574,
314,
3411,
2287,
6719,
14,
199,
70,
275,
1551,
8,
1274,
14,
3020,
59,
17,
467,
298,
4848,
531,
199,
1562,
63,
2706,
14,
28685,
8,
70,
14,
739,
1012,
199,
70,
14,
1600,
342,
199,
199,
1296,
8070,
7939,
8,
1562,
63,
2706,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of The Linux Foundation nor
# the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Build the kernel for all targets using the Android build environment.
from collections import namedtuple
import glob
from optparse import OptionParser
import os
import re
import shutil
import subprocess
import sys
import threading
import Queue
version = 'build-all.py, version 1.99'
build_dir = '../all-kernels'
make_command = ["vmlinux", "modules", "dtbs"]
all_options = {}
compile64 = os.environ.get('CROSS_COMPILE64')
def error(msg):
sys.stderr.write("error: %s\n" % msg)
def fail(msg):
"""Fail with a user-printed message"""
error(msg)
sys.exit(1)
if not os.environ.get('CROSS_COMPILE'):
fail("CROSS_COMPILE must be set in the environment")
def check_kernel():
"""Ensure that PWD is a kernel directory"""
if (not os.path.isfile('MAINTAINERS') or
not os.path.isfile('arch/arm/mach-msm/Kconfig')):
fail("This doesn't seem to be an MSM kernel dir")
def check_build():
"""Ensure that the build directory is present."""
if not os.path.isdir(build_dir):
try:
os.makedirs(build_dir)
except OSError as exc:
if exc.errno == errno.EEXIST:
pass
else:
raise
def build_threads():
"""Determine the number of build threads requested by the user"""
if all_options.load_average:
return all_options.load_average
return all_options.jobs or 1
failed_targets = []
BuildResult = namedtuple('BuildResult', ['status', 'messages'])
class BuildSequence(namedtuple('BuildSequence', ['log_name', 'short_name', 'steps'])):
def set_width(self, width):
self.width = width
def __enter__(self):
self.log = open(self.log_name, 'w')
def __exit__(self, type, value, traceback):
self.log.close()
def run(self):
self.status = None
messages = ["Building: " + self.short_name]
def printer(line):
text = "[%-*s] %s" % (self.width, self.short_name, line)
messages.append(text)
self.log.write(text)
self.log.write('\n')
for step in self.steps:
st = step.run(printer)
if st:
self.status = BuildResult(self.short_name, messages)
break
if not self.status:
self.status = BuildResult(None, messages)
class BuildTracker:
"""Manages all of the steps necessary to perform a build. The
build consists of one or more sequences of steps. The different
sequences can be processed independently, while the steps within a
sequence must be done in order."""
def __init__(self):
self.sequence = []
self.lock = threading.Lock()
def add_sequence(self, log_name, short_name, steps):
self.sequence.append(BuildSequence(log_name, short_name, steps))
def longest_name(self):
longest = 0
for seq in self.sequence:
longest = max(longest, len(seq.short_name))
return longest
def __repr__(self):
return "BuildTracker(%s)" % self.sequence
def run_child(self, seq):
seq.set_width(self.longest)
tok = self.build_tokens.get()
with self.lock:
print "Building:", seq.short_name
with seq:
seq.run()
self.results.put(seq.status)
self.build_tokens.put(tok)
def run(self):
self.longest = self.longest_name()
self.results = Queue.Queue()
children = []
errors = []
self.build_tokens = Queue.Queue()
nthreads = build_threads()
print "Building with", nthreads, "threads"
for i in range(nthreads):
self.build_tokens.put(True)
for seq in self.sequence:
child = threading.Thread(target=self.run_child, args=[seq])
children.append(child)
child.start()
for child in children:
stats = self.results.get()
if all_options.verbose:
with self.lock:
for line in stats.messages:
print line
sys.stdout.flush()
if stats.status:
errors.append(stats.status)
for child in children:
child.join()
if errors:
fail("\n ".join(["Failed targets:"] + errors))
class PrintStep:
"""A step that just prints a message"""
def __init__(self, message):
self.message = message
def run(self, outp):
outp(self.message)
class MkdirStep:
"""A step that makes a directory"""
def __init__(self, direc):
self.direc = direc
def run(self, outp):
outp("mkdir %s" % self.direc)
os.mkdir(self.direc)
class RmtreeStep:
def __init__(self, direc):
self.direc = direc
def run(self, outp):
outp("rmtree %s" % self.direc)
shutil.rmtree(self.direc, ignore_errors=True)
class CopyfileStep:
def __init__(self, src, dest):
self.src = src
self.dest = dest
def run(self, outp):
outp("cp %s %s" % (self.src, self.dest))
shutil.copyfile(self.src, self.dest)
class ExecStep:
def __init__(self, cmd, **kwargs):
self.cmd = cmd
self.kwargs = kwargs
def run(self, outp):
outp("exec: %s" % (" ".join(self.cmd),))
with open('/dev/null', 'r') as devnull:
proc = subprocess.Popen(self.cmd, stdin=devnull,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
**self.kwargs)
stdout = proc.stdout
while True:
line = stdout.readline()
if not line:
break
line = line.rstrip('\n')
outp(line)
result = proc.wait()
if result != 0:
return ('error', result)
else:
return None
class Builder():
def __init__(self, name, defconfig):
self.name = name
self.defconfig = defconfig
self.confname = self.defconfig.split('/')[-1]
# Determine if this is a 64-bit target based on the location
# of the defconfig.
self.make_env = os.environ.copy()
if "/arm64/" in defconfig:
if compile64:
self.make_env['CROSS_COMPILE'] = compile64
else:
fail("Attempting to build 64-bit, without setting CROSS_COMPILE64")
self.make_env['ARCH'] = 'arm64'
else:
self.make_env['ARCH'] = 'arm'
self.make_env['KCONFIG_NOTIMESTAMP'] = 'true'
self.log_name = "%s/log-%s.log" % (build_dir, self.name)
def build(self):
steps = []
dest_dir = os.path.join(build_dir, self.name)
log_name = "%s/log-%s.log" % (build_dir, self.name)
steps.append(PrintStep('Building %s in %s log %s' %
(self.name, dest_dir, log_name)))
if not os.path.isdir(dest_dir):
steps.append(MkdirStep(dest_dir))
defconfig = self.defconfig
dotconfig = '%s/.config' % dest_dir
savedefconfig = '%s/defconfig' % dest_dir
staging_dir = 'install_staging'
modi_dir = '%s' % staging_dir
hdri_dir = '%s/usr' % staging_dir
steps.append(RmtreeStep(os.path.join(dest_dir, staging_dir)))
steps.append(ExecStep(['make', 'O=%s' % dest_dir,
self.confname], env=self.make_env))
if not all_options.updateconfigs:
# Build targets can be dependent upon the completion of
# previous build targets, so build them one at a time.
cmd_line = ['make',
'INSTALL_HDR_PATH=%s' % hdri_dir,
'INSTALL_MOD_PATH=%s' % modi_dir,
'O=%s' % dest_dir]
build_targets = []
for c in make_command:
if re.match(r'^-{1,2}\w', c):
cmd_line.append(c)
else:
build_targets.append(c)
for t in build_targets:
steps.append(ExecStep(cmd_line + [t], env=self.make_env))
# Copy the defconfig back.
if all_options.configs or all_options.updateconfigs:
steps.append(ExecStep(['make', 'O=%s' % dest_dir,
'savedefconfig'], env=self.make_env))
steps.append(CopyfileStep(savedefconfig, defconfig))
return steps
def update_config(file, str):
print 'Updating %s with \'%s\'\n' % (file, str)
with open(file, 'a') as defconfig:
defconfig.write(str + '\n')
def scan_configs():
"""Get the full list of defconfigs appropriate for this tree."""
names = []
arch_pats = (
r'[fm]sm[0-9]*_defconfig',
r'apq*_defconfig',
r'qsd*_defconfig',
r'mdm*_defconfig',
r'mpq*_defconfig',
)
arch64_pats = (
r'msm*_defconfig',
)
for p in arch_pats:
for n in glob.glob('arch/arm/configs/' + p):
name = os.path.basename(n)[:-10]
names.append(Builder(name, n))
if 'CROSS_COMPILE64' in os.environ:
for p in arch64_pats:
for n in glob.glob('arch/arm64/configs/' + p):
name = os.path.basename(n)[:-10] + "-64"
names.append(Builder(name, n))
return names
def build_many(targets):
print "Building %d target(s)" % len(targets)
# If we are requesting multiple builds, divide down the job number
# to construct the make_command, giving it a floor of 2, so there
# is still some parallelism.
if all_options.jobs and all_options.jobs > 1:
j = max(all_options.jobs / len(targets), 2)
make_command.append("-j" + str(j))
tracker = BuildTracker()
for target in targets:
if all_options.updateconfigs:
update_config(target.defconfig, all_options.updateconfigs)
steps = target.build()
tracker.add_sequence(target.log_name, target.name, steps)
tracker.run()
def main():
global make_command
check_kernel()
check_build()
configs = scan_configs()
usage = ("""
%prog [options] all -- Build all targets
%prog [options] target target ... -- List specific targets
%prog [options] perf -- Build all perf targets
%prog [options] noperf -- Build all non-perf targets""")
parser = OptionParser(usage=usage, version=version)
parser.add_option('--configs', action='store_true',
dest='configs',
help="Copy configs back into tree")
parser.add_option('--list', action='store_true',
dest='list',
help='List available targets')
parser.add_option('-v', '--verbose', action='store_true',
dest='verbose',
help='Output to stdout in addition to log file')
parser.add_option('--oldconfig', action='store_true',
dest='oldconfig',
help='Only process "make oldconfig"')
parser.add_option('--updateconfigs',
dest='updateconfigs',
help="Update defconfigs with provided option setting, "
"e.g. --updateconfigs=\'CONFIG_USE_THING=y\'")
parser.add_option('-j', '--jobs', type='int', dest="jobs",
help="Number of simultaneous jobs")
parser.add_option('-l', '--load-average', type='int',
dest='load_average',
help="Don't start multiple jobs unless load is below LOAD_AVERAGE")
parser.add_option('-k', '--keep-going', action='store_true',
dest='keep_going', default=False,
help="Keep building other targets if a target fails")
parser.add_option('-m', '--make-target', action='append',
help='Build the indicated make target (default: %s)' %
' '.join(make_command))
(options, args) = parser.parse_args()
global all_options
all_options = options
if options.list:
print "Available targets:"
for target in configs:
print " %s" % target.name
sys.exit(0)
if options.oldconfig:
make_command = ["oldconfig"]
elif options.make_target:
make_command = options.make_target
if args == ['all']:
build_many(configs)
elif args == ['perf']:
targets = []
for t in configs:
if "perf" in t.name:
targets.append(t)
build_many(targets)
elif args == ['noperf']:
targets = []
for t in configs:
if "perf" not in t.name:
targets.append(t)
build_many(targets)
elif len(args) > 0:
all_configs = {}
for t in configs:
all_configs[t.name] = t
targets = []
for t in args:
if t not in all_configs:
parser.error("Target '%s' not one of %s" % (t, all_configs.keys()))
targets.append(all_configs[t])
build_many(targets)
else:
parser.error("Must specify a target to build, or 'all'")
if __name__ == "__main__":
main()
|
gpl-2.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
334,
67,
9,
8937,
13,
7280,
12,
710,
10130,
2752,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
755,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
710,
10130,
2752,
6590,
199,
3,
755,
314,
1561,
402,
2399,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
199,
3,
755,
7585,
7131,
687,
642,
2032,
1928,
2488,
6791,
5313,
199,
3,
755,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
199,
3,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
199,
3,
5292,
2990,
1634,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
11214,
13,
12799,
9315,
9706,
14,
221,
1621,
4825,
6461,
7000,
2334,
5877,
11489,
1549,
199,
3,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
199,
3,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
199,
3,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
199,
3,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
199,
3,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
199,
3,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
3,
6516,
314,
5114,
367,
1006,
4545,
1808,
314,
14694,
1900,
3734,
14,
199,
199,
504,
5055,
492,
12863,
199,
646,
5739,
199,
504,
8691,
492,
13491,
199,
646,
747,
199,
646,
295,
199,
646,
5145,
199,
646,
3873,
199,
646,
984,
199,
646,
5796,
199,
646,
10703,
199,
199,
1023,
275,
283,
1506,
13,
452,
14,
647,
12,
1015,
413,
14,
1020,
7,
199,
199,
1506,
63,
694,
275,
20644,
452,
13,
29824,
7,
199,
1875,
63,
1531,
275,
2097,
2611,
5135,
401,
298,
3112,
401,
298,
3583,
1533,
937,
199,
452,
63,
1419,
275,
1052,
199,
2014,
772,
275,
747,
14,
2314,
14,
362,
360,
28368,
63,
29911,
772,
358,
199,
199,
318,
1125,
8,
1328,
304,
272,
984,
14,
3083,
14,
952,
480,
705,
26,
450,
83,
60,
78,
2,
450,
1499,
9,
199,
199,
318,
2449,
8,
1328,
304,
272,
408,
4874,
543,
282,
922,
13,
27131,
1245,
624,
272,
1125,
8,
1328,
9,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
692,
440,
747,
14,
2314,
14,
362,
360,
28368,
63,
29911,
735,
272,
2449,
480,
28368,
63,
29911,
1471,
506,
663,
315,
314,
3734,
531,
199,
199,
318,
1104,
63,
4989,
837,
272,
408,
13913,
626,
510,
16698,
365,
282,
5114,
2082,
624,
272,
340,
334,
1397,
747,
14,
515,
14,
6292,
360,
2054,
2919,
9021,
3960,
358,
503,
267,
440,
747,
14,
515,
14,
6292,
360,
1047,
15,
5362,
15,
14121,
13,
706,
77,
15,
28033,
8109,
267,
2449,
480,
2765,
3181,
1133,
17021,
370,
506,
376,
603,
4029,
5114,
2935,
531,
199,
199,
318,
1104,
63,
1506,
837,
272,
408,
13913,
626,
314,
1900,
2082,
365,
3451,
1041,
272,
340,
440,
747,
14,
515,
14,
6027,
8,
1506,
63,
694,
304,
267,
862,
26,
288,
747,
14,
8347,
8,
1506,
63,
694,
9,
267,
871,
6440,
465,
3178,
26,
288,
340,
3178,
14,
7931,
508,
7554,
14,
28596,
26,
355,
986,
288,
587,
26,
355,
746,
199,
199,
318,
1900,
63,
6962,
837,
272,
408,
21767,
314,
1329,
402,
1900,
7183,
5839,
701,
314,
922,
624,
272,
340,
1006,
63,
1419,
14,
912,
63,
8536,
26,
267,
372,
1006,
63,
1419,
14,
912,
63,
8536,
272,
372,
1006,
63,
1419,
14,
6920,
503,
413,
199,
199,
4892,
63,
4684,
275,
942,
199,
199,
3425,
2889,
275,
12863,
360,
3425,
2889,
297,
788,
1205,
297,
283,
3431,
1105,
199,
199,
533,
6516,
5826,
8,
18921,
360,
3425,
5826,
297,
788,
793,
63,
354,
297,
283,
3612,
63,
354,
297,
283,
5895,
26536,
339,
347,
663,
63,
2063,
8,
277,
12,
3462,
304,
267,
291,
14,
2063,
275,
3462,
339,
347,
636,
4200,
721,
277,
304,
267,
291,
14,
793,
275,
1551,
8,
277,
14,
793,
63,
354,
12,
283,
87,
358,
272,
347,
636,
2224,
721,
277,
12,
730,
12,
574,
12,
5190,
304,
267,
291,
14,
793,
14,
1600,
342,
339,
347,
1255,
8,
277,
304,
267,
291,
14,
1205,
275,
488,
267,
3788,
275,
2097,
16461,
26,
298,
435,
291,
14,
3612,
63,
354,
61,
267,
347,
16639,
8,
604,
304,
288,
1318,
275,
26503,
13,
10,
83,
61,
450,
83,
2,
450,
334,
277,
14,
2063,
12,
291,
14,
3612,
63,
354,
12,
1004,
9,
288,
3788,
14,
740,
8,
505,
9,
288,
291,
14,
793,
14,
952,
8,
505,
9,
288,
291,
14,
793,
14,
952,
2258,
78,
358,
267,
367,
3650,
315,
291,
14,
5895,
26,
288,
410,
275,
3650,
14,
1065,
8,
11835,
9,
288,
340,
410,
26,
355,
291,
14,
1205,
275,
6516,
2889,
8,
277,
14,
3612,
63,
354,
12,
3788,
9,
355,
2059,
267,
340,
440,
291,
14,
1205,
26,
288,
291,
14,
1205,
275,
6516,
2889,
8,
403,
12,
3788,
9,
199,
199,
533,
6516,
13652,
26,
272,
408,
2395,
7441,
1006,
402,
314,
7124,
5784,
370,
5147,
282,
1900,
14,
221,
710,
272,
1900,
18581,
402,
1373,
503,
1655,
8013,
402,
7124,
14,
221,
710,
3365,
272,
8013,
883,
506,
7686,
30426,
12,
1830,
314,
7124,
4453,
282,
272,
3414,
1471,
506,
4224,
315,
1865,
1041,
339,
347,
636,
826,
721,
277
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
334,
67,
9,
8937,
13,
7280,
12,
710,
10130,
2752,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
755,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
710,
10130,
2752,
6590,
199,
3,
755,
314,
1561,
402,
2399,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
199,
3,
755,
7585,
7131,
687,
642,
2032,
1928,
2488,
6791,
5313,
199,
3,
755,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
199,
3,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
199,
3,
5292,
2990,
1634,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
11214,
13,
12799,
9315,
9706,
14,
221,
1621,
4825,
6461,
7000,
2334,
5877,
11489,
1549,
199,
3,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
199,
3,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
199,
3,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
199,
3,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
199,
3,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
199,
3,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
3,
6516,
314,
5114,
367,
1006,
4545,
1808,
314,
14694,
1900,
3734,
14,
199,
199,
504,
5055,
492,
12863,
199,
646,
5739,
199,
504,
8691,
492,
13491,
199,
646,
747,
199,
646,
295,
199,
646,
5145,
199,
646,
3873,
199,
646,
984,
199,
646,
5796,
199,
646,
10703,
199,
199,
1023,
275,
283,
1506,
13,
452,
14,
647,
12,
1015,
413,
14,
1020,
7,
199,
199,
1506,
63,
694,
275,
20644,
452,
13,
29824,
7,
199,
1875,
63,
1531,
275,
2097,
2611,
5135,
401,
298,
3112,
401,
298,
3583,
1533,
937,
199,
452,
63,
1419,
275,
1052,
199,
2014,
772,
275,
747,
14,
2314,
14,
362,
360,
28368,
63,
29911,
772,
358,
199,
199,
318,
1125,
8,
1328,
304,
272,
984,
14,
3083,
14,
952,
480,
705,
26,
450,
83,
60,
78,
2,
450,
1499,
9,
199,
199,
318,
2449,
8,
1328,
304,
272,
408,
4874,
543,
282,
922,
13,
27131,
1245,
624,
272,
1125,
8,
1328,
9,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
692,
440,
747,
14,
2314,
14,
362,
360,
28368,
63,
29911,
735,
272,
2449,
480,
28368,
63,
29911,
1471,
506,
663,
315,
314,
3734,
531,
199,
199,
318,
1104,
63,
4989,
837,
272,
408,
13913,
626,
510,
16698,
365,
282,
5114,
2082,
624,
272,
340,
334,
1397,
747,
14,
515,
14,
6292,
360,
2054,
2919,
9021,
3960,
358,
503,
267,
440,
747,
14,
515,
14,
6292,
360,
1047,
15,
5362,
15,
14121,
13,
706,
77,
15,
28033,
8109,
267,
2449,
480,
2765,
3181,
1133,
17021,
370,
506,
376,
603,
4029,
5114,
2935,
531,
199,
199,
318,
1104,
63,
1506,
837,
272,
408,
13913,
626,
314,
1900,
2082,
365,
3451,
1041,
272,
340,
440,
747,
14,
515,
14,
6027,
8,
1506,
63,
694,
304,
267,
862,
26,
288,
747,
14,
8347,
8,
1506,
63,
694,
9,
267,
871,
6440,
465,
3178,
26,
288,
340,
3178,
14,
7931,
508,
7554,
14,
28596,
26,
355,
986,
288,
587,
26,
355,
746,
199,
199,
318,
1900,
63,
6962,
837,
272,
408,
21767,
314,
1329,
402,
1900,
7183,
5839,
701,
314,
922,
624,
272,
340,
1006,
63,
1419,
14,
912,
63,
8536,
26,
267,
372,
1006,
63,
1419,
14,
912,
63,
8536,
272,
372,
1006,
63,
1419,
14,
6920,
503,
413,
199,
199,
4892,
63,
4684,
275,
942,
199,
199,
3425,
2889,
275,
12863,
360,
3425,
2889,
297,
788,
1205,
297,
283,
3431,
1105,
199,
199,
533,
6516,
5826,
8,
18921,
360,
3425,
5826,
297,
788,
793,
63,
354,
297,
283,
3612,
63,
354,
297,
283,
5895,
26536,
339,
347,
663,
63,
2063,
8,
277,
12,
3462,
304,
267,
291,
14,
2063,
275,
3462,
339,
347,
636,
4200,
721,
277,
304,
267,
291,
14,
793,
275,
1551,
8,
277,
14,
793,
63,
354,
12,
283,
87,
358,
272,
347,
636,
2224,
721,
277,
12,
730,
12,
574,
12,
5190,
304,
267,
291,
14,
793,
14,
1600,
342,
339,
347,
1255,
8,
277,
304,
267,
291,
14,
1205,
275,
488,
267,
3788,
275,
2097,
16461,
26,
298,
435,
291,
14,
3612,
63,
354,
61,
267,
347,
16639,
8,
604,
304,
288,
1318,
275,
26503,
13,
10,
83,
61,
450,
83,
2,
450,
334,
277,
14,
2063,
12,
291,
14,
3612,
63,
354,
12,
1004,
9,
288,
3788,
14,
740,
8,
505,
9,
288,
291,
14,
793,
14,
952,
8,
505,
9,
288,
291,
14,
793,
14,
952,
2258,
78,
358,
267,
367,
3650,
315,
291,
14,
5895,
26,
288,
410,
275,
3650,
14,
1065,
8,
11835,
9,
288,
340,
410,
26,
355,
291,
14,
1205,
275,
6516,
2889,
8,
277,
14,
3612,
63,
354,
12,
3788,
9,
355,
2059,
267,
340,
440,
291,
14,
1205,
26,
288,
291,
14,
1205,
275,
6516,
2889,
8,
403,
12,
3788,
9,
199,
199,
533,
6516,
13652,
26,
272,
408,
2395,
7441,
1006,
402,
314,
7124,
5784,
370,
5147,
282,
1900,
14,
221,
710,
272,
1900,
18581,
402,
1373,
503,
1655,
8013,
402,
7124,
14,
221,
710,
3365,
272,
8013,
883,
506,
7686,
30426,
12,
1830,
314,
7124,
4453,
282,
272,
3414,
1471,
506,
4224,
315,
1865,
1041,
339,
347,
636,
826,
721,
277,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
MichaelReiter/ProgrammingPractice
|
DFS.py
|
1
|
1656
|
#!/usr/bin/env python
def dfs_iter(graph, start, path=[]):
"""
Iterative version of depth first search.
Arguments:
graph - a dictionary of lists that is your graph and who you're connected to.
start - the node you wish to start at
path - a list of already visited nodes for a path
Returns:
path - a list of strings that equal a valid path in the graph
"""
q=[start]
while q:
v = q.pop(0)
if v not in path:
path += [v]
q += graph[v]
return path
def dfs_rec(graph, start, path=[]):
"""
Recursive version of depth first search.
Arguments:
graph - a dictionary of lists that is your graph and who you're connected to.
start - the node you wish to start at
path - a list of already visited nodes for a path
Returns:
path - a list of strings that equal a valid path in the graph
"""
path = path + [start]
for node in graph[start]:
if not node in path:
path = dfs_rec(graph, node, path)
return path
def bfs_iter(graph, start, path=[]):
"""
Iterative version of breadth first search.
Arguments:
graph - a dictionary of lists that is your graph and who you're connected to.
start - the node you wish to start at
path - a list of already visited nodes for a path
Returns:
path - a list of strings that equal a valid path in the graph
"""
q=[start]
while q:
v = q.pop(0)
if not v in path:
path +=[v]
q += graph[v]
return path
if __name__ == '__main__':
graph = {'A':['B','C'],'B':['D','E'],'C':['D','E'],'D':['E'],'E':['A']}
print dfs_iter(graph, 'A')
print dfs_rec(graph, 'A')
print bfs_iter(graph, 'A')
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
318,
366,
2319,
63,
1661,
8,
2180,
12,
1343,
12,
931,
17894,
523,
408,
523,
473,
2967,
857,
1015,
402,
5818,
1642,
2754,
14,
523,
7628,
26,
272,
3343,
446,
282,
2600,
402,
5548,
626,
365,
2195,
3343,
436,
3963,
1265,
3984,
8539,
370,
14,
272,
1343,
446,
314,
1031,
1265,
13809,
370,
1343,
737,
272,
931,
446,
282,
769,
402,
2575,
15867,
3380,
367,
282,
931,
523,
1803,
26,
272,
931,
446,
282,
769,
402,
3326,
626,
4472,
282,
1686,
931,
315,
314,
3343,
523,
408,
523,
1894,
1524,
928,
61,
523,
1830,
1894,
26,
272,
373,
275,
1894,
14,
1935,
8,
16,
9,
272,
340,
373,
440,
315,
931,
26,
489,
931,
847,
359,
86,
61,
489,
1894,
847,
3343,
59,
86,
61,
523,
372,
931,
199,
199,
318,
366,
2319,
63,
2761,
8,
2180,
12,
1343,
12,
931,
17894,
523,
408,
523,
18306,
3398,
1015,
402,
5818,
1642,
2754,
14,
523,
7628,
26,
272,
3343,
446,
282,
2600,
402,
5548,
626,
365,
2195,
3343,
436,
3963,
1265,
3984,
8539,
370,
14,
272,
1343,
446,
314,
1031,
1265,
13809,
370,
1343,
737,
272,
931,
446,
282,
769,
402,
2575,
15867,
3380,
367,
282,
931,
523,
1803,
26,
272,
931,
446,
282,
769,
402,
3326,
626,
4472,
282,
1686,
931,
315,
314,
3343,
523,
408,
523,
931,
275,
931,
435,
359,
928,
61,
523,
367,
1031,
315,
3343,
59,
928,
2189,
272,
340,
440,
1031,
315,
931,
26,
489,
931,
275,
366,
2319,
63,
2761,
8,
2180,
12,
1031,
12,
931,
9,
523,
372,
931,
199,
199,
318,
330,
2319,
63,
1661,
8,
2180,
12,
1343,
12,
931,
17894,
523,
408,
523,
473,
2967,
857,
1015,
402,
330,
739,
273,
1642,
2754,
14,
523,
7628,
26,
272,
3343,
446,
282,
2600,
402,
5548,
626,
365,
2195,
3343,
436,
3963,
1265,
3984,
8539,
370,
14,
272,
1343,
446,
314,
1031,
1265,
13809,
370,
1343,
737,
272,
931,
446,
282,
769,
402,
2575,
15867,
3380,
367,
282,
931,
523,
1803,
26,
272,
931,
446,
282,
769,
402,
3326,
626,
4472,
282,
1686,
931,
315,
314,
3343,
523,
408,
523,
1894,
1524,
928,
61,
523,
1830,
1894,
26,
272,
373,
275,
1894,
14,
1935,
8,
16,
9,
272,
340,
440,
373,
315,
931,
26,
489,
931,
847,
59,
86,
61,
489,
1894,
847,
3343,
59,
86,
61,
523,
372,
931,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
3343,
275,
791,
33,
21662,
34,
1673,
35,
995,
7,
34,
21662,
36,
1673,
37,
995,
7,
35,
21662,
36,
1673,
37,
995,
7,
36,
21662,
37,
995,
7,
37,
21662,
33,
12074,
523,
870,
366,
2319,
63,
1661,
8,
2180,
12,
283,
33,
358,
819,
870,
366,
2319,
63,
2761,
8,
2180,
12,
283,
33,
358,
12244,
870,
330,
2319,
63,
1661,
8,
2180,
12,
283,
33,
358,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
318,
366,
2319,
63,
1661,
8,
2180,
12,
1343,
12,
931,
17894,
523,
408,
523,
473,
2967,
857,
1015,
402,
5818,
1642,
2754,
14,
523,
7628,
26,
272,
3343,
446,
282,
2600,
402,
5548,
626,
365,
2195,
3343,
436,
3963,
1265,
3984,
8539,
370,
14,
272,
1343,
446,
314,
1031,
1265,
13809,
370,
1343,
737,
272,
931,
446,
282,
769,
402,
2575,
15867,
3380,
367,
282,
931,
523,
1803,
26,
272,
931,
446,
282,
769,
402,
3326,
626,
4472,
282,
1686,
931,
315,
314,
3343,
523,
408,
523,
1894,
1524,
928,
61,
523,
1830,
1894,
26,
272,
373,
275,
1894,
14,
1935,
8,
16,
9,
272,
340,
373,
440,
315,
931,
26,
489,
931,
847,
359,
86,
61,
489,
1894,
847,
3343,
59,
86,
61,
523,
372,
931,
199,
199,
318,
366,
2319,
63,
2761,
8,
2180,
12,
1343,
12,
931,
17894,
523,
408,
523,
18306,
3398,
1015,
402,
5818,
1642,
2754,
14,
523,
7628,
26,
272,
3343,
446,
282,
2600,
402,
5548,
626,
365,
2195,
3343,
436,
3963,
1265,
3984,
8539,
370,
14,
272,
1343,
446,
314,
1031,
1265,
13809,
370,
1343,
737,
272,
931,
446,
282,
769,
402,
2575,
15867,
3380,
367,
282,
931,
523,
1803,
26,
272,
931,
446,
282,
769,
402,
3326,
626,
4472,
282,
1686,
931,
315,
314,
3343,
523,
408,
523,
931,
275,
931,
435,
359,
928,
61,
523,
367,
1031,
315,
3343,
59,
928,
2189,
272,
340,
440,
1031,
315,
931,
26,
489,
931,
275,
366,
2319,
63,
2761,
8,
2180,
12,
1031,
12,
931,
9,
523,
372,
931,
199,
199,
318,
330,
2319,
63,
1661,
8,
2180,
12,
1343,
12,
931,
17894,
523,
408,
523,
473,
2967,
857,
1015,
402,
330,
739,
273,
1642,
2754,
14,
523,
7628,
26,
272,
3343,
446,
282,
2600,
402,
5548,
626,
365,
2195,
3343,
436,
3963,
1265,
3984,
8539,
370,
14,
272,
1343,
446,
314,
1031,
1265,
13809,
370,
1343,
737,
272,
931,
446,
282,
769,
402,
2575,
15867,
3380,
367,
282,
931,
523,
1803,
26,
272,
931,
446,
282,
769,
402,
3326,
626,
4472,
282,
1686,
931,
315,
314,
3343,
523,
408,
523,
1894,
1524,
928,
61,
523,
1830,
1894,
26,
272,
373,
275,
1894,
14,
1935,
8,
16,
9,
272,
340,
440,
373,
315,
931,
26,
489,
931,
847,
59,
86,
61,
489,
1894,
847,
3343,
59,
86,
61,
523,
372,
931,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
3343,
275,
791,
33,
21662,
34,
1673,
35,
995,
7,
34,
21662,
36,
1673,
37,
995,
7,
35,
21662,
36,
1673,
37,
995,
7,
36,
21662,
37,
995,
7,
37,
21662,
33,
12074,
523,
870,
366,
2319,
63,
1661,
8,
2180,
12,
283,
33,
358,
819,
870,
366,
2319,
63,
2761,
8,
2180,
12,
283,
33,
358,
12244,
870,
330,
2319,
63,
1661,
8,
2180,
12,
283,
33,
358,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
konstruktoid/ansible-upstream
|
test/units/config/test_data.py
|
61
|
1274
|
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.compat.tests import unittest
from ansible.config.data import ConfigData
from ansible.config.manager import Setting
mykey = Setting('mykey', 'myvalue', 'test', 'string')
mykey2 = Setting('mykey2', 'myvalue2', ['test', 'test2'], 'list')
mykey3 = Setting('mykey3', 'myvalue3', 11111111111, 'integer')
class TestConfigData(unittest.TestCase):
def setUp(self):
self.cdata = ConfigData()
def tearDown(self):
self.cdata = None
def test_update_setting(self):
for setting in [mykey, mykey2, mykey3]:
self.cdata.update_setting(setting)
self.assertEqual(setting, self.cdata._global_settings.get(setting.name))
def test_update_setting_with_plugin(self):
pass
def test_get_setting(self):
self.cdata._global_settings = {'mykey': mykey}
self.assertEqual(mykey, self.cdata.get_setting('mykey'))
def test_get_settings(self):
all_settings = {'mykey': mykey, 'mykey2': mykey2}
self.cdata._global_settings = all_settings
for setting in self.cdata.get_settings():
self.assertEqual(all_settings[setting.name], setting)
|
gpl-3.0
|
[
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
5819,
14,
2219,
492,
2882,
199,
199,
504,
3242,
14,
888,
14,
576,
492,
4094,
1451,
199,
504,
3242,
14,
888,
14,
2609,
492,
13510,
421,
199,
1662,
498,
275,
13510,
360,
1662,
498,
297,
283,
1662,
585,
297,
283,
396,
297,
283,
875,
358,
199,
1662,
498,
18,
275,
13510,
360,
1662,
498,
18,
297,
283,
1662,
585,
18,
297,
788,
396,
297,
283,
396,
18,
995,
283,
513,
358,
199,
1662,
498,
19,
275,
13510,
360,
1662,
498,
19,
297,
283,
1662,
585,
19,
297,
413,
14757,
845,
12,
283,
4115,
358,
421,
199,
533,
1379,
2028,
1451,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
15892,
275,
4094,
1451,
342,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
15892,
275,
488,
339,
347,
511,
63,
873,
63,
6031,
8,
277,
304,
267,
367,
4260,
315,
359,
1662,
498,
12,
3002,
498,
18,
12,
3002,
498,
19,
2189,
288,
291,
14,
15892,
14,
873,
63,
6031,
8,
6031,
9,
288,
291,
14,
629,
8,
6031,
12,
291,
14,
15892,
423,
2966,
63,
1751,
14,
362,
8,
6031,
14,
354,
430,
339,
347,
511,
63,
873,
63,
6031,
63,
1045,
63,
2718,
8,
277,
304,
267,
986,
339,
347,
511,
63,
362,
63,
6031,
8,
277,
304,
267,
291,
14,
15892,
423,
2966,
63,
1751,
275,
791,
1662,
498,
356,
3002,
498,
93,
267,
291,
14,
629,
8,
1662,
498,
12,
291,
14,
15892,
14,
362,
63,
6031,
360,
1662,
498,
1333,
339,
347,
511,
63,
362,
63,
1751,
8,
277,
304,
267,
1006,
63,
1751,
275,
791,
1662,
498,
356,
3002,
498,
12,
283,
1662,
498,
18,
356,
3002,
498,
18,
93,
267,
291,
14,
15892,
423,
2966,
63,
1751,
275,
1006,
63,
1751,
398,
367,
4260,
315,
291,
14,
15892,
14,
362,
63,
1751,
837,
288,
291,
14,
629,
8,
452,
63,
1751,
59,
6031,
14,
354,
467,
4260,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
5819,
14,
2219,
492,
2882,
199,
199,
504,
3242,
14,
888,
14,
576,
492,
4094,
1451,
199,
504,
3242,
14,
888,
14,
2609,
492,
13510,
421,
199,
1662,
498,
275,
13510,
360,
1662,
498,
297,
283,
1662,
585,
297,
283,
396,
297,
283,
875,
358,
199,
1662,
498,
18,
275,
13510,
360,
1662,
498,
18,
297,
283,
1662,
585,
18,
297,
788,
396,
297,
283,
396,
18,
995,
283,
513,
358,
199,
1662,
498,
19,
275,
13510,
360,
1662,
498,
19,
297,
283,
1662,
585,
19,
297,
413,
14757,
845,
12,
283,
4115,
358,
421,
199,
533,
1379,
2028,
1451,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
15892,
275,
4094,
1451,
342,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
15892,
275,
488,
339,
347,
511,
63,
873,
63,
6031,
8,
277,
304,
267,
367,
4260,
315,
359,
1662,
498,
12,
3002,
498,
18,
12,
3002,
498,
19,
2189,
288,
291,
14,
15892,
14,
873,
63,
6031,
8,
6031,
9,
288,
291,
14,
629,
8,
6031,
12,
291,
14,
15892,
423,
2966,
63,
1751,
14,
362,
8,
6031,
14,
354,
430,
339,
347,
511,
63,
873,
63,
6031,
63,
1045,
63,
2718,
8,
277,
304,
267,
986,
339,
347,
511,
63,
362,
63,
6031,
8,
277,
304,
267,
291,
14,
15892,
423,
2966,
63,
1751,
275,
791,
1662,
498,
356,
3002,
498,
93,
267,
291,
14,
629,
8,
1662,
498,
12,
291,
14,
15892,
14,
362,
63,
6031,
360,
1662,
498,
1333,
339,
347,
511,
63,
362,
63,
1751,
8,
277,
304,
267,
1006,
63,
1751,
275,
791,
1662,
498,
356,
3002,
498,
12,
283,
1662,
498,
18,
356,
3002,
498,
18,
93,
267,
291,
14,
15892,
423,
2966,
63,
1751,
275,
1006,
63,
1751,
398,
367,
4260,
315,
291,
14,
15892,
14,
362,
63,
1751,
837,
288,
291,
14,
629,
8,
452,
63,
1751,
59,
6031,
14,
354,
467,
4260,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ActiveState/code
|
recipes/Python/577083_POSIX_context_manager_temporarily_silence_or/recipe-577083.py
|
1
|
3124
|
#! /usr/bin/env python
"""
silence.py
Peter Waller
March 2010
"""
from __future__ import with_statement
from contextlib import contextmanager, nested
from threading import Thread
from tempfile import mkdtemp
from os.path import join as pjoin
from os import (dup, fdopen, open as osopen, O_NONBLOCK, O_RDONLY, remove,
rmdir, mkfifo)
from fcntl import fcntl, F_GETFL, F_SETFL
from select import select
from sys import stdout, stderr
from ctypes import PyDLL, CDLL, c_void_p, c_char_p, py_object
pyapi = PyDLL(None)
this_exe = CDLL(None)
def make_fn(what, res, *args):
what.restype = res
what.argtypes = args
return what
FILE_p = c_void_p
PyFile_AsFile = make_fn(pyapi.PyFile_AsFile, FILE_p, py_object)
freopen = make_fn(this_exe.freopen, FILE_p, c_char_p, c_char_p, FILE_p)
@contextmanager
def fifo():
"""
Create a fifo in a temporary place.
"""
tmpdir = mkdtemp()
filename = pjoin(tmpdir, 'myfifo')
try:
mkfifo(filename)
except OSError, e:
print >>stderr, "Failed to create FIFO: %s" % e
raise
else:
yield filename
remove(filename)
rmdir(tmpdir)
def reader_thread_func(filename, filter_, real_stdout):
"""
Sit there, reading lines from the pipe `filename`, sending those for which
`filter_()` returns False to `real_stdout`
"""
with fdopen(osopen(filename, O_NONBLOCK | O_RDONLY)) as fd:
while True:
rlist, _, _ = select([fd], [], [])
line = fd.readline()
if not line:
break
elif not filter_(line):
real_stdout.write(line)
@contextmanager
def threaded_file_reader(*args):
"""
Operate a read_thread_func in another thread. Block with statement exit
until the function completes.
"""
reader_thread = Thread(target=reader_thread_func, args=args)
reader_thread.start()
try:
yield
finally:
reader_thread.join()
@contextmanager
def silence(filter_=lambda line: True, file_=stdout):
"""
Prevent lines matching `filter_` ending up on `file_` (defaults to stdout)
"""
if not filter_:
yield
return
saved_stdout = dup(file_.fileno())
stdout_file = PyFile_AsFile(file_)
with nested(fdopen(saved_stdout, "w"), fifo()) as (real_stdout, filename):
with threaded_file_reader(filename, filter_, real_stdout):
# Redirect stdout to pipe
freopen(filename, "w", stdout_file)
try:
yield
finally:
# Redirect stdout back to it's original place
freopen("/dev/fd/%i" % saved_stdout, "w", stdout_file)
def test():
def filter_stupid(line):
if line.startswith("Stupid"):
return True
print "Before with block.."
with silence(filter_stupid):
print "Stupid output from a C library I don't want to hear"
print "Sensible stuff!"
print "After the silence block"
if __name__ == "__main__":
test()
|
mit
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
624,
199,
338,
17072,
14,
647,
199,
8070,
351,
644,
9230,
221,
199,
45,
1047,
7129,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
504,
15502,
492,
27608,
12,
6032,
199,
504,
5796,
492,
11086,
199,
199,
504,
5549,
492,
31781,
199,
504,
747,
14,
515,
492,
4263,
465,
299,
904,
199,
504,
747,
492,
334,
11048,
12,
6111,
1490,
12,
1551,
465,
747,
1490,
12,
593,
63,
13887,
8475,
12,
593,
63,
15543,
10452,
12,
2813,
12,
8892,
14267,
694,
12,
9199,
22976,
9,
199,
504,
12871,
492,
12871,
12,
481,
63,
2970,
3143,
12,
481,
63,
3597,
3143,
199,
504,
3504,
492,
3504,
199,
504,
984,
492,
3839,
12,
4635,
199,
199,
504,
5577,
492,
1611,
15982,
12,
445,
15982,
12,
286,
63,
1647,
63,
80,
12,
286,
63,
1560,
63,
80,
12,
1134,
63,
785,
199,
199,
647,
1246,
275,
1611,
15982,
8,
403,
9,
199,
3749,
63,
5803,
275,
445,
15982,
8,
403,
9,
199,
199,
318,
1852,
63,
2324,
8,
10058,
12,
522,
12,
627,
589,
304,
272,
4052,
14,
9990,
275,
522,
272,
4052,
14,
10025,
275,
1249,
272,
372,
4052,
1362,
199,
3817,
63,
80,
275,
286,
63,
1647,
63,
80,
1362,
199,
2713,
1173,
63,
2822,
1173,
275,
1852,
63,
2324,
8,
647,
1246,
14,
2713,
1173,
63,
2822,
1173,
12,
13024,
63,
80,
12,
1134,
63,
785,
9,
199,
20153,
1490,
275,
1852,
63,
2324,
8,
3749,
63,
5803,
14,
20153,
1490,
12,
13024,
63,
80,
12,
286,
63,
1560,
63,
80,
12,
286,
63,
1560,
63,
80,
12,
13024,
63,
80,
9,
199,
199,
32,
14237,
199,
318,
5883,
545,
837,
272,
408,
272,
2790,
282,
5883,
545,
315,
282,
7937,
4192,
14,
272,
408,
272,
12885,
275,
31781,
342,
272,
1788,
275,
299,
904,
8,
8616,
12,
283,
1662,
22976,
358,
272,
862,
26,
267,
9199,
22976,
8,
1501,
9,
272,
871,
6440,
12,
325,
26,
267,
870,
4331,
3083,
12,
298,
4276,
370,
1218,
15435,
3230,
26,
450,
83,
2,
450,
325,
267,
746,
272,
587,
26,
267,
1995,
1788,
267,
2813,
8,
1501,
9,
267,
14267,
694,
8,
8616,
9,
199,
199,
318,
7002,
63,
2671,
63,
1532,
8,
1501,
12,
2457,
3131,
3363,
63,
2703,
304,
272,
408,
272,
428,
390,
2337,
12,
7664,
2385,
687,
314,
5200,
658,
1501,
3559,
10209,
5204,
367,
1314,
272,
658,
1541,
63,
11995,
2529,
756,
370,
658,
3093,
63,
2703,
64,
272,
408,
272,
543,
6111,
1490,
8,
736,
1490,
8,
1501,
12,
593,
63,
13887,
8475,
1204,
593,
63,
15543,
10452,
430,
465,
6111,
26,
267,
1830,
715,
26,
288,
519,
513,
12,
5501,
485,
275,
3504,
779,
2592,
467,
990,
3073,
7846,
1004,
275,
6111,
14,
6407,
342,
288,
340,
440,
1004,
26,
355,
2059,
24850,
916,
440,
2457,
2531,
604,
304,
355,
3363,
63,
2703,
14,
952,
8,
604,
9,
199,
199,
32,
14237,
199,
318,
25396,
63,
493,
63,
5503,
2031,
589,
304,
272,
408,
272,
6654,
323,
282,
1586,
63,
2671,
63,
1532,
315,
4573,
2462,
14,
8651,
543,
5164,
4458,
272,
5133,
314,
805,
29672,
14,
272,
408,
272,
7002,
63,
2671,
275,
11086,
8,
1375,
29,
5503,
63,
2671,
63,
1532,
12,
1249,
29,
589,
9,
272,
7002,
63,
2671,
14,
928,
342,
272,
862,
26,
267,
1995,
272,
3753,
26,
267,
7002,
63,
2671,
14,
904,
342,
199,
199,
32,
14237,
199,
318,
9767,
21225,
8,
1541,
10683,
2734,
1004,
26,
715,
12,
570,
10683,
2703,
304,
272,
408,
272,
29861,
2385,
4877,
658,
1541,
28116,
13401,
1536,
641,
658,
493,
28116,
334,
4322,
370,
3839,
9,
272,
408,
272,
340,
440,
2457,
10388,
267,
1995,
267,
372,
2286,
6290,
63,
2703,
275,
11866,
8,
493,
3754,
9843,
1012,
272,
3839,
63,
493,
275,
1611,
1173,
63,
2822,
1173,
8,
493,
4602,
2286,
543,
6032,
8,
23140,
8,
8420,
63,
2703,
12,
298,
87,
1288,
5883,
545,
1012,
465,
334,
3093,
63,
2703,
12,
1788,
304,
267,
543,
25396,
63,
493,
63,
5503,
8,
1501,
12,
2457,
3131,
3363,
63,
2703,
304,
288,
327,
18532,
3839,
370,
5200,
288,
20673,
1490,
8,
1501,
12,
298,
87,
401,
3839,
63,
493,
9,
288,
862,
26,
355,
1995,
288,
3753,
26,
355,
327,
18532,
3839,
1771,
370,
652,
1159,
3379,
4192,
355,
20673,
1490,
4769,
2374,
15,
2592,
3149,
73,
2,
450,
6290,
63,
2703,
12,
298,
87,
401,
3839,
63,
493,
9,
199,
199,
318,
511,
837,
2286,
347,
2457,
63,
270,
31596,
8,
604,
304,
267,
340,
1004,
14,
2460,
480,
933,
31596,
2349,
288,
372,
715,
15567,
870,
298,
13569,
543,
1853,
703,
2,
2286,
543,
9767,
21225,
8,
1541,
63,
270,
31596,
304,
267,
870,
298,
933,
31596,
1072,
687,
282,
445,
3555,
473,
2793,
1133,
2934,
370,
946,
285,
2,
267,
870,
298,
18569,
1164,
8292,
9539,
5493,
870,
298,
10881,
314,
9767,
21225,
1853,
2,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
511,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
624,
199,
338,
17072,
14,
647,
199,
8070,
351,
644,
9230,
221,
199,
45,
1047,
7129,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
504,
15502,
492,
27608,
12,
6032,
199,
504,
5796,
492,
11086,
199,
199,
504,
5549,
492,
31781,
199,
504,
747,
14,
515,
492,
4263,
465,
299,
904,
199,
504,
747,
492,
334,
11048,
12,
6111,
1490,
12,
1551,
465,
747,
1490,
12,
593,
63,
13887,
8475,
12,
593,
63,
15543,
10452,
12,
2813,
12,
8892,
14267,
694,
12,
9199,
22976,
9,
199,
504,
12871,
492,
12871,
12,
481,
63,
2970,
3143,
12,
481,
63,
3597,
3143,
199,
504,
3504,
492,
3504,
199,
504,
984,
492,
3839,
12,
4635,
199,
199,
504,
5577,
492,
1611,
15982,
12,
445,
15982,
12,
286,
63,
1647,
63,
80,
12,
286,
63,
1560,
63,
80,
12,
1134,
63,
785,
199,
199,
647,
1246,
275,
1611,
15982,
8,
403,
9,
199,
3749,
63,
5803,
275,
445,
15982,
8,
403,
9,
199,
199,
318,
1852,
63,
2324,
8,
10058,
12,
522,
12,
627,
589,
304,
272,
4052,
14,
9990,
275,
522,
272,
4052,
14,
10025,
275,
1249,
272,
372,
4052,
1362,
199,
3817,
63,
80,
275,
286,
63,
1647,
63,
80,
1362,
199,
2713,
1173,
63,
2822,
1173,
275,
1852,
63,
2324,
8,
647,
1246,
14,
2713,
1173,
63,
2822,
1173,
12,
13024,
63,
80,
12,
1134,
63,
785,
9,
199,
20153,
1490,
275,
1852,
63,
2324,
8,
3749,
63,
5803,
14,
20153,
1490,
12,
13024,
63,
80,
12,
286,
63,
1560,
63,
80,
12,
286,
63,
1560,
63,
80,
12,
13024,
63,
80,
9,
199,
199,
32,
14237,
199,
318,
5883,
545,
837,
272,
408,
272,
2790,
282,
5883,
545,
315,
282,
7937,
4192,
14,
272,
408,
272,
12885,
275,
31781,
342,
272,
1788,
275,
299,
904,
8,
8616,
12,
283,
1662,
22976,
358,
272,
862,
26,
267,
9199,
22976,
8,
1501,
9,
272,
871,
6440,
12,
325,
26,
267,
870,
4331,
3083,
12,
298,
4276,
370,
1218,
15435,
3230,
26,
450,
83,
2,
450,
325,
267,
746,
272,
587,
26,
267,
1995,
1788,
267,
2813,
8,
1501,
9,
267,
14267,
694,
8,
8616,
9,
199,
199,
318,
7002,
63,
2671,
63,
1532,
8,
1501,
12,
2457,
3131,
3363,
63,
2703,
304,
272,
408,
272,
428,
390,
2337,
12,
7664,
2385,
687,
314,
5200,
658,
1501,
3559,
10209,
5204,
367,
1314,
272,
658,
1541,
63,
11995,
2529,
756,
370,
658,
3093,
63,
2703,
64,
272,
408,
272,
543,
6111,
1490,
8,
736,
1490,
8,
1501,
12,
593,
63,
13887,
8475,
1204,
593,
63,
15543,
10452,
430,
465,
6111,
26,
267,
1830,
715,
26,
288,
519,
513,
12,
5501,
485,
275,
3504,
779,
2592,
467,
990,
3073,
7846,
1004,
275,
6111,
14,
6407,
342,
288,
340,
440,
1004,
26,
355,
2059,
24850,
916,
440,
2457,
2531,
604,
304,
355,
3363,
63,
2703,
14,
952,
8,
604,
9,
199,
199,
32,
14237,
199,
318,
25396,
63,
493,
63,
5503,
2031,
589,
304,
272,
408,
272,
6654,
323,
282,
1586,
63,
2671,
63,
1532,
315,
4573,
2462,
14,
8651,
543,
5164,
4458,
272,
5133,
314,
805,
29672,
14,
272,
408,
272,
7002,
63,
2671,
275,
11086,
8,
1375,
29,
5503,
63,
2671,
63,
1532,
12,
1249,
29,
589,
9,
272,
7002,
63,
2671,
14,
928,
342,
272,
862,
26,
267,
1995,
272,
3753,
26,
267,
7002,
63,
2671,
14,
904,
342,
199,
199,
32,
14237,
199,
318,
9767,
21225,
8,
1541,
10683,
2734,
1004,
26,
715,
12,
570,
10683,
2703,
304,
272,
408,
272,
29861,
2385,
4877,
658,
1541,
28116,
13401,
1536,
641,
658,
493,
28116,
334,
4322,
370,
3839,
9,
272,
408,
272,
340,
440,
2457,
10388,
267,
1995,
267,
372,
2286,
6290,
63,
2703,
275,
11866,
8,
493,
3754,
9843,
1012,
272,
3839,
63,
493,
275,
1611,
1173,
63,
2822,
1173,
8,
493,
4602,
2286,
543,
6032,
8,
23140,
8,
8420,
63,
2703,
12,
298,
87,
1288,
5883,
545,
1012,
465,
334,
3093,
63,
2703,
12,
1788,
304,
267,
543,
25396,
63,
493,
63,
5503,
8,
1501,
12,
2457,
3131,
3363,
63,
2703,
304,
288,
327,
18532,
3839,
370,
5200,
288,
20673,
1490,
8,
1501,
12,
298,
87,
401,
3839,
63,
493,
9,
288,
862,
26,
355,
1995,
288,
3753,
26,
355,
327,
18532,
3839,
1771,
370,
652,
1159,
3379,
4192,
355,
20673,
1490,
4769,
2374,
15,
2592,
3149,
73,
2,
450,
6290,
63,
2703,
12,
298,
87,
401,
3839,
63,
493,
9,
199,
199,
318,
511,
837,
2286,
347,
2457,
63,
270,
31596,
8,
604,
304,
267,
340,
1004,
14,
2460,
480,
933,
31596,
2349,
288,
372,
715,
15567,
870,
298,
13569,
543,
1853,
703,
2,
2286,
543,
9767,
21225,
8,
1541,
63,
270,
31596,
304,
267,
870,
298,
933,
31596,
1072,
687,
282,
445,
3555,
473,
2793,
1133,
2934,
370,
946,
285,
2,
267,
870,
298,
18569,
1164,
8292,
9539,
5493,
870,
298,
10881,
314,
9767,
21225,
1853,
2,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
511,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
mashuai/Cassandra-Research
|
pylib/cqlshlib/test/ansi_colors.py
|
192
|
6073
|
# 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 re
LIGHT = 010
ansi_CSI = '\033['
ansi_seq = re.compile(re.escape(ansi_CSI) + r'(?P<params>[\x20-\x3f]*)(?P<final>[\x40-\x7e])')
ansi_cmd_SGR = 'm' # set graphics rendition
color_defs = (
(000, 'k', 'black'),
(001, 'r', 'dark red'),
(002, 'g', 'dark green'),
(003, 'w', 'brown', 'dark yellow'),
(004, 'b', 'dark blue'),
(005, 'm', 'dark magenta', 'dark purple'),
(006, 'c', 'dark cyan'),
(007, 'n', 'light grey', 'light gray', 'neutral', 'dark white'),
(010, 'B', 'dark grey', 'dark gray', 'light black'),
(011, 'R', 'red', 'light red'),
(012, 'G', 'green', 'light green'),
(013, 'Y', 'yellow', 'light yellow'),
(014, 'B', 'blue', 'light blue'),
(015, 'M', 'magenta', 'purple', 'light magenta', 'light purple'),
(016, 'C', 'cyan', 'light cyan'),
(017, 'W', 'white', 'light white'),
)
colors_by_num = {}
colors_by_letter = {}
colors_by_name = {}
letters_by_num = {}
for colordef in color_defs:
colorcode = colordef[0]
colorletter = colordef[1]
colors_by_num[colorcode] = nameset = set(colordef[2:])
colors_by_letter[colorletter] = colorcode
letters_by_num[colorcode] = colorletter
for c in list(nameset):
# equivalent names without spaces
nameset.add(c.replace(' ', ''))
for c in list(nameset):
# with "bright" being an alias for "light"
nameset.add(c.replace('light', 'bright'))
for c in nameset:
colors_by_name[c] = colorcode
class ColoredChar:
def __init__(self, c, colorcode):
self.c = c
self._colorcode = colorcode
def colorcode(self):
return self._colorcode
def plain(self):
return self.c
def __getattr__(self, name):
return getattr(self.c, name)
def ansi_color(self):
clr = str(30 + (07 & self._colorcode))
if self._colorcode & 010:
clr = '1;' + clr
return clr
def __str__(self):
return "<%s '%r'>" % (self.__class__.__name__, self.colored_repr())
__repr__ = __str__
def colored_version(self):
return '%s0;%sm%s%s0m' % (ansi_CSI, self.ansi_color(), self.c, ansi_CSI)
def colored_repr(self):
if self.c == "'":
crepr = r"\'"
elif self.c == '"':
crepr = self.c
else:
crepr = repr(self.c)[1:-1]
return '%s0;%sm%s%s0m' % (ansi_CSI, self.ansi_color(), crepr, ansi_CSI)
def colortag(self):
return lookup_letter_from_code(self._colorcode)
class ColoredText:
def __init__(self, source=''):
if isinstance(source, basestring):
plain, colors = self.parse_ansi_colors(source)
self.chars = map(ColoredChar, plain, colors)
else:
# expected that source is an iterable of ColoredChars (or duck-typed as such)
self.chars = tuple(source)
def splitlines(self):
lines = [[]]
for c in self.chars:
if c.plain() == '\n':
lines.append([])
else:
lines[-1].append(c)
return [self.__class__(line) for line in lines]
def plain(self):
return ''.join([c.plain() for c in self.chars])
def __getitem__(self, index):
return self.chars[index]
@classmethod
def parse_ansi_colors(cls, source):
# note: strips all control sequences, even if not SGRs.
colors = []
plain = ''
last = 0
curclr = 0
for match in ansi_seq.finditer(source):
prevsegment = source[last:match.start()]
plain += prevsegment
colors.extend([curclr] * len(prevsegment))
if match.group('final') == ansi_cmd_SGR:
try:
curclr = cls.parse_sgr_param(curclr, match.group('params'))
except ValueError:
pass
last = match.end()
prevsegment = source[last:]
plain += prevsegment
colors.extend([curclr] * len(prevsegment))
return ''.join(plain), colors
@staticmethod
def parse_sgr_param(curclr, paramstr):
oldclr = curclr
args = map(int, paramstr.split(';'))
for a in args:
if a == 0:
curclr = lookup_colorcode('neutral')
elif a == 1:
curclr |= LIGHT
elif 30 <= a <= 37:
curclr = (curclr & LIGHT) | (a - 30)
else:
# not supported renditions here; ignore for now
pass
return curclr
def __repr__(self):
return "<%s '%s'>" % (self.__class__.__name__, ''.join([c.colored_repr() for c in self.chars]))
__str__ = __repr__
def __iter__(self):
return iter(self.chars)
def colored_version(self):
return ''.join([c.colored_version() for c in self.chars])
def colortags(self):
return ''.join([c.colortag() for c in self.chars])
def lookup_colorcode(name):
return colors_by_name[name]
def lookup_colorname(code):
return colors_by_num.get(code, 'Unknown-color-0%o' % code)
def lookup_colorletter(letter):
return colors_by_letter[letter]
def lookup_letter_from_code(code):
letr = letters_by_num.get(code, ' ')
if letr == 'n':
letr = ' '
return letr
|
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,
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,
295,
199,
199,
21613,
275,
378,
709,
199,
199,
22204,
63,
35,
2684,
275,
1557,
8762,
459,
199,
22204,
63,
3610,
275,
295,
14,
2014,
8,
264,
14,
3765,
8,
22204,
63,
35,
2684,
9,
435,
519,
10120,
48,
28,
1162,
24693,
88,
1165,
2696,
88,
19,
70,
3672,
18168,
48,
28,
5094,
24693,
88,
2167,
2696,
88,
23,
69,
566,
358,
199,
22204,
63,
1760,
63,
51,
3975,
275,
283,
77,
7,
221,
327,
663,
24348,
2903,
1671,
199,
199,
2326,
63,
8710,
275,
334,
272,
334,
1493,
12,
283,
75,
297,
283,
8399,
659,
272,
334,
4587,
12,
283,
82,
297,
283,
13625,
8992,
659,
272,
334,
7432,
12,
283,
71,
297,
283,
13625,
12431,
659,
272,
334,
8262,
12,
283,
87,
297,
283,
27133,
297,
283,
13625,
31194,
659,
272,
334,
7979,
12,
283,
66,
297,
283,
13625,
10030,
659,
272,
334,
7972,
12,
283,
77,
297,
283,
13625,
8127,
21335,
297,
283,
13625,
5861,
11045,
659,
272,
334,
8010,
12,
283,
67,
297,
283,
13625,
6325,
290,
659,
272,
334,
8255,
12,
283,
78,
297,
283,
4040,
30357,
297,
283,
4040,
21977,
297,
283,
685,
29358,
297,
283,
13625,
10424,
659,
272,
334,
9523,
12,
283,
34,
297,
283,
13625,
30357,
297,
283,
13625,
21977,
297,
283,
4040,
12136,
659,
272,
334,
13059,
12,
283,
50,
297,
283,
581,
297,
283,
4040,
8992,
659,
272,
334,
11533,
12,
283,
39,
297,
283,
7731,
297,
283,
4040,
12431,
659,
272,
334,
13264,
12,
283,
57,
297,
283,
14514,
297,
283,
4040,
31194,
659,
272,
334,
10752,
12,
283,
34,
297,
283,
6304,
297,
283,
4040,
10030,
659,
272,
334,
11164,
12,
283,
45,
297,
283,
5615,
21335,
297,
283,
6653,
11045,
297,
283,
4040,
8127,
21335,
297,
283,
4040,
5861,
11045,
659,
272,
334,
10882,
12,
283,
35,
297,
283,
28291,
297,
283,
4040,
6325,
290,
659,
272,
334,
9570,
12,
283,
55,
297,
283,
7510,
297,
283,
4040,
10424,
659,
199,
9,
199,
199,
7120,
63,
991,
63,
1507,
275,
1052,
199,
7120,
63,
991,
63,
9269,
275,
1052,
199,
7120,
63,
991,
63,
354,
275,
1052,
199,
16415,
63,
991,
63,
1507,
275,
1052,
199,
199,
509,
3164,
318,
315,
3164,
63,
8710,
26,
272,
3164,
600,
275,
3164,
318,
59,
16,
61,
272,
3164,
9269,
275,
3164,
318,
59,
17,
61,
272,
9229,
63,
991,
63,
1507,
59,
2326,
600,
61,
275,
536,
409,
275,
663,
8,
2326,
318,
59,
18,
5728,
272,
9229,
63,
991,
63,
9269,
59,
2326,
9269,
61,
275,
3164,
600,
272,
14435,
63,
991,
63,
1507,
59,
2326,
600,
61,
275,
3164,
9269,
272,
367,
286,
315,
769,
8,
354,
409,
304,
267,
327,
7353,
1561,
1928,
7883,
267,
536,
409,
14,
525,
8,
67,
14,
1814,
360,
1656,
12381,
272,
367,
286,
315,
769,
8,
354,
409,
304,
267,
327,
543,
298,
27454,
2,
3769,
376,
5162,
367,
298,
4040,
2,
267,
536,
409,
14,
525,
8,
67,
14,
1814,
360,
4040,
297,
283,
27454,
1333,
272,
367,
286,
315,
536,
409,
26,
267,
9229,
63,
991,
63,
354,
59,
67,
61,
275,
3164,
600,
199,
199,
533,
1849,
21252,
1610,
26,
272,
347,
636,
826,
721,
277,
12,
286,
12,
3164,
600,
304,
267,
291,
14,
67,
275,
286,
267,
291,
423,
2326,
600,
275,
3164,
600,
339,
347,
3164,
600,
8,
277,
304,
267,
372,
291,
423,
2326,
600,
339,
347,
8971,
8,
277,
304,
267,
372,
291,
14,
67,
339,
347,
636,
5675,
721,
277,
12,
536,
304,
267,
372,
2519,
8,
277,
14,
67,
12,
536,
9,
339,
347,
376,
338,
63,
2326,
8,
277,
304,
267,
824,
82,
275,
620,
8,
1216,
435,
334,
1780,
1253,
291,
423,
2326,
600,
430,
267,
340,
291,
423,
2326,
600,
1253,
378,
709,
26,
288,
824,
82,
275,
283,
17,
8942,
435,
824,
82,
267,
372,
824,
82,
339,
347,
636,
495,
721,
277,
304,
267,
372,
23054,
83,
1543,
82,
7,
4335,
450,
334,
277,
855,
533,
4914,
354,
3108,
291,
14,
331,
21252,
63,
2722,
1012,
272,
636,
2722,
363,
275,
636,
495,
363,
339,
347,
32076,
63,
1023,
8,
277,
304,
267,
372,
1543,
83,
16,
27,
5,
3300,
5,
83,
5,
83,
16,
77,
7,
450,
334,
22204,
63,
35,
2684,
12,
291,
14,
22204,
63,
2326,
1062,
291,
14,
67,
12,
376,
338,
63,
35,
2684,
9,
339,
347,
32076,
63,
2722,
8,
277,
304,
267,
340,
291,
14,
67,
508,
3546,
582,
288,
286,
2722,
275,
519,
3212,
4065,
267,
916,
291,
14,
67,
508,
24536,
288,
286,
2722,
275,
291,
14,
67,
267,
587,
26,
288,
286,
2722,
275,
4700,
8,
277,
14,
67,
2788,
17,
6809,
17,
61,
267,
372,
1543,
83,
16,
27,
5,
3300,
5,
83,
5,
83,
16,
77,
7,
450,
334,
22204,
63,
35,
2684,
12,
291,
14,
22204,
63,
2326,
1062,
286,
2722,
12,
376,
338,
63,
35,
2684,
9,
339,
347,
1048,
361,
643,
8,
277,
304,
267,
372,
4237,
63,
9269,
63,
504,
63,
600,
8,
277,
423,
2326,
600,
9,
199,
199,
533,
1849
] |
[
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
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,
295,
199,
199,
21613,
275,
378,
709,
199,
199,
22204,
63,
35,
2684,
275,
1557,
8762,
459,
199,
22204,
63,
3610,
275,
295,
14,
2014,
8,
264,
14,
3765,
8,
22204,
63,
35,
2684,
9,
435,
519,
10120,
48,
28,
1162,
24693,
88,
1165,
2696,
88,
19,
70,
3672,
18168,
48,
28,
5094,
24693,
88,
2167,
2696,
88,
23,
69,
566,
358,
199,
22204,
63,
1760,
63,
51,
3975,
275,
283,
77,
7,
221,
327,
663,
24348,
2903,
1671,
199,
199,
2326,
63,
8710,
275,
334,
272,
334,
1493,
12,
283,
75,
297,
283,
8399,
659,
272,
334,
4587,
12,
283,
82,
297,
283,
13625,
8992,
659,
272,
334,
7432,
12,
283,
71,
297,
283,
13625,
12431,
659,
272,
334,
8262,
12,
283,
87,
297,
283,
27133,
297,
283,
13625,
31194,
659,
272,
334,
7979,
12,
283,
66,
297,
283,
13625,
10030,
659,
272,
334,
7972,
12,
283,
77,
297,
283,
13625,
8127,
21335,
297,
283,
13625,
5861,
11045,
659,
272,
334,
8010,
12,
283,
67,
297,
283,
13625,
6325,
290,
659,
272,
334,
8255,
12,
283,
78,
297,
283,
4040,
30357,
297,
283,
4040,
21977,
297,
283,
685,
29358,
297,
283,
13625,
10424,
659,
272,
334,
9523,
12,
283,
34,
297,
283,
13625,
30357,
297,
283,
13625,
21977,
297,
283,
4040,
12136,
659,
272,
334,
13059,
12,
283,
50,
297,
283,
581,
297,
283,
4040,
8992,
659,
272,
334,
11533,
12,
283,
39,
297,
283,
7731,
297,
283,
4040,
12431,
659,
272,
334,
13264,
12,
283,
57,
297,
283,
14514,
297,
283,
4040,
31194,
659,
272,
334,
10752,
12,
283,
34,
297,
283,
6304,
297,
283,
4040,
10030,
659,
272,
334,
11164,
12,
283,
45,
297,
283,
5615,
21335,
297,
283,
6653,
11045,
297,
283,
4040,
8127,
21335,
297,
283,
4040,
5861,
11045,
659,
272,
334,
10882,
12,
283,
35,
297,
283,
28291,
297,
283,
4040,
6325,
290,
659,
272,
334,
9570,
12,
283,
55,
297,
283,
7510,
297,
283,
4040,
10424,
659,
199,
9,
199,
199,
7120,
63,
991,
63,
1507,
275,
1052,
199,
7120,
63,
991,
63,
9269,
275,
1052,
199,
7120,
63,
991,
63,
354,
275,
1052,
199,
16415,
63,
991,
63,
1507,
275,
1052,
199,
199,
509,
3164,
318,
315,
3164,
63,
8710,
26,
272,
3164,
600,
275,
3164,
318,
59,
16,
61,
272,
3164,
9269,
275,
3164,
318,
59,
17,
61,
272,
9229,
63,
991,
63,
1507,
59,
2326,
600,
61,
275,
536,
409,
275,
663,
8,
2326,
318,
59,
18,
5728,
272,
9229,
63,
991,
63,
9269,
59,
2326,
9269,
61,
275,
3164,
600,
272,
14435,
63,
991,
63,
1507,
59,
2326,
600,
61,
275,
3164,
9269,
272,
367,
286,
315,
769,
8,
354,
409,
304,
267,
327,
7353,
1561,
1928,
7883,
267,
536,
409,
14,
525,
8,
67,
14,
1814,
360,
1656,
12381,
272,
367,
286,
315,
769,
8,
354,
409,
304,
267,
327,
543,
298,
27454,
2,
3769,
376,
5162,
367,
298,
4040,
2,
267,
536,
409,
14,
525,
8,
67,
14,
1814,
360,
4040,
297,
283,
27454,
1333,
272,
367,
286,
315,
536,
409,
26,
267,
9229,
63,
991,
63,
354,
59,
67,
61,
275,
3164,
600,
199,
199,
533,
1849,
21252,
1610,
26,
272,
347,
636,
826,
721,
277,
12,
286,
12,
3164,
600,
304,
267,
291,
14,
67,
275,
286,
267,
291,
423,
2326,
600,
275,
3164,
600,
339,
347,
3164,
600,
8,
277,
304,
267,
372,
291,
423,
2326,
600,
339,
347,
8971,
8,
277,
304,
267,
372,
291,
14,
67,
339,
347,
636,
5675,
721,
277,
12,
536,
304,
267,
372,
2519,
8,
277,
14,
67,
12,
536,
9,
339,
347,
376,
338,
63,
2326,
8,
277,
304,
267,
824,
82,
275,
620,
8,
1216,
435,
334,
1780,
1253,
291,
423,
2326,
600,
430,
267,
340,
291,
423,
2326,
600,
1253,
378,
709,
26,
288,
824,
82,
275,
283,
17,
8942,
435,
824,
82,
267,
372,
824,
82,
339,
347,
636,
495,
721,
277,
304,
267,
372,
23054,
83,
1543,
82,
7,
4335,
450,
334,
277,
855,
533,
4914,
354,
3108,
291,
14,
331,
21252,
63,
2722,
1012,
272,
636,
2722,
363,
275,
636,
495,
363,
339,
347,
32076,
63,
1023,
8,
277,
304,
267,
372,
1543,
83,
16,
27,
5,
3300,
5,
83,
5,
83,
16,
77,
7,
450,
334,
22204,
63,
35,
2684,
12,
291,
14,
22204,
63,
2326,
1062,
291,
14,
67,
12,
376,
338,
63,
35,
2684,
9,
339,
347,
32076,
63,
2722,
8,
277,
304,
267,
340,
291,
14,
67,
508,
3546,
582,
288,
286,
2722,
275,
519,
3212,
4065,
267,
916,
291,
14,
67,
508,
24536,
288,
286,
2722,
275,
291,
14,
67,
267,
587,
26,
288,
286,
2722,
275,
4700,
8,
277,
14,
67,
2788,
17,
6809,
17,
61,
267,
372,
1543,
83,
16,
27,
5,
3300,
5,
83,
5,
83,
16,
77,
7,
450,
334,
22204,
63,
35,
2684,
12,
291,
14,
22204,
63,
2326,
1062,
286,
2722,
12,
376,
338,
63,
35,
2684,
9,
339,
347,
1048,
361,
643,
8,
277,
304,
267,
372,
4237,
63,
9269,
63,
504,
63,
600,
8,
277,
423,
2326,
600,
9,
199,
199,
533,
1849,
0
] |
[
1,
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zadnouri/scipy
|
scipy/special/_mptestutils.py
|
9
|
12437
|
from __future__ import division, print_function, absolute_import
import sys
import time
import numpy as np
from numpy.testing import dec, assert_
from scipy._lib.six import reraise
from scipy.special._testutils import assert_func_equal
try:
import mpmath
except ImportError:
try:
import sympy.mpmath as mpmath
except ImportError:
pass
# ------------------------------------------------------------------------------
# Machinery for systematic tests with mpmath
# ------------------------------------------------------------------------------
class Arg(object):
"""
Generate a set of numbers on the real axis, concentrating on
'interesting' regions and covering all orders of magnitude.
"""
def __init__(self, a=-np.inf, b=np.inf, inclusive_a=True, inclusive_b=True):
self.a = a
self.b = b
self.inclusive_a = inclusive_a
self.inclusive_b = inclusive_b
if self.a == -np.inf:
self.a = -np.finfo(float).max/2
if self.b == np.inf:
self.b = np.finfo(float).max/2
def values(self, n):
"""Return an array containing approximatively `n` numbers."""
n1 = max(2, int(0.3*n))
n2 = max(2, int(0.2*n))
n3 = max(8, n - n1 - n2)
v1 = np.linspace(-1, 1, n1)
v2 = np.r_[np.linspace(-10, 10, max(0, n2-4)),
-9, -5.5, 5.5, 9]
if self.a >= 0 and self.b > 0:
v3 = np.r_[
np.logspace(-30, -1, 2 + n3//4),
np.logspace(5, np.log10(self.b), 1 + n3//4),
]
v4 = np.logspace(1, 5, 1 + n3//2)
elif self.a < 0 < self.b:
v3 = np.r_[
np.logspace(-30, -1, 2 + n3//8),
np.logspace(5, np.log10(self.b), 1 + n3//8),
-np.logspace(-30, -1, 2 + n3//8),
-np.logspace(5, np.log10(-self.a), 1 + n3//8)
]
v4 = np.r_[
np.logspace(1, 5, 1 + n3//4),
-np.logspace(1, 5, 1 + n3//4)
]
elif self.b < 0:
v3 = np.r_[
-np.logspace(-30, -1, 2 + n3//4),
-np.logspace(5, np.log10(-self.b), 1 + n3//4),
]
v4 = -np.logspace(1, 5, 1 + n3//2)
else:
v3 = []
v4 = []
v = np.r_[v1, v2, v3, v4, 0]
if self.inclusive_a:
v = v[v >= self.a]
else:
v = v[v > self.a]
if self.inclusive_b:
v = v[v <= self.b]
else:
v = v[v < self.b]
return np.unique(v)
class FixedArg(object):
def __init__(self, values):
self._values = np.asarray(values)
def values(self, n):
return self._values
class ComplexArg(object):
def __init__(self, a=complex(-np.inf, -np.inf), b=complex(np.inf, np.inf)):
self.real = Arg(a.real, b.real)
self.imag = Arg(a.imag, b.imag)
def values(self, n):
m = max(2, int(np.sqrt(n)))
x = self.real.values(m)
y = self.imag.values(m)
return (x[:,None] + 1j*y[None,:]).ravel()
class IntArg(object):
def __init__(self, a=-1000, b=1000):
self.a = a
self.b = b
def values(self, n):
v1 = Arg(self.a, self.b).values(max(1 + n//2, n-5)).astype(int)
v2 = np.arange(-5, 5)
v = np.unique(np.r_[v1, v2])
v = v[(v >= self.a) & (v < self.b)]
return v
def get_args(argspec, n):
if isinstance(argspec, np.ndarray):
args = argspec.copy()
else:
nargs = len(argspec)
ms = np.asarray([1.5 if isinstance(spec, ComplexArg) else 1.0 for spec in argspec])
ms = (n**(ms/sum(ms))).astype(int) + 1
args = []
for spec, m in zip(argspec, ms):
args.append(spec.values(m))
args = np.array(np.broadcast_arrays(*np.ix_(*args))).reshape(nargs, -1).T
return args
class MpmathData(object):
def __init__(self, scipy_func, mpmath_func, arg_spec, name=None,
dps=None, prec=None, n=5000, rtol=1e-7, atol=1e-300,
ignore_inf_sign=False, distinguish_nan_and_inf=True,
nan_ok=True, param_filter=None):
self.scipy_func = scipy_func
self.mpmath_func = mpmath_func
self.arg_spec = arg_spec
self.dps = dps
self.prec = prec
self.n = n
self.rtol = rtol
self.atol = atol
self.ignore_inf_sign = ignore_inf_sign
self.nan_ok = nan_ok
if isinstance(self.arg_spec, np.ndarray):
self.is_complex = np.issubdtype(self.arg_spec.dtype, np.complexfloating)
else:
self.is_complex = any([isinstance(arg, ComplexArg) for arg in self.arg_spec])
self.ignore_inf_sign = ignore_inf_sign
self.distinguish_nan_and_inf = distinguish_nan_and_inf
if not name or name == '<lambda>':
name = getattr(scipy_func, '__name__', None)
if not name or name == '<lambda>':
name = getattr(mpmath_func, '__name__', None)
self.name = name
self.param_filter = param_filter
def check(self):
np.random.seed(1234)
# Generate values for the arguments
argarr = get_args(self.arg_spec, self.n)
# Check
old_dps, old_prec = mpmath.mp.dps, mpmath.mp.prec
try:
if self.dps is not None:
dps_list = [self.dps]
else:
dps_list = [20]
if self.prec is not None:
mpmath.mp.prec = self.prec
# Proper casting of mpmath input and output types. Using
# native mpmath types as inputs gives improved precision
# in some cases.
if np.issubdtype(argarr.dtype, np.complexfloating):
pytype = mpc2complex
def mptype(x):
return mpmath.mpc(complex(x))
else:
def mptype(x):
return mpmath.mpf(float(x))
def pytype(x):
if abs(x.imag) > 1e-16*(1 + abs(x.real)):
return np.nan
else:
return mpf2float(x.real)
# Try out different dps until one (or none) works
for j, dps in enumerate(dps_list):
mpmath.mp.dps = dps
try:
assert_func_equal(self.scipy_func,
lambda *a: pytype(self.mpmath_func(*map(mptype, a))),
argarr,
vectorized=False,
rtol=self.rtol, atol=self.atol,
ignore_inf_sign=self.ignore_inf_sign,
distinguish_nan_and_inf=self.distinguish_nan_and_inf,
nan_ok=self.nan_ok,
param_filter=self.param_filter)
break
except AssertionError:
if j >= len(dps_list)-1:
reraise(*sys.exc_info())
finally:
mpmath.mp.dps, mpmath.mp.prec = old_dps, old_prec
def __repr__(self):
if self.is_complex:
return "<MpmathData: %s (complex)>" % (self.name,)
else:
return "<MpmathData: %s>" % (self.name,)
def assert_mpmath_equal(*a, **kw):
d = MpmathData(*a, **kw)
d.check()
def nonfunctional_tooslow(func):
return dec.skipif(True, " Test not yet functional (too slow), needs more work.")(func)
# ------------------------------------------------------------------------------
# Tools for dealing with mpmath quirks
# ------------------------------------------------------------------------------
def mpf2float(x):
"""
Convert an mpf to the nearest floating point number. Just using
float directly doesn't work because of results like this:
with mp.workdps(50):
float(mpf("0.99999999999999999")) = 0.9999999999999999
"""
return float(mpmath.nstr(x, 17, min_fixed=0, max_fixed=0))
def mpc2complex(x):
return complex(mpf2float(x.real), mpf2float(x.imag))
def trace_args(func):
def tofloat(x):
if isinstance(x, mpmath.mpc):
return complex(x)
else:
return float(x)
def wrap(*a, **kw):
sys.stderr.write("%r: " % (tuple(map(tofloat, a)),))
sys.stderr.flush()
try:
r = func(*a, **kw)
sys.stderr.write("-> %r" % r)
finally:
sys.stderr.write("\n")
sys.stderr.flush()
return r
return wrap
try:
import posix
import signal
POSIX = ('setitimer' in dir(signal))
except ImportError:
POSIX = False
class TimeoutError(Exception):
pass
def time_limited(timeout=0.5, return_val=np.nan, use_sigalrm=True):
"""
Decorator for setting a timeout for pure-Python functions.
If the function does not return within `timeout` seconds, the
value `return_val` is returned instead.
On POSIX this uses SIGALRM by default. On non-POSIX, settrace is
used. Do not use this with threads: the SIGALRM implementation
does probably not work well. The settrace implementation only
traces the current thread.
The settrace implementation slows down execution speed. Slowdown
by a factor around 10 is probably typical.
"""
if POSIX and use_sigalrm:
def sigalrm_handler(signum, frame):
raise TimeoutError()
def deco(func):
def wrap(*a, **kw):
old_handler = signal.signal(signal.SIGALRM, sigalrm_handler)
signal.setitimer(signal.ITIMER_REAL, timeout)
try:
return func(*a, **kw)
except TimeoutError:
return return_val
finally:
signal.setitimer(signal.ITIMER_REAL, 0)
signal.signal(signal.SIGALRM, old_handler)
return wrap
else:
def deco(func):
def wrap(*a, **kw):
start_time = time.time()
def trace(frame, event, arg):
if time.time() - start_time > timeout:
raise TimeoutError()
return None # turn off tracing except at function calls
sys.settrace(trace)
try:
return func(*a, **kw)
except TimeoutError:
sys.settrace(None)
return return_val
finally:
sys.settrace(None)
return wrap
return deco
def exception_to_nan(func):
"""Decorate function to return nan if it raises an exception"""
def wrap(*a, **kw):
try:
return func(*a, **kw)
except Exception:
return np.nan
return wrap
def inf_to_nan(func):
"""Decorate function to return nan if it returns inf"""
def wrap(*a, **kw):
v = func(*a, **kw)
if not np.isfinite(v):
return np.nan
return v
return wrap
def mp_assert_allclose(res, std, atol=0, rtol=1e-17):
"""
Compare lists of mpmath.mpf's or mpmath.mpc's directly so that it
can be done to higher precision than double.
"""
try:
len(res)
except TypeError:
res = list(res)
n = len(std)
if len(res) != n:
raise AssertionError("Lengths of inputs not equal.")
failures = []
for k in range(n):
try:
assert_(mpmath.fabs(res[k] - std[k]) <= atol + rtol*mpmath.fabs(std[k]))
except AssertionError:
failures.append(k)
ndigits = int(abs(np.log10(rtol)))
msg = [""]
msg.append("Bad results ({} out of {}) for the following points:"
.format(len(failures), n))
for k in failures:
resrep = mpmath.nstr(res[k], ndigits, min_fixed=0, max_fixed=0)
stdrep = mpmath.nstr(std[k], ndigits, min_fixed=0, max_fixed=0)
if std[k] == 0:
rdiff = "inf"
else:
rdiff = mpmath.fabs((res[k] - std[k])/std[k])
rdiff = mpmath.nstr(rdiff, 3)
msg.append("{}: {} != {} (rdiff {})".format(k, resrep, stdrep, rdiff))
if failures:
assert_(False, "\n".join(msg))
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
646,
984,
199,
646,
900,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
4776,
492,
9700,
12,
702,
63,
199,
199,
504,
7026,
423,
773,
14,
4174,
492,
24139,
199,
504,
7026,
14,
6664,
423,
396,
1208,
492,
702,
63,
1532,
63,
1452,
199,
199,
893,
26,
272,
492,
6118,
3442,
199,
2590,
3545,
26,
272,
862,
26,
267,
492,
5840,
14,
311,
3442,
465,
6118,
3442,
272,
871,
3545,
26,
267,
986,
421,
199,
3,
5620,
10965,
199,
3,
30611,
20067,
367,
984,
266,
3889,
2295,
543,
6118,
3442,
199,
3,
5620,
10965,
199,
199,
533,
29560,
8,
785,
304,
272,
408,
272,
7958,
282,
663,
402,
5579,
641,
314,
3363,
3114,
12,
406,
2497,
454,
1958,
641,
272,
283,
30267,
7,
16150,
436,
8486,
316,
1006,
15460,
402,
22877,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
282,
4022,
1590,
14,
4904,
12,
330,
29,
1590,
14,
4904,
12,
20728,
63,
65,
29,
549,
12,
20728,
63,
66,
29,
549,
304,
267,
291,
14,
65,
275,
282,
267,
291,
14,
66,
275,
330,
267,
291,
14,
26062,
63,
65,
275,
20728,
63,
65,
267,
291,
14,
26062,
63,
66,
275,
20728,
63,
66,
267,
340,
291,
14,
65,
508,
446,
1590,
14,
4904,
26,
288,
291,
14,
65,
275,
446,
1590,
14,
23087,
8,
1609,
680,
988,
15,
18,
267,
340,
291,
14,
66,
508,
980,
14,
4904,
26,
288,
291,
14,
66,
275,
980,
14,
23087,
8,
1609,
680,
988,
15,
18,
339,
347,
1338,
8,
277,
12,
302,
304,
267,
408,
1767,
376,
1625,
3035,
4286,
6865,
391,
9462,
658,
78,
64,
5579,
1041,
267,
302,
17,
275,
1390,
8,
18,
12,
1109,
8,
16,
14,
19,
10,
78,
430,
267,
302,
18,
275,
1390,
8,
18,
12,
1109,
8,
16,
14,
18,
10,
78,
430,
267,
302,
19,
275,
1390,
8,
24,
12,
302,
446,
302,
17,
446,
302,
18,
9,
398,
373,
17,
275,
980,
14,
11649,
2801,
17,
12,
413,
12,
302,
17,
9,
267,
373,
18,
275,
980,
14,
82,
9925,
1590,
14,
11649,
2801,
709,
12,
1616,
12,
1390,
8,
16,
12,
302,
18,
13,
20,
1826,
673,
446,
25,
12,
446,
21,
14,
21,
12,
959,
14,
21,
12,
1749,
61,
267,
340,
291,
14,
65,
2356,
378,
436,
291,
14,
66,
690,
378,
26,
288,
373,
19,
275,
980,
14,
82,
9925,
355,
980,
14,
7270,
1142,
2801,
1216,
12,
446,
17,
12,
499,
435,
302,
19,
501,
20,
395,
355,
980,
14,
7270,
1142,
8,
21,
12,
980,
14,
793,
709,
8,
277,
14,
66,
395,
413,
435,
302,
19,
501,
20,
395,
355,
1622,
288,
373,
20,
275,
980,
14,
7270,
1142,
8,
17,
12,
959,
12,
413,
435,
302,
19,
501,
18,
9,
267,
916,
291,
14,
65,
665,
378,
665,
291,
14,
66,
26,
288,
373,
19,
275,
980,
14,
82,
9925,
355,
980,
14,
7270,
1142,
2801,
1216,
12,
446,
17,
12,
499,
435,
302,
19,
501,
24,
395,
355,
980,
14,
7270,
1142,
8,
21,
12,
980,
14,
793,
709,
8,
277,
14,
66,
395,
413,
435,
302,
19,
501,
24,
395,
355,
446,
1590,
14,
7270,
1142,
2801,
1216,
12,
446,
17,
12,
499,
435,
302,
19,
501,
24,
395,
355,
446,
1590,
14,
7270,
1142,
8,
21,
12,
980,
14,
793,
709,
2801,
277,
14,
65,
395,
413,
435,
302,
19,
501,
24,
9,
355,
1622,
288,
373,
20,
275,
980,
14,
82,
9925,
355,
980,
14,
7270,
1142,
8,
17,
12,
959,
12,
413,
435,
302,
19,
501,
20,
395,
355,
446,
1590,
14,
7270,
1142,
8,
17,
12,
959,
12,
413,
435,
302,
19,
501,
20,
9,
355,
1622,
267,
916,
291,
14,
66,
665,
378,
26,
288,
373,
19,
275,
980,
14,
82,
9925,
355,
446,
1590,
14,
7270,
1142,
2801,
1216,
12,
446,
17,
12,
499,
435,
302,
19,
501,
20,
395,
355,
446,
1590,
14,
7270,
1142,
8,
21,
12,
980,
14,
793,
709,
2801,
277,
14,
66,
395,
413,
435,
302,
19,
501,
20,
395,
355,
1622,
288,
373,
20,
275,
446,
1590,
14,
7270,
1142,
8,
17,
12,
959,
12,
413,
435,
302,
19,
501,
18,
9,
267,
587,
26,
288,
373,
19,
275,
942,
288,
373,
20,
275,
942,
267,
373,
275,
980,
14,
82,
9925,
86,
17,
12,
373,
18,
12,
373,
19,
12,
373,
20,
12,
378,
61,
267,
340,
291,
14,
26062,
63,
65,
26,
288,
373,
275,
373,
59,
86,
2356,
291,
14,
65,
61,
267,
587,
26,
288,
373,
275,
373,
59,
86,
690,
291,
14,
65,
61,
267,
340,
291,
14,
26062,
63,
66,
26,
288,
373,
275,
373,
59,
86,
2695,
291,
14,
66,
61,
267,
587,
26,
288,
373,
275,
373,
59,
86,
665,
291,
14,
66,
61,
267,
372,
980,
14,
3235,
8,
86,
9,
421,
199,
533,
18659,
6373,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1338,
304,
267,
291,
423,
1459,
275,
980,
14,
8748,
8,
1459,
9,
339,
347,
1338,
8,
277,
12,
302,
304,
267,
372,
291,
423,
1459,
421,
199,
533,
19178,
6373,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
282,
29,
5254,
2801,
1590,
14,
4904,
12,
446,
1590,
14,
4904,
395,
330,
29,
5254,
8,
1590,
14,
4904,
12,
980,
14,
4904,
2298,
267,
291,
14,
3093,
275,
29560,
8,
65,
14,
3093,
12,
330,
14,
3093,
9,
267,
291,
14,
14688,
275,
29560,
8,
65,
14,
14688,
12,
330,
14,
14688,
9,
339,
347,
1338,
8,
277,
12,
302,
304,
267,
333,
275,
1390,
8,
18,
12,
1109,
8,
1590,
14,
5079,
8,
78,
1724,
267,
671,
275,
291,
14,
3093,
14,
1459,
8,
77,
9,
267,
612,
275,
291,
14,
14688,
14,
1459,
8,
77,
9,
267,
372,
334,
88,
3981,
403,
61,
435,
413,
74,
10,
89,
59,
403,
12,
5728,
14,
11186,
342,
421,
199,
533,
9805,
6373,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
282,
4022,
5279,
12,
330,
29,
5279,
304,
267,
291,
14,
65,
275
] |
[
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
646,
984,
199,
646,
900,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
4776,
492,
9700,
12,
702,
63,
199,
199,
504,
7026,
423,
773,
14,
4174,
492,
24139,
199,
504,
7026,
14,
6664,
423,
396,
1208,
492,
702,
63,
1532,
63,
1452,
199,
199,
893,
26,
272,
492,
6118,
3442,
199,
2590,
3545,
26,
272,
862,
26,
267,
492,
5840,
14,
311,
3442,
465,
6118,
3442,
272,
871,
3545,
26,
267,
986,
421,
199,
3,
5620,
10965,
199,
3,
30611,
20067,
367,
984,
266,
3889,
2295,
543,
6118,
3442,
199,
3,
5620,
10965,
199,
199,
533,
29560,
8,
785,
304,
272,
408,
272,
7958,
282,
663,
402,
5579,
641,
314,
3363,
3114,
12,
406,
2497,
454,
1958,
641,
272,
283,
30267,
7,
16150,
436,
8486,
316,
1006,
15460,
402,
22877,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
282,
4022,
1590,
14,
4904,
12,
330,
29,
1590,
14,
4904,
12,
20728,
63,
65,
29,
549,
12,
20728,
63,
66,
29,
549,
304,
267,
291,
14,
65,
275,
282,
267,
291,
14,
66,
275,
330,
267,
291,
14,
26062,
63,
65,
275,
20728,
63,
65,
267,
291,
14,
26062,
63,
66,
275,
20728,
63,
66,
267,
340,
291,
14,
65,
508,
446,
1590,
14,
4904,
26,
288,
291,
14,
65,
275,
446,
1590,
14,
23087,
8,
1609,
680,
988,
15,
18,
267,
340,
291,
14,
66,
508,
980,
14,
4904,
26,
288,
291,
14,
66,
275,
980,
14,
23087,
8,
1609,
680,
988,
15,
18,
339,
347,
1338,
8,
277,
12,
302,
304,
267,
408,
1767,
376,
1625,
3035,
4286,
6865,
391,
9462,
658,
78,
64,
5579,
1041,
267,
302,
17,
275,
1390,
8,
18,
12,
1109,
8,
16,
14,
19,
10,
78,
430,
267,
302,
18,
275,
1390,
8,
18,
12,
1109,
8,
16,
14,
18,
10,
78,
430,
267,
302,
19,
275,
1390,
8,
24,
12,
302,
446,
302,
17,
446,
302,
18,
9,
398,
373,
17,
275,
980,
14,
11649,
2801,
17,
12,
413,
12,
302,
17,
9,
267,
373,
18,
275,
980,
14,
82,
9925,
1590,
14,
11649,
2801,
709,
12,
1616,
12,
1390,
8,
16,
12,
302,
18,
13,
20,
1826,
673,
446,
25,
12,
446,
21,
14,
21,
12,
959,
14,
21,
12,
1749,
61,
267,
340,
291,
14,
65,
2356,
378,
436,
291,
14,
66,
690,
378,
26,
288,
373,
19,
275,
980,
14,
82,
9925,
355,
980,
14,
7270,
1142,
2801,
1216,
12,
446,
17,
12,
499,
435,
302,
19,
501,
20,
395,
355,
980,
14,
7270,
1142,
8,
21,
12,
980,
14,
793,
709,
8,
277,
14,
66,
395,
413,
435,
302,
19,
501,
20,
395,
355,
1622,
288,
373,
20,
275,
980,
14,
7270,
1142,
8,
17,
12,
959,
12,
413,
435,
302,
19,
501,
18,
9,
267,
916,
291,
14,
65,
665,
378,
665,
291,
14,
66,
26,
288,
373,
19,
275,
980,
14,
82,
9925,
355,
980,
14,
7270,
1142,
2801,
1216,
12,
446,
17,
12,
499,
435,
302,
19,
501,
24,
395,
355,
980,
14,
7270,
1142,
8,
21,
12,
980,
14,
793,
709,
8,
277,
14,
66,
395,
413,
435,
302,
19,
501,
24,
395,
355,
446,
1590,
14,
7270,
1142,
2801,
1216,
12,
446,
17,
12,
499,
435,
302,
19,
501,
24,
395,
355,
446,
1590,
14,
7270,
1142,
8,
21,
12,
980,
14,
793,
709,
2801,
277,
14,
65,
395,
413,
435,
302,
19,
501,
24,
9,
355,
1622,
288,
373,
20,
275,
980,
14,
82,
9925,
355,
980,
14,
7270,
1142,
8,
17,
12,
959,
12,
413,
435,
302,
19,
501,
20,
395,
355,
446,
1590,
14,
7270,
1142,
8,
17,
12,
959,
12,
413,
435,
302,
19,
501,
20,
9,
355,
1622,
267,
916,
291,
14,
66,
665,
378,
26,
288,
373,
19,
275,
980,
14,
82,
9925,
355,
446,
1590,
14,
7270,
1142,
2801,
1216,
12,
446,
17,
12,
499,
435,
302,
19,
501,
20,
395,
355,
446,
1590,
14,
7270,
1142,
8,
21,
12,
980,
14,
793,
709,
2801,
277,
14,
66,
395,
413,
435,
302,
19,
501,
20,
395,
355,
1622,
288,
373,
20,
275,
446,
1590,
14,
7270,
1142,
8,
17,
12,
959,
12,
413,
435,
302,
19,
501,
18,
9,
267,
587,
26,
288,
373,
19,
275,
942,
288,
373,
20,
275,
942,
267,
373,
275,
980,
14,
82,
9925,
86,
17,
12,
373,
18,
12,
373,
19,
12,
373,
20,
12,
378,
61,
267,
340,
291,
14,
26062,
63,
65,
26,
288,
373,
275,
373,
59,
86,
2356,
291,
14,
65,
61,
267,
587,
26,
288,
373,
275,
373,
59,
86,
690,
291,
14,
65,
61,
267,
340,
291,
14,
26062,
63,
66,
26,
288,
373,
275,
373,
59,
86,
2695,
291,
14,
66,
61,
267,
587,
26,
288,
373,
275,
373,
59,
86,
665,
291,
14,
66,
61,
267,
372,
980,
14,
3235,
8,
86,
9,
421,
199,
533,
18659,
6373,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1338,
304,
267,
291,
423,
1459,
275,
980,
14,
8748,
8,
1459,
9,
339,
347,
1338,
8,
277,
12,
302,
304,
267,
372,
291,
423,
1459,
421,
199,
533,
19178,
6373,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
282,
29,
5254,
2801,
1590,
14,
4904,
12,
446,
1590,
14,
4904,
395,
330,
29,
5254,
8,
1590,
14,
4904,
12,
980,
14,
4904,
2298,
267,
291,
14,
3093,
275,
29560,
8,
65,
14,
3093,
12,
330,
14,
3093,
9,
267,
291,
14,
14688,
275,
29560,
8,
65,
14,
14688,
12,
330,
14,
14688,
9,
339,
347,
1338,
8,
277,
12,
302,
304,
267,
333,
275,
1390,
8,
18,
12,
1109,
8,
1590,
14,
5079,
8,
78,
1724,
267,
671,
275,
291,
14,
3093,
14,
1459,
8,
77,
9,
267,
612,
275,
291,
14,
14688,
14,
1459,
8,
77,
9,
267,
372,
334,
88,
3981,
403,
61,
435,
413,
74,
10,
89,
59,
403,
12,
5728,
14,
11186,
342,
421,
199,
533,
9805,
6373,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
282,
4022,
5279,
12,
330,
29,
5279,
304,
267,
291,
14,
65,
275,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
BobBuildTool/bob
|
test/test_input_recipe.py
|
1
|
9169
|
from unittest import TestCase
from unittest.mock import MagicMock
import os
from bob.errors import ParseError
from bob.input import Recipe
from bob.languages import ScriptLanguage
from bob.stringparser import Env
class TestDependencies(TestCase):
def cmpEntry(self, entry, name, env={}, fwd=False, use=["result", "deps"], cond=None):
self.assertEqual(entry.recipe, name)
self.assertEqual(entry.envOverride, env)
self.assertEqual(entry.provideGlobal, fwd)
self.assertEqual(entry.useEnv, "environment" in use)
self.assertEqual(entry.useTools, "tools" in use)
self.assertEqual(entry.useBuildResult, "result" in use)
self.assertEqual(entry.useDeps, "deps" in use)
self.assertEqual(entry.useSandbox, "sandbox" in use)
self.assertEqual(entry.condition, cond)
def testSimpleList(self):
deps = [ "a", "b" ]
res = list(Recipe.Dependency.parseEntries(deps))
self.assertEqual(len(res), 2)
self.cmpEntry(res[0], "a")
self.cmpEntry(res[1], "b")
def testMixedList(self):
deps = [ "a", { "name" : "b", "environment" : { "foo" : "bar" }} ]
res = list(Recipe.Dependency.parseEntries(deps))
self.assertEqual(len(res), 2)
self.cmpEntry(res[0], "a")
self.cmpEntry(res[1], "b", env={"foo" : "bar" })
def testNestedList(self):
deps = [
"a",
{ "depends" : [
"b",
{ "depends" : [ "c" ] }
]}
]
res = list(Recipe.Dependency.parseEntries(deps))
self.assertEqual(len(res), 3)
self.cmpEntry(res[0], "a")
self.cmpEntry(res[1], "b")
self.cmpEntry(res[2], "c")
def testNestedEnv(self):
deps = [
"a",
{
"environment" : { "foo" : "1", "bar" : "2" },
"depends" : [
"b",
{
"environment" : { "bar" : "3", "baz" : "4" },
"depends" : [ "c" ]
},
"d"
]
},
"e"
]
res = list(Recipe.Dependency.parseEntries(deps))
self.assertEqual(len(res), 5)
self.cmpEntry(res[0], "a")
self.cmpEntry(res[1], "b", env={"foo" : "1", "bar" : "2"})
self.cmpEntry(res[2], "c", env={"foo" : "1", "bar" : "3", "baz" : "4"})
self.cmpEntry(res[3], "d", env={"foo" : "1", "bar" : "2"})
self.cmpEntry(res[4], "e")
def testNestedIf(self):
deps = [
"a",
{
"if" : "cond1",
"depends" : [
"b",
{
"if" : "cond2",
"depends" : [ "c" ]
},
"d"
]
},
"e"
]
res = list(Recipe.Dependency.parseEntries(deps))
self.assertEqual(len(res), 5)
self.cmpEntry(res[0], "a")
self.cmpEntry(res[1], "b", cond=["cond1"])
self.cmpEntry(res[2], "c", cond=["cond1","cond2"])
self.cmpEntry(res[3], "d", cond=["cond1"])
self.cmpEntry(res[4], "e")
def testNestedUse(self):
deps = [
"a",
{
"use" : [],
"depends" : [
"b",
{
"use" : ["tools"],
"depends" : [ "c" ]
},
"d"
]
},
"e"
]
res = list(Recipe.Dependency.parseEntries(deps))
self.assertEqual(len(res), 5)
self.cmpEntry(res[0], "a")
self.cmpEntry(res[1], "b", use=[])
self.cmpEntry(res[2], "c", use=["tools"])
self.cmpEntry(res[3], "d", use=[])
self.cmpEntry(res[4], "e")
def testNestedFwd(self):
deps = [
"a",
{
"forward" : True,
"depends" : [
"b",
{
"forward" : False,
"depends" : [ "c" ]
},
"d"
]
},
"e"
]
res = list(Recipe.Dependency.parseEntries(deps))
self.assertEqual(len(res), 5)
self.cmpEntry(res[0], "a")
self.cmpEntry(res[1], "b", fwd=True)
self.cmpEntry(res[2], "c",)
self.cmpEntry(res[3], "d", fwd=True)
self.cmpEntry(res[4], "e")
class TestRelocatable(TestCase):
def parseAndPrepare(self, name, recipe, classes={}, allRelocatable=None):
cwd = os.getcwd()
recipeSet = MagicMock()
recipeSet.loadBinary = MagicMock()
recipeSet.scriptLanguage = ScriptLanguage.BASH
recipeSet.getPolicy = lambda x: allRelocatable if x == 'allRelocatable' else None
cc = { n : Recipe(recipeSet, r, [], n+".yaml", cwd, n, n, {}, False)
for n, r in classes.items() }
recipeSet.getClass = lambda x, cc=cc: cc[x]
r = recipe.copy()
r["root"] = True
ret = Recipe(recipeSet, recipe, [], name+".yaml", cwd, name, name, {})
ret.resolveClasses(Env())
return ret.prepare(Env(), False, {})[0].refDeref([], {}, None, None)
def testNormalRelocatable(self):
"""Normal recipes are relocatable by default"""
recipe = {
"packageScript" : "asdf"
}
p = self.parseAndPrepare("foo", recipe)
self.assertTrue(p.isRelocatable())
def testToolsNonRelocatable(self):
"""Recipes providing tools are not relocatable by default"""
recipe = {
"packageScript" : "asdf",
"provideTools" : {
"foo" : "bar"
}
}
p = self.parseAndPrepare("foo", recipe)
self.assertFalse(p.isRelocatable())
def testCheckoutAndBuildStep(self):
"""Checkout and build steps are never relocatable"""
recipe = {
"checkoutScript" : "asdf",
"buildScript" : "asdf",
"packageScript" : "asdf",
}
p = self.parseAndPrepare("foo", recipe)
self.assertFalse(p.getCheckoutStep().isRelocatable())
self.assertFalse(p.getBuildStep().isRelocatable())
self.assertTrue(p.getPackageStep().isRelocatable())
def testToolRelocatable(self):
"""Test that tool can be marked relocable"""
recipe = {
"packageScript" : "asdf",
"provideTools" : {
"foo" : "bar"
},
"relocatable" : True
}
p = self.parseAndPrepare("foo", recipe)
self.assertTrue(p.isRelocatable())
def testNotRelocatable(self):
"""Normal recipes can be marked as not relocatable"""
recipe = {
"packageScript" : "asdf",
"relocatable" : False
}
p = self.parseAndPrepare("foo", recipe)
self.assertFalse(p.isRelocatable())
def testClassCanSetRelocatable(self):
"""Classes can set relocatable flag too"""
# single inheritence
recipe = {
"inherit" : [ "bar" ]
}
classes = {
"bar" : {
"relocatable" : False
}
}
p = self.parseAndPrepare("foo", recipe, classes)
self.assertFalse(p.isRelocatable())
# two-stage inheritence
classes = {
"bar" : {
"inherit" : [ "baz" ],
},
"baz" : {
"relocatable" : False,
}
}
p = self.parseAndPrepare("foo", recipe, classes)
self.assertFalse(p.isRelocatable())
def testClassOverride(self):
"""Inheriting recipe/class overrides inherited relocatable property"""
# two-stage inheritence
recipe = {
"inherit" : [ "bar" ],
}
classes = {
"bar" : {
"inherit" : [ "baz" ],
"relocatable" : False,
},
"baz" : {
"relocatable" : True,
}
}
p = self.parseAndPrepare("foo", recipe, classes)
self.assertFalse(p.isRelocatable())
# recipe overrides classes
recipe = {
"inherit" : [ "bar" ],
"relocatable" : True,
}
p = self.parseAndPrepare("foo", recipe, classes)
self.assertTrue(p.isRelocatable())
def testAllRelocatablePolicy(self):
"""Setting allRelocatable policy will make all packages relocatable"""
# normal package
recipe = {
"packageScript" : "asdf"
}
p = self.parseAndPrepare("foo", recipe, allRelocatable=True)
self.assertTrue(p.isRelocatable())
# tool package
recipe = {
"packageScript" : "asdf",
"provideTools" : {
"foo" : "bar"
}
}
p = self.parseAndPrepare("foo", recipe, allRelocatable=True)
self.assertTrue(p.isRelocatable())
|
gpl-3.0
|
[
199,
504,
2882,
492,
7640,
199,
504,
2882,
14,
1805,
492,
10079,
199,
646,
747,
199,
199,
504,
26961,
14,
2550,
492,
21743,
199,
504,
26961,
14,
1210,
492,
799,
8233,
199,
504,
26961,
14,
13209,
492,
14914,
8493,
199,
504,
26961,
14,
875,
2087,
492,
31543,
199,
199,
533,
1379,
11927,
8,
1746,
304,
339,
347,
10467,
3900,
8,
277,
12,
2397,
12,
536,
12,
2589,
10324,
31336,
29,
797,
12,
675,
6270,
1099,
401,
298,
5846,
2255,
9288,
29,
403,
304,
267,
291,
14,
629,
8,
2373,
14,
13191,
12,
536,
9,
267,
291,
14,
629,
8,
2373,
14,
1813,
11954,
12,
2589,
9,
267,
291,
14,
629,
8,
2373,
14,
20824,
7025,
12,
31336,
9,
267,
291,
14,
629,
8,
2373,
14,
1180,
7744,
12,
298,
5418,
2,
315,
675,
9,
267,
291,
14,
629,
8,
2373,
14,
1180,
11654,
12,
298,
2537,
2,
315,
675,
9,
267,
291,
14,
629,
8,
2373,
14,
1180,
3425,
2889,
12,
298,
1099,
2,
315,
675,
9,
267,
291,
14,
629,
8,
2373,
14,
1180,
27683,
12,
298,
5846,
2,
315,
675,
9,
267,
291,
14,
629,
8,
2373,
14,
1180,
29155,
12,
298,
16647,
2,
315,
675,
9,
267,
291,
14,
629,
8,
2373,
14,
5394,
12,
9288,
9,
339,
347,
511,
3184,
1296,
8,
277,
304,
267,
10140,
275,
359,
298,
65,
401,
298,
66,
2,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
499,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
467,
298,
66,
531,
339,
347,
511,
17899,
1296,
8,
277,
304,
267,
10140,
275,
359,
298,
65,
401,
469,
298,
354,
2,
520,
298,
66,
401,
298,
5418,
2,
520,
469,
298,
1421,
2,
520,
298,
1700,
2,
3586,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
499,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
467,
298,
66,
401,
2589,
8871,
1421,
2,
520,
298,
1700,
2,
3828,
339,
347,
511,
13029,
1296,
8,
277,
304,
267,
10140,
275,
359,
288,
298,
65,
401,
288,
469,
298,
8912,
2,
520,
359,
355,
298,
66,
401,
355,
469,
298,
8912,
2,
520,
359,
298,
67,
2,
1622,
789,
288,
1622,
93,
267,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
650,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
467,
298,
66,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
18,
467,
298,
67,
531,
339,
347,
511,
13029,
7744,
8,
277,
304,
267,
10140,
275,
359,
288,
298,
65,
401,
288,
469,
355,
298,
5418,
2,
520,
469,
298,
1421,
2,
520,
298,
17,
401,
298,
1700,
2,
520,
298,
18,
2,
1660,
355,
298,
8912,
2,
520,
359,
490,
298,
66,
401,
490,
469,
717,
298,
5418,
2,
520,
469,
298,
1700,
2,
520,
298,
19,
401,
298,
6185,
2,
520,
298,
20,
2,
1660,
717,
298,
8912,
2,
520,
359,
298,
67,
2,
1622,
490,
1660,
490,
298,
68,
2,
355,
1622,
288,
1660,
288,
298,
69,
2,
267,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
959,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
467,
298,
66,
401,
2589,
8871,
1421,
2,
520,
298,
17,
401,
298,
1700,
2,
520,
298,
18,
5984,
267,
291,
14,
5730,
3900,
8,
470,
59,
18,
467,
298,
67,
401,
2589,
8871,
1421,
2,
520,
298,
17,
401,
298,
1700,
2,
520,
298,
19,
401,
298,
6185,
2,
520,
298,
20,
5984,
267,
291,
14,
5730,
3900,
8,
470,
59,
19,
467,
298,
68,
401,
2589,
8871,
1421,
2,
520,
298,
17,
401,
298,
1700,
2,
520,
298,
18,
5984,
267,
291,
14,
5730,
3900,
8,
470,
59,
20,
467,
298,
69,
531,
339,
347,
511,
13029,
3917,
8,
277,
304,
267,
10140,
275,
359,
288,
298,
65,
401,
288,
469,
355,
298,
692,
2,
520,
298,
2067,
17,
401,
355,
298,
8912,
2,
520,
359,
490,
298,
66,
401,
490,
469,
717,
298,
692,
2,
520,
298,
2067,
18,
401,
717,
298,
8912,
2,
520,
359,
298,
67,
2,
1622,
490,
1660,
490,
298,
68,
2,
355,
1622,
288,
1660,
288,
298,
69,
2,
267,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
959,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
467,
298,
66,
401,
9288,
6270,
2067,
17,
3135,
267,
291,
14,
5730,
3900,
8,
470,
59,
18,
467,
298,
67,
401,
9288,
6270,
2067,
17,
2266,
2067,
18,
3135,
267,
291,
14,
5730,
3900,
8,
470,
59,
19,
467,
298,
68,
401,
9288,
6270,
2067,
17,
3135,
267,
291,
14,
5730,
3900,
8,
470,
59,
20,
467,
298,
69,
531,
339,
347,
511,
13029,
6119,
8,
277,
304,
267,
10140,
275,
359,
288,
298,
65,
401,
288,
469,
355,
298,
1180,
2,
520,
990,
355,
298,
8912,
2,
520,
359,
490,
298,
66,
401,
490,
469,
717,
298,
1180,
2,
520,
2097,
2537,
2255,
717,
298,
8912,
2,
520,
359,
298,
67,
2,
1622,
490,
1660,
490,
298,
68,
2,
355,
1622,
288,
1660,
288,
298,
69,
2,
267,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
959,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17
] |
[
504,
2882,
492,
7640,
199,
504,
2882,
14,
1805,
492,
10079,
199,
646,
747,
199,
199,
504,
26961,
14,
2550,
492,
21743,
199,
504,
26961,
14,
1210,
492,
799,
8233,
199,
504,
26961,
14,
13209,
492,
14914,
8493,
199,
504,
26961,
14,
875,
2087,
492,
31543,
199,
199,
533,
1379,
11927,
8,
1746,
304,
339,
347,
10467,
3900,
8,
277,
12,
2397,
12,
536,
12,
2589,
10324,
31336,
29,
797,
12,
675,
6270,
1099,
401,
298,
5846,
2255,
9288,
29,
403,
304,
267,
291,
14,
629,
8,
2373,
14,
13191,
12,
536,
9,
267,
291,
14,
629,
8,
2373,
14,
1813,
11954,
12,
2589,
9,
267,
291,
14,
629,
8,
2373,
14,
20824,
7025,
12,
31336,
9,
267,
291,
14,
629,
8,
2373,
14,
1180,
7744,
12,
298,
5418,
2,
315,
675,
9,
267,
291,
14,
629,
8,
2373,
14,
1180,
11654,
12,
298,
2537,
2,
315,
675,
9,
267,
291,
14,
629,
8,
2373,
14,
1180,
3425,
2889,
12,
298,
1099,
2,
315,
675,
9,
267,
291,
14,
629,
8,
2373,
14,
1180,
27683,
12,
298,
5846,
2,
315,
675,
9,
267,
291,
14,
629,
8,
2373,
14,
1180,
29155,
12,
298,
16647,
2,
315,
675,
9,
267,
291,
14,
629,
8,
2373,
14,
5394,
12,
9288,
9,
339,
347,
511,
3184,
1296,
8,
277,
304,
267,
10140,
275,
359,
298,
65,
401,
298,
66,
2,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
499,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
467,
298,
66,
531,
339,
347,
511,
17899,
1296,
8,
277,
304,
267,
10140,
275,
359,
298,
65,
401,
469,
298,
354,
2,
520,
298,
66,
401,
298,
5418,
2,
520,
469,
298,
1421,
2,
520,
298,
1700,
2,
3586,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
499,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
467,
298,
66,
401,
2589,
8871,
1421,
2,
520,
298,
1700,
2,
3828,
339,
347,
511,
13029,
1296,
8,
277,
304,
267,
10140,
275,
359,
288,
298,
65,
401,
288,
469,
298,
8912,
2,
520,
359,
355,
298,
66,
401,
355,
469,
298,
8912,
2,
520,
359,
298,
67,
2,
1622,
789,
288,
1622,
93,
267,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
650,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
467,
298,
66,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
18,
467,
298,
67,
531,
339,
347,
511,
13029,
7744,
8,
277,
304,
267,
10140,
275,
359,
288,
298,
65,
401,
288,
469,
355,
298,
5418,
2,
520,
469,
298,
1421,
2,
520,
298,
17,
401,
298,
1700,
2,
520,
298,
18,
2,
1660,
355,
298,
8912,
2,
520,
359,
490,
298,
66,
401,
490,
469,
717,
298,
5418,
2,
520,
469,
298,
1700,
2,
520,
298,
19,
401,
298,
6185,
2,
520,
298,
20,
2,
1660,
717,
298,
8912,
2,
520,
359,
298,
67,
2,
1622,
490,
1660,
490,
298,
68,
2,
355,
1622,
288,
1660,
288,
298,
69,
2,
267,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
959,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
467,
298,
66,
401,
2589,
8871,
1421,
2,
520,
298,
17,
401,
298,
1700,
2,
520,
298,
18,
5984,
267,
291,
14,
5730,
3900,
8,
470,
59,
18,
467,
298,
67,
401,
2589,
8871,
1421,
2,
520,
298,
17,
401,
298,
1700,
2,
520,
298,
19,
401,
298,
6185,
2,
520,
298,
20,
5984,
267,
291,
14,
5730,
3900,
8,
470,
59,
19,
467,
298,
68,
401,
2589,
8871,
1421,
2,
520,
298,
17,
401,
298,
1700,
2,
520,
298,
18,
5984,
267,
291,
14,
5730,
3900,
8,
470,
59,
20,
467,
298,
69,
531,
339,
347,
511,
13029,
3917,
8,
277,
304,
267,
10140,
275,
359,
288,
298,
65,
401,
288,
469,
355,
298,
692,
2,
520,
298,
2067,
17,
401,
355,
298,
8912,
2,
520,
359,
490,
298,
66,
401,
490,
469,
717,
298,
692,
2,
520,
298,
2067,
18,
401,
717,
298,
8912,
2,
520,
359,
298,
67,
2,
1622,
490,
1660,
490,
298,
68,
2,
355,
1622,
288,
1660,
288,
298,
69,
2,
267,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
959,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
467,
298,
66,
401,
9288,
6270,
2067,
17,
3135,
267,
291,
14,
5730,
3900,
8,
470,
59,
18,
467,
298,
67,
401,
9288,
6270,
2067,
17,
2266,
2067,
18,
3135,
267,
291,
14,
5730,
3900,
8,
470,
59,
19,
467,
298,
68,
401,
9288,
6270,
2067,
17,
3135,
267,
291,
14,
5730,
3900,
8,
470,
59,
20,
467,
298,
69,
531,
339,
347,
511,
13029,
6119,
8,
277,
304,
267,
10140,
275,
359,
288,
298,
65,
401,
288,
469,
355,
298,
1180,
2,
520,
990,
355,
298,
8912,
2,
520,
359,
490,
298,
66,
401,
490,
469,
717,
298,
1180,
2,
520,
2097,
2537,
2255,
717,
298,
8912,
2,
520,
359,
298,
67,
2,
1622,
490,
1660,
490,
298,
68,
2,
355,
1622,
288,
1660,
288,
298,
69,
2,
267,
1622,
267,
522,
275,
769,
8,
25879,
14,
14403,
14,
1122,
17816,
8,
5846,
430,
398,
291,
14,
629,
8,
552,
8,
470,
395,
959,
9,
267,
291,
14,
5730,
3900,
8,
470,
59,
16,
467,
298,
65,
531,
267,
291,
14,
5730,
3900,
8,
470,
59,
17,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
skg-net/ansible
|
lib/ansible/modules/network/nxos/nxos_gir.py
|
30
|
12352
|
#!/usr/bin/python
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'network'}
DOCUMENTATION = '''
---
module: nxos_gir
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Trigger a graceful removal or insertion (GIR) of the switch.
description:
- Trigger a graceful removal or insertion (GIR) of the switch.
author:
- Gabriele Gerbino (@GGabriele)
notes:
- Tested against NXOSv 7.3.(0)D1(1) on VIRL
- C(state) has effect only in combination with
C(system_mode_maintenance_timeout) or
C(system_mode_maintenance_on_reload_reset_reason).
- Using C(system_mode_maintenance) and
C(system_mode_maintenance_dont_generate_profile) would make the module
fail, but the system mode will be triggered anyway.
options:
system_mode_maintenance:
description:
- When C(system_mode_maintenance=true) it puts all enabled
protocols in maintenance mode (using the isolate command).
When C(system_mode_maintenance=false) it puts all enabled
protocols in normal mode (using the no isolate command).
type: bool
system_mode_maintenance_dont_generate_profile:
description:
- When C(system_mode_maintenance_dont_generate_profile=true) it
prevents the dynamic searching of enabled protocols and executes
commands configured in a maintenance-mode profile.
Use this option if you want the system to use a maintenance-mode
profile that you have created.
When C(system_mode_maintenance_dont_generate_profile=false) it
prevents the dynamic searching of enabled protocols and executes
commands configured in a normal-mode profile. Use this option if
you want the system to use a normal-mode profile that
you have created.
type: bool
system_mode_maintenance_timeout:
description:
- Keeps the switch in maintenance mode for a specified
number of minutes. Range is 5-65535.
system_mode_maintenance_shutdown:
description:
- Shuts down all protocols, vPC domains, and interfaces except
the management interface (using the shutdown command).
This option is disruptive while C(system_mode_maintenance)
(which uses the isolate command) is not.
type: bool
system_mode_maintenance_on_reload_reset_reason:
description:
- Boots the switch into maintenance mode automatically in the
event of a specified system crash. Note that not all reset
reasons are applicable for all platforms. Also if reset
reason is set to match_any, it is not idempotent as it turns
on all reset reasons. If reset reason is match_any and state
is absent, it turns off all the reset reasons.
choices: ['hw_error','svc_failure','kern_failure','wdog_timeout',
'fatal_error','lc_failure','match_any','manual_reload',
'any_other', 'maintenance']
state:
description:
- Specify desired state of the resource.
required: true
default: present
choices: ['present','absent']
'''
EXAMPLES = '''
# Trigger system maintenance mode
- nxos_gir:
system_mode_maintenance: true
host: "{{ inventory_hostname }}"
username: "{{ un }}"
password: "{{ pwd }}"
# Trigger system normal mode
- nxos_gir:
system_mode_maintenance: false
host: "{{ inventory_hostname }}"
username: "{{ un }}"
password: "{{ pwd }}"
# Configure on-reload reset-reason for maintenance mode
- nxos_gir:
system_mode_maintenance_on_reload_reset_reason: manual_reload
state: present
host: "{{ inventory_hostname }}"
username: "{{ un }}"
password: "{{ pwd }}"
# Add on-reload reset-reason for maintenance mode
- nxos_gir:
system_mode_maintenance_on_reload_reset_reason: hw_error
state: present
host: "{{ inventory_hostname }}"
username: "{{ un }}"
password: "{{ pwd }}"
# Remove on-reload reset-reason for maintenance mode
- nxos_gir:
system_mode_maintenance_on_reload_reset_reason: manual_reload
state: absent
host: "{{ inventory_hostname }}"
username: "{{ un }}"
password: "{{ pwd }}"
# Set timeout for maintenance mode
- nxos_gir:
system_mode_maintenance_timeout: 30
state: present
host: "{{ inventory_hostname }}"
username: "{{ un }}"
password: "{{ pwd }}"
# Remove timeout for maintenance mode
- nxos_gir:
system_mode_maintenance_timeout: 30
state: absent
host: "{{ inventory_hostname }}"
username: "{{ un }}"
password: "{{ pwd }}"
'''
RETURN = '''
final_system_mode:
description: describe the last system mode
returned: verbose mode
type: string
sample: normal
updates:
description: commands sent to the device
returned: verbose mode
type: list
sample: ["terminal dont-ask", "system mode maintenance timeout 10"]
changed:
description: check to see if a change was made on the device
returned: always
type: boolean
sample: true
'''
import re
from ansible.module_utils.network.nxos.nxos import get_config, load_config, run_commands
from ansible.module_utils.network.nxos.nxos import get_capabilities, nxos_argument_spec
from ansible.module_utils.basic import AnsibleModule
def get_system_mode(module):
command = {'command': 'show system mode', 'output': 'text'}
body = run_commands(module, [command])[0]
if body and 'normal' in body.lower():
mode = 'normal'
else:
mode = 'maintenance'
return mode
def get_maintenance_timeout(module):
command = {'command': 'show maintenance timeout', 'output': 'text'}
body = run_commands(module, [command])[0]
timeout = body.split()[4]
return timeout
def get_reset_reasons(module):
command = {'command': 'show maintenance on-reload reset-reasons', 'output': 'text'}
body = run_commands(module, [command])[0]
return body
def get_commands(module, state, mode):
commands = list()
system_mode = ''
if module.params['system_mode_maintenance'] is True and mode == 'normal':
commands.append('system mode maintenance')
elif (module.params['system_mode_maintenance'] is False and
mode == 'maintenance'):
commands.append('no system mode maintenance')
elif (module.params[
'system_mode_maintenance_dont_generate_profile'] is True and
mode == 'normal'):
commands.append('system mode maintenance dont-generate-profile')
elif (module.params[
'system_mode_maintenance_dont_generate_profile'] is False and
mode == 'maintenance'):
commands.append('no system mode maintenance dont-generate-profile')
elif module.params['system_mode_maintenance_timeout']:
timeout = get_maintenance_timeout(module)
if (state == 'present' and
timeout != module.params['system_mode_maintenance_timeout']):
commands.append('system mode maintenance timeout {0}'.format(
module.params['system_mode_maintenance_timeout']))
elif (state == 'absent' and
timeout == module.params['system_mode_maintenance_timeout']):
commands.append('no system mode maintenance timeout {0}'.format(
module.params['system_mode_maintenance_timeout']))
elif (module.params['system_mode_maintenance_shutdown'] and
mode == 'normal'):
commands.append('system mode maintenance shutdown')
elif (module.params[
'system_mode_maintenance_shutdown'] is False and
mode == 'maintenance'):
commands.append('no system mode maintenance')
elif module.params['system_mode_maintenance_on_reload_reset_reason']:
reset_reasons = get_reset_reasons(module)
if (state == 'present' and
module.params['system_mode_maintenance_on_reload_reset_reason'].lower() not in reset_reasons.lower()):
commands.append('system mode maintenance on-reload '
'reset-reason {0}'.format(
module.params[
'system_mode_maintenance_on_reload_reset_reason']))
elif (state == 'absent' and
module.params[
'system_mode_maintenance_on_reload_reset_reason'].lower() in
reset_reasons.lower()):
commands.append('no system mode maintenance on-reload '
'reset-reason {0}'.format(
module.params[
'system_mode_maintenance_on_reload_reset_reason']))
if commands:
commands.insert(0, 'terminal dont-ask')
return commands
def main():
argument_spec = dict(
system_mode_maintenance=dict(required=False, type='bool'),
system_mode_maintenance_dont_generate_profile=dict(required=False,
type='bool'),
system_mode_maintenance_timeout=dict(required=False, type='str'),
system_mode_maintenance_shutdown=dict(required=False, type='bool'),
system_mode_maintenance_on_reload_reset_reason=dict(required=False,
choices=['hw_error', 'svc_failure', 'kern_failure',
'wdog_timeout', 'fatal_error', 'lc_failure',
'match_any', 'manual_reload', 'any_other',
'maintenance']),
state=dict(choices=['absent', 'present', 'default'],
default='present', required=False)
)
argument_spec.update(nxos_argument_spec)
module = AnsibleModule(argument_spec=argument_spec,
mutually_exclusive=[[
'system_mode_maintenance',
'system_mode_maintenance_dont_generate_profile',
'system_mode_maintenance_timeout',
'system_mode_maintenance_shutdown',
'system_mode_maintenance_on_reload_reset_reason'
]],
required_one_of=[[
'system_mode_maintenance',
'system_mode_maintenance_dont_generate_profile',
'system_mode_maintenance_timeout',
'system_mode_maintenance_shutdown',
'system_mode_maintenance_on_reload_reset_reason'
]],
supports_check_mode=True)
warnings = list()
state = module.params['state']
mode = get_system_mode(module)
commands = get_commands(module, state, mode)
changed = False
if commands:
if module.check_mode:
module.exit_json(changed=True, commands=commands)
else:
load_config(module, commands)
changed = True
result = {}
result['changed'] = changed
if module._verbosity > 0:
final_system_mode = get_system_mode(module)
result['final_system_mode'] = final_system_mode
result['updates'] = commands
result['warnings'] = warnings
module.exit_json(**result)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
1200,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
22072,
63,
71,
723,
199,
11036,
63,
9970,
63,
7677,
26,
22072,
199,
1023,
63,
3270,
26,
298,
18,
14,
18,
2,
199,
3612,
63,
1802,
26,
24015,
282,
19756,
1893,
20055,
503,
22470,
334,
39,
3927,
9,
402,
314,
6258,
14,
199,
1802,
26,
272,
446,
24015,
282,
19756,
1893,
20055,
503,
22470,
334,
39,
3927,
9,
402,
314,
6258,
14,
199,
2502,
26,
272,
446,
598,
371,
322,
8081,
22261,
1393,
79,
8593,
2916,
371,
322,
8081,
9,
199,
5983,
26,
272,
446,
30568,
6169,
653,
56,
3100,
86,
1520,
14,
19,
14,
8,
16,
9,
36,
17,
8,
17,
9,
641,
812,
41,
2431,
272,
446,
445,
8,
929,
9,
965,
7763,
1454,
315,
14665,
543,
489,
445,
8,
2253,
63,
632,
63,
19725,
63,
2593,
9,
503,
489,
445,
8,
2253,
63,
632,
63,
19725,
63,
265,
63,
9233,
63,
3958,
63,
5764,
680,
272,
446,
11719,
445,
8,
2253,
63,
632,
63,
19725,
9,
436,
489,
445,
8,
2253,
63,
632,
63,
19725,
63,
18671,
63,
4208,
63,
2913,
9,
3955,
1852,
314,
859,
489,
2449,
12,
1325,
314,
2656,
818,
911,
506,
15572,
15988,
14,
199,
1419,
26,
272,
2656,
63,
632,
63,
19725,
26,
267,
1369,
26,
288,
446,
3979,
445,
8,
2253,
63,
632,
63,
19725,
29,
2052,
9,
652,
27000,
1006,
5223,
1598,
19230,
315,
21964,
818,
334,
4941,
314,
365,
16288,
1414,
680,
1598,
3979,
445,
8,
2253,
63,
632,
63,
19725,
29,
3910,
9,
652,
27000,
1006,
5223,
1598,
19230,
315,
3293,
818,
334,
4941,
314,
949,
365,
16288,
1414,
680,
267,
730,
26,
2155,
272,
2656,
63,
632,
63,
19725,
63,
18671,
63,
4208,
63,
2913,
26,
267,
1369,
26,
288,
446,
3979,
445,
8,
2253,
63,
632,
63,
19725,
63,
18671,
63,
4208,
63,
2913,
29,
2052,
9,
652,
1598,
21925,
314,
8336,
18112,
402,
5223,
19230,
436,
24956,
1598,
3718,
7526,
315,
282,
21964,
13,
632,
4690,
14,
1598,
3645,
642,
945,
340,
1265,
2934,
314,
2656,
370,
675,
282,
21964,
13,
632,
1598,
4690,
626,
1265,
1172,
2737,
14,
1598,
3979,
445,
8,
2253,
63,
632,
63,
19725,
63,
18671,
63,
4208,
63,
2913,
29,
3910,
9,
652,
1598,
21925,
314,
8336,
18112,
402,
5223,
19230,
436,
24956,
1598,
3718,
7526,
315,
282,
3293,
13,
632,
4690,
14,
3645,
642,
945,
340,
1598,
1265,
2934,
314,
2656,
370,
675,
282,
3293,
13,
632,
4690,
626,
1598,
1265,
1172,
2737,
14,
267,
730,
26,
2155,
272,
2656,
63,
632,
63,
19725,
63,
2593,
26,
267,
1369,
26,
288,
446,
1804,
1024,
1190,
314,
6258,
315,
21964,
818,
367,
282,
2013,
1598,
1329,
402,
9395,
14,
13114,
365,
959,
13,
26439,
14,
272,
2656,
63,
632,
63,
19725,
63,
8831,
26,
267,
1369,
26,
288,
446,
5244,
14608,
3224,
1006,
19230,
12,
373,
4222,
14006,
12,
436,
8386,
871,
1598,
314,
10041,
3217,
334,
4941,
314,
12842,
1414,
680,
1598,
961,
945,
365,
2153,
5505,
857,
1830,
445,
8,
2253,
63,
632,
63,
19725,
9,
1598,
334,
6777,
4440,
314,
365,
16288,
1414,
9,
365,
440,
14,
267,
730,
26,
2155,
272,
2656,
63,
632,
63,
19725,
63,
265,
63,
9233,
63,
3958,
63,
5764,
26,
267,
1369,
26,
288,
446,
5088,
16673,
314,
6258,
1901,
21964,
818,
5847,
315,
314,
1598,
1566,
402,
282,
2013,
2656,
12420,
14,
3390,
626,
440,
1006,
5305,
1598,
14872,
787,
3964,
367,
1006,
10677,
14,
6121,
340,
5305,
1598,
4499,
365,
663,
370,
1336,
63,
1629,
12,
652,
365,
440,
32122,
465,
652,
25449,
1598,
641,
1006,
5305,
14872,
14,
982,
5305,
4499,
365,
1336,
63,
1629,
436,
1174,
1598,
365,
9552,
12,
652,
25449,
2331,
1006,
314,
5305,
14872,
14,
267,
3415,
26,
788,
8090,
63,
705,
1673,
10599,
63,
5328,
1673,
30136,
63,
5328,
1673,
2989,
974,
63,
2593,
297,
2116,
283,
16208,
63,
705,
1673,
10181,
63,
5328,
1673,
1431,
63,
1629,
1673,
9285,
63,
9233,
297,
2116,
283,
1629,
63,
1848,
297,
283,
19725,
418,
272,
1174,
26,
267,
1369,
26,
288,
446,
13327,
6387,
1174,
402,
314,
2073,
14,
267,
1415,
26,
2549,
267,
849,
26,
3451,
267,
3415,
26,
788,
1881,
1673,
5575,
418,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
24015,
2656,
21964,
818,
199,
13,
22072,
63,
71,
723,
26,
272,
2656,
63,
632,
63,
19725,
26,
2549,
272,
1591,
26,
7370,
8200,
63,
4269,
7820,
272,
3434,
26,
7370,
625,
7820,
272,
2505,
26,
7370,
14374,
7820,
199,
3,
24015,
2656,
3293,
818,
199,
13,
22072,
63,
71,
723,
26,
272,
2656,
63,
632,
63,
19725,
26,
3055,
272,
1591,
26,
7370,
8200,
63,
4269,
7820,
272,
3434,
26,
7370,
625,
7820,
272,
2505,
26,
7370,
14374,
7820,
199,
3,
15453,
641,
13,
9233,
5305,
13,
5764,
367,
21964,
818,
199,
13,
22072,
63,
71,
723,
26,
272,
2656,
63,
632,
63,
19725,
63,
265,
63,
9233,
63,
3958,
63,
5764,
26,
8722,
63,
9233
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
1200,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
22072,
63,
71,
723,
199,
11036,
63,
9970,
63,
7677,
26,
22072,
199,
1023,
63,
3270,
26,
298,
18,
14,
18,
2,
199,
3612,
63,
1802,
26,
24015,
282,
19756,
1893,
20055,
503,
22470,
334,
39,
3927,
9,
402,
314,
6258,
14,
199,
1802,
26,
272,
446,
24015,
282,
19756,
1893,
20055,
503,
22470,
334,
39,
3927,
9,
402,
314,
6258,
14,
199,
2502,
26,
272,
446,
598,
371,
322,
8081,
22261,
1393,
79,
8593,
2916,
371,
322,
8081,
9,
199,
5983,
26,
272,
446,
30568,
6169,
653,
56,
3100,
86,
1520,
14,
19,
14,
8,
16,
9,
36,
17,
8,
17,
9,
641,
812,
41,
2431,
272,
446,
445,
8,
929,
9,
965,
7763,
1454,
315,
14665,
543,
489,
445,
8,
2253,
63,
632,
63,
19725,
63,
2593,
9,
503,
489,
445,
8,
2253,
63,
632,
63,
19725,
63,
265,
63,
9233,
63,
3958,
63,
5764,
680,
272,
446,
11719,
445,
8,
2253,
63,
632,
63,
19725,
9,
436,
489,
445,
8,
2253,
63,
632,
63,
19725,
63,
18671,
63,
4208,
63,
2913,
9,
3955,
1852,
314,
859,
489,
2449,
12,
1325,
314,
2656,
818,
911,
506,
15572,
15988,
14,
199,
1419,
26,
272,
2656,
63,
632,
63,
19725,
26,
267,
1369,
26,
288,
446,
3979,
445,
8,
2253,
63,
632,
63,
19725,
29,
2052,
9,
652,
27000,
1006,
5223,
1598,
19230,
315,
21964,
818,
334,
4941,
314,
365,
16288,
1414,
680,
1598,
3979,
445,
8,
2253,
63,
632,
63,
19725,
29,
3910,
9,
652,
27000,
1006,
5223,
1598,
19230,
315,
3293,
818,
334,
4941,
314,
949,
365,
16288,
1414,
680,
267,
730,
26,
2155,
272,
2656,
63,
632,
63,
19725,
63,
18671,
63,
4208,
63,
2913,
26,
267,
1369,
26,
288,
446,
3979,
445,
8,
2253,
63,
632,
63,
19725,
63,
18671,
63,
4208,
63,
2913,
29,
2052,
9,
652,
1598,
21925,
314,
8336,
18112,
402,
5223,
19230,
436,
24956,
1598,
3718,
7526,
315,
282,
21964,
13,
632,
4690,
14,
1598,
3645,
642,
945,
340,
1265,
2934,
314,
2656,
370,
675,
282,
21964,
13,
632,
1598,
4690,
626,
1265,
1172,
2737,
14,
1598,
3979,
445,
8,
2253,
63,
632,
63,
19725,
63,
18671,
63,
4208,
63,
2913,
29,
3910,
9,
652,
1598,
21925,
314,
8336,
18112,
402,
5223,
19230,
436,
24956,
1598,
3718,
7526,
315,
282,
3293,
13,
632,
4690,
14,
3645,
642,
945,
340,
1598,
1265,
2934,
314,
2656,
370,
675,
282,
3293,
13,
632,
4690,
626,
1598,
1265,
1172,
2737,
14,
267,
730,
26,
2155,
272,
2656,
63,
632,
63,
19725,
63,
2593,
26,
267,
1369,
26,
288,
446,
1804,
1024,
1190,
314,
6258,
315,
21964,
818,
367,
282,
2013,
1598,
1329,
402,
9395,
14,
13114,
365,
959,
13,
26439,
14,
272,
2656,
63,
632,
63,
19725,
63,
8831,
26,
267,
1369,
26,
288,
446,
5244,
14608,
3224,
1006,
19230,
12,
373,
4222,
14006,
12,
436,
8386,
871,
1598,
314,
10041,
3217,
334,
4941,
314,
12842,
1414,
680,
1598,
961,
945,
365,
2153,
5505,
857,
1830,
445,
8,
2253,
63,
632,
63,
19725,
9,
1598,
334,
6777,
4440,
314,
365,
16288,
1414,
9,
365,
440,
14,
267,
730,
26,
2155,
272,
2656,
63,
632,
63,
19725,
63,
265,
63,
9233,
63,
3958,
63,
5764,
26,
267,
1369,
26,
288,
446,
5088,
16673,
314,
6258,
1901,
21964,
818,
5847,
315,
314,
1598,
1566,
402,
282,
2013,
2656,
12420,
14,
3390,
626,
440,
1006,
5305,
1598,
14872,
787,
3964,
367,
1006,
10677,
14,
6121,
340,
5305,
1598,
4499,
365,
663,
370,
1336,
63,
1629,
12,
652,
365,
440,
32122,
465,
652,
25449,
1598,
641,
1006,
5305,
14872,
14,
982,
5305,
4499,
365,
1336,
63,
1629,
436,
1174,
1598,
365,
9552,
12,
652,
25449,
2331,
1006,
314,
5305,
14872,
14,
267,
3415,
26,
788,
8090,
63,
705,
1673,
10599,
63,
5328,
1673,
30136,
63,
5328,
1673,
2989,
974,
63,
2593,
297,
2116,
283,
16208,
63,
705,
1673,
10181,
63,
5328,
1673,
1431,
63,
1629,
1673,
9285,
63,
9233,
297,
2116,
283,
1629,
63,
1848,
297,
283,
19725,
418,
272,
1174,
26,
267,
1369,
26,
288,
446,
13327,
6387,
1174,
402,
314,
2073,
14,
267,
1415,
26,
2549,
267,
849,
26,
3451,
267,
3415,
26,
788,
1881,
1673,
5575,
418,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
24015,
2656,
21964,
818,
199,
13,
22072,
63,
71,
723,
26,
272,
2656,
63,
632,
63,
19725,
26,
2549,
272,
1591,
26,
7370,
8200,
63,
4269,
7820,
272,
3434,
26,
7370,
625,
7820,
272,
2505,
26,
7370,
14374,
7820,
199,
3,
24015,
2656,
3293,
818,
199,
13,
22072,
63,
71,
723,
26,
272,
2656,
63,
632,
63,
19725,
26,
3055,
272,
1591,
26,
7370,
8200,
63,
4269,
7820,
272,
3434,
26,
7370,
625,
7820,
272,
2505,
26,
7370,
14374,
7820,
199,
3,
15453,
641,
13,
9233,
5305,
13,
5764,
367,
21964,
818,
199,
13,
22072,
63,
71,
723,
26,
272,
2656,
63,
632,
63,
19725,
63,
265,
63,
9233,
63,
3958,
63,
5764,
26,
8722,
63,
9233,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
kurgm/gwv
|
gwv/validators/kosekitoki.py
|
1
|
1899
|
from gwv.dump import Dump
import gwv.filters as filters
from gwv.kagedata import KageData
from gwv.validators import Validator
from gwv.validators import ErrorCodes
error_codes = ErrorCodes(
NOT_ALIAS="0", # エイリアスでない(し、koseki-xxxxx0がtoki-00xxxxx0のエイリアスというわけでもない)
NOT_ALIAS_OF_KOSEKI="1", # koseki-xxxxx0のエイリアスでない
NOT_ALIAS_OF_ENTITY_OF_KOSEKI="2", # koseki-xxxxx0と異なる実体のエイリアス
)
class KosekitokiValidator(Validator):
name = "kosekitoki"
@filters.check_only(+filters.is_of_category({"toki"}))
def is_invalid(self, name: str, related: str, kage: KageData, gdata: str,
dump: Dump):
header = name[:7]
if header != "toki-00":
return False
koseki_name = "koseki-" + name[7:]
koseki_entity = koseki_name
koseki_gdata = dump.get(koseki_name)[1]
if koseki_gdata is not None:
koseki_kage = KageData(koseki_gdata)
if koseki_kage.is_alias:
koseki_entity = koseki_kage.lines[0].part_name
if not kage.is_alias:
entity = name
if entity != koseki_entity:
# エイリアスでない(し、koseki-xxxxx0がtoki-00xxxxx0のエイリアスというわけでもない)
return [error_codes.NOT_ALIAS]
else:
entity = kage.lines[0].part_name
if entity != koseki_entity:
if koseki_entity == koseki_name:
# koseki-xxxxx0のエイリアスでない
return [error_codes.NOT_ALIAS_OF_KOSEKI, entity]
# koseki-xxxxx0と異なる実体のエイリアス
return [
error_codes.NOT_ALIAS_OF_ENTITY_OF_KOSEKI,
entity, koseki_entity]
return False
|
mit
|
[
504,
22192,
86,
14,
2724,
492,
19460,
199,
646,
22192,
86,
14,
4273,
465,
4766,
199,
504,
22192,
86,
14,
75,
474,
576,
492,
1804,
474,
1451,
199,
504,
22192,
86,
14,
11346,
492,
4821,
707,
199,
504,
22192,
86,
14,
11346,
492,
4520,
14060,
421,
199,
705,
63,
6021,
275,
4520,
14060,
8,
272,
2845,
63,
12644,
628,
16,
401,
221,
327,
221,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
31221,
4197,
104,
20724,
8454,
231,
4197,
246,
23709,
75,
3362,
8810,
13,
5336,
88,
16,
32143,
475,
8810,
13,
383,
5336,
88,
16,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
29472,
20724,
28075,
5573,
238,
4197,
240,
31221,
5573,
225,
4197,
104,
20724,
8454,
232,
272,
2845,
63,
12644,
63,
3359,
63,
24839,
899,
16944,
628,
17,
401,
221,
327,
1022,
3362,
8810,
13,
5336,
88,
16,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
31221,
4197,
104,
20724,
272,
2845,
63,
12644,
63,
3359,
63,
13630,
63,
3359,
63,
24839,
899,
16944,
628,
18,
401,
221,
327,
1022,
3362,
8810,
13,
5336,
88,
16,
29472,
26546,
109,
4197,
104,
25871,
10270,
254,
11046,
242,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
199,
9,
421,
199,
533,
1804,
3362,
6065,
745,
73,
8640,
8,
8640,
304,
339,
536,
275,
298,
75,
3362,
6065,
745,
73,
2,
339,
768,
4273,
14,
1074,
63,
2118,
24303,
4273,
14,
374,
63,
1618,
63,
3710,
6333,
475,
8810,
3570,
430,
272,
347,
365,
63,
3197,
8,
277,
12,
536,
26,
620,
12,
4048,
26,
620,
12,
1022,
474,
26,
1804,
474,
1451,
12,
11006,
26,
620,
12,
673,
5461,
26,
19460,
304,
267,
1406,
275,
536,
1491,
23,
61,
267,
340,
1406,
1137,
298,
475,
8810,
13,
383,
582,
288,
372,
756,
398,
1022,
3362,
8810,
63,
354,
275,
298,
75,
3362,
8810,
23245,
435,
536,
59,
23,
2938,
267,
1022,
3362,
8810,
63,
4502,
275,
1022,
3362,
8810,
63,
354,
398,
1022,
3362,
8810,
63,
15275,
275,
5461,
14,
362,
8,
75,
3362,
8810,
63,
354,
2788,
17,
61,
267,
340,
1022,
3362,
8810,
63,
15275,
365,
440,
488,
26,
288,
1022,
3362,
8810,
63,
75,
474,
275,
1804,
474,
1451,
8,
75,
3362,
8810,
63,
15275,
9,
288,
340,
1022,
3362,
8810,
63,
75,
474,
14,
374,
63,
3620,
26,
355,
1022,
3362,
8810,
63,
4502,
275,
1022,
3362,
8810,
63,
75,
474,
14,
1278,
59,
16,
1055,
2064,
63,
354,
398,
340,
440,
1022,
474,
14,
374,
63,
3620,
26,
288,
4642,
275,
536,
288,
340,
4642,
1137,
1022,
3362,
8810,
63,
4502,
26,
355,
327,
221,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
31221,
4197,
104,
20724,
8454,
231,
4197,
246,
23709,
75,
3362,
8810,
13,
5336,
88,
16,
32143,
475,
8810,
13,
383,
5336,
88,
16,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
29472,
20724,
28075,
5573,
238,
4197,
240,
31221,
5573,
225,
4197,
104,
20724,
8454,
232,
355,
372,
359,
705,
63,
6021,
14,
4609,
63,
12644,
61,
267,
587,
26,
288,
4642,
275,
1022,
474,
14,
1278,
59,
16,
1055,
2064,
63,
354,
288,
340,
4642,
1137,
1022,
3362,
8810,
63,
4502,
26,
355,
340,
1022,
3362,
8810,
63,
4502,
508,
1022,
3362,
8810,
63,
354,
26,
490,
327,
1022,
3362,
8810,
13,
5336,
88,
16,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
31221,
4197,
104,
20724,
490,
372,
359,
705,
63,
6021,
14,
4609,
63,
12644,
63,
3359,
63,
24839,
899,
16944,
12,
4642,
61,
355,
327,
1022,
3362,
8810,
13,
5336,
88,
16,
29472,
26546,
109,
4197,
104,
25871,
10270,
254,
11046,
242,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
355,
372,
359,
490,
1125,
63,
6021,
14,
4609,
63,
12644,
63,
3359,
63,
13630,
63,
3359,
63,
24839,
899,
16944,
12,
490,
4642,
12,
1022,
3362,
8810,
63,
4502,
61,
267,
372,
756,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
22192,
86,
14,
2724,
492,
19460,
199,
646,
22192,
86,
14,
4273,
465,
4766,
199,
504,
22192,
86,
14,
75,
474,
576,
492,
1804,
474,
1451,
199,
504,
22192,
86,
14,
11346,
492,
4821,
707,
199,
504,
22192,
86,
14,
11346,
492,
4520,
14060,
421,
199,
705,
63,
6021,
275,
4520,
14060,
8,
272,
2845,
63,
12644,
628,
16,
401,
221,
327,
221,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
31221,
4197,
104,
20724,
8454,
231,
4197,
246,
23709,
75,
3362,
8810,
13,
5336,
88,
16,
32143,
475,
8810,
13,
383,
5336,
88,
16,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
29472,
20724,
28075,
5573,
238,
4197,
240,
31221,
5573,
225,
4197,
104,
20724,
8454,
232,
272,
2845,
63,
12644,
63,
3359,
63,
24839,
899,
16944,
628,
17,
401,
221,
327,
1022,
3362,
8810,
13,
5336,
88,
16,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
31221,
4197,
104,
20724,
272,
2845,
63,
12644,
63,
3359,
63,
13630,
63,
3359,
63,
24839,
899,
16944,
628,
18,
401,
221,
327,
1022,
3362,
8810,
13,
5336,
88,
16,
29472,
26546,
109,
4197,
104,
25871,
10270,
254,
11046,
242,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
199,
9,
421,
199,
533,
1804,
3362,
6065,
745,
73,
8640,
8,
8640,
304,
339,
536,
275,
298,
75,
3362,
6065,
745,
73,
2,
339,
768,
4273,
14,
1074,
63,
2118,
24303,
4273,
14,
374,
63,
1618,
63,
3710,
6333,
475,
8810,
3570,
430,
272,
347,
365,
63,
3197,
8,
277,
12,
536,
26,
620,
12,
4048,
26,
620,
12,
1022,
474,
26,
1804,
474,
1451,
12,
11006,
26,
620,
12,
673,
5461,
26,
19460,
304,
267,
1406,
275,
536,
1491,
23,
61,
267,
340,
1406,
1137,
298,
475,
8810,
13,
383,
582,
288,
372,
756,
398,
1022,
3362,
8810,
63,
354,
275,
298,
75,
3362,
8810,
23245,
435,
536,
59,
23,
2938,
267,
1022,
3362,
8810,
63,
4502,
275,
1022,
3362,
8810,
63,
354,
398,
1022,
3362,
8810,
63,
15275,
275,
5461,
14,
362,
8,
75,
3362,
8810,
63,
354,
2788,
17,
61,
267,
340,
1022,
3362,
8810,
63,
15275,
365,
440,
488,
26,
288,
1022,
3362,
8810,
63,
75,
474,
275,
1804,
474,
1451,
8,
75,
3362,
8810,
63,
15275,
9,
288,
340,
1022,
3362,
8810,
63,
75,
474,
14,
374,
63,
3620,
26,
355,
1022,
3362,
8810,
63,
4502,
275,
1022,
3362,
8810,
63,
75,
474,
14,
1278,
59,
16,
1055,
2064,
63,
354,
398,
340,
440,
1022,
474,
14,
374,
63,
3620,
26,
288,
4642,
275,
536,
288,
340,
4642,
1137,
1022,
3362,
8810,
63,
4502,
26,
355,
327,
221,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
31221,
4197,
104,
20724,
8454,
231,
4197,
246,
23709,
75,
3362,
8810,
13,
5336,
88,
16,
32143,
475,
8810,
13,
383,
5336,
88,
16,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
29472,
20724,
28075,
5573,
238,
4197,
240,
31221,
5573,
225,
4197,
104,
20724,
8454,
232,
355,
372,
359,
705,
63,
6021,
14,
4609,
63,
12644,
61,
267,
587,
26,
288,
4642,
275,
1022,
474,
14,
1278,
59,
16,
1055,
2064,
63,
354,
288,
340,
4642,
1137,
1022,
3362,
8810,
63,
4502,
26,
355,
340,
1022,
3362,
8810,
63,
4502,
508,
1022,
3362,
8810,
63,
354,
26,
490,
327,
1022,
3362,
8810,
13,
5336,
88,
16,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
31221,
4197,
104,
20724,
490,
372,
359,
705,
63,
6021,
14,
4609,
63,
12644,
63,
3359,
63,
24839,
899,
16944,
12,
4642,
61,
355,
327,
1022,
3362,
8810,
13,
5336,
88,
16,
29472,
26546,
109,
4197,
104,
25871,
10270,
254,
11046,
242,
14741,
5573,
102,
26873,
5692,
104,
5573,
96,
25111,
355,
372,
359,
490,
1125,
63,
6021,
14,
4609,
63,
12644,
63,
3359,
63,
13630,
63,
3359,
63,
24839,
899,
16944,
12,
490,
4642,
12,
1022,
3362,
8810,
63,
4502,
61,
267,
372,
756,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
Wafflespeanut/servo
|
tests/wpt/web-platform-tests/tools/py/testing/root/test_error.py
|
162
|
1111
|
import py
import errno
def test_error_classes():
for name in errno.errorcode.values():
x = getattr(py.error, name)
assert issubclass(x, py.error.Error)
assert issubclass(x, EnvironmentError)
def test_picklability_issue1():
e1 = py.error.ENOENT()
s = py.std.pickle.dumps(e1)
e2 = py.std.pickle.loads(s)
assert isinstance(e2, py.error.ENOENT)
def test_unknown_error():
num = 3999
cls = py.error._geterrnoclass(num)
assert cls.__name__ == 'UnknownErrno%d' % (num,)
assert issubclass(cls, py.error.Error)
assert issubclass(cls, EnvironmentError)
cls2 = py.error._geterrnoclass(num)
assert cls is cls2
def test_error_conversion_ENOTDIR(testdir):
p = testdir.makepyfile("")
excinfo = py.test.raises(py.error.Error, py.error.checked_call, p.listdir)
assert isinstance(excinfo.value, EnvironmentError)
assert isinstance(excinfo.value, py.error.Error)
assert "ENOTDIR" in repr(excinfo.value)
def test_checked_call_supports_kwargs(tmpdir):
import tempfile
py.error.checked_call(tempfile.mkdtemp, dir=str(tmpdir))
|
mpl-2.0
|
[
199,
646,
1134,
199,
199,
646,
7554,
199,
199,
318,
511,
63,
705,
63,
2888,
837,
272,
367,
536,
315,
7554,
14,
28857,
14,
1459,
837,
267,
671,
275,
2519,
8,
647,
14,
705,
12,
536,
9,
267,
702,
11602,
8,
88,
12,
1134,
14,
705,
14,
547,
9,
267,
702,
11602,
8,
88,
12,
25139,
9,
199,
199,
318,
511,
63,
4510,
76,
3616,
63,
5237,
17,
837,
272,
325,
17,
275,
1134,
14,
705,
14,
20465,
342,
272,
308,
275,
1134,
14,
1516,
14,
8092,
14,
4180,
8,
69,
17,
9,
272,
325,
18,
275,
1134,
14,
1516,
14,
8092,
14,
3640,
8,
83,
9,
272,
702,
1228,
8,
69,
18,
12,
1134,
14,
705,
14,
20465,
9,
199,
199,
318,
511,
63,
5187,
63,
705,
837,
272,
1967,
275,
650,
5637,
272,
843,
275,
1134,
14,
705,
423,
303,
22406,
889,
533,
8,
1507,
9,
272,
702,
843,
855,
354,
363,
508,
283,
5912,
23288,
5,
68,
7,
450,
334,
1507,
4258,
272,
702,
11602,
8,
1886,
12,
1134,
14,
705,
14,
547,
9,
272,
702,
11602,
8,
1886,
12,
25139,
9,
272,
843,
18,
275,
1134,
14,
705,
423,
303,
22406,
889,
533,
8,
1507,
9,
272,
702,
843,
365,
843,
18,
199,
199,
318,
511,
63,
705,
63,
15083,
63,
32710,
3022,
8,
16634,
304,
272,
299,
275,
7368,
14,
17358,
10804,
272,
21596,
275,
1134,
14,
396,
14,
3536,
8,
647,
14,
705,
14,
547,
12,
1134,
14,
705,
14,
10718,
63,
1250,
12,
299,
14,
7374,
9,
272,
702,
1228,
8,
27447,
14,
585,
12,
25139,
9,
272,
702,
1228,
8,
27447,
14,
585,
12,
1134,
14,
705,
14,
547,
9,
272,
702,
298,
32710,
3022,
2,
315,
4700,
8,
27447,
14,
585,
9,
421,
199,
318,
511,
63,
10718,
63,
1250,
63,
9823,
63,
958,
8,
8616,
304,
272,
492,
5549,
272,
1134,
14,
705,
14,
10718,
63,
1250,
8,
17336,
14,
11983,
12,
2935,
29,
495,
8,
8616,
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
] |
[
646,
1134,
199,
199,
646,
7554,
199,
199,
318,
511,
63,
705,
63,
2888,
837,
272,
367,
536,
315,
7554,
14,
28857,
14,
1459,
837,
267,
671,
275,
2519,
8,
647,
14,
705,
12,
536,
9,
267,
702,
11602,
8,
88,
12,
1134,
14,
705,
14,
547,
9,
267,
702,
11602,
8,
88,
12,
25139,
9,
199,
199,
318,
511,
63,
4510,
76,
3616,
63,
5237,
17,
837,
272,
325,
17,
275,
1134,
14,
705,
14,
20465,
342,
272,
308,
275,
1134,
14,
1516,
14,
8092,
14,
4180,
8,
69,
17,
9,
272,
325,
18,
275,
1134,
14,
1516,
14,
8092,
14,
3640,
8,
83,
9,
272,
702,
1228,
8,
69,
18,
12,
1134,
14,
705,
14,
20465,
9,
199,
199,
318,
511,
63,
5187,
63,
705,
837,
272,
1967,
275,
650,
5637,
272,
843,
275,
1134,
14,
705,
423,
303,
22406,
889,
533,
8,
1507,
9,
272,
702,
843,
855,
354,
363,
508,
283,
5912,
23288,
5,
68,
7,
450,
334,
1507,
4258,
272,
702,
11602,
8,
1886,
12,
1134,
14,
705,
14,
547,
9,
272,
702,
11602,
8,
1886,
12,
25139,
9,
272,
843,
18,
275,
1134,
14,
705,
423,
303,
22406,
889,
533,
8,
1507,
9,
272,
702,
843,
365,
843,
18,
199,
199,
318,
511,
63,
705,
63,
15083,
63,
32710,
3022,
8,
16634,
304,
272,
299,
275,
7368,
14,
17358,
10804,
272,
21596,
275,
1134,
14,
396,
14,
3536,
8,
647,
14,
705,
14,
547,
12,
1134,
14,
705,
14,
10718,
63,
1250,
12,
299,
14,
7374,
9,
272,
702,
1228,
8,
27447,
14,
585,
12,
25139,
9,
272,
702,
1228,
8,
27447,
14,
585,
12,
1134,
14,
705,
14,
547,
9,
272,
702,
298,
32710,
3022,
2,
315,
4700,
8,
27447,
14,
585,
9,
421,
199,
318,
511,
63,
10718,
63,
1250,
63,
9823,
63,
958,
8,
8616,
304,
272,
492,
5549,
272,
1134,
14,
705,
14,
10718,
63,
1250,
8,
17336,
14,
11983,
12,
2935,
29,
495,
8,
8616,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
pratikmallya/hue
|
desktop/core/ext-py/Django-1.6.10/django/core/management/templates.py
|
110
|
13207
|
import cgi
import errno
import mimetypes
import os
import posixpath
import re
import shutil
import stat
import sys
import tempfile
from optparse import make_option
from os import path
import django
from django.template import Template, Context
from django.utils import archive
from django.utils.six.moves.urllib.request import urlretrieve
from django.utils._os import rmtree_errorhandler
from django.core.management.base import BaseCommand, CommandError
from django.core.management.utils import handle_extensions
_drive_re = re.compile('^([a-z]):', re.I)
_url_drive_re = re.compile('^([a-z])[:|]', re.I)
class TemplateCommand(BaseCommand):
"""
Copies either a Django application layout template or a Django project
layout template into the specified directory.
:param style: A color style object (see django.core.management.color).
:param app_or_project: The string 'app' or 'project'.
:param name: The name of the application or project.
:param directory: The directory to which the template should be copied.
:param options: The additional variables passed to project or app templates
"""
args = "[name] [optional destination directory]"
option_list = BaseCommand.option_list + (
make_option('--template',
action='store', dest='template',
help='The path or URL to load the template from.'),
make_option('--extension', '-e', dest='extensions',
action='append', default=['py'],
help='The file extension(s) to render (default: "py"). '
'Separate multiple extensions with commas, or use '
'-e multiple times.'),
make_option('--name', '-n', dest='files',
action='append', default=[],
help='The file name(s) to render. '
'Separate multiple extensions with commas, or use '
'-n multiple times.')
)
requires_model_validation = False
# Can't import settings during this command, because they haven't
# necessarily been created.
can_import_settings = False
# The supported URL schemes
url_schemes = ['http', 'https', 'ftp']
# Can't perform any active locale changes during this command, because
# setting might not be available at all.
leave_locale_alone = True
def handle(self, app_or_project, name, target=None, **options):
self.app_or_project = app_or_project
self.paths_to_remove = []
self.verbosity = int(options.get('verbosity'))
self.validate_name(name, app_or_project)
# if some directory is given, make sure it's nicely expanded
if target is None:
top_dir = path.join(os.getcwd(), name)
try:
os.makedirs(top_dir)
except OSError as e:
if e.errno == errno.EEXIST:
message = "'%s' already exists" % top_dir
else:
message = e
raise CommandError(message)
else:
top_dir = os.path.abspath(path.expanduser(target))
if not os.path.exists(top_dir):
raise CommandError("Destination directory '%s' does not "
"exist, please create it first." % top_dir)
extensions = tuple(
handle_extensions(options.get('extensions'), ignored=()))
extra_files = []
for file in options.get('files'):
extra_files.extend(map(lambda x: x.strip(), file.split(',')))
if self.verbosity >= 2:
self.stdout.write("Rendering %s template files with "
"extensions: %s\n" %
(app_or_project, ', '.join(extensions)))
self.stdout.write("Rendering %s template files with "
"filenames: %s\n" %
(app_or_project, ', '.join(extra_files)))
base_name = '%s_name' % app_or_project
base_subdir = '%s_template' % app_or_project
base_directory = '%s_directory' % app_or_project
if django.VERSION[-2] != 'final':
docs_version = 'dev'
else:
docs_version = '%d.%d' % django.VERSION[:2]
context = Context(dict(options, **{
base_name: name,
base_directory: top_dir,
'docs_version': docs_version,
}), autoescape=False)
# Setup a stub settings environment for template rendering
from django.conf import settings
if not settings.configured:
settings.configure()
template_dir = self.handle_template(options.get('template'),
base_subdir)
prefix_length = len(template_dir) + 1
for root, dirs, files in os.walk(template_dir):
path_rest = root[prefix_length:]
relative_dir = path_rest.replace(base_name, name)
if relative_dir:
target_dir = path.join(top_dir, relative_dir)
if not path.exists(target_dir):
os.mkdir(target_dir)
for dirname in dirs[:]:
if dirname.startswith('.') or dirname == '__pycache__':
dirs.remove(dirname)
for filename in files:
if filename.endswith(('.pyo', '.pyc', '.py.class')):
# Ignore some files as they cause various breakages.
continue
old_path = path.join(root, filename)
new_path = path.join(top_dir, relative_dir,
filename.replace(base_name, name))
if path.exists(new_path):
raise CommandError("%s already exists, overlaying a "
"project or app into an existing "
"directory won't replace conflicting "
"files" % new_path)
# Only render the Python files, as we don't want to
# accidentally render Django templates files
with open(old_path, 'rb') as template_file:
content = template_file.read()
if filename.endswith(extensions) or filename in extra_files:
content = content.decode('utf-8')
template = Template(content)
content = template.render(context)
content = content.encode('utf-8')
with open(new_path, 'wb') as new_file:
new_file.write(content)
if self.verbosity >= 2:
self.stdout.write("Creating %s\n" % new_path)
try:
shutil.copymode(old_path, new_path)
self.make_writeable(new_path)
except OSError:
self.stderr.write(
"Notice: Couldn't set permission bits on %s. You're "
"probably using an uncommon filesystem setup. No "
"problem." % new_path, self.style.NOTICE)
if self.paths_to_remove:
if self.verbosity >= 2:
self.stdout.write("Cleaning up temporary files.\n")
for path_to_remove in self.paths_to_remove:
if path.isfile(path_to_remove):
os.remove(path_to_remove)
else:
shutil.rmtree(path_to_remove,
onerror=rmtree_errorhandler)
def handle_template(self, template, subdir):
"""
Determines where the app or project templates are.
Use django.__path__[0] as the default because we don't
know into which directory Django has been installed.
"""
if template is None:
return path.join(django.__path__[0], 'conf', subdir)
else:
if template.startswith('file://'):
template = template[7:]
expanded_template = path.expanduser(template)
expanded_template = path.normpath(expanded_template)
if path.isdir(expanded_template):
return expanded_template
if self.is_url(template):
# downloads the file and returns the path
absolute_path = self.download(template)
else:
absolute_path = path.abspath(expanded_template)
if path.exists(absolute_path):
return self.extract(absolute_path)
raise CommandError("couldn't handle %s template %s." %
(self.app_or_project, template))
def validate_name(self, name, app_or_project):
if name is None:
raise CommandError("you must provide %s %s name" % (
"an" if app_or_project == "app" else "a", app_or_project))
# If it's not a valid directory name.
if not re.search(r'^[_a-zA-Z]\w*$', name):
# Provide a smart error message, depending on the error.
if not re.search(r'^[_a-zA-Z]', name):
message = 'make sure the name begins with a letter or underscore'
else:
message = 'use only numbers, letters and underscores'
raise CommandError("%r is not a valid %s name. Please %s." %
(name, app_or_project, message))
def download(self, url):
"""
Downloads the given URL and returns the file name.
"""
def cleanup_url(url):
tmp = url.rstrip('/')
filename = tmp.split('/')[-1]
if url.endswith('/'):
display_url = tmp + '/'
else:
display_url = url
return filename, display_url
prefix = 'django_%s_template_' % self.app_or_project
tempdir = tempfile.mkdtemp(prefix=prefix, suffix='_download')
self.paths_to_remove.append(tempdir)
filename, display_url = cleanup_url(url)
if self.verbosity >= 2:
self.stdout.write("Downloading %s\n" % display_url)
try:
the_path, info = urlretrieve(url, path.join(tempdir, filename))
except IOError as e:
raise CommandError("couldn't download URL %s to %s: %s" %
(url, filename, e))
used_name = the_path.split('/')[-1]
# Trying to get better name from response headers
content_disposition = info.get('content-disposition')
if content_disposition:
_, params = cgi.parse_header(content_disposition)
guessed_filename = params.get('filename') or used_name
else:
guessed_filename = used_name
# Falling back to content type guessing
ext = self.splitext(guessed_filename)[1]
content_type = info.get('content-type')
if not ext and content_type:
ext = mimetypes.guess_extension(content_type)
if ext:
guessed_filename += ext
# Move the temporary file to a filename that has better
# chances of being recognnized by the archive utils
if used_name != guessed_filename:
guessed_path = path.join(tempdir, guessed_filename)
shutil.move(the_path, guessed_path)
return guessed_path
# Giving up
return the_path
def splitext(self, the_path):
"""
Like os.path.splitext, but takes off .tar, too
"""
base, ext = posixpath.splitext(the_path)
if base.lower().endswith('.tar'):
ext = base[-4:] + ext
base = base[:-4]
return base, ext
def extract(self, filename):
"""
Extracts the given file to a temporarily and returns
the path of the directory with the extracted content.
"""
prefix = 'django_%s_template_' % self.app_or_project
tempdir = tempfile.mkdtemp(prefix=prefix, suffix='_extract')
self.paths_to_remove.append(tempdir)
if self.verbosity >= 2:
self.stdout.write("Extracting %s\n" % filename)
try:
archive.extract(filename, tempdir)
return tempdir
except (archive.ArchiveException, IOError) as e:
raise CommandError("couldn't extract file %s to %s: %s" %
(filename, tempdir, e))
def is_url(self, template):
"""
Returns True if the name looks like a URL
"""
if ':' not in template:
return False
scheme = template.split(':', 1)[0].lower()
return scheme in self.url_schemes
def make_writeable(self, filename):
"""
Make sure that the file is writeable.
Useful if our source is read-only.
"""
if sys.platform.startswith('java'):
# On Jython there is no os.access()
return
if not os.access(filename, os.W_OK):
st = os.stat(filename)
new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR
os.chmod(filename, new_permissions)
|
apache-2.0
|
[
646,
16004,
199,
646,
7554,
199,
646,
13290,
199,
646,
747,
199,
646,
15454,
199,
646,
295,
199,
646,
5145,
199,
646,
5672,
199,
646,
984,
199,
646,
5549,
199,
199,
504,
8691,
492,
1852,
63,
1422,
199,
504,
747,
492,
931,
199,
199,
646,
1639,
199,
504,
1639,
14,
1160,
492,
5458,
12,
9470,
199,
504,
1639,
14,
1208,
492,
6359,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
1069,
492,
1166,
14270,
199,
504,
1639,
14,
1208,
423,
736,
492,
20978,
63,
705,
2232,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
22239,
12,
14393,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1208,
492,
2429,
63,
5359,
421,
199,
63,
9541,
63,
264,
275,
295,
14,
2014,
9097,
779,
65,
13,
90,
4682,
297,
295,
14,
41,
9,
199,
63,
633,
63,
9541,
63,
264,
275,
295,
14,
2014,
9097,
779,
65,
13,
90,
566,
1491,
92,
4300,
295,
14,
41,
9,
421,
199,
533,
5458,
3110,
8,
25150,
304,
272,
408,
272,
29622,
1500,
1902,
282,
5634,
4223,
7054,
1978,
503,
282,
5634,
2199,
272,
7054,
1978,
1901,
314,
2013,
2082,
14,
339,
520,
635,
3449,
26,
437,
3164,
3449,
909,
334,
3239,
1639,
14,
1018,
14,
8110,
14,
2326,
680,
272,
520,
635,
1145,
63,
269,
63,
1715,
26,
710,
1059,
283,
571,
7,
503,
283,
1715,
1370,
272,
520,
635,
536,
26,
710,
536,
402,
314,
4223,
503,
2199,
14,
272,
520,
635,
2082,
26,
710,
2082,
370,
1314,
314,
1978,
1077,
506,
8876,
14,
272,
520,
635,
1511,
26,
710,
4722,
2860,
3032,
370,
2199,
503,
1145,
7009,
272,
408,
272,
1249,
275,
7369,
354,
61,
359,
4144,
5724,
2082,
8480,
272,
945,
63,
513,
275,
22239,
14,
1422,
63,
513,
435,
334,
267,
1852,
63,
1422,
4517,
1160,
297,
490,
1595,
534,
1617,
297,
2053,
534,
1160,
297,
490,
1720,
534,
1918,
931,
503,
2851,
370,
2248,
314,
1978,
687,
8038,
267,
1852,
63,
1422,
4517,
3435,
297,
2475,
69,
297,
2053,
534,
5359,
297,
490,
1595,
534,
740,
297,
849,
2968,
647,
995,
490,
1720,
534,
1918,
570,
3329,
8,
83,
9,
370,
3795,
334,
885,
26,
298,
647,
3471,
283,
586,
283,
12653,
323,
3663,
5478,
543,
24476,
12,
503,
675,
283,
586,
2475,
69,
3663,
5431,
8038,
267,
1852,
63,
1422,
4517,
354,
297,
2475,
78,
297,
2053,
534,
1725,
297,
490,
1595,
534,
740,
297,
849,
6034,
490,
1720,
534,
1918,
570,
536,
8,
83,
9,
370,
3795,
14,
283,
586,
283,
12653,
323,
3663,
5478,
543,
24476,
12,
503,
675,
283,
586,
2475,
78,
3663,
5431,
2659,
267,
776,
272,
5074,
63,
1238,
63,
6136,
275,
756,
272,
327,
6855,
1133,
492,
2202,
5309,
642,
1414,
12,
2952,
2985,
19051,
1133,
272,
327,
20513,
2757,
2737,
14,
272,
883,
63,
646,
63,
1751,
275,
756,
272,
327,
710,
3748,
2851,
21149,
272,
1166,
63,
26818,
275,
788,
1014,
297,
283,
2859,
297,
283,
8915,
418,
272,
327,
6855,
1133,
5147,
1263,
4702,
5867,
4493,
5309,
642,
1414,
12,
2952,
272,
327,
4260,
5594,
440,
506,
2808,
737,
1006,
14,
272,
10137,
63,
5508,
63,
10636,
275,
715,
339,
347,
2429,
8,
277,
12,
1145,
63,
269,
63,
1715,
12,
536,
12,
1347,
29,
403,
12,
1011,
1419,
304,
267,
291,
14,
571,
63,
269,
63,
1715,
275,
1145,
63,
269,
63,
1715,
267,
291,
14,
3771,
63,
475,
63,
2168,
275,
942,
267,
291,
14,
9833,
275,
1109,
8,
1419,
14,
362,
360,
9833,
1333,
398,
291,
14,
3502,
63,
354,
8,
354,
12,
1145,
63,
269,
63,
1715,
9,
398,
327,
340,
2005,
2082,
365,
1627,
12,
1852,
3238,
652,
1159,
14213,
590,
11507,
267,
340,
1347,
365,
488,
26,
288,
2746,
63,
694,
275,
931,
14,
904,
8,
736,
14,
9458,
1062,
536,
9,
288,
862,
26,
355,
747,
14,
8347,
8,
2119,
63,
694,
9,
288,
871,
6440,
465,
325,
26,
355,
340,
325,
14,
7931,
508,
7554,
14,
28596,
26,
490,
1245,
275,
17648,
83,
7,
2575,
3495,
2,
450,
2746,
63,
694,
355,
587,
26,
490,
1245,
275,
325,
355,
746,
14393,
8,
1188,
9,
267,
587,
26,
288,
2746,
63,
694,
275,
747,
14,
515,
14,
4832,
8,
515,
14,
12131,
8,
1375,
430,
288,
340,
440,
747,
14,
515,
14,
2444,
8,
2119,
63,
694,
304,
355,
746,
14393,
480,
13151,
2082,
1543,
83,
7,
1630,
440,
298,
3521,
298,
4494,
12,
8749,
1218,
652,
1642,
2122,
450,
2746,
63,
694,
9,
398,
5478,
275,
2008,
8,
288,
2429,
63,
5359,
8,
1419,
14,
362,
360,
5359,
659,
5525,
29,
4059,
267,
2402,
63,
1725,
275,
942,
267,
367,
570,
315,
1511,
14,
362,
360,
1725,
735,
288,
2402,
63,
1725,
14,
2880,
8,
1130,
8,
2734,
671,
26,
671,
14,
1913,
1062,
570,
14,
1294,
5102,
7058,
267,
340,
291,
14,
9833,
2356,
499,
26,
288,
291,
14,
2703,
14,
952,
480,
9216,
316,
450,
83,
1978,
1584,
543,
298,
2892,
298,
5359,
26,
450,
83,
60,
78,
2,
450,
2892,
334,
571,
63,
269,
63,
1715,
12,
1656,
1987,
904,
8,
5359,
1724,
288,
291,
14,
2703,
14,
952,
480,
9216,
316,
450,
83,
1978,
1584,
543,
298,
2892,
298,
10309,
26,
450,
83,
60,
78,
2,
450,
2892,
334,
571,
63,
269,
63,
1715,
12,
1656,
1987,
904,
8,
2911,
63,
1725,
1724,
398,
1300,
63,
354,
275,
1543,
83,
63,
354,
7,
450,
1145,
63,
269,
63,
1715,
267,
1300,
63,
10622,
275,
1543,
83,
63,
1160,
7,
450,
1145,
63,
269,
63,
1715,
267,
1300,
63,
3619,
275,
1543,
83,
63,
3619,
7,
450,
1145,
63,
269,
63,
1715,
267,
340,
1639,
14,
4612,
1988,
18,
61,
1137,
283,
5094,
356,
288,
9149,
63,
1023,
275,
283,
2374,
7,
267,
587,
26,
288,
9149,
63,
1023,
275,
1543,
68,
4111,
68,
7,
450,
1639,
14,
4612,
1491,
18,
61,
398,
1067,
275,
9470,
8,
807,
8,
1419,
12,
31159,
288,
1300,
63,
354,
26,
536,
12,
288,
1300,
63,
3619,
26,
2746,
63,
694,
12,
288,
283,
4757,
63,
1023,
356,
9149,
63,
1023,
12,
267,
9998,
19102,
29,
797,
9,
398,
327
] |
[
16004,
199,
646,
7554,
199,
646,
13290,
199,
646,
747,
199,
646,
15454,
199,
646,
295,
199,
646,
5145,
199,
646,
5672,
199,
646,
984,
199,
646,
5549,
199,
199,
504,
8691,
492,
1852,
63,
1422,
199,
504,
747,
492,
931,
199,
199,
646,
1639,
199,
504,
1639,
14,
1160,
492,
5458,
12,
9470,
199,
504,
1639,
14,
1208,
492,
6359,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
1069,
492,
1166,
14270,
199,
504,
1639,
14,
1208,
423,
736,
492,
20978,
63,
705,
2232,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
22239,
12,
14393,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1208,
492,
2429,
63,
5359,
421,
199,
63,
9541,
63,
264,
275,
295,
14,
2014,
9097,
779,
65,
13,
90,
4682,
297,
295,
14,
41,
9,
199,
63,
633,
63,
9541,
63,
264,
275,
295,
14,
2014,
9097,
779,
65,
13,
90,
566,
1491,
92,
4300,
295,
14,
41,
9,
421,
199,
533,
5458,
3110,
8,
25150,
304,
272,
408,
272,
29622,
1500,
1902,
282,
5634,
4223,
7054,
1978,
503,
282,
5634,
2199,
272,
7054,
1978,
1901,
314,
2013,
2082,
14,
339,
520,
635,
3449,
26,
437,
3164,
3449,
909,
334,
3239,
1639,
14,
1018,
14,
8110,
14,
2326,
680,
272,
520,
635,
1145,
63,
269,
63,
1715,
26,
710,
1059,
283,
571,
7,
503,
283,
1715,
1370,
272,
520,
635,
536,
26,
710,
536,
402,
314,
4223,
503,
2199,
14,
272,
520,
635,
2082,
26,
710,
2082,
370,
1314,
314,
1978,
1077,
506,
8876,
14,
272,
520,
635,
1511,
26,
710,
4722,
2860,
3032,
370,
2199,
503,
1145,
7009,
272,
408,
272,
1249,
275,
7369,
354,
61,
359,
4144,
5724,
2082,
8480,
272,
945,
63,
513,
275,
22239,
14,
1422,
63,
513,
435,
334,
267,
1852,
63,
1422,
4517,
1160,
297,
490,
1595,
534,
1617,
297,
2053,
534,
1160,
297,
490,
1720,
534,
1918,
931,
503,
2851,
370,
2248,
314,
1978,
687,
8038,
267,
1852,
63,
1422,
4517,
3435,
297,
2475,
69,
297,
2053,
534,
5359,
297,
490,
1595,
534,
740,
297,
849,
2968,
647,
995,
490,
1720,
534,
1918,
570,
3329,
8,
83,
9,
370,
3795,
334,
885,
26,
298,
647,
3471,
283,
586,
283,
12653,
323,
3663,
5478,
543,
24476,
12,
503,
675,
283,
586,
2475,
69,
3663,
5431,
8038,
267,
1852,
63,
1422,
4517,
354,
297,
2475,
78,
297,
2053,
534,
1725,
297,
490,
1595,
534,
740,
297,
849,
6034,
490,
1720,
534,
1918,
570,
536,
8,
83,
9,
370,
3795,
14,
283,
586,
283,
12653,
323,
3663,
5478,
543,
24476,
12,
503,
675,
283,
586,
2475,
78,
3663,
5431,
2659,
267,
776,
272,
5074,
63,
1238,
63,
6136,
275,
756,
272,
327,
6855,
1133,
492,
2202,
5309,
642,
1414,
12,
2952,
2985,
19051,
1133,
272,
327,
20513,
2757,
2737,
14,
272,
883,
63,
646,
63,
1751,
275,
756,
272,
327,
710,
3748,
2851,
21149,
272,
1166,
63,
26818,
275,
788,
1014,
297,
283,
2859,
297,
283,
8915,
418,
272,
327,
6855,
1133,
5147,
1263,
4702,
5867,
4493,
5309,
642,
1414,
12,
2952,
272,
327,
4260,
5594,
440,
506,
2808,
737,
1006,
14,
272,
10137,
63,
5508,
63,
10636,
275,
715,
339,
347,
2429,
8,
277,
12,
1145,
63,
269,
63,
1715,
12,
536,
12,
1347,
29,
403,
12,
1011,
1419,
304,
267,
291,
14,
571,
63,
269,
63,
1715,
275,
1145,
63,
269,
63,
1715,
267,
291,
14,
3771,
63,
475,
63,
2168,
275,
942,
267,
291,
14,
9833,
275,
1109,
8,
1419,
14,
362,
360,
9833,
1333,
398,
291,
14,
3502,
63,
354,
8,
354,
12,
1145,
63,
269,
63,
1715,
9,
398,
327,
340,
2005,
2082,
365,
1627,
12,
1852,
3238,
652,
1159,
14213,
590,
11507,
267,
340,
1347,
365,
488,
26,
288,
2746,
63,
694,
275,
931,
14,
904,
8,
736,
14,
9458,
1062,
536,
9,
288,
862,
26,
355,
747,
14,
8347,
8,
2119,
63,
694,
9,
288,
871,
6440,
465,
325,
26,
355,
340,
325,
14,
7931,
508,
7554,
14,
28596,
26,
490,
1245,
275,
17648,
83,
7,
2575,
3495,
2,
450,
2746,
63,
694,
355,
587,
26,
490,
1245,
275,
325,
355,
746,
14393,
8,
1188,
9,
267,
587,
26,
288,
2746,
63,
694,
275,
747,
14,
515,
14,
4832,
8,
515,
14,
12131,
8,
1375,
430,
288,
340,
440,
747,
14,
515,
14,
2444,
8,
2119,
63,
694,
304,
355,
746,
14393,
480,
13151,
2082,
1543,
83,
7,
1630,
440,
298,
3521,
298,
4494,
12,
8749,
1218,
652,
1642,
2122,
450,
2746,
63,
694,
9,
398,
5478,
275,
2008,
8,
288,
2429,
63,
5359,
8,
1419,
14,
362,
360,
5359,
659,
5525,
29,
4059,
267,
2402,
63,
1725,
275,
942,
267,
367,
570,
315,
1511,
14,
362,
360,
1725,
735,
288,
2402,
63,
1725,
14,
2880,
8,
1130,
8,
2734,
671,
26,
671,
14,
1913,
1062,
570,
14,
1294,
5102,
7058,
267,
340,
291,
14,
9833,
2356,
499,
26,
288,
291,
14,
2703,
14,
952,
480,
9216,
316,
450,
83,
1978,
1584,
543,
298,
2892,
298,
5359,
26,
450,
83,
60,
78,
2,
450,
2892,
334,
571,
63,
269,
63,
1715,
12,
1656,
1987,
904,
8,
5359,
1724,
288,
291,
14,
2703,
14,
952,
480,
9216,
316,
450,
83,
1978,
1584,
543,
298,
2892,
298,
10309,
26,
450,
83,
60,
78,
2,
450,
2892,
334,
571,
63,
269,
63,
1715,
12,
1656,
1987,
904,
8,
2911,
63,
1725,
1724,
398,
1300,
63,
354,
275,
1543,
83,
63,
354,
7,
450,
1145,
63,
269,
63,
1715,
267,
1300,
63,
10622,
275,
1543,
83,
63,
1160,
7,
450,
1145,
63,
269,
63,
1715,
267,
1300,
63,
3619,
275,
1543,
83,
63,
3619,
7,
450,
1145,
63,
269,
63,
1715,
267,
340,
1639,
14,
4612,
1988,
18,
61,
1137,
283,
5094,
356,
288,
9149,
63,
1023,
275,
283,
2374,
7,
267,
587,
26,
288,
9149,
63,
1023,
275,
1543,
68,
4111,
68,
7,
450,
1639,
14,
4612,
1491,
18,
61,
398,
1067,
275,
9470,
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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
] |
salamer/django
|
tests/template_tests/syntax_tests/test_url.py
|
108
|
12717
|
# coding: utf-8
from django.core.urlresolvers import NoReverseMatch, resolve
from django.template import RequestContext, TemplateSyntaxError
from django.test import (
RequestFactory, SimpleTestCase, ignore_warnings, override_settings,
)
from django.utils.deprecation import RemovedInDjango110Warning
from ..utils import setup
@override_settings(ROOT_URLCONF='template_tests.urls')
class UrlTagTests(SimpleTestCase):
# Successes
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url01': '{% url "template_tests.views.client" client.id %}'})
def test_url01(self):
output = self.engine.render_to_string('url01', {'client': {'id': 1}})
self.assertEqual(output, '/client/1/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url02': '{% url "template_tests.views.client_action" id=client.id action="update" %}'})
def test_url02(self):
output = self.engine.render_to_string('url02', {'client': {'id': 1}})
self.assertEqual(output, '/client/1/update/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url02a': '{% url "template_tests.views.client_action" client.id "update" %}'})
def test_url02a(self):
output = self.engine.render_to_string('url02a', {'client': {'id': 1}})
self.assertEqual(output, '/client/1/update/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url02b': "{% url 'template_tests.views.client_action' id=client.id action='update' %}"})
def test_url02b(self):
output = self.engine.render_to_string('url02b', {'client': {'id': 1}})
self.assertEqual(output, '/client/1/update/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url02c': "{% url 'template_tests.views.client_action' client.id 'update' %}"})
def test_url02c(self):
output = self.engine.render_to_string('url02c', {'client': {'id': 1}})
self.assertEqual(output, '/client/1/update/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url03': '{% url "template_tests.views.index" %}'})
def test_url03(self):
output = self.engine.render_to_string('url03')
self.assertEqual(output, '/')
@setup({'url04': '{% url "named.client" client.id %}'})
def test_url04(self):
output = self.engine.render_to_string('url04', {'client': {'id': 1}})
self.assertEqual(output, '/named-client/1/')
@setup({'url05': '{% url "метка_оператора" v %}'})
def test_url05(self):
output = self.engine.render_to_string('url05', {'v': 'Ω'})
self.assertEqual(output, '/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/')
@setup({'url06': '{% url "метка_оператора_2" tag=v %}'})
def test_url06(self):
output = self.engine.render_to_string('url06', {'v': 'Ω'})
self.assertEqual(output, '/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url07': '{% url "template_tests.views.client2" tag=v %}'})
def test_url07(self):
output = self.engine.render_to_string('url07', {'v': 'Ω'})
self.assertEqual(output, '/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/')
@setup({'url08': '{% url "метка_оператора" v %}'})
def test_url08(self):
output = self.engine.render_to_string('url08', {'v': 'Ω'})
self.assertEqual(output, '/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/')
@setup({'url09': '{% url "метка_оператора_2" tag=v %}'})
def test_url09(self):
output = self.engine.render_to_string('url09', {'v': 'Ω'})
self.assertEqual(output, '/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url10': '{% url "template_tests.views.client_action" id=client.id action="two words" %}'})
def test_url10(self):
output = self.engine.render_to_string('url10', {'client': {'id': 1}})
self.assertEqual(output, '/client/1/two%20words/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url11': '{% url "template_tests.views.client_action" id=client.id action="==" %}'})
def test_url11(self):
output = self.engine.render_to_string('url11', {'client': {'id': 1}})
self.assertEqual(output, '/client/1/==/')
@setup({'url12': '{% url "template_tests.views.client_action" '
'id=client.id action="!$&\'()*+,;=~:@," %}'})
@ignore_warnings(category=RemovedInDjango110Warning)
def test_url12(self):
output = self.engine.render_to_string('url12', {'client': {'id': 1}})
self.assertEqual(output, '/client/1/!$&'()*+,;=~:@,/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url13': '{% url "template_tests.views.client_action" '
'id=client.id action=arg|join:"-" %}'})
def test_url13(self):
output = self.engine.render_to_string('url13', {'client': {'id': 1}, 'arg': ['a', 'b']})
self.assertEqual(output, '/client/1/a-b/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url14': '{% url "template_tests.views.client_action" client.id arg|join:"-" %}'})
def test_url14(self):
output = self.engine.render_to_string('url14', {'client': {'id': 1}, 'arg': ['a', 'b']})
self.assertEqual(output, '/client/1/a-b/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url15': '{% url "template_tests.views.client_action" 12 "test" %}'})
def test_url15(self):
output = self.engine.render_to_string('url15')
self.assertEqual(output, '/client/12/test/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url18': '{% url "template_tests.views.client" "1,2" %}'})
def test_url18(self):
output = self.engine.render_to_string('url18')
self.assertEqual(output, '/client/1,2/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url19': '{% url named_url client.id %}'})
def test_url19(self):
output = self.engine.render_to_string('url19', {'client': {'id': 1}, 'named_url': 'template_tests.views.client'})
self.assertEqual(output, '/client/1/')
@setup({'url20': '{% url url_name_in_var client.id %}'})
def test_url20(self):
output = self.engine.render_to_string('url20', {'client': {'id': 1}, 'url_name_in_var': 'named.client'})
self.assertEqual(output, '/named-client/1/')
@setup({'url21': '{% autoescape off %}'
'{% url "template_tests.views.client_action" '
'id=client.id action="!$&\'()*+,;=~:@," %}'
'{% endautoescape %}'})
@ignore_warnings(category=RemovedInDjango110Warning)
def test_url21(self):
output = self.engine.render_to_string('url21', {'client': {'id': 1}})
self.assertEqual(output, '/client/1/!$&\'()*+,;=~:@,/')
# Failures
@setup({'url-fail01': '{% url %}'})
def test_url_fail01(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('url-fail01')
@setup({'url-fail02': '{% url "no_such_view" %}'})
def test_url_fail02(self):
with self.assertRaises(NoReverseMatch):
self.engine.render_to_string('url-fail02')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url-fail03': '{% url "template_tests.views.client" %}'})
def test_url_fail03(self):
with self.assertRaises(NoReverseMatch):
self.engine.render_to_string('url-fail03')
@setup({'url-fail04': '{% url "view" id, %}'})
def test_url_fail04(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('url-fail04')
@setup({'url-fail05': '{% url "view" id= %}'})
def test_url_fail05(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('url-fail05')
@setup({'url-fail06': '{% url "view" a.id=id %}'})
def test_url_fail06(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('url-fail06')
@setup({'url-fail07': '{% url "view" a.id!id %}'})
def test_url_fail07(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('url-fail07')
@setup({'url-fail08': '{% url "view" id="unterminatedstring %}'})
def test_url_fail08(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('url-fail08')
@setup({'url-fail09': '{% url "view" id=", %}'})
def test_url_fail09(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('url-fail09')
@setup({'url-fail11': '{% url named_url %}'})
def test_url_fail11(self):
with self.assertRaises(NoReverseMatch):
self.engine.render_to_string('url-fail11')
@setup({'url-fail12': '{% url named_url %}'})
def test_url_fail12(self):
with self.assertRaises(NoReverseMatch):
self.engine.render_to_string('url-fail12', {'named_url': 'no_such_view'})
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url-fail13': '{% url named_url %}'})
def test_url_fail13(self):
with self.assertRaises(NoReverseMatch):
self.engine.render_to_string('url-fail13', {'named_url': 'template_tests.views.client'})
@setup({'url-fail14': '{% url named_url id, %}'})
def test_url_fail14(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.render_to_string('url-fail14', {'named_url': 'view'})
@setup({'url-fail15': '{% url named_url id= %}'})
def test_url_fail15(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.render_to_string('url-fail15', {'named_url': 'view'})
@setup({'url-fail16': '{% url named_url a.id=id %}'})
def test_url_fail16(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.render_to_string('url-fail16', {'named_url': 'view'})
@setup({'url-fail17': '{% url named_url a.id!id %}'})
def test_url_fail17(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.render_to_string('url-fail17', {'named_url': 'view'})
@setup({'url-fail18': '{% url named_url id="unterminatedstring %}'})
def test_url_fail18(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.render_to_string('url-fail18', {'named_url': 'view'})
@setup({'url-fail19': '{% url named_url id=", %}'})
def test_url_fail19(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.render_to_string('url-fail19', {'named_url': 'view'})
# {% url ... as var %}
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url-asvar01': '{% url "template_tests.views.index" as url %}'})
def test_url_asvar01(self):
output = self.engine.render_to_string('url-asvar01')
self.assertEqual(output, '')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'url-asvar02': '{% url "template_tests.views.index" as url %}{{ url }}'})
def test_url_asvar02(self):
output = self.engine.render_to_string('url-asvar02')
self.assertEqual(output, '/')
@setup({'url-asvar03': '{% url "no_such_view" as url %}{{ url }}'})
def test_url_asvar03(self):
output = self.engine.render_to_string('url-asvar03')
self.assertEqual(output, '')
@setup({'url-namespace01': '{% url "app:named.client" 42 %}'})
def test_url_namespace01(self):
request = RequestFactory().get('/')
request.resolver_match = resolve('/ns1/')
template = self.engine.get_template('url-namespace01')
context = RequestContext(request)
output = template.render(context)
self.assertEqual(output, '/ns1/named-client/42/')
@setup({'url-namespace02': '{% url "app:named.client" 42 %}'})
def test_url_namespace02(self):
request = RequestFactory().get('/')
request.resolver_match = resolve('/ns2/')
template = self.engine.get_template('url-namespace02')
context = RequestContext(request)
output = template.render(context)
self.assertEqual(output, '/ns2/named-client/42/')
@setup({'url-namespace03': '{% url "app:named.client" 42 %}'})
def test_url_namespace03(self):
request = RequestFactory().get('/')
template = self.engine.get_template('url-namespace03')
context = RequestContext(request)
output = template.render(context)
self.assertEqual(output, '/ns2/named-client/42/')
|
bsd-3-clause
|
[
3,
2803,
26,
2774,
13,
24,
199,
504,
1639,
14,
1018,
14,
16522,
492,
32036,
12,
7512,
199,
504,
1639,
14,
1160,
492,
22538,
12,
17762,
199,
504,
1639,
14,
396,
492,
334,
272,
18638,
12,
24424,
12,
3686,
63,
5451,
12,
4278,
63,
1751,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
6019,
3849,
199,
199,
504,
2508,
1208,
492,
3272,
421,
199,
32,
4415,
63,
1751,
8,
5441,
63,
18125,
534,
1160,
63,
2219,
14,
3603,
358,
199,
533,
20503,
1931,
2925,
8,
17968,
304,
339,
327,
428,
947,
5804,
272,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
614,
356,
12100,
1166,
298,
1160,
63,
2219,
14,
4196,
14,
1258,
2,
1890,
14,
344,
17776,
272,
347,
511,
63,
633,
614,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
614,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
1258,
15,
17,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
996,
356,
12100,
1166,
298,
1160,
63,
2219,
14,
4196,
14,
1258,
63,
1287,
2,
1305,
29,
1258,
14,
344,
1595,
628,
873,
2,
17776,
272,
347,
511,
63,
633,
996,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
996,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
1258,
15,
17,
15,
873,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
996,
65,
356,
12100,
1166,
298,
1160,
63,
2219,
14,
4196,
14,
1258,
63,
1287,
2,
1890,
14,
344,
298,
873,
2,
17776,
272,
347,
511,
63,
633,
996,
65,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
996,
65,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
1258,
15,
17,
15,
873,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
996,
66,
356,
22704,
1166,
283,
1160,
63,
2219,
14,
4196,
14,
1258,
63,
1287,
7,
1305,
29,
1258,
14,
344,
1595,
534,
873,
7,
3674,
5984,
272,
347,
511,
63,
633,
996,
66,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
996,
66,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
1258,
15,
17,
15,
873,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
996,
67,
356,
22704,
1166,
283,
1160,
63,
2219,
14,
4196,
14,
1258,
63,
1287,
7,
1890,
14,
344,
283,
873,
7,
3674,
5984,
272,
347,
511,
63,
633,
996,
67,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
996,
67,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
1258,
15,
17,
15,
873,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
1644,
356,
12100,
1166,
298,
1160,
63,
2219,
14,
4196,
14,
1080,
2,
17776,
272,
347,
511,
63,
633,
1644,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
1644,
358,
267,
291,
14,
629,
8,
1199,
12,
15107,
339,
768,
2758,
3252,
633,
966,
356,
12100,
1166,
298,
4579,
14,
1258,
2,
1890,
14,
344,
17776,
272,
347,
511,
63,
633,
966,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
966,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
4579,
13,
1258,
15,
17,
6217,
339,
768,
2758,
3252,
633,
1717,
356,
12100,
1166,
298,
23000,
30160,
29352,
63,
8381,
124,
21273,
24219,
26438,
5657,
2,
373,
17776,
272,
347,
511,
63,
633,
1717,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
1717,
297,
791,
86,
356,
283,
139,
103,
3071,
267,
291,
14,
629,
8,
1199,
12,
1994,
5,
36,
16,
5,
12500,
5,
36,
16,
5,
11156,
5,
36,
16,
5,
34,
24,
5,
36,
16,
5,
4134,
5,
36,
16,
5,
6773,
5,
36,
16,
5,
34,
20,
3149,
2089,
5,
33,
25,
6217,
339,
768,
2758,
3252,
633,
1690,
356,
12100,
1166,
298,
23000,
30160,
29352,
63,
8381,
124,
21273,
24219,
26438,
5657,
63,
18,
2,
1947,
29,
86,
17776,
272,
347,
511,
63,
633,
1690,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
1690,
297,
791,
86,
356,
283,
139,
103,
3071,
267,
291,
14,
629,
8,
1199,
12,
1994,
5,
36,
16,
5,
12500,
5,
36,
16,
5,
11156,
5,
36,
16,
5,
34,
24,
5,
36,
16,
5,
4134,
5,
36,
16,
5,
6773,
5,
36,
16,
5,
34,
20,
3149,
2089,
5,
33,
25,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
1780,
356,
12100,
1166,
298,
1160,
63,
2219,
14,
4196,
14,
1258,
18,
2,
1947,
29,
86,
17776,
272,
347,
511,
63,
633,
1780,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
1780,
297,
791,
86,
356,
283,
139,
103,
3071,
267,
291,
14,
629,
8,
1199,
12,
1994,
5,
36,
16,
5,
12500,
5,
36,
16,
5,
11156,
5,
36,
16,
5,
34,
24,
5,
36,
16,
5,
4134,
5,
36,
16,
5,
6773,
5,
36,
16,
5,
34,
20,
3149,
2089,
5,
33,
25,
6217,
339,
768,
2758,
3252,
633,
2036,
356,
12100,
1166,
298,
23000,
30160,
29352,
63,
8381,
124,
21273,
24219,
26438,
5657,
2,
373,
17776,
272,
347,
511,
63,
633,
2036,
8,
277,
304,
267
] |
[
2803,
26,
2774,
13,
24,
199,
504,
1639,
14,
1018,
14,
16522,
492,
32036,
12,
7512,
199,
504,
1639,
14,
1160,
492,
22538,
12,
17762,
199,
504,
1639,
14,
396,
492,
334,
272,
18638,
12,
24424,
12,
3686,
63,
5451,
12,
4278,
63,
1751,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
6019,
3849,
199,
199,
504,
2508,
1208,
492,
3272,
421,
199,
32,
4415,
63,
1751,
8,
5441,
63,
18125,
534,
1160,
63,
2219,
14,
3603,
358,
199,
533,
20503,
1931,
2925,
8,
17968,
304,
339,
327,
428,
947,
5804,
272,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
614,
356,
12100,
1166,
298,
1160,
63,
2219,
14,
4196,
14,
1258,
2,
1890,
14,
344,
17776,
272,
347,
511,
63,
633,
614,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
614,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
1258,
15,
17,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
996,
356,
12100,
1166,
298,
1160,
63,
2219,
14,
4196,
14,
1258,
63,
1287,
2,
1305,
29,
1258,
14,
344,
1595,
628,
873,
2,
17776,
272,
347,
511,
63,
633,
996,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
996,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
1258,
15,
17,
15,
873,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
996,
65,
356,
12100,
1166,
298,
1160,
63,
2219,
14,
4196,
14,
1258,
63,
1287,
2,
1890,
14,
344,
298,
873,
2,
17776,
272,
347,
511,
63,
633,
996,
65,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
996,
65,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
1258,
15,
17,
15,
873,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
996,
66,
356,
22704,
1166,
283,
1160,
63,
2219,
14,
4196,
14,
1258,
63,
1287,
7,
1305,
29,
1258,
14,
344,
1595,
534,
873,
7,
3674,
5984,
272,
347,
511,
63,
633,
996,
66,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
996,
66,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
1258,
15,
17,
15,
873,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
996,
67,
356,
22704,
1166,
283,
1160,
63,
2219,
14,
4196,
14,
1258,
63,
1287,
7,
1890,
14,
344,
283,
873,
7,
3674,
5984,
272,
347,
511,
63,
633,
996,
67,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
996,
67,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
1258,
15,
17,
15,
873,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
1644,
356,
12100,
1166,
298,
1160,
63,
2219,
14,
4196,
14,
1080,
2,
17776,
272,
347,
511,
63,
633,
1644,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
1644,
358,
267,
291,
14,
629,
8,
1199,
12,
15107,
339,
768,
2758,
3252,
633,
966,
356,
12100,
1166,
298,
4579,
14,
1258,
2,
1890,
14,
344,
17776,
272,
347,
511,
63,
633,
966,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
966,
297,
791,
1258,
356,
791,
344,
356,
413,
19575,
267,
291,
14,
629,
8,
1199,
12,
1994,
4579,
13,
1258,
15,
17,
6217,
339,
768,
2758,
3252,
633,
1717,
356,
12100,
1166,
298,
23000,
30160,
29352,
63,
8381,
124,
21273,
24219,
26438,
5657,
2,
373,
17776,
272,
347,
511,
63,
633,
1717,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
1717,
297,
791,
86,
356,
283,
139,
103,
3071,
267,
291,
14,
629,
8,
1199,
12,
1994,
5,
36,
16,
5,
12500,
5,
36,
16,
5,
11156,
5,
36,
16,
5,
34,
24,
5,
36,
16,
5,
4134,
5,
36,
16,
5,
6773,
5,
36,
16,
5,
34,
20,
3149,
2089,
5,
33,
25,
6217,
339,
768,
2758,
3252,
633,
1690,
356,
12100,
1166,
298,
23000,
30160,
29352,
63,
8381,
124,
21273,
24219,
26438,
5657,
63,
18,
2,
1947,
29,
86,
17776,
272,
347,
511,
63,
633,
1690,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
1690,
297,
791,
86,
356,
283,
139,
103,
3071,
267,
291,
14,
629,
8,
1199,
12,
1994,
5,
36,
16,
5,
12500,
5,
36,
16,
5,
11156,
5,
36,
16,
5,
34,
24,
5,
36,
16,
5,
4134,
5,
36,
16,
5,
6773,
5,
36,
16,
5,
34,
20,
3149,
2089,
5,
33,
25,
6217,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
6019,
3849,
9,
272,
768,
2758,
3252,
633,
1780,
356,
12100,
1166,
298,
1160,
63,
2219,
14,
4196,
14,
1258,
18,
2,
1947,
29,
86,
17776,
272,
347,
511,
63,
633,
1780,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
633,
1780,
297,
791,
86,
356,
283,
139,
103,
3071,
267,
291,
14,
629,
8,
1199,
12,
1994,
5,
36,
16,
5,
12500,
5,
36,
16,
5,
11156,
5,
36,
16,
5,
34,
24,
5,
36,
16,
5,
4134,
5,
36,
16,
5,
6773,
5,
36,
16,
5,
34,
20,
3149,
2089,
5,
33,
25,
6217,
339,
768,
2758,
3252,
633,
2036,
356,
12100,
1166,
298,
23000,
30160,
29352,
63,
8381,
124,
21273,
24219,
26438,
5657,
2,
373,
17776,
272,
347,
511,
63,
633,
2036,
8,
277,
304,
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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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
] |
nikolas/lettuce
|
tests/integration/lib/Django-1.3/django/conf/locale/no/formats.py
|
685
|
1657
|
# -*- encoding: utf-8 -*-
# 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
DATE_INPUT_FORMATS = (
'%Y-%m-%d', '%d.%m.%Y', '%d.%m.%y', # '2006-10-25', '25.10.2006', '25.10.06'
'%Y-%m-%d', # '2006-10-25',
# '%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'
)
TIME_INPUT_FORMATS = (
'%H:%M:%S', # '14:30:59'
'%H:%M', # '14:30'
)
DATETIME_INPUT_FORMATS = (
'%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59'
'%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', # '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', # '25.10.06 14:30'
'%d.%m.%y', # '25.10.06'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = ' '
NUMBER_GROUPING = 3
|
gpl-3.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
3,
961,
570,
365,
1854,
1334,
314,
2011,
4190,
465,
314,
5634,
2559,
14,
199,
3,
199,
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,
327,
32740,
199,
199,
3,
710,
20841,
7321,
63,
14019,
3326,
675,
314,
2018,
14053,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
2083,
14,
1360,
3,
6205,
13,
9866,
13,
17537,
199,
5390,
63,
7321,
63,
14019,
275,
334,
272,
1543,
57,
3295,
77,
3295,
68,
297,
1543,
68,
4111,
77,
4111,
57,
297,
1543,
68,
4111,
77,
4111,
89,
297,
327,
283,
7968,
13,
709,
13,
821,
297,
283,
821,
14,
709,
14,
7968,
297,
283,
821,
14,
709,
14,
1690,
7,
272,
1543,
57,
3295,
77,
3295,
68,
297,
12793,
327,
283,
7968,
13,
709,
13,
821,
297,
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,
9,
199,
4961,
63,
7321,
63,
14019,
275,
334,
272,
1543,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
1079,
26,
1216,
26,
1427,
7,
272,
1543,
40,
2689,
45,
297,
258,
327,
283,
1079,
26,
1216,
7,
199,
9,
199,
12488,
63,
7321,
63,
14019,
275,
334,
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,
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,
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,
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,
9,
199,
23925,
63,
15828,
275,
13647,
199,
28714,
63,
15828,
275,
283,
283,
199,
9190,
63,
7823,
1206,
275,
650,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
3,
961,
570,
365,
1854,
1334,
314,
2011,
4190,
465,
314,
5634,
2559,
14,
199,
3,
199,
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,
327,
32740,
199,
199,
3,
710,
20841,
7321,
63,
14019,
3326,
675,
314,
2018,
14053,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
2083,
14,
1360,
3,
6205,
13,
9866,
13,
17537,
199,
5390,
63,
7321,
63,
14019,
275,
334,
272,
1543,
57,
3295,
77,
3295,
68,
297,
1543,
68,
4111,
77,
4111,
57,
297,
1543,
68,
4111,
77,
4111,
89,
297,
327,
283,
7968,
13,
709,
13,
821,
297,
283,
821,
14,
709,
14,
7968,
297,
283,
821,
14,
709,
14,
1690,
7,
272,
1543,
57,
3295,
77,
3295,
68,
297,
12793,
327,
283,
7968,
13,
709,
13,
821,
297,
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,
9,
199,
4961,
63,
7321,
63,
14019,
275,
334,
272,
1543,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
1079,
26,
1216,
26,
1427,
7,
272,
1543,
40,
2689,
45,
297,
258,
327,
283,
1079,
26,
1216,
7,
199,
9,
199,
12488,
63,
7321,
63,
14019,
275,
334,
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,
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,
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,
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,
9,
199,
23925,
63,
15828,
275,
13647,
199,
28714,
63,
15828,
275,
283,
283,
199,
9190,
63,
7823,
1206,
275,
650,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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.models import Page
from cms.test_utils.fixtures.navextenders import NavextendersFixture
from cms.test_utils.testcases import SettingsOverrideTestCase
from cms.test_utils.util.menu_extender import TestMenu
from django.conf import settings
from django.template import Template
from menus.menu_pool import menu_pool
class NavExtenderTestCase(NavextendersFixture, SettingsOverrideTestCase):
"""
Tree from fixture:
page1
page2
page3
page4
page5
"""
def setUp(self):
if not menu_pool.discovered:
menu_pool.discover_menus()
self.old_menu = menu_pool.menus
menu_pool.menus = {'CMSMenu':self.old_menu['CMSMenu'], 'TestMenu':TestMenu()}
def tearDown(self):
menu_pool.menus = self.old_menu
def _get_page(self, num):
return Page.objects.get(title_set__title='page%s' % num)
def _update_page(self, num, **stuff):
Page.objects.filter(title_set__title='page%s' % num).update(**stuff)
def test_menu_registration(self):
self.assertEqual(len(menu_pool.menus), 2)
self.assertEqual(len(menu_pool.modifiers) >=4, True)
def test_extenders_on_root(self):
self._update_page(1, navigation_extenders="TestMenu")
menu_pool.clear(settings.SITE_ID)
context = self.get_context()
tpl = Template("{% load menu_tags %}{% show_menu 0 100 100 100 %}")
tpl.render(context)
nodes = context['children']
self.assertEqual(len(nodes), 2)
self.assertEqual(len(nodes[0].children), 4)
self.assertEqual(len(nodes[0].children[3].children), 1)
self._update_page(1, in_navigation=False)
menu_pool.clear(settings.SITE_ID)
tpl = Template("{% load menu_tags %}{% show_menu %}")
tpl.render(context)
nodes = context['children']
self.assertEqual(len(nodes), 5)
def test_extenders_on_root_child(self):
self._update_page(4, navigation_extenders="TestMenu")
menu_pool.clear(settings.SITE_ID)
context = self.get_context()
tpl = Template("{% load menu_tags %}{% show_menu 0 100 100 100 %}")
tpl.render(context)
nodes = context['children']
self.assertEqual(len(nodes), 2)
self.assertEqual(len(nodes[1].children), 4)
def test_extenders_on_child(self):
"""
TestMenu has 4 flat nodes
"""
self._update_page(1, in_navigation=False)
self._update_page(2, navigation_extenders="TestMenu")
menu_pool.clear(settings.SITE_ID)
menu_pool.clear(settings.SITE_ID)
context = self.get_context()
tpl = Template("{% load menu_tags %}{% show_menu 0 100 100 100 %}")
tpl.render(context)
nodes = context['children']
self.assertEqual(len(nodes), 2)
self.assertEqual(len(nodes[0].children), 4)
self.assertEqual(nodes[0].children[1].get_absolute_url(), "/" )
def test_incorrect_nav_extender_in_db(self):
self._update_page(2, navigation_extenders="SomethingWrong")
menu_pool.clear(settings.SITE_ID)
context = self.get_context()
tpl = Template("{% load menu_tags %}{% show_menu %}")
tpl.render(context)
nodes = context['children']
self.assertEqual(len(nodes), 2)
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
19240,
14,
992,
492,
10331,
199,
504,
19240,
14,
396,
63,
1208,
14,
8769,
14,
78,
811,
88,
724,
7735,
492,
653,
811,
88,
724,
7735,
12812,
199,
504,
19240,
14,
396,
63,
1208,
14,
396,
9403,
492,
13303,
11954,
1746,
199,
504,
19240,
14,
396,
63,
1208,
14,
1974,
14,
4470,
63,
1614,
424,
492,
1379,
5977,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1160,
492,
5458,
199,
504,
27906,
14,
4470,
63,
2293,
492,
6269,
63,
2293,
199,
199,
533,
653,
1214,
4377,
424,
1746,
8,
46,
811,
88,
724,
7735,
12812,
12,
13303,
11954,
1746,
304,
339,
408,
272,
12178,
687,
10949,
26,
13857,
2034,
17,
288,
2034,
18,
355,
2034,
19,
267,
2034,
20,
288,
2034,
21,
272,
408,
2286,
347,
3613,
8,
277,
304,
267,
340,
440,
6269,
63,
2293,
14,
2297,
13560,
26,
288,
6269,
63,
2293,
14,
18861,
63,
30969,
342,
267,
291,
14,
1753,
63,
4470,
275,
6269,
63,
2293,
14,
30969,
267,
6269,
63,
2293,
14,
30969,
275,
791,
17834,
5977,
356,
277,
14,
1753,
63,
4470,
459,
17834,
5977,
995,
283,
774,
5977,
356,
774,
5977,
12737,
1779,
272,
347,
6766,
8,
277,
304,
267,
6269,
63,
2293,
14,
30969,
275,
291,
14,
1753,
63,
4470,
5493,
347,
485,
362,
63,
1606,
8,
277,
12,
1967,
304,
267,
372,
10331,
14,
1462,
14,
362,
8,
1213,
63,
409,
363,
1213,
534,
1606,
5,
83,
7,
450,
1967,
9,
2286,
347,
485,
873,
63,
1606,
8,
277,
12,
1967,
12,
1011,
14573,
304,
267,
10331,
14,
1462,
14,
1541,
8,
1213,
63,
409,
363,
1213,
534,
1606,
5,
83,
7,
450,
1967,
680,
873,
3682,
14573,
9,
5493,
347,
511,
63,
4470,
63,
8054,
8,
277,
304,
267,
291,
14,
629,
8,
552,
8,
4470,
63,
2293,
14,
30969,
395,
499,
9,
267,
291,
14,
629,
8,
552,
8,
4470,
63,
2293,
14,
17431,
9,
2356,
20,
12,
715,
9,
5493,
347,
511,
63,
1614,
7735,
63,
265,
63,
1231,
8,
277,
304,
267,
291,
423,
873,
63,
1606,
8,
17,
12,
19191,
63,
1614,
7735,
628,
774,
5977,
531,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
1067,
275,
291,
14,
362,
63,
1100,
342,
2728,
20223,
275,
5458,
480,
3996,
2248,
6269,
63,
2969,
12760,
2498,
63,
4470,
378,
2948,
2948,
2948,
3674,
531,
267,
20223,
14,
3352,
8,
1100,
9,
4960,
3380,
275,
1067,
459,
3223,
418,
267,
291,
14,
629,
8,
552,
8,
2415,
395,
499,
9,
267,
291,
14,
629,
8,
552,
8,
2415,
59,
16,
1055,
3223,
395,
841,
9,
267,
291,
14,
629,
8,
552,
8,
2415,
59,
16,
1055,
3223,
59,
19,
1055,
3223,
395,
413,
9,
267,
291,
423,
873,
63,
1606,
8,
17,
12,
315,
63,
24148,
29,
797,
9,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
20223,
275,
5458,
480,
3996,
2248,
6269,
63,
2969,
12760,
2498,
63,
4470,
3674,
531,
267,
20223,
14,
3352,
8,
1100,
9,
4960,
3380,
275,
1067,
459,
3223,
418,
267,
291,
14,
629,
8,
552,
8,
2415,
395,
959,
9,
5493,
347,
511,
63,
1614,
7735,
63,
265,
63,
1231,
63,
1739,
8,
277,
304,
267,
291,
423,
873,
63,
1606,
8,
20,
12,
19191,
63,
1614,
7735,
628,
774,
5977,
531,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
1067,
275,
291,
14,
362,
63,
1100,
342,
267,
20223,
275,
5458,
480,
3996,
2248,
6269,
63,
2969,
12760,
2498,
63,
4470,
378,
2948,
2948,
2948,
3674,
531,
267,
20223,
14,
3352,
8,
1100,
9,
4960,
3380,
275,
1067,
459,
3223,
418,
267,
291,
14,
629,
8,
552,
8,
2415,
395,
499,
9,
267,
291,
14,
629,
8,
552,
8,
2415,
59,
17,
1055,
3223,
395,
841,
9,
5493,
347,
511,
63,
1614,
7735,
63,
265,
63,
1739,
8,
277,
304,
267,
408,
267,
1379,
5977,
965,
841,
6829,
3380,
267,
408,
267,
291,
423,
873,
63,
1606,
8,
17,
12,
315,
63,
24148,
29,
797,
9,
267,
291,
423,
873,
63,
1606,
8,
18,
12,
19191,
63,
1614,
7735,
628,
774,
5977,
531,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
1067,
275,
291,
14,
362,
63,
1100,
342,
267,
20223,
275,
5458,
480,
3996,
2248,
6269,
63,
2969,
12760,
2498,
63,
4470,
378,
2948,
2948,
2948,
3674,
531,
267,
20223,
14,
3352,
8,
1100,
9,
4960,
3380,
275,
1067,
459,
3223,
418,
267,
291,
14,
629,
8,
552,
8,
2415,
395,
499,
9,
267,
291,
14,
629,
8,
552,
8,
2415,
59,
16,
1055,
3223,
395,
841,
9,
267,
291,
14,
629,
8,
2415,
59,
16,
1055,
3223,
59,
17,
1055,
362,
63,
6116,
63,
633,
1062,
10609,
776,
5493,
347,
511,
63,
15448,
63,
10927,
63,
1614,
424,
63,
262,
63,
697,
8,
277,
304,
267,
291,
423,
873,
63,
1606,
8,
18,
12,
19191,
63,
1614,
7735,
628,
20641,
14858,
531,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
1067,
275,
291,
14,
362,
63,
1100,
342,
267,
20223,
275,
5458,
480,
3996,
2248,
6269,
63,
2969,
12760,
2498,
63,
4470,
3674,
531,
267,
20223,
14,
3352,
8,
1100,
9,
4960,
3380,
275,
1067,
459,
3223,
418,
267,
291,
14,
629,
8,
552,
8,
2415,
395,
499,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
19240,
14,
992,
492,
10331,
199,
504,
19240,
14,
396,
63,
1208,
14,
8769,
14,
78,
811,
88,
724,
7735,
492,
653,
811,
88,
724,
7735,
12812,
199,
504,
19240,
14,
396,
63,
1208,
14,
396,
9403,
492,
13303,
11954,
1746,
199,
504,
19240,
14,
396,
63,
1208,
14,
1974,
14,
4470,
63,
1614,
424,
492,
1379,
5977,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1160,
492,
5458,
199,
504,
27906,
14,
4470,
63,
2293,
492,
6269,
63,
2293,
199,
199,
533,
653,
1214,
4377,
424,
1746,
8,
46,
811,
88,
724,
7735,
12812,
12,
13303,
11954,
1746,
304,
339,
408,
272,
12178,
687,
10949,
26,
13857,
2034,
17,
288,
2034,
18,
355,
2034,
19,
267,
2034,
20,
288,
2034,
21,
272,
408,
2286,
347,
3613,
8,
277,
304,
267,
340,
440,
6269,
63,
2293,
14,
2297,
13560,
26,
288,
6269,
63,
2293,
14,
18861,
63,
30969,
342,
267,
291,
14,
1753,
63,
4470,
275,
6269,
63,
2293,
14,
30969,
267,
6269,
63,
2293,
14,
30969,
275,
791,
17834,
5977,
356,
277,
14,
1753,
63,
4470,
459,
17834,
5977,
995,
283,
774,
5977,
356,
774,
5977,
12737,
1779,
272,
347,
6766,
8,
277,
304,
267,
6269,
63,
2293,
14,
30969,
275,
291,
14,
1753,
63,
4470,
5493,
347,
485,
362,
63,
1606,
8,
277,
12,
1967,
304,
267,
372,
10331,
14,
1462,
14,
362,
8,
1213,
63,
409,
363,
1213,
534,
1606,
5,
83,
7,
450,
1967,
9,
2286,
347,
485,
873,
63,
1606,
8,
277,
12,
1967,
12,
1011,
14573,
304,
267,
10331,
14,
1462,
14,
1541,
8,
1213,
63,
409,
363,
1213,
534,
1606,
5,
83,
7,
450,
1967,
680,
873,
3682,
14573,
9,
5493,
347,
511,
63,
4470,
63,
8054,
8,
277,
304,
267,
291,
14,
629,
8,
552,
8,
4470,
63,
2293,
14,
30969,
395,
499,
9,
267,
291,
14,
629,
8,
552,
8,
4470,
63,
2293,
14,
17431,
9,
2356,
20,
12,
715,
9,
5493,
347,
511,
63,
1614,
7735,
63,
265,
63,
1231,
8,
277,
304,
267,
291,
423,
873,
63,
1606,
8,
17,
12,
19191,
63,
1614,
7735,
628,
774,
5977,
531,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
1067,
275,
291,
14,
362,
63,
1100,
342,
2728,
20223,
275,
5458,
480,
3996,
2248,
6269,
63,
2969,
12760,
2498,
63,
4470,
378,
2948,
2948,
2948,
3674,
531,
267,
20223,
14,
3352,
8,
1100,
9,
4960,
3380,
275,
1067,
459,
3223,
418,
267,
291,
14,
629,
8,
552,
8,
2415,
395,
499,
9,
267,
291,
14,
629,
8,
552,
8,
2415,
59,
16,
1055,
3223,
395,
841,
9,
267,
291,
14,
629,
8,
552,
8,
2415,
59,
16,
1055,
3223,
59,
19,
1055,
3223,
395,
413,
9,
267,
291,
423,
873,
63,
1606,
8,
17,
12,
315,
63,
24148,
29,
797,
9,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
20223,
275,
5458,
480,
3996,
2248,
6269,
63,
2969,
12760,
2498,
63,
4470,
3674,
531,
267,
20223,
14,
3352,
8,
1100,
9,
4960,
3380,
275,
1067,
459,
3223,
418,
267,
291,
14,
629,
8,
552,
8,
2415,
395,
959,
9,
5493,
347,
511,
63,
1614,
7735,
63,
265,
63,
1231,
63,
1739,
8,
277,
304,
267,
291,
423,
873,
63,
1606,
8,
20,
12,
19191,
63,
1614,
7735,
628,
774,
5977,
531,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
1067,
275,
291,
14,
362,
63,
1100,
342,
267,
20223,
275,
5458,
480,
3996,
2248,
6269,
63,
2969,
12760,
2498,
63,
4470,
378,
2948,
2948,
2948,
3674,
531,
267,
20223,
14,
3352,
8,
1100,
9,
4960,
3380,
275,
1067,
459,
3223,
418,
267,
291,
14,
629,
8,
552,
8,
2415,
395,
499,
9,
267,
291,
14,
629,
8,
552,
8,
2415,
59,
17,
1055,
3223,
395,
841,
9,
5493,
347,
511,
63,
1614,
7735,
63,
265,
63,
1739,
8,
277,
304,
267,
408,
267,
1379,
5977,
965,
841,
6829,
3380,
267,
408,
267,
291,
423,
873,
63,
1606,
8,
17,
12,
315,
63,
24148,
29,
797,
9,
267,
291,
423,
873,
63,
1606,
8,
18,
12,
19191,
63,
1614,
7735,
628,
774,
5977,
531,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
1067,
275,
291,
14,
362,
63,
1100,
342,
267,
20223,
275,
5458,
480,
3996,
2248,
6269,
63,
2969,
12760,
2498,
63,
4470,
378,
2948,
2948,
2948,
3674,
531,
267,
20223,
14,
3352,
8,
1100,
9,
4960,
3380,
275,
1067,
459,
3223,
418,
267,
291,
14,
629,
8,
552,
8,
2415,
395,
499,
9,
267,
291,
14,
629,
8,
552,
8,
2415,
59,
16,
1055,
3223,
395,
841,
9,
267,
291,
14,
629,
8,
2415,
59,
16,
1055,
3223,
59,
17,
1055,
362,
63,
6116,
63,
633,
1062,
10609,
776,
5493,
347,
511,
63,
15448,
63,
10927,
63,
1614,
424,
63,
262,
63,
697,
8,
277,
304,
267,
291,
423,
873,
63,
1606,
8,
18,
12,
19191,
63,
1614,
7735,
628,
20641,
14858,
531,
267,
6269,
63,
2293,
14,
3584,
8,
1751,
14,
7917,
63,
998,
9,
267,
1067,
275,
291,
14,
362,
63,
1100,
342,
267,
20223,
275,
5458,
480,
3996,
2248,
6269,
63,
2969,
12760,
2498,
63,
4470,
3674,
531,
267,
20223,
14,
3352,
8,
1100,
9,
4960,
3380,
275,
1067,
459,
3223,
418,
267,
291,
14,
629,
8,
552,
8,
2415,
395,
499,
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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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
] |
pschella/scipy
|
scipy/linalg/__init__.py
|
9
|
6404
|
"""
====================================
Linear algebra (:mod:`scipy.linalg`)
====================================
.. currentmodule:: scipy.linalg
Linear algebra functions.
.. seealso::
`numpy.linalg` for more linear algebra functions. Note that
although `scipy.linalg` imports most of them, identically named
functions from `scipy.linalg` may offer more or slightly differing
functionality.
Basics
======
.. autosummary::
:toctree: generated/
inv - Find the inverse of a square matrix
solve - Solve a linear system of equations
solve_banded - Solve a banded linear system
solveh_banded - Solve a Hermitian or symmetric banded system
solve_circulant - Solve a circulant system
solve_triangular - Solve a triangular matrix
solve_toeplitz - Solve a toeplitz matrix
det - Find the determinant of a square matrix
norm - Matrix and vector norm
lstsq - Solve a linear least-squares problem
pinv - Pseudo-inverse (Moore-Penrose) using lstsq
pinv2 - Pseudo-inverse using svd
pinvh - Pseudo-inverse of hermitian matrix
kron - Kronecker product of two arrays
tril - Construct a lower-triangular matrix from a given matrix
triu - Construct an upper-triangular matrix from a given matrix
orthogonal_procrustes - Solve an orthogonal Procrustes problem
matrix_balance - Balance matrix entries with a similarity transformation
LinAlgError
Eigenvalue Problems
===================
.. autosummary::
:toctree: generated/
eig - Find the eigenvalues and eigenvectors of a square matrix
eigvals - Find just the eigenvalues of a square matrix
eigh - Find the e-vals and e-vectors of a Hermitian or symmetric matrix
eigvalsh - Find just the eigenvalues of a Hermitian or symmetric matrix
eig_banded - Find the eigenvalues and eigenvectors of a banded matrix
eigvals_banded - Find just the eigenvalues of a banded matrix
Decompositions
==============
.. autosummary::
:toctree: generated/
lu - LU decomposition of a matrix
lu_factor - LU decomposition returning unordered matrix and pivots
lu_solve - Solve Ax=b using back substitution with output of lu_factor
svd - Singular value decomposition of a matrix
svdvals - Singular values of a matrix
diagsvd - Construct matrix of singular values from output of svd
orth - Construct orthonormal basis for the range of A using svd
cholesky - Cholesky decomposition of a matrix
cholesky_banded - Cholesky decomp. of a sym. or Hermitian banded matrix
cho_factor - Cholesky decomposition for use in solving a linear system
cho_solve - Solve previously factored linear system
cho_solve_banded - Solve previously factored banded linear system
polar - Compute the polar decomposition.
qr - QR decomposition of a matrix
qr_multiply - QR decomposition and multiplication by Q
qr_update - Rank k QR update
qr_delete - QR downdate on row or column deletion
qr_insert - QR update on row or column insertion
rq - RQ decomposition of a matrix
qz - QZ decomposition of a pair of matrices
ordqz - QZ decomposition of a pair of matrices with reordering
schur - Schur decomposition of a matrix
rsf2csf - Real to complex Schur form
hessenberg - Hessenberg form of a matrix
.. seealso::
`scipy.linalg.interpolative` -- Interpolative matrix decompositions
Matrix Functions
================
.. autosummary::
:toctree: generated/
expm - Matrix exponential
logm - Matrix logarithm
cosm - Matrix cosine
sinm - Matrix sine
tanm - Matrix tangent
coshm - Matrix hyperbolic cosine
sinhm - Matrix hyperbolic sine
tanhm - Matrix hyperbolic tangent
signm - Matrix sign
sqrtm - Matrix square root
funm - Evaluating an arbitrary matrix function
expm_frechet - Frechet derivative of the matrix exponential
expm_cond - Relative condition number of expm in the Frobenius norm
fractional_matrix_power - Fractional matrix power
Matrix Equation Solvers
=======================
.. autosummary::
:toctree: generated/
solve_sylvester - Solve the Sylvester matrix equation
solve_continuous_are - Solve the continuous-time algebraic Riccati equation
solve_discrete_are - Solve the discrete-time algebraic Riccati equation
solve_discrete_lyapunov - Solve the discrete-time Lyapunov equation
solve_lyapunov - Solve the (continous-time) Lyapunov equation
Special Matrices
================
.. autosummary::
:toctree: generated/
block_diag - Construct a block diagonal matrix from submatrices
circulant - Circulant matrix
companion - Companion matrix
dft - Discrete Fourier transform matrix
hadamard - Hadamard matrix of order 2**n
hankel - Hankel matrix
helmert - Helmert matrix
hilbert - Hilbert matrix
invhilbert - Inverse Hilbert matrix
leslie - Leslie matrix
pascal - Pascal matrix
invpascal - Inverse Pascal matrix
toeplitz - Toeplitz matrix
tri - Construct a matrix filled with ones at and below a given diagonal
Low-level routines
==================
.. autosummary::
:toctree: generated/
get_blas_funcs
get_lapack_funcs
find_best_blas_type
.. seealso::
`scipy.linalg.blas` -- Low-level BLAS functions
`scipy.linalg.lapack` -- Low-level LAPACK functions
`scipy.linalg.cython_blas` -- Low-level BLAS functions for Cython
`scipy.linalg.cython_lapack` -- Low-level LAPACK functions for Cython
"""
from __future__ import division, print_function, absolute_import
from .linalg_version import linalg_version as __version__
from .misc import *
from .basic import *
from .decomp import *
from .decomp_lu import *
from .decomp_cholesky import *
from .decomp_qr import *
from ._decomp_qz import *
from .decomp_svd import *
from .decomp_schur import *
from ._decomp_polar import *
from .matfuncs import *
from .blas import *
from .lapack import *
from .special_matrices import *
from ._solvers import *
from ._procrustes import *
from ._decomp_update import *
__all__ = [s for s in dir() if not s.startswith('_')]
from numpy.dual import register_func
for k in ['norm', 'inv', 'svd', 'solve', 'det', 'eig', 'eigh', 'eigvals',
'eigvalsh', 'lstsq', 'cholesky']:
try:
register_func(k, eval(k))
except ValueError:
pass
try:
register_func('pinv', pinv2)
except ValueError:
pass
del k, register_func
from numpy.testing import Tester
test = Tester().test
|
bsd-3-clause
|
[
624,
199,
2486,
532,
199,
10608,
741,
19355,
18479,
1494,
1705,
14248,
14,
10096,
10522,
199,
2486,
532,
199,
199,
703,
1453,
578,
447,
7026,
14,
10096,
199,
199,
10608,
741,
19355,
3423,
14,
199,
199,
703,
19352,
447,
8410,
658,
4714,
14,
10096,
64,
367,
1655,
7798,
741,
19355,
3423,
14,
221,
3390,
626,
2043,
22160,
658,
14248,
14,
10096,
64,
8925,
4750,
402,
3062,
12,
6120,
17269,
4310,
2043,
3423,
687,
658,
14248,
14,
10096,
64,
1443,
19793,
1655,
503,
18023,
28488,
2043,
9330,
14,
421,
199,
6845,
83,
199,
23476,
199,
199,
703,
26651,
29309,
447,
2043,
520,
475,
16970,
26,
4046,
15,
8410,
4572,
446,
6668,
314,
11484,
402,
282,
12386,
3634,
2043,
14241,
446,
428,
3344,
282,
7798,
2656,
402,
26426,
2043,
14241,
63,
66,
7028,
446,
428,
3344,
282,
330,
7028,
7798,
2656,
2043,
14241,
72,
63,
66,
7028,
446,
428,
3344,
282,
18769,
26649,
503,
16371,
330,
7028,
2656,
2043,
14241,
63,
6092,
348,
867,
446,
428,
3344,
282,
286,
723,
3119,
867,
2656,
2043,
14241,
63,
29663,
446,
428,
3344,
282,
3229,
11572,
3634,
2043,
14241,
63,
475,
1545,
29382,
446,
428,
3344,
282,
370,
1545,
29382,
3634,
2043,
20894,
446,
6668,
314,
4563,
867,
402,
282,
12386,
3634,
2043,
6316,
446,
8449,
436,
5477,
6316,
2043,
9877,
3526,
446,
428,
3344,
282,
7798,
5210,
13,
20956,
5160,
2043,
299,
5350,
446,
510,
9917,
13,
11668,
334,
3716,
720,
13,
15597,
293,
261,
9,
1808,
9877,
3526,
2043,
299,
5350,
18,
446,
510,
9917,
13,
11668,
1808,
26937,
2043,
299,
5350,
72,
446,
510,
9917,
13,
11668,
402,
14737,
26649,
3634,
2043,
1022,
2641,
446,
1804,
82,
368,
22043,
3336,
402,
2877,
6572,
2043,
3229,
76,
446,
9215,
282,
5117,
13,
29663,
3634,
687,
282,
1627,
3634,
2043,
3229,
85,
446,
9215,
376,
7008,
13,
29663,
3634,
687,
282,
1627,
3634,
2043,
29069,
63,
496,
1556,
527,
744,
446,
428,
3344,
376,
29069,
2165,
1556,
527,
744,
5160,
2043,
3634,
63,
7358,
446,
23928,
554,
3634,
4811,
543,
282,
22838,
13315,
2043,
29730,
28846,
547,
199,
199,
37,
8478,
585,
2165,
7561,
199,
1280,
5918,
199,
199,
703,
26651,
29309,
447,
2043,
520,
475,
16970,
26,
4046,
15,
8410,
26547,
446,
6668,
314,
22953,
436,
29802,
402,
282,
12386,
3634,
2043,
26547,
3643,
446,
6668,
2951,
314,
22953,
402,
282,
12386,
3634,
2043,
325,
2056,
446,
6668,
314,
325,
13,
3643,
436,
325,
13,
12280,
402,
282,
18769,
26649,
503,
16371,
3634,
2043,
26547,
637,
609,
446,
6668,
2951,
314,
22953,
402,
282,
18769,
26649,
503,
16371,
3634,
2043,
26547,
63,
66,
7028,
446,
6668,
314,
22953,
436,
29802,
402,
282,
330,
7028,
3634,
2043,
26547,
3643,
63,
66,
7028,
446,
6668,
2951,
314,
22953,
402,
282,
330,
7028,
3634,
199,
199,
872,
7784,
6150,
199,
17224,
199,
199,
703,
26651,
29309,
447,
2043,
520,
475,
16970,
26,
4046,
15,
8410,
16795,
446,
491,
53,
22706,
402,
282,
3634,
2043,
16795,
63,
4778,
446,
491,
53,
22706,
8152,
31716,
3634,
436,
22292,
83,
2043,
16795,
63,
11356,
446,
428,
3344,
437,
88,
29,
66,
1808,
1771,
20584,
543,
1072,
402,
16795,
63,
4778,
2043,
26937,
446,
428,
14257,
574,
22706,
402,
282,
3634,
2043,
26937,
3643,
446,
428,
14257,
1338,
402,
282,
3634,
2043,
487,
7391,
11549,
446,
9215,
3634,
402,
15823,
1338,
687,
1072,
402,
26937,
2043,
19425,
446,
9215,
503,
898,
1783,
5597,
367,
314,
1425,
402,
437,
1808,
26937,
2043,
2468,
19881,
446,
8802,
19881,
22706,
402,
282,
3634,
2043,
2468,
19881,
63,
66,
7028,
446,
8802,
19881,
477,
863,
14,
402,
282,
4678,
14,
503,
18769,
26649,
330,
7028,
3634,
2043,
2468,
63,
4778,
446,
8802,
19881,
22706,
367,
675,
315,
8597,
4007,
282,
7798,
2656,
2043,
2468,
63,
11356,
446,
428,
3344,
10889,
10572,
2908,
7798,
2656,
2043,
2468,
63,
11356,
63,
66,
7028,
446,
428,
3344,
10889,
10572,
2908,
330,
7028,
7798,
2656,
2043,
29167,
446,
8354,
314,
29167,
22706,
14,
2043,
29757,
446,
1413,
50,
22706,
402,
282,
3634,
2043,
29757,
63,
13710,
446,
1413,
50,
22706,
436,
24638,
701,
1413,
2043,
29757,
63,
873,
446,
31536,
1022,
1413,
50,
1678,
2043,
29757,
63,
1807,
446,
1413,
50,
3224,
602,
641,
1962,
503,
2763,
14068,
2043,
29757,
63,
3176,
446,
1413,
50,
1678,
641,
1962,
503,
2763,
22470,
2043,
24659,
446,
820,
49,
22706,
402,
282,
3634,
2043,
1894,
90,
446,
1413,
58,
22706,
402,
282,
4092,
402,
12627,
2043,
6206,
17156,
446,
1413,
58,
22706,
402,
282,
4092,
402,
12627,
543,
295,
7128,
2043,
308,
335,
300,
446,
22985,
300,
22706,
402,
282,
3634,
2043,
519,
7646,
18,
1259,
70,
446,
14849,
370,
6114,
22985,
300,
1824,
2043,
394,
397,
2464,
14630,
446,
869,
397,
2464,
14630,
1824,
402,
282,
3634,
199,
199,
703,
19352,
447,
8410,
658,
14248,
14,
10096,
14,
29690,
1905,
64,
1553,
6551,
2515,
1905,
3634,
477,
7784,
6150,
421,
199,
6443,
17471,
199,
1280,
199,
199,
703,
26651,
29309,
447,
2043,
520,
475,
16970,
26,
4046,
15,
8410,
1437,
77,
446,
8449,
23160,
2043,
943,
77,
446,
8449,
943,
18327,
77,
2043,
512,
3300,
446,
8449,
28188,
2043,
9829,
77,
446,
8449,
308,
1132,
2043,
20162,
77,
446,
8449,
307,
29360,
2043,
512,
609,
77,
446,
8449,
10342,
9670,
28188,
2043,
9829,
14038,
446,
8449,
10342,
9670,
308,
1132,
2043,
20162,
14038,
446,
8449,
10342,
9670,
307,
29360,
2043,
2070,
77,
446,
8449,
2070,
2043,
7452,
77,
446,
8449,
12386,
1738,
2043,
9627,
77,
446,
16494,
85,
1958,
376,
9697,
3634,
805,
2043,
1437,
77,
63,
20153,
335,
386,
446,
481,
264,
335,
386,
18883,
402,
314,
3634,
23160,
2043,
1437,
77,
63,
2067,
446,
22419,
5558,
1329,
402,
1437,
77,
315,
314,
481,
293,
18486,
73,
527,
6316,
2043,
27487,
63,
3642,
63,
5652,
446,
17980,
279,
3634,
7074,
421,
199,
6443,
662,
392,
425,
428,
3725,
83,
199,
1280,
18673,
199,
199,
703,
26651,
29309,
447,
2043,
520,
475,
16970,
26,
4046,
15,
8410,
14241,
63,
1786,
24279,
351,
446,
428,
3344,
314,
5515,
24279,
351,
3634,
18649,
2043,
14241,
63,
23458,
63,
1530,
446,
428,
3344,
314,
19922,
13,
521,
741,
27060,
820,
530,
696,
280,
18649,
2043,
14241,
63
] |
[
199,
2486,
532,
199,
10608,
741,
19355,
18479,
1494,
1705,
14248,
14,
10096,
10522,
199,
2486,
532,
199,
199,
703,
1453,
578,
447,
7026,
14,
10096,
199,
199,
10608,
741,
19355,
3423,
14,
199,
199,
703,
19352,
447,
8410,
658,
4714,
14,
10096,
64,
367,
1655,
7798,
741,
19355,
3423,
14,
221,
3390,
626,
2043,
22160,
658,
14248,
14,
10096,
64,
8925,
4750,
402,
3062,
12,
6120,
17269,
4310,
2043,
3423,
687,
658,
14248,
14,
10096,
64,
1443,
19793,
1655,
503,
18023,
28488,
2043,
9330,
14,
421,
199,
6845,
83,
199,
23476,
199,
199,
703,
26651,
29309,
447,
2043,
520,
475,
16970,
26,
4046,
15,
8410,
4572,
446,
6668,
314,
11484,
402,
282,
12386,
3634,
2043,
14241,
446,
428,
3344,
282,
7798,
2656,
402,
26426,
2043,
14241,
63,
66,
7028,
446,
428,
3344,
282,
330,
7028,
7798,
2656,
2043,
14241,
72,
63,
66,
7028,
446,
428,
3344,
282,
18769,
26649,
503,
16371,
330,
7028,
2656,
2043,
14241,
63,
6092,
348,
867,
446,
428,
3344,
282,
286,
723,
3119,
867,
2656,
2043,
14241,
63,
29663,
446,
428,
3344,
282,
3229,
11572,
3634,
2043,
14241,
63,
475,
1545,
29382,
446,
428,
3344,
282,
370,
1545,
29382,
3634,
2043,
20894,
446,
6668,
314,
4563,
867,
402,
282,
12386,
3634,
2043,
6316,
446,
8449,
436,
5477,
6316,
2043,
9877,
3526,
446,
428,
3344,
282,
7798,
5210,
13,
20956,
5160,
2043,
299,
5350,
446,
510,
9917,
13,
11668,
334,
3716,
720,
13,
15597,
293,
261,
9,
1808,
9877,
3526,
2043,
299,
5350,
18,
446,
510,
9917,
13,
11668,
1808,
26937,
2043,
299,
5350,
72,
446,
510,
9917,
13,
11668,
402,
14737,
26649,
3634,
2043,
1022,
2641,
446,
1804,
82,
368,
22043,
3336,
402,
2877,
6572,
2043,
3229,
76,
446,
9215,
282,
5117,
13,
29663,
3634,
687,
282,
1627,
3634,
2043,
3229,
85,
446,
9215,
376,
7008,
13,
29663,
3634,
687,
282,
1627,
3634,
2043,
29069,
63,
496,
1556,
527,
744,
446,
428,
3344,
376,
29069,
2165,
1556,
527,
744,
5160,
2043,
3634,
63,
7358,
446,
23928,
554,
3634,
4811,
543,
282,
22838,
13315,
2043,
29730,
28846,
547,
199,
199,
37,
8478,
585,
2165,
7561,
199,
1280,
5918,
199,
199,
703,
26651,
29309,
447,
2043,
520,
475,
16970,
26,
4046,
15,
8410,
26547,
446,
6668,
314,
22953,
436,
29802,
402,
282,
12386,
3634,
2043,
26547,
3643,
446,
6668,
2951,
314,
22953,
402,
282,
12386,
3634,
2043,
325,
2056,
446,
6668,
314,
325,
13,
3643,
436,
325,
13,
12280,
402,
282,
18769,
26649,
503,
16371,
3634,
2043,
26547,
637,
609,
446,
6668,
2951,
314,
22953,
402,
282,
18769,
26649,
503,
16371,
3634,
2043,
26547,
63,
66,
7028,
446,
6668,
314,
22953,
436,
29802,
402,
282,
330,
7028,
3634,
2043,
26547,
3643,
63,
66,
7028,
446,
6668,
2951,
314,
22953,
402,
282,
330,
7028,
3634,
199,
199,
872,
7784,
6150,
199,
17224,
199,
199,
703,
26651,
29309,
447,
2043,
520,
475,
16970,
26,
4046,
15,
8410,
16795,
446,
491,
53,
22706,
402,
282,
3634,
2043,
16795,
63,
4778,
446,
491,
53,
22706,
8152,
31716,
3634,
436,
22292,
83,
2043,
16795,
63,
11356,
446,
428,
3344,
437,
88,
29,
66,
1808,
1771,
20584,
543,
1072,
402,
16795,
63,
4778,
2043,
26937,
446,
428,
14257,
574,
22706,
402,
282,
3634,
2043,
26937,
3643,
446,
428,
14257,
1338,
402,
282,
3634,
2043,
487,
7391,
11549,
446,
9215,
3634,
402,
15823,
1338,
687,
1072,
402,
26937,
2043,
19425,
446,
9215,
503,
898,
1783,
5597,
367,
314,
1425,
402,
437,
1808,
26937,
2043,
2468,
19881,
446,
8802,
19881,
22706,
402,
282,
3634,
2043,
2468,
19881,
63,
66,
7028,
446,
8802,
19881,
477,
863,
14,
402,
282,
4678,
14,
503,
18769,
26649,
330,
7028,
3634,
2043,
2468,
63,
4778,
446,
8802,
19881,
22706,
367,
675,
315,
8597,
4007,
282,
7798,
2656,
2043,
2468,
63,
11356,
446,
428,
3344,
10889,
10572,
2908,
7798,
2656,
2043,
2468,
63,
11356,
63,
66,
7028,
446,
428,
3344,
10889,
10572,
2908,
330,
7028,
7798,
2656,
2043,
29167,
446,
8354,
314,
29167,
22706,
14,
2043,
29757,
446,
1413,
50,
22706,
402,
282,
3634,
2043,
29757,
63,
13710,
446,
1413,
50,
22706,
436,
24638,
701,
1413,
2043,
29757,
63,
873,
446,
31536,
1022,
1413,
50,
1678,
2043,
29757,
63,
1807,
446,
1413,
50,
3224,
602,
641,
1962,
503,
2763,
14068,
2043,
29757,
63,
3176,
446,
1413,
50,
1678,
641,
1962,
503,
2763,
22470,
2043,
24659,
446,
820,
49,
22706,
402,
282,
3634,
2043,
1894,
90,
446,
1413,
58,
22706,
402,
282,
4092,
402,
12627,
2043,
6206,
17156,
446,
1413,
58,
22706,
402,
282,
4092,
402,
12627,
543,
295,
7128,
2043,
308,
335,
300,
446,
22985,
300,
22706,
402,
282,
3634,
2043,
519,
7646,
18,
1259,
70,
446,
14849,
370,
6114,
22985,
300,
1824,
2043,
394,
397,
2464,
14630,
446,
869,
397,
2464,
14630,
1824,
402,
282,
3634,
199,
199,
703,
19352,
447,
8410,
658,
14248,
14,
10096,
14,
29690,
1905,
64,
1553,
6551,
2515,
1905,
3634,
477,
7784,
6150,
421,
199,
6443,
17471,
199,
1280,
199,
199,
703,
26651,
29309,
447,
2043,
520,
475,
16970,
26,
4046,
15,
8410,
1437,
77,
446,
8449,
23160,
2043,
943,
77,
446,
8449,
943,
18327,
77,
2043,
512,
3300,
446,
8449,
28188,
2043,
9829,
77,
446,
8449,
308,
1132,
2043,
20162,
77,
446,
8449,
307,
29360,
2043,
512,
609,
77,
446,
8449,
10342,
9670,
28188,
2043,
9829,
14038,
446,
8449,
10342,
9670,
308,
1132,
2043,
20162,
14038,
446,
8449,
10342,
9670,
307,
29360,
2043,
2070,
77,
446,
8449,
2070,
2043,
7452,
77,
446,
8449,
12386,
1738,
2043,
9627,
77,
446,
16494,
85,
1958,
376,
9697,
3634,
805,
2043,
1437,
77,
63,
20153,
335,
386,
446,
481,
264,
335,
386,
18883,
402,
314,
3634,
23160,
2043,
1437,
77,
63,
2067,
446,
22419,
5558,
1329,
402,
1437,
77,
315,
314,
481,
293,
18486,
73,
527,
6316,
2043,
27487,
63,
3642,
63,
5652,
446,
17980,
279,
3634,
7074,
421,
199,
6443,
662,
392,
425,
428,
3725,
83,
199,
1280,
18673,
199,
199,
703,
26651,
29309,
447,
2043,
520,
475,
16970,
26,
4046,
15,
8410,
14241,
63,
1786,
24279,
351,
446,
428,
3344,
314,
5515,
24279,
351,
3634,
18649,
2043,
14241,
63,
23458,
63,
1530,
446,
428,
3344,
314,
19922,
13,
521,
741,
27060,
820,
530,
696,
280,
18649,
2043,
14241,
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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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
] |
fearlessspider/python-social-auth
|
examples/pyramid_example/example/tests.py
|
63
|
1499
|
import unittest
import transaction
from pyramid import testing
from .models import DBSession
class TestMyViewSuccessCondition(unittest.TestCase):
def setUp(self):
self.config = testing.setUp()
from sqlalchemy import create_engine
engine = create_engine('sqlite://')
from .models import (
Base,
MyModel,
)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
model = MyModel(name='one', value=55)
DBSession.add(model)
def tearDown(self):
DBSession.remove()
testing.tearDown()
def test_passing_view(self):
from .views import my_view
request = testing.DummyRequest()
info = my_view(request)
self.assertEqual(info['one'].name, 'one')
self.assertEqual(info['project'], 'example')
class TestMyViewFailureCondition(unittest.TestCase):
def setUp(self):
self.config = testing.setUp()
from sqlalchemy import create_engine
engine = create_engine('sqlite://')
from .models import (
Base,
MyModel,
)
DBSession.configure(bind=engine)
def tearDown(self):
DBSession.remove()
testing.tearDown()
def test_failing_view(self):
from .views import my_view
request = testing.DummyRequest()
info = my_view(request)
self.assertEqual(info.status_int, 500)
|
bsd-3-clause
|
[
646,
2882,
199,
646,
6008,
199,
199,
504,
30704,
492,
5343,
199,
199,
504,
1275,
992,
492,
6249,
4434,
421,
199,
533,
1379,
5713,
2768,
8300,
9558,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
888,
275,
5343,
14,
5996,
342,
267,
687,
8335,
492,
1218,
63,
3908,
267,
6869,
275,
1218,
63,
3908,
360,
10659,
921,
358,
267,
687,
1275,
992,
492,
334,
288,
3523,
12,
288,
4932,
1685,
12,
288,
776,
267,
6249,
4434,
14,
6472,
8,
3409,
29,
3908,
9,
267,
3523,
14,
2343,
14,
981,
63,
452,
8,
3908,
9,
267,
543,
6008,
14,
2609,
26,
288,
1402,
275,
4932,
1685,
8,
354,
534,
368,
297,
574,
29,
1229,
9,
288,
6249,
4434,
14,
525,
8,
1238,
9,
339,
347,
6766,
8,
277,
304,
267,
6249,
4434,
14,
2168,
342,
267,
5343,
14,
12336,
342,
339,
347,
511,
63,
29436,
63,
1345,
8,
277,
304,
267,
687,
1275,
4196,
492,
3002,
63,
1345,
267,
1056,
275,
5343,
14,
11324,
2017,
342,
267,
2256,
275,
3002,
63,
1345,
8,
1069,
9,
267,
291,
14,
629,
8,
815,
459,
368,
2278,
354,
12,
283,
368,
358,
267,
291,
14,
629,
8,
815,
459,
1715,
995,
283,
2694,
358,
421,
199,
533,
1379,
5713,
2768,
6782,
9558,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
888,
275,
5343,
14,
5996,
342,
267,
687,
8335,
492,
1218,
63,
3908,
267,
6869,
275,
1218,
63,
3908,
360,
10659,
921,
358,
267,
687,
1275,
992,
492,
334,
288,
3523,
12,
288,
4932,
1685,
12,
288,
776,
267,
6249,
4434,
14,
6472,
8,
3409,
29,
3908,
9,
339,
347,
6766,
8,
277,
304,
267,
6249,
4434,
14,
2168,
342,
267,
5343,
14,
12336,
342,
339,
347,
511,
63,
25299,
63,
1345,
8,
277,
304,
267,
687,
1275,
4196,
492,
3002,
63,
1345,
267,
1056,
275,
5343,
14,
11324,
2017,
342,
267,
2256,
275,
3002,
63,
1345,
8,
1069,
9,
267,
291,
14,
629,
8,
815,
14,
1205,
63,
442,
12,
6891,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2882,
199,
646,
6008,
199,
199,
504,
30704,
492,
5343,
199,
199,
504,
1275,
992,
492,
6249,
4434,
421,
199,
533,
1379,
5713,
2768,
8300,
9558,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
888,
275,
5343,
14,
5996,
342,
267,
687,
8335,
492,
1218,
63,
3908,
267,
6869,
275,
1218,
63,
3908,
360,
10659,
921,
358,
267,
687,
1275,
992,
492,
334,
288,
3523,
12,
288,
4932,
1685,
12,
288,
776,
267,
6249,
4434,
14,
6472,
8,
3409,
29,
3908,
9,
267,
3523,
14,
2343,
14,
981,
63,
452,
8,
3908,
9,
267,
543,
6008,
14,
2609,
26,
288,
1402,
275,
4932,
1685,
8,
354,
534,
368,
297,
574,
29,
1229,
9,
288,
6249,
4434,
14,
525,
8,
1238,
9,
339,
347,
6766,
8,
277,
304,
267,
6249,
4434,
14,
2168,
342,
267,
5343,
14,
12336,
342,
339,
347,
511,
63,
29436,
63,
1345,
8,
277,
304,
267,
687,
1275,
4196,
492,
3002,
63,
1345,
267,
1056,
275,
5343,
14,
11324,
2017,
342,
267,
2256,
275,
3002,
63,
1345,
8,
1069,
9,
267,
291,
14,
629,
8,
815,
459,
368,
2278,
354,
12,
283,
368,
358,
267,
291,
14,
629,
8,
815,
459,
1715,
995,
283,
2694,
358,
421,
199,
533,
1379,
5713,
2768,
6782,
9558,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
888,
275,
5343,
14,
5996,
342,
267,
687,
8335,
492,
1218,
63,
3908,
267,
6869,
275,
1218,
63,
3908,
360,
10659,
921,
358,
267,
687,
1275,
992,
492,
334,
288,
3523,
12,
288,
4932,
1685,
12,
288,
776,
267,
6249,
4434,
14,
6472,
8,
3409,
29,
3908,
9,
339,
347,
6766,
8,
277,
304,
267,
6249,
4434,
14,
2168,
342,
267,
5343,
14,
12336,
342,
339,
347,
511,
63,
25299,
63,
1345,
8,
277,
304,
267,
687,
1275,
4196,
492,
3002,
63,
1345,
267,
1056,
275,
5343,
14,
11324,
2017,
342,
267,
2256,
275,
3002,
63,
1345,
8,
1069,
9,
267,
291,
14,
629,
8,
815,
14,
1205,
63,
442,
12,
6891,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
komissarex/centipede
|
lib/testers/base_tester.py
|
1
|
5818
|
from abc import ABCMeta, abstractmethod
from centipede import centipede
from shutil import rmtree
import os
import threading
import commands
import subprocess
import psutil
import time
class BaseTester(threading.Thread):
"""
Base abstract tester class, desined as thread
"""
__metaclass__ = ABCMeta
def __init__(self, solution, semaphore):
super(BaseTester, self).__init__()
self.semaphore = semaphore
self.solution = solution
self.semaphore.acquire()
def get_sandbox_path(self):
"""
:return: Compilation and running folder
"""
return os.path.join(centipede.config['SANDBOX_FOLDER'], str(self.solution.id))
def get_compiled_file(self):
"""
:return: Full path to the compiled file
"""
return os.path.join(self.get_sandbox_path(), str(self.solution.id))
def _compile_default(self, compilation_string):
"""
Implements default compilation process
:param compilation_string: Compilation string, containing {output} and {source} substrings
:return: True, if compilation successful
"""
self.solution.update(self.solution.STATUS['waiting']['compiling'])
path = self.get_sandbox_path()
if not os.path.exists(path):
os.makedirs(path)
status, output = commands.getstatusoutput(
compilation_string\
.format(output = self.get_compiled_file(), source = self.solution.get_solution_file()))
if status != 0:
self.solution.update(
self.solution.STATUS['tested']['error']['ce'],
message = output.decode('utf-8')
)
return False
return True
def _run_default(self, command = '{solution}'):
"""
Implements default testing process
:param command Running command, containing {solution} substring
:return: True, if solution passed all tests
"""
if self.compile():
self.solution.update(self.solution.STATUS['waiting']['running'])
test_number = 1
memory_max = curr_time = 0
for test in self.solution.problem.tests:
# filling input
input = open(os.path.join(self.get_sandbox_path(), 'input.txt'), 'w')
input.write(str(test.input))
input.close()
# spawn solution file
proc = subprocess.Popen(
command.format(solution = os.path.abspath(self.get_compiled_file())),
cwd = os.path.abspath(self.get_sandbox_path()),
)
# take care of time and memory
start_time = time.time()
while proc.poll() is None:
watchdog = psutil.Process(proc.pid)
curr_time = time.time() - start_time
memory = watchdog.get_memory_info().rss / 1024
if memory > memory_max:
memory_max = memory
print 'time: {time}, rss: {rss}'.format(time = curr_time, rss = memory)
# detectimg memory limit
if memory_max > self.solution.problem.memory * 1024:
proc.terminate()
self.solution.update(
self.solution.STATUS['tested']['error']['mle'],
time = curr_time,
memory = memory_max,
test_number = test_number
)
return False
# detecting time limit
if curr_time > self.solution.problem.time:
proc.terminate()
self.solution.update(
self.solution.STATUS['tested']['error']['tle'],
time = curr_time,
memory = memory_max,
test_number = test_number
)
return False
# detecting crash
if proc.returncode != 0:
self.solution.update(
self.solution.STATUS['tested']['error']['re'],
test_number = test_number
)
return False
# catching presentation errors
try:
output = open(os.path.join(self.get_sandbox_path(), 'output.txt'), 'r+')
except IOError:
self.solution.update(
self.solution.STATUS['tested']['error']['pe'],
test_number = test_number
)
return False
# catching WA
if str(test.output).strip() != str(output.read()).strip():
self.solution.update(
self.solution.STATUS['tested']['error']['wa'],
test_number = test_number,
time = curr_time,
memory = memory_max
)
return False
test_number += 1
# all tests passed, hurrah!
self.solution.update(
self.solution.STATUS['tested']['accept'],
time = curr_time,
memory = memory_max
)
return True
return False
def __del__(self):
self.semaphore.release()
@abstractmethod
def compile(self):
"""
Compilation process
"""
pass
@abstractmethod
def run(self):
"""
Testing process
"""
pass
|
mit
|
[
504,
13022,
492,
29565,
12,
9006,
765,
199,
504,
9679,
280,
321,
271,
492,
9679,
280,
321,
271,
199,
504,
221,
5145,
492,
20978,
199,
646,
747,
199,
646,
5796,
199,
646,
3718,
199,
646,
3873,
199,
646,
22214,
199,
646,
900,
199,
199,
533,
3523,
22403,
8,
12562,
14,
4436,
304,
272,
408,
272,
3523,
9006,
17570,
1021,
12,
18618,
1942,
465,
2462,
272,
408,
272,
636,
6577,
363,
275,
221,
29565,
339,
347,
636,
826,
721,
277,
12,
8744,
12,
542,
17185,
304,
267,
1613,
8,
1563,
22403,
12,
291,
2843,
826,
4533,
267,
291,
14,
261,
17185,
275,
542,
17185,
267,
291,
14,
14458,
275,
8744,
267,
291,
14,
261,
17185,
14,
8174,
342,
339,
347,
664,
63,
16647,
63,
515,
8,
277,
304,
267,
408,
267,
520,
1107,
26,
3599,
13696,
436,
3879,
4922,
267,
408,
267,
372,
747,
14,
515,
14,
904,
8,
2497,
280,
321,
271,
14,
888,
459,
51,
879,
2846,
29544,
63,
19041,
995,
620,
8,
277,
14,
14458,
14,
344,
430,
339,
347,
664,
63,
8427,
63,
493,
8,
277,
304,
267,
408,
267,
520,
1107,
26,
16579,
931,
370,
314,
10311,
570,
267,
408,
267,
372,
747,
14,
515,
14,
904,
8,
277,
14,
362,
63,
16647,
63,
515,
1062,
620,
8,
277,
14,
14458,
14,
344,
430,
339,
347,
485,
2014,
63,
885,
8,
277,
12,
18653,
63,
875,
304,
267,
408,
267,
24664,
849,
18653,
2112,
267,
520,
635,
18653,
63,
875,
26,
3599,
13696,
1059,
12,
3035,
469,
1199,
93,
436,
469,
1365,
93,
1007,
5465,
267,
520,
1107,
26,
715,
12,
340,
18653,
9512,
267,
408,
267,
291,
14,
14458,
14,
873,
8,
277,
14,
14458,
14,
6305,
459,
14093,
2545,
863,
5662,
1105,
398,
931,
275,
291,
14,
362,
63,
16647,
63,
515,
342,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
515,
304,
288,
747,
14,
8347,
8,
515,
9,
398,
2004,
12,
1072,
275,
3718,
14,
362,
1205,
1199,
8,
288,
18653,
63,
875,
60,
288,
1275,
908,
8,
1199,
275,
291,
14,
362,
63,
8427,
63,
493,
1062,
1350,
275,
291,
14,
14458,
14,
362,
63,
14458,
63,
493,
4059,
398,
340,
2004,
1137,
378,
26,
288,
291,
14,
14458,
14,
873,
8,
355,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
301,
995,
355,
1245,
275,
1072,
14,
2708,
360,
1624,
13,
24,
358,
288,
776,
288,
372,
756,
398,
372,
715,
339,
347,
485,
1065,
63,
885,
8,
277,
12,
1414,
275,
5041,
14458,
93,
735,
267,
408,
267,
24664,
849,
5343,
2112,
267,
520,
635,
1414,
26848,
1414,
12,
3035,
469,
14458,
93,
20597,
267,
520,
1107,
26,
715,
12,
340,
8744,
3032,
1006,
2295,
267,
408,
398,
340,
291,
14,
2014,
837,
288,
291,
14,
14458,
14,
873,
8,
277,
14,
14458,
14,
6305,
459,
14093,
2545,
5720,
1105,
953,
511,
63,
1955,
275,
413,
288,
4402,
63,
988,
275,
8230,
63,
521,
275,
378,
288,
367,
511,
315,
291,
14,
14458,
14,
6462,
14,
2219,
26,
355,
327,
32499,
1324,
355,
1324,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
277,
14,
362,
63,
16647,
63,
515,
1062,
283,
1210,
14,
2424,
659,
283,
87,
358,
355,
1324,
14,
952,
8,
495,
8,
396,
14,
1210,
430,
355,
1324,
14,
1600,
342,
2234,
327,
15187,
8744,
570,
355,
6499,
275,
3873,
14,
7942,
8,
490,
1414,
14,
908,
8,
14458,
275,
747,
14,
515,
14,
4832,
8,
277,
14,
362,
63,
8427,
63,
493,
22606,
490,
8288,
275,
747,
14,
515,
14,
4832,
8,
277,
14,
362,
63,
16647,
63,
515,
4000,
355,
776,
2234,
327,
5452,
10296,
402,
900,
436,
4402,
355,
1343,
63,
521,
275,
900,
14,
521,
342,
355,
1830,
6499,
14,
6843,
342,
365,
488,
26,
490,
9626,
13889,
275,
22214,
14,
3498,
8,
4687,
14,
3150,
9,
490,
8230,
63,
521,
275,
900,
14,
521,
342,
446,
1343,
63,
521,
490,
4402,
275,
9626,
13889,
14,
362,
63,
4844,
63,
815,
1252,
13614,
1182,
6619,
490,
340,
4402,
690,
4402,
63,
988,
26,
717,
4402,
63,
988,
275,
4402,
490,
870,
283,
521,
26,
469,
521,
1386,
32291,
26,
469,
13614,
5285,
908,
8,
521,
275,
8230,
63,
521,
12,
32291,
275,
4402,
9,
4951,
327,
477,
266,
67,
2906,
71,
4402,
2304,
490,
340,
4402,
63,
988,
690,
291,
14,
14458,
14,
6462,
14,
4844,
627,
6619,
26,
717,
6499,
14,
14478,
342,
717,
291,
14,
14458,
14,
873,
8,
1169,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
29198,
995,
1169,
900,
275,
8230,
63,
521,
12,
1169,
4402,
275,
4402,
63,
988,
12,
1169,
511,
63,
1955,
275,
511,
63,
1955,
717,
776,
717,
372,
756,
4951,
327,
9696,
316,
900,
2304,
490,
340,
8230,
63,
521,
690,
291,
14,
14458,
14,
6462,
14,
521,
26,
717,
6499,
14,
14478,
342,
717,
291,
14,
14458,
14,
873,
8,
1169,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
1118,
995,
1169,
900,
275,
8230,
63,
521,
12,
1169,
4402,
275,
4402,
63,
988,
12,
1169,
511,
63,
1955,
275,
511,
63,
1955,
717,
776,
717,
372,
756,
2234,
327,
9696,
316,
12420,
355,
340,
6499,
14,
9913,
1137,
378,
26,
490,
291,
14,
14458,
14,
873,
8,
717,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
264,
995,
717,
511,
63,
1955,
275,
511,
63,
1955,
490,
776,
490,
372,
756,
2234,
327,
8579,
316,
3451,
425,
2552,
355,
862,
26,
490,
1072,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
277,
14,
362,
63,
16647,
63,
515,
1062,
283,
1199,
14,
2424,
659,
283,
82,
13854,
355,
871,
5925,
26,
490,
291,
14,
14458,
14,
873,
8,
717,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
321,
995,
717,
511,
63,
1955,
275,
511,
63,
1955,
490,
776,
490,
372,
756,
2234,
327,
8579,
316,
644,
33,
355,
340,
620,
8,
396,
14,
1199,
680,
1913,
342,
1137,
620,
8,
1199,
14,
739,
8801,
1913,
837,
490,
291,
14,
14458,
14,
873,
8,
717,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
758,
995,
717,
511,
63,
1955
] |
[
13022,
492,
29565,
12,
9006,
765,
199,
504,
9679,
280,
321,
271,
492,
9679,
280,
321,
271,
199,
504,
221,
5145,
492,
20978,
199,
646,
747,
199,
646,
5796,
199,
646,
3718,
199,
646,
3873,
199,
646,
22214,
199,
646,
900,
199,
199,
533,
3523,
22403,
8,
12562,
14,
4436,
304,
272,
408,
272,
3523,
9006,
17570,
1021,
12,
18618,
1942,
465,
2462,
272,
408,
272,
636,
6577,
363,
275,
221,
29565,
339,
347,
636,
826,
721,
277,
12,
8744,
12,
542,
17185,
304,
267,
1613,
8,
1563,
22403,
12,
291,
2843,
826,
4533,
267,
291,
14,
261,
17185,
275,
542,
17185,
267,
291,
14,
14458,
275,
8744,
267,
291,
14,
261,
17185,
14,
8174,
342,
339,
347,
664,
63,
16647,
63,
515,
8,
277,
304,
267,
408,
267,
520,
1107,
26,
3599,
13696,
436,
3879,
4922,
267,
408,
267,
372,
747,
14,
515,
14,
904,
8,
2497,
280,
321,
271,
14,
888,
459,
51,
879,
2846,
29544,
63,
19041,
995,
620,
8,
277,
14,
14458,
14,
344,
430,
339,
347,
664,
63,
8427,
63,
493,
8,
277,
304,
267,
408,
267,
520,
1107,
26,
16579,
931,
370,
314,
10311,
570,
267,
408,
267,
372,
747,
14,
515,
14,
904,
8,
277,
14,
362,
63,
16647,
63,
515,
1062,
620,
8,
277,
14,
14458,
14,
344,
430,
339,
347,
485,
2014,
63,
885,
8,
277,
12,
18653,
63,
875,
304,
267,
408,
267,
24664,
849,
18653,
2112,
267,
520,
635,
18653,
63,
875,
26,
3599,
13696,
1059,
12,
3035,
469,
1199,
93,
436,
469,
1365,
93,
1007,
5465,
267,
520,
1107,
26,
715,
12,
340,
18653,
9512,
267,
408,
267,
291,
14,
14458,
14,
873,
8,
277,
14,
14458,
14,
6305,
459,
14093,
2545,
863,
5662,
1105,
398,
931,
275,
291,
14,
362,
63,
16647,
63,
515,
342,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
515,
304,
288,
747,
14,
8347,
8,
515,
9,
398,
2004,
12,
1072,
275,
3718,
14,
362,
1205,
1199,
8,
288,
18653,
63,
875,
60,
288,
1275,
908,
8,
1199,
275,
291,
14,
362,
63,
8427,
63,
493,
1062,
1350,
275,
291,
14,
14458,
14,
362,
63,
14458,
63,
493,
4059,
398,
340,
2004,
1137,
378,
26,
288,
291,
14,
14458,
14,
873,
8,
355,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
301,
995,
355,
1245,
275,
1072,
14,
2708,
360,
1624,
13,
24,
358,
288,
776,
288,
372,
756,
398,
372,
715,
339,
347,
485,
1065,
63,
885,
8,
277,
12,
1414,
275,
5041,
14458,
93,
735,
267,
408,
267,
24664,
849,
5343,
2112,
267,
520,
635,
1414,
26848,
1414,
12,
3035,
469,
14458,
93,
20597,
267,
520,
1107,
26,
715,
12,
340,
8744,
3032,
1006,
2295,
267,
408,
398,
340,
291,
14,
2014,
837,
288,
291,
14,
14458,
14,
873,
8,
277,
14,
14458,
14,
6305,
459,
14093,
2545,
5720,
1105,
953,
511,
63,
1955,
275,
413,
288,
4402,
63,
988,
275,
8230,
63,
521,
275,
378,
288,
367,
511,
315,
291,
14,
14458,
14,
6462,
14,
2219,
26,
355,
327,
32499,
1324,
355,
1324,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
277,
14,
362,
63,
16647,
63,
515,
1062,
283,
1210,
14,
2424,
659,
283,
87,
358,
355,
1324,
14,
952,
8,
495,
8,
396,
14,
1210,
430,
355,
1324,
14,
1600,
342,
2234,
327,
15187,
8744,
570,
355,
6499,
275,
3873,
14,
7942,
8,
490,
1414,
14,
908,
8,
14458,
275,
747,
14,
515,
14,
4832,
8,
277,
14,
362,
63,
8427,
63,
493,
22606,
490,
8288,
275,
747,
14,
515,
14,
4832,
8,
277,
14,
362,
63,
16647,
63,
515,
4000,
355,
776,
2234,
327,
5452,
10296,
402,
900,
436,
4402,
355,
1343,
63,
521,
275,
900,
14,
521,
342,
355,
1830,
6499,
14,
6843,
342,
365,
488,
26,
490,
9626,
13889,
275,
22214,
14,
3498,
8,
4687,
14,
3150,
9,
490,
8230,
63,
521,
275,
900,
14,
521,
342,
446,
1343,
63,
521,
490,
4402,
275,
9626,
13889,
14,
362,
63,
4844,
63,
815,
1252,
13614,
1182,
6619,
490,
340,
4402,
690,
4402,
63,
988,
26,
717,
4402,
63,
988,
275,
4402,
490,
870,
283,
521,
26,
469,
521,
1386,
32291,
26,
469,
13614,
5285,
908,
8,
521,
275,
8230,
63,
521,
12,
32291,
275,
4402,
9,
4951,
327,
477,
266,
67,
2906,
71,
4402,
2304,
490,
340,
4402,
63,
988,
690,
291,
14,
14458,
14,
6462,
14,
4844,
627,
6619,
26,
717,
6499,
14,
14478,
342,
717,
291,
14,
14458,
14,
873,
8,
1169,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
29198,
995,
1169,
900,
275,
8230,
63,
521,
12,
1169,
4402,
275,
4402,
63,
988,
12,
1169,
511,
63,
1955,
275,
511,
63,
1955,
717,
776,
717,
372,
756,
4951,
327,
9696,
316,
900,
2304,
490,
340,
8230,
63,
521,
690,
291,
14,
14458,
14,
6462,
14,
521,
26,
717,
6499,
14,
14478,
342,
717,
291,
14,
14458,
14,
873,
8,
1169,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
1118,
995,
1169,
900,
275,
8230,
63,
521,
12,
1169,
4402,
275,
4402,
63,
988,
12,
1169,
511,
63,
1955,
275,
511,
63,
1955,
717,
776,
717,
372,
756,
2234,
327,
9696,
316,
12420,
355,
340,
6499,
14,
9913,
1137,
378,
26,
490,
291,
14,
14458,
14,
873,
8,
717,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
264,
995,
717,
511,
63,
1955,
275,
511,
63,
1955,
490,
776,
490,
372,
756,
2234,
327,
8579,
316,
3451,
425,
2552,
355,
862,
26,
490,
1072,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
277,
14,
362,
63,
16647,
63,
515,
1062,
283,
1199,
14,
2424,
659,
283,
82,
13854,
355,
871,
5925,
26,
490,
291,
14,
14458,
14,
873,
8,
717,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
321,
995,
717,
511,
63,
1955,
275,
511,
63,
1955,
490,
776,
490,
372,
756,
2234,
327,
8579,
316,
644,
33,
355,
340,
620,
8,
396,
14,
1199,
680,
1913,
342,
1137,
620,
8,
1199,
14,
739,
8801,
1913,
837,
490,
291,
14,
14458,
14,
873,
8,
717,
291,
14,
14458,
14,
6305,
459,
10453,
2545,
705,
2545,
758,
995,
717,
511,
63,
1955,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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ael Gruener <michael.gruener@chaosmoon.net>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import binascii
import copy
import textwrap
from datetime import datetime
DOCUMENTATION = '''
---
module: letsencrypt
author: "Michael Gruener (@mgruener)"
version_added: "2.2"
short_description: Create SSL certificates with Let's Encrypt
description:
- "Create and renew SSL certificates with Let's Encrypt. Let’s Encrypt is a
free, automated, and open certificate authority (CA), run for the
public’s benefit. For details see U(https://letsencrypt.org). The current
implementation supports the http-01, tls-sni-02 and dns-01 challenges."
- "To use this module, it has to be executed at least twice. Either as two
different tasks in the same run or during multiple runs."
- "Between these two tasks you have to fulfill the required steps for the
choosen challenge by whatever means necessary. For http-01 that means
creating the necessary challenge file on the destination webserver. For
dns-01 the necessary dns record has to be created. tls-sni-02 requires
you to create a SSL certificate with the appropriate subjectAlternativeNames.
It is I(not) the responsibility of this module to perform these steps."
- "For details on how to fulfill these challenges, you might have to read through
U(https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-7)"
- "Although the defaults are choosen so that the module can be used with
the Let's Encrypt CA, the module can be used with any service using the ACME
protocol."
requirements:
- "python >= 2.6"
options:
account_key:
description:
- "File containing the the Let's Encrypt account RSA key."
- "Can be created with C(openssl rsa ...)."
required: true
account_email:
description:
- "The email address associated with this account."
- "It will be used for certificate expiration warnings."
required: false
default: null
acme_directory:
description:
- "The ACME directory to use. This is the entry point URL to access
CA server API."
- "For safety reasons the default is set to the Let's Encrypt staging server.
This will create technically correct, but untrusted certifiactes."
required: false
default: https://acme-staging.api.letsencrypt.org/directory
agreement:
description:
- "URI to a terms of service document you agree to when using the
ACME service at C(acme_directory)."
required: false
default: 'https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf'
challenge:
description: The challenge to be performed.
required: false
choices: [ 'http-01', 'dns-01', 'tls-sni-02']
default: 'http-01'
csr:
description:
- "File containing the CSR for the new certificate."
- "Can be created with C(openssl csr ...)."
- "The CSR may contain multiple Subject Alternate Names, but each one
will lead to an individual challenge that must be fulfilled for the
CSR to be signed."
required: true
alias: ['src']
data:
description:
- "The data to validate ongoing challenges."
- "The value that must be used here will be provided by a previous use
of this module."
required: false
default: null
dest:
description: The destination file for the certificate.
required: true
alias: ['cert']
remaining_days:
description:
- "The number of days the certificate must have left being valid before it
will be renewed."
required: false
default: 10
'''
EXAMPLES = '''
- letsencrypt:
account_key: /etc/pki/cert/private/account.key
csr: /etc/pki/cert/csr/sample.com.csr
dest: /etc/httpd/ssl/sample.com.crt
register: sample_com_challenge
# perform the necessary steps to fulfill the challenge
# for example:
#
# - copy:
# dest: /var/www/html/{{ sample_com_http_challenge['challenge_data']['sample.com']['http-01']['resource'] }}
# content: "{{ sample_com_http_challenge['challenge_data']['sample.com']['http-01']['resource_value'] }}"
# when: sample_com_challenge|changed
- letsencrypt:
account_key: /etc/pki/cert/private/account.key
csr: /etc/pki/cert/csr/sample.com.csr
dest: /etc/httpd/ssl/sample.com.crt
data: "{{ sample_com_challenge }}"
'''
RETURN = '''
cert_days:
description: the number of days the certificate remains valid.
returned: success
challenge_data:
description: per domain / challenge type challenge data
returned: changed
type: dictionary
contains:
resource:
description: the challenge resource that must be created for validation
returned: changed
type: string
sample: .well-known/acme-challenge/evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA
resource_value:
description: the value the resource has to produce for the validation
returned: changed
type: string
sample: IlirfxKKXA...17Dt3juxGJ-PCt92wr-oA
authorizations:
description: ACME authorization data.
returned: changed
type: list
contains:
authorization:
description: ACME authorization object. See https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-6.1.2
returned: success
type: dict
'''
def nopad_b64(data):
return base64.urlsafe_b64encode(data).decode('utf8').replace("=", "")
def simple_get(module,url):
resp, info = fetch_url(module, url, method='GET')
result = None
try:
content = resp.read()
if info['content-type'].startswith('application/json'):
result = module.from_json(content.decode('utf8'))
else:
result = content
except AttributeError:
result = None
except ValueError:
module.fail_json(msg="Failed to parse the ACME response: {0} {1}".format(url,content))
if info['status'] >= 400:
module.fail_json(msg="ACME request failed: CODE: {0} RESULT:{1}".format(info['status'],result))
return result
def get_cert_days(module,cert_file):
'''
Return the days the certificate in cert_file remains valid and -1
if the file was not found.
'''
_cert_file = os.path.expanduser(cert_file)
if not os.path.exists(_cert_file):
return -1
openssl_bin = module.get_bin_path('openssl', True)
openssl_cert_cmd = [openssl_bin, "x509", "-in", _cert_file, "-noout", "-text"]
_, out, _ = module.run_command(openssl_cert_cmd,check_rc=True)
try:
not_after_str = re.search(r"\s+Not After\s*:\s+(.*)",out.decode('utf8')).group(1)
not_after = datetime.datetime.fromtimestamp(time.mktime(time.strptime(not_after_str,'%b %d %H:%M:%S %Y %Z')))
except AttributeError:
module.fail_json(msg="No 'Not after' date found in {0}".format(cert_file))
except ValueError:
module.fail_json(msg="Faild to parse 'Not after' date of {0}".format(cert_file))
now = datetime.datetime.utcnow()
return (not_after - now).days
# function source: network/basics/uri.py
def write_file(module, dest, content):
'''
Write content to destination file dest, only if the content
has changed.
'''
changed = False
# create a tempfile with some test content
_, tmpsrc = tempfile.mkstemp()
f = open(tmpsrc, 'wb')
try:
f.write(content)
except Exception as err:
os.remove(tmpsrc)
module.fail_json(msg="failed to create temporary content file: %s" % str(err))
f.close()
checksum_src = None
checksum_dest = None
# raise an error if there is no tmpsrc file
if not os.path.exists(tmpsrc):
os.remove(tmpsrc)
module.fail_json(msg="Source %s does not exist" % (tmpsrc))
if not os.access(tmpsrc, os.R_OK):
os.remove(tmpsrc)
module.fail_json( msg="Source %s not readable" % (tmpsrc))
checksum_src = module.sha1(tmpsrc)
# check if there is no dest file
if os.path.exists(dest):
# raise an error if copy has no permission on dest
if not os.access(dest, os.W_OK):
os.remove(tmpsrc)
module.fail_json(msg="Destination %s not writable" % (dest))
if not os.access(dest, os.R_OK):
os.remove(tmpsrc)
module.fail_json(msg="Destination %s not readable" % (dest))
checksum_dest = module.sha1(dest)
else:
if not os.access(os.path.dirname(dest), os.W_OK):
os.remove(tmpsrc)
module.fail_json(msg="Destination dir %s not writable" % (os.path.dirname(dest)))
if checksum_src != checksum_dest:
try:
shutil.copyfile(tmpsrc, dest)
changed = True
except Exception as err:
os.remove(tmpsrc)
module.fail_json(msg="failed to copy %s to %s: %s" % (tmpsrc, dest, str(err)))
os.remove(tmpsrc)
return changed
class ACMEDirectory(object):
'''
The ACME server directory. Gives access to the available resources
and the Replay-Nonce for a given uri. This only works for
uris that permit GET requests (so normally not the ones that
require authentication).
https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-6.2
'''
def __init__(self, module):
self.module = module
self.directory_root = module.params['acme_directory']
self.directory = simple_get(self.module,self.directory_root)
def __getitem__(self, key): return self.directory[key]
def get_nonce(self,resource=None):
url = self.directory_root
if resource is not None:
url = resource
_, info = fetch_url(self.module, url, method='HEAD')
if info['status'] != 200:
self.module.fail_json(msg="Failed to get replay-nonce, got status {0}".format(info['status']))
return info['replay-nonce']
class ACMEAccount(object):
'''
ACME account object. Handles the authorized communication with the
ACME server. Provides access to accound bound information like
the currently active authorizations and valid certificates
'''
def __init__(self,module):
self.module = module
self.agreement = module.params['agreement']
self.key = os.path.expanduser(module.params['account_key'])
self.email = module.params['account_email']
self.data = module.params['data']
self.directory = ACMEDirectory(module)
self.uri = None
self.changed = False
self._authz_list_uri = None
self._certs_list_uri = None
if not os.path.exists(self.key):
module.fail_json(msg="Account key %s not found" % (self.key))
self._openssl_bin = module.get_bin_path('openssl', True)
pub_hex, pub_exp = self._parse_account_key(self.key)
self.jws_header = {
"alg": "RS256",
"jwk": {
"e": nopad_b64(binascii.unhexlify(pub_exp.encode("utf-8"))),
"kty": "RSA",
"n": nopad_b64(binascii.unhexlify(re.sub(r"(\s|:)", "", pub_hex).encode("utf-8"))),
},
}
self.init_account()
def get_keyauthorization(self,token):
'''
Returns the key authorization for the given token
https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-7.1
'''
accountkey_json = json.dumps(self.jws_header['jwk'], sort_keys=True, separators=(',', ':'))
thumbprint = nopad_b64(hashlib.sha256(accountkey_json.encode('utf8')).digest())
return "{0}.{1}".format(token, thumbprint)
def _parse_account_key(self,key):
'''
Parses an RSA key file in PEM format and returns the modulus
and public exponent of the key
'''
openssl_keydump_cmd = [self._openssl_bin, "rsa", "-in", key, "-noout", "-text"]
_, out, _ = self.module.run_command(openssl_keydump_cmd,check_rc=True)
pub_hex, pub_exp = re.search(
r"modulus:\n\s+00:([a-f0-9\:\s]+?)\npublicExponent: ([0-9]+)",
out.decode('utf8'), re.MULTILINE|re.DOTALL).groups()
pub_exp = "{0:x}".format(int(pub_exp))
if len(pub_exp) % 2:
pub_exp = "0{0}".format(pub_exp)
return pub_hex, pub_exp
def send_signed_request(self, url, payload):
'''
Sends a JWS signed HTTP POST request to the ACME server and returns
the response as dictionary
https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-5.2
'''
protected = copy.deepcopy(self.jws_header)
protected["nonce"] = self.directory.get_nonce()
try:
payload64 = nopad_b64(self.module.jsonify(payload).encode('utf8'))
protected64 = nopad_b64(self.module.jsonify(protected).encode('utf8'))
except Exception as e:
self.module.fail_json(msg="Failed to encode payload / headers as JSON: {0}".format(e))
openssl_sign_cmd = [self._openssl_bin, "dgst", "-sha256", "-sign", self.key]
sign_payload = "{0}.{1}".format(protected64, payload64).encode('utf8')
_, out, _ = self.module.run_command(openssl_sign_cmd,data=sign_payload,check_rc=True, binary_data=True)
data = self.module.jsonify({
"header": self.jws_header,
"protected": protected64,
"payload": payload64,
"signature": nopad_b64(out),
})
resp, info = fetch_url(self.module, url, data=data, method='POST')
result = None
try:
content = resp.read()
if info['content-type'].startswith('application/json'):
result = self.module.from_json(content.decode('utf8'))
else:
result = content
except AttributeError:
result = None
except ValueError:
self.module.fail_json(msg="Failed to parse the ACME response: {0} {1}".format(url,content))
return result,info
def _new_reg(self,contact=[]):
'''
Registers a new ACME account. Returns True if the account was
created and False if it already existed (e.g. it was not newly
created)
https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-6.3
'''
if self.uri is not None:
return True
new_reg = {
'resource': 'new-reg',
'agreement': self.agreement,
'contact': contact
}
result, info = self.send_signed_request(self.directory['new-reg'], new_reg)
if 'location' in info:
self.uri = info['location']
if info['status'] in [200,201]:
# Account did not exist
self.changed = True
return True
elif info['status'] == 409:
# Account did exist
return False
else:
self.module.fail_json(msg="Error registering: {0} {1}".format(info['status'], result))
def init_account(self):
'''
Create or update an account on the ACME server. As the only way
(without knowing an account URI) to test if an account exists
is to try and create one with the provided account key, this
method will always result in an account being present (except
on error situations). If the account already exists, it will
update the contact information.
https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-6.3
'''
contact = []
if self.email:
contact.append('mailto:' + self.email)
# if this is not a new registration (e.g. existing account)
if not self._new_reg(contact):
# pre-existing account, get account data...
result, _ = self.send_signed_request(self.uri, {'resource':'reg'})
# XXX: letsencrypt/boulder#1435
if 'authorizations' in result:
self._authz_list_uri = result['authorizations']
if 'certificates' in result:
self._certs_list_uri = result['certificates']
# ...and check if update is necessary
do_update = False
if 'contact' in result:
if cmp(contact,result['contact']) != 0:
do_update = True
elif len(contact) > 0:
do_update = True
if do_update:
upd_reg = result
upd_reg['contact'] = contact
result, _ = self.send_signed_request(self.uri, upd_reg)
self.changed = True
def get_authorizations(self):
'''
Return a list of currently active authorizations
https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-6.4
'''
authz_list = {'authorizations': []}
if self._authz_list_uri is None:
# XXX: letsencrypt/boulder#1435
# Workaround, retrieve the known authorization urls
# from the data attribute
# It is also a way to limit the queried authorizations, which
# might become relevant at some point
if (self.data is not None) and ('authorizations' in self.data):
for auth in self.data['authorizations']:
authz_list['authorizations'].append(auth['uri'])
else:
return []
else:
# TODO: need to handle pagination
authz_list = simple_get(self.module, self._authz_list_uri)
authz = []
for auth_uri in authz_list['authorizations']:
auth = simple_get(self.module,auth_uri)
auth['uri'] = auth_uri
authz.append(auth)
return authz
class ACMEClient(object):
'''
ACME client class. Uses an ACME account object and a CSR to
start and validate ACME challenges and download the respective
certificates.
'''
def __init__(self,module):
self.module = module
self.challenge = module.params['challenge']
self.csr = os.path.expanduser(module.params['csr'])
self.dest = os.path.expanduser(module.params['dest'])
self.account = ACMEAccount(module)
self.directory = self.account.directory
self.authorizations = self.account.get_authorizations()
self.cert_days = -1
self.changed = self.account.changed
if not os.path.exists(self.csr):
module.fail_json(msg="CSR %s not found" % (self.csr))
self._openssl_bin = module.get_bin_path('openssl', True)
self.domains = self._get_csr_domains()
def _get_csr_domains(self):
'''
Parse the CSR and return the list of requested domains
'''
openssl_csr_cmd = [self._openssl_bin, "req", "-in", self.csr, "-noout", "-text"]
_, out, _ = self.module.run_command(openssl_csr_cmd,check_rc=True)
domains = set([])
common_name = re.search(r"Subject:.*? CN=([^\s,;/]+)", out.decode('utf8'))
if common_name is not None:
domains.add(common_name.group(1))
subject_alt_names = re.search(r"X509v3 Subject Alternative Name: \n +([^\n]+)\n", out.decode('utf8'), re.MULTILINE|re.DOTALL)
if subject_alt_names is not None:
for san in subject_alt_names.group(1).split(", "):
if san.startswith("DNS:"):
domains.add(san[4:])
return domains
def _get_domain_auth(self,domain):
'''
Get the status string of the first authorization for the given domain.
Return None if no active authorization for the given domain was found.
'''
if self.authorizations is None:
return None
for auth in self.authorizations:
if (auth['identifier']['type'] == 'dns') and (auth['identifier']['value'] == domain):
return auth
return None
def _add_or_update_auth(self,auth):
'''
Add or update the given authroization in the global authorizations list.
Return True if the auth was updated/added and False if no change was
necessary.
'''
for index,cur_auth in enumerate(self.authorizations):
if (cur_auth['uri'] == auth['uri']):
# does the auth parameter contain updated data?
if cmp(cur_auth,auth) != 0:
# yes, update our current authorization list
self.authorizations[index] = auth
return True
else:
return False
# this is a new authorization, add it to the list of current
# authorizations
self.authorizations.append(auth)
return True
def _new_authz(self,domain):
'''
Create a new authorization for the given domain.
Return the authorization object of the new authorization
https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-6.4
'''
if self.account.uri is None:
return
new_authz = {
"resource": "new-authz",
"identifier": {"type": "dns", "value": domain},
}
result, info = self.account.send_signed_request(self.directory['new-authz'], new_authz)
if info['status'] not in [200,201]:
self.module.fail_json(msg="Error requesting challenges: CODE: {0} RESULT: {1}".format(info['status'], result))
else:
result['uri'] = info['location']
return result
def _get_challenge_data(self,auth):
'''
Returns a dict with the data for all proposed (and supported) challenges
of the given authorization.
'''
data = {}
# no need to choose a specific challenge here as this module
# is not responsible for fulfilling the challenges. Calculate
# and return the required information for each challenge.
for challenge in auth['challenges']:
type = challenge['type']
token = re.sub(r"[^A-Za-z0-9_\-]", "_", challenge['token'])
keyauthorization = self.account.get_keyauthorization(token)
# NOTE: tls-sni-01 is not supported by choice
# too complex to be usefull and tls-sni-02 is an alternative
# as soon as it is implemented server side
if type == 'http-01':
# https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-7.2
resource = '.well-known/acme-challenge/' + token
value = keyauthorization
elif type == 'tls-sni-02':
# https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-7.3
token_digest = hashlib.sha256(token.encode('utf8')).hexdigest()
ka_digest = hashlib.sha256(keyauthorization.encode('utf8')).hexdigest()
len_token_digest = len(token_digest)
len_ka_digest = len(ka_digest)
resource = 'subjectAlternativeNames'
value = [
"{0}.{1}.token.acme.invalid".format(token_digest[:len_token_digest/2],token_digest[len_token_digest/2:]),
"{0}.{1}.ka.acme.invalid".format(ka_digest[:len_ka_digest/2],ka_digest[len_ka_digest/2:]),
]
elif type == 'dns-01':
# https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-7.4
resource = '_acme-challenge'
value = nopad_b64(hashlib.sha256(keyauthorization).digest()).encode('utf8')
else:
continue
data[type] = { 'resource': resource, 'resource_value': value }
return data
def _validate_challenges(self,auth):
'''
Validate the authorization provided in the auth dict. Returns True
when the validation was successfull and False when it was not.
'''
for challenge in auth['challenges']:
if self.challenge != challenge['type']:
continue
uri = challenge['uri']
token = re.sub(r"[^A-Za-z0-9_\-]", "_", challenge['token'])
keyauthorization = self.account.get_keyauthorization(token)
challenge_response = {
"resource": "challenge",
"keyAuthorization": keyauthorization,
}
result, info = self.account.send_signed_request(uri, challenge_response)
if info['status'] != 200:
self.module.fail_json(msg="Error validating challenge: CODE: {0} RESULT: {1}".format(info['status'], result))
status = ''
while status not in ['valid','invalid','revoked']:
result = simple_get(self.module,auth['uri'])
result['uri'] = auth['uri']
if self._add_or_update_auth(result):
self.changed = True
# draft-ietf-acme-acme-02
# "status (required, string): ...
# If this field is missing, then the default value is "pending"."
if 'status' not in result:
status = 'pending'
else:
status = result['status']
time.sleep(2)
if status == 'invalid':
error_details = ''
# multiple challenges could have failed at this point, gather error
# details for all of them before failing
for challenge in result['challenges']:
if challenge['status'] == 'invalid':
error_details += ' CHALLENGE: {0}'.format(challenge['type'])
if 'error' in challenge:
error_details += ' DETAILS: {0};'.format(challenge['error']['detail'])
else:
error_details += ';'
self.module.fail_json(msg="Authorization for {0} returned invalid: {1}".format(result['identifier']['value'],error_details))
return status == 'valid'
def _new_cert(self):
'''
Create a new certificate based on the csr.
Return the certificate object as dict
https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-6.5
'''
openssl_csr_cmd = [self._openssl_bin, "req", "-in", self.csr, "-outform", "DER"]
_, out, _ = self.module.run_command(openssl_csr_cmd,check_rc=True)
new_cert = {
"resource": "new-cert",
"csr": nopad_b64(out),
}
result, info = self.account.send_signed_request(self.directory['new-cert'], new_cert)
if info['status'] not in [200,201]:
self.module.fail_json(msg="Error new cert: CODE: {0} RESULT: {1}".format(info['status'], result))
else:
return {'cert': result, 'uri': info['location']}
def _der_to_pem(self,der_cert):
'''
Convert the DER format certificate in der_cert to a PEM format
certificate and return it.
'''
return """-----BEGIN CERTIFICATE-----\n{0}\n-----END CERTIFICATE-----\n""".format(
"\n".join(textwrap.wrap(base64.b64encode(der_cert).decode('utf8'), 64)))
def do_challenges(self):
'''
Create new authorizations for all domains of the CSR and return
the challenge details for the choosen challenge type.
'''
data = {}
for domain in self.domains:
auth = self._get_domain_auth(domain)
if auth is None:
new_auth = self._new_authz(domain)
self._add_or_update_auth(new_auth)
data[domain] = self._get_challenge_data(new_auth)
self.changed = True
elif (auth['status'] == 'pending') or ('status' not in auth):
# draft-ietf-acme-acme-02
# "status (required, string): ...
# If this field is missing, then the default value is "pending"."
self._validate_challenges(auth)
# _validate_challenges updates the global authrozation dict,
# so get the current version of the authorization we are working
# on to retrieve the challenge data
data[domain] = self._get_challenge_data(self._get_domain_auth(domain))
return data
def get_certificate(self):
'''
Request a new certificate and write it to the destination file.
Only do this if a destination file was provided and if all authorizations
for the domains of the csr are valid. No Return value.
'''
if self.dest is None:
return
for domain in self.domains:
auth = self._get_domain_auth(domain)
if auth is None or ('status' not in auth) or (auth['status'] != 'valid'):
return
cert = self._new_cert()
if cert['cert'] is not None:
pem_cert = self._der_to_pem(cert['cert'])
if write_file(self.module,self.dest,pem_cert):
self.cert_days = get_cert_days(self.module,self.dest)
self.changed = True
def main():
module = AnsibleModule(
argument_spec = dict(
account_key = dict(required=True, type='str'),
account_email = dict(required=False, default=None, type='str'),
acme_directory = dict(required=False, default='https://acme-staging.api.letsencrypt.org/directory', type='str'),
agreement = dict(required=False, default='https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf', type='str'),
challenge = dict(required=False, default='http-01', choices=['http-01', 'dns-01', 'tls-sni-02'], type='str'),
csr = dict(required=True, aliases=['src'], type='str'),
data = dict(required=False, no_log=True, default=None, type='dict'),
dest = dict(required=True, aliases=['cert'], type='str'),
remaining_days = dict(required=False, default=10, type='int'),
),
supports_check_mode = True,
)
cert_days = get_cert_days(module,module.params['dest'])
if cert_days < module.params['remaining_days']:
# If checkmode is active, base the changed state solely on the status
# of the certificate file as all other actions (accessing an account, checking
# the authorization status...) would lead to potential changes of the current
# state
if module.check_mode:
module.exit_json(changed=True,authorizations={},
challenge_data={},cert_days=cert_days)
else:
client = ACMEClient(module)
client.cert_days = cert_days
data = client.do_challenges()
client.get_certificate()
module.exit_json(changed=client.changed,authorizations=client.authorizations,
challenge_data=data,cert_days=client.cert_days)
else:
module.exit_json(changed=False,cert_days=cert_days)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.urls 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,
7800,
16922,
598,
6558,
727,
665,
22333,
14,
2587,
85,
727,
32,
9518,
736,
573,
265,
14,
846,
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,
646,
14755,
199,
646,
1331,
199,
646,
13390,
199,
504,
2197,
492,
2197,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
4691,
31561,
199,
2502,
26,
298,
45,
11781,
598,
6558,
727,
8593,
7755,
85,
727,
2924,
199,
1023,
63,
3270,
26,
298,
18,
14,
18,
2,
199,
3612,
63,
1802,
26,
2790,
7799,
14512,
543,
12230,
1159,
3447,
4997,
199,
1802,
26,
2043,
446,
298,
2499,
436,
295,
1222,
7799,
14512,
543,
12230,
1159,
3447,
4997,
14,
12230,
21045,
83,
3447,
4997,
365,
282,
489,
2867,
12,
6384,
23513,
12,
436,
1551,
5897,
18330,
334,
3263,
395,
1255,
367,
314,
489,
4575,
21045,
83,
22477,
3269,
14,
2104,
2436,
1937,
738,
8,
2859,
921,
2723,
31561,
14,
1308,
680,
710,
1453,
489,
4514,
5171,
314,
1455,
13,
614,
12,
15142,
13,
5167,
73,
13,
996,
436,
6715,
13,
614,
682,
30599,
2122,
2043,
446,
298,
1378,
675,
642,
859,
12,
652,
965,
370,
506,
7934,
737,
5210,
13373,
14,
13083,
465,
2877,
489,
3365,
6527,
315,
314,
2011,
1255,
503,
5309,
3663,
7858,
2122,
2043,
446,
298,
24472,
3109,
3520,
2877,
6527,
1265,
1172,
370,
15632,
22503,
314,
1415,
7124,
367,
314,
489,
2468,
79,
2464,
14929,
701,
15685,
4910,
5784,
14,
2104,
1455,
13,
614,
626,
4910,
489,
6425,
314,
5784,
14929,
570,
641,
314,
5724,
3330,
1000,
14,
2104,
489,
6715,
13,
614,
314,
5784,
6715,
2777,
965,
370,
506,
2737,
14,
15142,
13,
5167,
73,
13,
996,
5074,
489,
1265,
370,
1218,
282,
7799,
5897,
543,
314,
5827,
5420,
19978,
1905,
5866,
14,
489,
2779,
365,
473,
8,
1397,
9,
314,
9163,
4783,
402,
642,
859,
370,
5147,
3520,
7124,
2122,
2043,
446,
298,
1858,
2436,
641,
4212,
370,
15632,
22503,
3520,
682,
30599,
12,
1265,
5594,
1172,
370,
1586,
4012,
489,
738,
8,
2859,
921,
2537,
14,
15799,
14,
1308,
15,
1360,
15,
7185,
13,
15799,
13,
18107,
13,
18107,
13,
996,
3,
2792,
13,
23,
2924,
2043,
446,
298,
2439,
15401,
314,
4243,
787,
2468,
79,
2464,
880,
626,
314,
859,
883,
506,
1202,
543,
489,
314,
12230,
1159,
3447,
4997,
7240,
12,
314,
859,
883,
506,
1202,
543,
1263,
2435,
1808,
314,
6570,
3635,
489,
4113,
2122,
199,
7538,
26,
523,
446,
298,
1548,
2356,
499,
14,
22,
2,
199,
1419,
26,
523,
2933,
63,
498,
26,
272,
1369,
26,
489,
446,
298,
1173,
3035,
314,
314,
12230,
1159,
3447,
4997,
2933,
18471,
790,
2122,
489,
446,
298,
6049,
506,
2737,
543,
445,
8,
14837,
23609,
2263,
17617,
272,
1415,
26,
2549,
523,
2933,
63,
2123,
26,
272,
1369,
26,
489,
446,
298,
1918,
3031,
2287,
4568,
543,
642,
2933,
2122,
489,
446,
298,
7940,
911,
506,
1202,
367,
5897,
15399,
3598,
2122,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
32433,
63,
3619,
26,
272,
1369,
26,
489,
446,
298,
1918,
6570,
3635,
2082,
370,
675,
14,
961,
365,
314,
2397,
2376,
2851,
370,
2879,
268,
7240,
1654,
3261,
2122,
489,
446,
298,
1858,
30261,
14872,
314,
849,
365,
663,
370,
314,
12230,
1159,
3447,
4997,
28512,
1654,
14,
268,
961,
911,
1218,
18077,
7288,
3211,
12,
1325,
625,
17549,
3361,
1428,
645,
744,
2122,
272,
1415,
26,
3055,
272,
849,
26,
4178,
921,
18107,
13,
26840,
14,
1246,
14,
2723,
31561,
14,
1308,
15,
3619,
523,
25025,
26,
272,
1369,
26,
489,
446,
298,
7639,
370,
282,
2895,
402,
2435,
2213,
1265,
10601,
370,
1380,
1808,
314,
268,
6570,
3635,
2435,
737,
445,
8,
18107,
63,
3619,
17617,
272,
1415,
26,
3055,
272,
849,
26,
283,
2859,
921,
2723,
31561,
14,
1308,
15,
12233,
15,
906,
13,
4251,
13,
86,
17,
14,
16,
14,
17,
13,
42,
21797,
13,
1465,
13,
7806,
14,
5607,
7,
523,
14929,
26,
272,
1369,
26,
710,
14929,
370,
506,
10585,
14,
272,
1415,
26,
3055,
272,
3415,
26,
359,
283,
1014,
13,
614,
297,
283,
5797,
13,
614,
297,
283,
9945,
13,
5167,
73,
13,
996,
418,
272,
849,
26,
283,
1014,
13,
614,
7,
523,
22258,
26,
272,
1369,
26,
489,
446,
298,
1173,
3035,
314,
16449,
367,
314,
892,
5897,
2122,
489,
446,
298,
6049,
506,
2737,
543,
445,
8,
14837,
22258,
2263,
17617,
489,
446,
298,
1918,
16449,
1443,
1395,
3663,
26793,
17669,
323,
23923,
12,
1325,
1924,
1373,
268,
911,
12690,
370,
376,
8212,
14929,
626,
1471,
506,
15632,
276,
14535,
367,
314,
268,
16449,
370,
506,
10514,
2122,
272,
1415,
26,
2549,
272,
5162,
26,
788,
2164,
418,
523,
666,
26,
272,
1369,
26,
489,
446,
298,
1918,
666,
370,
4107,
641,
10947,
682,
30599,
2122,
489,
446,
298,
1918,
574,
626,
1471,
506,
1202,
2348,
911,
506,
2741,
701,
282,
4136,
675,
268,
402,
642,
859,
2122,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
2053,
26,
272,
1369,
26,
710,
5724,
570,
367,
314,
5897,
14,
272,
1415,
26,
2549,
272,
5162,
26,
788,
4736,
418,
523,
7971,
63,
4899,
26,
272,
1369,
26,
489,
446,
298,
1918
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
7800,
16922,
598,
6558,
727,
665,
22333,
14,
2587,
85,
727,
32,
9518,
736,
573,
265,
14,
846,
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,
646,
14755,
199,
646,
1331,
199,
646,
13390,
199,
504,
2197,
492,
2197,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
4691,
31561,
199,
2502,
26,
298,
45,
11781,
598,
6558,
727,
8593,
7755,
85,
727,
2924,
199,
1023,
63,
3270,
26,
298,
18,
14,
18,
2,
199,
3612,
63,
1802,
26,
2790,
7799,
14512,
543,
12230,
1159,
3447,
4997,
199,
1802,
26,
2043,
446,
298,
2499,
436,
295,
1222,
7799,
14512,
543,
12230,
1159,
3447,
4997,
14,
12230,
21045,
83,
3447,
4997,
365,
282,
489,
2867,
12,
6384,
23513,
12,
436,
1551,
5897,
18330,
334,
3263,
395,
1255,
367,
314,
489,
4575,
21045,
83,
22477,
3269,
14,
2104,
2436,
1937,
738,
8,
2859,
921,
2723,
31561,
14,
1308,
680,
710,
1453,
489,
4514,
5171,
314,
1455,
13,
614,
12,
15142,
13,
5167,
73,
13,
996,
436,
6715,
13,
614,
682,
30599,
2122,
2043,
446,
298,
1378,
675,
642,
859,
12,
652,
965,
370,
506,
7934,
737,
5210,
13373,
14,
13083,
465,
2877,
489,
3365,
6527,
315,
314,
2011,
1255,
503,
5309,
3663,
7858,
2122,
2043,
446,
298,
24472,
3109,
3520,
2877,
6527,
1265,
1172,
370,
15632,
22503,
314,
1415,
7124,
367,
314,
489,
2468,
79,
2464,
14929,
701,
15685,
4910,
5784,
14,
2104,
1455,
13,
614,
626,
4910,
489,
6425,
314,
5784,
14929,
570,
641,
314,
5724,
3330,
1000,
14,
2104,
489,
6715,
13,
614,
314,
5784,
6715,
2777,
965,
370,
506,
2737,
14,
15142,
13,
5167,
73,
13,
996,
5074,
489,
1265,
370,
1218,
282,
7799,
5897,
543,
314,
5827,
5420,
19978,
1905,
5866,
14,
489,
2779,
365,
473,
8,
1397,
9,
314,
9163,
4783,
402,
642,
859,
370,
5147,
3520,
7124,
2122,
2043,
446,
298,
1858,
2436,
641,
4212,
370,
15632,
22503,
3520,
682,
30599,
12,
1265,
5594,
1172,
370,
1586,
4012,
489,
738,
8,
2859,
921,
2537,
14,
15799,
14,
1308,
15,
1360,
15,
7185,
13,
15799,
13,
18107,
13,
18107,
13,
996,
3,
2792,
13,
23,
2924,
2043,
446,
298,
2439,
15401,
314,
4243,
787,
2468,
79,
2464,
880,
626,
314,
859,
883,
506,
1202,
543,
489,
314,
12230,
1159,
3447,
4997,
7240,
12,
314,
859,
883,
506,
1202,
543,
1263,
2435,
1808,
314,
6570,
3635,
489,
4113,
2122,
199,
7538,
26,
523,
446,
298,
1548,
2356,
499,
14,
22,
2,
199,
1419,
26,
523,
2933,
63,
498,
26,
272,
1369,
26,
489,
446,
298,
1173,
3035,
314,
314,
12230,
1159,
3447,
4997,
2933,
18471,
790,
2122,
489,
446,
298,
6049,
506,
2737,
543,
445,
8,
14837,
23609,
2263,
17617,
272,
1415,
26,
2549,
523,
2933,
63,
2123,
26,
272,
1369,
26,
489,
446,
298,
1918,
3031,
2287,
4568,
543,
642,
2933,
2122,
489,
446,
298,
7940,
911,
506,
1202,
367,
5897,
15399,
3598,
2122,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
32433,
63,
3619,
26,
272,
1369,
26,
489,
446,
298,
1918,
6570,
3635,
2082,
370,
675,
14,
961,
365,
314,
2397,
2376,
2851,
370,
2879,
268,
7240,
1654,
3261,
2122,
489,
446,
298,
1858,
30261,
14872,
314,
849,
365,
663,
370,
314,
12230,
1159,
3447,
4997,
28512,
1654,
14,
268,
961,
911,
1218,
18077,
7288,
3211,
12,
1325,
625,
17549,
3361,
1428,
645,
744,
2122,
272,
1415,
26,
3055,
272,
849,
26,
4178,
921,
18107,
13,
26840,
14,
1246,
14,
2723,
31561,
14,
1308,
15,
3619,
523,
25025,
26,
272,
1369,
26,
489,
446,
298,
7639,
370,
282,
2895,
402,
2435,
2213,
1265,
10601,
370,
1380,
1808,
314,
268,
6570,
3635,
2435,
737,
445,
8,
18107,
63,
3619,
17617,
272,
1415,
26,
3055,
272,
849,
26,
283,
2859,
921,
2723,
31561,
14,
1308,
15,
12233,
15,
906,
13,
4251,
13,
86,
17,
14,
16,
14,
17,
13,
42,
21797,
13,
1465,
13,
7806,
14,
5607,
7,
523,
14929,
26,
272,
1369,
26,
710,
14929,
370,
506,
10585,
14,
272,
1415,
26,
3055,
272,
3415,
26,
359,
283,
1014,
13,
614,
297,
283,
5797,
13,
614,
297,
283,
9945,
13,
5167,
73,
13,
996,
418,
272,
849,
26,
283,
1014,
13,
614,
7,
523,
22258,
26,
272,
1369,
26,
489,
446,
298,
1173,
3035,
314,
16449,
367,
314,
892,
5897,
2122,
489,
446,
298,
6049,
506,
2737,
543,
445,
8,
14837,
22258,
2263,
17617,
489,
446,
298,
1918,
16449,
1443,
1395,
3663,
26793,
17669,
323,
23923,
12,
1325,
1924,
1373,
268,
911,
12690,
370,
376,
8212,
14929,
626,
1471,
506,
15632,
276,
14535,
367,
314,
268,
16449,
370,
506,
10514,
2122,
272,
1415,
26,
2549,
272,
5162,
26,
788,
2164,
418,
523,
666,
26,
272,
1369,
26,
489,
446,
298,
1918,
666,
370,
4107,
641,
10947,
682,
30599,
2122,
489,
446,
298,
1918,
574,
626,
1471,
506,
1202,
2348,
911,
506,
2741,
701,
282,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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
] |
sriramsitharaman/sp17-i524
|
project/S17-IR-P013/code/weather_data_analysis/src/iu/i524/S17IRP013/util/app_util.py
|
20
|
1804
|
import datetime as datetime
##########################################################################
def enum(**enums):
return type('Enum', (), enums)
##########################################################################
def get_year_list(start_date, end_date):
'Get list of date range with each range of one year. Date format is `yyyy-mm-dd`. Result will be a list of dictionary having \
key as `max_date` and `min_date` '
start_date_obj = datetime.datetime.strptime(start_date, '%Y-%m-%d')
end_date_obj = datetime.datetime.strptime(end_date, '%Y-%m-%d')
curr_date_obj = start_date_obj
year_list = list()
while(int(curr_date_obj.year) < int(end_date_obj.year)):
date_range = dict()
if(len(year_list) > 0):
curr_date_obj = curr_date_obj + datetime.timedelta(days=1)
date_range['min_date'] = curr_date_obj.strftime('%Y-%m-%d')
curr_date_obj = curr_date_obj + datetime.timedelta(days=365)
if(int(curr_date_obj.year) < int(end_date_obj.year)):
date_range['max_date'] = curr_date_obj.strftime('%Y-%m-%d')
year_list.append(date_range)
else:
date_range['max_date'] = end_date_obj.strftime('%Y-%m-%d')
year_list.append(date_range)
break;
if(len(year_list) == 0):
date_range = dict()
date_range['min_date'] = start_date_obj.strftime('%Y-%m-%d')
date_range['max_date'] = end_date_obj.strftime('%Y-%m-%d')
return year_list
##########################################################################
def format_date(dateTime,target_format,src_format='%Y-%m-%dT%H:%M:%S'):
dateTime_obj = datetime.datetime.strptime(dateTime, src_format)
return dateTime_obj.strftime('%Y-%m')
|
apache-2.0
|
[
646,
2197,
465,
2197,
199,
199,
26863,
199,
318,
4952,
3682,
19921,
304,
272,
372,
730,
360,
5081,
297,
11969,
28441,
9,
199,
199,
26863,
199,
318,
664,
63,
3403,
63,
513,
8,
928,
63,
602,
12,
1284,
63,
602,
304,
272,
283,
1002,
769,
402,
1434,
1425,
543,
1924,
1425,
402,
1373,
5361,
14,
6148,
1475,
365,
658,
18322,
13,
596,
13,
617,
2313,
10695,
911,
506,
282,
769,
402,
2600,
9445,
971,
272,
790,
465,
658,
988,
63,
602,
64,
436,
658,
827,
63,
602,
64,
283,
259,
272,
1343,
63,
602,
63,
1113,
275,
2197,
14,
2083,
14,
9866,
8,
928,
63,
602,
12,
1543,
57,
3295,
77,
3295,
68,
358,
272,
1284,
63,
602,
63,
1113,
275,
2197,
14,
2083,
14,
9866,
8,
500,
63,
602,
12,
1543,
57,
3295,
77,
3295,
68,
358,
272,
8230,
63,
602,
63,
1113,
275,
1343,
63,
602,
63,
1113,
5591,
5361,
63,
513,
275,
769,
342,
23855,
1830,
8,
442,
8,
9808,
63,
602,
63,
1113,
14,
3403,
9,
665,
1109,
8,
500,
63,
602,
63,
1113,
14,
3403,
2298,
18418,
1434,
63,
1842,
275,
1211,
342,
267,
340,
8,
552,
8,
3403,
63,
513,
9,
690,
378,
304,
288,
8230,
63,
602,
63,
1113,
275,
8230,
63,
602,
63,
1113,
435,
2197,
14,
7473,
8,
4899,
29,
17,
9,
263,
267,
1434,
63,
1842,
459,
827,
63,
602,
418,
275,
8230,
63,
602,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
267,
8230,
63,
602,
63,
1113,
275,
8230,
63,
602,
63,
1113,
435,
2197,
14,
7473,
8,
4899,
29,
12664,
9,
267,
340,
8,
442,
8,
9808,
63,
602,
63,
1113,
14,
3403,
9,
665,
1109,
8,
500,
63,
602,
63,
1113,
14,
3403,
2298,
288,
1434,
63,
1842,
459,
988,
63,
602,
418,
275,
8230,
63,
602,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
288,
5361,
63,
513,
14,
740,
8,
602,
63,
1842,
9,
267,
587,
26,
288,
1434,
63,
1842,
459,
988,
63,
602,
418,
275,
1284,
63,
602,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
258,
288,
5361,
63,
513,
14,
740,
8,
602,
63,
1842,
9,
288,
2059,
27,
272,
340,
8,
552,
8,
3403,
63,
513,
9,
508,
378,
304,
288,
1434,
63,
1842,
275,
1211,
342,
288,
1434,
63,
1842,
459,
827,
63,
602,
418,
275,
1343,
63,
602,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
288,
1434,
63,
1842,
459,
988,
63,
602,
418,
275,
1284,
63,
602,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
14821,
372,
221,
5361,
63,
513,
199,
26863,
199,
318,
1475,
63,
602,
8,
602,
1366,
12,
1375,
63,
908,
12,
2164,
63,
908,
9569,
57,
3295,
77,
3295,
19772,
5,
40,
2689,
45,
2689,
51,
735,
272,
1434,
1366,
63,
1113,
275,
2197,
14,
2083,
14,
9866,
8,
602,
1366,
12,
2928,
63,
908,
9,
272,
372,
1434,
1366,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
358,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
465,
2197,
199,
199,
26863,
199,
318,
4952,
3682,
19921,
304,
272,
372,
730,
360,
5081,
297,
11969,
28441,
9,
199,
199,
26863,
199,
318,
664,
63,
3403,
63,
513,
8,
928,
63,
602,
12,
1284,
63,
602,
304,
272,
283,
1002,
769,
402,
1434,
1425,
543,
1924,
1425,
402,
1373,
5361,
14,
6148,
1475,
365,
658,
18322,
13,
596,
13,
617,
2313,
10695,
911,
506,
282,
769,
402,
2600,
9445,
971,
272,
790,
465,
658,
988,
63,
602,
64,
436,
658,
827,
63,
602,
64,
283,
259,
272,
1343,
63,
602,
63,
1113,
275,
2197,
14,
2083,
14,
9866,
8,
928,
63,
602,
12,
1543,
57,
3295,
77,
3295,
68,
358,
272,
1284,
63,
602,
63,
1113,
275,
2197,
14,
2083,
14,
9866,
8,
500,
63,
602,
12,
1543,
57,
3295,
77,
3295,
68,
358,
272,
8230,
63,
602,
63,
1113,
275,
1343,
63,
602,
63,
1113,
5591,
5361,
63,
513,
275,
769,
342,
23855,
1830,
8,
442,
8,
9808,
63,
602,
63,
1113,
14,
3403,
9,
665,
1109,
8,
500,
63,
602,
63,
1113,
14,
3403,
2298,
18418,
1434,
63,
1842,
275,
1211,
342,
267,
340,
8,
552,
8,
3403,
63,
513,
9,
690,
378,
304,
288,
8230,
63,
602,
63,
1113,
275,
8230,
63,
602,
63,
1113,
435,
2197,
14,
7473,
8,
4899,
29,
17,
9,
263,
267,
1434,
63,
1842,
459,
827,
63,
602,
418,
275,
8230,
63,
602,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
267,
8230,
63,
602,
63,
1113,
275,
8230,
63,
602,
63,
1113,
435,
2197,
14,
7473,
8,
4899,
29,
12664,
9,
267,
340,
8,
442,
8,
9808,
63,
602,
63,
1113,
14,
3403,
9,
665,
1109,
8,
500,
63,
602,
63,
1113,
14,
3403,
2298,
288,
1434,
63,
1842,
459,
988,
63,
602,
418,
275,
8230,
63,
602,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
288,
5361,
63,
513,
14,
740,
8,
602,
63,
1842,
9,
267,
587,
26,
288,
1434,
63,
1842,
459,
988,
63,
602,
418,
275,
1284,
63,
602,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
258,
288,
5361,
63,
513,
14,
740,
8,
602,
63,
1842,
9,
288,
2059,
27,
272,
340,
8,
552,
8,
3403,
63,
513,
9,
508,
378,
304,
288,
1434,
63,
1842,
275,
1211,
342,
288,
1434,
63,
1842,
459,
827,
63,
602,
418,
275,
1343,
63,
602,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
288,
1434,
63,
1842,
459,
988,
63,
602,
418,
275,
1284,
63,
602,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
14821,
372,
221,
5361,
63,
513,
199,
26863,
199,
318,
1475,
63,
602,
8,
602,
1366,
12,
1375,
63,
908,
12,
2164,
63,
908,
9569,
57,
3295,
77,
3295,
19772,
5,
40,
2689,
45,
2689,
51,
735,
272,
1434,
1366,
63,
1113,
275,
2197,
14,
2083,
14,
9866,
8,
602,
1366,
12,
2928,
63,
908,
9,
272,
372,
1434,
1366,
63,
1113,
14,
6205,
3508,
57,
3295,
77,
358,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
googleapis/python-api-common-protos
|
google/logging/type/http_request_pb2.py
|
1
|
13178
|
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: google/logging/type/http_request.proto
"""Generated protocol buffer code."""
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
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2
DESCRIPTOR = _descriptor.FileDescriptor(
name="google/logging/type/http_request.proto",
package="google.logging.type",
syntax="proto3",
serialized_options=b"\n\027com.google.logging.typeB\020HttpRequestProtoP\001Z8google.golang.org/genproto/googleapis/logging/type;ltype\252\002\031Google.Cloud.Logging.Type\312\002\031Google\\Cloud\\Logging\\Type",
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n&google/logging/type/http_request.proto\x12\x13google.logging.type\x1a\x1cgoogle/api/annotations.proto\x1a\x1egoogle/protobuf/duration.proto"\xef\x02\n\x0bHttpRequest\x12\x16\n\x0erequest_method\x18\x01 \x01(\t\x12\x13\n\x0brequest_url\x18\x02 \x01(\t\x12\x14\n\x0crequest_size\x18\x03 \x01(\x03\x12\x0e\n\x06status\x18\x04 \x01(\x05\x12\x15\n\rresponse_size\x18\x05 \x01(\x03\x12\x12\n\nuser_agent\x18\x06 \x01(\t\x12\x11\n\tremote_ip\x18\x07 \x01(\t\x12\x11\n\tserver_ip\x18\r \x01(\t\x12\x0f\n\x07referer\x18\x08 \x01(\t\x12*\n\x07latency\x18\x0e \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x14\n\x0c\x63\x61\x63he_lookup\x18\x0b \x01(\x08\x12\x11\n\tcache_hit\x18\t \x01(\x08\x12*\n"cache_validated_with_origin_server\x18\n \x01(\x08\x12\x18\n\x10\x63\x61\x63he_fill_bytes\x18\x0c \x01(\x03\x12\x10\n\x08protocol\x18\x0f \x01(\tB\x9f\x01\n\x17\x63om.google.logging.typeB\x10HttpRequestProtoP\x01Z8google.golang.org/genproto/googleapis/logging/type;ltype\xaa\x02\x19Google.Cloud.Logging.Type\xca\x02\x19Google\\Cloud\\Logging\\Typeb\x06proto3',
dependencies=[
google_dot_api_dot_annotations__pb2.DESCRIPTOR,
google_dot_protobuf_dot_duration__pb2.DESCRIPTOR,
],
)
_HTTPREQUEST = _descriptor.Descriptor(
name="HttpRequest",
full_name="google.logging.type.HttpRequest",
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name="request_method",
full_name="google.logging.type.HttpRequest.request_method",
index=0,
number=1,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=b"".decode("utf-8"),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="request_url",
full_name="google.logging.type.HttpRequest.request_url",
index=1,
number=2,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=b"".decode("utf-8"),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="request_size",
full_name="google.logging.type.HttpRequest.request_size",
index=2,
number=3,
type=3,
cpp_type=2,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="status",
full_name="google.logging.type.HttpRequest.status",
index=3,
number=4,
type=5,
cpp_type=1,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="response_size",
full_name="google.logging.type.HttpRequest.response_size",
index=4,
number=5,
type=3,
cpp_type=2,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="user_agent",
full_name="google.logging.type.HttpRequest.user_agent",
index=5,
number=6,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=b"".decode("utf-8"),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="remote_ip",
full_name="google.logging.type.HttpRequest.remote_ip",
index=6,
number=7,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=b"".decode("utf-8"),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="server_ip",
full_name="google.logging.type.HttpRequest.server_ip",
index=7,
number=13,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=b"".decode("utf-8"),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="referer",
full_name="google.logging.type.HttpRequest.referer",
index=8,
number=8,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=b"".decode("utf-8"),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="latency",
full_name="google.logging.type.HttpRequest.latency",
index=9,
number=14,
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,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="cache_lookup",
full_name="google.logging.type.HttpRequest.cache_lookup",
index=10,
number=11,
type=8,
cpp_type=7,
label=1,
has_default_value=False,
default_value=False,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="cache_hit",
full_name="google.logging.type.HttpRequest.cache_hit",
index=11,
number=9,
type=8,
cpp_type=7,
label=1,
has_default_value=False,
default_value=False,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="cache_validated_with_origin_server",
full_name="google.logging.type.HttpRequest.cache_validated_with_origin_server",
index=12,
number=10,
type=8,
cpp_type=7,
label=1,
has_default_value=False,
default_value=False,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="cache_fill_bytes",
full_name="google.logging.type.HttpRequest.cache_fill_bytes",
index=13,
number=12,
type=3,
cpp_type=2,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="protocol",
full_name="google.logging.type.HttpRequest.protocol",
index=14,
number=15,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=b"".decode("utf-8"),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
],
extensions=[],
nested_types=[],
enum_types=[],
serialized_options=None,
is_extendable=False,
syntax="proto3",
extension_ranges=[],
oneofs=[],
serialized_start=126,
serialized_end=493,
)
_HTTPREQUEST.fields_by_name[
"latency"
].message_type = google_dot_protobuf_dot_duration__pb2._DURATION
DESCRIPTOR.message_types_by_name["HttpRequest"] = _HTTPREQUEST
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
HttpRequest = _reflection.GeneratedProtocolMessageType(
"HttpRequest",
(_message.Message,),
{
"DESCRIPTOR": _HTTPREQUEST,
"__module__": "google.logging.type.http_request_pb2"
# @@protoc_insertion_point(class_scope:google.logging.type.HttpRequest)
},
)
_sym_db.RegisterMessage(HttpRequest)
DESCRIPTOR._options = None
# @@protoc_insertion_point(module_scope)
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
25455,
4475,
20376,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
3,
17065,
701,
314,
4113,
3335,
6365,
14,
221,
3506,
2845,
24981,
1,
199,
3,
1350,
26,
6233,
15,
4806,
15,
466,
15,
1014,
63,
1069,
14,
2625,
199,
624,
12706,
4113,
3335,
1233,
1041,
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,
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,
6233,
14,
1246,
492,
15538,
63,
3317,
18,
465,
6233,
63,
3287,
63,
1246,
63,
3287,
63,
11270,
363,
3317,
18,
199,
504,
6233,
14,
7204,
492,
7373,
63,
3317,
18,
465,
6233,
63,
3287,
63,
7204,
63,
3287,
63,
5553,
363,
3317,
18,
421,
199,
7580,
275,
485,
4120,
14,
23859,
8,
272,
536,
628,
3098,
15,
4806,
15,
466,
15,
1014,
63,
1069,
14,
2625,
401,
272,
2559,
628,
3098,
14,
4806,
14,
466,
401,
272,
6302,
628,
2625,
19,
401,
272,
6380,
63,
1419,
29,
66,
3212,
78,
60,
14218,
957,
14,
3098,
14,
4806,
14,
466,
34,
60,
10173,
10441,
8548,
48,
60,
4587,
58,
24,
3098,
14,
71,
393,
621,
14,
1308,
15,
2268,
2625,
15,
17533,
15,
4806,
15,
466,
27,
76,
466,
60,
6390,
60,
7432,
60,
19225,
13266,
14,
9089,
14,
14054,
14,
804,
60,
16683,
60,
7432,
60,
19225,
13266,
1103,
9089,
1103,
14054,
1103,
804,
401,
272,
1218,
63,
498,
3699,
4120,
423,
4672,
63,
981,
63,
498,
12,
272,
6380,
63,
3317,
29,
66,
1154,
78,
6,
3098,
15,
4806,
15,
466,
15,
1014,
63,
1069,
14,
2625,
60,
88,
713,
60,
88,
969,
3098,
14,
4806,
14,
466,
60,
88,
17,
65,
60,
88,
17,
67,
3098,
15,
1246,
15,
11270,
14,
2625,
60,
88,
17,
65,
60,
88,
17,
69,
3098,
15,
7204,
15,
5553,
14,
2625,
3212,
9532,
60,
88,
996,
60,
78,
60,
88,
16,
66,
10441,
60,
88,
713,
60,
88,
975,
60,
78,
60,
88,
16,
69,
1069,
63,
765,
60,
88,
1085,
60,
88,
614,
971,
88,
614,
2961,
84,
60,
88,
713,
60,
88,
969,
60,
78,
60,
88,
16,
66,
1069,
63,
633,
60,
88,
1085,
60,
88,
996,
971,
88,
614,
2961,
84,
60,
88,
713,
60,
88,
1079,
60,
78,
60,
88,
16,
67,
1069,
63,
890,
60,
88,
1085,
60,
88,
1644,
971,
88,
614,
2961,
88,
1644,
60,
88,
713,
60,
88,
16,
69,
60,
78,
60,
88,
1690,
1205,
60,
88,
1085,
60,
88,
966,
971,
88,
614,
2961,
88,
1717,
60,
88,
713,
60,
88,
1046,
60,
78,
60,
82,
1310,
63,
890,
60,
88,
1085,
60,
88,
1717,
971,
88,
614,
2961,
88,
1644,
60,
88,
713,
60,
88,
713,
60,
78,
60,
78,
751,
63,
4054,
60,
88,
1085,
60,
88,
1690,
971,
88,
614,
2961,
84,
60,
88,
713,
60,
88,
845,
60,
78,
60,
84,
3846,
63,
711,
60,
88,
1085,
60,
88,
1780,
971,
88,
614,
2961,
84,
60,
88,
713,
60,
88,
845,
60,
78,
60,
84,
1000,
63,
711,
60,
88,
1085,
60,
82,
971,
88,
614,
2961,
84,
60,
88,
713,
60,
88,
16,
70,
60,
78,
60,
88,
1780,
20996,
60,
88,
1085,
60,
88,
2036,
971,
88,
614,
2961,
84,
60,
88,
713,
7590,
78,
60,
88,
1780,
19645,
60,
88,
1085,
60,
88,
16,
69,
971,
88,
614,
2961,
88,
16,
66,
60,
88,
708,
60,
88,
1167,
14,
3098,
14,
7204,
14,
13283,
60,
88,
713,
60,
88,
1079,
60,
78,
60,
88,
16,
67,
60,
88,
2766,
60,
88,
2976,
60,
88,
2766,
426,
63,
3892,
60,
88,
1085,
60,
88,
16,
66,
971,
88,
614,
2961,
88,
2036,
60,
88,
713,
60,
88,
845,
60,
78,
60,
84,
1637,
63,
12948,
60,
88,
1085,
60,
84,
971,
88,
614,
2961,
88,
2036,
60,
88,
713,
7590,
78,
2,
1637,
63,
24372,
63,
1045,
63,
6493,
63,
1000,
60,
88,
1085,
60,
78,
971,
88,
614,
2961,
88,
2036,
60,
88,
713,
60,
88,
1085,
60,
78,
60,
88,
709,
60,
88,
2766,
60,
88,
2976,
60,
88,
2766,
426,
63,
4498,
63,
2394,
60,
88,
1085,
60,
88,
16,
67,
971,
88,
614,
2961,
88,
1644,
60,
88,
713,
60,
88,
709,
60,
78,
60,
88,
2036,
3922,
60,
88,
1085,
60,
88,
16,
70,
971,
88,
614,
2961,
84,
34,
60,
88,
25,
70,
60,
88,
614,
60,
78,
60,
88,
1196,
60,
88,
2766,
676,
14,
3098,
14,
4806,
14,
466,
34,
60,
88,
709,
10441,
8548,
48,
60,
88,
614,
58,
24,
3098,
14,
71,
393,
621,
14,
1308,
15,
2268,
2625,
15,
17533,
15,
4806,
15,
466,
27,
76,
466,
60,
10117,
60,
88,
996,
60,
88,
1167,
13266,
14,
9089,
14,
14054,
14,
804,
60,
10768,
60,
88,
996,
60,
88,
1167,
13266,
1103,
9089,
1103,
14054,
1103,
804,
66,
60,
88,
1690,
2625,
19,
297,
272,
5124,
1524,
267,
6233,
63,
3287,
63,
1246,
63,
3287,
63,
11270,
363,
3317,
18,
14,
7580,
12,
267,
6233,
63,
3287,
63,
7204,
63,
3287
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
25455,
4475,
20376,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
3,
17065,
701,
314,
4113,
3335,
6365,
14,
221,
3506,
2845,
24981,
1,
199,
3,
1350,
26,
6233,
15,
4806,
15,
466,
15,
1014,
63,
1069,
14,
2625,
199,
624,
12706,
4113,
3335,
1233,
1041,
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,
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,
6233,
14,
1246,
492,
15538,
63,
3317,
18,
465,
6233,
63,
3287,
63,
1246,
63,
3287,
63,
11270,
363,
3317,
18,
199,
504,
6233,
14,
7204,
492,
7373,
63,
3317,
18,
465,
6233,
63,
3287,
63,
7204,
63,
3287,
63,
5553,
363,
3317,
18,
421,
199,
7580,
275,
485,
4120,
14,
23859,
8,
272,
536,
628,
3098,
15,
4806,
15,
466,
15,
1014,
63,
1069,
14,
2625,
401,
272,
2559,
628,
3098,
14,
4806,
14,
466,
401,
272,
6302,
628,
2625,
19,
401,
272,
6380,
63,
1419,
29,
66,
3212,
78,
60,
14218,
957,
14,
3098,
14,
4806,
14,
466,
34,
60,
10173,
10441,
8548,
48,
60,
4587,
58,
24,
3098,
14,
71,
393,
621,
14,
1308,
15,
2268,
2625,
15,
17533,
15,
4806,
15,
466,
27,
76,
466,
60,
6390,
60,
7432,
60,
19225,
13266,
14,
9089,
14,
14054,
14,
804,
60,
16683,
60,
7432,
60,
19225,
13266,
1103,
9089,
1103,
14054,
1103,
804,
401,
272,
1218,
63,
498,
3699,
4120,
423,
4672,
63,
981,
63,
498,
12,
272,
6380,
63,
3317,
29,
66,
1154,
78,
6,
3098,
15,
4806,
15,
466,
15,
1014,
63,
1069,
14,
2625,
60,
88,
713,
60,
88,
969,
3098,
14,
4806,
14,
466,
60,
88,
17,
65,
60,
88,
17,
67,
3098,
15,
1246,
15,
11270,
14,
2625,
60,
88,
17,
65,
60,
88,
17,
69,
3098,
15,
7204,
15,
5553,
14,
2625,
3212,
9532,
60,
88,
996,
60,
78,
60,
88,
16,
66,
10441,
60,
88,
713,
60,
88,
975,
60,
78,
60,
88,
16,
69,
1069,
63,
765,
60,
88,
1085,
60,
88,
614,
971,
88,
614,
2961,
84,
60,
88,
713,
60,
88,
969,
60,
78,
60,
88,
16,
66,
1069,
63,
633,
60,
88,
1085,
60,
88,
996,
971,
88,
614,
2961,
84,
60,
88,
713,
60,
88,
1079,
60,
78,
60,
88,
16,
67,
1069,
63,
890,
60,
88,
1085,
60,
88,
1644,
971,
88,
614,
2961,
88,
1644,
60,
88,
713,
60,
88,
16,
69,
60,
78,
60,
88,
1690,
1205,
60,
88,
1085,
60,
88,
966,
971,
88,
614,
2961,
88,
1717,
60,
88,
713,
60,
88,
1046,
60,
78,
60,
82,
1310,
63,
890,
60,
88,
1085,
60,
88,
1717,
971,
88,
614,
2961,
88,
1644,
60,
88,
713,
60,
88,
713,
60,
78,
60,
78,
751,
63,
4054,
60,
88,
1085,
60,
88,
1690,
971,
88,
614,
2961,
84,
60,
88,
713,
60,
88,
845,
60,
78,
60,
84,
3846,
63,
711,
60,
88,
1085,
60,
88,
1780,
971,
88,
614,
2961,
84,
60,
88,
713,
60,
88,
845,
60,
78,
60,
84,
1000,
63,
711,
60,
88,
1085,
60,
82,
971,
88,
614,
2961,
84,
60,
88,
713,
60,
88,
16,
70,
60,
78,
60,
88,
1780,
20996,
60,
88,
1085,
60,
88,
2036,
971,
88,
614,
2961,
84,
60,
88,
713,
7590,
78,
60,
88,
1780,
19645,
60,
88,
1085,
60,
88,
16,
69,
971,
88,
614,
2961,
88,
16,
66,
60,
88,
708,
60,
88,
1167,
14,
3098,
14,
7204,
14,
13283,
60,
88,
713,
60,
88,
1079,
60,
78,
60,
88,
16,
67,
60,
88,
2766,
60,
88,
2976,
60,
88,
2766,
426,
63,
3892,
60,
88,
1085,
60,
88,
16,
66,
971,
88,
614,
2961,
88,
2036,
60,
88,
713,
60,
88,
845,
60,
78,
60,
84,
1637,
63,
12948,
60,
88,
1085,
60,
84,
971,
88,
614,
2961,
88,
2036,
60,
88,
713,
7590,
78,
2,
1637,
63,
24372,
63,
1045,
63,
6493,
63,
1000,
60,
88,
1085,
60,
78,
971,
88,
614,
2961,
88,
2036,
60,
88,
713,
60,
88,
1085,
60,
78,
60,
88,
709,
60,
88,
2766,
60,
88,
2976,
60,
88,
2766,
426,
63,
4498,
63,
2394,
60,
88,
1085,
60,
88,
16,
67,
971,
88,
614,
2961,
88,
1644,
60,
88,
713,
60,
88,
709,
60,
78,
60,
88,
2036,
3922,
60,
88,
1085,
60,
88,
16,
70,
971,
88,
614,
2961,
84,
34,
60,
88,
25,
70,
60,
88,
614,
60,
78,
60,
88,
1196,
60,
88,
2766,
676,
14,
3098,
14,
4806,
14,
466,
34,
60,
88,
709,
10441,
8548,
48,
60,
88,
614,
58,
24,
3098,
14,
71,
393,
621,
14,
1308,
15,
2268,
2625,
15,
17533,
15,
4806,
15,
466,
27,
76,
466,
60,
10117,
60,
88,
996,
60,
88,
1167,
13266,
14,
9089,
14,
14054,
14,
804,
60,
10768,
60,
88,
996,
60,
88,
1167,
13266,
1103,
9089,
1103,
14054,
1103,
804,
66,
60,
88,
1690,
2625,
19,
297,
272,
5124,
1524,
267,
6233,
63,
3287,
63,
1246,
63,
3287,
63,
11270,
363,
3317,
18,
14,
7580,
12,
267,
6233,
63,
3287,
63,
7204,
63,
3287,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Chilledheart/chromium
|
tools/auto_bisect/bisect_state.py
|
58
|
3608
|
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
class RevisionState(object):
"""Contains bisect state for a given revision.
Properties:
depot: The depot that this revision is from (e.g. WebKit).
revision: Revision number (Git hash or SVN number).
index: Position of the state in the list of all revisions.
value: Value(s) returned from the test.
perf_time: Time that a test took.
build_time: Time that a build took.
passed: Represents whether the performance test was successful at that
revision. Possible values include: 1 (passed), 0 (failed),
'?' (skipped), 'F' (build failed).
external: If the revision is a 'src' revision, 'external' contains the
revisions of each of the external libraries.
"""
def __init__(self, depot, revision, index):
self.depot = depot
self.revision = revision
self.index = index
self.value = None
self.perf_time = 0
self.build_time = 0
self.passed = '?'
self.external = None
# TODO(sergiyb): Update() to parse run_results from the RunTest.
class BisectState(object):
"""Represents a state of the bisect as a collection of revision states."""
def __init__(self, depot, revisions):
"""Initializes a new BisectState object with a set of revision states.
Args:
depot: Name of the depot used for initial set of revision states.
revisions: List of revisions used for initial set of revision states.
"""
self.revision_states = []
self.revision_index = {}
index = 0
for revision in revisions:
new_state = self._InitRevisionState(depot, revision, index)
self.revision_states.append(new_state)
index += 1
@staticmethod
def _RevisionKey(depot, revision):
return "%s:%s" % (depot, revision)
def _InitRevisionState(self, depot, revision, index):
key = self._RevisionKey(depot, revision)
self.revision_index[key] = index
return RevisionState(depot, revision, index)
def GetRevisionState(self, depot, revision):
"""Returns a mutable revision state."""
key = self._RevisionKey(depot, revision)
index = self.revision_index.get(key)
return self.revision_states[index] if index else None
def CreateRevisionStatesAfter(self, depot, revisions, reference_depot,
reference_revision):
"""Creates a set of new revision states after a specified reference state.
Args:
depot: Name of the depot for the new revision states.
revisions: List of revisions for the new revision states.
reference_depot: Name of the depot for the reference revision state.
reference_revision: Revision for the reference revision state.
Returns:
A list containing all created revision states in order as they were added.
"""
ref_key = self._RevisionKey(reference_depot, reference_revision)
ref_index = self.revision_index[ref_key]
num_new_revisions = len(revisions)
for entry in self.revision_states:
if entry.index > ref_index:
entry.index += num_new_revisions
first_index = ref_index + 1
for index, revision in enumerate(revisions, start=first_index):
new_state = self._InitRevisionState(depot, revision, index)
self.revision_states.insert(index, new_state)
return self.revision_states[first_index:first_index + num_new_revisions]
def GetRevisionStates(self):
"""Returns a copy of the list of the revision states."""
return list(self.revision_states)
|
bsd-3-clause
|
[
3,
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
421,
199,
533,
27095,
2223,
8,
785,
304,
523,
408,
6906,
19063,
1174,
367,
282,
1627,
6974,
14,
819,
19329,
26,
272,
32544,
26,
710,
32544,
626,
642,
6974,
365,
687,
334,
69,
14,
71,
14,
6001,
14591,
680,
272,
6974,
26,
27095,
1329,
334,
14686,
2631,
503,
24639,
1329,
680,
272,
1478,
26,
15483,
402,
314,
1174,
315,
314,
769,
402,
1006,
22164,
14,
272,
574,
26,
1594,
8,
83,
9,
2138,
687,
314,
511,
14,
272,
8582,
63,
521,
26,
4703,
626,
282,
511,
27221,
14,
272,
1900,
63,
521,
26,
4703,
626,
282,
1900,
27221,
14,
272,
3032,
26,
21591,
3775,
314,
10238,
511,
1990,
9512,
737,
626,
267,
6974,
14,
18558,
1338,
2387,
26,
413,
334,
12070,
395,
378,
334,
4892,
395,
267,
15539,
334,
11962,
395,
283,
38,
7,
334,
1506,
3405,
680,
272,
5957,
26,
982,
314,
6974,
365,
282,
283,
2164,
7,
6974,
12,
283,
5159,
7,
3509,
314,
267,
22164,
402,
1924,
402,
314,
5957,
8363,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
32544,
12,
6974,
12,
1478,
304,
272,
291,
14,
27834,
275,
32544,
272,
291,
14,
5792,
275,
6974,
272,
291,
14,
1080,
275,
1478,
272,
291,
14,
585,
275,
488,
272,
291,
14,
9452,
63,
521,
275,
378,
272,
291,
14,
1506,
63,
521,
275,
378,
272,
291,
14,
12070,
275,
15539,
272,
291,
14,
5159,
275,
488,
819,
327,
3254,
8,
332,
6153,
28564,
304,
6162,
342,
370,
2198,
1255,
63,
2604,
687,
314,
3378,
774,
14,
421,
199,
533,
699,
13133,
2223,
8,
785,
304,
523,
408,
18089,
282,
1174,
402,
314,
19063,
465,
282,
3245,
402,
6974,
6363,
1041,
819,
347,
636,
826,
721,
277,
12,
32544,
12,
22164,
304,
272,
408,
23489,
282,
892,
699,
13133,
2223,
909,
543,
282,
663,
402,
6974,
6363,
14,
339,
3033,
26,
489,
32544,
26,
2812,
402,
314,
32544,
1202,
367,
2536,
663,
402,
6974,
6363,
14,
489,
22164,
26,
3820,
402,
22164,
1202,
367,
2536,
663,
402,
6974,
6363,
14,
272,
408,
272,
291,
14,
5792,
63,
4981,
275,
942,
272,
291,
14,
5792,
63,
1080,
275,
1052,
339,
1478,
275,
378,
272,
367,
6974,
315,
22164,
26,
489,
892,
63,
929,
275,
291,
423,
9346,
12714,
2223,
8,
27834,
12,
6974,
12,
1478,
9,
489,
291,
14,
5792,
63,
4981,
14,
740,
8,
1222,
63,
929,
9,
489,
1478,
847,
413,
819,
768,
4639,
523,
347,
485,
12714,
1197,
8,
27834,
12,
6974,
304,
272,
372,
2071,
83,
2689,
83,
2,
450,
334,
27834,
12,
6974,
9,
819,
347,
485,
9346,
12714,
2223,
8,
277,
12,
32544,
12,
6974,
12,
1478,
304,
272,
790,
275,
291,
423,
12714,
1197,
8,
27834,
12,
6974,
9,
272,
291,
14,
5792,
63,
1080,
59,
498,
61,
275,
1478,
272,
372,
27095,
2223,
8,
27834,
12,
6974,
12,
1478,
9,
819,
347,
2372,
12714,
2223,
8,
277,
12,
32544,
12,
6974,
304,
272,
408,
3407,
282,
17194,
6974,
1174,
1041,
272,
790,
275,
291,
423,
12714,
1197,
8,
27834,
12,
6974,
9,
272,
1478,
275,
291,
14,
5792,
63,
1080,
14,
362,
8,
498,
9,
272,
372,
291,
14,
5792,
63,
4981,
59,
1080,
61,
340,
1478,
587,
488,
819,
347,
2790,
12714,
18010,
10881,
8,
277,
12,
32544,
12,
22164,
12,
3659,
63,
27834,
12,
1816,
3659,
63,
5792,
304,
272,
408,
10607,
282,
663,
402,
892,
6974,
6363,
2410,
282,
2013,
3659,
1174,
14,
339,
3033,
26,
489,
32544,
26,
2812,
402,
314,
32544,
367,
314,
892,
6974,
6363,
14,
489,
22164,
26,
3820,
402,
22164,
367,
314,
892,
6974,
6363,
14,
489,
3659,
63,
27834,
26,
2812,
402,
314,
32544,
367,
314,
3659,
6974,
1174,
14,
489,
3659,
63,
5792,
26,
27095,
367,
314,
3659,
6974,
1174,
14,
339,
1803,
26,
489,
437,
769,
3035,
1006,
2737,
6974,
6363,
315,
1865,
465,
2985,
4898,
3483,
14,
272,
408,
272,
2984,
63,
498,
275,
291,
423,
12714,
1197,
8,
4443,
63,
27834,
12,
3659,
63,
5792,
9,
272,
2984,
63,
1080,
275,
291,
14,
5792,
63,
1080,
59,
1121,
63,
498,
61,
272,
1967,
63,
1222,
63,
23449,
275,
822,
8,
23449,
9,
272,
367,
2397,
315,
291,
14,
5792,
63,
4981,
26,
489,
340,
2397,
14,
1080,
690,
2984,
63,
1080,
26,
267,
2397,
14,
1080,
847,
1967,
63,
1222,
63,
23449,
339,
1642,
63,
1080,
275,
2984,
63,
1080,
435,
413,
272,
367,
1478,
12,
6974,
315,
3874,
8,
23449,
12,
1343,
29,
2246,
63,
1080,
304,
489,
892,
63,
929,
275,
291,
423,
9346,
12714,
2223,
8,
27834,
12,
6974,
12,
1478,
9,
489,
291,
14,
5792,
63,
4981,
14,
3176,
8,
1080,
12,
892,
63,
929,
9,
339,
372,
291,
14,
5792,
63,
4981,
59,
2246,
63,
1080,
26,
2246,
63,
1080,
435,
1967,
63,
1222,
63,
23449,
61,
819,
347,
2372,
12714,
18010,
8,
277,
304,
272,
408,
3407,
282,
1331,
402,
314,
769,
402,
314,
6974,
6363,
1041,
272,
372,
769,
8,
277,
14,
5792,
63,
4981,
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
] |
[
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
421,
199,
533,
27095,
2223,
8,
785,
304,
523,
408,
6906,
19063,
1174,
367,
282,
1627,
6974,
14,
819,
19329,
26,
272,
32544,
26,
710,
32544,
626,
642,
6974,
365,
687,
334,
69,
14,
71,
14,
6001,
14591,
680,
272,
6974,
26,
27095,
1329,
334,
14686,
2631,
503,
24639,
1329,
680,
272,
1478,
26,
15483,
402,
314,
1174,
315,
314,
769,
402,
1006,
22164,
14,
272,
574,
26,
1594,
8,
83,
9,
2138,
687,
314,
511,
14,
272,
8582,
63,
521,
26,
4703,
626,
282,
511,
27221,
14,
272,
1900,
63,
521,
26,
4703,
626,
282,
1900,
27221,
14,
272,
3032,
26,
21591,
3775,
314,
10238,
511,
1990,
9512,
737,
626,
267,
6974,
14,
18558,
1338,
2387,
26,
413,
334,
12070,
395,
378,
334,
4892,
395,
267,
15539,
334,
11962,
395,
283,
38,
7,
334,
1506,
3405,
680,
272,
5957,
26,
982,
314,
6974,
365,
282,
283,
2164,
7,
6974,
12,
283,
5159,
7,
3509,
314,
267,
22164,
402,
1924,
402,
314,
5957,
8363,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
32544,
12,
6974,
12,
1478,
304,
272,
291,
14,
27834,
275,
32544,
272,
291,
14,
5792,
275,
6974,
272,
291,
14,
1080,
275,
1478,
272,
291,
14,
585,
275,
488,
272,
291,
14,
9452,
63,
521,
275,
378,
272,
291,
14,
1506,
63,
521,
275,
378,
272,
291,
14,
12070,
275,
15539,
272,
291,
14,
5159,
275,
488,
819,
327,
3254,
8,
332,
6153,
28564,
304,
6162,
342,
370,
2198,
1255,
63,
2604,
687,
314,
3378,
774,
14,
421,
199,
533,
699,
13133,
2223,
8,
785,
304,
523,
408,
18089,
282,
1174,
402,
314,
19063,
465,
282,
3245,
402,
6974,
6363,
1041,
819,
347,
636,
826,
721,
277,
12,
32544,
12,
22164,
304,
272,
408,
23489,
282,
892,
699,
13133,
2223,
909,
543,
282,
663,
402,
6974,
6363,
14,
339,
3033,
26,
489,
32544,
26,
2812,
402,
314,
32544,
1202,
367,
2536,
663,
402,
6974,
6363,
14,
489,
22164,
26,
3820,
402,
22164,
1202,
367,
2536,
663,
402,
6974,
6363,
14,
272,
408,
272,
291,
14,
5792,
63,
4981,
275,
942,
272,
291,
14,
5792,
63,
1080,
275,
1052,
339,
1478,
275,
378,
272,
367,
6974,
315,
22164,
26,
489,
892,
63,
929,
275,
291,
423,
9346,
12714,
2223,
8,
27834,
12,
6974,
12,
1478,
9,
489,
291,
14,
5792,
63,
4981,
14,
740,
8,
1222,
63,
929,
9,
489,
1478,
847,
413,
819,
768,
4639,
523,
347,
485,
12714,
1197,
8,
27834,
12,
6974,
304,
272,
372,
2071,
83,
2689,
83,
2,
450,
334,
27834,
12,
6974,
9,
819,
347,
485,
9346,
12714,
2223,
8,
277,
12,
32544,
12,
6974,
12,
1478,
304,
272,
790,
275,
291,
423,
12714,
1197,
8,
27834,
12,
6974,
9,
272,
291,
14,
5792,
63,
1080,
59,
498,
61,
275,
1478,
272,
372,
27095,
2223,
8,
27834,
12,
6974,
12,
1478,
9,
819,
347,
2372,
12714,
2223,
8,
277,
12,
32544,
12,
6974,
304,
272,
408,
3407,
282,
17194,
6974,
1174,
1041,
272,
790,
275,
291,
423,
12714,
1197,
8,
27834,
12,
6974,
9,
272,
1478,
275,
291,
14,
5792,
63,
1080,
14,
362,
8,
498,
9,
272,
372,
291,
14,
5792,
63,
4981,
59,
1080,
61,
340,
1478,
587,
488,
819,
347,
2790,
12714,
18010,
10881,
8,
277,
12,
32544,
12,
22164,
12,
3659,
63,
27834,
12,
1816,
3659,
63,
5792,
304,
272,
408,
10607,
282,
663,
402,
892,
6974,
6363,
2410,
282,
2013,
3659,
1174,
14,
339,
3033,
26,
489,
32544,
26,
2812,
402,
314,
32544,
367,
314,
892,
6974,
6363,
14,
489,
22164,
26,
3820,
402,
22164,
367,
314,
892,
6974,
6363,
14,
489,
3659,
63,
27834,
26,
2812,
402,
314,
32544,
367,
314,
3659,
6974,
1174,
14,
489,
3659,
63,
5792,
26,
27095,
367,
314,
3659,
6974,
1174,
14,
339,
1803,
26,
489,
437,
769,
3035,
1006,
2737,
6974,
6363,
315,
1865,
465,
2985,
4898,
3483,
14,
272,
408,
272,
2984,
63,
498,
275,
291,
423,
12714,
1197,
8,
4443,
63,
27834,
12,
3659,
63,
5792,
9,
272,
2984,
63,
1080,
275,
291,
14,
5792,
63,
1080,
59,
1121,
63,
498,
61,
272,
1967,
63,
1222,
63,
23449,
275,
822,
8,
23449,
9,
272,
367,
2397,
315,
291,
14,
5792,
63,
4981,
26,
489,
340,
2397,
14,
1080,
690,
2984,
63,
1080,
26,
267,
2397,
14,
1080,
847,
1967,
63,
1222,
63,
23449,
339,
1642,
63,
1080,
275,
2984,
63,
1080,
435,
413,
272,
367,
1478,
12,
6974,
315,
3874,
8,
23449,
12,
1343,
29,
2246,
63,
1080,
304,
489,
892,
63,
929,
275,
291,
423,
9346,
12714,
2223,
8,
27834,
12,
6974,
12,
1478,
9,
489,
291,
14,
5792,
63,
4981,
14,
3176,
8,
1080,
12,
892,
63,
929,
9,
339,
372,
291,
14,
5792,
63,
4981,
59,
2246,
63,
1080,
26,
2246,
63,
1080,
435,
1967,
63,
1222,
63,
23449,
61,
819,
347,
2372,
12714,
18010,
8,
277,
304,
272,
408,
3407,
282,
1331,
402,
314,
769,
402,
314,
6974,
6363,
1041,
272,
372,
769,
8,
277,
14,
5792,
63,
4981,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
danmackinlay/AutoGP
|
experiments/sarcos.py
|
2
|
3138
|
import os
import subprocess
import sklearn.cluster
import numpy as np
import autogp
from autogp import likelihoods
from autogp import kernels
import tensorflow as tf
from autogp import datasets
from autogp import losses
from autogp import util
import pandas
import scipy.io as sio
DATA_DIR = "experiments/data/"
TRAIN_PATH = DATA_DIR + "sarcos_inv.mat"
TEST_PATH = DATA_DIR + "sarcos_inv_test"
def init_z(train_inputs, num_inducing):
# Initialize inducing points using clustering.
mini_batch = sklearn.cluster.MiniBatchKMeans(num_inducing)
cluster_indices = mini_batch.fit_predict(train_inputs)
inducing_locations = mini_batch.cluster_centers_
return inducing_locations
def get_sarcos_data():
print "Getting sarcos data ..."
os.chdir('experiments/data')
subprocess.call(["./get_sarcos_data.sh"])
os.chdir("../../")
print "done"
def sarcos_all_joints_data():
"""
Loads and returns data of SARCOS dataset for all joints.
Returns
-------
data : list
A list of length = 1, where each element is a dictionary which contains ``train_outputs``,
``train_inputs``, ``test_outputs``, ``test_inputs``, and ``id``
"""
train = sio.loadmat(TRAIN_PATH)['sarcos_inv']
test = sio.loadmat(TEST_PATH)['sarcos_inv_test']
return{
'train_inputs': train[:, :21],
'train_outputs': train[:, 21:],
'test_inputs': test[:, :21],
'test_outputs': test[:, 21:],
'id': 0
}
if __name__ == '__main__':
FLAGS = util.util.get_flags()
BATCH_SIZE = FLAGS.batch_size
LEARNING_RATE = FLAGS.learning_rate
DISPLAY_STEP = FLAGS.display_step
EPOCHS = FLAGS.n_epochs
NUM_SAMPLES = FLAGS.mc_train
NUM_INDUCING = FLAGS.n_inducing
IS_ARD = FLAGS.is_ard
if os.path.exists(TRAIN_PATH) is False: # directory does not exist, download the data
get_sarcos_data()
d = sarcos_all_joints_data()
data = datasets.DataSet(d['train_inputs'].astype(np.float32), d['train_outputs'].astype(np.float32))
test = datasets.DataSet(d['test_inputs'].astype(np.float32), d['test_outputs'].astype(np.float32))
# Setup initial values for the model.
likelihood = likelihoods.RegressionNetwork(7, 0.1)
kern = [kernels.RadialBasis(data.X.shape[1], lengthscale=8.0, input_scaling = IS_ARD) for i in range(8)]
# kern = [kernels.ArcCosine(data.X.shape[1], 1, 3, 5.0, 1.0, input_scaling=True) for i in range(10)]
Z = init_z(data.X, NUM_INDUCING)
m = autogp.GaussianProcess(likelihood, kern, Z, num_samples=NUM_SAMPLES)
# setting up loss to be reported during training
error_rate = None #losses.StandardizedMeanSqError(d['train_outputs'].astype(np.float32), data.Dout)
import time
o = tf.train.RMSPropOptimizer(LEARNING_RATE)
start = time.time()
m.fit(data, o, loo_steps=0, var_steps=50, epochs = EPOCHS, batch_size = BATCH_SIZE, display_step=DISPLAY_STEP, test = test,
loss = error_rate )
print time.time() - start
ypred = m.predict(test.X)[0]
print("Final " + error_rate.get_name() + "=" + "%.4f" % error_rate.eval(test.Y, ypred))
|
apache-2.0
|
[
646,
747,
199,
646,
3873,
199,
646,
6357,
14,
4201,
199,
646,
2680,
465,
980,
199,
646,
6384,
974,
80,
199,
504,
6384,
974,
80,
492,
22046,
83,
199,
504,
6384,
974,
80,
492,
26091,
199,
646,
3228,
465,
2833,
199,
504,
6384,
974,
80,
492,
13148,
199,
504,
6384,
974,
80,
492,
21289,
199,
504,
6384,
974,
80,
221,
492,
4884,
199,
646,
10634,
199,
646,
7026,
14,
2308,
465,
29129,
421,
199,
3998,
63,
3022,
275,
298,
476,
22263,
15,
576,
6687,
199,
18473,
63,
3243,
275,
7126,
63,
3022,
435,
298,
29637,
5197,
63,
5350,
14,
569,
2,
199,
2864,
63,
3243,
275,
7126,
63,
3022,
435,
298,
29637,
5197,
63,
5350,
63,
396,
2,
199,
199,
318,
4205,
63,
90,
8,
2834,
63,
3711,
12,
1967,
63,
688,
947,
316,
304,
272,
327,
11578,
315,
14713,
4501,
1808,
19454,
14,
272,
20536,
63,
2912,
275,
6357,
14,
4201,
14,
26822,
8842,
43,
21190,
8,
1507,
63,
688,
947,
316,
9,
272,
4350,
63,
4108,
275,
20536,
63,
2912,
14,
3269,
63,
6892,
8,
2834,
63,
3711,
9,
272,
315,
14713,
63,
8022,
275,
20536,
63,
2912,
14,
4201,
63,
15660,
63,
272,
372,
315,
14713,
63,
8022,
421,
199,
318,
664,
63,
29637,
5197,
63,
576,
837,
272,
870,
298,
28277,
308,
285,
5197,
666,
21742,
272,
747,
14,
8563,
360,
476,
22263,
15,
576,
358,
272,
3873,
14,
1250,
779,
1674,
15,
362,
63,
29637,
5197,
63,
576,
14,
609,
3135,
272,
747,
14,
8563,
480,
9707,
531,
272,
870,
298,
4456,
2,
421,
199,
318,
308,
285,
5197,
63,
452,
63,
10153,
83,
63,
576,
837,
272,
408,
272,
30367,
436,
2529,
666,
402,
428,
689,
1439,
51,
4789,
367,
1006,
5225,
13141,
14,
339,
1803,
272,
5514,
272,
666,
520,
769,
267,
437,
769,
402,
2582,
275,
413,
12,
2382,
1924,
1819,
365,
282,
2600,
1314,
3509,
1124,
2834,
63,
4467,
4542,
267,
1124,
2834,
63,
3711,
4542,
1124,
396,
63,
4467,
4542,
1124,
396,
63,
3711,
4542,
436,
1124,
344,
1040,
272,
408,
339,
3560,
275,
29129,
14,
912,
569,
8,
18473,
63,
3243,
11820,
29637,
5197,
63,
5350,
418,
272,
511,
275,
29129,
14,
912,
569,
8,
2864,
63,
3243,
11820,
29637,
5197,
63,
5350,
63,
396,
418,
272,
372,
91,
267,
283,
2834,
63,
3711,
356,
3560,
3981,
520,
2025,
467,
267,
283,
2834,
63,
4467,
356,
3560,
3981,
7829,
8429,
267,
283,
396,
63,
3711,
356,
511,
3981,
520,
2025,
467,
267,
283,
396,
63,
4467,
356,
511,
3981,
7829,
8429,
267,
283,
344,
356,
378,
272,
789,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
12846,
275,
4884,
14,
1974,
14,
362,
63,
2469,
342,
272,
699,
8078,
63,
4305,
275,
12846,
14,
2912,
63,
890,
272,
6124,
689,
6024,
63,
16553,
275,
12846,
14,
10546,
63,
1866,
272,
7587,
11625,
63,
17988,
275,
12846,
14,
2918,
63,
2926,
272,
662,
1512,
1244,
51,
275,
12846,
14,
78,
63,
13161,
272,
11576,
63,
51,
8236,
275,
221,
12846,
14,
5466,
63,
2834,
272,
11576,
63,
3192,
13371,
1206,
275,
12846,
14,
78,
63,
688,
947,
316,
272,
2281,
63,
7816,
275,
12846,
14,
374,
63,
1005,
339,
340,
747,
14,
515,
14,
2444,
8,
18473,
63,
3243,
9,
365,
756,
26,
221,
327,
2082,
1630,
440,
2187,
12,
5235,
314,
666,
267,
664,
63,
29637,
5197,
63,
576,
342,
339,
366,
275,
308,
285,
5197,
63,
452,
63,
10153,
83,
63,
576,
342,
272,
666,
275,
13148,
14,
30720,
8,
68,
459,
2834,
63,
3711,
2278,
6041,
8,
1590,
14,
1609,
708,
395,
366,
459,
2834,
63,
4467,
2278,
6041,
8,
1590,
14,
1609,
708,
430,
272,
511,
275,
13148,
14,
30720,
8,
68,
459,
396,
63,
3711,
2278,
6041,
8,
1590,
14,
1609,
708,
395,
366,
459,
396,
63,
4467,
2278,
6041,
8,
1590,
14,
1609,
708,
430,
339,
327,
12439,
2536,
1338,
367,
314,
1402,
14,
272,
22046,
275,
22046,
83,
14,
13013,
4491,
8,
23,
12,
378,
14,
17,
9,
272,
4303,
78,
275,
359,
29824,
14,
26647,
279,
34,
4864,
8,
576,
14,
56,
14,
1392,
59,
17,
467,
2582,
3467,
29,
24,
14,
16,
12,
1324,
63,
12153,
275,
2281,
63,
7816,
9,
367,
284,
315,
1425,
8,
24,
1874,
272,
327,
4303,
78,
275,
359,
29824,
14,
27604,
26253,
1132,
8,
576,
14,
56,
14,
1392,
59,
17,
467,
413,
12,
650,
12,
959,
14,
16,
12,
413,
14,
16,
12,
1324,
63,
12153,
29,
549,
9,
367,
284,
315,
1425,
8,
709,
1874,
339,
3107,
275,
4205,
63,
90,
8,
576,
14,
56,
12,
11576,
63,
3192,
13371,
1206,
9,
272,
333,
275,
6384,
974,
80,
14,
26756,
3498,
8,
20704,
12,
4303,
78,
12,
3107,
12,
1967,
63,
3356,
29,
7125,
63,
51,
8236,
9,
339,
327,
4260,
1536,
5621,
370,
506,
14581,
5309,
6093,
272,
1125,
63,
1866,
275,
488,
327,
17865,
14,
18736,
18980,
7068,
14825,
24614,
547,
8,
68,
459,
2834,
63,
4467,
2278,
6041,
8,
1590,
14,
1609,
708,
395,
666,
14,
36,
548,
9,
339,
492,
900,
272,
312,
275,
2833,
14,
2834,
14,
50,
3053,
9955,
13946,
8,
906,
689,
6024,
63,
16553,
9,
272,
1343,
275,
900,
14,
521,
342,
272,
333,
14,
3269,
8,
576,
12,
312,
12,
560,
79,
63,
5895,
29,
16,
12,
2729,
63,
5895,
29,
1400,
12,
18463,
275,
662,
1512,
1244,
51,
12,
3522,
63,
890,
275,
699,
8078,
63,
4305,
12,
2929,
63,
2926,
29,
20993,
63,
17988,
12,
511,
275,
511,
12,
288,
5621,
275,
1125,
63,
1866,
776,
272,
870,
900,
14,
521,
342,
446,
1343,
339,
612,
5991,
275,
333,
14,
6892,
8,
396,
14,
56,
2788,
16,
61,
272,
870,
480,
12776,
298,
435,
1125,
63,
1866,
14,
362,
63,
354,
342,
435,
22250,
435,
31681,
20,
70,
2,
450,
1125,
63,
1866,
14,
2579,
8,
396,
14,
57,
12,
612,
5991,
430,
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
] |
[
747,
199,
646,
3873,
199,
646,
6357,
14,
4201,
199,
646,
2680,
465,
980,
199,
646,
6384,
974,
80,
199,
504,
6384,
974,
80,
492,
22046,
83,
199,
504,
6384,
974,
80,
492,
26091,
199,
646,
3228,
465,
2833,
199,
504,
6384,
974,
80,
492,
13148,
199,
504,
6384,
974,
80,
492,
21289,
199,
504,
6384,
974,
80,
221,
492,
4884,
199,
646,
10634,
199,
646,
7026,
14,
2308,
465,
29129,
421,
199,
3998,
63,
3022,
275,
298,
476,
22263,
15,
576,
6687,
199,
18473,
63,
3243,
275,
7126,
63,
3022,
435,
298,
29637,
5197,
63,
5350,
14,
569,
2,
199,
2864,
63,
3243,
275,
7126,
63,
3022,
435,
298,
29637,
5197,
63,
5350,
63,
396,
2,
199,
199,
318,
4205,
63,
90,
8,
2834,
63,
3711,
12,
1967,
63,
688,
947,
316,
304,
272,
327,
11578,
315,
14713,
4501,
1808,
19454,
14,
272,
20536,
63,
2912,
275,
6357,
14,
4201,
14,
26822,
8842,
43,
21190,
8,
1507,
63,
688,
947,
316,
9,
272,
4350,
63,
4108,
275,
20536,
63,
2912,
14,
3269,
63,
6892,
8,
2834,
63,
3711,
9,
272,
315,
14713,
63,
8022,
275,
20536,
63,
2912,
14,
4201,
63,
15660,
63,
272,
372,
315,
14713,
63,
8022,
421,
199,
318,
664,
63,
29637,
5197,
63,
576,
837,
272,
870,
298,
28277,
308,
285,
5197,
666,
21742,
272,
747,
14,
8563,
360,
476,
22263,
15,
576,
358,
272,
3873,
14,
1250,
779,
1674,
15,
362,
63,
29637,
5197,
63,
576,
14,
609,
3135,
272,
747,
14,
8563,
480,
9707,
531,
272,
870,
298,
4456,
2,
421,
199,
318,
308,
285,
5197,
63,
452,
63,
10153,
83,
63,
576,
837,
272,
408,
272,
30367,
436,
2529,
666,
402,
428,
689,
1439,
51,
4789,
367,
1006,
5225,
13141,
14,
339,
1803,
272,
5514,
272,
666,
520,
769,
267,
437,
769,
402,
2582,
275,
413,
12,
2382,
1924,
1819,
365,
282,
2600,
1314,
3509,
1124,
2834,
63,
4467,
4542,
267,
1124,
2834,
63,
3711,
4542,
1124,
396,
63,
4467,
4542,
1124,
396,
63,
3711,
4542,
436,
1124,
344,
1040,
272,
408,
339,
3560,
275,
29129,
14,
912,
569,
8,
18473,
63,
3243,
11820,
29637,
5197,
63,
5350,
418,
272,
511,
275,
29129,
14,
912,
569,
8,
2864,
63,
3243,
11820,
29637,
5197,
63,
5350,
63,
396,
418,
272,
372,
91,
267,
283,
2834,
63,
3711,
356,
3560,
3981,
520,
2025,
467,
267,
283,
2834,
63,
4467,
356,
3560,
3981,
7829,
8429,
267,
283,
396,
63,
3711,
356,
511,
3981,
520,
2025,
467,
267,
283,
396,
63,
4467,
356,
511,
3981,
7829,
8429,
267,
283,
344,
356,
378,
272,
789,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
12846,
275,
4884,
14,
1974,
14,
362,
63,
2469,
342,
272,
699,
8078,
63,
4305,
275,
12846,
14,
2912,
63,
890,
272,
6124,
689,
6024,
63,
16553,
275,
12846,
14,
10546,
63,
1866,
272,
7587,
11625,
63,
17988,
275,
12846,
14,
2918,
63,
2926,
272,
662,
1512,
1244,
51,
275,
12846,
14,
78,
63,
13161,
272,
11576,
63,
51,
8236,
275,
221,
12846,
14,
5466,
63,
2834,
272,
11576,
63,
3192,
13371,
1206,
275,
12846,
14,
78,
63,
688,
947,
316,
272,
2281,
63,
7816,
275,
12846,
14,
374,
63,
1005,
339,
340,
747,
14,
515,
14,
2444,
8,
18473,
63,
3243,
9,
365,
756,
26,
221,
327,
2082,
1630,
440,
2187,
12,
5235,
314,
666,
267,
664,
63,
29637,
5197,
63,
576,
342,
339,
366,
275,
308,
285,
5197,
63,
452,
63,
10153,
83,
63,
576,
342,
272,
666,
275,
13148,
14,
30720,
8,
68,
459,
2834,
63,
3711,
2278,
6041,
8,
1590,
14,
1609,
708,
395,
366,
459,
2834,
63,
4467,
2278,
6041,
8,
1590,
14,
1609,
708,
430,
272,
511,
275,
13148,
14,
30720,
8,
68,
459,
396,
63,
3711,
2278,
6041,
8,
1590,
14,
1609,
708,
395,
366,
459,
396,
63,
4467,
2278,
6041,
8,
1590,
14,
1609,
708,
430,
339,
327,
12439,
2536,
1338,
367,
314,
1402,
14,
272,
22046,
275,
22046,
83,
14,
13013,
4491,
8,
23,
12,
378,
14,
17,
9,
272,
4303,
78,
275,
359,
29824,
14,
26647,
279,
34,
4864,
8,
576,
14,
56,
14,
1392,
59,
17,
467,
2582,
3467,
29,
24,
14,
16,
12,
1324,
63,
12153,
275,
2281,
63,
7816,
9,
367,
284,
315,
1425,
8,
24,
1874,
272,
327,
4303,
78,
275,
359,
29824,
14,
27604,
26253,
1132,
8,
576,
14,
56,
14,
1392,
59,
17,
467,
413,
12,
650,
12,
959,
14,
16,
12,
413,
14,
16,
12,
1324,
63,
12153,
29,
549,
9,
367,
284,
315,
1425,
8,
709,
1874,
339,
3107,
275,
4205,
63,
90,
8,
576,
14,
56,
12,
11576,
63,
3192,
13371,
1206,
9,
272,
333,
275,
6384,
974,
80,
14,
26756,
3498,
8,
20704,
12,
4303,
78,
12,
3107,
12,
1967,
63,
3356,
29,
7125,
63,
51,
8236,
9,
339,
327,
4260,
1536,
5621,
370,
506,
14581,
5309,
6093,
272,
1125,
63,
1866,
275,
488,
327,
17865,
14,
18736,
18980,
7068,
14825,
24614,
547,
8,
68,
459,
2834,
63,
4467,
2278,
6041,
8,
1590,
14,
1609,
708,
395,
666,
14,
36,
548,
9,
339,
492,
900,
272,
312,
275,
2833,
14,
2834,
14,
50,
3053,
9955,
13946,
8,
906,
689,
6024,
63,
16553,
9,
272,
1343,
275,
900,
14,
521,
342,
272,
333,
14,
3269,
8,
576,
12,
312,
12,
560,
79,
63,
5895,
29,
16,
12,
2729,
63,
5895,
29,
1400,
12,
18463,
275,
662,
1512,
1244,
51,
12,
3522,
63,
890,
275,
699,
8078,
63,
4305,
12,
2929,
63,
2926,
29,
20993,
63,
17988,
12,
511,
275,
511,
12,
288,
5621,
275,
1125,
63,
1866,
776,
272,
870,
900,
14,
521,
342,
446,
1343,
339,
612,
5991,
275,
333,
14,
6892,
8,
396,
14,
56,
2788,
16,
61,
272,
870,
480,
12776,
298,
435,
1125,
63,
1866,
14,
362,
63,
354,
342,
435,
22250,
435,
31681,
20,
70,
2,
450,
1125,
63,
1866,
14,
2579,
8,
396,
14,
57,
12,
612,
5991,
430,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
umitproject/tease-o-matic
|
pygments/formatters/__init__.py
|
72
|
1827
|
# -*- coding: utf-8 -*-
"""
pygments.formatters
~~~~~~~~~~~~~~~~~~~
Pygments formatters.
:copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import os.path
import fnmatch
from pygments.formatters._mapping import FORMATTERS
from pygments.plugin import find_plugin_formatters
from pygments.util import ClassNotFound
ns = globals()
for fcls in FORMATTERS:
ns[fcls.__name__] = fcls
del fcls
__all__ = ['get_formatter_by_name', 'get_formatter_for_filename',
'get_all_formatters'] + [cls.__name__ for cls in FORMATTERS]
_formatter_alias_cache = {}
_formatter_filename_cache = []
def _init_formatter_cache():
if _formatter_alias_cache:
return
for cls in get_all_formatters():
for alias in cls.aliases:
_formatter_alias_cache[alias] = cls
for fn in cls.filenames:
_formatter_filename_cache.append((fn, cls))
def find_formatter_class(name):
_init_formatter_cache()
cls = _formatter_alias_cache.get(name, None)
return cls
def get_formatter_by_name(name, **options):
_init_formatter_cache()
cls = _formatter_alias_cache.get(name, None)
if not cls:
raise ClassNotFound("No formatter found for name %r" % name)
return cls(**options)
def get_formatter_for_filename(fn, **options):
_init_formatter_cache()
fn = os.path.basename(fn)
for pattern, cls in _formatter_filename_cache:
if fnmatch.fnmatch(fn, pattern):
return cls(**options)
raise ClassNotFound("No formatter found for file name %r" % fn)
def get_all_formatters():
"""Return a generator for all formatters."""
for formatter in FORMATTERS:
yield formatter
for _, formatter in find_plugin_formatters():
yield formatter
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
24270,
272,
18294,
23597,
339,
14493,
30514,
14,
339,
520,
7307,
26,
1898,
8315,
13,
6542,
701,
314,
14493,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
646,
747,
14,
515,
199,
646,
15951,
199,
199,
504,
13277,
14,
24270,
423,
4745,
492,
11295,
619,
1157,
51,
199,
504,
13277,
14,
2718,
492,
2342,
63,
2718,
63,
24270,
199,
504,
13277,
14,
1974,
492,
8089,
4667,
199,
199,
561,
275,
7992,
342,
199,
509,
289,
1886,
315,
11295,
619,
1157,
51,
26,
272,
700,
59,
70,
1886,
855,
354,
22705,
275,
289,
1886,
199,
2264,
289,
1886,
199,
199,
363,
452,
363,
275,
788,
362,
63,
8911,
63,
991,
63,
354,
297,
283,
362,
63,
8911,
63,
509,
63,
1501,
297,
1779,
283,
362,
63,
452,
63,
24270,
418,
435,
359,
1886,
855,
354,
363,
367,
843,
315,
11295,
619,
1157,
51,
61,
421,
199,
63,
8911,
63,
3620,
63,
1637,
275,
1052,
199,
63,
8911,
63,
1501,
63,
1637,
275,
942,
199,
199,
318,
485,
826,
63,
8911,
63,
1637,
837,
272,
340,
485,
8911,
63,
3620,
63,
1637,
26,
267,
372,
272,
367,
843,
315,
664,
63,
452,
63,
24270,
837,
267,
367,
5162,
315,
843,
14,
8602,
26,
288,
485,
8911,
63,
3620,
63,
1637,
59,
3620,
61,
275,
843,
267,
367,
4325,
315,
843,
14,
10309,
26,
288,
485,
8911,
63,
1501,
63,
1637,
14,
740,
1332,
2324,
12,
843,
430,
421,
199,
318,
2342,
63,
8911,
63,
533,
8,
354,
304,
272,
485,
826,
63,
8911,
63,
1637,
342,
272,
843,
275,
485,
8911,
63,
3620,
63,
1637,
14,
362,
8,
354,
12,
488,
9,
272,
372,
843,
421,
199,
318,
664,
63,
8911,
63,
991,
63,
354,
8,
354,
12,
1011,
1419,
304,
272,
485,
826,
63,
8911,
63,
1637,
342,
272,
843,
275,
485,
8911,
63,
3620,
63,
1637,
14,
362,
8,
354,
12,
488,
9,
272,
340,
440,
843,
26,
267,
746,
8089,
4667,
480,
1944,
9698,
1911,
367,
536,
450,
82,
2,
450,
536,
9,
272,
372,
843,
3682,
1419,
9,
421,
199,
318,
664,
63,
8911,
63,
509,
63,
1501,
8,
2324,
12,
1011,
1419,
304,
272,
485,
826,
63,
8911,
63,
1637,
342,
272,
4325,
275,
747,
14,
515,
14,
4846,
8,
2324,
9,
272,
367,
3851,
12,
843,
315,
485,
8911,
63,
1501,
63,
1637,
26,
267,
340,
15951,
14,
15359,
8,
2324,
12,
3851,
304,
288,
372,
843,
3682,
1419,
9,
272,
746,
8089,
4667,
480,
1944,
9698,
1911,
367,
570,
536,
450,
82,
2,
450,
4325,
9,
421,
199,
318,
664,
63,
452,
63,
24270,
837,
272,
408,
1767,
282,
4306,
367,
1006,
30514,
1041,
272,
367,
9698,
315,
11295,
619,
1157,
51,
26,
267,
1995,
9698,
272,
367,
5501,
9698,
315,
2342,
63,
2718,
63,
24270,
837,
267,
1995,
9698,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
24270,
272,
18294,
23597,
339,
14493,
30514,
14,
339,
520,
7307,
26,
1898,
8315,
13,
6542,
701,
314,
14493,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
646,
747,
14,
515,
199,
646,
15951,
199,
199,
504,
13277,
14,
24270,
423,
4745,
492,
11295,
619,
1157,
51,
199,
504,
13277,
14,
2718,
492,
2342,
63,
2718,
63,
24270,
199,
504,
13277,
14,
1974,
492,
8089,
4667,
199,
199,
561,
275,
7992,
342,
199,
509,
289,
1886,
315,
11295,
619,
1157,
51,
26,
272,
700,
59,
70,
1886,
855,
354,
22705,
275,
289,
1886,
199,
2264,
289,
1886,
199,
199,
363,
452,
363,
275,
788,
362,
63,
8911,
63,
991,
63,
354,
297,
283,
362,
63,
8911,
63,
509,
63,
1501,
297,
1779,
283,
362,
63,
452,
63,
24270,
418,
435,
359,
1886,
855,
354,
363,
367,
843,
315,
11295,
619,
1157,
51,
61,
421,
199,
63,
8911,
63,
3620,
63,
1637,
275,
1052,
199,
63,
8911,
63,
1501,
63,
1637,
275,
942,
199,
199,
318,
485,
826,
63,
8911,
63,
1637,
837,
272,
340,
485,
8911,
63,
3620,
63,
1637,
26,
267,
372,
272,
367,
843,
315,
664,
63,
452,
63,
24270,
837,
267,
367,
5162,
315,
843,
14,
8602,
26,
288,
485,
8911,
63,
3620,
63,
1637,
59,
3620,
61,
275,
843,
267,
367,
4325,
315,
843,
14,
10309,
26,
288,
485,
8911,
63,
1501,
63,
1637,
14,
740,
1332,
2324,
12,
843,
430,
421,
199,
318,
2342,
63,
8911,
63,
533,
8,
354,
304,
272,
485,
826,
63,
8911,
63,
1637,
342,
272,
843,
275,
485,
8911,
63,
3620,
63,
1637,
14,
362,
8,
354,
12,
488,
9,
272,
372,
843,
421,
199,
318,
664,
63,
8911,
63,
991,
63,
354,
8,
354,
12,
1011,
1419,
304,
272,
485,
826,
63,
8911,
63,
1637,
342,
272,
843,
275,
485,
8911,
63,
3620,
63,
1637,
14,
362,
8,
354,
12,
488,
9,
272,
340,
440,
843,
26,
267,
746,
8089,
4667,
480,
1944,
9698,
1911,
367,
536,
450,
82,
2,
450,
536,
9,
272,
372,
843,
3682,
1419,
9,
421,
199,
318,
664,
63,
8911,
63,
509,
63,
1501,
8,
2324,
12,
1011,
1419,
304,
272,
485,
826,
63,
8911,
63,
1637,
342,
272,
4325,
275,
747,
14,
515,
14,
4846,
8,
2324,
9,
272,
367,
3851,
12,
843,
315,
485,
8911,
63,
1501,
63,
1637,
26,
267,
340,
15951,
14,
15359,
8,
2324,
12,
3851,
304,
288,
372,
843,
3682,
1419,
9,
272,
746,
8089,
4667,
480,
1944,
9698,
1911,
367,
570,
536,
450,
82,
2,
450,
4325,
9,
421,
199,
318,
664,
63,
452,
63,
24270,
837,
272,
408,
1767,
282,
4306,
367,
1006,
30514,
1041,
272,
367,
9698,
315,
11295,
619,
1157,
51,
26,
267,
1995,
9698,
272,
367,
5501,
9698,
315,
2342,
63,
2718,
63,
24270,
837,
267,
1995,
9698,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
highweb-project/highweb-webcl-html5spec
|
tools/cr/cr/base/host.py
|
89
|
5957
|
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Module for build host support."""
import os
import pipes
import signal
import subprocess
import cr
# Controls what verbosity level turns on command trail logging
_TRAIL_VERBOSITY = 2
def PrintTrail(trail):
print 'Command expanded the following variables:'
for key, value in trail:
if value == None:
value = ''
print ' ', key, '=', value
class Host(cr.Plugin, cr.Plugin.Type):
"""Base class for implementing cr hosts.
The host is the main access point to services provided by the machine cr
is running on. It exposes information about the machine, and runs external
commands on behalf of the actions.
"""
def __init__(self):
super(Host, self).__init__()
def Matches(self):
"""Detects whether this is the correct host implementation.
This method is overridden by the concrete implementations.
Returns:
true if the plugin matches the machine it is running on.
"""
return False
@classmethod
def Select(cls):
for host in cls.Plugins():
if host.Matches():
return host
def _Execute(self, command,
shell=False, capture=False, silent=False,
ignore_dry_run=False, return_status=False,
ignore_interrupt_signal=False):
"""This is the only method that launches external programs.
It is a thin wrapper around subprocess.Popen that handles cr specific
issues. The command is expanded in the active context so that variables
are substituted.
Args:
command: the command to run.
shell: whether to run the command using the shell.
capture: controls wether the output of the command is captured.
ignore_dry_run: Normally, if the context is in dry run mode the command is
printed but not executed. This flag overrides that behaviour, causing
the command to be run anyway.
return_status: switches the function to returning the status code rather
the output.
ignore_interrupt_signal: Ignore the interrupt signal (i.e., Ctrl-C) while
the command is running. Useful for letting interactive programs manage
Ctrl-C by themselves.
Returns:
the status if return_status is true, or the output if capture is true,
otherwise nothing.
"""
with cr.context.Trace():
command = [cr.context.Substitute(arg) for arg in command if arg]
trail = cr.context.trail
if not command:
print 'Empty command passed to execute'
exit(1)
if cr.context.verbose:
print ' '.join(command)
if cr.context.verbose >= _TRAIL_VERBOSITY:
PrintTrail(trail)
if ignore_dry_run or not cr.context.dry_run:
out = None
if capture:
out = subprocess.PIPE
elif silent:
out = open(os.devnull, "w")
try:
p = subprocess.Popen(
command, shell=shell,
env={k: str(v) for k, v in cr.context.exported.items()},
stdout=out)
except OSError:
print 'Failed to exec', command
# Don't log the trail if we already have
if cr.context.verbose < _TRAIL_VERBOSITY:
PrintTrail(trail)
exit(1)
try:
if ignore_interrupt_signal:
signal.signal(signal.SIGINT, signal.SIG_IGN)
output, _ = p.communicate()
finally:
if ignore_interrupt_signal:
signal.signal(signal.SIGINT, signal.SIG_DFL)
if silent:
out.close()
if return_status:
return p.returncode
if p.returncode != 0:
print 'Error {0} executing command {1}'.format(p.returncode, command)
exit(p.returncode)
return output or ''
return ''
@cr.Plugin.activemethod
def Shell(self, *command):
command = ' '.join([pipes.quote(arg) for arg in command])
return self._Execute([command], shell=True, ignore_interrupt_signal=True)
@cr.Plugin.activemethod
def Execute(self, *command):
return self._Execute(command, shell=False)
@cr.Plugin.activemethod
def ExecuteSilently(self, *command):
return self._Execute(command, shell=False, silent=True)
@cr.Plugin.activemethod
def CaptureShell(self, *command):
return self._Execute(command,
shell=True, capture=True, ignore_dry_run=True)
@cr.Plugin.activemethod
def Capture(self, *command):
return self._Execute(command, capture=True, ignore_dry_run=True)
@cr.Plugin.activemethod
def ExecuteStatus(self, *command):
return self._Execute(command,
ignore_dry_run=True, return_status=True)
@cr.Plugin.activemethod
def YesNo(self, question, default=True):
"""Ask the user a yes no question
This blocks until the user responds.
Args:
question: The question string to show the user
default: True if the default response is Yes
Returns:
True if the response was yes.
"""
options = 'Y/n' if default else 'y/N'
result = raw_input(question + ' [' + options + '] ').lower()
if result == '':
return default
return result in ['y', 'yes']
@classmethod
def SearchPath(cls, name, paths=[]):
"""Searches the PATH for an executable.
Args:
name: the name of the binary to search for.
Returns:
the set of executables found, or an empty list if none.
"""
result = []
extensions = ['']
extensions.extend(os.environ.get('PATHEXT', '').split(os.pathsep))
paths = [cr.context.Substitute(path) for path in paths if path]
paths = paths + os.environ.get('PATH', '').split(os.pathsep)
for path in paths:
partial = os.path.join(path, name)
for extension in extensions:
filename = partial + extension
if os.path.exists(filename) and filename not in result:
result.append(filename)
return result
|
bsd-3-clause
|
[
3,
1898,
6171,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
2377,
367,
1900,
1591,
2291,
1041,
199,
199,
646,
747,
199,
646,
20988,
199,
646,
4673,
199,
646,
3873,
199,
199,
646,
2467,
199,
199,
3,
29001,
4052,
8661,
2166,
25449,
641,
1414,
27225,
2050,
199,
63,
1766,
6593,
63,
2111,
34,
3100,
1922,
275,
499,
199,
199,
318,
9101,
2437,
382,
8,
15732,
304,
523,
870,
283,
3110,
11507,
314,
2569,
2860,
4881,
523,
367,
790,
12,
574,
315,
27225,
26,
272,
340,
574,
508,
488,
26,
489,
574,
275,
2125,
272,
870,
283,
257,
1656,
790,
12,
6291,
574,
421,
199,
533,
10891,
8,
1556,
14,
5061,
12,
2467,
14,
5061,
14,
804,
304,
523,
408,
1563,
1021,
367,
18234,
2467,
7057,
14,
819,
710,
1591,
365,
314,
2446,
2879,
2376,
370,
8500,
2741,
701,
314,
6844,
2467,
523,
365,
3879,
641,
14,
2779,
444,
10553,
2556,
3595,
314,
6844,
12,
436,
7858,
5957,
523,
3718,
641,
506,
10220,
402,
314,
5445,
14,
523,
408,
819,
347,
636,
826,
721,
277,
304,
272,
1613,
8,
4965,
12,
291,
2843,
826,
4533,
819,
347,
21682,
8,
277,
304,
272,
408,
872,
28853,
3775,
642,
365,
314,
3211,
1591,
4514,
14,
339,
961,
1083,
365,
10087,
701,
314,
13801,
12591,
14,
272,
1803,
26,
489,
2549,
340,
314,
3589,
4450,
314,
6844,
652,
365,
3879,
641,
14,
272,
408,
272,
372,
756,
819,
768,
3744,
523,
347,
9496,
8,
1886,
304,
272,
367,
1591,
315,
843,
14,
19330,
837,
489,
340,
1591,
14,
12962,
837,
267,
372,
1591,
819,
347,
485,
12049,
8,
277,
12,
1414,
12,
2049,
5218,
29,
797,
12,
12296,
29,
797,
12,
10866,
29,
797,
12,
2049,
3686,
63,
10481,
63,
1065,
29,
797,
12,
372,
63,
1205,
29,
797,
12,
2049,
3686,
63,
20172,
63,
4653,
29,
797,
304,
272,
408,
2765,
365,
314,
1454,
1083,
626,
10623,
397,
5957,
18572,
14,
339,
2779,
365,
282,
30758,
4975,
6818,
3873,
14,
7942,
626,
10022,
2467,
2488,
272,
10876,
14,
710,
1414,
365,
11507,
315,
314,
4702,
1067,
880,
626,
2860,
272,
787,
10004,
4241,
14,
272,
3033,
26,
489,
1414,
26,
314,
1414,
370,
1255,
14,
489,
5218,
26,
3775,
370,
1255,
314,
1414,
1808,
314,
5218,
14,
489,
12296,
26,
13467,
781,
728,
314,
1072,
402,
314,
1414,
365,
17487,
14,
489,
3686,
63,
10481,
63,
1065,
26,
24573,
12,
340,
314,
1067,
365,
315,
9951,
1255,
818,
314,
1414,
365,
267,
12487,
1325,
440,
7934,
14,
961,
3305,
10580,
626,
13942,
12,
25498,
267,
314,
1414,
370,
506,
1255,
15988,
14,
489,
372,
63,
1205,
26,
24563,
314,
805,
370,
8152,
314,
2004,
1233,
7830,
267,
314,
1072,
14,
489,
3686,
63,
20172,
63,
4653,
26,
14092,
314,
26791,
4673,
334,
73,
14,
69,
2020,
445,
7245,
13,
35,
9,
1830,
267,
314,
1414,
365,
3879,
14,
18491,
367,
4691,
1337,
12777,
18572,
9635,
267,
445,
7245,
13,
35,
701,
17279,
14,
272,
1803,
26,
489,
314,
2004,
340,
372,
63,
1205,
365,
2549,
12,
503,
314,
1072,
340,
12296,
365,
2549,
12,
489,
4257,
6548,
14,
272,
408,
272,
543,
2467,
14,
1100,
14,
3921,
837,
489,
1414,
275,
359,
1556,
14,
1100,
14,
2610,
25585,
8,
1273,
9,
367,
1680,
315,
1414,
340,
1680,
61,
272,
27225,
275,
2467,
14,
1100,
14,
15732,
272,
340,
440,
1414,
26,
489,
870,
283,
4699,
1414,
3032,
370,
5341,
7,
489,
4458,
8,
17,
9,
272,
340,
2467,
14,
1100,
14,
3832,
26,
489,
870,
283,
1987,
904,
8,
1531,
9,
489,
340,
2467,
14,
1100,
14,
3832,
2356,
485,
1766,
6593,
63,
2111,
34,
3100,
1922,
26,
267,
9101,
2437,
382,
8,
15732,
9,
272,
340,
3686,
63,
10481,
63,
1065,
503,
440,
2467,
14,
1100,
14,
10481,
63,
1065,
26,
489,
734,
275,
488,
489,
340,
12296,
26,
267,
734,
275,
3873,
14,
6089,
489,
916,
10866,
26,
267,
734,
275,
1551,
8,
736,
14,
19778,
12,
298,
87,
531,
489,
862,
26,
267,
299,
275,
3873,
14,
7942,
8,
288,
1414,
12,
5218,
29,
5641,
12,
288,
2589,
3126,
75,
26,
620,
8,
86,
9,
367,
1022,
12,
373,
315,
2467,
14,
1100,
14,
23028,
14,
1744,
342,
1386,
288,
3839,
29,
548,
9,
489,
871,
6440,
26,
267,
870,
283,
4276,
370,
2146,
297,
1414,
267,
327,
7529,
1133,
943,
314,
27225,
340,
781,
2575,
1172,
267,
340,
2467,
14,
1100,
14,
3832,
665,
485,
1766,
6593,
63,
2111,
34,
3100,
1922,
26,
881,
9101,
2437,
382,
8,
15732,
9,
267,
4458,
8,
17,
9,
489,
862,
26,
267,
340,
3686,
63,
20172,
63,
4653,
26,
881,
4673,
14,
4653,
8,
4653,
14,
21223,
12,
4673,
14,
7864,
63,
3203,
9,
267,
1072,
12,
485,
275,
299,
14,
10664,
342,
489,
3753,
26,
267,
340,
3686,
63,
20172,
63,
4653,
26,
881,
4673,
14,
4653,
8,
4653,
14,
21223,
12,
4673,
14,
7864,
63,
36,
3143,
9,
267,
340,
10866,
26,
881,
734,
14,
1600,
342,
489,
340,
372,
63,
1205,
26,
267,
372,
299,
14,
9913,
489,
340,
299,
14,
9913,
1137,
378,
26,
267,
870,
283,
547,
469,
16,
93,
14043,
1414,
469,
17,
5285,
908,
8,
80,
14,
9913,
12,
1414,
9,
267,
4458,
8,
80,
14,
9913,
9,
489,
372,
1072,
503,
2125,
272,
372,
2125,
819,
768,
1556,
14,
5061,
14,
2682,
765,
523,
347,
24599,
8,
277,
12,
627,
1531,
304,
272,
1414,
275,
283,
1987,
904,
779,
29942,
14,
3513,
8,
1273,
9,
367,
1680,
315,
1414,
566,
272,
372,
291,
423,
12049,
779,
1531,
467,
5218,
29,
549,
12,
3686,
63,
20172,
63,
4653,
29,
549,
9,
819,
768,
1556,
14,
5061,
14,
2682,
765,
523,
347,
17009,
8,
277,
12,
627,
1531,
304,
272,
372,
291,
423,
12049,
8,
1531,
12,
5218,
29,
797,
9,
819,
768,
1556,
14,
5061,
14,
2682,
765,
523,
347,
17009,
51,
441,
343,
590,
8,
277,
12,
627,
1531,
304,
272,
372,
291,
423,
12049,
8,
1531,
12,
5218
] |
[
1898,
6171,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
2377,
367,
1900,
1591,
2291,
1041,
199,
199,
646,
747,
199,
646,
20988,
199,
646,
4673,
199,
646,
3873,
199,
199,
646,
2467,
199,
199,
3,
29001,
4052,
8661,
2166,
25449,
641,
1414,
27225,
2050,
199,
63,
1766,
6593,
63,
2111,
34,
3100,
1922,
275,
499,
199,
199,
318,
9101,
2437,
382,
8,
15732,
304,
523,
870,
283,
3110,
11507,
314,
2569,
2860,
4881,
523,
367,
790,
12,
574,
315,
27225,
26,
272,
340,
574,
508,
488,
26,
489,
574,
275,
2125,
272,
870,
283,
257,
1656,
790,
12,
6291,
574,
421,
199,
533,
10891,
8,
1556,
14,
5061,
12,
2467,
14,
5061,
14,
804,
304,
523,
408,
1563,
1021,
367,
18234,
2467,
7057,
14,
819,
710,
1591,
365,
314,
2446,
2879,
2376,
370,
8500,
2741,
701,
314,
6844,
2467,
523,
365,
3879,
641,
14,
2779,
444,
10553,
2556,
3595,
314,
6844,
12,
436,
7858,
5957,
523,
3718,
641,
506,
10220,
402,
314,
5445,
14,
523,
408,
819,
347,
636,
826,
721,
277,
304,
272,
1613,
8,
4965,
12,
291,
2843,
826,
4533,
819,
347,
21682,
8,
277,
304,
272,
408,
872,
28853,
3775,
642,
365,
314,
3211,
1591,
4514,
14,
339,
961,
1083,
365,
10087,
701,
314,
13801,
12591,
14,
272,
1803,
26,
489,
2549,
340,
314,
3589,
4450,
314,
6844,
652,
365,
3879,
641,
14,
272,
408,
272,
372,
756,
819,
768,
3744,
523,
347,
9496,
8,
1886,
304,
272,
367,
1591,
315,
843,
14,
19330,
837,
489,
340,
1591,
14,
12962,
837,
267,
372,
1591,
819,
347,
485,
12049,
8,
277,
12,
1414,
12,
2049,
5218,
29,
797,
12,
12296,
29,
797,
12,
10866,
29,
797,
12,
2049,
3686,
63,
10481,
63,
1065,
29,
797,
12,
372,
63,
1205,
29,
797,
12,
2049,
3686,
63,
20172,
63,
4653,
29,
797,
304,
272,
408,
2765,
365,
314,
1454,
1083,
626,
10623,
397,
5957,
18572,
14,
339,
2779,
365,
282,
30758,
4975,
6818,
3873,
14,
7942,
626,
10022,
2467,
2488,
272,
10876,
14,
710,
1414,
365,
11507,
315,
314,
4702,
1067,
880,
626,
2860,
272,
787,
10004,
4241,
14,
272,
3033,
26,
489,
1414,
26,
314,
1414,
370,
1255,
14,
489,
5218,
26,
3775,
370,
1255,
314,
1414,
1808,
314,
5218,
14,
489,
12296,
26,
13467,
781,
728,
314,
1072,
402,
314,
1414,
365,
17487,
14,
489,
3686,
63,
10481,
63,
1065,
26,
24573,
12,
340,
314,
1067,
365,
315,
9951,
1255,
818,
314,
1414,
365,
267,
12487,
1325,
440,
7934,
14,
961,
3305,
10580,
626,
13942,
12,
25498,
267,
314,
1414,
370,
506,
1255,
15988,
14,
489,
372,
63,
1205,
26,
24563,
314,
805,
370,
8152,
314,
2004,
1233,
7830,
267,
314,
1072,
14,
489,
3686,
63,
20172,
63,
4653,
26,
14092,
314,
26791,
4673,
334,
73,
14,
69,
2020,
445,
7245,
13,
35,
9,
1830,
267,
314,
1414,
365,
3879,
14,
18491,
367,
4691,
1337,
12777,
18572,
9635,
267,
445,
7245,
13,
35,
701,
17279,
14,
272,
1803,
26,
489,
314,
2004,
340,
372,
63,
1205,
365,
2549,
12,
503,
314,
1072,
340,
12296,
365,
2549,
12,
489,
4257,
6548,
14,
272,
408,
272,
543,
2467,
14,
1100,
14,
3921,
837,
489,
1414,
275,
359,
1556,
14,
1100,
14,
2610,
25585,
8,
1273,
9,
367,
1680,
315,
1414,
340,
1680,
61,
272,
27225,
275,
2467,
14,
1100,
14,
15732,
272,
340,
440,
1414,
26,
489,
870,
283,
4699,
1414,
3032,
370,
5341,
7,
489,
4458,
8,
17,
9,
272,
340,
2467,
14,
1100,
14,
3832,
26,
489,
870,
283,
1987,
904,
8,
1531,
9,
489,
340,
2467,
14,
1100,
14,
3832,
2356,
485,
1766,
6593,
63,
2111,
34,
3100,
1922,
26,
267,
9101,
2437,
382,
8,
15732,
9,
272,
340,
3686,
63,
10481,
63,
1065,
503,
440,
2467,
14,
1100,
14,
10481,
63,
1065,
26,
489,
734,
275,
488,
489,
340,
12296,
26,
267,
734,
275,
3873,
14,
6089,
489,
916,
10866,
26,
267,
734,
275,
1551,
8,
736,
14,
19778,
12,
298,
87,
531,
489,
862,
26,
267,
299,
275,
3873,
14,
7942,
8,
288,
1414,
12,
5218,
29,
5641,
12,
288,
2589,
3126,
75,
26,
620,
8,
86,
9,
367,
1022,
12,
373,
315,
2467,
14,
1100,
14,
23028,
14,
1744,
342,
1386,
288,
3839,
29,
548,
9,
489,
871,
6440,
26,
267,
870,
283,
4276,
370,
2146,
297,
1414,
267,
327,
7529,
1133,
943,
314,
27225,
340,
781,
2575,
1172,
267,
340,
2467,
14,
1100,
14,
3832,
665,
485,
1766,
6593,
63,
2111,
34,
3100,
1922,
26,
881,
9101,
2437,
382,
8,
15732,
9,
267,
4458,
8,
17,
9,
489,
862,
26,
267,
340,
3686,
63,
20172,
63,
4653,
26,
881,
4673,
14,
4653,
8,
4653,
14,
21223,
12,
4673,
14,
7864,
63,
3203,
9,
267,
1072,
12,
485,
275,
299,
14,
10664,
342,
489,
3753,
26,
267,
340,
3686,
63,
20172,
63,
4653,
26,
881,
4673,
14,
4653,
8,
4653,
14,
21223,
12,
4673,
14,
7864,
63,
36,
3143,
9,
267,
340,
10866,
26,
881,
734,
14,
1600,
342,
489,
340,
372,
63,
1205,
26,
267,
372,
299,
14,
9913,
489,
340,
299,
14,
9913,
1137,
378,
26,
267,
870,
283,
547,
469,
16,
93,
14043,
1414,
469,
17,
5285,
908,
8,
80,
14,
9913,
12,
1414,
9,
267,
4458,
8,
80,
14,
9913,
9,
489,
372,
1072,
503,
2125,
272,
372,
2125,
819,
768,
1556,
14,
5061,
14,
2682,
765,
523,
347,
24599,
8,
277,
12,
627,
1531,
304,
272,
1414,
275,
283,
1987,
904,
779,
29942,
14,
3513,
8,
1273,
9,
367,
1680,
315,
1414,
566,
272,
372,
291,
423,
12049,
779,
1531,
467,
5218,
29,
549,
12,
3686,
63,
20172,
63,
4653,
29,
549,
9,
819,
768,
1556,
14,
5061,
14,
2682,
765,
523,
347,
17009,
8,
277,
12,
627,
1531,
304,
272,
372,
291,
423,
12049,
8,
1531,
12,
5218,
29,
797,
9,
819,
768,
1556,
14,
5061,
14,
2682,
765,
523,
347,
17009,
51,
441,
343,
590,
8,
277,
12,
627,
1531,
304,
272,
372,
291,
423,
12049,
8,
1531,
12,
5218,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
orgito/ansible
|
lib/ansible/modules/network/avi/avi_role.py
|
31
|
3395
|
#!/usr/bin/python
#
# @author: Gaurav Rastogi (grastogi@avinetworks.com)
# Eric Anderson (eanderson@avinetworks.com)
# module_check: supported
# Avi Version: 17.1.1
#
# Copyright: (c) 2017 Gaurav Rastogi, <grastogi@avinetworks.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: avi_role
author: Gaurav Rastogi (@grastogi23) <grastogi@avinetworks.com>
short_description: Module for setup of Role Avi RESTful Object
description:
- This module is used to configure Role object
- more examples at U(https://github.com/avinetworks/devops)
requirements: [ avisdk ]
version_added: "2.3"
options:
state:
description:
- The state that should be applied on the entity.
default: present
choices: ["absent", "present"]
avi_api_update_method:
description:
- Default method for object update is HTTP PUT.
- Setting to patch will override that behavior to use HTTP PATCH.
version_added: "2.5"
default: put
choices: ["put", "patch"]
avi_api_patch_op:
description:
- Patch operation to use when using avi_api_update_method as patch.
version_added: "2.5"
choices: ["add", "replace", "delete"]
name:
description:
- Name of the object.
required: true
privileges:
description:
- List of permission.
tenant_ref:
description:
- It is a reference to an object of type tenant.
url:
description:
- Avi controller URL of the object.
uuid:
description:
- Unique object identifier of the object.
extends_documentation_fragment:
- avi
'''
EXAMPLES = """
- name: Example to create Role object
avi_role:
controller: 10.10.25.42
username: admin
password: something
state: present
name: sample_role
"""
RETURN = '''
obj:
description: Role (api/role) object
returned: success, changed
type: dict
'''
from ansible.module_utils.basic import AnsibleModule
try:
from ansible.module_utils.network.avi.avi import (
avi_common_argument_spec, HAS_AVI, avi_ansible_api)
except ImportError:
HAS_AVI = False
def main():
argument_specs = dict(
state=dict(default='present',
choices=['absent', 'present']),
avi_api_update_method=dict(default='put',
choices=['put', 'patch']),
avi_api_patch_op=dict(choices=['add', 'replace', 'delete']),
name=dict(type='str', required=True),
privileges=dict(type='list',),
tenant_ref=dict(type='str',),
url=dict(type='str',),
uuid=dict(type='str',),
)
argument_specs.update(avi_common_argument_spec())
module = AnsibleModule(
argument_spec=argument_specs, supports_check_mode=True)
if not HAS_AVI:
return module.fail_json(msg=(
'Avi python API SDK (avisdk>=17.1) is not installed. '
'For more details visit https://github.com/avinetworks/sdk.'))
return avi_ansible_api(module, 'role',
set([]))
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
768,
2502,
26,
9647,
300,
1214,
820,
1810,
31114,
334,
926,
270,
31114,
32,
31808,
14,
957,
9,
199,
3,
3515,
662,
1567,
1626,
424,
834,
334,
69,
11438,
834,
32,
31808,
14,
957,
9,
199,
3,
859,
63,
1074,
26,
3748,
199,
3,
21710,
3394,
26,
5557,
14,
17,
14,
17,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
9708,
9647,
300,
1214,
820,
1810,
31114,
12,
665,
926,
270,
31114,
32,
31808,
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,
3,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
21661,
63,
3756,
199,
2502,
26,
9647,
300,
1214,
820,
1810,
31114,
8593,
926,
270,
31114,
1789,
9,
665,
926,
270,
31114,
32,
31808,
14,
957,
30,
199,
199,
3612,
63,
1802,
26,
5673,
367,
3272,
402,
18033,
21710,
14880,
1893,
6935,
199,
1802,
26,
272,
446,
961,
859,
365,
1202,
370,
7908,
18033,
909,
272,
446,
1655,
7251,
737,
738,
8,
2859,
921,
5031,
14,
957,
15,
31808,
15,
2374,
1483,
9,
199,
7538,
26,
359,
2289,
374,
6341,
1622,
199,
1023,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
1419,
26,
272,
1174,
26,
267,
1369,
26,
288,
446,
710,
1174,
626,
1077,
506,
6781,
641,
314,
4642,
14,
267,
849,
26,
3451,
267,
3415,
26,
2097,
5575,
401,
298,
1881,
937,
272,
21661,
63,
1246,
63,
873,
63,
765,
26,
267,
1369,
26,
288,
446,
3758,
1083,
367,
909,
1678,
365,
3101,
18337,
14,
288,
446,
13510,
370,
3371,
911,
4278,
626,
5953,
370,
675,
3101,
510,
8078,
14,
267,
1015,
63,
3270,
26,
298,
18,
14,
21,
2,
267,
849,
26,
5324,
267,
3415,
26,
2097,
524,
401,
298,
2068,
937,
272,
21661,
63,
1246,
63,
2068,
63,
411,
26,
267,
1369,
26,
288,
446,
19292,
3439,
370,
675,
1380,
1808,
21661,
63,
1246,
63,
873,
63,
765,
465,
3371,
14,
267,
1015,
63,
3270,
26,
298,
18,
14,
21,
2,
267,
3415,
26,
2097,
525,
401,
298,
1814,
401,
298,
1807,
937,
272,
536,
26,
267,
1369,
26,
288,
446,
2812,
402,
314,
909,
14,
267,
1415,
26,
2549,
272,
20001,
26,
267,
1369,
26,
288,
446,
3820,
402,
4983,
14,
272,
8261,
63,
1121,
26,
267,
1369,
26,
288,
446,
2779,
365,
282,
3659,
370,
376,
909,
402,
730,
8261,
14,
272,
1166,
26,
267,
1369,
26,
288,
446,
21710,
7614,
2851,
402,
314,
909,
14,
272,
5377,
26,
267,
1369,
26,
288,
446,
18276,
909,
5148,
402,
314,
909,
14,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
21661,
199,
2344,
199,
199,
8918,
275,
408,
199,
13,
536,
26,
5679,
370,
1218,
18033,
909,
523,
21661,
63,
3756,
26,
272,
7614,
26,
1616,
14,
709,
14,
821,
14,
2260,
272,
3434,
26,
4628,
272,
2505,
26,
6020,
272,
1174,
26,
3451,
272,
536,
26,
2690,
63,
3756,
199,
624,
199,
199,
9677,
275,
1449,
199,
1113,
26,
272,
1369,
26,
18033,
334,
1246,
15,
3756,
9,
909,
272,
2138,
26,
3182,
12,
2896,
272,
730,
26,
1211,
199,
2344,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
893,
26,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
7194,
14,
7194,
492,
334,
267,
21661,
63,
2330,
63,
2094,
63,
1650,
12,
7509,
63,
32636,
12,
21661,
63,
4853,
63,
1246,
9,
199,
2590,
3545,
26,
272,
7509,
63,
32636,
275,
756,
421,
199,
318,
2446,
837,
272,
1423,
63,
7273,
275,
1211,
8,
267,
1174,
29,
807,
8,
885,
534,
1881,
297,
673,
3415,
2968,
5575,
297,
283,
1881,
3815,
267,
21661,
63,
1246,
63,
873,
63,
765,
29,
807,
8,
885,
534,
524,
297,
3521,
3415,
2968,
524,
297,
283,
2068,
3815,
267,
21661,
63,
1246,
63,
2068,
63,
411,
29,
807,
8,
4577,
2968,
525,
297,
283,
1814,
297,
283,
1807,
3815,
267,
536,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
20001,
29,
807,
8,
466,
534,
513,
5529,
267,
8261,
63,
1121,
29,
807,
8,
466,
534,
495,
5529,
267,
1166,
29,
807,
8,
466,
534,
495,
5529,
267,
5377,
29,
807,
8,
466,
534,
495,
5529,
272,
776,
272,
1423,
63,
7273,
14,
873,
8,
7194,
63,
2330,
63,
2094,
63,
1650,
1012,
272,
859,
275,
6953,
8,
267,
1423,
63,
1650,
29,
2094,
63,
7273,
12,
5171,
63,
1074,
63,
632,
29,
549,
9,
272,
340,
440,
7509,
63,
32636,
26,
267,
372,
859,
14,
1633,
63,
1001,
8,
1328,
2687,
288,
283,
33,
433,
2366,
3261,
15610,
334,
1214,
374,
6341,
8119,
1196,
14,
17,
9,
365,
440,
4903,
14,
283,
288,
283,
1858,
1655,
2436,
5684,
4178,
921,
5031,
14,
957,
15,
31808,
15,
9277,
12459,
272,
372,
21661,
63,
4853,
63,
1246,
8,
578,
12,
283,
3756,
297,
2574,
663,
26064,
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
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
768,
2502,
26,
9647,
300,
1214,
820,
1810,
31114,
334,
926,
270,
31114,
32,
31808,
14,
957,
9,
199,
3,
3515,
662,
1567,
1626,
424,
834,
334,
69,
11438,
834,
32,
31808,
14,
957,
9,
199,
3,
859,
63,
1074,
26,
3748,
199,
3,
21710,
3394,
26,
5557,
14,
17,
14,
17,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
9708,
9647,
300,
1214,
820,
1810,
31114,
12,
665,
926,
270,
31114,
32,
31808,
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,
3,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
21661,
63,
3756,
199,
2502,
26,
9647,
300,
1214,
820,
1810,
31114,
8593,
926,
270,
31114,
1789,
9,
665,
926,
270,
31114,
32,
31808,
14,
957,
30,
199,
199,
3612,
63,
1802,
26,
5673,
367,
3272,
402,
18033,
21710,
14880,
1893,
6935,
199,
1802,
26,
272,
446,
961,
859,
365,
1202,
370,
7908,
18033,
909,
272,
446,
1655,
7251,
737,
738,
8,
2859,
921,
5031,
14,
957,
15,
31808,
15,
2374,
1483,
9,
199,
7538,
26,
359,
2289,
374,
6341,
1622,
199,
1023,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
1419,
26,
272,
1174,
26,
267,
1369,
26,
288,
446,
710,
1174,
626,
1077,
506,
6781,
641,
314,
4642,
14,
267,
849,
26,
3451,
267,
3415,
26,
2097,
5575,
401,
298,
1881,
937,
272,
21661,
63,
1246,
63,
873,
63,
765,
26,
267,
1369,
26,
288,
446,
3758,
1083,
367,
909,
1678,
365,
3101,
18337,
14,
288,
446,
13510,
370,
3371,
911,
4278,
626,
5953,
370,
675,
3101,
510,
8078,
14,
267,
1015,
63,
3270,
26,
298,
18,
14,
21,
2,
267,
849,
26,
5324,
267,
3415,
26,
2097,
524,
401,
298,
2068,
937,
272,
21661,
63,
1246,
63,
2068,
63,
411,
26,
267,
1369,
26,
288,
446,
19292,
3439,
370,
675,
1380,
1808,
21661,
63,
1246,
63,
873,
63,
765,
465,
3371,
14,
267,
1015,
63,
3270,
26,
298,
18,
14,
21,
2,
267,
3415,
26,
2097,
525,
401,
298,
1814,
401,
298,
1807,
937,
272,
536,
26,
267,
1369,
26,
288,
446,
2812,
402,
314,
909,
14,
267,
1415,
26,
2549,
272,
20001,
26,
267,
1369,
26,
288,
446,
3820,
402,
4983,
14,
272,
8261,
63,
1121,
26,
267,
1369,
26,
288,
446,
2779,
365,
282,
3659,
370,
376,
909,
402,
730,
8261,
14,
272,
1166,
26,
267,
1369,
26,
288,
446,
21710,
7614,
2851,
402,
314,
909,
14,
272,
5377,
26,
267,
1369,
26,
288,
446,
18276,
909,
5148,
402,
314,
909,
14,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
21661,
199,
2344,
199,
199,
8918,
275,
408,
199,
13,
536,
26,
5679,
370,
1218,
18033,
909,
523,
21661,
63,
3756,
26,
272,
7614,
26,
1616,
14,
709,
14,
821,
14,
2260,
272,
3434,
26,
4628,
272,
2505,
26,
6020,
272,
1174,
26,
3451,
272,
536,
26,
2690,
63,
3756,
199,
624,
199,
199,
9677,
275,
1449,
199,
1113,
26,
272,
1369,
26,
18033,
334,
1246,
15,
3756,
9,
909,
272,
2138,
26,
3182,
12,
2896,
272,
730,
26,
1211,
199,
2344,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
893,
26,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
7194,
14,
7194,
492,
334,
267,
21661,
63,
2330,
63,
2094,
63,
1650,
12,
7509,
63,
32636,
12,
21661,
63,
4853,
63,
1246,
9,
199,
2590,
3545,
26,
272,
7509,
63,
32636,
275,
756,
421,
199,
318,
2446,
837,
272,
1423,
63,
7273,
275,
1211,
8,
267,
1174,
29,
807,
8,
885,
534,
1881,
297,
673,
3415,
2968,
5575,
297,
283,
1881,
3815,
267,
21661,
63,
1246,
63,
873,
63,
765,
29,
807,
8,
885,
534,
524,
297,
3521,
3415,
2968,
524,
297,
283,
2068,
3815,
267,
21661,
63,
1246,
63,
2068,
63,
411,
29,
807,
8,
4577,
2968,
525,
297,
283,
1814,
297,
283,
1807,
3815,
267,
536,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
20001,
29,
807,
8,
466,
534,
513,
5529,
267,
8261,
63,
1121,
29,
807,
8,
466,
534,
495,
5529,
267,
1166,
29,
807,
8,
466,
534,
495,
5529,
267,
5377,
29,
807,
8,
466,
534,
495,
5529,
272,
776,
272,
1423,
63,
7273,
14,
873,
8,
7194,
63,
2330,
63,
2094,
63,
1650,
1012,
272,
859,
275,
6953,
8,
267,
1423,
63,
1650,
29,
2094,
63,
7273,
12,
5171,
63,
1074,
63,
632,
29,
549,
9,
272,
340,
440,
7509,
63,
32636,
26,
267,
372,
859,
14,
1633,
63,
1001,
8,
1328,
2687,
288,
283,
33,
433,
2366,
3261,
15610,
334,
1214,
374,
6341,
8119,
1196,
14,
17,
9,
365,
440,
4903,
14,
283,
288,
283,
1858,
1655,
2436,
5684,
4178,
921,
5031,
14,
957,
15,
31808,
15,
9277,
12459,
272,
372,
21661,
63,
4853,
63,
1246,
8,
578,
12,
283,
3756,
297,
2574,
663,
26064,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
KempfCreative/KempfCreative.github.io
|
node_modules/node-gyp/gyp/pylib/gyp/common_test.py
|
2542
|
1970
|
#!/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.
"""Unit tests for the common.py file."""
import gyp.common
import unittest
import sys
class TestTopologicallySorted(unittest.TestCase):
def test_Valid(self):
"""Test that sorting works on a valid graph with one possible order."""
graph = {
'a': ['b', 'c'],
'b': [],
'c': ['d'],
'd': ['b'],
}
def GetEdge(node):
return tuple(graph[node])
self.assertEqual(
gyp.common.TopologicallySorted(graph.keys(), GetEdge),
['a', 'c', 'd', 'b'])
def test_Cycle(self):
"""Test that an exception is thrown on a cyclic graph."""
graph = {
'a': ['b'],
'b': ['c'],
'c': ['d'],
'd': ['a'],
}
def GetEdge(node):
return tuple(graph[node])
self.assertRaises(
gyp.common.CycleError, gyp.common.TopologicallySorted,
graph.keys(), GetEdge)
class TestGetFlavor(unittest.TestCase):
"""Test that gyp.common.GetFlavor works as intended"""
original_platform = ''
def setUp(self):
self.original_platform = sys.platform
def tearDown(self):
sys.platform = self.original_platform
def assertFlavor(self, expected, argument, param):
sys.platform = argument
self.assertEqual(expected, gyp.common.GetFlavor(param))
def test_platform_default(self):
self.assertFlavor('freebsd', 'freebsd9' , {})
self.assertFlavor('freebsd', 'freebsd10', {})
self.assertFlavor('openbsd', 'openbsd5' , {})
self.assertFlavor('solaris', 'sunos5' , {});
self.assertFlavor('solaris', 'sunos' , {});
self.assertFlavor('linux' , 'linux2' , {});
self.assertFlavor('linux' , 'linux3' , {});
def test_param(self):
self.assertFlavor('foobar', 'linux2' , {'flavor': 'foobar'})
if __name__ == '__main__':
unittest.main()
|
mit
|
[
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,
5072,
2295,
367,
314,
2863,
14,
647,
570,
1041,
199,
199,
646,
4902,
14,
2330,
199,
646,
2882,
199,
646,
984,
421,
199,
533,
1379,
6105,
79,
793,
7288,
22861,
8,
2796,
14,
1746,
304,
523,
347,
511,
63,
3490,
8,
277,
304,
272,
408,
774,
626,
13351,
5419,
641,
282,
1686,
3343,
543,
1373,
3962,
1865,
1041,
272,
3343,
275,
469,
267,
283,
65,
356,
788,
66,
297,
283,
67,
995,
267,
283,
66,
356,
990,
267,
283,
67,
356,
788,
68,
995,
267,
283,
68,
356,
788,
66,
995,
267,
789,
272,
347,
2372,
12886,
8,
932,
304,
489,
372,
2008,
8,
2180,
59,
932,
566,
272,
291,
14,
629,
8,
489,
4902,
14,
2330,
14,
6105,
79,
793,
7288,
22861,
8,
2180,
14,
1612,
1062,
2372,
12886,
395,
489,
788,
65,
297,
283,
67,
297,
283,
68,
297,
283,
66,
1105,
819,
347,
511,
63,
15302,
8,
277,
304,
272,
408,
774,
626,
376,
1919,
365,
14031,
641,
282,
32637,
3343,
1041,
272,
3343,
275,
469,
267,
283,
65,
356,
788,
66,
995,
267,
283,
66,
356,
788,
67,
995,
267,
283,
67,
356,
788,
68,
995,
267,
283,
68,
356,
788,
65,
995,
267,
789,
272,
347,
2372,
12886,
8,
932,
304,
489,
372,
2008,
8,
2180,
59,
932,
566,
272,
291,
14,
1855,
8,
489,
4902,
14,
2330,
14,
15302,
547,
12,
4902,
14,
2330,
14,
6105,
79,
793,
7288,
22861,
12,
489,
3343,
14,
1612,
1062,
2372,
12886,
9,
421,
199,
533,
1379,
1002,
16739,
8,
2796,
14,
1746,
304,
523,
408,
774,
626,
4902,
14,
2330,
14,
1002,
16739,
5419,
465,
11619,
624,
523,
3379,
63,
3246,
275,
2125,
819,
347,
3613,
8,
277,
304,
272,
291,
14,
5043,
63,
3246,
275,
984,
14,
3246,
819,
347,
6766,
8,
277,
304,
272,
984,
14,
3246,
275,
291,
14,
5043,
63,
3246,
819,
347,
702,
16739,
8,
277,
12,
1420,
12,
1423,
12,
1215,
304,
272,
984,
14,
3246,
275,
1423,
272,
291,
14,
629,
8,
2062,
12,
4902,
14,
2330,
14,
1002,
16739,
8,
635,
430,
819,
347,
511,
63,
3246,
63,
885,
8,
277,
304,
272,
291,
14,
479,
16739,
360,
29629,
297,
283,
29629,
25,
7,
2360,
5009,
272,
291,
14,
479,
16739,
360,
29629,
297,
283,
29629,
709,
297,
5009,
272,
291,
14,
479,
16739,
360,
1490,
15746,
297,
283,
1490,
15746,
21,
7,
2360,
5009,
272,
291,
14,
479,
16739,
360,
7873,
4663,
297,
283,
11846,
736,
21,
7,
257,
2360,
1052,
2736,
272,
291,
14,
479,
16739,
360,
7873,
4663,
297,
283,
11846,
736,
7,
259,
2360,
1052,
2736,
272,
291,
14,
479,
16739,
360,
5135,
7,
221,
2360,
283,
5135,
18,
7,
257,
2360,
1052,
2736,
272,
291,
14,
479,
16739,
360,
5135,
7,
221,
2360,
283,
5135,
19,
7,
257,
2360,
1052,
2736,
819,
347,
511,
63,
635,
8,
277,
304,
272,
291,
14,
479,
16739,
360,
9664,
297,
283,
5135,
18,
7,
2360,
791,
6081,
356,
283,
9664,
3071,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
5072,
2295,
367,
314,
2863,
14,
647,
570,
1041,
199,
199,
646,
4902,
14,
2330,
199,
646,
2882,
199,
646,
984,
421,
199,
533,
1379,
6105,
79,
793,
7288,
22861,
8,
2796,
14,
1746,
304,
523,
347,
511,
63,
3490,
8,
277,
304,
272,
408,
774,
626,
13351,
5419,
641,
282,
1686,
3343,
543,
1373,
3962,
1865,
1041,
272,
3343,
275,
469,
267,
283,
65,
356,
788,
66,
297,
283,
67,
995,
267,
283,
66,
356,
990,
267,
283,
67,
356,
788,
68,
995,
267,
283,
68,
356,
788,
66,
995,
267,
789,
272,
347,
2372,
12886,
8,
932,
304,
489,
372,
2008,
8,
2180,
59,
932,
566,
272,
291,
14,
629,
8,
489,
4902,
14,
2330,
14,
6105,
79,
793,
7288,
22861,
8,
2180,
14,
1612,
1062,
2372,
12886,
395,
489,
788,
65,
297,
283,
67,
297,
283,
68,
297,
283,
66,
1105,
819,
347,
511,
63,
15302,
8,
277,
304,
272,
408,
774,
626,
376,
1919,
365,
14031,
641,
282,
32637,
3343,
1041,
272,
3343,
275,
469,
267,
283,
65,
356,
788,
66,
995,
267,
283,
66,
356,
788,
67,
995,
267,
283,
67,
356,
788,
68,
995,
267,
283,
68,
356,
788,
65,
995,
267,
789,
272,
347,
2372,
12886,
8,
932,
304,
489,
372,
2008,
8,
2180,
59,
932,
566,
272,
291,
14,
1855,
8,
489,
4902,
14,
2330,
14,
15302,
547,
12,
4902,
14,
2330,
14,
6105,
79,
793,
7288,
22861,
12,
489,
3343,
14,
1612,
1062,
2372,
12886,
9,
421,
199,
533,
1379,
1002,
16739,
8,
2796,
14,
1746,
304,
523,
408,
774,
626,
4902,
14,
2330,
14,
1002,
16739,
5419,
465,
11619,
624,
523,
3379,
63,
3246,
275,
2125,
819,
347,
3613,
8,
277,
304,
272,
291,
14,
5043,
63,
3246,
275,
984,
14,
3246,
819,
347,
6766,
8,
277,
304,
272,
984,
14,
3246,
275,
291,
14,
5043,
63,
3246,
819,
347,
702,
16739,
8,
277,
12,
1420,
12,
1423,
12,
1215,
304,
272,
984,
14,
3246,
275,
1423,
272,
291,
14,
629,
8,
2062,
12,
4902,
14,
2330,
14,
1002,
16739,
8,
635,
430,
819,
347,
511,
63,
3246,
63,
885,
8,
277,
304,
272,
291,
14,
479,
16739,
360,
29629,
297,
283,
29629,
25,
7,
2360,
5009,
272,
291,
14,
479,
16739,
360,
29629,
297,
283,
29629,
709,
297,
5009,
272,
291,
14,
479,
16739,
360,
1490,
15746,
297,
283,
1490,
15746,
21,
7,
2360,
5009,
272,
291,
14,
479,
16739,
360,
7873,
4663,
297,
283,
11846,
736,
21,
7,
257,
2360,
1052,
2736,
272,
291,
14,
479,
16739,
360,
7873,
4663,
297,
283,
11846,
736,
7,
259,
2360,
1052,
2736,
272,
291,
14,
479,
16739,
360,
5135,
7,
221,
2360,
283,
5135,
18,
7,
257,
2360,
1052,
2736,
272,
291,
14,
479,
16739,
360,
5135,
7,
221,
2360,
283,
5135,
19,
7,
257,
2360,
1052,
2736,
819,
347,
511,
63,
635,
8,
277,
304,
272,
291,
14,
479,
16739,
360,
9664,
297,
283,
5135,
18,
7,
2360,
791,
6081,
356,
283,
9664,
3071,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
pdr/django-pipeline
|
pipeline/templatetags/compressed.py
|
11
|
4139
|
try:
from staticfiles.storage import staticfiles_storage
except ImportError:
from django.contrib.staticfiles.storage import staticfiles_storage # noqa
from django import template
from django.template.loader import render_to_string
from pipeline.conf import settings
from pipeline.packager import Packager, PackageNotFound
from pipeline.utils import guess_type
register = template.Library()
class CompressedCSSNode(template.Node):
def __init__(self, name):
self.name = name
def render(self, context):
package_name = template.Variable(self.name).resolve(context)
package = settings.PIPELINE_CSS.get(package_name, {})
if package:
package = {package_name: package}
self.packager = Packager(css_packages=package, js_packages={})
try:
package = self.packager.package_for('css', package_name)
except PackageNotFound:
return '' # fail silently, do not return anything if an invalid group is specified
if settings.PIPELINE:
return self.render_css(package, package.output_filename)
else:
paths = self.packager.compile(package.paths)
return self.render_individual(package, paths)
def render_css(self, package, path):
template_name = package.template_name or "pipeline/css.html"
context = package.extra_context
context.update({
'type': guess_type(path, 'text/css'),
'url': staticfiles_storage.url(path)
})
return render_to_string(template_name, context)
def render_individual(self, package, paths):
tags = [self.render_css(package, path) for path in paths]
return '\n'.join(tags)
class CompressedJSNode(template.Node):
def __init__(self, name):
self.name = name
def render(self, context):
package_name = template.Variable(self.name).resolve(context)
package = settings.PIPELINE_JS.get(package_name, {})
if package:
package = {package_name: package}
self.packager = Packager(css_packages={}, js_packages=package)
try:
package = self.packager.package_for('js', package_name)
except PackageNotFound:
return '' # fail silently, do not return anything if an invalid group is specified
if settings.PIPELINE:
return self.render_js(package, package.output_filename)
else:
paths = self.packager.compile(package.paths)
templates = self.packager.pack_templates(package)
return self.render_individual(package, paths, templates)
def render_js(self, package, path):
template_name = package.template_name or "pipeline/js.html"
context = package.extra_context
context.update({
'type': guess_type(path, 'text/javascript'),
'url': staticfiles_storage.url(path)
})
return render_to_string(template_name, context)
def render_inline(self, package, js):
context = package.extra_context
context.update({
'source': js
})
return render_to_string("pipeline/inline_js.html", context)
def render_individual(self, package, paths, templates=None):
tags = [self.render_js(package, js) for js in paths]
if templates:
tags.append(self.render_inline(package, templates))
return '\n'.join(tags)
def compressed_css(parser, token):
try:
tag_name, name = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError, '%r requires exactly one argument: the name of a group in the PIPELINE_CSS setting' % token.split_contents()[0]
return CompressedCSSNode(name)
compressed_css = register.tag(compressed_css)
def compressed_js(parser, token):
try:
tag_name, name = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError, '%r requires exactly one argument: the name of a group in the PIPELINE_JS setting' % token.split_contents()[0]
return CompressedJSNode(name)
compressed_js = register.tag(compressed_js)
|
mit
|
[
893,
26,
272,
687,
2955,
1725,
14,
3494,
492,
2955,
1725,
63,
3494,
199,
2590,
3545,
26,
272,
687,
1639,
14,
2828,
14,
18373,
14,
3494,
492,
2955,
1725,
63,
3494,
327,
8151,
199,
199,
504,
1639,
492,
1978,
199,
504,
1639,
14,
1160,
14,
3422,
492,
3795,
63,
475,
63,
875,
199,
199,
504,
7679,
14,
2190,
492,
2202,
199,
504,
7679,
14,
1389,
1456,
492,
9954,
1456,
12,
15665,
4667,
199,
504,
7679,
14,
1208,
492,
9519,
63,
466,
199,
199,
2683,
275,
1978,
14,
7424,
342,
421,
199,
533,
3599,
5111,
14391,
1716,
8,
1160,
14,
1716,
304,
272,
347,
636,
826,
721,
277,
12,
536,
304,
267,
291,
14,
354,
275,
536,
339,
347,
3795,
8,
277,
12,
1067,
304,
267,
2559,
63,
354,
275,
1978,
14,
2773,
8,
277,
14,
354,
680,
6983,
8,
1100,
9,
267,
2559,
275,
2202,
14,
6089,
6174,
63,
14391,
14,
362,
8,
2491,
63,
354,
12,
5009,
267,
340,
2559,
26,
288,
2559,
275,
469,
2491,
63,
354,
26,
2559,
93,
267,
291,
14,
1389,
1456,
275,
9954,
1456,
8,
3919,
63,
5154,
29,
2491,
12,
8586,
63,
5154,
21146,
398,
862,
26,
288,
2559,
275,
291,
14,
1389,
1456,
14,
2491,
63,
509,
360,
3919,
297,
2559,
63,
354,
9,
267,
871,
15665,
4667,
26,
288,
372,
2125,
221,
327,
2449,
18030,
12,
886,
440,
372,
7003,
340,
376,
3866,
1572,
365,
2013,
398,
340,
2202,
14,
6089,
6174,
26,
288,
372,
291,
14,
3352,
63,
3919,
8,
2491,
12,
2559,
14,
1199,
63,
1501,
9,
267,
587,
26,
288,
3792,
275,
291,
14,
1389,
1456,
14,
2014,
8,
2491,
14,
3771,
9,
288,
372,
291,
14,
3352,
63,
23001,
8,
2491,
12,
3792,
9,
339,
347,
3795,
63,
3919,
8,
277,
12,
2559,
12,
931,
304,
267,
1978,
63,
354,
275,
2559,
14,
1160,
63,
354,
503,
298,
7379,
15,
3919,
14,
1360,
2,
267,
1067,
275,
2559,
14,
2911,
63,
1100,
267,
1067,
14,
873,
2561,
288,
283,
466,
356,
9519,
63,
466,
8,
515,
12,
283,
505,
15,
3919,
659,
288,
283,
633,
356,
2955,
1725,
63,
3494,
14,
633,
8,
515,
9,
267,
3828,
267,
372,
3795,
63,
475,
63,
875,
8,
1160,
63,
354,
12,
1067,
9,
339,
347,
3795,
63,
23001,
8,
277,
12,
2559,
12,
3792,
304,
267,
3762,
275,
359,
277,
14,
3352,
63,
3919,
8,
2491,
12,
931,
9,
367,
931,
315,
3792,
61,
267,
372,
1557,
78,
1370,
904,
8,
2969,
9,
421,
199,
533,
3599,
5111,
11378,
1716,
8,
1160,
14,
1716,
304,
272,
347,
636,
826,
721,
277,
12,
536,
304,
267,
291,
14,
354,
275,
536,
339,
347,
3795,
8,
277,
12,
1067,
304,
267,
2559,
63,
354,
275,
1978,
14,
2773,
8,
277,
14,
354,
680,
6983,
8,
1100,
9,
267,
2559,
275,
2202,
14,
6089,
6174,
63,
11378,
14,
362,
8,
2491,
63,
354,
12,
5009,
267,
340,
2559,
26,
288,
2559,
275,
469,
2491,
63,
354,
26,
2559,
93,
267,
291,
14,
1389,
1456,
275,
9954,
1456,
8,
3919,
63,
5154,
10324,
8586,
63,
5154,
29,
2491,
9,
398,
862,
26,
288,
2559,
275,
291,
14,
1389,
1456,
14,
2491,
63,
509,
360,
3596,
297,
2559,
63,
354,
9,
267,
871,
15665,
4667,
26,
288,
372,
2125,
221,
327,
2449,
18030,
12,
886,
440,
372,
7003,
340,
376,
3866,
1572,
365,
2013,
398,
340,
2202,
14,
6089,
6174,
26,
288,
372,
291,
14,
3352,
63,
3596,
8,
2491,
12,
2559,
14,
1199,
63,
1501,
9,
267,
587,
26,
288,
3792,
275,
291,
14,
1389,
1456,
14,
2014,
8,
2491,
14,
3771,
9,
288,
7009,
275,
291,
14,
1389,
1456,
14,
1389,
63,
5876,
8,
2491,
9,
288,
372,
291,
14,
3352,
63,
23001,
8,
2491,
12,
3792,
12,
7009,
9,
339,
347,
3795,
63,
3596,
8,
277,
12,
2559,
12,
931,
304,
267,
1978,
63,
354,
275,
2559,
14,
1160,
63,
354,
503,
298,
7379,
15,
3596,
14,
1360,
2,
267,
1067,
275,
2559,
14,
2911,
63,
1100,
267,
1067,
14,
873,
2561,
288,
283,
466,
356,
9519,
63,
466,
8,
515,
12,
283,
505,
15,
9554,
659,
288,
283,
633,
356,
2955,
1725,
63,
3494,
14,
633,
8,
515,
9,
267,
3828,
267,
372,
3795,
63,
475,
63,
875,
8,
1160,
63,
354,
12,
1067,
9,
339,
347,
3795,
63,
6460,
8,
277,
12,
2559,
12,
8586,
304,
267,
1067,
275,
2559,
14,
2911,
63,
1100,
267,
1067,
14,
873,
2561,
288,
283,
1365,
356,
8586,
267,
3828,
267,
372,
3795,
63,
475,
63,
875,
480,
7379,
15,
6460,
63,
3596,
14,
1360,
401,
1067,
9,
339,
347,
3795,
63,
23001,
8,
277,
12,
2559,
12,
3792,
12,
7009,
29,
403,
304,
267,
3762,
275,
359,
277,
14,
3352,
63,
3596,
8,
2491,
12,
8586,
9,
367,
8586,
315,
3792,
61,
267,
340,
7009,
26,
288,
3762,
14,
740,
8,
277,
14,
3352,
63,
6460,
8,
2491,
12,
7009,
430,
267,
372,
1557,
78,
1370,
904,
8,
2969,
9,
421,
199,
318,
12335,
63,
3919,
8,
2087,
12,
1526,
304,
272,
862,
26,
267,
1947,
63,
354,
12,
536,
275,
1526,
14,
1294,
63,
4407,
342,
272,
871,
1722,
26,
267,
746,
1978,
14,
20837,
12,
1543,
82,
5074,
8840,
1373,
1423,
26,
314,
536,
402,
282,
1572,
315,
314,
22773,
6174,
63,
14391,
4260,
7,
450,
1526,
14,
1294,
63,
4407,
3430,
16,
61,
272,
372,
3599,
5111,
14391,
1716,
8,
354,
9,
199,
10895,
63,
3919,
275,
2274,
14,
1450,
8,
10895,
63,
3919,
9,
421,
199,
318,
12335,
63,
3596,
8,
2087,
12,
1526,
304,
272,
862,
26,
267,
1947,
63,
354,
12,
536,
275,
1526,
14,
1294,
63,
4407,
342,
272,
871,
1722,
26,
267,
746,
1978,
14,
20837,
12,
1543,
82,
5074,
8840,
1373,
1423,
26,
314,
536,
402,
282,
1572,
315,
314,
22773,
6174,
63,
11378,
4260,
7,
450,
1526,
14,
1294,
63,
4407,
3430,
16,
61,
272,
372,
3599,
5111,
11378,
1716,
8,
354,
9,
199,
10895,
63,
3596,
275,
2274,
14,
1450,
8,
10895,
63,
3596,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
26,
272,
687,
2955,
1725,
14,
3494,
492,
2955,
1725,
63,
3494,
199,
2590,
3545,
26,
272,
687,
1639,
14,
2828,
14,
18373,
14,
3494,
492,
2955,
1725,
63,
3494,
327,
8151,
199,
199,
504,
1639,
492,
1978,
199,
504,
1639,
14,
1160,
14,
3422,
492,
3795,
63,
475,
63,
875,
199,
199,
504,
7679,
14,
2190,
492,
2202,
199,
504,
7679,
14,
1389,
1456,
492,
9954,
1456,
12,
15665,
4667,
199,
504,
7679,
14,
1208,
492,
9519,
63,
466,
199,
199,
2683,
275,
1978,
14,
7424,
342,
421,
199,
533,
3599,
5111,
14391,
1716,
8,
1160,
14,
1716,
304,
272,
347,
636,
826,
721,
277,
12,
536,
304,
267,
291,
14,
354,
275,
536,
339,
347,
3795,
8,
277,
12,
1067,
304,
267,
2559,
63,
354,
275,
1978,
14,
2773,
8,
277,
14,
354,
680,
6983,
8,
1100,
9,
267,
2559,
275,
2202,
14,
6089,
6174,
63,
14391,
14,
362,
8,
2491,
63,
354,
12,
5009,
267,
340,
2559,
26,
288,
2559,
275,
469,
2491,
63,
354,
26,
2559,
93,
267,
291,
14,
1389,
1456,
275,
9954,
1456,
8,
3919,
63,
5154,
29,
2491,
12,
8586,
63,
5154,
21146,
398,
862,
26,
288,
2559,
275,
291,
14,
1389,
1456,
14,
2491,
63,
509,
360,
3919,
297,
2559,
63,
354,
9,
267,
871,
15665,
4667,
26,
288,
372,
2125,
221,
327,
2449,
18030,
12,
886,
440,
372,
7003,
340,
376,
3866,
1572,
365,
2013,
398,
340,
2202,
14,
6089,
6174,
26,
288,
372,
291,
14,
3352,
63,
3919,
8,
2491,
12,
2559,
14,
1199,
63,
1501,
9,
267,
587,
26,
288,
3792,
275,
291,
14,
1389,
1456,
14,
2014,
8,
2491,
14,
3771,
9,
288,
372,
291,
14,
3352,
63,
23001,
8,
2491,
12,
3792,
9,
339,
347,
3795,
63,
3919,
8,
277,
12,
2559,
12,
931,
304,
267,
1978,
63,
354,
275,
2559,
14,
1160,
63,
354,
503,
298,
7379,
15,
3919,
14,
1360,
2,
267,
1067,
275,
2559,
14,
2911,
63,
1100,
267,
1067,
14,
873,
2561,
288,
283,
466,
356,
9519,
63,
466,
8,
515,
12,
283,
505,
15,
3919,
659,
288,
283,
633,
356,
2955,
1725,
63,
3494,
14,
633,
8,
515,
9,
267,
3828,
267,
372,
3795,
63,
475,
63,
875,
8,
1160,
63,
354,
12,
1067,
9,
339,
347,
3795,
63,
23001,
8,
277,
12,
2559,
12,
3792,
304,
267,
3762,
275,
359,
277,
14,
3352,
63,
3919,
8,
2491,
12,
931,
9,
367,
931,
315,
3792,
61,
267,
372,
1557,
78,
1370,
904,
8,
2969,
9,
421,
199,
533,
3599,
5111,
11378,
1716,
8,
1160,
14,
1716,
304,
272,
347,
636,
826,
721,
277,
12,
536,
304,
267,
291,
14,
354,
275,
536,
339,
347,
3795,
8,
277,
12,
1067,
304,
267,
2559,
63,
354,
275,
1978,
14,
2773,
8,
277,
14,
354,
680,
6983,
8,
1100,
9,
267,
2559,
275,
2202,
14,
6089,
6174,
63,
11378,
14,
362,
8,
2491,
63,
354,
12,
5009,
267,
340,
2559,
26,
288,
2559,
275,
469,
2491,
63,
354,
26,
2559,
93,
267,
291,
14,
1389,
1456,
275,
9954,
1456,
8,
3919,
63,
5154,
10324,
8586,
63,
5154,
29,
2491,
9,
398,
862,
26,
288,
2559,
275,
291,
14,
1389,
1456,
14,
2491,
63,
509,
360,
3596,
297,
2559,
63,
354,
9,
267,
871,
15665,
4667,
26,
288,
372,
2125,
221,
327,
2449,
18030,
12,
886,
440,
372,
7003,
340,
376,
3866,
1572,
365,
2013,
398,
340,
2202,
14,
6089,
6174,
26,
288,
372,
291,
14,
3352,
63,
3596,
8,
2491,
12,
2559,
14,
1199,
63,
1501,
9,
267,
587,
26,
288,
3792,
275,
291,
14,
1389,
1456,
14,
2014,
8,
2491,
14,
3771,
9,
288,
7009,
275,
291,
14,
1389,
1456,
14,
1389,
63,
5876,
8,
2491,
9,
288,
372,
291,
14,
3352,
63,
23001,
8,
2491,
12,
3792,
12,
7009,
9,
339,
347,
3795,
63,
3596,
8,
277,
12,
2559,
12,
931,
304,
267,
1978,
63,
354,
275,
2559,
14,
1160,
63,
354,
503,
298,
7379,
15,
3596,
14,
1360,
2,
267,
1067,
275,
2559,
14,
2911,
63,
1100,
267,
1067,
14,
873,
2561,
288,
283,
466,
356,
9519,
63,
466,
8,
515,
12,
283,
505,
15,
9554,
659,
288,
283,
633,
356,
2955,
1725,
63,
3494,
14,
633,
8,
515,
9,
267,
3828,
267,
372,
3795,
63,
475,
63,
875,
8,
1160,
63,
354,
12,
1067,
9,
339,
347,
3795,
63,
6460,
8,
277,
12,
2559,
12,
8586,
304,
267,
1067,
275,
2559,
14,
2911,
63,
1100,
267,
1067,
14,
873,
2561,
288,
283,
1365,
356,
8586,
267,
3828,
267,
372,
3795,
63,
475,
63,
875,
480,
7379,
15,
6460,
63,
3596,
14,
1360,
401,
1067,
9,
339,
347,
3795,
63,
23001,
8,
277,
12,
2559,
12,
3792,
12,
7009,
29,
403,
304,
267,
3762,
275,
359,
277,
14,
3352,
63,
3596,
8,
2491,
12,
8586,
9,
367,
8586,
315,
3792,
61,
267,
340,
7009,
26,
288,
3762,
14,
740,
8,
277,
14,
3352,
63,
6460,
8,
2491,
12,
7009,
430,
267,
372,
1557,
78,
1370,
904,
8,
2969,
9,
421,
199,
318,
12335,
63,
3919,
8,
2087,
12,
1526,
304,
272,
862,
26,
267,
1947,
63,
354,
12,
536,
275,
1526,
14,
1294,
63,
4407,
342,
272,
871,
1722,
26,
267,
746,
1978,
14,
20837,
12,
1543,
82,
5074,
8840,
1373,
1423,
26,
314,
536,
402,
282,
1572,
315,
314,
22773,
6174,
63,
14391,
4260,
7,
450,
1526,
14,
1294,
63,
4407,
3430,
16,
61,
272,
372,
3599,
5111,
14391,
1716,
8,
354,
9,
199,
10895,
63,
3919,
275,
2274,
14,
1450,
8,
10895,
63,
3919,
9,
421,
199,
318,
12335,
63,
3596,
8,
2087,
12,
1526,
304,
272,
862,
26,
267,
1947,
63,
354,
12,
536,
275,
1526,
14,
1294,
63,
4407,
342,
272,
871,
1722,
26,
267,
746,
1978,
14,
20837,
12,
1543,
82,
5074,
8840,
1373,
1423,
26,
314,
536,
402,
282,
1572,
315,
314,
22773,
6174,
63,
11378,
4260,
7,
450,
1526,
14,
1294,
63,
4407,
3430,
16,
61,
272,
372,
3599,
5111,
11378,
1716,
8,
354,
9,
199,
10895,
63,
3596,
275,
2274,
14,
1450,
8,
10895,
63,
3596,
9,
199,
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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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
leekchan/django_test
|
django/conf/locale/pt/formats.py
|
115
|
1717
|
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals
# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = r'j \d\e F \d\e Y'
TIME_FORMAT = 'H:i'
DATETIME_FORMAT = r'j \d\e F \d\e Y à\s H:i'
YEAR_MONTH_FORMAT = r'F \d\e Y'
MONTH_DAY_FORMAT = r'j \d\e F'
SHORT_DATE_FORMAT = 'd/m/Y'
SHORT_DATETIME_FORMAT = 'd/m/Y H:i'
FIRST_DAY_OF_WEEK = 0 # Sunday
# 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 de %b de %Y', '%d de %b, %Y', # '25 de Out de 2006', '25 Out, 2006'
# '%d de %B de %Y', '%d de %B, %Y', # '25 de Outubro de 2006', '25 de Outubro, 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'
'%d/%m/%Y %H:%M:%S', # '25/10/2006 14:30:59'
'%d/%m/%Y %H:%M:%S.%f', # '25/10/2006 14:30:59.000200'
'%d/%m/%Y %H:%M', # '25/10/2006 14:30'
'%d/%m/%Y', # '25/10/2006'
'%d/%m/%y %H:%M:%S', # '25/10/06 14:30:59'
'%d/%m/%y %H:%M:%S.%f', # '25/10/06 14:30:59.000200'
'%d/%m/%y %H:%M', # '25/10/06 14:30'
'%d/%m/%y', # '25/10/06'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = '.'
NUMBER_GROUPING = 3
|
bsd-3-clause
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
3,
961,
570,
365,
1854,
1334,
314,
2011,
4190,
465,
314,
5634,
2559,
14,
199,
3,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
3,
710,
20841,
4807,
3326,
675,
314,
5634,
1434,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
5876,
15,
10372,
12645,
602,
199,
5390,
63,
4807,
275,
519,
7,
74,
971,
68,
60,
69,
481,
971,
68,
60,
69,
1488,
7,
199,
4961,
63,
4807,
275,
283,
40,
26,
73,
7,
199,
12488,
63,
4807,
275,
519,
7,
74,
971,
68,
60,
69,
481,
971,
68,
60,
69,
1488,
26031,
60,
83,
869,
26,
73,
7,
199,
19216,
63,
16413,
63,
4807,
275,
519,
7,
38,
971,
68,
60,
69,
1488,
7,
199,
16413,
63,
11655,
63,
4807,
275,
519,
7,
74,
971,
68,
60,
69,
481,
7,
199,
13003,
63,
5390,
63,
4807,
275,
283,
68,
15,
77,
15,
57,
7,
199,
13003,
63,
12488,
63,
4807,
275,
283,
68,
15,
77,
15,
57,
869,
26,
73,
7,
199,
12903,
63,
11655,
63,
3359,
63,
24929,
275,
378,
221,
327,
428,
24759,
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,
334,
272,
1543,
57,
3295,
77,
3295,
68,
297,
1543,
68,
3149,
77,
3149,
57,
297,
1543,
68,
3149,
77,
3149,
89,
297,
257,
327,
283,
7968,
13,
709,
13,
821,
297,
283,
821,
15,
709,
15,
7968,
297,
283,
821,
15,
709,
15,
1690,
7,
272,
327,
1543,
68,
477,
450,
66,
477,
450,
57,
297,
1543,
68,
477,
450,
66,
12,
450,
57,
297,
257,
327,
283,
821,
477,
6219,
477,
8315,
297,
283,
821,
6219,
12,
8315,
7,
272,
327,
1543,
68,
477,
450,
34,
477,
450,
57,
297,
1543,
68,
477,
450,
34,
12,
450,
57,
297,
257,
327,
283,
821,
477,
6219,
456,
293,
477,
8315,
297,
283,
821,
477,
6219,
456,
293,
12,
8315,
7,
199,
9,
199,
12488,
63,
7321,
63,
14019,
275,
334,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
297,
263,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
7,
272,
1543,
57,
3295,
77,
3295,
68,
297,
4519,
327,
283,
7968,
13,
709,
13,
821,
7,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
7,
272,
1543,
68,
3149,
77,
3149,
57,
297,
4519,
327,
283,
821,
15,
709,
15,
7968,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
7,
272,
1543,
68,
3149,
77,
3149,
89,
297,
4519,
327,
283,
821,
15,
709,
15,
1690,
7,
199,
9,
199,
23925,
63,
15828,
275,
13647,
199,
28714,
63,
15828,
275,
7815,
199,
9190,
63,
7823,
1206,
275,
650,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
3,
961,
570,
365,
1854,
1334,
314,
2011,
4190,
465,
314,
5634,
2559,
14,
199,
3,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
3,
710,
20841,
4807,
3326,
675,
314,
5634,
1434,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
5876,
15,
10372,
12645,
602,
199,
5390,
63,
4807,
275,
519,
7,
74,
971,
68,
60,
69,
481,
971,
68,
60,
69,
1488,
7,
199,
4961,
63,
4807,
275,
283,
40,
26,
73,
7,
199,
12488,
63,
4807,
275,
519,
7,
74,
971,
68,
60,
69,
481,
971,
68,
60,
69,
1488,
26031,
60,
83,
869,
26,
73,
7,
199,
19216,
63,
16413,
63,
4807,
275,
519,
7,
38,
971,
68,
60,
69,
1488,
7,
199,
16413,
63,
11655,
63,
4807,
275,
519,
7,
74,
971,
68,
60,
69,
481,
7,
199,
13003,
63,
5390,
63,
4807,
275,
283,
68,
15,
77,
15,
57,
7,
199,
13003,
63,
12488,
63,
4807,
275,
283,
68,
15,
77,
15,
57,
869,
26,
73,
7,
199,
12903,
63,
11655,
63,
3359,
63,
24929,
275,
378,
221,
327,
428,
24759,
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,
334,
272,
1543,
57,
3295,
77,
3295,
68,
297,
1543,
68,
3149,
77,
3149,
57,
297,
1543,
68,
3149,
77,
3149,
89,
297,
257,
327,
283,
7968,
13,
709,
13,
821,
297,
283,
821,
15,
709,
15,
7968,
297,
283,
821,
15,
709,
15,
1690,
7,
272,
327,
1543,
68,
477,
450,
66,
477,
450,
57,
297,
1543,
68,
477,
450,
66,
12,
450,
57,
297,
257,
327,
283,
821,
477,
6219,
477,
8315,
297,
283,
821,
6219,
12,
8315,
7,
272,
327,
1543,
68,
477,
450,
34,
477,
450,
57,
297,
1543,
68,
477,
450,
34,
12,
450,
57,
297,
257,
327,
283,
821,
477,
6219,
456,
293,
477,
8315,
297,
283,
821,
477,
6219,
456,
293,
12,
8315,
7,
199,
9,
199,
12488,
63,
7321,
63,
14019,
275,
334,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
297,
263,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
7,
272,
1543,
57,
3295,
77,
3295,
68,
297,
4519,
327,
283,
7968,
13,
709,
13,
821,
7,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
7,
272,
1543,
68,
3149,
77,
3149,
57,
297,
4519,
327,
283,
821,
15,
709,
15,
7968,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
7,
272,
1543,
68,
3149,
77,
3149,
89,
297,
4519,
327,
283,
821,
15,
709,
15,
1690,
7,
199,
9,
199,
23925,
63,
15828,
275,
13647,
199,
28714,
63,
15828,
275,
7815,
199,
9190,
63,
7823,
1206,
275,
650,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
michealjroberts/stepjockey-data-retrieval
|
main.py
|
1
|
1217
|
#!/usr/bin/env python 2.7.12
#=======================================================================================================================================================#
#title :methods.py
#description :This collects KPI data from all relevant API sources
#author :Michael Roberts
#date :20170316
#version :0.1
#usage :python main.py (not CLI)
#notes :Tweepy version 3.5.0 and pyMongo 3.4.0
#python_version :2.7.12 |Anaconda 2.3.0 (x86_64)| (default, Jul 2 2016, 17:43:17) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)]
#=======================================================================================================================================================#
from base import BaseMethods
from send import SendToGoogleSheets
def main():
SendToGoogleSheetsMethods = SendToGoogleSheets()
SendToGoogleSheetsMethods.sessions()
SendToGoogleSheetsMethods.events()
SendToGoogleSheetsMethods.social()
SendToGoogleSheetsMethods.mobile()
SendToGoogleSheetsMethods.stepjockey()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print('\nGoodbye!')
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
499,
14,
23,
14,
713,
199,
199,
14813,
5695,
1280,
18673,
3,
199,
3,
1213,
3698,
520,
2474,
14,
647,
199,
3,
1802,
258,
520,
2765,
8775,
83,
1804,
2252,
666,
687,
1006,
12082,
3261,
5274,
199,
3,
2502,
3515,
520,
45,
11781,
6848,
605,
1086,
199,
3,
602,
3322,
520,
10680,
1644,
975,
199,
3,
1023,
260,
520,
16,
14,
17,
199,
3,
3807,
3698,
520,
1548,
2446,
14,
647,
334,
1397,
14214,
9,
199,
3,
5983,
3698,
520,
22879,
1024,
647,
1015,
650,
14,
21,
14,
16,
436,
1134,
20393,
650,
14,
20,
14,
16,
199,
3,
1548,
63,
1023,
221,
520,
18,
14,
23,
14,
713,
1204,
2493,
16928,
983,
499,
14,
19,
14,
16,
334,
88,
1184,
63,
772,
8636,
334,
885,
12,
1603,
348,
221,
499,
7800,
12,
5557,
26,
2824,
26,
1196,
9,
359,
10566,
841,
14,
18,
14,
17,
334,
20409,
641,
21257,
3277,
14,
1900,
12001,
2010,
9,
334,
4464,
6849,
1900,
499,
12135,
14,
845,
14,
383,
1874,
199,
14813,
5695,
1280,
18673,
3,
199,
199,
504,
1300,
492,
3523,
10385,
199,
504,
3222,
492,
10217,
1378,
13266,
16715,
83,
199,
199,
318,
2446,
837,
272,
10217,
1378,
13266,
16715,
83,
10385,
275,
10217,
1378,
13266,
16715,
83,
342,
272,
10217,
1378,
13266,
16715,
83,
10385,
14,
11676,
342,
272,
10217,
1378,
13266,
16715,
83,
10385,
14,
4368,
342,
272,
10217,
1378,
13266,
16715,
83,
10385,
14,
13574,
342,
272,
10217,
1378,
13266,
16715,
83,
10385,
14,
11375,
342,
272,
10217,
1378,
13266,
16715,
83,
10385,
14,
2926,
743,
346,
14655,
342,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
862,
26,
267,
2446,
342,
272,
871,
13483,
26,
267,
870,
2258,
78,
20652,
16481,
10916,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
499,
14,
23,
14,
713,
199,
199,
14813,
5695,
1280,
18673,
3,
199,
3,
1213,
3698,
520,
2474,
14,
647,
199,
3,
1802,
258,
520,
2765,
8775,
83,
1804,
2252,
666,
687,
1006,
12082,
3261,
5274,
199,
3,
2502,
3515,
520,
45,
11781,
6848,
605,
1086,
199,
3,
602,
3322,
520,
10680,
1644,
975,
199,
3,
1023,
260,
520,
16,
14,
17,
199,
3,
3807,
3698,
520,
1548,
2446,
14,
647,
334,
1397,
14214,
9,
199,
3,
5983,
3698,
520,
22879,
1024,
647,
1015,
650,
14,
21,
14,
16,
436,
1134,
20393,
650,
14,
20,
14,
16,
199,
3,
1548,
63,
1023,
221,
520,
18,
14,
23,
14,
713,
1204,
2493,
16928,
983,
499,
14,
19,
14,
16,
334,
88,
1184,
63,
772,
8636,
334,
885,
12,
1603,
348,
221,
499,
7800,
12,
5557,
26,
2824,
26,
1196,
9,
359,
10566,
841,
14,
18,
14,
17,
334,
20409,
641,
21257,
3277,
14,
1900,
12001,
2010,
9,
334,
4464,
6849,
1900,
499,
12135,
14,
845,
14,
383,
1874,
199,
14813,
5695,
1280,
18673,
3,
199,
199,
504,
1300,
492,
3523,
10385,
199,
504,
3222,
492,
10217,
1378,
13266,
16715,
83,
199,
199,
318,
2446,
837,
272,
10217,
1378,
13266,
16715,
83,
10385,
275,
10217,
1378,
13266,
16715,
83,
342,
272,
10217,
1378,
13266,
16715,
83,
10385,
14,
11676,
342,
272,
10217,
1378,
13266,
16715,
83,
10385,
14,
4368,
342,
272,
10217,
1378,
13266,
16715,
83,
10385,
14,
13574,
342,
272,
10217,
1378,
13266,
16715,
83,
10385,
14,
11375,
342,
272,
10217,
1378,
13266,
16715,
83,
10385,
14,
2926,
743,
346,
14655,
342,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
862,
26,
267,
2446,
342,
272,
871,
13483,
26,
267,
870,
2258,
78,
20652,
16481,
10916,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
RTsWorld/deepdive
|
examples/tutorial_example/step3-more-data/experiment-reports/v00003/code/udf/ext_has_spouse.py
|
90
|
2326
|
#! /usr/bin/env python
import csv, os, sys
# The directory of this UDF file
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
# Load the spouse dictionary for distant supervision.
# A person can have multiple spouses
spouses = set()
married_people = set()
lines = open(BASE_DIR + '/../data/spouses.tsv').readlines()
for line in lines:
name1, name2, relation = line.strip().split('\t')
spouses.add((name1, name2)) # Add a spouse relation pair
married_people.add(name1) # Record the person as married
married_people.add(name2)
# Load relations of people that are not spouse
# The non-spouse KB lists incompatible relations, e.g. childrens, siblings, parents.
non_spouses = set()
lines = open(BASE_DIR + '/../data/non-spouses.tsv').readlines()
for line in lines:
name1, name2, relation = line.strip().split('\t')
non_spouses.add((name1, name2)) # Add a non-spouse relation pair
# For each input tuple
for row in sys.stdin:
parts = row.strip().split('\t')
sentence_id, p1_id, p1_text, p2_id, p2_text = parts
p1_text = p1_text.strip()
p2_text = p2_text.strip()
p1_text_lower = p1_text.lower()
p2_text_lower = p2_text.lower()
# DS rule 1: true if they appear in spouse KB, false if they appear in non-spouse KB
is_true = '\N'
if (p1_text_lower, p2_text_lower) in spouses or \
(p2_text_lower, p1_text_lower) in spouses:
is_true = '1'
elif (p1_text_lower, p2_text_lower) in non_spouses or \
(p2_text_lower, p1_text_lower) in non_spouses:
is_true = '0'
# DS rule 3: false if they appear to be in same person
elif (p1_text == p2_text) or (p1_text in p2_text) or (p2_text in p1_text):
is_true = '0'
# DS rule 4 false if they are both married, but not married to each other:
elif p1_text_lower in married_people and p2_text_lower in married_people:
is_true = '0'
# Output relation candidates into output table
print '\t'.join([
p1_id, p2_id, sentence_id,
"%s-%s" %(p1_text, p2_text),
is_true,
"%s-%s" %(p1_id, p2_id),
'\N' # leave "id" blank for system!
])
# TABLE FORMAT: CREATE TABLE has_spouse(
# person1_id bigint,
# person2_id bigint,
# sentence_id bigint,
# description text,
# is_true boolean,
# relation_id bigint, -- unique identifier for has_spouse
# id bigint -- reserved for DeepDive
# );
|
apache-2.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
7392,
12,
747,
12,
984,
199,
199,
3,
710,
2082,
402,
642,
738,
3888,
570,
199,
5825,
63,
3022,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
8964,
199,
199,
3,
7190,
314,
25664,
1180,
2600,
367,
2917,
867,
1613,
2317,
14,
199,
3,
437,
4954,
883,
1172,
3663,
25664,
5589,
199,
22522,
5589,
275,
663,
342,
199,
4584,
18906,
63,
13562,
275,
663,
342,
199,
1278,
275,
1551,
8,
5825,
63,
3022,
435,
1994,
5093,
576,
15,
22522,
5589,
14,
29362,
1959,
9684,
342,
199,
509,
1004,
315,
2385,
26,
523,
536,
17,
12,
536,
18,
12,
5850,
275,
1004,
14,
1913,
1252,
1294,
2258,
84,
358,
523,
25664,
5589,
14,
525,
1332,
354,
17,
12,
536,
18,
430,
221,
327,
2654,
282,
25664,
1180,
5850,
4092,
523,
7557,
18906,
63,
13562,
14,
525,
8,
354,
17,
9,
259,
327,
12651,
314,
4954,
465,
7557,
18906,
523,
7557,
18906,
63,
13562,
14,
525,
8,
354,
18,
9,
199,
199,
3,
7190,
16109,
402,
13135,
626,
787,
440,
25664,
1180,
199,
3,
710,
2222,
13,
22522,
1180,
27638,
5548,
18457,
16109,
12,
325,
14,
71,
14,
1982,
27667,
12,
31871,
12,
8623,
14,
199,
2865,
63,
22522,
5589,
275,
663,
342,
199,
1278,
275,
1551,
8,
5825,
63,
3022,
435,
1994,
5093,
576,
15,
2865,
13,
22522,
5589,
14,
29362,
1959,
9684,
342,
199,
509,
1004,
315,
2385,
26,
523,
536,
17,
12,
536,
18,
12,
5850,
275,
1004,
14,
1913,
1252,
1294,
2258,
84,
358,
523,
2222,
63,
22522,
5589,
14,
525,
1332,
354,
17,
12,
536,
18,
430,
221,
327,
2654,
282,
2222,
13,
22522,
1180,
5850,
4092,
199,
199,
3,
2104,
1924,
1324,
2008,
199,
509,
1962,
315,
984,
14,
6626,
26,
523,
4184,
275,
1962,
14,
1913,
1252,
1294,
2258,
84,
358,
523,
14537,
63,
344,
12,
299,
17,
63,
344,
12,
299,
17,
63,
505,
12,
299,
18,
63,
344,
12,
299,
18,
63,
505,
275,
4184,
819,
299,
17,
63,
505,
275,
299,
17,
63,
505,
14,
1913,
342,
523,
299,
18,
63,
505,
275,
299,
18,
63,
505,
14,
1913,
342,
523,
299,
17,
63,
505,
63,
2325,
275,
299,
17,
63,
505,
14,
2325,
342,
523,
299,
18,
63,
505,
63,
2325,
275,
299,
18,
63,
505,
14,
2325,
342,
819,
327,
577,
51,
2332,
413,
26,
2549,
340,
2985,
7468,
315,
25664,
1180,
27638,
12,
3055,
340,
2985,
7468,
315,
2222,
13,
22522,
1180,
27638,
523,
365,
63,
2052,
275,
1557,
46,
7,
523,
340,
334,
80,
17,
63,
505,
63,
2325,
12,
299,
18,
63,
505,
63,
2325,
9,
315,
25664,
5589,
503,
971,
1362,
334,
80,
18,
63,
505,
63,
2325,
12,
299,
17,
63,
505,
63,
2325,
9,
315,
25664,
5589,
26,
272,
365,
63,
2052,
275,
283,
17,
7,
523,
916,
334,
80,
17,
63,
505,
63,
2325,
12,
299,
18,
63,
505,
63,
2325,
9,
315,
2222,
63,
22522,
5589,
503,
971,
2126,
334,
80,
18,
63,
505,
63,
2325,
12,
299,
17,
63,
505,
63,
2325,
9,
315,
2222,
63,
22522,
5589,
26,
272,
365,
63,
2052,
275,
283,
16,
7,
523,
327,
577,
51,
2332,
650,
26,
3055,
340,
2985,
7468,
370,
506,
315,
2011,
4954,
523,
916,
334,
80,
17,
63,
505,
508,
299,
18,
63,
505,
9,
503,
334,
80,
17,
63,
505,
315,
299,
18,
63,
505,
9,
503,
334,
80,
18,
63,
505,
315,
299,
17,
63,
505,
304,
272,
365,
63,
2052,
275,
283,
16,
7,
523,
327,
577,
51,
2332,
841,
3055,
340,
2985,
787,
3865,
7557,
18906,
12,
1325,
440,
7557,
18906,
370,
1924,
1163,
26,
523,
916,
299,
17,
63,
505,
63,
2325,
315,
7557,
18906,
63,
13562,
436,
299,
18,
63,
505,
63,
2325,
315,
7557,
18906,
63,
13562,
26,
272,
365,
63,
2052,
275,
283,
16,
7,
819,
327,
7242,
5850,
15101,
1901,
1072,
1817,
523,
870,
1557,
84,
1370,
904,
779,
272,
299,
17,
63,
344,
12,
299,
18,
63,
344,
12,
14537,
63,
344,
12,
272,
2071,
83,
3295,
83,
2,
2818,
80,
17,
63,
505,
12,
299,
18,
63,
505,
395,
272,
365,
63,
2052,
12,
272,
2071,
83,
3295,
83,
2,
2818,
80,
17,
63,
344,
12,
299,
18,
63,
344,
395,
272,
1557,
46,
7,
257,
327,
10137,
298,
344,
2,
4596,
367,
2656,
1,
272,
4794,
819,
327,
9934,
11295,
619,
26,
16999,
9934,
965,
63,
22522,
1180,
8,
523,
327,
4954,
17,
63,
344,
7282,
442,
12,
523,
327,
4954,
18,
63,
344,
7282,
442,
12,
523,
327,
14537,
63,
344,
7282,
442,
12,
523,
327,
1369,
1318,
12,
523,
327,
365,
63,
2052,
5046,
12,
523,
327,
5850,
63,
344,
7282,
442,
12,
1553,
3747,
5148,
367,
965,
63,
22522,
1180,
523,
327,
1305,
7282,
442,
257,
1553,
4644,
367,
577,
7840,
23794,
523,
327,
20682,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
7392,
12,
747,
12,
984,
199,
199,
3,
710,
2082,
402,
642,
738,
3888,
570,
199,
5825,
63,
3022,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
8964,
199,
199,
3,
7190,
314,
25664,
1180,
2600,
367,
2917,
867,
1613,
2317,
14,
199,
3,
437,
4954,
883,
1172,
3663,
25664,
5589,
199,
22522,
5589,
275,
663,
342,
199,
4584,
18906,
63,
13562,
275,
663,
342,
199,
1278,
275,
1551,
8,
5825,
63,
3022,
435,
1994,
5093,
576,
15,
22522,
5589,
14,
29362,
1959,
9684,
342,
199,
509,
1004,
315,
2385,
26,
523,
536,
17,
12,
536,
18,
12,
5850,
275,
1004,
14,
1913,
1252,
1294,
2258,
84,
358,
523,
25664,
5589,
14,
525,
1332,
354,
17,
12,
536,
18,
430,
221,
327,
2654,
282,
25664,
1180,
5850,
4092,
523,
7557,
18906,
63,
13562,
14,
525,
8,
354,
17,
9,
259,
327,
12651,
314,
4954,
465,
7557,
18906,
523,
7557,
18906,
63,
13562,
14,
525,
8,
354,
18,
9,
199,
199,
3,
7190,
16109,
402,
13135,
626,
787,
440,
25664,
1180,
199,
3,
710,
2222,
13,
22522,
1180,
27638,
5548,
18457,
16109,
12,
325,
14,
71,
14,
1982,
27667,
12,
31871,
12,
8623,
14,
199,
2865,
63,
22522,
5589,
275,
663,
342,
199,
1278,
275,
1551,
8,
5825,
63,
3022,
435,
1994,
5093,
576,
15,
2865,
13,
22522,
5589,
14,
29362,
1959,
9684,
342,
199,
509,
1004,
315,
2385,
26,
523,
536,
17,
12,
536,
18,
12,
5850,
275,
1004,
14,
1913,
1252,
1294,
2258,
84,
358,
523,
2222,
63,
22522,
5589,
14,
525,
1332,
354,
17,
12,
536,
18,
430,
221,
327,
2654,
282,
2222,
13,
22522,
1180,
5850,
4092,
199,
199,
3,
2104,
1924,
1324,
2008,
199,
509,
1962,
315,
984,
14,
6626,
26,
523,
4184,
275,
1962,
14,
1913,
1252,
1294,
2258,
84,
358,
523,
14537,
63,
344,
12,
299,
17,
63,
344,
12,
299,
17,
63,
505,
12,
299,
18,
63,
344,
12,
299,
18,
63,
505,
275,
4184,
819,
299,
17,
63,
505,
275,
299,
17,
63,
505,
14,
1913,
342,
523,
299,
18,
63,
505,
275,
299,
18,
63,
505,
14,
1913,
342,
523,
299,
17,
63,
505,
63,
2325,
275,
299,
17,
63,
505,
14,
2325,
342,
523,
299,
18,
63,
505,
63,
2325,
275,
299,
18,
63,
505,
14,
2325,
342,
819,
327,
577,
51,
2332,
413,
26,
2549,
340,
2985,
7468,
315,
25664,
1180,
27638,
12,
3055,
340,
2985,
7468,
315,
2222,
13,
22522,
1180,
27638,
523,
365,
63,
2052,
275,
1557,
46,
7,
523,
340,
334,
80,
17,
63,
505,
63,
2325,
12,
299,
18,
63,
505,
63,
2325,
9,
315,
25664,
5589,
503,
971,
1362,
334,
80,
18,
63,
505,
63,
2325,
12,
299,
17,
63,
505,
63,
2325,
9,
315,
25664,
5589,
26,
272,
365,
63,
2052,
275,
283,
17,
7,
523,
916,
334,
80,
17,
63,
505,
63,
2325,
12,
299,
18,
63,
505,
63,
2325,
9,
315,
2222,
63,
22522,
5589,
503,
971,
2126,
334,
80,
18,
63,
505,
63,
2325,
12,
299,
17,
63,
505,
63,
2325,
9,
315,
2222,
63,
22522,
5589,
26,
272,
365,
63,
2052,
275,
283,
16,
7,
523,
327,
577,
51,
2332,
650,
26,
3055,
340,
2985,
7468,
370,
506,
315,
2011,
4954,
523,
916,
334,
80,
17,
63,
505,
508,
299,
18,
63,
505,
9,
503,
334,
80,
17,
63,
505,
315,
299,
18,
63,
505,
9,
503,
334,
80,
18,
63,
505,
315,
299,
17,
63,
505,
304,
272,
365,
63,
2052,
275,
283,
16,
7,
523,
327,
577,
51,
2332,
841,
3055,
340,
2985,
787,
3865,
7557,
18906,
12,
1325,
440,
7557,
18906,
370,
1924,
1163,
26,
523,
916,
299,
17,
63,
505,
63,
2325,
315,
7557,
18906,
63,
13562,
436,
299,
18,
63,
505,
63,
2325,
315,
7557,
18906,
63,
13562,
26,
272,
365,
63,
2052,
275,
283,
16,
7,
819,
327,
7242,
5850,
15101,
1901,
1072,
1817,
523,
870,
1557,
84,
1370,
904,
779,
272,
299,
17,
63,
344,
12,
299,
18,
63,
344,
12,
14537,
63,
344,
12,
272,
2071,
83,
3295,
83,
2,
2818,
80,
17,
63,
505,
12,
299,
18,
63,
505,
395,
272,
365,
63,
2052,
12,
272,
2071,
83,
3295,
83,
2,
2818,
80,
17,
63,
344,
12,
299,
18,
63,
344,
395,
272,
1557,
46,
7,
257,
327,
10137,
298,
344,
2,
4596,
367,
2656,
1,
272,
4794,
819,
327,
9934,
11295,
619,
26,
16999,
9934,
965,
63,
22522,
1180,
8,
523,
327,
4954,
17,
63,
344,
7282,
442,
12,
523,
327,
4954,
18,
63,
344,
7282,
442,
12,
523,
327,
14537,
63,
344,
7282,
442,
12,
523,
327,
1369,
1318,
12,
523,
327,
365,
63,
2052,
5046,
12,
523,
327,
5850,
63,
344,
7282,
442,
12,
1553,
3747,
5148,
367,
965,
63,
22522,
1180,
523,
327,
1305,
7282,
442,
257,
1553,
4644,
367,
577,
7840,
23794,
523,
327,
20682,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
brelloch/volveR
|
node_modules/meanio/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py
|
574
|
21473
|
#!/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.
import copy
import gyp.input
import optparse
import os.path
import re
import shlex
import sys
import traceback
from gyp.common import GypError
# Default debug modes for GYP
debug = {}
# List of "official" debug modes, but you can use anything you like.
DEBUG_GENERAL = 'general'
DEBUG_VARIABLES = 'variables'
DEBUG_INCLUDES = 'includes'
def DebugOutput(mode, message, *args):
if 'all' in gyp.debug or mode in gyp.debug:
ctx = ('unknown', 0, 'unknown')
try:
f = traceback.extract_stack(limit=2)
if f:
ctx = f[0][:3]
except:
pass
if args:
message %= args
print '%s:%s:%d:%s %s' % (mode.upper(), os.path.basename(ctx[0]),
ctx[1], ctx[2], message)
def FindBuildFiles():
extension = '.gyp'
files = os.listdir(os.getcwd())
build_files = []
for file in files:
if file.endswith(extension):
build_files.append(file)
return build_files
def Load(build_files, format, default_variables={},
includes=[], depth='.', params=None, check=False,
circular_check=True):
"""
Loads one or more specified build files.
default_variables and includes will be copied before use.
Returns the generator for the specified format and the
data returned by loading the specified build files.
"""
if params is None:
params = {}
flavor = None
if '-' in format:
format, params['flavor'] = format.split('-', 1)
default_variables = copy.copy(default_variables)
# Default variables provided by this program and its modules should be
# named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace,
# avoiding collisions with user and automatic variables.
default_variables['GENERATOR'] = format
# Format can be a custom python file, or by default the name of a module
# within gyp.generator.
if format.endswith('.py'):
generator_name = os.path.splitext(format)[0]
path, generator_name = os.path.split(generator_name)
# Make sure the path to the custom generator is in sys.path
# Don't worry about removing it once we are done. Keeping the path
# to each generator that is used in sys.path is likely harmless and
# arguably a good idea.
path = os.path.abspath(path)
if path not in sys.path:
sys.path.insert(0, path)
else:
generator_name = 'gyp.generator.' + format
# These parameters are passed in order (as opposed to by key)
# because ActivePython cannot handle key parameters to __import__.
generator = __import__(generator_name, globals(), locals(), generator_name)
for (key, val) in generator.generator_default_variables.items():
default_variables.setdefault(key, val)
# Give the generator the opportunity to set additional variables based on
# the params it will receive in the output phase.
if getattr(generator, 'CalculateVariables', None):
generator.CalculateVariables(default_variables, params)
# Give the generator the opportunity to set generator_input_info based on
# the params it will receive in the output phase.
if getattr(generator, 'CalculateGeneratorInputInfo', None):
generator.CalculateGeneratorInputInfo(params)
# Fetch the generator specific info that gets fed to input, we use getattr
# so we can default things and the generators only have to provide what
# they need.
generator_input_info = {
'non_configuration_keys':
getattr(generator, 'generator_additional_non_configuration_keys', []),
'path_sections':
getattr(generator, 'generator_additional_path_sections', []),
'extra_sources_for_rules':
getattr(generator, 'generator_extra_sources_for_rules', []),
'generator_supports_multiple_toolsets':
getattr(generator, 'generator_supports_multiple_toolsets', False),
'generator_wants_static_library_dependencies_adjusted':
getattr(generator,
'generator_wants_static_library_dependencies_adjusted', True),
'generator_wants_sorted_dependencies':
getattr(generator, 'generator_wants_sorted_dependencies', False),
'generator_filelist_paths':
getattr(generator, 'generator_filelist_paths', None),
}
# Process the input specific to this generator.
result = gyp.input.Load(build_files, default_variables, includes[:],
depth, generator_input_info, check, circular_check,
params['parallel'], params['root_targets'])
return [generator] + result
def NameValueListToDict(name_value_list):
"""
Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary
of the pairs. If a string is simply NAME, then the value in the dictionary
is set to True. If VALUE can be converted to an integer, it is.
"""
result = { }
for item in name_value_list:
tokens = item.split('=', 1)
if len(tokens) == 2:
# If we can make it an int, use that, otherwise, use the string.
try:
token_value = int(tokens[1])
except ValueError:
token_value = tokens[1]
# Set the variable to the supplied value.
result[tokens[0]] = token_value
else:
# No value supplied, treat it as a boolean and set it.
result[tokens[0]] = True
return result
def ShlexEnv(env_name):
flags = os.environ.get(env_name, [])
if flags:
flags = shlex.split(flags)
return flags
def FormatOpt(opt, value):
if opt.startswith('--'):
return '%s=%s' % (opt, value)
return opt + value
def RegenerateAppendFlag(flag, values, predicate, env_name, options):
"""Regenerate a list of command line flags, for an option of action='append'.
The |env_name|, if given, is checked in the environment and used to generate
an initial list of options, then the options that were specified on the
command line (given in |values|) are appended. This matches the handling of
environment variables and command line flags where command line flags override
the environment, while not requiring the environment to be set when the flags
are used again.
"""
flags = []
if options.use_environment and env_name:
for flag_value in ShlexEnv(env_name):
value = FormatOpt(flag, predicate(flag_value))
if value in flags:
flags.remove(value)
flags.append(value)
if values:
for flag_value in values:
flags.append(FormatOpt(flag, predicate(flag_value)))
return flags
def RegenerateFlags(options):
"""Given a parsed options object, and taking the environment variables into
account, returns a list of flags that should regenerate an equivalent options
object (even in the absence of the environment variables.)
Any path options will be normalized relative to depth.
The format flag is not included, as it is assumed the calling generator will
set that as appropriate.
"""
def FixPath(path):
path = gyp.common.FixIfRelativePath(path, options.depth)
if not path:
return os.path.curdir
return path
def Noop(value):
return value
# We always want to ignore the environment when regenerating, to avoid
# duplicate or changed flags in the environment at the time of regeneration.
flags = ['--ignore-environment']
for name, metadata in options._regeneration_metadata.iteritems():
opt = metadata['opt']
value = getattr(options, name)
value_predicate = metadata['type'] == 'path' and FixPath or Noop
action = metadata['action']
env_name = metadata['env_name']
if action == 'append':
flags.extend(RegenerateAppendFlag(opt, value, value_predicate,
env_name, options))
elif action in ('store', None): # None is a synonym for 'store'.
if value:
flags.append(FormatOpt(opt, value_predicate(value)))
elif options.use_environment and env_name and os.environ.get(env_name):
flags.append(FormatOpt(opt, value_predicate(os.environ.get(env_name))))
elif action in ('store_true', 'store_false'):
if ((action == 'store_true' and value) or
(action == 'store_false' and not value)):
flags.append(opt)
elif options.use_environment and env_name:
print >>sys.stderr, ('Warning: environment regeneration unimplemented '
'for %s flag %r env_name %r' % (action, opt,
env_name))
else:
print >>sys.stderr, ('Warning: regeneration unimplemented for action %r '
'flag %r' % (action, opt))
return flags
class RegeneratableOptionParser(optparse.OptionParser):
def __init__(self):
self.__regeneratable_options = {}
optparse.OptionParser.__init__(self)
def add_option(self, *args, **kw):
"""Add an option to the parser.
This accepts the same arguments as OptionParser.add_option, plus the
following:
regenerate: can be set to False to prevent this option from being included
in regeneration.
env_name: name of environment variable that additional values for this
option come from.
type: adds type='path', to tell the regenerator that the values of
this option need to be made relative to options.depth
"""
env_name = kw.pop('env_name', None)
if 'dest' in kw and kw.pop('regenerate', True):
dest = kw['dest']
# The path type is needed for regenerating, for optparse we can just treat
# it as a string.
type = kw.get('type')
if type == 'path':
kw['type'] = 'string'
self.__regeneratable_options[dest] = {
'action': kw.get('action'),
'type': type,
'env_name': env_name,
'opt': args[0],
}
optparse.OptionParser.add_option(self, *args, **kw)
def parse_args(self, *args):
values, args = optparse.OptionParser.parse_args(self, *args)
values._regeneration_metadata = self.__regeneratable_options
return values, args
def gyp_main(args):
my_name = os.path.basename(sys.argv[0])
parser = RegeneratableOptionParser()
usage = 'usage: %s [options ...] [build_file ...]'
parser.set_usage(usage.replace('%s', '%prog'))
parser.add_option('--build', dest='configs', action='append',
help='configuration for build after project generation')
parser.add_option('--check', dest='check', action='store_true',
help='check format of gyp files')
parser.add_option('--config-dir', dest='config_dir', action='store',
env_name='GYP_CONFIG_DIR', default=None,
help='The location for configuration files like '
'include.gypi.')
parser.add_option('-d', '--debug', dest='debug', metavar='DEBUGMODE',
action='append', default=[], help='turn on a debugging '
'mode for debugging GYP. Supported modes are "variables", '
'"includes" and "general" or "all" for all of them.')
parser.add_option('-D', dest='defines', action='append', metavar='VAR=VAL',
env_name='GYP_DEFINES',
help='sets variable VAR to value VAL')
parser.add_option('--depth', dest='depth', metavar='PATH', type='path',
help='set DEPTH gyp variable to a relative path to PATH')
parser.add_option('-f', '--format', dest='formats', action='append',
env_name='GYP_GENERATORS', regenerate=False,
help='output formats to generate')
parser.add_option('-G', dest='generator_flags', action='append', default=[],
metavar='FLAG=VAL', env_name='GYP_GENERATOR_FLAGS',
help='sets generator flag FLAG to VAL')
parser.add_option('--generator-output', dest='generator_output',
action='store', default=None, metavar='DIR', type='path',
env_name='GYP_GENERATOR_OUTPUT',
help='puts generated build files under DIR')
parser.add_option('--ignore-environment', dest='use_environment',
action='store_false', default=True, regenerate=False,
help='do not read options from environment variables')
parser.add_option('-I', '--include', dest='includes', action='append',
metavar='INCLUDE', type='path',
help='files to include in all loaded .gyp files')
# --no-circular-check disables the check for circular relationships between
# .gyp files. These relationships should not exist, but they've only been
# observed to be harmful with the Xcode generator. Chromium's .gyp files
# currently have some circular relationships on non-Mac platforms, so this
# option allows the strict behavior to be used on Macs and the lenient
# behavior to be used elsewhere.
# TODO(mark): Remove this option when http://crbug.com/35878 is fixed.
parser.add_option('--no-circular-check', dest='circular_check',
action='store_false', default=True, regenerate=False,
help="don't check for circular relationships between files")
parser.add_option('--no-parallel', action='store_true', default=False,
help='Disable multiprocessing')
parser.add_option('-S', '--suffix', dest='suffix', default='',
help='suffix to add to generated files')
parser.add_option('--toplevel-dir', dest='toplevel_dir', action='store',
default=None, metavar='DIR', type='path',
help='directory to use as the root of the source tree')
parser.add_option('-R', '--root-target', dest='root_targets',
action='append', metavar='TARGET',
help='include only TARGET and its deep dependencies')
options, build_files_arg = parser.parse_args(args)
build_files = build_files_arg
# Set up the configuration directory (defaults to ~/.gyp)
if not options.config_dir:
home = None
home_dot_gyp = None
if options.use_environment:
home_dot_gyp = os.environ.get('GYP_CONFIG_DIR', None)
if home_dot_gyp:
home_dot_gyp = os.path.expanduser(home_dot_gyp)
if not home_dot_gyp:
home_vars = ['HOME']
if sys.platform in ('cygwin', 'win32'):
home_vars.append('USERPROFILE')
for home_var in home_vars:
home = os.getenv(home_var)
if home != None:
home_dot_gyp = os.path.join(home, '.gyp')
if not os.path.exists(home_dot_gyp):
home_dot_gyp = None
else:
break
else:
home_dot_gyp = os.path.expanduser(options.config_dir)
if home_dot_gyp and not os.path.exists(home_dot_gyp):
home_dot_gyp = None
if not options.formats:
# If no format was given on the command line, then check the env variable.
generate_formats = []
if options.use_environment:
generate_formats = os.environ.get('GYP_GENERATORS', [])
if generate_formats:
generate_formats = re.split('[\s,]', generate_formats)
if generate_formats:
options.formats = generate_formats
else:
# Nothing in the variable, default based on platform.
if sys.platform == 'darwin':
options.formats = ['xcode']
elif sys.platform in ('win32', 'cygwin'):
options.formats = ['msvs']
else:
options.formats = ['make']
if not options.generator_output and options.use_environment:
g_o = os.environ.get('GYP_GENERATOR_OUTPUT')
if g_o:
options.generator_output = g_o
options.parallel = not options.no_parallel
for mode in options.debug:
gyp.debug[mode] = 1
# Do an extra check to avoid work when we're not debugging.
if DEBUG_GENERAL in gyp.debug:
DebugOutput(DEBUG_GENERAL, 'running with these options:')
for option, value in sorted(options.__dict__.items()):
if option[0] == '_':
continue
if isinstance(value, basestring):
DebugOutput(DEBUG_GENERAL, " %s: '%s'", option, value)
else:
DebugOutput(DEBUG_GENERAL, " %s: %s", option, value)
if not build_files:
build_files = FindBuildFiles()
if not build_files:
raise GypError((usage + '\n\n%s: error: no build_file') %
(my_name, my_name))
# TODO(mark): Chromium-specific hack!
# For Chromium, the gyp "depth" variable should always be a relative path
# to Chromium's top-level "src" directory. If no depth variable was set
# on the command line, try to find a "src" directory by looking at the
# absolute path to each build file's directory. The first "src" component
# found will be treated as though it were the path used for --depth.
if not options.depth:
for build_file in build_files:
build_file_dir = os.path.abspath(os.path.dirname(build_file))
build_file_dir_components = build_file_dir.split(os.path.sep)
components_len = len(build_file_dir_components)
for index in xrange(components_len - 1, -1, -1):
if build_file_dir_components[index] == 'src':
options.depth = os.path.sep.join(build_file_dir_components)
break
del build_file_dir_components[index]
# If the inner loop found something, break without advancing to another
# build file.
if options.depth:
break
if not options.depth:
raise GypError('Could not automatically locate src directory. This is'
'a temporary Chromium feature that will be removed. Use'
'--depth as a workaround.')
# If toplevel-dir is not set, we assume that depth is the root of our source
# tree.
if not options.toplevel_dir:
options.toplevel_dir = options.depth
# -D on the command line sets variable defaults - D isn't just for define,
# it's for default. Perhaps there should be a way to force (-F?) a
# variable's value so that it can't be overridden by anything else.
cmdline_default_variables = {}
defines = []
if options.use_environment:
defines += ShlexEnv('GYP_DEFINES')
if options.defines:
defines += options.defines
cmdline_default_variables = NameValueListToDict(defines)
if DEBUG_GENERAL in gyp.debug:
DebugOutput(DEBUG_GENERAL,
"cmdline_default_variables: %s", cmdline_default_variables)
# Set up includes.
includes = []
# If ~/.gyp/include.gypi exists, it'll be forcibly included into every
# .gyp file that's loaded, before anything else is included.
if home_dot_gyp != None:
default_include = os.path.join(home_dot_gyp, 'include.gypi')
if os.path.exists(default_include):
print 'Using overrides found in ' + default_include
includes.append(default_include)
# Command-line --include files come after the default include.
if options.includes:
includes.extend(options.includes)
# Generator flags should be prefixed with the target generator since they
# are global across all generator runs.
gen_flags = []
if options.use_environment:
gen_flags += ShlexEnv('GYP_GENERATOR_FLAGS')
if options.generator_flags:
gen_flags += options.generator_flags
generator_flags = NameValueListToDict(gen_flags)
if DEBUG_GENERAL in gyp.debug.keys():
DebugOutput(DEBUG_GENERAL, "generator_flags: %s", generator_flags)
# Generate all requested formats (use a set in case we got one format request
# twice)
for format in set(options.formats):
params = {'options': options,
'build_files': build_files,
'generator_flags': generator_flags,
'cwd': os.getcwd(),
'build_files_arg': build_files_arg,
'gyp_binary': sys.argv[0],
'home_dot_gyp': home_dot_gyp,
'parallel': options.parallel,
'root_targets': options.root_targets}
# Start with the default variables from the command line.
[generator, flat_list, targets, data] = Load(build_files, format,
cmdline_default_variables,
includes, options.depth,
params, options.check,
options.circular_check)
# TODO(mark): Pass |data| for now because the generator needs a list of
# build files that came in. In the future, maybe it should just accept
# a list, and not the whole data dict.
# NOTE: flat_list is the flattened dependency graph specifying the order
# that targets may be built. Build systems that operate serially or that
# need to have dependencies defined before dependents reference them should
# generate targets in the order specified in flat_list.
generator.GenerateOutput(flat_list, targets, data, params)
if options.configs:
valid_configs = targets[flat_list[0]]['configurations'].keys()
for conf in options.configs:
if conf not in valid_configs:
raise GypError('Invalid config specified via --build: %s' % conf)
generator.PerformBuild(data, options.configs, params)
# Done
return 0
def main(args):
try:
return gyp_main(args)
except GypError, e:
sys.stderr.write("gyp: %s\n" % e)
return 1
# NOTE: setuptools generated console_scripts calls function with no arguments
def script_main():
return main(sys.argv[1:])
if __name__ == '__main__':
sys.exit(script_main())
|
mit
|
[
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,
646,
1331,
199,
646,
4902,
14,
1210,
199,
646,
8691,
199,
646,
747,
14,
515,
199,
646,
295,
199,
646,
16701,
199,
646,
984,
199,
646,
5190,
199,
504,
4902,
14,
2330,
492,
18151,
199,
199,
3,
3758,
3105,
12404,
367,
25686,
199,
1757,
275,
1052,
199,
199,
3,
3820,
402,
298,
29260,
2,
3105,
12404,
12,
1325,
1265,
883,
675,
7003,
1265,
2839,
14,
199,
5287,
63,
31548,
275,
283,
10706,
7,
199,
5287,
63,
21161,
275,
283,
3669,
7,
199,
5287,
63,
568,
29992,
275,
283,
9441,
7,
421,
199,
318,
14245,
2959,
8,
632,
12,
1245,
12,
627,
589,
304,
523,
340,
283,
452,
7,
315,
4902,
14,
1757,
503,
818,
315,
4902,
14,
1757,
26,
272,
4027,
275,
661,
5187,
297,
378,
12,
283,
5187,
358,
272,
862,
26,
489,
289,
275,
5190,
14,
5005,
63,
2340,
8,
3097,
29,
18,
9,
489,
340,
289,
26,
267,
4027,
275,
289,
59,
16,
19663,
19,
61,
272,
871,
26,
489,
986,
272,
340,
1249,
26,
489,
1245,
450,
29,
1249,
272,
870,
1543,
83,
2689,
83,
2689,
68,
2689,
83,
450,
83,
7,
450,
334,
632,
14,
4142,
1062,
747,
14,
515,
14,
4846,
8,
3799,
59,
16,
2522,
2892,
4027,
59,
17,
467,
4027,
59,
18,
467,
1245,
9,
199,
199,
318,
6668,
3425,
5535,
837,
523,
3329,
275,
1987,
6179,
7,
523,
1584,
275,
747,
14,
7374,
8,
736,
14,
9458,
1012,
523,
1900,
63,
1725,
275,
942,
523,
367,
570,
315,
1584,
26,
272,
340,
570,
14,
4130,
8,
3435,
304,
489,
1900,
63,
1725,
14,
740,
8,
493,
9,
523,
372,
1900,
63,
1725,
421,
199,
318,
7190,
8,
1506,
63,
1725,
12,
1475,
12,
849,
63,
3669,
10324,
268,
6952,
6034,
5818,
534,
3130,
1862,
29,
403,
12,
1104,
29,
797,
12,
268,
15032,
63,
1074,
29,
549,
304,
523,
408,
523,
30367,
1373,
503,
1655,
2013,
1900,
1584,
14,
523,
849,
63,
3669,
436,
6952,
911,
506,
8876,
2544,
675,
14,
523,
1803,
314,
4306,
367,
314,
2013,
1475,
436,
314,
523,
666,
2138,
701,
8697,
314,
2013,
1900,
1584,
14,
523,
408,
523,
340,
1862,
365,
488,
26,
272,
1862,
275,
1052,
819,
8541,
275,
488,
523,
340,
10791,
315,
1475,
26,
272,
1475,
12,
1862,
459,
6081,
418,
275,
1475,
14,
1294,
13858,
413,
9,
819,
849,
63,
3669,
275,
1331,
14,
1574,
8,
885,
63,
3669,
9,
819,
327,
3758,
2860,
2741,
701,
642,
2240,
436,
2399,
4621,
1077,
506,
523,
327,
4310,
1663,
63,
35,
2669,
63,
44,
1573,
51,
370,
5647,
282,
15392,
298,
7010,
24471,
2,
3231,
12,
523,
327,
5126,
316,
30063,
543,
922,
436,
4834,
2860,
14,
523,
849,
63,
3669,
459,
12795,
6467,
418,
275,
1475,
819,
327,
9701,
883,
506,
282,
3537,
2366,
570,
12,
503,
701,
849,
314,
536,
402,
282,
859,
523,
327,
4453,
4902,
14,
4679,
14,
523,
340,
1475,
14,
4130,
5175,
647,
735,
272,
4306,
63,
354,
275,
747,
14,
515,
14,
7973,
8,
908,
2788,
16,
61,
272,
931,
12,
4306,
63,
354,
275,
747,
14,
515,
14,
1294,
8,
4679,
63,
354,
9,
339,
327,
4155,
3238,
314,
931,
370,
314,
3537,
4306,
365,
315,
984,
14,
515,
272,
327,
7529,
1133,
30944,
3595,
12881,
652,
5403,
781,
787,
4224,
14,
221,
1804,
1024,
4073,
314,
931,
272,
327,
370,
1924,
4306,
626,
365,
1202,
315,
984,
14,
515,
365,
12060,
394,
5362,
2003,
436,
272,
327,
1680,
85,
6665,
282,
6954,
16819,
14,
272,
931,
275,
747,
14,
515,
14,
4832,
8,
515,
9,
272,
340,
931,
440,
315,
984,
14,
515,
26,
489,
984,
14,
515,
14,
3176,
8,
16,
12,
931,
9,
523,
587,
26,
272,
4306,
63,
354,
275,
283,
6179,
14,
4679,
3530,
435,
1475,
819,
327,
5723,
2633,
787,
3032,
315,
1865,
334,
305,
25068,
370,
701,
790,
9,
523,
327,
2952,
23241,
4718,
3913,
2429,
790,
2633,
370,
636,
646,
4343,
523,
4306,
275,
636,
646,
721,
4679,
63,
354,
12,
7992,
1062,
9480,
1062,
4306,
63,
354,
9,
523,
367,
334,
498,
12,
1139,
9,
315,
4306,
14,
4679,
63,
885,
63,
3669,
14,
1744,
837,
272,
849,
63,
3669,
14,
5486,
8,
498,
12,
1139,
9,
819,
327,
25495,
314,
4306,
314,
30914,
370,
663,
4722,
2860,
4079,
641,
523,
327,
314,
1862,
652,
911,
9128,
315,
314,
1072,
7669,
14,
523,
340,
2519,
8,
4679,
12,
283,
14860,
11458,
297,
488,
304,
272,
4306,
14,
14860,
11458,
8,
885,
63,
3669,
12,
1862,
9,
819,
327,
25495,
314,
4306,
314,
30914,
370,
663,
4306,
63,
1210,
63,
815,
4079,
641,
523,
327,
314,
1862,
652,
911,
9128,
315,
314,
1072,
7669,
14,
523,
340,
2519,
8,
4679,
12,
283,
14860,
7599,
3205,
2354,
297,
488,
304,
272,
4306,
14,
14860,
7599,
3205,
2354,
8,
1162,
9,
819,
327,
16347,
314,
4306,
2488,
2256,
626,
7545,
23036,
370,
1324,
12,
781,
675,
2519,
523,
327,
880,
781,
883,
849,
7645,
436,
314,
16952,
1454,
1172,
370,
5647,
4052,
523,
327,
2985,
1929,
14,
523,
4306,
63,
1210,
63,
815,
275,
469,
272,
283,
2865,
63,
4758,
63,
1612,
356,
267,
2519,
8,
4679,
12,
283,
4679,
63,
8460,
63,
2865,
63,
4758,
63,
1612,
297,
14431,
272,
283,
515,
63,
7786,
356,
267,
2519,
8,
4679,
12,
283,
4679,
63,
8460,
63,
515,
63,
7786,
297,
14431,
272,
283,
2911,
63,
4553,
63,
509,
63,
4423,
356,
267,
2519,
8,
4679,
12,
283,
4679,
63,
2911,
63,
4553,
63,
509,
63,
4423,
297,
14431,
272,
283,
4679,
63,
9823,
63,
6048,
63,
30116,
356,
267,
2519,
8,
4679,
12,
283,
4679,
63,
9823,
63,
6048,
63,
30116,
297,
756,
395,
272,
283,
4679,
63,
28789,
63,
1986,
63,
4342,
63,
5714,
63,
23395,
356,
267,
2519,
8,
4679,
12,
355,
283,
4679,
63,
28789,
63,
1986,
63,
4342,
63
] |
[
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,
646,
1331,
199,
646,
4902,
14,
1210,
199,
646,
8691,
199,
646,
747,
14,
515,
199,
646,
295,
199,
646,
16701,
199,
646,
984,
199,
646,
5190,
199,
504,
4902,
14,
2330,
492,
18151,
199,
199,
3,
3758,
3105,
12404,
367,
25686,
199,
1757,
275,
1052,
199,
199,
3,
3820,
402,
298,
29260,
2,
3105,
12404,
12,
1325,
1265,
883,
675,
7003,
1265,
2839,
14,
199,
5287,
63,
31548,
275,
283,
10706,
7,
199,
5287,
63,
21161,
275,
283,
3669,
7,
199,
5287,
63,
568,
29992,
275,
283,
9441,
7,
421,
199,
318,
14245,
2959,
8,
632,
12,
1245,
12,
627,
589,
304,
523,
340,
283,
452,
7,
315,
4902,
14,
1757,
503,
818,
315,
4902,
14,
1757,
26,
272,
4027,
275,
661,
5187,
297,
378,
12,
283,
5187,
358,
272,
862,
26,
489,
289,
275,
5190,
14,
5005,
63,
2340,
8,
3097,
29,
18,
9,
489,
340,
289,
26,
267,
4027,
275,
289,
59,
16,
19663,
19,
61,
272,
871,
26,
489,
986,
272,
340,
1249,
26,
489,
1245,
450,
29,
1249,
272,
870,
1543,
83,
2689,
83,
2689,
68,
2689,
83,
450,
83,
7,
450,
334,
632,
14,
4142,
1062,
747,
14,
515,
14,
4846,
8,
3799,
59,
16,
2522,
2892,
4027,
59,
17,
467,
4027,
59,
18,
467,
1245,
9,
199,
199,
318,
6668,
3425,
5535,
837,
523,
3329,
275,
1987,
6179,
7,
523,
1584,
275,
747,
14,
7374,
8,
736,
14,
9458,
1012,
523,
1900,
63,
1725,
275,
942,
523,
367,
570,
315,
1584,
26,
272,
340,
570,
14,
4130,
8,
3435,
304,
489,
1900,
63,
1725,
14,
740,
8,
493,
9,
523,
372,
1900,
63,
1725,
421,
199,
318,
7190,
8,
1506,
63,
1725,
12,
1475,
12,
849,
63,
3669,
10324,
268,
6952,
6034,
5818,
534,
3130,
1862,
29,
403,
12,
1104,
29,
797,
12,
268,
15032,
63,
1074,
29,
549,
304,
523,
408,
523,
30367,
1373,
503,
1655,
2013,
1900,
1584,
14,
523,
849,
63,
3669,
436,
6952,
911,
506,
8876,
2544,
675,
14,
523,
1803,
314,
4306,
367,
314,
2013,
1475,
436,
314,
523,
666,
2138,
701,
8697,
314,
2013,
1900,
1584,
14,
523,
408,
523,
340,
1862,
365,
488,
26,
272,
1862,
275,
1052,
819,
8541,
275,
488,
523,
340,
10791,
315,
1475,
26,
272,
1475,
12,
1862,
459,
6081,
418,
275,
1475,
14,
1294,
13858,
413,
9,
819,
849,
63,
3669,
275,
1331,
14,
1574,
8,
885,
63,
3669,
9,
819,
327,
3758,
2860,
2741,
701,
642,
2240,
436,
2399,
4621,
1077,
506,
523,
327,
4310,
1663,
63,
35,
2669,
63,
44,
1573,
51,
370,
5647,
282,
15392,
298,
7010,
24471,
2,
3231,
12,
523,
327,
5126,
316,
30063,
543,
922,
436,
4834,
2860,
14,
523,
849,
63,
3669,
459,
12795,
6467,
418,
275,
1475,
819,
327,
9701,
883,
506,
282,
3537,
2366,
570,
12,
503,
701,
849,
314,
536,
402,
282,
859,
523,
327,
4453,
4902,
14,
4679,
14,
523,
340,
1475,
14,
4130,
5175,
647,
735,
272,
4306,
63,
354,
275,
747,
14,
515,
14,
7973,
8,
908,
2788,
16,
61,
272,
931,
12,
4306,
63,
354,
275,
747,
14,
515,
14,
1294,
8,
4679,
63,
354,
9,
339,
327,
4155,
3238,
314,
931,
370,
314,
3537,
4306,
365,
315,
984,
14,
515,
272,
327,
7529,
1133,
30944,
3595,
12881,
652,
5403,
781,
787,
4224,
14,
221,
1804,
1024,
4073,
314,
931,
272,
327,
370,
1924,
4306,
626,
365,
1202,
315,
984,
14,
515,
365,
12060,
394,
5362,
2003,
436,
272,
327,
1680,
85,
6665,
282,
6954,
16819,
14,
272,
931,
275,
747,
14,
515,
14,
4832,
8,
515,
9,
272,
340,
931,
440,
315,
984,
14,
515,
26,
489,
984,
14,
515,
14,
3176,
8,
16,
12,
931,
9,
523,
587,
26,
272,
4306,
63,
354,
275,
283,
6179,
14,
4679,
3530,
435,
1475,
819,
327,
5723,
2633,
787,
3032,
315,
1865,
334,
305,
25068,
370,
701,
790,
9,
523,
327,
2952,
23241,
4718,
3913,
2429,
790,
2633,
370,
636,
646,
4343,
523,
4306,
275,
636,
646,
721,
4679,
63,
354,
12,
7992,
1062,
9480,
1062,
4306,
63,
354,
9,
523,
367,
334,
498,
12,
1139,
9,
315,
4306,
14,
4679,
63,
885,
63,
3669,
14,
1744,
837,
272,
849,
63,
3669,
14,
5486,
8,
498,
12,
1139,
9,
819,
327,
25495,
314,
4306,
314,
30914,
370,
663,
4722,
2860,
4079,
641,
523,
327,
314,
1862,
652,
911,
9128,
315,
314,
1072,
7669,
14,
523,
340,
2519,
8,
4679,
12,
283,
14860,
11458,
297,
488,
304,
272,
4306,
14,
14860,
11458,
8,
885,
63,
3669,
12,
1862,
9,
819,
327,
25495,
314,
4306,
314,
30914,
370,
663,
4306,
63,
1210,
63,
815,
4079,
641,
523,
327,
314,
1862,
652,
911,
9128,
315,
314,
1072,
7669,
14,
523,
340,
2519,
8,
4679,
12,
283,
14860,
7599,
3205,
2354,
297,
488,
304,
272,
4306,
14,
14860,
7599,
3205,
2354,
8,
1162,
9,
819,
327,
16347,
314,
4306,
2488,
2256,
626,
7545,
23036,
370,
1324,
12,
781,
675,
2519,
523,
327,
880,
781,
883,
849,
7645,
436,
314,
16952,
1454,
1172,
370,
5647,
4052,
523,
327,
2985,
1929,
14,
523,
4306,
63,
1210,
63,
815,
275,
469,
272,
283,
2865,
63,
4758,
63,
1612,
356,
267,
2519,
8,
4679,
12,
283,
4679,
63,
8460,
63,
2865,
63,
4758,
63,
1612,
297,
14431,
272,
283,
515,
63,
7786,
356,
267,
2519,
8,
4679,
12,
283,
4679,
63,
8460,
63,
515,
63,
7786,
297,
14431,
272,
283,
2911,
63,
4553,
63,
509,
63,
4423,
356,
267,
2519,
8,
4679,
12,
283,
4679,
63,
2911,
63,
4553,
63,
509,
63,
4423,
297,
14431,
272,
283,
4679,
63,
9823,
63,
6048,
63,
30116,
356,
267,
2519,
8,
4679,
12,
283,
4679,
63,
9823,
63,
6048,
63,
30116,
297,
756,
395,
272,
283,
4679,
63,
28789,
63,
1986,
63,
4342,
63,
5714,
63,
23395,
356,
267,
2519,
8,
4679,
12,
355,
283,
4679,
63,
28789,
63,
1986,
63,
4342,
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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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
] |
prathik/thrift
|
tutorial/py/PythonServer.py
|
26
|
2774
|
#!/usr/bin/env python
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
import sys, glob
sys.path.append('gen-py')
sys.path.insert(0, glob.glob('../../lib/py/build/lib.*')[0])
from tutorial import Calculator
from tutorial.ttypes import *
from shared.ttypes import SharedStruct
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
class CalculatorHandler:
def __init__(self):
self.log = {}
def ping(self):
print 'ping()'
def add(self, n1, n2):
print 'add(%d,%d)' % (n1, n2)
return n1+n2
def calculate(self, logid, work):
print 'calculate(%d, %r)' % (logid, work)
if work.op == Operation.ADD:
val = work.num1 + work.num2
elif work.op == Operation.SUBTRACT:
val = work.num1 - work.num2
elif work.op == Operation.MULTIPLY:
val = work.num1 * work.num2
elif work.op == Operation.DIVIDE:
if work.num2 == 0:
x = InvalidOperation()
x.what = work.op
x.why = 'Cannot divide by 0'
raise x
val = work.num1 / work.num2
else:
x = InvalidOperation()
x.what = work.op
x.why = 'Invalid operation'
raise x
log = SharedStruct()
log.key = logid
log.value = '%d' % (val)
self.log[logid] = log
return val
def getStruct(self, key):
print 'getStruct(%d)' % (key)
return self.log[key]
def zip(self):
print 'zip()'
handler = CalculatorHandler()
processor = Calculator.Processor(handler)
transport = TSocket.TServerSocket(port=9090)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
# You could do one of these for a multithreaded server
#server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
#server = TServer.TThreadPoolServer(processor, transport, tfactory, pfactory)
print 'Starting the server...'
server.serve()
print 'done.'
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
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,
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,
1666,
314,
844,
367,
314,
199,
3,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
3,
199,
199,
646,
984,
12,
5739,
199,
1274,
14,
515,
14,
740,
360,
2268,
13,
647,
358,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
5739,
14,
6463,
360,
9707,
773,
15,
647,
15,
1506,
15,
773,
2795,
5832,
16,
566,
199,
199,
504,
307,
15888,
492,
19821,
707,
199,
504,
307,
15888,
14,
21776,
492,
627,
199,
199,
504,
5709,
14,
21776,
492,
23752,
4836,
199,
199,
504,
17199,
14,
5545,
492,
377,
3869,
199,
504,
17199,
14,
5545,
492,
19391,
199,
504,
17199,
14,
3922,
492,
15934,
199,
504,
17199,
14,
1000,
492,
377,
3120,
199,
199,
533,
19821,
707,
2461,
26,
523,
347,
636,
826,
721,
277,
304,
272,
291,
14,
793,
275,
1052,
819,
347,
18249,
8,
277,
304,
272,
870,
283,
4073,
11716,
819,
347,
1050,
8,
277,
12,
302,
17,
12,
302,
18,
304,
272,
870,
283,
525,
4042,
68,
8719,
68,
3171,
450,
334,
78,
17,
12,
302,
18,
9,
272,
372,
302,
17,
11,
78,
18,
819,
347,
8671,
8,
277,
12,
943,
344,
12,
1736,
304,
272,
870,
283,
12063,
4042,
68,
12,
450,
82,
3171,
450,
334,
793,
344,
12,
1736,
9,
339,
340,
1736,
14,
411,
508,
17954,
14,
9732,
26,
489,
1139,
275,
1736,
14,
1507,
17,
435,
1736,
14,
1507,
18,
272,
916,
1736,
14,
411,
508,
17954,
14,
6348,
22280,
26,
489,
1139,
275,
1736,
14,
1507,
17,
446,
1736,
14,
1507,
18,
272,
916,
1736,
14,
411,
508,
17954,
14,
21894,
6084,
26,
489,
1139,
275,
1736,
14,
1507,
17,
627,
1736,
14,
1507,
18,
272,
916,
1736,
14,
411,
508,
17954,
14,
1914,
5437,
37,
26,
489,
340,
1736,
14,
1507,
18,
508,
378,
26,
267,
671,
275,
6378,
6044,
342,
267,
671,
14,
10058,
275,
1736,
14,
411,
267,
671,
14,
26460,
275,
283,
6612,
23003,
701,
378,
7,
267,
746,
671,
489,
1139,
275,
1736,
14,
1507,
17,
1182,
1736,
14,
1507,
18,
272,
587,
26,
489,
671,
275,
6378,
6044,
342,
489,
671,
14,
10058,
275,
1736,
14,
411,
489,
671,
14,
26460,
275,
283,
3364,
3439,
7,
489,
746,
671,
339,
943,
275,
23752,
4836,
342,
272,
943,
14,
498,
275,
943,
344,
272,
943,
14,
585,
275,
1543,
68,
7,
450,
334,
637,
9,
272,
291,
14,
793,
59,
793,
344,
61,
275,
943,
339,
372,
1139,
819,
347,
664,
4836,
8,
277,
12,
790,
304,
272,
870,
283,
362,
4836,
4042,
68,
3171,
450,
334,
498,
9,
272,
372,
291,
14,
793,
59,
498,
61,
819,
347,
3482,
8,
277,
304,
272,
870,
283,
3065,
11716,
199,
199,
2232,
275,
19821,
707,
2461,
342,
199,
6459,
275,
19821,
707,
14,
10438,
8,
2232,
9,
199,
5545,
275,
377,
3869,
14,
52,
3120,
3869,
8,
719,
29,
25,
18526,
9,
199,
84,
3702,
275,
19391,
14,
52,
23139,
7836,
2927,
342,
199,
80,
3702,
275,
15934,
14,
16805,
2927,
342,
199,
199,
1000,
275,
377,
3120,
14,
52,
3184,
3120,
8,
6459,
12,
7773,
12,
307,
3702,
12,
299,
3702,
9,
199,
199,
3,
2047,
4293,
886,
1373,
402,
3520,
367,
282,
3510,
19710,
1654,
199,
3,
1000,
275,
377,
3120,
14,
1481,
72,
11698,
3120,
8,
6459,
12,
7773,
12,
307,
3702,
12,
299,
3702,
9,
199,
3,
1000,
275,
377,
3120,
14,
1481,
72,
739,
5453,
3120,
8,
6459,
12,
7773,
12,
307,
3702,
12,
299,
3702,
9,
199,
199,
1361,
283,
14139,
314,
1654,
13698,
199,
1000,
14,
4909,
342,
199,
1361,
283,
4456,
3530,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
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,
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,
1666,
314,
844,
367,
314,
199,
3,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
3,
199,
199,
646,
984,
12,
5739,
199,
1274,
14,
515,
14,
740,
360,
2268,
13,
647,
358,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
5739,
14,
6463,
360,
9707,
773,
15,
647,
15,
1506,
15,
773,
2795,
5832,
16,
566,
199,
199,
504,
307,
15888,
492,
19821,
707,
199,
504,
307,
15888,
14,
21776,
492,
627,
199,
199,
504,
5709,
14,
21776,
492,
23752,
4836,
199,
199,
504,
17199,
14,
5545,
492,
377,
3869,
199,
504,
17199,
14,
5545,
492,
19391,
199,
504,
17199,
14,
3922,
492,
15934,
199,
504,
17199,
14,
1000,
492,
377,
3120,
199,
199,
533,
19821,
707,
2461,
26,
523,
347,
636,
826,
721,
277,
304,
272,
291,
14,
793,
275,
1052,
819,
347,
18249,
8,
277,
304,
272,
870,
283,
4073,
11716,
819,
347,
1050,
8,
277,
12,
302,
17,
12,
302,
18,
304,
272,
870,
283,
525,
4042,
68,
8719,
68,
3171,
450,
334,
78,
17,
12,
302,
18,
9,
272,
372,
302,
17,
11,
78,
18,
819,
347,
8671,
8,
277,
12,
943,
344,
12,
1736,
304,
272,
870,
283,
12063,
4042,
68,
12,
450,
82,
3171,
450,
334,
793,
344,
12,
1736,
9,
339,
340,
1736,
14,
411,
508,
17954,
14,
9732,
26,
489,
1139,
275,
1736,
14,
1507,
17,
435,
1736,
14,
1507,
18,
272,
916,
1736,
14,
411,
508,
17954,
14,
6348,
22280,
26,
489,
1139,
275,
1736,
14,
1507,
17,
446,
1736,
14,
1507,
18,
272,
916,
1736,
14,
411,
508,
17954,
14,
21894,
6084,
26,
489,
1139,
275,
1736,
14,
1507,
17,
627,
1736,
14,
1507,
18,
272,
916,
1736,
14,
411,
508,
17954,
14,
1914,
5437,
37,
26,
489,
340,
1736,
14,
1507,
18,
508,
378,
26,
267,
671,
275,
6378,
6044,
342,
267,
671,
14,
10058,
275,
1736,
14,
411,
267,
671,
14,
26460,
275,
283,
6612,
23003,
701,
378,
7,
267,
746,
671,
489,
1139,
275,
1736,
14,
1507,
17,
1182,
1736,
14,
1507,
18,
272,
587,
26,
489,
671,
275,
6378,
6044,
342,
489,
671,
14,
10058,
275,
1736,
14,
411,
489,
671,
14,
26460,
275,
283,
3364,
3439,
7,
489,
746,
671,
339,
943,
275,
23752,
4836,
342,
272,
943,
14,
498,
275,
943,
344,
272,
943,
14,
585,
275,
1543,
68,
7,
450,
334,
637,
9,
272,
291,
14,
793,
59,
793,
344,
61,
275,
943,
339,
372,
1139,
819,
347,
664,
4836,
8,
277,
12,
790,
304,
272,
870,
283,
362,
4836,
4042,
68,
3171,
450,
334,
498,
9,
272,
372,
291,
14,
793,
59,
498,
61,
819,
347,
3482,
8,
277,
304,
272,
870,
283,
3065,
11716,
199,
199,
2232,
275,
19821,
707,
2461,
342,
199,
6459,
275,
19821,
707,
14,
10438,
8,
2232,
9,
199,
5545,
275,
377,
3869,
14,
52,
3120,
3869,
8,
719,
29,
25,
18526,
9,
199,
84,
3702,
275,
19391,
14,
52,
23139,
7836,
2927,
342,
199,
80,
3702,
275,
15934,
14,
16805,
2927,
342,
199,
199,
1000,
275,
377,
3120,
14,
52,
3184,
3120,
8,
6459,
12,
7773,
12,
307,
3702,
12,
299,
3702,
9,
199,
199,
3,
2047,
4293,
886,
1373,
402,
3520,
367,
282,
3510,
19710,
1654,
199,
3,
1000,
275,
377,
3120,
14,
1481,
72,
11698,
3120,
8,
6459,
12,
7773,
12,
307,
3702,
12,
299,
3702,
9,
199,
3,
1000,
275,
377,
3120,
14,
1481,
72,
739,
5453,
3120,
8,
6459,
12,
7773,
12,
307,
3702,
12,
299,
3702,
9,
199,
199,
1361,
283,
14139,
314,
1654,
13698,
199,
1000,
14,
4909,
342,
199,
1361,
283,
4456,
3530,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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Minio Python Library for Amazon S3 Compatible Cloud Storage, (C) 2015 Minio, 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.
# Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-prefixname
# are dummy values, please replace them with original values.
from minio import Minio
client = Minio('s3.amazonaws.com',
access_key='YOUR-ACCESSKEYID',
secret_key='YOUR-SECRETACCESSKEY')
# List all object paths in bucket that begin with my-prefixname.
objects = client.list_objects('my-bucketname', prefix='my-prefixname',
recursive=True)
for obj in objects:
print(obj.bucket_name, obj.object_name.encode('utf-8'), obj.last_modified,
obj.etag, obj.size, obj.content_type)
# List all object paths in bucket that begin with my-prefixname using
# V2 listing API.
objects = client.list_objects_v2('my-bucketname', prefix='my-prefixname',
recursive=True)
for obj in objects:
print(obj.bucket_name, obj.object_name.encode('utf-8'), obj.last_modified,
obj.etag, obj.size, obj.content_type)
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
10195,
2308,
2018,
11243,
367,
14347,
428,
19,
3599,
4727,
8142,
10533,
12,
334,
35,
9,
6900,
10195,
2308,
12,
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,
199,
3,
3390,
26,
1488,
11237,
13,
11074,
3078,
998,
12,
1488,
11237,
13,
12961,
11074,
3078,
12,
3002,
13,
4623,
354,
436,
3002,
13,
1861,
354,
199,
3,
787,
7283,
1338,
12,
8749,
3350,
3062,
543,
3379,
1338,
14,
199,
199,
504,
1748,
2308,
492,
10195,
2308,
199,
199,
1258,
275,
10195,
2308,
360,
83,
19,
14,
21442,
14,
957,
297,
2049,
2879,
63,
498,
534,
57,
11237,
13,
11074,
3078,
998,
297,
2049,
7565,
63,
498,
534,
57,
11237,
13,
12961,
11074,
3078,
358,
199,
199,
3,
3820,
1006,
909,
3792,
315,
5315,
626,
5386,
543,
3002,
13,
1861,
354,
14,
199,
1462,
275,
1890,
14,
513,
63,
1462,
360,
1662,
13,
4623,
354,
297,
2403,
534,
1662,
13,
1861,
354,
297,
2892,
9133,
29,
549,
9,
199,
509,
1559,
315,
2251,
26,
272,
870,
8,
1113,
14,
4623,
63,
354,
12,
1559,
14,
785,
63,
354,
14,
2143,
360,
1624,
13,
24,
659,
1559,
14,
2019,
63,
5540,
12,
881,
1559,
14,
11304,
12,
1559,
14,
890,
12,
1559,
14,
1317,
63,
466,
9,
199,
199,
3,
3820,
1006,
909,
3792,
315,
5315,
626,
5386,
543,
3002,
13,
1861,
354,
1808,
199,
3,
812,
18,
13778,
3261,
14,
199,
1462,
275,
1890,
14,
513,
63,
1462,
63,
86,
18,
360,
1662,
13,
4623,
354,
297,
2403,
534,
1662,
13,
1861,
354,
297,
2892,
9133,
29,
549,
9,
199,
509,
1559,
315,
2251,
26,
272,
870,
8,
1113,
14,
4623,
63,
354,
12,
1559,
14,
785,
63,
354,
14,
2143,
360,
1624,
13,
24,
659,
1559,
14,
2019,
63,
5540,
12,
881,
1559,
14,
11304,
12,
1559,
14,
890,
12,
1559,
14,
1317,
63,
466,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
10195,
2308,
2018,
11243,
367,
14347,
428,
19,
3599,
4727,
8142,
10533,
12,
334,
35,
9,
6900,
10195,
2308,
12,
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,
199,
3,
3390,
26,
1488,
11237,
13,
11074,
3078,
998,
12,
1488,
11237,
13,
12961,
11074,
3078,
12,
3002,
13,
4623,
354,
436,
3002,
13,
1861,
354,
199,
3,
787,
7283,
1338,
12,
8749,
3350,
3062,
543,
3379,
1338,
14,
199,
199,
504,
1748,
2308,
492,
10195,
2308,
199,
199,
1258,
275,
10195,
2308,
360,
83,
19,
14,
21442,
14,
957,
297,
2049,
2879,
63,
498,
534,
57,
11237,
13,
11074,
3078,
998,
297,
2049,
7565,
63,
498,
534,
57,
11237,
13,
12961,
11074,
3078,
358,
199,
199,
3,
3820,
1006,
909,
3792,
315,
5315,
626,
5386,
543,
3002,
13,
1861,
354,
14,
199,
1462,
275,
1890,
14,
513,
63,
1462,
360,
1662,
13,
4623,
354,
297,
2403,
534,
1662,
13,
1861,
354,
297,
2892,
9133,
29,
549,
9,
199,
509,
1559,
315,
2251,
26,
272,
870,
8,
1113,
14,
4623,
63,
354,
12,
1559,
14,
785,
63,
354,
14,
2143,
360,
1624,
13,
24,
659,
1559,
14,
2019,
63,
5540,
12,
881,
1559,
14,
11304,
12,
1559,
14,
890,
12,
1559,
14,
1317,
63,
466,
9,
199,
199,
3,
3820,
1006,
909,
3792,
315,
5315,
626,
5386,
543,
3002,
13,
1861,
354,
1808,
199,
3,
812,
18,
13778,
3261,
14,
199,
1462,
275,
1890,
14,
513,
63,
1462,
63,
86,
18,
360,
1662,
13,
4623,
354,
297,
2403,
534,
1662,
13,
1861,
354,
297,
2892,
9133,
29,
549,
9,
199,
509,
1559,
315,
2251,
26,
272,
870,
8,
1113,
14,
4623,
63,
354,
12,
1559,
14,
785,
63,
354,
14,
2143,
360,
1624,
13,
24,
659,
1559,
14,
2019,
63,
5540,
12,
881,
1559,
14,
11304,
12,
1559,
14,
890,
12,
1559,
14,
1317,
63,
466,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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
] |
IKholopov/HackUPC2017
|
hackupc/env/lib/python3.5/site-packages/django/db/models/options.py
|
28
|
34250
|
from __future__ import unicode_literals
import copy
import warnings
from bisect import bisect
from collections import OrderedDict, defaultdict
from itertools import chain
from django.apps import apps
from django.conf import settings
from django.core.exceptions import FieldDoesNotExist
from django.db import connections
from django.db.models import Manager
from django.db.models.fields import AutoField
from django.db.models.fields.proxy import OrderWrt
from django.utils import six
from django.utils.datastructures import ImmutableList, OrderedSet
from django.utils.deprecation import (
RemovedInDjango20Warning, warn_about_renamed_method,
)
from django.utils.encoding import (
force_text, python_2_unicode_compatible, smart_text,
)
from django.utils.functional import cached_property
from django.utils.text import camel_case_to_spaces
from django.utils.translation import override, string_concat
NOT_PROVIDED = object()
PROXY_PARENTS = object()
EMPTY_RELATION_TREE = tuple()
IMMUTABLE_WARNING = (
"The return type of '%s' should never be mutated. If you want to manipulate this list "
"for your own use, make a copy first."
)
DEFAULT_NAMES = (
'verbose_name', 'verbose_name_plural', 'db_table', 'ordering',
'unique_together', 'permissions', 'get_latest_by', 'order_with_respect_to',
'app_label', 'db_tablespace', 'abstract', 'managed', 'proxy', 'swappable',
'auto_created', 'index_together', 'apps', 'default_permissions',
'select_on_save', 'default_related_name', 'required_db_features',
'required_db_vendor', 'base_manager_name', 'default_manager_name',
'manager_inheritance_from_future',
)
def normalize_together(option_together):
"""
option_together can be either a tuple of tuples, or a single
tuple of two strings. Normalize it to a tuple of tuples, so that
calling code can uniformly expect that.
"""
try:
if not option_together:
return ()
if not isinstance(option_together, (tuple, list)):
raise TypeError
first_element = next(iter(option_together))
if not isinstance(first_element, (tuple, list)):
option_together = (option_together,)
# Normalize everything to tuples
return tuple(tuple(ot) for ot in option_together)
except TypeError:
# If the value of option_together isn't valid, return it
# verbatim; this will be picked up by the check framework later.
return option_together
def make_immutable_fields_list(name, data):
return ImmutableList(data, warning=IMMUTABLE_WARNING % name)
@python_2_unicode_compatible
class Options(object):
FORWARD_PROPERTIES = {
'fields', 'many_to_many', 'concrete_fields', 'local_concrete_fields',
'_forward_fields_map', 'managers', 'managers_map', 'base_manager',
'default_manager',
}
REVERSE_PROPERTIES = {'related_objects', 'fields_map', '_relation_tree'}
default_apps = apps
def __init__(self, meta, app_label=None):
self._get_fields_cache = {}
self.local_fields = []
self.local_many_to_many = []
self.private_fields = []
self.manager_inheritance_from_future = False
self.local_managers = []
self.base_manager_name = None
self.default_manager_name = None
self.model_name = None
self.verbose_name = None
self.verbose_name_plural = None
self.db_table = ''
self.ordering = []
self._ordering_clash = False
self.unique_together = []
self.index_together = []
self.select_on_save = False
self.default_permissions = ('add', 'change', 'delete')
self.permissions = []
self.object_name = None
self.app_label = app_label
self.get_latest_by = None
self.order_with_respect_to = None
self.db_tablespace = settings.DEFAULT_TABLESPACE
self.required_db_features = []
self.required_db_vendor = None
self.meta = meta
self.pk = None
self.has_auto_field = False
self.auto_field = None
self.abstract = False
self.managed = True
self.proxy = False
# For any class that is a proxy (including automatically created
# classes for deferred object loading), proxy_for_model tells us
# which class this model is proxying. Note that proxy_for_model
# can create a chain of proxy models. For non-proxy models, the
# variable is always None.
self.proxy_for_model = None
# For any non-abstract class, the concrete class is the model
# in the end of the proxy_for_model chain. In particular, for
# concrete models, the concrete_model is always the class itself.
self.concrete_model = None
self.swappable = None
self.parents = OrderedDict()
self.auto_created = False
# List of all lookups defined in ForeignKey 'limit_choices_to' options
# from *other* models. Needed for some admin checks. Internal use only.
self.related_fkey_lookups = []
# A custom app registry to use, if you're making a separate model set.
self.apps = self.default_apps
self.default_related_name = None
@property
def label(self):
return '%s.%s' % (self.app_label, self.object_name)
@property
def label_lower(self):
return '%s.%s' % (self.app_label, self.model_name)
@property
def app_config(self):
# Don't go through get_app_config to avoid triggering imports.
return self.apps.app_configs.get(self.app_label)
@property
def installed(self):
return self.app_config is not None
def contribute_to_class(self, cls, name):
from django.db import connection
from django.db.backends.utils import truncate_name
cls._meta = self
self.model = cls
# First, construct the default values for these options.
self.object_name = cls.__name__
self.model_name = self.object_name.lower()
self.verbose_name = camel_case_to_spaces(self.object_name)
# Store the original user-defined values for each option,
# for use when serializing the model definition
self.original_attrs = {}
# Next, apply any overridden values from 'class Meta'.
if self.meta:
meta_attrs = self.meta.__dict__.copy()
for name in self.meta.__dict__:
# Ignore any private attributes that Django doesn't care about.
# NOTE: We can't modify a dictionary's contents while looping
# over it, so we loop over the *original* dictionary instead.
if name.startswith('_'):
del meta_attrs[name]
for attr_name in DEFAULT_NAMES:
if attr_name in meta_attrs:
setattr(self, attr_name, meta_attrs.pop(attr_name))
self.original_attrs[attr_name] = getattr(self, attr_name)
elif hasattr(self.meta, attr_name):
setattr(self, attr_name, getattr(self.meta, attr_name))
self.original_attrs[attr_name] = getattr(self, attr_name)
self.unique_together = normalize_together(self.unique_together)
self.index_together = normalize_together(self.index_together)
# verbose_name_plural is a special case because it uses a 's'
# by default.
if self.verbose_name_plural is None:
self.verbose_name_plural = string_concat(self.verbose_name, 's')
# order_with_respect_and ordering are mutually exclusive.
self._ordering_clash = bool(self.ordering and self.order_with_respect_to)
# Any leftover attributes must be invalid.
if meta_attrs != {}:
raise TypeError("'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()))
else:
self.verbose_name_plural = string_concat(self.verbose_name, 's')
del self.meta
# If the db_table wasn't provided, use the app_label + model_name.
if not self.db_table:
self.db_table = "%s_%s" % (self.app_label, self.model_name)
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
def _prepare(self, model):
if self.order_with_respect_to:
# The app registry will not be ready at this point, so we cannot
# use get_field().
query = self.order_with_respect_to
try:
self.order_with_respect_to = next(
f for f in self._get_fields(reverse=False)
if f.name == query or f.attname == query
)
except StopIteration:
raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, query))
self.ordering = ('_order',)
if not any(isinstance(field, OrderWrt) for field in model._meta.local_fields):
model.add_to_class('_order', OrderWrt())
else:
self.order_with_respect_to = None
if self.pk is None:
if self.parents:
# Promote the first parent link in lieu of adding yet another
# field.
field = next(six.itervalues(self.parents))
# Look for a local field with the same name as the
# first parent link. If a local field has already been
# created, use it instead of promoting the parent
already_created = [fld for fld in self.local_fields if fld.name == field.name]
if already_created:
field = already_created[0]
field.primary_key = True
self.setup_pk(field)
if not field.remote_field.parent_link:
warnings.warn(
'Add parent_link=True to %s as an implicit link is '
'deprecated.' % field, RemovedInDjango20Warning
)
else:
auto = AutoField(verbose_name='ID', primary_key=True, auto_created=True)
model.add_to_class('id', auto)
def add_manager(self, manager):
self.local_managers.append(manager)
self._expire_cache()
def add_field(self, field, private=False, virtual=NOT_PROVIDED):
if virtual is not NOT_PROVIDED:
warnings.warn(
"The `virtual` argument of Options.add_field() has been renamed to `private`.",
RemovedInDjango20Warning, stacklevel=2
)
private = virtual
# Insert the given field in the order in which it was created, using
# the "creation_counter" attribute of the field.
# Move many-to-many related fields from self.fields into
# self.many_to_many.
if private:
self.private_fields.append(field)
elif field.is_relation and field.many_to_many:
self.local_many_to_many.insert(bisect(self.local_many_to_many, field), field)
else:
self.local_fields.insert(bisect(self.local_fields, field), field)
self.setup_pk(field)
# If the field being added is a relation to another known field,
# expire the cache on this field and the forward cache on the field
# being referenced, because there will be new relationships in the
# cache. Otherwise, expire the cache of references *to* this field.
# The mechanism for getting at the related model is slightly odd -
# ideally, we'd just ask for field.related_model. However, related_model
# is a cached property, and all the models haven't been loaded yet, so
# we need to make sure we don't cache a string reference.
if field.is_relation and hasattr(field.remote_field, 'model') and field.remote_field.model:
try:
field.remote_field.model._meta._expire_cache(forward=False)
except AttributeError:
pass
self._expire_cache()
else:
self._expire_cache(reverse=False)
def setup_pk(self, field):
if not self.pk and field.primary_key:
self.pk = field
field.serialize = False
def setup_proxy(self, target):
"""
Does the internal setup so that the current model is a proxy for
"target".
"""
self.pk = target._meta.pk
self.proxy_for_model = target
self.db_table = target._meta.db_table
def __repr__(self):
return '<Options for %s>' % self.object_name
def __str__(self):
return "%s.%s" % (smart_text(self.app_label), smart_text(self.model_name))
def can_migrate(self, connection):
"""
Return True if the model can/should be migrated on the `connection`.
`connection` can be either a real connection or a connection alias.
"""
if self.proxy or self.swapped or not self.managed:
return False
if isinstance(connection, six.string_types):
connection = connections[connection]
if self.required_db_vendor:
return self.required_db_vendor == connection.vendor
if self.required_db_features:
return all(getattr(connection.features, feat, False)
for feat in self.required_db_features)
return True
@property
def verbose_name_raw(self):
"""
There are a few places where the untranslated verbose name is needed
(so that we get the same value regardless of currently active
locale).
"""
with override(None):
return force_text(self.verbose_name)
@property
def swapped(self):
"""
Has this model been swapped out for another? If so, return the model
name of the replacement; otherwise, return None.
For historical reasons, model name lookups using get_model() are
case insensitive, so we make sure we are case insensitive here.
"""
if self.swappable:
swapped_for = getattr(settings, self.swappable, None)
if swapped_for:
try:
swapped_label, swapped_object = swapped_for.split('.')
except ValueError:
# setting not in the format app_label.model_name
# raising ImproperlyConfigured here causes problems with
# test cleanup code - instead it is raised in get_user_model
# or as part of validation.
return swapped_for
if '%s.%s' % (swapped_label, swapped_object.lower()) != self.label_lower:
return swapped_for
return None
@cached_property
def managers(self):
managers = []
seen_managers = set()
bases = (b for b in self.model.mro() if hasattr(b, '_meta'))
for depth, base in enumerate(bases):
for manager in base._meta.local_managers:
if manager.name in seen_managers:
continue
manager = copy.copy(manager)
manager.model = self.model
seen_managers.add(manager.name)
managers.append((depth, manager.creation_counter, manager))
# Used for deprecation of legacy manager inheritance,
# remove afterwards. (RemovedInDjango20Warning)
manager._originating_model = base
return make_immutable_fields_list(
"managers",
(m[2] for m in sorted(managers)),
)
@cached_property
def managers_map(self):
return {manager.name: manager for manager in self.managers}
@cached_property
def base_manager(self):
base_manager_name = self.base_manager_name
if not base_manager_name:
# Get the first parent's base_manager_name if there's one.
for parent in self.model.mro()[1:]:
if hasattr(parent, '_meta'):
if parent._base_manager.name != '_base_manager':
base_manager_name = parent._base_manager.name
break
if base_manager_name:
try:
return self.managers_map[base_manager_name]
except KeyError:
raise ValueError(
"%s has no manager named %r" % (
self.object_name,
base_manager_name,
)
)
# Deprecation shim for `use_for_related_fields`.
for i, base_manager_class in enumerate(self.default_manager.__class__.mro()):
if getattr(base_manager_class, 'use_for_related_fields', False):
if not getattr(base_manager_class, 'silence_use_for_related_fields_deprecation', False):
warnings.warn(
"use_for_related_fields is deprecated, instead "
"set Meta.base_manager_name on '{}'.".format(self.model._meta.label),
RemovedInDjango20Warning, 2
)
if i == 0:
manager = self.default_manager
else:
manager = base_manager_class()
manager.name = '_base_manager'
manager.model = self.model
return manager
manager = Manager()
manager.name = '_base_manager'
manager.model = self.model
manager.auto_created = True
return manager
@cached_property
def default_manager(self):
default_manager_name = self.default_manager_name
if not default_manager_name and not self.local_managers:
# Get the first parent's default_manager_name if there's one.
for parent in self.model.mro()[1:]:
if hasattr(parent, '_meta'):
default_manager_name = parent._meta.default_manager_name
break
if default_manager_name:
try:
return self.managers_map[default_manager_name]
except KeyError:
raise ValueError(
"%s has no manager named %r" % (
self.object_name,
default_manager_name,
)
)
if self.managers:
return self.managers[0]
@cached_property
def fields(self):
"""
Returns a list of all forward fields on the model and its parents,
excluding ManyToManyFields.
Private API intended only to be used by Django itself; get_fields()
combined with filtering of field properties is the public API for
obtaining this field list.
"""
# For legacy reasons, the fields property should only contain forward
# fields that are not private or with a m2m cardinality. Therefore we
# pass these three filters as filters to the generator.
# The third lambda is a longwinded way of checking f.related_model - we don't
# use that property directly because related_model is a cached property,
# and all the models may not have been loaded yet; we don't want to cache
# the string reference to the related_model.
def is_not_an_m2m_field(f):
return not (f.is_relation and f.many_to_many)
def is_not_a_generic_relation(f):
return not (f.is_relation and f.one_to_many)
def is_not_a_generic_foreign_key(f):
return not (
f.is_relation and f.many_to_one and not (hasattr(f.remote_field, 'model') and f.remote_field.model)
)
return make_immutable_fields_list(
"fields",
(f for f in self._get_fields(reverse=False)
if is_not_an_m2m_field(f) and is_not_a_generic_relation(f) and is_not_a_generic_foreign_key(f))
)
@cached_property
def concrete_fields(self):
"""
Returns a list of all concrete fields on the model and its parents.
Private API intended only to be used by Django itself; get_fields()
combined with filtering of field properties is the public API for
obtaining this field list.
"""
return make_immutable_fields_list(
"concrete_fields", (f for f in self.fields if f.concrete)
)
@property
@warn_about_renamed_method(
'Options', 'virtual_fields', 'private_fields',
RemovedInDjango20Warning
)
def virtual_fields(self):
return self.private_fields
@cached_property
def local_concrete_fields(self):
"""
Returns a list of all concrete fields on the model.
Private API intended only to be used by Django itself; get_fields()
combined with filtering of field properties is the public API for
obtaining this field list.
"""
return make_immutable_fields_list(
"local_concrete_fields", (f for f in self.local_fields if f.concrete)
)
@cached_property
def many_to_many(self):
"""
Returns a list of all many to many fields on the model and its parents.
Private API intended only to be used by Django itself; get_fields()
combined with filtering of field properties is the public API for
obtaining this list.
"""
return make_immutable_fields_list(
"many_to_many",
(f for f in self._get_fields(reverse=False) if f.is_relation and f.many_to_many)
)
@cached_property
def related_objects(self):
"""
Returns all related objects pointing to the current model. The related
objects can come from a one-to-one, one-to-many, or many-to-many field
relation type.
Private API intended only to be used by Django itself; get_fields()
combined with filtering of field properties is the public API for
obtaining this field list.
"""
all_related_fields = self._get_fields(forward=False, reverse=True, include_hidden=True)
return make_immutable_fields_list(
"related_objects",
(obj for obj in all_related_fields if not obj.hidden or obj.field.many_to_many)
)
@cached_property
def _forward_fields_map(self):
res = {}
fields = self._get_fields(reverse=False)
for field in fields:
res[field.name] = field
# Due to the way Django's internals work, get_field() should also
# be able to fetch a field by attname. In the case of a concrete
# field with relation, includes the *_id name too
try:
res[field.attname] = field
except AttributeError:
pass
return res
@cached_property
def fields_map(self):
res = {}
fields = self._get_fields(forward=False, include_hidden=True)
for field in fields:
res[field.name] = field
# Due to the way Django's internals work, get_field() should also
# be able to fetch a field by attname. In the case of a concrete
# field with relation, includes the *_id name too
try:
res[field.attname] = field
except AttributeError:
pass
return res
def get_field(self, field_name):
"""
Return a field instance given the name of a forward or reverse field.
"""
try:
# In order to avoid premature loading of the relation tree
# (expensive) we prefer checking if the field is a forward field.
return self._forward_fields_map[field_name]
except KeyError:
# If the app registry is not ready, reverse fields are
# unavailable, therefore we throw a FieldDoesNotExist exception.
if not self.apps.models_ready:
raise FieldDoesNotExist(
"%s has no field named %r. The app cache isn't ready yet, "
"so if this is an auto-created related field, it won't "
"be available yet." % (self.object_name, field_name)
)
try:
# Retrieve field instance by name from cached or just-computed
# field map.
return self.fields_map[field_name]
except KeyError:
raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, field_name))
def get_base_chain(self, model):
"""
Return a list of parent classes leading to `model` (ordered from
closest to most distant ancestor). This has to handle the case where
`model` is a grandparent or even more distant relation.
"""
if not self.parents:
return []
if model in self.parents:
return [model]
for parent in self.parents:
res = parent._meta.get_base_chain(model)
if res:
res.insert(0, parent)
return res
return []
def get_parent_list(self):
"""
Returns all the ancestors of this model as a list ordered by MRO.
Useful for determining if something is an ancestor, regardless of lineage.
"""
result = OrderedSet(self.parents)
for parent in self.parents:
for ancestor in parent._meta.get_parent_list():
result.add(ancestor)
return list(result)
def get_ancestor_link(self, ancestor):
"""
Returns the field on the current model which points to the given
"ancestor". This is possible an indirect link (a pointer to a parent
model, which points, eventually, to the ancestor). Used when
constructing table joins for model inheritance.
Returns None if the model isn't an ancestor of this one.
"""
if ancestor in self.parents:
return self.parents[ancestor]
for parent in self.parents:
# Tries to get a link field from the immediate parent
parent_link = parent._meta.get_ancestor_link(ancestor)
if parent_link:
# In case of a proxied model, the first link
# of the chain to the ancestor is that parent
# links
return self.parents[parent] or parent_link
def _populate_directed_relation_graph(self):
"""
This method is used by each model to find its reverse objects. As this
method is very expensive and is accessed frequently (it looks up every
field in a model, in every app), it is computed on first access and then
is set as a property on every model.
"""
related_objects_graph = defaultdict(list)
all_models = self.apps.get_models(include_auto_created=True)
for model in all_models:
opts = model._meta
# Abstract model's fields are copied to child models, hence we will
# see the fields from the child models.
if opts.abstract:
continue
fields_with_relations = (
f for f in opts._get_fields(reverse=False, include_parents=False)
if f.is_relation and f.related_model is not None
)
for f in fields_with_relations:
if not isinstance(f.remote_field.model, six.string_types):
related_objects_graph[f.remote_field.model._meta.concrete_model._meta].append(f)
for model in all_models:
# Set the relation_tree using the internal __dict__. In this way
# we avoid calling the cached property. In attribute lookup,
# __dict__ takes precedence over a data descriptor (such as
# @cached_property). This means that the _meta._relation_tree is
# only called if related_objects is not in __dict__.
related_objects = related_objects_graph[model._meta.concrete_model._meta]
model._meta.__dict__['_relation_tree'] = related_objects
# It seems it is possible that self is not in all_models, so guard
# against that with default for get().
return self.__dict__.get('_relation_tree', EMPTY_RELATION_TREE)
@cached_property
def _relation_tree(self):
return self._populate_directed_relation_graph()
def _expire_cache(self, forward=True, reverse=True):
# This method is usually called by apps.cache_clear(), when the
# registry is finalized, or when a new field is added.
if forward:
for cache_key in self.FORWARD_PROPERTIES:
if cache_key in self.__dict__:
delattr(self, cache_key)
if reverse and not self.abstract:
for cache_key in self.REVERSE_PROPERTIES:
if cache_key in self.__dict__:
delattr(self, cache_key)
self._get_fields_cache = {}
def get_fields(self, include_parents=True, include_hidden=False):
"""
Returns a list of fields associated to the model. By default, includes
forward and reverse fields, fields derived from inheritance, but not
hidden fields. The returned fields can be changed using the parameters:
- include_parents: include fields derived from inheritance
- include_hidden: include fields that have a related_name that
starts with a "+"
"""
if include_parents is False:
include_parents = PROXY_PARENTS
return self._get_fields(include_parents=include_parents, include_hidden=include_hidden)
def _get_fields(self, forward=True, reverse=True, include_parents=True, include_hidden=False,
seen_models=None):
"""
Internal helper function to return fields of the model.
* If forward=True, then fields defined on this model are returned.
* If reverse=True, then relations pointing to this model are returned.
* If include_hidden=True, then fields with is_hidden=True are returned.
* The include_parents argument toggles if fields from parent models
should be included. It has three values: True, False, and
PROXY_PARENTS. When set to PROXY_PARENTS, the call will return all
fields defined for the current model or any of its parents in the
parent chain to the model's concrete model.
"""
if include_parents not in (True, False, PROXY_PARENTS):
raise TypeError("Invalid argument for include_parents: %s" % (include_parents,))
# This helper function is used to allow recursion in ``get_fields()``
# implementation and to provide a fast way for Django's internals to
# access specific subsets of fields.
# We must keep track of which models we have already seen. Otherwise we
# could include the same field multiple times from different models.
topmost_call = False
if seen_models is None:
seen_models = set()
topmost_call = True
seen_models.add(self.model)
# Creates a cache key composed of all arguments
cache_key = (forward, reverse, include_parents, include_hidden, topmost_call)
try:
# In order to avoid list manipulation. Always return a shallow copy
# of the results.
return self._get_fields_cache[cache_key]
except KeyError:
pass
fields = []
# Recursively call _get_fields() on each parent, with the same
# options provided in this call.
if include_parents is not False:
for parent in self.parents:
# In diamond inheritance it is possible that we see the same
# model from two different routes. In that case, avoid adding
# fields from the same parent again.
if parent in seen_models:
continue
if (parent._meta.concrete_model != self.concrete_model and
include_parents == PROXY_PARENTS):
continue
for obj in parent._meta._get_fields(
forward=forward, reverse=reverse, include_parents=include_parents,
include_hidden=include_hidden, seen_models=seen_models):
if getattr(obj, 'parent_link', False) and obj.model != self.concrete_model:
continue
fields.append(obj)
if reverse and not self.proxy:
# Tree is computed once and cached until the app cache is expired.
# It is composed of a list of fields pointing to the current model
# from other models.
all_fields = self._relation_tree
for field in all_fields:
# If hidden fields should be included or the relation is not
# intentionally hidden, add to the fields dict.
if include_hidden or not field.remote_field.hidden:
fields.append(field.remote_field)
if forward:
fields.extend(
field for field in chain(self.local_fields, self.local_many_to_many)
)
# Private fields are recopied to each child model, and they get a
# different model as field.model in each child. Hence we have to
# add the private fields separately from the topmost call. If we
# did this recursively similar to local_fields, we would get field
# instances with field.model != self.model.
if topmost_call:
fields.extend(
f for f in self.private_fields
)
# In order to avoid list manipulation. Always
# return a shallow copy of the results
fields = make_immutable_fields_list("get_fields()", fields)
# Store result into cache for later access
self._get_fields_cache[cache_key] = fields
return fields
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
1331,
199,
646,
3598,
199,
504,
19063,
492,
19063,
199,
504,
5055,
492,
8773,
12,
10018,
199,
504,
7975,
492,
6036,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
3924,
492,
29994,
199,
504,
1639,
14,
697,
492,
6947,
199,
504,
1639,
14,
697,
14,
992,
492,
13537,
199,
504,
1639,
14,
697,
14,
992,
14,
955,
492,
9195,
792,
199,
504,
1639,
14,
697,
14,
992,
14,
955,
14,
3280,
492,
9240,
55,
2591,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
23004,
492,
25609,
1296,
12,
23617,
199,
504,
1639,
14,
1208,
14,
15383,
492,
334,
272,
23687,
1165,
3849,
12,
7987,
63,
10254,
63,
29401,
63,
765,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
2991,
492,
334,
272,
3542,
63,
505,
12,
2366,
63,
18,
63,
2975,
63,
6490,
12,
11179,
63,
505,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
15481,
492,
6328,
63,
1829,
199,
504,
1639,
14,
1208,
14,
505,
492,
31129,
63,
2546,
63,
475,
63,
10749,
199,
504,
1639,
14,
1208,
14,
6893,
492,
4278,
12,
1059,
63,
9419,
199,
199,
4609,
63,
21403,
1149,
275,
909,
342,
199,
199,
20026,
63,
20562,
51,
275,
909,
342,
199,
199,
13993,
63,
13604,
2594,
63,
22841,
275,
2008,
342,
199,
199,
1469,
25890,
2617,
63,
9171,
275,
334,
272,
298,
1918,
372,
730,
402,
1543,
83,
7,
1077,
7078,
506,
8567,
972,
14,
982,
1265,
2934,
370,
27232,
642,
769,
298,
272,
298,
509,
2195,
5705,
675,
12,
1852,
282,
1331,
1642,
2122,
199,
9,
199,
199,
3472,
63,
14546,
275,
334,
272,
283,
3832,
63,
354,
297,
283,
3832,
63,
354,
63,
10019,
297,
283,
697,
63,
1224,
297,
283,
7128,
297,
272,
283,
3235,
63,
6314,
297,
283,
6060,
297,
283,
362,
63,
7410,
63,
991,
297,
283,
1648,
63,
1045,
63,
27872,
63,
475,
297,
272,
283,
571,
63,
1302,
297,
283,
697,
63,
26730,
297,
283,
6198,
297,
283,
11122,
297,
283,
3280,
297,
283,
31925,
297,
272,
283,
2495,
63,
3966,
297,
283,
1080,
63,
6314,
297,
283,
5181,
297,
283,
885,
63,
6060,
297,
272,
283,
2416,
63,
265,
63,
2117,
297,
283,
885,
63,
2407,
63,
354,
297,
283,
2427,
63,
697,
63,
3179,
297,
272,
283,
2427,
63,
697,
63,
9884,
297,
283,
1095,
63,
2609,
63,
354,
297,
283,
885,
63,
2609,
63,
354,
297,
272,
283,
2609,
63,
13136,
63,
504,
63,
2443,
297,
199,
9,
421,
199,
318,
7666,
63,
6314,
8,
1422,
63,
6314,
304,
272,
408,
272,
945,
63,
6314,
883,
506,
1902,
282,
2008,
402,
6346,
12,
503,
282,
2849,
272,
2008,
402,
2877,
3326,
14,
21017,
652,
370,
282,
2008,
402,
6346,
12,
880,
626,
272,
6358,
1233,
883,
14818,
590,
4282,
626,
14,
272,
408,
272,
862,
26,
267,
340,
440,
945,
63,
6314,
26,
288,
372,
6248,
267,
340,
440,
1228,
8,
1422,
63,
6314,
12,
334,
2960,
12,
769,
2298,
288,
746,
3146,
267,
1642,
63,
2108,
275,
2163,
8,
1661,
8,
1422,
63,
6314,
430,
267,
340,
440,
1228,
8,
2246,
63,
2108,
12,
334,
2960,
12,
769,
2298,
288,
945,
63,
6314,
275,
334,
1422,
63,
6314,
4258,
267,
327,
21017,
8137,
370,
6346,
267,
372,
2008,
8,
2960,
8,
357,
9,
367,
312,
84,
315,
945,
63,
6314,
9,
272,
871,
3146,
26,
267,
327,
982,
314,
574,
402,
945,
63,
6314,
5712,
1133,
1686,
12,
372,
652,
267,
327,
16041,
24218,
27,
642,
911,
506,
29438,
1536,
701,
314,
1104,
10059,
2945,
14,
267,
372,
945,
63,
6314,
421,
199,
318,
1852,
63,
17836,
63,
955,
63,
513,
8,
354,
12,
666,
304,
272,
372,
25609,
1296,
8,
576,
12,
5721,
29,
1469,
25890,
2617,
63,
9171,
450,
536,
9,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
8394,
8,
785,
304,
272,
2381,
2982,
36,
63,
18858,
29807,
275,
469,
267,
283,
955,
297,
283,
3479,
63,
475,
63,
3479,
297,
283,
13455,
63,
955,
297,
283,
1832,
63,
13455,
63,
955,
297,
267,
2513,
6688,
63,
955,
63,
1130,
297,
283,
16259,
297,
283,
16259,
63,
1130,
297,
283,
1095,
63,
2609,
297,
267,
283,
885,
63,
2609,
297,
272,
789,
272,
28229,
63,
18858,
29807,
275,
791,
2407,
63,
1462,
297,
283,
955,
63,
1130,
297,
2513,
5690,
63,
2350,
936,
339,
849,
63,
5181,
275,
8686,
339,
347,
636,
826,
721,
277,
12,
3404,
12,
1145,
63,
1302,
29,
403,
304,
267,
291,
423,
362,
63,
955,
63,
1637,
275,
1052,
267,
291,
14,
1832,
63,
955,
275,
942,
267,
291,
14,
1832,
63,
3479,
63,
475,
63,
3479,
275,
942,
267,
291,
14,
4239,
63,
955,
275,
942,
267,
291,
14,
2609,
63,
13136,
63,
504,
63,
2443,
275,
756,
267,
291,
14,
1832,
63,
16259,
275,
942,
267,
291,
14,
1095,
63,
2609,
63,
354,
275,
488,
267,
291,
14,
885,
63,
2609,
63,
354,
275,
488,
267,
291,
14,
1238,
63,
354,
275,
488,
267,
291,
14,
3832,
63,
354,
275,
488,
267,
291,
14,
3832,
63,
354,
63,
10019,
275,
488,
267,
291,
14,
697,
63,
1224,
275,
2125,
267,
291,
14,
7128,
275,
942,
267,
291,
423,
7128,
63,
24268,
275,
756,
267,
291,
14,
3235,
63,
6314,
275,
942,
267,
291,
14,
1080,
63,
6314,
275,
942,
267,
291,
14,
2416,
63,
265,
63,
2117,
275,
756,
267,
291,
14,
885,
63,
6060,
275,
661,
525,
297,
283,
1461,
297,
283,
1807,
358,
267,
291,
14,
6060,
275,
942,
267,
291,
14,
785,
63,
354,
275,
488,
267,
291,
14,
571,
63,
1302,
275,
1145,
63,
1302,
267,
291,
14,
362,
63,
7410,
63,
991,
275,
488,
267,
291,
14,
1648,
63,
1045,
63,
27872,
63,
475,
275,
488,
267,
291,
14,
697,
63,
26730,
275,
2202,
14,
3472,
63,
10129,
44,
9136,
267,
291,
14,
2427,
63,
697,
63,
3179,
275,
942,
267,
291,
14,
2427,
63,
697,
63,
9884,
275,
488,
267,
291,
14,
2024,
275,
3404
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
1331,
199,
646,
3598,
199,
504,
19063,
492,
19063,
199,
504,
5055,
492,
8773,
12,
10018,
199,
504,
7975,
492,
6036,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
3924,
492,
29994,
199,
504,
1639,
14,
697,
492,
6947,
199,
504,
1639,
14,
697,
14,
992,
492,
13537,
199,
504,
1639,
14,
697,
14,
992,
14,
955,
492,
9195,
792,
199,
504,
1639,
14,
697,
14,
992,
14,
955,
14,
3280,
492,
9240,
55,
2591,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
23004,
492,
25609,
1296,
12,
23617,
199,
504,
1639,
14,
1208,
14,
15383,
492,
334,
272,
23687,
1165,
3849,
12,
7987,
63,
10254,
63,
29401,
63,
765,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
2991,
492,
334,
272,
3542,
63,
505,
12,
2366,
63,
18,
63,
2975,
63,
6490,
12,
11179,
63,
505,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
15481,
492,
6328,
63,
1829,
199,
504,
1639,
14,
1208,
14,
505,
492,
31129,
63,
2546,
63,
475,
63,
10749,
199,
504,
1639,
14,
1208,
14,
6893,
492,
4278,
12,
1059,
63,
9419,
199,
199,
4609,
63,
21403,
1149,
275,
909,
342,
199,
199,
20026,
63,
20562,
51,
275,
909,
342,
199,
199,
13993,
63,
13604,
2594,
63,
22841,
275,
2008,
342,
199,
199,
1469,
25890,
2617,
63,
9171,
275,
334,
272,
298,
1918,
372,
730,
402,
1543,
83,
7,
1077,
7078,
506,
8567,
972,
14,
982,
1265,
2934,
370,
27232,
642,
769,
298,
272,
298,
509,
2195,
5705,
675,
12,
1852,
282,
1331,
1642,
2122,
199,
9,
199,
199,
3472,
63,
14546,
275,
334,
272,
283,
3832,
63,
354,
297,
283,
3832,
63,
354,
63,
10019,
297,
283,
697,
63,
1224,
297,
283,
7128,
297,
272,
283,
3235,
63,
6314,
297,
283,
6060,
297,
283,
362,
63,
7410,
63,
991,
297,
283,
1648,
63,
1045,
63,
27872,
63,
475,
297,
272,
283,
571,
63,
1302,
297,
283,
697,
63,
26730,
297,
283,
6198,
297,
283,
11122,
297,
283,
3280,
297,
283,
31925,
297,
272,
283,
2495,
63,
3966,
297,
283,
1080,
63,
6314,
297,
283,
5181,
297,
283,
885,
63,
6060,
297,
272,
283,
2416,
63,
265,
63,
2117,
297,
283,
885,
63,
2407,
63,
354,
297,
283,
2427,
63,
697,
63,
3179,
297,
272,
283,
2427,
63,
697,
63,
9884,
297,
283,
1095,
63,
2609,
63,
354,
297,
283,
885,
63,
2609,
63,
354,
297,
272,
283,
2609,
63,
13136,
63,
504,
63,
2443,
297,
199,
9,
421,
199,
318,
7666,
63,
6314,
8,
1422,
63,
6314,
304,
272,
408,
272,
945,
63,
6314,
883,
506,
1902,
282,
2008,
402,
6346,
12,
503,
282,
2849,
272,
2008,
402,
2877,
3326,
14,
21017,
652,
370,
282,
2008,
402,
6346,
12,
880,
626,
272,
6358,
1233,
883,
14818,
590,
4282,
626,
14,
272,
408,
272,
862,
26,
267,
340,
440,
945,
63,
6314,
26,
288,
372,
6248,
267,
340,
440,
1228,
8,
1422,
63,
6314,
12,
334,
2960,
12,
769,
2298,
288,
746,
3146,
267,
1642,
63,
2108,
275,
2163,
8,
1661,
8,
1422,
63,
6314,
430,
267,
340,
440,
1228,
8,
2246,
63,
2108,
12,
334,
2960,
12,
769,
2298,
288,
945,
63,
6314,
275,
334,
1422,
63,
6314,
4258,
267,
327,
21017,
8137,
370,
6346,
267,
372,
2008,
8,
2960,
8,
357,
9,
367,
312,
84,
315,
945,
63,
6314,
9,
272,
871,
3146,
26,
267,
327,
982,
314,
574,
402,
945,
63,
6314,
5712,
1133,
1686,
12,
372,
652,
267,
327,
16041,
24218,
27,
642,
911,
506,
29438,
1536,
701,
314,
1104,
10059,
2945,
14,
267,
372,
945,
63,
6314,
421,
199,
318,
1852,
63,
17836,
63,
955,
63,
513,
8,
354,
12,
666,
304,
272,
372,
25609,
1296,
8,
576,
12,
5721,
29,
1469,
25890,
2617,
63,
9171,
450,
536,
9,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
8394,
8,
785,
304,
272,
2381,
2982,
36,
63,
18858,
29807,
275,
469,
267,
283,
955,
297,
283,
3479,
63,
475,
63,
3479,
297,
283,
13455,
63,
955,
297,
283,
1832,
63,
13455,
63,
955,
297,
267,
2513,
6688,
63,
955,
63,
1130,
297,
283,
16259,
297,
283,
16259,
63,
1130,
297,
283,
1095,
63,
2609,
297,
267,
283,
885,
63,
2609,
297,
272,
789,
272,
28229,
63,
18858,
29807,
275,
791,
2407,
63,
1462,
297,
283,
955,
63,
1130,
297,
2513,
5690,
63,
2350,
936,
339,
849,
63,
5181,
275,
8686,
339,
347,
636,
826,
721,
277,
12,
3404,
12,
1145,
63,
1302,
29,
403,
304,
267,
291,
423,
362,
63,
955,
63,
1637,
275,
1052,
267,
291,
14,
1832,
63,
955,
275,
942,
267,
291,
14,
1832,
63,
3479,
63,
475,
63,
3479,
275,
942,
267,
291,
14,
4239,
63,
955,
275,
942,
267,
291,
14,
2609,
63,
13136,
63,
504,
63,
2443,
275,
756,
267,
291,
14,
1832,
63,
16259,
275,
942,
267,
291,
14,
1095,
63,
2609,
63,
354,
275,
488,
267,
291,
14,
885,
63,
2609,
63,
354,
275,
488,
267,
291,
14,
1238,
63,
354,
275,
488,
267,
291,
14,
3832,
63,
354,
275,
488,
267,
291,
14,
3832,
63,
354,
63,
10019,
275,
488,
267,
291,
14,
697,
63,
1224,
275,
2125,
267,
291,
14,
7128,
275,
942,
267,
291,
423,
7128,
63,
24268,
275,
756,
267,
291,
14,
3235,
63,
6314,
275,
942,
267,
291,
14,
1080,
63,
6314,
275,
942,
267,
291,
14,
2416,
63,
265,
63,
2117,
275,
756,
267,
291,
14,
885,
63,
6060,
275,
661,
525,
297,
283,
1461,
297,
283,
1807,
358,
267,
291,
14,
6060,
275,
942,
267,
291,
14,
785,
63,
354,
275,
488,
267,
291,
14,
571,
63,
1302,
275,
1145,
63,
1302,
267,
291,
14,
362,
63,
7410,
63,
991,
275,
488,
267,
291,
14,
1648,
63,
1045,
63,
27872,
63,
475,
275,
488,
267,
291,
14,
697,
63,
26730,
275,
2202,
14,
3472,
63,
10129,
44,
9136,
267,
291,
14,
2427,
63,
697,
63,
3179,
275,
942,
267,
291,
14,
2427,
63,
697,
63,
9884,
275,
488,
267,
291,
14,
2024,
275,
3404,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
geodynamics/gale
|
StgDomain/Mesh/Python/Mesh.py
|
6
|
2137
|
#!/usr/bin/env python
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##
## Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
##
## Authors:
## Stevan M. Quenette, Senior Software Engineer, VPAC. (steve@vpac.org)
## Patrick D. Sunter, Software Engineer, VPAC. (pds@vpac.org)
## Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins@vpac.org)
## Siew-Ching Tan, Software Engineer, VPAC. (siew@vpac.org)
## Alan H. Lo, Computational Engineer, VPAC. (alan@vpac.org)
## Raquibul Hassan, Computational Engineer, VPAC. (raq@vpac.org)
##
## 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
##
## $Id: Mesh.py 3462 2006-02-19 06:53:24Z WalterLandry $
##
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import StGermain.Discretisation.Bindings.Mesh as bindings
import StGermain.Base.IO.Dictionary as Dictionary
def copyright():
return "StGermain.Discretisation.Mesh Python module: Copyright (c) 2003 Victorian Partnership for Advanced Computing (VPAC) Ltd. Australia.";
class Mesh:
def Print( self ):
return bindings.Print( self._handle )
def __init__( self, handle ):
self._handle = handle
self.dictionary = Dictionary.Dictionary( bindings.GetDictionary( self._handle ) )
return
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
309,
30642,
30642,
30642,
30642,
1714,
199,
309,
199,
309,
1898,
334,
35,
395,
13004,
12,
6561,
630,
5653,
31351,
3319,
367,
32445,
27799,
334,
14159,
1348,
9,
12126,
12,
16814,
6561,
630,
4674,
14259,
12,
603,
352,
656,
349,
69,
12,
650,
20454,
12,
437,
22306,
14,
199,
309,
199,
309,
6642,
26,
199,
309,
198,
26696,
20662,
603,
14,
5843,
287,
386,
266,
12,
428,
287,
15499,
2290,
12580,
281,
12,
812,
48,
1348,
14,
334,
1597,
432,
32,
86,
28582,
14,
1308,
9,
199,
309,
198,
48,
292,
27091,
577,
14,
428,
7867,
12,
2290,
12580,
281,
12,
812,
48,
1348,
14,
334,
80,
795,
32,
86,
28582,
14,
1308,
9,
199,
309,
198,
18176,
415,
1603,
14,
869,
364,
19269,
834,
12,
3599,
337,
6279,
12580,
281,
12,
812,
48,
1348,
14,
334,
25514,
364,
75,
3617,
32,
86,
28582,
14,
1308,
9,
199,
309,
198,
18934,
546,
13,
1049,
316,
377,
290,
12,
2290,
12580,
281,
12,
812,
48,
1348,
14,
334,
338,
546,
32,
86,
28582,
14,
1308,
9,
199,
309,
198,
33,
1502,
869,
14,
3835,
12,
3599,
337,
6279,
12580,
281,
12,
812,
48,
1348,
14,
334,
279,
290,
32,
86,
28582,
14,
1308,
9,
199,
309,
198,
1537,
783,
25792,
869,
405,
290,
12,
3599,
337,
6279,
12580,
281,
12,
812,
48,
1348,
14,
334,
345,
81,
32,
86,
28582,
14,
1308,
9,
199,
309,
199,
309,
221,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
309,
221,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
309,
221,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
309,
221,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
309,
199,
309,
221,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
309,
221,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
309,
221,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
309,
221,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
309,
199,
309,
221,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
309,
221,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
309,
221,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
221,
8217,
199,
309,
199,
309,
2672,
1304,
26,
603,
10613,
14,
647,
650,
24509,
8315,
13,
996,
13,
1167,
24293,
26,
2481,
26,
1194,
58,
644,
11858,
44,
460,
651,
2672,
199,
309,
199,
309,
30642,
30642,
30642,
30642,
1714,
199,
199,
646,
1933,
27866,
973,
14,
2825,
1353,
16753,
425,
14,
8198,
780,
14,
12241,
465,
17792,
199,
646,
1933,
27866,
973,
14,
1563,
14,
2090,
14,
11728,
465,
11932,
199,
199,
318,
4248,
837,
199,
198,
1107,
298,
933,
27866,
973,
14,
2825,
1353,
16753,
425,
14,
12241,
2018,
859,
26,
1898,
334,
67,
9,
13004,
6561,
630,
5653,
31351,
3319,
367,
32445,
27799,
334,
14159,
1348,
9,
12126,
14,
437,
22306,
2122,
27,
199,
199,
533,
603,
10613,
26,
199,
198,
318,
9101,
8,
291,
3461,
507,
198,
1107,
17792,
14,
5375,
8,
291,
423,
2479,
776,
8299,
198,
318,
636,
826,
721,
291,
12,
2429,
3461,
507,
198,
277,
423,
2479,
275,
2429,
507,
198,
277,
14,
9086,
275,
11932,
14,
11728,
8,
17792,
14,
1002,
11728,
8,
291,
423,
2479,
776,
776,
507,
198,
1107,
8299,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
309,
30642,
30642,
30642,
30642,
1714,
199,
309,
199,
309,
1898,
334,
35,
395,
13004,
12,
6561,
630,
5653,
31351,
3319,
367,
32445,
27799,
334,
14159,
1348,
9,
12126,
12,
16814,
6561,
630,
4674,
14259,
12,
603,
352,
656,
349,
69,
12,
650,
20454,
12,
437,
22306,
14,
199,
309,
199,
309,
6642,
26,
199,
309,
198,
26696,
20662,
603,
14,
5843,
287,
386,
266,
12,
428,
287,
15499,
2290,
12580,
281,
12,
812,
48,
1348,
14,
334,
1597,
432,
32,
86,
28582,
14,
1308,
9,
199,
309,
198,
48,
292,
27091,
577,
14,
428,
7867,
12,
2290,
12580,
281,
12,
812,
48,
1348,
14,
334,
80,
795,
32,
86,
28582,
14,
1308,
9,
199,
309,
198,
18176,
415,
1603,
14,
869,
364,
19269,
834,
12,
3599,
337,
6279,
12580,
281,
12,
812,
48,
1348,
14,
334,
25514,
364,
75,
3617,
32,
86,
28582,
14,
1308,
9,
199,
309,
198,
18934,
546,
13,
1049,
316,
377,
290,
12,
2290,
12580,
281,
12,
812,
48,
1348,
14,
334,
338,
546,
32,
86,
28582,
14,
1308,
9,
199,
309,
198,
33,
1502,
869,
14,
3835,
12,
3599,
337,
6279,
12580,
281,
12,
812,
48,
1348,
14,
334,
279,
290,
32,
86,
28582,
14,
1308,
9,
199,
309,
198,
1537,
783,
25792,
869,
405,
290,
12,
3599,
337,
6279,
12580,
281,
12,
812,
48,
1348,
14,
334,
345,
81,
32,
86,
28582,
14,
1308,
9,
199,
309,
199,
309,
221,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
309,
221,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
309,
221,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
309,
221,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
309,
199,
309,
221,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
309,
221,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
309,
221,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
309,
221,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
309,
199,
309,
221,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
309,
221,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
309,
221,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
221,
8217,
199,
309,
199,
309,
2672,
1304,
26,
603,
10613,
14,
647,
650,
24509,
8315,
13,
996,
13,
1167,
24293,
26,
2481,
26,
1194,
58,
644,
11858,
44,
460,
651,
2672,
199,
309,
199,
309,
30642,
30642,
30642,
30642,
1714,
199,
199,
646,
1933,
27866,
973,
14,
2825,
1353,
16753,
425,
14,
8198,
780,
14,
12241,
465,
17792,
199,
646,
1933,
27866,
973,
14,
1563,
14,
2090,
14,
11728,
465,
11932,
199,
199,
318,
4248,
837,
199,
198,
1107,
298,
933,
27866,
973,
14,
2825,
1353,
16753,
425,
14,
12241,
2018,
859,
26,
1898,
334,
67,
9,
13004,
6561,
630,
5653,
31351,
3319,
367,
32445,
27799,
334,
14159,
1348,
9,
12126,
14,
437,
22306,
2122,
27,
199,
199,
533,
603,
10613,
26,
199,
198,
318,
9101,
8,
291,
3461,
507,
198,
1107,
17792,
14,
5375,
8,
291,
423,
2479,
776,
8299,
198,
318,
636,
826,
721,
291,
12,
2429,
3461,
507,
198,
277,
423,
2479,
275,
2429,
507,
198,
277,
14,
9086,
275,
11932,
14,
11728,
8,
17792,
14,
1002,
11728,
8,
291,
423,
2479,
776,
776,
507,
198,
1107,
8299,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
wojnilowicz/git-cola
|
test/cmds_test.py
|
3
|
1399
|
#!/usr/bin/env python
from __future__ import absolute_import, division, unicode_literals
import unittest
from cola import cmds
from cola.compat import unichr
class CmdsTestCase(unittest.TestCase):
"""Tests the cola.core module's unicode handling
"""
def test_Commit_strip_comments(self):
"""Ensure that commit messages are stripped of comments"""
msg = 'subject\n\n#comment\nbody'
expect = 'subject\n\nbody\n'
actual = cmds.Commit.strip_comments(msg)
self.assertEqual(expect, actual)
def test_Commit_strip_comments_unicode(self):
"""Ensure that unicode is preserved in stripped commit messages"""
msg = unichr(0x1234) + '\n\n#comment\nbody'
expect = unichr(0x1234) + '\n\nbody\n'
actual = cmds.Commit.strip_comments(msg)
self.assertEqual(expect, actual)
def test_unix_path_win32(self):
path = r'Z:\Program Files\git-cola\bin\git-dag'
expect = '/Z/Program Files/git-cola/bin/git-dag'
actual = cmds.unix_path(path, is_win32=lambda: True)
self.assertEqual(expect, actual)
def test_unix_path_is_a_noop_on_sane_platforms(self):
path = r'/:we/don\t/need/no/stinking/badgers!'
expect = path
actual = cmds.unix_path(path, is_win32=lambda: False)
self.assertEqual(expect, actual)
if __name__ == '__main__':
unittest.main()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
646,
2882,
421,
199,
504,
1048,
65,
492,
11465,
199,
504,
1048,
65,
14,
5819,
492,
17742,
421,
199,
533,
445,
77,
795,
1746,
8,
2796,
14,
1746,
304,
272,
408,
2925,
314,
1048,
65,
14,
1018,
859,
1159,
2649,
7252,
272,
408,
339,
347,
511,
63,
11421,
63,
1913,
63,
6223,
8,
277,
304,
267,
408,
13913,
626,
5532,
3788,
787,
14489,
402,
6786,
624,
398,
1499,
275,
283,
5875,
60,
78,
60,
78,
3,
3349,
60,
78,
2030,
7,
267,
4282,
275,
283,
5875,
60,
78,
60,
78,
2030,
60,
78,
7,
267,
3503,
275,
11465,
14,
11421,
14,
1913,
63,
6223,
8,
1328,
9,
267,
291,
14,
629,
8,
4921,
12,
3503,
9,
339,
347,
511,
63,
11421,
63,
1913,
63,
6223,
63,
2975,
8,
277,
304,
267,
408,
13913,
626,
2649,
365,
17731,
315,
14489,
5532,
3788,
624,
398,
1499,
275,
17742,
8,
16,
88,
4321,
9,
435,
1557,
78,
60,
78,
3,
3349,
60,
78,
2030,
7,
267,
4282,
275,
17742,
8,
16,
88,
4321,
9,
435,
1557,
78,
60,
78,
2030,
60,
78,
7,
267,
3503,
275,
11465,
14,
11421,
14,
1913,
63,
6223,
8,
1328,
9,
267,
291,
14,
629,
8,
4921,
12,
3503,
9,
339,
347,
511,
63,
11864,
63,
515,
63,
2676,
708,
8,
277,
304,
267,
931,
275,
519,
7,
58,
3427,
9184,
16920,
60,
3187,
13,
331,
416,
60,
1393,
60,
3187,
13,
7406,
7,
267,
4282,
275,
1994,
58,
15,
9184,
16920,
15,
3187,
13,
331,
416,
15,
1393,
15,
3187,
13,
7406,
7,
267,
3503,
275,
11465,
14,
11864,
63,
515,
8,
515,
12,
365,
63,
2676,
708,
29,
2734,
26,
715,
9,
267,
291,
14,
629,
8,
4921,
12,
3503,
9,
339,
347,
511,
63,
11864,
63,
515,
63,
374,
63,
65,
63,
12921,
63,
265,
63,
83,
5865,
63,
19601,
8,
277,
304,
267,
931,
275,
519,
9807,
26,
1129,
15,
13196,
60,
84,
15,
9321,
15,
889,
15,
270,
2292,
316,
15,
4087,
31988,
11213,
267,
4282,
275,
931,
267,
3503,
275,
11465,
14,
11864,
63,
515,
8,
515,
12,
365,
63,
2676,
708,
29,
2734,
26,
756,
9,
267,
291,
14,
629,
8,
4921,
12,
3503,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
646,
2882,
421,
199,
504,
1048,
65,
492,
11465,
199,
504,
1048,
65,
14,
5819,
492,
17742,
421,
199,
533,
445,
77,
795,
1746,
8,
2796,
14,
1746,
304,
272,
408,
2925,
314,
1048,
65,
14,
1018,
859,
1159,
2649,
7252,
272,
408,
339,
347,
511,
63,
11421,
63,
1913,
63,
6223,
8,
277,
304,
267,
408,
13913,
626,
5532,
3788,
787,
14489,
402,
6786,
624,
398,
1499,
275,
283,
5875,
60,
78,
60,
78,
3,
3349,
60,
78,
2030,
7,
267,
4282,
275,
283,
5875,
60,
78,
60,
78,
2030,
60,
78,
7,
267,
3503,
275,
11465,
14,
11421,
14,
1913,
63,
6223,
8,
1328,
9,
267,
291,
14,
629,
8,
4921,
12,
3503,
9,
339,
347,
511,
63,
11421,
63,
1913,
63,
6223,
63,
2975,
8,
277,
304,
267,
408,
13913,
626,
2649,
365,
17731,
315,
14489,
5532,
3788,
624,
398,
1499,
275,
17742,
8,
16,
88,
4321,
9,
435,
1557,
78,
60,
78,
3,
3349,
60,
78,
2030,
7,
267,
4282,
275,
17742,
8,
16,
88,
4321,
9,
435,
1557,
78,
60,
78,
2030,
60,
78,
7,
267,
3503,
275,
11465,
14,
11421,
14,
1913,
63,
6223,
8,
1328,
9,
267,
291,
14,
629,
8,
4921,
12,
3503,
9,
339,
347,
511,
63,
11864,
63,
515,
63,
2676,
708,
8,
277,
304,
267,
931,
275,
519,
7,
58,
3427,
9184,
16920,
60,
3187,
13,
331,
416,
60,
1393,
60,
3187,
13,
7406,
7,
267,
4282,
275,
1994,
58,
15,
9184,
16920,
15,
3187,
13,
331,
416,
15,
1393,
15,
3187,
13,
7406,
7,
267,
3503,
275,
11465,
14,
11864,
63,
515,
8,
515,
12,
365,
63,
2676,
708,
29,
2734,
26,
715,
9,
267,
291,
14,
629,
8,
4921,
12,
3503,
9,
339,
347,
511,
63,
11864,
63,
515,
63,
374,
63,
65,
63,
12921,
63,
265,
63,
83,
5865,
63,
19601,
8,
277,
304,
267,
931,
275,
519,
9807,
26,
1129,
15,
13196,
60,
84,
15,
9321,
15,
889,
15,
270,
2292,
316,
15,
4087,
31988,
11213,
267,
4282,
275,
931,
267,
3503,
275,
11465,
14,
11864,
63,
515,
8,
515,
12,
365,
63,
2676,
708,
29,
2734,
26,
756,
9,
267,
291,
14,
629,
8,
4921,
12,
3503,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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
1
|
17594
|
"""Tests for the SmartThings component init module."""
from uuid import uuid4
from aiohttp import ClientConnectionError, ClientResponseError
from asynctest import Mock, patch
from pysmartthings import InstalledAppStatus, OAuthToken
import pytest
from homeassistant.components import cloud, smartthings
from homeassistant.components.smartthings.const import (
CONF_CLOUDHOOK_URL,
CONF_INSTALLED_APP_ID,
CONF_REFRESH_TOKEN,
DATA_BROKERS,
DOMAIN,
EVENT_BUTTON,
SIGNAL_SMARTTHINGS_UPDATE,
SUPPORTED_PLATFORMS,
)
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from tests.common import MockConfigEntry
async def test_migration_creates_new_flow(hass, smartthings_mock, config_entry):
"""Test migration deletes app and creates new flow."""
config_entry.version = 1
config_entry.add_to_hass(hass)
await smartthings.async_migrate_entry(hass, config_entry)
await hass.async_block_till_done()
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.call_count == 1
assert not hass.config_entries.async_entries(DOMAIN)
flows = hass.config_entries.flow.async_progress()
assert len(flows) == 1
assert flows[0]["handler"] == "smartthings"
assert flows[0]["context"] == {"source": "import"}
async def test_unrecoverable_api_errors_create_new_flow(
hass, config_entry, smartthings_mock
):
"""
Test a new config flow is initiated when there are API errors.
401 (unauthorized): Occurs when the access token is no longer valid.
403 (forbidden/not found): Occurs when the app or installed app could
not be retrieved/found (likely deleted?)
"""
config_entry.add_to_hass(hass)
smartthings_mock.app.side_effect = ClientResponseError(None, None, status=401)
# Assert setup returns false
result = await smartthings.async_setup_entry(hass, config_entry)
assert not result
# Assert entry was removed and new flow created
await hass.async_block_till_done()
assert not hass.config_entries.async_entries(DOMAIN)
flows = hass.config_entries.flow.async_progress()
assert len(flows) == 1
assert flows[0]["handler"] == "smartthings"
assert flows[0]["context"] == {"source": "import"}
hass.config_entries.flow.async_abort(flows[0]["flow_id"])
async def test_recoverable_api_errors_raise_not_ready(
hass, config_entry, smartthings_mock
):
"""Test config entry not ready raised for recoverable API errors."""
config_entry.add_to_hass(hass)
smartthings_mock.app.side_effect = ClientResponseError(None, None, status=500)
with pytest.raises(ConfigEntryNotReady):
await smartthings.async_setup_entry(hass, config_entry)
async def test_scenes_api_errors_raise_not_ready(
hass, config_entry, app, installed_app, smartthings_mock
):
"""Test if scenes are unauthorized we continue to load platforms."""
config_entry.add_to_hass(hass)
smartthings_mock.app.return_value = app
smartthings_mock.installed_app.return_value = installed_app
smartthings_mock.scenes.side_effect = ClientResponseError(None, None, status=500)
with pytest.raises(ConfigEntryNotReady):
await smartthings.async_setup_entry(hass, config_entry)
async def test_connection_errors_raise_not_ready(hass, config_entry, smartthings_mock):
"""Test config entry not ready raised for connection errors."""
config_entry.add_to_hass(hass)
smartthings_mock.app.side_effect = ClientConnectionError()
with pytest.raises(ConfigEntryNotReady):
await smartthings.async_setup_entry(hass, config_entry)
async def test_base_url_no_longer_https_does_not_load(
hass, config_entry, app, smartthings_mock
):
"""Test base_url no longer valid creates a new flow."""
hass.config.api.base_url = "http://0.0.0.0"
config_entry.add_to_hass(hass)
smartthings_mock.app.return_value = app
# Assert setup returns false
result = await smartthings.async_setup_entry(hass, config_entry)
assert not result
async def test_unauthorized_installed_app_raises_not_ready(
hass, config_entry, app, installed_app, smartthings_mock
):
"""Test config entry not ready raised when the app isn't authorized."""
config_entry.add_to_hass(hass)
installed_app.installed_app_status = InstalledAppStatus.PENDING
smartthings_mock.app.return_value = app
smartthings_mock.installed_app.return_value = installed_app
with pytest.raises(ConfigEntryNotReady):
await smartthings.async_setup_entry(hass, config_entry)
async def test_scenes_unauthorized_loads_platforms(
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
):
"""Test if scenes are unauthorized we continue to load platforms."""
config_entry.add_to_hass(hass)
smartthings_mock.app.return_value = app
smartthings_mock.installed_app.return_value = installed_app
smartthings_mock.devices.return_value = [device]
smartthings_mock.scenes.side_effect = ClientResponseError(None, None, status=403)
mock_token = Mock()
mock_token.access_token.return_value = str(uuid4())
mock_token.refresh_token.return_value = str(uuid4())
smartthings_mock.generate_tokens.return_value = mock_token
subscriptions = [
subscription_factory(capability) for capability in device.capabilities
]
smartthings_mock.subscriptions.return_value = subscriptions
with patch.object(hass.config_entries, "async_forward_entry_setup") as forward_mock:
assert await smartthings.async_setup_entry(hass, config_entry)
# Assert platforms loaded
await hass.async_block_till_done()
assert forward_mock.call_count == len(SUPPORTED_PLATFORMS)
async def test_config_entry_loads_platforms(
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
scene,
):
"""Test config entry loads properly and proxies to platforms."""
config_entry.add_to_hass(hass)
smartthings_mock.app.return_value = app
smartthings_mock.installed_app.return_value = installed_app
smartthings_mock.devices.return_value = [device]
smartthings_mock.scenes.return_value = [scene]
mock_token = Mock()
mock_token.access_token.return_value = str(uuid4())
mock_token.refresh_token.return_value = str(uuid4())
smartthings_mock.generate_tokens.return_value = mock_token
subscriptions = [
subscription_factory(capability) for capability in device.capabilities
]
smartthings_mock.subscriptions.return_value = subscriptions
with patch.object(hass.config_entries, "async_forward_entry_setup") as forward_mock:
assert await smartthings.async_setup_entry(hass, config_entry)
# Assert platforms loaded
await hass.async_block_till_done()
assert forward_mock.call_count == len(SUPPORTED_PLATFORMS)
async def test_config_entry_loads_unconnected_cloud(
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
scene,
):
"""Test entry loads during startup when cloud isn't connected."""
config_entry.add_to_hass(hass)
hass.data[DOMAIN][CONF_CLOUDHOOK_URL] = "https://test.cloud"
hass.config.api.base_url = "http://0.0.0.0"
smartthings_mock.app.return_value = app
smartthings_mock.installed_app.return_value = installed_app
smartthings_mock.devices.return_value = [device]
smartthings_mock.scenes.return_value = [scene]
mock_token = Mock()
mock_token.access_token.return_value = str(uuid4())
mock_token.refresh_token.return_value = str(uuid4())
smartthings_mock.generate_tokens.return_value = mock_token
subscriptions = [
subscription_factory(capability) for capability in device.capabilities
]
smartthings_mock.subscriptions.return_value = subscriptions
with patch.object(hass.config_entries, "async_forward_entry_setup") as forward_mock:
assert await smartthings.async_setup_entry(hass, config_entry)
await hass.async_block_till_done()
assert forward_mock.call_count == len(SUPPORTED_PLATFORMS)
async def test_unload_entry(hass, config_entry):
"""Test entries are unloaded correctly."""
connect_disconnect = Mock()
smart_app = Mock()
smart_app.connect_event.return_value = connect_disconnect
broker = smartthings.DeviceBroker(hass, config_entry, Mock(), smart_app, [], [])
broker.connect()
hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id] = broker
with patch.object(
hass.config_entries, "async_forward_entry_unload", return_value=True
) as forward_mock:
assert await smartthings.async_unload_entry(hass, config_entry)
assert connect_disconnect.call_count == 1
assert config_entry.entry_id not in hass.data[DOMAIN][DATA_BROKERS]
# Assert platforms unloaded
await hass.async_block_till_done()
assert forward_mock.call_count == len(SUPPORTED_PLATFORMS)
async def test_remove_entry(hass, config_entry, smartthings_mock):
"""Test that the installed app and app are removed up."""
# Act
await smartthings.async_remove_entry(hass, config_entry)
# Assert
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.call_count == 1
async def test_remove_entry_cloudhook(hass, config_entry, smartthings_mock):
"""Test that the installed app, app, and cloudhook are removed up."""
# Arrange
config_entry.add_to_hass(hass)
hass.data[DOMAIN][CONF_CLOUDHOOK_URL] = "https://test.cloud"
# Act
with patch.object(
cloud, "async_is_logged_in", return_value=True
) as mock_async_is_logged_in, patch.object(
cloud, "async_delete_cloudhook"
) as mock_async_delete_cloudhook:
await smartthings.async_remove_entry(hass, config_entry)
# Assert
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.call_count == 1
assert mock_async_is_logged_in.call_count == 1
assert mock_async_delete_cloudhook.call_count == 1
async def test_remove_entry_app_in_use(hass, config_entry, smartthings_mock):
"""Test app is not removed if in use by another config entry."""
# Arrange
config_entry.add_to_hass(hass)
data = config_entry.data.copy()
data[CONF_INSTALLED_APP_ID] = str(uuid4())
entry2 = MockConfigEntry(version=2, domain=DOMAIN, data=data)
entry2.add_to_hass(hass)
# Act
await smartthings.async_remove_entry(hass, config_entry)
# Assert
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.call_count == 0
async def test_remove_entry_already_deleted(hass, config_entry, smartthings_mock):
"""Test handles when the apps have already been removed."""
# Arrange
smartthings_mock.delete_installed_app.side_effect = ClientResponseError(
None, None, status=403
)
smartthings_mock.delete_app.side_effect = ClientResponseError(
None, None, status=403
)
# Act
await smartthings.async_remove_entry(hass, config_entry)
# Assert
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.call_count == 1
async def test_remove_entry_installedapp_api_error(
hass, config_entry, smartthings_mock
):
"""Test raises exceptions removing the installed app."""
# Arrange
smartthings_mock.delete_installed_app.side_effect = ClientResponseError(
None, None, status=500
)
# Act
with pytest.raises(ClientResponseError):
await smartthings.async_remove_entry(hass, config_entry)
# Assert
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.call_count == 0
async def test_remove_entry_installedapp_unknown_error(
hass, config_entry, smartthings_mock
):
"""Test raises exceptions removing the installed app."""
# Arrange
smartthings_mock.delete_installed_app.side_effect = Exception
# Act
with pytest.raises(Exception):
await smartthings.async_remove_entry(hass, config_entry)
# Assert
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.call_count == 0
async def test_remove_entry_app_api_error(hass, config_entry, smartthings_mock):
"""Test raises exceptions removing the app."""
# Arrange
smartthings_mock.delete_app.side_effect = ClientResponseError(
None, None, status=500
)
# Act
with pytest.raises(ClientResponseError):
await smartthings.async_remove_entry(hass, config_entry)
# Assert
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.call_count == 1
async def test_remove_entry_app_unknown_error(hass, config_entry, smartthings_mock):
"""Test raises exceptions removing the app."""
# Arrange
smartthings_mock.delete_app.side_effect = Exception
# Act
with pytest.raises(Exception):
await smartthings.async_remove_entry(hass, config_entry)
# Assert
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.call_count == 1
async def test_broker_regenerates_token(hass, config_entry):
"""Test the device broker regenerates the refresh token."""
token = Mock(OAuthToken)
token.refresh_token = str(uuid4())
stored_action = None
def async_track_time_interval(hass, action, interval):
nonlocal stored_action
stored_action = action
with patch(
"homeassistant.components.smartthings" ".async_track_time_interval",
new=async_track_time_interval,
):
broker = smartthings.DeviceBroker(hass, config_entry, token, Mock(), [], [])
broker.connect()
assert stored_action
await stored_action(None) # pylint:disable=not-callable
assert token.refresh.call_count == 1
assert config_entry.data[CONF_REFRESH_TOKEN] == token.refresh_token
async def test_event_handler_dispatches_updated_devices(
hass, config_entry, device_factory, event_request_factory, event_factory
):
"""Test the event handler dispatches updated devices."""
devices = [
device_factory("Bedroom 1 Switch", ["switch"]),
device_factory("Bathroom 1", ["switch"]),
device_factory("Sensor", ["motionSensor"]),
device_factory("Lock", ["lock"]),
]
device_ids = [
devices[0].device_id,
devices[1].device_id,
devices[2].device_id,
devices[3].device_id,
]
event = event_factory(
devices[3].device_id,
capability="lock",
attribute="lock",
value="locked",
data={"codeId": "1"},
)
request = event_request_factory(device_ids=device_ids, events=[event])
config_entry.data[CONF_INSTALLED_APP_ID] = request.installed_app_id
called = False
def signal(ids):
nonlocal called
called = True
assert device_ids == ids
async_dispatcher_connect(hass, SIGNAL_SMARTTHINGS_UPDATE, signal)
broker = smartthings.DeviceBroker(hass, config_entry, Mock(), Mock(), devices, [])
broker.connect()
# pylint:disable=protected-access
await broker._event_handler(request, None, None)
await hass.async_block_till_done()
assert called
for device in devices:
assert device.status.values["Updated"] == "Value"
assert devices[3].status.attributes["lock"].value == "locked"
assert devices[3].status.attributes["lock"].data == {"codeId": "1"}
async def test_event_handler_ignores_other_installed_app(
hass, config_entry, device_factory, event_request_factory
):
"""Test the event handler dispatches updated devices."""
device = device_factory("Bedroom 1 Switch", ["switch"])
request = event_request_factory([device.device_id])
called = False
def signal(ids):
nonlocal called
called = True
async_dispatcher_connect(hass, SIGNAL_SMARTTHINGS_UPDATE, signal)
broker = smartthings.DeviceBroker(hass, config_entry, Mock(), Mock(), [device], [])
broker.connect()
# pylint:disable=protected-access
await broker._event_handler(request, None, None)
await hass.async_block_till_done()
assert not called
async def test_event_handler_fires_button_events(
hass, config_entry, device_factory, event_factory, event_request_factory
):
"""Test the event handler fires button events."""
device = device_factory("Button 1", ["button"])
event = event_factory(
device.device_id, capability="button", attribute="button", value="pushed"
)
request = event_request_factory(events=[event])
config_entry.data[CONF_INSTALLED_APP_ID] = request.installed_app_id
called = False
def handler(evt):
nonlocal called
called = True
assert evt.data == {
"component_id": "main",
"device_id": device.device_id,
"location_id": event.location_id,
"value": "pushed",
"name": device.label,
"data": None,
}
hass.bus.async_listen(EVENT_BUTTON, handler)
broker = smartthings.DeviceBroker(hass, config_entry, Mock(), Mock(), [device], [])
broker.connect()
# pylint:disable=protected-access
await broker._event_handler(request, None, None)
await hass.async_block_till_done()
assert called
|
apache-2.0
|
[
624,
2925,
367,
314,
26017,
2719,
780,
3931,
4205,
859,
1041,
199,
504,
5377,
492,
5377,
20,
199,
199,
504,
30274,
492,
6810,
20349,
12,
6810,
19712,
199,
504,
5316,
396,
492,
4420,
12,
3371,
199,
504,
10382,
77,
580,
25970,
492,
14089,
1843,
2640,
3694,
12,
11715,
3264,
199,
646,
4613,
199,
199,
504,
8846,
14,
4608,
492,
8002,
12,
11179,
25970,
199,
504,
8846,
14,
4608,
14,
7853,
25970,
14,
1297,
492,
334,
272,
6392,
63,
29495,
28706,
63,
2632,
12,
272,
6392,
63,
15942,
63,
7121,
63,
998,
12,
272,
6392,
63,
8279,
15098,
63,
8803,
12,
272,
7126,
63,
21111,
43,
3960,
12,
272,
15265,
12,
272,
6461,
63,
13272,
12,
272,
24360,
63,
4029,
689,
1481,
40,
3881,
63,
10383,
12,
272,
32501,
63,
2749,
619,
11518,
12,
199,
9,
199,
504,
8846,
14,
3924,
492,
4094,
3900,
1763,
17960,
199,
504,
8846,
14,
7546,
14,
14913,
492,
5316,
63,
14913,
63,
2242,
199,
199,
504,
2295,
14,
2330,
492,
4420,
2028,
3900,
421,
199,
4146,
347,
511,
63,
8998,
63,
28219,
63,
1222,
63,
1659,
8,
5387,
12,
11179,
25970,
63,
1805,
12,
1101,
63,
2373,
304,
272,
408,
774,
8367,
21812,
1145,
436,
8491,
892,
6369,
1041,
272,
1101,
63,
2373,
14,
1023,
275,
413,
272,
1101,
63,
2373,
14,
525,
63,
475,
63,
5387,
8,
5387,
9,
339,
5517,
11179,
25970,
14,
4146,
63,
8462,
63,
2373,
8,
5387,
12,
1101,
63,
2373,
9,
272,
5517,
6298,
14,
4146,
63,
1457,
63,
12587,
63,
4456,
342,
339,
702,
11179,
25970,
63,
1805,
14,
1807,
63,
7657,
63,
571,
14,
1250,
63,
835,
508,
413,
272,
702,
11179,
25970,
63,
1805,
14,
1807,
63,
571,
14,
1250,
63,
835,
508,
413,
272,
702,
440,
6298,
14,
888,
63,
3189,
14,
4146,
63,
3189,
8,
7378,
9,
272,
30708,
275,
6298,
14,
888,
63,
3189,
14,
1659,
14,
4146,
63,
5734,
342,
272,
702,
822,
8,
22777,
9,
508,
413,
272,
702,
30708,
59,
16,
7541,
2232,
937,
508,
298,
7853,
25970,
2,
272,
702,
30708,
59,
16,
7541,
1100,
937,
508,
2420,
1365,
582,
298,
646,
3570,
421,
199,
4146,
347,
511,
63,
324,
23131,
461,
63,
1246,
63,
2550,
63,
981,
63,
1222,
63,
1659,
8,
272,
6298,
12,
1101,
63,
2373,
12,
11179,
25970,
63,
1805,
199,
304,
272,
408,
272,
1379,
282,
892,
1101,
6369,
365,
11023,
972,
1380,
2337,
787,
3261,
2552,
14,
339,
13952,
334,
324,
11497,
304,
593,
67,
17255,
1380,
314,
2879,
1526,
365,
949,
8088,
1686,
14,
272,
13269,
334,
29293,
15,
1397,
1911,
304,
593,
67,
17255,
1380,
314,
1145,
503,
4903,
1145,
4293,
267,
440,
506,
12396,
15,
4214,
334,
24227,
5463,
17076,
272,
408,
272,
1101,
63,
2373,
14,
525,
63,
475,
63,
5387,
8,
5387,
9,
272,
11179,
25970,
63,
1805,
14,
571,
14,
2441,
63,
5881,
275,
6810,
19712,
8,
403,
12,
488,
12,
2004,
29,
8854,
9,
339,
327,
10716,
3272,
2529,
3055,
272,
754,
275,
5517,
11179,
25970,
14,
4146,
63,
2758,
63,
2373,
8,
5387,
12,
1101,
63,
2373,
9,
272,
702,
440,
754,
339,
327,
10716,
2397,
1990,
4829,
436,
892,
6369,
2737,
272,
5517,
6298,
14,
4146,
63,
1457,
63,
12587,
63,
4456,
342,
272,
702,
440,
6298,
14,
888,
63,
3189,
14,
4146,
63,
3189,
8,
7378,
9,
272,
30708,
275,
6298,
14,
888,
63,
3189,
14,
1659,
14,
4146,
63,
5734,
342,
272,
702,
822,
8,
22777,
9,
508,
413,
272,
702,
30708,
59,
16,
7541,
2232,
937,
508,
298,
7853,
25970,
2,
272,
702,
30708,
59,
16,
7541,
1100,
937,
508,
2420,
1365,
582,
298,
646,
3570,
272,
6298,
14,
888,
63,
3189,
14,
1659,
14,
4146,
63,
13845,
8,
22777,
59,
16,
7541,
1659,
63,
344,
3135,
421,
199,
4146,
347,
511,
63,
23131,
461,
63,
1246,
63,
2550,
63,
3730,
63,
1397,
63,
2179,
8,
272,
6298,
12,
1101,
63,
2373,
12,
11179,
25970,
63,
1805,
199,
304,
272,
408,
774,
1101,
2397,
440,
10144,
4915,
367,
22803,
461,
3261,
2552,
1041,
272,
1101,
63,
2373,
14,
525,
63,
475,
63,
5387,
8,
5387,
9,
272,
11179,
25970,
63,
1805,
14,
571,
14,
2441,
63,
5881,
275,
6810,
19712,
8,
403,
12,
488,
12,
2004,
29,
5783,
9,
339,
543,
4613,
14,
3536,
8,
2028,
3900,
1763,
17960,
304,
267,
5517,
11179,
25970,
14,
4146,
63,
2758,
63,
2373,
8,
5387,
12,
1101,
63,
2373,
9,
421,
199,
4146,
347,
511,
63,
10845,
397,
63,
1246,
63,
2550,
63,
3730,
63,
1397,
63,
2179,
8,
272,
6298,
12,
1101,
63,
2373,
12,
1145,
12,
4903,
63,
571,
12,
11179,
25970,
63,
1805,
199,
304,
272,
408,
774,
340,
8482,
397,
787,
625,
11497,
781,
1980,
370,
2248,
10677,
1041,
272,
1101,
63,
2373,
14,
525,
63,
475,
63,
5387,
8,
5387,
9,
272,
11179,
25970,
63,
1805,
14,
571,
14,
1107,
63,
585,
275,
1145,
272,
11179,
25970,
63,
1805,
14,
7657,
63,
571,
14,
1107,
63,
585,
275,
4903,
63,
571,
272,
11179,
25970,
63,
1805,
14,
10845,
397,
14,
2441,
63,
5881,
275,
6810,
19712,
8,
403,
12,
488,
12,
2004,
29,
5783,
9,
272,
543,
4613,
14,
3536,
8,
2028,
3900,
1763,
17960,
304,
267,
5517,
11179,
25970,
14,
4146,
63,
2758,
63,
2373,
8,
5387,
12,
1101,
63,
2373,
9,
421,
199,
4146,
347,
511,
63,
2105,
63,
2550,
63,
3730,
63,
1397,
63,
2179,
8,
5387,
12,
1101,
63,
2373,
12,
11179,
25970,
63,
1805,
304,
272,
408,
774,
1101,
2397,
440,
10144,
4915,
367,
1950,
2552,
1041,
272,
1101,
63,
2373,
14,
525,
63,
475,
63,
5387,
8,
5387,
9,
272,
11179,
25970,
63,
1805,
14,
571,
14,
2441,
63,
5881,
275,
6810,
20349,
342,
339,
543,
4613,
14,
3536,
8,
2028,
3900,
1763,
17960,
304,
267,
5517,
11179,
25970,
14,
4146,
63,
2758,
63,
2373,
8,
5387,
12,
1101,
63,
2373,
9,
421,
199,
4146,
347,
511,
63,
1095,
63,
633,
63,
889,
63,
5298,
836,
63,
2859,
63,
9105,
63,
1397,
63,
912,
8,
272,
6298,
12,
1101,
63,
2373,
12,
1145,
12,
11179,
25970,
63,
1805,
199,
304,
272,
408,
774,
1300,
63,
633,
949
] |
[
2925,
367,
314,
26017,
2719,
780,
3931,
4205,
859,
1041,
199,
504,
5377,
492,
5377,
20,
199,
199,
504,
30274,
492,
6810,
20349,
12,
6810,
19712,
199,
504,
5316,
396,
492,
4420,
12,
3371,
199,
504,
10382,
77,
580,
25970,
492,
14089,
1843,
2640,
3694,
12,
11715,
3264,
199,
646,
4613,
199,
199,
504,
8846,
14,
4608,
492,
8002,
12,
11179,
25970,
199,
504,
8846,
14,
4608,
14,
7853,
25970,
14,
1297,
492,
334,
272,
6392,
63,
29495,
28706,
63,
2632,
12,
272,
6392,
63,
15942,
63,
7121,
63,
998,
12,
272,
6392,
63,
8279,
15098,
63,
8803,
12,
272,
7126,
63,
21111,
43,
3960,
12,
272,
15265,
12,
272,
6461,
63,
13272,
12,
272,
24360,
63,
4029,
689,
1481,
40,
3881,
63,
10383,
12,
272,
32501,
63,
2749,
619,
11518,
12,
199,
9,
199,
504,
8846,
14,
3924,
492,
4094,
3900,
1763,
17960,
199,
504,
8846,
14,
7546,
14,
14913,
492,
5316,
63,
14913,
63,
2242,
199,
199,
504,
2295,
14,
2330,
492,
4420,
2028,
3900,
421,
199,
4146,
347,
511,
63,
8998,
63,
28219,
63,
1222,
63,
1659,
8,
5387,
12,
11179,
25970,
63,
1805,
12,
1101,
63,
2373,
304,
272,
408,
774,
8367,
21812,
1145,
436,
8491,
892,
6369,
1041,
272,
1101,
63,
2373,
14,
1023,
275,
413,
272,
1101,
63,
2373,
14,
525,
63,
475,
63,
5387,
8,
5387,
9,
339,
5517,
11179,
25970,
14,
4146,
63,
8462,
63,
2373,
8,
5387,
12,
1101,
63,
2373,
9,
272,
5517,
6298,
14,
4146,
63,
1457,
63,
12587,
63,
4456,
342,
339,
702,
11179,
25970,
63,
1805,
14,
1807,
63,
7657,
63,
571,
14,
1250,
63,
835,
508,
413,
272,
702,
11179,
25970,
63,
1805,
14,
1807,
63,
571,
14,
1250,
63,
835,
508,
413,
272,
702,
440,
6298,
14,
888,
63,
3189,
14,
4146,
63,
3189,
8,
7378,
9,
272,
30708,
275,
6298,
14,
888,
63,
3189,
14,
1659,
14,
4146,
63,
5734,
342,
272,
702,
822,
8,
22777,
9,
508,
413,
272,
702,
30708,
59,
16,
7541,
2232,
937,
508,
298,
7853,
25970,
2,
272,
702,
30708,
59,
16,
7541,
1100,
937,
508,
2420,
1365,
582,
298,
646,
3570,
421,
199,
4146,
347,
511,
63,
324,
23131,
461,
63,
1246,
63,
2550,
63,
981,
63,
1222,
63,
1659,
8,
272,
6298,
12,
1101,
63,
2373,
12,
11179,
25970,
63,
1805,
199,
304,
272,
408,
272,
1379,
282,
892,
1101,
6369,
365,
11023,
972,
1380,
2337,
787,
3261,
2552,
14,
339,
13952,
334,
324,
11497,
304,
593,
67,
17255,
1380,
314,
2879,
1526,
365,
949,
8088,
1686,
14,
272,
13269,
334,
29293,
15,
1397,
1911,
304,
593,
67,
17255,
1380,
314,
1145,
503,
4903,
1145,
4293,
267,
440,
506,
12396,
15,
4214,
334,
24227,
5463,
17076,
272,
408,
272,
1101,
63,
2373,
14,
525,
63,
475,
63,
5387,
8,
5387,
9,
272,
11179,
25970,
63,
1805,
14,
571,
14,
2441,
63,
5881,
275,
6810,
19712,
8,
403,
12,
488,
12,
2004,
29,
8854,
9,
339,
327,
10716,
3272,
2529,
3055,
272,
754,
275,
5517,
11179,
25970,
14,
4146,
63,
2758,
63,
2373,
8,
5387,
12,
1101,
63,
2373,
9,
272,
702,
440,
754,
339,
327,
10716,
2397,
1990,
4829,
436,
892,
6369,
2737,
272,
5517,
6298,
14,
4146,
63,
1457,
63,
12587,
63,
4456,
342,
272,
702,
440,
6298,
14,
888,
63,
3189,
14,
4146,
63,
3189,
8,
7378,
9,
272,
30708,
275,
6298,
14,
888,
63,
3189,
14,
1659,
14,
4146,
63,
5734,
342,
272,
702,
822,
8,
22777,
9,
508,
413,
272,
702,
30708,
59,
16,
7541,
2232,
937,
508,
298,
7853,
25970,
2,
272,
702,
30708,
59,
16,
7541,
1100,
937,
508,
2420,
1365,
582,
298,
646,
3570,
272,
6298,
14,
888,
63,
3189,
14,
1659,
14,
4146,
63,
13845,
8,
22777,
59,
16,
7541,
1659,
63,
344,
3135,
421,
199,
4146,
347,
511,
63,
23131,
461,
63,
1246,
63,
2550,
63,
3730,
63,
1397,
63,
2179,
8,
272,
6298,
12,
1101,
63,
2373,
12,
11179,
25970,
63,
1805,
199,
304,
272,
408,
774,
1101,
2397,
440,
10144,
4915,
367,
22803,
461,
3261,
2552,
1041,
272,
1101,
63,
2373,
14,
525,
63,
475,
63,
5387,
8,
5387,
9,
272,
11179,
25970,
63,
1805,
14,
571,
14,
2441,
63,
5881,
275,
6810,
19712,
8,
403,
12,
488,
12,
2004,
29,
5783,
9,
339,
543,
4613,
14,
3536,
8,
2028,
3900,
1763,
17960,
304,
267,
5517,
11179,
25970,
14,
4146,
63,
2758,
63,
2373,
8,
5387,
12,
1101,
63,
2373,
9,
421,
199,
4146,
347,
511,
63,
10845,
397,
63,
1246,
63,
2550,
63,
3730,
63,
1397,
63,
2179,
8,
272,
6298,
12,
1101,
63,
2373,
12,
1145,
12,
4903,
63,
571,
12,
11179,
25970,
63,
1805,
199,
304,
272,
408,
774,
340,
8482,
397,
787,
625,
11497,
781,
1980,
370,
2248,
10677,
1041,
272,
1101,
63,
2373,
14,
525,
63,
475,
63,
5387,
8,
5387,
9,
272,
11179,
25970,
63,
1805,
14,
571,
14,
1107,
63,
585,
275,
1145,
272,
11179,
25970,
63,
1805,
14,
7657,
63,
571,
14,
1107,
63,
585,
275,
4903,
63,
571,
272,
11179,
25970,
63,
1805,
14,
10845,
397,
14,
2441,
63,
5881,
275,
6810,
19712,
8,
403,
12,
488,
12,
2004,
29,
5783,
9,
272,
543,
4613,
14,
3536,
8,
2028,
3900,
1763,
17960,
304,
267,
5517,
11179,
25970,
14,
4146,
63,
2758,
63,
2373,
8,
5387,
12,
1101,
63,
2373,
9,
421,
199,
4146,
347,
511,
63,
2105,
63,
2550,
63,
3730,
63,
1397,
63,
2179,
8,
5387,
12,
1101,
63,
2373,
12,
11179,
25970,
63,
1805,
304,
272,
408,
774,
1101,
2397,
440,
10144,
4915,
367,
1950,
2552,
1041,
272,
1101,
63,
2373,
14,
525,
63,
475,
63,
5387,
8,
5387,
9,
272,
11179,
25970,
63,
1805,
14,
571,
14,
2441,
63,
5881,
275,
6810,
20349,
342,
339,
543,
4613,
14,
3536,
8,
2028,
3900,
1763,
17960,
304,
267,
5517,
11179,
25970,
14,
4146,
63,
2758,
63,
2373,
8,
5387,
12,
1101,
63,
2373,
9,
421,
199,
4146,
347,
511,
63,
1095,
63,
633,
63,
889,
63,
5298,
836,
63,
2859,
63,
9105,
63,
1397,
63,
912,
8,
272,
6298,
12,
1101,
63,
2373,
12,
1145,
12,
11179,
25970,
63,
1805,
199,
304,
272,
408,
774,
1300,
63,
633,
949,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
rahuldhote/odoo
|
addons/mrp/report/__init__.py
|
378
|
1122
|
# -*- 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 price
import workcenter_load
import bom_structure
import mrp_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,
8033,
199,
646,
1736,
4218,
63,
912,
199,
646,
17190,
63,
6976,
199,
646,
333,
4599,
63,
3070,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
8033,
199,
646,
1736,
4218,
63,
912,
199,
646,
17190,
63,
6976,
199,
646,
333,
4599,
63,
3070,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
flavour/cert
|
models/patient.py
|
3
|
7976
|
# -*- coding: utf-8 -*-
"""
Patient Tracking
@author: Fran Boon
"""
if deployment_settings.has_module("patient"):
def patient_tables():
# ---------------------------------------------------------------------
tablename = "patient_patient"
table = db.define_table(tablename,
person_id(widget=S3AddPersonWidget(),
requires=IS_ADD_PERSON_WIDGET(),
label=T("Patient"),
comment=None),
#person_id(empty=False, label = T("Patient")),
Field("country",
label = T("Current Location Country"),
requires = IS_NULL_OR(IS_IN_SET_LAZY(
lambda: gis.get_countries(key_type="code"),
zero = SELECT_LOCATION)),
represent = lambda code: \
gis.get_country(code, key_type="code") or \
UNKNOWN_OPT),
hospital_id(empty=False,
label = T("Current Location Treating Hospital")),
Field("phone", requires=s3_phone_requires,
label=T("Current Location Phone Number")),
Field("treatment_date", "date", label=T("Date of Treatment")),
Field("return_date", "date", label=T("Expected Return Home")),
s3_comments(),
*s3_meta_fields())
# CRUD strings
ADD_PATIENT = T("New Patient")
LIST_PATIENTS = T("List Patients")
s3.crud_strings[tablename] = Storage(
title_create = ADD_PATIENT,
title_display = T("Patient Details"),
title_list = LIST_PATIENTS,
title_update = T("Edit Patient"),
title_search = T("Search Patients"),
subtitle_create = T("Add New Patient"),
subtitle_list = T("Patients"),
label_list_button = LIST_PATIENTS,
label_create_button = ADD_PATIENT,
label_delete_button = T("Delete Patient"),
msg_record_created = T("Patient added"),
msg_record_modified = T("Patient updated"),
msg_record_deleted = T("Patient deleted"),
msg_list_empty = T("No Patients currently registered"))
def patient_represent(id):
if isinstance(id, Row):
# Do not repeat the lookup if already done by IS_ONE_OF or RHeader
patient = id
else:
table = db.patient_patient
query = (table.id == id)
patient = db(query).select(table.person_id,
limitby = (0, 1)).first()
if patient:
represent = via.fullname(patient.person_id)
else:
represent = "-"
return represent
# Reusable Field for Component Link
patient_id = S3ReusableField("patient_id", db.patient_patient,
requires = IS_ONE_OF(db,
"patient_patient.id",
patient_represent),
represent = patient_represent,
ondelete = "RESTRICT")
# ---------------------------------------------------------------------
tablename = "patient_relative"
table = db.define_table(tablename,
patient_id(readable=False, writable=False),
#person_id(label = T("Accompanying Relative")),
person_id(widget=S3AddPersonWidget(),
requires=IS_ADD_PERSON_WIDGET(),
label=T("Accompanying Relative"),
comment=None),
s3_comments(),
*s3_meta_fields())
# CRUD strings
ADD_RELATIVE = T("New Relative")
LIST_RELATIVES = T("List Relatives")
s3.crud_strings[tablename] = Storage(
title_create = ADD_RELATIVE,
title_display = T("Relative Details"),
title_list = LIST_RELATIVES,
title_update = T("Edit Relative"),
title_search = T("Search Relatives"),
subtitle_create = T("Add New Relative"),
subtitle_list = T("Relatives"),
label_list_button = LIST_RELATIVES,
label_create_button = ADD_RELATIVE,
label_delete_button = T("Delete Relative"),
msg_record_created = T("Relative added"),
msg_record_modified = T("Relative updated"),
msg_record_deleted = T("Relative deleted"),
msg_list_empty = T("No Relatives currently registered"))
# Home as Component of Patients
s3mgr.model.add_component(table,
patient_patient=dict(joinby="patient_id",
multiple=False))
# ---------------------------------------------------------------------
# @ToDo: Default the Home Phone Number from the Person, if available
# @ToDo: Onvalidation to set the Relative's Contact
tablename = "patient_home"
table = db.define_table(tablename,
patient_id(readable=False, writable=False),
person_id(widget=S3AddPersonWidget(),
requires=IS_ADD_PERSON_WIDGET(),
label=T("Home Relative"),
comment=None),
#person_id(label = T("Home Relative")),
location_id(label=T("Home City"),
widget = S3LocationAutocompleteWidget(level="L2"),
requires = IS_LOCATION(level="L2")),
Field("phone",
requires=IS_NULL_OR(s3_phone_requires),
label=T("Home Phone Number")),
s3_comments(),
*s3_meta_fields())
# CRUD strings
ADD_HOME = T("New Home")
LIST_HOMES = T("List Homes")
s3.crud_strings[tablename] = Storage(
title_create = ADD_HOME,
title_display = T("Home Details"),
title_list = LIST_HOMES,
title_update = T("Edit Home"),
title_search = T("Search Homes"),
subtitle_create = T("Add New Home"),
subtitle_list = T("Homes"),
label_list_button = LIST_HOMES,
label_create_button = ADD_HOME,
label_delete_button = T("Delete Home"),
msg_record_created = T("Home added"),
msg_record_modified = T("Home updated"),
msg_record_deleted = T("Home deleted"),
msg_list_empty = T("No Homes currently registered"))
# Home as Component of Patients
s3mgr.model.add_component(table,
patient_patient=dict(joinby="patient_id",
multiple=False))
# Provide a handle to this load function
s3mgr.loader(patient_tables,
"patient_patient")
# END =========================================================================
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
272,
510,
31078,
17507,
316,
339,
768,
2502,
26,
481,
1312,
5088,
265,
199,
624,
199,
199,
692,
14295,
63,
1751,
14,
1989,
63,
578,
480,
25067,
2349,
339,
347,
30905,
63,
5987,
837,
267,
327,
5620,
9858,
267,
20283,
275,
298,
25067,
63,
25067,
2,
267,
1817,
275,
1592,
14,
4640,
63,
1224,
8,
10983,
12,
1816,
4954,
63,
344,
8,
3440,
29,
51,
19,
1123,
7344,
3339,
1062,
5101,
5074,
29,
1311,
63,
9732,
63,
30973,
63,
9845,
2970,
1062,
5101,
1768,
29,
52,
480,
48,
31078,
1288,
5101,
3721,
29,
403,
395,
1816,
327,
5484,
63,
344,
8,
1667,
29,
797,
12,
1768,
275,
377,
480,
48,
31078,
8150,
1816,
5024,
480,
6063,
401,
4228,
1768,
275,
377,
480,
5639,
12625,
19453,
1288,
4228,
5074,
275,
2281,
63,
8084,
63,
726,
8,
1311,
63,
568,
63,
3597,
63,
5837,
58,
57,
8,
3147,
2400,
26,
486,
374,
14,
362,
63,
23598,
8,
498,
63,
466,
628,
600,
1288,
3147,
4697,
275,
10468,
63,
16575,
1826,
4228,
2954,
275,
2400,
1233,
26,
971,
3147,
486,
374,
14,
362,
63,
6063,
8,
600,
12,
790,
63,
466,
628,
600,
531,
503,
971,
4490,
24740,
63,
5123,
395,
1816,
2636,
681,
6910,
63,
344,
8,
1667,
29,
797,
12,
4490,
1768,
275,
377,
480,
5639,
12625,
377,
264,
1958,
28673,
681,
6910,
8150,
1816,
5024,
480,
9339,
401,
5074,
29,
83,
19,
63,
9339,
63,
6537,
12,
4228,
1768,
29,
52,
480,
5639,
12625,
27585,
4860,
8150,
1816,
5024,
480,
84,
8319,
434,
63,
602,
401,
298,
602,
401,
1768,
29,
52,
480,
2506,
402,
377,
8319,
434,
8150,
1816,
5024,
480,
1107,
63,
602,
401,
298,
602,
401,
1768,
29,
52,
480,
6964,
1432,
14621,
8150,
1816,
308,
19,
63,
6223,
1062,
1816,
627,
83,
19,
63,
2024,
63,
955,
1012,
398,
327,
17101,
3383,
3326,
267,
21380,
63,
2805,
25451,
275,
377,
480,
4665,
510,
31078,
531,
267,
21716,
63,
2805,
25451,
51,
275,
377,
480,
1296,
510,
2159,
24871,
531,
267,
308,
19,
14,
28941,
63,
5465,
59,
10983,
61,
275,
10533,
8,
288,
2538,
63,
981,
275,
21380,
63,
2805,
25451,
12,
288,
2538,
63,
2918,
275,
377,
480,
48,
31078,
15621,
1288,
288,
2538,
63,
513,
275,
21716,
63,
2805,
25451,
51,
12,
288,
2538,
63,
873,
275,
377,
480,
4685,
510,
31078,
1288,
288,
2538,
63,
1733,
275,
377,
480,
5278,
510,
2159,
24871,
1288,
288,
18197,
63,
981,
275,
377,
480,
1123,
7053,
510,
31078,
1288,
288,
18197,
63,
513,
275,
377,
480,
48,
2159,
24871,
1288,
288,
1768,
63,
513,
63,
3887,
275,
21716,
63,
2805,
25451,
51,
12,
288,
1768,
63,
981,
63,
3887,
275,
21380,
63,
2805,
25451,
12,
288,
1768,
63,
1807,
63,
3887,
275,
377,
480,
5392,
510,
31078,
1288,
288,
1499,
63,
3059,
63,
3966,
275,
377,
480,
48,
31078,
3483,
1288,
288,
1499,
63,
3059,
63,
5540,
275,
377,
480,
48,
31078,
4588,
1288,
288,
1499,
63,
3059,
63,
6062,
275,
377,
480,
48,
31078,
5463,
1288,
288,
1499,
63,
513,
63,
1667,
275,
377,
480,
1944,
510,
2159,
24871,
5544,
7264,
2237,
398,
347,
30905,
63,
13063,
8,
344,
304,
288,
340,
1228,
8,
344,
12,
15231,
304,
355,
327,
4226,
440,
11982,
314,
4237,
340,
2575,
4224,
701,
2281,
63,
4817,
63,
3359,
503,
820,
2567,
355,
30905,
275,
1305,
288,
587,
26,
355,
1817,
275,
1592,
14,
25067,
63,
25067,
355,
1827,
275,
334,
1224,
14,
344,
508,
1305,
9,
355,
30905,
275,
1592,
8,
1131,
680,
2416,
8,
1224,
14,
5484,
63,
344,
12,
5644,
2304,
991,
275,
334,
16,
12,
413,
4992,
2246,
342,
288,
340,
30905,
26,
355,
2954,
275,
4799,
14,
9930,
8,
25067,
14,
5484,
63,
344,
9,
288,
587,
26,
355,
2954,
275,
17155,
953,
372,
2954,
398,
327,
799,
14418,
5024,
367,
12727,
10967,
267,
30905,
63,
344,
275,
428,
19,
497,
14418,
792,
480,
25067,
63,
344,
401,
1592,
14,
25067,
63,
25067,
12,
3660,
5074,
275,
2281,
63,
4817,
63,
3359,
8,
697,
12,
12933,
298,
25067,
63,
25067,
14,
344,
401,
12933,
30905,
63,
13063,
395,
3660,
2954,
275,
30905,
63,
13063,
12,
3660,
16549,
275,
298,
15740,
50,
6196,
531,
398,
327,
5620,
9858,
267,
20283,
275,
298,
25067,
63,
6188,
2,
267,
1817,
275,
1592,
14,
4640,
63,
1224,
8,
10983,
12,
1816,
30905,
63,
344,
8,
11875,
29,
797,
12,
17267,
29,
797,
395,
1816,
327,
5484,
63,
344,
8,
1302,
275,
377,
480,
1945,
4627,
316,
22419,
8150,
1816,
4954,
63,
344,
8,
3440,
29,
51,
19,
1123,
7344,
3339,
1062,
5101,
5074,
29,
1311,
63,
9732,
63,
30973,
63,
9845,
2970,
1062,
5101,
1768,
29,
52,
480,
1945,
4627,
316,
22419,
1288,
5101,
3721,
29,
403,
395,
1816,
308,
19,
63,
6223,
1062,
1816,
627,
83,
19,
63,
2024,
63,
955,
1012,
398,
327,
17101,
3383,
3326,
267,
21380,
63,
13604,
14277,
275,
377,
480,
4665,
22419,
531,
267,
21716,
63,
13604,
619,
6882,
654,
275,
377,
480,
1296,
9781,
10661,
531,
267,
308,
19,
14,
28941,
63,
5465,
59,
10983,
61,
275,
10533,
8,
288,
2538,
63,
981,
275,
21380,
63,
13604,
14277,
12,
288,
2538,
63,
2918,
275,
377,
480,
15277,
15621,
1288,
288,
2538,
63,
513,
275,
21716,
63,
13604,
619,
6882,
654,
12,
288,
2538,
63,
873,
275,
377,
480,
4685,
22419,
1288,
288,
2538,
63,
1733,
275,
377,
480,
5278,
9781,
10661,
1288,
288,
18197,
63,
981,
275,
377,
480,
1123,
7053,
22419,
1288,
288,
18197,
63,
513,
275,
377,
480,
5640,
10661,
1288,
288,
1768,
63,
513,
63,
3887,
275,
21716,
63,
13604,
619,
6882,
654,
12,
288,
1768,
63,
981,
63,
3887,
275,
21380,
63,
13604,
14277,
12,
288,
1768,
63,
1807,
63,
3887,
275,
377,
480,
5392,
22419,
1288,
288,
1499,
63,
3059,
63,
3966,
275,
377,
480,
15277,
3483,
1288,
288,
1499,
63,
3059,
63,
5540,
275,
377,
480,
15277,
4588,
1288,
288,
1499,
63,
3059,
63,
6062,
275,
377,
480,
15277,
5463,
1288,
288,
1499,
63,
513,
63,
1667,
275,
377,
480,
1944,
9781,
10661,
5544,
7264,
2237,
398,
327,
14621
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
272,
510,
31078,
17507,
316,
339,
768,
2502,
26,
481,
1312,
5088,
265,
199,
624,
199,
199,
692,
14295,
63,
1751,
14,
1989,
63,
578,
480,
25067,
2349,
339,
347,
30905,
63,
5987,
837,
267,
327,
5620,
9858,
267,
20283,
275,
298,
25067,
63,
25067,
2,
267,
1817,
275,
1592,
14,
4640,
63,
1224,
8,
10983,
12,
1816,
4954,
63,
344,
8,
3440,
29,
51,
19,
1123,
7344,
3339,
1062,
5101,
5074,
29,
1311,
63,
9732,
63,
30973,
63,
9845,
2970,
1062,
5101,
1768,
29,
52,
480,
48,
31078,
1288,
5101,
3721,
29,
403,
395,
1816,
327,
5484,
63,
344,
8,
1667,
29,
797,
12,
1768,
275,
377,
480,
48,
31078,
8150,
1816,
5024,
480,
6063,
401,
4228,
1768,
275,
377,
480,
5639,
12625,
19453,
1288,
4228,
5074,
275,
2281,
63,
8084,
63,
726,
8,
1311,
63,
568,
63,
3597,
63,
5837,
58,
57,
8,
3147,
2400,
26,
486,
374,
14,
362,
63,
23598,
8,
498,
63,
466,
628,
600,
1288,
3147,
4697,
275,
10468,
63,
16575,
1826,
4228,
2954,
275,
2400,
1233,
26,
971,
3147,
486,
374,
14,
362,
63,
6063,
8,
600,
12,
790,
63,
466,
628,
600,
531,
503,
971,
4490,
24740,
63,
5123,
395,
1816,
2636,
681,
6910,
63,
344,
8,
1667,
29,
797,
12,
4490,
1768,
275,
377,
480,
5639,
12625,
377,
264,
1958,
28673,
681,
6910,
8150,
1816,
5024,
480,
9339,
401,
5074,
29,
83,
19,
63,
9339,
63,
6537,
12,
4228,
1768,
29,
52,
480,
5639,
12625,
27585,
4860,
8150,
1816,
5024,
480,
84,
8319,
434,
63,
602,
401,
298,
602,
401,
1768,
29,
52,
480,
2506,
402,
377,
8319,
434,
8150,
1816,
5024,
480,
1107,
63,
602,
401,
298,
602,
401,
1768,
29,
52,
480,
6964,
1432,
14621,
8150,
1816,
308,
19,
63,
6223,
1062,
1816,
627,
83,
19,
63,
2024,
63,
955,
1012,
398,
327,
17101,
3383,
3326,
267,
21380,
63,
2805,
25451,
275,
377,
480,
4665,
510,
31078,
531,
267,
21716,
63,
2805,
25451,
51,
275,
377,
480,
1296,
510,
2159,
24871,
531,
267,
308,
19,
14,
28941,
63,
5465,
59,
10983,
61,
275,
10533,
8,
288,
2538,
63,
981,
275,
21380,
63,
2805,
25451,
12,
288,
2538,
63,
2918,
275,
377,
480,
48,
31078,
15621,
1288,
288,
2538,
63,
513,
275,
21716,
63,
2805,
25451,
51,
12,
288,
2538,
63,
873,
275,
377,
480,
4685,
510,
31078,
1288,
288,
2538,
63,
1733,
275,
377,
480,
5278,
510,
2159,
24871,
1288,
288,
18197,
63,
981,
275,
377,
480,
1123,
7053,
510,
31078,
1288,
288,
18197,
63,
513,
275,
377,
480,
48,
2159,
24871,
1288,
288,
1768,
63,
513,
63,
3887,
275,
21716,
63,
2805,
25451,
51,
12,
288,
1768,
63,
981,
63,
3887,
275,
21380,
63,
2805,
25451,
12,
288,
1768,
63,
1807,
63,
3887,
275,
377,
480,
5392,
510,
31078,
1288,
288,
1499,
63,
3059,
63,
3966,
275,
377,
480,
48,
31078,
3483,
1288,
288,
1499,
63,
3059,
63,
5540,
275,
377,
480,
48,
31078,
4588,
1288,
288,
1499,
63,
3059,
63,
6062,
275,
377,
480,
48,
31078,
5463,
1288,
288,
1499,
63,
513,
63,
1667,
275,
377,
480,
1944,
510,
2159,
24871,
5544,
7264,
2237,
398,
347,
30905,
63,
13063,
8,
344,
304,
288,
340,
1228,
8,
344,
12,
15231,
304,
355,
327,
4226,
440,
11982,
314,
4237,
340,
2575,
4224,
701,
2281,
63,
4817,
63,
3359,
503,
820,
2567,
355,
30905,
275,
1305,
288,
587,
26,
355,
1817,
275,
1592,
14,
25067,
63,
25067,
355,
1827,
275,
334,
1224,
14,
344,
508,
1305,
9,
355,
30905,
275,
1592,
8,
1131,
680,
2416,
8,
1224,
14,
5484,
63,
344,
12,
5644,
2304,
991,
275,
334,
16,
12,
413,
4992,
2246,
342,
288,
340,
30905,
26,
355,
2954,
275,
4799,
14,
9930,
8,
25067,
14,
5484,
63,
344,
9,
288,
587,
26,
355,
2954,
275,
17155,
953,
372,
2954,
398,
327,
799,
14418,
5024,
367,
12727,
10967,
267,
30905,
63,
344,
275,
428,
19,
497,
14418,
792,
480,
25067,
63,
344,
401,
1592,
14,
25067,
63,
25067,
12,
3660,
5074,
275,
2281,
63,
4817,
63,
3359,
8,
697,
12,
12933,
298,
25067,
63,
25067,
14,
344,
401,
12933,
30905,
63,
13063,
395,
3660,
2954,
275,
30905,
63,
13063,
12,
3660,
16549,
275,
298,
15740,
50,
6196,
531,
398,
327,
5620,
9858,
267,
20283,
275,
298,
25067,
63,
6188,
2,
267,
1817,
275,
1592,
14,
4640,
63,
1224,
8,
10983,
12,
1816,
30905,
63,
344,
8,
11875,
29,
797,
12,
17267,
29,
797,
395,
1816,
327,
5484,
63,
344,
8,
1302,
275,
377,
480,
1945,
4627,
316,
22419,
8150,
1816,
4954,
63,
344,
8,
3440,
29,
51,
19,
1123,
7344,
3339,
1062,
5101,
5074,
29,
1311,
63,
9732,
63,
30973,
63,
9845,
2970,
1062,
5101,
1768,
29,
52,
480,
1945,
4627,
316,
22419,
1288,
5101,
3721,
29,
403,
395,
1816,
308,
19,
63,
6223,
1062,
1816,
627,
83,
19,
63,
2024,
63,
955,
1012,
398,
327,
17101,
3383,
3326,
267,
21380,
63,
13604,
14277,
275,
377,
480,
4665,
22419,
531,
267,
21716,
63,
13604,
619,
6882,
654,
275,
377,
480,
1296,
9781,
10661,
531,
267,
308,
19,
14,
28941,
63,
5465,
59,
10983,
61,
275,
10533,
8,
288,
2538,
63,
981,
275,
21380,
63,
13604,
14277,
12,
288,
2538,
63,
2918,
275,
377,
480,
15277,
15621,
1288,
288,
2538,
63,
513,
275,
21716,
63,
13604,
619,
6882,
654,
12,
288,
2538,
63,
873,
275,
377,
480,
4685,
22419,
1288,
288,
2538,
63,
1733,
275,
377,
480,
5278,
9781,
10661,
1288,
288,
18197,
63,
981,
275,
377,
480,
1123,
7053,
22419,
1288,
288,
18197,
63,
513,
275,
377,
480,
5640,
10661,
1288,
288,
1768,
63,
513,
63,
3887,
275,
21716,
63,
13604,
619,
6882,
654,
12,
288,
1768,
63,
981,
63,
3887,
275,
21380,
63,
13604,
14277,
12,
288,
1768,
63,
1807,
63,
3887,
275,
377,
480,
5392,
22419,
1288,
288,
1499,
63,
3059,
63,
3966,
275,
377,
480,
15277,
3483,
1288,
288,
1499,
63,
3059,
63,
5540,
275,
377,
480,
15277,
4588,
1288,
288,
1499,
63,
3059,
63,
6062,
275,
377,
480,
15277,
5463,
1288,
288,
1499,
63,
513,
63,
1667,
275,
377,
480,
1944,
9781,
10661,
5544,
7264,
2237,
398,
327,
14621,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
flavour/cert
|
modules/geopy/geocoders/dot_us.py
|
28
|
2098
|
import getpass
import xmlrpclib
from geopy.geocoders.base import Geocoder
from geopy.point import Point
from geopy.location import Location
from geopy import util
class GeocoderDotUS(Geocoder):
def __init__(self, username=None, password=None, format_string='%s'):
super(GeocoderDotUS, self).__init__(format_string=format_string)
if username and password is None:
password = getpass.getpass(
"geocoder.us password for %r: " % username
)
self.username = username
self.__password = password
def get_url(self, string=None):
username = self.username
password = self.__password
if username and password:
auth = '%s@%s:' % (username, password)
resource = 'member/service/xmlrpc/'
else:
auth = ''
resource = 'service/xmlrpc/'
return 'http://%sgeocoder.us/%s' % (auth, resource)
def geocode(self, string, **kwargs):
locations = []
server = xmlrpclib.ServerProxy(self.url)
results = server.geocode(self.format_string % string)
for result in results:
name = self._format_name(result)
latitude = result.get('lat')
longitude = result.get('long')
if latitude and longitude:
point = Point(latitude, longitude)
else:
point = None
location = Location(name, point, dict(result))
locations.append(location)
return locations
def _format_name(self, result):
address = [
result.get('number'),
result.get('prefix'),
result.get('street'),
result.get('street_type'),
result.get('suffix')
]
city = result.get('city')
state = result.get('state')
zip_code = result.get('zip')
return util.join_filter(", ", [
util.join_filter(" ", address),
city,
util.join_filter(" ", [state, zip_code])
])
|
mit
|
[
646,
18354,
199,
646,
19122,
199,
504,
2312,
927,
14,
6721,
2693,
83,
14,
1095,
492,
8875,
2693,
199,
504,
2312,
927,
14,
1403,
492,
7584,
199,
504,
2312,
927,
14,
1985,
492,
12625,
199,
504,
2312,
927,
492,
4884,
199,
199,
533,
8875,
2693,
14004,
1668,
8,
10748,
2693,
304,
272,
347,
636,
826,
721,
277,
12,
3434,
29,
403,
12,
2505,
29,
403,
12,
1475,
63,
875,
9569,
83,
735,
267,
1613,
8,
10748,
2693,
14004,
1668,
12,
291,
2843,
826,
721,
908,
63,
875,
29,
908,
63,
875,
9,
2728,
340,
3434,
436,
2505,
365,
488,
26,
288,
2505,
275,
18354,
14,
27481,
8,
355,
298,
6721,
2693,
14,
527,
2505,
367,
450,
82,
26,
298,
450,
3434,
288,
776,
2728,
291,
14,
2473,
275,
3434,
267,
291,
855,
2060,
275,
2505,
2286,
347,
664,
63,
633,
8,
277,
12,
1059,
29,
403,
304,
267,
3434,
275,
291,
14,
2473,
267,
2505,
275,
291,
855,
2060,
267,
340,
3434,
436,
2505,
26,
288,
1790,
275,
1543,
83,
19437,
83,
4881,
450,
334,
2473,
12,
2505,
9,
288,
2073,
275,
283,
1114,
15,
1364,
15,
17596,
4805,
267,
587,
26,
288,
1790,
275,
2125,
288,
2073,
275,
283,
1364,
15,
17596,
4805,
2728,
372,
283,
1014,
13827,
83,
6721,
2693,
14,
527,
3149,
83,
7,
450,
334,
1178,
12,
2073,
9,
2286,
347,
8509,
600,
8,
277,
12,
1059,
12,
1011,
958,
304,
267,
9918,
275,
942,
267,
1654,
275,
19122,
14,
3120,
4936,
8,
277,
14,
633,
9,
267,
2058,
275,
1654,
14,
6721,
600,
8,
277,
14,
908,
63,
875,
450,
1059,
9,
267,
367,
754,
315,
2058,
26,
288,
536,
275,
291,
423,
908,
63,
354,
8,
1099,
9,
288,
18896,
275,
754,
14,
362,
360,
4452,
358,
288,
18154,
275,
754,
14,
362,
360,
2809,
358,
288,
340,
18896,
436,
18154,
26,
355,
2376,
275,
7584,
8,
13331,
12,
18154,
9,
288,
587,
26,
355,
2376,
275,
488,
288,
2909,
275,
12625,
8,
354,
12,
2376,
12,
1211,
8,
1099,
430,
288,
9918,
14,
740,
8,
1985,
9,
267,
372,
9918,
2286,
347,
485,
908,
63,
354,
8,
277,
12,
754,
304,
267,
2287,
275,
359,
288,
754,
14,
362,
360,
1955,
659,
288,
754,
14,
362,
360,
1861,
659,
288,
754,
14,
362,
360,
20451,
659,
288,
754,
14,
362,
360,
20451,
63,
466,
659,
288,
754,
14,
362,
360,
4511,
358,
267,
1622,
267,
14492,
275,
754,
14,
362,
360,
3690,
358,
267,
1174,
275,
754,
14,
362,
360,
929,
358,
267,
3482,
63,
600,
275,
754,
14,
362,
360,
3065,
358,
2728,
372,
4884,
14,
904,
63,
1541,
11854,
3872,
359,
288,
4884,
14,
904,
63,
1541,
480,
3872,
2287,
395,
288,
14492,
12,
288,
4884,
14,
904,
63,
1541,
480,
3872,
359,
929,
12,
3482,
63,
600,
566,
267,
4794,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
18354,
199,
646,
19122,
199,
504,
2312,
927,
14,
6721,
2693,
83,
14,
1095,
492,
8875,
2693,
199,
504,
2312,
927,
14,
1403,
492,
7584,
199,
504,
2312,
927,
14,
1985,
492,
12625,
199,
504,
2312,
927,
492,
4884,
199,
199,
533,
8875,
2693,
14004,
1668,
8,
10748,
2693,
304,
272,
347,
636,
826,
721,
277,
12,
3434,
29,
403,
12,
2505,
29,
403,
12,
1475,
63,
875,
9569,
83,
735,
267,
1613,
8,
10748,
2693,
14004,
1668,
12,
291,
2843,
826,
721,
908,
63,
875,
29,
908,
63,
875,
9,
2728,
340,
3434,
436,
2505,
365,
488,
26,
288,
2505,
275,
18354,
14,
27481,
8,
355,
298,
6721,
2693,
14,
527,
2505,
367,
450,
82,
26,
298,
450,
3434,
288,
776,
2728,
291,
14,
2473,
275,
3434,
267,
291,
855,
2060,
275,
2505,
2286,
347,
664,
63,
633,
8,
277,
12,
1059,
29,
403,
304,
267,
3434,
275,
291,
14,
2473,
267,
2505,
275,
291,
855,
2060,
267,
340,
3434,
436,
2505,
26,
288,
1790,
275,
1543,
83,
19437,
83,
4881,
450,
334,
2473,
12,
2505,
9,
288,
2073,
275,
283,
1114,
15,
1364,
15,
17596,
4805,
267,
587,
26,
288,
1790,
275,
2125,
288,
2073,
275,
283,
1364,
15,
17596,
4805,
2728,
372,
283,
1014,
13827,
83,
6721,
2693,
14,
527,
3149,
83,
7,
450,
334,
1178,
12,
2073,
9,
2286,
347,
8509,
600,
8,
277,
12,
1059,
12,
1011,
958,
304,
267,
9918,
275,
942,
267,
1654,
275,
19122,
14,
3120,
4936,
8,
277,
14,
633,
9,
267,
2058,
275,
1654,
14,
6721,
600,
8,
277,
14,
908,
63,
875,
450,
1059,
9,
267,
367,
754,
315,
2058,
26,
288,
536,
275,
291,
423,
908,
63,
354,
8,
1099,
9,
288,
18896,
275,
754,
14,
362,
360,
4452,
358,
288,
18154,
275,
754,
14,
362,
360,
2809,
358,
288,
340,
18896,
436,
18154,
26,
355,
2376,
275,
7584,
8,
13331,
12,
18154,
9,
288,
587,
26,
355,
2376,
275,
488,
288,
2909,
275,
12625,
8,
354,
12,
2376,
12,
1211,
8,
1099,
430,
288,
9918,
14,
740,
8,
1985,
9,
267,
372,
9918,
2286,
347,
485,
908,
63,
354,
8,
277,
12,
754,
304,
267,
2287,
275,
359,
288,
754,
14,
362,
360,
1955,
659,
288,
754,
14,
362,
360,
1861,
659,
288,
754,
14,
362,
360,
20451,
659,
288,
754,
14,
362,
360,
20451,
63,
466,
659,
288,
754,
14,
362,
360,
4511,
358,
267,
1622,
267,
14492,
275,
754,
14,
362,
360,
3690,
358,
267,
1174,
275,
754,
14,
362,
360,
929,
358,
267,
3482,
63,
600,
275,
754,
14,
362,
360,
3065,
358,
2728,
372,
4884,
14,
904,
63,
1541,
11854,
3872,
359,
288,
4884,
14,
904,
63,
1541,
480,
3872,
2287,
395,
288,
14492,
12,
288,
4884,
14,
904,
63,
1541,
480,
3872,
359,
929,
12,
3482,
63,
600,
566,
267,
4794,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
fossoult/odoo
|
addons/purchase_double_validation/__init__.py
|
441
|
1090
|
# -*- 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 purchase_double_validation_installer
# 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,
15932,
63,
3157,
63,
6136,
63,
17047,
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
] |
[
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,
15932,
63,
3157,
63,
6136,
63,
17047,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
NL66278/OCB
|
addons/base_report_designer/plugin/openerp_report_designer/bin/script/NewReport.py
|
384
|
3903
|
#########################################################################
#
# Copyright (c) 2003-2004 Danny Brewer d29583@groovegarden.com
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#############################################################################
import uno
import string
import unohelper
import xmlrpclib
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from lib.error import ErrorDialog
from lib.functions import *
from lib.logreport import *
from LoginTest import *
from lib.rpc import *
database="test"
uid = 3
#
#
#
# Start OpenOffice.org, listen for connections and open testing document
#
#
class NewReport(unohelper.Base, XJobExecutor):
def __init__(self, ctx):
self.ctx = ctx
self.module = "openerp_report"
self.version = "0.1"
LoginTest()
self.logobj=Logger()
if not loginstatus and __name__=="package":
exit(1)
self.win=DBModalDialog(60, 50, 180, 115, "Open New Report")
self.win.addFixedText("lblModuleSelection", 2, 2, 60, 15, "Module Selection")
self.win.addComboListBox("lstModule", -2,13,176,80 , False)
self.lstModule = self.win.getControl( "lstModule" )
self.aModuleName=[]
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
global passwd
self.password = passwd
global url
self.sock=RPCSession(url)
ids = self.sock.execute(database, uid, self.password, 'ir.model' , 'search',[])
fields = [ 'model','name']
res = self.sock.execute(database, uid, self.password, 'ir.model' , 'read', ids, fields)
res.sort(lambda x, y: cmp(x['name'],y['name']))
for i in range(len(res)):
self.lstModule.addItem(res[i]['name'],self.lstModule.getItemCount())
self.aModuleName.append(res[i]['model'])
self.win.addButton('btnOK',-2 ,-5, 70,15,'Use Module in Report' ,actionListenerProc = self.btnOk_clicked )
self.win.addButton('btnCancel',-2 - 70 - 5 ,-5, 35,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked )
self.win.doModalDialog("",None)
def btnOk_clicked(self, oActionEvent):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
docinfo.setUserFieldValue(3,self.aModuleName[self.lstModule.getSelectedItemPos()])
self.logobj.log_write('Module Name',LOG_INFO, ':Module use in creating a report %s using database %s' % (self.aModuleName[self.lstModule.getSelectedItemPos()], database))
self.win.endExecute()
def btnCancel_clicked(self, oActionEvent):
self.win.endExecute()
if __name__<>"package" and __name__=="__main__":
NewReport(None)
elif __name__=="package":
g_ImplementationHelper.addImplementation( \
NewReport,
"org.openoffice.openerp.report.opennewreport",
("com.sun.star.task.Job",),)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3949,
3,
199,
3,
199,
3,
221,
1898,
334,
67,
9,
13004,
13,
15431,
577,
1189,
89,
699,
264,
2135,
366,
1398,
16793,
32,
23260,
79,
432,
23909,
848,
14,
957,
199,
3,
221,
1898,
334,
35,
9,
8353,
13,
6542,
7653,
13950,
8642,
1014,
921,
11267,
14,
957,
10121,
199,
3,
199,
3,
221,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
221,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
221,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
221,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
221,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
221,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
221,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
221,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
221,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
221,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
221,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
221,
8217,
199,
3,
199,
3,
221,
1666,
26,
221,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
9783,
1168,
14,
1360,
199,
3,
199,
31635,
199,
199,
646,
625,
79,
199,
646,
1059,
199,
646,
625,
79,
3676,
199,
646,
19122,
199,
199,
504,
2414,
14,
11846,
14,
7848,
14,
1765,
492,
1323,
6694,
16752,
199,
692,
636,
354,
363,
28,
4335,
2491,
582,
272,
687,
1973,
14,
5885,
492,
627,
272,
687,
1973,
14,
705,
492,
4520,
5619,
272,
687,
1973,
14,
5777,
492,
627,
272,
687,
1973,
14,
793,
3070,
492,
627,
272,
687,
16430,
774,
492,
627,
272,
687,
1973,
14,
4354,
492,
627,
272,
3050,
628,
396,
2,
272,
1747,
275,
650,
199,
3,
199,
3,
199,
3,
199,
3,
7707,
3232,
31166,
14,
1308,
12,
6938,
367,
6947,
436,
1551,
5343,
2213,
199,
3,
199,
3,
199,
533,
7053,
7457,
8,
324,
79,
3676,
14,
1563,
12,
1323,
6694,
16752,
304,
272,
347,
636,
826,
721,
277,
12,
4027,
304,
267,
291,
14,
3799,
258,
275,
4027,
267,
291,
14,
578,
221,
275,
298,
11267,
63,
3070,
2,
267,
291,
14,
1023,
275,
298,
16,
14,
17,
2,
267,
16430,
774,
342,
267,
291,
14,
793,
1113,
29,
4455,
342,
267,
340,
440,
4676,
1205,
436,
636,
354,
363,
11800,
2491,
582,
288,
4458,
8,
17,
9,
267,
291,
14,
2676,
29,
2846,
23689,
5619,
8,
2259,
12,
5238,
12,
13576,
12,
22560,
12,
298,
4299,
7053,
11774,
531,
267,
291,
14,
2676,
14,
525,
9515,
1872,
480,
18842,
2377,
7713,
401,
499,
12,
499,
12,
5212,
12,
4114,
12,
298,
2377,
3240,
1486,
531,
267,
291,
14,
2676,
14,
525,
12413,
26764,
480,
6916,
2377,
401,
446,
18,
12,
969,
12,
10216,
12,
1257,
2360,
756,
9,
267,
291,
14,
6916,
2377,
275,
291,
14,
2676,
14,
25117,
8,
298,
6916,
2377,
2,
776,
267,
291,
14,
65,
2377,
985,
9811,
267,
19763,
29,
362,
20436,
342,
267,
1382,
275,
19763,
14,
16662,
7004,
342,
267,
1382,
815,
29,
1301,
14,
362,
5564,
2354,
342,
398,
2288,
15081,
267,
291,
14,
2060,
275,
15081,
267,
2288,
1166,
267,
291,
14,
5096,
29,
18612,
3298,
3552,
8,
633,
9,
267,
2762,
275,
291,
14,
5096,
14,
2526,
8,
4659,
12,
1747,
12,
291,
14,
2060,
12,
283,
723,
14,
1238,
7,
2360,
283,
1733,
23993,
566,
267,
1504,
275,
359,
283,
1238,
1673,
354,
418,
267,
522,
275,
291,
14,
5096,
14,
2526,
8,
4659,
12,
1747,
12,
291,
14,
2060,
12,
283,
723,
14,
1238,
7,
2360,
283,
739,
297,
2762,
12,
1504,
9,
267,
522,
14,
3191,
8,
2734,
671,
12,
612,
26,
10467,
8,
88,
459,
354,
995,
89,
459,
354,
5156,
398,
367,
284,
315,
1425,
8,
552,
8,
470,
2298,
288,
291,
14,
6916,
2377,
14,
19798,
8,
470,
59,
73,
2733,
354,
995,
277,
14,
6916,
2377,
14,
362,
2081,
2353,
1012,
288,
291,
14,
65,
2377,
985,
14,
740,
8,
470,
59,
73,
2733,
1238,
1105,
267,
291,
14,
2676,
14,
525,
4259,
360,
9633,
3593,
297,
13,
18,
2360,
13,
21,
12,
10045,
12,
1046,
2584,
6119,
5673,
315,
11774,
7,
2360,
1287,
10464,
15019,
275,
291,
14,
9633,
11622,
63,
11276,
776,
267,
291,
14,
2676,
14,
525,
4259,
360,
9633,
9083,
297,
13,
18,
446,
10045,
446,
959,
2360,
13,
21,
12,
8685,
12,
1046,
2584,
9083,
7,
2360,
1287,
10464,
15019,
275,
291,
14,
9633,
9083,
63,
11276,
776,
267,
291,
14,
2676,
14,
1117,
23689,
5619,
12398,
403,
9,
339,
347,
19368,
11622,
63,
11276,
8,
277,
12,
312,
3310,
2390,
304,
267,
19763,
29,
362,
20436,
342,
267,
1382,
275,
19763,
14,
16662,
7004,
342,
267,
1382,
815,
29,
1301,
14,
362,
5564,
2354,
342,
267,
1382,
815,
14,
409,
1899,
792,
1110,
8,
19,
12,
277,
14,
65,
2377,
985,
59,
277,
14,
6916,
2377,
14,
362,
12461,
2081,
6981,
9383,
267,
291,
14,
793,
1113,
14,
793,
63,
952,
360,
2377,
2812,
297,
4947,
63,
4531,
12,
7596,
2377,
675,
315,
6425,
282,
3622,
450,
83,
221,
1808,
3050,
450,
83,
7,
450,
334,
277,
14,
65,
2377,
985,
59,
277,
14,
6916,
2377,
14,
362,
12461,
2081,
6981,
15618,
3050,
430,
267,
291,
14,
2676,
14,
500,
12049,
342,
339,
347,
19368,
9083,
63,
11276,
8,
277,
12,
312,
3310,
2390,
304,
267,
291,
14,
2676,
14,
500,
12049,
342,
199,
199,
692,
636,
354,
363,
28,
4335,
2491,
2,
436,
636,
354,
363,
11800,
363,
973,
5727,
272,
7053,
7457,
8,
403,
9,
199,
4164,
636,
354,
363,
11800,
2491,
582,
272,
486,
63,
7921,
4433,
14,
525,
7921,
8,
971,
288,
7053,
7457,
12,
288,
298,
1308,
14,
1490,
18812,
14,
11267,
14,
3070,
14,
1490,
1222,
3070,
401
] |
[
3,
199,
3,
199,
3,
221,
1898,
334,
67,
9,
13004,
13,
15431,
577,
1189,
89,
699,
264,
2135,
366,
1398,
16793,
32,
23260,
79,
432,
23909,
848,
14,
957,
199,
3,
221,
1898,
334,
35,
9,
8353,
13,
6542,
7653,
13950,
8642,
1014,
921,
11267,
14,
957,
10121,
199,
3,
199,
3,
221,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
221,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
221,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
221,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
221,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
221,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
221,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
221,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
221,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
221,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
221,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
221,
8217,
199,
3,
199,
3,
221,
1666,
26,
221,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
9783,
1168,
14,
1360,
199,
3,
199,
31635,
199,
199,
646,
625,
79,
199,
646,
1059,
199,
646,
625,
79,
3676,
199,
646,
19122,
199,
199,
504,
2414,
14,
11846,
14,
7848,
14,
1765,
492,
1323,
6694,
16752,
199,
692,
636,
354,
363,
28,
4335,
2491,
582,
272,
687,
1973,
14,
5885,
492,
627,
272,
687,
1973,
14,
705,
492,
4520,
5619,
272,
687,
1973,
14,
5777,
492,
627,
272,
687,
1973,
14,
793,
3070,
492,
627,
272,
687,
16430,
774,
492,
627,
272,
687,
1973,
14,
4354,
492,
627,
272,
3050,
628,
396,
2,
272,
1747,
275,
650,
199,
3,
199,
3,
199,
3,
199,
3,
7707,
3232,
31166,
14,
1308,
12,
6938,
367,
6947,
436,
1551,
5343,
2213,
199,
3,
199,
3,
199,
533,
7053,
7457,
8,
324,
79,
3676,
14,
1563,
12,
1323,
6694,
16752,
304,
272,
347,
636,
826,
721,
277,
12,
4027,
304,
267,
291,
14,
3799,
258,
275,
4027,
267,
291,
14,
578,
221,
275,
298,
11267,
63,
3070,
2,
267,
291,
14,
1023,
275,
298,
16,
14,
17,
2,
267,
16430,
774,
342,
267,
291,
14,
793,
1113,
29,
4455,
342,
267,
340,
440,
4676,
1205,
436,
636,
354,
363,
11800,
2491,
582,
288,
4458,
8,
17,
9,
267,
291,
14,
2676,
29,
2846,
23689,
5619,
8,
2259,
12,
5238,
12,
13576,
12,
22560,
12,
298,
4299,
7053,
11774,
531,
267,
291,
14,
2676,
14,
525,
9515,
1872,
480,
18842,
2377,
7713,
401,
499,
12,
499,
12,
5212,
12,
4114,
12,
298,
2377,
3240,
1486,
531,
267,
291,
14,
2676,
14,
525,
12413,
26764,
480,
6916,
2377,
401,
446,
18,
12,
969,
12,
10216,
12,
1257,
2360,
756,
9,
267,
291,
14,
6916,
2377,
275,
291,
14,
2676,
14,
25117,
8,
298,
6916,
2377,
2,
776,
267,
291,
14,
65,
2377,
985,
9811,
267,
19763,
29,
362,
20436,
342,
267,
1382,
275,
19763,
14,
16662,
7004,
342,
267,
1382,
815,
29,
1301,
14,
362,
5564,
2354,
342,
398,
2288,
15081,
267,
291,
14,
2060,
275,
15081,
267,
2288,
1166,
267,
291,
14,
5096,
29,
18612,
3298,
3552,
8,
633,
9,
267,
2762,
275,
291,
14,
5096,
14,
2526,
8,
4659,
12,
1747,
12,
291,
14,
2060,
12,
283,
723,
14,
1238,
7,
2360,
283,
1733,
23993,
566,
267,
1504,
275,
359,
283,
1238,
1673,
354,
418,
267,
522,
275,
291,
14,
5096,
14,
2526,
8,
4659,
12,
1747,
12,
291,
14,
2060,
12,
283,
723,
14,
1238,
7,
2360,
283,
739,
297,
2762,
12,
1504,
9,
267,
522,
14,
3191,
8,
2734,
671,
12,
612,
26,
10467,
8,
88,
459,
354,
995,
89,
459,
354,
5156,
398,
367,
284,
315,
1425,
8,
552,
8,
470,
2298,
288,
291,
14,
6916,
2377,
14,
19798,
8,
470,
59,
73,
2733,
354,
995,
277,
14,
6916,
2377,
14,
362,
2081,
2353,
1012,
288,
291,
14,
65,
2377,
985,
14,
740,
8,
470,
59,
73,
2733,
1238,
1105,
267,
291,
14,
2676,
14,
525,
4259,
360,
9633,
3593,
297,
13,
18,
2360,
13,
21,
12,
10045,
12,
1046,
2584,
6119,
5673,
315,
11774,
7,
2360,
1287,
10464,
15019,
275,
291,
14,
9633,
11622,
63,
11276,
776,
267,
291,
14,
2676,
14,
525,
4259,
360,
9633,
9083,
297,
13,
18,
446,
10045,
446,
959,
2360,
13,
21,
12,
8685,
12,
1046,
2584,
9083,
7,
2360,
1287,
10464,
15019,
275,
291,
14,
9633,
9083,
63,
11276,
776,
267,
291,
14,
2676,
14,
1117,
23689,
5619,
12398,
403,
9,
339,
347,
19368,
11622,
63,
11276,
8,
277,
12,
312,
3310,
2390,
304,
267,
19763,
29,
362,
20436,
342,
267,
1382,
275,
19763,
14,
16662,
7004,
342,
267,
1382,
815,
29,
1301,
14,
362,
5564,
2354,
342,
267,
1382,
815,
14,
409,
1899,
792,
1110,
8,
19,
12,
277,
14,
65,
2377,
985,
59,
277,
14,
6916,
2377,
14,
362,
12461,
2081,
6981,
9383,
267,
291,
14,
793,
1113,
14,
793,
63,
952,
360,
2377,
2812,
297,
4947,
63,
4531,
12,
7596,
2377,
675,
315,
6425,
282,
3622,
450,
83,
221,
1808,
3050,
450,
83,
7,
450,
334,
277,
14,
65,
2377,
985,
59,
277,
14,
6916,
2377,
14,
362,
12461,
2081,
6981,
15618,
3050,
430,
267,
291,
14,
2676,
14,
500,
12049,
342,
339,
347,
19368,
9083,
63,
11276,
8,
277,
12,
312,
3310,
2390,
304,
267,
291,
14,
2676,
14,
500,
12049,
342,
199,
199,
692,
636,
354,
363,
28,
4335,
2491,
2,
436,
636,
354,
363,
11800,
363,
973,
5727,
272,
7053,
7457,
8,
403,
9,
199,
4164,
636,
354,
363,
11800,
2491,
582,
272,
486,
63,
7921,
4433,
14,
525,
7921,
8,
971,
288,
7053,
7457,
12,
288,
298,
1308,
14,
1490,
18812,
14,
11267,
14,
3070,
14,
1490,
1222,
3070,
401,
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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settings
from django.http import HttpResponsePermanentRedirect
class SecurityMiddleware(object):
def __init__(self):
self.sts_seconds = settings.SECURE_HSTS_SECONDS
self.sts_include_subdomains = settings.SECURE_HSTS_INCLUDE_SUBDOMAINS
self.content_type_nosniff = settings.SECURE_CONTENT_TYPE_NOSNIFF
self.xss_filter = settings.SECURE_BROWSER_XSS_FILTER
self.redirect = settings.SECURE_SSL_REDIRECT
self.redirect_host = settings.SECURE_SSL_HOST
self.redirect_exempt = [re.compile(r) for r in settings.SECURE_REDIRECT_EXEMPT]
def process_request(self, request):
path = request.path.lstrip("/")
if (self.redirect and not request.is_secure() and
not any(pattern.search(path)
for pattern in self.redirect_exempt)):
host = self.redirect_host or request.get_host()
return HttpResponsePermanentRedirect(
"https://%s%s" % (host, request.get_full_path())
)
def process_response(self, request, response):
if (self.sts_seconds and request.is_secure() and
'strict-transport-security' not in response):
sts_header = "max-age=%s" % self.sts_seconds
if self.sts_include_subdomains:
sts_header = sts_header + "; includeSubDomains"
response["strict-transport-security"] = sts_header
if self.content_type_nosniff and 'x-content-type-options' not in response:
response["x-content-type-options"] = "nosniff"
if self.xss_filter and 'x-xss-protection' not in response:
response["x-xss-protection"] = "1; mode=block"
return response
|
mit
|
[
646,
295,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1014,
492,
6183,
31776,
7071,
421,
199,
533,
13863,
6608,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
10329,
63,
4515,
275,
2202,
14,
20696,
63,
40,
840,
51,
63,
23319,
267,
291,
14,
10329,
63,
2613,
63,
954,
9756,
275,
2202,
14,
20696,
63,
40,
840,
51,
63,
18171,
63,
6348,
7378,
51,
267,
291,
14,
1317,
63,
466,
63,
12712,
8445,
556,
275,
2202,
14,
20696,
63,
9663,
63,
2711,
63,
2826,
8199,
24150,
267,
291,
14,
88,
385,
63,
1541,
275,
2202,
14,
20696,
63,
31956,
3279,
63,
56,
2300,
63,
9905,
267,
291,
14,
4876,
275,
2202,
14,
20696,
63,
5413,
63,
19747,
267,
291,
14,
4876,
63,
1102,
275,
2202,
14,
20696,
63,
5413,
63,
5449,
267,
291,
14,
4876,
63,
25254,
275,
359,
264,
14,
2014,
8,
82,
9,
367,
519,
315,
2202,
14,
20696,
63,
19747,
63,
23017,
26178,
61,
339,
347,
2112,
63,
1069,
8,
277,
12,
1056,
304,
267,
931,
275,
1056,
14,
515,
14,
10124,
19031,
267,
340,
334,
277,
14,
4876,
436,
440,
1056,
14,
374,
63,
7817,
342,
436,
355,
440,
1263,
8,
3401,
14,
1733,
8,
515,
9,
717,
367,
3851,
315,
291,
14,
4876,
63,
25254,
2298,
288,
1591,
275,
291,
14,
4876,
63,
1102,
503,
1056,
14,
362,
63,
1102,
342,
288,
372,
6183,
31776,
7071,
8,
355,
298,
2859,
13827,
83,
5,
83,
2,
450,
334,
1102,
12,
1056,
14,
362,
63,
2861,
63,
515,
1012,
288,
776,
339,
347,
2112,
63,
1310,
8,
277,
12,
1056,
12,
1177,
304,
267,
340,
334,
277,
14,
10329,
63,
4515,
436,
1056,
14,
374,
63,
7817,
342,
436,
355,
283,
4768,
13,
5545,
13,
4416,
7,
440,
315,
1177,
304,
288,
23014,
63,
1291,
275,
298,
988,
13,
474,
2458,
83,
2,
450,
291,
14,
10329,
63,
4515,
953,
340,
291,
14,
10329,
63,
2613,
63,
954,
9756,
26,
355,
23014,
63,
1291,
275,
23014,
63,
1291,
435,
28036,
2387,
2610,
7705,
83,
2,
953,
1177,
905,
4768,
13,
5545,
13,
4416,
937,
275,
23014,
63,
1291,
398,
340,
291,
14,
1317,
63,
466,
63,
12712,
8445,
556,
436,
283,
88,
13,
1317,
13,
466,
13,
1419,
7,
440,
315,
1177,
26,
288,
1177,
905,
88,
13,
1317,
13,
466,
13,
1419,
937,
275,
298,
12712,
8445,
556,
2,
398,
340,
291,
14,
88,
385,
63,
1541,
436,
283,
88,
13,
88,
385,
13,
14103,
7,
440,
315,
1177,
26,
288,
1177,
905,
88,
13,
88,
385,
13,
14103,
937,
275,
298,
17,
27,
818,
29,
1457,
2,
398,
372,
1177,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1014,
492,
6183,
31776,
7071,
421,
199,
533,
13863,
6608,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
10329,
63,
4515,
275,
2202,
14,
20696,
63,
40,
840,
51,
63,
23319,
267,
291,
14,
10329,
63,
2613,
63,
954,
9756,
275,
2202,
14,
20696,
63,
40,
840,
51,
63,
18171,
63,
6348,
7378,
51,
267,
291,
14,
1317,
63,
466,
63,
12712,
8445,
556,
275,
2202,
14,
20696,
63,
9663,
63,
2711,
63,
2826,
8199,
24150,
267,
291,
14,
88,
385,
63,
1541,
275,
2202,
14,
20696,
63,
31956,
3279,
63,
56,
2300,
63,
9905,
267,
291,
14,
4876,
275,
2202,
14,
20696,
63,
5413,
63,
19747,
267,
291,
14,
4876,
63,
1102,
275,
2202,
14,
20696,
63,
5413,
63,
5449,
267,
291,
14,
4876,
63,
25254,
275,
359,
264,
14,
2014,
8,
82,
9,
367,
519,
315,
2202,
14,
20696,
63,
19747,
63,
23017,
26178,
61,
339,
347,
2112,
63,
1069,
8,
277,
12,
1056,
304,
267,
931,
275,
1056,
14,
515,
14,
10124,
19031,
267,
340,
334,
277,
14,
4876,
436,
440,
1056,
14,
374,
63,
7817,
342,
436,
355,
440,
1263,
8,
3401,
14,
1733,
8,
515,
9,
717,
367,
3851,
315,
291,
14,
4876,
63,
25254,
2298,
288,
1591,
275,
291,
14,
4876,
63,
1102,
503,
1056,
14,
362,
63,
1102,
342,
288,
372,
6183,
31776,
7071,
8,
355,
298,
2859,
13827,
83,
5,
83,
2,
450,
334,
1102,
12,
1056,
14,
362,
63,
2861,
63,
515,
1012,
288,
776,
339,
347,
2112,
63,
1310,
8,
277,
12,
1056,
12,
1177,
304,
267,
340,
334,
277,
14,
10329,
63,
4515,
436,
1056,
14,
374,
63,
7817,
342,
436,
355,
283,
4768,
13,
5545,
13,
4416,
7,
440,
315,
1177,
304,
288,
23014,
63,
1291,
275,
298,
988,
13,
474,
2458,
83,
2,
450,
291,
14,
10329,
63,
4515,
953,
340,
291,
14,
10329,
63,
2613,
63,
954,
9756,
26,
355,
23014,
63,
1291,
275,
23014,
63,
1291,
435,
28036,
2387,
2610,
7705,
83,
2,
953,
1177,
905,
4768,
13,
5545,
13,
4416,
937,
275,
23014,
63,
1291,
398,
340,
291,
14,
1317,
63,
466,
63,
12712,
8445,
556,
436,
283,
88,
13,
1317,
13,
466,
13,
1419,
7,
440,
315,
1177,
26,
288,
1177,
905,
88,
13,
1317,
13,
466,
13,
1419,
937,
275,
298,
12712,
8445,
556,
2,
398,
340,
291,
14,
88,
385,
63,
1541,
436,
283,
88,
13,
88,
385,
13,
14103,
7,
440,
315,
1177,
26,
288,
1177,
905,
88,
13,
88,
385,
13,
14103,
937,
275,
298,
17,
27,
818,
29,
1457,
2,
398,
372,
1177,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768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,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jjinux/party-playlist-picker
|
third-party/gdata/tlslite/utils/cryptomath.py
|
103
|
11654
|
"""cryptomath module
This module has basic math/crypto code."""
import os
import sys
import math
import base64
import binascii
if sys.version_info[:2] <= (2, 4):
from sha import sha as sha1
else:
from hashlib import sha1
from compat import *
# **************************************************************************
# Load Optional Modules
# **************************************************************************
# Try to load M2Crypto/OpenSSL
try:
from M2Crypto import m2
m2cryptoLoaded = True
except ImportError:
m2cryptoLoaded = False
# Try to load cryptlib
try:
import cryptlib_py
try:
cryptlib_py.cryptInit()
except cryptlib_py.CryptException, e:
#If tlslite and cryptoIDlib are both present,
#they might each try to re-initialize this,
#so we're tolerant of that.
if e[0] != cryptlib_py.CRYPT_ERROR_INITED:
raise
cryptlibpyLoaded = True
except ImportError:
cryptlibpyLoaded = False
#Try to load GMPY
try:
import gmpy
gmpyLoaded = True
except ImportError:
gmpyLoaded = False
#Try to load pycrypto
try:
import Crypto.Cipher.AES
pycryptoLoaded = True
except ImportError:
pycryptoLoaded = False
# **************************************************************************
# PRNG Functions
# **************************************************************************
# Get os.urandom PRNG
try:
os.urandom(1)
def getRandomBytes(howMany):
return stringToBytes(os.urandom(howMany))
prngName = "os.urandom"
except:
# Else get cryptlib PRNG
if cryptlibpyLoaded:
def getRandomBytes(howMany):
randomKey = cryptlib_py.cryptCreateContext(cryptlib_py.CRYPT_UNUSED,
cryptlib_py.CRYPT_ALGO_AES)
cryptlib_py.cryptSetAttribute(randomKey,
cryptlib_py.CRYPT_CTXINFO_MODE,
cryptlib_py.CRYPT_MODE_OFB)
cryptlib_py.cryptGenerateKey(randomKey)
bytes = createByteArrayZeros(howMany)
cryptlib_py.cryptEncrypt(randomKey, bytes)
return bytes
prngName = "cryptlib"
else:
#Else get UNIX /dev/urandom PRNG
try:
devRandomFile = open("/dev/urandom", "rb")
def getRandomBytes(howMany):
return stringToBytes(devRandomFile.read(howMany))
prngName = "/dev/urandom"
except IOError:
#Else get Win32 CryptoAPI PRNG
try:
import win32prng
def getRandomBytes(howMany):
s = win32prng.getRandomBytes(howMany)
if len(s) != howMany:
raise AssertionError()
return stringToBytes(s)
prngName ="CryptoAPI"
except ImportError:
#Else no PRNG :-(
def getRandomBytes(howMany):
raise NotImplementedError("No Random Number Generator "\
"available.")
prngName = "None"
# **************************************************************************
# Converter Functions
# **************************************************************************
def bytesToNumber(bytes):
total = 0L
multiplier = 1L
for count in range(len(bytes)-1, -1, -1):
byte = bytes[count]
total += multiplier * byte
multiplier *= 256
return total
def numberToBytes(n):
howManyBytes = numBytes(n)
bytes = createByteArrayZeros(howManyBytes)
for count in range(howManyBytes-1, -1, -1):
bytes[count] = int(n % 256)
n >>= 8
return bytes
def bytesToBase64(bytes):
s = bytesToString(bytes)
return stringToBase64(s)
def base64ToBytes(s):
s = base64ToString(s)
return stringToBytes(s)
def numberToBase64(n):
bytes = numberToBytes(n)
return bytesToBase64(bytes)
def base64ToNumber(s):
bytes = base64ToBytes(s)
return bytesToNumber(bytes)
def stringToNumber(s):
bytes = stringToBytes(s)
return bytesToNumber(bytes)
def numberToString(s):
bytes = numberToBytes(s)
return bytesToString(bytes)
def base64ToString(s):
try:
return base64.decodestring(s)
except binascii.Error, e:
raise SyntaxError(e)
except binascii.Incomplete, e:
raise SyntaxError(e)
def stringToBase64(s):
return base64.encodestring(s).replace("\n", "")
def mpiToNumber(mpi): #mpi is an openssl-format bignum string
if (ord(mpi[4]) & 0x80) !=0: #Make sure this is a positive number
raise AssertionError()
bytes = stringToBytes(mpi[4:])
return bytesToNumber(bytes)
def numberToMPI(n):
bytes = numberToBytes(n)
ext = 0
#If the high-order bit is going to be set,
#add an extra byte of zeros
if (numBits(n) & 0x7)==0:
ext = 1
length = numBytes(n) + ext
bytes = concatArrays(createByteArrayZeros(4+ext), bytes)
bytes[0] = (length >> 24) & 0xFF
bytes[1] = (length >> 16) & 0xFF
bytes[2] = (length >> 8) & 0xFF
bytes[3] = length & 0xFF
return bytesToString(bytes)
# **************************************************************************
# Misc. Utility Functions
# **************************************************************************
def numBytes(n):
if n==0:
return 0
bits = numBits(n)
return int(math.ceil(bits / 8.0))
def hashAndBase64(s):
return stringToBase64(sha1(s).digest())
def getBase64Nonce(numChars=22): #defaults to an 132 bit nonce
bytes = getRandomBytes(numChars)
bytesStr = "".join([chr(b) for b in bytes])
return stringToBase64(bytesStr)[:numChars]
# **************************************************************************
# Big Number Math
# **************************************************************************
def getRandomNumber(low, high):
if low >= high:
raise AssertionError()
howManyBits = numBits(high)
howManyBytes = numBytes(high)
lastBits = howManyBits % 8
while 1:
bytes = getRandomBytes(howManyBytes)
if lastBits:
bytes[0] = bytes[0] % (1 << lastBits)
n = bytesToNumber(bytes)
if n >= low and n < high:
return n
def gcd(a,b):
a, b = max(a,b), min(a,b)
while b:
a, b = b, a % b
return a
def lcm(a, b):
#This will break when python division changes, but we can't use // cause
#of Jython
return (a * b) / gcd(a, b)
#Returns inverse of a mod b, zero if none
#Uses Extended Euclidean Algorithm
def invMod(a, b):
c, d = a, b
uc, ud = 1, 0
while c != 0:
#This will break when python division changes, but we can't use //
#cause of Jython
q = d / c
c, d = d-(q*c), c
uc, ud = ud - (q * uc), uc
if d == 1:
return ud % b
return 0
if gmpyLoaded:
def powMod(base, power, modulus):
base = gmpy.mpz(base)
power = gmpy.mpz(power)
modulus = gmpy.mpz(modulus)
result = pow(base, power, modulus)
return long(result)
else:
#Copied from Bryan G. Olson's post to comp.lang.python
#Does left-to-right instead of pow()'s right-to-left,
#thus about 30% faster than the python built-in with small bases
def powMod(base, power, modulus):
nBitScan = 5
""" Return base**power mod modulus, using multi bit scanning
with nBitScan bits at a time."""
#TREV - Added support for negative exponents
negativeResult = False
if (power < 0):
power *= -1
negativeResult = True
exp2 = 2**nBitScan
mask = exp2 - 1
# Break power into a list of digits of nBitScan bits.
# The list is recursive so easy to read in reverse direction.
nibbles = None
while power:
nibbles = int(power & mask), nibbles
power = power >> nBitScan
# Make a table of powers of base up to 2**nBitScan - 1
lowPowers = [1]
for i in xrange(1, exp2):
lowPowers.append((lowPowers[i-1] * base) % modulus)
# To exponentiate by the first nibble, look it up in the table
nib, nibbles = nibbles
prod = lowPowers[nib]
# For the rest, square nBitScan times, then multiply by
# base^nibble
while nibbles:
nib, nibbles = nibbles
for i in xrange(nBitScan):
prod = (prod * prod) % modulus
if nib: prod = (prod * lowPowers[nib]) % modulus
#TREV - Added support for negative exponents
if negativeResult:
prodInv = invMod(prod, modulus)
#Check to make sure the inverse is correct
if (prod * prodInv) % modulus != 1:
raise AssertionError()
return prodInv
return prod
#Pre-calculate a sieve of the ~100 primes < 1000:
def makeSieve(n):
sieve = range(n)
for count in range(2, int(math.sqrt(n))):
if sieve[count] == 0:
continue
x = sieve[count] * 2
while x < len(sieve):
sieve[x] = 0
x += sieve[count]
sieve = [x for x in sieve[2:] if x]
return sieve
sieve = makeSieve(1000)
def isPrime(n, iterations=5, display=False):
#Trial division with sieve
for x in sieve:
if x >= n: return True
if n % x == 0: return False
#Passed trial division, proceed to Rabin-Miller
#Rabin-Miller implemented per Ferguson & Schneier
#Compute s, t for Rabin-Miller
if display: print "*",
s, t = n-1, 0
while s % 2 == 0:
s, t = s/2, t+1
#Repeat Rabin-Miller x times
a = 2 #Use 2 as a base for first iteration speedup, per HAC
for count in range(iterations):
v = powMod(a, s, n)
if v==1:
continue
i = 0
while v != n-1:
if i == t-1:
return False
else:
v, i = powMod(v, 2, n), i+1
a = getRandomNumber(2, n)
return True
def getRandomPrime(bits, display=False):
if bits < 10:
raise AssertionError()
#The 1.5 ensures the 2 MSBs are set
#Thus, when used for p,q in RSA, n will have its MSB set
#
#Since 30 is lcm(2,3,5), we'll set our test numbers to
#29 % 30 and keep them there
low = (2L ** (bits-1)) * 3/2
high = 2L ** bits - 30
p = getRandomNumber(low, high)
p += 29 - (p % 30)
while 1:
if display: print ".",
p += 30
if p >= high:
p = getRandomNumber(low, high)
p += 29 - (p % 30)
if isPrime(p, display=display):
return p
#Unused at the moment...
def getRandomSafePrime(bits, display=False):
if bits < 10:
raise AssertionError()
#The 1.5 ensures the 2 MSBs are set
#Thus, when used for p,q in RSA, n will have its MSB set
#
#Since 30 is lcm(2,3,5), we'll set our test numbers to
#29 % 30 and keep them there
low = (2 ** (bits-2)) * 3/2
high = (2 ** (bits-1)) - 30
q = getRandomNumber(low, high)
q += 29 - (q % 30)
while 1:
if display: print ".",
q += 30
if (q >= high):
q = getRandomNumber(low, high)
q += 29 - (q % 30)
#Ideas from Tom Wu's SRP code
#Do trial division on p and q before Rabin-Miller
if isPrime(q, 0, display=display):
p = (2 * q) + 1
if isPrime(p, display=display):
if isPrime(q, display=display):
return p
|
apache-2.0
|
[
624,
10316,
3442,
859,
199,
199,
2765,
859,
965,
5678,
3473,
15,
10316,
1233,
1041,
199,
199,
646,
747,
199,
646,
984,
199,
646,
3473,
199,
646,
1300,
772,
199,
646,
14755,
199,
692,
984,
14,
1023,
63,
815,
1491,
18,
61,
2695,
334,
18,
12,
841,
304,
523,
687,
7793,
492,
7793,
465,
7793,
17,
199,
2836,
26,
523,
687,
8337,
492,
7793,
17,
199,
199,
504,
8434,
492,
627,
421,
199,
3,
1011,
14355,
199,
3,
7190,
4879,
18167,
199,
3,
1011,
14355,
199,
199,
3,
7649,
370,
2248,
603,
18,
17134,
15,
22791,
199,
893,
26,
272,
687,
603,
18,
17134,
492,
333,
18,
272,
333,
18,
10316,
19757,
275,
715,
199,
199,
2590,
3545,
26,
272,
333,
18,
10316,
19757,
275,
756,
421,
199,
3,
7649,
370,
2248,
21570,
773,
199,
893,
26,
272,
492,
21570,
773,
63,
647,
272,
862,
26,
267,
21570,
773,
63,
647,
14,
4997,
9346,
342,
272,
871,
21570,
773,
63,
647,
14,
35,
13656,
1726,
12,
325,
26,
267,
327,
3917,
15142,
5333,
436,
13230,
998,
773,
787,
3865,
3451,
12,
267,
327,
29002,
5594,
1924,
862,
370,
295,
13,
8489,
642,
12,
267,
327,
1152,
781,
3984,
370,
1435,
867,
402,
626,
14,
267,
340,
325,
59,
16,
61,
1137,
21570,
773,
63,
647,
14,
19079,
63,
3170,
63,
8727,
1149,
26,
288,
746,
272,
21570,
773,
647,
19757,
275,
715,
199,
199,
2590,
3545,
26,
272,
21570,
773,
647,
19757,
275,
756,
199,
199,
3,
12357,
370,
2248,
598,
1658,
57,
199,
893,
26,
272,
492,
486,
5086,
272,
486,
5086,
19757,
275,
715,
199,
2590,
3545,
26,
272,
486,
5086,
19757,
275,
756,
199,
199,
3,
12357,
370,
2248,
1134,
10316,
199,
893,
26,
272,
492,
18855,
14,
21967,
14,
14494,
272,
1134,
10316,
19757,
275,
715,
199,
2590,
3545,
26,
272,
1134,
10316,
19757,
275,
756,
421,
199,
3,
1011,
14355,
199,
3,
12218,
12259,
17471,
199,
3,
1011,
14355,
199,
199,
3,
2372,
747,
14,
22776,
12218,
12259,
199,
893,
26,
272,
747,
14,
22776,
8,
17,
9,
272,
347,
664,
3883,
5571,
8,
1917,
4089,
304,
267,
372,
1059,
1378,
5571,
8,
736,
14,
22776,
8,
1917,
4089,
430,
272,
5448,
2753,
985,
275,
298,
736,
14,
22776,
2,
199,
199,
2590,
26,
272,
327,
19524,
664,
21570,
773,
12218,
12259,
272,
340,
21570,
773,
647,
19757,
26,
267,
347,
664,
3883,
5571,
8,
1917,
4089,
304,
288,
2196,
1197,
275,
21570,
773,
63,
647,
14,
4997,
2499,
2998,
8,
4997,
773,
63,
647,
14,
19079,
63,
53,
27726,
12,
10940,
21570,
773,
63,
647,
14,
19079,
63,
748,
13160,
63,
14494,
9,
288,
21570,
773,
63,
647,
14,
4997,
24131,
8,
2355,
1197,
12,
5101,
21570,
773,
63,
647,
14,
19079,
63,
21524,
4531,
63,
6963,
12,
5101,
21570,
773,
63,
647,
14,
19079,
63,
6963,
63,
3359,
34,
9,
288,
21570,
773,
63,
647,
14,
4997,
6864,
1197,
8,
2355,
1197,
9,
288,
2783,
275,
1218,
4861,
3836,
58,
27431,
8,
1917,
4089,
9,
288,
21570,
773,
63,
647,
14,
4997,
1327,
4997,
8,
2355,
1197,
12,
2783,
9,
288,
372,
2783,
267,
5448,
2753,
985,
275,
298,
4997,
773,
2,
339,
587,
26,
267,
327,
26836,
664,
22242,
1182,
2374,
15,
22776,
12218,
12259,
267,
862,
26,
288,
4866,
3883,
1173,
275,
1551,
4769,
2374,
15,
22776,
401,
298,
4848,
531,
288,
347,
664,
3883,
5571,
8,
1917,
4089,
304,
355,
372,
1059,
1378,
5571,
8,
2374,
3883,
1173,
14,
739,
8,
1917,
4089,
430,
288,
5448,
2753,
985,
275,
3286,
2374,
15,
22776,
2,
267,
871,
5925,
26,
288,
327,
26836,
664,
13036,
708,
18855,
3735,
12218,
12259,
288,
862,
26,
355,
492,
4747,
708,
2700,
2753,
355,
347,
664,
3883,
5571,
8,
1917,
4089,
304,
490,
308,
275,
4747,
708,
2700,
2753,
14,
362,
3883,
5571,
8,
1917,
4089,
9,
490,
340,
822,
8,
83,
9,
1137,
4212,
4089,
26,
717,
746,
9070,
342,
490,
372,
1059,
1378,
5571,
8,
83,
9,
355,
5448,
2753,
985,
29049,
17134,
3735,
2,
288,
871,
3545,
26,
355,
327,
26836,
949,
12218,
12259,
520,
15426,
355,
347,
664,
3883,
5571,
8,
1917,
4089,
304,
490,
746,
4279,
480,
1944,
9571,
4860,
15042,
1867,
6343,
298,
4561,
2685,
288,
5448,
2753,
985,
275,
298,
403,
2,
199,
199,
3,
1011,
14355,
199,
3,
11801,
351,
17471,
199,
3,
1011,
14355,
199,
199,
318,
2783,
1378,
3259,
8,
2394,
304,
272,
3141,
275,
378,
44,
272,
22215,
275,
413,
44,
272,
367,
2338,
315,
1425,
8,
552,
8,
2394,
7216,
17,
12,
446,
17,
12,
446,
17,
304,
267,
3696,
275,
2783,
59,
835,
61,
267,
3141,
847,
22215,
627,
3696,
267,
22215,
9000,
7633,
272,
372,
3141,
199,
199,
318,
1329,
1378,
5571,
8,
78,
304,
272,
4212,
4089,
5571,
275,
1967,
5571,
8,
78,
9,
272,
2783,
275,
1218,
4861,
3836,
58,
27431,
8,
1917,
4089,
5571,
9,
272,
367,
2338,
315,
1425,
8,
1917,
4089,
5571,
13,
17,
12,
446,
17,
12,
446,
17,
304,
267,
2783,
59,
835,
61,
275,
1109,
8,
78,
450,
7633,
9,
267,
302,
4331,
29,
1695,
272,
372,
2783,
199,
199,
318,
2783,
1378,
1563,
772,
8,
2394,
304,
272,
308,
275,
2783,
7756,
8,
2394,
9,
272,
372,
1059,
1378,
1563,
772,
8,
83,
9,
199,
199,
318,
1300,
772,
1378,
5571,
8,
83,
304,
272,
308,
275,
1300,
772,
7756,
8,
83,
9,
272,
372,
1059,
1378,
5571,
8,
83,
9,
199,
199,
318,
1329,
1378,
1563,
772,
8,
78,
304,
272,
2783,
275,
1329,
1378,
5571,
8,
78,
9,
272,
372,
2783,
1378,
1563,
772,
8,
2394,
9,
199,
199,
318,
1300,
772,
1378,
3259,
8,
83,
304,
272,
2783,
275,
1300,
772,
1378,
5571,
8,
83,
9,
272,
372,
2783,
1378,
3259,
8,
2394,
9,
199,
199,
318,
1059,
1378,
3259,
8,
83,
304,
272,
2783,
275,
1059,
1378,
5571,
8,
83,
9,
272,
372,
2783,
1378,
3259,
8,
2394,
9,
199,
199,
318,
1329,
7756,
8,
83,
304,
272,
2783,
275,
1329,
1378,
5571,
8,
83,
9,
272,
372,
2783,
7756,
8,
2394,
9,
199,
199,
318,
1300,
772,
7756,
8,
83,
304,
272
] |
[
10316,
3442,
859,
199,
199,
2765,
859,
965,
5678,
3473,
15,
10316,
1233,
1041,
199,
199,
646,
747,
199,
646,
984,
199,
646,
3473,
199,
646,
1300,
772,
199,
646,
14755,
199,
692,
984,
14,
1023,
63,
815,
1491,
18,
61,
2695,
334,
18,
12,
841,
304,
523,
687,
7793,
492,
7793,
465,
7793,
17,
199,
2836,
26,
523,
687,
8337,
492,
7793,
17,
199,
199,
504,
8434,
492,
627,
421,
199,
3,
1011,
14355,
199,
3,
7190,
4879,
18167,
199,
3,
1011,
14355,
199,
199,
3,
7649,
370,
2248,
603,
18,
17134,
15,
22791,
199,
893,
26,
272,
687,
603,
18,
17134,
492,
333,
18,
272,
333,
18,
10316,
19757,
275,
715,
199,
199,
2590,
3545,
26,
272,
333,
18,
10316,
19757,
275,
756,
421,
199,
3,
7649,
370,
2248,
21570,
773,
199,
893,
26,
272,
492,
21570,
773,
63,
647,
272,
862,
26,
267,
21570,
773,
63,
647,
14,
4997,
9346,
342,
272,
871,
21570,
773,
63,
647,
14,
35,
13656,
1726,
12,
325,
26,
267,
327,
3917,
15142,
5333,
436,
13230,
998,
773,
787,
3865,
3451,
12,
267,
327,
29002,
5594,
1924,
862,
370,
295,
13,
8489,
642,
12,
267,
327,
1152,
781,
3984,
370,
1435,
867,
402,
626,
14,
267,
340,
325,
59,
16,
61,
1137,
21570,
773,
63,
647,
14,
19079,
63,
3170,
63,
8727,
1149,
26,
288,
746,
272,
21570,
773,
647,
19757,
275,
715,
199,
199,
2590,
3545,
26,
272,
21570,
773,
647,
19757,
275,
756,
199,
199,
3,
12357,
370,
2248,
598,
1658,
57,
199,
893,
26,
272,
492,
486,
5086,
272,
486,
5086,
19757,
275,
715,
199,
2590,
3545,
26,
272,
486,
5086,
19757,
275,
756,
199,
199,
3,
12357,
370,
2248,
1134,
10316,
199,
893,
26,
272,
492,
18855,
14,
21967,
14,
14494,
272,
1134,
10316,
19757,
275,
715,
199,
2590,
3545,
26,
272,
1134,
10316,
19757,
275,
756,
421,
199,
3,
1011,
14355,
199,
3,
12218,
12259,
17471,
199,
3,
1011,
14355,
199,
199,
3,
2372,
747,
14,
22776,
12218,
12259,
199,
893,
26,
272,
747,
14,
22776,
8,
17,
9,
272,
347,
664,
3883,
5571,
8,
1917,
4089,
304,
267,
372,
1059,
1378,
5571,
8,
736,
14,
22776,
8,
1917,
4089,
430,
272,
5448,
2753,
985,
275,
298,
736,
14,
22776,
2,
199,
199,
2590,
26,
272,
327,
19524,
664,
21570,
773,
12218,
12259,
272,
340,
21570,
773,
647,
19757,
26,
267,
347,
664,
3883,
5571,
8,
1917,
4089,
304,
288,
2196,
1197,
275,
21570,
773,
63,
647,
14,
4997,
2499,
2998,
8,
4997,
773,
63,
647,
14,
19079,
63,
53,
27726,
12,
10940,
21570,
773,
63,
647,
14,
19079,
63,
748,
13160,
63,
14494,
9,
288,
21570,
773,
63,
647,
14,
4997,
24131,
8,
2355,
1197,
12,
5101,
21570,
773,
63,
647,
14,
19079,
63,
21524,
4531,
63,
6963,
12,
5101,
21570,
773,
63,
647,
14,
19079,
63,
6963,
63,
3359,
34,
9,
288,
21570,
773,
63,
647,
14,
4997,
6864,
1197,
8,
2355,
1197,
9,
288,
2783,
275,
1218,
4861,
3836,
58,
27431,
8,
1917,
4089,
9,
288,
21570,
773,
63,
647,
14,
4997,
1327,
4997,
8,
2355,
1197,
12,
2783,
9,
288,
372,
2783,
267,
5448,
2753,
985,
275,
298,
4997,
773,
2,
339,
587,
26,
267,
327,
26836,
664,
22242,
1182,
2374,
15,
22776,
12218,
12259,
267,
862,
26,
288,
4866,
3883,
1173,
275,
1551,
4769,
2374,
15,
22776,
401,
298,
4848,
531,
288,
347,
664,
3883,
5571,
8,
1917,
4089,
304,
355,
372,
1059,
1378,
5571,
8,
2374,
3883,
1173,
14,
739,
8,
1917,
4089,
430,
288,
5448,
2753,
985,
275,
3286,
2374,
15,
22776,
2,
267,
871,
5925,
26,
288,
327,
26836,
664,
13036,
708,
18855,
3735,
12218,
12259,
288,
862,
26,
355,
492,
4747,
708,
2700,
2753,
355,
347,
664,
3883,
5571,
8,
1917,
4089,
304,
490,
308,
275,
4747,
708,
2700,
2753,
14,
362,
3883,
5571,
8,
1917,
4089,
9,
490,
340,
822,
8,
83,
9,
1137,
4212,
4089,
26,
717,
746,
9070,
342,
490,
372,
1059,
1378,
5571,
8,
83,
9,
355,
5448,
2753,
985,
29049,
17134,
3735,
2,
288,
871,
3545,
26,
355,
327,
26836,
949,
12218,
12259,
520,
15426,
355,
347,
664,
3883,
5571,
8,
1917,
4089,
304,
490,
746,
4279,
480,
1944,
9571,
4860,
15042,
1867,
6343,
298,
4561,
2685,
288,
5448,
2753,
985,
275,
298,
403,
2,
199,
199,
3,
1011,
14355,
199,
3,
11801,
351,
17471,
199,
3,
1011,
14355,
199,
199,
318,
2783,
1378,
3259,
8,
2394,
304,
272,
3141,
275,
378,
44,
272,
22215,
275,
413,
44,
272,
367,
2338,
315,
1425,
8,
552,
8,
2394,
7216,
17,
12,
446,
17,
12,
446,
17,
304,
267,
3696,
275,
2783,
59,
835,
61,
267,
3141,
847,
22215,
627,
3696,
267,
22215,
9000,
7633,
272,
372,
3141,
199,
199,
318,
1329,
1378,
5571,
8,
78,
304,
272,
4212,
4089,
5571,
275,
1967,
5571,
8,
78,
9,
272,
2783,
275,
1218,
4861,
3836,
58,
27431,
8,
1917,
4089,
5571,
9,
272,
367,
2338,
315,
1425,
8,
1917,
4089,
5571,
13,
17,
12,
446,
17,
12,
446,
17,
304,
267,
2783,
59,
835,
61,
275,
1109,
8,
78,
450,
7633,
9,
267,
302,
4331,
29,
1695,
272,
372,
2783,
199,
199,
318,
2783,
1378,
1563,
772,
8,
2394,
304,
272,
308,
275,
2783,
7756,
8,
2394,
9,
272,
372,
1059,
1378,
1563,
772,
8,
83,
9,
199,
199,
318,
1300,
772,
1378,
5571,
8,
83,
304,
272,
308,
275,
1300,
772,
7756,
8,
83,
9,
272,
372,
1059,
1378,
5571,
8,
83,
9,
199,
199,
318,
1329,
1378,
1563,
772,
8,
78,
304,
272,
2783,
275,
1329,
1378,
5571,
8,
78,
9,
272,
372,
2783,
1378,
1563,
772,
8,
2394,
9,
199,
199,
318,
1300,
772,
1378,
3259,
8,
83,
304,
272,
2783,
275,
1300,
772,
1378,
5571,
8,
83,
9,
272,
372,
2783,
1378,
3259,
8,
2394,
9,
199,
199,
318,
1059,
1378,
3259,
8,
83,
304,
272,
2783,
275,
1059,
1378,
5571,
8,
83,
9,
272,
372,
2783,
1378,
3259,
8,
2394,
9,
199,
199,
318,
1329,
7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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
printerpam/hyde
|
hyde/ext/plugins/urls.py
|
7
|
2399
|
# -*- coding: utf-8 -*-
"""
Contains classes and utilities related to hyde urls.
"""
from hyde.plugin import Plugin
from hyde.site import Site
from functools import wraps
from fswrap import File
class UrlCleanerPlugin(Plugin):
"""
Url Cleaner plugin for hyde. Adds to hyde the ability to generate clean
urls.
Configuration example
---------------------
#yaml
urlcleaner:
index_file_names:
# Identifies the files that represents a directory listing.
# These file names are automatically stripped away when
# the content_url function is called.
- index.html
strip_extensions:
# The following extensions are automatically removed when
# generating the urls using content_url function.
- html
# This option will append a slash to the end of directory paths
append_slash: true
"""
def __init__(self, site):
super(UrlCleanerPlugin, self).__init__(site)
def begin_site(self):
"""
Replace the content_url method in the site object with a custom method
that cleans urls based on the given configuration.
"""
config = self.site.config
if not hasattr(config, 'urlcleaner'):
return
if (hasattr(Site, '___url_cleaner_patched___')):
return
settings = config.urlcleaner
def clean_url(urlgetter):
@wraps(urlgetter)
def wrapper(site, path, safe=None):
url = urlgetter(site, path, safe)
index_file_names = getattr(settings,
'index_file_names',
['index.html'])
rep = File(url)
if rep.name in index_file_names:
url = rep.parent.path.rstrip('/')
if hasattr(settings, 'append_slash') and \
settings.append_slash:
url += '/'
elif hasattr(settings, 'strip_extensions'):
if rep.kind in settings.strip_extensions:
url = rep.parent.child(rep.name_without_extension)
return url or '/'
return wrapper
Site.___url_cleaner_patched___ = True
Site.content_url = clean_url(Site.content_url)
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
6906,
3992,
436,
15841,
4048,
370,
7188,
271,
8187,
14,
199,
624,
199,
504,
7188,
271,
14,
2718,
492,
11349,
199,
504,
7188,
271,
14,
2124,
492,
11666,
199,
199,
504,
9143,
492,
14018,
199,
504,
289,
3519,
1330,
492,
3814,
421,
199,
533,
20503,
6580,
281,
5061,
8,
5061,
304,
339,
408,
272,
20503,
12762,
281,
3589,
367,
7188,
271,
14,
15747,
370,
7188,
271,
314,
21255,
370,
3550,
3633,
272,
8187,
14,
339,
11595,
2893,
272,
10652,
9858,
272,
327,
5963,
272,
1166,
3118,
281,
26,
267,
1478,
63,
493,
63,
1247,
26,
288,
327,
473,
2433,
397,
314,
1584,
626,
8469,
282,
2082,
13778,
14,
288,
327,
5723,
570,
1561,
787,
5847,
14489,
13437,
1380,
288,
327,
314,
1564,
63,
633,
805,
365,
2797,
14,
288,
446,
1478,
14,
1360,
267,
6202,
63,
5359,
26,
288,
327,
710,
2569,
5478,
787,
5847,
4829,
1380,
288,
327,
12999,
314,
8187,
1808,
1564,
63,
633,
805,
14,
288,
446,
3517,
267,
327,
961,
945,
911,
5666,
282,
14457,
370,
314,
1284,
402,
2082,
3792,
267,
5666,
63,
7001,
26,
2549,
272,
408,
339,
347,
636,
826,
721,
277,
12,
4770,
304,
267,
1613,
8,
6417,
6580,
281,
5061,
12,
291,
2843,
826,
721,
2124,
9,
339,
347,
5386,
63,
2124,
8,
277,
304,
267,
408,
267,
14402,
314,
1564,
63,
633,
1083,
315,
314,
4770,
909,
543,
282,
3537,
1083,
267,
626,
15158,
796,
8187,
4079,
641,
314,
1627,
2897,
14,
267,
408,
267,
1101,
275,
291,
14,
2124,
14,
888,
398,
340,
440,
2688,
8,
888,
12,
283,
633,
3118,
281,
735,
288,
372,
398,
340,
334,
11161,
8,
8972,
12,
2560,
63,
633,
63,
3118,
281,
63,
22631,
8989,
8109,
288,
372,
398,
2202,
275,
1101,
14,
633,
3118,
281,
398,
347,
3633,
63,
633,
8,
633,
7416,
304,
288,
768,
13582,
8,
633,
7416,
9,
288,
347,
4975,
8,
2124,
12,
931,
12,
5048,
29,
403,
304,
355,
1166,
275,
1166,
7416,
8,
2124,
12,
931,
12,
5048,
9,
355,
1478,
63,
493,
63,
1247,
275,
2519,
8,
1751,
12,
5644,
283,
1080,
63,
493,
63,
1247,
297,
5644,
788,
1080,
14,
1360,
1105,
355,
1833,
275,
3814,
8,
633,
9,
355,
340,
1833,
14,
354,
315,
1478,
63,
493,
63,
1247,
26,
490,
1166,
275,
1833,
14,
1708,
14,
515,
14,
6735,
7825,
490,
340,
2688,
8,
1751,
12,
283,
740,
63,
7001,
358,
436,
971,
1169,
2202,
14,
740,
63,
7001,
26,
717,
1166,
847,
7324,
355,
916,
2688,
8,
1751,
12,
283,
1913,
63,
5359,
735,
490,
340,
1833,
14,
5091,
315,
2202,
14,
1913,
63,
5359,
26,
717,
1166,
275,
1833,
14,
1708,
14,
1739,
8,
1155,
14,
354,
63,
7395,
63,
3435,
9,
355,
372,
1166,
503,
7324,
288,
372,
4975,
398,
11666,
855,
63,
633,
63,
3118,
281,
63,
22631,
8989,
275,
715,
267,
11666,
14,
1317,
63,
633,
275,
3633,
63,
633,
8,
8972,
14,
1317,
63,
633,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
6906,
3992,
436,
15841,
4048,
370,
7188,
271,
8187,
14,
199,
624,
199,
504,
7188,
271,
14,
2718,
492,
11349,
199,
504,
7188,
271,
14,
2124,
492,
11666,
199,
199,
504,
9143,
492,
14018,
199,
504,
289,
3519,
1330,
492,
3814,
421,
199,
533,
20503,
6580,
281,
5061,
8,
5061,
304,
339,
408,
272,
20503,
12762,
281,
3589,
367,
7188,
271,
14,
15747,
370,
7188,
271,
314,
21255,
370,
3550,
3633,
272,
8187,
14,
339,
11595,
2893,
272,
10652,
9858,
272,
327,
5963,
272,
1166,
3118,
281,
26,
267,
1478,
63,
493,
63,
1247,
26,
288,
327,
473,
2433,
397,
314,
1584,
626,
8469,
282,
2082,
13778,
14,
288,
327,
5723,
570,
1561,
787,
5847,
14489,
13437,
1380,
288,
327,
314,
1564,
63,
633,
805,
365,
2797,
14,
288,
446,
1478,
14,
1360,
267,
6202,
63,
5359,
26,
288,
327,
710,
2569,
5478,
787,
5847,
4829,
1380,
288,
327,
12999,
314,
8187,
1808,
1564,
63,
633,
805,
14,
288,
446,
3517,
267,
327,
961,
945,
911,
5666,
282,
14457,
370,
314,
1284,
402,
2082,
3792,
267,
5666,
63,
7001,
26,
2549,
272,
408,
339,
347,
636,
826,
721,
277,
12,
4770,
304,
267,
1613,
8,
6417,
6580,
281,
5061,
12,
291,
2843,
826,
721,
2124,
9,
339,
347,
5386,
63,
2124,
8,
277,
304,
267,
408,
267,
14402,
314,
1564,
63,
633,
1083,
315,
314,
4770,
909,
543,
282,
3537,
1083,
267,
626,
15158,
796,
8187,
4079,
641,
314,
1627,
2897,
14,
267,
408,
267,
1101,
275,
291,
14,
2124,
14,
888,
398,
340,
440,
2688,
8,
888,
12,
283,
633,
3118,
281,
735,
288,
372,
398,
340,
334,
11161,
8,
8972,
12,
2560,
63,
633,
63,
3118,
281,
63,
22631,
8989,
8109,
288,
372,
398,
2202,
275,
1101,
14,
633,
3118,
281,
398,
347,
3633,
63,
633,
8,
633,
7416,
304,
288,
768,
13582,
8,
633,
7416,
9,
288,
347,
4975,
8,
2124,
12,
931,
12,
5048,
29,
403,
304,
355,
1166,
275,
1166,
7416,
8,
2124,
12,
931,
12,
5048,
9,
355,
1478,
63,
493,
63,
1247,
275,
2519,
8,
1751,
12,
5644,
283,
1080,
63,
493,
63,
1247,
297,
5644,
788,
1080,
14,
1360,
1105,
355,
1833,
275,
3814,
8,
633,
9,
355,
340,
1833,
14,
354,
315,
1478,
63,
493,
63,
1247,
26,
490,
1166,
275,
1833,
14,
1708,
14,
515,
14,
6735,
7825,
490,
340,
2688,
8,
1751,
12,
283,
740,
63,
7001,
358,
436,
971,
1169,
2202,
14,
740,
63,
7001,
26,
717,
1166,
847,
7324,
355,
916,
2688,
8,
1751,
12,
283,
1913,
63,
5359,
735,
490,
340,
1833,
14,
5091,
315,
2202,
14,
1913,
63,
5359,
26,
717,
1166,
275,
1833,
14,
1708,
14,
1739,
8,
1155,
14,
354,
63,
7395,
63,
3435,
9,
355,
372,
1166,
503,
7324,
288,
372,
4975,
398,
11666,
855,
63,
633,
63,
3118,
281,
63,
22631,
8989,
275,
715,
267,
11666,
14,
1317,
63,
633,
275,
3633,
63,
633,
8,
8972,
14,
1317,
63,
633,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
bunnyitvn/webptn
|
django/utils/timezone.py
|
103
|
8344
|
"""Timezone helper functions.
This module uses pytz when it's available and fallbacks when it isn't.
"""
from datetime import datetime, timedelta, tzinfo
from threading import local
import time as _time
try:
import pytz
except ImportError:
pytz = None
from django.conf import settings
from django.utils import six
__all__ = [
'utc', 'get_default_timezone', 'get_current_timezone',
'activate', 'deactivate', 'override',
'is_naive', 'is_aware', 'make_aware', 'make_naive',
]
# UTC and local time zones
ZERO = timedelta(0)
class UTC(tzinfo):
"""
UTC implementation taken from Python's docs.
Used only when pytz isn't available.
"""
def __repr__(self):
return "<UTC>"
def utcoffset(self, dt):
return ZERO
def tzname(self, dt):
return "UTC"
def dst(self, dt):
return ZERO
class LocalTimezone(tzinfo):
"""
Local time implementation taken from Python's docs.
Used only when pytz isn't available, and most likely inaccurate. If you're
having trouble with this class, don't waste your time, just install pytz.
"""
def __init__(self):
# This code is moved in __init__ to execute it as late as possible
# See get_default_timezone().
self.STDOFFSET = timedelta(seconds=-_time.timezone)
if _time.daylight:
self.DSTOFFSET = timedelta(seconds=-_time.altzone)
else:
self.DSTOFFSET = self.STDOFFSET
self.DSTDIFF = self.DSTOFFSET - self.STDOFFSET
tzinfo.__init__(self)
def __repr__(self):
return "<LocalTimezone>"
def utcoffset(self, dt):
if self._isdst(dt):
return self.DSTOFFSET
else:
return self.STDOFFSET
def dst(self, dt):
if self._isdst(dt):
return self.DSTDIFF
else:
return ZERO
def tzname(self, dt):
return _time.tzname[self._isdst(dt)]
def _isdst(self, dt):
tt = (dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second,
dt.weekday(), 0, 0)
stamp = _time.mktime(tt)
tt = _time.localtime(stamp)
return tt.tm_isdst > 0
utc = pytz.utc if pytz else UTC()
"""UTC time zone as a tzinfo instance."""
# In order to avoid accessing the settings at compile time,
# wrap the expression in a function and cache the result.
_localtime = None
def get_default_timezone():
"""
Returns the default time zone as a tzinfo instance.
This is the time zone defined by settings.TIME_ZONE.
See also :func:`get_current_timezone`.
"""
global _localtime
if _localtime is None:
if isinstance(settings.TIME_ZONE, six.string_types) and pytz is not None:
_localtime = pytz.timezone(settings.TIME_ZONE)
else:
# This relies on os.environ['TZ'] being set to settings.TIME_ZONE.
_localtime = LocalTimezone()
return _localtime
# This function exists for consistency with get_current_timezone_name
def get_default_timezone_name():
"""
Returns the name of the default time zone.
"""
return _get_timezone_name(get_default_timezone())
_active = local()
def get_current_timezone():
"""
Returns the currently active time zone as a tzinfo instance.
"""
return getattr(_active, "value", get_default_timezone())
def get_current_timezone_name():
"""
Returns the name of the currently active time zone.
"""
return _get_timezone_name(get_current_timezone())
def _get_timezone_name(timezone):
"""
Returns the name of ``timezone``.
"""
try:
# for pytz timezones
return timezone.zone
except AttributeError:
# for regular tzinfo objects
local_now = datetime.now(timezone)
return timezone.tzname(local_now)
# Timezone selection functions.
# These functions don't change os.environ['TZ'] and call time.tzset()
# because it isn't thread safe.
def activate(timezone):
"""
Sets the time zone for the current thread.
The ``timezone`` argument must be an instance of a tzinfo subclass or a
time zone name. If it is a time zone name, pytz is required.
"""
if isinstance(timezone, tzinfo):
_active.value = timezone
elif isinstance(timezone, six.string_types) and pytz is not None:
_active.value = pytz.timezone(timezone)
else:
raise ValueError("Invalid timezone: %r" % timezone)
def deactivate():
"""
Unsets the time zone for the current thread.
Django will then use the time zone defined by settings.TIME_ZONE.
"""
if hasattr(_active, "value"):
del _active.value
class override(object):
"""
Temporarily set the time zone for the current thread.
This is a context manager that uses ``~django.utils.timezone.activate()``
to set the timezone on entry, and restores the previously active timezone
on exit.
The ``timezone`` argument must be an instance of a ``tzinfo`` subclass, a
time zone name, or ``None``. If is it a time zone name, pytz is required.
If it is ``None``, Django enables the default time zone.
"""
def __init__(self, timezone):
self.timezone = timezone
self.old_timezone = getattr(_active, 'value', None)
def __enter__(self):
if self.timezone is None:
deactivate()
else:
activate(self.timezone)
def __exit__(self, exc_type, exc_value, traceback):
if self.old_timezone is None:
deactivate()
else:
_active.value = self.old_timezone
# Templates
def template_localtime(value, use_tz=None):
"""
Checks if value is a datetime and converts it to local time if necessary.
If use_tz is provided and is not None, that will force the value to
be converted (or not), overriding the value of settings.USE_TZ.
This function is designed for use by the template engine.
"""
should_convert = (isinstance(value, datetime)
and (settings.USE_TZ if use_tz is None else use_tz)
and not is_naive(value)
and getattr(value, 'convert_to_local_time', True))
return localtime(value) if should_convert else value
# Utilities
def localtime(value, timezone=None):
"""
Converts an aware datetime.datetime to local time.
Local time is defined by the current time zone, unless another time zone
is specified.
"""
if timezone is None:
timezone = get_current_timezone()
value = value.astimezone(timezone)
if hasattr(timezone, 'normalize'):
# available for pytz time zones
value = timezone.normalize(value)
return value
def now():
"""
Returns an aware or naive datetime.datetime, depending on settings.USE_TZ.
"""
if settings.USE_TZ:
# timeit shows that datetime.now(tz=utc) is 24% slower
return datetime.utcnow().replace(tzinfo=utc)
else:
return datetime.now()
# By design, these four functions don't perform any checks on their arguments.
# The caller should ensure that they don't receive an invalid value like None.
def is_aware(value):
"""
Determines if a given datetime.datetime is aware.
The logic is described in Python's docs:
http://docs.python.org/library/datetime.html#datetime.tzinfo
"""
return value.tzinfo is not None and value.tzinfo.utcoffset(value) is not None
def is_naive(value):
"""
Determines if a given datetime.datetime is naive.
The logic is described in Python's docs:
http://docs.python.org/library/datetime.html#datetime.tzinfo
"""
return value.tzinfo is None or value.tzinfo.utcoffset(value) is None
def make_aware(value, timezone):
"""
Makes a naive datetime.datetime in a given time zone aware.
"""
if hasattr(timezone, 'localize'):
# available for pytz time zones
return timezone.localize(value, is_dst=None)
else:
# may be wrong around DST changes
return value.replace(tzinfo=timezone)
def make_naive(value, timezone):
"""
Makes an aware datetime.datetime naive in a given time zone.
"""
value = value.astimezone(timezone)
if hasattr(timezone, 'normalize'):
# available for pytz time zones
value = timezone.normalize(value)
return value.replace(tzinfo=None)
|
bsd-3-clause
|
[
624,
28705,
5922,
3423,
14,
199,
199,
2765,
859,
4440,
15444,
1380,
652,
1159,
2808,
436,
9567,
83,
1380,
652,
5712,
1133,
14,
199,
624,
199,
199,
504,
2197,
492,
2197,
12,
6871,
12,
10313,
199,
504,
5796,
492,
2257,
199,
646,
900,
465,
485,
521,
199,
199,
893,
26,
272,
492,
15444,
199,
2590,
3545,
26,
272,
15444,
275,
488,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1208,
492,
3816,
199,
199,
363,
452,
363,
275,
359,
272,
283,
5834,
297,
283,
362,
63,
885,
63,
7145,
297,
283,
362,
63,
1818,
63,
7145,
297,
272,
283,
8222,
297,
283,
24891,
297,
283,
4415,
297,
272,
283,
374,
63,
21578,
297,
283,
374,
63,
14600,
297,
283,
1875,
63,
14600,
297,
283,
1875,
63,
21578,
297,
199,
61,
421,
199,
3,
12174,
436,
2257,
900,
18666,
199,
199,
24655,
275,
6871,
8,
16,
9,
199,
199,
533,
12174,
8,
9374,
304,
272,
408,
272,
12174,
4514,
9394,
687,
2018,
1159,
9149,
14,
339,
8051,
1454,
1380,
15444,
5712,
1133,
2808,
14,
272,
408,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
3886,
11288,
4335,
339,
347,
11430,
18102,
8,
277,
12,
4487,
304,
267,
372,
20348,
339,
347,
28054,
8,
277,
12,
4487,
304,
267,
372,
298,
11288,
2,
339,
347,
5042,
8,
277,
12,
4487,
304,
267,
372,
20348,
199,
199,
533,
10111,
28705,
8,
9374,
304,
272,
408,
272,
10111,
900,
4514,
9394,
687,
2018,
1159,
9149,
14,
339,
8051,
1454,
1380,
15444,
5712,
1133,
2808,
12,
436,
4750,
12060,
315,
645,
19471,
14,
982,
1265,
3984,
272,
9445,
29616,
543,
642,
1021,
12,
2793,
1133,
1990,
266,
2195,
900,
12,
2951,
3907,
15444,
14,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
327,
961,
1233,
365,
12155,
315,
636,
826,
363,
370,
5341,
652,
465,
2465,
465,
3962,
267,
327,
1666,
664,
63,
885,
63,
7145,
1252,
267,
291,
14,
840,
1649,
1665,
3597,
275,
6871,
8,
4515,
4022,
63,
521,
14,
7145,
9,
267,
340,
485,
521,
14,
2977,
4040,
26,
288,
291,
14,
18651,
14839,
275,
6871,
8,
4515,
4022,
63,
521,
14,
4478,
2619,
9,
267,
587,
26,
288,
291,
14,
18651,
14839,
275,
291,
14,
840,
1649,
1665,
3597,
267,
291,
14,
18651,
10596,
275,
291,
14,
18651,
14839,
446,
291,
14,
840,
1649,
1665,
3597,
267,
10313,
855,
826,
721,
277,
9,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
3886,
5339,
28705,
4335,
339,
347,
11430,
18102,
8,
277,
12,
4487,
304,
267,
340,
291,
423,
374,
5119,
8,
3583,
304,
288,
372,
291,
14,
18651,
14839,
267,
587,
26,
288,
372,
291,
14,
840,
1649,
1665,
3597,
339,
347,
5042,
8,
277,
12,
4487,
304,
267,
340,
291,
423,
374,
5119,
8,
3583,
304,
288,
372,
291,
14,
18651,
10596,
267,
587,
26,
288,
372,
20348,
339,
347,
28054,
8,
277,
12,
4487,
304,
267,
372,
485,
521,
14,
20027,
59,
277,
423,
374,
5119,
8,
3583,
1874,
339,
347,
485,
374,
5119,
8,
277,
12,
4487,
304,
267,
13638,
275,
334,
3583,
14,
3403,
12,
4487,
14,
4482,
12,
4487,
14,
2977,
12,
1598,
4487,
14,
5180,
12,
4487,
14,
10698,
12,
4487,
14,
4375,
12,
1598,
4487,
14,
12451,
1062,
378,
12,
378,
9,
267,
16206,
275,
485,
521,
14,
23456,
8,
6215,
9,
267,
13638,
275,
485,
521,
14,
15198,
8,
2359,
9,
267,
372,
13638,
14,
7574,
63,
374,
5119,
690,
378,
421,
199,
5834,
275,
15444,
14,
5834,
340,
15444,
587,
12174,
342,
199,
624,
11288,
900,
5718,
465,
282,
10313,
1256,
1041,
199,
199,
3,
1010,
1865,
370,
5126,
18549,
314,
2202,
737,
6555,
900,
12,
199,
3,
4816,
314,
3965,
315,
282,
805,
436,
2581,
314,
754,
14,
199,
63,
15198,
275,
488,
199,
199,
318,
664,
63,
885,
63,
7145,
837,
272,
408,
272,
1803,
314,
849,
900,
5718,
465,
282,
10313,
1256,
14,
339,
961,
365,
314,
900,
5718,
3247,
701,
2202,
14,
4961,
63,
15353,
14,
339,
1666,
2597,
520,
1532,
1705,
362,
63,
1818,
63,
7145,
2313,
272,
408,
272,
2288,
485,
15198,
272,
340,
485,
15198,
365,
488,
26,
267,
340,
1228,
8,
1751,
14,
4961,
63,
15353,
12,
3816,
14,
875,
63,
1313,
9,
436,
15444,
365,
440,
488,
26,
288,
485,
15198,
275,
15444,
14,
7145,
8,
1751,
14,
4961,
63,
15353,
9,
267,
587,
26,
288,
327,
961,
25749,
641,
747,
14,
2314,
459,
14226,
418,
3769,
663,
370,
2202,
14,
4961,
63,
15353,
14,
288,
485,
15198,
275,
10111,
28705,
342,
272,
372,
485,
15198,
199,
199,
3,
961,
805,
3495,
367,
17754,
543,
664,
63,
1818,
63,
7145,
63,
354,
199,
318,
664,
63,
885,
63,
7145,
63,
354,
837,
272,
408,
272,
1803,
314,
536,
402,
314,
849,
900,
5718,
14,
272,
408,
272,
372,
485,
362,
63,
7145,
63,
354,
8,
362,
63,
885,
63,
7145,
1012,
199,
199,
63,
2682,
275,
2257,
342,
199,
199,
318,
664,
63,
1818,
63,
7145,
837,
272,
408,
272,
1803,
314,
5544,
4702,
900,
5718,
465,
282,
10313,
1256,
14,
272,
408,
272,
372,
2519,
1547,
2682,
12,
298,
585,
401,
664,
63,
885,
63,
7145,
1012,
199,
199,
318,
664,
63,
1818,
63,
7145,
63,
354,
837,
272,
408,
272,
1803,
314,
536,
402,
314,
5544,
4702,
900,
5718,
14,
272,
408,
272,
372,
485,
362,
63,
7145,
63,
354,
8,
362,
63,
1818,
63,
7145,
1012,
199,
199,
318,
485,
362,
63,
7145,
63,
354,
8,
7145,
304,
272,
408,
272,
1803,
314,
536,
402,
1124,
7145,
4345,
272,
408,
272,
862,
26,
267,
327,
367,
15444,
7137,
83,
267,
372,
7137,
14,
2619,
272,
871,
4281,
26,
267,
327,
367,
5578,
10313,
2251,
267,
2257,
63,
2131,
275,
2197,
14,
2131,
8,
7145,
9,
267,
372,
7137,
14,
20027,
8,
1832,
63,
2131,
9,
199,
199,
3,
4703,
2619,
7267,
3423,
14,
199,
199,
3,
5723,
3423,
2793,
1133,
1570,
747,
14,
2314,
459,
14226,
418,
436,
1240,
900,
14,
3903,
409,
342,
199,
3,
2952,
652,
5712,
1133,
2462,
5048,
14,
199,
199,
318,
15422,
8,
7145,
304,
272,
408,
272,
10729,
314,
900
] |
[
28705,
5922,
3423,
14,
199,
199,
2765,
859,
4440,
15444,
1380,
652,
1159,
2808,
436,
9567,
83,
1380,
652,
5712,
1133,
14,
199,
624,
199,
199,
504,
2197,
492,
2197,
12,
6871,
12,
10313,
199,
504,
5796,
492,
2257,
199,
646,
900,
465,
485,
521,
199,
199,
893,
26,
272,
492,
15444,
199,
2590,
3545,
26,
272,
15444,
275,
488,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1208,
492,
3816,
199,
199,
363,
452,
363,
275,
359,
272,
283,
5834,
297,
283,
362,
63,
885,
63,
7145,
297,
283,
362,
63,
1818,
63,
7145,
297,
272,
283,
8222,
297,
283,
24891,
297,
283,
4415,
297,
272,
283,
374,
63,
21578,
297,
283,
374,
63,
14600,
297,
283,
1875,
63,
14600,
297,
283,
1875,
63,
21578,
297,
199,
61,
421,
199,
3,
12174,
436,
2257,
900,
18666,
199,
199,
24655,
275,
6871,
8,
16,
9,
199,
199,
533,
12174,
8,
9374,
304,
272,
408,
272,
12174,
4514,
9394,
687,
2018,
1159,
9149,
14,
339,
8051,
1454,
1380,
15444,
5712,
1133,
2808,
14,
272,
408,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
3886,
11288,
4335,
339,
347,
11430,
18102,
8,
277,
12,
4487,
304,
267,
372,
20348,
339,
347,
28054,
8,
277,
12,
4487,
304,
267,
372,
298,
11288,
2,
339,
347,
5042,
8,
277,
12,
4487,
304,
267,
372,
20348,
199,
199,
533,
10111,
28705,
8,
9374,
304,
272,
408,
272,
10111,
900,
4514,
9394,
687,
2018,
1159,
9149,
14,
339,
8051,
1454,
1380,
15444,
5712,
1133,
2808,
12,
436,
4750,
12060,
315,
645,
19471,
14,
982,
1265,
3984,
272,
9445,
29616,
543,
642,
1021,
12,
2793,
1133,
1990,
266,
2195,
900,
12,
2951,
3907,
15444,
14,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
327,
961,
1233,
365,
12155,
315,
636,
826,
363,
370,
5341,
652,
465,
2465,
465,
3962,
267,
327,
1666,
664,
63,
885,
63,
7145,
1252,
267,
291,
14,
840,
1649,
1665,
3597,
275,
6871,
8,
4515,
4022,
63,
521,
14,
7145,
9,
267,
340,
485,
521,
14,
2977,
4040,
26,
288,
291,
14,
18651,
14839,
275,
6871,
8,
4515,
4022,
63,
521,
14,
4478,
2619,
9,
267,
587,
26,
288,
291,
14,
18651,
14839,
275,
291,
14,
840,
1649,
1665,
3597,
267,
291,
14,
18651,
10596,
275,
291,
14,
18651,
14839,
446,
291,
14,
840,
1649,
1665,
3597,
267,
10313,
855,
826,
721,
277,
9,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
3886,
5339,
28705,
4335,
339,
347,
11430,
18102,
8,
277,
12,
4487,
304,
267,
340,
291,
423,
374,
5119,
8,
3583,
304,
288,
372,
291,
14,
18651,
14839,
267,
587,
26,
288,
372,
291,
14,
840,
1649,
1665,
3597,
339,
347,
5042,
8,
277,
12,
4487,
304,
267,
340,
291,
423,
374,
5119,
8,
3583,
304,
288,
372,
291,
14,
18651,
10596,
267,
587,
26,
288,
372,
20348,
339,
347,
28054,
8,
277,
12,
4487,
304,
267,
372,
485,
521,
14,
20027,
59,
277,
423,
374,
5119,
8,
3583,
1874,
339,
347,
485,
374,
5119,
8,
277,
12,
4487,
304,
267,
13638,
275,
334,
3583,
14,
3403,
12,
4487,
14,
4482,
12,
4487,
14,
2977,
12,
1598,
4487,
14,
5180,
12,
4487,
14,
10698,
12,
4487,
14,
4375,
12,
1598,
4487,
14,
12451,
1062,
378,
12,
378,
9,
267,
16206,
275,
485,
521,
14,
23456,
8,
6215,
9,
267,
13638,
275,
485,
521,
14,
15198,
8,
2359,
9,
267,
372,
13638,
14,
7574,
63,
374,
5119,
690,
378,
421,
199,
5834,
275,
15444,
14,
5834,
340,
15444,
587,
12174,
342,
199,
624,
11288,
900,
5718,
465,
282,
10313,
1256,
1041,
199,
199,
3,
1010,
1865,
370,
5126,
18549,
314,
2202,
737,
6555,
900,
12,
199,
3,
4816,
314,
3965,
315,
282,
805,
436,
2581,
314,
754,
14,
199,
63,
15198,
275,
488,
199,
199,
318,
664,
63,
885,
63,
7145,
837,
272,
408,
272,
1803,
314,
849,
900,
5718,
465,
282,
10313,
1256,
14,
339,
961,
365,
314,
900,
5718,
3247,
701,
2202,
14,
4961,
63,
15353,
14,
339,
1666,
2597,
520,
1532,
1705,
362,
63,
1818,
63,
7145,
2313,
272,
408,
272,
2288,
485,
15198,
272,
340,
485,
15198,
365,
488,
26,
267,
340,
1228,
8,
1751,
14,
4961,
63,
15353,
12,
3816,
14,
875,
63,
1313,
9,
436,
15444,
365,
440,
488,
26,
288,
485,
15198,
275,
15444,
14,
7145,
8,
1751,
14,
4961,
63,
15353,
9,
267,
587,
26,
288,
327,
961,
25749,
641,
747,
14,
2314,
459,
14226,
418,
3769,
663,
370,
2202,
14,
4961,
63,
15353,
14,
288,
485,
15198,
275,
10111,
28705,
342,
272,
372,
485,
15198,
199,
199,
3,
961,
805,
3495,
367,
17754,
543,
664,
63,
1818,
63,
7145,
63,
354,
199,
318,
664,
63,
885,
63,
7145,
63,
354,
837,
272,
408,
272,
1803,
314,
536,
402,
314,
849,
900,
5718,
14,
272,
408,
272,
372,
485,
362,
63,
7145,
63,
354,
8,
362,
63,
885,
63,
7145,
1012,
199,
199,
63,
2682,
275,
2257,
342,
199,
199,
318,
664,
63,
1818,
63,
7145,
837,
272,
408,
272,
1803,
314,
5544,
4702,
900,
5718,
465,
282,
10313,
1256,
14,
272,
408,
272,
372,
2519,
1547,
2682,
12,
298,
585,
401,
664,
63,
885,
63,
7145,
1012,
199,
199,
318,
664,
63,
1818,
63,
7145,
63,
354,
837,
272,
408,
272,
1803,
314,
536,
402,
314,
5544,
4702,
900,
5718,
14,
272,
408,
272,
372,
485,
362,
63,
7145,
63,
354,
8,
362,
63,
1818,
63,
7145,
1012,
199,
199,
318,
485,
362,
63,
7145,
63,
354,
8,
7145,
304,
272,
408,
272,
1803,
314,
536,
402,
1124,
7145,
4345,
272,
408,
272,
862,
26,
267,
327,
367,
15444,
7137,
83,
267,
372,
7137,
14,
2619,
272,
871,
4281,
26,
267,
327,
367,
5578,
10313,
2251,
267,
2257,
63,
2131,
275,
2197,
14,
2131,
8,
7145,
9,
267,
372,
7137,
14,
20027,
8,
1832,
63,
2131,
9,
199,
199,
3,
4703,
2619,
7267,
3423,
14,
199,
199,
3,
5723,
3423,
2793,
1133,
1570,
747,
14,
2314,
459,
14226,
418,
436,
1240,
900,
14,
3903,
409,
342,
199,
3,
2952,
652,
5712,
1133,
2462,
5048,
14,
199,
199,
318,
15422,
8,
7145,
304,
272,
408,
272,
10729,
314,
900,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Changaco/oh-mainline
|
vendor/packages/gdata/src/gdata/Crypto/Hash/HMAC.py
|
226
|
3330
|
"""HMAC (Keyed-Hashing for Message Authentication) Python module.
Implements the HMAC algorithm as described by RFC 2104.
This is just a copy of the Python 2.2 HMAC module, modified to work when
used on versions of Python before 2.2.
"""
__revision__ = "$Id: HMAC.py,v 1.5 2002/07/25 17:19:02 z3p Exp $"
import string
def _strxor(s1, s2):
"""Utility method. XOR the two strings s1 and s2 (must have same length).
"""
return "".join(map(lambda x, y: chr(ord(x) ^ ord(y)), s1, s2))
# The size of the digests returned by HMAC depends on the underlying
# hashing module used.
digest_size = None
class HMAC:
"""RFC2104 HMAC class.
This supports the API for Cryptographic Hash Functions (PEP 247).
"""
def __init__(self, key, msg = None, digestmod = None):
"""Create a new HMAC object.
key: key for the keyed hash object.
msg: Initial input for the hash, if provided.
digestmod: A module supporting PEP 247. Defaults to the md5 module.
"""
if digestmod == None:
import md5
digestmod = md5
self.digestmod = digestmod
self.outer = digestmod.new()
self.inner = digestmod.new()
try:
self.digest_size = digestmod.digest_size
except AttributeError:
self.digest_size = len(self.outer.digest())
blocksize = 64
ipad = "\x36" * blocksize
opad = "\x5C" * blocksize
if len(key) > blocksize:
key = digestmod.new(key).digest()
key = key + chr(0) * (blocksize - len(key))
self.outer.update(_strxor(key, opad))
self.inner.update(_strxor(key, ipad))
if (msg):
self.update(msg)
## def clear(self):
## raise NotImplementedError, "clear() method not available in HMAC."
def update(self, msg):
"""Update this hashing object with the string msg.
"""
self.inner.update(msg)
def copy(self):
"""Return a separate copy of this hashing object.
An update to this copy won't affect the original object.
"""
other = HMAC("")
other.digestmod = self.digestmod
other.inner = self.inner.copy()
other.outer = self.outer.copy()
return other
def digest(self):
"""Return the hash value of this hashing object.
This returns a string containing 8-bit data. The object is
not altered in any way by this function; you can continue
updating the object after calling this function.
"""
h = self.outer.copy()
h.update(self.inner.digest())
return h.digest()
def hexdigest(self):
"""Like digest(), but returns a string of hexadecimal digits instead.
"""
return "".join([string.zfill(hex(ord(x))[2:], 2)
for x in tuple(self.digest())])
def new(key, msg = None, digestmod = None):
"""Create a new hashing object and return it.
key: The starting key for the hash.
msg: if available, will immediately be hashed into the object's starting
state.
You can now feed arbitrary strings into the object using its update()
method, and can ask for the hash value at any time by calling its digest()
method.
"""
return HMAC(key, msg, digestmod)
|
agpl-3.0
|
[
624,
23034,
334,
1197,
379,
13,
3476,
316,
367,
6430,
15995,
9,
2018,
859,
14,
199,
199,
29452,
314,
29817,
5563,
465,
11736,
701,
7329,
499,
6785,
14,
199,
199,
2765,
365,
2951,
282,
1331,
402,
314,
2018,
499,
14,
18,
29817,
859,
12,
6042,
370,
1736,
1380,
199,
2972,
641,
5459,
402,
2018,
2544,
499,
14,
18,
14,
199,
624,
199,
199,
363,
5792,
363,
275,
7880,
1304,
26,
29817,
14,
647,
12,
86,
413,
14,
21,
14790,
15,
1780,
15,
821,
5557,
26,
1167,
26,
996,
1315,
19,
80,
7910,
2672,
2,
199,
199,
646,
1059,
199,
199,
318,
485,
495,
15721,
8,
83,
17,
12,
308,
18,
304,
272,
408,
17505,
1083,
14,
1323,
726,
314,
2877,
3326,
308,
17,
436,
308,
18,
334,
7790,
1172,
2011,
2582,
680,
272,
408,
272,
372,
10587,
904,
8,
1130,
8,
2734,
671,
12,
612,
26,
8678,
8,
2181,
8,
88,
9,
7167,
6206,
8,
89,
1826,
308,
17,
12,
308,
18,
430,
199,
199,
3,
710,
1568,
402,
314,
10017,
83,
2138,
701,
29817,
8350,
641,
314,
8793,
199,
3,
25223,
859,
1202,
14,
199,
5671,
63,
890,
275,
488,
199,
199,
533,
29817,
26,
272,
408,
14468,
18,
6785,
29817,
1021,
14,
339,
961,
5171,
314,
3261,
367,
18855,
9770,
16101,
17471,
334,
25633,
499,
2417,
680,
272,
408,
339,
347,
636,
826,
721,
277,
12,
790,
12,
1499,
275,
488,
12,
10017,
1494,
275,
488,
304,
267,
408,
2499,
282,
892,
29817,
909,
14,
398,
790,
26,
755,
790,
367,
314,
19272,
2631,
909,
14,
267,
1499,
26,
755,
6026,
1324,
367,
314,
2631,
12,
340,
2741,
14,
267,
10017,
1494,
26,
437,
859,
21038,
13663,
499,
2417,
14,
7827,
370,
314,
6128,
21,
859,
14,
267,
408,
267,
340,
10017,
1494,
508,
488,
26,
288,
492,
6128,
21,
288,
10017,
1494,
275,
6128,
21,
398,
291,
14,
5671,
1494,
275,
10017,
1494,
267,
291,
14,
7837,
275,
10017,
1494,
14,
1222,
342,
267,
291,
14,
5216,
275,
10017,
1494,
14,
1222,
342,
267,
862,
26,
288,
291,
14,
5671,
63,
890,
275,
10017,
1494,
14,
5671,
63,
890,
267,
871,
4281,
26,
288,
291,
14,
5671,
63,
890,
275,
822,
8,
277,
14,
7837,
14,
5671,
1012,
398,
27461,
275,
5049,
267,
3384,
350,
275,
1867,
88,
1344,
2,
627,
27461,
267,
1687,
350,
275,
1867,
88,
21,
35,
2,
627,
27461,
398,
340,
822,
8,
498,
9,
690,
27461,
26,
288,
790,
275,
10017,
1494,
14,
1222,
8,
498,
680,
5671,
342,
398,
790,
275,
790,
435,
8678,
8,
16,
9,
627,
334,
25959,
446,
822,
8,
498,
430,
267,
291,
14,
7837,
14,
873,
1547,
495,
15721,
8,
498,
12,
1687,
350,
430,
267,
291,
14,
5216,
14,
873,
1547,
495,
15721,
8,
498,
12,
3384,
350,
430,
267,
340,
334,
1328,
304,
288,
291,
14,
873,
8,
1328,
9,
199,
199,
309,
259,
347,
5436,
8,
277,
304,
199,
309,
263,
746,
4279,
12,
298,
3584,
342,
1083,
440,
2808,
315,
29817,
2122,
339,
347,
1678,
8,
277,
12,
1499,
304,
267,
408,
4152,
642,
25223,
909,
543,
314,
1059,
1499,
14,
267,
408,
267,
291,
14,
5216,
14,
873,
8,
1328,
9,
339,
347,
1331,
8,
277,
304,
267,
408,
1767,
282,
7396,
1331,
402,
642,
25223,
909,
14,
398,
1626,
1678,
370,
642,
1331,
7859,
1133,
12787,
314,
3379,
909,
14,
267,
408,
267,
1163,
275,
29817,
10804,
267,
1163,
14,
5671,
1494,
275,
291,
14,
5671,
1494,
267,
1163,
14,
5216,
275,
291,
14,
5216,
14,
1574,
342,
267,
1163,
14,
7837,
275,
291,
14,
7837,
14,
1574,
342,
267,
372,
1163,
339,
347,
10017,
8,
277,
304,
267,
408,
1767,
314,
2631,
574,
402,
642,
25223,
909,
14,
398,
961,
2529,
282,
1059,
3035,
1695,
13,
2075,
666,
14,
221,
710,
909,
365,
267,
440,
29815,
315,
1263,
4340,
701,
642,
805,
27,
1265,
883,
1980,
267,
12928,
314,
909,
2410,
6358,
642,
805,
14,
267,
408,
267,
394,
275,
291,
14,
7837,
14,
1574,
342,
267,
394,
14,
873,
8,
277,
14,
5216,
14,
5671,
1012,
267,
372,
394,
14,
5671,
342,
339,
347,
6318,
5671,
8,
277,
304,
267,
408,
12545,
10017,
1062,
1325,
2529,
282,
1059,
402,
20379,
7576,
3140,
14,
267,
408,
267,
372,
10587,
904,
779,
875,
14,
26626,
8,
4097,
8,
2181,
8,
88,
11515,
18,
8429,
499,
9,
717,
367,
671,
315,
2008,
8,
277,
14,
5671,
30719,
199,
199,
318,
892,
8,
498,
12,
1499,
275,
488,
12,
10017,
1494,
275,
488,
304,
272,
408,
2499,
282,
892,
25223,
909,
436,
372,
652,
14,
339,
790,
26,
710,
6617,
790,
367,
314,
2631,
14,
272,
1499,
26,
340,
2808,
12,
911,
9939,
506,
19871,
1901,
314,
909,
1159,
6617,
272,
1174,
14,
339,
2047,
883,
3063,
4733,
9697,
3326,
1901,
314,
909,
1808,
2399,
1678,
342,
272,
1083,
12,
436,
883,
7198,
367,
314,
2631,
574,
737,
1263,
900,
701,
6358,
2399,
10017,
342,
272,
1083,
14,
272,
408,
272,
372,
29817,
8,
498,
12,
1499,
12,
10017,
1494,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
23034,
334,
1197,
379,
13,
3476,
316,
367,
6430,
15995,
9,
2018,
859,
14,
199,
199,
29452,
314,
29817,
5563,
465,
11736,
701,
7329,
499,
6785,
14,
199,
199,
2765,
365,
2951,
282,
1331,
402,
314,
2018,
499,
14,
18,
29817,
859,
12,
6042,
370,
1736,
1380,
199,
2972,
641,
5459,
402,
2018,
2544,
499,
14,
18,
14,
199,
624,
199,
199,
363,
5792,
363,
275,
7880,
1304,
26,
29817,
14,
647,
12,
86,
413,
14,
21,
14790,
15,
1780,
15,
821,
5557,
26,
1167,
26,
996,
1315,
19,
80,
7910,
2672,
2,
199,
199,
646,
1059,
199,
199,
318,
485,
495,
15721,
8,
83,
17,
12,
308,
18,
304,
272,
408,
17505,
1083,
14,
1323,
726,
314,
2877,
3326,
308,
17,
436,
308,
18,
334,
7790,
1172,
2011,
2582,
680,
272,
408,
272,
372,
10587,
904,
8,
1130,
8,
2734,
671,
12,
612,
26,
8678,
8,
2181,
8,
88,
9,
7167,
6206,
8,
89,
1826,
308,
17,
12,
308,
18,
430,
199,
199,
3,
710,
1568,
402,
314,
10017,
83,
2138,
701,
29817,
8350,
641,
314,
8793,
199,
3,
25223,
859,
1202,
14,
199,
5671,
63,
890,
275,
488,
199,
199,
533,
29817,
26,
272,
408,
14468,
18,
6785,
29817,
1021,
14,
339,
961,
5171,
314,
3261,
367,
18855,
9770,
16101,
17471,
334,
25633,
499,
2417,
680,
272,
408,
339,
347,
636,
826,
721,
277,
12,
790,
12,
1499,
275,
488,
12,
10017,
1494,
275,
488,
304,
267,
408,
2499,
282,
892,
29817,
909,
14,
398,
790,
26,
755,
790,
367,
314,
19272,
2631,
909,
14,
267,
1499,
26,
755,
6026,
1324,
367,
314,
2631,
12,
340,
2741,
14,
267,
10017,
1494,
26,
437,
859,
21038,
13663,
499,
2417,
14,
7827,
370,
314,
6128,
21,
859,
14,
267,
408,
267,
340,
10017,
1494,
508,
488,
26,
288,
492,
6128,
21,
288,
10017,
1494,
275,
6128,
21,
398,
291,
14,
5671,
1494,
275,
10017,
1494,
267,
291,
14,
7837,
275,
10017,
1494,
14,
1222,
342,
267,
291,
14,
5216,
275,
10017,
1494,
14,
1222,
342,
267,
862,
26,
288,
291,
14,
5671,
63,
890,
275,
10017,
1494,
14,
5671,
63,
890,
267,
871,
4281,
26,
288,
291,
14,
5671,
63,
890,
275,
822,
8,
277,
14,
7837,
14,
5671,
1012,
398,
27461,
275,
5049,
267,
3384,
350,
275,
1867,
88,
1344,
2,
627,
27461,
267,
1687,
350,
275,
1867,
88,
21,
35,
2,
627,
27461,
398,
340,
822,
8,
498,
9,
690,
27461,
26,
288,
790,
275,
10017,
1494,
14,
1222,
8,
498,
680,
5671,
342,
398,
790,
275,
790,
435,
8678,
8,
16,
9,
627,
334,
25959,
446,
822,
8,
498,
430,
267,
291,
14,
7837,
14,
873,
1547,
495,
15721,
8,
498,
12,
1687,
350,
430,
267,
291,
14,
5216,
14,
873,
1547,
495,
15721,
8,
498,
12,
3384,
350,
430,
267,
340,
334,
1328,
304,
288,
291,
14,
873,
8,
1328,
9,
199,
199,
309,
259,
347,
5436,
8,
277,
304,
199,
309,
263,
746,
4279,
12,
298,
3584,
342,
1083,
440,
2808,
315,
29817,
2122,
339,
347,
1678,
8,
277,
12,
1499,
304,
267,
408,
4152,
642,
25223,
909,
543,
314,
1059,
1499,
14,
267,
408,
267,
291,
14,
5216,
14,
873,
8,
1328,
9,
339,
347,
1331,
8,
277,
304,
267,
408,
1767,
282,
7396,
1331,
402,
642,
25223,
909,
14,
398,
1626,
1678,
370,
642,
1331,
7859,
1133,
12787,
314,
3379,
909,
14,
267,
408,
267,
1163,
275,
29817,
10804,
267,
1163,
14,
5671,
1494,
275,
291,
14,
5671,
1494,
267,
1163,
14,
5216,
275,
291,
14,
5216,
14,
1574,
342,
267,
1163,
14,
7837,
275,
291,
14,
7837,
14,
1574,
342,
267,
372,
1163,
339,
347,
10017,
8,
277,
304,
267,
408,
1767,
314,
2631,
574,
402,
642,
25223,
909,
14,
398,
961,
2529,
282,
1059,
3035,
1695,
13,
2075,
666,
14,
221,
710,
909,
365,
267,
440,
29815,
315,
1263,
4340,
701,
642,
805,
27,
1265,
883,
1980,
267,
12928,
314,
909,
2410,
6358,
642,
805,
14,
267,
408,
267,
394,
275,
291,
14,
7837,
14,
1574,
342,
267,
394,
14,
873,
8,
277,
14,
5216,
14,
5671,
1012,
267,
372,
394,
14,
5671,
342,
339,
347,
6318,
5671,
8,
277,
304,
267,
408,
12545,
10017,
1062,
1325,
2529,
282,
1059,
402,
20379,
7576,
3140,
14,
267,
408,
267,
372,
10587,
904,
779,
875,
14,
26626,
8,
4097,
8,
2181,
8,
88,
11515,
18,
8429,
499,
9,
717,
367,
671,
315,
2008,
8,
277,
14,
5671,
30719,
199,
199,
318,
892,
8,
498,
12,
1499,
275,
488,
12,
10017,
1494,
275,
488,
304,
272,
408,
2499,
282,
892,
25223,
909,
436,
372,
652,
14,
339,
790,
26,
710,
6617,
790,
367,
314,
2631,
14,
272,
1499,
26,
340,
2808,
12,
911,
9939,
506,
19871,
1901,
314,
909,
1159,
6617,
272,
1174,
14,
339,
2047,
883,
3063,
4733,
9697,
3326,
1901,
314,
909,
1808,
2399,
1678,
342,
272,
1083,
12,
436,
883,
7198,
367,
314,
2631,
574,
737,
1263,
900,
701,
6358,
2399,
10017,
342,
272,
1083,
14,
272,
408,
272,
372,
29817,
8,
498,
12,
1499,
12,
10017,
1494,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
mikejs/python-votesmart
|
votesmart.py
|
1
|
25110
|
""" Python library for interacting with Project Vote Smart API.
Project Vote Smart's API (http://www.votesmart.org/services_api.php)
provides rich biographical data, including data on votes, committee
assignments, and much more.
"""
__author__ = "James Turk (jturk@sunlightfoundation.com)"
__version__ = "0.2.1"
__copyright__ = "Copyright (c) 2009 Sunlight Labs"
__license__ = "BSD"
import urllib, urllib2
try:
import json
except ImportError:
import simplejson as json
class VotesmartApiError(Exception):
""" Exception for Sunlight API errors """
class VotesmartApiObject(object):
def __init__(self, d):
self.__dict__ = d
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.__dict__)
class Address(object):
def __init__(self, d):
self.__dict__.update(d['address'])
self.__dict__.update(d['phone'])
self.__dict__.update(d['notes'])
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.__dict__)
class WebAddress(VotesmartApiObject):
def __str__(self):
return self.webAddress
class Bio(object):
def __init__(self, d):
#self.__dict__.update(d['election'])
#self.__dict__.update(d['office'])
self.__dict__.update(d['candidate'])
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.__dict__)
class AddlBio(VotesmartApiObject):
def __str__(self):
return ': '.join((self.name, self.data))
class Candidate(VotesmartApiObject):
def __str__(self):
return ' '.join((self.firstName, self.lastName))
class CommitteeType(VotesmartApiObject):
def __str__(self):
return self.name
class Committee(VotesmartApiObject):
def __str__(self):
return self.name
class CommitteeDetail(VotesmartApiObject):
def __str__(self):
return self.name
class CommitteeMember(VotesmartApiObject):
def __str__(self):
return ' '.join((self.title, self.firstName, self.lastName))
class District(VotesmartApiObject):
def __str__(self):
return self.name
class Election(VotesmartApiObject):
def __init__(self, d):
stages = [ElectionStage(s) for s in d.pop('stage')]
self.__dict__ = d
self.stages = stages
def __str__(self):
return self.name
class ElectionStage(VotesmartApiObject):
def __str__(self):
return '%s (%s)' % (self.name, self.electionDate)
class Official(VotesmartApiObject):
def __str__(self):
return ' '.join((self.title, self.firstName, self.lastName))
class LeadershipPosition(VotesmartApiObject):
def __str__(self):
return self.name
class Locality(VotesmartApiObject):
def __str__(self):
return self.name
class Measure(VotesmartApiObject):
def __str__(self):
return self.title
class MeasureDetail(VotesmartApiObject):
def __str__(self):
return self.title
class OfficeType(VotesmartApiObject):
def __str__(self):
return ': '.join((self.officeTypeId, self.name))
class OfficeBranch(VotesmartApiObject):
def __str__(self):
return ': '.join((self.officeBranchId, self.name))
class OfficeLevel(VotesmartApiObject):
def __str__(self):
return ': '.join((self.officeLevelId, self.name))
class Office(VotesmartApiObject):
def __str__(self):
return self.name
class Category(VotesmartApiObject):
def __str__(self):
return ': '.join((self.categoryId, self.name))
class Sig(VotesmartApiObject):
def __str__(self):
return ': '.join((self.sigId, self.name))
class SigDetail(VotesmartApiObject):
def __str__(self):
return self.name
class Rating(VotesmartApiObject):
def __str__(self):
return self.ratingText
class State(VotesmartApiObject):
def __str__(self):
return ' '.join((self.stateId, self.name))
class StateDetail(VotesmartApiObject):
def __str__(self):
return ' '.join((self.stateId, self.name))
class BillSponsor(VotesmartApiObject):
def __str__(self):
return self.name
class BillAction(VotesmartApiObject):
def __str__(self):
return ' - '.join((self.statusDate, self.stage))
class BillAmendment(VotesmartApiObject):
def __str__(self):
return self.title
class BillDetail(VotesmartApiObject):
def __init__(self, d):
sponsors = d.pop('sponsors')
actions = d.pop('actions')
amendments = d.pop('ammendments') # ammendments -- sic
self.sponsors = _result_to_obj(BillSponsor, sponsors['sponsor'])
self.actions = _result_to_obj(BillAction, actions['action'])
if amendments:
self.amendments = _result_to_obj(BillAmendment, amendments['ammendment'])
self.__dict__.update(d)
class BillActionDetail(VotesmartApiObject):
def __str__(self):
return self.officialTitle
class Bill(VotesmartApiObject):
def __str__(self):
return ' '.join((self.billNumber, self.title))
class Vote(VotesmartApiObject):
def __str__(self):
return ': '.join((self.candidateName, self.action))
class Veto(VotesmartApiObject):
def __str__(self):
return ' '.join((self.billNumber, self.billTitle))
def _result_to_obj(cls, result):
if isinstance(result, dict):
return [cls(result)]
else:
return [cls(o) for o in result]
class votesmart(object):
apikey = None
@staticmethod
def _apicall(func, params):
if votesmart.apikey is None:
raise VotesmartApiError('Missing Project Vote Smart apikey')
params = dict([(k,v) for (k,v) in params.iteritems() if v])
url = 'http://api.votesmart.org/%s?o=JSON&key=%s&%s' % (func,
votesmart.apikey, urllib.urlencode(params))
try:
response = urllib2.urlopen(url).read()
obj = json.loads(response)
if 'error' in obj:
raise VotesmartApiError(obj['error']['errorMessage'])
else:
return obj
except urllib2.HTTPError, e:
raise VotesmartApiError(e.read())
except ValueError, e:
raise VotesmartApiError('Invalid Response')
class address(object):
@staticmethod
def getCampaign(candidateId):
params = {'candidateId': candidateId}
result = votesmart._apicall('Address.getCampaign', params)
return _result_to_obj(Address, result['address']['office'])
@staticmethod
def getCampaignWebAddress(candidateId):
params = {'candidateId': candidateId}
result = votesmart._apicall('Address.getCampaignWebAddress', params)
return _result_to_obj(WebAddress, result['webaddress']['address'])
@staticmethod
def getCampaignByElection(electionId):
params = {'electionId': electionId}
result = votesmart._apicall('Address.getCampaignByElection', params)
return _result_to_obj(Address, result['address']['office'])
@staticmethod
def getOffice(candidateId):
params = {'candidateId': candidateId}
result = votesmart._apicall('Address.getOffice', params)
return _result_to_obj(Address, result['address']['office'])
@staticmethod
def getOfficeWebAddress(candidateId):
params = {'candidateId': candidateId}
result = votesmart._apicall('Address.getOfficeWebAddress', params)
return _result_to_obj(WebAddress, result['webaddress']['address'])
#@staticmethod
#def getOfficeByOfficeState(officeId, stateId=None):
# params = {'officeId': officeId, 'stateId': stateId}
# result = votesmart._apicall('Address.getOfficeByOfficeState', params)
# return _result_to_obj(Address, result['address']['office'])
class candidatebio(object):
@staticmethod
def getBio(candidateId):
params = {'candidateId': candidateId}
result = votesmart._apicall('CandidateBio.getBio', params)
return Bio(result['bio'])
@staticmethod
def getAddlBio(candidateId):
params = {'candidateId': candidateId}
result = votesmart._apicall('CandidateBio.getAddlBio', params)
return _result_to_obj(AddlBio,
result['addlbio']['additional']['item'])
class candidates(object):
@staticmethod
def getByOfficeState(officeId, stateId=None, electionYear=None):
params = {'officeId': officeId, 'stateId':stateId, 'electionYear': electionYear}
result = votesmart._apicall('Candidates.getByOfficeState', params)
return _result_to_obj(Candidate, result['candidateList']['candidate'])
@staticmethod
def getByLastname(lastName, electionYear=None):
params = {'lastName': lastName, 'electionYear':electionYear}
result = votesmart._apicall('Candidates.getByLastname', params)
return _result_to_obj(Candidate, result['candidateList']['candidate'])
@staticmethod
def getByLevenstein(lastName, electionYear=None):
params = {'lastName': lastName, 'electionYear':electionYear}
result = votesmart._apicall('Candidates.getByLevenstein', params)
return _result_to_obj(Candidate, result['candidateList']['candidate'])
@staticmethod
def getByElection(electionId):
params = {'electionId': electionId}
result = votesmart._apicall('Candidates.getByElection', params)
return _result_to_obj(Candidate, result['candidateList']['candidate'])
@staticmethod
def getByDistrict(districtId, electionYear=None):
params = {'districtId': districtId, 'electionYear':electionYear}
result = votesmart._apicall('Candidates.getByDistrict', params)
return _result_to_obj(Candidate, result['candidateList']['candidate'])
@staticmethod
def getByZip(zip5, zip4=None):
params = {'zip4': zip4, 'zip5': zip5}
result = votesmart._apicall('Candidates.getByZip', params)
return _result_to_obj(Candidate, result['candidateList']['candidate'])
class committee(object):
@staticmethod
def getTypes():
result = votesmart._apicall('Committee.getTypes', {})
return _result_to_obj(CommitteeType, result['committeeTypes']['type'])
@staticmethod
def getCommitteesByTypeState(typeId=None, stateId=None):
params = {'typeId':typeId, 'stateId':stateId}
result = votesmart._apicall('Committee.getCommitteesByTypeState', params)
return _result_to_obj(Committee, result['committees']['committee'])
@staticmethod
def getCommittee(committeeId):
params = {'committeeId' : committeeId}
result = votesmart._apicall('Committee.getCommittee', params)
return CommitteeDetail(result['committee'])
@staticmethod
def getCommitteeMembers(committeeId):
params = {'committeeId' : committeeId}
result = votesmart._apicall('Committee.getCommitteeMembers', params)
return _result_to_obj(CommitteeMember, result['committeeMembers']['member'])
class district(object):
@staticmethod
def getByOfficeState(officeId, stateId, districtName=None):
params = {'officeId':officeId, 'stateId': stateId, 'districtName': districtName}
result = votesmart._apicall('District.getByOfficeState', params)
return _result_to_obj(District, result['districtList']['district'])
@staticmethod
def getByZip(zip5, zip4=None):
params = {'zip5': zip5, 'zip4': zip4}
result = votesmart._apicall('District.getByZip', params)
return _result_to_obj(District, result['districtList']['district'])
class election(object):
@staticmethod
def getElection(electionId):
params = {'electionId':electionId}
result = votesmart._apicall('Election.getElection', params)
return Election(result['elections']['election'])
@staticmethod
def getElectionByYearState(year, stateId=None):
params = {'year':year, 'stateId':stateId}
result = votesmart._apicall('Election.getElectionByYearState', params)
return _result_to_obj(Election, result['elections']['election'])
@staticmethod
def getElectionByZip(zip5, zip4=None, year=None):
params = {'zip5': zip5, 'zip4': zip4, 'year': year}
result = votesmart._apicall('Election.getElectionByZip', params)
return _result_to_obj(Election, result['elections']['election'])
#@staticmethod
#def getStageCandidates(electionId, stageId,
# party=None, districtId=None, stateId=None):
# params = {'electionId':electionId, 'stageId':stageId, 'party':party,
# 'districtId':districtId, 'stateId':stateId}
# result = votesmart._apicall('Election.getElectionByYearState', params)
# ['stageCandidates']['candidate']
class leadership(object):
@staticmethod
def getPositions(stateId=None, officeId=None):
params = {'stateId':stateId, 'officeId':officeId}
result = votesmart._apicall('Leadership.getPositions', params)
return _result_to_obj(LeadershipPosition, result['leadership']['position'])
#@staticmethod
#def getCandidates(leadershipId, stateId=None):
# params = {'leadershipId':leadershipId, 'stateId':stateId}
# result = votesmart._apicall('Leadership.getCandidates', params)
# return result['leaders']['leader']
class local(object):
@staticmethod
def getCounties(stateId):
params = {'stateId': stateId}
result = votesmart._apicall('Local.getCounties', params)
return _result_to_obj(Locality, result['counties']['county'])
@staticmethod
def getCities(stateId):
params = {'stateId': stateId}
result = votesmart._apicall('Local.getCities', params)
return _result_to_obj(Locality, result['cities']['city'])
@staticmethod
def getOfficials(localId):
params = {'localId': localId}
result = votesmart._apicall('Local.getOfficials', params)
return _result_to_obj(Official, result['candidateList']['candidate'])
class measure(object):
@staticmethod
def getMeasuresByYearState(year, stateId):
params = {'year':year, 'stateId':stateId}
result = votesmart._apicall('Measure.getMeasuresByYearState', params)
return _result_to_obj(Measure, result['measures']['measure'])
@staticmethod
def getMeasure(measureId):
params = {'measureId':measureId}
result = votesmart._apicall('Measure.getMeasure', params)
return MeasureDetail(result['measure'])
class npat(object):
@staticmethod
def getNpat(candidateId):
params = {'candidateId':candidateId}
result = votesmart._apicall('Npat.getNpat', params)
return result['npat']
class office(object):
@staticmethod
def getTypes():
result = votesmart._apicall('Office.getTypes', {})
return _result_to_obj(OfficeType, result['officeTypes']['type'])
@staticmethod
def getBranches():
result = votesmart._apicall('Office.getBranches', {})
return _result_to_obj(OfficeBranch, result['branches']['branch'])
@staticmethod
def getLevels():
result = votesmart._apicall('Office.getLevels', {})
return _result_to_obj(OfficeLevel, result['levels']['level'])
@staticmethod
def getOfficesByType(typeId):
params = {'typeId':typeId}
result = votesmart._apicall('Office.getOfficesByType', params)
return _result_to_obj(Office, result['offices']['office'])
@staticmethod
def getOfficesByLevel(levelId):
params = {'levelId':levelId}
result = votesmart._apicall('Office.getOfficesByLevel', params)
return _result_to_obj(Office, result['offices']['office'])
@staticmethod
def getOfficesByTypeLevel(typeId, levelId):
params = {'typeId':typeId, 'levelId':levelId}
result = votesmart._apicall('Office.getOfficesByTypeLevel', params)
return _result_to_obj(Office, result['offices']['office'])
@staticmethod
def getOfficesByBranchLevel(branchId, levelId):
params = {'branchId':branchId, 'levelId':levelId}
result = votesmart._apicall('Office.getOfficesByBranchLevel', params)
return _result_to_obj(Office, result['offices']['office'])
class officials(object):
@staticmethod
def getStatewide(stateId=None):
params = {'stateId': stateId}
result = votesmart._apicall('Officials.getStatewide', params)
return _result_to_obj(Official, result['candidateList']['candidate'])
@staticmethod
def getByOfficeState(officeId, stateId=None):
params = {'officeId':officeId, 'stateId': stateId}
result = votesmart._apicall('Officials.getByOfficeState', params)
return _result_to_obj(Official, result['candidateList']['candidate'])
@staticmethod
def getByLastname(lastName):
params = {'lastName':lastName}
result = votesmart._apicall('Officials.getByLastname', params)
return _result_to_obj(Official, result['candidateList']['candidate'])
@staticmethod
def getByLevenstein(lastName):
params = {'lastName':lastName}
result = votesmart._apicall('Officials.getByLevenstein', params)
return _result_to_obj(Official, result['candidateList']['candidate'])
@staticmethod
def getByElection(electionId):
params = {'electionId':electionId}
result = votesmart._apicall('Officials.getByElection', params)
return _result_to_obj(Official, result['candidateList']['candidate'])
@staticmethod
def getByDistrict(districtId):
params = {'districtId':districtId}
result = votesmart._apicall('Officials.getByDistrict', params)
return _result_to_obj(Official, result['candidateList']['candidate'])
@staticmethod
def getByZip(zip5, zip4=None):
params = {'zip4': zip4, 'zip5': zip5}
result = votesmart._apicall('Officials.getByZip', params)
return _result_to_obj(Official, result['candidateList']['candidate'])
class rating(object):
@staticmethod
def getCategories(stateId=None):
params = {'stateId':stateId}
result = votesmart._apicall('Rating.getCategories', params)
return _result_to_obj(Category, result['categories']['category'])
@staticmethod
def getSigList(categoryId, stateId=None):
params = {'categoryId':categoryId, 'stateId':stateId}
result = votesmart._apicall('Rating.getSigList', params)
return _result_to_obj(Sig, result['sigs']['sig'])
@staticmethod
def getSig(sigId):
params = {'sigId':sigId}
result = votesmart._apicall('Rating.getSig', params)
return SigDetail(result['sig'])
@staticmethod
def getCandidateRating(candidateId, sigId):
params = {'candidateId':candidateId, 'sigId':sigId}
result = votesmart._apicall('Rating.getCandidateRating', params)
return _result_to_obj(Rating, result['candidateRating']['rating'])
class state(object):
@staticmethod
def getStateIDs():
result = votesmart._apicall('State.getStateIDs', {})
return _result_to_obj(State, result['stateList']['list']['state'])
@staticmethod
def getState(stateId):
params = {'stateId':stateId}
result = votesmart._apicall('State.getState', params)
return StateDetail(result['state']['details'])
class votes(object):
@staticmethod
def getCategories(year, stateId=None):
params = {'year':year, 'stateId':stateId}
result = votesmart._apicall('Votes.getCategories', params)
return _result_to_obj(Category, result['categories']['category'])
@staticmethod
def getBill(billId):
params = {'billId':billId}
result = votesmart._apicall('Votes.getBill', params)
return BillDetail(result['bill'])
@staticmethod
def getBillAction(actionId):
params = {'actionId':actionId}
result = votesmart._apicall('Votes.getBillAction', params)
return BillActionDetail(result['action'])
@staticmethod
def getBillActionVotes(actionId):
params = {'actionId':actionId}
result = votesmart._apicall('Votes.getBillActionVotes', params)
return _result_to_obj(Vote, result['votes']['vote'])
@staticmethod
def getBillActionVoteByOfficial(actionId, candidateId):
params = {'actionId':actionId, 'candidateId':candidateId}
result = votesmart._apicall('Votes.getBillActionVoteByOfficial', params)
return Vote(result['votes']['vote'])
@staticmethod
def getByBillNumber(billNumber):
params = {'billNumber': billNumber}
result = votesmart._apicall('Votes.getByBillNumber', params)
return _result_to_obj(Bill, result['bills']['bill'])
@staticmethod
def getBillsByCategoryYearState(categoryId, year, stateId=None):
params = {'categoryId':categoryId, 'year':year, 'stateId':stateId}
result = votesmart._apicall('Votes.getBillsByCategoryYearState', params)
return _result_to_obj(Bill, result['bills']['bill'])
@staticmethod
def getBillsByYearState(year, stateId=None):
params = {'year':year, 'stateId':stateId}
result = votesmart._apicall('Votes.getBillsByYearState', params)
return _result_to_obj(Bill, result['bills']['bill'])
@staticmethod
def getBillsByOfficialYearOffice(candidateId, year, officeId=None):
params = {'candidateId':candidateId, 'year':year, 'officeId':officeId}
result = votesmart._apicall('Votes.getBillsByOfficialYearOffice', params)
return _result_to_obj(Bill, result['bills']['bill'])
@staticmethod
def getBillsByCandidateCategoryOffice(candidateId, categoryId, officeId=None):
params = {'candidateId':candidateId, 'categoryId':categoryId, 'officeId':officeId}
result = votesmart._apicall('Votes.getBillsByCandidateCategoryOffice', params)
return _result_to_obj(Bill, result['bills']['bill'])
@staticmethod
def getBillsBySponsorYear(candidateId, year):
params = {'candidateId':candidateId, 'year':year}
result = votesmart._apicall('Votes.getBillsBySponsorYear', params)
return _result_to_obj(Bill, result['bills']['bill'])
@staticmethod
def getBillsBySponsorCategory(candidateId, categoryId):
params = {'candidateId':candidateId, 'categoryId':categoryId}
result = votesmart._apicall('Votes.getBillsBySponsorCategory', params)
return _result_to_obj(Bill, result['bills']['bill'])
@staticmethod
def getBillsByStateRecent(stateId=None, amount=None):
params = {'stateId':stateId, 'amount':amount}
result = votesmart._apicall('Votes.getBillsByStateRecent', params)
return _result_to_obj(Bill, result['bills']['bill'])
@staticmethod
def getVetoes(candidateId):
params = {'candidateId': candidateId}
result = votesmart._apicall('Votes.getVetoes', params)
return _result_to_obj(Veto, result['vetoes']['veto'])
|
bsd-3-clause
|
[
624,
2018,
3555,
367,
17232,
316,
543,
7290,
812,
1583,
26017,
3261,
14,
339,
7290,
812,
1583,
26017,
1159,
3261,
334,
1014,
921,
1544,
14,
16660,
77,
580,
14,
1308,
15,
5950,
63,
1246,
14,
8624,
9,
272,
6571,
30162,
28897,
2180,
2652,
666,
12,
5893,
666,
641,
373,
6510,
12,
5532,
15557,
272,
18121,
12,
436,
8298,
1655,
14,
199,
624,
199,
199,
363,
2502,
363,
275,
298,
42,
14015,
377,
300,
75,
334,
74,
16218,
75,
32,
11846,
4040,
4214,
425,
14,
957,
2924,
199,
363,
1023,
363,
275,
298,
16,
14,
18,
14,
17,
2,
199,
363,
7307,
363,
275,
298,
7384,
334,
67,
9,
8937,
25625,
4040,
491,
2101,
2,
199,
363,
1682,
363,
275,
298,
15400,
2,
199,
199,
646,
4011,
12,
4011,
18,
199,
893,
26,
272,
492,
2022,
199,
2590,
3545,
26,
272,
492,
13804,
465,
2022,
199,
199,
533,
812,
6510,
77,
580,
7394,
547,
8,
1726,
304,
272,
408,
2186,
367,
25625,
4040,
3261,
2552,
408,
1362,
199,
533,
812,
6510,
77,
580,
7394,
1692,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
366,
304,
267,
291,
855,
807,
363,
275,
366,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1543,
83,
4042,
82,
3171,
450,
334,
277,
855,
533,
4914,
354,
3108,
291,
855,
807,
3368,
268,
199,
533,
9906,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
366,
304,
267,
291,
855,
807,
4343,
873,
8,
68,
459,
1562,
1105,
267,
291,
855,
807,
4343,
873,
8,
68,
459,
9339,
1105,
267,
291,
855,
807,
4343,
873,
8,
68,
459,
5983,
1105,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1543,
83,
4042,
82,
3171,
450,
334,
277,
855,
533,
4914,
354,
3108,
291,
855,
807,
3368,
199,
199,
533,
6001,
1476,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
2520,
1476,
1362,
199,
533,
699,
2308,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
366,
304,
267,
327,
277,
855,
807,
4343,
873,
8,
68,
459,
28507,
1105,
267,
327,
277,
855,
807,
4343,
873,
8,
68,
459,
18812,
1105,
267,
291,
855,
807,
4343,
873,
8,
68,
459,
9007,
1105,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1543,
83,
4042,
82,
3171,
450,
334,
277,
855,
533,
4914,
354,
3108,
291,
855,
807,
3368,
1362,
199,
533,
2654,
76,
34,
2308,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
7596,
1987,
904,
1332,
277,
14,
354,
12,
291,
14,
576,
430,
1362,
199,
533,
6855,
5168,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
283,
1987,
904,
1332,
277,
14,
2246,
985,
12,
291,
14,
2019,
985,
430,
268,
199,
533,
21447,
15557,
804,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
199,
199,
533,
21447,
15557,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
21447,
15557,
8064,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
199,
199,
533,
21447,
15557,
7021,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
283,
1987,
904,
1332,
277,
14,
1213,
12,
291,
14,
2246,
985,
12,
291,
14,
2019,
985,
430,
199,
199,
533,
577,
5230,
319,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
662,
1486,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
826,
721,
277,
12,
366,
304,
267,
24490,
275,
359,
37,
1486,
21052,
8,
83,
9,
367,
308,
315,
366,
14,
1935,
360,
8614,
5440,
267,
291,
855,
807,
363,
275,
366,
267,
291,
14,
30646,
275,
24490,
2286,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
662,
1486,
21052,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
1543,
83,
4366,
83,
3171,
450,
334,
277,
14,
354,
12,
291,
14,
28507,
2506,
9,
258,
199,
199,
533,
24545,
16714,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
283,
1987,
904,
1332,
277,
14,
1213,
12,
291,
14,
2246,
985,
12,
291,
14,
2019,
985,
430,
1362,
199,
533,
7005,
669,
3319,
5625,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
6263,
6712,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
22933,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
1213,
1362,
199,
533,
22933,
8064,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
1213,
199,
199,
533,
593,
11286,
301,
804,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
7596,
1987,
904,
1332,
277,
14,
18812,
2568,
12,
291,
14,
354,
430,
1362,
199,
533,
593,
11286,
301,
12526,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
7596,
1987,
904,
1332,
277,
14,
18812,
12526,
1304,
12,
291,
14,
354,
430,
1362,
199,
533,
593,
11286,
301,
4670,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
7596,
1987,
904,
1332,
277,
14,
18812,
4670,
1304,
12,
291,
14,
354,
430,
1362,
199,
533,
593,
11286,
301,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
13573,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
7596,
1987,
904
] |
[
2018,
3555,
367,
17232,
316,
543,
7290,
812,
1583,
26017,
3261,
14,
339,
7290,
812,
1583,
26017,
1159,
3261,
334,
1014,
921,
1544,
14,
16660,
77,
580,
14,
1308,
15,
5950,
63,
1246,
14,
8624,
9,
272,
6571,
30162,
28897,
2180,
2652,
666,
12,
5893,
666,
641,
373,
6510,
12,
5532,
15557,
272,
18121,
12,
436,
8298,
1655,
14,
199,
624,
199,
199,
363,
2502,
363,
275,
298,
42,
14015,
377,
300,
75,
334,
74,
16218,
75,
32,
11846,
4040,
4214,
425,
14,
957,
2924,
199,
363,
1023,
363,
275,
298,
16,
14,
18,
14,
17,
2,
199,
363,
7307,
363,
275,
298,
7384,
334,
67,
9,
8937,
25625,
4040,
491,
2101,
2,
199,
363,
1682,
363,
275,
298,
15400,
2,
199,
199,
646,
4011,
12,
4011,
18,
199,
893,
26,
272,
492,
2022,
199,
2590,
3545,
26,
272,
492,
13804,
465,
2022,
199,
199,
533,
812,
6510,
77,
580,
7394,
547,
8,
1726,
304,
272,
408,
2186,
367,
25625,
4040,
3261,
2552,
408,
1362,
199,
533,
812,
6510,
77,
580,
7394,
1692,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
366,
304,
267,
291,
855,
807,
363,
275,
366,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1543,
83,
4042,
82,
3171,
450,
334,
277,
855,
533,
4914,
354,
3108,
291,
855,
807,
3368,
268,
199,
533,
9906,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
366,
304,
267,
291,
855,
807,
4343,
873,
8,
68,
459,
1562,
1105,
267,
291,
855,
807,
4343,
873,
8,
68,
459,
9339,
1105,
267,
291,
855,
807,
4343,
873,
8,
68,
459,
5983,
1105,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1543,
83,
4042,
82,
3171,
450,
334,
277,
855,
533,
4914,
354,
3108,
291,
855,
807,
3368,
199,
199,
533,
6001,
1476,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
2520,
1476,
1362,
199,
533,
699,
2308,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
366,
304,
267,
327,
277,
855,
807,
4343,
873,
8,
68,
459,
28507,
1105,
267,
327,
277,
855,
807,
4343,
873,
8,
68,
459,
18812,
1105,
267,
291,
855,
807,
4343,
873,
8,
68,
459,
9007,
1105,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1543,
83,
4042,
82,
3171,
450,
334,
277,
855,
533,
4914,
354,
3108,
291,
855,
807,
3368,
1362,
199,
533,
2654,
76,
34,
2308,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
7596,
1987,
904,
1332,
277,
14,
354,
12,
291,
14,
576,
430,
1362,
199,
533,
6855,
5168,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
283,
1987,
904,
1332,
277,
14,
2246,
985,
12,
291,
14,
2019,
985,
430,
268,
199,
533,
21447,
15557,
804,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
199,
199,
533,
21447,
15557,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
21447,
15557,
8064,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
199,
199,
533,
21447,
15557,
7021,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
283,
1987,
904,
1332,
277,
14,
1213,
12,
291,
14,
2246,
985,
12,
291,
14,
2019,
985,
430,
199,
199,
533,
577,
5230,
319,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
662,
1486,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
826,
721,
277,
12,
366,
304,
267,
24490,
275,
359,
37,
1486,
21052,
8,
83,
9,
367,
308,
315,
366,
14,
1935,
360,
8614,
5440,
267,
291,
855,
807,
363,
275,
366,
267,
291,
14,
30646,
275,
24490,
2286,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
662,
1486,
21052,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
1543,
83,
4366,
83,
3171,
450,
334,
277,
14,
354,
12,
291,
14,
28507,
2506,
9,
258,
199,
199,
533,
24545,
16714,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
283,
1987,
904,
1332,
277,
14,
1213,
12,
291,
14,
2246,
985,
12,
291,
14,
2019,
985,
430,
1362,
199,
533,
7005,
669,
3319,
5625,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
6263,
6712,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
22933,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
1213,
1362,
199,
533,
22933,
8064,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
1213,
199,
199,
533,
593,
11286,
301,
804,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
7596,
1987,
904,
1332,
277,
14,
18812,
2568,
12,
291,
14,
354,
430,
1362,
199,
533,
593,
11286,
301,
12526,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
7596,
1987,
904,
1332,
277,
14,
18812,
12526,
1304,
12,
291,
14,
354,
430,
1362,
199,
533,
593,
11286,
301,
4670,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
7596,
1987,
904,
1332,
277,
14,
18812,
4670,
1304,
12,
291,
14,
354,
430,
1362,
199,
533,
593,
11286,
301,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
1362,
199,
533,
13573,
8,
54,
6510,
77,
580,
7394,
1692,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
7596,
1987,
904,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
derDavidT/sympy
|
sympy/physics/quantum/tests/test_qexpr.py
|
120
|
1457
|
from sympy import Symbol, Integer
from sympy.physics.quantum.qexpr import QExpr, _qsympify_sequence
from sympy.physics.quantum.hilbert import HilbertSpace
from sympy.core.containers import Tuple
x = Symbol('x')
y = Symbol('y')
def test_qexpr_new():
q = QExpr(0)
assert q.label == (0,)
assert q.hilbert_space == HilbertSpace()
assert q.is_commutative is False
q = QExpr(0, 1)
assert q.label == (Integer(0), Integer(1))
q = QExpr._new_rawargs(HilbertSpace(), Integer(0), Integer(1))
assert q.label == (Integer(0), Integer(1))
assert q.hilbert_space == HilbertSpace()
def test_qexpr_commutative():
q1 = QExpr(x)
q2 = QExpr(y)
assert q1.is_commutative is False
assert q2.is_commutative is False
assert q1*q2 != q2*q1
q = QExpr._new_rawargs(0, 1, HilbertSpace())
assert q.is_commutative is False
def test_qexpr_commutative_free_symbols():
q1 = QExpr(x)
assert q1.free_symbols.pop().is_commutative is False
q2 = QExpr('q2')
assert q2.free_symbols.pop().is_commutative is False
def test_qexpr_subs():
q1 = QExpr(x, y)
assert q1.subs(x, y) == QExpr(y, y)
assert q1.subs({x: 1, y: 2}) == QExpr(1, 2)
def test_qsympify():
assert _qsympify_sequence([[1, 2], [1, 3]]) == (Tuple(1, 2), Tuple(1, 3))
assert _qsympify_sequence(([1, 2, [3, 4, [2, ]], 1], 3)) == \
(Tuple(1, 2, Tuple(3, 4, Tuple(2,)), 1), 3)
assert _qsympify_sequence((1,)) == (1,)
|
bsd-3-clause
|
[
504,
5840,
492,
10080,
12,
7225,
199,
504,
5840,
14,
24724,
14,
25999,
14,
81,
3684,
492,
1413,
8561,
12,
485,
81,
1786,
18456,
63,
4041,
199,
504,
5840,
14,
24724,
14,
25999,
14,
72,
382,
12504,
492,
869,
382,
12504,
7643,
199,
504,
5840,
14,
1018,
14,
13577,
492,
11634,
199,
199,
88,
275,
10080,
360,
88,
358,
199,
89,
275,
10080,
360,
89,
358,
421,
199,
318,
511,
63,
81,
3684,
63,
1222,
837,
272,
1894,
275,
1413,
8561,
8,
16,
9,
272,
702,
1894,
14,
1302,
508,
334,
16,
4258,
272,
702,
1894,
14,
72,
382,
12504,
63,
2638,
508,
869,
382,
12504,
7643,
342,
272,
702,
1894,
14,
374,
63,
1404,
28177,
365,
756,
339,
1894,
275,
1413,
8561,
8,
16,
12,
413,
9,
272,
702,
1894,
14,
1302,
508,
334,
2674,
8,
16,
395,
7225,
8,
17,
430,
339,
1894,
275,
1413,
8561,
423,
1222,
63,
1773,
589,
8,
40,
382,
12504,
7643,
1062,
7225,
8,
16,
395,
7225,
8,
17,
430,
272,
702,
1894,
14,
1302,
508,
334,
2674,
8,
16,
395,
7225,
8,
17,
430,
272,
702,
1894,
14,
72,
382,
12504,
63,
2638,
508,
869,
382,
12504,
7643,
342,
421,
199,
318,
511,
63,
81,
3684,
63,
1404,
28177,
837,
272,
1894,
17,
275,
1413,
8561,
8,
88,
9,
272,
1894,
18,
275,
1413,
8561,
8,
89,
9,
272,
702,
1894,
17,
14,
374,
63,
1404,
28177,
365,
756,
272,
702,
1894,
18,
14,
374,
63,
1404,
28177,
365,
756,
272,
702,
1894,
17,
10,
81,
18,
1137,
1894,
18,
10,
81,
17,
339,
1894,
275,
1413,
8561,
423,
1222,
63,
1773,
589,
8,
16,
12,
413,
12,
869,
382,
12504,
7643,
1012,
272,
702,
1894,
14,
374,
63,
1404,
28177,
365,
756,
199,
199,
318,
511,
63,
81,
3684,
63,
1404,
28177,
63,
4624,
63,
7450,
837,
272,
1894,
17,
275,
1413,
8561,
8,
88,
9,
272,
702,
1894,
17,
14,
4624,
63,
7450,
14,
1935,
1252,
374,
63,
1404,
28177,
365,
756,
339,
1894,
18,
275,
1413,
8561,
360,
81,
18,
358,
272,
702,
1894,
18,
14,
4624,
63,
7450,
14,
1935,
1252,
374,
63,
1404,
28177,
365,
756,
199,
199,
318,
511,
63,
81,
3684,
63,
9841,
837,
272,
1894,
17,
275,
1413,
8561,
8,
88,
12,
612,
9,
272,
702,
1894,
17,
14,
9841,
8,
88,
12,
612,
9,
508,
1413,
8561,
8,
89,
12,
612,
9,
272,
702,
1894,
17,
14,
9841,
2561,
88,
26,
413,
12,
612,
26,
499,
1552,
508,
1413,
8561,
8,
17,
12,
499,
9,
421,
199,
318,
511,
63,
81,
1786,
18456,
837,
272,
702,
485,
81,
1786,
18456,
63,
4041,
4038,
17,
12,
499,
467,
359,
17,
12,
650,
3934,
508,
334,
7075,
8,
17,
12,
499,
395,
11634,
8,
17,
12,
650,
430,
272,
702,
485,
81,
1786,
18456,
63,
4041,
27123,
17,
12,
499,
12,
359,
19,
12,
841,
12,
359,
18,
12,
1622,
467,
413,
467,
650,
430,
508,
971,
267,
334,
7075,
8,
17,
12,
499,
12,
11634,
8,
19,
12,
841,
12,
11634,
8,
18,
16965,
413,
395,
650,
9,
272,
702,
485,
81,
1786,
18456,
63,
4041,
1332,
17,
4641,
508,
334,
17,
4258,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
5840,
492,
10080,
12,
7225,
199,
504,
5840,
14,
24724,
14,
25999,
14,
81,
3684,
492,
1413,
8561,
12,
485,
81,
1786,
18456,
63,
4041,
199,
504,
5840,
14,
24724,
14,
25999,
14,
72,
382,
12504,
492,
869,
382,
12504,
7643,
199,
504,
5840,
14,
1018,
14,
13577,
492,
11634,
199,
199,
88,
275,
10080,
360,
88,
358,
199,
89,
275,
10080,
360,
89,
358,
421,
199,
318,
511,
63,
81,
3684,
63,
1222,
837,
272,
1894,
275,
1413,
8561,
8,
16,
9,
272,
702,
1894,
14,
1302,
508,
334,
16,
4258,
272,
702,
1894,
14,
72,
382,
12504,
63,
2638,
508,
869,
382,
12504,
7643,
342,
272,
702,
1894,
14,
374,
63,
1404,
28177,
365,
756,
339,
1894,
275,
1413,
8561,
8,
16,
12,
413,
9,
272,
702,
1894,
14,
1302,
508,
334,
2674,
8,
16,
395,
7225,
8,
17,
430,
339,
1894,
275,
1413,
8561,
423,
1222,
63,
1773,
589,
8,
40,
382,
12504,
7643,
1062,
7225,
8,
16,
395,
7225,
8,
17,
430,
272,
702,
1894,
14,
1302,
508,
334,
2674,
8,
16,
395,
7225,
8,
17,
430,
272,
702,
1894,
14,
72,
382,
12504,
63,
2638,
508,
869,
382,
12504,
7643,
342,
421,
199,
318,
511,
63,
81,
3684,
63,
1404,
28177,
837,
272,
1894,
17,
275,
1413,
8561,
8,
88,
9,
272,
1894,
18,
275,
1413,
8561,
8,
89,
9,
272,
702,
1894,
17,
14,
374,
63,
1404,
28177,
365,
756,
272,
702,
1894,
18,
14,
374,
63,
1404,
28177,
365,
756,
272,
702,
1894,
17,
10,
81,
18,
1137,
1894,
18,
10,
81,
17,
339,
1894,
275,
1413,
8561,
423,
1222,
63,
1773,
589,
8,
16,
12,
413,
12,
869,
382,
12504,
7643,
1012,
272,
702,
1894,
14,
374,
63,
1404,
28177,
365,
756,
199,
199,
318,
511,
63,
81,
3684,
63,
1404,
28177,
63,
4624,
63,
7450,
837,
272,
1894,
17,
275,
1413,
8561,
8,
88,
9,
272,
702,
1894,
17,
14,
4624,
63,
7450,
14,
1935,
1252,
374,
63,
1404,
28177,
365,
756,
339,
1894,
18,
275,
1413,
8561,
360,
81,
18,
358,
272,
702,
1894,
18,
14,
4624,
63,
7450,
14,
1935,
1252,
374,
63,
1404,
28177,
365,
756,
199,
199,
318,
511,
63,
81,
3684,
63,
9841,
837,
272,
1894,
17,
275,
1413,
8561,
8,
88,
12,
612,
9,
272,
702,
1894,
17,
14,
9841,
8,
88,
12,
612,
9,
508,
1413,
8561,
8,
89,
12,
612,
9,
272,
702,
1894,
17,
14,
9841,
2561,
88,
26,
413,
12,
612,
26,
499,
1552,
508,
1413,
8561,
8,
17,
12,
499,
9,
421,
199,
318,
511,
63,
81,
1786,
18456,
837,
272,
702,
485,
81,
1786,
18456,
63,
4041,
4038,
17,
12,
499,
467,
359,
17,
12,
650,
3934,
508,
334,
7075,
8,
17,
12,
499,
395,
11634,
8,
17,
12,
650,
430,
272,
702,
485,
81,
1786,
18456,
63,
4041,
27123,
17,
12,
499,
12,
359,
19,
12,
841,
12,
359,
18,
12,
1622,
467,
413,
467,
650,
430,
508,
971,
267,
334,
7075,
8,
17,
12,
499,
12,
11634,
8,
19,
12,
841,
12,
11634,
8,
18,
16965,
413,
395,
650,
9,
272,
702,
485,
81,
1786,
18456,
63,
4041,
1332,
17,
4641,
508,
334,
17,
4258,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
josenavas/qiime
|
scripts/pick_de_novo_otus.py
|
15
|
8993
|
#!/usr/bin/env python
# File created on 27 Oct 2009.
from __future__ import division
__author__ = "Greg Caporaso"
__copyright__ = "Copyright 2011, The QIIME Project"
__credits__ = ["Greg Caporaso", "Kyle Bittinger"]
__license__ = "GPL"
__version__ = "1.9.1-dev"
__maintainer__ = "Greg Caporaso"
__email__ = "gregcaporaso@gmail.com"
from qiime.util import make_option
from os import makedirs
from qiime.util import (load_qiime_config,
parse_command_line_parameters,
get_options_lookup)
from qiime.parse import parse_qiime_parameters
from qiime.workflow.upstream import run_pick_de_novo_otus
from qiime.workflow.util import (print_commands,
call_commands_serially,
print_to_stdout,
no_status_updates,
validate_and_set_jobs_to_start)
qiime_config = load_qiime_config()
options_lookup = get_options_lookup()
script_info = {}
script_info[
'brief_description'] = """A workflow for de novo OTU picking, taxonomy assignment, phylogenetic tree construction, and OTU table construction."""
script_info[
'script_description'] = """This script takes a sequence file and performs all processing steps through building the OTU table."""
script_info['script_usage'] = []
script_info['script_usage'].append(
("""Uclust example""",
"""The following command will start an analysis on seqs.fna (-i), which is a post-split_libraries fasta file. The sequence identifiers in this file should be of the form <sample_id>_<unique_seq_id>. The following steps, corresponding to the preliminary data preparation, are applied: Pick de novo OTUs at 97%; pick a representative sequence for each OTU (the OTU centroid sequence); align the representative set with PyNAST; assign taxonomy with the uclust consensus taxonomy assigner; filter the alignment prior to tree building - remove positions which are all gaps, and specified as 0 in the lanemask; build a phylogenetic tree with FastTree; build an OTU table. All output files will be written to the directory specified by -o, and subdirectories as appropriate. ALWAYS SPECIFY ABSOLUTE FILE PATHS (absolute path represented here as $PWD, but will generally look something like /home/ubuntu/my_analysis/).""",
"""%prog -i $PWD/seqs.fna -o $PWD/uclust_otus/"""))
script_info['script_usage'].append(
("SumaClust example",
"The following command will start an analysis on seqs.fna (-i), "
"which is a post-split_libraries fasta file. The sequence identifiers "
"in this file should be of the form <sample_id>_<unique_seq_id>. The "
"following steps, corresponding to the preliminary data preparation, "
"are applied: Pick de novo OTUs at 97%; pick a representative sequence "
"for each OTU (the OTU centroid sequence); align the representative set "
"with PyNAST; assign taxonomy with the RDP consensus taxonomy "
"assigner; filter the alignment prior to tree building - remove "
"positions which are all gaps, and specified as 0 in the lanemask; "
"build a phylogenetic tree with FastTree; build an OTU table. All "
"output files will be written to the directory specified by -o, and "
"subdirectories as appropriate. ALWAYS SPECIFY ABSOLUTE FILE PATHS "
"(absolute path represented here as $PWD, but will generally look "
"something like /home/ubuntu/my_analysis/). ",
"%prog -i $PWD/seqs.fna -o $PWD/sumaclust_otus/ -p "
"$PWD/sumaclust_params.txt"))
script_info['script_usage'].append(
("Swarm example",
"The following command will start an analysis on seqs.fna (-i), "
"which is a post-split_libraries fasta file. The sequence identifiers "
"in this file should be of the form <sample_id>_<unique_seq_id>. The "
"following steps, corresponding to the preliminary data preparation, "
"are applied: Pick de novo OTUs at 97%; pick a representative sequence "
"for each OTU (the OTU centroid sequence); align the representative set "
"with PyNAST; assign taxonomy with the RDP consensus taxonomy "
"assigner; filter the alignment prior to tree building - remove "
"positions which are all gaps, and specified as 0 in the lanemask; "
"build a phylogenetic tree with FastTree; build an OTU table. All "
"output files will be written to the directory specified by -o, and "
"subdirectories as appropriate. ALWAYS SPECIFY ABSOLUTE FILE PATHS "
"(absolute path represented here as $PWD, but will generally look "
"something like /home/ubuntu/my_analysis/). ",
"%prog -i $PWD/seqs.fna -o $PWD/swarm_otus/ -p "
"$PWD/swarm_params.txt"))
script_info['script_usage_output_to_remove'] = ['$PWD/uclust_otus/',
'$PWD/sumaclust_otus/',
'$PWD/swarm_otus/']
script_info[
'output_description'] = """This script will produce an OTU mapping file (pick_otus.py), a representative set of sequences (FASTA file from pick_rep_set.py), a sequence alignment file (FASTA file from align_seqs.py), taxonomy assignment file (from assign_taxonomy.py), a filtered sequence alignment (from filter_alignment.py), a phylogenetic tree (Newick file from make_phylogeny.py) and a biom-formatted OTU table (from make_otu_table.py)."""
script_info['required_options'] = [
make_option('-i', '--input_fp', type='existing_filepath',
help='the input fasta file [REQUIRED]'),
make_option('-o', '--output_dir', type='new_dirpath',
help='the output directory [REQUIRED]'),
]
script_info['optional_options'] = [
make_option('-p', '--parameter_fp', type='existing_filepath',
help='path to the parameter file, which specifies changes' +
' to the default behavior. ' +
'See http://www.qiime.org/documentation/file_formats.html#qiime-parameters .' +
' [if omitted, default values will be used]'),
make_option('-f', '--force', action='store_true',
dest='force', help='Force overwrite of existing output directory' +
' (note: existing files in output_dir will not be removed)' +
' [default: %default]'),
make_option('-w', '--print_only', action='store_true',
dest='print_only', help='Print the commands but don\'t call them -- ' +
'useful for debugging [default: %default]', default=False),
make_option('-a', '--parallel', action='store_true',
dest='parallel', default=False,
help='Run in parallel where available [default: %default]'),
options_lookup['jobs_to_start_workflow']
]
script_info['version'] = __version__
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
verbose = opts.verbose
input_fp = opts.input_fp
output_dir = opts.output_dir
verbose = opts.verbose
print_only = opts.print_only
parallel = opts.parallel
# No longer checking that jobs_to_start > 2, but
# commenting as we may change our minds about this.
#if parallel: raise_error_on_parallel_unavailable()
if opts.parameter_fp:
try:
parameter_f = open(opts.parameter_fp, 'U')
except IOError:
raise IOError("Can't open parameters file (%s). Does it exist? Do you have read access?"
% opts.parameter_fp)
params = parse_qiime_parameters(parameter_f)
parameter_f.close()
else:
params = parse_qiime_parameters([])
# empty list returns empty defaultdict for now
jobs_to_start = opts.jobs_to_start
default_jobs_to_start = qiime_config['jobs_to_start']
validate_and_set_jobs_to_start(params,
jobs_to_start,
default_jobs_to_start,
parallel,
option_parser)
try:
makedirs(output_dir)
except OSError:
if opts.force:
pass
else:
# Since the analysis can take quite a while, I put this check
# in to help users avoid overwriting previous output.
option_parser.error("Output directory already exists. Please choose"
" a different directory, or force overwrite with -f.")
if print_only:
command_handler = print_commands
else:
command_handler = call_commands_serially
if verbose:
status_update_callback = print_to_stdout
else:
status_update_callback = no_status_updates
run_pick_de_novo_otus(
input_fp,
output_dir,
command_handler=command_handler,
params=params,
qiime_config=qiime_config,
parallel=parallel,
status_update_callback=status_update_callback)
if __name__ == "__main__":
main()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
3814,
2737,
641,
8087,
18365,
8937,
14,
199,
504,
636,
2443,
363,
492,
4629,
199,
199,
363,
2502,
363,
275,
298,
39,
1135,
22516,
269,
305,
79,
2,
199,
363,
7307,
363,
275,
298,
7384,
7760,
12,
710,
1413,
41,
3465,
7290,
2,
199,
363,
22461,
363,
275,
2097,
39,
1135,
22516,
269,
305,
79,
401,
298,
43,
1775,
10199,
1337,
281,
937,
199,
363,
1682,
363,
275,
298,
12006,
2,
199,
363,
1023,
363,
275,
298,
17,
14,
25,
14,
17,
13,
2374,
2,
199,
363,
26665,
363,
275,
298,
39,
1135,
22516,
269,
305,
79,
2,
199,
363,
2123,
363,
275,
298,
3939,
2874,
269,
305,
79,
32,
6799,
14,
957,
2,
199,
199,
504,
31402,
1036,
14,
1974,
492,
1852,
63,
1422,
199,
504,
747,
492,
1852,
3220,
199,
504,
31402,
1036,
14,
1974,
492,
334,
912,
63,
23104,
1036,
63,
888,
12,
717,
2198,
63,
1531,
63,
604,
63,
3214,
12,
717,
664,
63,
1419,
63,
3892,
9,
199,
504,
31402,
1036,
14,
1122,
492,
2198,
63,
23104,
1036,
63,
3214,
199,
504,
31402,
1036,
14,
8856,
14,
20099,
492,
1255,
63,
4510,
63,
271,
63,
889,
2392,
63,
357,
527,
199,
504,
31402,
1036,
14,
8856,
14,
1974,
492,
334,
1361,
63,
4405,
12,
639,
1240,
63,
4405,
63,
261,
322,
1183,
12,
639,
870,
63,
475,
63,
2703,
12,
639,
949,
63,
1205,
63,
7618,
12,
639,
4107,
63,
460,
63,
409,
63,
6920,
63,
475,
63,
928,
9,
199,
199,
23104,
1036,
63,
888,
275,
2248,
63,
23104,
1036,
63,
888,
342,
199,
1419,
63,
3892,
275,
664,
63,
1419,
63,
3892,
342,
199,
1579,
63,
815,
275,
1052,
199,
1579,
63,
815,
59,
272,
283,
19127,
63,
1802,
418,
275,
408,
33,
10431,
367,
477,
949,
2392,
593,
21364,
12433,
12,
9067,
17293,
9801,
12,
11831,
793,
6349,
764,
3123,
14538,
12,
436,
593,
21364,
1817,
14538,
1041,
199,
1579,
63,
815,
59,
272,
283,
1579,
63,
1802,
418,
275,
408,
2765,
2884,
6181,
282,
3414,
570,
436,
18628,
1006,
6661,
7124,
4012,
10015,
314,
593,
21364,
1817,
1041,
199,
199,
1579,
63,
815,
459,
1579,
63,
3807,
418,
275,
942,
199,
199,
1579,
63,
815,
459,
1579,
63,
3807,
2278,
740,
8,
272,
334,
624,
53,
429,
833,
2893,
7208,
1362,
408,
1918,
2569,
1414,
911,
1343,
376,
11284,
641,
5412,
83,
14,
2324,
65,
5868,
73,
395,
1314,
365,
282,
2963,
13,
1294,
63,
10159,
30544,
570,
14,
710,
3414,
14154,
315,
642,
570,
1077,
506,
402,
314,
1824,
665,
3271,
63,
344,
30,
27718,
3235,
63,
3610,
63,
344,
10827,
710,
2569,
7124,
12,
5226,
370,
314,
876,
13769,
695,
666,
876,
462,
425,
12,
787,
6781,
26,
16568,
477,
949,
2392,
593,
21364,
83,
737,
15997,
5,
27,
3732,
282,
2954,
1905,
3414,
367,
1924,
593,
21364,
334,
1589,
593,
21364,
27587,
3414,
2736,
6998,
314,
2954,
1905,
663,
543,
1611,
7170,
840,
27,
5090,
9067,
17293,
543,
314,
399,
429,
833,
406,
31664,
9067,
17293,
5090,
281,
27,
2457,
314,
13177,
6791,
370,
3123,
10015,
446,
2813,
12266,
1314,
787,
1006,
486,
7461,
12,
436,
2013,
465,
378,
315,
314,
634,
5865,
2629,
27,
1900,
282,
11831,
793,
6349,
764,
3123,
543,
22613,
3987,
27,
1900,
376,
593,
21364,
1817,
14,
2900,
1072,
1584,
911,
506,
5313,
370,
314,
2082,
2013,
701,
446,
79,
12,
436,
24799,
465,
5827,
14,
12112,
26194,
428,
7236,
18114,
437,
11087,
2228,
4586,
13024,
15097,
51,
334,
6116,
931,
11159,
2348,
465,
2672,
10780,
36,
12,
1325,
911,
16711,
3648,
6020,
2839,
1182,
4219,
15,
21151,
15,
1662,
63,
10466,
15,
680,
7208,
1362,
408,
5,
6595,
446,
73,
2672,
10780,
36,
15,
19467,
14,
2324,
65,
446,
79,
2672,
10780,
36,
15,
85,
429,
833,
63,
357,
527,
15,
624,
430,
199,
199,
1579,
63,
815,
459,
1579,
63,
3807,
2278,
740,
8,
272,
1689,
27032,
391,
1968,
833,
2893,
401,
1362,
298,
1918,
2569,
1414,
911,
1343,
376,
11284,
641,
5412,
83,
14,
2324,
65,
5868,
73,
395,
298,
1362,
298,
6777,
365,
282,
2963,
13,
1294,
63,
10159,
30544,
570,
14,
710,
3414,
14154,
298,
1362,
298,
262,
642,
570,
1077,
506,
402,
314,
1824,
665,
3271,
63,
344,
30,
27718,
3235,
63,
3610,
63,
344,
10827,
710,
298,
1362,
298,
21589,
7124,
12,
5226,
370,
314,
876,
13769,
695,
666,
876,
462,
425,
12,
298,
1362,
298,
1530,
6781,
26,
16568,
477,
949,
2392,
593,
21364,
83,
737,
15997,
5,
27,
3732,
282,
2954,
1905,
3414,
298,
1362,
298,
509,
1924,
593,
21364,
334,
1589,
593,
21364,
27587,
3414,
2736,
6998,
314,
2954,
1905,
663,
298,
1362,
298,
1045,
1611,
7170,
840,
27,
5090,
9067,
17293,
543,
314,
820,
11741,
406,
31664,
9067,
17293,
298,
1362,
298,
5038,
281,
27,
2457,
314,
13177,
6791,
370,
3123,
10015,
446,
2813,
298,
1362,
298,
12658,
1314,
787,
1006,
486,
7461,
12,
436,
2013,
465,
378,
315,
314,
634,
5865,
2629,
27,
298,
1362,
298,
1506,
282,
11831,
793,
6349,
764,
3123,
543,
22613,
3987,
27,
1900,
376,
593,
21364,
1817,
14,
2900,
298,
1362,
298,
1199,
1584,
911,
506,
5313,
370,
314,
2082,
2013,
701,
446,
79,
12,
436,
298,
1362,
298,
954,
12629,
465,
5827,
14,
12112,
26194,
428,
7236,
18114,
437,
11087,
2228,
4586,
13024,
15097,
51,
298,
1362,
7340,
6116,
931,
11159,
2348,
465,
2672,
10780,
36,
12,
1325,
911,
16711,
3648,
298,
1362,
298,
10297,
2839,
1182,
4219,
15,
21151,
15,
1662,
63,
10466,
15,
680,
3872,
1362,
2071,
6595,
446,
73,
2672,
10780,
36,
15,
19467,
14,
2324,
65,
446,
79,
2672,
10780,
36,
15,
9648,
391,
429,
833,
63,
357,
527,
15,
446,
80,
298,
1362,
7880,
10780,
36,
15,
9648,
391,
429,
833,
63,
1162,
14,
2424,
2237,
199,
199,
1579,
63,
815,
459,
1579,
63,
3807,
2278,
740,
8,
272,
1689,
51,
10669,
2893,
401,
1362,
298,
1918,
2569,
1414,
911,
1343,
376,
11284,
641,
5412,
83,
14,
2324,
65,
5868,
73,
395,
298,
1362,
298,
6777,
365,
282,
2963,
13,
1294,
63,
10159,
30544,
570,
14,
710,
3414,
14154,
298,
1362,
298,
262,
642,
570
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
3814,
2737,
641,
8087,
18365,
8937,
14,
199,
504,
636,
2443,
363,
492,
4629,
199,
199,
363,
2502,
363,
275,
298,
39,
1135,
22516,
269,
305,
79,
2,
199,
363,
7307,
363,
275,
298,
7384,
7760,
12,
710,
1413,
41,
3465,
7290,
2,
199,
363,
22461,
363,
275,
2097,
39,
1135,
22516,
269,
305,
79,
401,
298,
43,
1775,
10199,
1337,
281,
937,
199,
363,
1682,
363,
275,
298,
12006,
2,
199,
363,
1023,
363,
275,
298,
17,
14,
25,
14,
17,
13,
2374,
2,
199,
363,
26665,
363,
275,
298,
39,
1135,
22516,
269,
305,
79,
2,
199,
363,
2123,
363,
275,
298,
3939,
2874,
269,
305,
79,
32,
6799,
14,
957,
2,
199,
199,
504,
31402,
1036,
14,
1974,
492,
1852,
63,
1422,
199,
504,
747,
492,
1852,
3220,
199,
504,
31402,
1036,
14,
1974,
492,
334,
912,
63,
23104,
1036,
63,
888,
12,
717,
2198,
63,
1531,
63,
604,
63,
3214,
12,
717,
664,
63,
1419,
63,
3892,
9,
199,
504,
31402,
1036,
14,
1122,
492,
2198,
63,
23104,
1036,
63,
3214,
199,
504,
31402,
1036,
14,
8856,
14,
20099,
492,
1255,
63,
4510,
63,
271,
63,
889,
2392,
63,
357,
527,
199,
504,
31402,
1036,
14,
8856,
14,
1974,
492,
334,
1361,
63,
4405,
12,
639,
1240,
63,
4405,
63,
261,
322,
1183,
12,
639,
870,
63,
475,
63,
2703,
12,
639,
949,
63,
1205,
63,
7618,
12,
639,
4107,
63,
460,
63,
409,
63,
6920,
63,
475,
63,
928,
9,
199,
199,
23104,
1036,
63,
888,
275,
2248,
63,
23104,
1036,
63,
888,
342,
199,
1419,
63,
3892,
275,
664,
63,
1419,
63,
3892,
342,
199,
1579,
63,
815,
275,
1052,
199,
1579,
63,
815,
59,
272,
283,
19127,
63,
1802,
418,
275,
408,
33,
10431,
367,
477,
949,
2392,
593,
21364,
12433,
12,
9067,
17293,
9801,
12,
11831,
793,
6349,
764,
3123,
14538,
12,
436,
593,
21364,
1817,
14538,
1041,
199,
1579,
63,
815,
59,
272,
283,
1579,
63,
1802,
418,
275,
408,
2765,
2884,
6181,
282,
3414,
570,
436,
18628,
1006,
6661,
7124,
4012,
10015,
314,
593,
21364,
1817,
1041,
199,
199,
1579,
63,
815,
459,
1579,
63,
3807,
418,
275,
942,
199,
199,
1579,
63,
815,
459,
1579,
63,
3807,
2278,
740,
8,
272,
334,
624,
53,
429,
833,
2893,
7208,
1362,
408,
1918,
2569,
1414,
911,
1343,
376,
11284,
641,
5412,
83,
14,
2324,
65,
5868,
73,
395,
1314,
365,
282,
2963,
13,
1294,
63,
10159,
30544,
570,
14,
710,
3414,
14154,
315,
642,
570,
1077,
506,
402,
314,
1824,
665,
3271,
63,
344,
30,
27718,
3235,
63,
3610,
63,
344,
10827,
710,
2569,
7124,
12,
5226,
370,
314,
876,
13769,
695,
666,
876,
462,
425,
12,
787,
6781,
26,
16568,
477,
949,
2392,
593,
21364,
83,
737,
15997,
5,
27,
3732,
282,
2954,
1905,
3414,
367,
1924,
593,
21364,
334,
1589,
593,
21364,
27587,
3414,
2736,
6998,
314,
2954,
1905,
663,
543,
1611,
7170,
840,
27,
5090,
9067,
17293,
543,
314,
399,
429,
833,
406,
31664,
9067,
17293,
5090,
281,
27,
2457,
314,
13177,
6791,
370,
3123,
10015,
446,
2813,
12266,
1314,
787,
1006,
486,
7461,
12,
436,
2013,
465,
378,
315,
314,
634,
5865,
2629,
27,
1900,
282,
11831,
793,
6349,
764,
3123,
543,
22613,
3987,
27,
1900,
376,
593,
21364,
1817,
14,
2900,
1072,
1584,
911,
506,
5313,
370,
314,
2082,
2013,
701,
446,
79,
12,
436,
24799,
465,
5827,
14,
12112,
26194,
428,
7236,
18114,
437,
11087,
2228,
4586,
13024,
15097,
51,
334,
6116,
931,
11159,
2348,
465,
2672,
10780,
36,
12,
1325,
911,
16711,
3648,
6020,
2839,
1182,
4219,
15,
21151,
15,
1662,
63,
10466,
15,
680,
7208,
1362,
408,
5,
6595,
446,
73,
2672,
10780,
36,
15,
19467,
14,
2324,
65,
446,
79,
2672,
10780,
36,
15,
85,
429,
833,
63,
357,
527,
15,
624,
430,
199,
199,
1579,
63,
815,
459,
1579,
63,
3807,
2278,
740,
8,
272,
1689,
27032,
391,
1968,
833,
2893,
401,
1362,
298,
1918,
2569,
1414,
911,
1343,
376,
11284,
641,
5412,
83,
14,
2324,
65,
5868,
73,
395,
298,
1362,
298,
6777,
365,
282,
2963,
13,
1294,
63,
10159,
30544,
570,
14,
710,
3414,
14154,
298,
1362,
298,
262,
642,
570,
1077,
506,
402,
314,
1824,
665,
3271,
63,
344,
30,
27718,
3235,
63,
3610,
63,
344,
10827,
710,
298,
1362,
298,
21589,
7124,
12,
5226,
370,
314,
876,
13769,
695,
666,
876,
462,
425,
12,
298,
1362,
298,
1530,
6781,
26,
16568,
477,
949,
2392,
593,
21364,
83,
737,
15997,
5,
27,
3732,
282,
2954,
1905,
3414,
298,
1362,
298,
509,
1924,
593,
21364,
334,
1589,
593,
21364,
27587,
3414,
2736,
6998,
314,
2954,
1905,
663,
298,
1362,
298,
1045,
1611,
7170,
840,
27,
5090,
9067,
17293,
543,
314,
820,
11741,
406,
31664,
9067,
17293,
298,
1362,
298,
5038,
281,
27,
2457,
314,
13177,
6791,
370,
3123,
10015,
446,
2813,
298,
1362,
298,
12658,
1314,
787,
1006,
486,
7461,
12,
436,
2013,
465,
378,
315,
314,
634,
5865,
2629,
27,
298,
1362,
298,
1506,
282,
11831,
793,
6349,
764,
3123,
543,
22613,
3987,
27,
1900,
376,
593,
21364,
1817,
14,
2900,
298,
1362,
298,
1199,
1584,
911,
506,
5313,
370,
314,
2082,
2013,
701,
446,
79,
12,
436,
298,
1362,
298,
954,
12629,
465,
5827,
14,
12112,
26194,
428,
7236,
18114,
437,
11087,
2228,
4586,
13024,
15097,
51,
298,
1362,
7340,
6116,
931,
11159,
2348,
465,
2672,
10780,
36,
12,
1325,
911,
16711,
3648,
298,
1362,
298,
10297,
2839,
1182,
4219,
15,
21151,
15,
1662,
63,
10466,
15,
680,
3872,
1362,
2071,
6595,
446,
73,
2672,
10780,
36,
15,
19467,
14,
2324,
65,
446,
79,
2672,
10780,
36,
15,
9648,
391,
429,
833,
63,
357,
527,
15,
446,
80,
298,
1362,
7880,
10780,
36,
15,
9648,
391,
429,
833,
63,
1162,
14,
2424,
2237,
199,
199,
1579,
63,
815,
459,
1579,
63,
3807,
2278,
740,
8,
272,
1689,
51,
10669,
2893,
401,
1362,
298,
1918,
2569,
1414,
911,
1343,
376,
11284,
641,
5412,
83,
14,
2324,
65,
5868,
73,
395,
298,
1362,
298,
6777,
365,
282,
2963,
13,
1294,
63,
10159,
30544,
570,
14,
710,
3414,
14154,
298,
1362,
298,
262,
642,
570,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
HoboSci/OBIS-Capelin
|
Loop_on_date_python_script.py
|
1
|
16260
|
import os
import platform
import subprocess
import datetime as dt
import time
import calendar
import sys
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# General Parameters - Tools - Proxy Network - Output Directory
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Path declaration to the motu-client.py opensource-TOOLS to connect to MOTU CopernicusMarineHub.
# Input the 'motu-client.py' absolute path. By default, usually in "Downloads" dir. after having followed the article on "python basic requirements":
# http://marine.copernicus.eu/faq/what-are-the-motu-and-python-requirements/?idpage=169
motu_cl = 'C:/Users\Sam\Downloads/motu-client-python-1.5.00-20180223190259664-bin.tar/motu-client-python/motu-client.py'
# File to log unsuccessful data extraction request(s)
logfile = 'logfile.txt'
# Copernicus Marine API Key - Login Credentials
username_cmems = 'XXX'
password_cmems = 'XXX'
# Proxy Configuration
# Please replace "False" by "True" if you use a proxy to connect to internet and fill in the below variables.
proxy_flag = False
proxy_server_url = "http://your_proxy_address"
proxy_server_port = "8080"
proxy_user_login = "your_proxy_login"
proxy_user_password = "your_proxy_password"
# Output directory name to store the Copernicus Marine data - (do not use whitespace character)
# If only 'copernicus' is given (not in absolute path), then it will be converted automatically into '$HOME/copernicus/'
local_storage_directory_name = 'glorys_data'
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Product(s), Dataset(s) and MOTU server Parameters
# - - - - - - - - - - - - - - - - - - - - - - - - -
# CMEMS MOTU server ID & Service ID
# /!\ To find the information about the motu server name, you can simply rely on the "VIEW SCRIPT" button of the Copernicus Marine Online Catalogue (http://marine.copernicus.eu), using its DataExtraction WebInterface (also called GUI). It will generate the parameters based on your selection/extraction.
# Please refer to this article to understand how to call/trigger this webservice/feature to generate the right parameters : http://marine.copernicus.eu/faq/how-to-write-and-run-the-script-to-download-cmems-products-through-subset-or-direct-download-mechanisms/?idpage=169
# -m MOTU, --motu=MOTU the motu server to use (url)
# -s SERVICE_ID, --service-id=SERVICE_ID
# The service identifier (string)
motu_serv_id = "http://nrtcmems.mercator-ocean.fr/motu-web/Motu"
service_prod_id = "GLOBAL_ANALYSIS_FORECAST_PHY_001_025-TDS"
# CMEMS Dataset ID and Variables
# Define a dict to get {file name(Type_): [variable(-v), dataset(-d)]}
# (more details on how to get these parameters here http://bit.ly/2cUe9dT) - dead link
# /!\ Same comment as above. Please check this article for other examples : http://marine.copernicus.eu/faq/can-you-give-a-few-examples-of-command-lines-to-download/?idpage=169
# I would also highly recommend you to check this one to get an in-depth understanding of how it works
# (/!\ all CMEMS products are NOT hosted by a single server - they are grouped by product family, and you can always rely on the "VIEW SCRIPT" button to get the right parameters)
# -v VARIABLE, --variable=VARIABLE
# The variable (list of strings)
# -d PRODUCT_ID, --product-id=PRODUCT_ID
# The product (data set) to download (string)
dict_id = {"Northward-Velocity_dailymean": \
["-v vo", "-d global-analysis-forecast-phy-001-025"],\
"Temperature_hourly": \
["-v sea_water_potential_temperature", "-d global-analysis-forecast-phy-001-025-hourly-t-u-v-ssh"]
}
# And I can already image your next question : What if I'd like to download several variables from different datasets?
# Well, Let's take an example then !
# Let's say that you want to download from the daily dataset global-analysis-forecast-phy-001-024, the salinity, the Sea Surface Height, and the Temperature.
# And you also want to download the same variables (except salinity which is not available) for the hourly dataset global-analysis-forecast-phy-001-024-hourly-t-u-v-ssh.
# Then it will give us the following dictionary :
# (to use it, just uncomment the following lines - deleting the "#" at the beginning)
# dict_id = {"Salinity_daily_": \
# ["-v so", "-d global-analysis-forecast-phy-001-024"], \
# "SeaSurfaceHeight_daily_": \
# ["-v zos", "-d global-analysis-forecast-phy-001-024"], \
# "Temperature_daily_": \
# ["-v thetao", "-d global-analysis-forecast-phy-001-024"], \
# "SeaSurfaceHeight_hourly_": \
# ["-v zos", "-d global-analysis-forecast-phy-001-024-hourly-t-u-v-ssh"], \
# "Temperature_hourly_": \
# ["-v thetao", "-d global-analysis-forecast-phy-001-024-hourly-t-u-v-ssh"], \
# "Eastward-Velocity_dailymean_": \
# ["-v uo", "-d global-analysis-forecast-phy-001-024"]
# }
# - - - - - - - - - - - - - - - - - - - - - -
# Geographical Area Parameters and Timerange
# - - - - - - - - - - - - - - - - - - - - - -
# -y LATITUDE_MIN, --latitude-min=LATITUDE_MIN
# The min latitude (float in the interval [-90 ; 90])
# -Y LATITUDE_MAX, --latitude-max=LATITUDE_MAX
# The max latitude (float in the interval [-90 ; 90])
# -x LONGITUDE_MIN, --longitude-min=LONGITUDE_MIN
# The min longitude (float in the interval [-180 ; 180])
# -X LONGITUDE_MAX, --longitude-max=LONGITUDE_MAX
# The max longitude (float in the interval [-180 ; 180])
# -z DEPTH_MIN, --depth-min=DEPTH_MIN
# The min depth (float in the interval [0 ; 2e31] or
# string 'Surface')
# -Z DEPTH_MAX, --depth-max=DEPTH_MAX
# The max depth (float in the interval [0 ; 2e31] or
# string 'Surface')
# Area : x east-west longitude, y north-south latitude, z depth
xmin_longitude = "-45"
xmax_longitude = "-20"
ymin_latitude = "57"
ymax_latitude = "61"
zmin_depth = "0.494"
zmax_depth = "0.4942"
# Date - Timerange
yyyystart = 2007
mmstart = 01
yyyyend = 2007
mmend = 12
hhstart = " 12:00:00"
hhend = " 12:00:00"
dd = 1
# Output files
out_path= "C:\Users\Sam\Downloads\glorys_data"
pre_name= "TestPythonExtr_"
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Main Program
#
# Motu Client Call through Python Loop
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Specific comment For WINDOWS USER:
# If you're using this script for the first time, you
# shouldn't be worried by the following. Just save your
# script (ctrl + s), quit (alt + F4) and launch it
# (WinKey + R then input cmd then ENTER) by typing
# "C:\Python27\python script_name.py"
#
# For users, be careful if you have to modify the lines below.
# CMEMS Central Service Desk will be happy to help you
# either via email (servicedesk.cmems@mercator-ocean.eu)
# or via the CMEMS Forum (http://bit.ly/1L1Iy5f)
# Get PYTHON PATH depending on OS
if platform.system() == "Windows":
PYTHON = "C:/Python27/ArcGIS10.2/python.exe"
else:
PYTHON = "/usr/bin/python"
# Check motu-client.py file exists
if not os.path.exists(motu_cl):
print "\n[ERROR] Path to motu-client.py cannot be found: %s\n\n[INFO] Please correct value of 'motu_cl' variable."%motu_cl
print "\n\n[INFO] If you haven't downloaded the motu-client-python yet, get the latest version here:\nhttps://github.com/clstoulouse/motu-client-python/releases/latest\n"
sys.exit()
# Check if output directory is well formated and if it exists, otherwise create it
absolute_path_substring = ['/home/', 'C:\\']
if local_storage_directory_name[-1] != '/':
local_storage_directory_name = local_storage_directory_name + "/"
if not any(x in local_storage_directory_name for x in absolute_path_substring):
local_storage_directory_name = os.path.expanduser('~') + "/" + local_storage_directory_name
if not os.path.exists(local_storage_directory_name):
os.makedirs(local_storage_directory_name)
# Flags to let the server clears the buffer - better to be respectful when retrieving OPEN data
buffer_flag = False
cmd_flag = False
# Error Handle on dates (to illustrate an if statement >)
if yyyystart>yyyyend:
print "[ERROR] in [Date Parameters]"
print """Please double check your date parameters, specifically the "yyyystart" which is currently greater than "yyyyend."""
print """End of data extraction service."""
sys.exit()
# Other variable definitions to be compatible with deprecated script versions still available on the Internet
pre_name = "CMEMS_" + (serv_id.split()[1]).split("-")[0] + "_"
log_cmems = "-u " + username_cmems
pwd_cmems = "-p " + password_cmems
motu_id = "-m " + motu_serv_id
serv_id = "-s " + service_prod_id
pre_fic_cmd = "-f "+ pre_name
out_cmd = "-o " + local_storage_directory_name
proxy_user = "--proxy-user " + proxy_user_login
proxy_pwd = "--proxy-pwd " + proxy_user_password
proxy_server = "--proxy-server " + proxy_server_url + ":" + proxy_server_port
xmin = "-x " + xmin_longitude
xmax = "-X " + xmax_longitude
ymin = "-y " + ymin_latitude
ymax = "-Y " + ymax_latitude
zmin = "-z " + zmin_depth
zmax = "-Z " + zmax_depth
# To illustrate a simple Error Handle to delete a file when desired
#try:
# os.remove(out_cmd.split()[1] + logfile)
#except OSError:
# print ""
print"\n+----------------------------+\n| ! - CONNEXION TO CMEMS HUB |\n+----------------------------+\n\n"
# To illustrate a For_Loop in order to generate download requests for several datasets held in a product
#for key, value in dict_id.iteritems():
# if buffer_flag:
# print "Little pause to let the server clearing the buffer, it will automatically resume once it's completed.\nNot mandatory but server-friendly <span class="Emoticon Emoticon1"><span>:-)</span></span>\n"
# time.sleep(2)
# buffer_flag = False
# Date declaration
date_start = dt.datetime(yyyystart,mmstart,dd,0,0)
date_end = dt.datetime(yyyyend,mmend,dd,0,0)
# To illustrate a While_Loop in order to extract dailymean data, packed by month (Jan., Fev., Mar. etc...),
# for as many download requests as number of months available in the timerange.
while (date_start<=date_end):
date_end_cmd = (dt.datetime(date_start.year, date_start.month,\
calendar.monthrange(date_start.year, date_start.month)[1]))
date_cmd = ' -t \"' + date_start.strftime("%Y-%m-%d") + hhstart + '\"'\
+' -T \"' + date_end_cmd.strftime("%Y-%m-%d") + hhend + '\"'
fic_cmd = pre_fic_cmd + key + "_" + date_end_cmd.strftime("%Y-%m") + ".nc"
ficout = pre_name + key + "_" + date_end_cmd.strftime("%Y-%m") + ".nc"
print "----------------------------------\n- ! - Processing dataset request : %s"%ficout
print "----------------------------------\n"
if not os.path.exists(out_cmd.split()[1] + ficout):
if proxy_flag:
if not zmin_depth:
cmd = ' '.join([PYTHON, motu_cl, log_cmems, pwd_cmems,\
motu_id, serv_id, value[1],\
xmin, xmax, ymin, ymax,\
date_cmd, value[0], out_cmd, fic_cmd,\
proxy_server, proxy_user, proxy_pwd, "-q"])
else:
cmd = ' '.join([PYTHON, motu_cl, log_cmems, pwd_cmems,\
motu_id, serv_id, value[1],\
xmin, xmax, ymin, ymax, zmin, zmax,\
date_cmd, value[0], out_cmd, fic_cmd,\
proxy_server, proxy_user, proxy_pwd, "-q"])
else:
if not zmin_depth:
cmd = ' '.join([PYTHON, motu_cl, log_cmems, pwd_cmems,\
motu_id, serv_id, value[1],\
xmin, xmax, ymin, ymax,\
date_cmd, value[0], out_cmd, fic_cmd, "-q"])
else:
cmd = ' '.join([PYTHON, motu_cl, log_cmems, pwd_cmems,\
motu_id, serv_id, value[1],\
xmin, xmax, ymin, ymax, zmin, zmax,\
date_cmd, value[0], out_cmd, fic_cmd, "-q"])
print "## MOTU API COMMAND ##"
print cmd
print "\n[INFO] CMEMS server is checking both your credentials and command syntax. If successful, it will extract the data and create your dataset on the fly. Please wait. \n"
subpro=subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
message,erreur = subpro.communicate()
stat = subpro.returncode
if stat != 0:
print "-- ERROR Incorrect Credentials :\n %s"%message
with open(out_cmd.split()[1] + logfile,'a') as mylog:
mylog.write("Error : %s NOK\nDue to : %s"%(ficout,message))
if 'HTTP Error 400' in message:
print '''[INFO] Copernicus Marine USERNAME ('username_cmems') and/or PASSWORD ('password_cmems') are incorrect.\n\n[INFO] To execute the MOTU API COMMAND from your shell/terminal, please note the following rules:\n
On *nix OS, you must use the single quote, otherwise it may expand specific characters.
[...] -u 'string' or --user='string' [...]\n
On Windows OS, you must use the double quote, because single quotes are treated literally.
[...] -p "string" or --pwd="string" [...]\n'''
sys.exit()
if 'HTTP Error 407' in message:
print '''[INFO] Proxy Authentication Required to connect to the Central Authentication System https://cmems-cas.cls.fr/cas/login\n\n[INFO] Check the value of proxy_flag (it should be True).\n\n[INFO] Double check your proxy settings:\n --proxy-server=PROXY_SERVER\n the proxy server (url)\n --proxy-user=PROXY_USER\n the proxy user (string)\n --proxy-pwd=PROXY_PWD\n the proxy password (string)\n\n[INFO] If your proxy credentials are correct but your proxy password (string) contains a '@' then replace it by '%%40' '''
print '''[INFO] This issue is raised due either a misconfiguration in proxy settings or a network issue. If it persists, please contact your network administrator.'''
sys.exit()
print """[INFO] Failed data extraction has been logged.\n"""
else:
if "[ERROR]" in message:
print "-- ERROR Downloading command :\n %s"%message
with open(out_cmd.split()[1] + logfile,'a') as mylog:
mylog.write("Error : %s NOK\nDue to : %s"%(ficout,message))
print """[INFO] Failed data extraction has been logged.\n"""
else:
print "-- MOTU Download successful :\n %s OK\n"%fic_cmd.split()[1]
cmd_flag = True
else:
print "-- This data for %s has already been downloaded in %s --\n"% (fic_cmd.split()[1],out_cmd.split()[1])
cmd_flag = False
date_start = date_end_cmd + dt.timedelta(days=1)
if cmd_flag:
buffer_flag = True
cmd_flag = False
if not os.path.exists(out_cmd.split()[1]+logfile):
print "\n------------------------------------------------\n - ! - Your Copernicus Dataset(s) are located in %s\n------------------------------------------------\n"%(out_cmd.split()[1])
else :
print "## [ERROR] ##"
print "/!\\ Some download requests failed. Please see recommendation in %s%s"%(out_cmd.split()[1], logfile)
print "+--------------------------------------------+\n| ! - CONNEXION TO CMEMS HUB HAS BEEN CLOSED |\n+--------------------------------------------+\n"
#------------------------------------------------- End of Script -----------------------------------------------------
|
mit
|
[
646,
747,
199,
646,
4298,
199,
646,
3873,
199,
646,
2197,
465,
4487,
199,
646,
900,
199,
646,
11234,
199,
646,
984,
199,
199,
3,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
199,
3,
1696,
3897,
446,
23228,
446,
12373,
7220,
446,
7242,
15191,
199,
3,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
421,
199,
3,
6912,
12560,
370,
314,
333,
357,
85,
13,
1258,
14,
647,
1551,
1365,
13,
20261,
370,
4907,
370,
603,
1387,
53,
445,
2262,
12165,
527,
10570,
1132,
15338,
14,
199,
3,
6924,
314,
283,
30034,
85,
13,
1258,
14,
647,
7,
3679,
931,
14,
4885,
849,
12,
9987,
315,
298,
3514,
3640,
2,
2935,
14,
2410,
9445,
9437,
314,
9772,
641,
298,
1548,
5678,
9760,
582,
199,
3,
1455,
921,
4584,
1132,
14,
331,
529,
12165,
527,
14,
16913,
15,
667,
81,
15,
10058,
13,
1530,
13,
1589,
13,
30034,
85,
13,
460,
13,
1548,
13,
7538,
10197,
344,
1606,
29,
10143,
199,
30034,
85,
63,
429,
275,
283,
35,
11254,
12117,
60,
51,
455,
60,
3514,
3640,
15,
30034,
85,
13,
1258,
13,
1548,
13,
17,
14,
21,
14,
383,
13,
1797,
11366,
1789,
12205,
821,
2534,
772,
13,
1393,
14,
5369,
15,
30034,
85,
13,
1258,
13,
1548,
15,
30034,
85,
13,
1258,
14,
647,
7,
421,
199,
3,
3814,
370,
943,
625,
18157,
666,
19967,
1056,
8,
83,
9,
199,
12804,
275,
283,
12804,
14,
2424,
7,
199,
199,
3,
445,
2262,
12165,
527,
16794,
1132,
3261,
2606,
446,
16430,
23934,
199,
2473,
63,
67,
278,
706,
275,
283,
13933,
7,
199,
2060,
63,
67,
278,
706,
275,
283,
13933,
7,
199,
199,
3,
12373,
11595,
199,
3,
7754,
3350,
298,
797,
2,
701,
298,
549,
2,
340,
1265,
675,
282,
4566,
370,
4907,
370,
21408,
436,
5554,
315,
314,
5084,
2860,
14,
199,
3280,
63,
4173,
275,
756,
199,
3280,
63,
1000,
63,
633,
275,
298,
1014,
921,
12695,
63,
3280,
63,
1562,
2,
199,
3280,
63,
1000,
63,
719,
275,
298,
15844,
2,
199,
3280,
63,
751,
63,
2886,
275,
298,
12695,
63,
3280,
63,
2886,
2,
199,
3280,
63,
751,
63,
2060,
275,
298,
12695,
63,
3280,
63,
2060,
2,
199,
199,
3,
7242,
2082,
536,
370,
3877,
314,
445,
2262,
12165,
527,
16794,
1132,
666,
446,
334,
1117,
440,
675,
8139,
4528,
9,
199,
3,
982,
1454,
283,
331,
529,
12165,
527,
7,
365,
1627,
334,
1397,
315,
3679,
931,
395,
2066,
652,
911,
506,
6702,
5847,
1901,
4505,
9524,
15,
331,
529,
12165,
527,
4805,
199,
1832,
63,
3494,
63,
3619,
63,
354,
275,
283,
3528,
269,
588,
63,
576,
7,
199,
199,
3,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
199,
3,
12705,
8,
83,
395,
20284,
8,
83,
9,
436,
603,
1387,
53,
1654,
3897,
199,
3,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
199,
199,
3,
445,
10293,
51,
603,
1387,
53,
1654,
2870,
1253,
7591,
2870,
199,
3,
1182,
12525,
4005,
2342,
314,
2556,
3595,
314,
333,
357,
85,
1654,
536,
12,
1265,
883,
9329,
19687,
641,
314,
298,
12058,
30203,
2,
5528,
402,
314,
445,
2262,
12165,
527,
16794,
1132,
4068,
604,
22881,
310,
334,
1014,
921,
4584,
1132,
14,
331,
529,
12165,
527,
14,
16913,
395,
1808,
2399,
3918,
4942,
6156,
6001,
4267,
334,
12344,
2797,
17160,
680,
2779,
911,
3550,
314,
2633,
4079,
641,
2195,
7267,
15,
24020,
14,
199,
3,
7754,
10618,
370,
642,
9772,
370,
20647,
4212,
370,
1240,
15,
7631,
642,
3330,
1364,
15,
4445,
370,
3550,
314,
2451,
2633,
520,
1455,
921,
4584,
1132,
14,
331,
529,
12165,
527,
14,
16913,
15,
667,
81,
15,
1917,
13,
475,
13,
952,
13,
460,
13,
1065,
13,
1589,
13,
1579,
13,
475,
13,
4249,
13,
67,
278,
706,
13,
13336,
13,
8304,
13,
9401,
13,
269,
13,
2275,
13,
4249,
13,
278,
10832,
706,
10197,
344,
1606,
29,
10143,
199,
3,
10619,
446,
77,
603,
1387,
53,
12,
1553,
30034,
85,
29,
27235,
53,
10619,
314,
333,
357,
85,
1654,
370,
675,
334,
633,
9,
199,
3,
10619,
446,
83,
16655,
63,
998,
12,
1553,
1364,
13,
344,
29,
10486,
63,
998,
199,
3,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
710,
2435,
5148,
334,
875,
9,
199,
30034,
85,
63,
7297,
63,
344,
275,
298,
1014,
921,
78,
23392,
278,
706,
14,
278,
1195,
707,
13,
31737,
14,
4391,
15,
30034,
85,
13,
2520,
15,
45,
357,
85,
2,
199,
1364,
63,
8788,
63,
344,
275,
298,
13808,
63,
31158,
20238,
1311,
63,
18155,
18898,
63,
9791,
57,
63,
4587,
63,
18823,
13,
52,
3177,
2,
199,
199,
3,
445,
10293,
51,
20284,
2870,
436,
17198,
199,
3,
13930,
282,
1211,
370,
664,
469,
493,
536,
8,
804,
7822,
359,
1975,
2801,
86,
395,
4789,
2801,
68,
1874,
93,
199,
3,
334,
6878,
2436,
641,
4212,
370,
664,
3520,
2633,
2348,
1455,
921,
2075,
14,
590,
15,
18,
67,
53,
69,
25,
19772,
9,
446,
12314,
2142,
199,
3,
1182,
12525,
14766,
3721,
465,
3432,
14,
7754,
1104,
642,
9772,
367,
1163,
7251,
520,
1455,
921,
4584,
1132,
14,
331,
529,
12165,
527,
14,
16913,
15,
667,
81,
15,
2425,
13,
13297,
13,
26035,
13,
65,
13,
70,
546,
13,
8589,
13,
1618,
13,
1531,
13,
1278,
13,
475,
13,
4249,
10197,
344,
1606,
29,
10143,
199,
3,
473,
3955,
2597,
4721,
590,
27747,
1265,
370,
1104,
642,
1373,
370,
664,
376,
315,
13,
4631,
1334,
18126,
402,
4212,
652,
5419,
199,
3,
334,
15,
12525,
1006,
445,
10293,
51,
7585,
787,
2845,
28311,
701,
282,
2849,
1654
] |
[
747,
199,
646,
4298,
199,
646,
3873,
199,
646,
2197,
465,
4487,
199,
646,
900,
199,
646,
11234,
199,
646,
984,
199,
199,
3,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
199,
3,
1696,
3897,
446,
23228,
446,
12373,
7220,
446,
7242,
15191,
199,
3,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
421,
199,
3,
6912,
12560,
370,
314,
333,
357,
85,
13,
1258,
14,
647,
1551,
1365,
13,
20261,
370,
4907,
370,
603,
1387,
53,
445,
2262,
12165,
527,
10570,
1132,
15338,
14,
199,
3,
6924,
314,
283,
30034,
85,
13,
1258,
14,
647,
7,
3679,
931,
14,
4885,
849,
12,
9987,
315,
298,
3514,
3640,
2,
2935,
14,
2410,
9445,
9437,
314,
9772,
641,
298,
1548,
5678,
9760,
582,
199,
3,
1455,
921,
4584,
1132,
14,
331,
529,
12165,
527,
14,
16913,
15,
667,
81,
15,
10058,
13,
1530,
13,
1589,
13,
30034,
85,
13,
460,
13,
1548,
13,
7538,
10197,
344,
1606,
29,
10143,
199,
30034,
85,
63,
429,
275,
283,
35,
11254,
12117,
60,
51,
455,
60,
3514,
3640,
15,
30034,
85,
13,
1258,
13,
1548,
13,
17,
14,
21,
14,
383,
13,
1797,
11366,
1789,
12205,
821,
2534,
772,
13,
1393,
14,
5369,
15,
30034,
85,
13,
1258,
13,
1548,
15,
30034,
85,
13,
1258,
14,
647,
7,
421,
199,
3,
3814,
370,
943,
625,
18157,
666,
19967,
1056,
8,
83,
9,
199,
12804,
275,
283,
12804,
14,
2424,
7,
199,
199,
3,
445,
2262,
12165,
527,
16794,
1132,
3261,
2606,
446,
16430,
23934,
199,
2473,
63,
67,
278,
706,
275,
283,
13933,
7,
199,
2060,
63,
67,
278,
706,
275,
283,
13933,
7,
199,
199,
3,
12373,
11595,
199,
3,
7754,
3350,
298,
797,
2,
701,
298,
549,
2,
340,
1265,
675,
282,
4566,
370,
4907,
370,
21408,
436,
5554,
315,
314,
5084,
2860,
14,
199,
3280,
63,
4173,
275,
756,
199,
3280,
63,
1000,
63,
633,
275,
298,
1014,
921,
12695,
63,
3280,
63,
1562,
2,
199,
3280,
63,
1000,
63,
719,
275,
298,
15844,
2,
199,
3280,
63,
751,
63,
2886,
275,
298,
12695,
63,
3280,
63,
2886,
2,
199,
3280,
63,
751,
63,
2060,
275,
298,
12695,
63,
3280,
63,
2060,
2,
199,
199,
3,
7242,
2082,
536,
370,
3877,
314,
445,
2262,
12165,
527,
16794,
1132,
666,
446,
334,
1117,
440,
675,
8139,
4528,
9,
199,
3,
982,
1454,
283,
331,
529,
12165,
527,
7,
365,
1627,
334,
1397,
315,
3679,
931,
395,
2066,
652,
911,
506,
6702,
5847,
1901,
4505,
9524,
15,
331,
529,
12165,
527,
4805,
199,
1832,
63,
3494,
63,
3619,
63,
354,
275,
283,
3528,
269,
588,
63,
576,
7,
199,
199,
3,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
199,
3,
12705,
8,
83,
395,
20284,
8,
83,
9,
436,
603,
1387,
53,
1654,
3897,
199,
3,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
446,
199,
199,
3,
445,
10293,
51,
603,
1387,
53,
1654,
2870,
1253,
7591,
2870,
199,
3,
1182,
12525,
4005,
2342,
314,
2556,
3595,
314,
333,
357,
85,
1654,
536,
12,
1265,
883,
9329,
19687,
641,
314,
298,
12058,
30203,
2,
5528,
402,
314,
445,
2262,
12165,
527,
16794,
1132,
4068,
604,
22881,
310,
334,
1014,
921,
4584,
1132,
14,
331,
529,
12165,
527,
14,
16913,
395,
1808,
2399,
3918,
4942,
6156,
6001,
4267,
334,
12344,
2797,
17160,
680,
2779,
911,
3550,
314,
2633,
4079,
641,
2195,
7267,
15,
24020,
14,
199,
3,
7754,
10618,
370,
642,
9772,
370,
20647,
4212,
370,
1240,
15,
7631,
642,
3330,
1364,
15,
4445,
370,
3550,
314,
2451,
2633,
520,
1455,
921,
4584,
1132,
14,
331,
529,
12165,
527,
14,
16913,
15,
667,
81,
15,
1917,
13,
475,
13,
952,
13,
460,
13,
1065,
13,
1589,
13,
1579,
13,
475,
13,
4249,
13,
67,
278,
706,
13,
13336,
13,
8304,
13,
9401,
13,
269,
13,
2275,
13,
4249,
13,
278,
10832,
706,
10197,
344,
1606,
29,
10143,
199,
3,
10619,
446,
77,
603,
1387,
53,
12,
1553,
30034,
85,
29,
27235,
53,
10619,
314,
333,
357,
85,
1654,
370,
675,
334,
633,
9,
199,
3,
10619,
446,
83,
16655,
63,
998,
12,
1553,
1364,
13,
344,
29,
10486,
63,
998,
199,
3,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
10619,
710,
2435,
5148,
334,
875,
9,
199,
30034,
85,
63,
7297,
63,
344,
275,
298,
1014,
921,
78,
23392,
278,
706,
14,
278,
1195,
707,
13,
31737,
14,
4391,
15,
30034,
85,
13,
2520,
15,
45,
357,
85,
2,
199,
1364,
63,
8788,
63,
344,
275,
298,
13808,
63,
31158,
20238,
1311,
63,
18155,
18898,
63,
9791,
57,
63,
4587,
63,
18823,
13,
52,
3177,
2,
199,
199,
3,
445,
10293,
51,
20284,
2870,
436,
17198,
199,
3,
13930,
282,
1211,
370,
664,
469,
493,
536,
8,
804,
7822,
359,
1975,
2801,
86,
395,
4789,
2801,
68,
1874,
93,
199,
3,
334,
6878,
2436,
641,
4212,
370,
664,
3520,
2633,
2348,
1455,
921,
2075,
14,
590,
15,
18,
67,
53,
69,
25,
19772,
9,
446,
12314,
2142,
199,
3,
1182,
12525,
14766,
3721,
465,
3432,
14,
7754,
1104,
642,
9772,
367,
1163,
7251,
520,
1455,
921,
4584,
1132,
14,
331,
529,
12165,
527,
14,
16913,
15,
667,
81,
15,
2425,
13,
13297,
13,
26035,
13,
65,
13,
70,
546,
13,
8589,
13,
1618,
13,
1531,
13,
1278,
13,
475,
13,
4249,
10197,
344,
1606,
29,
10143,
199,
3,
473,
3955,
2597,
4721,
590,
27747,
1265,
370,
1104,
642,
1373,
370,
664,
376,
315,
13,
4631,
1334,
18126,
402,
4212,
652,
5419,
199,
3,
334,
15,
12525,
1006,
445,
10293,
51,
7585,
787,
2845,
28311,
701,
282,
2849,
1654,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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