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
tswast/google-cloud-python
bigquery/samples/undelete_table.py
2
2396
# Copyright 2019 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from google.api_core import datetime_helpers def undelete_table(table_id, recovered_table_id): # [START bigquery_undelete_table] import time from google.cloud import bigquery # Construct a BigQuery client object. client = bigquery.Client() # TODO(developer): Choose a table to recover. # table_id = "your-project.your_dataset.your_table" # TODO(developer): Choose a new table ID for the recovered table data. # recovery_table_id = "your-project.your_dataset.your_table_recovered" # TODO(developer): Choose an appropriate snapshot point as epoch # milliseconds. For this example, we choose the current time as we're about # to delete the table immediately afterwards. snapshot_epoch = int(time.time() * 1000) # [START_EXCLUDE] # Due to very short lifecycle of the table, ensure we're not picking a time # prior to the table creation due to time drift between backend and client. table = client.get_table(table_id) created_epoch = datetime_helpers.to_milliseconds(table.created) if created_epoch > snapshot_epoch: snapshot_epoch = created_epoch # [END_EXCLUDE] # "Accidentally" delete the table. client.delete_table(table_id) # Make an API request. # Construct the restore-from table ID using a snapshot decorator. snapshot_table_id = "{}@{}".format(table_id, snapshot_epoch) # Construct and run a copy job. job = client.copy_table( snapshot_table_id, recovered_table_id, # Must match the source and destination tables location. location="US", ) # Make an API request. job.result() # Wait for the job to complete. print( "Copied data from deleted table {} to {}".format(table_id, recovered_table_id) ) # [END bigquery_undelete_table]
apache-2.0
[ 3, 1898, 20312, 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, 4178, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 6233, 14, 1246, 63, 1018, 492, 2197, 63, 7546, 421, 199, 318, 625, 1807, 63, 1224, 8, 1224, 63, 344, 12, 295, 13560, 63, 1224, 63, 344, 304, 272, 327, 359, 7363, 7282, 1131, 63, 324, 1807, 63, 1224, 61, 272, 492, 900, 339, 687, 6233, 14, 4091, 492, 7282, 1131, 339, 327, 9215, 282, 13123, 3227, 1890, 909, 14, 272, 1890, 275, 7282, 1131, 14, 3041, 342, 339, 327, 3254, 8, 11071, 304, 29826, 282, 1817, 370, 22803, 14, 272, 327, 1817, 63, 344, 275, 298, 12695, 13, 1715, 14, 12695, 63, 5214, 14, 12695, 63, 1224, 2, 339, 327, 3254, 8, 11071, 304, 29826, 282, 892, 1817, 2870, 367, 314, 295, 13560, 1817, 666, 14, 272, 327, 24201, 63, 1224, 63, 344, 275, 298, 12695, 13, 1715, 14, 12695, 63, 5214, 14, 12695, 63, 1224, 63, 264, 13560, 2, 339, 327, 3254, 8, 11071, 304, 29826, 376, 5827, 5740, 2376, 465, 9463, 272, 327, 21131, 14, 2104, 642, 2893, 12, 781, 11496, 314, 1453, 900, 465, 781, 3984, 3595, 272, 327, 370, 3145, 314, 1817, 9939, 26982, 14, 272, 5740, 63, 7367, 275, 1109, 8, 521, 14, 521, 342, 627, 5198, 9, 339, 327, 359, 7363, 63, 1438, 13958, 61, 272, 327, 25855, 370, 7437, 3974, 15451, 7612, 402, 314, 1817, 12, 4868, 781, 3984, 440, 12433, 282, 900, 272, 327, 6791, 370, 314, 1817, 7143, 7037, 370, 900, 366, 6501, 3382, 4865, 436, 1890, 14, 272, 1817, 275, 1890, 14, 362, 63, 1224, 8, 1224, 63, 344, 9, 272, 2737, 63, 7367, 275, 2197, 63, 7546, 14, 475, 63, 19579, 4515, 8, 1224, 14, 3966, 9, 272, 340, 2737, 63, 7367, 690, 5740, 63, 7367, 26, 267, 5740, 63, 7367, 275, 2737, 63, 7367, 272, 327, 359, 3902, 63, 1438, 13958, 61, 339, 327, 298, 1945, 12689, 1183, 2, 3145, 314, 1817, 14, 272, 1890, 14, 1807, 63, 1224, 8, 1224, 63, 344, 9, 221, 327, 4155, 376, 3261, 1056, 14, 339, 327, 9215, 314, 9066, 13, 504, 1817, 2870, 1808, 282, 5740, 7531, 14, 272, 5740, 63, 1224, 63, 344, 275, 11491, 32, 13536, 908, 8, 1224, 63, 344, 12, 5740, 63, 7367, 9, 339, 327, 9215, 436, 1255, 282, 1331, 3906, 14, 272, 3906, 275, 1890, 14, 1574, 63, 1224, 8, 267, 5740, 63, 1224, 63, 344, 12, 267, 295, 13560, 63, 1224, 63, 344, 12, 267, 327, 9498, 1336, 314, 1350, 436, 5724, 6716, 2909, 14, 267, 2909, 628, 1668, 401, 272, 776, 221, 327, 4155, 376, 3261, 1056, 14, 339, 3906, 14, 1099, 342, 221, 327, 13144, 367, 314, 3906, 370, 4890, 14, 339, 870, 8, 267, 298, 18268, 5299, 666, 687, 5463, 1817, 1052, 370, 8352, 908, 8, 1224, 63, 344, 12, 295, 13560, 63, 1224, 63, 344, 9, 272, 776, 272, 327, 359, 3902, 7282, 1131, 63, 324, 1807, 63, 1224, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 20312, 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, 4178, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 6233, 14, 1246, 63, 1018, 492, 2197, 63, 7546, 421, 199, 318, 625, 1807, 63, 1224, 8, 1224, 63, 344, 12, 295, 13560, 63, 1224, 63, 344, 304, 272, 327, 359, 7363, 7282, 1131, 63, 324, 1807, 63, 1224, 61, 272, 492, 900, 339, 687, 6233, 14, 4091, 492, 7282, 1131, 339, 327, 9215, 282, 13123, 3227, 1890, 909, 14, 272, 1890, 275, 7282, 1131, 14, 3041, 342, 339, 327, 3254, 8, 11071, 304, 29826, 282, 1817, 370, 22803, 14, 272, 327, 1817, 63, 344, 275, 298, 12695, 13, 1715, 14, 12695, 63, 5214, 14, 12695, 63, 1224, 2, 339, 327, 3254, 8, 11071, 304, 29826, 282, 892, 1817, 2870, 367, 314, 295, 13560, 1817, 666, 14, 272, 327, 24201, 63, 1224, 63, 344, 275, 298, 12695, 13, 1715, 14, 12695, 63, 5214, 14, 12695, 63, 1224, 63, 264, 13560, 2, 339, 327, 3254, 8, 11071, 304, 29826, 376, 5827, 5740, 2376, 465, 9463, 272, 327, 21131, 14, 2104, 642, 2893, 12, 781, 11496, 314, 1453, 900, 465, 781, 3984, 3595, 272, 327, 370, 3145, 314, 1817, 9939, 26982, 14, 272, 5740, 63, 7367, 275, 1109, 8, 521, 14, 521, 342, 627, 5198, 9, 339, 327, 359, 7363, 63, 1438, 13958, 61, 272, 327, 25855, 370, 7437, 3974, 15451, 7612, 402, 314, 1817, 12, 4868, 781, 3984, 440, 12433, 282, 900, 272, 327, 6791, 370, 314, 1817, 7143, 7037, 370, 900, 366, 6501, 3382, 4865, 436, 1890, 14, 272, 1817, 275, 1890, 14, 362, 63, 1224, 8, 1224, 63, 344, 9, 272, 2737, 63, 7367, 275, 2197, 63, 7546, 14, 475, 63, 19579, 4515, 8, 1224, 14, 3966, 9, 272, 340, 2737, 63, 7367, 690, 5740, 63, 7367, 26, 267, 5740, 63, 7367, 275, 2737, 63, 7367, 272, 327, 359, 3902, 63, 1438, 13958, 61, 339, 327, 298, 1945, 12689, 1183, 2, 3145, 314, 1817, 14, 272, 1890, 14, 1807, 63, 1224, 8, 1224, 63, 344, 9, 221, 327, 4155, 376, 3261, 1056, 14, 339, 327, 9215, 314, 9066, 13, 504, 1817, 2870, 1808, 282, 5740, 7531, 14, 272, 5740, 63, 1224, 63, 344, 275, 11491, 32, 13536, 908, 8, 1224, 63, 344, 12, 5740, 63, 7367, 9, 339, 327, 9215, 436, 1255, 282, 1331, 3906, 14, 272, 3906, 275, 1890, 14, 1574, 63, 1224, 8, 267, 5740, 63, 1224, 63, 344, 12, 267, 295, 13560, 63, 1224, 63, 344, 12, 267, 327, 9498, 1336, 314, 1350, 436, 5724, 6716, 2909, 14, 267, 2909, 628, 1668, 401, 272, 776, 221, 327, 4155, 376, 3261, 1056, 14, 339, 3906, 14, 1099, 342, 221, 327, 13144, 367, 314, 3906, 370, 4890, 14, 339, 870, 8, 267, 298, 18268, 5299, 666, 687, 5463, 1817, 1052, 370, 8352, 908, 8, 1224, 63, 344, 12, 295, 13560, 63, 1224, 63, 344, 9, 272, 776, 272, 327, 359, 3902, 7282, 1131, 63, 324, 1807, 63, 1224, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
saddingtonbaynes/rez
src/rez/tests/test_shells.py
3
9971
""" test shell invocation """ from rez.system import system from rez.shells import create_shell from rez.resolved_context import ResolvedContext from rez.rex import RexExecutor, literal, expandable import rez.vendor.unittest2 as unittest from rez.tests.util import TestBase, TempdirMixin, shell_dependent, \ install_dependent from rez.util import which from rez.bind import hello_world from rez.utils.platform_ import platform_ import subprocess import tempfile import inspect import textwrap import os import sys def _stdout(proc): out_, _ = proc.communicate() return out_.strip() class TestShells(TestBase, TempdirMixin): @classmethod def setUpClass(cls): TempdirMixin.setUpClass() packages_path = os.path.join(cls.root, "packages") os.makedirs(packages_path) hello_world.bind(packages_path) cls.settings = dict( packages_path=[packages_path], package_filter=None, implicit_packages=[], warn_untimestamped=False) @classmethod def tearDownClass(cls): TempdirMixin.tearDownClass() @classmethod def _create_context(cls, pkgs): from rez.config import config return ResolvedContext(pkgs, caching=False) @shell_dependent(exclude=["cmd"]) def test_no_output(self): # TODO: issues with binding the 'hello_world' package means it is not # possible to run this test on Windows. The 'hello_world' executable # is not registered correctly on Windows so always returned the # incorrect error code. sh = create_shell() _, _, _, command = sh.startup_capabilities(command=True) if command: r = self._create_context(["hello_world"]) p = r.execute_shell(command="hello_world -q", stdout=subprocess.PIPE) self.assertEqual( _stdout(p), '', "This test and others will fail, because one or more of your " "startup scripts are printing to stdout. Please remove the " "printout and try again.") @shell_dependent(exclude=["cmd"]) def test_command(self): # TODO: issues with binding the 'hello_world' package means it is not # possible to run this test on Windows. The 'hello_world' executable # is not registered correctly on Windows so always returned the # incorrect error code. sh = create_shell() _, _, _, command = sh.startup_capabilities(command=True) if command: r = self._create_context(["hello_world"]) p = r.execute_shell(command="hello_world", stdout=subprocess.PIPE) self.assertEqual(_stdout(p), "Hello Rez World!") @shell_dependent(exclude=["cmd"]) def test_command_returncode(self): # TODO: issues with binding the 'hello_world' package means it is not # possible to run this test on Windows. The 'hello_world' executable # is not registered correctly on Windows so always returned the # incorrect error code. sh = create_shell() _, _, _, command = sh.startup_capabilities(command=True) if command: r = self._create_context(["hello_world"]) command = "hello_world -q -r 66" commands = (command, command.split()) for cmd in commands: p = r.execute_shell(command=cmd, stdout=subprocess.PIPE) p.wait() self.assertEqual(p.returncode, 66) @shell_dependent() def test_norc(self): sh = create_shell() _, norc, _, command = sh.startup_capabilities(norc=True, command=True) if norc and command: r = self._create_context(["hello_world"]) p = r.execute_shell(norc=True, command="hello_world", stdout=subprocess.PIPE) self.assertEqual(_stdout(p), "Hello Rez World!") @shell_dependent() def test_stdin(self): sh = create_shell() _, _, stdin, _ = sh.startup_capabilities(stdin=True) if stdin: r = self._create_context(["hello_world"]) p = r.execute_shell(stdout=subprocess.PIPE, stdin=subprocess.PIPE, norc=True) stdout, _ = p.communicate(input="hello_world\n") stdout = stdout.strip() self.assertEqual(stdout, "Hello Rez World!") @shell_dependent() def test_rcfile(self): sh = create_shell() rcfile, _, _, command = sh.startup_capabilities(rcfile=True, command=True) if rcfile and command: f, path = tempfile.mkstemp() os.write(f, "hello_world\n") os.close(f) r = self._create_context(["hello_world"]) p = r.execute_shell(rcfile=path, command="hello_world -q", stdout=subprocess.PIPE) self.assertEqual(_stdout(p), "Hello Rez World!") os.remove(path) @shell_dependent(exclude=["cmd"]) @install_dependent def test_rez_env_output(self): # TODO: this test does not run on Windows using the CMD shell as it # does not accept commands from stdin. Rather than explicitly skipping # the test (via the decorator) perhaps we should check for startup # capabilities as the other tests do. from rez.vendor.sh import sh # here we are making sure that running a command via rez-env prints # exactly what we expect. We use 'sh' because subprocess strips special # characters such as color codes - we want to ensure that the output # EXACTLY matches the output of the command being run. echo_cmd = which("echo") if not echo_cmd: print "\nskipping test, 'echo' command not found." return cmd = sh.Command(os.path.join(system.rez_bin_path, "rez-env")) sh_out = cmd(["--", "echo", "hey"]) out = str(sh_out).strip() self.assertEqual(out, "hey") @shell_dependent() @install_dependent def test_rez_command(self): sh = create_shell() _, _, _, command = sh.startup_capabilities(command=True) if command: r = self._create_context([]) p = r.execute_shell(command="rezolve -h") p.wait() self.assertEqual(p.returncode, 0) p = r.execute_shell(command="rez-env -h") p.wait() self.assertEqual(p.returncode, 0) @shell_dependent() def test_rex_code(self): """Test that Rex code run in the shell creates the environment variable values that we expect.""" def _execute_code(func, expected_output): loc = inspect.getsourcelines(func)[0][1:] code = textwrap.dedent('\n'.join(loc)) r = self._create_context([]) p = r.execute_rex_code(code, stdout=subprocess.PIPE) out, _ = p.communicate() self.assertEqual(p.returncode, 0) token = '\r\n' if platform_.name == 'windows' else '\n' output = out.strip().split(token) self.assertEqual(output, expected_output) def _rex_assigning(): import os windows = os.name == "nt" def _print(value): env.FOO = value info("%FOO%" if windows else "${FOO}") env.GREET = "hi" env.WHO = "Gary" _print("ello") _print(literal("ello")) _print(expandable("ello")) _print("\\") _print("\\'") _print("\\\"") _print(literal("\\")) _print(literal("\\'")) _print(literal("\\\"")) _print("\\path1\\path2\\path3") _print(literal("\\path1").e("\\path2\\path3")) _print("hello world") _print("hello 'world'") _print('hello "world"') _print(literal("hello world")) _print(literal("hello 'world'")) _print(literal('hello "world"')) _print("hey %WHO%" if windows else "hey $WHO") _print("hey %WHO%" if windows else "hey ${WHO}") _print(expandable("%GREET% " if windows else "${GREET} ").e("%WHO%" if windows else "$WHO")) _print(expandable("%GREET% " if windows else "${GREET} ").l("$WHO")) _print(literal("${WHO}")) _print(literal("${WHO}").e(" %WHO%" if windows else " $WHO")) expected_output = [ "ello", "ello", "ello", "\\", "\\'", "\\\"", "\\", "\\'", "\\\"", "\\path1\\path2\\path3", "\\path1\\path2\\path3", "hello world", "hello 'world'", 'hello "world"', "hello world", "hello 'world'", 'hello "world"', "hey Gary", "hey Gary", "hi Gary", "hi $WHO", "${WHO}", "${WHO} Gary" ] _execute_code(_rex_assigning, expected_output) def _rex_appending(): import os windows = os.name == "nt" env.FOO.append("hey") info("%FOO%" if windows else "${FOO}") env.FOO.append(literal("$DAVE")) info("%FOO%" if windows else "${FOO}") env.FOO.append("Dave's not here man") info("%FOO%" if windows else "${FOO}") expected_output = [ "hey", os.pathsep.join(["hey", "$DAVE"]), os.pathsep.join(["hey", "$DAVE", "Dave's not here man"]) ] _execute_code(_rex_appending, expected_output) if __name__ == '__main__': unittest.main()
gpl-3.0
[ 624, 199, 396, 5218, 19569, 199, 624, 199, 504, 295, 90, 14, 2253, 492, 2656, 199, 504, 295, 90, 14, 609, 6840, 492, 1218, 63, 5641, 199, 504, 295, 90, 14, 13697, 63, 1100, 492, 3591, 7064, 2998, 199, 504, 295, 90, 14, 15063, 492, 820, 476, 16752, 12, 8785, 12, 6544, 461, 199, 646, 295, 90, 14, 9884, 14, 2796, 18, 465, 2882, 199, 504, 295, 90, 14, 2219, 14, 1974, 492, 1379, 1563, 12, 12540, 694, 4256, 12, 5218, 63, 7106, 12, 971, 272, 3907, 63, 7106, 199, 504, 295, 90, 14, 1974, 492, 1314, 199, 504, 295, 90, 14, 3409, 492, 16509, 63, 7617, 199, 504, 295, 90, 14, 1208, 14, 3246, 63, 492, 4298, 63, 199, 646, 3873, 199, 646, 5549, 199, 646, 6485, 199, 646, 13390, 199, 646, 747, 199, 646, 984, 421, 199, 318, 485, 2703, 8, 4687, 304, 272, 734, 3131, 485, 275, 6499, 14, 10664, 342, 272, 372, 734, 3754, 1913, 342, 421, 199, 533, 1379, 2662, 6840, 8, 14440, 12, 12540, 694, 4256, 304, 272, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 12540, 694, 4256, 14, 27777, 342, 398, 6117, 63, 515, 275, 747, 14, 515, 14, 904, 8, 1886, 14, 1231, 12, 298, 5154, 531, 267, 747, 14, 8347, 8, 5154, 63, 515, 9, 267, 16509, 63, 7617, 14, 3409, 8, 5154, 63, 515, 9, 398, 843, 14, 1751, 275, 1211, 8, 288, 6117, 63, 515, 1524, 5154, 63, 515, 467, 288, 2559, 63, 1541, 29, 403, 12, 288, 9227, 63, 5154, 6034, 288, 7987, 63, 324, 3954, 379, 29, 797, 9, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 12540, 694, 4256, 14, 12336, 2543, 342, 339, 768, 3744, 272, 347, 485, 981, 63, 1100, 8, 1886, 12, 24162, 304, 267, 687, 295, 90, 14, 888, 492, 1101, 267, 372, 3591, 7064, 2998, 8, 16624, 12, 13627, 29, 797, 9, 339, 768, 5641, 63, 7106, 8, 5473, 6270, 1760, 3135, 272, 347, 511, 63, 889, 63, 1199, 8, 277, 304, 267, 327, 3254, 26, 10876, 543, 11696, 314, 283, 5006, 63, 7617, 7, 2559, 4910, 652, 365, 440, 267, 327, 3962, 370, 1255, 642, 511, 641, 5417, 14, 221, 710, 283, 5006, 63, 7617, 7, 7286, 267, 327, 365, 440, 7264, 6657, 641, 5417, 880, 3544, 2138, 314, 267, 327, 8927, 1125, 1233, 14, 267, 1033, 275, 1218, 63, 5641, 342, 267, 5501, 5501, 5501, 1414, 275, 1033, 14, 16480, 63, 10732, 8, 1531, 29, 549, 9, 267, 340, 1414, 26, 288, 519, 275, 291, 423, 981, 63, 1100, 5234, 5006, 63, 7617, 3135, 288, 299, 275, 519, 14, 2526, 63, 5641, 8, 1531, 628, 5006, 63, 7617, 446, 81, 401, 1816, 3839, 29, 5781, 14, 6089, 9, 953, 291, 14, 629, 8, 355, 485, 2703, 8, 80, 395, 3260, 355, 298, 2765, 511, 436, 11789, 911, 2449, 12, 2952, 1373, 503, 1655, 402, 2195, 298, 355, 298, 16480, 10554, 787, 16116, 370, 3839, 14, 7754, 2813, 314, 298, 355, 298, 1361, 548, 436, 862, 4020, 2685, 339, 768, 5641, 63, 7106, 8, 5473, 6270, 1760, 3135, 272, 347, 511, 63, 1531, 8, 277, 304, 267, 327, 3254, 26, 10876, 543, 11696, 314, 283, 5006, 63, 7617, 7, 2559, 4910, 652, 365, 440, 267, 327, 3962, 370, 1255, 642, 511, 641, 5417, 14, 221, 710, 283, 5006, 63, 7617, 7, 7286, 267, 327, 365, 440, 7264, 6657, 641, 5417, 880, 3544, 2138, 314, 267, 327, 8927, 1125, 1233, 14, 267, 1033, 275, 1218, 63, 5641, 342, 267, 5501, 5501, 5501, 1414, 275, 1033, 14, 16480, 63, 10732, 8, 1531, 29, 549, 9, 398, 340, 1414, 26, 288, 519, 275, 291, 423, 981, 63, 1100, 5234, 5006, 63, 7617, 3135, 288, 299, 275, 519, 14, 2526, 63, 5641, 8, 1531, 628, 5006, 63, 7617, 401, 1816, 3839, 29, 5781, 14, 6089, 9, 288, 291, 14, 629, 1547, 2703, 8, 80, 395, 298, 6257, 799, 90, 13064, 9124, 339, 768, 5641, 63, 7106, 8, 5473, 6270, 1760, 3135, 272, 347, 511, 63, 1531, 63, 9913, 8, 277, 304, 267, 327, 3254, 26, 10876, 543, 11696, 314, 283, 5006, 63, 7617, 7, 2559, 4910, 652, 365, 440, 267, 327, 3962, 370, 1255, 642, 511, 641, 5417, 14, 221, 710, 283, 5006, 63, 7617, 7, 7286, 267, 327, 365, 440, 7264, 6657, 641, 5417, 880, 3544, 2138, 314, 267, 327, 8927, 1125, 1233, 14, 267, 1033, 275, 1218, 63, 5641, 342, 267, 5501, 5501, 5501, 1414, 275, 1033, 14, 16480, 63, 10732, 8, 1531, 29, 549, 9, 398, 340, 1414, 26, 288, 519, 275, 291, 423, 981, 63, 1100, 5234, 5006, 63, 7617, 3135, 288, 1414, 275, 298, 5006, 63, 7617, 446, 81, 446, 82, 14157, 2, 288, 3718, 275, 334, 1531, 12, 1414, 14, 1294, 1012, 288, 367, 2088, 315, 3718, 26, 355, 299, 275, 519, 14, 2526, 63, 5641, 8, 1531, 29, 1760, 12, 3839, 29, 5781, 14, 6089, 9, 355, 299, 14, 2573, 342, 355, 291, 14, 629, 8, 80, 14, 9913, 12, 14157, 9, 339, 768, 5641, 63, 7106, 342, 272, 347, 511, 63, 6505, 67, 8, 277, 304, 267, 1033, 275, 1218, 63, 5641, 342, 267, 5501, 6590, 67, 12, 5501, 1414, 275, 1033, 14, 16480, 63, 10732, 8, 6505, 67, 29, 549, 12, 1414, 29, 549, 9, 398, 340, 6590, 67, 436, 1414, 26, 288, 519, 275, 291, 423, 981, 63, 1100, 5234, 5006, 63, 7617, 3135, 288, 299, 275, 519, 14, 2526, 63, 5641, 8, 6505, 67, 29, 549, 12, 1816, 1414, 628, 5006, 63, 7617, 401, 1816, 3839, 29, 5781, 14, 6089, 9, 288, 291, 14, 629, 1547, 2703, 8, 80, 395, 298, 6257, 799, 90, 13064, 9124, 339, 768, 5641, 63, 7106, 342, 272, 347, 511, 63, 6626, 8, 277, 304, 267, 1033, 275, 1218, 63, 5641, 342, 267, 5501, 5501, 9009, 12, 485, 275, 1033, 14, 16480, 63, 10732, 8, 6626, 29, 549, 9, 398, 340, 9009, 26, 288, 519, 275, 291, 423, 981, 63, 1100, 5234, 5006, 63, 7617, 3135, 288, 299, 275, 519, 14, 2526, 63, 5641, 8, 2703, 29, 5781, 14, 6089, 12, 1816, 9009, 29, 5781, 14, 6089, 12, 1816, 6590, 67, 29, 549, 9, 288, 3839, 12, 485 ]
[ 199, 396, 5218, 19569, 199, 624, 199, 504, 295, 90, 14, 2253, 492, 2656, 199, 504, 295, 90, 14, 609, 6840, 492, 1218, 63, 5641, 199, 504, 295, 90, 14, 13697, 63, 1100, 492, 3591, 7064, 2998, 199, 504, 295, 90, 14, 15063, 492, 820, 476, 16752, 12, 8785, 12, 6544, 461, 199, 646, 295, 90, 14, 9884, 14, 2796, 18, 465, 2882, 199, 504, 295, 90, 14, 2219, 14, 1974, 492, 1379, 1563, 12, 12540, 694, 4256, 12, 5218, 63, 7106, 12, 971, 272, 3907, 63, 7106, 199, 504, 295, 90, 14, 1974, 492, 1314, 199, 504, 295, 90, 14, 3409, 492, 16509, 63, 7617, 199, 504, 295, 90, 14, 1208, 14, 3246, 63, 492, 4298, 63, 199, 646, 3873, 199, 646, 5549, 199, 646, 6485, 199, 646, 13390, 199, 646, 747, 199, 646, 984, 421, 199, 318, 485, 2703, 8, 4687, 304, 272, 734, 3131, 485, 275, 6499, 14, 10664, 342, 272, 372, 734, 3754, 1913, 342, 421, 199, 533, 1379, 2662, 6840, 8, 14440, 12, 12540, 694, 4256, 304, 272, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 12540, 694, 4256, 14, 27777, 342, 398, 6117, 63, 515, 275, 747, 14, 515, 14, 904, 8, 1886, 14, 1231, 12, 298, 5154, 531, 267, 747, 14, 8347, 8, 5154, 63, 515, 9, 267, 16509, 63, 7617, 14, 3409, 8, 5154, 63, 515, 9, 398, 843, 14, 1751, 275, 1211, 8, 288, 6117, 63, 515, 1524, 5154, 63, 515, 467, 288, 2559, 63, 1541, 29, 403, 12, 288, 9227, 63, 5154, 6034, 288, 7987, 63, 324, 3954, 379, 29, 797, 9, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 12540, 694, 4256, 14, 12336, 2543, 342, 339, 768, 3744, 272, 347, 485, 981, 63, 1100, 8, 1886, 12, 24162, 304, 267, 687, 295, 90, 14, 888, 492, 1101, 267, 372, 3591, 7064, 2998, 8, 16624, 12, 13627, 29, 797, 9, 339, 768, 5641, 63, 7106, 8, 5473, 6270, 1760, 3135, 272, 347, 511, 63, 889, 63, 1199, 8, 277, 304, 267, 327, 3254, 26, 10876, 543, 11696, 314, 283, 5006, 63, 7617, 7, 2559, 4910, 652, 365, 440, 267, 327, 3962, 370, 1255, 642, 511, 641, 5417, 14, 221, 710, 283, 5006, 63, 7617, 7, 7286, 267, 327, 365, 440, 7264, 6657, 641, 5417, 880, 3544, 2138, 314, 267, 327, 8927, 1125, 1233, 14, 267, 1033, 275, 1218, 63, 5641, 342, 267, 5501, 5501, 5501, 1414, 275, 1033, 14, 16480, 63, 10732, 8, 1531, 29, 549, 9, 267, 340, 1414, 26, 288, 519, 275, 291, 423, 981, 63, 1100, 5234, 5006, 63, 7617, 3135, 288, 299, 275, 519, 14, 2526, 63, 5641, 8, 1531, 628, 5006, 63, 7617, 446, 81, 401, 1816, 3839, 29, 5781, 14, 6089, 9, 953, 291, 14, 629, 8, 355, 485, 2703, 8, 80, 395, 3260, 355, 298, 2765, 511, 436, 11789, 911, 2449, 12, 2952, 1373, 503, 1655, 402, 2195, 298, 355, 298, 16480, 10554, 787, 16116, 370, 3839, 14, 7754, 2813, 314, 298, 355, 298, 1361, 548, 436, 862, 4020, 2685, 339, 768, 5641, 63, 7106, 8, 5473, 6270, 1760, 3135, 272, 347, 511, 63, 1531, 8, 277, 304, 267, 327, 3254, 26, 10876, 543, 11696, 314, 283, 5006, 63, 7617, 7, 2559, 4910, 652, 365, 440, 267, 327, 3962, 370, 1255, 642, 511, 641, 5417, 14, 221, 710, 283, 5006, 63, 7617, 7, 7286, 267, 327, 365, 440, 7264, 6657, 641, 5417, 880, 3544, 2138, 314, 267, 327, 8927, 1125, 1233, 14, 267, 1033, 275, 1218, 63, 5641, 342, 267, 5501, 5501, 5501, 1414, 275, 1033, 14, 16480, 63, 10732, 8, 1531, 29, 549, 9, 398, 340, 1414, 26, 288, 519, 275, 291, 423, 981, 63, 1100, 5234, 5006, 63, 7617, 3135, 288, 299, 275, 519, 14, 2526, 63, 5641, 8, 1531, 628, 5006, 63, 7617, 401, 1816, 3839, 29, 5781, 14, 6089, 9, 288, 291, 14, 629, 1547, 2703, 8, 80, 395, 298, 6257, 799, 90, 13064, 9124, 339, 768, 5641, 63, 7106, 8, 5473, 6270, 1760, 3135, 272, 347, 511, 63, 1531, 63, 9913, 8, 277, 304, 267, 327, 3254, 26, 10876, 543, 11696, 314, 283, 5006, 63, 7617, 7, 2559, 4910, 652, 365, 440, 267, 327, 3962, 370, 1255, 642, 511, 641, 5417, 14, 221, 710, 283, 5006, 63, 7617, 7, 7286, 267, 327, 365, 440, 7264, 6657, 641, 5417, 880, 3544, 2138, 314, 267, 327, 8927, 1125, 1233, 14, 267, 1033, 275, 1218, 63, 5641, 342, 267, 5501, 5501, 5501, 1414, 275, 1033, 14, 16480, 63, 10732, 8, 1531, 29, 549, 9, 398, 340, 1414, 26, 288, 519, 275, 291, 423, 981, 63, 1100, 5234, 5006, 63, 7617, 3135, 288, 1414, 275, 298, 5006, 63, 7617, 446, 81, 446, 82, 14157, 2, 288, 3718, 275, 334, 1531, 12, 1414, 14, 1294, 1012, 288, 367, 2088, 315, 3718, 26, 355, 299, 275, 519, 14, 2526, 63, 5641, 8, 1531, 29, 1760, 12, 3839, 29, 5781, 14, 6089, 9, 355, 299, 14, 2573, 342, 355, 291, 14, 629, 8, 80, 14, 9913, 12, 14157, 9, 339, 768, 5641, 63, 7106, 342, 272, 347, 511, 63, 6505, 67, 8, 277, 304, 267, 1033, 275, 1218, 63, 5641, 342, 267, 5501, 6590, 67, 12, 5501, 1414, 275, 1033, 14, 16480, 63, 10732, 8, 6505, 67, 29, 549, 12, 1414, 29, 549, 9, 398, 340, 6590, 67, 436, 1414, 26, 288, 519, 275, 291, 423, 981, 63, 1100, 5234, 5006, 63, 7617, 3135, 288, 299, 275, 519, 14, 2526, 63, 5641, 8, 6505, 67, 29, 549, 12, 1816, 1414, 628, 5006, 63, 7617, 401, 1816, 3839, 29, 5781, 14, 6089, 9, 288, 291, 14, 629, 1547, 2703, 8, 80, 395, 298, 6257, 799, 90, 13064, 9124, 339, 768, 5641, 63, 7106, 342, 272, 347, 511, 63, 6626, 8, 277, 304, 267, 1033, 275, 1218, 63, 5641, 342, 267, 5501, 5501, 9009, 12, 485, 275, 1033, 14, 16480, 63, 10732, 8, 6626, 29, 549, 9, 398, 340, 9009, 26, 288, 519, 275, 291, 423, 981, 63, 1100, 5234, 5006, 63, 7617, 3135, 288, 299, 275, 519, 14, 2526, 63, 5641, 8, 2703, 29, 5781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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 ]
ijat/Hotspot-PUTRA-Auto-login
PyInstaller-3.2/PyInstaller/hooks/hook-IPython.py
1
1076
#----------------------------------------------------------------------------- # Copyright (c) 2013-2016, PyInstaller Development Team. # # Distributed under the terms of the GNU General Public License with exception # for distributing bootloader. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- # Tested with IPython 4.0.0. from PyInstaller.compat import modname_tkinter, is_win, is_darwin from PyInstaller.utils.hooks import collect_data_files, collect_submodules # Ignore 'matplotlib'. IPython contains support for matplotlib. # Ignore GUI libraries. IPython supports integration with GUI frameworks. # Assume that it will be imported by any other module when the user really # uses it. excludedimports = ['gtk', 'matplotlib', 'PyQt4', 'PyQt5', 'PySide'] # IPython uses 'tkinter' for clipboard access on Linux/Unix. Exclude it on Windows and OS X. if is_win or is_darwin: excludedimports.append(modname_tkinter) datas = collect_data_files('IPython')
gpl-3.0
[ 18045, 199, 3, 1898, 334, 67, 9, 6171, 13, 9261, 12, 1611, 27598, 15290, 11682, 14, 199, 3, 199, 3, 17484, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 543, 1919, 199, 3, 367, 29573, 4655, 8498, 3422, 14, 199, 3, 199, 3, 710, 2615, 4190, 365, 315, 314, 570, 9685, 14, 2424, 12, 1854, 543, 642, 2032, 14, 199, 18045, 421, 199, 3, 30568, 543, 16243, 841, 14, 16, 14, 16, 14, 199, 199, 504, 1611, 27598, 14, 5819, 492, 13526, 63, 12223, 12, 365, 63, 2676, 12, 365, 63, 13245, 199, 504, 1611, 27598, 14, 1208, 14, 7922, 492, 8775, 63, 576, 63, 1725, 12, 8775, 63, 954, 3112, 199, 199, 3, 14092, 283, 16440, 1370, 16243, 3509, 2291, 367, 8027, 14, 199, 3, 14092, 17160, 8363, 14, 16243, 5171, 13150, 543, 17160, 10059, 83, 14, 199, 3, 16269, 626, 652, 911, 506, 8439, 701, 1263, 1163, 859, 1380, 314, 922, 7710, 199, 3, 4440, 652, 14, 199, 5473, 328, 412, 83, 275, 788, 12275, 297, 283, 16440, 297, 283, 24107, 20, 297, 283, 24107, 21, 297, 283, 2713, 15414, 418, 199, 199, 3, 16243, 4440, 283, 12223, 7, 367, 11353, 3576, 2879, 641, 10130, 15, 21607, 14, 28554, 652, 641, 5417, 436, 4403, 1323, 14, 199, 692, 365, 63, 2676, 503, 365, 63, 13245, 26, 272, 5760, 328, 412, 83, 14, 740, 8, 14789, 63, 12223, 9, 421, 199, 11563, 275, 8775, 63, 576, 63, 1725, 360, 1772, 11361, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 334, 67, 9, 6171, 13, 9261, 12, 1611, 27598, 15290, 11682, 14, 199, 3, 199, 3, 17484, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 543, 1919, 199, 3, 367, 29573, 4655, 8498, 3422, 14, 199, 3, 199, 3, 710, 2615, 4190, 365, 315, 314, 570, 9685, 14, 2424, 12, 1854, 543, 642, 2032, 14, 199, 18045, 421, 199, 3, 30568, 543, 16243, 841, 14, 16, 14, 16, 14, 199, 199, 504, 1611, 27598, 14, 5819, 492, 13526, 63, 12223, 12, 365, 63, 2676, 12, 365, 63, 13245, 199, 504, 1611, 27598, 14, 1208, 14, 7922, 492, 8775, 63, 576, 63, 1725, 12, 8775, 63, 954, 3112, 199, 199, 3, 14092, 283, 16440, 1370, 16243, 3509, 2291, 367, 8027, 14, 199, 3, 14092, 17160, 8363, 14, 16243, 5171, 13150, 543, 17160, 10059, 83, 14, 199, 3, 16269, 626, 652, 911, 506, 8439, 701, 1263, 1163, 859, 1380, 314, 922, 7710, 199, 3, 4440, 652, 14, 199, 5473, 328, 412, 83, 275, 788, 12275, 297, 283, 16440, 297, 283, 24107, 20, 297, 283, 24107, 21, 297, 283, 2713, 15414, 418, 199, 199, 3, 16243, 4440, 283, 12223, 7, 367, 11353, 3576, 2879, 641, 10130, 15, 21607, 14, 28554, 652, 641, 5417, 436, 4403, 1323, 14, 199, 692, 365, 63, 2676, 503, 365, 63, 13245, 26, 272, 5760, 328, 412, 83, 14, 740, 8, 14789, 63, 12223, 9, 421, 199, 11563, 275, 8775, 63, 576, 63, 1725, 360, 1772, 11361, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
coreyfarrell/testsuite
lib/python/asterisk/ari.py
2
29367
""" Copyright (C) 2013, Digium, Inc. David M. Lee, II <dlee@digium.com> This program is free software, distributed under the terms of the GNU General Public License Version 2. """ import datetime import json import logging import re import requests import traceback try: from urllib.parse import urlencode except: from urllib import urlencode from .test_case import TestCase from .test_runner import load_and_parse_module from .pluggable_registry import PLUGGABLE_EVENT_REGISTRY,\ PLUGGABLE_ACTION_REGISTRY, var_replace from .test_suite_utils import all_match from twisted.internet import reactor try: from autobahn.websocket import WebSocketClientFactory, \ WebSocketClientProtocol, connectWS except: from autobahn.twisted.websocket import WebSocketClientFactory, \ WebSocketClientProtocol, connectWS LOGGER = logging.getLogger(__name__) DEFAULT_HOST = '127.0.0.1' DEFAULT_PORT = 8088 #: Default matcher to ensure we don't have any validation failures on the # WebSocket VALIDATION_MATCHER = { 'conditions': { 'match': { 'error': "^InvalidMessage$" } }, 'count': 0 } class AriBaseTestObject(TestCase): """Class that acts as a Test Object in the pluggable module framework""" def __init__(self, test_path='', test_config=None): """Constructor for a test object :param test_path The full path to the test location :param test_config The YAML test configuration """ super(AriBaseTestObject, self).__init__(test_path, test_config) if test_config is None: # Meh, just use defaults test_config = {} self.apps = test_config.get('apps', 'testsuite') if isinstance(self.apps, list): self.apps = ','.join(self.apps) default_host = DEFAULT_HOST if self.global_config.config: asterisks = self.global_config.config.get('asterisk-instances') if asterisks: default_host = asterisks[0]['host'] host = test_config.get('host', default_host) port = test_config.get('port', DEFAULT_PORT) userpass = (test_config.get('username', 'testsuite'), test_config.get('password', 'testsuite')) subscribe_all = test_config.get('subscribe-all') # Create the REST interface and the WebSocket Factory self.ari = ARI(host, port=port, userpass=userpass) self.ari_factory = AriClientFactory(receiver=self, host=host, port=port, apps=self.apps, userpass=userpass, subscribe_all=subscribe_all) self._ws_connection = None self._ws_event_handlers = [] self._ws_open_handlers = [] self.timed_out = False self.asterisk_instances = test_config.get('asterisk-instances', 1) self.create_asterisk(count=self.asterisk_instances, test_config=test_config) def run(self): """Override of TestCase run Called when reactor starts and after all instances of Asterisk have started """ super(AriBaseTestObject, self).run() self.ari_factory.connect() def register_ws_event_handler(self, callback): """Register a callback for when an event is received over the WS :param callback The method to call when an event is received. This will have a single parameter (the event) passed to it """ self._ws_event_handlers.append(callback) def on_reactor_timeout(self): """Called when the reactor times out""" self.timed_out = True # Fail the tests if we have timed out self.set_passed(False) def on_ws_event(self, message): """Handler for WebSocket events :param message The WS event payload """ if self.timed_out: # Ignore messages received after timeout LOGGER.debug("Ignoring message received after timeout") return for handler in self._ws_event_handlers: handler(message) def on_ws_open(self, protocol): """Handler for WebSocket Client Protocol opened :param protocol The WS Client protocol object """ self._ws_connection = protocol for observer in self._ws_open_handlers: observer(self) reactor.callLater(0, self._create_ami_connection) def register_ari_observer(self, observer): """Register an observer for ARI WS connection :param observer The WS observer. This will be called with this object. """ self._ws_open_handlers.append(observer) def on_ws_closed(self, protocol): """Handler for WebSocket Client Protocol closed :param protocol The WS Client protocol object """ self._ws_connection = None LOGGER.debug("WebSocket connection closed...") def _create_ami_connection(self): """Create the AMI connection""" self.create_ami_factory(count=self.asterisk_instances) def stop_reactor(self): if self._ws_connection is not None: self._ws_connection.dropConnection() super(AriBaseTestObject, self).stop_reactor() class AriTestObject(AriBaseTestObject): """Class that acts as a Test Object in the pluggable module framework""" def __init__(self, test_path='', test_config=None): """Constructor for a test object :param test_path The full path to the test location :param test_config The YAML test configuration """ super(AriTestObject, self).__init__(test_path, test_config) if test_config is None: # Meh, just use defaults test_config = {} self.iterations = test_config.get('test-iterations') self.stop_on_end = test_config.get('stop-on-end', True) self.test_iteration = 0 self.channels = [] if self.iterations is None: self.iterations = [{'channel': 'Local/s@default', 'application': 'Echo'}] def ami_connect(self, ami): """Override of AriBaseTestObject ami_connect Called when an AMI connection is made :param ami The AMI factory """ # only use the first ami instance if ami.id != 0: return ami.registerEvent('Newchannel', self._new_channel_handler) ami.registerEvent('Hangup', self._hangup_handler) self.execute_test() return ami def _new_channel_handler(self, ami, event): """Handler for new channels :param ami The AMI instance :param event The Newchannl event """ LOGGER.debug("Tracking channel %s", event['channel']) self.channels.append(event['channel']) return (ami, event) def _hangup_handler(self, ami, event): """Handler for channel hangup :param ami The AMI instance :param event Hangup event """ if event['channel'] not in self.channels: return (ami, event) LOGGER.debug("Removing tracking for %s", event['channel']) self.channels.remove(event['channel']) if len(self.channels) == 0: self.test_iteration += 1 self.execute_test() return (ami, event) def execute_test(self): """Execute the current iteration of the test""" if not isinstance(self.iterations, list): return if self.test_iteration == len(self.iterations): LOGGER.info("All iterations executed") if self.stop_on_end: LOGGER.info("Stopping test") self.stop_reactor() return iteration = self.iterations[self.test_iteration] if isinstance(iteration, list): for channel in iteration: self._spawn_channel(channel) else: self._spawn_channel(iteration) def _spawn_channel(self, channel_def): """Create a new channel""" # There's only one Asterisk instance, so just use the first AMI factory LOGGER.info("Creating channel %s", channel_def['channel']) if not self.ami[0]: LOGGER.warning("Error creating channel - no ami available") return deferred = self.ami[0].originate(**channel_def) deferred.addErrback(self.handle_originate_failure) class AriOriginateTestObject(AriTestObject): """Class that overrides AriTestObject origination to use ARI""" def __init__(self, test_path='', test_config=None): """Constructor for a test object :param test_path The full path to the test location :param test_config The YAML test configuration """ if test_config is None: test_config = {} if not test_config.get('test-iterations'): # preset the default test in ARI format to prevent post failure test_config['test-iterations'] = [{ 'endpoint': 'Local/s@default', 'channelId': 'testsuite-default-id', 'app': 'testsuite' }] super(AriOriginateTestObject, self).__init__(test_path, test_config) def _spawn_channel(self, channel_def): """Create a new channel""" # Create a channel using ARI POST to channel instead LOGGER.info("Creating channel %s", channel_def['endpoint']) self.ari.post('channels', **channel_def) class WebSocketEventModule(object): """Module for capturing events from the ARI WebSocket""" def __init__(self, module_config, test_object): """Constructor. :param module_config: Configuration dict parse from test-config.yaml. :param test_object: Test control object. """ self.ari = test_object.ari self.event_matchers = [ EventMatcher(self.ari, e, test_object) for e in module_config['events']] self.event_matchers.append(EventMatcher(self.ari, VALIDATION_MATCHER, test_object)) test_object.register_ws_event_handler(self.on_event) def on_event(self, event): """Handle incoming events from the WebSocket. :param event: Dictionary parsed from incoming JSON event. """ LOGGER.debug("Received event: %r", event.get('type')) matched = False for matcher in self.event_matchers: if matcher.on_event(event): matched = True if not matched: LOGGER.info("Event had no matcher: %r", event) class AriClientFactory(WebSocketClientFactory): """Twisted protocol factory for building ARI WebSocket clients.""" def __init__(self, receiver, host, apps, userpass, port=DEFAULT_PORT, timeout_secs=60, subscribe_all=False): """Constructor :param receiver The object that will receive events from the protocol :param host: Hostname of Asterisk. :param apps: App names to subscribe to. :param port: Port of Asterisk web server. :param timeout_secs: Maximum time to try to connect to Asterisk. :param subscribe_all: If true, subscribe to all events. """ url = "ws://%s:%d/ari/events?%s" % \ (host, port, urlencode({'app': apps, 'api_key': '%s:%s' % userpass})) if subscribe_all: url += '&subscribeAll=true' LOGGER.info("WebSocketClientFactory(url=%s)", url) try: WebSocketClientFactory.__init__(self, url, debug=True, protocols=['ari'], debugCodePaths=True) except TypeError: WebSocketClientFactory.__init__(self, url, protocols=['ari']) self.timeout_secs = timeout_secs self.attempts = 0 self.start = None self.receiver = receiver def buildProtocol(self, addr): """Make the protocol""" return AriClientProtocol(self.receiver, self) def clientConnectionFailed(self, connector, reason): """Doh, connection lost""" LOGGER.debug("Connection lost; attempting again in 1 second") reactor.callLater(1, self.reconnect) def connect(self): """Start the connection""" self.reconnect() def reconnect(self): """Attempt to reconnect the ARI WebSocket. This call will give up after timeout_secs has been exceeded. """ self.attempts += 1 LOGGER.debug("WebSocket attempt #%d", self.attempts) if not self.start: self.start = datetime.datetime.now() runtime = (datetime.datetime.now() - self.start).seconds if runtime >= self.timeout_secs: LOGGER.error(" Giving up after %d seconds", self.timeout_secs) raise Exception("Failed to connect after %d seconds" % self.timeout_secs) connectWS(self) class AriClientProtocol(WebSocketClientProtocol): """Twisted protocol for handling a ARI WebSocket connection.""" def __init__(self, receiver, factory): """Constructor. :param receiver The event receiver """ try: super(AriClientProtocol, self).__init__() except TypeError as te: # Older versions of Autobahn use old style classes with no initializer. # Newer versions must have their initializer called by derived # implementations. LOGGER.debug("AriClientProtocol: TypeError thrown in init: {0}".format(te)) LOGGER.debug("Made me a client protocol!") self.receiver = receiver self.factory = factory def onOpen(self): """Called back when connection is open.""" LOGGER.debug("WebSocket Open") self.receiver.on_ws_open(self) def onClose(self, wasClean, code, reason): """Called back when connection is closed.""" LOGGER.debug("WebSocket closed(%r, %d, %s)", wasClean, code, reason) self.receiver.on_ws_closed(self) def onMessage(self, msg, binary): """Called back when message is received. :param msg: Received text message. """ LOGGER.debug("rxed: %s", msg) msg = json.loads(msg) self.receiver.on_ws_event(msg) class ARI(object): """Bare bones object for an ARI interface.""" def __init__(self, host, userpass, port=DEFAULT_PORT): """Constructor. :param host: Hostname of Asterisk. :param port: Port of the Asterisk webserver. """ self.base_url = "http://%s:%d/ari" % (host, port) self.userpass = userpass self.allow_errors = False def build_url(self, *args): """Build a URL from the given path. For example:: # Builds the URL for /channels/{channel_id}/answer ari.build_url('channels', channel_id, 'answer') :param args: Path segments. """ path = [str(arg) for arg in args] return '/'.join([self.base_url] + path) def get(self, *args, **kwargs): """Send a GET request to ARI. :param args: Path segements. :param kwargs: Query parameters. :returns: requests.models.Response :throws: requests.exceptions.HTTPError """ url = self.build_url(*args) LOGGER.info("GET %s %r", url, kwargs) return self.raise_on_err(requests.get(url, params=kwargs, auth=self.userpass)) def put(self, *args, **kwargs): """Send a PUT request to ARI. :param args: Path segements. :param kwargs: Query parameters. :returns: requests.models.Response :throws: requests.exceptions.HTTPError """ url = self.build_url(*args) json = kwargs.pop('json', None) LOGGER.info("PUT %s %r", url, kwargs) return self.raise_on_err(requests.put(url, params=kwargs, json=json, auth=self.userpass)) def post(self, *args, **kwargs): """Send a POST request to ARI. :param args: Path segements. :param kwargs: Query parameters. :returns: requests.models.Response :throws: requests.exceptions.HTTPError """ url = self.build_url(*args) json = kwargs.pop('json', None) LOGGER.info("POST %s %r", url, kwargs) return self.raise_on_err(requests.post(url, params=kwargs, json=json, auth=self.userpass)) def delete(self, *args, **kwargs): """Send a DELETE request to ARI. :param args: Path segements. :param kwargs: Query parameters. :returns: requests.models.Response :throws: requests.exceptions.HTTPError """ url = self.build_url(*args) LOGGER.info("DELETE %s %r", url, kwargs) return self.raise_on_err(requests.delete(url, params=kwargs, auth=self.userpass)) def request(self, method, *args, **kwargs): """ Send an arbitrary request to ARI. :param method: Method (get, post, delete, etc). :param args: Path segements. :param kwargs: Query parameters. :returns: requests.models.Response :throws: requests.exceptions.HTTPError """ url = self.build_url(*args) LOGGER.info("%s %s %r", method, url, kwargs) requests_method = getattr(requests, method) return self.raise_on_err(requests_method(url, params=kwargs, auth=self.userpass)) def set_allow_errors(self, value): """Sets whether error responses returns exceptions. If True, then error responses are returned. Otherwise, methods throw an exception on error. :param value True/False value for allow_errors. """ self.allow_errors = value def raise_on_err(self, resp): """Helper to raise an exception when a response is a 4xx or 5xx error. If allow_errors is True, then an exception is not raised. :param resp: requests.models.Response object :returns: resp """ if not self.allow_errors and resp.status_code / 100 != 2: LOGGER.error('%s (%d %s): %r', resp.url, resp.status_code, resp.reason, resp.text) resp.raise_for_status() return resp class ARIRequest(object): """ Object that issues ARI requests and valiates response """ def __init__(self, ari, config): self.ari = ari self.method = config['method'] self.uri = config['uri'] self.response_body = config.get('response_body') self.params = config.get('params') or {} self.body = config.get('body') self.instance = config.get('instance') self.delay = config.get('delay') self.expect = config.get('expect') self.headers = None if self.body: self.body = json.dumps(self.body) self.headers = {'Content-type': 'application/json'} def send(self, values): """Send this ARI request substituting the given values""" uri = var_replace(self.uri, values) url = self.ari.build_url(uri) requests_method = getattr(requests, self.method) params = dict((key, var_replace(val, values)) for key, val in self.params.items()) response = requests_method( url, params=params, data=self.body, headers=self.headers, auth=self.ari.userpass) if self.response_body: match = self.response_body.get('match') return all_match(match, response.json()) if self.expect: if response.status_code != self.expect: LOGGER.error('sent %s %s %s expected %s response %d %s', self.method, self.uri, self.params, self.expect, response.status_code, response.text) return False else: if response.status_code // 100 != 2: LOGGER.error('sent %s %s %s response %d %s', self.method, self.uri, self.params, response.status_code, response.text) return False LOGGER.info('sent %s %s %s response %d %s', self.method, self.uri, self.params, response.status_code, response.text) return response class EventMatcher(object): """Object to observe incoming events and match them against a config""" def __init__(self, ari, instance_config, test_object): self.ari = ari self.instance_config = instance_config self.test_object = test_object self.conditions = self.instance_config['conditions'] self.count_range = decode_range(self.instance_config.get('count')) self.count = 0 self.passed = True callback = self.instance_config.get('callback') if callback: self.callback = load_and_parse_module(callback['module'] + '.' + callback['method']) else: # No callback; just use a no-op self.callback = lambda *args, **kwargs: True request_list = self.instance_config.get('requests') or [] if isinstance(request_list, dict): request_list = [request_list] self.requests = [ARIRequest(ari, request_config) for request_config in request_list] test_object.register_stop_observer(self.on_stop) def on_event(self, message): """Callback for every received ARI event. :param message: Parsed event from ARI WebSocket. """ if self.matches(message): self.count += 1 # send any associated requests for request in self.requests: if request.instance and request.instance != self.count: continue if request.delay: reactor.callLater(request.delay, request.send, message) else: response = request.send(message) if response is False: self.passed = False # Split call and accumulation to always call the callback try: res = self.callback(self.ari, message, self.test_object) if res: return True else: LOGGER.error("Callback failed: %r", self.instance_config) self.passed = False except: LOGGER.error("Exception in callback: %s", traceback.format_exc()) self.passed = False return False def on_stop(self, *args): """Callback for the end of the test. :param args: Ignored arguments. """ if not self.count_range.contains(self.count): # max could be int or float('inf'); format with %r LOGGER.error("Expected %d <= count <= %r; was %d (%r)", self.count_range.min_value, self.count_range.max_value, self.count, self.conditions) self.passed = False self.test_object.set_passed(self.passed) def matches(self, message): """Compares a message against the configured conditions. :param message: Incoming ARI WebSocket event. :returns: True if message matches conditions; False otherwise. """ match = self.conditions.get('match') res = all_match(match, message) # Now validate the nomatch, if it's there nomatch = self.conditions.get('nomatch') if res and nomatch: res = not all_match(nomatch, message) return res class Range(object): """Utility object to handle numeric ranges (inclusive).""" def __init__(self, min_value=0, max_value=float("inf")): """Constructor. :param min: Minimum value of the range. :param max: Maximum value of the range. """ self.min_value = min_value self.max_value = max_value def contains(self, value): """Checks if the given value is within this Range. :param value: Value to check. :returns: True/False if v is/isn't in the Range. """ return self.min_value <= value <= self.max_value def decode_range(yaml): """Parse a range from YAML specification.""" if yaml is None: # Unspecified; receive at least one return Range(1, float("inf")) elif isinstance(yaml, int): # Need exactly this many events return Range(yaml, yaml) elif yaml[0] == '<': # Need at most this many events return Range(0, int(yaml[1:])) elif yaml[0] == '>': # Need at least this many events return Range(int(yaml[1:]), float("inf")) else: # Need exactly this many events return Range(int(yaml), int(yaml)) class ARIPluggableEventModule(object): """Subclass of ARIEventInstance that works with the pluggable event action module. """ def __init__(self, test_object, triggered_callback, config): """Setup the ARI event observer""" self.test_object = test_object self.triggered_callback = triggered_callback if isinstance(config, list): self.config = config else: self.config = [config] for event_description in self.config: event_description["expected_count_range"] =\ decode_range(event_description.get('count', 1)) event_description["event_count"] = 0 test_object.register_ws_event_handler(self.event_callback) test_object.register_stop_observer(self.on_stop) def event_callback(self, event): """Callback called when an event is received from ARI""" for event_description in self.config: match = event_description["match"] nomatch = event_description.get("nomatch", None) if not all_match(match, event): continue # Now validate the nomatch, if it's there if nomatch and all_match(nomatch, event): continue event_description["event_count"] += 1 self.triggered_callback(self, self.test_object.ari, event) def on_stop(self, *args): """Callback for the end of the test. :param args: Ignored arguments. """ for event_desc in self.config: if not event_desc["expected_count_range"].contains(event_desc["event_count"]): # max could be int or float('inf'); format with %r LOGGER.error("Expected %d <= count <= %r; was %d (%r, !%r)", event_desc["expected_count_range"].min_value, event_desc["expected_count_range"].max_value, event_desc["event_count"], event_desc["match"], event_desc.get("nomatch", None)) self.test_object.set_passed(False) self.test_object.set_passed(True) PLUGGABLE_EVENT_REGISTRY.register("ari-events", ARIPluggableEventModule) class ARIPluggableStartModule(object): """Pluggable ARI module that kicks off when Asterisk starts """ def __init__(self, test_object, triggered_callback, config): """Constructor""" self.triggered_callback = triggered_callback self.test_object = test_object # AMI connects after ARI, so this should call back once we're # good and ready test_object.register_ami_observer(self.on_ami_connect) def on_ami_connect(self, ami): """AMI connect handler""" self.triggered_callback(self, self.test_object.ari, None) PLUGGABLE_EVENT_REGISTRY.register("ari-start", ARIPluggableStartModule) class ARIPluggableRequestModule(object): """Pluggable ARI action module. """ def __init__(self, test_object, config): """Setup the ARI event observer""" self.test_object = test_object if not isinstance(config, list): config = [config] self.requests = [ARIRequest(test_object.ari, request_config) for request_config in config] self.count = 0 def run(self, triggered_by, source, extra): """Callback called when this action is triggered.""" self.count += 1 for request in self.requests: if request.instance and request.instance != self.count: continue if request.delay: reactor.callLater(request.delay, request.send, extra) else: result = request.send(extra) if isinstance(result, bool) and not result: self.test_object.set_passed(False) else: self.test_object.set_passed(True) PLUGGABLE_ACTION_REGISTRY.register("ari-requests", ARIPluggableRequestModule) # vim:sw=4:ts=4:expandtab:textwidth=79
gpl-2.0
[ 624, 199, 7384, 334, 35, 9, 6171, 12, 22442, 5170, 12, 3277, 14, 199, 36, 17204, 603, 14, 491, 1024, 12, 473, 41, 665, 3011, 69, 32, 18367, 5170, 14, 957, 30, 199, 199, 2765, 2240, 365, 2867, 2032, 12, 1854, 1334, 314, 2895, 402, 199, 1589, 1664, 1696, 1684, 844, 3394, 499, 14, 199, 624, 199, 199, 646, 2197, 199, 646, 2022, 199, 646, 2050, 199, 646, 295, 199, 646, 4145, 199, 646, 5190, 199, 893, 26, 272, 687, 4011, 14, 1122, 492, 16511, 199, 2590, 26, 272, 687, 4011, 492, 16511, 199, 199, 504, 1275, 396, 63, 2546, 492, 7640, 199, 504, 1275, 396, 63, 5933, 492, 2248, 63, 460, 63, 1122, 63, 578, 199, 504, 1275, 13963, 16725, 63, 5189, 492, 10092, 53, 2916, 2617, 63, 8193, 63, 25304, 57, 4202, 272, 10092, 53, 2916, 2617, 63, 10052, 63, 25304, 57, 12, 2729, 63, 1814, 199, 504, 1275, 396, 63, 5768, 63, 1208, 492, 1006, 63, 1431, 199, 504, 7390, 14, 4901, 492, 9655, 199, 893, 26, 272, 687, 2599, 2470, 6164, 14, 13508, 492, 18846, 30115, 12, 971, 267, 18846, 3041, 3658, 12, 4907, 5035, 199, 2590, 26, 272, 687, 2599, 2470, 6164, 14, 12145, 14, 13508, 492, 18846, 30115, 12, 971, 267, 18846, 3041, 3658, 12, 4907, 5035, 199, 199, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3472, 63, 5449, 275, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 199, 3472, 63, 3657, 275, 5939, 1299, 199, 199, 12573, 3758, 15990, 370, 4868, 781, 2793, 1133, 1172, 1263, 6411, 9081, 641, 314, 199, 3, 221, 18846, 199, 5600, 2594, 63, 14747, 540, 275, 469, 272, 283, 9855, 356, 469, 267, 283, 1431, 356, 469, 288, 283, 705, 356, 18129, 3364, 2209, 17351, 267, 789, 272, 1660, 272, 283, 835, 356, 378, 199, 93, 421, 199, 533, 31153, 23170, 1692, 8, 1746, 304, 272, 408, 2543, 626, 17795, 465, 282, 1379, 6935, 315, 314, 14202, 16725, 859, 10059, 624, 339, 347, 636, 826, 721, 277, 12, 511, 63, 515, 4581, 511, 63, 888, 29, 403, 304, 267, 408, 11447, 367, 282, 511, 909, 398, 520, 635, 511, 63, 515, 710, 2615, 931, 370, 314, 511, 2909, 267, 520, 635, 511, 63, 888, 710, 18916, 511, 2897, 267, 408, 267, 1613, 8, 26291, 23170, 1692, 12, 291, 2843, 826, 721, 396, 63, 515, 12, 511, 63, 888, 9, 398, 340, 511, 63, 888, 365, 488, 26, 288, 327, 3194, 72, 12, 2951, 675, 4243, 288, 511, 63, 888, 275, 1052, 398, 291, 14, 5181, 275, 511, 63, 888, 14, 362, 360, 5181, 297, 283, 14239, 358, 267, 340, 1228, 8, 277, 14, 5181, 12, 769, 304, 288, 291, 14, 5181, 275, 12814, 904, 8, 277, 14, 5181, 9, 267, 849, 63, 1102, 275, 6186, 63, 5449, 267, 340, 291, 14, 2966, 63, 888, 14, 888, 26, 288, 465, 6236, 1339, 83, 275, 291, 14, 2966, 63, 888, 14, 888, 14, 362, 360, 305, 6236, 1339, 13, 5990, 358, 288, 340, 465, 6236, 1339, 83, 26, 355, 849, 63, 1102, 275, 465, 6236, 1339, 83, 59, 16, 2733, 1102, 418, 267, 1591, 275, 511, 63, 888, 14, 362, 360, 1102, 297, 849, 63, 1102, 9, 267, 1844, 275, 511, 63, 888, 14, 362, 360, 719, 297, 6186, 63, 3657, 9, 267, 922, 1529, 275, 334, 396, 63, 888, 14, 362, 360, 2473, 297, 283, 14239, 659, 490, 511, 63, 888, 14, 362, 360, 2060, 297, 283, 14239, 1333, 267, 23421, 63, 452, 275, 511, 63, 888, 14, 362, 360, 10108, 13, 452, 358, 398, 327, 2790, 314, 14880, 3217, 436, 314, 18846, 23616, 267, 291, 14, 759, 275, 4160, 41, 8, 1102, 12, 1844, 29, 719, 12, 922, 1529, 29, 751, 1529, 9, 267, 291, 14, 759, 63, 3702, 275, 31153, 30115, 8, 10244, 29, 277, 12, 1591, 29, 1102, 12, 1844, 29, 719, 12, 4490, 8686, 29, 277, 14, 5181, 12, 922, 1529, 29, 751, 1529, 12, 4490, 23421, 63, 452, 29, 10108, 63, 452, 9, 398, 291, 423, 3569, 63, 2105, 275, 488, 267, 291, 423, 3569, 63, 1430, 63, 5586, 275, 942, 267, 291, 423, 3569, 63, 1490, 63, 5586, 275, 942, 267, 291, 14, 26687, 63, 548, 275, 756, 398, 291, 14, 305, 6236, 1339, 63, 5990, 275, 511, 63, 888, 14, 362, 360, 305, 6236, 1339, 13, 5990, 297, 413, 9, 267, 291, 14, 981, 63, 305, 6236, 1339, 8, 835, 29, 277, 14, 305, 6236, 1339, 63, 5990, 12, 511, 63, 888, 29, 396, 63, 888, 9, 339, 347, 1255, 8, 277, 304, 267, 408, 11954, 402, 7640, 1255, 398, 12295, 1380, 9655, 9174, 436, 2410, 1006, 4454, 402, 437, 1597, 27473, 1172, 267, 8239, 267, 408, 267, 1613, 8, 26291, 23170, 1692, 12, 291, 680, 1065, 342, 267, 291, 14, 759, 63, 3702, 14, 2242, 342, 339, 347, 2274, 63, 3569, 63, 1430, 63, 2232, 8, 277, 12, 3233, 304, 267, 408, 7099, 282, 3233, 367, 1380, 376, 1566, 365, 3086, 1806, 314, 644, 51, 398, 520, 635, 3233, 710, 1083, 370, 1240, 1380, 376, 1566, 365, 3086, 14, 961, 267, 911, 1172, 282, 2849, 2725, 334, 1589, 1566, 9, 3032, 370, 652, 267, 408, 267, 291, 423, 3569, 63, 1430, 63, 5586, 14, 740, 8, 3058, 9, 339, 347, 641, 63, 13544, 63, 2593, 8, 277, 304, 267, 408, 10474, 1380, 314, 9655, 5431, 734, 624, 267, 291, 14, 26687, 63, 548, 275, 715, 267, 327, 12176, 314, 2295, 340, 781, 1172, 18590, 734, 267, 291, 14, 409, 63, 12070, 8, 797, 9, 339, 347, 641, 63, 3569, 63, 1430, 8, 277, 12, 1245, 304, 267, 408, 2461, 367, 18846, 4474, 398, 520, 635, 1245, 710, 644, 51, 1566, 4886, 267, 408, 267, 340, 291, 14, 26687, 63, 548, 26, 288, 327, 14092, 3788, 3086, 2410, 2653, 288, 20184, 14, 1757, 480, 32390, 1245, 3086, 2410, 2653, 531, 288, 372, 398, 367, 3016, 315, 291, 423, 3569, 63, 1430, 63, 5586, 26, 288, 3016, 8, 1188, 9, 339, 347, 641, 63, 3569, 63, 1490, 8, 277, 12, 4113, 304, 267, 408, 2461, 367, 18846, 6810, 11557, 12123, 398, 520, 635, 4113, 710, 644, 51, 6810, 4113, 909, 267, 408, 267 ]
[ 199, 7384, 334, 35, 9, 6171, 12, 22442, 5170, 12, 3277, 14, 199, 36, 17204, 603, 14, 491, 1024, 12, 473, 41, 665, 3011, 69, 32, 18367, 5170, 14, 957, 30, 199, 199, 2765, 2240, 365, 2867, 2032, 12, 1854, 1334, 314, 2895, 402, 199, 1589, 1664, 1696, 1684, 844, 3394, 499, 14, 199, 624, 199, 199, 646, 2197, 199, 646, 2022, 199, 646, 2050, 199, 646, 295, 199, 646, 4145, 199, 646, 5190, 199, 893, 26, 272, 687, 4011, 14, 1122, 492, 16511, 199, 2590, 26, 272, 687, 4011, 492, 16511, 199, 199, 504, 1275, 396, 63, 2546, 492, 7640, 199, 504, 1275, 396, 63, 5933, 492, 2248, 63, 460, 63, 1122, 63, 578, 199, 504, 1275, 13963, 16725, 63, 5189, 492, 10092, 53, 2916, 2617, 63, 8193, 63, 25304, 57, 4202, 272, 10092, 53, 2916, 2617, 63, 10052, 63, 25304, 57, 12, 2729, 63, 1814, 199, 504, 1275, 396, 63, 5768, 63, 1208, 492, 1006, 63, 1431, 199, 504, 7390, 14, 4901, 492, 9655, 199, 893, 26, 272, 687, 2599, 2470, 6164, 14, 13508, 492, 18846, 30115, 12, 971, 267, 18846, 3041, 3658, 12, 4907, 5035, 199, 2590, 26, 272, 687, 2599, 2470, 6164, 14, 12145, 14, 13508, 492, 18846, 30115, 12, 971, 267, 18846, 3041, 3658, 12, 4907, 5035, 199, 199, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3472, 63, 5449, 275, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 199, 3472, 63, 3657, 275, 5939, 1299, 199, 199, 12573, 3758, 15990, 370, 4868, 781, 2793, 1133, 1172, 1263, 6411, 9081, 641, 314, 199, 3, 221, 18846, 199, 5600, 2594, 63, 14747, 540, 275, 469, 272, 283, 9855, 356, 469, 267, 283, 1431, 356, 469, 288, 283, 705, 356, 18129, 3364, 2209, 17351, 267, 789, 272, 1660, 272, 283, 835, 356, 378, 199, 93, 421, 199, 533, 31153, 23170, 1692, 8, 1746, 304, 272, 408, 2543, 626, 17795, 465, 282, 1379, 6935, 315, 314, 14202, 16725, 859, 10059, 624, 339, 347, 636, 826, 721, 277, 12, 511, 63, 515, 4581, 511, 63, 888, 29, 403, 304, 267, 408, 11447, 367, 282, 511, 909, 398, 520, 635, 511, 63, 515, 710, 2615, 931, 370, 314, 511, 2909, 267, 520, 635, 511, 63, 888, 710, 18916, 511, 2897, 267, 408, 267, 1613, 8, 26291, 23170, 1692, 12, 291, 2843, 826, 721, 396, 63, 515, 12, 511, 63, 888, 9, 398, 340, 511, 63, 888, 365, 488, 26, 288, 327, 3194, 72, 12, 2951, 675, 4243, 288, 511, 63, 888, 275, 1052, 398, 291, 14, 5181, 275, 511, 63, 888, 14, 362, 360, 5181, 297, 283, 14239, 358, 267, 340, 1228, 8, 277, 14, 5181, 12, 769, 304, 288, 291, 14, 5181, 275, 12814, 904, 8, 277, 14, 5181, 9, 267, 849, 63, 1102, 275, 6186, 63, 5449, 267, 340, 291, 14, 2966, 63, 888, 14, 888, 26, 288, 465, 6236, 1339, 83, 275, 291, 14, 2966, 63, 888, 14, 888, 14, 362, 360, 305, 6236, 1339, 13, 5990, 358, 288, 340, 465, 6236, 1339, 83, 26, 355, 849, 63, 1102, 275, 465, 6236, 1339, 83, 59, 16, 2733, 1102, 418, 267, 1591, 275, 511, 63, 888, 14, 362, 360, 1102, 297, 849, 63, 1102, 9, 267, 1844, 275, 511, 63, 888, 14, 362, 360, 719, 297, 6186, 63, 3657, 9, 267, 922, 1529, 275, 334, 396, 63, 888, 14, 362, 360, 2473, 297, 283, 14239, 659, 490, 511, 63, 888, 14, 362, 360, 2060, 297, 283, 14239, 1333, 267, 23421, 63, 452, 275, 511, 63, 888, 14, 362, 360, 10108, 13, 452, 358, 398, 327, 2790, 314, 14880, 3217, 436, 314, 18846, 23616, 267, 291, 14, 759, 275, 4160, 41, 8, 1102, 12, 1844, 29, 719, 12, 922, 1529, 29, 751, 1529, 9, 267, 291, 14, 759, 63, 3702, 275, 31153, 30115, 8, 10244, 29, 277, 12, 1591, 29, 1102, 12, 1844, 29, 719, 12, 4490, 8686, 29, 277, 14, 5181, 12, 922, 1529, 29, 751, 1529, 12, 4490, 23421, 63, 452, 29, 10108, 63, 452, 9, 398, 291, 423, 3569, 63, 2105, 275, 488, 267, 291, 423, 3569, 63, 1430, 63, 5586, 275, 942, 267, 291, 423, 3569, 63, 1490, 63, 5586, 275, 942, 267, 291, 14, 26687, 63, 548, 275, 756, 398, 291, 14, 305, 6236, 1339, 63, 5990, 275, 511, 63, 888, 14, 362, 360, 305, 6236, 1339, 13, 5990, 297, 413, 9, 267, 291, 14, 981, 63, 305, 6236, 1339, 8, 835, 29, 277, 14, 305, 6236, 1339, 63, 5990, 12, 511, 63, 888, 29, 396, 63, 888, 9, 339, 347, 1255, 8, 277, 304, 267, 408, 11954, 402, 7640, 1255, 398, 12295, 1380, 9655, 9174, 436, 2410, 1006, 4454, 402, 437, 1597, 27473, 1172, 267, 8239, 267, 408, 267, 1613, 8, 26291, 23170, 1692, 12, 291, 680, 1065, 342, 267, 291, 14, 759, 63, 3702, 14, 2242, 342, 339, 347, 2274, 63, 3569, 63, 1430, 63, 2232, 8, 277, 12, 3233, 304, 267, 408, 7099, 282, 3233, 367, 1380, 376, 1566, 365, 3086, 1806, 314, 644, 51, 398, 520, 635, 3233, 710, 1083, 370, 1240, 1380, 376, 1566, 365, 3086, 14, 961, 267, 911, 1172, 282, 2849, 2725, 334, 1589, 1566, 9, 3032, 370, 652, 267, 408, 267, 291, 423, 3569, 63, 1430, 63, 5586, 14, 740, 8, 3058, 9, 339, 347, 641, 63, 13544, 63, 2593, 8, 277, 304, 267, 408, 10474, 1380, 314, 9655, 5431, 734, 624, 267, 291, 14, 26687, 63, 548, 275, 715, 267, 327, 12176, 314, 2295, 340, 781, 1172, 18590, 734, 267, 291, 14, 409, 63, 12070, 8, 797, 9, 339, 347, 641, 63, 3569, 63, 1430, 8, 277, 12, 1245, 304, 267, 408, 2461, 367, 18846, 4474, 398, 520, 635, 1245, 710, 644, 51, 1566, 4886, 267, 408, 267, 340, 291, 14, 26687, 63, 548, 26, 288, 327, 14092, 3788, 3086, 2410, 2653, 288, 20184, 14, 1757, 480, 32390, 1245, 3086, 2410, 2653, 531, 288, 372, 398, 367, 3016, 315, 291, 423, 3569, 63, 1430, 63, 5586, 26, 288, 3016, 8, 1188, 9, 339, 347, 641, 63, 3569, 63, 1490, 8, 277, 12, 4113, 304, 267, 408, 2461, 367, 18846, 6810, 11557, 12123, 398, 520, 635, 4113, 710, 644, 51, 6810, 4113, 909, 267, 408, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
CalvinChhour/GoogleTest
test/gtest_uninitialized_test.py
2901
2480
#!/usr/bin/env python # # Copyright 2008, 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. """Verifies that Google Test warns the user when not initialized properly.""" __author__ = 'wan@google.com (Zhanyong Wan)' import gtest_test_utils COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_') def Assert(condition): if not condition: raise AssertionError def AssertEq(expected, actual): if expected != actual: print 'Expected: %s' % (expected,) print ' Actual: %s' % (actual,) raise AssertionError def TestExitCodeAndOutput(command): """Runs the given command and verifies its exit code and output.""" # Verifies that 'command' exits with code 1. p = gtest_test_utils.Subprocess(command) Assert(p.exited) AssertEq(1, p.exit_code) Assert('InitGoogleTest' in p.output) class GTestUninitializedTest(gtest_test_utils.TestCase): def testExitCodeAndOutput(self): TestExitCodeAndOutput(COMMAND) if __name__ == '__main__': gtest_test_utils.Main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 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, 21168, 626, 4475, 1379, 3429, 561, 314, 922, 1380, 440, 10038, 7684, 1041, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 9088, 63, 396, 63, 1208, 421, 199, 10761, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 324, 12486, 63, 396, 15452, 421, 199, 318, 10716, 8, 5394, 304, 523, 340, 440, 5558, 26, 272, 746, 9070, 421, 199, 318, 10716, 19706, 8, 2062, 12, 3503, 304, 523, 340, 1420, 1137, 3503, 26, 272, 870, 283, 6964, 26, 450, 83, 7, 450, 334, 2062, 4258, 272, 870, 283, 221, 18982, 1061, 26, 450, 83, 7, 450, 334, 6514, 4258, 272, 746, 9070, 421, 199, 318, 1379, 6699, 3034, 3325, 2959, 8, 1531, 304, 523, 408, 16291, 314, 1627, 1414, 436, 22694, 2399, 4458, 1233, 436, 1072, 1041, 819, 327, 26114, 626, 283, 1531, 7, 20100, 543, 1233, 413, 14, 523, 299, 275, 9088, 63, 396, 63, 1208, 14, 22299, 8, 1531, 9, 523, 10716, 8, 80, 14, 32290, 9, 523, 10716, 19706, 8, 17, 12, 299, 14, 2224, 63, 600, 9, 523, 10716, 360, 9346, 13266, 774, 7, 315, 299, 14, 1199, 9, 421, 199, 533, 598, 774, 1358, 12486, 774, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 523, 347, 511, 6699, 3034, 3325, 2959, 8, 277, 304, 272, 1379, 6699, 3034, 3325, 2959, 8, 10761, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 9088, 63, 396, 63, 1208, 14, 6756, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 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, 21168, 626, 4475, 1379, 3429, 561, 314, 922, 1380, 440, 10038, 7684, 1041, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 9088, 63, 396, 63, 1208, 421, 199, 10761, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 324, 12486, 63, 396, 15452, 421, 199, 318, 10716, 8, 5394, 304, 523, 340, 440, 5558, 26, 272, 746, 9070, 421, 199, 318, 10716, 19706, 8, 2062, 12, 3503, 304, 523, 340, 1420, 1137, 3503, 26, 272, 870, 283, 6964, 26, 450, 83, 7, 450, 334, 2062, 4258, 272, 870, 283, 221, 18982, 1061, 26, 450, 83, 7, 450, 334, 6514, 4258, 272, 746, 9070, 421, 199, 318, 1379, 6699, 3034, 3325, 2959, 8, 1531, 304, 523, 408, 16291, 314, 1627, 1414, 436, 22694, 2399, 4458, 1233, 436, 1072, 1041, 819, 327, 26114, 626, 283, 1531, 7, 20100, 543, 1233, 413, 14, 523, 299, 275, 9088, 63, 396, 63, 1208, 14, 22299, 8, 1531, 9, 523, 10716, 8, 80, 14, 32290, 9, 523, 10716, 19706, 8, 17, 12, 299, 14, 2224, 63, 600, 9, 523, 10716, 360, 9346, 13266, 774, 7, 315, 299, 14, 1199, 9, 421, 199, 533, 598, 774, 1358, 12486, 774, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 523, 347, 511, 6699, 3034, 3325, 2959, 8, 277, 304, 272, 1379, 6699, 3034, 3325, 2959, 8, 10761, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 9088, 63, 396, 63, 1208, 14, 6756, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
foufou55/Sick-Beard
lib/requests/packages/urllib3/request.py
107
5427
# urllib3/request.py # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt) # # This module is part of urllib3 and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php try: from urllib.parse import urlencode except ImportError: from urllib import urlencode from .filepost import encode_multipart_formdata __all__ = ['RequestMethods'] class RequestMethods(object): """ Convenience mixin for classes who implement a :meth:`urlopen` method, such as :class:`~urllib3.connectionpool.HTTPConnectionPool` and :class:`~urllib3.poolmanager.PoolManager`. Provides behavior for making common types of HTTP request methods and decides which type of request field encoding to use. Specifically, :meth:`.request_encode_url` is for sending requests whose fields are encoded in the URL (such as GET, HEAD, DELETE). :meth:`.request_encode_body` is for sending requests whose fields are encoded in the *body* of the request using multipart or www-orm-urlencoded (such as for POST, PUT, PATCH). :meth:`.request` is for making any kind of request, it will look up the appropriate encoding format and use one of the above two methods to make the request. """ _encode_url_methods = set(['DELETE', 'GET', 'HEAD', 'OPTIONS']) _encode_body_methods = set(['PATCH', 'POST', 'PUT', 'TRACE']) def urlopen(self, method, url, body=None, headers=None, encode_multipart=True, multipart_boundary=None, **kw): # Abstract raise NotImplemented("Classes extending RequestMethods must implement " "their own ``urlopen`` method.") def request(self, method, url, fields=None, headers=None, **urlopen_kw): """ Make a request using :meth:`urlopen` with the appropriate encoding of ``fields`` based on the ``method`` used. This is a convenience method that requires the least amount of manual effort. It can be used in most situations, while still having the option to drop down to more specific methods when necessary, such as :meth:`request_encode_url`, :meth:`request_encode_body`, or even the lowest level :meth:`urlopen`. """ method = method.upper() if method in self._encode_url_methods: return self.request_encode_url(method, url, fields=fields, headers=headers, **urlopen_kw) else: return self.request_encode_body(method, url, fields=fields, headers=headers, **urlopen_kw) def request_encode_url(self, method, url, fields=None, **urlopen_kw): """ Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc. """ if fields: url += '?' + urlencode(fields) return self.urlopen(method, url, **urlopen_kw) def request_encode_body(self, method, url, fields=None, headers=None, encode_multipart=True, multipart_boundary=None, **urlopen_kw): """ Make a request using :meth:`urlopen` with the ``fields`` encoded in the body. This is useful for request methods like POST, PUT, PATCH, etc. When ``encode_multipart=True`` (default), then :meth:`urllib3.filepost.encode_multipart_formdata` is used to encode the payload with the appropriate content type. Otherwise :meth:`urllib.urlencode` is used with the 'application/x-www-form-urlencoded' content type. Multipart encoding must be used when posting files, and it's reasonably safe to use it in other times too. However, it may break request signing, such as with OAuth. Supports an optional ``fields`` parameter of key/value strings AND key/filetuple. A filetuple is a (filename, data) tuple. For example: :: fields = { 'foo': 'bar', 'fakefile': ('foofile.txt', 'contents of foofile'), 'realfile': ('barfile.txt', open('realfile').read()), 'nonamefile': ('contents of nonamefile field'), } When uploading a file, providing a filename (the first parameter of the tuple) is optional but recommended to best mimick behavior of browsers. Note that if ``headers`` are supplied, the 'Content-Type' header will be overwritten because it depends on the dynamic random boundary string which is used to compose the body of the request. The random boundary string can be explicitly set with the ``multipart_boundary`` parameter. """ if encode_multipart: body, content_type = encode_multipart_formdata(fields or {}, boundary=multipart_boundary) else: body, content_type = (urlencode(fields or {}), 'application/x-www-form-urlencoded') headers = headers or {} headers.update({'Content-Type': content_type}) return self.urlopen(method, url, body=body, headers=headers, **urlopen_kw)
gpl-3.0
[ 3, 4011, 19, 15, 1069, 14, 647, 199, 3, 1898, 9079, 13, 7409, 6061, 17885, 31449, 293, 86, 436, 8417, 334, 3239, 6483, 14, 2424, 9, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 4011, 19, 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, 893, 26, 272, 687, 4011, 14, 1122, 492, 16511, 199, 2590, 3545, 26, 272, 687, 4011, 492, 16511, 199, 199, 504, 1275, 493, 1932, 492, 3752, 63, 10123, 63, 30942, 421, 199, 363, 452, 363, 275, 788, 2017, 10385, 418, 421, 199, 533, 4784, 10385, 8, 785, 304, 272, 408, 272, 1448, 23329, 20048, 367, 3992, 3963, 5669, 282, 520, 5247, 1705, 10890, 64, 1083, 12, 4066, 272, 465, 520, 533, 6054, 4078, 19, 14, 2105, 2293, 14, 19114, 5453, 64, 436, 272, 520, 533, 6054, 4078, 19, 14, 2293, 2609, 14, 5453, 2988, 2313, 339, 21552, 5953, 367, 10663, 2863, 2943, 402, 3101, 1056, 3102, 436, 272, 12985, 3424, 1314, 730, 402, 1056, 901, 2644, 370, 675, 14, 339, 30836, 12, 339, 520, 5247, 5026, 1069, 63, 2143, 63, 633, 64, 365, 367, 10209, 4145, 7447, 1504, 787, 5737, 272, 315, 314, 2851, 334, 10180, 465, 9576, 12, 13053, 12, 15137, 680, 339, 520, 5247, 5026, 1069, 63, 2143, 63, 2030, 64, 365, 367, 10209, 4145, 7447, 1504, 787, 272, 5737, 315, 314, 627, 2030, 10, 402, 314, 1056, 1808, 15193, 503, 20732, 13, 1025, 13, 21886, 272, 334, 10180, 465, 367, 8761, 12, 18337, 12, 510, 8078, 680, 339, 520, 5247, 5026, 1069, 64, 365, 367, 10663, 1263, 4928, 402, 1056, 12, 652, 911, 3648, 1536, 314, 272, 5827, 2644, 1475, 436, 675, 1373, 402, 314, 3432, 2877, 3102, 370, 1852, 272, 314, 1056, 14, 272, 408, 339, 485, 2143, 63, 633, 63, 2474, 275, 663, 2941, 7014, 297, 283, 2970, 297, 283, 5211, 297, 283, 8808, 1105, 339, 485, 2143, 63, 2030, 63, 2474, 275, 663, 2941, 17073, 297, 283, 4030, 297, 283, 4013, 297, 283, 20112, 1105, 339, 347, 18279, 8, 277, 12, 1083, 12, 1166, 12, 2396, 29, 403, 12, 2323, 29, 403, 12, 355, 3752, 63, 10123, 29, 549, 12, 15193, 63, 9891, 29, 403, 12, 355, 1011, 829, 304, 327, 11836, 267, 746, 3784, 480, 15711, 2178, 1098, 4784, 10385, 1471, 5669, 298, 2490, 298, 1589, 723, 5705, 1124, 10890, 1040, 1083, 2685, 339, 347, 1056, 8, 277, 12, 1083, 12, 1166, 12, 1504, 29, 403, 12, 2323, 29, 403, 12, 1011, 10890, 63, 829, 304, 267, 408, 267, 4155, 282, 1056, 1808, 520, 5247, 1705, 10890, 64, 543, 314, 5827, 2644, 402, 267, 1124, 955, 1040, 4079, 641, 314, 1124, 765, 1040, 1202, 14, 398, 961, 365, 282, 16777, 1083, 626, 5074, 314, 5210, 5982, 402, 8722, 267, 28058, 14, 2779, 883, 506, 1202, 315, 4750, 24325, 12, 1830, 5139, 9445, 314, 945, 267, 370, 5978, 3224, 370, 1655, 2488, 3102, 1380, 5784, 12, 4066, 465, 267, 520, 5247, 1705, 1069, 63, 2143, 63, 633, 3559, 520, 5247, 1705, 1069, 63, 2143, 63, 2030, 3559, 267, 503, 2755, 314, 18966, 2166, 520, 5247, 1705, 10890, 2313, 267, 408, 267, 1083, 275, 1083, 14, 4142, 342, 398, 340, 1083, 315, 291, 423, 2143, 63, 633, 63, 2474, 26, 288, 372, 291, 14, 1069, 63, 2143, 63, 633, 8, 765, 12, 1166, 12, 1504, 29, 955, 12, 4490, 2323, 29, 2139, 12, 4490, 1011, 10890, 63, 829, 9, 267, 587, 26, 288, 372, 291, 14, 1069, 63, 2143, 63, 2030, 8, 765, 12, 1166, 12, 1504, 29, 955, 12, 6163, 2323, 29, 2139, 12, 6163, 1011, 10890, 63, 829, 9, 339, 347, 1056, 63, 2143, 63, 633, 8, 277, 12, 1083, 12, 1166, 12, 1504, 29, 403, 12, 1011, 10890, 63, 829, 304, 267, 408, 267, 4155, 282, 1056, 1808, 520, 5247, 1705, 10890, 64, 543, 314, 1124, 955, 1040, 5737, 315, 267, 314, 1166, 14, 961, 365, 2997, 367, 1056, 3102, 2839, 9576, 12, 13053, 12, 15137, 12, 5423, 14, 267, 408, 267, 340, 1504, 26, 288, 1166, 847, 15539, 435, 16511, 8, 955, 9, 267, 372, 291, 14, 10890, 8, 765, 12, 1166, 12, 1011, 10890, 63, 829, 9, 339, 347, 1056, 63, 2143, 63, 2030, 8, 277, 12, 1083, 12, 1166, 12, 1504, 29, 403, 12, 2323, 29, 403, 12, 1169, 3752, 63, 10123, 29, 549, 12, 15193, 63, 9891, 29, 403, 12, 1169, 1011, 10890, 63, 829, 304, 267, 408, 267, 4155, 282, 1056, 1808, 520, 5247, 1705, 10890, 64, 543, 314, 1124, 955, 1040, 5737, 315, 267, 314, 2396, 14, 961, 365, 2997, 367, 1056, 3102, 2839, 8761, 12, 18337, 12, 510, 8078, 12, 5423, 14, 398, 3979, 1124, 2143, 63, 10123, 29, 549, 1040, 334, 885, 395, 2066, 267, 520, 5247, 1705, 4078, 19, 14, 493, 1932, 14, 2143, 63, 10123, 63, 30942, 64, 365, 1202, 370, 3752, 314, 267, 4886, 543, 314, 5827, 1564, 730, 14, 6630, 267, 520, 5247, 1705, 4078, 14, 10738, 64, 365, 1202, 543, 314, 267, 283, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 7, 1564, 730, 14, 398, 6879, 2064, 2644, 1471, 506, 1202, 1380, 25386, 1584, 12, 436, 652, 1159, 4499, 6665, 267, 5048, 370, 675, 652, 315, 1163, 5431, 4634, 14, 9738, 12, 652, 1443, 2059, 1056, 18057, 12, 267, 4066, 465, 543, 11715, 14, 398, 32090, 376, 2716, 1124, 955, 1040, 2725, 402, 790, 15, 585, 3326, 2401, 267, 790, 15, 493, 2960, 14, 437, 570, 2960, 365, 282, 334, 1501, 12, 666, 9, 2008, 14, 2104, 2893, 26, 3800, 953, 1504, 275, 469, 355, 283, 1421, 356, 283, 1700, 297, 355, 283, 3183, 493, 356, 661, 1421, 493, 14, 2424, 297, 283, 4407, 402, 3925, 493, 659, 355, 283, 264, 7411, 441, 356, 661, 1700, 493, 14, 2424, 297, 1551, 360, 264, 7411, 441, 1959, 739, 4000, 355, 283, 2865, 313, 493, 356, 661, 4407, 402, 2222, 313, 493, 901, 659, 288, 789, 398, 3979, 24349, 282, 570, 12, 13070, 282, 1788, 334, 1589, 1642, 2725, 402, 314, 267, 2008, 9, 365, 2716, 1325, 14318, 370, 5526, 24102, 2000, 5953, 402, 23776, 14, 398, 3390, 626 ]
[ 4011, 19, 15, 1069, 14, 647, 199, 3, 1898, 9079, 13, 7409, 6061, 17885, 31449, 293, 86, 436, 8417, 334, 3239, 6483, 14, 2424, 9, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 4011, 19, 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, 893, 26, 272, 687, 4011, 14, 1122, 492, 16511, 199, 2590, 3545, 26, 272, 687, 4011, 492, 16511, 199, 199, 504, 1275, 493, 1932, 492, 3752, 63, 10123, 63, 30942, 421, 199, 363, 452, 363, 275, 788, 2017, 10385, 418, 421, 199, 533, 4784, 10385, 8, 785, 304, 272, 408, 272, 1448, 23329, 20048, 367, 3992, 3963, 5669, 282, 520, 5247, 1705, 10890, 64, 1083, 12, 4066, 272, 465, 520, 533, 6054, 4078, 19, 14, 2105, 2293, 14, 19114, 5453, 64, 436, 272, 520, 533, 6054, 4078, 19, 14, 2293, 2609, 14, 5453, 2988, 2313, 339, 21552, 5953, 367, 10663, 2863, 2943, 402, 3101, 1056, 3102, 436, 272, 12985, 3424, 1314, 730, 402, 1056, 901, 2644, 370, 675, 14, 339, 30836, 12, 339, 520, 5247, 5026, 1069, 63, 2143, 63, 633, 64, 365, 367, 10209, 4145, 7447, 1504, 787, 5737, 272, 315, 314, 2851, 334, 10180, 465, 9576, 12, 13053, 12, 15137, 680, 339, 520, 5247, 5026, 1069, 63, 2143, 63, 2030, 64, 365, 367, 10209, 4145, 7447, 1504, 787, 272, 5737, 315, 314, 627, 2030, 10, 402, 314, 1056, 1808, 15193, 503, 20732, 13, 1025, 13, 21886, 272, 334, 10180, 465, 367, 8761, 12, 18337, 12, 510, 8078, 680, 339, 520, 5247, 5026, 1069, 64, 365, 367, 10663, 1263, 4928, 402, 1056, 12, 652, 911, 3648, 1536, 314, 272, 5827, 2644, 1475, 436, 675, 1373, 402, 314, 3432, 2877, 3102, 370, 1852, 272, 314, 1056, 14, 272, 408, 339, 485, 2143, 63, 633, 63, 2474, 275, 663, 2941, 7014, 297, 283, 2970, 297, 283, 5211, 297, 283, 8808, 1105, 339, 485, 2143, 63, 2030, 63, 2474, 275, 663, 2941, 17073, 297, 283, 4030, 297, 283, 4013, 297, 283, 20112, 1105, 339, 347, 18279, 8, 277, 12, 1083, 12, 1166, 12, 2396, 29, 403, 12, 2323, 29, 403, 12, 355, 3752, 63, 10123, 29, 549, 12, 15193, 63, 9891, 29, 403, 12, 355, 1011, 829, 304, 327, 11836, 267, 746, 3784, 480, 15711, 2178, 1098, 4784, 10385, 1471, 5669, 298, 2490, 298, 1589, 723, 5705, 1124, 10890, 1040, 1083, 2685, 339, 347, 1056, 8, 277, 12, 1083, 12, 1166, 12, 1504, 29, 403, 12, 2323, 29, 403, 12, 1011, 10890, 63, 829, 304, 267, 408, 267, 4155, 282, 1056, 1808, 520, 5247, 1705, 10890, 64, 543, 314, 5827, 2644, 402, 267, 1124, 955, 1040, 4079, 641, 314, 1124, 765, 1040, 1202, 14, 398, 961, 365, 282, 16777, 1083, 626, 5074, 314, 5210, 5982, 402, 8722, 267, 28058, 14, 2779, 883, 506, 1202, 315, 4750, 24325, 12, 1830, 5139, 9445, 314, 945, 267, 370, 5978, 3224, 370, 1655, 2488, 3102, 1380, 5784, 12, 4066, 465, 267, 520, 5247, 1705, 1069, 63, 2143, 63, 633, 3559, 520, 5247, 1705, 1069, 63, 2143, 63, 2030, 3559, 267, 503, 2755, 314, 18966, 2166, 520, 5247, 1705, 10890, 2313, 267, 408, 267, 1083, 275, 1083, 14, 4142, 342, 398, 340, 1083, 315, 291, 423, 2143, 63, 633, 63, 2474, 26, 288, 372, 291, 14, 1069, 63, 2143, 63, 633, 8, 765, 12, 1166, 12, 1504, 29, 955, 12, 4490, 2323, 29, 2139, 12, 4490, 1011, 10890, 63, 829, 9, 267, 587, 26, 288, 372, 291, 14, 1069, 63, 2143, 63, 2030, 8, 765, 12, 1166, 12, 1504, 29, 955, 12, 6163, 2323, 29, 2139, 12, 6163, 1011, 10890, 63, 829, 9, 339, 347, 1056, 63, 2143, 63, 633, 8, 277, 12, 1083, 12, 1166, 12, 1504, 29, 403, 12, 1011, 10890, 63, 829, 304, 267, 408, 267, 4155, 282, 1056, 1808, 520, 5247, 1705, 10890, 64, 543, 314, 1124, 955, 1040, 5737, 315, 267, 314, 1166, 14, 961, 365, 2997, 367, 1056, 3102, 2839, 9576, 12, 13053, 12, 15137, 12, 5423, 14, 267, 408, 267, 340, 1504, 26, 288, 1166, 847, 15539, 435, 16511, 8, 955, 9, 267, 372, 291, 14, 10890, 8, 765, 12, 1166, 12, 1011, 10890, 63, 829, 9, 339, 347, 1056, 63, 2143, 63, 2030, 8, 277, 12, 1083, 12, 1166, 12, 1504, 29, 403, 12, 2323, 29, 403, 12, 1169, 3752, 63, 10123, 29, 549, 12, 15193, 63, 9891, 29, 403, 12, 1169, 1011, 10890, 63, 829, 304, 267, 408, 267, 4155, 282, 1056, 1808, 520, 5247, 1705, 10890, 64, 543, 314, 1124, 955, 1040, 5737, 315, 267, 314, 2396, 14, 961, 365, 2997, 367, 1056, 3102, 2839, 8761, 12, 18337, 12, 510, 8078, 12, 5423, 14, 398, 3979, 1124, 2143, 63, 10123, 29, 549, 1040, 334, 885, 395, 2066, 267, 520, 5247, 1705, 4078, 19, 14, 493, 1932, 14, 2143, 63, 10123, 63, 30942, 64, 365, 1202, 370, 3752, 314, 267, 4886, 543, 314, 5827, 1564, 730, 14, 6630, 267, 520, 5247, 1705, 4078, 14, 10738, 64, 365, 1202, 543, 314, 267, 283, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 7, 1564, 730, 14, 398, 6879, 2064, 2644, 1471, 506, 1202, 1380, 25386, 1584, 12, 436, 652, 1159, 4499, 6665, 267, 5048, 370, 675, 652, 315, 1163, 5431, 4634, 14, 9738, 12, 652, 1443, 2059, 1056, 18057, 12, 267, 4066, 465, 543, 11715, 14, 398, 32090, 376, 2716, 1124, 955, 1040, 2725, 402, 790, 15, 585, 3326, 2401, 267, 790, 15, 493, 2960, 14, 437, 570, 2960, 365, 282, 334, 1501, 12, 666, 9, 2008, 14, 2104, 2893, 26, 3800, 953, 1504, 275, 469, 355, 283, 1421, 356, 283, 1700, 297, 355, 283, 3183, 493, 356, 661, 1421, 493, 14, 2424, 297, 283, 4407, 402, 3925, 493, 659, 355, 283, 264, 7411, 441, 356, 661, 1700, 493, 14, 2424, 297, 1551, 360, 264, 7411, 441, 1959, 739, 4000, 355, 283, 2865, 313, 493, 356, 661, 4407, 402, 2222, 313, 493, 901, 659, 288, 789, 398, 3979, 24349, 282, 570, 12, 13070, 282, 1788, 334, 1589, 1642, 2725, 402, 314, 267, 2008, 9, 365, 2716, 1325, 14318, 370, 5526, 24102, 2000, 5953, 402, 23776, 14, 398, 3390, 626, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
caot/intellij-community
python/lib/Lib/site-packages/django/contrib/localflavor/cl/forms.py
110
3188
""" Chile specific form helpers. """ from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import RegexField, Select from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_unicode class CLRegionSelect(Select): """ A Select widget that uses a list of Chilean Regions (Regiones) as its choices. """ def __init__(self, attrs=None): from cl_regions import REGION_CHOICES super(CLRegionSelect, self).__init__(attrs, choices=REGION_CHOICES) class CLRutField(RegexField): """ Chilean "Rol Unico Tributario" (RUT) field. This is the Chilean national identification number. Samples for testing are available from https://palena.sii.cl/cvc/dte/ee_empresas_emisoras.html """ default_error_messages = { 'invalid': _('Enter a valid Chilean RUT.'), 'strict': _('Enter a valid Chilean RUT. The format is XX.XXX.XXX-X.'), 'checksum': _('The Chilean RUT is not valid.'), } def __init__(self, *args, **kwargs): if 'strict' in kwargs: del kwargs['strict'] super(CLRutField, self).__init__(r'^(\d{1,2}\.)?\d{3}\.\d{3}-[\dkK]$', error_message=self.default_error_messages['strict'], *args, **kwargs) else: # In non-strict mode, accept RUTs that validate but do not exist in # the real world. super(CLRutField, self).__init__(r'^[\d\.]{1,11}-?[\dkK]$', *args, **kwargs) def clean(self, value): """ Check and clean the Chilean RUT. """ super(CLRutField, self).clean(value) if value in EMPTY_VALUES: return u'' rut, verificador = self._canonify(value) if self._algorithm(rut) == verificador: return self._format(rut, verificador) else: raise ValidationError(self.error_messages['checksum']) def _algorithm(self, rut): """ Takes RUT in pure canonical form, calculates the verifier digit. """ suma = 0 multi = 2 for r in rut[::-1]: suma += int(r) * multi multi += 1 if multi == 8: multi = 2 return u'0123456789K0'[11 - suma % 11] def _canonify(self, rut): """ Turns the RUT into one normalized format. Returns a (rut, verifier) tuple. """ rut = smart_unicode(rut).replace(' ', '').replace('.', '').replace('-', '') return rut[:-1], rut[-1] def _format(self, code, verifier=None): """ Formats the RUT from canonical form to the common string representation. If verifier=None, then the last digit in 'code' is the verifier. """ if verifier is None: verifier = code[-1] code = code[:-1] while len(code) > 3 and '.' not in code[:3]: pos = code.find('.') if pos == -1: new_dot = -3 else: new_dot = pos - 3 code = code[:new_dot] + '.' + code[new_dot:] return u'%s-%s' % (code, verifier)
apache-2.0
[ 624, 199, 1049, 441, 2488, 1824, 10897, 14, 199, 624, 199, 199, 504, 1639, 14, 1018, 14, 11346, 492, 16589, 63, 15514, 199, 504, 1639, 14, 3351, 492, 8505, 199, 504, 1639, 14, 3351, 14, 955, 492, 12939, 792, 12, 9496, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 2975, 421, 199, 533, 13354, 10708, 5446, 8, 5446, 304, 272, 408, 272, 437, 9496, 3938, 626, 4440, 282, 769, 402, 2799, 441, 290, 5044, 15293, 334, 2872, 73, 4548, 9, 272, 465, 2399, 3415, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 687, 824, 63, 11963, 492, 14142, 1075, 63, 16236, 267, 1613, 8, 1981, 10708, 5446, 12, 291, 2843, 826, 721, 3288, 12, 3415, 29, 23030, 63, 16236, 9, 199, 199, 533, 13354, 50, 337, 792, 8, 5103, 792, 304, 272, 408, 272, 2799, 441, 290, 298, 50, 393, 1910, 12802, 12480, 7911, 6936, 2, 334, 50, 934, 9, 901, 14, 961, 365, 314, 2799, 441, 290, 302, 6279, 272, 29193, 1329, 14, 339, 428, 1889, 367, 5343, 787, 2808, 687, 272, 4178, 921, 387, 552, 65, 14, 338, 73, 14, 429, 15, 5107, 67, 15, 68, 266, 15, 1024, 63, 2109, 470, 305, 63, 69, 1292, 269, 305, 14, 1360, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 2799, 441, 290, 820, 934, 8038, 267, 283, 4768, 356, 4018, 8468, 282, 1686, 2799, 441, 290, 820, 934, 14, 710, 1475, 365, 1323, 56, 14, 13933, 14, 13933, 13, 56, 8038, 267, 283, 8928, 356, 4018, 1918, 2799, 441, 290, 820, 934, 365, 440, 1686, 8038, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 283, 4768, 7, 315, 2074, 26, 288, 2150, 2074, 459, 4768, 418, 288, 1613, 8, 25346, 337, 792, 12, 291, 2843, 826, 721, 82, 31344, 68, 91, 17, 12, 18, 93, 20316, 60, 68, 91, 19, 4988, 3134, 68, 91, 19, 17063, 7023, 6341, 43, 61, 4268, 355, 1125, 63, 1188, 29, 277, 14, 885, 63, 705, 63, 3431, 459, 4768, 995, 627, 589, 12, 1011, 958, 9, 267, 587, 26, 288, 327, 1010, 2222, 13, 4768, 818, 12, 4729, 820, 934, 83, 626, 4107, 1325, 886, 440, 2187, 315, 288, 327, 314, 3363, 6701, 14, 288, 1613, 8, 25346, 337, 792, 12, 291, 2843, 826, 721, 82, 4289, 7023, 68, 4537, 8194, 17, 12, 845, 17063, 31, 7023, 6341, 43, 61, 4268, 627, 589, 12, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 408, 267, 2670, 436, 3633, 314, 2799, 441, 290, 820, 934, 14, 267, 408, 267, 1613, 8, 25346, 337, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 519, 337, 12, 809, 12061, 25453, 275, 291, 423, 2425, 265, 2021, 8, 585, 9, 267, 340, 291, 423, 8833, 8, 82, 337, 9, 508, 809, 12061, 25453, 26, 288, 372, 291, 423, 908, 8, 82, 337, 12, 809, 12061, 25453, 9, 267, 587, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 8928, 1105, 339, 347, 485, 8833, 8, 277, 12, 519, 337, 304, 267, 408, 267, 17415, 820, 934, 315, 15111, 11358, 1824, 12, 6966, 2335, 314, 25581, 10964, 14, 267, 408, 267, 18741, 391, 221, 275, 378, 267, 3510, 275, 499, 267, 367, 519, 315, 519, 337, 14172, 17, 2189, 288, 18741, 391, 221, 847, 1109, 8, 82, 9, 627, 3510, 288, 3510, 847, 413, 288, 340, 3510, 508, 1695, 26, 355, 3510, 275, 499, 267, 372, 399, 7, 11371, 43, 16, 3894, 845, 446, 18741, 391, 450, 4119, 61, 339, 347, 485, 2425, 265, 2021, 8, 277, 12, 519, 337, 304, 267, 408, 267, 16147, 83, 314, 820, 934, 1901, 1373, 9657, 1475, 14, 1803, 282, 334, 82, 337, 12, 25581, 9, 267, 2008, 14, 267, 408, 267, 519, 337, 275, 11179, 63, 2975, 8, 82, 337, 680, 1814, 360, 1656, 12548, 1814, 14078, 12548, 1814, 13858, 4074, 267, 372, 519, 337, 4439, 17, 467, 519, 337, 1988, 17, 61, 339, 347, 485, 908, 8, 277, 12, 1233, 12, 25581, 29, 403, 304, 267, 408, 267, 9701, 83, 314, 820, 934, 687, 11358, 1824, 370, 314, 2863, 1059, 6025, 14, 267, 982, 25581, 29, 403, 12, 2066, 314, 2061, 10964, 315, 283, 600, 7, 365, 314, 25581, 14, 267, 408, 267, 340, 25581, 365, 488, 26, 288, 25581, 275, 1233, 1988, 17, 61, 288, 1233, 275, 1233, 4439, 17, 61, 267, 1830, 822, 8, 600, 9, 690, 650, 436, 7815, 440, 315, 1233, 1491, 19, 2189, 288, 2086, 275, 1233, 14, 1623, 7563, 288, 340, 2086, 508, 446, 17, 26, 355, 892, 63, 3287, 275, 446, 19, 288, 587, 26, 355, 892, 63, 3287, 275, 2086, 446, 650, 288, 1233, 275, 1233, 1491, 1222, 63, 3287, 61, 435, 7815, 435, 1233, 59, 1222, 63, 3287, 2938, 267, 372, 399, 5956, 83, 3295, 83, 7, 450, 334, 600, 12, 25581, 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 ]
[ 199, 1049, 441, 2488, 1824, 10897, 14, 199, 624, 199, 199, 504, 1639, 14, 1018, 14, 11346, 492, 16589, 63, 15514, 199, 504, 1639, 14, 3351, 492, 8505, 199, 504, 1639, 14, 3351, 14, 955, 492, 12939, 792, 12, 9496, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 2975, 421, 199, 533, 13354, 10708, 5446, 8, 5446, 304, 272, 408, 272, 437, 9496, 3938, 626, 4440, 282, 769, 402, 2799, 441, 290, 5044, 15293, 334, 2872, 73, 4548, 9, 272, 465, 2399, 3415, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 687, 824, 63, 11963, 492, 14142, 1075, 63, 16236, 267, 1613, 8, 1981, 10708, 5446, 12, 291, 2843, 826, 721, 3288, 12, 3415, 29, 23030, 63, 16236, 9, 199, 199, 533, 13354, 50, 337, 792, 8, 5103, 792, 304, 272, 408, 272, 2799, 441, 290, 298, 50, 393, 1910, 12802, 12480, 7911, 6936, 2, 334, 50, 934, 9, 901, 14, 961, 365, 314, 2799, 441, 290, 302, 6279, 272, 29193, 1329, 14, 339, 428, 1889, 367, 5343, 787, 2808, 687, 272, 4178, 921, 387, 552, 65, 14, 338, 73, 14, 429, 15, 5107, 67, 15, 68, 266, 15, 1024, 63, 2109, 470, 305, 63, 69, 1292, 269, 305, 14, 1360, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 2799, 441, 290, 820, 934, 8038, 267, 283, 4768, 356, 4018, 8468, 282, 1686, 2799, 441, 290, 820, 934, 14, 710, 1475, 365, 1323, 56, 14, 13933, 14, 13933, 13, 56, 8038, 267, 283, 8928, 356, 4018, 1918, 2799, 441, 290, 820, 934, 365, 440, 1686, 8038, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 283, 4768, 7, 315, 2074, 26, 288, 2150, 2074, 459, 4768, 418, 288, 1613, 8, 25346, 337, 792, 12, 291, 2843, 826, 721, 82, 31344, 68, 91, 17, 12, 18, 93, 20316, 60, 68, 91, 19, 4988, 3134, 68, 91, 19, 17063, 7023, 6341, 43, 61, 4268, 355, 1125, 63, 1188, 29, 277, 14, 885, 63, 705, 63, 3431, 459, 4768, 995, 627, 589, 12, 1011, 958, 9, 267, 587, 26, 288, 327, 1010, 2222, 13, 4768, 818, 12, 4729, 820, 934, 83, 626, 4107, 1325, 886, 440, 2187, 315, 288, 327, 314, 3363, 6701, 14, 288, 1613, 8, 25346, 337, 792, 12, 291, 2843, 826, 721, 82, 4289, 7023, 68, 4537, 8194, 17, 12, 845, 17063, 31, 7023, 6341, 43, 61, 4268, 627, 589, 12, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 408, 267, 2670, 436, 3633, 314, 2799, 441, 290, 820, 934, 14, 267, 408, 267, 1613, 8, 25346, 337, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 519, 337, 12, 809, 12061, 25453, 275, 291, 423, 2425, 265, 2021, 8, 585, 9, 267, 340, 291, 423, 8833, 8, 82, 337, 9, 508, 809, 12061, 25453, 26, 288, 372, 291, 423, 908, 8, 82, 337, 12, 809, 12061, 25453, 9, 267, 587, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 8928, 1105, 339, 347, 485, 8833, 8, 277, 12, 519, 337, 304, 267, 408, 267, 17415, 820, 934, 315, 15111, 11358, 1824, 12, 6966, 2335, 314, 25581, 10964, 14, 267, 408, 267, 18741, 391, 221, 275, 378, 267, 3510, 275, 499, 267, 367, 519, 315, 519, 337, 14172, 17, 2189, 288, 18741, 391, 221, 847, 1109, 8, 82, 9, 627, 3510, 288, 3510, 847, 413, 288, 340, 3510, 508, 1695, 26, 355, 3510, 275, 499, 267, 372, 399, 7, 11371, 43, 16, 3894, 845, 446, 18741, 391, 450, 4119, 61, 339, 347, 485, 2425, 265, 2021, 8, 277, 12, 519, 337, 304, 267, 408, 267, 16147, 83, 314, 820, 934, 1901, 1373, 9657, 1475, 14, 1803, 282, 334, 82, 337, 12, 25581, 9, 267, 2008, 14, 267, 408, 267, 519, 337, 275, 11179, 63, 2975, 8, 82, 337, 680, 1814, 360, 1656, 12548, 1814, 14078, 12548, 1814, 13858, 4074, 267, 372, 519, 337, 4439, 17, 467, 519, 337, 1988, 17, 61, 339, 347, 485, 908, 8, 277, 12, 1233, 12, 25581, 29, 403, 304, 267, 408, 267, 9701, 83, 314, 820, 934, 687, 11358, 1824, 370, 314, 2863, 1059, 6025, 14, 267, 982, 25581, 29, 403, 12, 2066, 314, 2061, 10964, 315, 283, 600, 7, 365, 314, 25581, 14, 267, 408, 267, 340, 25581, 365, 488, 26, 288, 25581, 275, 1233, 1988, 17, 61, 288, 1233, 275, 1233, 4439, 17, 61, 267, 1830, 822, 8, 600, 9, 690, 650, 436, 7815, 440, 315, 1233, 1491, 19, 2189, 288, 2086, 275, 1233, 14, 1623, 7563, 288, 340, 2086, 508, 446, 17, 26, 355, 892, 63, 3287, 275, 446, 19, 288, 587, 26, 355, 892, 63, 3287, 275, 2086, 446, 650, 288, 1233, 275, 1233, 1491, 1222, 63, 3287, 61, 435, 7815, 435, 1233, 59, 1222, 63, 3287, 2938, 267, 372, 399, 5956, 83, 3295, 83, 7, 450, 334, 600, 12, 25581, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
EZchip/gdb
gdb/testsuite/gdb.python/py-pp-maint.py
19
2875
# Copyright (C) 2010-2012 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # This file is part of the GDB testsuite. It tests python pretty # printers. import re import gdb.types import gdb.printing def lookup_function_lookup_test(val): class PrintFunctionLookup(object): def __init__(self, val): self.val = val def to_string(self): return ("x=<" + str(self.val["x"]) + "> y=<" + str(self.val["y"]) + ">") typename = gdb.types.get_basic_type(val.type).tag # Note: typename could be None. if typename == "function_lookup_test": return PrintFunctionLookup(val) return None class pp_s: def __init__(self, val): self.val = val def to_string(self): a = self.val["a"] b = self.val["b"] if a.address != b: raise Exception("&a(%s) != b(%s)" % (str(a.address), str(b))) return "a=<" + str(self.val["a"]) + "> b=<" + str(self.val["b"]) + ">" class pp_ss: def __init__(self, val): self.val = val def to_string(self): return "a=<" + str(self.val["a"]) + "> b=<" + str(self.val["b"]) + ">" def build_pretty_printer(): pp = gdb.printing.RegexpCollectionPrettyPrinter("pp-test") pp.add_printer('struct s', '^struct s$', pp_s) pp.add_printer('s', '^s$', pp_s) # Use a lambda this time to exercise doing things this way. pp.add_printer('struct ss', '^struct ss$', lambda val: pp_ss(val)) pp.add_printer('ss', '^ss$', lambda val: pp_ss(val)) pp.add_printer('enum flag_enum', '^flag_enum$', gdb.printing.FlagEnumerationPrinter('enum flag_enum')) return pp gdb.printing.register_pretty_printer(gdb, lookup_function_lookup_test) my_pretty_printer = build_pretty_printer() gdb.printing.register_pretty_printer(gdb, my_pretty_printer) # Exercise the "replace" argument to register pretty_printer. saw_runtime_error = False try: gdb.printing.register_pretty_printer(gdb, my_pretty_printer, replace=False) except RuntimeError: saw_runtime_error = True pass if not saw_runtime_error: raise RuntimeError("Missing RuntimeError from register_pretty_printer") gdb.printing.register_pretty_printer(gdb, my_pretty_printer, replace=True)
gpl-2.0
[ 3, 1898, 334, 35, 9, 7129, 13, 7409, 2868, 2290, 2752, 12, 3277, 14, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 961, 570, 365, 1777, 402, 314, 598, 2846, 2295, 2577, 14, 221, 2779, 2295, 2366, 7268, 199, 3, 5448, 11005, 14, 199, 199, 646, 295, 199, 646, 12124, 14, 1313, 199, 646, 12124, 14, 26514, 421, 199, 318, 4237, 63, 1593, 63, 3892, 63, 396, 8, 637, 304, 272, 1021, 9101, 3481, 7521, 8, 785, 304, 267, 347, 636, 826, 721, 277, 12, 1139, 304, 288, 291, 14, 637, 275, 1139, 398, 347, 370, 63, 875, 8, 277, 304, 288, 372, 1689, 88, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 88, 3135, 435, 490, 15281, 612, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 89, 3135, 435, 298, 9579, 339, 19151, 275, 12124, 14, 1313, 14, 362, 63, 4316, 63, 466, 8, 637, 14, 466, 680, 1450, 272, 327, 3390, 26, 19151, 4293, 506, 488, 14, 272, 340, 19151, 508, 298, 1593, 63, 3892, 63, 396, 582, 267, 372, 9101, 3481, 7521, 8, 637, 9, 272, 372, 488, 421, 199, 533, 11618, 63, 83, 26, 272, 347, 636, 826, 721, 277, 12, 1139, 304, 267, 291, 14, 637, 275, 1139, 339, 347, 370, 63, 875, 8, 277, 304, 267, 282, 275, 291, 14, 637, 905, 65, 937, 267, 330, 275, 291, 14, 637, 905, 66, 937, 267, 340, 282, 14, 1562, 1137, 330, 26, 288, 746, 2186, 22077, 65, 4042, 83, 9, 1137, 330, 4042, 83, 2924, 450, 334, 495, 8, 65, 14, 1562, 395, 620, 8, 66, 1724, 267, 372, 298, 65, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 65, 3135, 435, 15281, 330, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 66, 3135, 435, 28192, 421, 199, 533, 11618, 63, 385, 26, 272, 347, 636, 826, 721, 277, 12, 1139, 304, 267, 291, 14, 637, 275, 1139, 339, 347, 370, 63, 875, 8, 277, 304, 267, 372, 298, 65, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 65, 3135, 435, 15281, 330, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 66, 3135, 435, 28192, 421, 199, 318, 1900, 63, 9118, 63, 11835, 837, 272, 11618, 275, 12124, 14, 26514, 14, 8357, 7768, 27153, 14131, 480, 802, 13, 396, 531, 339, 11618, 14, 525, 63, 11835, 360, 1820, 308, 297, 14452, 1820, 308, 4268, 11618, 63, 83, 9, 272, 11618, 14, 525, 63, 11835, 360, 83, 297, 14452, 83, 4268, 11618, 63, 83, 9, 339, 327, 3645, 282, 2400, 642, 900, 370, 26511, 9689, 7645, 642, 4340, 14, 272, 11618, 14, 525, 63, 11835, 360, 1820, 10110, 297, 14452, 1820, 10110, 4268, 2400, 1139, 26, 11618, 63, 385, 8, 637, 430, 272, 11618, 14, 525, 63, 11835, 360, 385, 297, 14452, 385, 4268, 2400, 1139, 26, 11618, 63, 385, 8, 637, 430, 339, 11618, 14, 525, 63, 11835, 360, 4869, 3305, 63, 4869, 297, 14452, 4173, 63, 4869, 4268, 673, 12124, 14, 26514, 14, 5318, 13425, 14131, 360, 4869, 3305, 63, 4869, 1333, 339, 372, 11618, 421, 199, 17119, 14, 26514, 14, 2683, 63, 9118, 63, 11835, 8, 17119, 12, 4237, 63, 1593, 63, 3892, 63, 396, 9, 199, 1662, 63, 9118, 63, 11835, 275, 1900, 63, 9118, 63, 11835, 342, 199, 17119, 14, 26514, 14, 2683, 63, 9118, 63, 11835, 8, 17119, 12, 3002, 63, 9118, 63, 11835, 9, 199, 199, 3, 1316, 20616, 314, 298, 1814, 2, 1423, 370, 2274, 7268, 63, 11835, 14, 199, 2231, 87, 63, 7726, 63, 705, 275, 756, 199, 893, 26, 523, 12124, 14, 26514, 14, 2683, 63, 9118, 63, 11835, 8, 17119, 12, 3002, 63, 9118, 63, 11835, 12, 3350, 29, 797, 9, 199, 2590, 6064, 26, 523, 28454, 63, 7726, 63, 705, 275, 715, 523, 986, 199, 692, 440, 28454, 63, 7726, 63, 705, 26, 523, 746, 6064, 480, 7718, 6064, 687, 2274, 63, 9118, 63, 11835, 531, 199, 17119, 14, 26514, 14, 2683, 63, 9118, 63, 11835, 8, 17119, 12, 3002, 63, 9118, 63, 11835, 12, 3350, 29, 549, 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 ]
[ 1898, 334, 35, 9, 7129, 13, 7409, 2868, 2290, 2752, 12, 3277, 14, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 961, 570, 365, 1777, 402, 314, 598, 2846, 2295, 2577, 14, 221, 2779, 2295, 2366, 7268, 199, 3, 5448, 11005, 14, 199, 199, 646, 295, 199, 646, 12124, 14, 1313, 199, 646, 12124, 14, 26514, 421, 199, 318, 4237, 63, 1593, 63, 3892, 63, 396, 8, 637, 304, 272, 1021, 9101, 3481, 7521, 8, 785, 304, 267, 347, 636, 826, 721, 277, 12, 1139, 304, 288, 291, 14, 637, 275, 1139, 398, 347, 370, 63, 875, 8, 277, 304, 288, 372, 1689, 88, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 88, 3135, 435, 490, 15281, 612, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 89, 3135, 435, 298, 9579, 339, 19151, 275, 12124, 14, 1313, 14, 362, 63, 4316, 63, 466, 8, 637, 14, 466, 680, 1450, 272, 327, 3390, 26, 19151, 4293, 506, 488, 14, 272, 340, 19151, 508, 298, 1593, 63, 3892, 63, 396, 582, 267, 372, 9101, 3481, 7521, 8, 637, 9, 272, 372, 488, 421, 199, 533, 11618, 63, 83, 26, 272, 347, 636, 826, 721, 277, 12, 1139, 304, 267, 291, 14, 637, 275, 1139, 339, 347, 370, 63, 875, 8, 277, 304, 267, 282, 275, 291, 14, 637, 905, 65, 937, 267, 330, 275, 291, 14, 637, 905, 66, 937, 267, 340, 282, 14, 1562, 1137, 330, 26, 288, 746, 2186, 22077, 65, 4042, 83, 9, 1137, 330, 4042, 83, 2924, 450, 334, 495, 8, 65, 14, 1562, 395, 620, 8, 66, 1724, 267, 372, 298, 65, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 65, 3135, 435, 15281, 330, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 66, 3135, 435, 28192, 421, 199, 533, 11618, 63, 385, 26, 272, 347, 636, 826, 721, 277, 12, 1139, 304, 267, 291, 14, 637, 275, 1139, 339, 347, 370, 63, 875, 8, 277, 304, 267, 372, 298, 65, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 65, 3135, 435, 15281, 330, 18987, 2, 435, 620, 8, 277, 14, 637, 905, 66, 3135, 435, 28192, 421, 199, 318, 1900, 63, 9118, 63, 11835, 837, 272, 11618, 275, 12124, 14, 26514, 14, 8357, 7768, 27153, 14131, 480, 802, 13, 396, 531, 339, 11618, 14, 525, 63, 11835, 360, 1820, 308, 297, 14452, 1820, 308, 4268, 11618, 63, 83, 9, 272, 11618, 14, 525, 63, 11835, 360, 83, 297, 14452, 83, 4268, 11618, 63, 83, 9, 339, 327, 3645, 282, 2400, 642, 900, 370, 26511, 9689, 7645, 642, 4340, 14, 272, 11618, 14, 525, 63, 11835, 360, 1820, 10110, 297, 14452, 1820, 10110, 4268, 2400, 1139, 26, 11618, 63, 385, 8, 637, 430, 272, 11618, 14, 525, 63, 11835, 360, 385, 297, 14452, 385, 4268, 2400, 1139, 26, 11618, 63, 385, 8, 637, 430, 339, 11618, 14, 525, 63, 11835, 360, 4869, 3305, 63, 4869, 297, 14452, 4173, 63, 4869, 4268, 673, 12124, 14, 26514, 14, 5318, 13425, 14131, 360, 4869, 3305, 63, 4869, 1333, 339, 372, 11618, 421, 199, 17119, 14, 26514, 14, 2683, 63, 9118, 63, 11835, 8, 17119, 12, 4237, 63, 1593, 63, 3892, 63, 396, 9, 199, 1662, 63, 9118, 63, 11835, 275, 1900, 63, 9118, 63, 11835, 342, 199, 17119, 14, 26514, 14, 2683, 63, 9118, 63, 11835, 8, 17119, 12, 3002, 63, 9118, 63, 11835, 9, 199, 199, 3, 1316, 20616, 314, 298, 1814, 2, 1423, 370, 2274, 7268, 63, 11835, 14, 199, 2231, 87, 63, 7726, 63, 705, 275, 756, 199, 893, 26, 523, 12124, 14, 26514, 14, 2683, 63, 9118, 63, 11835, 8, 17119, 12, 3002, 63, 9118, 63, 11835, 12, 3350, 29, 797, 9, 199, 2590, 6064, 26, 523, 28454, 63, 7726, 63, 705, 275, 715, 523, 986, 199, 692, 440, 28454, 63, 7726, 63, 705, 26, 523, 746, 6064, 480, 7718, 6064, 687, 2274, 63, 9118, 63, 11835, 531, 199, 17119, 14, 26514, 14, 2683, 63, 9118, 63, 11835, 8, 17119, 12, 3002, 63, 9118, 63, 11835, 12, 3350, 29, 549, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
joachimmetz/plaso
plaso/analyzers/manager.py
4
3480
# -*- coding: utf-8 -*- """This file contains a class for managing digest analyzers for Plaso.""" class AnalyzersManager(object): """Class that implements the analyzers manager.""" _analyzer_classes = {} @classmethod def DeregisterAnalyzer(cls, analyzer_class): """Deregisters a analyzer class. The analyzer classes are identified based on their lower case name. Args: analyzer_class (type): class object of the analyzer. Raises: KeyError: if analyzer class is not set for the corresponding name. """ analyzer_name = analyzer_class.NAME.lower() if analyzer_name not in cls._analyzer_classes: raise KeyError('analyzer class not set for name: {0:s}'.format( analyzer_class.NAME)) del cls._analyzer_classes[analyzer_name] @classmethod def GetAnalyzersInformation(cls): """Retrieves the analyzers information. Returns: list[tuple]: containing: str: analyzer name. str: analyzer description. """ analyzer_information = [] for _, analyzer_class in cls.GetAnalyzers(): description = getattr(analyzer_class, 'DESCRIPTION', '') analyzer_information.append((analyzer_class.NAME, description)) return analyzer_information @classmethod def GetAnalyzerInstance(cls, analyzer_name): """Retrieves an instance of a specific analyzer. Args: analyzer_name (str): name of the analyzer to retrieve. Returns: BaseAnalyzer: analyzer instance. Raises: KeyError: if analyzer class is not set for the corresponding name. """ analyzer_name = analyzer_name.lower() if analyzer_name not in cls._analyzer_classes: raise KeyError( 'analyzer class not set for name: {0:s}.'.format(analyzer_name)) analyzer_class = cls._analyzer_classes[analyzer_name] return analyzer_class() @classmethod def GetAnalyzerInstances(cls, analyzer_names): """Retrieves instances for all the specified analyzers. Args: analyzer_names (list[str]): names of the analyzers to retrieve. Returns: list[BaseAnalyzer]: analyzer instances. """ analyzer_instances = [] for analyzer_name, analyzer_class in cls.GetAnalyzers(): if analyzer_name in analyzer_names: analyzer_instances.append(analyzer_class()) return analyzer_instances @classmethod def GetAnalyzerNames(cls): """Retrieves the names of all loaded analyzers. Returns: list[str]: of analyzer names. """ return cls._analyzer_classes.keys() @classmethod def GetAnalyzers(cls): """Retrieves the registered analyzers. Yields: tuple: containing: str: the uniquely identifying name of the analyzer type: the analyzer class. """ for analyzer_name, analyzer_class in cls._analyzer_classes.items(): yield analyzer_name, analyzer_class @classmethod def RegisterAnalyzer(cls, analyzer_class): """Registers a analyzer class. The analyzer classes are identified by their lower case name. Args: analyzer_class (type): the analyzer class to register. Raises: KeyError: if analyzer class is already set for the corresponding name. """ analyzer_name = analyzer_class.NAME.lower() if analyzer_name in cls._analyzer_classes: raise KeyError('analyzer class already set for name: {0:s}.'.format( analyzer_class.NAME)) cls._analyzer_classes[analyzer_name] = analyzer_class
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2765, 570, 3509, 282, 1021, 367, 28453, 10017, 5909, 90, 1192, 367, 7497, 305, 79, 1041, 421, 199, 533, 14279, 90, 1192, 2988, 8, 785, 304, 523, 408, 2543, 626, 9031, 314, 5909, 90, 1192, 5256, 1041, 819, 485, 17965, 63, 2888, 275, 1052, 819, 768, 3744, 523, 347, 1487, 2683, 17606, 8, 1886, 12, 24608, 63, 533, 304, 272, 408, 872, 30792, 282, 24608, 1021, 14, 339, 710, 24608, 3992, 787, 15836, 4079, 641, 3932, 5117, 1930, 536, 14, 339, 3033, 26, 489, 24608, 63, 533, 334, 466, 304, 1021, 909, 402, 314, 24608, 14, 339, 6218, 26, 489, 4067, 26, 340, 24608, 1021, 365, 440, 663, 367, 314, 5226, 536, 14, 272, 408, 272, 24608, 63, 354, 275, 24608, 63, 533, 14, 2339, 14, 2325, 342, 272, 340, 24608, 63, 354, 440, 315, 843, 423, 17965, 63, 2888, 26, 489, 746, 4067, 360, 17965, 1021, 440, 663, 367, 536, 26, 469, 16, 26, 83, 5285, 908, 8, 881, 24608, 63, 533, 14, 2339, 430, 339, 2150, 843, 423, 17965, 63, 2888, 59, 17965, 63, 354, 61, 819, 768, 3744, 523, 347, 2372, 8014, 90, 1192, 4935, 8, 1886, 304, 272, 408, 28112, 314, 5909, 90, 1192, 2556, 14, 339, 1803, 26, 489, 769, 59, 2960, 2189, 3035, 26, 398, 620, 26, 24608, 536, 14, 267, 620, 26, 24608, 1369, 14, 272, 408, 272, 24608, 63, 11697, 275, 942, 272, 367, 5501, 24608, 63, 533, 315, 843, 14, 1002, 8014, 90, 1192, 837, 489, 1369, 275, 2519, 8, 17965, 63, 533, 12, 283, 17705, 297, 4074, 489, 24608, 63, 11697, 14, 740, 1332, 17965, 63, 533, 14, 2339, 12, 1369, 430, 339, 372, 24608, 63, 11697, 819, 768, 3744, 523, 347, 2372, 17606, 3244, 8, 1886, 12, 24608, 63, 354, 304, 272, 408, 28112, 376, 1256, 402, 282, 2488, 24608, 14, 339, 3033, 26, 489, 24608, 63, 354, 334, 495, 304, 536, 402, 314, 24608, 370, 8044, 14, 339, 1803, 26, 489, 3523, 17606, 26, 24608, 1256, 14, 339, 6218, 26, 489, 4067, 26, 340, 24608, 1021, 365, 440, 663, 367, 314, 5226, 536, 14, 272, 408, 272, 24608, 63, 354, 275, 24608, 63, 354, 14, 2325, 342, 272, 340, 24608, 63, 354, 440, 315, 843, 423, 17965, 63, 2888, 26, 489, 746, 4067, 8, 881, 283, 17965, 1021, 440, 663, 367, 536, 26, 469, 16, 26, 83, 5565, 1370, 908, 8, 17965, 63, 354, 430, 339, 24608, 63, 533, 275, 843, 423, 17965, 63, 2888, 59, 17965, 63, 354, 61, 272, 372, 24608, 63, 533, 342, 819, 768, 3744, 523, 347, 2372, 17606, 18194, 8, 1886, 12, 24608, 63, 1247, 304, 272, 408, 28112, 4454, 367, 1006, 314, 2013, 5909, 90, 1192, 14, 339, 3033, 26, 489, 24608, 63, 1247, 334, 513, 59, 495, 4682, 1561, 402, 314, 5909, 90, 1192, 370, 8044, 14, 339, 1803, 26, 489, 769, 59, 1563, 17606, 2189, 24608, 4454, 14, 272, 408, 272, 24608, 63, 5990, 275, 942, 272, 367, 24608, 63, 354, 12, 24608, 63, 533, 315, 843, 14, 1002, 8014, 90, 1192, 837, 489, 340, 24608, 63, 354, 315, 24608, 63, 1247, 26, 267, 24608, 63, 5990, 14, 740, 8, 17965, 63, 533, 1012, 339, 372, 24608, 63, 5990, 819, 768, 3744, 523, 347, 2372, 17606, 5866, 8, 1886, 304, 272, 408, 28112, 314, 1561, 402, 1006, 6511, 5909, 90, 1192, 14, 339, 1803, 26, 489, 769, 59, 495, 2189, 402, 24608, 1561, 14, 272, 408, 272, 372, 843, 423, 17965, 63, 2888, 14, 1612, 342, 819, 768, 3744, 523, 347, 2372, 8014, 90, 1192, 8, 1886, 304, 272, 408, 28112, 314, 7264, 5909, 90, 1192, 14, 339, 23771, 83, 26, 489, 2008, 26, 3035, 26, 398, 620, 26, 314, 28727, 21119, 536, 402, 314, 24608, 267, 730, 26, 314, 24608, 1021, 14, 272, 408, 272, 367, 24608, 63, 354, 12, 24608, 63, 533, 315, 843, 423, 17965, 63, 2888, 14, 1744, 837, 489, 1995, 24608, 63, 354, 12, 24608, 63, 533, 819, 768, 3744, 523, 347, 11828, 17606, 8, 1886, 12, 24608, 63, 533, 304, 272, 408, 31136, 282, 24608, 1021, 14, 339, 710, 24608, 3992, 787, 15836, 701, 3932, 5117, 1930, 536, 14, 339, 3033, 26, 489, 24608, 63, 533, 334, 466, 304, 314, 24608, 1021, 370, 2274, 14, 339, 6218, 26, 489, 4067, 26, 340, 24608, 1021, 365, 2575, 663, 367, 314, 5226, 536, 14, 272, 408, 272, 24608, 63, 354, 275, 24608, 63, 533, 14, 2339, 14, 2325, 342, 272, 340, 24608, 63, 354, 315, 843, 423, 17965, 63, 2888, 26, 489, 746, 4067, 360, 17965, 1021, 2575, 663, 367, 536, 26, 469, 16, 26, 83, 5565, 1370, 908, 8, 881, 24608, 63, 533, 14, 2339, 430, 339, 843, 423, 17965, 63, 2888, 59, 17965, 63, 354, 61, 275, 24608, 63, 533, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2765, 570, 3509, 282, 1021, 367, 28453, 10017, 5909, 90, 1192, 367, 7497, 305, 79, 1041, 421, 199, 533, 14279, 90, 1192, 2988, 8, 785, 304, 523, 408, 2543, 626, 9031, 314, 5909, 90, 1192, 5256, 1041, 819, 485, 17965, 63, 2888, 275, 1052, 819, 768, 3744, 523, 347, 1487, 2683, 17606, 8, 1886, 12, 24608, 63, 533, 304, 272, 408, 872, 30792, 282, 24608, 1021, 14, 339, 710, 24608, 3992, 787, 15836, 4079, 641, 3932, 5117, 1930, 536, 14, 339, 3033, 26, 489, 24608, 63, 533, 334, 466, 304, 1021, 909, 402, 314, 24608, 14, 339, 6218, 26, 489, 4067, 26, 340, 24608, 1021, 365, 440, 663, 367, 314, 5226, 536, 14, 272, 408, 272, 24608, 63, 354, 275, 24608, 63, 533, 14, 2339, 14, 2325, 342, 272, 340, 24608, 63, 354, 440, 315, 843, 423, 17965, 63, 2888, 26, 489, 746, 4067, 360, 17965, 1021, 440, 663, 367, 536, 26, 469, 16, 26, 83, 5285, 908, 8, 881, 24608, 63, 533, 14, 2339, 430, 339, 2150, 843, 423, 17965, 63, 2888, 59, 17965, 63, 354, 61, 819, 768, 3744, 523, 347, 2372, 8014, 90, 1192, 4935, 8, 1886, 304, 272, 408, 28112, 314, 5909, 90, 1192, 2556, 14, 339, 1803, 26, 489, 769, 59, 2960, 2189, 3035, 26, 398, 620, 26, 24608, 536, 14, 267, 620, 26, 24608, 1369, 14, 272, 408, 272, 24608, 63, 11697, 275, 942, 272, 367, 5501, 24608, 63, 533, 315, 843, 14, 1002, 8014, 90, 1192, 837, 489, 1369, 275, 2519, 8, 17965, 63, 533, 12, 283, 17705, 297, 4074, 489, 24608, 63, 11697, 14, 740, 1332, 17965, 63, 533, 14, 2339, 12, 1369, 430, 339, 372, 24608, 63, 11697, 819, 768, 3744, 523, 347, 2372, 17606, 3244, 8, 1886, 12, 24608, 63, 354, 304, 272, 408, 28112, 376, 1256, 402, 282, 2488, 24608, 14, 339, 3033, 26, 489, 24608, 63, 354, 334, 495, 304, 536, 402, 314, 24608, 370, 8044, 14, 339, 1803, 26, 489, 3523, 17606, 26, 24608, 1256, 14, 339, 6218, 26, 489, 4067, 26, 340, 24608, 1021, 365, 440, 663, 367, 314, 5226, 536, 14, 272, 408, 272, 24608, 63, 354, 275, 24608, 63, 354, 14, 2325, 342, 272, 340, 24608, 63, 354, 440, 315, 843, 423, 17965, 63, 2888, 26, 489, 746, 4067, 8, 881, 283, 17965, 1021, 440, 663, 367, 536, 26, 469, 16, 26, 83, 5565, 1370, 908, 8, 17965, 63, 354, 430, 339, 24608, 63, 533, 275, 843, 423, 17965, 63, 2888, 59, 17965, 63, 354, 61, 272, 372, 24608, 63, 533, 342, 819, 768, 3744, 523, 347, 2372, 17606, 18194, 8, 1886, 12, 24608, 63, 1247, 304, 272, 408, 28112, 4454, 367, 1006, 314, 2013, 5909, 90, 1192, 14, 339, 3033, 26, 489, 24608, 63, 1247, 334, 513, 59, 495, 4682, 1561, 402, 314, 5909, 90, 1192, 370, 8044, 14, 339, 1803, 26, 489, 769, 59, 1563, 17606, 2189, 24608, 4454, 14, 272, 408, 272, 24608, 63, 5990, 275, 942, 272, 367, 24608, 63, 354, 12, 24608, 63, 533, 315, 843, 14, 1002, 8014, 90, 1192, 837, 489, 340, 24608, 63, 354, 315, 24608, 63, 1247, 26, 267, 24608, 63, 5990, 14, 740, 8, 17965, 63, 533, 1012, 339, 372, 24608, 63, 5990, 819, 768, 3744, 523, 347, 2372, 17606, 5866, 8, 1886, 304, 272, 408, 28112, 314, 1561, 402, 1006, 6511, 5909, 90, 1192, 14, 339, 1803, 26, 489, 769, 59, 495, 2189, 402, 24608, 1561, 14, 272, 408, 272, 372, 843, 423, 17965, 63, 2888, 14, 1612, 342, 819, 768, 3744, 523, 347, 2372, 8014, 90, 1192, 8, 1886, 304, 272, 408, 28112, 314, 7264, 5909, 90, 1192, 14, 339, 23771, 83, 26, 489, 2008, 26, 3035, 26, 398, 620, 26, 314, 28727, 21119, 536, 402, 314, 24608, 267, 730, 26, 314, 24608, 1021, 14, 272, 408, 272, 367, 24608, 63, 354, 12, 24608, 63, 533, 315, 843, 423, 17965, 63, 2888, 14, 1744, 837, 489, 1995, 24608, 63, 354, 12, 24608, 63, 533, 819, 768, 3744, 523, 347, 11828, 17606, 8, 1886, 12, 24608, 63, 533, 304, 272, 408, 31136, 282, 24608, 1021, 14, 339, 710, 24608, 3992, 787, 15836, 701, 3932, 5117, 1930, 536, 14, 339, 3033, 26, 489, 24608, 63, 533, 334, 466, 304, 314, 24608, 1021, 370, 2274, 14, 339, 6218, 26, 489, 4067, 26, 340, 24608, 1021, 365, 2575, 663, 367, 314, 5226, 536, 14, 272, 408, 272, 24608, 63, 354, 275, 24608, 63, 533, 14, 2339, 14, 2325, 342, 272, 340, 24608, 63, 354, 315, 843, 423, 17965, 63, 2888, 26, 489, 746, 4067, 360, 17965, 1021, 2575, 663, 367, 536, 26, 469, 16, 26, 83, 5565, 1370, 908, 8, 881, 24608, 63, 533, 14, 2339, 430, 339, 843, 423, 17965, 63, 2888, 59, 17965, 63, 354, 61, 275, 24608, 63, 533, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
cechrist/cardoon
cardoon/devices/cppaddev.py
1
5902
"""CppAD device interface. Provides functions to implement evaluation of nonlinear equations and derivatives using the pycppad library: http://www.seanet.com/~bradbell/pycppad/index.xml Usage: ===== import cppaddev as ad ... def process_params(self): ... # Add the following at the end to make sure tape is re-generated ad.delete_tape(self) def set_temp_vars(self, temp): ... # Add the following at the end to make sure tape is re-generated ad.delete_tape(self) # Use automatic differentiation for eval and deriv function eval_and_deriv = ad.eval_and_deriv eval = ad.eval Note1: This module disables printing of RuntimeWarnings. Comment the filterwarnings line to see warnings. Note2: use the condassign() function below to replace any if statements dependent on AD variables in eval_cqs() and set_temp_vars(). Otherwise, you have to re-tape at each iteration (call delete_tape() at the end of eval() and eval_and_deriv() in that device. If statements dependent on device parameters are OK (if we are not doing sensitivities). ------------------------------------------------------------------- Copyright Carlos Christoffersen <c.christoffersen@ieee.org> This file is part of the cardoon electronic circuit simulator. Cardoon is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later: http://www.gnu.org/licenses/gpl.html """ from __future__ import print_function import numpy as np import pycppad as ad import warnings def safe_exp(x): """ Same as exp() except when x is greater than threshold. It has continuous derivatives. """ threshold = 50. c = np.exp(x) d = np.exp(threshold) * (x - threshold + 1.) if type(x) == ad.cppad_.a_float: return ad.condexp_lt(x, ad.ad(threshold), c, d) else: if x < threshold: return c else: return d def condassign(b, c, d): """ Returns the result of (b>0)? c : d Use instead of if statements to force taping both c and d expressions. Uses type(b) to decide if ad.condexp_gt() should be called, so make sure this an ad type if you are generating a tape. """ if type(b) == ad.cppad_.a_float: try: return ad.condexp_gt(b, ad.ad(0.), c, d) except: # Had to catch all because could not find exception name if type(c) != ad.cppad_.a_float: c = ad.ad(c) if type(d) != ad.cppad_.a_float: d = ad.ad(d) return ad.condexp_gt(b, ad.ad(0.), c, d) else: if b > 0.: #print('a',end='') return c else: #print('b',end='') return d def delete_tape(dev): """ Delete CppAD tape, if any. Call this function (in process_params) to make sure tape is re-generated """ try: del(dev._func) # del(dev._opfunc) except AttributeError: # do nothing if tape does not exist pass def create_tape(dev, vPort): """ Generate main CppAD tape Normally there is no need to call this function manually as tapes are generated as needed. """ #import pdb; pdb.set_trace() assert dev.isNonlinear # Create derivative vector a_vPort = ad.independent(vPort) # perform actual calculation (i_out, q_out) = dev.eval_cqs(a_vPort) # Concatenate vectors as we want only one tape to be generated a_out = np.concatenate((i_out, q_out), axis=0) # Save main function tape dev._func = ad.adfun(a_vPort, a_out) # optimize main function tape dev._func.optimize() def eval_and_deriv(dev, vPort): """ Evaluates current and charge sources of a nonlinear device. vPort is a numpy vector with input voltages Returns a tuple with one vector for currents and charges and another for the jacobian. """ #import pdb; pdb.set_trace() try: fout = dev._func.forward(0, vPort) except AttributeError: create_tape(dev, vPort) fout = dev._func.forward(0, vPort) try: jac = dev._func.jacobian(vPort) except ValueError as e: # Derivative can not be calculated: Return a zero jacobian # (an alternative would be using a numerical derivative) warnings.warn(e.message,RuntimeWarning) jac = np.zeros((len(fout), len(vPort)), dtype=float) return (fout, jac) def eval(dev, vPort): """ Evaluates current and charge sources of a nonlinear device. vPort is a numpy vector with input voltages """ try: return dev._func.forward(0, vPort) except AttributeError: create_tape(dev, vPort) return dev._func.forward(0, vPort) # The following no longer needed as operating point variables no # longer handled by the AD library # def create_OP_tape(dev, vPort): # """ # Generate operating point CppAD tape # # Normally there is no need to call this function manually as tapes # are generated as needed. # """ # assert dev.isNonlinear # a_vPort = ad.independent(vPort) # (i_out, q_out, a_opvars) = dev.eval_cqs(a_vPort, saveOP=True) # # Save operating point variable tape # dev._opfunc = ad.adfun(a_vPort, a_opvars) # # optimize tape (if needed uncomment) # # dev._opfunc.optimize() # def get_op_vars(dev, vPort): # """ # Evaluates OP variables of a nonlinear device. # # vPort is a numpy vector with input voltages # # Returns OP variables # """ # #import pdb; pdb.set_trace() # try: # opvars = dev._opfunc.forward(0, vPort) # except AttributeError: # create_OP_tape(dev, vPort) # opvars = dev._opfunc.forward(0, vPort) # # return opvars
gpl-3.0
[ 624, 19705, 1554, 2243, 3217, 14, 21552, 3423, 370, 5669, 11735, 402, 199, 2865, 6676, 26426, 436, 28059, 1808, 314, 1134, 5910, 350, 3555, 26, 199, 199, 1014, 921, 1544, 14, 261, 290, 386, 14, 957, 22500, 7828, 697, 1697, 15, 647, 5910, 350, 15, 1080, 14, 1652, 199, 199, 7692, 26, 199, 19989, 199, 199, 646, 7246, 350, 2374, 465, 1503, 199, 1396, 339, 347, 2112, 63, 1162, 8, 277, 304, 267, 2263, 267, 327, 2654, 314, 2569, 737, 314, 1284, 370, 1852, 3238, 307, 924, 365, 295, 13, 10176, 267, 1503, 14, 1807, 63, 502, 321, 8, 277, 9, 339, 347, 663, 63, 808, 63, 2936, 8, 277, 12, 2388, 304, 267, 2263, 267, 327, 2654, 314, 2569, 737, 314, 1284, 370, 1852, 3238, 307, 924, 365, 295, 13, 10176, 267, 1503, 14, 1807, 63, 502, 321, 8, 277, 9, 339, 327, 3645, 4834, 26796, 425, 367, 3468, 436, 13624, 805, 272, 3468, 63, 460, 63, 17922, 275, 1503, 14, 2579, 63, 460, 63, 17922, 272, 3468, 275, 1503, 14, 2579, 199, 199, 7443, 17, 26, 961, 859, 28421, 16116, 402, 19103, 15921, 14, 6819, 314, 199, 23945, 1004, 370, 1937, 3598, 14, 1362, 199, 7443, 18, 26, 675, 314, 9288, 5038, 342, 805, 5084, 370, 3350, 1263, 340, 199, 15384, 11410, 641, 16271, 2860, 315, 3468, 63, 67, 6177, 342, 436, 199, 409, 63, 808, 63, 2936, 1252, 6630, 12, 1265, 1172, 370, 295, 13, 502, 321, 737, 1924, 8494, 199, 8, 1250, 3145, 63, 502, 321, 342, 737, 314, 1284, 402, 3468, 342, 436, 3468, 63, 460, 63, 17922, 342, 315, 626, 199, 1782, 14, 199, 199, 3917, 9834, 11410, 641, 2243, 2633, 787, 9949, 334, 692, 781, 787, 440, 199, 1117, 316, 4334, 338, 15805, 680, 199, 199, 3606, 2595, 199, 7384, 14243, 11560, 2799, 18824, 12786, 2464, 665, 67, 14, 335, 18824, 12786, 2464, 32, 73, 18777, 14, 1308, 30, 199, 199, 2765, 570, 365, 1777, 402, 314, 12564, 79, 265, 325, 16728, 530, 20304, 15797, 14, 199, 199, 13832, 79, 265, 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, 1015, 650, 503, 2945, 26, 199, 199, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 199, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 2680, 465, 980, 199, 646, 1134, 5910, 350, 465, 1503, 199, 646, 3598, 199, 199, 318, 5048, 63, 1474, 8, 88, 304, 272, 408, 272, 14766, 465, 1437, 342, 871, 1380, 671, 365, 8932, 2419, 8765, 14, 2779, 965, 272, 19922, 28059, 14, 272, 408, 14821, 8765, 275, 5238, 14, 272, 286, 275, 980, 14, 1474, 8, 88, 9, 272, 366, 275, 980, 14, 1474, 8, 7227, 9, 627, 334, 88, 446, 8765, 435, 413, 4959, 272, 340, 730, 8, 88, 9, 508, 1503, 14, 5910, 350, 3754, 65, 63, 1609, 26, 267, 372, 1503, 14, 388, 31450, 63, 4116, 8, 88, 12, 1503, 14, 350, 8, 7227, 395, 286, 12, 366, 9, 272, 587, 26, 267, 340, 671, 665, 8765, 26, 288, 372, 286, 267, 587, 26, 288, 372, 366, 199, 199, 318, 9288, 5038, 8, 66, 12, 286, 12, 366, 304, 272, 408, 272, 1803, 314, 754, 402, 334, 66, 30, 16, 5547, 286, 520, 366, 18407, 3645, 3140, 402, 340, 9834, 370, 3542, 307, 17818, 3865, 286, 436, 366, 272, 8455, 14, 14911, 730, 8, 66, 9, 370, 19822, 340, 1503, 14, 388, 31450, 63, 3308, 342, 1077, 506, 272, 2797, 12, 880, 1852, 3238, 642, 376, 1503, 730, 340, 1265, 787, 12999, 282, 307, 924, 14, 272, 408, 272, 340, 730, 8, 66, 9, 508, 1503, 14, 5910, 350, 3754, 65, 63, 1609, 26, 267, 862, 26, 288, 372, 1503, 14, 388, 31450, 63, 3308, 8, 66, 12, 1503, 14, 350, 8, 16, 15631, 286, 12, 366, 9, 267, 871, 26, 288, 327, 869, 350, 370, 8579, 1006, 2952, 4293, 440, 2342, 1919, 536, 288, 340, 730, 8, 67, 9, 1137, 1503, 14, 5910, 350, 3754, 65, 63, 1609, 26, 355, 286, 275, 1503, 14, 350, 8, 67, 9, 288, 340, 730, 8, 68, 9, 1137, 1503, 14, 5910, 350, 3754, 65, 63, 1609, 26, 355, 366, 275, 1503, 14, 350, 8, 68, 9, 288, 372, 1503, 14, 388, 31450, 63, 3308, 8, 66, 12, 1503, 14, 350, 8, 16, 15631, 286, 12, 366, 9, 272, 587, 26, 267, 340, 330, 690, 378, 16781, 288, 327, 1361, 360, 65, 297, 500, 13275, 288, 372, 286, 267, 587, 26, 288, 327, 1361, 360, 66, 297, 500, 13275, 288, 372, 366, 421, 199, 318, 3145, 63, 502, 321, 8, 2374, 304, 272, 408, 272, 8496, 445, 802, 1554, 307, 924, 12, 340, 1263, 14, 339, 6523, 642, 805, 334, 262, 2112, 63, 1162, 9, 370, 1852, 3238, 307, 924, 365, 272, 295, 13, 10176, 272, 408, 272, 862, 26, 267, 2150, 8, 2374, 423, 1532, 9, 267, 327, 2150, 8, 2374, 423, 411, 1532, 9, 272, 871, 4281, 26, 267, 327, 886, 6548, 340, 307, 924, 1630, 440, 2187, 267, 986, 199, 199, 318, 1218, 63, 502, 321, 8, 2374, 12, 373, 4313, 304, 272, 408, 272, 7958, 2446, 445, 802, 1554, 307, 924, 339, 24573, 2337, 365, 949, 1929, 370, 1240, 642, 805, 10250, 465, 307, 924, 83, 272, 787, 4046, 465, 4346, 14, 272, 408, 272, 327, 646, 10543, 27, 10543, 14, 409, 63, 3446, 342, 272, 702, 4866, 14, 374, 6932, 6676, 272, 327, 2790, 18883, 5477, 272, 282, 63, 86, 4313, 275, 1503, 14, 26083, 8, 86, 4313, 9, 272, 327, 5147, 3503, 15232, 5591, 334, 73, 63, 548, 12, 1894, 63, 548, 9, 275, 4866, 14, 2579, 63, 67, 6177, 8, 65, 63, 86, 4313, 9, 272, 327, 1448, 10592, 11102, 465, 781, 2934, 1454, 1373, 307, 924, 370, 506, 4046, 272, 282, 63, 548, 275, 980, 14, 13433, 1332, 73, 63, 548, 12, 1894, 63, 548, 395, 3114, 29, 16, 9, 272, 327, 11063, 2446, 805, 307, 924, 272, 4866, 423, 1532, 275, 1503, 14, 350, 7036, 8, 65, 63, 86 ]
[ 19705, 1554, 2243, 3217, 14, 21552, 3423, 370, 5669, 11735, 402, 199, 2865, 6676, 26426, 436, 28059, 1808, 314, 1134, 5910, 350, 3555, 26, 199, 199, 1014, 921, 1544, 14, 261, 290, 386, 14, 957, 22500, 7828, 697, 1697, 15, 647, 5910, 350, 15, 1080, 14, 1652, 199, 199, 7692, 26, 199, 19989, 199, 199, 646, 7246, 350, 2374, 465, 1503, 199, 1396, 339, 347, 2112, 63, 1162, 8, 277, 304, 267, 2263, 267, 327, 2654, 314, 2569, 737, 314, 1284, 370, 1852, 3238, 307, 924, 365, 295, 13, 10176, 267, 1503, 14, 1807, 63, 502, 321, 8, 277, 9, 339, 347, 663, 63, 808, 63, 2936, 8, 277, 12, 2388, 304, 267, 2263, 267, 327, 2654, 314, 2569, 737, 314, 1284, 370, 1852, 3238, 307, 924, 365, 295, 13, 10176, 267, 1503, 14, 1807, 63, 502, 321, 8, 277, 9, 339, 327, 3645, 4834, 26796, 425, 367, 3468, 436, 13624, 805, 272, 3468, 63, 460, 63, 17922, 275, 1503, 14, 2579, 63, 460, 63, 17922, 272, 3468, 275, 1503, 14, 2579, 199, 199, 7443, 17, 26, 961, 859, 28421, 16116, 402, 19103, 15921, 14, 6819, 314, 199, 23945, 1004, 370, 1937, 3598, 14, 1362, 199, 7443, 18, 26, 675, 314, 9288, 5038, 342, 805, 5084, 370, 3350, 1263, 340, 199, 15384, 11410, 641, 16271, 2860, 315, 3468, 63, 67, 6177, 342, 436, 199, 409, 63, 808, 63, 2936, 1252, 6630, 12, 1265, 1172, 370, 295, 13, 502, 321, 737, 1924, 8494, 199, 8, 1250, 3145, 63, 502, 321, 342, 737, 314, 1284, 402, 3468, 342, 436, 3468, 63, 460, 63, 17922, 342, 315, 626, 199, 1782, 14, 199, 199, 3917, 9834, 11410, 641, 2243, 2633, 787, 9949, 334, 692, 781, 787, 440, 199, 1117, 316, 4334, 338, 15805, 680, 199, 199, 3606, 2595, 199, 7384, 14243, 11560, 2799, 18824, 12786, 2464, 665, 67, 14, 335, 18824, 12786, 2464, 32, 73, 18777, 14, 1308, 30, 199, 199, 2765, 570, 365, 1777, 402, 314, 12564, 79, 265, 325, 16728, 530, 20304, 15797, 14, 199, 199, 13832, 79, 265, 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, 1015, 650, 503, 2945, 26, 199, 199, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 199, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 2680, 465, 980, 199, 646, 1134, 5910, 350, 465, 1503, 199, 646, 3598, 199, 199, 318, 5048, 63, 1474, 8, 88, 304, 272, 408, 272, 14766, 465, 1437, 342, 871, 1380, 671, 365, 8932, 2419, 8765, 14, 2779, 965, 272, 19922, 28059, 14, 272, 408, 14821, 8765, 275, 5238, 14, 272, 286, 275, 980, 14, 1474, 8, 88, 9, 272, 366, 275, 980, 14, 1474, 8, 7227, 9, 627, 334, 88, 446, 8765, 435, 413, 4959, 272, 340, 730, 8, 88, 9, 508, 1503, 14, 5910, 350, 3754, 65, 63, 1609, 26, 267, 372, 1503, 14, 388, 31450, 63, 4116, 8, 88, 12, 1503, 14, 350, 8, 7227, 395, 286, 12, 366, 9, 272, 587, 26, 267, 340, 671, 665, 8765, 26, 288, 372, 286, 267, 587, 26, 288, 372, 366, 199, 199, 318, 9288, 5038, 8, 66, 12, 286, 12, 366, 304, 272, 408, 272, 1803, 314, 754, 402, 334, 66, 30, 16, 5547, 286, 520, 366, 18407, 3645, 3140, 402, 340, 9834, 370, 3542, 307, 17818, 3865, 286, 436, 366, 272, 8455, 14, 14911, 730, 8, 66, 9, 370, 19822, 340, 1503, 14, 388, 31450, 63, 3308, 342, 1077, 506, 272, 2797, 12, 880, 1852, 3238, 642, 376, 1503, 730, 340, 1265, 787, 12999, 282, 307, 924, 14, 272, 408, 272, 340, 730, 8, 66, 9, 508, 1503, 14, 5910, 350, 3754, 65, 63, 1609, 26, 267, 862, 26, 288, 372, 1503, 14, 388, 31450, 63, 3308, 8, 66, 12, 1503, 14, 350, 8, 16, 15631, 286, 12, 366, 9, 267, 871, 26, 288, 327, 869, 350, 370, 8579, 1006, 2952, 4293, 440, 2342, 1919, 536, 288, 340, 730, 8, 67, 9, 1137, 1503, 14, 5910, 350, 3754, 65, 63, 1609, 26, 355, 286, 275, 1503, 14, 350, 8, 67, 9, 288, 340, 730, 8, 68, 9, 1137, 1503, 14, 5910, 350, 3754, 65, 63, 1609, 26, 355, 366, 275, 1503, 14, 350, 8, 68, 9, 288, 372, 1503, 14, 388, 31450, 63, 3308, 8, 66, 12, 1503, 14, 350, 8, 16, 15631, 286, 12, 366, 9, 272, 587, 26, 267, 340, 330, 690, 378, 16781, 288, 327, 1361, 360, 65, 297, 500, 13275, 288, 372, 286, 267, 587, 26, 288, 327, 1361, 360, 66, 297, 500, 13275, 288, 372, 366, 421, 199, 318, 3145, 63, 502, 321, 8, 2374, 304, 272, 408, 272, 8496, 445, 802, 1554, 307, 924, 12, 340, 1263, 14, 339, 6523, 642, 805, 334, 262, 2112, 63, 1162, 9, 370, 1852, 3238, 307, 924, 365, 272, 295, 13, 10176, 272, 408, 272, 862, 26, 267, 2150, 8, 2374, 423, 1532, 9, 267, 327, 2150, 8, 2374, 423, 411, 1532, 9, 272, 871, 4281, 26, 267, 327, 886, 6548, 340, 307, 924, 1630, 440, 2187, 267, 986, 199, 199, 318, 1218, 63, 502, 321, 8, 2374, 12, 373, 4313, 304, 272, 408, 272, 7958, 2446, 445, 802, 1554, 307, 924, 339, 24573, 2337, 365, 949, 1929, 370, 1240, 642, 805, 10250, 465, 307, 924, 83, 272, 787, 4046, 465, 4346, 14, 272, 408, 272, 327, 646, 10543, 27, 10543, 14, 409, 63, 3446, 342, 272, 702, 4866, 14, 374, 6932, 6676, 272, 327, 2790, 18883, 5477, 272, 282, 63, 86, 4313, 275, 1503, 14, 26083, 8, 86, 4313, 9, 272, 327, 5147, 3503, 15232, 5591, 334, 73, 63, 548, 12, 1894, 63, 548, 9, 275, 4866, 14, 2579, 63, 67, 6177, 8, 65, 63, 86, 4313, 9, 272, 327, 1448, 10592, 11102, 465, 781, 2934, 1454, 1373, 307, 924, 370, 506, 4046, 272, 282, 63, 548, 275, 980, 14, 13433, 1332, 73, 63, 548, 12, 1894, 63, 548, 395, 3114, 29, 16, 9, 272, 327, 11063, 2446, 805, 307, 924, 272, 4866, 423, 1532, 275, 1503, 14, 350, 7036, 8, 65, 63, 86, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
piiswrong/mxnet
tools/caffe_converter/convert_symbol.py
35
13432
# 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. """Convert caffe prototxt to symbol """ from __future__ import print_function import argparse import re import caffe_parser def _get_input(proto): """Get input size """ layer = caffe_parser.get_layers(proto) if len(proto.input_dim) > 0: input_dim = proto.input_dim elif len(proto.input_shape) > 0: input_dim = proto.input_shape[0].dim elif layer[0].type == "Input": input_dim = layer[0].input_param.shape[0].dim layer.pop(0) else: raise ValueError('Cannot find input size') assert layer[0].type != "Input", 'only support single input' # We assume the first bottom blob of first layer is the output from data layer input_name = layer[0].bottom[0] return input_name, input_dim, layer def _convert_conv_param(param): """ Convert convolution layer parameter from Caffe to MXNet """ param_string = "num_filter=%d" % param.num_output pad_w = 0 pad_h = 0 if isinstance(param.pad, int): pad = param.pad param_string += ", pad=(%d, %d)" % (pad, pad) else: if len(param.pad) > 0: pad = param.pad[0] param_string += ", pad=(%d, %d)" % (pad, pad) else: if isinstance(param.pad_w, int): pad_w = param.pad_w if isinstance(param.pad_h, int): pad_h = param.pad_h param_string += ", pad=(%d, %d)" % (pad_h, pad_w) if isinstance(param.kernel_size, int): kernel_size = param.kernel_size param_string += ", kernel=(%d,%d)" % (kernel_size, kernel_size) else: if len(param.kernel_size) > 0: kernel_size = param.kernel_size[0] param_string += ", kernel=(%d,%d)" % (kernel_size, kernel_size) else: assert isinstance(param.kernel_w, int) kernel_w = param.kernel_w assert isinstance(param.kernel_h, int) kernel_h = param.kernel_h param_string += ", kernel=(%d,%d)" % (kernel_h, kernel_w) stride = 1 if isinstance(param.stride, int): stride = param.stride else: stride = 1 if len(param.stride) == 0 else param.stride[0] param_string += ", stride=(%d,%d)" % (stride, stride) dilate = 1 if hasattr(param, 'dilation'): if isinstance(param.dilation, int): dilate = param.dilation else: dilate = 1 if len(param.dilation) == 0 else param.dilation[0] param_string += ", no_bias=%s" % (not param.bias_term) # deal with dilation. Won't be in deconvolution if dilate > 1: param_string += ", dilate=(%d, %d)" % (dilate, dilate) if isinstance(param.group, int): if param.group != 1: param_string += ", num_group=%d" % param.group return param_string def _convert_pooling_param(param): """Convert the pooling layer parameter """ param_string = "pooling_convention='full', " if param.global_pooling: param_string += "global_pool=True, kernel=(1,1)" else: param_string += "pad=(%d,%d), kernel=(%d,%d), stride=(%d,%d)" % ( param.pad, param.pad, param.kernel_size, param.kernel_size, param.stride, param.stride) if param.pool == 0: param_string += ", pool_type='max'" elif param.pool == 1: param_string += ", pool_type='avg'" else: raise ValueError("Unknown Pooling Method!") return param_string def _parse_proto(prototxt_fname): """Parse Caffe prototxt into symbol string """ proto = caffe_parser.read_prototxt(prototxt_fname) # process data layer input_name, input_dim, layers = _get_input(proto) # only support single input, so always use `data` as the input data mapping = {input_name: 'data'} need_flatten = {input_name: False} symbol_string = "import mxnet as mx\ndata = mx.symbol.Variable(name='data')\n" flatten_count = 0 output_name = "" prev_name = None _output_name = {} # convert reset layers one by one for i, layer in enumerate(layers): type_string = '' param_string = '' skip_layer = False name = re.sub('[-/]', '_', layer.name) for k in range(len(layer.bottom)): if layer.bottom[k] in _output_name: _output_name[layer.bottom[k]]['count'] = _output_name[layer.bottom[k]]['count']+1 else: _output_name[layer.bottom[k]] = {'count':0} for k in range(len(layer.top)): if layer.top[k] in _output_name: _output_name[layer.top[k]]['count'] = _output_name[layer.top[k]]['count']+1 else: _output_name[layer.top[k]] = {'count':0, 'name':name} if layer.type == 'Convolution' or layer.type == 4: type_string = 'mx.symbol.Convolution' param_string = _convert_conv_param(layer.convolution_param) need_flatten[name] = True if layer.type == 'Deconvolution' or layer.type == 39: type_string = 'mx.symbol.Deconvolution' param_string = _convert_conv_param(layer.convolution_param) need_flatten[name] = True if layer.type == 'Pooling' or layer.type == 17: type_string = 'mx.symbol.Pooling' param_string = _convert_pooling_param(layer.pooling_param) need_flatten[name] = True if layer.type == 'ReLU' or layer.type == 18: type_string = 'mx.symbol.Activation' param_string = "act_type='relu'" param = layer.relu_param if hasattr(param, 'negative_slope'): if param.negative_slope > 0: type_string = 'mx.symbol.LeakyReLU' param_string = "act_type='leaky', slope=%f" % param.negative_slope need_flatten[name] = need_flatten[mapping[layer.bottom[0]]] if layer.type == 'TanH' or layer.type == 23: type_string = 'mx.symbol.Activation' param_string = "act_type='tanh'" need_flatten[name] = need_flatten[mapping[layer.bottom[0]]] if layer.type == 'Sigmoid' or layer.type == 19: type_string = 'mx.symbol.Activation' param_string = "act_type='sigmoid'" need_flatten[name] = need_flatten[mapping[layer.bottom[0]]] if layer.type == 'LRN' or layer.type == 15: type_string = 'mx.symbol.LRN' param = layer.lrn_param param_string = "alpha=%f, beta=%f, knorm=%f, nsize=%d" % ( param.alpha, param.beta, param.k, param.local_size) need_flatten[name] = True if layer.type == 'InnerProduct' or layer.type == 14: type_string = 'mx.symbol.FullyConnected' param = layer.inner_product_param param_string = "num_hidden=%d, no_bias=%s" % ( param.num_output, not param.bias_term) need_flatten[name] = False if layer.type == 'Dropout' or layer.type == 6: type_string = 'mx.symbol.Dropout' param = layer.dropout_param param_string = "p=%f" % param.dropout_ratio need_flatten[name] = need_flatten[mapping[layer.bottom[0]]] if layer.type == 'Softmax' or layer.type == 20: type_string = 'mx.symbol.SoftmaxOutput' if layer.type == 'Flatten' or layer.type == 8: type_string = 'mx.symbol.Flatten' need_flatten[name] = False if layer.type == 'Split' or layer.type == 22: type_string = 'split' # will process later if layer.type == 'Concat' or layer.type == 3: type_string = 'mx.symbol.Concat' need_flatten[name] = True if layer.type == 'Crop': type_string = 'mx.symbol.Crop' need_flatten[name] = True param_string = 'center_crop=True' if layer.type == 'BatchNorm': type_string = 'mx.symbol.BatchNorm' param = layer.batch_norm_param # CuDNN requires eps to be greater than 1e-05 # We compensate for this change in convert_model epsilon = param.eps if (epsilon <= 1e-05): epsilon = 1e-04 # if next layer is scale, don't fix gamma fix_gamma = layers[i+1].type != 'Scale' param_string = 'use_global_stats=%s, fix_gamma=%s, eps=%f' % ( param.use_global_stats, fix_gamma, epsilon) need_flatten[name] = need_flatten[mapping[layer.bottom[0]]] if layer.type == 'Scale': assert layers[i-1].type == 'BatchNorm' need_flatten[name] = need_flatten[mapping[layer.bottom[0]]] skip_layer = True prev_name = re.sub('[-/]', '_', layers[i-1].name) if layer.type == 'PReLU': type_string = 'mx.symbol.LeakyReLU' param = layer.prelu_param param_string = "act_type='prelu', slope=%f" % param.filler.value need_flatten[name] = need_flatten[mapping[layer.bottom[0]]] if layer.type == 'Eltwise': type_string = 'mx.symbol.broadcast_add' param = layer.eltwise_param param_string = "" need_flatten[name] = False if layer.type == 'Reshape': type_string = 'mx.symbol.Reshape' need_flatten[name] = False param = layer.reshape_param param_string = "shape=(%s)" % (','.join(param.shape.dim),) if layer.type == 'AbsVal': type_string = 'mx.symbol.abs' need_flatten[name] = need_flatten[mapping[layer.bottom[0]]] if skip_layer: assert len(layer.bottom) == 1 symbol_string += "%s = %s\n" % (name, prev_name) elif type_string == '': raise ValueError('Unknown layer %s!' % layer.type) elif type_string != 'split': bottom = layer.bottom if param_string != "": param_string = ", " + param_string if len(bottom) == 1: if need_flatten[mapping[bottom[0]]] and type_string == 'mx.symbol.FullyConnected': flatten_name = "flatten_%d" % flatten_count symbol_string += "%s=mx.symbol.Flatten(name='%s', data=%s)\n" % ( flatten_name, flatten_name, mapping[bottom[0]]) flatten_count += 1 need_flatten[flatten_name] = False bottom[0] = flatten_name mapping[bottom[0]] = bottom[0] symbol_string += "%s = %s(name='%s', data=%s %s)\n" % ( name, type_string, name, mapping[bottom[0]], param_string) else: if layer.type == 'Eltwise' and param.operation == 1 and len(param.coeff) > 0: symbol_string += "%s = " % name symbol_string += " + ".join(["%s * %s" % ( mapping[bottom[i]], param.coeff[i]) for i in range(len(param.coeff))]) symbol_string += "\n" else: symbol_string += "%s = %s(name='%s', *[%s] %s)\n" % ( name, type_string, name, ','.join( [mapping[x] for x in bottom]), param_string) for j in range(len(layer.top)): mapping[layer.top[j]] = name output_name = name output_name = [] for i in _output_name: if 'name' in _output_name[i] and _output_name[i]['count'] == 0: output_name.append(_output_name[i]['name']) return symbol_string, output_name, input_dim def convert_symbol(prototxt_fname): """Convert caffe model definition into Symbol Parameters ---------- prototxt_fname : str Filename of the prototxt file Returns ------- Symbol Converted Symbol tuple Input shape """ sym, output_name, input_dim = _parse_proto(prototxt_fname) exec(sym) # pylint: disable=exec-used _locals = locals() ret = [] for i in output_name: exec("ret = " + i, globals(), _locals) # pylint: disable=exec-used ret.append(_locals['ret']) ret = mx.sym.Group(ret) return ret, input_dim def main(): parser = argparse.ArgumentParser( description='Convert caffe prototxt into Symbol') parser.add_argument('prototxt', help='The prototxt filename') parser.add_argument('output', help='filename for the output json file') args = parser.parse_args() sym, _ = convert_symbol(args.prototxt) sym.save(args.output) if __name__ == '__main__': main()
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 624, 7306, 1704, 2026, 557, 13280, 400, 370, 5272, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7534, 199, 646, 295, 199, 646, 1704, 2026, 63, 2087, 199, 199, 318, 485, 362, 63, 1210, 8, 2625, 304, 272, 408, 1002, 1324, 1568, 272, 408, 272, 4045, 275, 1704, 2026, 63, 2087, 14, 362, 63, 4359, 8, 2625, 9, 272, 340, 822, 8, 2625, 14, 1210, 63, 3572, 9, 690, 378, 26, 267, 1324, 63, 3572, 275, 4104, 14, 1210, 63, 3572, 272, 916, 822, 8, 2625, 14, 1210, 63, 1392, 9, 690, 378, 26, 267, 1324, 63, 3572, 275, 4104, 14, 1210, 63, 1392, 59, 16, 1055, 3572, 272, 916, 4045, 59, 16, 1055, 466, 508, 298, 3205, 582, 267, 1324, 63, 3572, 275, 4045, 59, 16, 1055, 1210, 63, 635, 14, 1392, 59, 16, 1055, 3572, 267, 4045, 14, 1935, 8, 16, 9, 272, 587, 26, 267, 746, 1722, 360, 6612, 2342, 1324, 1568, 358, 339, 702, 4045, 59, 16, 1055, 466, 1137, 298, 3205, 401, 283, 2118, 2291, 2849, 1324, 7, 272, 327, 2136, 5534, 314, 1642, 9048, 9182, 402, 1642, 4045, 365, 314, 1072, 687, 666, 4045, 272, 1324, 63, 354, 275, 4045, 59, 16, 1055, 8305, 59, 16, 61, 272, 372, 1324, 63, 354, 12, 1324, 63, 3572, 12, 4045, 199, 199, 318, 485, 3916, 63, 5598, 63, 635, 8, 635, 304, 272, 408, 272, 7905, 17461, 4045, 2725, 687, 8790, 2026, 370, 603, 56, 2480, 272, 408, 272, 1215, 63, 875, 275, 298, 1507, 63, 1541, 2458, 68, 2, 450, 1215, 14, 1507, 63, 1199, 339, 6567, 63, 87, 275, 378, 272, 6567, 63, 72, 275, 378, 272, 340, 1228, 8, 635, 14, 6226, 12, 1109, 304, 267, 6567, 275, 1215, 14, 6226, 267, 1215, 63, 875, 847, 3872, 6567, 2687, 5, 68, 12, 450, 68, 2924, 450, 334, 6226, 12, 6567, 9, 272, 587, 26, 267, 340, 822, 8, 635, 14, 6226, 9, 690, 378, 26, 288, 6567, 275, 1215, 14, 6226, 59, 16, 61, 288, 1215, 63, 875, 847, 3872, 6567, 2687, 5, 68, 12, 450, 68, 2924, 450, 334, 6226, 12, 6567, 9, 267, 587, 26, 288, 340, 1228, 8, 635, 14, 6226, 63, 87, 12, 1109, 304, 355, 6567, 63, 87, 275, 1215, 14, 6226, 63, 87, 288, 340, 1228, 8, 635, 14, 6226, 63, 72, 12, 1109, 304, 355, 6567, 63, 72, 275, 1215, 14, 6226, 63, 72, 288, 1215, 63, 875, 847, 3872, 6567, 2687, 5, 68, 12, 450, 68, 2924, 450, 334, 6226, 63, 72, 12, 6567, 63, 87, 9, 339, 340, 1228, 8, 635, 14, 4989, 63, 890, 12, 1109, 304, 267, 5114, 63, 890, 275, 1215, 14, 4989, 63, 890, 267, 1215, 63, 875, 847, 3872, 5114, 2687, 5, 68, 8719, 68, 2924, 450, 334, 4989, 63, 890, 12, 5114, 63, 890, 9, 272, 587, 26, 267, 340, 822, 8, 635, 14, 4989, 63, 890, 9, 690, 378, 26, 288, 5114, 63, 890, 275, 1215, 14, 4989, 63, 890, 59, 16, 61, 288, 1215, 63, 875, 847, 3872, 5114, 2687, 5, 68, 8719, 68, 2924, 450, 334, 4989, 63, 890, 12, 5114, 63, 890, 9, 267, 587, 26, 288, 702, 1228, 8, 635, 14, 4989, 63, 87, 12, 1109, 9, 288, 5114, 63, 87, 275, 1215, 14, 4989, 63, 87, 288, 702, 1228, 8, 635, 14, 4989, 63, 72, 12, 1109, 9, 288, 5114, 63, 72, 275, 1215, 14, 4989, 63, 72, 288, 1215, 63, 875, 847, 3872, 5114, 2687, 5, 68, 8719, 68, 2924, 450, 334, 4989, 63, 72, 12, 5114, 63, 87, 9, 339, 7345, 275, 413, 272, 340, 1228, 8, 635, 14, 12318, 12, 1109, 304, 267, 7345, 275, 1215, 14, 12318, 272, 587, 26, 267, 7345, 275, 413, 340, 822, 8, 635, 14, 12318, 9, 508, 378, 587, 1215, 14, 12318, 59, 16, 61, 339, 1215, 63, 875, 847, 3872, 7345, 2687, 5, 68, 8719, 68, 2924, 450, 334, 12318, 12, 7345, 9, 339, 487, 750, 275, 413, 272, 340, 2688, 8, 635, 12, 283, 328, 2212, 735, 267, 340, 1228, 8, 635, 14, 328, 2212, 12, 1109, 304, 288, 487, 750, 275, 1215, 14, 328, 2212, 267, 587, 26, 288, 487, 750, 275, 413, 340, 822, 8, 635, 14, 328, 2212, 9, 508, 378, 587, 1215, 14, 328, 2212, 59, 16, 61, 339, 1215, 63, 875, 847, 3872, 949, 63, 8160, 2458, 83, 2, 450, 334, 1397, 1215, 14, 8160, 63, 5125, 9, 339, 327, 7962, 543, 30040, 14, 644, 265, 1133, 506, 315, 477, 27625, 272, 340, 487, 750, 690, 413, 26, 267, 1215, 63, 875, 847, 3872, 487, 750, 2687, 5, 68, 12, 450, 68, 2924, 450, 334, 328, 750, 12, 487, 750, 9, 339, 340, 1228, 8, 635, 14, 923, 12, 1109, 304, 267, 340, 1215, 14, 923, 1137, 413, 26, 288, 1215, 63, 875, 847, 3872, 1967, 63, 923, 2458, 68, 2, 450, 1215, 14, 923, 339, 372, 1215, 63, 875, 199, 199, 318, 485, 3916, 63, 28624, 63, 635, 8, 635, 304, 272, 408, 7306, 314, 20699, 4045, 2725, 272, 408, 272, 1215 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 624, 7306, 1704, 2026, 557, 13280, 400, 370, 5272, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7534, 199, 646, 295, 199, 646, 1704, 2026, 63, 2087, 199, 199, 318, 485, 362, 63, 1210, 8, 2625, 304, 272, 408, 1002, 1324, 1568, 272, 408, 272, 4045, 275, 1704, 2026, 63, 2087, 14, 362, 63, 4359, 8, 2625, 9, 272, 340, 822, 8, 2625, 14, 1210, 63, 3572, 9, 690, 378, 26, 267, 1324, 63, 3572, 275, 4104, 14, 1210, 63, 3572, 272, 916, 822, 8, 2625, 14, 1210, 63, 1392, 9, 690, 378, 26, 267, 1324, 63, 3572, 275, 4104, 14, 1210, 63, 1392, 59, 16, 1055, 3572, 272, 916, 4045, 59, 16, 1055, 466, 508, 298, 3205, 582, 267, 1324, 63, 3572, 275, 4045, 59, 16, 1055, 1210, 63, 635, 14, 1392, 59, 16, 1055, 3572, 267, 4045, 14, 1935, 8, 16, 9, 272, 587, 26, 267, 746, 1722, 360, 6612, 2342, 1324, 1568, 358, 339, 702, 4045, 59, 16, 1055, 466, 1137, 298, 3205, 401, 283, 2118, 2291, 2849, 1324, 7, 272, 327, 2136, 5534, 314, 1642, 9048, 9182, 402, 1642, 4045, 365, 314, 1072, 687, 666, 4045, 272, 1324, 63, 354, 275, 4045, 59, 16, 1055, 8305, 59, 16, 61, 272, 372, 1324, 63, 354, 12, 1324, 63, 3572, 12, 4045, 199, 199, 318, 485, 3916, 63, 5598, 63, 635, 8, 635, 304, 272, 408, 272, 7905, 17461, 4045, 2725, 687, 8790, 2026, 370, 603, 56, 2480, 272, 408, 272, 1215, 63, 875, 275, 298, 1507, 63, 1541, 2458, 68, 2, 450, 1215, 14, 1507, 63, 1199, 339, 6567, 63, 87, 275, 378, 272, 6567, 63, 72, 275, 378, 272, 340, 1228, 8, 635, 14, 6226, 12, 1109, 304, 267, 6567, 275, 1215, 14, 6226, 267, 1215, 63, 875, 847, 3872, 6567, 2687, 5, 68, 12, 450, 68, 2924, 450, 334, 6226, 12, 6567, 9, 272, 587, 26, 267, 340, 822, 8, 635, 14, 6226, 9, 690, 378, 26, 288, 6567, 275, 1215, 14, 6226, 59, 16, 61, 288, 1215, 63, 875, 847, 3872, 6567, 2687, 5, 68, 12, 450, 68, 2924, 450, 334, 6226, 12, 6567, 9, 267, 587, 26, 288, 340, 1228, 8, 635, 14, 6226, 63, 87, 12, 1109, 304, 355, 6567, 63, 87, 275, 1215, 14, 6226, 63, 87, 288, 340, 1228, 8, 635, 14, 6226, 63, 72, 12, 1109, 304, 355, 6567, 63, 72, 275, 1215, 14, 6226, 63, 72, 288, 1215, 63, 875, 847, 3872, 6567, 2687, 5, 68, 12, 450, 68, 2924, 450, 334, 6226, 63, 72, 12, 6567, 63, 87, 9, 339, 340, 1228, 8, 635, 14, 4989, 63, 890, 12, 1109, 304, 267, 5114, 63, 890, 275, 1215, 14, 4989, 63, 890, 267, 1215, 63, 875, 847, 3872, 5114, 2687, 5, 68, 8719, 68, 2924, 450, 334, 4989, 63, 890, 12, 5114, 63, 890, 9, 272, 587, 26, 267, 340, 822, 8, 635, 14, 4989, 63, 890, 9, 690, 378, 26, 288, 5114, 63, 890, 275, 1215, 14, 4989, 63, 890, 59, 16, 61, 288, 1215, 63, 875, 847, 3872, 5114, 2687, 5, 68, 8719, 68, 2924, 450, 334, 4989, 63, 890, 12, 5114, 63, 890, 9, 267, 587, 26, 288, 702, 1228, 8, 635, 14, 4989, 63, 87, 12, 1109, 9, 288, 5114, 63, 87, 275, 1215, 14, 4989, 63, 87, 288, 702, 1228, 8, 635, 14, 4989, 63, 72, 12, 1109, 9, 288, 5114, 63, 72, 275, 1215, 14, 4989, 63, 72, 288, 1215, 63, 875, 847, 3872, 5114, 2687, 5, 68, 8719, 68, 2924, 450, 334, 4989, 63, 72, 12, 5114, 63, 87, 9, 339, 7345, 275, 413, 272, 340, 1228, 8, 635, 14, 12318, 12, 1109, 304, 267, 7345, 275, 1215, 14, 12318, 272, 587, 26, 267, 7345, 275, 413, 340, 822, 8, 635, 14, 12318, 9, 508, 378, 587, 1215, 14, 12318, 59, 16, 61, 339, 1215, 63, 875, 847, 3872, 7345, 2687, 5, 68, 8719, 68, 2924, 450, 334, 12318, 12, 7345, 9, 339, 487, 750, 275, 413, 272, 340, 2688, 8, 635, 12, 283, 328, 2212, 735, 267, 340, 1228, 8, 635, 14, 328, 2212, 12, 1109, 304, 288, 487, 750, 275, 1215, 14, 328, 2212, 267, 587, 26, 288, 487, 750, 275, 413, 340, 822, 8, 635, 14, 328, 2212, 9, 508, 378, 587, 1215, 14, 328, 2212, 59, 16, 61, 339, 1215, 63, 875, 847, 3872, 949, 63, 8160, 2458, 83, 2, 450, 334, 1397, 1215, 14, 8160, 63, 5125, 9, 339, 327, 7962, 543, 30040, 14, 644, 265, 1133, 506, 315, 477, 27625, 272, 340, 487, 750, 690, 413, 26, 267, 1215, 63, 875, 847, 3872, 487, 750, 2687, 5, 68, 12, 450, 68, 2924, 450, 334, 328, 750, 12, 487, 750, 9, 339, 340, 1228, 8, 635, 14, 923, 12, 1109, 304, 267, 340, 1215, 14, 923, 1137, 413, 26, 288, 1215, 63, 875, 847, 3872, 1967, 63, 923, 2458, 68, 2, 450, 1215, 14, 923, 339, 372, 1215, 63, 875, 199, 199, 318, 485, 3916, 63, 28624, 63, 635, 8, 635, 304, 272, 408, 7306, 314, 20699, 4045, 2725, 272, 408, 272, 1215, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Flimm/linkchecker
scripts/debugparse.py
9
1429
#!/usr/bin/env python # -*- coding: iso-8859-1 -*- # Copyright (C) 2011-2014 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """ Parse HTML given as file parameter or piped to stdin. """ import sys import os sys.path.append(os.getcwd()) import linkcheck.HtmlParser.htmlsax import linkcheck.HtmlParser.htmllib def main (text): parser = linkcheck.HtmlParser.htmlsax.parser() handler = linkcheck.HtmlParser.htmllib.HtmlPrinter() parser.handler = handler # debug lexer #parser.debug(1) parser.feed(text) parser.flush() if __name__ == '__main__': if len(sys.argv) <= 1: text = sys.stdin.read() else: filename = sys.argv[1] with open(filename) as fp: text = fp.read() main(text)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 11601, 13, 4830, 13, 17, 1882, 199, 3, 1898, 334, 35, 9, 7760, 13, 7280, 699, 1810, 5653, 1804, 274, 1132, 344, 455, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 624, 199, 4003, 4163, 1627, 465, 570, 2725, 503, 6682, 1915, 370, 9009, 14, 199, 624, 199, 646, 984, 199, 646, 747, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 9458, 1012, 199, 646, 2142, 1074, 14, 12957, 2842, 14, 15575, 478, 1219, 199, 646, 2142, 1074, 14, 12957, 2842, 14, 1360, 773, 421, 199, 318, 2446, 334, 505, 304, 272, 1798, 275, 2142, 1074, 14, 12957, 2842, 14, 15575, 478, 1219, 14, 2087, 342, 272, 3016, 275, 2142, 1074, 14, 12957, 2842, 14, 1360, 773, 14, 12957, 14131, 342, 272, 1798, 14, 2232, 275, 3016, 272, 327, 3105, 10426, 272, 327, 2087, 14, 1757, 8, 17, 9, 272, 1798, 14, 3871, 8, 505, 9, 272, 1798, 14, 4939, 342, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 822, 8, 1274, 14, 3020, 9, 2695, 413, 26, 267, 1318, 275, 984, 14, 6626, 14, 739, 342, 272, 587, 26, 267, 1788, 275, 984, 14, 3020, 59, 17, 61, 267, 543, 1551, 8, 1501, 9, 465, 4090, 26, 288, 1318, 275, 4090, 14, 739, 342, 272, 2446, 8, 505, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 11601, 13, 4830, 13, 17, 1882, 199, 3, 1898, 334, 35, 9, 7760, 13, 7280, 699, 1810, 5653, 1804, 274, 1132, 344, 455, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 624, 199, 4003, 4163, 1627, 465, 570, 2725, 503, 6682, 1915, 370, 9009, 14, 199, 624, 199, 646, 984, 199, 646, 747, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 9458, 1012, 199, 646, 2142, 1074, 14, 12957, 2842, 14, 15575, 478, 1219, 199, 646, 2142, 1074, 14, 12957, 2842, 14, 1360, 773, 421, 199, 318, 2446, 334, 505, 304, 272, 1798, 275, 2142, 1074, 14, 12957, 2842, 14, 15575, 478, 1219, 14, 2087, 342, 272, 3016, 275, 2142, 1074, 14, 12957, 2842, 14, 1360, 773, 14, 12957, 14131, 342, 272, 1798, 14, 2232, 275, 3016, 272, 327, 3105, 10426, 272, 327, 2087, 14, 1757, 8, 17, 9, 272, 1798, 14, 3871, 8, 505, 9, 272, 1798, 14, 4939, 342, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 822, 8, 1274, 14, 3020, 9, 2695, 413, 26, 267, 1318, 275, 984, 14, 6626, 14, 739, 342, 272, 587, 26, 267, 1788, 275, 984, 14, 3020, 59, 17, 61, 267, 543, 1551, 8, 1501, 9, 465, 4090, 26, 288, 1318, 275, 4090, 14, 739, 342, 272, 2446, 8, 505, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
open-synergy/sale-workflow
product_special_type_sale/sale.py
33
5086
# -*- coding: utf-8 -*- # # # Author: Guewen Baconnier # Copyright 2012 Camptocamp SA # # 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 decimal_precision as dp from operator import add from osv import osv, fields class sale_order(osv.osv): _inherit = 'sale.order' def _special_lines(self, cr, uid, ids, name, args, context=None): """ Compute Discount and Advances amounts (sum of all the products of these types) """ res = {} product_to_fields = {'discount': 'extra_discount_amount', 'advance': 'advance_amount', 'delivery': 'delivery_amount'} for order in self.browse(cr, uid, ids, context=context): res[order.id] = dict((field, 0.0) for field in product_to_fields.values()) for special_type, field in product_to_fields.iteritems(): res[order.id][field] = reduce( add, [ line.price_subtotal for line in order.order_line if line.product_id and line.product_id.special_type == special_type ], 0.0) return res # super does not work for store function triggers as self is not the # current object # we have to redefine the methods in this class def _get_order(self, cr, uid, ids, context=None): result = {} for line in self.pool.get('sale.order.line').browse( cr, uid, ids, context=context ): result[line.order_id.id] = True return result.keys() _columns = { 'extra_discount_amount': fields.function( _special_lines, method=True, digits_compute=dp.get_precision( 'Product Price'), string='Extra-Discount', help="The amount of extra-discount", multi='special_lines', store={ 'sale.order': ( lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10 ), 'sale.order.line': (_get_order, [ 'price_unit', 'tax_id', 'discount', 'product_uom_qty', 'product_id' ], 10), }), 'advance_amount': fields.function( _special_lines, method=True, digits_compute=dp.get_precision( 'Product Price'), string='Advance', help="The amount of advances", multi='special_lines', store={ 'sale.order': ( lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10 ), 'sale.order.line': (_get_order, [ 'price_unit', 'tax_id', 'discount', 'product_uom_qty', 'product_id' ], 10), }), 'delivery_amount': fields.function( _special_lines, method=True, digits_compute=dp.get_precision( 'Product Price'), string='Delivery Costs', help="The amount of delivery costs", multi='special_lines', store={ 'sale.order': ( lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10 ), 'sale.order.line': (_get_order, [ 'price_unit', 'tax_id', 'discount', 'product_uom_qty', 'product_id' ], 10), }), } sale_order() class sale_order_line(osv.osv): _inherit = 'sale.order.line' def _hidden_in_report(self, cr, uid, ids, name, args, context=None): """ Discount and Advances are hidden in the report template and displayed as a sum in the totals """ res = {} for line in self.browse(cr, uid, ids, context=context): res[line.id] = False if line.product_id and line.product_id.special_type in ( 'discount', 'advance', 'delivery' ): res[line.id] = True return res _columns = { 'hide_in_report': fields.function(_hidden_in_report, method=True, string='Hide the line in reports', type="boolean",) } sale_order_line()
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 199, 3, 259, 6529, 26, 598, 310, 87, 287, 699, 65, 1631, 4446, 199, 3, 259, 1898, 6029, 24569, 475, 20290, 13950, 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, 3, 199, 199, 646, 6107, 63, 6833, 465, 12392, 199, 199, 504, 4182, 492, 1050, 199, 504, 9506, 492, 9506, 12, 1504, 421, 199, 533, 13590, 63, 1648, 8, 4795, 14, 4795, 304, 339, 485, 6486, 275, 283, 8515, 14, 1648, 7, 339, 347, 485, 6664, 63, 1278, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1249, 12, 1067, 29, 403, 304, 267, 408, 8354, 5289, 835, 436, 4431, 6278, 83, 32247, 334, 1838, 402, 1006, 314, 7585, 402, 267, 3520, 2943, 9, 267, 408, 267, 522, 275, 1052, 267, 3336, 63, 475, 63, 955, 275, 791, 15446, 356, 283, 2911, 63, 15446, 63, 4606, 297, 2490, 283, 21195, 356, 283, 21195, 63, 4606, 297, 2490, 283, 14564, 356, 283, 14564, 63, 4606, 936, 267, 367, 1865, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 522, 59, 1648, 14, 344, 61, 275, 1211, 1332, 698, 12, 378, 14, 16, 9, 639, 367, 901, 315, 3336, 63, 475, 63, 955, 14, 1459, 1012, 288, 367, 4539, 63, 466, 12, 901, 315, 3336, 63, 475, 63, 955, 14, 4611, 837, 355, 522, 59, 1648, 14, 344, 1527, 698, 61, 275, 7114, 8, 490, 1050, 12, 359, 717, 1004, 14, 4777, 63, 954, 2923, 367, 1004, 315, 1865, 14, 1648, 63, 604, 717, 340, 1004, 14, 2558, 63, 344, 436, 717, 1004, 14, 2558, 63, 344, 14, 6664, 63, 466, 508, 4539, 63, 466, 490, 2156, 378, 14, 16, 9, 398, 372, 522, 339, 327, 1613, 1630, 440, 1736, 367, 3877, 805, 18899, 465, 291, 365, 440, 314, 272, 327, 1453, 909, 272, 327, 781, 1172, 370, 295, 4640, 314, 3102, 315, 642, 1021, 272, 347, 485, 362, 63, 1648, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 754, 275, 1052, 267, 367, 1004, 315, 291, 14, 2293, 14, 362, 360, 8515, 14, 1648, 14, 604, 1959, 4570, 8, 288, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 267, 3461, 288, 754, 59, 604, 14, 1648, 63, 344, 14, 344, 61, 275, 715, 267, 372, 754, 14, 1612, 342, 339, 485, 3406, 275, 469, 267, 283, 2911, 63, 15446, 63, 4606, 356, 1504, 14, 1593, 8, 288, 485, 6664, 63, 1278, 12, 1083, 29, 549, 12, 288, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 8, 355, 283, 5884, 20276, 659, 288, 1059, 534, 7426, 13, 2825, 835, 297, 288, 1720, 628, 1918, 5982, 402, 2402, 13, 15446, 401, 288, 3510, 534, 6664, 63, 1278, 297, 288, 3877, 3126, 355, 283, 8515, 14, 1648, 356, 334, 490, 2400, 291, 12, 2467, 12, 1747, 12, 2762, 12, 286, 29, 403, 26, 2762, 12, 788, 1648, 63, 604, 995, 1616, 355, 2318, 355, 283, 8515, 14, 1648, 14, 604, 356, 6110, 362, 63, 1648, 12, 359, 490, 283, 4777, 63, 3248, 297, 283, 5530, 63, 344, 297, 283, 15446, 297, 490, 283, 2558, 63, 7519, 63, 5643, 297, 283, 2558, 63, 344, 7, 355, 2156, 1616, 395, 288, 9998, 267, 283, 21195, 63, 4606, 356, 1504, 14, 1593, 8, 288, 485, 6664, 63, 1278, 12, 1083, 29, 549, 12, 288, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 8, 355, 283, 5884, 20276, 659, 288, 1059, 534, 2767, 6278, 297, 288, 1720, 628, 1918, 5982, 402, 18695, 83, 401, 288, 3510, 534, 6664, 63, 1278, 297, 288, 3877, 3126, 355, 283, 8515, 14, 1648, 356, 334, 490, 2400, 291, 12, 2467, 12, 1747, 12, 2762, 12, 286, 29, 403, 26, 2762, 12, 788, 1648, 63, 604, 995, 1616, 355, 2318, 355, 283, 8515, 14, 1648, 14, 604, 356, 6110, 362, 63, 1648, 12, 359, 490, 283, 4777, 63, 3248, 297, 283, 5530, 63, 344, 297, 283, 15446, 297, 490, 283, 2558, 63, 7519, 63, 5643, 297, 283, 2558, 63, 344, 7, 355, 2156, 1616, 395, 288, 9998, 267, 283, 14564, 63, 4606, 356, 1504, 14, 1593, 8, 288, 485, 6664, 63, 1278, 12, 1083, 29, 549, 12, 288, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 8, 355, 283, 5884, 20276, 659, 288, 1059, 534, 24640, 24681, 83, 297, 288, 1720, 628, 1918, 5982, 402, 18719, 26819, 401, 288, 3510, 534, 6664, 63, 1278, 297, 288, 3877, 3126, 355, 283, 8515, 14, 1648, 356, 334, 490, 2400, 291, 12, 2467, 12, 1747, 12, 2762, 12, 286, 29, 403, 26, 2762, 12, 788, 1648, 63, 604, 995, 1616, 355, 2318, 355, 283, 8515, 14, 1648, 14, 604, 356, 6110, 362, 63, 1648, 12, 359, 490, 283, 4777, 63, 3248, 297, 283, 5530, 63, 344, 297, 283, 15446, 297, 490, 283, 2558, 63, 7519, 63, 5643, 297, 283, 2558, 63, 344, 7, 355, 2156, 1616, 395, 288, 9998, 272, 789, 199, 199, 8515, 63, 1648, 342, 421, 199, 533, 13590, 63, 1648, 63, 604, 8, 4795, 14, 4795, 304, 339, 485, 6486, 275, 283, 8515, 14, 1648, 14, 604, 7, 339, 347, 485, 5642, 63, 262, 63, 3070, 8 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 199, 3, 259, 6529, 26, 598, 310, 87, 287, 699, 65, 1631, 4446, 199, 3, 259, 1898, 6029, 24569, 475, 20290, 13950, 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, 3, 199, 199, 646, 6107, 63, 6833, 465, 12392, 199, 199, 504, 4182, 492, 1050, 199, 504, 9506, 492, 9506, 12, 1504, 421, 199, 533, 13590, 63, 1648, 8, 4795, 14, 4795, 304, 339, 485, 6486, 275, 283, 8515, 14, 1648, 7, 339, 347, 485, 6664, 63, 1278, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1249, 12, 1067, 29, 403, 304, 267, 408, 8354, 5289, 835, 436, 4431, 6278, 83, 32247, 334, 1838, 402, 1006, 314, 7585, 402, 267, 3520, 2943, 9, 267, 408, 267, 522, 275, 1052, 267, 3336, 63, 475, 63, 955, 275, 791, 15446, 356, 283, 2911, 63, 15446, 63, 4606, 297, 2490, 283, 21195, 356, 283, 21195, 63, 4606, 297, 2490, 283, 14564, 356, 283, 14564, 63, 4606, 936, 267, 367, 1865, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 522, 59, 1648, 14, 344, 61, 275, 1211, 1332, 698, 12, 378, 14, 16, 9, 639, 367, 901, 315, 3336, 63, 475, 63, 955, 14, 1459, 1012, 288, 367, 4539, 63, 466, 12, 901, 315, 3336, 63, 475, 63, 955, 14, 4611, 837, 355, 522, 59, 1648, 14, 344, 1527, 698, 61, 275, 7114, 8, 490, 1050, 12, 359, 717, 1004, 14, 4777, 63, 954, 2923, 367, 1004, 315, 1865, 14, 1648, 63, 604, 717, 340, 1004, 14, 2558, 63, 344, 436, 717, 1004, 14, 2558, 63, 344, 14, 6664, 63, 466, 508, 4539, 63, 466, 490, 2156, 378, 14, 16, 9, 398, 372, 522, 339, 327, 1613, 1630, 440, 1736, 367, 3877, 805, 18899, 465, 291, 365, 440, 314, 272, 327, 1453, 909, 272, 327, 781, 1172, 370, 295, 4640, 314, 3102, 315, 642, 1021, 272, 347, 485, 362, 63, 1648, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 754, 275, 1052, 267, 367, 1004, 315, 291, 14, 2293, 14, 362, 360, 8515, 14, 1648, 14, 604, 1959, 4570, 8, 288, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 267, 3461, 288, 754, 59, 604, 14, 1648, 63, 344, 14, 344, 61, 275, 715, 267, 372, 754, 14, 1612, 342, 339, 485, 3406, 275, 469, 267, 283, 2911, 63, 15446, 63, 4606, 356, 1504, 14, 1593, 8, 288, 485, 6664, 63, 1278, 12, 1083, 29, 549, 12, 288, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 8, 355, 283, 5884, 20276, 659, 288, 1059, 534, 7426, 13, 2825, 835, 297, 288, 1720, 628, 1918, 5982, 402, 2402, 13, 15446, 401, 288, 3510, 534, 6664, 63, 1278, 297, 288, 3877, 3126, 355, 283, 8515, 14, 1648, 356, 334, 490, 2400, 291, 12, 2467, 12, 1747, 12, 2762, 12, 286, 29, 403, 26, 2762, 12, 788, 1648, 63, 604, 995, 1616, 355, 2318, 355, 283, 8515, 14, 1648, 14, 604, 356, 6110, 362, 63, 1648, 12, 359, 490, 283, 4777, 63, 3248, 297, 283, 5530, 63, 344, 297, 283, 15446, 297, 490, 283, 2558, 63, 7519, 63, 5643, 297, 283, 2558, 63, 344, 7, 355, 2156, 1616, 395, 288, 9998, 267, 283, 21195, 63, 4606, 356, 1504, 14, 1593, 8, 288, 485, 6664, 63, 1278, 12, 1083, 29, 549, 12, 288, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 8, 355, 283, 5884, 20276, 659, 288, 1059, 534, 2767, 6278, 297, 288, 1720, 628, 1918, 5982, 402, 18695, 83, 401, 288, 3510, 534, 6664, 63, 1278, 297, 288, 3877, 3126, 355, 283, 8515, 14, 1648, 356, 334, 490, 2400, 291, 12, 2467, 12, 1747, 12, 2762, 12, 286, 29, 403, 26, 2762, 12, 788, 1648, 63, 604, 995, 1616, 355, 2318, 355, 283, 8515, 14, 1648, 14, 604, 356, 6110, 362, 63, 1648, 12, 359, 490, 283, 4777, 63, 3248, 297, 283, 5530, 63, 344, 297, 283, 15446, 297, 490, 283, 2558, 63, 7519, 63, 5643, 297, 283, 2558, 63, 344, 7, 355, 2156, 1616, 395, 288, 9998, 267, 283, 14564, 63, 4606, 356, 1504, 14, 1593, 8, 288, 485, 6664, 63, 1278, 12, 1083, 29, 549, 12, 288, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 8, 355, 283, 5884, 20276, 659, 288, 1059, 534, 24640, 24681, 83, 297, 288, 1720, 628, 1918, 5982, 402, 18719, 26819, 401, 288, 3510, 534, 6664, 63, 1278, 297, 288, 3877, 3126, 355, 283, 8515, 14, 1648, 356, 334, 490, 2400, 291, 12, 2467, 12, 1747, 12, 2762, 12, 286, 29, 403, 26, 2762, 12, 788, 1648, 63, 604, 995, 1616, 355, 2318, 355, 283, 8515, 14, 1648, 14, 604, 356, 6110, 362, 63, 1648, 12, 359, 490, 283, 4777, 63, 3248, 297, 283, 5530, 63, 344, 297, 283, 15446, 297, 490, 283, 2558, 63, 7519, 63, 5643, 297, 283, 2558, 63, 344, 7, 355, 2156, 1616, 395, 288, 9998, 272, 789, 199, 199, 8515, 63, 1648, 342, 421, 199, 533, 13590, 63, 1648, 63, 604, 8, 4795, 14, 4795, 304, 339, 485, 6486, 275, 283, 8515, 14, 1648, 14, 604, 7, 339, 347, 485, 5642, 63, 262, 63, 3070, 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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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 ]
zhangjiajie/PTP-light
PTP.py
1
11582
#! /usr/bin/env python try: import sys import math import collections import os import argparse import treeIO from treeIO import Tree, SeqGroup from nexus import NexusReader from PTPLLH import lh_ratio_test, exp_distribution, species_setting, exponential_mixture from summary import partitionparser except ImportError: print("Some packages are missing for PTP.py.") sys.exit() class bootstrap_ptp: """Run MCMC on multiple trees""" def __init__(self, filename, ftype = "nexus", reroot = False, method = "H1", firstktrees = 0): self.method = method self.firstktrees = firstktrees if ftype == "nexus": self.nexus = NexusReader(filename) self.nexus.blocks['trees'].detranslate() self.trees = self.nexus.trees.trees else: self.trees = self.raxmlTreeParser(filename) if self.firstktrees > 0 and self.firstktrees <= len(self.trees): self.trees = self.trees[:self.firstktrees] self.taxa_order = Tree(self.trees[0]).get_leaf_names() self.numtaxa = len(self.taxa_order) self.numtrees = len(self.trees) self.reroot = reroot def remove_outgroups(self, ognames, remove = False): """reroot using outgroups and remove them""" self.reroot = False try: if remove: for og in ognames: self.taxa_order.remove(og) self.numtaxa = len(self.taxa_order) for i in range(len(self.trees)): t = Tree(self.trees[i]) if len(ognames) < 2: t.set_outgroup(ognames[0]) if remove: t.prune(self.taxa_order, preserve_branch_length=True) else: ancestor = t.get_common_ancestor(ognames) if not t == ancestor: t.set_outgroup(ancestor) if remove: t.prune(self.taxa_order, preserve_branch_length=True) self.trees[i] = t.write() except ValueError, e: print(e) print("\n Somthing is wrong with the input outgroup names \n Quiting ...") sys.exit() def delimit(self, args): self.partitions = [] self.settings = [] cnt = 1 if len(self.trees) == 1: tree = self.trees[0] me = None if args.spe_rate <= 0: me = exponential_mixture(tree= tree, max_iters = args.max_iter, min_br = args.min_brl) else: me = exponential_mixture(tree= tree, max_iters = args.max_iter, min_br = args.min_brl, sp_rate = args.spe_rate, fix_sp_rate = True) if args.whiten: me.whitening_search(reroot = self.reroot, strategy = args.sstrategy) else: me.search(reroot = self.reroot, strategy = args.sstrategy) #print to screen #me.count_species(pv = args.pvalue) #me.print_species() print("Number of species: " + repr(me.count_species(pv = args.pvalue))) to, par = me.output_species(taxa_order = self.taxa_order) self.partitions.append(par) self.settings.append(me.max_setting) else: for tree in self.trees: print("Running PTP on tree " + repr(cnt) + " ........") cnt = cnt + 1 me = exponential_mixture(tree= tree, max_iters = args.max_iter, min_br = args.min_brl) me.search(reroot = self.reroot, strategy = args.sstrategy) me.count_species(pv = args.pvalue, print_log = False) to, par = me.output_species(taxa_order = self.taxa_order) self.partitions.append(par) self.settings.append(me.max_setting) print("") return self.partitions, self.settings def delimit_EPA(self, sstrategy, reroot, max_iters, min_brl, sp_rate, pvalue = 0.001): tree = self.trees[0] me = exponential_mixture(tree= tree, max_iters = max_iters, min_br = min_brl, sp_rate = sp_rate, fix_sp_rate = True) me.search(reroot = reroot, strategy = sstrategy) num_spe = me.count_species(print_log = False, pv = pvalue) taxa_order, partition = me.output_species(taxa_order = self.taxa_order) return partition2names(taxa_order, partition) def raxmlTreeParser(self, fin): f = open(fin) lines = f.readlines() f.close() trees = [] for line in lines: line = line.strip() if not line == "": trees.append(line[line.index("("):]) return trees def partition2names(taxa_order, partition): nameparts = [] a = min(partition) b = max(partition) + 1 for i in range(a, b): onepar = [] for j in range(len(partition)): idfier = partition[j] if idfier == i: onepar.append(taxa_order[j]) nameparts.append(onepar) return nameparts """ def build_ref_tree(nfin, num_thread = "2"): nfout = "ptptemp" nfolder = os.path.dirname(os.path.abspath(nfin)) + "/" if os.path.exists(nfolder + nfout + ".tre"): print("Using existing reference tree !!") return nfolder + nfout + ".tre" basepath = os.path.dirname(os.path.abspath(__file__)) call([basepath + "/bin/raxmlHPC-PTHREADS-SSE3","-m","GTRGAMMA","-s",nfin,"-n",nfout,"-p", "1234", "-T", num_thread, "-w", nfolder] ) #, stdout=open(os.devnull, "w"), stderr=subprocess.STDOUT) os.rename(nfolder + "RAxML_bestTree."+nfout, nfolder + nfout + ".tre") os.remove(nfolder + "RAxML_info." + nfout) os.remove(nfolder + "RAxML_log." + nfout) os.remove(nfolder + "RAxML_parsimonyTree." + nfout) os.remove(nfolder + "RAxML_result." + nfout) return nfolder + nfout + ".tre" """ def parse_arguments(): parser = argparse.ArgumentParser(description="""PTP: Poisson Tree Processes model for species delimitation with bootstrap support. By using this program, you agree to cite: "J. Zhang, P. Kapli, P. Pavlidis, A. Stamatakis: A General Species Delimitation Method with Applications to Phylogenetic Placements. Bioinformatics (2013), 29 (22): 2869-2876 " Bugs, questions and suggestions please send to bestzhangjiajie@gmail.com. Version 2.2 released by Jiajie Zhang on 14-02-2014.""", formatter_class=argparse.RawDescriptionHelpFormatter, prog= "python PTP.py") parser.add_argument("-t", dest = "stree", metavar = "TREE", help = """Input phylogenetic tree file. Tree can be both rooted or unrooted, if unrooted, please use -r option. Supported format: NEXUS (trees without annotation), RAxML (simple Newick foramt). If the input file contains multiple trees, the program will do bootstrap analysis""", required = True) parser.add_argument("-o", dest = "output", help = "Output file name", required = True) parser.add_argument("-r", dest = "sreroot", help = """Re-rooting the input tree on the longest branch (default not)""", default = False, action="store_true") parser.add_argument("-g", dest = "outgroups", nargs='+', help = """Outgroup names, seperate by space. If this option is specified, input tree will be rerooted accordingly""") parser.add_argument("-d", dest = "delete", help = """Remove outgroups specified by -g (default not)""", default = False, action="store_true") parser.add_argument("-m", dest = "sstrategy", help = """Method for generate the starting partition (H0, H1, H2, H3, Brutal) (default H0)""", choices=["H0", "H1", "H2", "H3", "Brutal"], default= "H0") parser.add_argument("-pvalue", dest = "pvalue", help = """Set the p-value for likelihood ratio test.(default 0.001) If the test failed, the program will output only one species. Note this could mean there is only one species or all input taxon are different species""", type = float, default = 0.001) parser.add_argument("-w", dest = "whiten", help = """Specify this option to normalize the No.sequenes of each species from the first run and re-run the program""", default = False, action="store_true") parser.add_argument("-minbr", dest = "min_brl", help = """The minimal branch length allowed in tree (default 0.0001)""", type = float, default = 0.0001) parser.add_argument("-sprate", dest = "spe_rate", help = """Fix the speciation rate to the input value during model optimization (default not fixed)""", type = float, default = -1.0) parser.add_argument("-maxiters", dest = "max_iter", help = """Set the max number of search if using Brutal search (default 20000). The program will calculate how many searches are needed for Brutal search, if the number of actual search is great than this value, the program will use H0 instead""", type = int, default = 20000) parser.add_argument("-k", dest = "num_trees", metavar = "NUM-TREES", help = """Run bPTP on first k trees (default all trees)""", type = int, default = 0) parser.add_argument("--nmi", help = """Summary mutiple partitions using max NMI, note this is very slow for large number of trees""", default = False, action="store_true") parser.add_argument('--version', action='version', version='%(prog)s 2.2 (14-02-2014)') return parser.parse_args() def print_run_info(args): print("") print("PTP finished running with the following parameters:") print(" Input tree:.....................%s" % args.stree) print(" Search heuristic:...............%s" % args.sstrategy) print("") print(" Maximal likelihood search results written to:") print(" "+args.output + ".PTPPartitions.txt") print("") print(" Bootstrap values (if input contains multiple trees) of partitions written to:") print(" "+args.output + ".PTPPartitonSummary.txt") print("") print(" Highest bootstrap supported partition (if input contains multiple trees) written to:") print(" "+args.output + ".PTPhSupportPartition.txt") print(" Tree plot written to:") print(" "+args.output + ".PTPhSupportPartition.txt.png") print(" "+args.output + ".PTPhSupportPartition.txt.svg") if args.nmi: print("") print(" MAX NMI partition (if input contains multiple trees) written to:") print(" "+args.output + ".PTPhNMIPartition.txt") def EPA_interface(tree, sp_rate, reroot = True, method = "H0", max_iters = 20000, min_brl = 0.0001, pvalue = 0.001 ): bsptp = bootstrap_ptp(filename = tree, ftype = "raxml", reroot = reroot, method = method) return bsptp.delimit_EPA(sstrategy = method, reroot = reroot, max_iters = max_iters, min_brl = min_brl, sp_rate = sp_rate, pvalue = pvalue) def delimit_species(args): if not os.path.exists(args.stree): print("Input tree file does not exists: %s" % args.strees) sys.exit() try: tree = args.stree treetest = open(args.stree) l1 = treetest.readline() treetest.close() inputformat = "nexus" if l1.strip() == "#NEXUS": inputformat = "nexus" else: inputformat = "raxml" bsptp = bootstrap_ptp(filename = args.stree, ftype = inputformat, reroot = args.sreroot, method = args.sstrategy, firstktrees = args.num_trees) if args.outgroups!= None and len(args.outgroups) > 0: bsptp.remove_outgroups(args.outgroups, remove = args.delete) pars, settings = bsptp.delimit(args=args) pp = partitionparser(taxa_order = bsptp.taxa_order, partitions = pars, scale = 1) pp.summary(fout = args.output, bnmi = args.nmi, sp_setting = settings) if bsptp.numtrees > 1: min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions() print("Estimated number of species is between " + repr(min_no_p) + " and " + repr(max_no_p)) print("Mean: " + repr(mean_no_p)) print_run_info(args = args) except treeIO.newick.NewickError: print("Unexisting tree file or Malformed newick tree structure.") if __name__ == "__main__": if len(sys.argv) == 1: sys.argv.append("-h") args = parse_arguments() delimit_species(args) #p = EPA_interface(tree = args.stree, reroot = True, sp_rate = 3.745, method = "H0", max_iters = 20000, min_brl = 0.0001, pvalue = 0.001 ) #print(p)
gpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 893, 26, 199, 198, 646, 984, 199, 198, 646, 3473, 199, 198, 646, 5055, 199, 198, 646, 747, 199, 198, 646, 7534, 199, 198, 646, 3123, 2090, 199, 198, 504, 3123, 2090, 492, 12178, 12, 28534, 2448, 199, 198, 504, 22761, 527, 492, 653, 476, 527, 5929, 199, 198, 504, 510, 52, 2749, 44, 40, 492, 634, 72, 63, 6884, 63, 396, 12, 1437, 63, 4972, 12, 20340, 63, 6031, 12, 23160, 63, 2664, 4167, 199, 198, 504, 6212, 492, 6484, 2087, 199, 2590, 3545, 26, 199, 198, 1361, 480, 7700, 6117, 787, 4124, 367, 510, 6495, 14, 647, 2685, 199, 198, 1274, 14, 2224, 342, 199, 199, 533, 15865, 63, 541, 80, 26, 199, 198, 624, 2540, 32685, 7608, 641, 3663, 14416, 624, 199, 198, 318, 636, 826, 721, 277, 12, 1788, 12, 8570, 275, 298, 21787, 401, 295, 1231, 275, 756, 12, 1083, 275, 298, 40, 17, 401, 1642, 5973, 5710, 275, 378, 304, 507, 198, 277, 14, 765, 275, 1083, 507, 198, 277, 14, 2246, 5973, 5710, 275, 1642, 5973, 5710, 507, 198, 692, 8570, 508, 298, 21787, 582, 686, 198, 277, 14, 21787, 275, 653, 476, 527, 5929, 8, 1501, 9, 686, 198, 277, 14, 21787, 14, 4166, 459, 14635, 2278, 271, 5275, 342, 686, 198, 277, 14, 14635, 275, 291, 14, 21787, 14, 14635, 14, 14635, 507, 198, 2836, 26, 686, 198, 277, 14, 14635, 275, 291, 14, 345, 1652, 3987, 2842, 8, 1501, 9, 9068, 198, 692, 291, 14, 2246, 5973, 5710, 690, 378, 436, 291, 14, 2246, 5973, 5710, 2695, 822, 8, 277, 14, 14635, 304, 686, 198, 277, 14, 14635, 275, 291, 14, 14635, 1491, 277, 14, 2246, 5973, 5710, 61, 9068, 198, 277, 14, 502, 1800, 63, 1648, 275, 12178, 8, 277, 14, 14635, 59, 16, 6575, 362, 63, 8914, 63, 1247, 342, 507, 198, 277, 14, 1507, 502, 1800, 275, 822, 8, 277, 14, 502, 1800, 63, 1648, 9, 507, 198, 277, 14, 1507, 14635, 275, 822, 8, 277, 14, 14635, 9, 507, 198, 277, 14, 264, 1231, 275, 295, 1231, 507, 8299, 198, 318, 2813, 63, 548, 2634, 8, 277, 12, 312, 71, 1247, 12, 2813, 275, 756, 304, 507, 198, 624, 264, 1231, 1808, 734, 2634, 436, 2813, 3062, 624, 507, 198, 277, 14, 264, 1231, 275, 756, 507, 198, 893, 26, 686, 198, 692, 2813, 26, 1585, 198, 509, 312, 71, 315, 312, 71, 1247, 26, 1871, 198, 277, 14, 502, 1800, 63, 1648, 14, 2168, 8, 974, 9, 1585, 198, 277, 14, 1507, 502, 1800, 275, 822, 8, 277, 14, 502, 1800, 63, 1648, 9, 686, 198, 509, 284, 315, 1425, 8, 552, 8, 277, 14, 14635, 2298, 1585, 198, 84, 275, 12178, 8, 277, 14, 14635, 59, 73, 566, 1585, 198, 692, 822, 8, 974, 1247, 9, 665, 499, 26, 1871, 198, 84, 14, 409, 63, 548, 923, 8, 974, 1247, 59, 16, 566, 1871, 198, 692, 2813, 26, 4671, 198, 84, 14, 22268, 8, 277, 14, 502, 1800, 63, 1648, 12, 11211, 63, 4694, 63, 1267, 29, 549, 9, 1585, 198, 2836, 26, 1871, 198, 20745, 275, 307, 14, 362, 63, 2330, 63, 20745, 8, 974, 1247, 9, 1871, 198, 692, 440, 307, 508, 18432, 26, 4671, 198, 84, 14, 409, 63, 548, 923, 8, 20745, 9, 1871, 198, 692, 2813, 26, 4671, 198, 84, 14, 22268, 8, 277, 14, 502, 1800, 63, 1648, 12, 11211, 63, 4694, 63, 1267, 29, 549, 9, 1585, 198, 277, 14, 14635, 59, 73, 61, 275, 307, 14, 952, 342, 507, 198, 2590, 1722, 12, 325, 26, 686, 198, 1361, 8, 69, 9, 686, 198, 1361, 4582, 78, 428, 676, 2127, 365, 6835, 543, 314, 1324, 734, 923, 1561, 971, 78, 1413, 4993, 316, 2263, 531, 686, 198, 1274, 14, 2224, 342, 507, 8299, 198, 318, 477, 3097, 8, 277, 12, 1249, 304, 507, 198, 277, 14, 12553, 275, 942, 507, 198, 277, 14, 1751, 275, 942, 507, 198, 6507, 275, 413, 9068, 198, 692, 822, 8, 277, 14, 14635, 9, 508, 413, 26, 686, 198, 2350, 275, 291, 14, 14635, 59, 16, 61, 686, 198, 278, 275, 488, 20866, 198, 692, 1249, 14, 12325, 63, 1866, 2695, 378, 26, 1585, 198, 278, 275, 23160, 63, 2664, 4167, 8, 2350, 29, 3123, 12, 1390, 63, 15266, 275, 1249, 14, 988, 63, 1661, 12, 1748, 63, 3289, 275, 1249, 14, 827, 63, 3289, 76, 9, 686, 198, 2836, 26, 1585, 198, 278, 275, 23160, 63, 2664, 4167, 8, 2350, 29, 3123, 12, 1390, 63, 15266, 275, 1249, 14, 988, 63, 1661, 12, 1748, 63, 3289, 275, 1249, 14, 827, 63, 3289, 76, 12, 2249, 63, 1866, 275, 1249, 14, 12325, 63, 1866, 12, 5325, 63, 681, 63, 1866, 275, 715, 9, 26140, 198, 692, 1249, 14, 2191, 25840, 26, 1585, 198, 278, 14, 2191, 25840, 316, 63, 1733, 8, 264, 1231, 275, 291, 14, 264, 1231, 12, 10054, 275, 1249, 14, 83, 8590, 9, 686, 198, 2836, 26, 1585, 198, 278, 14, 1733, 8, 264, 1231, 275, 291, 14, 264, 1231, 12, 10054, 275, 1249, 14, 83, 8590, 9, 26140, 198, 3, 1361, 370, 6426, 686, 198, 3, 278, 14, 835, 63, 17168, 8, 1381, 275, 1249, 14, 80, 585, 9, 686, 198, 3, 278, 14, 1361, 63, 17168, 342, 686, 198, 1361, 480, 3259, 402, 20340, 26, 298, 435, 4700, 8, 278, 14, 835, 63, 17168, 8, 1381, 275, 1249, 14, 80, 585, 1724, 26140, 198, 475, 12, 623, 275, 562, 14, 1199, 63, 17168, 8, 502, 1800, 63, 1648, 275, 291, 14, 502, 1800, 63, 1648, 9, 686, 198, 277, 14, 12553, 14, 740, 8, 462, 9, 686, 198, 277, 14, 1751, 14, 740, 8, 278, 14, 988, 63, 6031, 9, 1585, 507, 198, 2836, 26, 686, 198, 509, 3123, 315, 291, 14, 14635, 26, 1585, 198, 1361, 480, 9602, 510, 6495, 641, 3123, 298, 435, 4700, 8, 6507, 9, 435, 298, 2508, 32478, 531, 1585, 198, 6507, 275, 12703, 435, 413, 1585, 198, 278, 275, 23160, 63, 2664, 4167, 8, 2350, 29, 3123, 12, 1390, 63, 15266, 275, 1249, 14, 988, 63, 1661, 12, 1748, 63, 3289, 275, 1249, 14, 827 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 893, 26, 199, 198, 646, 984, 199, 198, 646, 3473, 199, 198, 646, 5055, 199, 198, 646, 747, 199, 198, 646, 7534, 199, 198, 646, 3123, 2090, 199, 198, 504, 3123, 2090, 492, 12178, 12, 28534, 2448, 199, 198, 504, 22761, 527, 492, 653, 476, 527, 5929, 199, 198, 504, 510, 52, 2749, 44, 40, 492, 634, 72, 63, 6884, 63, 396, 12, 1437, 63, 4972, 12, 20340, 63, 6031, 12, 23160, 63, 2664, 4167, 199, 198, 504, 6212, 492, 6484, 2087, 199, 2590, 3545, 26, 199, 198, 1361, 480, 7700, 6117, 787, 4124, 367, 510, 6495, 14, 647, 2685, 199, 198, 1274, 14, 2224, 342, 199, 199, 533, 15865, 63, 541, 80, 26, 199, 198, 624, 2540, 32685, 7608, 641, 3663, 14416, 624, 199, 198, 318, 636, 826, 721, 277, 12, 1788, 12, 8570, 275, 298, 21787, 401, 295, 1231, 275, 756, 12, 1083, 275, 298, 40, 17, 401, 1642, 5973, 5710, 275, 378, 304, 507, 198, 277, 14, 765, 275, 1083, 507, 198, 277, 14, 2246, 5973, 5710, 275, 1642, 5973, 5710, 507, 198, 692, 8570, 508, 298, 21787, 582, 686, 198, 277, 14, 21787, 275, 653, 476, 527, 5929, 8, 1501, 9, 686, 198, 277, 14, 21787, 14, 4166, 459, 14635, 2278, 271, 5275, 342, 686, 198, 277, 14, 14635, 275, 291, 14, 21787, 14, 14635, 14, 14635, 507, 198, 2836, 26, 686, 198, 277, 14, 14635, 275, 291, 14, 345, 1652, 3987, 2842, 8, 1501, 9, 9068, 198, 692, 291, 14, 2246, 5973, 5710, 690, 378, 436, 291, 14, 2246, 5973, 5710, 2695, 822, 8, 277, 14, 14635, 304, 686, 198, 277, 14, 14635, 275, 291, 14, 14635, 1491, 277, 14, 2246, 5973, 5710, 61, 9068, 198, 277, 14, 502, 1800, 63, 1648, 275, 12178, 8, 277, 14, 14635, 59, 16, 6575, 362, 63, 8914, 63, 1247, 342, 507, 198, 277, 14, 1507, 502, 1800, 275, 822, 8, 277, 14, 502, 1800, 63, 1648, 9, 507, 198, 277, 14, 1507, 14635, 275, 822, 8, 277, 14, 14635, 9, 507, 198, 277, 14, 264, 1231, 275, 295, 1231, 507, 8299, 198, 318, 2813, 63, 548, 2634, 8, 277, 12, 312, 71, 1247, 12, 2813, 275, 756, 304, 507, 198, 624, 264, 1231, 1808, 734, 2634, 436, 2813, 3062, 624, 507, 198, 277, 14, 264, 1231, 275, 756, 507, 198, 893, 26, 686, 198, 692, 2813, 26, 1585, 198, 509, 312, 71, 315, 312, 71, 1247, 26, 1871, 198, 277, 14, 502, 1800, 63, 1648, 14, 2168, 8, 974, 9, 1585, 198, 277, 14, 1507, 502, 1800, 275, 822, 8, 277, 14, 502, 1800, 63, 1648, 9, 686, 198, 509, 284, 315, 1425, 8, 552, 8, 277, 14, 14635, 2298, 1585, 198, 84, 275, 12178, 8, 277, 14, 14635, 59, 73, 566, 1585, 198, 692, 822, 8, 974, 1247, 9, 665, 499, 26, 1871, 198, 84, 14, 409, 63, 548, 923, 8, 974, 1247, 59, 16, 566, 1871, 198, 692, 2813, 26, 4671, 198, 84, 14, 22268, 8, 277, 14, 502, 1800, 63, 1648, 12, 11211, 63, 4694, 63, 1267, 29, 549, 9, 1585, 198, 2836, 26, 1871, 198, 20745, 275, 307, 14, 362, 63, 2330, 63, 20745, 8, 974, 1247, 9, 1871, 198, 692, 440, 307, 508, 18432, 26, 4671, 198, 84, 14, 409, 63, 548, 923, 8, 20745, 9, 1871, 198, 692, 2813, 26, 4671, 198, 84, 14, 22268, 8, 277, 14, 502, 1800, 63, 1648, 12, 11211, 63, 4694, 63, 1267, 29, 549, 9, 1585, 198, 277, 14, 14635, 59, 73, 61, 275, 307, 14, 952, 342, 507, 198, 2590, 1722, 12, 325, 26, 686, 198, 1361, 8, 69, 9, 686, 198, 1361, 4582, 78, 428, 676, 2127, 365, 6835, 543, 314, 1324, 734, 923, 1561, 971, 78, 1413, 4993, 316, 2263, 531, 686, 198, 1274, 14, 2224, 342, 507, 8299, 198, 318, 477, 3097, 8, 277, 12, 1249, 304, 507, 198, 277, 14, 12553, 275, 942, 507, 198, 277, 14, 1751, 275, 942, 507, 198, 6507, 275, 413, 9068, 198, 692, 822, 8, 277, 14, 14635, 9, 508, 413, 26, 686, 198, 2350, 275, 291, 14, 14635, 59, 16, 61, 686, 198, 278, 275, 488, 20866, 198, 692, 1249, 14, 12325, 63, 1866, 2695, 378, 26, 1585, 198, 278, 275, 23160, 63, 2664, 4167, 8, 2350, 29, 3123, 12, 1390, 63, 15266, 275, 1249, 14, 988, 63, 1661, 12, 1748, 63, 3289, 275, 1249, 14, 827, 63, 3289, 76, 9, 686, 198, 2836, 26, 1585, 198, 278, 275, 23160, 63, 2664, 4167, 8, 2350, 29, 3123, 12, 1390, 63, 15266, 275, 1249, 14, 988, 63, 1661, 12, 1748, 63, 3289, 275, 1249, 14, 827, 63, 3289, 76, 12, 2249, 63, 1866, 275, 1249, 14, 12325, 63, 1866, 12, 5325, 63, 681, 63, 1866, 275, 715, 9, 26140, 198, 692, 1249, 14, 2191, 25840, 26, 1585, 198, 278, 14, 2191, 25840, 316, 63, 1733, 8, 264, 1231, 275, 291, 14, 264, 1231, 12, 10054, 275, 1249, 14, 83, 8590, 9, 686, 198, 2836, 26, 1585, 198, 278, 14, 1733, 8, 264, 1231, 275, 291, 14, 264, 1231, 12, 10054, 275, 1249, 14, 83, 8590, 9, 26140, 198, 3, 1361, 370, 6426, 686, 198, 3, 278, 14, 835, 63, 17168, 8, 1381, 275, 1249, 14, 80, 585, 9, 686, 198, 3, 278, 14, 1361, 63, 17168, 342, 686, 198, 1361, 480, 3259, 402, 20340, 26, 298, 435, 4700, 8, 278, 14, 835, 63, 17168, 8, 1381, 275, 1249, 14, 80, 585, 1724, 26140, 198, 475, 12, 623, 275, 562, 14, 1199, 63, 17168, 8, 502, 1800, 63, 1648, 275, 291, 14, 502, 1800, 63, 1648, 9, 686, 198, 277, 14, 12553, 14, 740, 8, 462, 9, 686, 198, 277, 14, 1751, 14, 740, 8, 278, 14, 988, 63, 6031, 9, 1585, 507, 198, 2836, 26, 686, 198, 509, 3123, 315, 291, 14, 14635, 26, 1585, 198, 1361, 480, 9602, 510, 6495, 641, 3123, 298, 435, 4700, 8, 6507, 9, 435, 298, 2508, 32478, 531, 1585, 198, 6507, 275, 12703, 435, 413, 1585, 198, 278, 275, 23160, 63, 2664, 4167, 8, 2350, 29, 3123, 12, 1390, 63, 15266, 275, 1249, 14, 988, 63, 1661, 12, 1748, 63, 3289, 275, 1249, 14, 827, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MayankGo/ec2-api
ec2api/db/api.py
1
3832
# Copyright 2013 Cloudscaling Group, 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. """Defines interface for DB access. Functions in this module are imported into the ec2api.db namespace. Call these functions from ec2api.db namespace, not the ec2api.db.api namespace. **Related Flags** :dbackend: string to lookup in the list of LazyPluggable backends. `sqlalchemy` is the only supported backend right now. :connection: string specifying the sqlalchemy connection to use, like: `sqlite:///var/lib/ec2api/ec2api.sqlite`. """ from eventlet import tpool from oslo_config import cfg from oslo_db import api as db_api from oslo_log import log as logging tpool_opts = [ cfg.BoolOpt('use_tpool', default=False, deprecated_name='dbapi_use_tpool', deprecated_group='DEFAULT', help='Enable the experimental use of thread pooling for ' 'all DB API calls'), ] CONF = cfg.CONF CONF.register_opts(tpool_opts, 'database') _BACKEND_MAPPING = {'sqlalchemy': 'ec2api.db.sqlalchemy.api'} class EC2DBAPI(object): """ec2's DB API wrapper class. This wraps the oslo DB API with an option to be able to use eventlet's thread pooling. Since the CONF variable may not be loaded at the time this class is instantiated, we must look at it on the first DB API call. """ def __init__(self): self.__db_api = None @property def _db_api(self): if not self.__db_api: ec2_db_api = db_api.DBAPI(CONF.database.backend, backend_mapping=_BACKEND_MAPPING) if CONF.database.use_tpool: self.__db_api = tpool.Proxy(ec2_db_api) else: self.__db_api = ec2_db_api return self.__db_api def __getattr__(self, key): return getattr(self._db_api, key) IMPL = EC2DBAPI() LOG = logging.getLogger(__name__) def add_item(context, kind, data, project_id=None): return IMPL.add_item(context, kind, data, project_id=project_id) def add_item_id(context, kind, os_id, project_id=None): return IMPL.add_item_id(context, kind, os_id, project_id=project_id) def update_item(context, item): IMPL.update_item(context, item) def delete_item(context, item_id): IMPL.delete_item(context, item_id) def restore_item(context, kind, data): return IMPL.restore_item(context, kind, data) def get_items(context, kind): return IMPL.get_items(context, kind) def get_item_by_id(context, item_id): return IMPL.get_item_by_id(context, item_id) def get_items_by_ids(context, item_ids): return IMPL.get_items_by_ids(context, item_ids) def get_public_items(context, kind, item_ids=None): return IMPL.get_public_items(context, kind, item_ids) def get_items_ids(context, kind, item_ids=None, item_os_ids=None): return IMPL.get_items_ids(context, kind, item_ids=item_ids, item_os_ids=item_os_ids) def add_tags(context, tags): return IMPL.add_tags(context, tags) def delete_tags(context, item_ids, tag_pairs=None): return IMPL.delete_tags(context, item_ids, tag_pairs) def get_tags(context, kinds=None, item_ids=None): return IMPL.get_tags(context, kinds, item_ids)
apache-2.0
[ 3, 259, 1898, 6171, 8142, 12153, 5611, 12, 3277, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 23891, 3217, 367, 6249, 2879, 14, 199, 199, 13967, 315, 642, 859, 787, 8439, 1901, 314, 7062, 18, 1246, 14, 697, 3231, 14, 6523, 3520, 199, 5777, 687, 7062, 18, 1246, 14, 697, 3231, 12, 440, 314, 7062, 18, 1246, 14, 697, 14, 1246, 3231, 14, 199, 199, 538, 13885, 24870, 538, 199, 199, 26, 697, 564, 500, 26, 221, 1059, 370, 4237, 315, 314, 769, 402, 22373, 19173, 16725, 14745, 14, 288, 658, 14536, 64, 365, 314, 1454, 3748, 4865, 2451, 3063, 14, 199, 199, 26, 2105, 26, 221, 1059, 9176, 314, 8335, 1950, 370, 675, 12, 2839, 26, 1598, 658, 10659, 24436, 1391, 15, 773, 15, 825, 18, 1246, 15, 825, 18, 1246, 14, 10659, 2313, 199, 199, 624, 199, 199, 504, 21819, 492, 307, 2293, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 697, 492, 2986, 465, 1592, 63, 1246, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 421, 199, 84, 2293, 63, 3291, 275, 359, 272, 4810, 14, 10349, 9985, 360, 1180, 63, 84, 2293, 297, 355, 849, 29, 797, 12, 355, 5906, 63, 354, 534, 22103, 63, 1180, 63, 84, 2293, 297, 355, 5906, 63, 923, 534, 3472, 297, 355, 1720, 534, 6476, 314, 22820, 675, 402, 2462, 20699, 367, 283, 2151, 283, 452, 6249, 3261, 4882, 659, 199, 61, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 3291, 8, 84, 2293, 63, 3291, 12, 283, 4659, 358, 199, 199, 63, 18145, 63, 20351, 275, 791, 14536, 356, 283, 825, 18, 1246, 14, 697, 14, 14536, 14, 1246, 936, 421, 199, 533, 15352, 18, 2846, 3735, 8, 785, 304, 272, 408, 825, 18, 1159, 6249, 3261, 4975, 1021, 14, 339, 961, 14018, 314, 11258, 6249, 3261, 543, 376, 945, 370, 506, 7688, 370, 675, 21819, 1159, 272, 2462, 20699, 14, 9336, 314, 6392, 1750, 1443, 440, 506, 6511, 737, 314, 900, 272, 642, 1021, 365, 17544, 12, 781, 1471, 3648, 737, 652, 641, 314, 1642, 6249, 3261, 1240, 14, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 855, 697, 63, 1246, 275, 488, 339, 768, 1829, 272, 347, 485, 697, 63, 1246, 8, 277, 304, 267, 340, 440, 291, 855, 697, 63, 1246, 26, 288, 7062, 18, 63, 697, 63, 1246, 275, 1592, 63, 1246, 14, 2846, 3735, 8, 3103, 14, 4659, 14, 4620, 12, 4228, 4865, 63, 4745, 3699, 18145, 63, 20351, 9, 288, 340, 6392, 14, 4659, 14, 1180, 63, 84, 2293, 26, 355, 291, 855, 697, 63, 1246, 275, 307, 2293, 14, 4936, 8, 825, 18, 63, 697, 63, 1246, 9, 288, 587, 26, 355, 291, 855, 697, 63, 1246, 275, 7062, 18, 63, 697, 63, 1246, 267, 372, 291, 855, 697, 63, 1246, 339, 347, 636, 5675, 721, 277, 12, 790, 304, 267, 372, 2519, 8, 277, 423, 697, 63, 1246, 12, 790, 9, 421, 199, 26312, 275, 15352, 18, 2846, 3735, 342, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 1050, 63, 1053, 8, 1100, 12, 4928, 12, 666, 12, 2199, 63, 344, 29, 403, 304, 272, 372, 473, 3950, 14, 525, 63, 1053, 8, 1100, 12, 4928, 12, 666, 12, 2199, 63, 344, 29, 1715, 63, 344, 9, 421, 199, 318, 1050, 63, 1053, 63, 344, 8, 1100, 12, 4928, 12, 747, 63, 344, 12, 2199, 63, 344, 29, 403, 304, 272, 372, 473, 3950, 14, 525, 63, 1053, 63, 344, 8, 1100, 12, 4928, 12, 747, 63, 344, 12, 2199, 63, 344, 29, 1715, 63, 344, 9, 421, 199, 318, 1678, 63, 1053, 8, 1100, 12, 1242, 304, 272, 473, 3950, 14, 873, 63, 1053, 8, 1100, 12, 1242, 9, 421, 199, 318, 3145, 63, 1053, 8, 1100, 12, 1242, 63, 344, 304, 272, 473, 3950, 14, 1807, 63, 1053, 8, 1100, 12, 1242, 63, 344, 9, 421, 199, 318, 9066, 63, 1053, 8, 1100, 12, 4928, 12, 666, 304, 272, 372, 473, 3950, 14, 8011, 63, 1053, 8, 1100, 12, 4928, 12, 666, 9, 421, 199, 318, 664, 63, 1744, 8, 1100, 12, 4928, 304, 272, 372, 473, 3950, 14, 362, 63, 1744, 8, 1100, 12, 4928, 9, 421, 199, 318, 664, 63, 1053, 63, 991, 63, 344, 8, 1100, 12, 1242, 63, 344, 304, 272, 372, 473, 3950, 14, 362, 63, 1053, 63, 991, 63, 344, 8, 1100, 12, 1242, 63, 344, 9, 421, 199, 318, 664, 63, 1744, 63, 991, 63, 1580, 8, 1100, 12, 1242, 63, 1580, 304, 272, 372, 473, 3950, 14, 362, 63, 1744, 63, 991, 63, 1580, 8, 1100, 12, 1242, 63, 1580, 9, 421, 199, 318, 664, 63, 3455, 63, 1744, 8, 1100, 12, 4928, 12, 1242, 63, 1580, 29, 403, 304, 272, 372, 473, 3950, 14, 362, 63, 3455, 63, 1744, 8, 1100, 12, 4928, 12, 1242, 63, 1580, 9, 421, 199, 318, 664, 63, 1744, 63, 1580, 8, 1100, 12, 4928, 12, 1242, 63, 1580, 29, 403, 12, 1242, 63, 736, 63, 1580, 29, 403, 304, 272, 372, 473, 3950, 14, 362, 63, 1744, 63, 1580, 8, 1100, 12, 4928, 12, 1242, 63, 1580, 29, 1053, 63, 1580, 12, 2892, 1242, 63, 736, 63, 1580, 29, 1053, 63, 736, 63, 1580, 9, 421, 199, 318, 1050, 63, 2969, 8, 1100, 12, 3762, 304, 272, 372 ]
[ 259, 1898, 6171, 8142, 12153, 5611, 12, 3277, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 23891, 3217, 367, 6249, 2879, 14, 199, 199, 13967, 315, 642, 859, 787, 8439, 1901, 314, 7062, 18, 1246, 14, 697, 3231, 14, 6523, 3520, 199, 5777, 687, 7062, 18, 1246, 14, 697, 3231, 12, 440, 314, 7062, 18, 1246, 14, 697, 14, 1246, 3231, 14, 199, 199, 538, 13885, 24870, 538, 199, 199, 26, 697, 564, 500, 26, 221, 1059, 370, 4237, 315, 314, 769, 402, 22373, 19173, 16725, 14745, 14, 288, 658, 14536, 64, 365, 314, 1454, 3748, 4865, 2451, 3063, 14, 199, 199, 26, 2105, 26, 221, 1059, 9176, 314, 8335, 1950, 370, 675, 12, 2839, 26, 1598, 658, 10659, 24436, 1391, 15, 773, 15, 825, 18, 1246, 15, 825, 18, 1246, 14, 10659, 2313, 199, 199, 624, 199, 199, 504, 21819, 492, 307, 2293, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 697, 492, 2986, 465, 1592, 63, 1246, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 421, 199, 84, 2293, 63, 3291, 275, 359, 272, 4810, 14, 10349, 9985, 360, 1180, 63, 84, 2293, 297, 355, 849, 29, 797, 12, 355, 5906, 63, 354, 534, 22103, 63, 1180, 63, 84, 2293, 297, 355, 5906, 63, 923, 534, 3472, 297, 355, 1720, 534, 6476, 314, 22820, 675, 402, 2462, 20699, 367, 283, 2151, 283, 452, 6249, 3261, 4882, 659, 199, 61, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 3291, 8, 84, 2293, 63, 3291, 12, 283, 4659, 358, 199, 199, 63, 18145, 63, 20351, 275, 791, 14536, 356, 283, 825, 18, 1246, 14, 697, 14, 14536, 14, 1246, 936, 421, 199, 533, 15352, 18, 2846, 3735, 8, 785, 304, 272, 408, 825, 18, 1159, 6249, 3261, 4975, 1021, 14, 339, 961, 14018, 314, 11258, 6249, 3261, 543, 376, 945, 370, 506, 7688, 370, 675, 21819, 1159, 272, 2462, 20699, 14, 9336, 314, 6392, 1750, 1443, 440, 506, 6511, 737, 314, 900, 272, 642, 1021, 365, 17544, 12, 781, 1471, 3648, 737, 652, 641, 314, 1642, 6249, 3261, 1240, 14, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 855, 697, 63, 1246, 275, 488, 339, 768, 1829, 272, 347, 485, 697, 63, 1246, 8, 277, 304, 267, 340, 440, 291, 855, 697, 63, 1246, 26, 288, 7062, 18, 63, 697, 63, 1246, 275, 1592, 63, 1246, 14, 2846, 3735, 8, 3103, 14, 4659, 14, 4620, 12, 4228, 4865, 63, 4745, 3699, 18145, 63, 20351, 9, 288, 340, 6392, 14, 4659, 14, 1180, 63, 84, 2293, 26, 355, 291, 855, 697, 63, 1246, 275, 307, 2293, 14, 4936, 8, 825, 18, 63, 697, 63, 1246, 9, 288, 587, 26, 355, 291, 855, 697, 63, 1246, 275, 7062, 18, 63, 697, 63, 1246, 267, 372, 291, 855, 697, 63, 1246, 339, 347, 636, 5675, 721, 277, 12, 790, 304, 267, 372, 2519, 8, 277, 423, 697, 63, 1246, 12, 790, 9, 421, 199, 26312, 275, 15352, 18, 2846, 3735, 342, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 1050, 63, 1053, 8, 1100, 12, 4928, 12, 666, 12, 2199, 63, 344, 29, 403, 304, 272, 372, 473, 3950, 14, 525, 63, 1053, 8, 1100, 12, 4928, 12, 666, 12, 2199, 63, 344, 29, 1715, 63, 344, 9, 421, 199, 318, 1050, 63, 1053, 63, 344, 8, 1100, 12, 4928, 12, 747, 63, 344, 12, 2199, 63, 344, 29, 403, 304, 272, 372, 473, 3950, 14, 525, 63, 1053, 63, 344, 8, 1100, 12, 4928, 12, 747, 63, 344, 12, 2199, 63, 344, 29, 1715, 63, 344, 9, 421, 199, 318, 1678, 63, 1053, 8, 1100, 12, 1242, 304, 272, 473, 3950, 14, 873, 63, 1053, 8, 1100, 12, 1242, 9, 421, 199, 318, 3145, 63, 1053, 8, 1100, 12, 1242, 63, 344, 304, 272, 473, 3950, 14, 1807, 63, 1053, 8, 1100, 12, 1242, 63, 344, 9, 421, 199, 318, 9066, 63, 1053, 8, 1100, 12, 4928, 12, 666, 304, 272, 372, 473, 3950, 14, 8011, 63, 1053, 8, 1100, 12, 4928, 12, 666, 9, 421, 199, 318, 664, 63, 1744, 8, 1100, 12, 4928, 304, 272, 372, 473, 3950, 14, 362, 63, 1744, 8, 1100, 12, 4928, 9, 421, 199, 318, 664, 63, 1053, 63, 991, 63, 344, 8, 1100, 12, 1242, 63, 344, 304, 272, 372, 473, 3950, 14, 362, 63, 1053, 63, 991, 63, 344, 8, 1100, 12, 1242, 63, 344, 9, 421, 199, 318, 664, 63, 1744, 63, 991, 63, 1580, 8, 1100, 12, 1242, 63, 1580, 304, 272, 372, 473, 3950, 14, 362, 63, 1744, 63, 991, 63, 1580, 8, 1100, 12, 1242, 63, 1580, 9, 421, 199, 318, 664, 63, 3455, 63, 1744, 8, 1100, 12, 4928, 12, 1242, 63, 1580, 29, 403, 304, 272, 372, 473, 3950, 14, 362, 63, 3455, 63, 1744, 8, 1100, 12, 4928, 12, 1242, 63, 1580, 9, 421, 199, 318, 664, 63, 1744, 63, 1580, 8, 1100, 12, 4928, 12, 1242, 63, 1580, 29, 403, 12, 1242, 63, 736, 63, 1580, 29, 403, 304, 272, 372, 473, 3950, 14, 362, 63, 1744, 63, 1580, 8, 1100, 12, 4928, 12, 1242, 63, 1580, 29, 1053, 63, 1580, 12, 2892, 1242, 63, 736, 63, 1580, 29, 1053, 63, 736, 63, 1580, 9, 421, 199, 318, 1050, 63, 2969, 8, 1100, 12, 3762, 304, 272, 372, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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html#_obtaining_the_waf_file import os,tempfile,optparse,sys,re from waflib import Logs,Utils,Context cmds='distclean configure build install clean uninstall check dist distcheck'.split() options={} commands=[] lockfile=os.environ.get('WAFLOCK','.lock-waf_%s_build'%sys.platform) try:cache_global=os.path.abspath(os.environ['WAFCACHE']) except KeyError:cache_global='' platform=Utils.unversioned_sys_platform() class opt_parser(optparse.OptionParser): def __init__(self,ctx): optparse.OptionParser.__init__(self,conflict_handler="resolve",version='waf %s (%s)'%(Context.WAFVERSION,Context.WAFREVISION)) self.formatter.width=Logs.get_term_cols() p=self.add_option self.ctx=ctx jobs=ctx.jobs() p('-j','--jobs',dest='jobs',default=jobs,type='int',help='amount of parallel jobs (%r)'%jobs) p('-k','--keep',dest='keep',default=0,action='count',help='keep running happily even if errors are found') p('-v','--verbose',dest='verbose',default=0,action='count',help='verbosity level -v -vv or -vvv [default: 0]') p('--nocache',dest='nocache',default=False,action='store_true',help='ignore the WAFCACHE (if set)') p('--zones',dest='zones',default='',action='store',help='debugging zones (task_gen, deps, tasks, etc)') gr=optparse.OptionGroup(self,'configure options') self.add_option_group(gr) gr.add_option('-o','--out',action='store',default='',help='build dir for the project',dest='out') gr.add_option('-t','--top',action='store',default='',help='src dir for the project',dest='top') default_prefix=os.environ.get('PREFIX') if not default_prefix: if platform=='win32': d=tempfile.gettempdir() default_prefix=d[0].upper()+d[1:] else: default_prefix='/usr/local/' gr.add_option('--prefix',dest='prefix',default=default_prefix,help='installation prefix [default: %r]'%default_prefix) gr.add_option('--download',dest='download',default=False,action='store_true',help='try to download the tools if missing') gr=optparse.OptionGroup(self,'build and install options') self.add_option_group(gr) gr.add_option('-p','--progress',dest='progress_bar',default=0,action='count',help='-p: progress bar; -pp: ide output') gr.add_option('--targets',dest='targets',default='',action='store',help='task generators, e.g. "target1,target2"') gr=optparse.OptionGroup(self,'step options') self.add_option_group(gr) gr.add_option('--files',dest='files',default='',action='store',help='files to process, by regexp, e.g. "*/main.c,*/test/main.o"') default_destdir=os.environ.get('DESTDIR','') gr=optparse.OptionGroup(self,'install/uninstall options') self.add_option_group(gr) gr.add_option('--destdir',help='installation root [default: %r]'%default_destdir,default=default_destdir,dest='destdir') gr.add_option('-f','--force',dest='force',default=False,action='store_true',help='force file installation') gr.add_option('--distcheck-args',help='arguments to pass to distcheck',default=None,action='store') def get_usage(self): cmds_str={} for cls in Context.classes: if not cls.cmd or cls.cmd=='options': continue s=cls.__doc__ or'' cmds_str[cls.cmd]=s if Context.g_module: for(k,v)in Context.g_module.__dict__.items(): if k in['options','init','shutdown']: continue if type(v)is type(Context.create_context): if v.__doc__ and not k.startswith('_'): cmds_str[k]=v.__doc__ just=0 for k in cmds_str: just=max(just,len(k)) lst=[' %s: %s'%(k.ljust(just),v)for(k,v)in cmds_str.items()] lst.sort() ret='\n'.join(lst) return'''waf [commands] [options] Main commands (example: ./waf build -j4) %s '''%ret class OptionsContext(Context.Context): cmd='options' fun='options' def __init__(self,**kw): super(OptionsContext,self).__init__(**kw) self.parser=opt_parser(self) self.option_groups={} def jobs(self): count=int(os.environ.get('JOBS',0)) if count<1: if'NUMBER_OF_PROCESSORS'in os.environ: count=int(os.environ.get('NUMBER_OF_PROCESSORS',1)) else: if hasattr(os,'sysconf_names'): if'SC_NPROCESSORS_ONLN'in os.sysconf_names: count=int(os.sysconf('SC_NPROCESSORS_ONLN')) elif'SC_NPROCESSORS_CONF'in os.sysconf_names: count=int(os.sysconf('SC_NPROCESSORS_CONF')) if not count and os.name not in('nt','java'): try: tmp=self.cmd_and_log(['sysctl','-n','hw.ncpu'],quiet=0) except Exception: pass else: if re.match('^[0-9]+$',tmp): count=int(tmp) if count<1: count=1 elif count>1024: count=1024 return count def add_option(self,*k,**kw): return self.parser.add_option(*k,**kw) def add_option_group(self,*k,**kw): try: gr=self.option_groups[k[0]] except KeyError: gr=self.parser.add_option_group(*k,**kw) self.option_groups[k[0]]=gr return gr def get_option_group(self,opt_str): try: return self.option_groups[opt_str] except KeyError: for group in self.parser.option_groups: if group.title==opt_str: return group return None def parse_args(self,_args=None): global options,commands (options,leftover_args)=self.parser.parse_args(args=_args) commands=leftover_args if options.destdir: options.destdir=os.path.abspath(os.path.expanduser(options.destdir)) if options.verbose>=1: self.load('errcheck') def execute(self): super(OptionsContext,self).execute() self.parse_args()
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 1455, 921, 21500, 14, 31864, 14, 957, 15, 3187, 15, 4757, 15, 21500, 2706, 15, 4780, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 17336, 12, 2992, 1122, 12, 1274, 12, 264, 199, 504, 31380, 492, 3835, 458, 12, 7535, 12, 2998, 199, 12975, 534, 2686, 3118, 7908, 1900, 3907, 3633, 22199, 1104, 2917, 2917, 1074, 1370, 1294, 342, 199, 1419, 7622, 199, 4405, 9811, 199, 26204, 29, 736, 14, 2314, 14, 362, 360, 55, 5699, 4406, 26409, 831, 13, 21500, 4970, 83, 63, 1506, 5956, 1274, 14, 3246, 9, 199, 893, 26, 1637, 63, 2966, 29, 736, 14, 515, 14, 4832, 8, 736, 14, 2314, 459, 55, 5699, 8677, 1105, 199, 2590, 4067, 26, 1637, 63, 2966, 19070, 199, 3246, 29, 7535, 14, 324, 24155, 63, 1274, 63, 3246, 342, 199, 533, 2450, 63, 2087, 8, 2992, 1122, 14, 14553, 304, 199, 198, 318, 636, 826, 721, 277, 12, 3799, 304, 507, 198, 2992, 1122, 14, 14553, 855, 826, 721, 277, 12, 15207, 63, 2232, 628, 6983, 401, 1023, 534, 21500, 450, 83, 4366, 83, 3171, 2840, 2998, 14, 55, 5699, 4612, 12, 2998, 14, 55, 5699, 907, 18775, 430, 507, 198, 277, 14, 8911, 14, 2063, 29, 16333, 14, 362, 63, 5125, 63, 4574, 342, 507, 198, 80, 29, 277, 14, 525, 63, 1422, 507, 198, 277, 14, 3799, 29, 3799, 507, 198, 6920, 29, 3799, 14, 6920, 342, 507, 198, 80, 3654, 74, 28280, 6920, 297, 2614, 534, 6920, 297, 885, 29, 6920, 12, 466, 534, 442, 297, 3437, 534, 4606, 402, 9861, 9643, 4366, 82, 3171, 5, 6920, 9, 507, 198, 80, 3654, 75, 28280, 3250, 297, 2614, 534, 3250, 297, 885, 29, 16, 12, 1287, 534, 835, 297, 3437, 534, 3250, 3879, 394, 571, 3444, 2755, 340, 2552, 787, 1911, 358, 507, 198, 80, 3654, 86, 28280, 3832, 297, 2614, 534, 3832, 297, 885, 29, 16, 12, 1287, 534, 835, 297, 3437, 534, 9833, 2166, 446, 86, 446, 8958, 503, 446, 24622, 359, 885, 26, 378, 10374, 507, 198, 80, 4517, 23507, 21481, 297, 2614, 534, 23507, 21481, 297, 885, 29, 797, 12, 1287, 534, 1617, 63, 2052, 297, 3437, 534, 4247, 314, 644, 5699, 8677, 334, 692, 663, 5942, 507, 198, 80, 4517, 13325, 297, 2614, 534, 13325, 297, 885, 4581, 1287, 534, 1617, 297, 3437, 534, 24913, 18666, 334, 1765, 63, 2268, 12, 10140, 12, 6527, 12, 5423, 5942, 507, 198, 2587, 29, 2992, 1122, 14, 2602, 2448, 8, 277, 2584, 6472, 1511, 358, 507, 198, 277, 14, 525, 63, 1422, 63, 923, 8, 2587, 9, 507, 198, 2587, 14, 525, 63, 1422, 3654, 79, 28280, 548, 297, 1287, 534, 1617, 297, 885, 4581, 3437, 534, 1506, 2935, 367, 314, 2199, 297, 2614, 534, 548, 358, 507, 198, 2587, 14, 525, 63, 1422, 3654, 84, 28280, 2119, 297, 1287, 534, 1617, 297, 885, 4581, 3437, 534, 2164, 2935, 367, 314, 2199, 297, 2614, 534, 2119, 358, 507, 198, 885, 63, 1861, 29, 736, 14, 2314, 14, 362, 360, 6351, 358, 507, 198, 692, 440, 849, 63, 1861, 26, 686, 198, 692, 4298, 6803, 2676, 708, 356, 1585, 198, 68, 29, 17336, 14, 31572, 342, 1585, 198, 885, 63, 1861, 29, 68, 59, 16, 1055, 4142, 24543, 68, 59, 17, 2938, 686, 198, 2836, 26, 1585, 198, 885, 63, 1861, 8805, 2647, 15, 1832, 4805, 507, 198, 2587, 14, 525, 63, 1422, 4517, 1861, 297, 2614, 534, 1861, 297, 885, 29, 885, 63, 1861, 12, 3437, 534, 23048, 2403, 359, 885, 26, 450, 82, 61, 5956, 885, 63, 1861, 9, 507, 198, 2587, 14, 525, 63, 1422, 4517, 4249, 297, 2614, 534, 4249, 297, 885, 29, 797, 12, 1287, 534, 1617, 63, 2052, 297, 3437, 534, 893, 370, 5235, 314, 7249, 340, 4124, 358, 507, 198, 2587, 29, 2992, 1122, 14, 2602, 2448, 8, 277, 2584, 1506, 436, 3907, 1511, 358, 507, 198, 277, 14, 525, 63, 1422, 63, 923, 8, 2587, 9, 507, 198, 2587, 14, 525, 63, 1422, 3654, 80, 28280, 5734, 297, 2614, 534, 5734, 63, 1700, 297, 885, 29, 16, 12, 1287, 534, 835, 297, 3437, 18274, 80, 26, 6696, 4681, 27, 446, 802, 26, 9979, 1072, 358, 507, 198, 2587, 14, 525, 63, 1422, 4517, 4684, 297, 2614, 534, 4684, 297, 885, 4581, 1287, 534, 1617, 297, 3437, 534, 1765, 16952, 12, 325, 14, 71, 14, 298, 1375, 17, 12, 1375, 18, 9008, 507, 198, 2587, 29, 2992, 1122, 14, 2602, 2448, 8, 277, 2584, 2926, 1511, 358, 507, 198, 277, 14, 525, 63, 1422, 63, 923, 8, 2587, 9, 507, 198, 2587, 14, 525, 63, 1422, 4517, 1725, 297, 2614, 534, 1725, 297, 885, 4581, 1287, 534, 1617, 297, 3437, 534, 1725, 370, 2112, 12, 701, 13156, 12, 325, 14, 71, 14, 8969, 15, 973, 14, 67, 12, 15870, 396, 15, 973, 14, 79, 9008, 507, 198, 885, 63, 32669, 29, 736, 14, 2314, 14, 362, 360, 19374, 3022, 20944, 507, 198, 2587, 29, 2992, 1122, 14, 2602, 2448, 8, 277, 2584, 3174, 15, 19502, 1511, 358, 507, 198, 277, 14, 525, 63, 1422, 63, 923, 8, 2587, 9, 507, 198, 2587, 14, 525, 63, 1422, 4517, 32669, 297, 3437, 534, 23048, 1738, 359, 885, 26, 450, 82, 61, 5956, 885, 63, 32669, 12, 885, 29, 885, 63, 32669, 12, 2614, 534, 32669, 358, 507, 198, 2587, 14, 525, 63, 1422, 3654, 70, 28280, 3990, 297, 2614, 534, 3990, 297, 885, 29, 797, 12, 1287, 534, 1617, 63, 2052, 297, 3437, 534, 3990, 570, 12096, 358, 507, 198, 2587, 14, 525, 63, 1422, 4517, 2686, 1074, 13, 589, 297, 3437, 534, 4958, 370, 986, 370, 2917, 1074, 297, 885, 29, 403, 12, 1287, 534, 1617, 358, 199, 198, 318, 664, 63, 3807, 8, 277, 304, 507, 198, 12975, 63, 495, 7622, 507, 198, 509, 843, 315, 9470, 14, 2888, 26, 686, 198, 692, 440, 843, 14, 1760, 503, 843, 14, 1760, 6803, 1419, 356, 1585, 198, 6958, 686, 198, 83, 29, 1886, 855, 1301, 363, 503, 891, 686, 198, 12975, 63 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 1455, 921, 21500, 14, 31864, 14, 957, 15, 3187, 15, 4757, 15, 21500, 2706, 15, 4780, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 17336, 12, 2992, 1122, 12, 1274, 12, 264, 199, 504, 31380, 492, 3835, 458, 12, 7535, 12, 2998, 199, 12975, 534, 2686, 3118, 7908, 1900, 3907, 3633, 22199, 1104, 2917, 2917, 1074, 1370, 1294, 342, 199, 1419, 7622, 199, 4405, 9811, 199, 26204, 29, 736, 14, 2314, 14, 362, 360, 55, 5699, 4406, 26409, 831, 13, 21500, 4970, 83, 63, 1506, 5956, 1274, 14, 3246, 9, 199, 893, 26, 1637, 63, 2966, 29, 736, 14, 515, 14, 4832, 8, 736, 14, 2314, 459, 55, 5699, 8677, 1105, 199, 2590, 4067, 26, 1637, 63, 2966, 19070, 199, 3246, 29, 7535, 14, 324, 24155, 63, 1274, 63, 3246, 342, 199, 533, 2450, 63, 2087, 8, 2992, 1122, 14, 14553, 304, 199, 198, 318, 636, 826, 721, 277, 12, 3799, 304, 507, 198, 2992, 1122, 14, 14553, 855, 826, 721, 277, 12, 15207, 63, 2232, 628, 6983, 401, 1023, 534, 21500, 450, 83, 4366, 83, 3171, 2840, 2998, 14, 55, 5699, 4612, 12, 2998, 14, 55, 5699, 907, 18775, 430, 507, 198, 277, 14, 8911, 14, 2063, 29, 16333, 14, 362, 63, 5125, 63, 4574, 342, 507, 198, 80, 29, 277, 14, 525, 63, 1422, 507, 198, 277, 14, 3799, 29, 3799, 507, 198, 6920, 29, 3799, 14, 6920, 342, 507, 198, 80, 3654, 74, 28280, 6920, 297, 2614, 534, 6920, 297, 885, 29, 6920, 12, 466, 534, 442, 297, 3437, 534, 4606, 402, 9861, 9643, 4366, 82, 3171, 5, 6920, 9, 507, 198, 80, 3654, 75, 28280, 3250, 297, 2614, 534, 3250, 297, 885, 29, 16, 12, 1287, 534, 835, 297, 3437, 534, 3250, 3879, 394, 571, 3444, 2755, 340, 2552, 787, 1911, 358, 507, 198, 80, 3654, 86, 28280, 3832, 297, 2614, 534, 3832, 297, 885, 29, 16, 12, 1287, 534, 835, 297, 3437, 534, 9833, 2166, 446, 86, 446, 8958, 503, 446, 24622, 359, 885, 26, 378, 10374, 507, 198, 80, 4517, 23507, 21481, 297, 2614, 534, 23507, 21481, 297, 885, 29, 797, 12, 1287, 534, 1617, 63, 2052, 297, 3437, 534, 4247, 314, 644, 5699, 8677, 334, 692, 663, 5942, 507, 198, 80, 4517, 13325, 297, 2614, 534, 13325, 297, 885, 4581, 1287, 534, 1617, 297, 3437, 534, 24913, 18666, 334, 1765, 63, 2268, 12, 10140, 12, 6527, 12, 5423, 5942, 507, 198, 2587, 29, 2992, 1122, 14, 2602, 2448, 8, 277, 2584, 6472, 1511, 358, 507, 198, 277, 14, 525, 63, 1422, 63, 923, 8, 2587, 9, 507, 198, 2587, 14, 525, 63, 1422, 3654, 79, 28280, 548, 297, 1287, 534, 1617, 297, 885, 4581, 3437, 534, 1506, 2935, 367, 314, 2199, 297, 2614, 534, 548, 358, 507, 198, 2587, 14, 525, 63, 1422, 3654, 84, 28280, 2119, 297, 1287, 534, 1617, 297, 885, 4581, 3437, 534, 2164, 2935, 367, 314, 2199, 297, 2614, 534, 2119, 358, 507, 198, 885, 63, 1861, 29, 736, 14, 2314, 14, 362, 360, 6351, 358, 507, 198, 692, 440, 849, 63, 1861, 26, 686, 198, 692, 4298, 6803, 2676, 708, 356, 1585, 198, 68, 29, 17336, 14, 31572, 342, 1585, 198, 885, 63, 1861, 29, 68, 59, 16, 1055, 4142, 24543, 68, 59, 17, 2938, 686, 198, 2836, 26, 1585, 198, 885, 63, 1861, 8805, 2647, 15, 1832, 4805, 507, 198, 2587, 14, 525, 63, 1422, 4517, 1861, 297, 2614, 534, 1861, 297, 885, 29, 885, 63, 1861, 12, 3437, 534, 23048, 2403, 359, 885, 26, 450, 82, 61, 5956, 885, 63, 1861, 9, 507, 198, 2587, 14, 525, 63, 1422, 4517, 4249, 297, 2614, 534, 4249, 297, 885, 29, 797, 12, 1287, 534, 1617, 63, 2052, 297, 3437, 534, 893, 370, 5235, 314, 7249, 340, 4124, 358, 507, 198, 2587, 29, 2992, 1122, 14, 2602, 2448, 8, 277, 2584, 1506, 436, 3907, 1511, 358, 507, 198, 277, 14, 525, 63, 1422, 63, 923, 8, 2587, 9, 507, 198, 2587, 14, 525, 63, 1422, 3654, 80, 28280, 5734, 297, 2614, 534, 5734, 63, 1700, 297, 885, 29, 16, 12, 1287, 534, 835, 297, 3437, 18274, 80, 26, 6696, 4681, 27, 446, 802, 26, 9979, 1072, 358, 507, 198, 2587, 14, 525, 63, 1422, 4517, 4684, 297, 2614, 534, 4684, 297, 885, 4581, 1287, 534, 1617, 297, 3437, 534, 1765, 16952, 12, 325, 14, 71, 14, 298, 1375, 17, 12, 1375, 18, 9008, 507, 198, 2587, 29, 2992, 1122, 14, 2602, 2448, 8, 277, 2584, 2926, 1511, 358, 507, 198, 277, 14, 525, 63, 1422, 63, 923, 8, 2587, 9, 507, 198, 2587, 14, 525, 63, 1422, 4517, 1725, 297, 2614, 534, 1725, 297, 885, 4581, 1287, 534, 1617, 297, 3437, 534, 1725, 370, 2112, 12, 701, 13156, 12, 325, 14, 71, 14, 8969, 15, 973, 14, 67, 12, 15870, 396, 15, 973, 14, 79, 9008, 507, 198, 885, 63, 32669, 29, 736, 14, 2314, 14, 362, 360, 19374, 3022, 20944, 507, 198, 2587, 29, 2992, 1122, 14, 2602, 2448, 8, 277, 2584, 3174, 15, 19502, 1511, 358, 507, 198, 277, 14, 525, 63, 1422, 63, 923, 8, 2587, 9, 507, 198, 2587, 14, 525, 63, 1422, 4517, 32669, 297, 3437, 534, 23048, 1738, 359, 885, 26, 450, 82, 61, 5956, 885, 63, 32669, 12, 885, 29, 885, 63, 32669, 12, 2614, 534, 32669, 358, 507, 198, 2587, 14, 525, 63, 1422, 3654, 70, 28280, 3990, 297, 2614, 534, 3990, 297, 885, 29, 797, 12, 1287, 534, 1617, 63, 2052, 297, 3437, 534, 3990, 570, 12096, 358, 507, 198, 2587, 14, 525, 63, 1422, 4517, 2686, 1074, 13, 589, 297, 3437, 534, 4958, 370, 986, 370, 2917, 1074, 297, 885, 29, 403, 12, 1287, 534, 1617, 358, 199, 198, 318, 664, 63, 3807, 8, 277, 304, 507, 198, 12975, 63, 495, 7622, 507, 198, 509, 843, 315, 9470, 14, 2888, 26, 686, 198, 692, 440, 843, 14, 1760, 503, 843, 14, 1760, 6803, 1419, 356, 1585, 198, 6958, 686, 198, 83, 29, 1886, 855, 1301, 363, 503, 891, 686, 198, 12975, 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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from lxml import html as lxml_html try: import html except ImportError: import HTMLParser html = HTMLParser.HTMLParser() try: import cPickle as pk except ImportError: import pickle as pk class LeetcodeProblems(object): def get_problems_info(self): leetcode_url = 'https://leetcode.com/problemset/algorithms' res = requests.get(leetcode_url) if not res.ok: print('request error') sys.exit() cm = res.text cmt = cm.split('tbody>')[-2] indexs = re.findall(r'<td>(\d+)</td>', cmt) problem_urls = ['https://leetcode.com' + url \ for url in re.findall( r'<a href="(/problems/.+?)"', cmt)] levels = re.findall(r"<td value='\d*'>(.+?)</td>", cmt) tinfos = zip(indexs, levels, problem_urls) assert (len(indexs) == len(problem_urls) == len(levels)) infos = [] for info in tinfos: res = requests.get(info[-1]) if not res.ok: print('request error') sys.exit() tree = lxml_html.fromstring(res.text) title = tree.xpath('//meta[@property="og:title"]/@content')[0] description = tree.xpath('//meta[@property="description"]/@content') if not description: description = tree.xpath('//meta[@property="og:description"]/@content')[0] else: description = description[0] description = html.unescape(description.strip()) tags = tree.xpath('//div[@id="tags"]/following::a[@class="btn btn-xs btn-primary"]/text()') infos.append( { 'title': title, 'level': info[1], 'index': int(info[0]), 'description': description, 'tags': tags } ) with open('leecode_problems.pk', 'wb') as g: pk.dump(infos, g) return infos def to_text(self, pm_infos): if self.args.index: key = 'index' elif self.args.title: key = 'title' elif self.args.tag: key = 'tags' elif self.args.level: key = 'level' else: key = 'index' infos = sorted(pm_infos, key=lambda i: i[key]) text_template = '## {index} - {title}\n' \ '~{level}~ {tags}\n' \ '{description}\n' + '\n' * self.args.line text = '' for info in infos: if self.args.rm_blank: info['description'] = re.sub(r'[\n\r]+', r'\n', info['description']) text += text_template.format(**info) with open('leecode problems.txt', 'w') as g: g.write(text) def run(self): if os.path.exists('leecode_problems.pk') and not self.args.redownload: with open('leecode_problems.pk', 'rb') as f: pm_infos = pk.load(f) else: pm_infos = self.get_problems_info() print('find %s problems.' % len(pm_infos)) self.to_text(pm_infos) def handle_args(argv): p = argparse.ArgumentParser(description='extract all leecode problems to location') p.add_argument('--index', action='store_true', help='sort by index') p.add_argument('--level', action='store_true', help='sort by level') p.add_argument('--tag', action='store_true', help='sort by tag') p.add_argument('--title', action='store_true', help='sort by title') p.add_argument('--rm_blank', action='store_true', help='remove blank') p.add_argument('--line', action='store', type=int, default=10, help='blank of two problems') p.add_argument('-r', '--redownload', action='store_true', help='redownload data') args = p.parse_args(argv[1:]) return args def main(argv): args = handle_args(argv) x = LeetcodeProblems() x.args = args x.run() if __name__ == '__main__': argv = sys.argv main(argv)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 29, 1624, 13, 24, 1882, 199, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 646, 7534, 199, 646, 4145, 199, 504, 14490, 492, 3517, 465, 14490, 63, 1360, 199, 199, 893, 26, 272, 492, 3517, 199, 2590, 3545, 26, 272, 492, 24581, 272, 3517, 275, 24581, 14, 27375, 342, 199, 199, 893, 26, 272, 492, 17572, 465, 3803, 199, 2590, 3545, 26, 272, 492, 5927, 465, 3803, 199, 199, 533, 7005, 386, 600, 919, 7561, 8, 785, 304, 272, 347, 664, 63, 22959, 63, 815, 8, 277, 304, 267, 1026, 386, 600, 63, 633, 275, 283, 2859, 921, 274, 386, 600, 14, 957, 15, 6462, 409, 15, 24365, 7, 267, 522, 275, 4145, 14, 362, 8, 274, 386, 600, 63, 633, 9, 267, 340, 440, 522, 14, 745, 26, 288, 870, 360, 1069, 1125, 358, 288, 984, 14, 2224, 342, 267, 6904, 275, 522, 14, 505, 267, 286, 2037, 275, 6904, 14, 1294, 360, 17847, 5971, 1988, 18, 61, 267, 1478, 83, 275, 295, 14, 6452, 8, 82, 7601, 2076, 30, 2961, 68, 8771, 1108, 2076, 4206, 286, 2037, 9, 267, 5160, 63, 3603, 275, 788, 2859, 921, 274, 386, 600, 14, 957, 7, 435, 1166, 971, 717, 367, 1166, 315, 295, 14, 6452, 8, 1169, 519, 7601, 65, 4369, 628, 29478, 22959, 15, 11198, 32691, 286, 2037, 1874, 267, 11106, 275, 295, 14, 6452, 8, 82, 17030, 2076, 574, 17115, 68, 10, 8423, 28149, 15939, 2076, 7166, 286, 2037, 9, 267, 307, 14195, 275, 3482, 8, 1080, 83, 12, 11106, 12, 5160, 63, 3603, 9, 267, 702, 334, 552, 8, 1080, 83, 9, 508, 822, 8, 6462, 63, 3603, 9, 508, 822, 8, 11402, 430, 267, 24485, 275, 942, 267, 367, 2256, 315, 307, 14195, 26, 288, 522, 275, 4145, 14, 362, 8, 815, 1988, 17, 566, 288, 340, 440, 522, 14, 745, 26, 355, 870, 360, 1069, 1125, 358, 355, 984, 14, 2224, 342, 288, 3123, 275, 14490, 63, 1360, 14, 13521, 8, 470, 14, 505, 9, 288, 2538, 275, 3123, 14, 8006, 15079, 2024, 14251, 1829, 628, 974, 26, 1213, 937, 15, 32, 1317, 5832, 16, 61, 288, 1369, 275, 3123, 14, 8006, 15079, 2024, 14251, 1829, 628, 1802, 937, 15, 32, 1317, 358, 288, 340, 440, 1369, 26, 355, 1369, 275, 3123, 14, 8006, 15079, 2024, 14251, 1829, 628, 974, 26, 1802, 937, 15, 32, 1317, 5832, 16, 61, 288, 587, 26, 355, 1369, 275, 1369, 59, 16, 61, 288, 1369, 275, 3517, 14, 22726, 8, 1802, 14, 1913, 1012, 288, 3762, 275, 3123, 14, 8006, 15079, 3015, 14251, 344, 628, 2969, 937, 15, 21589, 447, 65, 14251, 533, 628, 9633, 19368, 13, 7977, 19368, 13, 3327, 937, 15, 505, 19004, 288, 24485, 14, 740, 8, 355, 469, 490, 283, 1213, 356, 2538, 12, 490, 283, 1896, 356, 2256, 59, 17, 467, 490, 283, 1080, 356, 1109, 8, 815, 59, 16, 2522, 490, 283, 1802, 356, 1369, 12, 490, 283, 2969, 356, 3762, 355, 789, 288, 776, 398, 543, 1551, 360, 18387, 600, 63, 22959, 14, 2051, 297, 283, 6603, 358, 465, 486, 26, 288, 3803, 14, 2724, 8, 14195, 12, 486, 9, 267, 372, 24485, 339, 347, 370, 63, 505, 8, 277, 12, 14207, 63, 14195, 304, 267, 340, 291, 14, 589, 14, 1080, 26, 288, 790, 275, 283, 1080, 7, 267, 916, 291, 14, 589, 14, 1213, 26, 288, 790, 275, 283, 1213, 7, 267, 916, 291, 14, 589, 14, 1450, 26, 288, 790, 275, 283, 2969, 7, 267, 916, 291, 14, 589, 14, 1896, 26, 288, 790, 275, 283, 1896, 7, 267, 587, 26, 288, 790, 275, 283, 1080, 7, 398, 24485, 275, 3355, 8, 7073, 63, 14195, 12, 790, 29, 2734, 284, 26, 284, 59, 498, 566, 398, 1318, 63, 1160, 275, 283, 309, 469, 1080, 93, 446, 469, 1213, 4988, 78, 7, 971, 288, 17352, 91, 1896, 93, 94, 221, 469, 2969, 4988, 78, 7, 971, 288, 5041, 1802, 4988, 78, 7, 435, 1557, 78, 7, 627, 291, 14, 589, 14, 604, 267, 1318, 275, 2125, 267, 367, 2256, 315, 24485, 26, 288, 340, 291, 14, 589, 14, 5682, 63, 2500, 26, 355, 2256, 459, 1802, 418, 275, 295, 14, 954, 8, 82, 22123, 78, 60, 82, 11529, 519, 1154, 78, 297, 2256, 459, 1802, 1105, 288, 1318, 847, 1318, 63, 1160, 14, 908, 3682, 815, 9, 398, 543, 1551, 360, 18387, 600, 8826, 14, 2424, 297, 283, 87, 358, 465, 486, 26, 288, 486, 14, 952, 8, 505, 9, 339, 347, 1255, 8, 277, 304, 267, 340, 747, 14, 515, 14, 2444, 360, 18387, 600, 63, 22959, 14, 2051, 358, 436, 440, 291, 14, 589, 14, 581, 944, 912, 26, 288, 543, 1551, 360, 18387, 600, 63, 22959, 14, 2051, 297, 283, 4848, 358, 465, 289, 26, 355, 14207, 63, 14195, 275, 3803, 14, 912, 8, 70, 9, 267, 587, 26, 288, 14207, 63, 14195, 275, 291, 14, 362, 63, 22959, 63, 815, 342, 398, 870, 360, 1623, 450, 83, 8826, 3530, 450, 822, 8, 7073, 63, 14195, 430, 267, 291, 14, 475, 63, 505, 8, 7073, 63, 14195, 9, 199, 199, 318, 2429, 63, 589, 8, 3020, 304, 272, 299, 275, 7534, 14, 10730, 8, 1802, 534, 5005, 1006, 1026, 69, 600, 8826, 370, 2909, 358, 272, 299, 14, 525, 63, 2094, 4517, 1080, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 3191, 701, 1478, 358, 272, 299, 14, 525, 63, 2094, 4517, 1896, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 3191, 701, 2166, 358, 272, 299, 14, 525, 63, 2094, 4517, 1450, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 3191, 701, 1947, 358, 272, 299, 14, 525, 63, 2094, 4517, 1213, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 3191, 701, 2538, 358, 272, 299, 14, 525, 63, 2094, 4517, 5682, 63, 2500, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 2168, 4596, 358, 272, 299, 14, 525, 63, 2094, 4517, 604, 297, 1595, 534, 1617, 297, 730, 29, 442, 12, 849, 29, 709, 12, 1720, 534, 2500, 402, 2877, 8826, 358, 272, 299, 14, 525, 63, 2094, 3654, 82, 297, 2850 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 29, 1624, 13, 24, 1882, 199, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 646, 7534, 199, 646, 4145, 199, 504, 14490, 492, 3517, 465, 14490, 63, 1360, 199, 199, 893, 26, 272, 492, 3517, 199, 2590, 3545, 26, 272, 492, 24581, 272, 3517, 275, 24581, 14, 27375, 342, 199, 199, 893, 26, 272, 492, 17572, 465, 3803, 199, 2590, 3545, 26, 272, 492, 5927, 465, 3803, 199, 199, 533, 7005, 386, 600, 919, 7561, 8, 785, 304, 272, 347, 664, 63, 22959, 63, 815, 8, 277, 304, 267, 1026, 386, 600, 63, 633, 275, 283, 2859, 921, 274, 386, 600, 14, 957, 15, 6462, 409, 15, 24365, 7, 267, 522, 275, 4145, 14, 362, 8, 274, 386, 600, 63, 633, 9, 267, 340, 440, 522, 14, 745, 26, 288, 870, 360, 1069, 1125, 358, 288, 984, 14, 2224, 342, 267, 6904, 275, 522, 14, 505, 267, 286, 2037, 275, 6904, 14, 1294, 360, 17847, 5971, 1988, 18, 61, 267, 1478, 83, 275, 295, 14, 6452, 8, 82, 7601, 2076, 30, 2961, 68, 8771, 1108, 2076, 4206, 286, 2037, 9, 267, 5160, 63, 3603, 275, 788, 2859, 921, 274, 386, 600, 14, 957, 7, 435, 1166, 971, 717, 367, 1166, 315, 295, 14, 6452, 8, 1169, 519, 7601, 65, 4369, 628, 29478, 22959, 15, 11198, 32691, 286, 2037, 1874, 267, 11106, 275, 295, 14, 6452, 8, 82, 17030, 2076, 574, 17115, 68, 10, 8423, 28149, 15939, 2076, 7166, 286, 2037, 9, 267, 307, 14195, 275, 3482, 8, 1080, 83, 12, 11106, 12, 5160, 63, 3603, 9, 267, 702, 334, 552, 8, 1080, 83, 9, 508, 822, 8, 6462, 63, 3603, 9, 508, 822, 8, 11402, 430, 267, 24485, 275, 942, 267, 367, 2256, 315, 307, 14195, 26, 288, 522, 275, 4145, 14, 362, 8, 815, 1988, 17, 566, 288, 340, 440, 522, 14, 745, 26, 355, 870, 360, 1069, 1125, 358, 355, 984, 14, 2224, 342, 288, 3123, 275, 14490, 63, 1360, 14, 13521, 8, 470, 14, 505, 9, 288, 2538, 275, 3123, 14, 8006, 15079, 2024, 14251, 1829, 628, 974, 26, 1213, 937, 15, 32, 1317, 5832, 16, 61, 288, 1369, 275, 3123, 14, 8006, 15079, 2024, 14251, 1829, 628, 1802, 937, 15, 32, 1317, 358, 288, 340, 440, 1369, 26, 355, 1369, 275, 3123, 14, 8006, 15079, 2024, 14251, 1829, 628, 974, 26, 1802, 937, 15, 32, 1317, 5832, 16, 61, 288, 587, 26, 355, 1369, 275, 1369, 59, 16, 61, 288, 1369, 275, 3517, 14, 22726, 8, 1802, 14, 1913, 1012, 288, 3762, 275, 3123, 14, 8006, 15079, 3015, 14251, 344, 628, 2969, 937, 15, 21589, 447, 65, 14251, 533, 628, 9633, 19368, 13, 7977, 19368, 13, 3327, 937, 15, 505, 19004, 288, 24485, 14, 740, 8, 355, 469, 490, 283, 1213, 356, 2538, 12, 490, 283, 1896, 356, 2256, 59, 17, 467, 490, 283, 1080, 356, 1109, 8, 815, 59, 16, 2522, 490, 283, 1802, 356, 1369, 12, 490, 283, 2969, 356, 3762, 355, 789, 288, 776, 398, 543, 1551, 360, 18387, 600, 63, 22959, 14, 2051, 297, 283, 6603, 358, 465, 486, 26, 288, 3803, 14, 2724, 8, 14195, 12, 486, 9, 267, 372, 24485, 339, 347, 370, 63, 505, 8, 277, 12, 14207, 63, 14195, 304, 267, 340, 291, 14, 589, 14, 1080, 26, 288, 790, 275, 283, 1080, 7, 267, 916, 291, 14, 589, 14, 1213, 26, 288, 790, 275, 283, 1213, 7, 267, 916, 291, 14, 589, 14, 1450, 26, 288, 790, 275, 283, 2969, 7, 267, 916, 291, 14, 589, 14, 1896, 26, 288, 790, 275, 283, 1896, 7, 267, 587, 26, 288, 790, 275, 283, 1080, 7, 398, 24485, 275, 3355, 8, 7073, 63, 14195, 12, 790, 29, 2734, 284, 26, 284, 59, 498, 566, 398, 1318, 63, 1160, 275, 283, 309, 469, 1080, 93, 446, 469, 1213, 4988, 78, 7, 971, 288, 17352, 91, 1896, 93, 94, 221, 469, 2969, 4988, 78, 7, 971, 288, 5041, 1802, 4988, 78, 7, 435, 1557, 78, 7, 627, 291, 14, 589, 14, 604, 267, 1318, 275, 2125, 267, 367, 2256, 315, 24485, 26, 288, 340, 291, 14, 589, 14, 5682, 63, 2500, 26, 355, 2256, 459, 1802, 418, 275, 295, 14, 954, 8, 82, 22123, 78, 60, 82, 11529, 519, 1154, 78, 297, 2256, 459, 1802, 1105, 288, 1318, 847, 1318, 63, 1160, 14, 908, 3682, 815, 9, 398, 543, 1551, 360, 18387, 600, 8826, 14, 2424, 297, 283, 87, 358, 465, 486, 26, 288, 486, 14, 952, 8, 505, 9, 339, 347, 1255, 8, 277, 304, 267, 340, 747, 14, 515, 14, 2444, 360, 18387, 600, 63, 22959, 14, 2051, 358, 436, 440, 291, 14, 589, 14, 581, 944, 912, 26, 288, 543, 1551, 360, 18387, 600, 63, 22959, 14, 2051, 297, 283, 4848, 358, 465, 289, 26, 355, 14207, 63, 14195, 275, 3803, 14, 912, 8, 70, 9, 267, 587, 26, 288, 14207, 63, 14195, 275, 291, 14, 362, 63, 22959, 63, 815, 342, 398, 870, 360, 1623, 450, 83, 8826, 3530, 450, 822, 8, 7073, 63, 14195, 430, 267, 291, 14, 475, 63, 505, 8, 7073, 63, 14195, 9, 199, 199, 318, 2429, 63, 589, 8, 3020, 304, 272, 299, 275, 7534, 14, 10730, 8, 1802, 534, 5005, 1006, 1026, 69, 600, 8826, 370, 2909, 358, 272, 299, 14, 525, 63, 2094, 4517, 1080, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 3191, 701, 1478, 358, 272, 299, 14, 525, 63, 2094, 4517, 1896, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 3191, 701, 2166, 358, 272, 299, 14, 525, 63, 2094, 4517, 1450, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 3191, 701, 1947, 358, 272, 299, 14, 525, 63, 2094, 4517, 1213, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 3191, 701, 2538, 358, 272, 299, 14, 525, 63, 2094, 4517, 5682, 63, 2500, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 2168, 4596, 358, 272, 299, 14, 525, 63, 2094, 4517, 604, 297, 1595, 534, 1617, 297, 730, 29, 442, 12, 849, 29, 709, 12, 1720, 534, 2500, 402, 2877, 8826, 358, 272, 299, 14, 525, 63, 2094, 3654, 82, 297, 2850, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
40223125/40223125-2
static/Brython3.1.0-20150301-090019/Lib/xml/sax/saxutils.py
730
11688
"""\ A library of useful helper classes to the SAX classes, for the convenience of application and driver writers. """ import os, urllib.parse, urllib.request import io from . import handler from . import xmlreader def __dict_replace(s, d): """Replace substrings of a string using a dictionary.""" for key, value in d.items(): s = s.replace(key, value) return s def escape(data, entities={}): """Escape &, <, and > in a string of data. You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. """ # must do ampersand first data = data.replace("&", "&amp;") data = data.replace(">", "&gt;") data = data.replace("<", "&lt;") if entities: data = __dict_replace(data, entities) return data def unescape(data, entities={}): """Unescape &amp;, &lt;, and &gt; in a string of data. You can unescape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. """ data = data.replace("&lt;", "<") data = data.replace("&gt;", ">") if entities: data = __dict_replace(data, entities) # must do ampersand last return data.replace("&amp;", "&") def quoteattr(data, entities={}): """Escape and quote an attribute value. Escape &, <, and > in a string of data, then quote it for use as an attribute value. The \" character will be escaped as well, if necessary. You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. """ entities = entities.copy() entities.update({'\n': '&#10;', '\r': '&#13;', '\t':'&#9;'}) data = escape(data, entities) if '"' in data: if "'" in data: data = '"%s"' % data.replace('"', "&quot;") else: data = "'%s'" % data else: data = '"%s"' % data return data def _gettextwriter(out, encoding): if out is None: import sys return sys.stdout if isinstance(out, io.TextIOBase): # use a text writer as is return out # wrap a binary writer with TextIOWrapper if isinstance(out, io.RawIOBase): # Keep the original file open when the TextIOWrapper is # destroyed class _wrapper: __class__ = out.__class__ def __getattr__(self, name): return getattr(out, name) buffer = _wrapper() buffer.close = lambda: None else: # This is to handle passed objects that aren't in the # IOBase hierarchy, but just have a write method buffer = io.BufferedIOBase() buffer.writable = lambda: True buffer.write = out.write try: # TextIOWrapper uses this methods to determine # if BOM (for UTF-16, etc) should be added buffer.seekable = out.seekable buffer.tell = out.tell except AttributeError: pass return io.TextIOWrapper(buffer, encoding=encoding, errors='xmlcharrefreplace', newline='\n', write_through=True) class XMLGenerator(handler.ContentHandler): def __init__(self, out=None, encoding="iso-8859-1", short_empty_elements=False): handler.ContentHandler.__init__(self) out = _gettextwriter(out, encoding) self._write = out.write self._flush = out.flush self._ns_contexts = [{}] # contains uri -> prefix dicts self._current_context = self._ns_contexts[-1] self._undeclared_ns_maps = [] self._encoding = encoding self._short_empty_elements = short_empty_elements self._pending_start_element = False def _qname(self, name): """Builds a qualified name from a (ns_url, localname) pair""" if name[0]: # Per http://www.w3.org/XML/1998/namespace, The 'xml' prefix is # bound by definition to http://www.w3.org/XML/1998/namespace. It # does not need to be declared and will not usually be found in # self._current_context. if 'http://www.w3.org/XML/1998/namespace' == name[0]: return 'xml:' + name[1] # The name is in a non-empty namespace prefix = self._current_context[name[0]] if prefix: # If it is not the default namespace, prepend the prefix return prefix + ":" + name[1] # Return the unqualified name return name[1] def _finish_pending_start_element(self,endElement=False): if self._pending_start_element: self._write('>') self._pending_start_element = False # ContentHandler methods def startDocument(self): self._write('<?xml version="1.0" encoding="%s"?>\n' % self._encoding) def endDocument(self): self._flush() def startPrefixMapping(self, prefix, uri): self._ns_contexts.append(self._current_context.copy()) self._current_context[uri] = prefix self._undeclared_ns_maps.append((prefix, uri)) def endPrefixMapping(self, prefix): self._current_context = self._ns_contexts[-1] del self._ns_contexts[-1] def startElement(self, name, attrs): self._finish_pending_start_element() self._write('<' + name) for (name, value) in attrs.items(): self._write(' %s=%s' % (name, quoteattr(value))) if self._short_empty_elements: self._pending_start_element = True else: self._write(">") def endElement(self, name): if self._pending_start_element: self._write('/>') self._pending_start_element = False else: self._write('</%s>' % name) def startElementNS(self, name, qname, attrs): self._finish_pending_start_element() self._write('<' + self._qname(name)) for prefix, uri in self._undeclared_ns_maps: if prefix: self._write(' xmlns:%s="%s"' % (prefix, uri)) else: self._write(' xmlns="%s"' % uri) self._undeclared_ns_maps = [] for (name, value) in attrs.items(): self._write(' %s=%s' % (self._qname(name), quoteattr(value))) if self._short_empty_elements: self._pending_start_element = True else: self._write(">") def endElementNS(self, name, qname): if self._pending_start_element: self._write('/>') self._pending_start_element = False else: self._write('</%s>' % self._qname(name)) def characters(self, content): if content: self._finish_pending_start_element() self._write(escape(content)) def ignorableWhitespace(self, content): if content: self._finish_pending_start_element() self._write(content) def processingInstruction(self, target, data): self._finish_pending_start_element() self._write('<?%s %s?>' % (target, data)) class XMLFilterBase(xmlreader.XMLReader): """This class is designed to sit between an XMLReader and the client application's event handlers. By default, it does nothing but pass requests up to the reader and events on to the handlers unmodified, but subclasses can override specific methods to modify the event stream or the configuration requests as they pass through.""" def __init__(self, parent = None): xmlreader.XMLReader.__init__(self) self._parent = parent # ErrorHandler methods def error(self, exception): self._err_handler.error(exception) def fatalError(self, exception): self._err_handler.fatalError(exception) def warning(self, exception): self._err_handler.warning(exception) # ContentHandler methods def setDocumentLocator(self, locator): self._cont_handler.setDocumentLocator(locator) def startDocument(self): self._cont_handler.startDocument() def endDocument(self): self._cont_handler.endDocument() def startPrefixMapping(self, prefix, uri): self._cont_handler.startPrefixMapping(prefix, uri) def endPrefixMapping(self, prefix): self._cont_handler.endPrefixMapping(prefix) def startElement(self, name, attrs): self._cont_handler.startElement(name, attrs) def endElement(self, name): self._cont_handler.endElement(name) def startElementNS(self, name, qname, attrs): self._cont_handler.startElementNS(name, qname, attrs) def endElementNS(self, name, qname): self._cont_handler.endElementNS(name, qname) def characters(self, content): self._cont_handler.characters(content) def ignorableWhitespace(self, chars): self._cont_handler.ignorableWhitespace(chars) def processingInstruction(self, target, data): self._cont_handler.processingInstruction(target, data) def skippedEntity(self, name): self._cont_handler.skippedEntity(name) # DTDHandler methods def notationDecl(self, name, publicId, systemId): self._dtd_handler.notationDecl(name, publicId, systemId) def unparsedEntityDecl(self, name, publicId, systemId, ndata): self._dtd_handler.unparsedEntityDecl(name, publicId, systemId, ndata) # EntityResolver methods def resolveEntity(self, publicId, systemId): return self._ent_handler.resolveEntity(publicId, systemId) # XMLReader methods def parse(self, source): self._parent.setContentHandler(self) self._parent.setErrorHandler(self) self._parent.setEntityResolver(self) self._parent.setDTDHandler(self) self._parent.parse(source) def setLocale(self, locale): self._parent.setLocale(locale) def getFeature(self, name): return self._parent.getFeature(name) def setFeature(self, name, state): self._parent.setFeature(name, state) def getProperty(self, name): return self._parent.getProperty(name) def setProperty(self, name, value): self._parent.setProperty(name, value) # XMLFilter methods def getParent(self): return self._parent def setParent(self, parent): self._parent = parent # --- Utility functions def prepare_input_source(source, base=""): """This function takes an InputSource and an optional base URL and returns a fully resolved InputSource object ready for reading.""" if isinstance(source, str): source = xmlreader.InputSource(source) elif hasattr(source, "read"): f = source source = xmlreader.InputSource() source.setByteStream(f) if hasattr(f, "name"): source.setSystemId(f.name) if source.getByteStream() is None: sysid = source.getSystemId() basehead = os.path.dirname(os.path.normpath(base)) sysidfilename = os.path.join(basehead, sysid) if os.path.isfile(sysidfilename): source.setSystemId(sysidfilename) f = open(sysidfilename, "rb") else: source.setSystemId(urllib.parse.urljoin(base, sysid)) f = urllib.request.urlopen(source.getSystemId()) source.setByteStream(f) return source
gpl-3.0
[ 19659, 199, 33, 3555, 402, 2997, 5922, 3992, 370, 314, 19310, 3992, 12, 367, 314, 199, 388, 23329, 402, 4223, 436, 5253, 2211, 878, 14, 199, 624, 199, 199, 646, 747, 12, 4011, 14, 1122, 12, 4011, 14, 1069, 199, 646, 5890, 199, 504, 1275, 492, 3016, 199, 504, 1275, 492, 2748, 5503, 199, 199, 318, 636, 807, 63, 1814, 8, 83, 12, 366, 304, 272, 408, 11328, 1007, 5465, 402, 282, 1059, 1808, 282, 2600, 1041, 272, 367, 790, 12, 574, 315, 366, 14, 1744, 837, 267, 308, 275, 308, 14, 1814, 8, 498, 12, 574, 9, 272, 372, 308, 199, 199, 318, 4772, 8, 576, 12, 9045, 16420, 272, 408, 10260, 17181, 665, 12, 436, 690, 315, 282, 1059, 402, 666, 14, 339, 2047, 883, 4772, 1163, 3326, 402, 666, 701, 9476, 282, 2600, 465, 272, 314, 2716, 9045, 2725, 14, 221, 710, 2883, 436, 1338, 1471, 1006, 506, 272, 3326, 27, 1924, 790, 911, 506, 8717, 543, 2399, 5226, 574, 14, 272, 408, 339, 327, 1471, 886, 15204, 1192, 460, 1642, 272, 666, 275, 666, 14, 1814, 22077, 401, 11746, 5282, 15027, 272, 666, 275, 666, 14, 1814, 480, 7166, 11746, 3308, 15027, 272, 666, 275, 666, 14, 1814, 6757, 401, 11746, 4116, 15027, 272, 340, 9045, 26, 267, 666, 275, 636, 807, 63, 1814, 8, 576, 12, 9045, 9, 272, 372, 666, 199, 199, 318, 22221, 8, 576, 12, 9045, 16420, 272, 408, 1358, 3765, 1253, 5282, 27031, 1253, 4116, 27031, 436, 1253, 3308, 27, 315, 282, 1059, 402, 666, 14, 339, 2047, 883, 22221, 1163, 3326, 402, 666, 701, 9476, 282, 2600, 465, 272, 314, 2716, 9045, 2725, 14, 221, 710, 2883, 436, 1338, 1471, 1006, 506, 272, 3326, 27, 1924, 790, 911, 506, 8717, 543, 2399, 5226, 574, 14, 272, 408, 272, 666, 275, 666, 14, 1814, 22077, 4116, 17259, 3886, 531, 272, 666, 275, 666, 14, 1814, 22077, 3308, 17259, 298, 9579, 272, 340, 9045, 26, 267, 666, 275, 636, 807, 63, 1814, 8, 576, 12, 9045, 9, 272, 327, 1471, 886, 15204, 1192, 460, 2061, 272, 372, 666, 14, 1814, 22077, 5282, 17259, 11746, 531, 199, 199, 318, 6313, 962, 8, 576, 12, 9045, 16420, 272, 408, 10260, 436, 6313, 376, 2225, 574, 14, 339, 21067, 17181, 665, 12, 436, 690, 315, 282, 1059, 402, 666, 12, 2066, 6313, 652, 367, 675, 465, 272, 376, 2225, 574, 14, 221, 710, 8441, 4528, 911, 506, 11077, 465, 5521, 12, 340, 272, 5784, 14, 339, 2047, 883, 4772, 1163, 3326, 402, 666, 701, 9476, 282, 2600, 465, 272, 314, 2716, 9045, 2725, 14, 221, 710, 2883, 436, 1338, 1471, 1006, 506, 272, 3326, 27, 1924, 790, 911, 506, 8717, 543, 2399, 5226, 574, 14, 272, 408, 272, 9045, 275, 9045, 14, 1574, 342, 272, 9045, 14, 873, 2561, 1154, 78, 356, 7673, 3, 709, 10805, 1557, 82, 356, 7673, 3, 969, 10805, 1557, 84, 5242, 7997, 25, 27, 3071, 272, 666, 275, 4772, 8, 576, 12, 9045, 9, 272, 340, 14788, 315, 666, 26, 267, 340, 21673, 315, 666, 26, 288, 666, 275, 18253, 83, 4507, 450, 666, 14, 1814, 20630, 11746, 5184, 15027, 267, 587, 26, 288, 666, 275, 17648, 83, 4065, 450, 666, 272, 587, 26, 267, 666, 275, 18253, 83, 4507, 450, 666, 272, 372, 666, 421, 199, 318, 485, 5152, 5491, 8, 548, 12, 2644, 304, 272, 340, 734, 365, 488, 26, 267, 492, 984, 267, 372, 984, 14, 2703, 339, 340, 1228, 8, 548, 12, 5890, 14, 1872, 23413, 304, 267, 327, 675, 282, 1318, 7060, 465, 365, 267, 372, 734, 339, 327, 4816, 282, 3366, 7060, 543, 4516, 29365, 272, 340, 1228, 8, 548, 12, 5890, 14, 7963, 23413, 304, 267, 327, 14797, 314, 3379, 570, 1551, 1380, 314, 4516, 29365, 365, 267, 327, 28924, 267, 1021, 485, 5029, 26, 288, 636, 533, 363, 275, 734, 855, 533, 363, 288, 347, 636, 5675, 721, 277, 12, 536, 304, 355, 372, 2519, 8, 548, 12, 536, 9, 267, 3335, 275, 485, 5029, 342, 267, 3335, 14, 1600, 275, 2400, 26, 488, 272, 587, 26, 267, 327, 961, 365, 370, 2429, 3032, 2251, 626, 10621, 1133, 315, 314, 267, 327, 5004, 1563, 14446, 12, 1325, 2951, 1172, 282, 2218, 1083, 267, 3335, 275, 5890, 14, 23139, 23413, 342, 267, 3335, 14, 15053, 275, 2400, 26, 715, 267, 3335, 14, 952, 275, 734, 14, 952, 267, 862, 26, 288, 327, 4516, 29365, 4440, 642, 3102, 370, 6705, 288, 327, 340, 17720, 334, 509, 9094, 13, 975, 12, 5423, 9, 1077, 506, 3483, 288, 3335, 14, 25895, 275, 734, 14, 25895, 288, 3335, 14, 9974, 275, 734, 14, 9974, 267, 871, 4281, 26, 288, 986, 272, 372, 5890, 14, 1872, 29365, 8, 2738, 12, 2644, 29, 2991, 12, 1169, 2552, 534, 1652, 24253, 1814, 297, 1169, 8057, 17115, 78, 297, 1169, 2218, 63, 8304, 29, 549, 9, 199, 199, 533, 4692, 7599, 8, 2232, 14, 2714, 2461, 304, 339, 347, 636, 826, 721, 277, 12, 734, 29, 403, 12, 2644, 628, 4595, 13, 4830, 13, 17, 401, 3974, 63, 1667, 63, 5527, 29, 797, 304, 267, 3016, 14, 2714, 2461, 855, 826, 721, 277, 9, 267, 734, 275, 485, 5152, 5491, 8, 548, 12, 2644, 9, 267, 291, 423, 952, 275, 734, 14, 952, 267, 291, 423, 4939, 275, 734, 14, 4939, 267, 291, 423, 561, 63, 19010, 275, 359, 27922, 327, 3509, 5108, 1035, 2403, 10809, 267, 291, 423, 1818, 63, 1100, 275, 291, 423, 561, 63, 19010, 1988, 17, 61, 267, 291, 423, 31531, 63, 561, 63, 8919, 275, 942, 267, 291, 423, 2991, 275, 2644, 267, 291, 423, 3612, 63, 1667, 63, 5527, 275, 3974, 63, 1667, 63, 5527, 267, 291, 423, 6455, 63, 928, 63, 2108, 275, 756, 339, 347, 485, 12333, 8, 277, 12, 536, 304, 267, 408, 27856, 282, 12313, 536, 687, 282, 334, 561, 63, 633, 12, 2257, 354, 9, 4092, 624, 267, 340, 536, 59, 16, 2189, 288, 327, 3492, 1455, 921, 1544, 14, 87, 19, 14, 1308, 15, 4317, 15, 23756, 15, 3251, 12, 710, 283, 1652, 7, 2403, 365, 288, 327, 3914, 701, 5492, 370, 1455, 921, 1544, 14, 87, 19, 14, 1308, 15, 4317, 15 ]
[ 199, 33, 3555, 402, 2997, 5922, 3992, 370, 314, 19310, 3992, 12, 367, 314, 199, 388, 23329, 402, 4223, 436, 5253, 2211, 878, 14, 199, 624, 199, 199, 646, 747, 12, 4011, 14, 1122, 12, 4011, 14, 1069, 199, 646, 5890, 199, 504, 1275, 492, 3016, 199, 504, 1275, 492, 2748, 5503, 199, 199, 318, 636, 807, 63, 1814, 8, 83, 12, 366, 304, 272, 408, 11328, 1007, 5465, 402, 282, 1059, 1808, 282, 2600, 1041, 272, 367, 790, 12, 574, 315, 366, 14, 1744, 837, 267, 308, 275, 308, 14, 1814, 8, 498, 12, 574, 9, 272, 372, 308, 199, 199, 318, 4772, 8, 576, 12, 9045, 16420, 272, 408, 10260, 17181, 665, 12, 436, 690, 315, 282, 1059, 402, 666, 14, 339, 2047, 883, 4772, 1163, 3326, 402, 666, 701, 9476, 282, 2600, 465, 272, 314, 2716, 9045, 2725, 14, 221, 710, 2883, 436, 1338, 1471, 1006, 506, 272, 3326, 27, 1924, 790, 911, 506, 8717, 543, 2399, 5226, 574, 14, 272, 408, 339, 327, 1471, 886, 15204, 1192, 460, 1642, 272, 666, 275, 666, 14, 1814, 22077, 401, 11746, 5282, 15027, 272, 666, 275, 666, 14, 1814, 480, 7166, 11746, 3308, 15027, 272, 666, 275, 666, 14, 1814, 6757, 401, 11746, 4116, 15027, 272, 340, 9045, 26, 267, 666, 275, 636, 807, 63, 1814, 8, 576, 12, 9045, 9, 272, 372, 666, 199, 199, 318, 22221, 8, 576, 12, 9045, 16420, 272, 408, 1358, 3765, 1253, 5282, 27031, 1253, 4116, 27031, 436, 1253, 3308, 27, 315, 282, 1059, 402, 666, 14, 339, 2047, 883, 22221, 1163, 3326, 402, 666, 701, 9476, 282, 2600, 465, 272, 314, 2716, 9045, 2725, 14, 221, 710, 2883, 436, 1338, 1471, 1006, 506, 272, 3326, 27, 1924, 790, 911, 506, 8717, 543, 2399, 5226, 574, 14, 272, 408, 272, 666, 275, 666, 14, 1814, 22077, 4116, 17259, 3886, 531, 272, 666, 275, 666, 14, 1814, 22077, 3308, 17259, 298, 9579, 272, 340, 9045, 26, 267, 666, 275, 636, 807, 63, 1814, 8, 576, 12, 9045, 9, 272, 327, 1471, 886, 15204, 1192, 460, 2061, 272, 372, 666, 14, 1814, 22077, 5282, 17259, 11746, 531, 199, 199, 318, 6313, 962, 8, 576, 12, 9045, 16420, 272, 408, 10260, 436, 6313, 376, 2225, 574, 14, 339, 21067, 17181, 665, 12, 436, 690, 315, 282, 1059, 402, 666, 12, 2066, 6313, 652, 367, 675, 465, 272, 376, 2225, 574, 14, 221, 710, 8441, 4528, 911, 506, 11077, 465, 5521, 12, 340, 272, 5784, 14, 339, 2047, 883, 4772, 1163, 3326, 402, 666, 701, 9476, 282, 2600, 465, 272, 314, 2716, 9045, 2725, 14, 221, 710, 2883, 436, 1338, 1471, 1006, 506, 272, 3326, 27, 1924, 790, 911, 506, 8717, 543, 2399, 5226, 574, 14, 272, 408, 272, 9045, 275, 9045, 14, 1574, 342, 272, 9045, 14, 873, 2561, 1154, 78, 356, 7673, 3, 709, 10805, 1557, 82, 356, 7673, 3, 969, 10805, 1557, 84, 5242, 7997, 25, 27, 3071, 272, 666, 275, 4772, 8, 576, 12, 9045, 9, 272, 340, 14788, 315, 666, 26, 267, 340, 21673, 315, 666, 26, 288, 666, 275, 18253, 83, 4507, 450, 666, 14, 1814, 20630, 11746, 5184, 15027, 267, 587, 26, 288, 666, 275, 17648, 83, 4065, 450, 666, 272, 587, 26, 267, 666, 275, 18253, 83, 4507, 450, 666, 272, 372, 666, 421, 199, 318, 485, 5152, 5491, 8, 548, 12, 2644, 304, 272, 340, 734, 365, 488, 26, 267, 492, 984, 267, 372, 984, 14, 2703, 339, 340, 1228, 8, 548, 12, 5890, 14, 1872, 23413, 304, 267, 327, 675, 282, 1318, 7060, 465, 365, 267, 372, 734, 339, 327, 4816, 282, 3366, 7060, 543, 4516, 29365, 272, 340, 1228, 8, 548, 12, 5890, 14, 7963, 23413, 304, 267, 327, 14797, 314, 3379, 570, 1551, 1380, 314, 4516, 29365, 365, 267, 327, 28924, 267, 1021, 485, 5029, 26, 288, 636, 533, 363, 275, 734, 855, 533, 363, 288, 347, 636, 5675, 721, 277, 12, 536, 304, 355, 372, 2519, 8, 548, 12, 536, 9, 267, 3335, 275, 485, 5029, 342, 267, 3335, 14, 1600, 275, 2400, 26, 488, 272, 587, 26, 267, 327, 961, 365, 370, 2429, 3032, 2251, 626, 10621, 1133, 315, 314, 267, 327, 5004, 1563, 14446, 12, 1325, 2951, 1172, 282, 2218, 1083, 267, 3335, 275, 5890, 14, 23139, 23413, 342, 267, 3335, 14, 15053, 275, 2400, 26, 715, 267, 3335, 14, 952, 275, 734, 14, 952, 267, 862, 26, 288, 327, 4516, 29365, 4440, 642, 3102, 370, 6705, 288, 327, 340, 17720, 334, 509, 9094, 13, 975, 12, 5423, 9, 1077, 506, 3483, 288, 3335, 14, 25895, 275, 734, 14, 25895, 288, 3335, 14, 9974, 275, 734, 14, 9974, 267, 871, 4281, 26, 288, 986, 272, 372, 5890, 14, 1872, 29365, 8, 2738, 12, 2644, 29, 2991, 12, 1169, 2552, 534, 1652, 24253, 1814, 297, 1169, 8057, 17115, 78, 297, 1169, 2218, 63, 8304, 29, 549, 9, 199, 199, 533, 4692, 7599, 8, 2232, 14, 2714, 2461, 304, 339, 347, 636, 826, 721, 277, 12, 734, 29, 403, 12, 2644, 628, 4595, 13, 4830, 13, 17, 401, 3974, 63, 1667, 63, 5527, 29, 797, 304, 267, 3016, 14, 2714, 2461, 855, 826, 721, 277, 9, 267, 734, 275, 485, 5152, 5491, 8, 548, 12, 2644, 9, 267, 291, 423, 952, 275, 734, 14, 952, 267, 291, 423, 4939, 275, 734, 14, 4939, 267, 291, 423, 561, 63, 19010, 275, 359, 27922, 327, 3509, 5108, 1035, 2403, 10809, 267, 291, 423, 1818, 63, 1100, 275, 291, 423, 561, 63, 19010, 1988, 17, 61, 267, 291, 423, 31531, 63, 561, 63, 8919, 275, 942, 267, 291, 423, 2991, 275, 2644, 267, 291, 423, 3612, 63, 1667, 63, 5527, 275, 3974, 63, 1667, 63, 5527, 267, 291, 423, 6455, 63, 928, 63, 2108, 275, 756, 339, 347, 485, 12333, 8, 277, 12, 536, 304, 267, 408, 27856, 282, 12313, 536, 687, 282, 334, 561, 63, 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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 ]
callowayproject/django-resources
contentrelations/related.py
1
7787
from django.db.models import Q from django.db import models from django.contrib.contenttypes.models import ContentType try: from django.contrib.contenttypes.fields import GenericForeignKey except ImportError: from django.contrib.contenttypes.generic import GenericForeignKey from .generic import GFKOptimizedQuerySet class RelatedResourceManager(models.Manager): def get_content_type(self, content_type, **kwargs): """ Get all the items of the given content type related to this item. """ qs = self.get_queryset() return qs.filter(content_type__name=content_type, **kwargs) def get_relation_source(self, relation_source, **kwargs): """ Get all the items of the given relation source to this item """ qs = self.get_queryset() return qs.filter(relation_source=relation_source, **kwargs) class RelatedResource(models.Model): """ A resource related to another object """ # SOURCE OBJECT source_type = models.ForeignKey(ContentType, related_name="child_relatedobjects") source_id = models.IntegerField(db_index=True) source = GenericForeignKey( ct_field="source_type", fk_field="source_id") # ACTUAL RELATED OBJECT: object_type = models.ForeignKey(ContentType, related_name="related_objects",) object_id = models.IntegerField(db_index=True) object = GenericForeignKey( ct_field="object_type", fk_field="object_id") # METADATA relation_source = models.IntegerField( editable=False, blank=True, null=True) relation_type = models.CharField( max_length=255, blank=True, null=True) order = models.IntegerField( blank=True, null=True) objects = RelatedResourceManager() class Meta: ordering = ('order', ) def __unicode__(self): out = u'%s related to %s' % (self.source, self.object) if self.relation_type: return "%s (%s)" % (out, self.relation_type) else: return out class RelatedObjectsDescriptor(object): def __init__(self, model=None, from_field='source', to_field='object'): self.related_model = model or RelatedResource self.from_field = self.get_related_model_field(from_field) self.to_field = self.get_related_model_field(to_field) def get_related_model_field(self, field_name): opts = self.related_model._meta for virtual_field in opts.virtual_fields: if virtual_field.name == field_name: return virtual_field return opts.get_field(field_name) def is_gfk(self, field): return isinstance(field, GenericForeignKey) def get_query_for_field(self, instance, field): if self.is_gfk(field): ctype = ContentType.objects.get_for_model(instance) return { field.ct_field: ctype, field.fk_field: instance.pk } elif isinstance(instance, field.rel.to): return {field.name: instance} raise TypeError('Unable to query %s with %s' % (field, instance)) def get_query_from(self, instance): return self.get_query_for_field(instance, self.from_field) def get_query_to(self, instance): return self.get_query_for_field(instance, self.to_field) def set_attributes_from_name(self, name): self.name = name self.concrete = False self.verbose_name = self.name.replace('_', ' ') def contribute_to_class(self, cls, name, virtual_only=False): self.set_attributes_from_name(name) self.model = cls # if virtual_only: # cls._meta.add_virtual_field(self) # else: # cls._meta.add_field(self) setattr(cls, self.name, self) def __get__(self, instance, cls=None): if instance is None: return self ManagerClass = type(self.related_model._default_manager) # NOQA return self.create_manager(instance, ManagerClass) def __set__(self, instance, value): if instance is None: raise AttributeError("Manager must be accessed via instance") manager = self.__get__(instance) manager.add(*value) def delete_manager(self, instance): return self.create_manager(instance, self.related_model._base_manager.__class__) def create_manager(self, instance, superclass, cf_from=True): rel_obj = self if cf_from: core_filters = self.get_query_from(instance) rel_field = self.to_field else: core_filters = self.get_query_to(instance) rel_field = self.from_field uses_gfk = self.is_gfk(rel_field) class RelatedManager(superclass): def get_queryset(self): if uses_gfk: qs = GFKOptimizedQuerySet(self.model, gfk_field=rel_field) return qs.filter(**(core_filters)) else: return superclass.get_queryset(self).filter(**(core_filters)) def add(self, *objs): for obj in objs: if not isinstance(obj, self.model): raise TypeError("'%s' instance expected" % self.model._meta.object_name) for (k, v) in core_filters.iteritems(): setattr(obj, k, v) obj.save() add.alters_data = True def create(self, **kwargs): kwargs.update(core_filters) return super(RelatedManager, self).create(**kwargs) create.alters_data = True def get_or_create(self, **kwargs): kwargs.update(core_filters) return super(RelatedManager, self).get_or_create(**kwargs) get_or_create.alters_data = True def remove(self, *objs): for obj in objs: # Is obj actually part of this descriptor set? if obj in self.all(): obj.delete() else: raise rel_obj.related_model.DoesNotExist, \ "%r is not related to %r." % (obj, instance) remove.alters_data = True def clear(self): self.all().delete() clear.alters_data = True def connect(self, obj, **kwargs): kwargs.update(rel_obj.get_query_to(obj)) connection, created = self.get_or_create(**kwargs) return connection def related_to(self): mgr = rel_obj.create_manager(instance, superclass, False) return mgr.filter( **rel_obj.get_query_to(instance) ) def symmetrical(self): return superclass.get_queryset(self).filter( Q(**rel_obj.get_query_from(instance)) | Q(**rel_obj.get_query_to(instance)) ).distinct() manager = RelatedManager() manager.core_filters = core_filters manager.model = self.related_model return manager def all(self): if self.is_gfk(self.from_field): ctype = ContentType.objects.get_for_model(self.model) query = {self.from_field.ct_field: ctype} else: query = {} return self.related_model._default_manager.filter(**query) class ReverseRelatedObjectsDescriptor(RelatedObjectsDescriptor): def __init__(self, model=None, from_field='object', to_field='source'): super(ReverseRelatedObjectsDescriptor, self).__init__(model, from_field, to_field)
apache-2.0
[ 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 893, 26, 272, 687, 1639, 14, 2828, 14, 10778, 14, 955, 492, 8307, 3190, 199, 2590, 3545, 26, 272, 687, 1639, 14, 2828, 14, 10778, 14, 6767, 492, 8307, 3190, 199, 199, 504, 1275, 6767, 492, 598, 21490, 9867, 1759, 13689, 421, 199, 533, 20116, 4031, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 1317, 63, 466, 8, 277, 12, 1564, 63, 466, 12, 1011, 958, 304, 267, 408, 267, 2372, 1006, 314, 2974, 402, 314, 1627, 1564, 730, 4048, 370, 642, 1242, 14, 267, 408, 267, 6377, 275, 291, 14, 362, 63, 7924, 342, 267, 372, 6377, 14, 1541, 8, 1317, 63, 466, 363, 354, 29, 1317, 63, 466, 12, 1011, 958, 9, 339, 347, 664, 63, 5690, 63, 1365, 8, 277, 12, 5850, 63, 1365, 12, 1011, 958, 304, 267, 408, 267, 2372, 1006, 314, 2974, 402, 314, 1627, 5850, 1350, 370, 642, 1242, 267, 408, 267, 6377, 275, 291, 14, 362, 63, 7924, 342, 267, 372, 6377, 14, 1541, 8, 5690, 63, 1365, 29, 5690, 63, 1365, 12, 1011, 958, 9, 421, 199, 533, 20116, 4031, 8, 992, 14, 1685, 304, 272, 408, 272, 437, 2073, 4048, 370, 4573, 909, 272, 408, 272, 327, 25470, 28652, 5550, 272, 1350, 63, 466, 275, 1709, 14, 3190, 8, 11282, 12, 267, 4048, 63, 354, 628, 1739, 63, 2407, 1462, 531, 272, 1350, 63, 344, 275, 1709, 14, 3901, 8, 697, 63, 1080, 29, 549, 9, 272, 1350, 275, 8307, 3190, 8, 267, 9428, 63, 698, 628, 1365, 63, 466, 401, 267, 14830, 63, 698, 628, 1365, 63, 344, 531, 339, 327, 21401, 13841, 820, 2901, 6989, 28652, 5550, 26, 272, 909, 63, 466, 275, 1709, 14, 3190, 8, 11282, 12, 267, 4048, 63, 354, 628, 2407, 63, 1462, 26360, 272, 909, 63, 344, 275, 1709, 14, 3901, 8, 697, 63, 1080, 29, 549, 9, 272, 909, 275, 8307, 3190, 8, 267, 9428, 63, 698, 628, 785, 63, 466, 401, 267, 14830, 63, 698, 628, 785, 63, 344, 531, 339, 327, 19357, 8071, 272, 5850, 63, 1365, 275, 1709, 14, 3901, 8, 267, 14783, 29, 797, 12, 267, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 5850, 63, 466, 275, 1709, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 4596, 29, 549, 12, 267, 2973, 29, 549, 9, 272, 1865, 275, 1709, 14, 3901, 8, 267, 4596, 29, 549, 12, 2973, 29, 549, 9, 339, 2251, 275, 20116, 4031, 2988, 342, 339, 1021, 6288, 26, 267, 7794, 275, 661, 1648, 297, 776, 339, 347, 636, 2975, 721, 277, 304, 267, 734, 275, 399, 5956, 83, 4048, 370, 450, 83, 7, 450, 334, 277, 14, 1365, 12, 291, 14, 785, 9, 267, 340, 291, 14, 5690, 63, 466, 26, 288, 372, 2071, 83, 4366, 83, 2924, 450, 334, 548, 12, 291, 14, 5690, 63, 466, 9, 267, 587, 26, 288, 372, 734, 421, 199, 533, 20116, 11188, 4311, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1402, 29, 403, 12, 687, 63, 698, 534, 1365, 297, 370, 63, 698, 534, 785, 735, 267, 291, 14, 2407, 63, 1238, 275, 1402, 503, 20116, 4031, 267, 291, 14, 504, 63, 698, 275, 291, 14, 362, 63, 2407, 63, 1238, 63, 698, 8, 504, 63, 698, 9, 267, 291, 14, 475, 63, 698, 275, 291, 14, 362, 63, 2407, 63, 1238, 63, 698, 8, 475, 63, 698, 9, 339, 347, 664, 63, 2407, 63, 1238, 63, 698, 8, 277, 12, 901, 63, 354, 304, 267, 3999, 275, 291, 14, 2407, 63, 1238, 423, 2024, 267, 367, 5791, 63, 698, 315, 3999, 14, 2065, 63, 955, 26, 288, 340, 5791, 63, 698, 14, 354, 508, 901, 63, 354, 26, 355, 372, 5791, 63, 698, 267, 372, 3999, 14, 362, 63, 698, 8, 698, 63, 354, 9, 339, 347, 365, 63, 7102, 75, 8, 277, 12, 901, 304, 267, 372, 1228, 8, 698, 12, 8307, 3190, 9, 339, 347, 664, 63, 1131, 63, 509, 63, 698, 8, 277, 12, 1256, 12, 901, 304, 267, 340, 291, 14, 374, 63, 7102, 75, 8, 698, 304, 288, 16360, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 842, 9, 288, 372, 469, 355, 901, 14, 319, 63, 698, 26, 16360, 12, 355, 901, 14, 9010, 63, 698, 26, 1256, 14, 2051, 288, 789, 267, 916, 1228, 8, 842, 12, 901, 14, 3369, 14, 475, 304, 288, 372, 469, 698, 14, 354, 26, 1256, 93, 398, 746, 3146, 360, 6005, 370, 1827, 450, 83, 543, 450, 83, 7, 450, 334, 698, 12, 1256, 430, 339, 347, 664, 63, 1131, 63, 504, 8, 277, 12, 1256, 304, 267, 372, 291, 14, 362, 63, 1131, 63, 509, 63, 698, 8, 842, 12, 291, 14, 504, 63, 698, 9, 339, 347, 664, 63, 1131, 63, 475, 8, 277, 12, 1256, 304, 267, 372, 291, 14, 362, 63, 1131, 63, 509, 63, 698, 8, 842, 12, 291, 14, 475, 63, 698, 9, 339, 347, 663, 63, 2987, 63, 504, 63, 354, 8, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 13455, 275, 756, 267, 291, 14, 3832, 63, 354, 275, 291, 14, 354, 14, 1814, 20928, 283, 5320, 339, 347, 28567, 63, 475, 63, 533, 8, 277, 12, 843, 12, 536, 12, 5791, 63, 2118, 29, 797, 304, 267, 291, 14, 409, 63, 2987, 63, 504, 63, 354, 8, 354, 9, 267, 291, 14, 1238, 275, 843, 267, 327, 340, 5791, 63, 2118, 26, 267, 327, 258, 843, 423, 2024, 14, 525, 63, 2065, 63, 698, 8, 277, 9, 267, 327, 587, 26, 267, 327, 258, 843, 423, 2024, 14, 525, 63, 698, 8, 277, 9, 267, 5371, 8, 1886, 12, 291, 14, 354, 12, 291, 9, 339, 347, 636, 362, 721, 277, 12, 1256, 12, 843, 29, 403, 304, 267, 340, 1256, 365, 488, 26, 288, 372, 291, 398, 13537, 2543, 275, 730, 8, 277, 14, 2407, 63, 1238, 423, 885, 63, 2609, 9, 221, 327, 20432, 267, 372, 291, 14, 981, 63, 2609 ]
[ 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 893, 26, 272, 687, 1639, 14, 2828, 14, 10778, 14, 955, 492, 8307, 3190, 199, 2590, 3545, 26, 272, 687, 1639, 14, 2828, 14, 10778, 14, 6767, 492, 8307, 3190, 199, 199, 504, 1275, 6767, 492, 598, 21490, 9867, 1759, 13689, 421, 199, 533, 20116, 4031, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 1317, 63, 466, 8, 277, 12, 1564, 63, 466, 12, 1011, 958, 304, 267, 408, 267, 2372, 1006, 314, 2974, 402, 314, 1627, 1564, 730, 4048, 370, 642, 1242, 14, 267, 408, 267, 6377, 275, 291, 14, 362, 63, 7924, 342, 267, 372, 6377, 14, 1541, 8, 1317, 63, 466, 363, 354, 29, 1317, 63, 466, 12, 1011, 958, 9, 339, 347, 664, 63, 5690, 63, 1365, 8, 277, 12, 5850, 63, 1365, 12, 1011, 958, 304, 267, 408, 267, 2372, 1006, 314, 2974, 402, 314, 1627, 5850, 1350, 370, 642, 1242, 267, 408, 267, 6377, 275, 291, 14, 362, 63, 7924, 342, 267, 372, 6377, 14, 1541, 8, 5690, 63, 1365, 29, 5690, 63, 1365, 12, 1011, 958, 9, 421, 199, 533, 20116, 4031, 8, 992, 14, 1685, 304, 272, 408, 272, 437, 2073, 4048, 370, 4573, 909, 272, 408, 272, 327, 25470, 28652, 5550, 272, 1350, 63, 466, 275, 1709, 14, 3190, 8, 11282, 12, 267, 4048, 63, 354, 628, 1739, 63, 2407, 1462, 531, 272, 1350, 63, 344, 275, 1709, 14, 3901, 8, 697, 63, 1080, 29, 549, 9, 272, 1350, 275, 8307, 3190, 8, 267, 9428, 63, 698, 628, 1365, 63, 466, 401, 267, 14830, 63, 698, 628, 1365, 63, 344, 531, 339, 327, 21401, 13841, 820, 2901, 6989, 28652, 5550, 26, 272, 909, 63, 466, 275, 1709, 14, 3190, 8, 11282, 12, 267, 4048, 63, 354, 628, 2407, 63, 1462, 26360, 272, 909, 63, 344, 275, 1709, 14, 3901, 8, 697, 63, 1080, 29, 549, 9, 272, 909, 275, 8307, 3190, 8, 267, 9428, 63, 698, 628, 785, 63, 466, 401, 267, 14830, 63, 698, 628, 785, 63, 344, 531, 339, 327, 19357, 8071, 272, 5850, 63, 1365, 275, 1709, 14, 3901, 8, 267, 14783, 29, 797, 12, 267, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 5850, 63, 466, 275, 1709, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 267, 4596, 29, 549, 12, 267, 2973, 29, 549, 9, 272, 1865, 275, 1709, 14, 3901, 8, 267, 4596, 29, 549, 12, 2973, 29, 549, 9, 339, 2251, 275, 20116, 4031, 2988, 342, 339, 1021, 6288, 26, 267, 7794, 275, 661, 1648, 297, 776, 339, 347, 636, 2975, 721, 277, 304, 267, 734, 275, 399, 5956, 83, 4048, 370, 450, 83, 7, 450, 334, 277, 14, 1365, 12, 291, 14, 785, 9, 267, 340, 291, 14, 5690, 63, 466, 26, 288, 372, 2071, 83, 4366, 83, 2924, 450, 334, 548, 12, 291, 14, 5690, 63, 466, 9, 267, 587, 26, 288, 372, 734, 421, 199, 533, 20116, 11188, 4311, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1402, 29, 403, 12, 687, 63, 698, 534, 1365, 297, 370, 63, 698, 534, 785, 735, 267, 291, 14, 2407, 63, 1238, 275, 1402, 503, 20116, 4031, 267, 291, 14, 504, 63, 698, 275, 291, 14, 362, 63, 2407, 63, 1238, 63, 698, 8, 504, 63, 698, 9, 267, 291, 14, 475, 63, 698, 275, 291, 14, 362, 63, 2407, 63, 1238, 63, 698, 8, 475, 63, 698, 9, 339, 347, 664, 63, 2407, 63, 1238, 63, 698, 8, 277, 12, 901, 63, 354, 304, 267, 3999, 275, 291, 14, 2407, 63, 1238, 423, 2024, 267, 367, 5791, 63, 698, 315, 3999, 14, 2065, 63, 955, 26, 288, 340, 5791, 63, 698, 14, 354, 508, 901, 63, 354, 26, 355, 372, 5791, 63, 698, 267, 372, 3999, 14, 362, 63, 698, 8, 698, 63, 354, 9, 339, 347, 365, 63, 7102, 75, 8, 277, 12, 901, 304, 267, 372, 1228, 8, 698, 12, 8307, 3190, 9, 339, 347, 664, 63, 1131, 63, 509, 63, 698, 8, 277, 12, 1256, 12, 901, 304, 267, 340, 291, 14, 374, 63, 7102, 75, 8, 698, 304, 288, 16360, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 842, 9, 288, 372, 469, 355, 901, 14, 319, 63, 698, 26, 16360, 12, 355, 901, 14, 9010, 63, 698, 26, 1256, 14, 2051, 288, 789, 267, 916, 1228, 8, 842, 12, 901, 14, 3369, 14, 475, 304, 288, 372, 469, 698, 14, 354, 26, 1256, 93, 398, 746, 3146, 360, 6005, 370, 1827, 450, 83, 543, 450, 83, 7, 450, 334, 698, 12, 1256, 430, 339, 347, 664, 63, 1131, 63, 504, 8, 277, 12, 1256, 304, 267, 372, 291, 14, 362, 63, 1131, 63, 509, 63, 698, 8, 842, 12, 291, 14, 504, 63, 698, 9, 339, 347, 664, 63, 1131, 63, 475, 8, 277, 12, 1256, 304, 267, 372, 291, 14, 362, 63, 1131, 63, 509, 63, 698, 8, 842, 12, 291, 14, 475, 63, 698, 9, 339, 347, 663, 63, 2987, 63, 504, 63, 354, 8, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 13455, 275, 756, 267, 291, 14, 3832, 63, 354, 275, 291, 14, 354, 14, 1814, 20928, 283, 5320, 339, 347, 28567, 63, 475, 63, 533, 8, 277, 12, 843, 12, 536, 12, 5791, 63, 2118, 29, 797, 304, 267, 291, 14, 409, 63, 2987, 63, 504, 63, 354, 8, 354, 9, 267, 291, 14, 1238, 275, 843, 267, 327, 340, 5791, 63, 2118, 26, 267, 327, 258, 843, 423, 2024, 14, 525, 63, 2065, 63, 698, 8, 277, 9, 267, 327, 587, 26, 267, 327, 258, 843, 423, 2024, 14, 525, 63, 698, 8, 277, 9, 267, 5371, 8, 1886, 12, 291, 14, 354, 12, 291, 9, 339, 347, 636, 362, 721, 277, 12, 1256, 12, 843, 29, 403, 304, 267, 340, 1256, 365, 488, 26, 288, 372, 291, 398, 13537, 2543, 275, 730, 8, 277, 14, 2407, 63, 1238, 423, 885, 63, 2609, 9, 221, 327, 20432, 267, 372, 291, 14, 981, 63, 2609, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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=float, buffer=None, offset=0, strides=None, order=None) An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.) Arrays should be constructed using `array`, `zeros` or `empty` (refer to the See Also section below). The parameters given here refer to a low-level method (`ndarray(...)`) for instantiating an array. For more information, refer to the `numpy` module and examine the the methods and attributes of an array. Parameters ---------- (for the __new__ method; see Notes below) shape : tuple of ints Shape of created array. dtype : data-type, optional Any object that can be interpreted as a numpy data type. buffer : object exposing buffer interface, optional Used to fill the array with data. offset : int, optional Offset of array data in buffer. strides : tuple of ints, optional Strides of data in memory. order : {'C', 'F'}, optional Row-major or column-major order. Attributes ---------- T : ndarray Transpose of the array. data : buffer The array's elements, in memory. dtype : dtype object Describes the format of the elements in the array. flags : dict Dictionary containing information related to memory use, e.g., 'C_CONTIGUOUS', 'OWNDATA', 'WRITEABLE', etc. flat : numpy.flatiter object Flattened version of the array as an iterator. The iterator allows assignments, e.g., ``x.flat = 3`` (See `ndarray.flat` for assignment examples; TODO). imag : ndarray Imaginary part of the array. real : ndarray Real part of the array. size : int Number of elements in the array. itemsize : int The memory use of each array element in bytes. nbytes : int The total number of bytes required to store the array data, i.e., ``itemsize * size``. ndim : int The array's number of dimensions. shape : tuple of ints Shape of the array. strides : tuple of ints The step-size required to move from one element to the next in memory. For example, a contiguous ``(3, 4)`` array of type ``int16`` in C-order has strides ``(8, 2)``. This implies that to move from element to element in memory requires jumps of 2 bytes. To move from row-to-row, one needs to jump 8 bytes at a time (``2 * 4``). ctypes : ctypes object Class containing properties of the array needed for interaction with ctypes. base : ndarray If the array is a view into another array, that array is its `base` (unless that array is also a view). The `base` array is where the array data is actually stored. See Also -------- array : Construct an array. zeros : Create an array, each element of which is zero. empty : Create an array, but leave its allocated memory unchanged (i.e., it contains "garbage"). dtype : Create a data-type. Notes ----- There are two modes of creating an array using ``__new__``: 1. If `buffer` is None, then only `shape`, `dtype`, and `order` are used. 2. If `buffer` is an object exposing the buffer interface, then all keywords are interpreted. No ``__init__`` method is needed because the array is fully initialized after the ``__new__`` method. Examples -------- These examples illustrate the low-level `ndarray` constructor. Refer to the `See Also` section above for easier ways of constructing an ndarray. First mode, `buffer` is None: >>> np.ndarray(shape=(2,2), dtype=float, order='F') array([[ -1.13698227e+002, 4.25087011e-303], [ 2.88528414e-306, 3.27025015e-309]]) #random Second mode: >>> np.ndarray((2,), buffer=np.array([1,2,3]), ... offset=np.int_().itemsize, ... dtype=int) # offset = 1*itemsize, i.e. skip first element array([2, 3]) """ pass def __mul__(self, y): """ x.__mul__(y) <==> x*y """ pass def __rmul__(self, y): """ x.__rmul__(y) <==> x*y """ pass
apache-2.0
[ 533, 6800, 8, 785, 304, 272, 408, 272, 6800, 8, 1392, 12, 2152, 29, 1609, 12, 3335, 29, 403, 12, 3268, 29, 16, 12, 355, 11883, 29, 403, 12, 1865, 29, 403, 9, 398, 1626, 1625, 909, 8469, 282, 3510, 13014, 12, 2636, 23748, 1625, 267, 402, 6317, 13, 890, 2974, 14, 221, 1626, 4568, 666, 13, 466, 909, 23369, 314, 267, 1475, 402, 1924, 1819, 315, 314, 1625, 334, 1405, 3696, 13, 1648, 12, 4212, 5002, 2783, 652, 267, 26182, 1500, 315, 4402, 12, 3775, 652, 365, 376, 3000, 12, 282, 8402, 2376, 1329, 12, 267, 503, 6020, 587, 12, 5423, 4959, 398, 1952, 4814, 1077, 506, 14701, 1808, 658, 1144, 3559, 658, 4250, 64, 503, 658, 1667, 64, 334, 21928, 267, 370, 314, 1666, 6121, 3420, 5084, 680, 221, 710, 2633, 1627, 2348, 10618, 370, 267, 282, 6465, 13, 1896, 1083, 13493, 8237, 20186, 10522, 367, 9034, 1958, 376, 1625, 14, 398, 2104, 1655, 2556, 12, 10618, 370, 314, 658, 4714, 64, 859, 436, 31758, 314, 267, 314, 3102, 436, 3004, 402, 376, 1625, 14, 398, 3897, 267, 4143, 267, 334, 509, 314, 636, 1222, 363, 1083, 27, 1937, 8144, 5084, 9, 398, 2215, 520, 2008, 402, 14526, 288, 16528, 402, 2737, 1625, 14, 267, 2152, 520, 666, 13, 466, 12, 2716, 288, 6184, 909, 626, 883, 506, 11922, 465, 282, 2680, 666, 730, 14, 267, 3335, 520, 909, 444, 555, 1044, 3335, 3217, 12, 2716, 288, 8051, 370, 5554, 314, 1625, 543, 666, 14, 267, 3268, 520, 1109, 12, 2716, 288, 29432, 402, 1625, 666, 315, 3335, 14, 267, 11883, 520, 2008, 402, 14526, 12, 2716, 288, 31309, 3424, 402, 666, 315, 4402, 14, 267, 1865, 520, 791, 35, 297, 283, 38, 2267, 2716, 288, 15231, 13, 8452, 503, 2763, 13, 8452, 1865, 14, 398, 9382, 267, 4143, 267, 377, 520, 6800, 288, 6266, 4070, 402, 314, 1625, 14, 267, 666, 520, 3335, 288, 710, 1625, 1159, 4008, 12, 315, 4402, 14, 267, 2152, 520, 2152, 909, 288, 28571, 11562, 314, 1475, 402, 314, 4008, 315, 314, 1625, 14, 267, 3285, 520, 1211, 288, 11932, 3035, 2556, 4048, 370, 4402, 675, 12, 325, 14, 71, 2020, 288, 283, 35, 63, 5801, 1277, 32504, 297, 283, 47, 3705, 3998, 297, 283, 10387, 2617, 297, 5423, 14, 267, 6829, 520, 2680, 14, 14163, 280, 351, 909, 288, 19005, 724, 379, 1015, 402, 314, 1625, 465, 376, 6122, 14, 221, 710, 6122, 288, 6127, 18121, 12, 325, 14, 71, 2020, 1124, 88, 14, 7088, 275, 650, 1040, 334, 9295, 658, 8237, 14, 7088, 64, 367, 288, 9801, 7251, 27, 3254, 680, 267, 284, 5615, 520, 6800, 288, 473, 391, 17580, 1777, 402, 314, 1625, 14, 267, 3363, 520, 6800, 288, 14849, 1777, 402, 314, 1625, 14, 267, 1568, 520, 1109, 288, 4860, 402, 4008, 315, 314, 1625, 14, 267, 1242, 890, 520, 1109, 288, 710, 4402, 675, 402, 1924, 1625, 1819, 315, 2783, 14, 267, 302, 2394, 520, 1109, 288, 710, 3141, 1329, 402, 2783, 1415, 370, 3877, 314, 1625, 666, 12, 288, 284, 14, 69, 2020, 1124, 21210, 627, 1568, 4345, 267, 17951, 520, 1109, 288, 710, 1625, 1159, 1329, 402, 7365, 14, 267, 2215, 520, 2008, 402, 14526, 288, 16528, 402, 314, 1625, 14, 267, 11883, 520, 2008, 402, 14526, 288, 710, 3650, 13, 890, 1415, 370, 4057, 687, 1373, 1819, 370, 314, 2163, 315, 288, 4402, 14, 2104, 2893, 12, 282, 26611, 15475, 19, 12, 841, 9719, 1625, 402, 730, 288, 1124, 442, 975, 1040, 315, 445, 13, 1648, 965, 11883, 15475, 24, 12, 499, 20642, 221, 961, 22660, 626, 288, 370, 4057, 687, 1819, 370, 1819, 315, 4402, 5074, 14882, 83, 402, 499, 2783, 14, 288, 4005, 4057, 687, 1962, 13, 475, 13, 1143, 12, 1373, 4839, 370, 14882, 1695, 2783, 737, 282, 900, 288, 15693, 18, 627, 841, 20008, 267, 5577, 520, 5577, 909, 288, 8089, 3035, 4382, 402, 314, 1625, 4346, 367, 18752, 288, 543, 5577, 14, 267, 1300, 520, 6800, 288, 982, 314, 1625, 365, 282, 2455, 1901, 4573, 1625, 12, 626, 1625, 365, 2399, 658, 1095, 64, 288, 334, 18447, 626, 1625, 365, 2597, 282, 2455, 680, 221, 710, 658, 1095, 64, 1625, 365, 2382, 314, 288, 1625, 666, 365, 5965, 5489, 14, 398, 1666, 6121, 267, 3001, 267, 1625, 520, 9215, 376, 1625, 14, 267, 10136, 520, 2790, 376, 1625, 12, 1924, 1819, 402, 1314, 365, 4697, 14, 267, 2701, 520, 2790, 376, 1625, 12, 1325, 10137, 2399, 17659, 4402, 14874, 334, 73, 14, 69, 2020, 355, 652, 3509, 298, 28737, 3471, 267, 2152, 520, 2790, 282, 666, 13, 466, 14, 398, 8144, 267, 9063, 267, 6006, 787, 2877, 12404, 402, 6425, 376, 1625, 1808, 9035, 1222, 18762, 26, 398, 413, 14, 982, 658, 2738, 64, 365, 488, 12, 2066, 1454, 658, 1392, 3559, 658, 2271, 3559, 436, 658, 1648, 64, 1779, 787, 1202, 14, 267, 499, 14, 982, 658, 2738, 64, 365, 376, 909, 444, 555, 1044, 314, 3335, 3217, 12, 2066, 1779, 1006, 7681, 787, 11922, 14, 398, 3091, 9035, 826, 18762, 1083, 365, 4346, 2952, 314, 1625, 365, 9999, 10038, 267, 2410, 314, 9035, 1222, 18762, 1083, 14, 398, 6058, 267, 3001, 267, 5723, 7251, 22907, 11409, 323, 314, 6465, 13, 1896, 658, 8237, 64, 3787, 14, 221, 21751, 267, 370, 314, 658, 9295, 6121, 64, 3420, 3432, 367, 14905, 15217, 402, 22048, 376, 267, 6800, 14, 398, 7758, 818, 12, 658, 2738, 64, 365, 488, 26, 398, 1306, 980, 14, 8237, 8, 1392, 2687, 18, 12, 18, 395, 2152, 29, 1609, 12, 1865, 534, 38, 358, 267, 1625, 4038, 446, 17, 14, 969, 1876, 10228, 23, 69, 11, 7432, 12, 257, 841, 14, 7991, 1555, 13059, 69, 13, 11810, 467, 2049, 359, 221, 499, 14, 1299, 2528, 1349, 1079, 69, 13, 11363, 12, 257, 650, 14, 13299, 821, 11164, 69, 13, 10556, 3934, 260, 327, 2355, 398, 16707, 818, 26, 398, 1306, 980, 14, 8237, 1332, 18, 4706, 3335, 29, 1590, 14, 1144, 779, 17, 12, 18, 12, 19, 2522, 267, 2263, 3322, 3268, 29, 1590, 14, 442, 63, 1252, 21210, 12, 267, 2263, 3322, 2152, 29, 442, 9, 327, 3268, 275, 413, 10, 21210, 12, 284, 14, 69, 14, 3372 ]
[ 6800, 8, 785, 304, 272, 408, 272, 6800, 8, 1392, 12, 2152, 29, 1609, 12, 3335, 29, 403, 12, 3268, 29, 16, 12, 355, 11883, 29, 403, 12, 1865, 29, 403, 9, 398, 1626, 1625, 909, 8469, 282, 3510, 13014, 12, 2636, 23748, 1625, 267, 402, 6317, 13, 890, 2974, 14, 221, 1626, 4568, 666, 13, 466, 909, 23369, 314, 267, 1475, 402, 1924, 1819, 315, 314, 1625, 334, 1405, 3696, 13, 1648, 12, 4212, 5002, 2783, 652, 267, 26182, 1500, 315, 4402, 12, 3775, 652, 365, 376, 3000, 12, 282, 8402, 2376, 1329, 12, 267, 503, 6020, 587, 12, 5423, 4959, 398, 1952, 4814, 1077, 506, 14701, 1808, 658, 1144, 3559, 658, 4250, 64, 503, 658, 1667, 64, 334, 21928, 267, 370, 314, 1666, 6121, 3420, 5084, 680, 221, 710, 2633, 1627, 2348, 10618, 370, 267, 282, 6465, 13, 1896, 1083, 13493, 8237, 20186, 10522, 367, 9034, 1958, 376, 1625, 14, 398, 2104, 1655, 2556, 12, 10618, 370, 314, 658, 4714, 64, 859, 436, 31758, 314, 267, 314, 3102, 436, 3004, 402, 376, 1625, 14, 398, 3897, 267, 4143, 267, 334, 509, 314, 636, 1222, 363, 1083, 27, 1937, 8144, 5084, 9, 398, 2215, 520, 2008, 402, 14526, 288, 16528, 402, 2737, 1625, 14, 267, 2152, 520, 666, 13, 466, 12, 2716, 288, 6184, 909, 626, 883, 506, 11922, 465, 282, 2680, 666, 730, 14, 267, 3335, 520, 909, 444, 555, 1044, 3335, 3217, 12, 2716, 288, 8051, 370, 5554, 314, 1625, 543, 666, 14, 267, 3268, 520, 1109, 12, 2716, 288, 29432, 402, 1625, 666, 315, 3335, 14, 267, 11883, 520, 2008, 402, 14526, 12, 2716, 288, 31309, 3424, 402, 666, 315, 4402, 14, 267, 1865, 520, 791, 35, 297, 283, 38, 2267, 2716, 288, 15231, 13, 8452, 503, 2763, 13, 8452, 1865, 14, 398, 9382, 267, 4143, 267, 377, 520, 6800, 288, 6266, 4070, 402, 314, 1625, 14, 267, 666, 520, 3335, 288, 710, 1625, 1159, 4008, 12, 315, 4402, 14, 267, 2152, 520, 2152, 909, 288, 28571, 11562, 314, 1475, 402, 314, 4008, 315, 314, 1625, 14, 267, 3285, 520, 1211, 288, 11932, 3035, 2556, 4048, 370, 4402, 675, 12, 325, 14, 71, 2020, 288, 283, 35, 63, 5801, 1277, 32504, 297, 283, 47, 3705, 3998, 297, 283, 10387, 2617, 297, 5423, 14, 267, 6829, 520, 2680, 14, 14163, 280, 351, 909, 288, 19005, 724, 379, 1015, 402, 314, 1625, 465, 376, 6122, 14, 221, 710, 6122, 288, 6127, 18121, 12, 325, 14, 71, 2020, 1124, 88, 14, 7088, 275, 650, 1040, 334, 9295, 658, 8237, 14, 7088, 64, 367, 288, 9801, 7251, 27, 3254, 680, 267, 284, 5615, 520, 6800, 288, 473, 391, 17580, 1777, 402, 314, 1625, 14, 267, 3363, 520, 6800, 288, 14849, 1777, 402, 314, 1625, 14, 267, 1568, 520, 1109, 288, 4860, 402, 4008, 315, 314, 1625, 14, 267, 1242, 890, 520, 1109, 288, 710, 4402, 675, 402, 1924, 1625, 1819, 315, 2783, 14, 267, 302, 2394, 520, 1109, 288, 710, 3141, 1329, 402, 2783, 1415, 370, 3877, 314, 1625, 666, 12, 288, 284, 14, 69, 2020, 1124, 21210, 627, 1568, 4345, 267, 17951, 520, 1109, 288, 710, 1625, 1159, 1329, 402, 7365, 14, 267, 2215, 520, 2008, 402, 14526, 288, 16528, 402, 314, 1625, 14, 267, 11883, 520, 2008, 402, 14526, 288, 710, 3650, 13, 890, 1415, 370, 4057, 687, 1373, 1819, 370, 314, 2163, 315, 288, 4402, 14, 2104, 2893, 12, 282, 26611, 15475, 19, 12, 841, 9719, 1625, 402, 730, 288, 1124, 442, 975, 1040, 315, 445, 13, 1648, 965, 11883, 15475, 24, 12, 499, 20642, 221, 961, 22660, 626, 288, 370, 4057, 687, 1819, 370, 1819, 315, 4402, 5074, 14882, 83, 402, 499, 2783, 14, 288, 4005, 4057, 687, 1962, 13, 475, 13, 1143, 12, 1373, 4839, 370, 14882, 1695, 2783, 737, 282, 900, 288, 15693, 18, 627, 841, 20008, 267, 5577, 520, 5577, 909, 288, 8089, 3035, 4382, 402, 314, 1625, 4346, 367, 18752, 288, 543, 5577, 14, 267, 1300, 520, 6800, 288, 982, 314, 1625, 365, 282, 2455, 1901, 4573, 1625, 12, 626, 1625, 365, 2399, 658, 1095, 64, 288, 334, 18447, 626, 1625, 365, 2597, 282, 2455, 680, 221, 710, 658, 1095, 64, 1625, 365, 2382, 314, 288, 1625, 666, 365, 5965, 5489, 14, 398, 1666, 6121, 267, 3001, 267, 1625, 520, 9215, 376, 1625, 14, 267, 10136, 520, 2790, 376, 1625, 12, 1924, 1819, 402, 1314, 365, 4697, 14, 267, 2701, 520, 2790, 376, 1625, 12, 1325, 10137, 2399, 17659, 4402, 14874, 334, 73, 14, 69, 2020, 355, 652, 3509, 298, 28737, 3471, 267, 2152, 520, 2790, 282, 666, 13, 466, 14, 398, 8144, 267, 9063, 267, 6006, 787, 2877, 12404, 402, 6425, 376, 1625, 1808, 9035, 1222, 18762, 26, 398, 413, 14, 982, 658, 2738, 64, 365, 488, 12, 2066, 1454, 658, 1392, 3559, 658, 2271, 3559, 436, 658, 1648, 64, 1779, 787, 1202, 14, 267, 499, 14, 982, 658, 2738, 64, 365, 376, 909, 444, 555, 1044, 314, 3335, 3217, 12, 2066, 1779, 1006, 7681, 787, 11922, 14, 398, 3091, 9035, 826, 18762, 1083, 365, 4346, 2952, 314, 1625, 365, 9999, 10038, 267, 2410, 314, 9035, 1222, 18762, 1083, 14, 398, 6058, 267, 3001, 267, 5723, 7251, 22907, 11409, 323, 314, 6465, 13, 1896, 658, 8237, 64, 3787, 14, 221, 21751, 267, 370, 314, 658, 9295, 6121, 64, 3420, 3432, 367, 14905, 15217, 402, 22048, 376, 267, 6800, 14, 398, 7758, 818, 12, 658, 2738, 64, 365, 488, 26, 398, 1306, 980, 14, 8237, 8, 1392, 2687, 18, 12, 18, 395, 2152, 29, 1609, 12, 1865, 534, 38, 358, 267, 1625, 4038, 446, 17, 14, 969, 1876, 10228, 23, 69, 11, 7432, 12, 257, 841, 14, 7991, 1555, 13059, 69, 13, 11810, 467, 2049, 359, 221, 499, 14, 1299, 2528, 1349, 1079, 69, 13, 11363, 12, 257, 650, 14, 13299, 821, 11164, 69, 13, 10556, 3934, 260, 327, 2355, 398, 16707, 818, 26, 398, 1306, 980, 14, 8237, 1332, 18, 4706, 3335, 29, 1590, 14, 1144, 779, 17, 12, 18, 12, 19, 2522, 267, 2263, 3322, 3268, 29, 1590, 14, 442, 63, 1252, 21210, 12, 267, 2263, 3322, 2152, 29, 442, 9, 327, 3268, 275, 413, 10, 21210, 12, 284, 14, 69, 14, 3372, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tadebayo/myedge
myvenv/Lib/site-packages/easy_thumbnails/get_version.py
13
1911
from __future__ import unicode_literals import datetime import os import subprocess def get_version(version=None): "Returns a PEP 386-compliant version number from VERSION." if version is None: from easy_thumbnails import VERSION as version else: assert len(version) == 5 assert version[3] in ('alpha', 'beta', 'rc', 'final') # Now build the two parts of the version number: # main = X.Y[.Z] # sub = .devN - for pre-alpha releases # | {a|b|c}N - for alpha, beta and rc releases parts = 2 if version[2] == 0 else 3 main = '.'.join(str(x) for x in version[:parts]) sub = '' if version[3] == 'post': sub_v = version[4] or get_git_changeset() sub = '.post%s' % sub_v elif version[3] == 'alpha' and version[4] == 0: git_changeset = get_git_changeset() if git_changeset: sub = '.dev%s' % git_changeset elif version[3] != 'final': mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'} sub = mapping[version[3]] + str(version[4]) return str(main + sub) def get_git_changeset(): """Returns a numeric identifier of the latest git changeset. The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. This value isn't guaranteed to be unique, but collisions are very unlikely, so it's sufficient for generating the development version numbers. """ repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) git_log = subprocess.Popen( 'git log --pretty=format:%ct --quiet -1 HEAD', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=repo_dir, universal_newlines=True) timestamp = git_log.communicate()[0] try: timestamp = datetime.datetime.utcfromtimestamp(int(timestamp)) except ValueError: return None return timestamp.strftime('%Y%m%d%H%M%S')
mit
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 747, 199, 646, 3873, 421, 199, 318, 664, 63, 1023, 8, 1023, 29, 403, 304, 272, 298, 3407, 282, 13663, 650, 1184, 13, 863, 22676, 1015, 1329, 687, 15945, 2122, 272, 340, 1015, 365, 488, 26, 267, 687, 8837, 63, 8311, 83, 492, 15945, 465, 1015, 272, 587, 26, 267, 702, 822, 8, 1023, 9, 508, 959, 267, 702, 1015, 59, 19, 61, 315, 661, 4468, 297, 283, 5683, 297, 283, 1195, 297, 283, 5094, 358, 339, 327, 7356, 1900, 314, 2877, 4184, 402, 314, 1015, 1329, 26, 272, 327, 2446, 275, 1323, 14, 57, 30352, 58, 61, 272, 327, 1007, 275, 1275, 2374, 46, 446, 367, 876, 13, 4468, 19015, 272, 327, 258, 1204, 469, 65, 92, 66, 92, 67, 93, 46, 446, 367, 5131, 12, 8201, 436, 4819, 19015, 339, 4184, 275, 499, 340, 1015, 59, 18, 61, 508, 378, 587, 650, 272, 2446, 275, 15671, 904, 8, 495, 8, 88, 9, 367, 671, 315, 1015, 1491, 4181, 566, 339, 1007, 275, 2125, 272, 340, 1015, 59, 19, 61, 508, 283, 1932, 356, 267, 1007, 63, 86, 275, 1015, 59, 20, 61, 503, 664, 63, 3187, 63, 26027, 342, 267, 1007, 275, 1987, 1932, 5, 83, 7, 450, 1007, 63, 86, 339, 916, 1015, 59, 19, 61, 508, 283, 4468, 7, 436, 1015, 59, 20, 61, 508, 378, 26, 267, 6135, 63, 26027, 275, 664, 63, 3187, 63, 26027, 342, 267, 340, 6135, 63, 26027, 26, 288, 1007, 275, 1987, 2374, 5, 83, 7, 450, 6135, 63, 26027, 339, 916, 1015, 59, 19, 61, 1137, 283, 5094, 356, 267, 4412, 275, 791, 4468, 356, 283, 65, 297, 283, 5683, 356, 283, 66, 297, 283, 1195, 356, 283, 67, 936, 267, 1007, 275, 4412, 59, 1023, 59, 19, 2677, 435, 620, 8, 1023, 59, 20, 566, 339, 372, 620, 8, 973, 435, 1007, 9, 421, 199, 318, 664, 63, 3187, 63, 26027, 837, 272, 408, 3407, 282, 8950, 5148, 402, 314, 8839, 6135, 23316, 14, 339, 710, 754, 365, 314, 12174, 4913, 402, 314, 23316, 315, 31946, 3218, 5745, 10213, 3218, 2300, 1475, 14, 272, 961, 574, 5712, 1133, 17334, 370, 506, 3747, 12, 1325, 30063, 787, 7437, 625, 24227, 12, 272, 880, 652, 1159, 19258, 367, 12999, 314, 16367, 1015, 5579, 14, 272, 408, 272, 3831, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 29658, 272, 6135, 63, 793, 275, 3873, 14, 7942, 8, 267, 283, 3187, 943, 1553, 9118, 29, 908, 2689, 319, 1553, 10243, 446, 17, 13053, 297, 267, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 12, 267, 5218, 29, 549, 12, 8288, 29, 3417, 63, 694, 12, 17508, 63, 13839, 29, 549, 9, 272, 4913, 275, 6135, 63, 793, 14, 10664, 3430, 16, 61, 272, 862, 26, 267, 4913, 275, 2197, 14, 2083, 14, 5834, 18531, 8, 442, 8, 3954, 430, 272, 871, 1722, 26, 267, 372, 488, 272, 372, 4913, 14, 6205, 3508, 57, 5, 77, 5, 68, 5, 40, 5, 45, 5, 51, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 747, 199, 646, 3873, 421, 199, 318, 664, 63, 1023, 8, 1023, 29, 403, 304, 272, 298, 3407, 282, 13663, 650, 1184, 13, 863, 22676, 1015, 1329, 687, 15945, 2122, 272, 340, 1015, 365, 488, 26, 267, 687, 8837, 63, 8311, 83, 492, 15945, 465, 1015, 272, 587, 26, 267, 702, 822, 8, 1023, 9, 508, 959, 267, 702, 1015, 59, 19, 61, 315, 661, 4468, 297, 283, 5683, 297, 283, 1195, 297, 283, 5094, 358, 339, 327, 7356, 1900, 314, 2877, 4184, 402, 314, 1015, 1329, 26, 272, 327, 2446, 275, 1323, 14, 57, 30352, 58, 61, 272, 327, 1007, 275, 1275, 2374, 46, 446, 367, 876, 13, 4468, 19015, 272, 327, 258, 1204, 469, 65, 92, 66, 92, 67, 93, 46, 446, 367, 5131, 12, 8201, 436, 4819, 19015, 339, 4184, 275, 499, 340, 1015, 59, 18, 61, 508, 378, 587, 650, 272, 2446, 275, 15671, 904, 8, 495, 8, 88, 9, 367, 671, 315, 1015, 1491, 4181, 566, 339, 1007, 275, 2125, 272, 340, 1015, 59, 19, 61, 508, 283, 1932, 356, 267, 1007, 63, 86, 275, 1015, 59, 20, 61, 503, 664, 63, 3187, 63, 26027, 342, 267, 1007, 275, 1987, 1932, 5, 83, 7, 450, 1007, 63, 86, 339, 916, 1015, 59, 19, 61, 508, 283, 4468, 7, 436, 1015, 59, 20, 61, 508, 378, 26, 267, 6135, 63, 26027, 275, 664, 63, 3187, 63, 26027, 342, 267, 340, 6135, 63, 26027, 26, 288, 1007, 275, 1987, 2374, 5, 83, 7, 450, 6135, 63, 26027, 339, 916, 1015, 59, 19, 61, 1137, 283, 5094, 356, 267, 4412, 275, 791, 4468, 356, 283, 65, 297, 283, 5683, 356, 283, 66, 297, 283, 1195, 356, 283, 67, 936, 267, 1007, 275, 4412, 59, 1023, 59, 19, 2677, 435, 620, 8, 1023, 59, 20, 566, 339, 372, 620, 8, 973, 435, 1007, 9, 421, 199, 318, 664, 63, 3187, 63, 26027, 837, 272, 408, 3407, 282, 8950, 5148, 402, 314, 8839, 6135, 23316, 14, 339, 710, 754, 365, 314, 12174, 4913, 402, 314, 23316, 315, 31946, 3218, 5745, 10213, 3218, 2300, 1475, 14, 272, 961, 574, 5712, 1133, 17334, 370, 506, 3747, 12, 1325, 30063, 787, 7437, 625, 24227, 12, 272, 880, 652, 1159, 19258, 367, 12999, 314, 16367, 1015, 5579, 14, 272, 408, 272, 3831, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 29658, 272, 6135, 63, 793, 275, 3873, 14, 7942, 8, 267, 283, 3187, 943, 1553, 9118, 29, 908, 2689, 319, 1553, 10243, 446, 17, 13053, 297, 267, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 12, 267, 5218, 29, 549, 12, 8288, 29, 3417, 63, 694, 12, 17508, 63, 13839, 29, 549, 9, 272, 4913, 275, 6135, 63, 793, 14, 10664, 3430, 16, 61, 272, 862, 26, 267, 4913, 275, 2197, 14, 2083, 14, 5834, 18531, 8, 442, 8, 3954, 430, 272, 871, 1722, 26, 267, 372, 488, 272, 372, 4913, 14, 6205, 3508, 57, 5, 77, 5, 68, 5, 40, 5, 45, 5, 51, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hbmartin/robotframework-selenium2library
src/Selenium2Library/locators/tableelementfinder.py
33
3235
from selenium.common.exceptions import NoSuchElementException from Selenium2Library import utils from elementfinder import ElementFinder class TableElementFinder(object): def __init__(self, element_finder=None): if not element_finder: element_finder = ElementFinder() self._element_finder = element_finder self._locator_suffixes = { ('css', 'default'): [''], ('css', 'content'): [''], ('css', 'header'): [' th'], ('css', 'footer'): [' tfoot td'], ('css', 'row'): [' tr:nth-child(%s)'], ('css', 'col'): [' tr td:nth-child(%s)', ' tr th:nth-child(%s)'], ('xpath', 'default'): [''], ('xpath', 'content'): ['//*'], ('xpath', 'header'): ['//th'], ('xpath', 'footer'): ['//tfoot//td'], ('xpath', 'row'): ['//tr[%s]//*'], ('xpath', 'col'): ['//tr//*[self::td or self::th][%s]'] }; def find(self, browser, table_locator): locators = self._parse_table_locator(table_locator, 'default') return self._search_in_locators(browser, locators, None) def find_by_content(self, browser, table_locator, content): locators = self._parse_table_locator(table_locator, 'content') return self._search_in_locators(browser, locators, content) def find_by_header(self, browser, table_locator, content): locators = self._parse_table_locator(table_locator, 'header') return self._search_in_locators(browser, locators, content) def find_by_footer(self, browser, table_locator, content): locators = self._parse_table_locator(table_locator, 'footer') return self._search_in_locators(browser, locators, content) def find_by_row(self, browser, table_locator, col, content): locators = self._parse_table_locator(table_locator, 'row') locators = [locator % str(col) for locator in locators] return self._search_in_locators(browser, locators, content) def find_by_col(self, browser, table_locator, col, content): locators = self._parse_table_locator(table_locator, 'col') locators = [locator % str(col) for locator in locators] return self._search_in_locators(browser, locators, content) def _parse_table_locator(self, table_locator, location_method): if table_locator.startswith('xpath='): table_locator_type = 'xpath' else: if not table_locator.startswith('css='): table_locator = "css=table#%s" % table_locator table_locator_type = 'css' locator_suffixes = self._locator_suffixes[(table_locator_type, location_method)] return map( lambda locator_suffix: table_locator + locator_suffix, locator_suffixes) def _search_in_locators(self, browser, locators, content): for locator in locators: elements = self._element_finder.find(browser, locator) for element in elements: if content is None: return element element_text = element.text if element_text and content in element_text: return element return None
apache-2.0
[ 504, 19481, 14, 2330, 14, 3924, 492, 23798, 2162, 1726, 199, 504, 3240, 9465, 18, 7424, 492, 3778, 199, 504, 1819, 11681, 492, 6566, 11791, 199, 199, 533, 6957, 2162, 11791, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1819, 63, 11681, 29, 403, 304, 267, 340, 440, 1819, 63, 11681, 26, 288, 1819, 63, 11681, 275, 6566, 11791, 342, 267, 291, 423, 2108, 63, 11681, 275, 1819, 63, 11681, 398, 291, 423, 6354, 63, 16097, 275, 469, 288, 661, 3919, 297, 283, 885, 735, 788, 995, 288, 661, 3919, 297, 283, 1317, 735, 788, 995, 288, 661, 3919, 297, 283, 1291, 735, 788, 294, 995, 288, 661, 3919, 297, 283, 12781, 735, 788, 307, 11407, 12749, 995, 288, 661, 3919, 297, 283, 1143, 735, 788, 5651, 26, 16621, 13, 1739, 4042, 83, 9, 995, 288, 661, 3919, 297, 283, 761, 735, 788, 5651, 12749, 26, 16621, 13, 1739, 4042, 83, 3196, 283, 5651, 294, 26, 16621, 13, 1739, 4042, 83, 9, 995, 953, 661, 8006, 297, 283, 885, 735, 788, 995, 288, 661, 8006, 297, 283, 1317, 735, 788, 501, 10, 995, 288, 661, 8006, 297, 283, 1291, 735, 788, 501, 273, 995, 288, 661, 8006, 297, 283, 12781, 735, 788, 501, 84, 11407, 501, 2076, 995, 288, 661, 8006, 297, 283, 1143, 735, 788, 501, 454, 9722, 83, 61, 501, 10, 995, 288, 661, 8006, 297, 283, 761, 735, 788, 501, 454, 501, 23033, 277, 447, 2076, 503, 291, 447, 273, 1527, 5, 83, 61, 418, 267, 16735, 339, 347, 2342, 8, 277, 12, 7042, 12, 1817, 63, 6354, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 885, 358, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 488, 9, 339, 347, 2342, 63, 991, 63, 1317, 8, 277, 12, 7042, 12, 1817, 63, 6354, 12, 1564, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 1317, 358, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 1564, 9, 339, 347, 2342, 63, 991, 63, 1291, 8, 277, 12, 7042, 12, 1817, 63, 6354, 12, 1564, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 1291, 358, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 1564, 9, 339, 347, 2342, 63, 991, 63, 12781, 8, 277, 12, 7042, 12, 1817, 63, 6354, 12, 1564, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 12781, 358, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 1564, 9, 339, 347, 2342, 63, 991, 63, 1143, 8, 277, 12, 7042, 12, 1817, 63, 6354, 12, 1048, 12, 1564, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 1143, 358, 267, 4355, 2750, 275, 359, 6354, 450, 620, 8, 761, 9, 367, 14067, 315, 4355, 2750, 61, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 1564, 9, 339, 347, 2342, 63, 991, 63, 761, 8, 277, 12, 7042, 12, 1817, 63, 6354, 12, 1048, 12, 1564, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 761, 358, 267, 4355, 2750, 275, 359, 6354, 450, 620, 8, 761, 9, 367, 14067, 315, 4355, 2750, 61, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 1564, 9, 339, 347, 485, 1122, 63, 1224, 63, 6354, 8, 277, 12, 1817, 63, 6354, 12, 2909, 63, 765, 304, 267, 340, 1817, 63, 6354, 14, 2460, 360, 8006, 534, 304, 288, 1817, 63, 6354, 63, 466, 275, 283, 8006, 7, 267, 587, 26, 288, 340, 440, 1817, 63, 6354, 14, 2460, 360, 3919, 534, 304, 355, 1817, 63, 6354, 275, 298, 3919, 29, 1224, 25745, 83, 2, 450, 1817, 63, 6354, 288, 1817, 63, 6354, 63, 466, 275, 283, 3919, 7, 398, 14067, 63, 16097, 275, 291, 423, 6354, 63, 16097, 7528, 1224, 63, 6354, 63, 466, 12, 2909, 63, 765, 1874, 398, 372, 2341, 8, 288, 2400, 14067, 63, 4511, 26, 1817, 63, 6354, 435, 14067, 63, 4511, 12, 288, 14067, 63, 16097, 9, 339, 347, 485, 1733, 63, 262, 63, 2102, 2750, 8, 277, 12, 7042, 12, 4355, 2750, 12, 1564, 304, 267, 367, 14067, 315, 4355, 2750, 26, 288, 4008, 275, 291, 423, 2108, 63, 11681, 14, 1623, 8, 5750, 12, 14067, 9, 288, 367, 1819, 315, 4008, 26, 355, 340, 1564, 365, 488, 26, 372, 1819, 355, 1819, 63, 505, 275, 1819, 14, 505, 355, 340, 1819, 63, 505, 436, 1564, 315, 1819, 63, 505, 26, 490, 372, 1819, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 19481, 14, 2330, 14, 3924, 492, 23798, 2162, 1726, 199, 504, 3240, 9465, 18, 7424, 492, 3778, 199, 504, 1819, 11681, 492, 6566, 11791, 199, 199, 533, 6957, 2162, 11791, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1819, 63, 11681, 29, 403, 304, 267, 340, 440, 1819, 63, 11681, 26, 288, 1819, 63, 11681, 275, 6566, 11791, 342, 267, 291, 423, 2108, 63, 11681, 275, 1819, 63, 11681, 398, 291, 423, 6354, 63, 16097, 275, 469, 288, 661, 3919, 297, 283, 885, 735, 788, 995, 288, 661, 3919, 297, 283, 1317, 735, 788, 995, 288, 661, 3919, 297, 283, 1291, 735, 788, 294, 995, 288, 661, 3919, 297, 283, 12781, 735, 788, 307, 11407, 12749, 995, 288, 661, 3919, 297, 283, 1143, 735, 788, 5651, 26, 16621, 13, 1739, 4042, 83, 9, 995, 288, 661, 3919, 297, 283, 761, 735, 788, 5651, 12749, 26, 16621, 13, 1739, 4042, 83, 3196, 283, 5651, 294, 26, 16621, 13, 1739, 4042, 83, 9, 995, 953, 661, 8006, 297, 283, 885, 735, 788, 995, 288, 661, 8006, 297, 283, 1317, 735, 788, 501, 10, 995, 288, 661, 8006, 297, 283, 1291, 735, 788, 501, 273, 995, 288, 661, 8006, 297, 283, 12781, 735, 788, 501, 84, 11407, 501, 2076, 995, 288, 661, 8006, 297, 283, 1143, 735, 788, 501, 454, 9722, 83, 61, 501, 10, 995, 288, 661, 8006, 297, 283, 761, 735, 788, 501, 454, 501, 23033, 277, 447, 2076, 503, 291, 447, 273, 1527, 5, 83, 61, 418, 267, 16735, 339, 347, 2342, 8, 277, 12, 7042, 12, 1817, 63, 6354, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 885, 358, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 488, 9, 339, 347, 2342, 63, 991, 63, 1317, 8, 277, 12, 7042, 12, 1817, 63, 6354, 12, 1564, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 1317, 358, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 1564, 9, 339, 347, 2342, 63, 991, 63, 1291, 8, 277, 12, 7042, 12, 1817, 63, 6354, 12, 1564, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 1291, 358, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 1564, 9, 339, 347, 2342, 63, 991, 63, 12781, 8, 277, 12, 7042, 12, 1817, 63, 6354, 12, 1564, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 12781, 358, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 1564, 9, 339, 347, 2342, 63, 991, 63, 1143, 8, 277, 12, 7042, 12, 1817, 63, 6354, 12, 1048, 12, 1564, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 1143, 358, 267, 4355, 2750, 275, 359, 6354, 450, 620, 8, 761, 9, 367, 14067, 315, 4355, 2750, 61, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 1564, 9, 339, 347, 2342, 63, 991, 63, 761, 8, 277, 12, 7042, 12, 1817, 63, 6354, 12, 1048, 12, 1564, 304, 267, 4355, 2750, 275, 291, 423, 1122, 63, 1224, 63, 6354, 8, 1224, 63, 6354, 12, 283, 761, 358, 267, 4355, 2750, 275, 359, 6354, 450, 620, 8, 761, 9, 367, 14067, 315, 4355, 2750, 61, 267, 372, 291, 423, 1733, 63, 262, 63, 2102, 2750, 8, 5750, 12, 4355, 2750, 12, 1564, 9, 339, 347, 485, 1122, 63, 1224, 63, 6354, 8, 277, 12, 1817, 63, 6354, 12, 2909, 63, 765, 304, 267, 340, 1817, 63, 6354, 14, 2460, 360, 8006, 534, 304, 288, 1817, 63, 6354, 63, 466, 275, 283, 8006, 7, 267, 587, 26, 288, 340, 440, 1817, 63, 6354, 14, 2460, 360, 3919, 534, 304, 355, 1817, 63, 6354, 275, 298, 3919, 29, 1224, 25745, 83, 2, 450, 1817, 63, 6354, 288, 1817, 63, 6354, 63, 466, 275, 283, 3919, 7, 398, 14067, 63, 16097, 275, 291, 423, 6354, 63, 16097, 7528, 1224, 63, 6354, 63, 466, 12, 2909, 63, 765, 1874, 398, 372, 2341, 8, 288, 2400, 14067, 63, 4511, 26, 1817, 63, 6354, 435, 14067, 63, 4511, 12, 288, 14067, 63, 16097, 9, 339, 347, 485, 1733, 63, 262, 63, 2102, 2750, 8, 277, 12, 7042, 12, 4355, 2750, 12, 1564, 304, 267, 367, 14067, 315, 4355, 2750, 26, 288, 4008, 275, 291, 423, 2108, 63, 11681, 14, 1623, 8, 5750, 12, 14067, 9, 288, 367, 1819, 315, 4008, 26, 355, 340, 1564, 365, 488, 26, 372, 1819, 355, 1819, 63, 505, 275, 1819, 14, 505, 355, 340, 1819, 63, 505, 436, 1564, 315, 1819, 63, 505, 26, 490, 372, 1819, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
midnightmagic/p2pool
wstools/Namespaces.py
292
9396
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. """Namespace module, so you don't need PyXML """ ident = "$Id$" try: from xml.ns import SOAP, SCHEMA, WSDL, XMLNS, DSIG, ENCRYPTION DSIG.C14N = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315" except: class SOAP: ENV = "http://schemas.xmlsoap.org/soap/envelope/" ENC = "http://schemas.xmlsoap.org/soap/encoding/" ACTOR_NEXT = "http://schemas.xmlsoap.org/soap/actor/next" class SCHEMA: XSD1 = "http://www.w3.org/1999/XMLSchema" XSD2 = "http://www.w3.org/2000/10/XMLSchema" XSD3 = "http://www.w3.org/2001/XMLSchema" XSD_LIST = [ XSD1, XSD2, XSD3] XSI1 = "http://www.w3.org/1999/XMLSchema-instance" XSI2 = "http://www.w3.org/2000/10/XMLSchema-instance" XSI3 = "http://www.w3.org/2001/XMLSchema-instance" XSI_LIST = [ XSI1, XSI2, XSI3 ] BASE = XSD3 class WSDL: BASE = "http://schemas.xmlsoap.org/wsdl/" BIND_HTTP = "http://schemas.xmlsoap.org/wsdl/http/" BIND_MIME = "http://schemas.xmlsoap.org/wsdl/mime/" BIND_SOAP = "http://schemas.xmlsoap.org/wsdl/soap/" BIND_SOAP12 = "http://schemas.xmlsoap.org/wsdl/soap12/" class XMLNS: BASE = "http://www.w3.org/2000/xmlns/" XML = "http://www.w3.org/XML/1998/namespace" HTML = "http://www.w3.org/TR/REC-html40" class DSIG: BASE = "http://www.w3.org/2000/09/xmldsig#" C14N = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315" C14N_COMM = "http://www.w3.org/TR/2000/CR-xml-c14n-20010315#WithComments" C14N_EXCL = "http://www.w3.org/2001/10/xml-exc-c14n#" DIGEST_MD2 = "http://www.w3.org/2000/09/xmldsig#md2" DIGEST_MD5 = "http://www.w3.org/2000/09/xmldsig#md5" DIGEST_SHA1 = "http://www.w3.org/2000/09/xmldsig#sha1" ENC_BASE64 = "http://www.w3.org/2000/09/xmldsig#base64" ENVELOPED = "http://www.w3.org/2000/09/xmldsig#enveloped-signature" HMAC_SHA1 = "http://www.w3.org/2000/09/xmldsig#hmac-sha1" SIG_DSA_SHA1 = "http://www.w3.org/2000/09/xmldsig#dsa-sha1" SIG_RSA_SHA1 = "http://www.w3.org/2000/09/xmldsig#rsa-sha1" XPATH = "http://www.w3.org/TR/1999/REC-xpath-19991116" XSLT = "http://www.w3.org/TR/1999/REC-xslt-19991116" class ENCRYPTION: BASE = "http://www.w3.org/2001/04/xmlenc#" BLOCK_3DES = "http://www.w3.org/2001/04/xmlenc#des-cbc" BLOCK_AES128 = "http://www.w3.org/2001/04/xmlenc#aes128-cbc" BLOCK_AES192 = "http://www.w3.org/2001/04/xmlenc#aes192-cbc" BLOCK_AES256 = "http://www.w3.org/2001/04/xmlenc#aes256-cbc" DIGEST_RIPEMD160 = "http://www.w3.org/2001/04/xmlenc#ripemd160" DIGEST_SHA256 = "http://www.w3.org/2001/04/xmlenc#sha256" DIGEST_SHA512 = "http://www.w3.org/2001/04/xmlenc#sha512" KA_DH = "http://www.w3.org/2001/04/xmlenc#dh" KT_RSA_1_5 = "http://www.w3.org/2001/04/xmlenc#rsa-1_5" KT_RSA_OAEP = "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" STREAM_ARCFOUR = "http://www.w3.org/2001/04/xmlenc#arcfour" WRAP_3DES = "http://www.w3.org/2001/04/xmlenc#kw-3des" WRAP_AES128 = "http://www.w3.org/2001/04/xmlenc#kw-aes128" WRAP_AES192 = "http://www.w3.org/2001/04/xmlenc#kw-aes192" WRAP_AES256 = "http://www.w3.org/2001/04/xmlenc#kw-aes256" class WSRF_V1_2: '''OASIS WSRF Specifications Version 1.2 ''' class LIFETIME: XSD_DRAFT1 = "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd" XSD_DRAFT4 = "http://docs.oasis-open.org/wsrf/2004/11/wsrf-WS-ResourceLifetime-1.2-draft-04.xsd" WSDL_DRAFT1 = "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.wsdl" WSDL_DRAFT4 = "http://docs.oasis-open.org/wsrf/2004/11/wsrf-WS-ResourceLifetime-1.2-draft-04.wsdl" LATEST = WSDL_DRAFT4 WSDL_LIST = (WSDL_DRAFT1, WSDL_DRAFT4) XSD_LIST = (XSD_DRAFT1, XSD_DRAFT4) class PROPERTIES: XSD_DRAFT1 = "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd" XSD_DRAFT5 = "http://docs.oasis-open.org/wsrf/2004/11/wsrf-WS-ResourceProperties-1.2-draft-05.xsd" WSDL_DRAFT1 = "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl" WSDL_DRAFT5 = "http://docs.oasis-open.org/wsrf/2004/11/wsrf-WS-ResourceProperties-1.2-draft-05.wsdl" LATEST = WSDL_DRAFT5 WSDL_LIST = (WSDL_DRAFT1, WSDL_DRAFT5) XSD_LIST = (XSD_DRAFT1, XSD_DRAFT5) class BASENOTIFICATION: XSD_DRAFT1 = "http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd" WSDL_DRAFT1 = "http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.wsdl" LATEST = WSDL_DRAFT1 WSDL_LIST = (WSDL_DRAFT1,) XSD_LIST = (XSD_DRAFT1,) class BASEFAULTS: XSD_DRAFT1 = "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-BaseFaults-1.2-draft-01.xsd" XSD_DRAFT3 = "http://docs.oasis-open.org/wsrf/2004/11/wsrf-WS-BaseFaults-1.2-draft-03.xsd" #LATEST = DRAFT3 #WSDL_LIST = (WSDL_DRAFT1, WSDL_DRAFT3) XSD_LIST = (XSD_DRAFT1, XSD_DRAFT3) WSRF = WSRF_V1_2 WSRFLIST = (WSRF_V1_2,) class OASIS: '''URLs for Oasis specifications ''' WSSE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" UTILITY = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" class X509TOKEN: Base64Binary = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" STRTransform = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0" PKCS7 = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#PKCS7" X509 = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509" X509PKIPathv1 = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1" X509v3SubjectKeyIdentifier = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3SubjectKeyIdentifier" LIFETIME = WSRF_V1_2.LIFETIME.XSD_DRAFT1 PROPERTIES = WSRF_V1_2.PROPERTIES.XSD_DRAFT1 BASENOTIFICATION = WSRF_V1_2.BASENOTIFICATION.XSD_DRAFT1 BASEFAULTS = WSRF_V1_2.BASEFAULTS.XSD_DRAFT1 class APACHE: '''This name space is defined by AXIS and it is used for the TC in TCapache.py, Map and file attachment (DataHandler) ''' AXIS_NS = "http://xml.apache.org/xml-soap" class WSTRUST: BASE = "http://schemas.xmlsoap.org/ws/2004/04/trust" ISSUE = "http://schemas.xmlsoap.org/ws/2004/04/trust/Issue" class WSSE: BASE = "http://schemas.xmlsoap.org/ws/2002/04/secext" TRUST = WSTRUST.BASE class WSU: BASE = "http://schemas.xmlsoap.org/ws/2002/04/utility" UTILITY = "http://schemas.xmlsoap.org/ws/2002/07/utility" class WSR: PROPERTIES = "http://www.ibm.com/xmlns/stdwip/web-services/WS-ResourceProperties" LIFETIME = "http://www.ibm.com/xmlns/stdwip/web-services/WS-ResourceLifetime" class WSA200508: ADDRESS = "http://www.w3.org/2005/08/addressing" ANONYMOUS = "%s/anonymous" %ADDRESS FAULT = "%s/fault" %ADDRESS class WSA200408: ADDRESS = "http://schemas.xmlsoap.org/ws/2004/08/addressing" ANONYMOUS = "%s/role/anonymous" %ADDRESS FAULT = "%s/fault" %ADDRESS class WSA200403: ADDRESS = "http://schemas.xmlsoap.org/ws/2004/03/addressing" ANONYMOUS = "%s/role/anonymous" %ADDRESS FAULT = "%s/fault" %ADDRESS class WSA200303: ADDRESS = "http://schemas.xmlsoap.org/ws/2003/03/addressing" ANONYMOUS = "%s/role/anonymous" %ADDRESS FAULT = None WSA = WSA200408 WSA_LIST = (WSA200508, WSA200408, WSA200403, WSA200303) class _WSAW(str): """ Define ADDRESS attribute to be compatible with WSA* layout """ ADDRESS = property(lambda s: s) WSAW200605 = _WSAW("http://www.w3.org/2006/05/addressing/wsdl") WSAW_LIST = (WSAW200605,) class WSP: POLICY = "http://schemas.xmlsoap.org/ws/2002/12/policy" class BEA: SECCONV = "http://schemas.xmlsoap.org/ws/2004/04/sc" SCTOKEN = "http://schemas.xmlsoap.org/ws/2004/04/security/sc/sct" class GLOBUS: SECCONV = "http://wsrf.globus.org/core/2004/07/security/secconv" CORE = "http://www.globus.org/namespaces/2004/06/core" SIG = "http://www.globus.org/2002/04/xmlenc#gssapi-sign" TOKEN = "http://www.globus.org/ws/2004/09/security/sc#GSSAPI_GSI_TOKEN" ZSI_SCHEMA_URI = 'http://www.zolera.com/schemas/ZSI/'
gpl-3.0
[ 3, 1898, 334, 67, 9, 12521, 3107, 13458, 11098, 436, 23212, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 961, 2032, 365, 5420, 370, 314, 1727, 1356, 402, 314, 3107, 13458, 1684, 844, 12, 199, 3, 3394, 499, 14, 16, 334, 58, 2749, 680, 221, 437, 1331, 402, 314, 3107, 2749, 1077, 21727, 642, 4084, 14, 199, 3, 5749, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 1821, 2401, 11727, 7168, 1549, 5292, 199, 3, 2990, 9315, 9706, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 377, 16507, 12, 3169, 12, 437, 9741, 7834, 1621, 12600, 12, 2401, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 199, 624, 8814, 859, 12, 880, 1265, 2793, 1133, 1929, 1611, 4317, 221, 199, 624, 199, 199, 5425, 275, 7880, 1304, 17351, 199, 893, 26, 272, 687, 2748, 14, 561, 492, 26805, 12, 428, 10364, 12, 644, 14029, 12, 4692, 2709, 12, 577, 7864, 12, 5070, 19079, 1075, 272, 577, 7864, 14, 35, 1079, 46, 755, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 8339, 15, 9481, 13, 1652, 13, 67, 1079, 78, 13, 1840, 8845, 1046, 2, 1362, 199, 2590, 26, 272, 1021, 26805, 26, 267, 5070, 54, 260, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21818, 15, 19707, 6687, 267, 5070, 35, 260, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21818, 15, 2991, 6687, 267, 21401, 726, 63, 21917, 221, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21818, 15, 5021, 15, 2184, 2, 339, 1021, 428, 10364, 26, 267, 1323, 3693, 17, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 16278, 15, 32565, 2, 267, 1323, 3693, 18, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 709, 15, 32565, 2, 267, 1323, 3693, 19, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8339, 15, 32565, 2, 267, 1323, 3693, 63, 4924, 259, 275, 359, 1323, 3693, 17, 12, 1323, 3693, 18, 12, 1323, 3693, 19, 61, 267, 1323, 2684, 17, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 16278, 15, 32565, 13, 842, 2, 267, 1323, 2684, 18, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 709, 15, 32565, 13, 842, 2, 267, 1323, 2684, 19, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8339, 15, 32565, 13, 842, 2, 267, 1323, 2684, 63, 4924, 259, 275, 359, 1323, 2684, 17, 12, 1323, 2684, 18, 12, 1323, 2684, 19, 1622, 267, 19721, 263, 275, 1323, 3693, 19, 339, 1021, 644, 14029, 26, 267, 19721, 263, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21452, 6687, 267, 699, 3192, 63, 2856, 257, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21452, 15, 1014, 6687, 267, 699, 3192, 63, 17057, 257, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21452, 15, 7626, 6687, 267, 699, 3192, 63, 4118, 1282, 257, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21452, 15, 21818, 6687, 267, 699, 3192, 63, 4118, 1282, 713, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21452, 15, 21818, 713, 6687, 339, 1021, 4692, 2709, 26, 267, 19721, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 13991, 6687, 267, 4692, 260, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 4317, 15, 23756, 15, 3251, 2, 267, 4163, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 9481, 13, 1360, 2167, 2, 339, 1021, 577, 7864, 26, 267, 19721, 260, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 23662, 267, 445, 1079, 46, 260, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 8339, 15, 9481, 13, 1652, 13, 67, 1079, 78, 13, 1840, 8845, 1046, 2, 267, 445, 1079, 46, 63, 5378, 259, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 8269, 15, 2944, 13, 1652, 13, 67, 1079, 78, 13, 1840, 8845, 1046, 3, 3007, 18929, 2, 267, 445, 1079, 46, 63, 29647, 259, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8339, 15, 709, 15, 1652, 13, 2804, 13, 67, 1079, 78, 23662, 267, 577, 1277, 1719, 63, 5127, 18, 257, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 1064, 18, 2, 267, 577, 1277, 1719, 63, 5127, 21, 257, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 1064, 21, 2, 267, 577, 1277, 1719, 63, 8461, 17, 221, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 4835, 17, 2, 267, 5070, 35, 63, 5825, 772, 257, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 1095, 772, 2, 267, 5070, 2524, 1484, 19359, 259, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 287, 27813, 13, 5233, 2, 267, 29817, 63, 8461, 17, 259, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 18537, 13, 4835, 17, 2, 267, 15522, 63, 23007, 63, 8461, 17, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 24760, 13, 4835, 17, 2, 267, 15522, 63, 12115, 63, 8461, 17, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 13487, 13, 4835, 17, 2, 267, 1323, 3243, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 16278, 15, 9481, 13, 8006, 13, 16278, 845, 975, 2, 267, 1323, 4929 ]
[ 1898, 334, 67, 9, 12521, 3107, 13458, 11098, 436, 23212, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 961, 2032, 365, 5420, 370, 314, 1727, 1356, 402, 314, 3107, 13458, 1684, 844, 12, 199, 3, 3394, 499, 14, 16, 334, 58, 2749, 680, 221, 437, 1331, 402, 314, 3107, 2749, 1077, 21727, 642, 4084, 14, 199, 3, 5749, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 1821, 2401, 11727, 7168, 1549, 5292, 199, 3, 2990, 9315, 9706, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 377, 16507, 12, 3169, 12, 437, 9741, 7834, 1621, 12600, 12, 2401, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 199, 624, 8814, 859, 12, 880, 1265, 2793, 1133, 1929, 1611, 4317, 221, 199, 624, 199, 199, 5425, 275, 7880, 1304, 17351, 199, 893, 26, 272, 687, 2748, 14, 561, 492, 26805, 12, 428, 10364, 12, 644, 14029, 12, 4692, 2709, 12, 577, 7864, 12, 5070, 19079, 1075, 272, 577, 7864, 14, 35, 1079, 46, 755, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 8339, 15, 9481, 13, 1652, 13, 67, 1079, 78, 13, 1840, 8845, 1046, 2, 1362, 199, 2590, 26, 272, 1021, 26805, 26, 267, 5070, 54, 260, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21818, 15, 19707, 6687, 267, 5070, 35, 260, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21818, 15, 2991, 6687, 267, 21401, 726, 63, 21917, 221, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21818, 15, 5021, 15, 2184, 2, 339, 1021, 428, 10364, 26, 267, 1323, 3693, 17, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 16278, 15, 32565, 2, 267, 1323, 3693, 18, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 709, 15, 32565, 2, 267, 1323, 3693, 19, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8339, 15, 32565, 2, 267, 1323, 3693, 63, 4924, 259, 275, 359, 1323, 3693, 17, 12, 1323, 3693, 18, 12, 1323, 3693, 19, 61, 267, 1323, 2684, 17, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 16278, 15, 32565, 13, 842, 2, 267, 1323, 2684, 18, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 709, 15, 32565, 13, 842, 2, 267, 1323, 2684, 19, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8339, 15, 32565, 13, 842, 2, 267, 1323, 2684, 63, 4924, 259, 275, 359, 1323, 2684, 17, 12, 1323, 2684, 18, 12, 1323, 2684, 19, 1622, 267, 19721, 263, 275, 1323, 3693, 19, 339, 1021, 644, 14029, 26, 267, 19721, 263, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21452, 6687, 267, 699, 3192, 63, 2856, 257, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21452, 15, 1014, 6687, 267, 699, 3192, 63, 17057, 257, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21452, 15, 7626, 6687, 267, 699, 3192, 63, 4118, 1282, 257, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21452, 15, 21818, 6687, 267, 699, 3192, 63, 4118, 1282, 713, 275, 298, 1014, 921, 9482, 14, 10198, 5770, 439, 14, 1308, 15, 21452, 15, 21818, 713, 6687, 339, 1021, 4692, 2709, 26, 267, 19721, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 13991, 6687, 267, 4692, 260, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 4317, 15, 23756, 15, 3251, 2, 267, 4163, 263, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 9481, 13, 1360, 2167, 2, 339, 1021, 577, 7864, 26, 267, 19721, 260, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 23662, 267, 445, 1079, 46, 260, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 8339, 15, 9481, 13, 1652, 13, 67, 1079, 78, 13, 1840, 8845, 1046, 2, 267, 445, 1079, 46, 63, 5378, 259, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 8269, 15, 2944, 13, 1652, 13, 67, 1079, 78, 13, 1840, 8845, 1046, 3, 3007, 18929, 2, 267, 445, 1079, 46, 63, 29647, 259, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8339, 15, 709, 15, 1652, 13, 2804, 13, 67, 1079, 78, 23662, 267, 577, 1277, 1719, 63, 5127, 18, 257, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 1064, 18, 2, 267, 577, 1277, 1719, 63, 5127, 21, 257, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 1064, 21, 2, 267, 577, 1277, 1719, 63, 8461, 17, 221, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 4835, 17, 2, 267, 5070, 35, 63, 5825, 772, 257, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 1095, 772, 2, 267, 5070, 2524, 1484, 19359, 259, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 287, 27813, 13, 5233, 2, 267, 29817, 63, 8461, 17, 259, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 18537, 13, 4835, 17, 2, 267, 15522, 63, 23007, 63, 8461, 17, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 24760, 13, 4835, 17, 2, 267, 15522, 63, 12115, 63, 8461, 17, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 1643, 15, 1652, 68, 4093, 3, 13487, 13, 4835, 17, 2, 267, 1323, 3243, 263, 275, 298, 1014, 921, 1544, 14, 87, 19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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 ]
keichan100yen/ode-ext
boost/tools/build/test/preprocessor.py
58
1070
#!/usr/bin/python # Copyright 2003 Vladimir Prus # Copyright 2011 Steven Watanabe # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) # Test the C/C++ preprocessor. import BoostBuild t = BoostBuild.Tester() t.write("jamroot.jam", """ project ; preprocessed hello : hello.cpp ; preprocessed a : a.c ; exe hello.exe : hello a : <define>FAIL ; """) t.write("hello.cpp", """ #ifndef __cplusplus #error "This file must be compiled as C++" #endif #ifdef FAIL #error "Not preprocessed?" #endif extern "C" int foo(); int main() { return foo(); } """) t.write("a.c", """ /* This will not compile unless in C mode. */ #ifdef __cplusplus #error "This file must be compiled as C" #endif #ifdef FAIL #error "Not preprocessed?" #endif int foo() { int new = 0; new = (new+1)*7; return new; } """) t.run_build_system() t.expect_addition("bin/$toolset/debug/hello.ii") t.expect_addition("bin/$toolset/debug/a.i") t.expect_addition("bin/$toolset/debug/hello.exe") t.cleanup()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 13004, 812, 416, 3572, 723, 510, 20791, 199, 3, 1898, 7760, 17854, 1856, 644, 16080, 7570, 199, 3, 17484, 1334, 314, 30470, 2290, 844, 12, 3394, 413, 14, 16, 14, 199, 3, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 199, 199, 3, 1379, 314, 445, 15, 35, 4176, 22335, 14, 199, 199, 646, 30470, 3425, 199, 199, 84, 275, 30470, 3425, 14, 22403, 342, 199, 199, 84, 14, 952, 480, 16997, 1231, 14, 16997, 401, 408, 199, 1715, 8700, 199, 657, 7292, 16509, 520, 16509, 14, 5910, 8700, 199, 657, 7292, 282, 520, 282, 14, 67, 8700, 199, 5803, 16509, 14, 5803, 520, 16509, 282, 520, 665, 4640, 30, 8784, 8700, 199, 6141, 199, 199, 84, 14, 952, 480, 5006, 14, 5910, 401, 408, 199, 3, 27708, 636, 67, 6666, 6666, 199, 3, 705, 298, 2765, 570, 1471, 506, 10311, 465, 445, 4176, 2, 199, 3, 13739, 199, 3, 27737, 10341, 199, 3, 705, 298, 1763, 876, 7292, 13472, 199, 3, 13739, 199, 18587, 298, 35, 2, 1109, 3925, 7303, 199, 442, 2446, 342, 469, 372, 3925, 7303, 789, 199, 6141, 199, 199, 84, 14, 952, 480, 65, 14, 67, 401, 408, 199, 6331, 961, 911, 440, 6555, 7444, 315, 445, 818, 14, 11589, 199, 3, 27737, 636, 67, 6666, 6666, 199, 3, 705, 298, 2765, 570, 1471, 506, 10311, 465, 445, 2, 199, 3, 13739, 199, 3, 27737, 10341, 199, 3, 705, 298, 1763, 876, 7292, 13472, 199, 3, 13739, 199, 442, 3925, 342, 199, 91, 272, 1109, 892, 275, 378, 27, 272, 892, 275, 334, 1222, 11, 17, 3342, 23, 27, 272, 372, 892, 27, 199, 93, 199, 6141, 199, 199, 84, 14, 1065, 63, 1506, 63, 2253, 342, 199, 84, 14, 4921, 63, 26799, 480, 1393, 21792, 12081, 15, 1757, 15, 5006, 14, 5908, 531, 199, 84, 14, 4921, 63, 26799, 480, 1393, 21792, 12081, 15, 1757, 15, 65, 14, 73, 531, 199, 84, 14, 4921, 63, 26799, 480, 1393, 21792, 12081, 15, 1757, 15, 5006, 14, 5803, 531, 199, 199, 84, 14, 7661, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 13004, 812, 416, 3572, 723, 510, 20791, 199, 3, 1898, 7760, 17854, 1856, 644, 16080, 7570, 199, 3, 17484, 1334, 314, 30470, 2290, 844, 12, 3394, 413, 14, 16, 14, 199, 3, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 199, 199, 3, 1379, 314, 445, 15, 35, 4176, 22335, 14, 199, 199, 646, 30470, 3425, 199, 199, 84, 275, 30470, 3425, 14, 22403, 342, 199, 199, 84, 14, 952, 480, 16997, 1231, 14, 16997, 401, 408, 199, 1715, 8700, 199, 657, 7292, 16509, 520, 16509, 14, 5910, 8700, 199, 657, 7292, 282, 520, 282, 14, 67, 8700, 199, 5803, 16509, 14, 5803, 520, 16509, 282, 520, 665, 4640, 30, 8784, 8700, 199, 6141, 199, 199, 84, 14, 952, 480, 5006, 14, 5910, 401, 408, 199, 3, 27708, 636, 67, 6666, 6666, 199, 3, 705, 298, 2765, 570, 1471, 506, 10311, 465, 445, 4176, 2, 199, 3, 13739, 199, 3, 27737, 10341, 199, 3, 705, 298, 1763, 876, 7292, 13472, 199, 3, 13739, 199, 18587, 298, 35, 2, 1109, 3925, 7303, 199, 442, 2446, 342, 469, 372, 3925, 7303, 789, 199, 6141, 199, 199, 84, 14, 952, 480, 65, 14, 67, 401, 408, 199, 6331, 961, 911, 440, 6555, 7444, 315, 445, 818, 14, 11589, 199, 3, 27737, 636, 67, 6666, 6666, 199, 3, 705, 298, 2765, 570, 1471, 506, 10311, 465, 445, 2, 199, 3, 13739, 199, 3, 27737, 10341, 199, 3, 705, 298, 1763, 876, 7292, 13472, 199, 3, 13739, 199, 442, 3925, 342, 199, 91, 272, 1109, 892, 275, 378, 27, 272, 892, 275, 334, 1222, 11, 17, 3342, 23, 27, 272, 372, 892, 27, 199, 93, 199, 6141, 199, 199, 84, 14, 1065, 63, 1506, 63, 2253, 342, 199, 84, 14, 4921, 63, 26799, 480, 1393, 21792, 12081, 15, 1757, 15, 5006, 14, 5908, 531, 199, 84, 14, 4921, 63, 26799, 480, 1393, 21792, 12081, 15, 1757, 15, 65, 14, 73, 531, 199, 84, 14, 4921, 63, 26799, 480, 1393, 21792, 12081, 15, 1757, 15, 5006, 14, 5803, 531, 199, 199, 84, 14, 7661, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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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 ]
google/struct2tensor
struct2tensor/expression_impl/promote_and_broadcast.py
1
4361
# Copyright 2019 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. r"""promote_and_broadcast a set of nodes. For example, suppose an expr represents: ``` + | +-session* (stars indicate repeated) | +-event* | | | +-val*-int64 | +-user_info? (question mark indicates optional) | +-age? int64 session: { event: { val: 1 } event: { val: 4 val: 5 } user_info: { age: 25 } } session: { event: { val: 7 } event: { val: 8 val: 9 } user_info: { age: 20 } } ``` ``` promote_and_broadcast.promote_and_broadcast( path.Path(["event"]),{"nage":path.Path(["user_info","age"])}) ``` creates: ``` + | +-session* (stars indicate repeated) | +-event* | | | +-val*-int64 | | | +-nage*-int64 | +-user_info? (question mark indicates optional) | +-age? int64 session: { event: { nage: 25 val: 1 } event: { nage: 25 val: 4 val: 5 } user_info: { age: 25 } } session: { event: { nage: 20 val: 7 } event: { nage: 20 val: 8 val: 9 } user_info: { age: 20 } } ``` """ from typing import Mapping, Tuple from struct2tensor import expression from struct2tensor import expression_add from struct2tensor import path from struct2tensor.expression_impl import broadcast from struct2tensor.expression_impl import promote def promote_and_broadcast_anonymous( root: expression.Expression, origin: path.Path, new_parent: path.Path) -> Tuple[expression.Expression, path.Path]: """Promotes then broadcasts the origin until its parent is new_parent.""" least_common_ancestor = origin.get_least_common_ancestor(new_parent) new_expr, new_path = root, origin while new_path.get_parent() != least_common_ancestor: new_expr, new_path = promote.promote_anonymous(new_expr, new_path) while new_path.get_parent() != new_parent: new_parent_step = new_parent.field_list[len(new_path) - 1] new_expr, new_path = broadcast.broadcast_anonymous(new_expr, new_path, new_parent_step) return new_expr, new_path def _promote_and_broadcast_name(root: expression.Expression, origin: path.Path, dest_path_parent: path.Path, field_name: path.Step) -> expression.Expression: new_root, anonymous_path = promote_and_broadcast_anonymous( root, origin, dest_path_parent) path_result = dest_path_parent.get_child(field_name) return expression_add.add_paths( new_root, {path_result: new_root.get_descendant_or_error(anonymous_path)}) def promote_and_broadcast(root: expression.Expression, path_dictionary: Mapping[path.Step, path.Path], dest_path_parent: path.Path) -> expression.Expression: """Promote and broadcast a set of paths to a particular location. Args: root: the original expression. path_dictionary: a map from destination fields to origin paths. dest_path_parent: a map from destination strings. Returns: A new expression, where all the origin paths are promoted and broadcast until they are children of dest_path_parent. """ result_paths = {} # Here, we branch out and create a different tree for each field that is # promoted and broadcast. for field_name, origin_path in path_dictionary.items(): result_path = dest_path_parent.get_child(field_name) new_root = _promote_and_broadcast_name(root, origin_path, dest_path_parent, field_name) result_paths[result_path] = new_root # We create a new tree that has all of the generated fields from the older # trees. return expression_add.add_to(root, result_paths)
apache-2.0
[ 3, 1898, 20312, 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, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 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, 82, 624, 20422, 63, 460, 63, 10786, 282, 663, 402, 3380, 14, 199, 199, 1858, 2893, 12, 1029, 4070, 376, 5348, 8469, 26, 199, 199, 32323, 199, 11, 199, 92, 199, 16341, 1730, 10, 257, 334, 270, 4291, 6623, 10877, 9, 1362, 1204, 1362, 435, 13, 1430, 10, 1362, 1204, 257, 1204, 1362, 1204, 257, 435, 13, 637, 1837, 442, 772, 1362, 1204, 1362, 435, 13, 751, 63, 815, 31, 334, 4790, 2216, 9126, 2716, 9, 1779, 1204, 1779, 435, 13, 474, 31, 1109, 772, 199, 199, 1730, 26, 469, 523, 1566, 26, 469, 272, 1139, 26, 413, 523, 789, 523, 1566, 26, 469, 272, 1139, 26, 841, 272, 1139, 26, 959, 523, 789, 523, 922, 63, 815, 26, 469, 272, 11437, 26, 5661, 523, 789, 199, 93, 199, 199, 1730, 26, 469, 523, 1566, 26, 469, 272, 1139, 26, 1520, 523, 789, 523, 1566, 26, 469, 272, 1139, 26, 1695, 272, 1139, 26, 1749, 523, 789, 523, 922, 63, 815, 26, 469, 272, 11437, 26, 3388, 523, 789, 199, 93, 199, 32323, 199, 199, 32323, 199, 20422, 63, 460, 63, 10786, 14, 20422, 63, 460, 63, 10786, 8, 272, 931, 14, 2042, 5234, 1430, 10252, 6641, 78, 474, 582, 515, 14, 2042, 5234, 751, 63, 815, 2266, 474, 3135, 1552, 199, 32323, 199, 199, 28219, 26, 199, 199, 32323, 199, 11, 199, 92, 199, 16341, 1730, 10, 257, 334, 270, 4291, 6623, 10877, 9, 1362, 1204, 1362, 435, 13, 1430, 10, 1362, 1204, 257, 1204, 1362, 1204, 257, 435, 13, 637, 1837, 442, 772, 1362, 1204, 257, 1204, 1362, 1204, 257, 435, 13, 78, 474, 1837, 442, 772, 1362, 1204, 1362, 435, 13, 751, 63, 815, 31, 334, 4790, 2216, 9126, 2716, 9, 1779, 1204, 1779, 435, 13, 474, 31, 1109, 772, 199, 199, 1730, 26, 469, 523, 1566, 26, 469, 272, 302, 474, 26, 5661, 272, 1139, 26, 413, 523, 789, 523, 1566, 26, 469, 272, 302, 474, 26, 5661, 272, 1139, 26, 841, 272, 1139, 26, 959, 523, 789, 523, 922, 63, 815, 26, 469, 272, 11437, 26, 5661, 523, 789, 199, 93, 199, 199, 1730, 26, 469, 523, 1566, 26, 469, 272, 302, 474, 26, 3388, 272, 1139, 26, 1520, 523, 789, 523, 1566, 26, 469, 272, 302, 474, 26, 3388, 272, 1139, 26, 1695, 272, 1139, 26, 1749, 523, 789, 523, 922, 63, 815, 26, 469, 272, 11437, 26, 3388, 523, 789, 199, 93, 199, 32323, 199, 199, 624, 199, 199, 504, 14090, 492, 12340, 12, 11634, 199, 199, 504, 2702, 18, 3128, 492, 3965, 199, 504, 2702, 18, 3128, 492, 3965, 63, 525, 199, 504, 2702, 18, 3128, 492, 931, 199, 504, 2702, 18, 3128, 14, 5599, 63, 5472, 492, 11180, 199, 504, 2702, 18, 3128, 14, 5599, 63, 5472, 492, 10016, 421, 199, 318, 10016, 63, 460, 63, 10786, 63, 12628, 8, 272, 1738, 26, 3965, 14, 9093, 12, 6330, 26, 931, 14, 2042, 12, 272, 892, 63, 1708, 26, 931, 14, 2042, 9, 1035, 11634, 59, 5599, 14, 9093, 12, 931, 14, 2042, 2189, 523, 408, 19250, 6510, 2066, 11180, 83, 314, 6330, 5133, 2399, 1676, 365, 892, 63, 1708, 1041, 523, 5210, 63, 2330, 63, 20745, 275, 6330, 14, 362, 63, 11790, 63, 2330, 63, 20745, 8, 1222, 63, 1708, 9, 819, 892, 63, 3684, 12, 892, 63, 515, 275, 1738, 12, 6330, 523, 1830, 892, 63, 515, 14, 362, 63, 1708, 342, 1137, 5210, 63, 2330, 63, 20745, 26, 272, 892, 63, 3684, 12, 892, 63, 515, 275, 10016, 14, 20422, 63, 12628, 8, 1222, 63, 3684, 12, 892, 63, 515, 9, 819, 1830, 892, 63, 515, 14, 362, 63, 1708, 342, 1137, 892, 63, 1708, 26, 272, 892, 63, 1708, 63, 2926, 275, 892, 63, 1708, 14, 698, 63, 513, 59, 552, 8, 1222, 63, 515, 9, 446, 413, 61, 272, 892, 63, 3684, 12, 892, 63, 515, 275, 11180, 14, 10786, 63, 12628, 8, 1222, 63, 3684, 12, 892, 63, 515, 12, 10940, 892, 63, 1708, 63, 2926, 9, 819, 372, 892, 63, 3684, 12, 892, 63, 515, 421, 199, 318, 485, 20422, 63, 460, 63, 10786, 63, 354, 8, 1231, 26, 3965, 14, 9093, 12, 6330, 26, 931, 14, 2042, 12, 1816, 2053, 63, 515, 63, 1708, 26, 931, 14, 2042, 12, 1816, 901, 63, 354, 26, 931, 14, 7801, 9, 1035, 3965, 14, 9093, 26, 523, 892, 63, 1231, 12, 16535, 63, 515, 275, 10016, 63, 460, 63, 10786, 63, 12628, 8, 489, 1738, 12, 6330, 12, 2053, 63, 515, 63, 1708, 9, 523, 931, 63, 1099, 275, 2053, 63, 515, 63, 1708, 14, 362, 63, 1739, 8, 698, 63, 354, 9, 523, 372, 3965, 63, 525, 14, 525, 63, 3771, 8, 489, 892, 63, 1231, 12, 469, 515, 63, 1099, 26, 892, 63, 1231, 14, 362, 63, 31759, 63, 269, 63, 705, 8, 12628, 63, 515, 11466, 421, 199, 318, 10016, 63, 460, 63, 10786, 8, 1231, 26, 3965, 14, 9093, 12, 2079, 931, 63, 9086, 26, 12340, 59, 515, 14, 7801, 12, 931, 14, 2042, 467, 2079, 2053, 63, 515, 63, 1708, 26, 931, 14, 2042, 9, 1035, 3965, 14, 9093, 26, 523, 408, 19250, 1583, 436, 11180, 282, 663, 402, 3792, 370, 282, 6770, 2909, 14, 819, 3033, 26, 272, 1738, 26, 314, 3379, 3965, 14, 272, 931, 63, 9086, 26, 282, 2341, 687, 5724, 1504, 370, 6330, 3792, 14 ]
[ 1898, 20312, 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, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 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, 82, 624, 20422, 63, 460, 63, 10786, 282, 663, 402, 3380, 14, 199, 199, 1858, 2893, 12, 1029, 4070, 376, 5348, 8469, 26, 199, 199, 32323, 199, 11, 199, 92, 199, 16341, 1730, 10, 257, 334, 270, 4291, 6623, 10877, 9, 1362, 1204, 1362, 435, 13, 1430, 10, 1362, 1204, 257, 1204, 1362, 1204, 257, 435, 13, 637, 1837, 442, 772, 1362, 1204, 1362, 435, 13, 751, 63, 815, 31, 334, 4790, 2216, 9126, 2716, 9, 1779, 1204, 1779, 435, 13, 474, 31, 1109, 772, 199, 199, 1730, 26, 469, 523, 1566, 26, 469, 272, 1139, 26, 413, 523, 789, 523, 1566, 26, 469, 272, 1139, 26, 841, 272, 1139, 26, 959, 523, 789, 523, 922, 63, 815, 26, 469, 272, 11437, 26, 5661, 523, 789, 199, 93, 199, 199, 1730, 26, 469, 523, 1566, 26, 469, 272, 1139, 26, 1520, 523, 789, 523, 1566, 26, 469, 272, 1139, 26, 1695, 272, 1139, 26, 1749, 523, 789, 523, 922, 63, 815, 26, 469, 272, 11437, 26, 3388, 523, 789, 199, 93, 199, 32323, 199, 199, 32323, 199, 20422, 63, 460, 63, 10786, 14, 20422, 63, 460, 63, 10786, 8, 272, 931, 14, 2042, 5234, 1430, 10252, 6641, 78, 474, 582, 515, 14, 2042, 5234, 751, 63, 815, 2266, 474, 3135, 1552, 199, 32323, 199, 199, 28219, 26, 199, 199, 32323, 199, 11, 199, 92, 199, 16341, 1730, 10, 257, 334, 270, 4291, 6623, 10877, 9, 1362, 1204, 1362, 435, 13, 1430, 10, 1362, 1204, 257, 1204, 1362, 1204, 257, 435, 13, 637, 1837, 442, 772, 1362, 1204, 257, 1204, 1362, 1204, 257, 435, 13, 78, 474, 1837, 442, 772, 1362, 1204, 1362, 435, 13, 751, 63, 815, 31, 334, 4790, 2216, 9126, 2716, 9, 1779, 1204, 1779, 435, 13, 474, 31, 1109, 772, 199, 199, 1730, 26, 469, 523, 1566, 26, 469, 272, 302, 474, 26, 5661, 272, 1139, 26, 413, 523, 789, 523, 1566, 26, 469, 272, 302, 474, 26, 5661, 272, 1139, 26, 841, 272, 1139, 26, 959, 523, 789, 523, 922, 63, 815, 26, 469, 272, 11437, 26, 5661, 523, 789, 199, 93, 199, 199, 1730, 26, 469, 523, 1566, 26, 469, 272, 302, 474, 26, 3388, 272, 1139, 26, 1520, 523, 789, 523, 1566, 26, 469, 272, 302, 474, 26, 3388, 272, 1139, 26, 1695, 272, 1139, 26, 1749, 523, 789, 523, 922, 63, 815, 26, 469, 272, 11437, 26, 3388, 523, 789, 199, 93, 199, 32323, 199, 199, 624, 199, 199, 504, 14090, 492, 12340, 12, 11634, 199, 199, 504, 2702, 18, 3128, 492, 3965, 199, 504, 2702, 18, 3128, 492, 3965, 63, 525, 199, 504, 2702, 18, 3128, 492, 931, 199, 504, 2702, 18, 3128, 14, 5599, 63, 5472, 492, 11180, 199, 504, 2702, 18, 3128, 14, 5599, 63, 5472, 492, 10016, 421, 199, 318, 10016, 63, 460, 63, 10786, 63, 12628, 8, 272, 1738, 26, 3965, 14, 9093, 12, 6330, 26, 931, 14, 2042, 12, 272, 892, 63, 1708, 26, 931, 14, 2042, 9, 1035, 11634, 59, 5599, 14, 9093, 12, 931, 14, 2042, 2189, 523, 408, 19250, 6510, 2066, 11180, 83, 314, 6330, 5133, 2399, 1676, 365, 892, 63, 1708, 1041, 523, 5210, 63, 2330, 63, 20745, 275, 6330, 14, 362, 63, 11790, 63, 2330, 63, 20745, 8, 1222, 63, 1708, 9, 819, 892, 63, 3684, 12, 892, 63, 515, 275, 1738, 12, 6330, 523, 1830, 892, 63, 515, 14, 362, 63, 1708, 342, 1137, 5210, 63, 2330, 63, 20745, 26, 272, 892, 63, 3684, 12, 892, 63, 515, 275, 10016, 14, 20422, 63, 12628, 8, 1222, 63, 3684, 12, 892, 63, 515, 9, 819, 1830, 892, 63, 515, 14, 362, 63, 1708, 342, 1137, 892, 63, 1708, 26, 272, 892, 63, 1708, 63, 2926, 275, 892, 63, 1708, 14, 698, 63, 513, 59, 552, 8, 1222, 63, 515, 9, 446, 413, 61, 272, 892, 63, 3684, 12, 892, 63, 515, 275, 11180, 14, 10786, 63, 12628, 8, 1222, 63, 3684, 12, 892, 63, 515, 12, 10940, 892, 63, 1708, 63, 2926, 9, 819, 372, 892, 63, 3684, 12, 892, 63, 515, 421, 199, 318, 485, 20422, 63, 460, 63, 10786, 63, 354, 8, 1231, 26, 3965, 14, 9093, 12, 6330, 26, 931, 14, 2042, 12, 1816, 2053, 63, 515, 63, 1708, 26, 931, 14, 2042, 12, 1816, 901, 63, 354, 26, 931, 14, 7801, 9, 1035, 3965, 14, 9093, 26, 523, 892, 63, 1231, 12, 16535, 63, 515, 275, 10016, 63, 460, 63, 10786, 63, 12628, 8, 489, 1738, 12, 6330, 12, 2053, 63, 515, 63, 1708, 9, 523, 931, 63, 1099, 275, 2053, 63, 515, 63, 1708, 14, 362, 63, 1739, 8, 698, 63, 354, 9, 523, 372, 3965, 63, 525, 14, 525, 63, 3771, 8, 489, 892, 63, 1231, 12, 469, 515, 63, 1099, 26, 892, 63, 1231, 14, 362, 63, 31759, 63, 269, 63, 705, 8, 12628, 63, 515, 11466, 421, 199, 318, 10016, 63, 460, 63, 10786, 8, 1231, 26, 3965, 14, 9093, 12, 2079, 931, 63, 9086, 26, 12340, 59, 515, 14, 7801, 12, 931, 14, 2042, 467, 2079, 2053, 63, 515, 63, 1708, 26, 931, 14, 2042, 9, 1035, 3965, 14, 9093, 26, 523, 408, 19250, 1583, 436, 11180, 282, 663, 402, 3792, 370, 282, 6770, 2909, 14, 819, 3033, 26, 272, 1738, 26, 314, 3379, 3965, 14, 272, 931, 63, 9086, 26, 282, 2341, 687, 5724, 1504, 370, 6330, 3792, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
zwqjsj0404/HBase-Research
src/examples/thrift2/DemoClient.py
23
2351
""" Copyright 2011 The Apache Software Foundation 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. """ # Instructions: # 1. Run Thrift to generate the python module hbase # thrift --gen py ../../../src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift # 2. Create a directory of your choosing that contains: # a. This file (DemoClient.py). # b. The directory gen-py/hbase (generated by instruction step 1). # 3. pip install thrift==0.7.0 # 4. Create a table call "example", with a family called "family1" using the hbase shell. # 5. Start the hbase thrift2 server # bin/hbase thrift2 start # 6. Execute {python DemoClient.py}. from thrift.transport import TTransport from thrift.transport import TSocket from thrift.transport import THttpClient from thrift.protocol import TBinaryProtocol from hbase import THBaseService from hbase.ttypes import * print "Thrift2 Demo" print "This demo assumes you have a table called \"example\" with a column family called \"family1\"" host = "localhost" port = 9090 framed = False socket = TSocket.TSocket(host, port) if framed: transport = TTransport.TFramedTransport(socket) else: transport = TTransport.TBufferedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = THBaseService.Client(protocol) transport.open() table = "example" put = TPut(row="row1", columnValues=[TColumnValue(family="family1",qualifier="qualifier1",value="value1")]) print "Putting:", put client.put(table, put) get = TGet(row="row1") print "Getting:", get result = client.get(table, get) print "Result:", result transport.close()
apache-2.0
[ 624, 523, 1898, 7760, 710, 3668, 2290, 2752, 12244, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 523, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 523, 1854, 543, 642, 1736, 367, 4722, 2556, 523, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 523, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 523, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 523, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 2043, 1362, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 12244, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 523, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 523, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 523, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 523, 4204, 1334, 314, 844, 14, 199, 624, 199, 3, 1010, 10583, 26, 199, 3, 413, 14, 3378, 3868, 6501, 370, 3550, 314, 2366, 859, 394, 1095, 199, 3, 259, 17199, 1553, 2268, 1134, 24272, 9707, 2164, 15, 973, 15, 4435, 15, 1308, 15, 3796, 15, 15449, 15, 72, 1095, 15, 8430, 18, 15, 72, 1095, 14, 8430, 199, 3, 499, 14, 2790, 282, 2082, 402, 2195, 2468, 26056, 626, 3509, 26, 199, 3, 258, 282, 14, 961, 570, 334, 21493, 3041, 14, 647, 680, 199, 3, 258, 330, 14, 710, 2082, 3805, 13, 647, 15, 72, 1095, 334, 10176, 701, 16329, 3650, 413, 680, 199, 3, 650, 14, 7305, 3907, 17199, 389, 16, 14, 23, 14, 16, 199, 3, 841, 14, 2790, 282, 1817, 1240, 298, 2694, 401, 543, 282, 9614, 2797, 298, 6606, 17, 2, 1808, 314, 394, 1095, 5218, 14, 199, 3, 959, 14, 7707, 314, 394, 1095, 17199, 18, 1654, 199, 3, 259, 2517, 15, 72, 1095, 17199, 18, 1343, 199, 3, 1227, 14, 17009, 469, 1548, 28939, 3041, 14, 647, 5565, 199, 199, 504, 17199, 14, 5545, 492, 19391, 199, 504, 17199, 14, 5545, 492, 377, 3869, 199, 504, 17199, 14, 5545, 492, 4221, 3370, 3041, 199, 504, 17199, 14, 3922, 492, 15934, 199, 199, 504, 394, 1095, 492, 4221, 1563, 3167, 199, 504, 394, 1095, 14, 21776, 492, 627, 199, 199, 1361, 298, 2719, 6501, 18, 28939, 2, 199, 1361, 298, 2765, 14779, 15194, 1265, 1172, 282, 1817, 2797, 8441, 2694, 4451, 543, 282, 2763, 9614, 2797, 8441, 6606, 17, 18781, 199, 199, 1102, 275, 298, 5967, 2, 199, 719, 275, 1749, 18526, 199, 1943, 68, 275, 756, 199, 199, 3450, 275, 377, 3869, 14, 52, 3869, 8, 1102, 12, 1844, 9, 199, 692, 2787, 68, 26, 523, 7773, 275, 19391, 14, 52, 3160, 68, 7836, 8, 3450, 9, 199, 2836, 26, 523, 7773, 275, 19391, 14, 52, 23139, 7836, 8, 3450, 9, 199, 3922, 275, 15934, 14, 16805, 8, 5545, 9, 199, 1258, 275, 4221, 1563, 3167, 14, 3041, 8, 3922, 9, 199, 199, 5545, 14, 1490, 342, 199, 199, 1224, 275, 298, 2694, 2, 199, 199, 524, 275, 377, 18989, 8, 1143, 628, 1143, 17, 401, 2763, 6550, 1524, 52, 4547, 1110, 8, 6606, 628, 6606, 17, 401, 27005, 628, 27005, 17, 401, 585, 628, 585, 17, 13403, 199, 1361, 298, 18989, 1337, 6783, 5324, 199, 1258, 14, 524, 8, 1224, 12, 5324, 9, 199, 199, 362, 275, 377, 1002, 8, 1143, 628, 1143, 17, 531, 199, 1361, 298, 28277, 6783, 664, 199, 1099, 275, 1890, 14, 362, 8, 1224, 12, 664, 9, 199, 199, 1361, 298, 2889, 6783, 754, 2043, 199, 5545, 14, 1600, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 523, 1898, 7760, 710, 3668, 2290, 2752, 12244, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 523, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 523, 1854, 543, 642, 1736, 367, 4722, 2556, 523, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 523, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 523, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 523, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 2043, 1362, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 12244, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 523, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 523, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 523, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 523, 4204, 1334, 314, 844, 14, 199, 624, 199, 3, 1010, 10583, 26, 199, 3, 413, 14, 3378, 3868, 6501, 370, 3550, 314, 2366, 859, 394, 1095, 199, 3, 259, 17199, 1553, 2268, 1134, 24272, 9707, 2164, 15, 973, 15, 4435, 15, 1308, 15, 3796, 15, 15449, 15, 72, 1095, 15, 8430, 18, 15, 72, 1095, 14, 8430, 199, 3, 499, 14, 2790, 282, 2082, 402, 2195, 2468, 26056, 626, 3509, 26, 199, 3, 258, 282, 14, 961, 570, 334, 21493, 3041, 14, 647, 680, 199, 3, 258, 330, 14, 710, 2082, 3805, 13, 647, 15, 72, 1095, 334, 10176, 701, 16329, 3650, 413, 680, 199, 3, 650, 14, 7305, 3907, 17199, 389, 16, 14, 23, 14, 16, 199, 3, 841, 14, 2790, 282, 1817, 1240, 298, 2694, 401, 543, 282, 9614, 2797, 298, 6606, 17, 2, 1808, 314, 394, 1095, 5218, 14, 199, 3, 959, 14, 7707, 314, 394, 1095, 17199, 18, 1654, 199, 3, 259, 2517, 15, 72, 1095, 17199, 18, 1343, 199, 3, 1227, 14, 17009, 469, 1548, 28939, 3041, 14, 647, 5565, 199, 199, 504, 17199, 14, 5545, 492, 19391, 199, 504, 17199, 14, 5545, 492, 377, 3869, 199, 504, 17199, 14, 5545, 492, 4221, 3370, 3041, 199, 504, 17199, 14, 3922, 492, 15934, 199, 199, 504, 394, 1095, 492, 4221, 1563, 3167, 199, 504, 394, 1095, 14, 21776, 492, 627, 199, 199, 1361, 298, 2719, 6501, 18, 28939, 2, 199, 1361, 298, 2765, 14779, 15194, 1265, 1172, 282, 1817, 2797, 8441, 2694, 4451, 543, 282, 2763, 9614, 2797, 8441, 6606, 17, 18781, 199, 199, 1102, 275, 298, 5967, 2, 199, 719, 275, 1749, 18526, 199, 1943, 68, 275, 756, 199, 199, 3450, 275, 377, 3869, 14, 52, 3869, 8, 1102, 12, 1844, 9, 199, 692, 2787, 68, 26, 523, 7773, 275, 19391, 14, 52, 3160, 68, 7836, 8, 3450, 9, 199, 2836, 26, 523, 7773, 275, 19391, 14, 52, 23139, 7836, 8, 3450, 9, 199, 3922, 275, 15934, 14, 16805, 8, 5545, 9, 199, 1258, 275, 4221, 1563, 3167, 14, 3041, 8, 3922, 9, 199, 199, 5545, 14, 1490, 342, 199, 199, 1224, 275, 298, 2694, 2, 199, 199, 524, 275, 377, 18989, 8, 1143, 628, 1143, 17, 401, 2763, 6550, 1524, 52, 4547, 1110, 8, 6606, 628, 6606, 17, 401, 27005, 628, 27005, 17, 401, 585, 628, 585, 17, 13403, 199, 1361, 298, 18989, 1337, 6783, 5324, 199, 1258, 14, 524, 8, 1224, 12, 5324, 9, 199, 199, 362, 275, 377, 1002, 8, 1143, 628, 1143, 17, 531, 199, 1361, 298, 28277, 6783, 664, 199, 1099, 275, 1890, 14, 362, 8, 1224, 12, 664, 9, 199, 199, 1361, 298, 2889, 6783, 754, 2043, 199, 5545, 14, 1600, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
guewen/OpenUpgrade
doc/conf.py
52
8573
# -*- coding: utf-8 -*- # # OpenERP Technical Documentation configuration file, created by # sphinx-quickstart on Fri Feb 17 16:14:06 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, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) sys.path.append(os.path.abspath('./_themes')) sys.path.append(os.path.abspath('..')) sys.path.append(os.path.abspath('../openerp')) # -- 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', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.viewcode', 'patchqueue'] # 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'OpenERP Server Developers Documentation' copyright = u'2012, OpenERP s.a.' # 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 = '7.0' # The full version, including alpha/beta/rc tags. release = '7.0b' # 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 --------------------------------------------------- import sphinx_bootstrap_theme # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'bootstrap' # 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 = sphinx_bootstrap_theme.get_html_theme_path() # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. html_sidebars = { 'index': ['sidebarintro.html', 'sourcelink.html', 'searchbox.html'], '**': ['sidebarlogo.html', 'localtoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html'] } # 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 = 'openerp-server-doc' # -- 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', 'openerp-server-doc.tex', u'OpenERP Server Developers Documentation', u'OpenERP s.a.', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'openerp-server-doc', u'OpenERP Server Developers Documentation', [u'OpenERP s.a.'], 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', 'OpenERPServerDocumentation', u'OpenERP Server Developers Documentation', u'OpenERP s.a.', 'OpenERPServerDocumentation', 'Developers documentation for the openobject-server 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' # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { 'python': ('http://docs.python.org/', None), }
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 7653, 5773, 28836, 15249, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 31712, 21141, 5557, 3193, 26, 1079, 26, 1690, 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, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 5175, 15607, 23900, 1333, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 24893, 1333, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 24592, 11267, 1333, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 1058, 8008, 297, 283, 8008, 14, 832, 14, 11396, 297, 283, 8008, 14, 832, 14, 1345, 600, 297, 283, 2068, 1825, 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, 25347, 7146, 23493, 15249, 7, 199, 7307, 275, 399, 7, 7409, 12, 7653, 308, 14, 65, 3530, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 23, 14, 16, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 23, 14, 16, 66, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 646, 15882, 63, 11146, 63, 7915, 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, 11146, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 1360, 63, 7915, 63, 515, 275, 15882, 63, 11146, 63, 7915, 14, 362, 63, 1360, 63, 7915, 63, 515, 342, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 7653, 5773, 28836, 15249, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 31712, 21141, 5557, 3193, 26, 1079, 26, 1690, 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, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 5175, 15607, 23900, 1333, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 24893, 1333, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 24592, 11267, 1333, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 1058, 8008, 297, 283, 8008, 14, 832, 14, 11396, 297, 283, 8008, 14, 832, 14, 1345, 600, 297, 283, 2068, 1825, 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, 25347, 7146, 23493, 15249, 7, 199, 7307, 275, 399, 7, 7409, 12, 7653, 308, 14, 65, 3530, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 23, 14, 16, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 23, 14, 16, 66, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 646, 15882, 63, 11146, 63, 7915, 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, 11146, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 1360, 63, 7915, 63, 515, 275, 15882, 63, 11146, 63, 7915, 14, 362, 63, 1360, 63, 7915, 63, 515, 342, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 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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 ]
madmouser1/beets
beets/plugins.py
11
16228
# -*- coding: utf-8 -*- # This file is part of beets. # Copyright 2016, Adrian Sampson. # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. """Support for beets plugins.""" from __future__ import division, absolute_import, print_function import inspect import traceback import re from collections import defaultdict from functools import wraps import beets from beets import logging from beets import mediafile import six PLUGIN_NAMESPACE = 'beetsplug' # Plugins using the Last.fm API can share the same API key. LASTFM_KEY = '2dc3914abf35f0d9c92d97d8f8e42b43' # Global logger. log = logging.getLogger('beets') class PluginConflictException(Exception): """Indicates that the services provided by one plugin conflict with those of another. For example two plugins may define different types for flexible fields. """ class PluginLogFilter(logging.Filter): """A logging filter that identifies the plugin that emitted a log message. """ def __init__(self, plugin): self.prefix = u'{0}: '.format(plugin.name) def filter(self, record): if hasattr(record.msg, 'msg') and isinstance(record.msg.msg, six.string_types): # A _LogMessage from our hacked-up Logging replacement. record.msg.msg = self.prefix + record.msg.msg elif isinstance(record.msg, six.string_types): record.msg = self.prefix + record.msg return True # Managing the plugins themselves. class BeetsPlugin(object): """The base class for all beets plugins. Plugins provide functionality by defining a subclass of BeetsPlugin and overriding the abstract methods defined here. """ def __init__(self, name=None): """Perform one-time plugin setup. """ self.name = name or self.__module__.split('.')[-1] self.config = beets.config[self.name] if not self.template_funcs: self.template_funcs = {} if not self.template_fields: self.template_fields = {} if not self.album_template_fields: self.album_template_fields = {} self.import_stages = [] self._log = log.getChild(self.name) self._log.setLevel(logging.NOTSET) # Use `beets` logger level. if not any(isinstance(f, PluginLogFilter) for f in self._log.filters): self._log.addFilter(PluginLogFilter(self)) def commands(self): """Should return a list of beets.ui.Subcommand objects for commands that should be added to beets' CLI. """ return () def get_import_stages(self): """Return a list of functions that should be called as importer pipelines stages. The callables are wrapped versions of the functions in `self.import_stages`. Wrapping provides some bookkeeping for the plugin: specifically, the logging level is adjusted to WARNING. """ return [self._set_log_level_and_params(logging.WARNING, import_stage) for import_stage in self.import_stages] def _set_log_level_and_params(self, base_log_level, func): """Wrap `func` to temporarily set this plugin's logger level to `base_log_level` + config options (and restore it to its previous value after the function returns). Also determines which params may not be sent for backwards-compatibility. """ argspec = inspect.getargspec(func) @wraps(func) def wrapper(*args, **kwargs): assert self._log.level == logging.NOTSET verbosity = beets.config['verbose'].get(int) log_level = max(logging.DEBUG, base_log_level - 10 * verbosity) self._log.setLevel(log_level) try: try: return func(*args, **kwargs) except TypeError as exc: if exc.args[0].startswith(func.__name__): # caused by 'func' and not stuff internal to 'func' kwargs = dict((arg, val) for arg, val in kwargs.items() if arg in argspec.args) return func(*args, **kwargs) else: raise finally: self._log.setLevel(logging.NOTSET) return wrapper def queries(self): """Should return a dict mapping prefixes to Query subclasses. """ return {} def track_distance(self, item, info): """Should return a Distance object to be added to the distance for every track comparison. """ return beets.autotag.hooks.Distance() def album_distance(self, items, album_info, mapping): """Should return a Distance object to be added to the distance for every album-level comparison. """ return beets.autotag.hooks.Distance() def candidates(self, items, artist, album, va_likely): """Should return a sequence of AlbumInfo objects that match the album whose items are provided. """ return () def item_candidates(self, item, artist, title): """Should return a sequence of TrackInfo objects that match the item provided. """ return () def album_for_id(self, album_id): """Return an AlbumInfo object or None if no matching release was found. """ return None def track_for_id(self, track_id): """Return a TrackInfo object or None if no matching release was found. """ return None def add_media_field(self, name, descriptor): """Add a field that is synchronized between media files and items. When a media field is added ``item.write()`` will set the name property of the item's MediaFile to ``item[name]`` and save the changes. Similarly ``item.read()`` will set ``item[name]`` to the value of the name property of the media file. ``descriptor`` must be an instance of ``mediafile.MediaField``. """ # Defer impor to prevent circular dependency from beets import library mediafile.MediaFile.add_field(name, descriptor) library.Item._media_fields.add(name) _raw_listeners = None listeners = None def register_listener(self, event, func): """Add a function as a listener for the specified event. """ wrapped_func = self._set_log_level_and_params(logging.WARNING, func) cls = self.__class__ if cls.listeners is None or cls._raw_listeners is None: cls._raw_listeners = defaultdict(list) cls.listeners = defaultdict(list) if func not in cls._raw_listeners[event]: cls._raw_listeners[event].append(func) cls.listeners[event].append(wrapped_func) template_funcs = None template_fields = None album_template_fields = None @classmethod def template_func(cls, name): """Decorator that registers a path template function. The function will be invoked as ``%name{}`` from path format strings. """ def helper(func): if cls.template_funcs is None: cls.template_funcs = {} cls.template_funcs[name] = func return func return helper @classmethod def template_field(cls, name): """Decorator that registers a path template field computation. The value will be referenced as ``$name`` from path format strings. The function must accept a single parameter, the Item being formatted. """ def helper(func): if cls.template_fields is None: cls.template_fields = {} cls.template_fields[name] = func return func return helper _classes = set() def load_plugins(names=()): """Imports the modules for a sequence of plugin names. Each name must be the name of a Python module under the "beetsplug" namespace package in sys.path; the module indicated should contain the BeetsPlugin subclasses desired. """ for name in names: modname = '{0}.{1}'.format(PLUGIN_NAMESPACE, name) try: try: namespace = __import__(modname, None, None) except ImportError as exc: # Again, this is hacky: if exc.args[0].endswith(' ' + name): log.warning(u'** plugin {0} not found', name) else: raise else: for obj in getattr(namespace, name).__dict__.values(): if isinstance(obj, type) and issubclass(obj, BeetsPlugin) \ and obj != BeetsPlugin and obj not in _classes: _classes.add(obj) except: log.warning( u'** error loading plugin {}:\n{}', name, traceback.format_exc(), ) _instances = {} def find_plugins(): """Returns a list of BeetsPlugin subclass instances from all currently loaded beets plugins. Loads the default plugin set first. """ load_plugins() plugins = [] for cls in _classes: # Only instantiate each plugin class once. if cls not in _instances: _instances[cls] = cls() plugins.append(_instances[cls]) return plugins # Communication with plugins. def commands(): """Returns a list of Subcommand objects from all loaded plugins. """ out = [] for plugin in find_plugins(): out += plugin.commands() return out def queries(): """Returns a dict mapping prefix strings to Query subclasses all loaded plugins. """ out = {} for plugin in find_plugins(): out.update(plugin.queries()) return out def types(model_cls): # Gives us `item_types` and `album_types` attr_name = '{0}_types'.format(model_cls.__name__.lower()) types = {} for plugin in find_plugins(): plugin_types = getattr(plugin, attr_name, {}) for field in plugin_types: if field in types and plugin_types[field] != types[field]: raise PluginConflictException( u'Plugin {0} defines flexible field {1} ' u'which has already been defined with ' u'another type.'.format(plugin.name, field) ) types.update(plugin_types) return types def track_distance(item, info): """Gets the track distance calculated by all loaded plugins. Returns a Distance object. """ from beets.autotag.hooks import Distance dist = Distance() for plugin in find_plugins(): dist.update(plugin.track_distance(item, info)) return dist def album_distance(items, album_info, mapping): """Returns the album distance calculated by plugins.""" from beets.autotag.hooks import Distance dist = Distance() for plugin in find_plugins(): dist.update(plugin.album_distance(items, album_info, mapping)) return dist def candidates(items, artist, album, va_likely): """Gets MusicBrainz candidates for an album from each plugin. """ for plugin in find_plugins(): for candidate in plugin.candidates(items, artist, album, va_likely): yield candidate def item_candidates(item, artist, title): """Gets MusicBrainz candidates for an item from the plugins. """ for plugin in find_plugins(): for item_candidate in plugin.item_candidates(item, artist, title): yield item_candidate def album_for_id(album_id): """Get AlbumInfo objects for a given ID string. """ for plugin in find_plugins(): album = plugin.album_for_id(album_id) if album: yield album def track_for_id(track_id): """Get TrackInfo objects for a given ID string. """ for plugin in find_plugins(): track = plugin.track_for_id(track_id) if track: yield track def template_funcs(): """Get all the template functions declared by plugins as a dictionary. """ funcs = {} for plugin in find_plugins(): if plugin.template_funcs: funcs.update(plugin.template_funcs) return funcs def import_stages(): """Get a list of import stage functions defined by plugins.""" stages = [] for plugin in find_plugins(): stages += plugin.get_import_stages() return stages # New-style (lazy) plugin-provided fields. def item_field_getters(): """Get a dictionary mapping field names to unary functions that compute the field's value. """ funcs = {} for plugin in find_plugins(): if plugin.template_fields: funcs.update(plugin.template_fields) return funcs def album_field_getters(): """As above, for album fields. """ funcs = {} for plugin in find_plugins(): if plugin.album_template_fields: funcs.update(plugin.album_template_fields) return funcs # Event dispatch. def event_handlers(): """Find all event handlers from plugins as a dictionary mapping event names to sequences of callables. """ all_handlers = defaultdict(list) for plugin in find_plugins(): if plugin.listeners: for event, handlers in plugin.listeners.items(): all_handlers[event] += handlers return all_handlers def send(event, **arguments): """Send an event to all assigned event listeners. `event` is the name of the event to send, all other named arguments are passed along to the handlers. Return a list of non-None values returned from the handlers. """ log.debug(u'Sending event: {0}', event) results = [] for handler in event_handlers()[event]: result = handler(**arguments) if result is not None: results.append(result) return results def feat_tokens(for_artist=True): """Return a regular expression that matches phrases like "featuring" that separate a main artist or a song title from secondary artists. The `for_artist` option determines whether the regex should be suitable for matching artist fields (the default) or title fields. """ feat_words = ['ft', 'featuring', 'feat', 'feat.', 'ft.'] if for_artist: feat_words += ['with', 'vs', 'and', 'con', '&'] return '(?<=\s)(?:{0})(?=\s)'.format( '|'.join(re.escape(x) for x in feat_words) ) def sanitize_choices(choices, choices_all): """Clean up a stringlist configuration attribute: keep only choices elements present in choices_all, remove duplicate elements, expand '*' wildcard while keeping original stringlist order. """ seen = set() others = [x for x in choices_all if x not in choices] res = [] for s in choices: if s in list(choices_all) + ['*']: if not (s in seen or seen.add(s)): res.extend(list(others) if s == '*' else [s]) return res def notify_info_yielded(event): """Makes a generator send the event 'event' every time it yields. This decorator is supposed to decorate a generator, but any function returning an iterable should work. Each yielded value is passed to plugins using the 'info' parameter of 'send'. """ def decorator(generator): def decorated(*args, **kwargs): for v in generator(*args, **kwargs): send(event, info=v) yield v return decorated return decorator
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 506, 8716, 14, 199, 3, 1898, 7800, 12, 4431, 18429, 428, 5282, 834, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 199, 3, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 624, 11532, 367, 506, 8716, 8963, 1041, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 6485, 199, 646, 5190, 199, 646, 295, 199, 504, 5055, 492, 10018, 199, 504, 9143, 492, 14018, 421, 199, 646, 506, 8716, 199, 504, 506, 8716, 492, 2050, 199, 504, 506, 8716, 492, 5898, 493, 199, 646, 3816, 199, 199, 19108, 63, 13001, 275, 283, 1235, 386, 15276, 1518, 7, 199, 199, 3, 30317, 1808, 314, 15237, 14, 10886, 3261, 883, 8663, 314, 2011, 3261, 790, 14, 199, 16901, 22367, 63, 3078, 275, 283, 18, 3833, 1355, 1079, 32706, 1276, 70, 16, 68, 25, 67, 2942, 68, 2576, 68, 24, 70, 24, 69, 2260, 66, 2824, 7, 199, 199, 3, 13641, 2512, 14, 199, 793, 275, 2050, 14, 5572, 360, 1235, 8716, 358, 421, 199, 533, 11349, 15919, 1726, 8, 1726, 304, 272, 408, 607, 16292, 626, 314, 8500, 2741, 701, 1373, 3589, 12395, 543, 272, 5204, 402, 4573, 14, 339, 2104, 2893, 2877, 8963, 1443, 5627, 3365, 2943, 367, 26841, 1504, 14, 272, 408, 421, 199, 533, 11349, 2445, 4131, 8, 4806, 14, 4131, 304, 272, 408, 33, 2050, 2457, 626, 22975, 314, 3589, 626, 19515, 282, 943, 272, 1245, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3589, 304, 267, 291, 14, 1861, 275, 399, 16019, 16, 9160, 1987, 908, 8, 2718, 14, 354, 9, 339, 347, 2457, 8, 277, 12, 2777, 304, 267, 340, 2688, 8, 3059, 14, 1328, 12, 283, 1328, 358, 436, 1228, 8, 3059, 14, 1328, 14, 1328, 12, 9349, 3816, 14, 875, 63, 1313, 304, 288, 327, 437, 485, 2445, 2209, 687, 4154, 11176, 379, 13, 384, 19928, 8343, 14, 288, 2777, 14, 1328, 14, 1328, 275, 291, 14, 1861, 435, 2777, 14, 1328, 14, 1328, 267, 916, 1228, 8, 3059, 14, 1328, 12, 3816, 14, 875, 63, 1313, 304, 288, 2777, 14, 1328, 275, 291, 14, 1861, 435, 2777, 14, 1328, 267, 372, 715, 421, 199, 3, 4688, 7407, 314, 8963, 17279, 14, 199, 199, 533, 6423, 8716, 5061, 8, 785, 304, 272, 408, 1918, 1300, 1021, 367, 1006, 506, 8716, 8963, 14, 30317, 5647, 272, 9330, 701, 12669, 282, 5516, 402, 6423, 8716, 5061, 436, 18972, 272, 314, 9006, 3102, 3247, 2348, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536, 29, 403, 304, 267, 408, 20906, 1373, 13, 521, 3589, 3272, 14, 267, 408, 267, 291, 14, 354, 275, 536, 503, 291, 855, 578, 4343, 1294, 29084, 17, 61, 267, 291, 14, 888, 275, 506, 8716, 14, 888, 59, 277, 14, 354, 61, 267, 340, 440, 291, 14, 1160, 63, 9204, 26, 288, 291, 14, 1160, 63, 9204, 275, 1052, 267, 340, 440, 291, 14, 1160, 63, 955, 26, 288, 291, 14, 1160, 63, 955, 275, 1052, 267, 340, 440, 291, 14, 12110, 63, 1160, 63, 955, 26, 288, 291, 14, 12110, 63, 1160, 63, 955, 275, 1052, 267, 291, 14, 646, 63, 30646, 275, 942, 398, 291, 423, 793, 275, 943, 14, 26023, 8, 277, 14, 354, 9, 267, 291, 423, 793, 14, 13548, 8, 4806, 14, 4609, 3597, 9, 221, 327, 3645, 658, 1235, 8716, 64, 2512, 2166, 14, 267, 340, 440, 1263, 8, 6074, 8, 70, 12, 11349, 2445, 4131, 9, 367, 289, 315, 291, 423, 793, 14, 4273, 304, 288, 291, 423, 793, 14, 525, 4131, 8, 5061, 2445, 4131, 8, 277, 430, 339, 347, 3718, 8, 277, 304, 267, 408, 11408, 372, 282, 769, 402, 506, 8716, 14, 1907, 14, 2610, 1531, 2251, 367, 267, 3718, 626, 1077, 506, 3483, 370, 506, 8716, 7, 14214, 14, 267, 408, 267, 372, 6248, 339, 347, 664, 63, 646, 63, 30646, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 3423, 626, 1077, 506, 2797, 465, 13479, 267, 5200, 1278, 24490, 14, 398, 710, 28041, 787, 8072, 5459, 402, 314, 3423, 315, 267, 658, 277, 14, 646, 63, 30646, 2313, 644, 15521, 6571, 2005, 6719, 3250, 316, 367, 314, 267, 3589, 26, 22543, 12, 314, 2050, 2166, 365, 19477, 370, 14750, 14, 267, 408, 267, 372, 359, 277, 423, 409, 63, 793, 63, 1896, 63, 460, 63, 1162, 8, 4806, 14, 9171, 12, 492, 63, 8614, 9, 355, 367, 492, 63, 8614, 315, 291, 14, 646, 63, 30646, 61, 339, 347, 485, 409, 63, 793, 63, 1896, 63, 460, 63, 1162, 8, 277, 12, 1300, 63, 793, 63, 1896, 12, 2562, 304, 267, 408, 15991, 658, 1532, 64, 370, 22256, 663, 642, 3589, 1159, 2512, 2166, 370, 267, 658, 1095, 63, 793, 63, 1896, 64, 435, 1101, 1511, 334, 460, 9066, 652, 370, 2399, 4136, 267, 574, 2410, 314, 805, 2529, 680, 6121, 16756, 1314, 1862, 1443, 440, 267, 506, 4847, 367, 8552, 13, 15390, 14, 267, 408, 267, 26632, 275, 6485, 14, 29836, 8, 1532, 9, 398, 768, 13582, 8, 1532, 9, 267, 347, 4975, 2031, 589, 12, 1011, 958, 304, 288, 702, 291, 423, 793, 14, 1896, 508, 2050, 14, 4609, 3597, 288, 8661, 275, 506, 8716, 14, 888, 459, 3832, 2278, 362, 8, 442, 9, 288, 943, 63, 1896, 275, 1390, 8, 4806, 14, 5287, 12, 1300, 63, 793, 63, 1896, 446, 1616, 627, 8661, 9, 288, 291, 423, 793, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 506, 8716, 14, 199, 3, 1898, 7800, 12, 4431, 18429, 428, 5282, 834, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 199, 3, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 624, 11532, 367, 506, 8716, 8963, 1041, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 6485, 199, 646, 5190, 199, 646, 295, 199, 504, 5055, 492, 10018, 199, 504, 9143, 492, 14018, 421, 199, 646, 506, 8716, 199, 504, 506, 8716, 492, 2050, 199, 504, 506, 8716, 492, 5898, 493, 199, 646, 3816, 199, 199, 19108, 63, 13001, 275, 283, 1235, 386, 15276, 1518, 7, 199, 199, 3, 30317, 1808, 314, 15237, 14, 10886, 3261, 883, 8663, 314, 2011, 3261, 790, 14, 199, 16901, 22367, 63, 3078, 275, 283, 18, 3833, 1355, 1079, 32706, 1276, 70, 16, 68, 25, 67, 2942, 68, 2576, 68, 24, 70, 24, 69, 2260, 66, 2824, 7, 199, 199, 3, 13641, 2512, 14, 199, 793, 275, 2050, 14, 5572, 360, 1235, 8716, 358, 421, 199, 533, 11349, 15919, 1726, 8, 1726, 304, 272, 408, 607, 16292, 626, 314, 8500, 2741, 701, 1373, 3589, 12395, 543, 272, 5204, 402, 4573, 14, 339, 2104, 2893, 2877, 8963, 1443, 5627, 3365, 2943, 367, 26841, 1504, 14, 272, 408, 421, 199, 533, 11349, 2445, 4131, 8, 4806, 14, 4131, 304, 272, 408, 33, 2050, 2457, 626, 22975, 314, 3589, 626, 19515, 282, 943, 272, 1245, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3589, 304, 267, 291, 14, 1861, 275, 399, 16019, 16, 9160, 1987, 908, 8, 2718, 14, 354, 9, 339, 347, 2457, 8, 277, 12, 2777, 304, 267, 340, 2688, 8, 3059, 14, 1328, 12, 283, 1328, 358, 436, 1228, 8, 3059, 14, 1328, 14, 1328, 12, 9349, 3816, 14, 875, 63, 1313, 304, 288, 327, 437, 485, 2445, 2209, 687, 4154, 11176, 379, 13, 384, 19928, 8343, 14, 288, 2777, 14, 1328, 14, 1328, 275, 291, 14, 1861, 435, 2777, 14, 1328, 14, 1328, 267, 916, 1228, 8, 3059, 14, 1328, 12, 3816, 14, 875, 63, 1313, 304, 288, 2777, 14, 1328, 275, 291, 14, 1861, 435, 2777, 14, 1328, 267, 372, 715, 421, 199, 3, 4688, 7407, 314, 8963, 17279, 14, 199, 199, 533, 6423, 8716, 5061, 8, 785, 304, 272, 408, 1918, 1300, 1021, 367, 1006, 506, 8716, 8963, 14, 30317, 5647, 272, 9330, 701, 12669, 282, 5516, 402, 6423, 8716, 5061, 436, 18972, 272, 314, 9006, 3102, 3247, 2348, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536, 29, 403, 304, 267, 408, 20906, 1373, 13, 521, 3589, 3272, 14, 267, 408, 267, 291, 14, 354, 275, 536, 503, 291, 855, 578, 4343, 1294, 29084, 17, 61, 267, 291, 14, 888, 275, 506, 8716, 14, 888, 59, 277, 14, 354, 61, 267, 340, 440, 291, 14, 1160, 63, 9204, 26, 288, 291, 14, 1160, 63, 9204, 275, 1052, 267, 340, 440, 291, 14, 1160, 63, 955, 26, 288, 291, 14, 1160, 63, 955, 275, 1052, 267, 340, 440, 291, 14, 12110, 63, 1160, 63, 955, 26, 288, 291, 14, 12110, 63, 1160, 63, 955, 275, 1052, 267, 291, 14, 646, 63, 30646, 275, 942, 398, 291, 423, 793, 275, 943, 14, 26023, 8, 277, 14, 354, 9, 267, 291, 423, 793, 14, 13548, 8, 4806, 14, 4609, 3597, 9, 221, 327, 3645, 658, 1235, 8716, 64, 2512, 2166, 14, 267, 340, 440, 1263, 8, 6074, 8, 70, 12, 11349, 2445, 4131, 9, 367, 289, 315, 291, 423, 793, 14, 4273, 304, 288, 291, 423, 793, 14, 525, 4131, 8, 5061, 2445, 4131, 8, 277, 430, 339, 347, 3718, 8, 277, 304, 267, 408, 11408, 372, 282, 769, 402, 506, 8716, 14, 1907, 14, 2610, 1531, 2251, 367, 267, 3718, 626, 1077, 506, 3483, 370, 506, 8716, 7, 14214, 14, 267, 408, 267, 372, 6248, 339, 347, 664, 63, 646, 63, 30646, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 3423, 626, 1077, 506, 2797, 465, 13479, 267, 5200, 1278, 24490, 14, 398, 710, 28041, 787, 8072, 5459, 402, 314, 3423, 315, 267, 658, 277, 14, 646, 63, 30646, 2313, 644, 15521, 6571, 2005, 6719, 3250, 316, 367, 314, 267, 3589, 26, 22543, 12, 314, 2050, 2166, 365, 19477, 370, 14750, 14, 267, 408, 267, 372, 359, 277, 423, 409, 63, 793, 63, 1896, 63, 460, 63, 1162, 8, 4806, 14, 9171, 12, 492, 63, 8614, 9, 355, 367, 492, 63, 8614, 315, 291, 14, 646, 63, 30646, 61, 339, 347, 485, 409, 63, 793, 63, 1896, 63, 460, 63, 1162, 8, 277, 12, 1300, 63, 793, 63, 1896, 12, 2562, 304, 267, 408, 15991, 658, 1532, 64, 370, 22256, 663, 642, 3589, 1159, 2512, 2166, 370, 267, 658, 1095, 63, 793, 63, 1896, 64, 435, 1101, 1511, 334, 460, 9066, 652, 370, 2399, 4136, 267, 574, 2410, 314, 805, 2529, 680, 6121, 16756, 1314, 1862, 1443, 440, 267, 506, 4847, 367, 8552, 13, 15390, 14, 267, 408, 267, 26632, 275, 6485, 14, 29836, 8, 1532, 9, 398, 768, 13582, 8, 1532, 9, 267, 347, 4975, 2031, 589, 12, 1011, 958, 304, 288, 702, 291, 423, 793, 14, 1896, 508, 2050, 14, 4609, 3597, 288, 8661, 275, 506, 8716, 14, 888, 459, 3832, 2278, 362, 8, 442, 9, 288, 943, 63, 1896, 275, 1390, 8, 4806, 14, 5287, 12, 1300, 63, 793, 63, 1896, 446, 1616, 627, 8661, 9, 288, 291, 423, 793, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
plotly/python-api
packages/python/plotly/plotly/validators/barpolar/marker/colorbar/title/_font.py
2
1543
import _plotly_utils.basevalidators class FontValidator(_plotly_utils.basevalidators.CompoundValidator): def __init__( self, plotly_name="font", parent_name="barpolar.marker.colorbar.title", **kwargs ): super(FontValidator, self).__init__( plotly_name=plotly_name, parent_name=parent_name, data_class_str=kwargs.pop("data_class_str", "Font"), data_docs=kwargs.pop( "data_docs", """ color family HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size """, ), **kwargs )
mit
[ 646, 485, 2798, 590, 63, 1208, 14, 1095, 11346, 421, 199, 533, 26159, 8640, 1547, 2798, 590, 63, 1208, 14, 1095, 11346, 14, 26552, 8640, 304, 272, 347, 636, 826, 721, 267, 291, 12, 5137, 590, 63, 354, 628, 4246, 401, 1676, 63, 354, 628, 1700, 19830, 14, 4211, 14, 30995, 14, 1213, 401, 1011, 958, 272, 3461, 267, 1613, 8, 6986, 8640, 12, 291, 2843, 826, 721, 288, 5137, 590, 63, 354, 29, 2798, 590, 63, 354, 12, 288, 1676, 63, 354, 29, 1708, 63, 354, 12, 288, 666, 63, 533, 63, 495, 29, 958, 14, 1935, 480, 576, 63, 533, 63, 495, 401, 298, 6986, 1288, 288, 666, 63, 4757, 29, 958, 14, 1935, 8, 355, 298, 576, 63, 4757, 401, 355, 408, 288, 3164, 953, 9614, 355, 4163, 5023, 9614, 446, 314, 730, 1409, 626, 911, 506, 355, 6781, 701, 314, 3330, 7042, 14, 710, 3330, 7042, 355, 911, 1454, 506, 7688, 370, 4838, 282, 5023, 340, 652, 365, 355, 2808, 641, 314, 2656, 1314, 652, 1758, 2335, 14, 355, 22896, 3663, 5023, 21450, 20111, 12, 11673, 701, 355, 24476, 12, 370, 6623, 314, 16705, 315, 1314, 370, 355, 4838, 26219, 340, 2985, 10621, 1133, 2808, 641, 314, 355, 2656, 14, 710, 24874, 13225, 8142, 334, 292, 355, 4178, 921, 9019, 13, 19806, 14, 2798, 590, 14, 957, 503, 641, 13, 657, 77, 572, 9, 355, 12821, 5935, 641, 282, 1654, 12, 2382, 1454, 282, 355, 3504, 1329, 402, 26219, 787, 4903, 436, 355, 3748, 14, 5723, 2387, 298, 33, 1383, 401, 298, 13129, 475, 401, 355, 298, 35, 567, 4446, 7053, 401, 298, 36, 3977, 428, 796, 401, 12, 298, 36, 3977, 3739, 692, 401, 355, 298, 36, 3977, 428, 796, 10953, 79, 401, 298, 5761, 86, 390, 305, 7309, 401, 298, 16411, 355, 9739, 377, 52, 401, 298, 4299, 428, 796, 401, 298, 5674, 1529, 401, 298, 4189, 428, 796, 355, 653, 7691, 401, 298, 1537, 274, 3316, 401, 298, 17687, 7053, 820, 21604, 1674, 288, 1568, 199, 199, 7208, 288, 2318, 288, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 485, 2798, 590, 63, 1208, 14, 1095, 11346, 421, 199, 533, 26159, 8640, 1547, 2798, 590, 63, 1208, 14, 1095, 11346, 14, 26552, 8640, 304, 272, 347, 636, 826, 721, 267, 291, 12, 5137, 590, 63, 354, 628, 4246, 401, 1676, 63, 354, 628, 1700, 19830, 14, 4211, 14, 30995, 14, 1213, 401, 1011, 958, 272, 3461, 267, 1613, 8, 6986, 8640, 12, 291, 2843, 826, 721, 288, 5137, 590, 63, 354, 29, 2798, 590, 63, 354, 12, 288, 1676, 63, 354, 29, 1708, 63, 354, 12, 288, 666, 63, 533, 63, 495, 29, 958, 14, 1935, 480, 576, 63, 533, 63, 495, 401, 298, 6986, 1288, 288, 666, 63, 4757, 29, 958, 14, 1935, 8, 355, 298, 576, 63, 4757, 401, 355, 408, 288, 3164, 953, 9614, 355, 4163, 5023, 9614, 446, 314, 730, 1409, 626, 911, 506, 355, 6781, 701, 314, 3330, 7042, 14, 710, 3330, 7042, 355, 911, 1454, 506, 7688, 370, 4838, 282, 5023, 340, 652, 365, 355, 2808, 641, 314, 2656, 1314, 652, 1758, 2335, 14, 355, 22896, 3663, 5023, 21450, 20111, 12, 11673, 701, 355, 24476, 12, 370, 6623, 314, 16705, 315, 1314, 370, 355, 4838, 26219, 340, 2985, 10621, 1133, 2808, 641, 314, 355, 2656, 14, 710, 24874, 13225, 8142, 334, 292, 355, 4178, 921, 9019, 13, 19806, 14, 2798, 590, 14, 957, 503, 641, 13, 657, 77, 572, 9, 355, 12821, 5935, 641, 282, 1654, 12, 2382, 1454, 282, 355, 3504, 1329, 402, 26219, 787, 4903, 436, 355, 3748, 14, 5723, 2387, 298, 33, 1383, 401, 298, 13129, 475, 401, 355, 298, 35, 567, 4446, 7053, 401, 298, 36, 3977, 428, 796, 401, 12, 298, 36, 3977, 3739, 692, 401, 355, 298, 36, 3977, 428, 796, 10953, 79, 401, 298, 5761, 86, 390, 305, 7309, 401, 298, 16411, 355, 9739, 377, 52, 401, 298, 4299, 428, 796, 401, 298, 5674, 1529, 401, 298, 4189, 428, 796, 355, 653, 7691, 401, 298, 1537, 274, 3316, 401, 298, 17687, 7053, 820, 21604, 1674, 288, 1568, 199, 199, 7208, 288, 2318, 288, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
WoLpH/CouchPotatoServer
libs/bs4/builder/_html5lib.py
119
7746
__all__ = [ 'HTML5TreeBuilder', ] import warnings from bs4.builder import ( PERMISSIVE, HTML, HTML_5, HTMLTreeBuilder, ) from bs4.element import NamespacedAttribute import html5lib from html5lib.constants import namespaces from bs4.element import ( Comment, Doctype, NavigableString, Tag, ) class HTML5TreeBuilder(HTMLTreeBuilder): """Use html5lib to build a tree.""" features = ['html5lib', PERMISSIVE, HTML_5, HTML] def prepare_markup(self, markup, user_specified_encoding): # Store the user-specified encoding for use later on. self.user_specified_encoding = user_specified_encoding return markup, None, None, False # These methods are defined by Beautiful Soup. def feed(self, markup): if self.soup.parse_only is not None: warnings.warn("You provided a value for parse_only, but the html5lib tree builder doesn't support parse_only. The entire document will be parsed.") parser = html5lib.HTMLParser(tree=self.create_treebuilder) doc = parser.parse(markup, encoding=self.user_specified_encoding) # Set the character encoding detected by the tokenizer. if isinstance(markup, unicode): # We need to special-case this because html5lib sets # charEncoding to UTF-8 if it gets Unicode input. doc.original_encoding = None else: doc.original_encoding = parser.tokenizer.stream.charEncoding[0] def create_treebuilder(self, namespaceHTMLElements): self.underlying_builder = TreeBuilderForHtml5lib( self.soup, namespaceHTMLElements) return self.underlying_builder def test_fragment_to_document(self, fragment): """See `TreeBuilder`.""" return u'<html><head></head><body>%s</body></html>' % fragment class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder): def __init__(self, soup, namespaceHTMLElements): self.soup = soup super(TreeBuilderForHtml5lib, self).__init__(namespaceHTMLElements) def documentClass(self): self.soup.reset() return Element(self.soup, self.soup, None) def insertDoctype(self, token): name = token["name"] publicId = token["publicId"] systemId = token["systemId"] doctype = Doctype.for_name_and_ids(name, publicId, systemId) self.soup.object_was_parsed(doctype) def elementClass(self, name, namespace): tag = self.soup.new_tag(name, namespace) return Element(tag, self.soup, namespace) def commentClass(self, data): return TextNode(Comment(data), self.soup) def fragmentClass(self): self.soup = BeautifulSoup("") self.soup.name = "[document_fragment]" return Element(self.soup, self.soup, None) def appendChild(self, node): # XXX This code is not covered by the BS4 tests. self.soup.append(node.element) def getDocument(self): return self.soup def getFragment(self): return html5lib.treebuilders._base.TreeBuilder.getFragment(self).element class AttrList(object): def __init__(self, element): self.element = element self.attrs = dict(self.element.attrs) def __iter__(self): return list(self.attrs.items()).__iter__() def __setitem__(self, name, value): "set attr", name, value self.element[name] = value def items(self): return list(self.attrs.items()) def keys(self): return list(self.attrs.keys()) def __len__(self): return len(self.attrs) def __getitem__(self, name): return self.attrs[name] def __contains__(self, name): return name in list(self.attrs.keys()) class Element(html5lib.treebuilders._base.Node): def __init__(self, element, soup, namespace): html5lib.treebuilders._base.Node.__init__(self, element.name) self.element = element self.soup = soup self.namespace = namespace def appendChild(self, node): if (node.element.__class__ == NavigableString and self.element.contents and self.element.contents[-1].__class__ == NavigableString): # Concatenate new text onto old text node # XXX This has O(n^2) performance, for input like # "a</a>a</a>a</a>..." old_element = self.element.contents[-1] new_element = self.soup.new_string(old_element + node.element) old_element.replace_with(new_element) else: self.element.append(node.element) node.parent = self def getAttributes(self): return AttrList(self.element) def setAttributes(self, attributes): if attributes is not None and len(attributes) > 0: converted_attributes = [] for name, value in list(attributes.items()): if isinstance(name, tuple): new_name = NamespacedAttribute(*name) del attributes[name] attributes[new_name] = value self.soup.builder._replace_cdata_list_attribute_values( self.name, attributes) for name, value in attributes.items(): self.element[name] = value # The attributes may contain variables that need substitution. # Call set_up_substitutions manually. # # The Tag constructor called this method when the Tag was created, # but we just set/changed the attributes, so call it again. self.soup.builder.set_up_substitutions(self.element) attributes = property(getAttributes, setAttributes) def insertText(self, data, insertBefore=None): text = TextNode(self.soup.new_string(data), self.soup) if insertBefore: self.insertBefore(text, insertBefore) else: self.appendChild(text) def insertBefore(self, node, refNode): index = self.element.index(refNode.element) if (node.element.__class__ == NavigableString and self.element.contents and self.element.contents[index-1].__class__ == NavigableString): # (See comments in appendChild) old_node = self.element.contents[index-1] new_str = self.soup.new_string(old_node + node.element) old_node.replace_with(new_str) else: self.element.insert(index, node.element) node.parent = self def removeChild(self, node): node.element.extract() def reparentChildren(self, newParent): while self.element.contents: child = self.element.contents[0] child.extract() if isinstance(child, Tag): newParent.appendChild( Element(child, self.soup, namespaces["html"])) else: newParent.appendChild( TextNode(child, self.soup)) def cloneNode(self): tag = self.soup.new_tag(self.element.name, self.namespace) node = Element(tag, self.soup, self.namespace) for key,value in self.attributes: node.attributes[key] = value return node def hasContent(self): return self.element.contents def getNameTuple(self): if self.namespace == None: return namespaces["html"], self.name else: return self.namespace, self.name nameTuple = property(getNameTuple) class TextNode(Element): def __init__(self, element, soup): html5lib.treebuilders._base.Node.__init__(self, None) self.element = element self.soup = soup def cloneNode(self): raise NotImplementedError
gpl-3.0
[ 363, 452, 363, 275, 359, 272, 283, 4943, 21, 20437, 297, 272, 1622, 199, 199, 646, 3598, 199, 504, 9922, 20, 14, 5649, 492, 334, 272, 13873, 9674, 2684, 2524, 12, 272, 4163, 12, 272, 4163, 63, 21, 12, 272, 4163, 20437, 12, 272, 776, 199, 504, 9922, 20, 14, 2108, 492, 19317, 68, 1646, 199, 646, 3517, 21, 773, 199, 504, 3517, 21, 773, 14, 5559, 492, 10747, 199, 504, 9922, 20, 14, 2108, 492, 334, 272, 6819, 12, 272, 4226, 3667, 12, 272, 20721, 16725, 1558, 12, 272, 8053, 12, 272, 776, 199, 199, 533, 4163, 21, 20437, 8, 4943, 20437, 304, 272, 408, 6119, 3517, 21, 773, 370, 1900, 282, 3123, 1041, 339, 4534, 275, 788, 1360, 21, 773, 297, 13873, 9674, 2684, 2524, 12, 4163, 63, 21, 12, 4163, 61, 339, 347, 9275, 63, 10131, 8, 277, 12, 9189, 12, 922, 63, 10085, 63, 2991, 304, 267, 327, 13874, 314, 922, 13, 10085, 2644, 367, 675, 2945, 641, 14, 267, 291, 14, 751, 63, 10085, 63, 2991, 275, 922, 63, 10085, 63, 2991, 267, 372, 9189, 12, 488, 12, 488, 12, 756, 339, 327, 5723, 3102, 787, 3247, 701, 14562, 28028, 14, 272, 347, 4733, 8, 277, 12, 9189, 304, 267, 340, 291, 14, 9317, 14, 1122, 63, 2118, 365, 440, 488, 26, 288, 3598, 14, 4050, 480, 5556, 2741, 282, 574, 367, 2198, 63, 2118, 12, 1325, 314, 3517, 21, 773, 3123, 6545, 3181, 1133, 2291, 2198, 63, 2118, 14, 710, 8039, 2213, 911, 506, 4565, 2685, 267, 1798, 275, 3517, 21, 773, 14, 27375, 8, 2350, 29, 277, 14, 981, 63, 2350, 5649, 9, 267, 1382, 275, 1798, 14, 1122, 8, 10131, 12, 2644, 29, 277, 14, 751, 63, 10085, 63, 2991, 9, 398, 327, 2494, 314, 4528, 2644, 10501, 701, 314, 14803, 14, 267, 340, 1228, 8, 10131, 12, 2649, 304, 288, 327, 2136, 1929, 370, 4539, 13, 2546, 642, 2952, 3517, 21, 773, 5951, 288, 327, 1495, 7630, 370, 9094, 13, 24, 340, 652, 7545, 6140, 1324, 14, 288, 1382, 14, 5043, 63, 2991, 275, 488, 267, 587, 26, 288, 1382, 14, 5043, 63, 2991, 275, 1798, 14, 13771, 14, 1745, 14, 1560, 7630, 59, 16, 61, 339, 347, 1218, 63, 2350, 5649, 8, 277, 12, 3231, 31428, 20446, 304, 267, 291, 14, 7138, 6670, 63, 5649, 275, 12178, 6437, 1858, 12957, 21, 773, 8, 288, 291, 14, 9317, 12, 3231, 31428, 20446, 9, 267, 372, 291, 14, 7138, 6670, 63, 5649, 339, 347, 511, 63, 7677, 63, 475, 63, 3554, 8, 277, 12, 7956, 304, 267, 408, 9295, 658, 20437, 17105, 267, 372, 399, 7601, 1360, 2535, 2993, 2957, 2993, 2535, 2030, 6598, 83, 1108, 2030, 2957, 1360, 3524, 450, 7956, 421, 199, 533, 12178, 6437, 1858, 12957, 21, 773, 8, 1360, 21, 773, 14, 2350, 20968, 423, 1095, 14, 20437, 304, 339, 347, 636, 826, 721, 277, 12, 9108, 12, 3231, 31428, 20446, 304, 267, 291, 14, 9317, 275, 9108, 267, 1613, 8, 20437, 1858, 12957, 21, 773, 12, 291, 2843, 826, 721, 3251, 31428, 20446, 9, 339, 347, 2213, 2543, 8, 277, 304, 267, 291, 14, 9317, 14, 3958, 342, 267, 372, 6566, 8, 277, 14, 9317, 12, 291, 14, 9317, 12, 488, 9, 339, 347, 5518, 21629, 8, 277, 12, 1526, 304, 267, 536, 275, 1526, 905, 354, 937, 267, 25753, 275, 1526, 905, 25311, 937, 267, 22873, 275, 1526, 905, 20150, 937, 398, 13265, 275, 4226, 3667, 14, 509, 63, 354, 63, 460, 63, 1580, 8, 354, 12, 25753, 12, 22873, 9, 267, 291, 14, 9317, 14, 785, 63, 10274, 63, 6751, 8, 6356, 9, 339, 347, 1819, 2543, 8, 277, 12, 536, 12, 3231, 304, 267, 1947, 275, 291, 14, 9317, 14, 1222, 63, 1450, 8, 354, 12, 3231, 9, 267, 372, 6566, 8, 1450, 12, 291, 14, 9317, 12, 3231, 9, 339, 347, 3721, 2543, 8, 277, 12, 666, 304, 267, 372, 4516, 1716, 8, 7488, 8, 576, 395, 291, 14, 9317, 9, 339, 347, 7956, 2543, 8, 277, 304, 267, 291, 14, 9317, 275, 17132, 10804, 267, 291, 14, 9317, 14, 354, 275, 7369, 3554, 63, 7677, 8480, 267, 372, 6566, 8, 277, 14, 9317, 12, 291, 14, 9317, 12, 488, 9, 339, 347, 5666, 3493, 8, 277, 12, 1031, 304, 267, 327, 5787, 961, 1233, 365, 440, 24295, 701, 314, 699, 51, 20, 2295, 14, 267, 291, 14, 9317, 14, 740, 8, 932, 14, 2108, 9, 339, 347, 664, 5564, 8, 277, 304, 267, 372, 291, 14, 9317, 339, 347, 664, 11080, 8, 277, 304, 267, 372, 3517, 21, 773, 14, 2350, 20968, 423, 1095, 14, 20437, 14, 362, 11080, 8, 277, 680, 2108, 199, 199, 533, 20516, 1296, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1819, 304, 267, 291, 14, 2108, 275, 1819, 267, 291, 14, 3288, 275, 1211, 8, 277, 14, 2108, 14, 3288, 9, 272, 347, 636, 1661, 721, 277, 304, 267, 372, 769, 8, 277, 14, 3288, 14, 1744, 342, 2843, 1661, 4533, 272, 347, 636, 8617, 721, 277, 12, 536, 12, 574, 304, 267, 298, 409, 1921, 401, 536, 12, 574, 267, 291, 14, 2108, 59, 354, 61, 275, 574, 272, 347, 2974, 8, 277, 304, 267, 372, 769, 8, 277, 14, 3288, 14, 1744, 1012, 272, 347, 2883, 8, 277, 304, 267, 372, 769, 8, 277, 14, 3288, 14, 1612, 1012, 272, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 14, 3288, 9, 272, 347, 636, 6095, 721, 277, 12, 536, 304, 267, 372, 291, 14, 3288, 59, 354, 61, 272, 347, 636, 6134, 721, 277, 12, 536, 304, 267, 372, 536, 315, 769, 8, 277, 14, 3288, 14, 1612, 1012, 421, 199, 533, 6566, 8, 1360, 21, 773, 14, 2350, 20968, 423, 1095, 14, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 1819, 12, 9108, 12, 3231, 304, 267, 3517, 21, 773, 14, 2350, 20968, 423, 1095, 14, 1716, 855, 826, 721, 277, 12, 1819, 14, 354, 9, 267, 291, 14, 2108, 275, 1819, 267, 291, 14, 9317, 275, 9108, 267, 291, 14, 3251, 275, 3231, 339, 347, 5666, 3493, 8, 277, 12, 1031, 304, 267, 340, 334, 932, 14, 2108, 855, 533 ]
[ 452, 363, 275, 359, 272, 283, 4943, 21, 20437, 297, 272, 1622, 199, 199, 646, 3598, 199, 504, 9922, 20, 14, 5649, 492, 334, 272, 13873, 9674, 2684, 2524, 12, 272, 4163, 12, 272, 4163, 63, 21, 12, 272, 4163, 20437, 12, 272, 776, 199, 504, 9922, 20, 14, 2108, 492, 19317, 68, 1646, 199, 646, 3517, 21, 773, 199, 504, 3517, 21, 773, 14, 5559, 492, 10747, 199, 504, 9922, 20, 14, 2108, 492, 334, 272, 6819, 12, 272, 4226, 3667, 12, 272, 20721, 16725, 1558, 12, 272, 8053, 12, 272, 776, 199, 199, 533, 4163, 21, 20437, 8, 4943, 20437, 304, 272, 408, 6119, 3517, 21, 773, 370, 1900, 282, 3123, 1041, 339, 4534, 275, 788, 1360, 21, 773, 297, 13873, 9674, 2684, 2524, 12, 4163, 63, 21, 12, 4163, 61, 339, 347, 9275, 63, 10131, 8, 277, 12, 9189, 12, 922, 63, 10085, 63, 2991, 304, 267, 327, 13874, 314, 922, 13, 10085, 2644, 367, 675, 2945, 641, 14, 267, 291, 14, 751, 63, 10085, 63, 2991, 275, 922, 63, 10085, 63, 2991, 267, 372, 9189, 12, 488, 12, 488, 12, 756, 339, 327, 5723, 3102, 787, 3247, 701, 14562, 28028, 14, 272, 347, 4733, 8, 277, 12, 9189, 304, 267, 340, 291, 14, 9317, 14, 1122, 63, 2118, 365, 440, 488, 26, 288, 3598, 14, 4050, 480, 5556, 2741, 282, 574, 367, 2198, 63, 2118, 12, 1325, 314, 3517, 21, 773, 3123, 6545, 3181, 1133, 2291, 2198, 63, 2118, 14, 710, 8039, 2213, 911, 506, 4565, 2685, 267, 1798, 275, 3517, 21, 773, 14, 27375, 8, 2350, 29, 277, 14, 981, 63, 2350, 5649, 9, 267, 1382, 275, 1798, 14, 1122, 8, 10131, 12, 2644, 29, 277, 14, 751, 63, 10085, 63, 2991, 9, 398, 327, 2494, 314, 4528, 2644, 10501, 701, 314, 14803, 14, 267, 340, 1228, 8, 10131, 12, 2649, 304, 288, 327, 2136, 1929, 370, 4539, 13, 2546, 642, 2952, 3517, 21, 773, 5951, 288, 327, 1495, 7630, 370, 9094, 13, 24, 340, 652, 7545, 6140, 1324, 14, 288, 1382, 14, 5043, 63, 2991, 275, 488, 267, 587, 26, 288, 1382, 14, 5043, 63, 2991, 275, 1798, 14, 13771, 14, 1745, 14, 1560, 7630, 59, 16, 61, 339, 347, 1218, 63, 2350, 5649, 8, 277, 12, 3231, 31428, 20446, 304, 267, 291, 14, 7138, 6670, 63, 5649, 275, 12178, 6437, 1858, 12957, 21, 773, 8, 288, 291, 14, 9317, 12, 3231, 31428, 20446, 9, 267, 372, 291, 14, 7138, 6670, 63, 5649, 339, 347, 511, 63, 7677, 63, 475, 63, 3554, 8, 277, 12, 7956, 304, 267, 408, 9295, 658, 20437, 17105, 267, 372, 399, 7601, 1360, 2535, 2993, 2957, 2993, 2535, 2030, 6598, 83, 1108, 2030, 2957, 1360, 3524, 450, 7956, 421, 199, 533, 12178, 6437, 1858, 12957, 21, 773, 8, 1360, 21, 773, 14, 2350, 20968, 423, 1095, 14, 20437, 304, 339, 347, 636, 826, 721, 277, 12, 9108, 12, 3231, 31428, 20446, 304, 267, 291, 14, 9317, 275, 9108, 267, 1613, 8, 20437, 1858, 12957, 21, 773, 12, 291, 2843, 826, 721, 3251, 31428, 20446, 9, 339, 347, 2213, 2543, 8, 277, 304, 267, 291, 14, 9317, 14, 3958, 342, 267, 372, 6566, 8, 277, 14, 9317, 12, 291, 14, 9317, 12, 488, 9, 339, 347, 5518, 21629, 8, 277, 12, 1526, 304, 267, 536, 275, 1526, 905, 354, 937, 267, 25753, 275, 1526, 905, 25311, 937, 267, 22873, 275, 1526, 905, 20150, 937, 398, 13265, 275, 4226, 3667, 14, 509, 63, 354, 63, 460, 63, 1580, 8, 354, 12, 25753, 12, 22873, 9, 267, 291, 14, 9317, 14, 785, 63, 10274, 63, 6751, 8, 6356, 9, 339, 347, 1819, 2543, 8, 277, 12, 536, 12, 3231, 304, 267, 1947, 275, 291, 14, 9317, 14, 1222, 63, 1450, 8, 354, 12, 3231, 9, 267, 372, 6566, 8, 1450, 12, 291, 14, 9317, 12, 3231, 9, 339, 347, 3721, 2543, 8, 277, 12, 666, 304, 267, 372, 4516, 1716, 8, 7488, 8, 576, 395, 291, 14, 9317, 9, 339, 347, 7956, 2543, 8, 277, 304, 267, 291, 14, 9317, 275, 17132, 10804, 267, 291, 14, 9317, 14, 354, 275, 7369, 3554, 63, 7677, 8480, 267, 372, 6566, 8, 277, 14, 9317, 12, 291, 14, 9317, 12, 488, 9, 339, 347, 5666, 3493, 8, 277, 12, 1031, 304, 267, 327, 5787, 961, 1233, 365, 440, 24295, 701, 314, 699, 51, 20, 2295, 14, 267, 291, 14, 9317, 14, 740, 8, 932, 14, 2108, 9, 339, 347, 664, 5564, 8, 277, 304, 267, 372, 291, 14, 9317, 339, 347, 664, 11080, 8, 277, 304, 267, 372, 3517, 21, 773, 14, 2350, 20968, 423, 1095, 14, 20437, 14, 362, 11080, 8, 277, 680, 2108, 199, 199, 533, 20516, 1296, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1819, 304, 267, 291, 14, 2108, 275, 1819, 267, 291, 14, 3288, 275, 1211, 8, 277, 14, 2108, 14, 3288, 9, 272, 347, 636, 1661, 721, 277, 304, 267, 372, 769, 8, 277, 14, 3288, 14, 1744, 342, 2843, 1661, 4533, 272, 347, 636, 8617, 721, 277, 12, 536, 12, 574, 304, 267, 298, 409, 1921, 401, 536, 12, 574, 267, 291, 14, 2108, 59, 354, 61, 275, 574, 272, 347, 2974, 8, 277, 304, 267, 372, 769, 8, 277, 14, 3288, 14, 1744, 1012, 272, 347, 2883, 8, 277, 304, 267, 372, 769, 8, 277, 14, 3288, 14, 1612, 1012, 272, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 14, 3288, 9, 272, 347, 636, 6095, 721, 277, 12, 536, 304, 267, 372, 291, 14, 3288, 59, 354, 61, 272, 347, 636, 6134, 721, 277, 12, 536, 304, 267, 372, 536, 315, 769, 8, 277, 14, 3288, 14, 1612, 1012, 421, 199, 533, 6566, 8, 1360, 21, 773, 14, 2350, 20968, 423, 1095, 14, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 1819, 12, 9108, 12, 3231, 304, 267, 3517, 21, 773, 14, 2350, 20968, 423, 1095, 14, 1716, 855, 826, 721, 277, 12, 1819, 14, 354, 9, 267, 291, 14, 2108, 275, 1819, 267, 291, 14, 9317, 275, 9108, 267, 291, 14, 3251, 275, 3231, 339, 347, 5666, 3493, 8, 277, 12, 1031, 304, 267, 340, 334, 932, 14, 2108, 855, 533, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hawkowl/treq
treq/auth.py
8
1208
from twisted.web.http_headers import Headers import base64 class UnknownAuthConfig(Exception): def __init__(self, config): super(Exception, self).__init__( '{0!r} not of a known type.'.format(config)) class _RequestHeaderSettingAgent(object): def __init__(self, agent, request_headers): self._agent = agent self._request_headers = request_headers def request(self, method, uri, headers=None, bodyProducer=None): if headers is None: headers = self._request_headers else: for header, values in self._request_headers.getAllRawHeaders(): headers.setRawHeaders(header, values) return self._agent.request( method, uri, headers=headers, bodyProducer=bodyProducer) def add_basic_auth(agent, username, password): creds = base64.b64encode('{0}:{1}'.format(username, password)) return _RequestHeaderSettingAgent( agent, Headers({'Authorization': ['Basic {0}'.format(creds)]})) def add_auth(agent, auth_config): if isinstance(auth_config, tuple): return add_basic_auth(agent, auth_config[0], auth_config[1]) raise UnknownAuthConfig(auth_config)
mit
[ 504, 7390, 14, 2520, 14, 1014, 63, 2139, 492, 21391, 199, 646, 1300, 772, 421, 199, 533, 14831, 2817, 2028, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1101, 304, 267, 1613, 8, 1726, 12, 291, 2843, 826, 721, 288, 5041, 16, 1, 82, 93, 440, 402, 282, 6040, 730, 17374, 908, 8, 888, 430, 421, 199, 533, 485, 20165, 7776, 7788, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 6631, 12, 1056, 63, 2139, 304, 267, 291, 423, 4054, 275, 6631, 267, 291, 423, 1069, 63, 2139, 275, 1056, 63, 2139, 339, 347, 1056, 8, 277, 12, 1083, 12, 5108, 12, 2323, 29, 403, 12, 2396, 15532, 29, 403, 304, 267, 340, 2323, 365, 488, 26, 288, 2323, 275, 291, 423, 1069, 63, 2139, 267, 587, 26, 288, 367, 1406, 12, 1338, 315, 291, 423, 1069, 63, 2139, 14, 31359, 7963, 9883, 837, 355, 2323, 14, 409, 7963, 9883, 8, 1291, 12, 1338, 9, 398, 372, 291, 423, 4054, 14, 1069, 8, 288, 1083, 12, 5108, 12, 2323, 29, 2139, 12, 2396, 15532, 29, 2030, 15532, 9, 421, 199, 318, 1050, 63, 4316, 63, 1178, 8, 4054, 12, 3434, 12, 2505, 304, 272, 20023, 275, 1300, 772, 14, 66, 772, 2143, 11117, 16, 16495, 17, 5285, 908, 8, 2473, 12, 2505, 430, 272, 372, 485, 20165, 7776, 7788, 8, 267, 6631, 12, 267, 21391, 3252, 11626, 356, 788, 6845, 469, 16, 5285, 908, 8, 15226, 1874, 12466, 421, 199, 318, 1050, 63, 1178, 8, 4054, 12, 1790, 63, 888, 304, 272, 340, 1228, 8, 1178, 63, 888, 12, 2008, 304, 267, 372, 1050, 63, 4316, 63, 1178, 8, 4054, 12, 1790, 63, 888, 59, 16, 467, 1790, 63, 888, 59, 17, 566, 339, 746, 14831, 2817, 2028, 8, 1178, 63, 888, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 7390, 14, 2520, 14, 1014, 63, 2139, 492, 21391, 199, 646, 1300, 772, 421, 199, 533, 14831, 2817, 2028, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1101, 304, 267, 1613, 8, 1726, 12, 291, 2843, 826, 721, 288, 5041, 16, 1, 82, 93, 440, 402, 282, 6040, 730, 17374, 908, 8, 888, 430, 421, 199, 533, 485, 20165, 7776, 7788, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 6631, 12, 1056, 63, 2139, 304, 267, 291, 423, 4054, 275, 6631, 267, 291, 423, 1069, 63, 2139, 275, 1056, 63, 2139, 339, 347, 1056, 8, 277, 12, 1083, 12, 5108, 12, 2323, 29, 403, 12, 2396, 15532, 29, 403, 304, 267, 340, 2323, 365, 488, 26, 288, 2323, 275, 291, 423, 1069, 63, 2139, 267, 587, 26, 288, 367, 1406, 12, 1338, 315, 291, 423, 1069, 63, 2139, 14, 31359, 7963, 9883, 837, 355, 2323, 14, 409, 7963, 9883, 8, 1291, 12, 1338, 9, 398, 372, 291, 423, 4054, 14, 1069, 8, 288, 1083, 12, 5108, 12, 2323, 29, 2139, 12, 2396, 15532, 29, 2030, 15532, 9, 421, 199, 318, 1050, 63, 4316, 63, 1178, 8, 4054, 12, 3434, 12, 2505, 304, 272, 20023, 275, 1300, 772, 14, 66, 772, 2143, 11117, 16, 16495, 17, 5285, 908, 8, 2473, 12, 2505, 430, 272, 372, 485, 20165, 7776, 7788, 8, 267, 6631, 12, 267, 21391, 3252, 11626, 356, 788, 6845, 469, 16, 5285, 908, 8, 15226, 1874, 12466, 421, 199, 318, 1050, 63, 1178, 8, 4054, 12, 1790, 63, 888, 304, 272, 340, 1228, 8, 1178, 63, 888, 12, 2008, 304, 267, 372, 1050, 63, 4316, 63, 1178, 8, 4054, 12, 1790, 63, 888, 59, 16, 467, 1790, 63, 888, 59, 17, 566, 339, 746, 14831, 2817, 2028, 8, 1178, 63, 888, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
v1bri/gnuradio
grc/core/utils/odict.py
12
3417
""" Copyright 2008-2015 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GNU Radio Companion is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ from UserDict import DictMixin class odict(DictMixin): def __init__(self, d={}): self._keys = list(d.keys()) self._data = dict(d.copy()) def __setitem__(self, key, value): if key not in self._data: self._keys.append(key) self._data[key] = value def __getitem__(self, key): return self._data[key] def __delitem__(self, key): del self._data[key] self._keys.remove(key) def keys(self): return list(self._keys) def copy(self): copy_dict = odict() copy_dict._data = self._data.copy() copy_dict._keys = list(self._keys) return copy_dict def insert_after(self, pos_key, key, val): """ Insert the new key, value entry after the entry given by the position key. If the positional key is None, insert at the end. Args: pos_key: the positional key key: the key for the new entry val: the value for the new entry """ index = (pos_key is None) and len(self._keys) or self._keys.index(pos_key) if key in self._keys: raise KeyError('Cannot insert, key "{0}" already exists'.format(str(key))) self._keys.insert(index+1, key) self._data[key] = val def insert_before(self, pos_key, key, val): """ Insert the new key, value entry before the entry given by the position key. If the positional key is None, insert at the begining. Args: pos_key: the positional key key: the key for the new entry val: the value for the new entry """ index = (pos_key is not None) and self._keys.index(pos_key) or 0 if key in self._keys: raise KeyError('Cannot insert, key "{0}" already exists'.format(str(key))) self._keys.insert(index, key) self._data[key] = val def find(self, key): """ Get the value for this key if exists. Args: key: the key to search for Returns: the value or None """ if key in self: return self[key] return None def findall(self, key): """ Get a list of values for this key. Args: key: the key to search for Returns: a list of values or empty list """ obj = self.find(key) if obj is None: obj = list() if isinstance(obj, list): return obj return [obj] def clear(self): self._data.clear() del self._keys[:]
gpl-3.0
[ 624, 199, 7384, 9079, 13, 7806, 2868, 2290, 2752, 12, 3277, 14, 199, 2765, 570, 365, 1777, 402, 1664, 13514, 199, 199, 17732, 13514, 3599, 32012, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 8951, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 305, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 1618, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 17732, 13514, 3599, 32012, 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, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 199, 624, 199, 199, 504, 32241, 492, 7448, 4256, 421, 199, 533, 312, 807, 8, 2141, 4256, 304, 339, 347, 636, 826, 721, 277, 12, 366, 16420, 267, 291, 423, 1612, 275, 769, 8, 68, 14, 1612, 1012, 267, 291, 423, 576, 275, 1211, 8, 68, 14, 1574, 1012, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 340, 790, 440, 315, 291, 423, 576, 26, 288, 291, 423, 1612, 14, 740, 8, 498, 9, 267, 291, 423, 576, 59, 498, 61, 275, 574, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 423, 576, 59, 498, 61, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 2150, 291, 423, 576, 59, 498, 61, 267, 291, 423, 1612, 14, 2168, 8, 498, 9, 339, 347, 2883, 8, 277, 304, 267, 372, 769, 8, 277, 423, 1612, 9, 339, 347, 1331, 8, 277, 304, 267, 1331, 63, 807, 275, 312, 807, 342, 267, 1331, 63, 807, 423, 576, 275, 291, 423, 576, 14, 1574, 342, 267, 1331, 63, 807, 423, 1612, 275, 769, 8, 277, 423, 1612, 9, 267, 372, 1331, 63, 807, 339, 347, 5518, 63, 4399, 8, 277, 12, 2086, 63, 498, 12, 790, 12, 1139, 304, 267, 408, 267, 15496, 314, 892, 790, 12, 574, 2397, 2410, 314, 2397, 1627, 701, 314, 3421, 790, 14, 267, 982, 314, 11333, 790, 365, 488, 12, 5518, 737, 314, 1284, 14, 398, 3033, 26, 288, 2086, 63, 498, 26, 314, 11333, 790, 288, 790, 26, 314, 790, 367, 314, 892, 2397, 288, 1139, 26, 314, 574, 367, 314, 892, 2397, 267, 408, 267, 1478, 275, 334, 1712, 63, 498, 365, 488, 9, 436, 822, 8, 277, 423, 1612, 9, 503, 291, 423, 1612, 14, 1080, 8, 1712, 63, 498, 9, 267, 340, 790, 315, 291, 423, 1612, 26, 288, 746, 4067, 360, 6612, 5518, 12, 790, 5310, 16, 7063, 2575, 3495, 1370, 908, 8, 495, 8, 498, 1724, 267, 291, 423, 1612, 14, 3176, 8, 1080, 11, 17, 12, 790, 9, 267, 291, 423, 576, 59, 498, 61, 275, 1139, 339, 347, 5518, 63, 5182, 8, 277, 12, 2086, 63, 498, 12, 790, 12, 1139, 304, 267, 408, 267, 15496, 314, 892, 790, 12, 574, 2397, 2544, 314, 2397, 1627, 701, 314, 3421, 790, 14, 267, 982, 314, 11333, 790, 365, 488, 12, 5518, 737, 314, 5386, 316, 14, 398, 3033, 26, 288, 2086, 63, 498, 26, 314, 11333, 790, 288, 790, 26, 314, 790, 367, 314, 892, 2397, 288, 1139, 26, 314, 574, 367, 314, 892, 2397, 267, 408, 267, 1478, 275, 334, 1712, 63, 498, 365, 440, 488, 9, 436, 291, 423, 1612, 14, 1080, 8, 1712, 63, 498, 9, 503, 378, 267, 340, 790, 315, 291, 423, 1612, 26, 288, 746, 4067, 360, 6612, 5518, 12, 790, 5310, 16, 7063, 2575, 3495, 1370, 908, 8, 495, 8, 498, 1724, 267, 291, 423, 1612, 14, 3176, 8, 1080, 12, 790, 9, 267, 291, 423, 576, 59, 498, 61, 275, 1139, 339, 347, 2342, 8, 277, 12, 790, 304, 267, 408, 267, 2372, 314, 574, 367, 642, 790, 340, 3495, 14, 398, 3033, 26, 288, 790, 26, 314, 790, 370, 2754, 367, 398, 1803, 26, 288, 314, 574, 503, 488, 267, 408, 267, 340, 790, 315, 291, 26, 288, 372, 291, 59, 498, 61, 267, 372, 488, 339, 347, 2342, 452, 8, 277, 12, 790, 304, 267, 408, 267, 2372, 282, 769, 402, 1338, 367, 642, 790, 14, 398, 3033, 26, 288, 790, 26, 314, 790, 370, 2754, 367, 398, 1803, 26, 288, 282, 769, 402, 1338, 503, 2701, 769, 267, 408, 267, 1559, 275, 291, 14, 1623, 8, 498, 9, 267, 340, 1559, 365, 488, 26, 288, 1559, 275, 769, 342, 267, 340, 1228, 8, 1113, 12, 769, 304, 288, 372, 1559, 267, 372, 359, 1113, 61, 339, 347, 5436, 8, 277, 304, 267, 291, 423, 576, 14, 3584, 342, 267, 2150, 291, 423, 1612, 5873, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 7384, 9079, 13, 7806, 2868, 2290, 2752, 12, 3277, 14, 199, 2765, 570, 365, 1777, 402, 1664, 13514, 199, 199, 17732, 13514, 3599, 32012, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 8951, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 305, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 1618, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 17732, 13514, 3599, 32012, 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, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 199, 624, 199, 199, 504, 32241, 492, 7448, 4256, 421, 199, 533, 312, 807, 8, 2141, 4256, 304, 339, 347, 636, 826, 721, 277, 12, 366, 16420, 267, 291, 423, 1612, 275, 769, 8, 68, 14, 1612, 1012, 267, 291, 423, 576, 275, 1211, 8, 68, 14, 1574, 1012, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 340, 790, 440, 315, 291, 423, 576, 26, 288, 291, 423, 1612, 14, 740, 8, 498, 9, 267, 291, 423, 576, 59, 498, 61, 275, 574, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 423, 576, 59, 498, 61, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 2150, 291, 423, 576, 59, 498, 61, 267, 291, 423, 1612, 14, 2168, 8, 498, 9, 339, 347, 2883, 8, 277, 304, 267, 372, 769, 8, 277, 423, 1612, 9, 339, 347, 1331, 8, 277, 304, 267, 1331, 63, 807, 275, 312, 807, 342, 267, 1331, 63, 807, 423, 576, 275, 291, 423, 576, 14, 1574, 342, 267, 1331, 63, 807, 423, 1612, 275, 769, 8, 277, 423, 1612, 9, 267, 372, 1331, 63, 807, 339, 347, 5518, 63, 4399, 8, 277, 12, 2086, 63, 498, 12, 790, 12, 1139, 304, 267, 408, 267, 15496, 314, 892, 790, 12, 574, 2397, 2410, 314, 2397, 1627, 701, 314, 3421, 790, 14, 267, 982, 314, 11333, 790, 365, 488, 12, 5518, 737, 314, 1284, 14, 398, 3033, 26, 288, 2086, 63, 498, 26, 314, 11333, 790, 288, 790, 26, 314, 790, 367, 314, 892, 2397, 288, 1139, 26, 314, 574, 367, 314, 892, 2397, 267, 408, 267, 1478, 275, 334, 1712, 63, 498, 365, 488, 9, 436, 822, 8, 277, 423, 1612, 9, 503, 291, 423, 1612, 14, 1080, 8, 1712, 63, 498, 9, 267, 340, 790, 315, 291, 423, 1612, 26, 288, 746, 4067, 360, 6612, 5518, 12, 790, 5310, 16, 7063, 2575, 3495, 1370, 908, 8, 495, 8, 498, 1724, 267, 291, 423, 1612, 14, 3176, 8, 1080, 11, 17, 12, 790, 9, 267, 291, 423, 576, 59, 498, 61, 275, 1139, 339, 347, 5518, 63, 5182, 8, 277, 12, 2086, 63, 498, 12, 790, 12, 1139, 304, 267, 408, 267, 15496, 314, 892, 790, 12, 574, 2397, 2544, 314, 2397, 1627, 701, 314, 3421, 790, 14, 267, 982, 314, 11333, 790, 365, 488, 12, 5518, 737, 314, 5386, 316, 14, 398, 3033, 26, 288, 2086, 63, 498, 26, 314, 11333, 790, 288, 790, 26, 314, 790, 367, 314, 892, 2397, 288, 1139, 26, 314, 574, 367, 314, 892, 2397, 267, 408, 267, 1478, 275, 334, 1712, 63, 498, 365, 440, 488, 9, 436, 291, 423, 1612, 14, 1080, 8, 1712, 63, 498, 9, 503, 378, 267, 340, 790, 315, 291, 423, 1612, 26, 288, 746, 4067, 360, 6612, 5518, 12, 790, 5310, 16, 7063, 2575, 3495, 1370, 908, 8, 495, 8, 498, 1724, 267, 291, 423, 1612, 14, 3176, 8, 1080, 12, 790, 9, 267, 291, 423, 576, 59, 498, 61, 275, 1139, 339, 347, 2342, 8, 277, 12, 790, 304, 267, 408, 267, 2372, 314, 574, 367, 642, 790, 340, 3495, 14, 398, 3033, 26, 288, 790, 26, 314, 790, 370, 2754, 367, 398, 1803, 26, 288, 314, 574, 503, 488, 267, 408, 267, 340, 790, 315, 291, 26, 288, 372, 291, 59, 498, 61, 267, 372, 488, 339, 347, 2342, 452, 8, 277, 12, 790, 304, 267, 408, 267, 2372, 282, 769, 402, 1338, 367, 642, 790, 14, 398, 3033, 26, 288, 790, 26, 314, 790, 370, 2754, 367, 398, 1803, 26, 288, 282, 769, 402, 1338, 503, 2701, 769, 267, 408, 267, 1559, 275, 291, 14, 1623, 8, 498, 9, 267, 340, 1559, 365, 488, 26, 288, 1559, 275, 769, 342, 267, 340, 1228, 8, 1113, 12, 769, 304, 288, 372, 1559, 267, 372, 359, 1113, 61, 339, 347, 5436, 8, 277, 304, 267, 291, 423, 576, 14, 3584, 342, 267, 2150, 291, 423, 1612, 5873, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
cjb/etherpad-lite
bin/dirty-db-cleaner.py
70
1394
#!/usr/bin/python -u # # Created by Bjarni R. Einarsson, placed in the public domain. Go wild! # import json import os import sys try: dirtydb_input = sys.argv[1] dirtydb_output = '%s.new' % dirtydb_input assert(os.path.exists(dirtydb_input)) assert(not os.path.exists(dirtydb_output)) except: print print 'Usage: %s /path/to/dirty.db' % sys.argv[0] print print 'Note: Will create a file named dirty.db.new in the same folder,' print ' please make sure permissions are OK and a file by that' print ' name does not exist already. This script works by omitting' print ' duplicate lines from the dirty.db file, keeping only the' print ' last (latest) instance. No revision data should be lost,' print ' but be careful, make backups. If it breaks you get to keep' print ' both pieces!' print sys.exit(1) dirtydb = {} lines = 0 with open(dirtydb_input, 'r') as fd: print 'Reading %s' % dirtydb_input for line in fd: lines += 1 data = json.loads(line) dirtydb[data['key']] = line if lines % 10000 == 0: sys.stderr.write('.') print print 'OK, found %d unique keys in %d lines' % (len(dirtydb), lines) with open(dirtydb_output, 'w') as fd: for data in dirtydb.values(): fd.write(data) print 'Wrote data to %s. All done!' % dirtydb_output
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 446, 85, 199, 3, 199, 3, 18208, 701, 699, 74, 1060, 73, 820, 14, 662, 262, 285, 385, 265, 12, 15090, 315, 314, 4575, 2881, 14, 3971, 336, 668, 1, 199, 3, 199, 646, 2022, 199, 646, 747, 199, 646, 984, 199, 199, 893, 26, 272, 14650, 697, 63, 1210, 275, 984, 14, 3020, 59, 17, 61, 272, 14650, 697, 63, 1199, 275, 1543, 83, 14, 1222, 7, 450, 14650, 697, 63, 1210, 272, 702, 8, 736, 14, 515, 14, 2444, 8, 8799, 697, 63, 1210, 430, 272, 702, 8, 1397, 747, 14, 515, 14, 2444, 8, 8799, 697, 63, 1199, 430, 199, 2590, 26, 272, 870, 5591, 870, 283, 7692, 26, 450, 83, 1182, 515, 15, 475, 15, 8799, 14, 697, 7, 450, 984, 14, 3020, 59, 16, 61, 272, 870, 5591, 870, 283, 7443, 26, 12823, 1218, 282, 570, 4310, 14650, 14, 697, 14, 1222, 315, 314, 2011, 4922, 2584, 272, 870, 283, 420, 8749, 1852, 3238, 3443, 787, 9949, 436, 282, 570, 701, 626, 7, 272, 870, 283, 420, 536, 1630, 440, 2187, 2575, 14, 961, 2884, 5419, 701, 19413, 1337, 7, 272, 870, 283, 420, 9250, 2385, 687, 314, 14650, 14, 697, 570, 12, 22181, 1454, 314, 7, 272, 870, 283, 420, 2061, 334, 7410, 9, 1256, 14, 3091, 6974, 666, 1077, 506, 14669, 2584, 272, 870, 283, 420, 1325, 506, 25082, 12, 1852, 6902, 83, 14, 982, 652, 18277, 1265, 664, 370, 4215, 7, 272, 870, 283, 420, 3865, 10338, 11213, 272, 870, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 8799, 697, 275, 1052, 199, 1278, 275, 378, 199, 1045, 1551, 8, 8799, 697, 63, 1210, 12, 283, 82, 358, 465, 6111, 26, 272, 870, 283, 20568, 450, 83, 7, 450, 14650, 697, 63, 1210, 272, 367, 1004, 315, 6111, 26, 267, 2385, 847, 413, 267, 666, 275, 2022, 14, 3640, 8, 604, 9, 267, 14650, 697, 59, 576, 459, 498, 6538, 275, 1004, 267, 340, 2385, 450, 11630, 508, 378, 26, 288, 984, 14, 3083, 14, 952, 7563, 199, 1361, 199, 1361, 283, 3593, 12, 1911, 450, 68, 3747, 2883, 315, 450, 68, 2385, 7, 450, 334, 552, 8, 8799, 697, 395, 2385, 9, 199, 199, 1045, 1551, 8, 8799, 697, 63, 1199, 12, 283, 87, 358, 465, 6111, 26, 272, 367, 666, 315, 14650, 697, 14, 1459, 837, 267, 6111, 14, 952, 8, 576, 9, 199, 199, 1361, 283, 55, 22665, 666, 370, 450, 83, 14, 2900, 4224, 11213, 450, 14650, 697, 63, 1199, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 446, 85, 199, 3, 199, 3, 18208, 701, 699, 74, 1060, 73, 820, 14, 662, 262, 285, 385, 265, 12, 15090, 315, 314, 4575, 2881, 14, 3971, 336, 668, 1, 199, 3, 199, 646, 2022, 199, 646, 747, 199, 646, 984, 199, 199, 893, 26, 272, 14650, 697, 63, 1210, 275, 984, 14, 3020, 59, 17, 61, 272, 14650, 697, 63, 1199, 275, 1543, 83, 14, 1222, 7, 450, 14650, 697, 63, 1210, 272, 702, 8, 736, 14, 515, 14, 2444, 8, 8799, 697, 63, 1210, 430, 272, 702, 8, 1397, 747, 14, 515, 14, 2444, 8, 8799, 697, 63, 1199, 430, 199, 2590, 26, 272, 870, 5591, 870, 283, 7692, 26, 450, 83, 1182, 515, 15, 475, 15, 8799, 14, 697, 7, 450, 984, 14, 3020, 59, 16, 61, 272, 870, 5591, 870, 283, 7443, 26, 12823, 1218, 282, 570, 4310, 14650, 14, 697, 14, 1222, 315, 314, 2011, 4922, 2584, 272, 870, 283, 420, 8749, 1852, 3238, 3443, 787, 9949, 436, 282, 570, 701, 626, 7, 272, 870, 283, 420, 536, 1630, 440, 2187, 2575, 14, 961, 2884, 5419, 701, 19413, 1337, 7, 272, 870, 283, 420, 9250, 2385, 687, 314, 14650, 14, 697, 570, 12, 22181, 1454, 314, 7, 272, 870, 283, 420, 2061, 334, 7410, 9, 1256, 14, 3091, 6974, 666, 1077, 506, 14669, 2584, 272, 870, 283, 420, 1325, 506, 25082, 12, 1852, 6902, 83, 14, 982, 652, 18277, 1265, 664, 370, 4215, 7, 272, 870, 283, 420, 3865, 10338, 11213, 272, 870, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 8799, 697, 275, 1052, 199, 1278, 275, 378, 199, 1045, 1551, 8, 8799, 697, 63, 1210, 12, 283, 82, 358, 465, 6111, 26, 272, 870, 283, 20568, 450, 83, 7, 450, 14650, 697, 63, 1210, 272, 367, 1004, 315, 6111, 26, 267, 2385, 847, 413, 267, 666, 275, 2022, 14, 3640, 8, 604, 9, 267, 14650, 697, 59, 576, 459, 498, 6538, 275, 1004, 267, 340, 2385, 450, 11630, 508, 378, 26, 288, 984, 14, 3083, 14, 952, 7563, 199, 1361, 199, 1361, 283, 3593, 12, 1911, 450, 68, 3747, 2883, 315, 450, 68, 2385, 7, 450, 334, 552, 8, 8799, 697, 395, 2385, 9, 199, 199, 1045, 1551, 8, 8799, 697, 63, 1199, 12, 283, 87, 358, 465, 6111, 26, 272, 367, 666, 315, 14650, 697, 14, 1459, 837, 267, 6111, 14, 952, 8, 576, 9, 199, 199, 1361, 283, 55, 22665, 666, 370, 450, 83, 14, 2900, 4224, 11213, 450, 14650, 697, 63, 1199, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0 ]
Rogentos/argent-anaconda
scripts/getlangnames.py
4
1394
# # getlangnames.py # # Copyright (C) 2007 Red Hat, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys sys.path.append("..") import language import gettext langs = language.Language() names = {} for k in langs.localeInfo.keys(): found = False for l in language.expandLangs(k): try: f = open("po/%s.gmo" %(l,)) except (OSError, IOError): continue cat = gettext.GNUTranslations(f) cat.set_output_charset("utf-8") names[langs.localeInfo[k][0]] = cat.lgettext(langs.localeInfo[k][0]) found = True break if not found: names[langs.localeInfo[k][0]] = langs.localeInfo[k][0] nameList = names.keys() nameList.sort() for k in nameList: print("%s\t%s" % (k, names[k]))
gpl-2.0
[ 3, 199, 3, 664, 4159, 1247, 14, 647, 199, 3, 199, 3, 1898, 334, 35, 9, 10219, 221, 9572, 13002, 12, 3277, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 646, 984, 199, 1274, 14, 515, 14, 740, 480, 703, 531, 199, 646, 2637, 199, 199, 646, 9796, 199, 199, 28182, 275, 2637, 14, 8493, 342, 199, 1247, 275, 1052, 199, 509, 1022, 315, 31769, 14, 5508, 2354, 14, 1612, 837, 272, 1911, 275, 756, 272, 367, 634, 315, 2637, 14, 4441, 44, 20068, 8, 75, 304, 267, 862, 26, 288, 289, 275, 1551, 480, 555, 3149, 83, 14, 71, 573, 2, 2818, 76, 4641, 267, 871, 334, 16719, 12, 5925, 304, 288, 1980, 267, 6230, 275, 9796, 14, 15306, 934, 1320, 6011, 8, 70, 9, 267, 6230, 14, 409, 63, 1199, 63, 6043, 480, 1624, 13, 24, 531, 267, 1561, 59, 28182, 14, 5508, 2354, 59, 75, 1527, 16, 2677, 275, 6230, 14, 76, 5152, 8, 28182, 14, 5508, 2354, 59, 75, 1527, 16, 566, 267, 1911, 275, 715, 267, 2059, 272, 340, 440, 1911, 26, 267, 1561, 59, 28182, 14, 5508, 2354, 59, 75, 1527, 16, 2677, 275, 31769, 14, 5508, 2354, 59, 75, 1527, 16, 61, 199, 199, 354, 1296, 275, 1561, 14, 1612, 342, 199, 354, 1296, 14, 3191, 342, 199, 199, 509, 1022, 315, 536, 1296, 26, 272, 870, 3647, 83, 60, 84, 5, 83, 2, 450, 334, 75, 12, 1561, 59, 75, 2459, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 664, 4159, 1247, 14, 647, 199, 3, 199, 3, 1898, 334, 35, 9, 10219, 221, 9572, 13002, 12, 3277, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 646, 984, 199, 1274, 14, 515, 14, 740, 480, 703, 531, 199, 646, 2637, 199, 199, 646, 9796, 199, 199, 28182, 275, 2637, 14, 8493, 342, 199, 1247, 275, 1052, 199, 509, 1022, 315, 31769, 14, 5508, 2354, 14, 1612, 837, 272, 1911, 275, 756, 272, 367, 634, 315, 2637, 14, 4441, 44, 20068, 8, 75, 304, 267, 862, 26, 288, 289, 275, 1551, 480, 555, 3149, 83, 14, 71, 573, 2, 2818, 76, 4641, 267, 871, 334, 16719, 12, 5925, 304, 288, 1980, 267, 6230, 275, 9796, 14, 15306, 934, 1320, 6011, 8, 70, 9, 267, 6230, 14, 409, 63, 1199, 63, 6043, 480, 1624, 13, 24, 531, 267, 1561, 59, 28182, 14, 5508, 2354, 59, 75, 1527, 16, 2677, 275, 6230, 14, 76, 5152, 8, 28182, 14, 5508, 2354, 59, 75, 1527, 16, 566, 267, 1911, 275, 715, 267, 2059, 272, 340, 440, 1911, 26, 267, 1561, 59, 28182, 14, 5508, 2354, 59, 75, 1527, 16, 2677, 275, 31769, 14, 5508, 2354, 59, 75, 1527, 16, 61, 199, 199, 354, 1296, 275, 1561, 14, 1612, 342, 199, 354, 1296, 14, 3191, 342, 199, 199, 509, 1022, 315, 536, 1296, 26, 272, 870, 3647, 83, 60, 84, 5, 83, 2, 450, 334, 75, 12, 1561, 59, 75, 2459, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sxpert/ansible-modules-core
utilities/logic/async_status.py
137
3042
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>, and others # # 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: async_status short_description: Obtain status of asynchronous task description: - "This module gets the status of an asynchronous task." version_added: "0.5" options: jid: description: - Job or task identifier required: true default: null aliases: [] mode: description: - if C(status), obtain the status; if C(cleanup), clean up the async job cache located in C(~/.ansible_async/) for the specified job I(jid). required: false choices: [ "status", "cleanup" ] default: "status" notes: - See also U(http://docs.ansible.com/playbooks_async.html) requirements: [] author: - "Ansible Core Team" - "Michael DeHaan" ''' import datetime import traceback def main(): module = AnsibleModule(argument_spec=dict( jid=dict(required=True), mode=dict(default='status', choices=['status','cleanup']), )) mode = module.params['mode'] jid = module.params['jid'] # setup logging directory logdir = os.path.expanduser("~/.ansible_async") log_path = os.path.join(logdir, jid) if not os.path.exists(log_path): module.fail_json(msg="could not find job", ansible_job_id=jid) if mode == 'cleanup': os.unlink(log_path) module.exit_json(ansible_job_id=jid, erased=log_path) # NOT in cleanup mode, assume regular status mode # no remote kill mode currently exists, but probably should # consider log_path + ".pid" file and also unlink that above data = file(log_path).read() try: data = json.loads(data) except Exception, e: if data == '': # file not written yet? That means it is running module.exit_json(results_file=log_path, ansible_job_id=jid, started=1, finished=0) else: module.fail_json(ansible_job_id=jid, results_file=log_path, msg="Could not parse job output: %s" % data) if not 'started' in data: data['finished'] = 1 data['ansible_job_id'] = jid # Fix error: TypeError: exit_json() keywords must be strings data = dict([(str(k), v) for k, v in data.iteritems()]) module.exit_json(**data) # import module snippets from ansible.module_utils.basic import * 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, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 6244, 436, 11789, 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, 8948, 275, 1449, 199, 2595, 199, 578, 26, 5316, 63, 1205, 199, 3612, 63, 1802, 26, 17985, 877, 2004, 402, 15608, 2120, 199, 1802, 26, 1362, 446, 298, 2765, 859, 7545, 314, 2004, 402, 376, 15608, 2120, 2122, 199, 1023, 63, 3270, 26, 298, 16, 14, 21, 2, 199, 1419, 26, 523, 21752, 26, 272, 1369, 26, 489, 446, 15057, 503, 2120, 5148, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 818, 26, 272, 1369, 26, 489, 446, 340, 445, 8, 1205, 395, 3332, 314, 2004, 27, 340, 445, 8, 7661, 395, 3633, 1536, 314, 5316, 3906, 2581, 267, 16180, 315, 445, 26428, 8083, 4853, 63, 4146, 24793, 367, 314, 2013, 3906, 473, 8, 14203, 680, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 1205, 401, 298, 7661, 2, 1622, 272, 849, 26, 298, 1205, 2, 199, 5983, 26, 272, 446, 1666, 2597, 738, 8, 1014, 921, 4757, 14, 4853, 14, 957, 15, 2802, 8858, 63, 4146, 14, 1360, 9, 199, 7538, 26, 942, 199, 2502, 26, 5591, 446, 298, 10047, 11672, 11682, 2, 272, 446, 298, 45, 11781, 22453, 2, 199, 2344, 199, 199, 646, 2197, 199, 646, 5190, 199, 199, 318, 2446, 837, 339, 859, 275, 6953, 8, 2094, 63, 1650, 29, 807, 8, 267, 21752, 29, 807, 8, 2427, 29, 549, 395, 267, 818, 29, 807, 8, 885, 534, 1205, 297, 3415, 2968, 1205, 1673, 7661, 3815, 272, 5082, 339, 818, 275, 859, 14, 1162, 459, 632, 418, 272, 21752, 221, 275, 859, 14, 1162, 459, 14203, 418, 339, 327, 3272, 2050, 2082, 272, 28825, 275, 747, 14, 515, 14, 12131, 20793, 8083, 4853, 63, 4146, 531, 272, 943, 63, 515, 275, 747, 14, 515, 14, 904, 8, 22222, 12, 21752, 9, 339, 340, 440, 747, 14, 515, 14, 2444, 8, 793, 63, 515, 304, 267, 859, 14, 1633, 63, 1001, 8, 1328, 628, 15153, 440, 2342, 3906, 401, 3242, 63, 2423, 63, 344, 29, 14203, 9, 339, 340, 818, 508, 283, 7661, 356, 267, 747, 14, 7162, 8, 793, 63, 515, 9, 267, 859, 14, 2224, 63, 1001, 8, 4853, 63, 2423, 63, 344, 29, 14203, 12, 9266, 11185, 29, 793, 63, 515, 9, 339, 327, 2845, 315, 9058, 818, 12, 5534, 5578, 2004, 818, 272, 327, 949, 3982, 14561, 818, 5544, 3495, 12, 1325, 8646, 1077, 272, 327, 11201, 943, 63, 515, 435, 3680, 3150, 2, 570, 436, 2597, 17002, 626, 3432, 339, 666, 275, 570, 8, 793, 63, 515, 680, 739, 342, 272, 862, 26, 267, 666, 275, 2022, 14, 3640, 8, 576, 9, 272, 871, 2186, 12, 325, 26, 267, 340, 666, 508, 8061, 288, 327, 570, 440, 5313, 5966, 31, 221, 10314, 4910, 652, 365, 3879, 288, 859, 14, 2224, 63, 1001, 8, 2604, 63, 493, 29, 793, 63, 515, 12, 3242, 63, 2423, 63, 344, 29, 14203, 12, 8239, 29, 17, 12, 9158, 29, 16, 9, 267, 587, 26, 288, 859, 14, 1633, 63, 1001, 8, 4853, 63, 2423, 63, 344, 29, 14203, 12, 2058, 63, 493, 29, 793, 63, 515, 12, 355, 1499, 628, 6531, 440, 2198, 3906, 1072, 26, 450, 83, 2, 450, 666, 9, 339, 340, 440, 283, 8924, 7, 315, 666, 26, 267, 666, 459, 8669, 418, 275, 413, 267, 666, 459, 4853, 63, 2423, 63, 344, 418, 275, 21752, 339, 327, 14811, 1125, 26, 3146, 26, 4458, 63, 1001, 342, 7681, 1471, 506, 3326, 272, 666, 275, 1211, 7694, 495, 8, 75, 395, 373, 9, 367, 1022, 12, 373, 315, 666, 14, 4611, 9383, 339, 859, 14, 2224, 63, 1001, 3682, 576, 9, 199, 199, 3, 492, 859, 19484, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3, 334, 67, 9, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 6244, 436, 11789, 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, 8948, 275, 1449, 199, 2595, 199, 578, 26, 5316, 63, 1205, 199, 3612, 63, 1802, 26, 17985, 877, 2004, 402, 15608, 2120, 199, 1802, 26, 1362, 446, 298, 2765, 859, 7545, 314, 2004, 402, 376, 15608, 2120, 2122, 199, 1023, 63, 3270, 26, 298, 16, 14, 21, 2, 199, 1419, 26, 523, 21752, 26, 272, 1369, 26, 489, 446, 15057, 503, 2120, 5148, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 818, 26, 272, 1369, 26, 489, 446, 340, 445, 8, 1205, 395, 3332, 314, 2004, 27, 340, 445, 8, 7661, 395, 3633, 1536, 314, 5316, 3906, 2581, 267, 16180, 315, 445, 26428, 8083, 4853, 63, 4146, 24793, 367, 314, 2013, 3906, 473, 8, 14203, 680, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 1205, 401, 298, 7661, 2, 1622, 272, 849, 26, 298, 1205, 2, 199, 5983, 26, 272, 446, 1666, 2597, 738, 8, 1014, 921, 4757, 14, 4853, 14, 957, 15, 2802, 8858, 63, 4146, 14, 1360, 9, 199, 7538, 26, 942, 199, 2502, 26, 5591, 446, 298, 10047, 11672, 11682, 2, 272, 446, 298, 45, 11781, 22453, 2, 199, 2344, 199, 199, 646, 2197, 199, 646, 5190, 199, 199, 318, 2446, 837, 339, 859, 275, 6953, 8, 2094, 63, 1650, 29, 807, 8, 267, 21752, 29, 807, 8, 2427, 29, 549, 395, 267, 818, 29, 807, 8, 885, 534, 1205, 297, 3415, 2968, 1205, 1673, 7661, 3815, 272, 5082, 339, 818, 275, 859, 14, 1162, 459, 632, 418, 272, 21752, 221, 275, 859, 14, 1162, 459, 14203, 418, 339, 327, 3272, 2050, 2082, 272, 28825, 275, 747, 14, 515, 14, 12131, 20793, 8083, 4853, 63, 4146, 531, 272, 943, 63, 515, 275, 747, 14, 515, 14, 904, 8, 22222, 12, 21752, 9, 339, 340, 440, 747, 14, 515, 14, 2444, 8, 793, 63, 515, 304, 267, 859, 14, 1633, 63, 1001, 8, 1328, 628, 15153, 440, 2342, 3906, 401, 3242, 63, 2423, 63, 344, 29, 14203, 9, 339, 340, 818, 508, 283, 7661, 356, 267, 747, 14, 7162, 8, 793, 63, 515, 9, 267, 859, 14, 2224, 63, 1001, 8, 4853, 63, 2423, 63, 344, 29, 14203, 12, 9266, 11185, 29, 793, 63, 515, 9, 339, 327, 2845, 315, 9058, 818, 12, 5534, 5578, 2004, 818, 272, 327, 949, 3982, 14561, 818, 5544, 3495, 12, 1325, 8646, 1077, 272, 327, 11201, 943, 63, 515, 435, 3680, 3150, 2, 570, 436, 2597, 17002, 626, 3432, 339, 666, 275, 570, 8, 793, 63, 515, 680, 739, 342, 272, 862, 26, 267, 666, 275, 2022, 14, 3640, 8, 576, 9, 272, 871, 2186, 12, 325, 26, 267, 340, 666, 508, 8061, 288, 327, 570, 440, 5313, 5966, 31, 221, 10314, 4910, 652, 365, 3879, 288, 859, 14, 2224, 63, 1001, 8, 2604, 63, 493, 29, 793, 63, 515, 12, 3242, 63, 2423, 63, 344, 29, 14203, 12, 8239, 29, 17, 12, 9158, 29, 16, 9, 267, 587, 26, 288, 859, 14, 1633, 63, 1001, 8, 4853, 63, 2423, 63, 344, 29, 14203, 12, 2058, 63, 493, 29, 793, 63, 515, 12, 355, 1499, 628, 6531, 440, 2198, 3906, 1072, 26, 450, 83, 2, 450, 666, 9, 339, 340, 440, 283, 8924, 7, 315, 666, 26, 267, 666, 459, 8669, 418, 275, 413, 267, 666, 459, 4853, 63, 2423, 63, 344, 418, 275, 21752, 339, 327, 14811, 1125, 26, 3146, 26, 4458, 63, 1001, 342, 7681, 1471, 506, 3326, 272, 666, 275, 1211, 7694, 495, 8, 75, 395, 373, 9, 367, 1022, 12, 373, 315, 666, 14, 4611, 9383, 339, 859, 14, 2224, 63, 1001, 3682, 576, 9, 199, 199, 3, 492, 859, 19484, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
minhphung171093/OpenERP_V7
openerp/addons/hr_recruitment/__init__.py
433
1145
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved # $Id$ # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import hr_recruitment import report import wizard import res_config # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 2900, 5924, 5702, 199, 3, 259, 2672, 1304, 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, 16140, 63, 264, 31365, 434, 199, 646, 3622, 199, 646, 12262, 199, 646, 522, 63, 888, 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 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 2900, 5924, 5702, 199, 3, 259, 2672, 1304, 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, 16140, 63, 264, 31365, 434, 199, 646, 3622, 199, 646, 12262, 199, 646, 522, 63, 888, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nuxleus/cherokee-webserver
admin/plugins/rrd.py
3
1705
# -*- coding: utf-8 -*- # # Cheroke-admin # # Authors: # Alvaro Lopez Ortega <alvaro@alobbs.com> # # Copyright (C) 2009 Alvaro Lopez Ortega # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public # License as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # import CTK import validations URL_APPLY = '/plugin/rrd/apply' NOTE_DB_DIR = N_("Directory where the RRDtool databases should be written.") NOTE_RRDTOOL = N_("Path to the rrdtool binary. By default the server will look in the PATH.") class Plugin_rrd (CTK.Plugin): def __init__ (self, key): CTK.Plugin.__init__ (self, key) # GUI table = CTK.PropsAuto (URL_APPLY) table.Add (_('Round Robin Database directory'), CTK.TextCfg('%s!database_dir'%(key), True), _(NOTE_DB_DIR)) table.Add (_('Custom rrdtool binary'), CTK.TextCfg('%s!rrdtool_path'%(key), True), _(NOTE_RRDTOOL)) self += table # Input Validation VALS = [('%s!database_dir'%(key), validations.is_local_dir_exists), ('%s!rrdtool_path'%(key), validations.is_exec_file)] CTK.publish ('^%s'%(URL_APPLY), CTK.cfg_apply_post, validation=VALS, method="POST")
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 30992, 79, 415, 13, 2113, 199, 3, 199, 3, 6642, 26, 199, 3, 420, 4580, 1391, 79, 3835, 321, 90, 4236, 266, 5294, 665, 279, 1391, 79, 32, 279, 2873, 1533, 14, 957, 30, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 4580, 1391, 79, 3835, 321, 90, 4236, 266, 5294, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 1015, 499, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 646, 445, 15263, 199, 646, 1686, 1298, 199, 199, 2632, 63, 1282, 31370, 275, 1994, 2718, 15, 82, 6883, 15, 4998, 7, 199, 199, 19855, 63, 2846, 63, 3022, 221, 275, 653, 14332, 6231, 2382, 314, 820, 15543, 3557, 16219, 1077, 506, 5313, 2685, 199, 19855, 63, 13381, 36, 9731, 275, 653, 14332, 2042, 370, 314, 519, 6883, 3557, 3366, 14, 4885, 849, 314, 1654, 911, 3648, 315, 314, 15097, 2685, 421, 199, 533, 11349, 63, 82, 6883, 334, 1028, 43, 14, 5061, 304, 272, 347, 636, 826, 363, 334, 277, 12, 790, 304, 267, 445, 15263, 14, 5061, 855, 826, 363, 334, 277, 12, 790, 9, 398, 327, 17160, 267, 1817, 275, 445, 15263, 14, 24188, 3358, 334, 2632, 63, 1282, 31370, 9, 267, 1817, 14, 1123, 21790, 18579, 6848, 1393, 8692, 2082, 659, 445, 15263, 14, 1872, 22457, 3508, 83, 1, 4659, 63, 694, 13328, 498, 395, 715, 395, 12561, 19855, 63, 2846, 63, 3022, 430, 267, 1817, 14, 1123, 21790, 7223, 519, 6883, 3557, 3366, 659, 221, 445, 15263, 14, 1872, 22457, 3508, 83, 1, 82, 6883, 3557, 63, 515, 13328, 498, 395, 715, 395, 12561, 19855, 63, 13381, 36, 9731, 430, 267, 291, 847, 1817, 398, 327, 6924, 19381, 267, 8986, 51, 275, 359, 3508, 83, 1, 4659, 63, 694, 13328, 498, 395, 1686, 1298, 14, 374, 63, 1832, 63, 694, 63, 2444, 395, 355, 16651, 83, 1, 82, 6883, 3557, 63, 515, 13328, 498, 395, 1686, 1298, 14, 374, 63, 1628, 63, 493, 1874, 398, 445, 15263, 14, 4763, 661, 62, 5, 83, 13328, 2632, 63, 1282, 31370, 395, 445, 15263, 14, 4128, 63, 4998, 63, 1932, 12, 6411, 29, 3204, 51, 12, 1083, 628, 4030, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 30992, 79, 415, 13, 2113, 199, 3, 199, 3, 6642, 26, 199, 3, 420, 4580, 1391, 79, 3835, 321, 90, 4236, 266, 5294, 665, 279, 1391, 79, 32, 279, 2873, 1533, 14, 957, 30, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 4580, 1391, 79, 3835, 321, 90, 4236, 266, 5294, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 1015, 499, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 646, 445, 15263, 199, 646, 1686, 1298, 199, 199, 2632, 63, 1282, 31370, 275, 1994, 2718, 15, 82, 6883, 15, 4998, 7, 199, 199, 19855, 63, 2846, 63, 3022, 221, 275, 653, 14332, 6231, 2382, 314, 820, 15543, 3557, 16219, 1077, 506, 5313, 2685, 199, 19855, 63, 13381, 36, 9731, 275, 653, 14332, 2042, 370, 314, 519, 6883, 3557, 3366, 14, 4885, 849, 314, 1654, 911, 3648, 315, 314, 15097, 2685, 421, 199, 533, 11349, 63, 82, 6883, 334, 1028, 43, 14, 5061, 304, 272, 347, 636, 826, 363, 334, 277, 12, 790, 304, 267, 445, 15263, 14, 5061, 855, 826, 363, 334, 277, 12, 790, 9, 398, 327, 17160, 267, 1817, 275, 445, 15263, 14, 24188, 3358, 334, 2632, 63, 1282, 31370, 9, 267, 1817, 14, 1123, 21790, 18579, 6848, 1393, 8692, 2082, 659, 445, 15263, 14, 1872, 22457, 3508, 83, 1, 4659, 63, 694, 13328, 498, 395, 715, 395, 12561, 19855, 63, 2846, 63, 3022, 430, 267, 1817, 14, 1123, 21790, 7223, 519, 6883, 3557, 3366, 659, 221, 445, 15263, 14, 1872, 22457, 3508, 83, 1, 82, 6883, 3557, 63, 515, 13328, 498, 395, 715, 395, 12561, 19855, 63, 13381, 36, 9731, 430, 267, 291, 847, 1817, 398, 327, 6924, 19381, 267, 8986, 51, 275, 359, 3508, 83, 1, 4659, 63, 694, 13328, 498, 395, 1686, 1298, 14, 374, 63, 1832, 63, 694, 63, 2444, 395, 355, 16651, 83, 1, 82, 6883, 3557, 63, 515, 13328, 498, 395, 1686, 1298, 14, 374, 63, 1628, 63, 493, 1874, 398, 445, 15263, 14, 4763, 661, 62, 5, 83, 13328, 2632, 63, 1282, 31370, 395, 445, 15263, 14, 4128, 63, 4998, 63, 1932, 12, 6411, 29, 3204, 51, 12, 1083, 628, 4030, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
vikatory/kbengine
kbe/res/scripts/common/Lib/unittest/test/_test_warnings.py
858
2304
# helper module for test_runner.Test_TextTestRunner.test_warnings """ This module has a number of tests that raise different kinds of warnings. When the tests are run, the warnings are caught and their messages are printed to stdout. This module also accepts an arg that is then passed to unittest.main to affect the behavior of warnings. Test_TextTestRunner.test_warnings executes this script with different combinations of warnings args and -W flags and check that the output is correct. See #10535. """ import sys import unittest import warnings def warnfun(): warnings.warn('rw', RuntimeWarning) class TestWarnings(unittest.TestCase): # unittest warnings will be printed at most once per type (max one message # for the fail* methods, and one for the assert* methods) def test_assert(self): self.assertEquals(2+2, 4) self.assertEquals(2*2, 4) self.assertEquals(2**2, 4) def test_fail(self): self.failUnless(1) self.failUnless(True) def test_other_unittest(self): self.assertAlmostEqual(2+2, 4) self.assertNotAlmostEqual(4+4, 2) # these warnings are normally silenced, but they are printed in unittest def test_deprecation(self): warnings.warn('dw', DeprecationWarning) warnings.warn('dw', DeprecationWarning) warnings.warn('dw', DeprecationWarning) def test_import(self): warnings.warn('iw', ImportWarning) warnings.warn('iw', ImportWarning) warnings.warn('iw', ImportWarning) # user warnings should always be printed def test_warning(self): warnings.warn('uw') warnings.warn('uw') warnings.warn('uw') # these warnings come from the same place; they will be printed # only once by default or three times if the 'always' filter is used def test_function(self): warnfun() warnfun() warnfun() if __name__ == '__main__': with warnings.catch_warnings(record=True) as ws: # if an arg is provided pass it to unittest.main as 'warnings' if len(sys.argv) == 2: unittest.main(exit=False, warnings=sys.argv.pop()) else: unittest.main(exit=False) # print all the warning messages collected for w in ws: print(w.message)
lgpl-3.0
[ 3, 5922, 859, 367, 511, 63, 5933, 14, 774, 63, 24285, 14, 396, 63, 5451, 199, 199, 624, 199, 2765, 859, 965, 282, 1329, 402, 2295, 626, 746, 3365, 24241, 402, 3598, 14, 199, 11423, 314, 2295, 787, 1255, 12, 314, 3598, 787, 15604, 436, 3932, 3788, 787, 12487, 199, 475, 3839, 14, 221, 961, 859, 2597, 11479, 376, 1680, 626, 365, 2066, 3032, 370, 199, 2796, 14, 973, 370, 12787, 314, 5953, 402, 3598, 14, 199, 774, 63, 24285, 14, 396, 63, 5451, 24956, 642, 2884, 543, 3365, 199, 18026, 402, 3598, 1249, 436, 446, 55, 3285, 436, 1104, 626, 314, 1072, 365, 3211, 14, 199, 9295, 327, 7320, 1276, 14, 199, 624, 199, 199, 646, 984, 199, 646, 2882, 199, 646, 3598, 199, 199, 318, 7987, 7036, 837, 272, 3598, 14, 4050, 360, 13057, 297, 25178, 9, 199, 199, 533, 1379, 15921, 8, 2796, 14, 1746, 304, 272, 327, 2882, 3598, 911, 506, 12487, 737, 4750, 5403, 1126, 730, 334, 988, 1373, 1245, 272, 327, 367, 314, 2449, 10, 3102, 12, 436, 1373, 367, 314, 702, 10, 3102, 9, 272, 347, 511, 63, 479, 8, 277, 304, 267, 291, 14, 2947, 8, 18, 11, 18, 12, 841, 9, 267, 291, 14, 2947, 8, 18, 10, 18, 12, 841, 9, 267, 291, 14, 2947, 8, 18, 538, 18, 12, 841, 9, 339, 347, 511, 63, 1633, 8, 277, 304, 267, 291, 14, 7589, 8, 17, 9, 267, 291, 14, 7589, 8, 549, 9, 339, 347, 511, 63, 1848, 63, 2796, 8, 277, 304, 267, 291, 14, 7904, 8, 18, 11, 18, 12, 841, 9, 267, 291, 14, 4809, 7331, 8, 20, 11, 20, 12, 499, 9, 339, 327, 3520, 3598, 787, 12252, 9767, 78, 6867, 12, 1325, 2985, 787, 12487, 315, 2882, 272, 347, 511, 63, 15383, 8, 277, 304, 267, 3598, 14, 4050, 360, 10772, 297, 13413, 9, 267, 3598, 14, 4050, 360, 10772, 297, 13413, 9, 267, 3598, 14, 4050, 360, 10772, 297, 13413, 9, 339, 347, 511, 63, 646, 8, 277, 304, 267, 3598, 14, 4050, 360, 73, 87, 297, 3161, 3849, 9, 267, 3598, 14, 4050, 360, 73, 87, 297, 3161, 3849, 9, 267, 3598, 14, 4050, 360, 73, 87, 297, 3161, 3849, 9, 339, 327, 922, 3598, 1077, 3544, 506, 12487, 272, 347, 511, 63, 3764, 8, 277, 304, 267, 3598, 14, 4050, 360, 29638, 358, 267, 3598, 14, 4050, 360, 29638, 358, 267, 3598, 14, 4050, 360, 29638, 358, 339, 327, 3520, 3598, 11492, 687, 314, 2011, 4192, 27, 2985, 911, 506, 12487, 272, 327, 1454, 5403, 701, 849, 503, 7795, 5431, 340, 314, 283, 9223, 7, 2457, 365, 1202, 272, 347, 511, 63, 1593, 8, 277, 304, 398, 7987, 7036, 342, 267, 7987, 7036, 342, 267, 7987, 7036, 342, 4388, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 10900, 26, 267, 327, 340, 376, 1680, 365, 2741, 986, 652, 370, 2882, 14, 973, 465, 283, 5451, 7, 267, 340, 822, 8, 1274, 14, 3020, 9, 508, 499, 26, 288, 2882, 14, 973, 8, 2224, 29, 797, 12, 3598, 29, 1274, 14, 3020, 14, 1935, 1012, 267, 587, 26, 288, 2882, 14, 973, 8, 2224, 29, 797, 9, 339, 327, 870, 1006, 314, 5721, 3788, 13736, 272, 367, 336, 315, 10900, 26, 267, 870, 8, 87, 14, 1188, 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 ]
[ 5922, 859, 367, 511, 63, 5933, 14, 774, 63, 24285, 14, 396, 63, 5451, 199, 199, 624, 199, 2765, 859, 965, 282, 1329, 402, 2295, 626, 746, 3365, 24241, 402, 3598, 14, 199, 11423, 314, 2295, 787, 1255, 12, 314, 3598, 787, 15604, 436, 3932, 3788, 787, 12487, 199, 475, 3839, 14, 221, 961, 859, 2597, 11479, 376, 1680, 626, 365, 2066, 3032, 370, 199, 2796, 14, 973, 370, 12787, 314, 5953, 402, 3598, 14, 199, 774, 63, 24285, 14, 396, 63, 5451, 24956, 642, 2884, 543, 3365, 199, 18026, 402, 3598, 1249, 436, 446, 55, 3285, 436, 1104, 626, 314, 1072, 365, 3211, 14, 199, 9295, 327, 7320, 1276, 14, 199, 624, 199, 199, 646, 984, 199, 646, 2882, 199, 646, 3598, 199, 199, 318, 7987, 7036, 837, 272, 3598, 14, 4050, 360, 13057, 297, 25178, 9, 199, 199, 533, 1379, 15921, 8, 2796, 14, 1746, 304, 272, 327, 2882, 3598, 911, 506, 12487, 737, 4750, 5403, 1126, 730, 334, 988, 1373, 1245, 272, 327, 367, 314, 2449, 10, 3102, 12, 436, 1373, 367, 314, 702, 10, 3102, 9, 272, 347, 511, 63, 479, 8, 277, 304, 267, 291, 14, 2947, 8, 18, 11, 18, 12, 841, 9, 267, 291, 14, 2947, 8, 18, 10, 18, 12, 841, 9, 267, 291, 14, 2947, 8, 18, 538, 18, 12, 841, 9, 339, 347, 511, 63, 1633, 8, 277, 304, 267, 291, 14, 7589, 8, 17, 9, 267, 291, 14, 7589, 8, 549, 9, 339, 347, 511, 63, 1848, 63, 2796, 8, 277, 304, 267, 291, 14, 7904, 8, 18, 11, 18, 12, 841, 9, 267, 291, 14, 4809, 7331, 8, 20, 11, 20, 12, 499, 9, 339, 327, 3520, 3598, 787, 12252, 9767, 78, 6867, 12, 1325, 2985, 787, 12487, 315, 2882, 272, 347, 511, 63, 15383, 8, 277, 304, 267, 3598, 14, 4050, 360, 10772, 297, 13413, 9, 267, 3598, 14, 4050, 360, 10772, 297, 13413, 9, 267, 3598, 14, 4050, 360, 10772, 297, 13413, 9, 339, 347, 511, 63, 646, 8, 277, 304, 267, 3598, 14, 4050, 360, 73, 87, 297, 3161, 3849, 9, 267, 3598, 14, 4050, 360, 73, 87, 297, 3161, 3849, 9, 267, 3598, 14, 4050, 360, 73, 87, 297, 3161, 3849, 9, 339, 327, 922, 3598, 1077, 3544, 506, 12487, 272, 347, 511, 63, 3764, 8, 277, 304, 267, 3598, 14, 4050, 360, 29638, 358, 267, 3598, 14, 4050, 360, 29638, 358, 267, 3598, 14, 4050, 360, 29638, 358, 339, 327, 3520, 3598, 11492, 687, 314, 2011, 4192, 27, 2985, 911, 506, 12487, 272, 327, 1454, 5403, 701, 849, 503, 7795, 5431, 340, 314, 283, 9223, 7, 2457, 365, 1202, 272, 347, 511, 63, 1593, 8, 277, 304, 398, 7987, 7036, 342, 267, 7987, 7036, 342, 267, 7987, 7036, 342, 4388, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 10900, 26, 267, 327, 340, 376, 1680, 365, 2741, 986, 652, 370, 2882, 14, 973, 465, 283, 5451, 7, 267, 340, 822, 8, 1274, 14, 3020, 9, 508, 499, 26, 288, 2882, 14, 973, 8, 2224, 29, 797, 12, 3598, 29, 1274, 14, 3020, 14, 1935, 1012, 267, 587, 26, 288, 2882, 14, 973, 8, 2224, 29, 797, 9, 339, 327, 870, 1006, 314, 5721, 3788, 13736, 272, 367, 336, 315, 10900, 26, 267, 870, 8, 87, 14, 1188, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
dberroya/trad-arducopter
Tools/autotest/pysim/fdpexpect.py
264
2488
"""This is like pexpect, but will work on any file descriptor that you pass it. So you are reponsible for opening and close the file descriptor. $Id: fdpexpect.py 505 2007-12-26 21:33:50Z noah $ """ from pexpect import * import os __all__ = ['fdspawn'] class fdspawn (spawn): """This is like pexpect.spawn but allows you to supply your own open file descriptor. For example, you could use it to read through a file looking for patterns, or to control a modem or serial device. """ def __init__ (self, fd, args=[], timeout=30, maxread=2000, searchwindowsize=None, logfile=None): """This takes a file descriptor (an int) or an object that support the fileno() method (returning an int). All Python file-like objects support fileno(). """ ### TODO: Add better handling of trying to use fdspawn in place of spawn ### TODO: (overload to allow fdspawn to also handle commands as spawn does. if type(fd) != type(0) and hasattr(fd, 'fileno'): fd = fd.fileno() if type(fd) != type(0): raise ExceptionPexpect ('The fd argument is not an int. If this is a command string then maybe you want to use pexpect.spawn.') try: # make sure fd is a valid file descriptor os.fstat(fd) except OSError: raise ExceptionPexpect, 'The fd argument is not a valid file descriptor.' self.args = None self.command = None spawn.__init__(self, None, args, timeout, maxread, searchwindowsize, logfile) self.child_fd = fd self.own_fd = False self.closed = False self.name = '<file descriptor %d>' % fd def __del__ (self): return def close (self): if self.child_fd == -1: return if self.own_fd: self.close (self) else: self.flush() os.close(self.child_fd) self.child_fd = -1 self.closed = True def isalive (self): """This checks if the file descriptor is still valid. If os.fstat() does not raise an exception then we assume it is alive. """ if self.child_fd == -1: return False try: os.fstat(self.child_fd) return True except: return False def terminate (self, force=False): raise ExceptionPexpect ('This method is not valid for file descriptors.') def kill (self, sig): return
gpl-3.0
[ 624, 2765, 365, 2839, 28855, 12, 1325, 911, 1736, 641, 1263, 570, 5872, 626, 1265, 986, 652, 14, 199, 5158, 1265, 787, 295, 678, 1164, 367, 13618, 436, 4002, 314, 570, 5872, 14, 199, 199, 4, 1304, 26, 6111, 16531, 1764, 14, 647, 959, 1717, 10219, 13, 713, 13, 1479, 7829, 26, 1153, 26, 1400, 58, 949, 11326, 2672, 199, 624, 199, 199, 504, 28855, 492, 627, 199, 646, 747, 199, 199, 363, 452, 363, 275, 788, 14240, 387, 3501, 418, 199, 199, 533, 289, 795, 387, 3501, 334, 10212, 304, 339, 408, 2765, 365, 2839, 28855, 14, 10212, 1325, 6127, 1265, 370, 17169, 2195, 5705, 1551, 570, 272, 5872, 14, 2104, 2893, 12, 1265, 4293, 675, 652, 370, 1586, 4012, 282, 570, 10023, 272, 367, 7970, 12, 503, 370, 3304, 282, 818, 77, 503, 3012, 2243, 14, 408, 339, 347, 636, 826, 363, 334, 277, 12, 6111, 12, 1249, 6034, 2653, 29, 1216, 12, 1390, 739, 29, 8269, 12, 2754, 3806, 890, 29, 403, 12, 17251, 29, 403, 304, 398, 408, 2765, 6181, 282, 570, 5872, 334, 290, 1109, 9, 503, 376, 909, 626, 2291, 314, 267, 25255, 342, 1083, 334, 24112, 376, 1109, 680, 2900, 2018, 570, 13, 2930, 2251, 267, 2291, 25255, 1252, 408, 398, 6754, 3254, 26, 2654, 8034, 7252, 402, 9936, 370, 675, 289, 795, 387, 3501, 315, 4192, 402, 15187, 267, 6754, 3254, 26, 334, 1883, 912, 370, 2040, 289, 795, 387, 3501, 370, 2597, 2429, 3718, 465, 15187, 1630, 14, 398, 340, 730, 8, 2592, 9, 1137, 730, 8, 16, 9, 436, 2688, 8, 2592, 12, 283, 9843, 735, 288, 6111, 275, 6111, 14, 9843, 342, 398, 340, 730, 8, 2592, 9, 1137, 730, 8, 16, 304, 288, 746, 2186, 48, 4921, 661, 1918, 6111, 1423, 365, 440, 376, 1109, 14, 982, 642, 365, 282, 1414, 1059, 2066, 11703, 1265, 2934, 370, 675, 28855, 14, 10212, 2659, 398, 862, 26, 327, 1852, 3238, 6111, 365, 282, 1686, 570, 5872, 288, 747, 14, 32127, 8, 2592, 9, 267, 871, 6440, 26, 288, 746, 2186, 48, 4921, 12, 283, 1918, 6111, 1423, 365, 440, 282, 1686, 570, 5872, 3530, 398, 291, 14, 589, 275, 488, 267, 291, 14, 1531, 275, 488, 267, 15187, 855, 826, 721, 277, 12, 488, 12, 1249, 12, 2653, 12, 1390, 739, 12, 2754, 3806, 890, 12, 17251, 9, 267, 291, 14, 1739, 63, 2592, 275, 6111, 267, 291, 14, 944, 63, 2592, 275, 756, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 354, 275, 2650, 493, 5872, 450, 68, 3524, 450, 6111, 339, 347, 636, 2264, 363, 334, 277, 304, 398, 372, 339, 347, 4002, 334, 277, 304, 398, 340, 291, 14, 1739, 63, 2592, 508, 446, 17, 26, 288, 372, 267, 340, 291, 14, 944, 63, 2592, 26, 288, 291, 14, 1600, 334, 277, 9, 267, 587, 26, 288, 291, 14, 4939, 342, 288, 747, 14, 1600, 8, 277, 14, 1739, 63, 2592, 9, 288, 291, 14, 1739, 63, 2592, 275, 446, 17, 288, 291, 14, 5938, 275, 715, 339, 347, 365, 9631, 334, 277, 304, 398, 408, 2765, 5920, 340, 314, 570, 5872, 365, 5139, 1686, 14, 982, 747, 14, 32127, 342, 267, 1630, 440, 746, 376, 1919, 2066, 781, 5534, 652, 365, 19708, 14, 408, 398, 340, 291, 14, 1739, 63, 2592, 508, 446, 17, 26, 288, 372, 756, 267, 862, 26, 288, 747, 14, 32127, 8, 277, 14, 1739, 63, 2592, 9, 288, 372, 715, 267, 871, 26, 288, 372, 756, 339, 347, 15095, 334, 277, 12, 3542, 29, 797, 304, 398, 746, 2186, 48, 4921, 661, 2765, 1083, 365, 440, 1686, 367, 570, 15428, 2659, 339, 347, 14561, 334, 277, 12, 5259, 304, 398, 372, 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 ]
[ 2765, 365, 2839, 28855, 12, 1325, 911, 1736, 641, 1263, 570, 5872, 626, 1265, 986, 652, 14, 199, 5158, 1265, 787, 295, 678, 1164, 367, 13618, 436, 4002, 314, 570, 5872, 14, 199, 199, 4, 1304, 26, 6111, 16531, 1764, 14, 647, 959, 1717, 10219, 13, 713, 13, 1479, 7829, 26, 1153, 26, 1400, 58, 949, 11326, 2672, 199, 624, 199, 199, 504, 28855, 492, 627, 199, 646, 747, 199, 199, 363, 452, 363, 275, 788, 14240, 387, 3501, 418, 199, 199, 533, 289, 795, 387, 3501, 334, 10212, 304, 339, 408, 2765, 365, 2839, 28855, 14, 10212, 1325, 6127, 1265, 370, 17169, 2195, 5705, 1551, 570, 272, 5872, 14, 2104, 2893, 12, 1265, 4293, 675, 652, 370, 1586, 4012, 282, 570, 10023, 272, 367, 7970, 12, 503, 370, 3304, 282, 818, 77, 503, 3012, 2243, 14, 408, 339, 347, 636, 826, 363, 334, 277, 12, 6111, 12, 1249, 6034, 2653, 29, 1216, 12, 1390, 739, 29, 8269, 12, 2754, 3806, 890, 29, 403, 12, 17251, 29, 403, 304, 398, 408, 2765, 6181, 282, 570, 5872, 334, 290, 1109, 9, 503, 376, 909, 626, 2291, 314, 267, 25255, 342, 1083, 334, 24112, 376, 1109, 680, 2900, 2018, 570, 13, 2930, 2251, 267, 2291, 25255, 1252, 408, 398, 6754, 3254, 26, 2654, 8034, 7252, 402, 9936, 370, 675, 289, 795, 387, 3501, 315, 4192, 402, 15187, 267, 6754, 3254, 26, 334, 1883, 912, 370, 2040, 289, 795, 387, 3501, 370, 2597, 2429, 3718, 465, 15187, 1630, 14, 398, 340, 730, 8, 2592, 9, 1137, 730, 8, 16, 9, 436, 2688, 8, 2592, 12, 283, 9843, 735, 288, 6111, 275, 6111, 14, 9843, 342, 398, 340, 730, 8, 2592, 9, 1137, 730, 8, 16, 304, 288, 746, 2186, 48, 4921, 661, 1918, 6111, 1423, 365, 440, 376, 1109, 14, 982, 642, 365, 282, 1414, 1059, 2066, 11703, 1265, 2934, 370, 675, 28855, 14, 10212, 2659, 398, 862, 26, 327, 1852, 3238, 6111, 365, 282, 1686, 570, 5872, 288, 747, 14, 32127, 8, 2592, 9, 267, 871, 6440, 26, 288, 746, 2186, 48, 4921, 12, 283, 1918, 6111, 1423, 365, 440, 282, 1686, 570, 5872, 3530, 398, 291, 14, 589, 275, 488, 267, 291, 14, 1531, 275, 488, 267, 15187, 855, 826, 721, 277, 12, 488, 12, 1249, 12, 2653, 12, 1390, 739, 12, 2754, 3806, 890, 12, 17251, 9, 267, 291, 14, 1739, 63, 2592, 275, 6111, 267, 291, 14, 944, 63, 2592, 275, 756, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 354, 275, 2650, 493, 5872, 450, 68, 3524, 450, 6111, 339, 347, 636, 2264, 363, 334, 277, 304, 398, 372, 339, 347, 4002, 334, 277, 304, 398, 340, 291, 14, 1739, 63, 2592, 508, 446, 17, 26, 288, 372, 267, 340, 291, 14, 944, 63, 2592, 26, 288, 291, 14, 1600, 334, 277, 9, 267, 587, 26, 288, 291, 14, 4939, 342, 288, 747, 14, 1600, 8, 277, 14, 1739, 63, 2592, 9, 288, 291, 14, 1739, 63, 2592, 275, 446, 17, 288, 291, 14, 5938, 275, 715, 339, 347, 365, 9631, 334, 277, 304, 398, 408, 2765, 5920, 340, 314, 570, 5872, 365, 5139, 1686, 14, 982, 747, 14, 32127, 342, 267, 1630, 440, 746, 376, 1919, 2066, 781, 5534, 652, 365, 19708, 14, 408, 398, 340, 291, 14, 1739, 63, 2592, 508, 446, 17, 26, 288, 372, 756, 267, 862, 26, 288, 747, 14, 32127, 8, 277, 14, 1739, 63, 2592, 9, 288, 372, 715, 267, 871, 26, 288, 372, 756, 339, 347, 15095, 334, 277, 12, 3542, 29, 797, 304, 398, 746, 2186, 48, 4921, 661, 2765, 1083, 365, 440, 1686, 367, 570, 15428, 2659, 339, 347, 14561, 334, 277, 12, 5259, 304, 398, 372, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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ribution_behaviorGBM(): #Log.info("==============================") #Log.info("Default Behavior - Gaussian") #Log.info("==============================") eco = h2o.import_file(path=h2o.locate("smalldata/gbm_test/ecology_model.csv")) # 0/1 response: expect gaussian eco_model = h2o.gbm(x=eco[2:13], y=eco["Angaus"]) assert isinstance(eco_model,h2o.model.regression.H2ORegressionModel) # more than 2 integers for response: expect gaussian cars = h2o.import_file(path=h2o.locate("smalldata/junit/cars.csv")) cars_model = h2o.gbm(x=cars[3:7], y=cars["cylinders"]) assert isinstance(cars_model,h2o.model.regression.H2ORegressionModel) #Log.info("==============================") #Log.info("Gaussian Behavior") #Log.info("==============================") # 0/1 response: expect gaussian eco_model = h2o.gbm(x=eco[2:13], y=eco["Angaus"], distribution="gaussian") assert isinstance(eco_model,h2o.model.regression.H2ORegressionModel) # character response: expect error try: eco_model = h2o.gbm(x=eco[1:8], y=eco["Method"], distribution="gaussian") assert False, "expected an error" except EnvironmentError: assert True #Log.info("==============================") #Log.info("Bernoulli Behavior") #Log.info("==============================") # 0/1 response: expect bernoulli eco_model = h2o.gbm(x=eco[2:13], y=eco["Angaus"].asfactor(), distribution="bernoulli") assert isinstance(eco_model,h2o.model.binomial.H2OBinomialModel) # 2 level character response: expect bernoulli tree = h2o.import_file(path=h2o.locate("smalldata/junit/test_tree_minmax.csv")) tree_model = h2o.gbm(x=tree[0:3], y=tree["response"], distribution="bernoulli", min_rows=1) assert isinstance(tree_model,h2o.model.binomial.H2OBinomialModel) # more than two integers for response: expect error try: cars_mod = h2o.gbm(x=cars[3:7], y=cars["cylinders"], distribution="bernoulli") assert False, "expected an error" except EnvironmentError: assert True # more than two character levels for response: expect error try: eco_model = h2o.gbm(x=eco[0:8], y=eco["Method"], distribution="bernoulli") assert False, "expected an error" except EnvironmentError: assert True #Log.info("==============================") #Log.info("Multinomial Behavior") #Log.info("==============================") # more than two integers for response: expect multinomial cars_model = h2o.gbm(x=cars[3:7], y=cars["cylinders"].asfactor(), distribution="multinomial") assert isinstance(cars_model,h2o.model.multinomial.H2OMultinomialModel) # more than two character levels for response: expect multinomial eco_model = h2o.gbm(x=eco[0:8], y=eco["Method"], distribution="multinomial") assert isinstance(eco_model,h2o.model.multinomial.H2OMultinomialModel) if __name__ == "__main__": tests.run_test(sys.argv, distribution_behaviorGBM)
apache-2.0
[ 646, 984, 199, 1274, 14, 515, 14, 3176, 8, 17, 12, 298, 29866, 531, 199, 646, 394, 18, 79, 12, 2295, 199, 199, 318, 4084, 63, 17537, 6487, 45, 837, 2043, 2043, 819, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 2445, 14, 815, 480, 2698, 6423, 13115, 446, 17131, 531, 523, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 325, 331, 275, 394, 18, 79, 14, 646, 63, 493, 8, 515, 29, 72, 18, 79, 14, 6280, 480, 7241, 576, 15, 4908, 77, 63, 396, 15, 69, 331, 4956, 63, 1238, 14, 4737, 2237, 523, 327, 378, 15, 17, 1177, 26, 4282, 28912, 523, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 18, 26, 969, 467, 612, 29, 69, 331, 905, 2493, 5294, 527, 3135, 523, 702, 1228, 8, 69, 331, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 12513, 14, 40, 18, 47, 13013, 1685, 9, 523, 327, 1655, 2419, 499, 9446, 367, 1177, 26, 4282, 28912, 523, 286, 4291, 275, 394, 18, 79, 14, 646, 63, 493, 8, 515, 29, 72, 18, 79, 14, 6280, 480, 7241, 576, 15, 74, 3248, 15, 67, 4291, 14, 4737, 2237, 523, 286, 4291, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 67, 4291, 59, 19, 26, 23, 467, 612, 29, 67, 4291, 905, 1480, 472, 7735, 3135, 523, 702, 1228, 8, 67, 4291, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 12513, 14, 40, 18, 47, 13013, 1685, 9, 819, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 2445, 14, 815, 480, 26756, 6423, 13115, 531, 523, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 378, 15, 17, 1177, 26, 4282, 28912, 523, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 18, 26, 969, 467, 612, 29, 69, 331, 905, 2493, 5294, 527, 2255, 4084, 628, 22911, 531, 523, 702, 1228, 8, 69, 331, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 12513, 14, 40, 18, 47, 13013, 1685, 9, 523, 327, 4528, 1177, 26, 4282, 1125, 523, 862, 26, 272, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 17, 26, 24, 467, 612, 29, 69, 331, 905, 3767, 2255, 4084, 628, 22911, 531, 272, 702, 756, 12, 298, 2062, 376, 1125, 2, 523, 871, 25139, 26, 272, 702, 715, 819, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 2445, 14, 815, 480, 24947, 24992, 6423, 13115, 531, 523, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 378, 15, 17, 1177, 26, 4282, 330, 281, 24992, 523, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 18, 26, 969, 467, 612, 29, 69, 331, 905, 2493, 5294, 527, 4140, 305, 4778, 1062, 4084, 628, 605, 24992, 531, 523, 702, 1228, 8, 69, 331, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 27578, 14, 40, 18, 5488, 16956, 1685, 9, 523, 327, 499, 2166, 4528, 1177, 26, 4282, 330, 281, 24992, 523, 3123, 275, 394, 18, 79, 14, 646, 63, 493, 8, 515, 29, 72, 18, 79, 14, 6280, 480, 7241, 576, 15, 74, 3248, 15, 396, 63, 2350, 63, 827, 988, 14, 4737, 2237, 523, 3123, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 2350, 59, 16, 26, 19, 467, 612, 29, 2350, 905, 1310, 2255, 4084, 628, 605, 24992, 401, 1748, 63, 3838, 29, 17, 9, 523, 702, 1228, 8, 2350, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 27578, 14, 40, 18, 5488, 16956, 1685, 9, 523, 327, 1655, 2419, 2877, 9446, 367, 1177, 26, 4282, 1125, 523, 862, 26, 272, 286, 4291, 63, 1494, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 67, 4291, 59, 19, 26, 23, 467, 612, 29, 67, 4291, 905, 1480, 472, 7735, 2255, 4084, 628, 605, 24992, 531, 272, 702, 756, 12, 298, 2062, 376, 1125, 2, 523, 871, 25139, 26, 272, 702, 715, 523, 327, 1655, 2419, 2877, 4528, 11106, 367, 1177, 26, 4282, 1125, 523, 862, 26, 272, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 16, 26, 24, 467, 612, 29, 69, 331, 905, 3767, 2255, 4084, 628, 605, 24992, 531, 272, 702, 756, 12, 298, 2062, 376, 1125, 2, 523, 871, 25139, 26, 272, 702, 715, 819, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 2445, 14, 815, 480, 30233, 16956, 6423, 13115, 531, 523, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 1655, 2419, 2877, 9446, 367, 1177, 26, 4282, 20861, 16956, 523, 286, 4291, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 67, 4291, 59, 19, 26, 23, 467, 612, 29, 67, 4291, 905, 1480, 472, 7735, 4140, 305, 4778, 1062, 4084, 628, 28265, 531, 523, 702, 1228, 8, 67, 4291, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 28265, 14, 40, 18, 7474, 427, 16956, 1685, 9, 523, 327, 1655, 2419, 2877, 4528, 11106, 367, 1177, 26, 4282, 20861, 16956, 523, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 16, 26, 24, 467, 612, 29, 69, 331, 905, 3767, 2255, 4084, 628, 28265, 531, 523, 702, 1228, 8, 69, 331, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 28265, 14, 40, 18, 7474, 427, 16956, 1685, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2295, 14, 1065, 63, 396, 8, 1274, 14, 3020, 12, 4084, 63, 17537, 6487, 45, 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 ]
[ 984, 199, 1274, 14, 515, 14, 3176, 8, 17, 12, 298, 29866, 531, 199, 646, 394, 18, 79, 12, 2295, 199, 199, 318, 4084, 63, 17537, 6487, 45, 837, 2043, 2043, 819, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 2445, 14, 815, 480, 2698, 6423, 13115, 446, 17131, 531, 523, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 325, 331, 275, 394, 18, 79, 14, 646, 63, 493, 8, 515, 29, 72, 18, 79, 14, 6280, 480, 7241, 576, 15, 4908, 77, 63, 396, 15, 69, 331, 4956, 63, 1238, 14, 4737, 2237, 523, 327, 378, 15, 17, 1177, 26, 4282, 28912, 523, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 18, 26, 969, 467, 612, 29, 69, 331, 905, 2493, 5294, 527, 3135, 523, 702, 1228, 8, 69, 331, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 12513, 14, 40, 18, 47, 13013, 1685, 9, 523, 327, 1655, 2419, 499, 9446, 367, 1177, 26, 4282, 28912, 523, 286, 4291, 275, 394, 18, 79, 14, 646, 63, 493, 8, 515, 29, 72, 18, 79, 14, 6280, 480, 7241, 576, 15, 74, 3248, 15, 67, 4291, 14, 4737, 2237, 523, 286, 4291, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 67, 4291, 59, 19, 26, 23, 467, 612, 29, 67, 4291, 905, 1480, 472, 7735, 3135, 523, 702, 1228, 8, 67, 4291, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 12513, 14, 40, 18, 47, 13013, 1685, 9, 819, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 2445, 14, 815, 480, 26756, 6423, 13115, 531, 523, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 378, 15, 17, 1177, 26, 4282, 28912, 523, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 18, 26, 969, 467, 612, 29, 69, 331, 905, 2493, 5294, 527, 2255, 4084, 628, 22911, 531, 523, 702, 1228, 8, 69, 331, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 12513, 14, 40, 18, 47, 13013, 1685, 9, 523, 327, 4528, 1177, 26, 4282, 1125, 523, 862, 26, 272, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 17, 26, 24, 467, 612, 29, 69, 331, 905, 3767, 2255, 4084, 628, 22911, 531, 272, 702, 756, 12, 298, 2062, 376, 1125, 2, 523, 871, 25139, 26, 272, 702, 715, 819, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 2445, 14, 815, 480, 24947, 24992, 6423, 13115, 531, 523, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 378, 15, 17, 1177, 26, 4282, 330, 281, 24992, 523, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 18, 26, 969, 467, 612, 29, 69, 331, 905, 2493, 5294, 527, 4140, 305, 4778, 1062, 4084, 628, 605, 24992, 531, 523, 702, 1228, 8, 69, 331, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 27578, 14, 40, 18, 5488, 16956, 1685, 9, 523, 327, 499, 2166, 4528, 1177, 26, 4282, 330, 281, 24992, 523, 3123, 275, 394, 18, 79, 14, 646, 63, 493, 8, 515, 29, 72, 18, 79, 14, 6280, 480, 7241, 576, 15, 74, 3248, 15, 396, 63, 2350, 63, 827, 988, 14, 4737, 2237, 523, 3123, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 2350, 59, 16, 26, 19, 467, 612, 29, 2350, 905, 1310, 2255, 4084, 628, 605, 24992, 401, 1748, 63, 3838, 29, 17, 9, 523, 702, 1228, 8, 2350, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 27578, 14, 40, 18, 5488, 16956, 1685, 9, 523, 327, 1655, 2419, 2877, 9446, 367, 1177, 26, 4282, 1125, 523, 862, 26, 272, 286, 4291, 63, 1494, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 67, 4291, 59, 19, 26, 23, 467, 612, 29, 67, 4291, 905, 1480, 472, 7735, 2255, 4084, 628, 605, 24992, 531, 272, 702, 756, 12, 298, 2062, 376, 1125, 2, 523, 871, 25139, 26, 272, 702, 715, 523, 327, 1655, 2419, 2877, 4528, 11106, 367, 1177, 26, 4282, 1125, 523, 862, 26, 272, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 16, 26, 24, 467, 612, 29, 69, 331, 905, 3767, 2255, 4084, 628, 605, 24992, 531, 272, 702, 756, 12, 298, 2062, 376, 1125, 2, 523, 871, 25139, 26, 272, 702, 715, 819, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 2445, 14, 815, 480, 30233, 16956, 6423, 13115, 531, 523, 327, 2445, 14, 815, 480, 1280, 17224, 531, 523, 327, 1655, 2419, 2877, 9446, 367, 1177, 26, 4282, 20861, 16956, 523, 286, 4291, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 67, 4291, 59, 19, 26, 23, 467, 612, 29, 67, 4291, 905, 1480, 472, 7735, 4140, 305, 4778, 1062, 4084, 628, 28265, 531, 523, 702, 1228, 8, 67, 4291, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 28265, 14, 40, 18, 7474, 427, 16956, 1685, 9, 523, 327, 1655, 2419, 2877, 4528, 11106, 367, 1177, 26, 4282, 20861, 16956, 523, 325, 331, 63, 1238, 275, 394, 18, 79, 14, 4908, 77, 8, 88, 29, 69, 331, 59, 16, 26, 24, 467, 612, 29, 69, 331, 905, 3767, 2255, 4084, 628, 28265, 531, 523, 702, 1228, 8, 69, 331, 63, 1238, 12, 72, 18, 79, 14, 1238, 14, 28265, 14, 40, 18, 7474, 427, 16956, 1685, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2295, 14, 1065, 63, 396, 8, 1274, 14, 3020, 12, 4084, 63, 17537, 6487, 45, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
loveward/yingsuo
mujson_mgr.py
1
10335
#!/usr/bin/python # -*- coding: UTF-8 -*- import traceback from shadowsocks import shell, common from configloader import load_config, get_config import random import getopt import sys import json import base64 class MuJsonLoader(object): def __init__(self): self.json = None def load(self, path): l = "[]" try: with open(path, 'rb+') as f: l = f.read().decode('utf8') except: pass self.json = json.loads(l) def save(self, path): if self.json is not None: output = json.dumps(self.json, sort_keys=True, indent=4, separators=(',', ': ')) with open(path, 'a'): pass with open(path, 'rb+') as f: f.write(output.encode('utf8')) f.truncate() class MuMgr(object): def __init__(self): self.config_path = get_config().MUDB_FILE try: self.server_addr = get_config().SERVER_PUB_ADDR except: self.server_addr = '127.0.0.1' self.data = MuJsonLoader() if self.server_addr == '127.0.0.1': self.server_addr = self.getipaddr() def getipaddr(self, ifname='eth0'): import socket import struct ret = '127.0.0.1' try: ret = socket.gethostbyname(socket.getfqdn(socket.gethostname())) except: pass if ret == '127.0.0.1': try: import fcntl s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ret = socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))[20:24]) except: pass return ret def ssrlink(self, user, encode, muid): protocol = user.get('protocol', '') obfs = user.get('obfs', '') protocol = protocol.replace("_compatible", "") obfs = obfs.replace("_compatible", "") protocol_param = '' if muid is not None: protocol_param_ = user.get('protocol_param', '') param = protocol_param_.split('#') if len(param) == 2: for row in self.data.json: if int(row['port']) == muid: param = str(muid) + ':' + row['passwd'] protocol_param = '/?protoparam=' + common.to_str(base64.urlsafe_b64encode(common.to_bytes(param))).replace("=", "") break link = ("%s:%s:%s:%s:%s:%s" % (self.server_addr, user['port'], protocol, user['method'], obfs, common.to_str(base64.urlsafe_b64encode(common.to_bytes(user['passwd']))).replace("=", ""))) + protocol_param return "ssr://" + (encode and common.to_str(base64.urlsafe_b64encode(common.to_bytes(link))).replace("=", "") or link) def userinfo(self, user, muid = None): ret = "" key_list = ['user', 'port', 'method', 'passwd', 'protocol', 'protocol_param', 'obfs', 'obfs_param', 'transfer_enable', 'u', 'd'] for key in sorted(user): if key not in key_list: key_list.append(key) for key in key_list: if key in ['enable'] or key not in user: continue ret += '\n' if (muid is not None) and (key in ['protocol_param']): for row in self.data.json: if int(row['port']) == muid: ret += " %s : %s" % (key, str(muid) + ':' + row['passwd']) break elif key in ['transfer_enable', 'u', 'd']: if muid is not None: for row in self.data.json: if int(row['port']) == muid: val = row[key] break else: val = user[key] if val / 1024 < 4: ret += " %s : %s" % (key, val) elif val / 1024 ** 2 < 4: val /= float(1024) ret += " %s : %s K Bytes" % (key, val) elif val / 1024 ** 3 < 4: val /= float(1024 ** 2) ret += " %s : %s M Bytes" % (key, val) else: val /= float(1024 ** 3) ret += " %s : %s G Bytes" % (key, val) else: ret += " %s : %s" % (key, user[key]) ret += "\n " + self.ssrlink(user, False, muid) ret += "\n " + self.ssrlink(user, True, muid) return ret def rand_pass(self): return ''.join([random.choice('''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~-_=+(){}[]^&%$@''') for i in range(8)]) def add(self, user): up = {'enable': 1, 'u': 0, 'd': 0, 'method': "aes-128-ctr", 'protocol': "auth_aes128_md5", 'obfs': "tls1.2_ticket_auth_compatible", 'transfer_enable': 9007199254740992} up['passwd'] = self.rand_pass() up.update(user) self.data.load(self.config_path) for row in self.data.json: match = False if 'user' in user and row['user'] == user['user']: match = True if 'port' in user and row['port'] == user['port']: match = True if match: print("user [%s] port [%s] already exist" % (row['user'], row['port'])) return self.data.json.append(up) print("### add user info %s" % self.userinfo(up)) self.data.save(self.config_path) def edit(self, user): self.data.load(self.config_path) for row in self.data.json: match = True if 'user' in user and row['user'] != user['user']: match = False if 'port' in user and row['port'] != user['port']: match = False if match: print("edit user [%s]" % (row['user'],)) row.update(user) print("### new user info %s" % self.userinfo(row)) break self.data.save(self.config_path) def delete(self, user): self.data.load(self.config_path) index = 0 for row in self.data.json: match = True if 'user' in user and row['user'] != user['user']: match = False if 'port' in user and row['port'] != user['port']: match = False if match: print("delete user [%s]" % row['user']) del self.data.json[index] break index += 1 self.data.save(self.config_path) def clear_ud(self, user): up = {'u': 0, 'd': 0} self.data.load(self.config_path) for row in self.data.json: match = True if 'user' in user and row['user'] != user['user']: match = False if 'port' in user and row['port'] != user['port']: match = False if match: row.update(up) print("clear user [%s]" % row['user']) self.data.save(self.config_path) def list_user(self, user): self.data.load(self.config_path) if not user: for row in self.data.json: print("user [%s] port %s" % (row['user'], row['port'])) return for row in self.data.json: match = True if 'user' in user and row['user'] != user['user']: match = False if 'port' in user and row['port'] != user['port']: match = False if match: muid = None if 'muid' in user: muid = user['muid'] print("### user [%s] info %s" % (row['user'], self.userinfo(row, muid))) def print_server_help(): print('''usage: python mujson_manage.py -a|-d|-e|-c|-l [OPTION]... Actions: -a ADD add/edit a user -d DELETE delete a user -e EDIT edit a user -c CLEAR set u/d to zero -l LIST display a user infomation or all users infomation Options: -u USER the user name -p PORT server port (only this option must be set if add a user) -k PASSWORD password -m METHOD encryption method, default: aes-128-ctr -O PROTOCOL protocol plugin, default: auth_aes128_md5 -o OBFS obfs plugin, default: tls1.2_ticket_auth_compatible -G PROTOCOL_PARAM protocol plugin param -g OBFS_PARAM obfs plugin param -t TRANSFER max transfer for G bytes, default: 8388608 (8 PB or 8192 TB) -f FORBID set forbidden ports. Example (ban 1~79 and 81~100): -f "1-79,81-100" -i MUID set sub id to display (only work with -l) General options: -h, --help show this help message and exit ''') def main(): shortopts = 'adeclu:i:p:k:O:o:G:g:m:t:f:h' longopts = ['help'] action = None user = {} fast_set_obfs = {'0': 'plain', '+1': 'http_simple_compatible', '1': 'http_simple', '+2': 'tls1.2_ticket_auth_compatible', '2': 'tls1.2_ticket_auth'} fast_set_protocol = {'0': 'origin', '+ota': 'verify_sha1_compatible', 'ota': 'verify_sha1', 'a1': 'auth_sha1', '+a1': 'auth_sha1_compatible', 'a2': 'auth_sha1_v2', '+a2': 'auth_sha1_v2_compatible', 'a4': 'auth_sha1_v4', '+a4': 'auth_sha1_v4_compatible', 'am': 'auth_aes128_md5', 'as': 'auth_aes128_sha1', } fast_set_method = {'a0': 'aes-128-cfb', 'a1': 'aes-192-cfb', 'a2': 'aes-256-cfb', 'r': 'rc4-md5', 'r6': 'rc4-md5-6', 'c': 'chacha20', 'ci': 'chacha20-ietf', 's': 'salsa20', 'b': 'bf-cfb', 'm0': 'camellia-128-cfb', 'm1': 'camellia-192-cfb', 'm2': 'camellia-256-cfb', 'a0t': 'aes-128-ctr', 'a1t': 'aes-192-ctr', 'a2t': 'aes-256-ctr'} try: optlist, args = getopt.getopt(sys.argv[1:], shortopts, longopts) for key, value in optlist: if key == '-a': action = 1 elif key == '-d': action = 2 elif key == '-e': action = 3 elif key == '-l': action = 4 elif key == '-c': action = 0 elif key == '-u': user['user'] = value elif key == '-i': user['muid'] = int(value) elif key == '-p': user['port'] = int(value) elif key == '-k': user['passwd'] = value elif key == '-o': if value in fast_set_obfs: user['obfs'] = fast_set_obfs[value] else: user['obfs'] = value elif key == '-O': if value in fast_set_protocol: user['protocol'] = fast_set_protocol[value] else: user['protocol'] = value elif key == '-g': user['obfs_param'] = value elif key == '-G': user['protocol_param'] = value elif key == '-m': if value in fast_set_method: user['method'] = fast_set_method[value] else: user['method'] = value elif key == '-f': user['forbidden_port'] = value elif key == '-t': val = float(value) try: val = int(value) except: pass user['transfer_enable'] = int(val * 1024) * (1024 ** 2) elif key in ('-h', '--help'): print_server_help() sys.exit(0) except getopt.GetoptError as e: print(e) sys.exit(2) manage = MuMgr() if action == 0: manage.clear_ud(user) elif action == 1: if 'user' not in user and 'port' in user: user['user'] = str(user['port']) if 'user' in user and 'port' in user: manage.add(user) else: print("You have to set the port with -p") elif action == 2: if 'user' in user or 'port' in user: manage.delete(user) else: print("You have to set the user name or port with -u/-p") elif action == 3: if 'user' in user or 'port' in user: manage.edit(user) else: print("You have to set the user name or port with -u/-p") elif action == 4: manage.list_user(user) elif action is None: print_server_help() if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 199, 646, 5190, 199, 504, 15084, 21234, 492, 5218, 12, 2863, 199, 504, 1101, 3422, 492, 2248, 63, 888, 12, 664, 63, 888, 199, 646, 2196, 199, 646, 12733, 199, 646, 984, 199, 646, 2022, 199, 646, 1300, 772, 421, 199, 533, 28919, 9653, 5455, 8, 785, 304, 199, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 14, 1001, 275, 488, 421, 198, 318, 2248, 8, 277, 12, 931, 304, 507, 198, 76, 275, 7369, 8480, 507, 198, 893, 26, 686, 198, 1045, 1551, 8, 515, 12, 283, 4848, 13854, 465, 289, 26, 1585, 198, 76, 275, 289, 14, 739, 1252, 2708, 360, 1624, 24, 358, 507, 198, 2590, 26, 686, 198, 1529, 507, 198, 277, 14, 1001, 275, 2022, 14, 3640, 8, 76, 9, 421, 198, 318, 3354, 8, 277, 12, 931, 304, 507, 198, 692, 291, 14, 1001, 365, 440, 488, 26, 686, 198, 1199, 275, 2022, 14, 4180, 8, 277, 14, 1001, 12, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 12, 17658, 2687, 23324, 7596, 20005, 686, 198, 1045, 1551, 8, 515, 12, 283, 65, 735, 1585, 198, 1529, 686, 198, 1045, 1551, 8, 515, 12, 283, 4848, 13854, 465, 289, 26, 1585, 198, 70, 14, 952, 8, 1199, 14, 2143, 360, 1624, 24, 1333, 1585, 198, 70, 14, 12517, 342, 421, 199, 533, 28919, 20752, 8, 785, 304, 199, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 14, 888, 63, 515, 275, 664, 63, 888, 1252, 45, 53, 2846, 63, 3817, 507, 198, 893, 26, 686, 198, 277, 14, 1000, 63, 2697, 275, 664, 63, 888, 1252, 6613, 63, 13047, 63, 7803, 507, 198, 2590, 26, 686, 198, 277, 14, 1000, 63, 2697, 275, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 507, 198, 277, 14, 576, 275, 28919, 9653, 5455, 342, 2742, 198, 692, 291, 14, 1000, 63, 2697, 508, 283, 4195, 14, 16, 14, 16, 14, 17, 356, 686, 198, 277, 14, 1000, 63, 2697, 275, 291, 14, 303, 8996, 2697, 342, 421, 198, 318, 2312, 8996, 2697, 8, 277, 12, 340, 354, 534, 12391, 16, 735, 507, 198, 646, 2838, 507, 198, 646, 2702, 507, 198, 3292, 275, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 507, 198, 893, 26, 686, 198, 3292, 275, 2838, 14, 20256, 24810, 8, 3450, 14, 362, 18364, 8, 3450, 14, 29789, 4059, 507, 198, 2590, 26, 686, 198, 1529, 507, 198, 692, 2203, 508, 283, 4195, 14, 16, 14, 16, 14, 17, 356, 686, 198, 893, 26, 1585, 198, 646, 12871, 1585, 198, 83, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 25351, 9, 1585, 198, 3292, 275, 2838, 14, 10811, 63, 343, 20047, 8, 24477, 14, 2308, 8077, 8, 83, 14, 9843, 1062, 378, 88, 1407, 1046, 12, 2702, 14, 1389, 360, 3912, 83, 297, 340, 354, 1491, 1046, 2459, 59, 1165, 26, 1194, 566, 686, 198, 2590, 26, 1585, 198, 1529, 507, 198, 1107, 2203, 421, 198, 318, 308, 5474, 1073, 8, 277, 12, 922, 12, 3752, 12, 333, 1535, 304, 507, 198, 3922, 275, 922, 14, 362, 360, 3922, 297, 4074, 507, 198, 2873, 2319, 275, 922, 14, 362, 360, 2873, 2319, 297, 4074, 507, 198, 3922, 275, 4113, 14, 1814, 11008, 6490, 401, 6899, 507, 198, 2873, 2319, 275, 2607, 2319, 14, 1814, 11008, 6490, 401, 6899, 507, 198, 3922, 63, 635, 275, 2125, 507, 198, 692, 333, 1535, 365, 440, 488, 26, 686, 198, 3922, 63, 635, 63, 275, 922, 14, 362, 360, 3922, 63, 635, 297, 4074, 686, 198, 635, 275, 4113, 63, 635, 3754, 1294, 7863, 358, 686, 198, 692, 822, 8, 635, 9, 508, 499, 26, 1585, 198, 509, 1962, 315, 291, 14, 576, 14, 1001, 26, 1871, 198, 692, 1109, 8, 1143, 459, 719, 1105, 508, 333, 1535, 26, 4671, 198, 635, 275, 620, 8, 77, 1535, 9, 435, 10871, 435, 1962, 459, 12671, 418, 4671, 198, 3922, 63, 635, 275, 1994, 31, 496, 2119, 285, 455, 534, 435, 2863, 14, 475, 63, 495, 8, 1095, 772, 14, 28201, 63, 66, 772, 2143, 8, 2330, 14, 475, 63, 2394, 8, 635, 23261, 1814, 480, 11107, 6899, 4671, 198, 4785, 507, 198, 1073, 275, 19426, 83, 2689, 83, 2689, 83, 2689, 83, 2689, 83, 2689, 83, 2, 450, 334, 277, 14, 1000, 63, 2697, 12, 922, 459, 719, 995, 4113, 12, 922, 459, 765, 995, 2607, 2319, 12, 2863, 14, 475, 63, 495, 8, 1095, 772, 14, 28201, 63, 66, 772, 2143, 8, 2330, 14, 475, 63, 2394, 8, 751, 459, 12671, 5156, 680, 1814, 480, 11107, 3087, 1724, 435, 4113, 63, 635, 507, 198, 1107, 298, 385, 82, 30443, 435, 334, 2143, 436, 2863, 14, 475, 63, 495, 8, 1095, 772, 14, 28201, 63, 66, 772, 2143, 8, 2330, 14, 475, 63, 2394, 8, 1073, 23261, 1814, 480, 11107, 6899, 503, 2142, 9, 421, 198, 318, 922, 815, 8, 277, 12, 922, 12, 333, 1535, 275, 488, 304, 507, 198, 3292, 275, 3087, 507, 198, 498, 63, 513, 275, 788, 751, 297, 283, 719, 297, 283, 765, 297, 283, 12671, 297, 283, 3922, 297, 283, 3922, 63, 635, 297, 283, 2873, 2319, 297, 283, 2873, 2319, 63, 635, 297, 283, 9609, 63, 4296, 297, 283, 85, 297, 283, 68, 418, 507, 198, 509, 790, 315, 3355, 8, 751, 304, 686, 198, 692, 790, 440, 315, 790, 63, 513, 26, 1585, 198, 498, 63, 513, 14, 740, 8, 498, 9, 507, 198, 509, 790, 315, 790, 63, 513, 26, 686, 198, 692, 790, 315, 788, 4296, 418, 503, 790, 440, 315, 922, 26, 1585, 198, 6958, 686, 198, 3292, 847, 1557, 78, 7, 686, 198, 692, 334, 77, 1535, 365, 440, 488, 9, 436, 334, 498, 315, 788, 3922, 63, 635, 9090, 1585, 198, 509, 1962, 315, 291, 14, 576, 14, 1001, 26, 1871, 198, 692, 1109, 8, 1143, 459, 719, 1105, 508, 333, 1535, 26, 4671, 198, 3292, 847, 298, 259, 450, 83, 520, 450, 83, 2, 450, 334, 498, 12, 620, 8, 77, 1535, 9, 435, 10871, 435, 1962, 459 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 199, 646, 5190, 199, 504, 15084, 21234, 492, 5218, 12, 2863, 199, 504, 1101, 3422, 492, 2248, 63, 888, 12, 664, 63, 888, 199, 646, 2196, 199, 646, 12733, 199, 646, 984, 199, 646, 2022, 199, 646, 1300, 772, 421, 199, 533, 28919, 9653, 5455, 8, 785, 304, 199, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 14, 1001, 275, 488, 421, 198, 318, 2248, 8, 277, 12, 931, 304, 507, 198, 76, 275, 7369, 8480, 507, 198, 893, 26, 686, 198, 1045, 1551, 8, 515, 12, 283, 4848, 13854, 465, 289, 26, 1585, 198, 76, 275, 289, 14, 739, 1252, 2708, 360, 1624, 24, 358, 507, 198, 2590, 26, 686, 198, 1529, 507, 198, 277, 14, 1001, 275, 2022, 14, 3640, 8, 76, 9, 421, 198, 318, 3354, 8, 277, 12, 931, 304, 507, 198, 692, 291, 14, 1001, 365, 440, 488, 26, 686, 198, 1199, 275, 2022, 14, 4180, 8, 277, 14, 1001, 12, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 12, 17658, 2687, 23324, 7596, 20005, 686, 198, 1045, 1551, 8, 515, 12, 283, 65, 735, 1585, 198, 1529, 686, 198, 1045, 1551, 8, 515, 12, 283, 4848, 13854, 465, 289, 26, 1585, 198, 70, 14, 952, 8, 1199, 14, 2143, 360, 1624, 24, 1333, 1585, 198, 70, 14, 12517, 342, 421, 199, 533, 28919, 20752, 8, 785, 304, 199, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 14, 888, 63, 515, 275, 664, 63, 888, 1252, 45, 53, 2846, 63, 3817, 507, 198, 893, 26, 686, 198, 277, 14, 1000, 63, 2697, 275, 664, 63, 888, 1252, 6613, 63, 13047, 63, 7803, 507, 198, 2590, 26, 686, 198, 277, 14, 1000, 63, 2697, 275, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 507, 198, 277, 14, 576, 275, 28919, 9653, 5455, 342, 2742, 198, 692, 291, 14, 1000, 63, 2697, 508, 283, 4195, 14, 16, 14, 16, 14, 17, 356, 686, 198, 277, 14, 1000, 63, 2697, 275, 291, 14, 303, 8996, 2697, 342, 421, 198, 318, 2312, 8996, 2697, 8, 277, 12, 340, 354, 534, 12391, 16, 735, 507, 198, 646, 2838, 507, 198, 646, 2702, 507, 198, 3292, 275, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 507, 198, 893, 26, 686, 198, 3292, 275, 2838, 14, 20256, 24810, 8, 3450, 14, 362, 18364, 8, 3450, 14, 29789, 4059, 507, 198, 2590, 26, 686, 198, 1529, 507, 198, 692, 2203, 508, 283, 4195, 14, 16, 14, 16, 14, 17, 356, 686, 198, 893, 26, 1585, 198, 646, 12871, 1585, 198, 83, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 25351, 9, 1585, 198, 3292, 275, 2838, 14, 10811, 63, 343, 20047, 8, 24477, 14, 2308, 8077, 8, 83, 14, 9843, 1062, 378, 88, 1407, 1046, 12, 2702, 14, 1389, 360, 3912, 83, 297, 340, 354, 1491, 1046, 2459, 59, 1165, 26, 1194, 566, 686, 198, 2590, 26, 1585, 198, 1529, 507, 198, 1107, 2203, 421, 198, 318, 308, 5474, 1073, 8, 277, 12, 922, 12, 3752, 12, 333, 1535, 304, 507, 198, 3922, 275, 922, 14, 362, 360, 3922, 297, 4074, 507, 198, 2873, 2319, 275, 922, 14, 362, 360, 2873, 2319, 297, 4074, 507, 198, 3922, 275, 4113, 14, 1814, 11008, 6490, 401, 6899, 507, 198, 2873, 2319, 275, 2607, 2319, 14, 1814, 11008, 6490, 401, 6899, 507, 198, 3922, 63, 635, 275, 2125, 507, 198, 692, 333, 1535, 365, 440, 488, 26, 686, 198, 3922, 63, 635, 63, 275, 922, 14, 362, 360, 3922, 63, 635, 297, 4074, 686, 198, 635, 275, 4113, 63, 635, 3754, 1294, 7863, 358, 686, 198, 692, 822, 8, 635, 9, 508, 499, 26, 1585, 198, 509, 1962, 315, 291, 14, 576, 14, 1001, 26, 1871, 198, 692, 1109, 8, 1143, 459, 719, 1105, 508, 333, 1535, 26, 4671, 198, 635, 275, 620, 8, 77, 1535, 9, 435, 10871, 435, 1962, 459, 12671, 418, 4671, 198, 3922, 63, 635, 275, 1994, 31, 496, 2119, 285, 455, 534, 435, 2863, 14, 475, 63, 495, 8, 1095, 772, 14, 28201, 63, 66, 772, 2143, 8, 2330, 14, 475, 63, 2394, 8, 635, 23261, 1814, 480, 11107, 6899, 4671, 198, 4785, 507, 198, 1073, 275, 19426, 83, 2689, 83, 2689, 83, 2689, 83, 2689, 83, 2689, 83, 2, 450, 334, 277, 14, 1000, 63, 2697, 12, 922, 459, 719, 995, 4113, 12, 922, 459, 765, 995, 2607, 2319, 12, 2863, 14, 475, 63, 495, 8, 1095, 772, 14, 28201, 63, 66, 772, 2143, 8, 2330, 14, 475, 63, 2394, 8, 751, 459, 12671, 5156, 680, 1814, 480, 11107, 3087, 1724, 435, 4113, 63, 635, 507, 198, 1107, 298, 385, 82, 30443, 435, 334, 2143, 436, 2863, 14, 475, 63, 495, 8, 1095, 772, 14, 28201, 63, 66, 772, 2143, 8, 2330, 14, 475, 63, 2394, 8, 1073, 23261, 1814, 480, 11107, 6899, 503, 2142, 9, 421, 198, 318, 922, 815, 8, 277, 12, 922, 12, 333, 1535, 275, 488, 304, 507, 198, 3292, 275, 3087, 507, 198, 498, 63, 513, 275, 788, 751, 297, 283, 719, 297, 283, 765, 297, 283, 12671, 297, 283, 3922, 297, 283, 3922, 63, 635, 297, 283, 2873, 2319, 297, 283, 2873, 2319, 63, 635, 297, 283, 9609, 63, 4296, 297, 283, 85, 297, 283, 68, 418, 507, 198, 509, 790, 315, 3355, 8, 751, 304, 686, 198, 692, 790, 440, 315, 790, 63, 513, 26, 1585, 198, 498, 63, 513, 14, 740, 8, 498, 9, 507, 198, 509, 790, 315, 790, 63, 513, 26, 686, 198, 692, 790, 315, 788, 4296, 418, 503, 790, 440, 315, 922, 26, 1585, 198, 6958, 686, 198, 3292, 847, 1557, 78, 7, 686, 198, 692, 334, 77, 1535, 365, 440, 488, 9, 436, 334, 498, 315, 788, 3922, 63, 635, 9090, 1585, 198, 509, 1962, 315, 291, 14, 576, 14, 1001, 26, 1871, 198, 692, 1109, 8, 1143, 459, 719, 1105, 508, 333, 1535, 26, 4671, 198, 3292, 847, 298, 259, 450, 83, 520, 450, 83, 2, 450, 334, 498, 12, 620, 8, 77, 1535, 9, 435, 10871, 435, 1962, 459, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
goodes/fit4school
fit4school/core/migrations/0007_trackeractivity.py
1
1072
# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-12-10 07:54 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('core', '0006_auto_20171207_0148'), ] operations = [ migrations.CreateModel( name='TrackerActivity', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('timestamp', models.DateField()), ('steps', models.IntegerField()), ('minutesSedentary', models.IntegerField()), ('minutesLightlyActive', models.IntegerField()), ('minutesFairlyActive', models.IntegerField()), ('minutesVeryActive', models.IntegerField()), ('tracker', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='activity', to='core.Tracker', verbose_name='tracker')), ], ), ]
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 845, 14, 20, 641, 9708, 13, 713, 13, 709, 24937, 26, 1477, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 1018, 297, 283, 20965, 63, 2495, 63, 10680, 713, 1780, 63, 614, 2006, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 13652, 14350, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 3954, 297, 1709, 14, 14071, 4000, 355, 661, 5895, 297, 1709, 14, 3901, 4000, 355, 661, 10430, 1513, 1326, 695, 297, 1709, 14, 3901, 4000, 355, 661, 10430, 16393, 590, 7472, 297, 1709, 14, 3901, 4000, 355, 661, 10430, 1906, 723, 590, 7472, 297, 1709, 14, 3901, 4000, 355, 661, 10430, 54, 994, 7472, 297, 1709, 14, 3901, 4000, 355, 661, 8877, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 4048, 63, 354, 534, 8240, 297, 370, 534, 1018, 14, 13652, 297, 3376, 63, 354, 534, 8877, 3855, 288, 2156, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 845, 14, 20, 641, 9708, 13, 713, 13, 709, 24937, 26, 1477, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 1018, 297, 283, 20965, 63, 2495, 63, 10680, 713, 1780, 63, 614, 2006, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 13652, 14350, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 3954, 297, 1709, 14, 14071, 4000, 355, 661, 5895, 297, 1709, 14, 3901, 4000, 355, 661, 10430, 1513, 1326, 695, 297, 1709, 14, 3901, 4000, 355, 661, 10430, 16393, 590, 7472, 297, 1709, 14, 3901, 4000, 355, 661, 10430, 1906, 723, 590, 7472, 297, 1709, 14, 3901, 4000, 355, 661, 10430, 54, 994, 7472, 297, 1709, 14, 3901, 4000, 355, 661, 8877, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 4048, 63, 354, 534, 8240, 297, 370, 534, 1018, 14, 13652, 297, 3376, 63, 354, 534, 8877, 3855, 288, 2156, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
EvanK/ansible-modules-extras
monitoring/zabbix_group.py
45
7421
#!/usr/bin/python # -*- coding: utf-8 -*- # # (c) 2013-2014, Epic Games, Inc. # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: zabbix_group short_description: Zabbix host groups creates/deletes description: - Create host groups if they do not exist. - Delete existing host groups if they exist. version_added: "1.8" author: - "(@cove)" - "Tony Minfei Ding" - "Harrison Gu (@harrisongu)" requirements: - "python >= 2.6" - zabbix-api options: server_url: description: - Url of Zabbix server, with protocol (http or https). C(url) is an alias for C(server_url). required: true aliases: [ "url" ] login_user: description: - Zabbix user name. required: true login_password: description: - Zabbix user password. required: true http_login_user: description: - Basic Auth login required: false default: None version_added: "2.1" http_login_password: description: - Basic Auth password required: false default: None version_added: "2.1" state: description: - Create or delete host group. required: false default: "present" choices: [ "present", "absent" ] timeout: description: - The timeout of API request(seconds). default: 10 host_groups: description: - List of host groups to create or delete. required: true aliases: [ "host_group" ] notes: - Too many concurrent updates to the same group may cause Zabbix to return errors, see examples for a workaround if needed. ''' EXAMPLES = ''' # Base create host groups example - name: Create host groups local_action: module: zabbix_group server_url: http://monitor.example.com login_user: username login_password: password state: present host_groups: - Example group1 - Example group2 # Limit the Zabbix group creations to one host since Zabbix can return an error when doing concurent updates - name: Create host groups local_action: module: zabbix_group server_url: http://monitor.example.com login_user: username login_password: password state: present host_groups: - Example group1 - Example group2 when: inventory_hostname==groups['group_name'][0] ''' try: from zabbix_api import ZabbixAPI, ZabbixAPISubClass from zabbix_api import Already_Exists HAS_ZABBIX_API = True except ImportError: HAS_ZABBIX_API = False class HostGroup(object): def __init__(self, module, zbx): self._module = module self._zapi = zbx # create host group(s) if not exists def create_host_group(self, group_names): try: group_add_list = [] for group_name in group_names: result = self._zapi.hostgroup.get({'filter': {'name': group_name}}) if not result: try: if self._module.check_mode: self._module.exit_json(changed=True) self._zapi.hostgroup.create({'name': group_name}) group_add_list.append(group_name) except Already_Exists: return group_add_list return group_add_list except Exception, e: self._module.fail_json(msg="Failed to create host group(s): %s" % e) # delete host group(s) def delete_host_group(self, group_ids): try: if self._module.check_mode: self._module.exit_json(changed=True) self._zapi.hostgroup.delete(group_ids) except Exception, e: self._module.fail_json(msg="Failed to delete host group(s), Exception: %s" % e) # get group ids by name def get_group_ids(self, host_groups): group_ids = [] group_list = self._zapi.hostgroup.get({'output': 'extend', 'filter': {'name': host_groups}}) for group in group_list: group_id = group['groupid'] group_ids.append(group_id) return group_ids, group_list def main(): module = AnsibleModule( argument_spec=dict( server_url=dict(type='str', required=True, aliases=['url']), login_user=dict(type='str', required=True), login_password=dict(type='str', required=True, no_log=True), http_login_user=dict(type='str',required=False, default=None), http_login_password=dict(type='str',required=False, default=None, no_log=True), host_groups=dict(type='list', required=True, aliases=['host_group']), state=dict(default="present", choices=['present','absent']), timeout=dict(type='int', default=10) ), supports_check_mode=True ) if not HAS_ZABBIX_API: module.fail_json(msg="Missing requried zabbix-api module (check docs or install with: pip install zabbix-api)") server_url = module.params['server_url'] login_user = module.params['login_user'] login_password = module.params['login_password'] http_login_user = module.params['http_login_user'] http_login_password = module.params['http_login_password'] host_groups = module.params['host_groups'] state = module.params['state'] timeout = module.params['timeout'] zbx = None # login to zabbix try: zbx = ZabbixAPI(server_url, timeout=timeout, user=http_login_user, passwd=http_login_password) zbx.login(login_user, login_password) except Exception, e: module.fail_json(msg="Failed to connect to Zabbix server: %s" % e) hostGroup = HostGroup(module, zbx) group_ids = [] group_list = [] if host_groups: group_ids, group_list = hostGroup.get_group_ids(host_groups) if state == "absent": # delete host groups if group_ids: delete_group_names = [] hostGroup.delete_host_group(group_ids) for group in group_list: delete_group_names.append(group['name']) module.exit_json(changed=True, result="Successfully deleted host group(s): %s." % ",".join(delete_group_names)) else: module.exit_json(changed=False, result="No host group(s) to delete.") else: # create host groups group_add_list = hostGroup.create_host_group(host_groups) if len(group_add_list) > 0: module.exit_json(changed=True, result="Successfully created host group(s): %s" % group_add_list) else: module.exit_json(changed=False) from ansible.module_utils.basic import * main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 334, 67, 9, 6171, 13, 7280, 12, 662, 12475, 598, 14015, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 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, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 1315, 20325, 63, 923, 199, 3612, 63, 1802, 26, 3107, 20325, 1591, 4652, 8491, 15, 26289, 199, 1802, 26, 2043, 446, 2790, 1591, 4652, 340, 2985, 886, 440, 2187, 14, 2043, 446, 8496, 3411, 1591, 4652, 340, 2985, 2187, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 24, 2, 199, 2502, 26, 272, 446, 7340, 32, 24617, 2924, 272, 446, 298, 52, 5220, 10195, 771, 73, 577, 316, 2, 272, 446, 298, 18248, 322, 834, 12436, 8593, 8210, 322, 834, 6051, 2924, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 1315, 20325, 13, 1246, 199, 1419, 26, 272, 1654, 63, 633, 26, 267, 1369, 26, 288, 446, 20503, 402, 3107, 20325, 1654, 12, 543, 4113, 334, 1014, 503, 4178, 680, 1598, 445, 8, 633, 9, 365, 376, 5162, 367, 445, 8, 1000, 63, 633, 680, 267, 1415, 26, 2549, 267, 5481, 26, 359, 298, 633, 2, 1622, 272, 4676, 63, 751, 26, 267, 1369, 26, 288, 446, 3107, 20325, 922, 536, 14, 267, 1415, 26, 2549, 272, 4676, 63, 2060, 26, 267, 1369, 26, 288, 446, 3107, 20325, 922, 2505, 14, 267, 1415, 26, 2549, 272, 1455, 63, 2886, 63, 751, 26, 267, 1369, 26, 288, 446, 10082, 3590, 4676, 267, 1415, 26, 3055, 267, 849, 26, 488, 267, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 272, 1455, 63, 2886, 63, 2060, 26, 267, 1369, 26, 288, 446, 10082, 3590, 2505, 267, 1415, 26, 3055, 267, 849, 26, 488, 267, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 272, 1174, 26, 267, 1369, 26, 288, 446, 2790, 503, 3145, 1591, 1572, 14, 267, 1415, 26, 3055, 267, 849, 26, 298, 1881, 2, 267, 3415, 26, 359, 298, 1881, 401, 298, 5575, 2, 1622, 272, 2653, 26, 267, 1369, 26, 288, 446, 710, 2653, 402, 3261, 1056, 8, 4515, 680, 267, 849, 26, 1616, 272, 1591, 63, 2634, 26, 267, 1369, 26, 288, 446, 3820, 402, 1591, 4652, 370, 1218, 503, 3145, 14, 267, 1415, 26, 2549, 267, 5481, 26, 359, 298, 1102, 63, 923, 2, 1622, 199, 5983, 26, 272, 446, 22893, 5002, 23002, 7029, 370, 314, 2011, 1572, 1443, 7675, 3107, 20325, 370, 372, 2552, 12, 1937, 7251, 367, 282, 18092, 340, 4346, 14, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 3523, 1218, 1591, 4652, 2893, 199, 13, 536, 26, 2790, 1591, 4652, 523, 2257, 63, 1287, 26, 272, 859, 26, 1315, 20325, 63, 923, 272, 1654, 63, 633, 26, 1455, 921, 7157, 14, 2694, 14, 957, 272, 4676, 63, 751, 26, 3434, 272, 4676, 63, 2060, 26, 2505, 272, 1174, 26, 3451, 272, 1591, 63, 2634, 26, 489, 446, 5679, 1572, 17, 489, 446, 5679, 1572, 18, 199, 199, 3, 22672, 314, 3107, 20325, 1572, 2837, 1298, 370, 1373, 1591, 3967, 3107, 20325, 883, 372, 376, 1125, 1380, 9689, 406, 67, 608, 343, 7029, 199, 13, 536, 26, 2790, 1591, 4652, 523, 2257, 63, 1287, 26, 272, 859, 26, 1315, 20325, 63, 923, 272, 1654, 63, 633, 26, 1455, 921, 7157, 14, 2694, 14, 957, 272, 4676, 63, 751, 26, 3434, 272, 4676, 63, 2060, 26, 2505, 272, 1174, 26, 3451, 272, 1591, 63, 2634, 26, 489, 446, 5679, 1572, 17, 489, 446, 5679, 1572, 18, 523, 1380, 26, 8200, 63, 4269, 389, 2634, 459, 923, 63, 354, 3488, 16, 61, 199, 2344, 199, 199, 893, 26, 272, 687, 1315, 20325, 63, 1246, 492, 3107, 20325, 3735, 12, 3107, 20325, 1282, 1311, 456, 2543, 272, 687, 1315, 20325, 63, 1246, 492, 21086, 63, 7965, 339, 7509, 63, 58, 1217, 34, 3867, 63, 3735, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 58, 1217, 34, 3867, 63, 3735, 275, 756, 421, 199, 533, 10891, 2448, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 859, 12, 1315, 13691, 304, 267, 291, 423, 578, 275, 859, 267, 291, 423, 21059, 275, 1315, 13691, 339, 327, 1218, 1591, 1572, 8, 83, 9, 340, 440, 3495, 272, 347, 1218, 63, 1102, 63, 923, 8, 277, 12, 1572, 63, 1247, 304, 267, 862, 26, 288, 1572, 63, 525, 63, 513, 275, 942, 288, 367, 1572, 63, 354, 315, 1572, 63, 1247, 26, 355, 754, 275, 291, 423, 21059, 14, 28221, 14, 362, 3252, 1541, 356, 791, 354, 356, 1572, 63, 354, 19575, 355, 340, 440, 754, 26, 490, 862, 26, 717, 340, 291, 423, 578, 14, 1074, 63, 632, 26, 1169, 291, 423, 578, 14, 2224, 63, 1001, 8, 2489, 29, 549, 9, 717, 291, 423, 21059, 14, 28221, 14, 981, 3252, 354, 356, 1572, 63, 354, 1552, 717, 1572, 63, 525, 63, 513, 14, 740, 8, 923, 63, 354, 9, 490, 871, 21086, 63, 7965, 26, 717, 372, 1572, 63, 525, 63, 513, 288, 372, 1572, 63, 525, 63, 513, 267, 871, 2186, 12, 325, 26, 288, 291, 423, 578, 14, 1633, 63, 1001, 8, 1328, 628, 4276, 370, 1218, 1591, 1572, 8, 83, 304, 450, 83, 2, 450, 325, 9, 339, 327 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 334, 67, 9, 6171, 13, 7280, 12, 662, 12475, 598, 14015, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 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, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 1315, 20325, 63, 923, 199, 3612, 63, 1802, 26, 3107, 20325, 1591, 4652, 8491, 15, 26289, 199, 1802, 26, 2043, 446, 2790, 1591, 4652, 340, 2985, 886, 440, 2187, 14, 2043, 446, 8496, 3411, 1591, 4652, 340, 2985, 2187, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 24, 2, 199, 2502, 26, 272, 446, 7340, 32, 24617, 2924, 272, 446, 298, 52, 5220, 10195, 771, 73, 577, 316, 2, 272, 446, 298, 18248, 322, 834, 12436, 8593, 8210, 322, 834, 6051, 2924, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 1315, 20325, 13, 1246, 199, 1419, 26, 272, 1654, 63, 633, 26, 267, 1369, 26, 288, 446, 20503, 402, 3107, 20325, 1654, 12, 543, 4113, 334, 1014, 503, 4178, 680, 1598, 445, 8, 633, 9, 365, 376, 5162, 367, 445, 8, 1000, 63, 633, 680, 267, 1415, 26, 2549, 267, 5481, 26, 359, 298, 633, 2, 1622, 272, 4676, 63, 751, 26, 267, 1369, 26, 288, 446, 3107, 20325, 922, 536, 14, 267, 1415, 26, 2549, 272, 4676, 63, 2060, 26, 267, 1369, 26, 288, 446, 3107, 20325, 922, 2505, 14, 267, 1415, 26, 2549, 272, 1455, 63, 2886, 63, 751, 26, 267, 1369, 26, 288, 446, 10082, 3590, 4676, 267, 1415, 26, 3055, 267, 849, 26, 488, 267, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 272, 1455, 63, 2886, 63, 2060, 26, 267, 1369, 26, 288, 446, 10082, 3590, 2505, 267, 1415, 26, 3055, 267, 849, 26, 488, 267, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 272, 1174, 26, 267, 1369, 26, 288, 446, 2790, 503, 3145, 1591, 1572, 14, 267, 1415, 26, 3055, 267, 849, 26, 298, 1881, 2, 267, 3415, 26, 359, 298, 1881, 401, 298, 5575, 2, 1622, 272, 2653, 26, 267, 1369, 26, 288, 446, 710, 2653, 402, 3261, 1056, 8, 4515, 680, 267, 849, 26, 1616, 272, 1591, 63, 2634, 26, 267, 1369, 26, 288, 446, 3820, 402, 1591, 4652, 370, 1218, 503, 3145, 14, 267, 1415, 26, 2549, 267, 5481, 26, 359, 298, 1102, 63, 923, 2, 1622, 199, 5983, 26, 272, 446, 22893, 5002, 23002, 7029, 370, 314, 2011, 1572, 1443, 7675, 3107, 20325, 370, 372, 2552, 12, 1937, 7251, 367, 282, 18092, 340, 4346, 14, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 3523, 1218, 1591, 4652, 2893, 199, 13, 536, 26, 2790, 1591, 4652, 523, 2257, 63, 1287, 26, 272, 859, 26, 1315, 20325, 63, 923, 272, 1654, 63, 633, 26, 1455, 921, 7157, 14, 2694, 14, 957, 272, 4676, 63, 751, 26, 3434, 272, 4676, 63, 2060, 26, 2505, 272, 1174, 26, 3451, 272, 1591, 63, 2634, 26, 489, 446, 5679, 1572, 17, 489, 446, 5679, 1572, 18, 199, 199, 3, 22672, 314, 3107, 20325, 1572, 2837, 1298, 370, 1373, 1591, 3967, 3107, 20325, 883, 372, 376, 1125, 1380, 9689, 406, 67, 608, 343, 7029, 199, 13, 536, 26, 2790, 1591, 4652, 523, 2257, 63, 1287, 26, 272, 859, 26, 1315, 20325, 63, 923, 272, 1654, 63, 633, 26, 1455, 921, 7157, 14, 2694, 14, 957, 272, 4676, 63, 751, 26, 3434, 272, 4676, 63, 2060, 26, 2505, 272, 1174, 26, 3451, 272, 1591, 63, 2634, 26, 489, 446, 5679, 1572, 17, 489, 446, 5679, 1572, 18, 523, 1380, 26, 8200, 63, 4269, 389, 2634, 459, 923, 63, 354, 3488, 16, 61, 199, 2344, 199, 199, 893, 26, 272, 687, 1315, 20325, 63, 1246, 492, 3107, 20325, 3735, 12, 3107, 20325, 1282, 1311, 456, 2543, 272, 687, 1315, 20325, 63, 1246, 492, 21086, 63, 7965, 339, 7509, 63, 58, 1217, 34, 3867, 63, 3735, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 58, 1217, 34, 3867, 63, 3735, 275, 756, 421, 199, 533, 10891, 2448, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 859, 12, 1315, 13691, 304, 267, 291, 423, 578, 275, 859, 267, 291, 423, 21059, 275, 1315, 13691, 339, 327, 1218, 1591, 1572, 8, 83, 9, 340, 440, 3495, 272, 347, 1218, 63, 1102, 63, 923, 8, 277, 12, 1572, 63, 1247, 304, 267, 862, 26, 288, 1572, 63, 525, 63, 513, 275, 942, 288, 367, 1572, 63, 354, 315, 1572, 63, 1247, 26, 355, 754, 275, 291, 423, 21059, 14, 28221, 14, 362, 3252, 1541, 356, 791, 354, 356, 1572, 63, 354, 19575, 355, 340, 440, 754, 26, 490, 862, 26, 717, 340, 291, 423, 578, 14, 1074, 63, 632, 26, 1169, 291, 423, 578, 14, 2224, 63, 1001, 8, 2489, 29, 549, 9, 717, 291, 423, 21059, 14, 28221, 14, 981, 3252, 354, 356, 1572, 63, 354, 1552, 717, 1572, 63, 525, 63, 513, 14, 740, 8, 923, 63, 354, 9, 490, 871, 21086, 63, 7965, 26, 717, 372, 1572, 63, 525, 63, 513, 288, 372, 1572, 63, 525, 63, 513, 267, 871, 2186, 12, 325, 26, 288, 291, 423, 578, 14, 1633, 63, 1001, 8, 1328, 628, 4276, 370, 1218, 1591, 1572, 8, 83, 304, 450, 83, 2, 450, 325, 9, 339, 327, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hgl888/flatbuffers
python/flatbuffers/table.py
20
4708
# Copyright 2014 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from . import encode from . import number_types as N class Table(object): """Table wraps a byte slice and provides read access to its data. The variable `Pos` indicates the root of the FlatBuffers object therein.""" __slots__ = ("Bytes", "Pos") def __init__(self, buf, pos): N.enforce_number(pos, N.UOffsetTFlags) self.Bytes = buf self.Pos = pos def Offset(self, vtableOffset): """Offset provides access into the Table's vtable. Deprecated fields are ignored by checking the vtable's length.""" vtable = self.Pos - self.Get(N.SOffsetTFlags, self.Pos) vtableEnd = self.Get(N.VOffsetTFlags, vtable) if vtableOffset < vtableEnd: return self.Get(N.VOffsetTFlags, vtable + vtableOffset) return 0 def Indirect(self, off): """Indirect retrieves the relative offset stored at `offset`.""" N.enforce_number(off, N.UOffsetTFlags) return off + encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) def String(self, off): """String gets a string from data stored inside the flatbuffer.""" N.enforce_number(off, N.UOffsetTFlags) off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) start = off + N.UOffsetTFlags.bytewidth length = encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) return bytes(self.Bytes[start:start+length]) def VectorLen(self, off): """VectorLen retrieves the length of the vector whose offset is stored at "off" in this object.""" N.enforce_number(off, N.UOffsetTFlags) off += self.Pos off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) ret = encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) return ret def Vector(self, off): """Vector retrieves the start of data of the vector whose offset is stored at "off" in this object.""" N.enforce_number(off, N.UOffsetTFlags) off += self.Pos x = off + self.Get(N.UOffsetTFlags, off) # data starts after metadata containing the vector length x += N.UOffsetTFlags.bytewidth return x def Union(self, t2, off): """Union initializes any Table-derived type to point to the union at the given offset.""" assert type(t2) is Table N.enforce_number(off, N.UOffsetTFlags) off += self.Pos t2.Pos = off + self.Get(N.UOffsetTFlags, off) t2.Bytes = self.Bytes def Get(self, flags, off): """ Get retrieves a value of the type specified by `flags` at the given offset. """ N.enforce_number(off, N.UOffsetTFlags) return flags.py_type(encode.Get(flags.packer_type, self.Bytes, off)) def GetSlot(self, slot, d, validator_flags): N.enforce_number(slot, N.VOffsetTFlags) if validator_flags is not None: N.enforce_number(d, validator_flags) off = self.Offset(slot) if off == 0: return d return self.Get(validator_flags, self.Pos + off) def GetVectorAsNumpy(self, flags, off): """ GetVectorAsNumpy returns the vector that starts at `Vector(off)` as a numpy array with the type specified by `flags`. The array is a `view` into Bytes, so modifying the returned array will modify Bytes in place. """ offset = self.Vector(off) length = self.VectorLen(off) # TODO: length accounts for bytewidth, right? numpy_dtype = N.to_numpy_type(flags) return encode.GetVectorAsNumpy(numpy_dtype, self.Bytes, length, offset) def GetVOffsetTSlot(self, slot, d): """ GetVOffsetTSlot retrieves the VOffsetT that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned. """ N.enforce_number(slot, N.VOffsetTFlags) N.enforce_number(d, N.VOffsetTFlags) off = self.Offset(slot) if off == 0: return d return off
apache-2.0
[ 3, 1898, 6927, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 1275, 492, 3752, 199, 504, 1275, 492, 1329, 63, 1313, 465, 653, 421, 199, 533, 6957, 8, 785, 304, 272, 408, 3186, 14018, 282, 3696, 6014, 436, 6571, 1586, 2879, 370, 2399, 666, 14, 339, 710, 1750, 658, 6981, 64, 9126, 314, 1738, 402, 314, 19005, 30705, 909, 2337, 262, 1041, 339, 636, 7257, 363, 275, 1689, 5571, 401, 298, 6981, 531, 339, 347, 636, 826, 721, 277, 12, 4123, 12, 2086, 304, 267, 653, 14, 19817, 63, 1955, 8, 1712, 12, 653, 14, 53, 6397, 6145, 1550, 9, 398, 291, 14, 5571, 275, 4123, 267, 291, 14, 6981, 275, 2086, 339, 347, 29432, 8, 277, 12, 373, 1224, 6397, 304, 267, 408, 6397, 6571, 2879, 1901, 314, 6957, 1159, 373, 1224, 14, 398, 17993, 1504, 787, 5525, 701, 7907, 314, 373, 1224, 1159, 2582, 1041, 398, 373, 1224, 275, 291, 14, 6981, 446, 291, 14, 1002, 8, 46, 14, 4118, 12449, 6145, 1550, 12, 291, 14, 6981, 9, 267, 373, 1224, 3005, 275, 291, 14, 1002, 8, 46, 14, 54, 6397, 6145, 1550, 12, 373, 1224, 9, 267, 340, 373, 1224, 6397, 665, 373, 1224, 3005, 26, 288, 372, 291, 14, 1002, 8, 46, 14, 54, 6397, 6145, 1550, 12, 373, 1224, 435, 373, 1224, 6397, 9, 267, 372, 378, 339, 347, 1010, 2275, 8, 277, 12, 2331, 304, 267, 408, 607, 2275, 9619, 2310, 314, 3847, 3268, 5489, 737, 658, 2743, 17105, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 267, 372, 2331, 435, 3752, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 9, 339, 347, 2624, 8, 277, 12, 2331, 304, 267, 408, 1558, 7545, 282, 1059, 687, 666, 5489, 6272, 314, 6829, 2738, 1041, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 267, 2331, 847, 3752, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 9, 267, 1343, 275, 2331, 435, 653, 14, 53, 6397, 6145, 1550, 14, 4414, 2063, 267, 2582, 275, 3752, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 9, 267, 372, 2783, 8, 277, 14, 5571, 59, 928, 26, 928, 11, 1267, 566, 339, 347, 11388, 3166, 8, 277, 12, 2331, 304, 267, 408, 3646, 3166, 9619, 2310, 314, 2582, 402, 314, 5477, 7447, 3268, 365, 5489, 1779, 737, 298, 1997, 2, 315, 642, 909, 1041, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 398, 2331, 847, 291, 14, 6981, 267, 2331, 847, 3752, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 9, 267, 2203, 275, 3752, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 9, 267, 372, 2203, 339, 347, 11388, 8, 277, 12, 2331, 304, 267, 408, 3646, 9619, 2310, 314, 1343, 402, 666, 402, 314, 5477, 7447, 3268, 365, 1779, 5489, 737, 298, 1997, 2, 315, 642, 909, 1041, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 398, 2331, 847, 291, 14, 6981, 267, 671, 275, 2331, 435, 291, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 12, 2331, 9, 267, 327, 666, 9174, 2410, 3341, 3035, 314, 5477, 2582, 267, 671, 847, 653, 14, 53, 6397, 6145, 1550, 14, 4414, 2063, 267, 372, 671, 339, 347, 15961, 8, 277, 12, 307, 18, 12, 2331, 304, 267, 408, 15540, 2536, 6491, 1263, 6957, 13, 19588, 730, 370, 2376, 370, 314, 13629, 737, 1779, 314, 1627, 3268, 1041, 267, 702, 730, 8, 84, 18, 9, 365, 6957, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 398, 2331, 847, 291, 14, 6981, 267, 307, 18, 14, 6981, 275, 2331, 435, 291, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 12, 2331, 9, 267, 307, 18, 14, 5571, 275, 291, 14, 5571, 339, 347, 2372, 8, 277, 12, 3285, 12, 2331, 304, 267, 408, 267, 2372, 9619, 2310, 282, 574, 402, 314, 730, 2013, 701, 658, 2469, 64, 221, 737, 314, 267, 1627, 3268, 14, 267, 408, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 267, 372, 3285, 14, 647, 63, 466, 8, 2143, 14, 1002, 8, 2469, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 430, 339, 347, 2372, 15183, 8, 277, 12, 9348, 12, 366, 12, 11822, 63, 2469, 304, 267, 653, 14, 19817, 63, 1955, 8, 7998, 12, 653, 14, 54, 6397, 6145, 1550, 9, 267, 340, 11822, 63, 2469, 365, 440, 488, 26, 288, 653, 14, 19817, 63, 1955, 8, 68, 12, 11822, 63, 2469, 9, 267, 2331, 275, 291, 14, 6397, 8, 7998, 9, 267, 340, 2331, 508, 378, 26, 288, 372, 366, 267, 372, 291, 14, 1002, 8, 11034, 63, 2469, 12, 291, 14, 6981, 435, 2331, 9, 339, 347, 2372, 3646, 2822, 25218, 8, 277, 12, 3285, 12, 2331, 304, 267, 408, 267, 2372, 3646, 2822, 25218, 2529, 314, 5477, 626, 9174, 737 ]
[ 1898, 6927, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 1275, 492, 3752, 199, 504, 1275, 492, 1329, 63, 1313, 465, 653, 421, 199, 533, 6957, 8, 785, 304, 272, 408, 3186, 14018, 282, 3696, 6014, 436, 6571, 1586, 2879, 370, 2399, 666, 14, 339, 710, 1750, 658, 6981, 64, 9126, 314, 1738, 402, 314, 19005, 30705, 909, 2337, 262, 1041, 339, 636, 7257, 363, 275, 1689, 5571, 401, 298, 6981, 531, 339, 347, 636, 826, 721, 277, 12, 4123, 12, 2086, 304, 267, 653, 14, 19817, 63, 1955, 8, 1712, 12, 653, 14, 53, 6397, 6145, 1550, 9, 398, 291, 14, 5571, 275, 4123, 267, 291, 14, 6981, 275, 2086, 339, 347, 29432, 8, 277, 12, 373, 1224, 6397, 304, 267, 408, 6397, 6571, 2879, 1901, 314, 6957, 1159, 373, 1224, 14, 398, 17993, 1504, 787, 5525, 701, 7907, 314, 373, 1224, 1159, 2582, 1041, 398, 373, 1224, 275, 291, 14, 6981, 446, 291, 14, 1002, 8, 46, 14, 4118, 12449, 6145, 1550, 12, 291, 14, 6981, 9, 267, 373, 1224, 3005, 275, 291, 14, 1002, 8, 46, 14, 54, 6397, 6145, 1550, 12, 373, 1224, 9, 267, 340, 373, 1224, 6397, 665, 373, 1224, 3005, 26, 288, 372, 291, 14, 1002, 8, 46, 14, 54, 6397, 6145, 1550, 12, 373, 1224, 435, 373, 1224, 6397, 9, 267, 372, 378, 339, 347, 1010, 2275, 8, 277, 12, 2331, 304, 267, 408, 607, 2275, 9619, 2310, 314, 3847, 3268, 5489, 737, 658, 2743, 17105, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 267, 372, 2331, 435, 3752, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 9, 339, 347, 2624, 8, 277, 12, 2331, 304, 267, 408, 1558, 7545, 282, 1059, 687, 666, 5489, 6272, 314, 6829, 2738, 1041, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 267, 2331, 847, 3752, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 9, 267, 1343, 275, 2331, 435, 653, 14, 53, 6397, 6145, 1550, 14, 4414, 2063, 267, 2582, 275, 3752, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 9, 267, 372, 2783, 8, 277, 14, 5571, 59, 928, 26, 928, 11, 1267, 566, 339, 347, 11388, 3166, 8, 277, 12, 2331, 304, 267, 408, 3646, 3166, 9619, 2310, 314, 2582, 402, 314, 5477, 7447, 3268, 365, 5489, 1779, 737, 298, 1997, 2, 315, 642, 909, 1041, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 398, 2331, 847, 291, 14, 6981, 267, 2331, 847, 3752, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 9, 267, 2203, 275, 3752, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 9, 267, 372, 2203, 339, 347, 11388, 8, 277, 12, 2331, 304, 267, 408, 3646, 9619, 2310, 314, 1343, 402, 666, 402, 314, 5477, 7447, 3268, 365, 1779, 5489, 737, 298, 1997, 2, 315, 642, 909, 1041, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 398, 2331, 847, 291, 14, 6981, 267, 671, 275, 2331, 435, 291, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 12, 2331, 9, 267, 327, 666, 9174, 2410, 3341, 3035, 314, 5477, 2582, 267, 671, 847, 653, 14, 53, 6397, 6145, 1550, 14, 4414, 2063, 267, 372, 671, 339, 347, 15961, 8, 277, 12, 307, 18, 12, 2331, 304, 267, 408, 15540, 2536, 6491, 1263, 6957, 13, 19588, 730, 370, 2376, 370, 314, 13629, 737, 1779, 314, 1627, 3268, 1041, 267, 702, 730, 8, 84, 18, 9, 365, 6957, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 398, 2331, 847, 291, 14, 6981, 267, 307, 18, 14, 6981, 275, 2331, 435, 291, 14, 1002, 8, 46, 14, 53, 6397, 6145, 1550, 12, 2331, 9, 267, 307, 18, 14, 5571, 275, 291, 14, 5571, 339, 347, 2372, 8, 277, 12, 3285, 12, 2331, 304, 267, 408, 267, 2372, 9619, 2310, 282, 574, 402, 314, 730, 2013, 701, 658, 2469, 64, 221, 737, 314, 267, 1627, 3268, 14, 267, 408, 267, 653, 14, 19817, 63, 1955, 8, 1997, 12, 653, 14, 53, 6397, 6145, 1550, 9, 267, 372, 3285, 14, 647, 63, 466, 8, 2143, 14, 1002, 8, 2469, 14, 1389, 281, 63, 466, 12, 291, 14, 5571, 12, 2331, 430, 339, 347, 2372, 15183, 8, 277, 12, 9348, 12, 366, 12, 11822, 63, 2469, 304, 267, 653, 14, 19817, 63, 1955, 8, 7998, 12, 653, 14, 54, 6397, 6145, 1550, 9, 267, 340, 11822, 63, 2469, 365, 440, 488, 26, 288, 653, 14, 19817, 63, 1955, 8, 68, 12, 11822, 63, 2469, 9, 267, 2331, 275, 291, 14, 6397, 8, 7998, 9, 267, 340, 2331, 508, 378, 26, 288, 372, 366, 267, 372, 291, 14, 1002, 8, 11034, 63, 2469, 12, 291, 14, 6981, 435, 2331, 9, 339, 347, 2372, 3646, 2822, 25218, 8, 277, 12, 3285, 12, 2331, 304, 267, 408, 267, 2372, 3646, 2822, 25218, 2529, 314, 5477, 626, 9174, 737, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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ute/subcommands/forwarding_rules/create.py
2
5592
# Copyright 2014 Google Inc. All Rights Reserved. """Command for creating forwarding rules.""" from googlecloudapis.compute.v1 import compute_v1_messages from googlecloudsdk.calliope import exceptions from googlecloudsdk.compute.lib import base_classes from googlecloudsdk.compute.lib import forwarding_rules_utils as utils def _supported_protocols(messages): return messages.ForwardingRule.IPProtocolValueValuesEnum.to_dict().keys() class Create(base_classes.ListOutputMixin, utils.ForwardingRulesTargetMutator): """Create a forwarding rule to direct network traffic to a load balancer.""" @staticmethod def Args(parser): utils.ForwardingRulesTargetMutator.Args(parser, include_beta_targets=True) address = parser.add_argument( '--address', help='The external IP address that the forwarding rule will serve.') address.detailed_help = """\ The external IP address that the forwarding rule will serve. All traffic sent to this IP address is directed to the target pointed to by the forwarding rule. If the address is reserved, it must either (1) reside in the global scope if the forwarding rule is being configured to point to a target HTTP proxy or (2) reside in the same region as the forwarding rule if the forwarding rule is being configured to point to a target pool or target instance. If this flag is omitted, an ephemeral IP address is assigned. """ ip_protocol = parser.add_argument( '--ip-protocol', choices=_supported_protocols(compute_v1_messages), type=lambda x: x.upper(), help='The IP protocol that the rule will serve.') ip_protocol.detailed_help = """\ The IP protocol that the rule will serve. If left empty, TCP is used. Supported protocols are: {0}. """.format(', '.join(_supported_protocols(compute_v1_messages))) parser.add_argument( '--description', help='An optional textual description for the forwarding rule.') port_range = parser.add_argument( '--port-range', help=('If specified, only packets addressed to the port or ' 'ports in the specified range will be forwarded.'), metavar='[PORT | PORT-PORT]') port_range.detailed_help = """\ If specified, only packets addressed to ports in the specified range will be forwarded. If not specified for regional forwarding rules, all ports are matched. This flag is required for global forwarding rules. """ @property def method(self): return 'Insert' def ConstructProtocol(self, args): if args.ip_protocol: return self.messages.ForwardingRule.IPProtocolValueValuesEnum( args.ip_protocol) else: return def CreateGlobalRequests(self, args): """Create a globally scoped request.""" if not args.port_range: raise exceptions.ToolException( '[--port-range] is required for global forwarding rules.') target_ref = self.GetGlobalTarget(args) forwarding_rule_ref = self.CreateGlobalReference( args.name, resource_type='globalForwardingRules') protocol = self.ConstructProtocol(args) request = self.messages.ComputeGlobalForwardingRulesInsertRequest( forwardingRule=self.messages.ForwardingRule( description=args.description, name=forwarding_rule_ref.Name(), IPAddress=args.address, IPProtocol=protocol, portRange=args.port_range, target=target_ref.SelfLink(), ), project=self.project) return [request] def CreateRegionalRequests(self, args): """Create a regionally scoped request.""" target_ref, target_region = self.GetRegionalTarget(args) forwarding_rule_ref = self.CreateRegionalReference( args.name, args.region or target_region) protocol = self.ConstructProtocol(args) request = self.messages.ComputeForwardingRulesInsertRequest( forwardingRule=self.messages.ForwardingRule( description=args.description, name=forwarding_rule_ref.Name(), IPAddress=args.address, IPProtocol=protocol, portRange=args.port_range, target=target_ref.SelfLink(), ), project=self.project, region=forwarding_rule_ref.region) return [request] Create.detailed_help = { 'brief': ('Create a forwarding rule to direct network traffic to a load ' 'balancer'), 'DESCRIPTION': """\ *{command}* is used to create a forwarding rule. Forwarding rules match and direct certain types of traffic to a load balancer which is controlled by a target pool, a target instance, or a target HTTP proxy. Target pools and target instances perform load balancing at the layer 3 of the OSI networking model (link:http://en.wikipedia.org/wiki/Network_layer[]). Target HTTP proxies perform load balancing at layer 7. Forwarding rules can be either regional or global. They are regional if they point to a target pool or a target instance and global if they point to a target HTTP proxy. For more information on load balancing, see link:https://developers.google.com/compute/docs/load-balancing/[]. When creating a forwarding rule, exactly one of ``--target-instance'' ``--target-pool'', and ``--target-http-proxy'' must be specified. """, }
bsd-3-clause
[ 3, 1898, 6927, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 624, 3110, 367, 6425, 24119, 4713, 1041, 199, 199, 504, 6233, 4091, 12662, 14, 3357, 14, 86, 17, 492, 4526, 63, 86, 17, 63, 3431, 199, 504, 6233, 29691, 6341, 14, 915, 317, 13458, 492, 4967, 199, 504, 6233, 29691, 6341, 14, 3357, 14, 773, 492, 1300, 63, 2888, 199, 504, 6233, 29691, 6341, 14, 3357, 14, 773, 492, 24119, 63, 4423, 63, 1208, 465, 3778, 421, 199, 318, 485, 4946, 63, 16541, 8, 3431, 304, 523, 372, 3788, 14, 26427, 5065, 14, 1772, 3658, 1110, 6550, 5081, 14, 475, 63, 807, 1252, 1612, 342, 421, 199, 533, 2790, 8, 1095, 63, 2888, 14, 1296, 2959, 4256, 12, 1467, 3778, 14, 26427, 12920, 4277, 22539, 707, 304, 523, 408, 2499, 282, 24119, 2332, 370, 4125, 2784, 15602, 370, 282, 2248, 17005, 1041, 819, 768, 4639, 523, 347, 3033, 8, 2087, 304, 272, 3778, 14, 26427, 12920, 4277, 22539, 707, 14, 6213, 8, 2087, 12, 4490, 2387, 63, 5683, 63, 4684, 29, 549, 9, 339, 2287, 275, 1798, 14, 525, 63, 2094, 8, 267, 2850, 1562, 297, 267, 1720, 534, 1918, 5957, 3531, 2287, 626, 314, 24119, 2332, 911, 14062, 2659, 272, 2287, 14, 19170, 63, 3437, 275, 9638, 267, 710, 5957, 3531, 2287, 626, 314, 24119, 2332, 911, 267, 14062, 14, 2900, 15602, 4847, 370, 642, 3531, 2287, 365, 23667, 370, 314, 267, 1347, 32031, 370, 701, 314, 24119, 2332, 14, 982, 314, 2287, 365, 267, 4644, 12, 652, 1471, 1902, 334, 17, 9, 295, 2441, 315, 314, 2288, 4194, 340, 314, 267, 24119, 2332, 365, 3769, 7526, 370, 2376, 370, 282, 1347, 3101, 267, 4566, 503, 334, 18, 9, 295, 2441, 315, 314, 2011, 4897, 465, 314, 24119, 2332, 267, 340, 314, 24119, 2332, 365, 3769, 7526, 370, 2376, 370, 282, 267, 1347, 4203, 503, 1347, 1256, 14, 982, 642, 3305, 365, 11684, 12, 376, 267, 26288, 3531, 2287, 365, 7943, 14, 267, 408, 339, 3384, 63, 3922, 275, 1798, 14, 525, 63, 2094, 8, 267, 2850, 711, 13, 3922, 297, 267, 3415, 3699, 4946, 63, 16541, 8, 3357, 63, 86, 17, 63, 3431, 395, 267, 730, 29, 2734, 671, 26, 671, 14, 4142, 1062, 267, 1720, 534, 1918, 3531, 4113, 626, 314, 2332, 911, 14062, 2659, 272, 3384, 63, 3922, 14, 19170, 63, 3437, 275, 9638, 267, 710, 3531, 4113, 626, 314, 2332, 911, 14062, 14, 982, 3602, 2701, 12, 13488, 267, 365, 1202, 14, 26167, 19230, 787, 26, 469, 16, 5565, 267, 30512, 908, 5102, 1987, 904, 1547, 4946, 63, 16541, 8, 3357, 63, 86, 17, 63, 3431, 1724, 339, 1798, 14, 525, 63, 2094, 8, 267, 2850, 1802, 297, 267, 1720, 534, 2493, 2716, 25884, 1369, 367, 314, 24119, 2332, 2659, 339, 1844, 63, 1842, 275, 1798, 14, 525, 63, 2094, 8, 267, 2850, 719, 13, 1842, 297, 267, 1720, 7782, 3917, 2013, 12, 1454, 14593, 1050, 5111, 370, 314, 1844, 503, 283, 1598, 283, 5203, 315, 314, 2013, 1425, 911, 506, 24172, 8038, 267, 8214, 30845, 3657, 1204, 25562, 13, 3657, 10374, 272, 1844, 63, 1842, 14, 19170, 63, 3437, 275, 9638, 267, 982, 2013, 12, 1454, 14593, 1050, 5111, 370, 8873, 315, 314, 2013, 267, 1425, 911, 506, 24172, 14, 982, 440, 2013, 367, 4897, 279, 24119, 267, 4713, 12, 1006, 8873, 787, 7838, 14, 961, 3305, 365, 1415, 367, 2288, 267, 24119, 4713, 14, 267, 408, 819, 768, 1829, 523, 347, 1083, 8, 277, 304, 272, 372, 283, 9971, 7, 819, 347, 9215, 3658, 8, 277, 12, 1249, 304, 272, 340, 1249, 14, 711, 63, 3922, 26, 489, 372, 291, 14, 3431, 14, 26427, 5065, 14, 1772, 3658, 1110, 6550, 5081, 8, 881, 1249, 14, 711, 63, 3922, 9, 272, 587, 26, 489, 372, 819, 347, 2790, 7025, 16272, 8, 277, 12, 1249, 304, 272, 408, 2499, 282, 26662, 27582, 1056, 1041, 272, 340, 440, 1249, 14, 719, 63, 1842, 26, 489, 746, 4967, 14, 5157, 1726, 8, 881, 6730, 306, 719, 13, 1842, 61, 365, 1415, 367, 2288, 24119, 4713, 2659, 339, 1347, 63, 1121, 275, 291, 14, 1002, 7025, 4277, 8, 589, 9, 272, 24119, 63, 2200, 63, 1121, 275, 291, 14, 2499, 7025, 5083, 8, 267, 1249, 14, 354, 12, 2073, 63, 466, 534, 2966, 26427, 12920, 358, 272, 4113, 275, 291, 14, 11493, 3658, 8, 589, 9, 339, 1056, 275, 291, 14, 3431, 14, 8564, 7025, 26427, 12920, 9971, 2017, 8, 267, 24119, 5065, 29, 277, 14, 3431, 14, 26427, 5065, 8, 288, 1369, 29, 589, 14, 1802, 12, 288, 536, 29, 21513, 63, 2200, 63, 1121, 14, 985, 1062, 288, 3531, 1476, 29, 589, 14, 1562, 12, 288, 3531, 3658, 29, 3922, 12, 288, 1844, 4709, 29, 589, 14, 719, 63, 1842, 12, 288, 1347, 29, 1375, 63, 1121, 14, 12887, 3834, 1062, 267, 2318, 267, 2199, 29, 277, 14, 1715, 9, 339, 372, 359, 1069, 61, 819, 347, 2790, 10708, 279, 16272, 8, 277, 12, 1249, 304, 272, 408, 2499, 282, 4897, 1183, 27582, 1056, 1041, 272, 1347, 63, 1121, 12, 1347, 63, 4551, 275, 291, 14, 1002, 10708, 279, 4277, 8, 589, 9, 272, 24119, 63, 2200, 63, 1121, 275, 291, 14, 2499, 10708, 279, 5083, 8, 267, 1249, 14, 354, 12, 1249, 14, 4551, 503, 1347, 63, 4551, 9, 272, 4113, 275, 291, 14, 11493, 3658, 8, 589, 9, 339, 1056, 275, 291, 14, 3431, 14, 8564, 26427, 12920, 9971, 2017, 8, 267, 24119, 5065, 29, 277, 14, 3431, 14, 26427, 5065, 8, 288, 1369, 29, 589, 14, 1802, 12, 288, 536, 29, 21513, 63, 2200, 63, 1121, 14, 985, 1062, 288, 3531, 1476, 29, 589, 14, 1562, 12, 288, 3531, 3658, 29, 3922, 12, 288, 1844, 4709, 29, 589, 14, 719, 63, 1842, 12, 288, 1347, 29, 1375, 63, 1121, 14, 12887, 3834, 1062, 267, 2318, 267, 2199, 29, 277, 14, 1715, 12, 267, 4897, 29, 21513, 63, 2200, 63, 1121, 14, 4551, 9, 339, 372, 359, 1069, 61, 199, 199, 2499, 14, 19170, 63, 3437, 275, 469, 272, 283, 19127, 356, 661, 2499, 282, 24119, 2332, 370, 4125, 2784, 15602, 370, 282, 2248, 283, 1598, 283, 11841, 659, 272, 283, 17705, 356, 9638, 267, 627, 91 ]
[ 1898, 6927, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 624, 3110, 367, 6425, 24119, 4713, 1041, 199, 199, 504, 6233, 4091, 12662, 14, 3357, 14, 86, 17, 492, 4526, 63, 86, 17, 63, 3431, 199, 504, 6233, 29691, 6341, 14, 915, 317, 13458, 492, 4967, 199, 504, 6233, 29691, 6341, 14, 3357, 14, 773, 492, 1300, 63, 2888, 199, 504, 6233, 29691, 6341, 14, 3357, 14, 773, 492, 24119, 63, 4423, 63, 1208, 465, 3778, 421, 199, 318, 485, 4946, 63, 16541, 8, 3431, 304, 523, 372, 3788, 14, 26427, 5065, 14, 1772, 3658, 1110, 6550, 5081, 14, 475, 63, 807, 1252, 1612, 342, 421, 199, 533, 2790, 8, 1095, 63, 2888, 14, 1296, 2959, 4256, 12, 1467, 3778, 14, 26427, 12920, 4277, 22539, 707, 304, 523, 408, 2499, 282, 24119, 2332, 370, 4125, 2784, 15602, 370, 282, 2248, 17005, 1041, 819, 768, 4639, 523, 347, 3033, 8, 2087, 304, 272, 3778, 14, 26427, 12920, 4277, 22539, 707, 14, 6213, 8, 2087, 12, 4490, 2387, 63, 5683, 63, 4684, 29, 549, 9, 339, 2287, 275, 1798, 14, 525, 63, 2094, 8, 267, 2850, 1562, 297, 267, 1720, 534, 1918, 5957, 3531, 2287, 626, 314, 24119, 2332, 911, 14062, 2659, 272, 2287, 14, 19170, 63, 3437, 275, 9638, 267, 710, 5957, 3531, 2287, 626, 314, 24119, 2332, 911, 267, 14062, 14, 2900, 15602, 4847, 370, 642, 3531, 2287, 365, 23667, 370, 314, 267, 1347, 32031, 370, 701, 314, 24119, 2332, 14, 982, 314, 2287, 365, 267, 4644, 12, 652, 1471, 1902, 334, 17, 9, 295, 2441, 315, 314, 2288, 4194, 340, 314, 267, 24119, 2332, 365, 3769, 7526, 370, 2376, 370, 282, 1347, 3101, 267, 4566, 503, 334, 18, 9, 295, 2441, 315, 314, 2011, 4897, 465, 314, 24119, 2332, 267, 340, 314, 24119, 2332, 365, 3769, 7526, 370, 2376, 370, 282, 267, 1347, 4203, 503, 1347, 1256, 14, 982, 642, 3305, 365, 11684, 12, 376, 267, 26288, 3531, 2287, 365, 7943, 14, 267, 408, 339, 3384, 63, 3922, 275, 1798, 14, 525, 63, 2094, 8, 267, 2850, 711, 13, 3922, 297, 267, 3415, 3699, 4946, 63, 16541, 8, 3357, 63, 86, 17, 63, 3431, 395, 267, 730, 29, 2734, 671, 26, 671, 14, 4142, 1062, 267, 1720, 534, 1918, 3531, 4113, 626, 314, 2332, 911, 14062, 2659, 272, 3384, 63, 3922, 14, 19170, 63, 3437, 275, 9638, 267, 710, 3531, 4113, 626, 314, 2332, 911, 14062, 14, 982, 3602, 2701, 12, 13488, 267, 365, 1202, 14, 26167, 19230, 787, 26, 469, 16, 5565, 267, 30512, 908, 5102, 1987, 904, 1547, 4946, 63, 16541, 8, 3357, 63, 86, 17, 63, 3431, 1724, 339, 1798, 14, 525, 63, 2094, 8, 267, 2850, 1802, 297, 267, 1720, 534, 2493, 2716, 25884, 1369, 367, 314, 24119, 2332, 2659, 339, 1844, 63, 1842, 275, 1798, 14, 525, 63, 2094, 8, 267, 2850, 719, 13, 1842, 297, 267, 1720, 7782, 3917, 2013, 12, 1454, 14593, 1050, 5111, 370, 314, 1844, 503, 283, 1598, 283, 5203, 315, 314, 2013, 1425, 911, 506, 24172, 8038, 267, 8214, 30845, 3657, 1204, 25562, 13, 3657, 10374, 272, 1844, 63, 1842, 14, 19170, 63, 3437, 275, 9638, 267, 982, 2013, 12, 1454, 14593, 1050, 5111, 370, 8873, 315, 314, 2013, 267, 1425, 911, 506, 24172, 14, 982, 440, 2013, 367, 4897, 279, 24119, 267, 4713, 12, 1006, 8873, 787, 7838, 14, 961, 3305, 365, 1415, 367, 2288, 267, 24119, 4713, 14, 267, 408, 819, 768, 1829, 523, 347, 1083, 8, 277, 304, 272, 372, 283, 9971, 7, 819, 347, 9215, 3658, 8, 277, 12, 1249, 304, 272, 340, 1249, 14, 711, 63, 3922, 26, 489, 372, 291, 14, 3431, 14, 26427, 5065, 14, 1772, 3658, 1110, 6550, 5081, 8, 881, 1249, 14, 711, 63, 3922, 9, 272, 587, 26, 489, 372, 819, 347, 2790, 7025, 16272, 8, 277, 12, 1249, 304, 272, 408, 2499, 282, 26662, 27582, 1056, 1041, 272, 340, 440, 1249, 14, 719, 63, 1842, 26, 489, 746, 4967, 14, 5157, 1726, 8, 881, 6730, 306, 719, 13, 1842, 61, 365, 1415, 367, 2288, 24119, 4713, 2659, 339, 1347, 63, 1121, 275, 291, 14, 1002, 7025, 4277, 8, 589, 9, 272, 24119, 63, 2200, 63, 1121, 275, 291, 14, 2499, 7025, 5083, 8, 267, 1249, 14, 354, 12, 2073, 63, 466, 534, 2966, 26427, 12920, 358, 272, 4113, 275, 291, 14, 11493, 3658, 8, 589, 9, 339, 1056, 275, 291, 14, 3431, 14, 8564, 7025, 26427, 12920, 9971, 2017, 8, 267, 24119, 5065, 29, 277, 14, 3431, 14, 26427, 5065, 8, 288, 1369, 29, 589, 14, 1802, 12, 288, 536, 29, 21513, 63, 2200, 63, 1121, 14, 985, 1062, 288, 3531, 1476, 29, 589, 14, 1562, 12, 288, 3531, 3658, 29, 3922, 12, 288, 1844, 4709, 29, 589, 14, 719, 63, 1842, 12, 288, 1347, 29, 1375, 63, 1121, 14, 12887, 3834, 1062, 267, 2318, 267, 2199, 29, 277, 14, 1715, 9, 339, 372, 359, 1069, 61, 819, 347, 2790, 10708, 279, 16272, 8, 277, 12, 1249, 304, 272, 408, 2499, 282, 4897, 1183, 27582, 1056, 1041, 272, 1347, 63, 1121, 12, 1347, 63, 4551, 275, 291, 14, 1002, 10708, 279, 4277, 8, 589, 9, 272, 24119, 63, 2200, 63, 1121, 275, 291, 14, 2499, 10708, 279, 5083, 8, 267, 1249, 14, 354, 12, 1249, 14, 4551, 503, 1347, 63, 4551, 9, 272, 4113, 275, 291, 14, 11493, 3658, 8, 589, 9, 339, 1056, 275, 291, 14, 3431, 14, 8564, 26427, 12920, 9971, 2017, 8, 267, 24119, 5065, 29, 277, 14, 3431, 14, 26427, 5065, 8, 288, 1369, 29, 589, 14, 1802, 12, 288, 536, 29, 21513, 63, 2200, 63, 1121, 14, 985, 1062, 288, 3531, 1476, 29, 589, 14, 1562, 12, 288, 3531, 3658, 29, 3922, 12, 288, 1844, 4709, 29, 589, 14, 719, 63, 1842, 12, 288, 1347, 29, 1375, 63, 1121, 14, 12887, 3834, 1062, 267, 2318, 267, 2199, 29, 277, 14, 1715, 12, 267, 4897, 29, 21513, 63, 2200, 63, 1121, 14, 4551, 9, 339, 372, 359, 1069, 61, 199, 199, 2499, 14, 19170, 63, 3437, 275, 469, 272, 283, 19127, 356, 661, 2499, 282, 24119, 2332, 370, 4125, 2784, 15602, 370, 282, 2248, 283, 1598, 283, 11841, 659, 272, 283, 17705, 356, 9638, 267, 627, 91, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
devttys0/idascript
src/idascript.py
1
1858
################################################################################################## # Python module for IDAPython scripts executed via idascript. # # Copied from the original idascript utility, with minor changes: http://www.hexblog.com/?p=128 # # Craig Heffner # 14-November-2012 # http://www.tacnetsol.com # http://www.devttys0.com ################################################################################################## import os import sys import tempfile import idc import idaapi import re import traceback __idascript_active__ = False def exit(code=0): if __idascript_active__: idc.Exit(code) class ToFileStdOut(object): def __init__(self, outfile): self.outfile = open(outfile, 'w') def write(self, text): self.outfile.write(text) def flush(self): self.outfile.flush() def isatty(self): return False def __del__(self): self.outfile.close() def loadAllPythonPlugins(): plugins_dir = idaapi.idadir('plugins') print("idascript: loading all .py plugins in %s" % plugins_dir) files = [f for f in os.listdir(plugins_dir) if re.match(r'.*\.py', f)] for path in files: idaapi.load_plugin(path) if len(idc.ARGV) > 1 and idc.ARGV[1] == '__idascript_active__': __idascript_active__ = True idc.ARGV.pop(1) outfile=idc.ARGV.pop(1) # Redirect stdout and stderr to the output file sys.stdout = sys.stderr = ToFileStdOut(os.path.join(tempfile.gettempdir(), outfile)) # Make the normal sys.argv and sys.exit function properly sys.argv = idc.ARGV sys.exit = idc.Exit try: loadAllPythonPlugins() except: traceback.print_exc() exit(1) # Wait for IDA's auto analysis to finish idaapi.autoWait()
mit
[ 3060, 1371, 309, 202, 199, 3, 2018, 859, 367, 2870, 1282, 11361, 10554, 7934, 4799, 1305, 7229, 14, 202, 199, 3, 202, 199, 3, 29622, 5299, 687, 314, 3379, 1305, 7229, 11420, 12, 543, 12612, 4493, 26, 1455, 921, 1544, 14, 426, 1774, 793, 14, 957, 10197, 80, 29, 3933, 202, 199, 3, 202, 199, 3, 445, 345, 528, 869, 3609, 1372, 202, 199, 3, 4329, 13, 1944, 432, 976, 13, 7409, 202, 199, 3, 1455, 921, 1544, 14, 27308, 846, 7873, 14, 957, 202, 199, 3, 1455, 921, 1544, 14, 2374, 4707, 83, 16, 14, 957, 202, 199, 3060, 1371, 309, 2999, 199, 646, 747, 202, 199, 646, 984, 202, 199, 646, 5549, 202, 199, 646, 1305, 67, 202, 199, 646, 284, 983, 1246, 202, 199, 646, 295, 2999, 199, 646, 5190, 2999, 199, 363, 344, 7229, 63, 2682, 363, 275, 756, 2999, 199, 318, 4458, 8, 600, 29, 16, 304, 1128, 340, 636, 344, 7229, 63, 2682, 10651, 1039, 1305, 67, 14, 6699, 8, 600, 9, 2999, 199, 533, 4005, 1173, 11976, 2204, 8, 785, 304, 1128, 347, 636, 826, 721, 277, 12, 4386, 304, 1039, 291, 14, 4984, 275, 1551, 8, 4984, 12, 283, 87, 358, 2958, 347, 2218, 8, 277, 12, 1318, 304, 1039, 291, 14, 4984, 14, 952, 8, 505, 9, 2958, 347, 8976, 8, 277, 304, 1039, 291, 14, 4984, 14, 4939, 342, 2958, 347, 365, 16623, 8, 277, 304, 1039, 372, 756, 2958, 347, 636, 2264, 721, 277, 304, 1039, 291, 14, 4984, 14, 1600, 342, 2999, 199, 318, 2248, 2422, 4718, 19330, 837, 1128, 8963, 63, 694, 275, 284, 983, 1246, 14, 29132, 694, 360, 5265, 358, 1128, 870, 480, 344, 7229, 26, 8697, 1006, 1275, 647, 8963, 315, 450, 83, 2, 450, 8963, 63, 694, 9, 1128, 1584, 275, 359, 70, 367, 289, 315, 747, 14, 7374, 8, 5265, 63, 694, 9, 340, 295, 14, 1431, 8, 82, 24898, 4537, 647, 297, 289, 1874, 1128, 367, 931, 315, 1584, 26, 1039, 284, 983, 1246, 14, 912, 63, 2718, 8, 515, 9, 2999, 199, 692, 822, 8, 344, 67, 14, 11611, 54, 9, 690, 413, 436, 1305, 67, 14, 11611, 54, 59, 17, 61, 508, 2560, 344, 7229, 63, 2682, 3706, 1128, 636, 344, 7229, 63, 2682, 363, 275, 715, 1128, 1305, 67, 14, 11611, 54, 14, 1935, 8, 17, 9, 1128, 4386, 29, 344, 67, 14, 11611, 54, 14, 1935, 8, 17, 9, 2958, 327, 18532, 3839, 436, 4635, 370, 314, 1072, 570, 1128, 984, 14, 2703, 275, 984, 14, 3083, 275, 4005, 1173, 11976, 2204, 8, 736, 14, 515, 14, 904, 8, 17336, 14, 31572, 1062, 4386, 430, 1128, 327, 4155, 314, 3293, 984, 14, 3020, 436, 984, 14, 2224, 805, 7684, 1128, 984, 14, 3020, 275, 1305, 67, 14, 11611, 54, 1128, 984, 14, 2224, 275, 1305, 67, 14, 6699, 2958, 862, 26, 1039, 2248, 2422, 4718, 19330, 342, 1128, 871, 26, 1039, 5190, 14, 1361, 63, 2804, 342, 1039, 4458, 8, 17, 9, 2958, 327, 13144, 367, 2870, 33, 1159, 2599, 11284, 370, 9578, 1128, 284, 983, 1246, 14, 2495, 7536, 342, 10060, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1371, 309, 202, 199, 3, 2018, 859, 367, 2870, 1282, 11361, 10554, 7934, 4799, 1305, 7229, 14, 202, 199, 3, 202, 199, 3, 29622, 5299, 687, 314, 3379, 1305, 7229, 11420, 12, 543, 12612, 4493, 26, 1455, 921, 1544, 14, 426, 1774, 793, 14, 957, 10197, 80, 29, 3933, 202, 199, 3, 202, 199, 3, 445, 345, 528, 869, 3609, 1372, 202, 199, 3, 4329, 13, 1944, 432, 976, 13, 7409, 202, 199, 3, 1455, 921, 1544, 14, 27308, 846, 7873, 14, 957, 202, 199, 3, 1455, 921, 1544, 14, 2374, 4707, 83, 16, 14, 957, 202, 199, 3060, 1371, 309, 2999, 199, 646, 747, 202, 199, 646, 984, 202, 199, 646, 5549, 202, 199, 646, 1305, 67, 202, 199, 646, 284, 983, 1246, 202, 199, 646, 295, 2999, 199, 646, 5190, 2999, 199, 363, 344, 7229, 63, 2682, 363, 275, 756, 2999, 199, 318, 4458, 8, 600, 29, 16, 304, 1128, 340, 636, 344, 7229, 63, 2682, 10651, 1039, 1305, 67, 14, 6699, 8, 600, 9, 2999, 199, 533, 4005, 1173, 11976, 2204, 8, 785, 304, 1128, 347, 636, 826, 721, 277, 12, 4386, 304, 1039, 291, 14, 4984, 275, 1551, 8, 4984, 12, 283, 87, 358, 2958, 347, 2218, 8, 277, 12, 1318, 304, 1039, 291, 14, 4984, 14, 952, 8, 505, 9, 2958, 347, 8976, 8, 277, 304, 1039, 291, 14, 4984, 14, 4939, 342, 2958, 347, 365, 16623, 8, 277, 304, 1039, 372, 756, 2958, 347, 636, 2264, 721, 277, 304, 1039, 291, 14, 4984, 14, 1600, 342, 2999, 199, 318, 2248, 2422, 4718, 19330, 837, 1128, 8963, 63, 694, 275, 284, 983, 1246, 14, 29132, 694, 360, 5265, 358, 1128, 870, 480, 344, 7229, 26, 8697, 1006, 1275, 647, 8963, 315, 450, 83, 2, 450, 8963, 63, 694, 9, 1128, 1584, 275, 359, 70, 367, 289, 315, 747, 14, 7374, 8, 5265, 63, 694, 9, 340, 295, 14, 1431, 8, 82, 24898, 4537, 647, 297, 289, 1874, 1128, 367, 931, 315, 1584, 26, 1039, 284, 983, 1246, 14, 912, 63, 2718, 8, 515, 9, 2999, 199, 692, 822, 8, 344, 67, 14, 11611, 54, 9, 690, 413, 436, 1305, 67, 14, 11611, 54, 59, 17, 61, 508, 2560, 344, 7229, 63, 2682, 3706, 1128, 636, 344, 7229, 63, 2682, 363, 275, 715, 1128, 1305, 67, 14, 11611, 54, 14, 1935, 8, 17, 9, 1128, 4386, 29, 344, 67, 14, 11611, 54, 14, 1935, 8, 17, 9, 2958, 327, 18532, 3839, 436, 4635, 370, 314, 1072, 570, 1128, 984, 14, 2703, 275, 984, 14, 3083, 275, 4005, 1173, 11976, 2204, 8, 736, 14, 515, 14, 904, 8, 17336, 14, 31572, 1062, 4386, 430, 1128, 327, 4155, 314, 3293, 984, 14, 3020, 436, 984, 14, 2224, 805, 7684, 1128, 984, 14, 3020, 275, 1305, 67, 14, 11611, 54, 1128, 984, 14, 2224, 275, 1305, 67, 14, 6699, 2958, 862, 26, 1039, 2248, 2422, 4718, 19330, 342, 1128, 871, 26, 1039, 5190, 14, 1361, 63, 2804, 342, 1039, 4458, 8, 17, 9, 2958, 327, 13144, 367, 2870, 33, 1159, 2599, 11284, 370, 9578, 1128, 284, 983, 1246, 14, 2495, 7536, 342, 10060, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
wfxiang08/django178
tests/queries/tests.py
3
145751
from __future__ import unicode_literals import datetime import pickle import unittest import warnings from collections import OrderedDict from operator import attrgetter from django.core.exceptions import FieldError from django.db import DEFAULT_DB_ALIAS, connection from django.db.models import F, Q, Count from django.db.models.sql.datastructures import EmptyResultSet from django.db.models.sql.where import EverythingNode, NothingNode, WhereNode from django.test import TestCase, skipUnlessDBFeature from django.test.utils import CaptureQueriesContext, str_prefix from django.utils import six from django.utils.six.moves import range from .models import ( FK1, X, Annotation, Article, Author, BaseA, Book, CategoryItem, CategoryRelationship, Celebrity, Channel, Chapter, Child, Classroom, Company, Cover, CustomPk, CustomPkTag, Detail, DumbCategory, Eaten, Employment, ExtraInfo, Fan, Food, Identifier, Individual, Item, Job, JobResponsibilities, Join, LeafA, LeafB, LoopX, LoopZ, ManagedModel, Member, ModelA, ModelB, ModelC, ModelD, MyObject, NamedCategory, Node, Note, NullableName, Number, ObjectA, ObjectB, ObjectC, OneToOneCategory, Order, OrderItem, Page, Paragraph, Person, Plaything, PointerA, Program, ProxyCategory, Ranking, Related, RelatedIndividual, RelatedObject, Report, ReservedName, Responsibility, School, SharedConnection, SimpleCategory, SingleObject, SpecialCategory, Staff, StaffUser, Student, Tag, Task, Ticket21203Child, Ticket21203Parent, Ticket23605A, Ticket23605B, Ticket23605C, TvChef, Valid, ) class BaseQuerysetTest(TestCase): def assertValueQuerysetEqual(self, qs, values): return self.assertQuerysetEqual(qs, values, transform=lambda x: x) class Queries1Tests(BaseQuerysetTest): def setUp(self): generic = NamedCategory.objects.create(name="Generic") self.t1 = Tag.objects.create(name='t1', category=generic) self.t2 = Tag.objects.create(name='t2', parent=self.t1, category=generic) self.t3 = Tag.objects.create(name='t3', parent=self.t1) t4 = Tag.objects.create(name='t4', parent=self.t3) self.t5 = Tag.objects.create(name='t5', parent=self.t3) self.n1 = Note.objects.create(note='n1', misc='foo', id=1) n2 = Note.objects.create(note='n2', misc='bar', id=2) self.n3 = Note.objects.create(note='n3', misc='foo', id=3) ann1 = Annotation.objects.create(name='a1', tag=self.t1) ann1.notes.add(self.n1) ann2 = Annotation.objects.create(name='a2', tag=t4) ann2.notes.add(n2, self.n3) # Create these out of order so that sorting by 'id' will be different to sorting # by 'info'. Helps detect some problems later. self.e2 = ExtraInfo.objects.create(info='e2', note=n2, value=41) e1 = ExtraInfo.objects.create(info='e1', note=self.n1, value=42) self.a1 = Author.objects.create(name='a1', num=1001, extra=e1) self.a2 = Author.objects.create(name='a2', num=2002, extra=e1) a3 = Author.objects.create(name='a3', num=3003, extra=self.e2) self.a4 = Author.objects.create(name='a4', num=4004, extra=self.e2) self.time1 = datetime.datetime(2007, 12, 19, 22, 25, 0) self.time2 = datetime.datetime(2007, 12, 19, 21, 0, 0) time3 = datetime.datetime(2007, 12, 20, 22, 25, 0) time4 = datetime.datetime(2007, 12, 20, 21, 0, 0) self.i1 = Item.objects.create(name='one', created=self.time1, modified=self.time1, creator=self.a1, note=self.n3) self.i1.tags = [self.t1, self.t2] self.i2 = Item.objects.create(name='two', created=self.time2, creator=self.a2, note=n2) self.i2.tags = [self.t1, self.t3] self.i3 = Item.objects.create(name='three', created=time3, creator=self.a2, note=self.n3) i4 = Item.objects.create(name='four', created=time4, creator=self.a4, note=self.n3) i4.tags = [t4] self.r1 = Report.objects.create(name='r1', creator=self.a1) Report.objects.create(name='r2', creator=a3) Report.objects.create(name='r3') # Ordering by 'rank' gives us rank2, rank1, rank3. Ordering by the Meta.ordering # will be rank3, rank2, rank1. self.rank1 = Ranking.objects.create(rank=2, author=self.a2) Cover.objects.create(title="first", item=i4) Cover.objects.create(title="second", item=self.i2) def test_subquery_condition(self): qs1 = Tag.objects.filter(pk__lte=0) qs2 = Tag.objects.filter(parent__in=qs1) qs3 = Tag.objects.filter(parent__in=qs2) self.assertEqual(qs3.query.subq_aliases, set(['T', 'U', 'V'])) self.assertIn('v0', str(qs3.query).lower()) qs4 = qs3.filter(parent__in=qs1) self.assertEqual(qs4.query.subq_aliases, set(['T', 'U', 'V'])) # It is possible to reuse U for the second subquery, no need to use W. self.assertNotIn('w0', str(qs4.query).lower()) # So, 'U0."id"' is referenced twice. self.assertTrue(str(qs4.query).lower().count('u0'), 2) def test_ticket1050(self): self.assertQuerysetEqual( Item.objects.filter(tags__isnull=True), ['<Item: three>'] ) self.assertQuerysetEqual( Item.objects.filter(tags__id__isnull=True), ['<Item: three>'] ) def test_ticket1801(self): self.assertQuerysetEqual( Author.objects.filter(item=self.i2), ['<Author: a2>'] ) self.assertQuerysetEqual( Author.objects.filter(item=self.i3), ['<Author: a2>'] ) self.assertQuerysetEqual( Author.objects.filter(item=self.i2) & Author.objects.filter(item=self.i3), ['<Author: a2>'] ) def test_ticket2306(self): # Checking that no join types are "left outer" joins. query = Item.objects.filter(tags=self.t2).query self.assertTrue(query.LOUTER not in [x[2] for x in query.alias_map.values()]) self.assertQuerysetEqual( Item.objects.filter(Q(tags=self.t1)).order_by('name'), ['<Item: one>', '<Item: two>'] ) self.assertQuerysetEqual( Item.objects.filter(Q(tags=self.t1)).filter(Q(tags=self.t2)), ['<Item: one>'] ) self.assertQuerysetEqual( Item.objects.filter(Q(tags=self.t1)).filter(Q(creator__name='fred') | Q(tags=self.t2)), ['<Item: one>'] ) # Each filter call is processed "at once" against a single table, so this is # different from the previous example as it tries to find tags that are two # things at once (rather than two tags). self.assertQuerysetEqual( Item.objects.filter(Q(tags=self.t1) & Q(tags=self.t2)), [] ) self.assertQuerysetEqual( Item.objects.filter(Q(tags=self.t1), Q(creator__name='fred') | Q(tags=self.t2)), [] ) qs = Author.objects.filter(ranking__rank=2, ranking__id=self.rank1.id) self.assertQuerysetEqual(list(qs), ['<Author: a2>']) self.assertEqual(2, qs.query.count_active_tables(), 2) qs = Author.objects.filter(ranking__rank=2).filter(ranking__id=self.rank1.id) self.assertEqual(qs.query.count_active_tables(), 3) def test_ticket4464(self): self.assertQuerysetEqual( Item.objects.filter(tags=self.t1).filter(tags=self.t2), ['<Item: one>'] ) self.assertQuerysetEqual( Item.objects.filter(tags__in=[self.t1, self.t2]).distinct().order_by('name'), ['<Item: one>', '<Item: two>'] ) self.assertQuerysetEqual( Item.objects.filter(tags__in=[self.t1, self.t2]).filter(tags=self.t3), ['<Item: two>'] ) # Make sure .distinct() works with slicing (this was broken in Oracle). self.assertQuerysetEqual( Item.objects.filter(tags__in=[self.t1, self.t2]).order_by('name')[:3], ['<Item: one>', '<Item: one>', '<Item: two>'] ) self.assertQuerysetEqual( Item.objects.filter(tags__in=[self.t1, self.t2]).distinct().order_by('name')[:3], ['<Item: one>', '<Item: two>'] ) def test_tickets_2080_3592(self): self.assertQuerysetEqual( Author.objects.filter(item__name='one') | Author.objects.filter(name='a3'), ['<Author: a1>', '<Author: a3>'] ) self.assertQuerysetEqual( Author.objects.filter(Q(item__name='one') | Q(name='a3')), ['<Author: a1>', '<Author: a3>'] ) self.assertQuerysetEqual( Author.objects.filter(Q(name='a3') | Q(item__name='one')), ['<Author: a1>', '<Author: a3>'] ) self.assertQuerysetEqual( Author.objects.filter(Q(item__name='three') | Q(report__name='r3')), ['<Author: a2>'] ) def test_ticket6074(self): # Merging two empty result sets shouldn't leave a queryset with no constraints # (which would match everything). self.assertQuerysetEqual(Author.objects.filter(Q(id__in=[])), []) self.assertQuerysetEqual( Author.objects.filter(Q(id__in=[]) | Q(id__in=[])), [] ) def test_tickets_1878_2939(self): self.assertEqual(Item.objects.values('creator').distinct().count(), 3) # Create something with a duplicate 'name' so that we can test multi-column # cases (which require some tricky SQL transformations under the covers). xx = Item(name='four', created=self.time1, creator=self.a2, note=self.n1) xx.save() self.assertEqual( Item.objects.exclude(name='two').values('creator', 'name').distinct().count(), 4 ) self.assertEqual( Item.objects.exclude(name='two').extra(select={'foo': '%s'}, select_params=(1,)).values('creator', 'name', 'foo').distinct().count(), 4 ) self.assertEqual( Item.objects.exclude(name='two').extra(select={'foo': '%s'}, select_params=(1,)).values('creator', 'name').distinct().count(), 4 ) xx.delete() def test_ticket7323(self): self.assertEqual(Item.objects.values('creator', 'name').count(), 4) def test_ticket2253(self): q1 = Item.objects.order_by('name') q2 = Item.objects.filter(id=self.i1.id) self.assertQuerysetEqual( q1, ['<Item: four>', '<Item: one>', '<Item: three>', '<Item: two>'] ) self.assertQuerysetEqual(q2, ['<Item: one>']) self.assertQuerysetEqual( (q1 | q2).order_by('name'), ['<Item: four>', '<Item: one>', '<Item: three>', '<Item: two>'] ) self.assertQuerysetEqual((q1 & q2).order_by('name'), ['<Item: one>']) q1 = Item.objects.filter(tags=self.t1) q2 = Item.objects.filter(note=self.n3, tags=self.t2) q3 = Item.objects.filter(creator=self.a4) self.assertQuerysetEqual( ((q1 & q2) | q3).order_by('name'), ['<Item: four>', '<Item: one>'] ) def test_order_by_tables(self): q1 = Item.objects.order_by('name') q2 = Item.objects.filter(id=self.i1.id) list(q2) combined_query = (q1 & q2).order_by('name').query self.assertEqual(len([ t for t in combined_query.tables if combined_query.alias_refcount[t] ]), 1) def test_order_by_join_unref(self): """ This test is related to the above one, testing that there aren't old JOINs in the query. """ qs = Celebrity.objects.order_by('greatest_fan__fan_of') self.assertIn('OUTER JOIN', str(qs.query)) qs = qs.order_by('id') self.assertNotIn('OUTER JOIN', str(qs.query)) def test_tickets_4088_4306(self): self.assertQuerysetEqual( Report.objects.filter(creator=1001), ['<Report: r1>'] ) self.assertQuerysetEqual( Report.objects.filter(creator__num=1001), ['<Report: r1>'] ) self.assertQuerysetEqual(Report.objects.filter(creator__id=1001), []) self.assertQuerysetEqual( Report.objects.filter(creator__id=self.a1.id), ['<Report: r1>'] ) self.assertQuerysetEqual( Report.objects.filter(creator__name='a1'), ['<Report: r1>'] ) def test_ticket4510(self): self.assertQuerysetEqual( Author.objects.filter(report__name='r1'), ['<Author: a1>'] ) def test_ticket7378(self): self.assertQuerysetEqual(self.a1.report_set.all(), ['<Report: r1>']) def test_tickets_5324_6704(self): self.assertQuerysetEqual( Item.objects.filter(tags__name='t4'), ['<Item: four>'] ) self.assertQuerysetEqual( Item.objects.exclude(tags__name='t4').order_by('name').distinct(), ['<Item: one>', '<Item: three>', '<Item: two>'] ) self.assertQuerysetEqual( Item.objects.exclude(tags__name='t4').order_by('name').distinct().reverse(), ['<Item: two>', '<Item: three>', '<Item: one>'] ) self.assertQuerysetEqual( Author.objects.exclude(item__name='one').distinct().order_by('name'), ['<Author: a2>', '<Author: a3>', '<Author: a4>'] ) # Excluding across a m2m relation when there is more than one related # object associated was problematic. self.assertQuerysetEqual( Item.objects.exclude(tags__name='t1').order_by('name'), ['<Item: four>', '<Item: three>'] ) self.assertQuerysetEqual( Item.objects.exclude(tags__name='t1').exclude(tags__name='t4'), ['<Item: three>'] ) # Excluding from a relation that cannot be NULL should not use outer joins. query = Item.objects.exclude(creator__in=[self.a1, self.a2]).query self.assertTrue(query.LOUTER not in [x[2] for x in query.alias_map.values()]) # Similarly, when one of the joins cannot possibly, ever, involve NULL # values (Author -> ExtraInfo, in the following), it should never be # promoted to a left outer join. So the following query should only # involve one "left outer" join (Author -> Item is 0-to-many). qs = Author.objects.filter(id=self.a1.id).filter(Q(extra__note=self.n1) | Q(item__note=self.n3)) self.assertEqual( len([x[2] for x in qs.query.alias_map.values() if x[2] == query.LOUTER and qs.query.alias_refcount[x[1]]]), 1 ) # The previous changes shouldn't affect nullable foreign key joins. self.assertQuerysetEqual( Tag.objects.filter(parent__isnull=True).order_by('name'), ['<Tag: t1>'] ) self.assertQuerysetEqual( Tag.objects.exclude(parent__isnull=True).order_by('name'), ['<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Tag.objects.exclude(Q(parent__name='t1') | Q(parent__isnull=True)).order_by('name'), ['<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Tag.objects.exclude(Q(parent__isnull=True) | Q(parent__name='t1')).order_by('name'), ['<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Tag.objects.exclude(Q(parent__parent__isnull=True)).order_by('name'), ['<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Tag.objects.filter(~Q(parent__parent__isnull=True)).order_by('name'), ['<Tag: t4>', '<Tag: t5>'] ) def test_ticket2091(self): t = Tag.objects.get(name='t4') self.assertQuerysetEqual( Item.objects.filter(tags__in=[t]), ['<Item: four>'] ) def test_avoid_infinite_loop_on_too_many_subqueries(self): x = Tag.objects.filter(pk=1) local_recursion_limit = 127 msg = 'Maximum recursion depth exceeded: too many subqueries.' with self.assertRaisesMessage(RuntimeError, msg): for i in six.moves.range(local_recursion_limit * 2): x = Tag.objects.filter(pk__in=x) def test_reasonable_number_of_subq_aliases(self): x = Tag.objects.filter(pk=1) for _ in range(20): x = Tag.objects.filter(pk__in=x) self.assertEqual( x.query.subq_aliases, { 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', } ) def test_heterogeneous_qs_combination(self): # Combining querysets built on different models should behave in a well-defined # fashion. We raise an error. self.assertRaisesMessage( AssertionError, 'Cannot combine queries on two different base models.', lambda: Author.objects.all() & Tag.objects.all() ) self.assertRaisesMessage( AssertionError, 'Cannot combine queries on two different base models.', lambda: Author.objects.all() | Tag.objects.all() ) def test_ticket3141(self): self.assertEqual(Author.objects.extra(select={'foo': '1'}).count(), 4) self.assertEqual( Author.objects.extra(select={'foo': '%s'}, select_params=(1,)).count(), 4 ) def test_ticket2400(self): self.assertQuerysetEqual( Author.objects.filter(item__isnull=True), ['<Author: a3>'] ) self.assertQuerysetEqual( Tag.objects.filter(item__isnull=True), ['<Tag: t5>'] ) def test_ticket2496(self): self.assertQuerysetEqual( Item.objects.extra(tables=['queries_author']).select_related().order_by('name')[:1], ['<Item: four>'] ) def test_tickets_2076_7256(self): # Ordering on related tables should be possible, even if the table is # not otherwise involved. self.assertQuerysetEqual( Item.objects.order_by('note__note', 'name'), ['<Item: two>', '<Item: four>', '<Item: one>', '<Item: three>'] ) # Ordering on a related field should use the remote model's default # ordering as a final step. self.assertQuerysetEqual( Author.objects.order_by('extra', '-name'), ['<Author: a2>', '<Author: a1>', '<Author: a4>', '<Author: a3>'] ) # Using remote model default ordering can span multiple models (in this # case, Cover is ordered by Item's default, which uses Note's default). self.assertQuerysetEqual( Cover.objects.all(), ['<Cover: first>', '<Cover: second>'] ) # If the remote model does not have a default ordering, we order by its 'id' # field. self.assertQuerysetEqual( Item.objects.order_by('creator', 'name'), ['<Item: one>', '<Item: three>', '<Item: two>', '<Item: four>'] ) # Ordering by a many-valued attribute (e.g. a many-to-many or reverse # ForeignKey) is legal, but the results might not make sense. That # isn't Django's problem. Garbage in, garbage out. self.assertQuerysetEqual( Item.objects.filter(tags__isnull=False).order_by('tags', 'id'), ['<Item: one>', '<Item: two>', '<Item: one>', '<Item: two>', '<Item: four>'] ) # If we replace the default ordering, Django adjusts the required # tables automatically. Item normally requires a join with Note to do # the default ordering, but that isn't needed here. qs = Item.objects.order_by('name') self.assertQuerysetEqual( qs, ['<Item: four>', '<Item: one>', '<Item: three>', '<Item: two>'] ) self.assertEqual(len(qs.query.tables), 1) def test_tickets_2874_3002(self): qs = Item.objects.select_related().order_by('note__note', 'name') self.assertQuerysetEqual( qs, ['<Item: two>', '<Item: four>', '<Item: one>', '<Item: three>'] ) # This is also a good select_related() test because there are multiple # Note entries in the SQL. The two Note items should be different. self.assertTrue(repr(qs[0].note), '<Note: n2>') self.assertEqual(repr(qs[0].creator.extra.note), '<Note: n1>') def test_ticket3037(self): self.assertQuerysetEqual( Item.objects.filter(Q(creator__name='a3', name='two') | Q(creator__name='a4', name='four')), ['<Item: four>'] ) def test_tickets_5321_7070(self): # Ordering columns must be included in the output columns. Note that # this means results that might otherwise be distinct are not (if there # are multiple values in the ordering cols), as in this example. This # isn't a bug; it's a warning to be careful with the selection of # ordering columns. self.assertValueQuerysetEqual( Note.objects.values('misc').distinct().order_by('note', '-misc'), [{'misc': 'foo'}, {'misc': 'bar'}, {'misc': 'foo'}] ) def test_ticket4358(self): # If you don't pass any fields to values(), relation fields are # returned as "foo_id" keys, not "foo". For consistency, you should be # able to pass "foo_id" in the fields list and have it work, too. We # actually allow both "foo" and "foo_id". # The *_id version is returned by default. self.assertTrue('note_id' in ExtraInfo.objects.values()[0]) # You can also pass it in explicitly. self.assertValueQuerysetEqual( ExtraInfo.objects.values('note_id'), [{'note_id': 1}, {'note_id': 2}] ) # ...or use the field name. self.assertValueQuerysetEqual( ExtraInfo.objects.values('note'), [{'note': 1}, {'note': 2}] ) def test_ticket2902(self): # Parameters can be given to extra_select, *if* you use an OrderedDict. # (First we need to know which order the keys fall in "naturally" on # your system, so we can put things in the wrong way around from # normal. A normal dict would thus fail.) s = [('a', '%s'), ('b', '%s')] params = ['one', 'two'] if {'a': 1, 'b': 2}.keys() == ['a', 'b']: s.reverse() params.reverse() # This slightly odd comparison works around the fact that PostgreSQL will # return 'one' and 'two' as strings, not Unicode objects. It's a side-effect of # using constants here and not a real concern. d = Item.objects.extra(select=OrderedDict(s), select_params=params).values('a', 'b')[0] self.assertEqual(d, {'a': 'one', 'b': 'two'}) # Order by the number of tags attached to an item. l = Item.objects.extra(select={'count': 'select count(*) from queries_item_tags where queries_item_tags.item_id = queries_item.id'}).order_by('-count') self.assertEqual([o.count for o in l], [2, 2, 1, 0]) def test_ticket6154(self): # Multiple filter statements are joined using "AND" all the time. self.assertQuerysetEqual( Author.objects.filter(id=self.a1.id).filter(Q(extra__note=self.n1) | Q(item__note=self.n3)), ['<Author: a1>'] ) self.assertQuerysetEqual( Author.objects.filter(Q(extra__note=self.n1) | Q(item__note=self.n3)).filter(id=self.a1.id), ['<Author: a1>'] ) def test_ticket6981(self): self.assertQuerysetEqual( Tag.objects.select_related('parent').order_by('name'), ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'] ) def test_ticket9926(self): self.assertQuerysetEqual( Tag.objects.select_related("parent", "category").order_by('name'), ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Tag.objects.select_related('parent', "parent__category").order_by('name'), ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'] ) def test_tickets_6180_6203(self): # Dates with limits and/or counts self.assertEqual(Item.objects.count(), 4) self.assertEqual(Item.objects.datetimes('created', 'month').count(), 1) self.assertEqual(Item.objects.datetimes('created', 'day').count(), 2) self.assertEqual(len(Item.objects.datetimes('created', 'day')), 2) self.assertEqual(Item.objects.datetimes('created', 'day')[0], datetime.datetime(2007, 12, 19, 0, 0)) def test_tickets_7087_12242(self): # Dates with extra select columns self.assertQuerysetEqual( Item.objects.datetimes('created', 'day').extra(select={'a': 1}), ['datetime.datetime(2007, 12, 19, 0, 0)', 'datetime.datetime(2007, 12, 20, 0, 0)'] ) self.assertQuerysetEqual( Item.objects.extra(select={'a': 1}).datetimes('created', 'day'), ['datetime.datetime(2007, 12, 19, 0, 0)', 'datetime.datetime(2007, 12, 20, 0, 0)'] ) name = "one" self.assertQuerysetEqual( Item.objects.datetimes('created', 'day').extra(where=['name=%s'], params=[name]), ['datetime.datetime(2007, 12, 19, 0, 0)'] ) self.assertQuerysetEqual( Item.objects.extra(where=['name=%s'], params=[name]).datetimes('created', 'day'), ['datetime.datetime(2007, 12, 19, 0, 0)'] ) def test_ticket7155(self): # Nullable dates self.assertQuerysetEqual( Item.objects.datetimes('modified', 'day'), ['datetime.datetime(2007, 12, 19, 0, 0)'] ) def test_ticket7098(self): # Make sure semi-deprecated ordering by related models syntax still # works. self.assertValueQuerysetEqual( Item.objects.values('note__note').order_by('queries_note.note', 'id'), [{'note__note': 'n2'}, {'note__note': 'n3'}, {'note__note': 'n3'}, {'note__note': 'n3'}] ) def test_ticket7096(self): # Make sure exclude() with multiple conditions continues to work. self.assertQuerysetEqual( Tag.objects.filter(parent=self.t1, name='t3').order_by('name'), ['<Tag: t3>'] ) self.assertQuerysetEqual( Tag.objects.exclude(parent=self.t1, name='t3').order_by('name'), ['<Tag: t1>', '<Tag: t2>', '<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Item.objects.exclude(tags__name='t1', name='one').order_by('name').distinct(), ['<Item: four>', '<Item: three>', '<Item: two>'] ) self.assertQuerysetEqual( Item.objects.filter(name__in=['three', 'four']).exclude(tags__name='t1').order_by('name'), ['<Item: four>', '<Item: three>'] ) # More twisted cases, involving nested negations. self.assertQuerysetEqual( Item.objects.exclude(~Q(tags__name='t1', name='one')), ['<Item: one>'] ) self.assertQuerysetEqual( Item.objects.filter(~Q(tags__name='t1', name='one'), name='two'), ['<Item: two>'] ) self.assertQuerysetEqual( Item.objects.exclude(~Q(tags__name='t1', name='one'), name='two'), ['<Item: four>', '<Item: one>', '<Item: three>'] ) def test_tickets_7204_7506(self): # Make sure querysets with related fields can be pickled. If this # doesn't crash, it's a Good Thing. pickle.dumps(Item.objects.all()) def test_ticket7813(self): # We should also be able to pickle things that use select_related(). # The only tricky thing here is to ensure that we do the related # selections properly after unpickling. qs = Item.objects.select_related() query = qs.query.get_compiler(qs.db).as_sql()[0] query2 = pickle.loads(pickle.dumps(qs.query)) self.assertEqual( query2.get_compiler(qs.db).as_sql()[0], query ) def test_deferred_load_qs_pickling(self): # Check pickling of deferred-loading querysets qs = Item.objects.defer('name', 'creator') q2 = pickle.loads(pickle.dumps(qs)) self.assertEqual(list(qs), list(q2)) q3 = pickle.loads(pickle.dumps(qs, pickle.HIGHEST_PROTOCOL)) self.assertEqual(list(qs), list(q3)) def test_ticket7277(self): self.assertQuerysetEqual( self.n1.annotation_set.filter(Q(tag=self.t5) | Q(tag__children=self.t5) | Q(tag__children__children=self.t5)), ['<Annotation: a1>'] ) def test_tickets_7448_7707(self): # Complex objects should be converted to strings before being used in # lookups. self.assertQuerysetEqual( Item.objects.filter(created__in=[self.time1, self.time2]), ['<Item: one>', '<Item: two>'] ) def test_ticket7235(self): # An EmptyQuerySet should not raise exceptions if it is filtered. Eaten.objects.create(meal='m') q = Eaten.objects.none() with self.assertNumQueries(0): self.assertQuerysetEqual(q.all(), []) self.assertQuerysetEqual(q.filter(meal='m'), []) self.assertQuerysetEqual(q.exclude(meal='m'), []) self.assertQuerysetEqual(q.complex_filter({'pk': 1}), []) self.assertQuerysetEqual(q.select_related('food'), []) self.assertQuerysetEqual(q.annotate(Count('food')), []) self.assertQuerysetEqual(q.order_by('meal', 'food'), []) self.assertQuerysetEqual(q.distinct(), []) self.assertQuerysetEqual( q.extra(select={'foo': "1"}), [] ) q.query.low_mark = 1 self.assertRaisesMessage( AssertionError, 'Cannot change a query once a slice has been taken', q.extra, select={'foo': "1"} ) self.assertQuerysetEqual(q.reverse(), []) self.assertQuerysetEqual(q.defer('meal'), []) self.assertQuerysetEqual(q.only('meal'), []) def test_ticket7791(self): # There were "issues" when ordering and distinct-ing on fields related # via ForeignKeys. self.assertEqual( len(Note.objects.order_by('extrainfo__info').distinct()), 3 ) # Pickling of DateQuerySets used to fail qs = Item.objects.datetimes('created', 'month') pickle.loads(pickle.dumps(qs)) def test_ticket9997(self): # If a ValuesList or Values queryset is passed as an inner query, we # make sure it's only requesting a single value and use that as the # thing to select. self.assertQuerysetEqual( Tag.objects.filter(name__in=Tag.objects.filter(parent=self.t1).values('name')), ['<Tag: t2>', '<Tag: t3>'] ) # Multi-valued values() and values_list() querysets should raise errors. self.assertRaisesMessage( TypeError, 'Cannot use a multi-field ValuesQuerySet as a filter value.', lambda: Tag.objects.filter(name__in=Tag.objects.filter(parent=self.t1).values('name', 'id')) ) self.assertRaisesMessage( TypeError, 'Cannot use a multi-field ValuesListQuerySet as a filter value.', lambda: Tag.objects.filter(name__in=Tag.objects.filter(parent=self.t1).values_list('name', 'id')) ) def test_ticket9985(self): # qs.values_list(...).values(...) combinations should work. self.assertValueQuerysetEqual( Note.objects.values_list("note", flat=True).values("id").order_by("id"), [{'id': 1}, {'id': 2}, {'id': 3}] ) self.assertQuerysetEqual( Annotation.objects.filter(notes__in=Note.objects.filter(note="n1").values_list('note').values('id')), ['<Annotation: a1>'] ) def test_ticket10205(self): # When bailing out early because of an empty "__in" filter, we need # to set things up correctly internally so that subqueries can continue properly. self.assertEqual(Tag.objects.filter(name__in=()).update(name="foo"), 0) def test_ticket10432(self): # Testing an empty "__in" filter with a generator as the value. def f(): return iter([]) n_obj = Note.objects.all()[0] def g(): for i in [n_obj.pk]: yield i self.assertQuerysetEqual(Note.objects.filter(pk__in=f()), []) self.assertEqual(list(Note.objects.filter(pk__in=g())), [n_obj]) def test_ticket10742(self): # Queries used in an __in clause don't execute subqueries subq = Author.objects.filter(num__lt=3000) qs = Author.objects.filter(pk__in=subq) self.assertQuerysetEqual(qs, ['<Author: a1>', '<Author: a2>']) # The subquery result cache should not be populated self.assertTrue(subq._result_cache is None) subq = Author.objects.filter(num__lt=3000) qs = Author.objects.exclude(pk__in=subq) self.assertQuerysetEqual(qs, ['<Author: a3>', '<Author: a4>']) # The subquery result cache should not be populated self.assertTrue(subq._result_cache is None) subq = Author.objects.filter(num__lt=3000) self.assertQuerysetEqual( Author.objects.filter(Q(pk__in=subq) & Q(name='a1')), ['<Author: a1>'] ) # The subquery result cache should not be populated self.assertTrue(subq._result_cache is None) def test_ticket7076(self): # Excluding shouldn't eliminate NULL entries. self.assertQuerysetEqual( Item.objects.exclude(modified=self.time1).order_by('name'), ['<Item: four>', '<Item: three>', '<Item: two>'] ) self.assertQuerysetEqual( Tag.objects.exclude(parent__name=self.t1.name), ['<Tag: t1>', '<Tag: t4>', '<Tag: t5>'] ) def test_ticket7181(self): # Ordering by related tables should accommodate nullable fields (this # test is a little tricky, since NULL ordering is database dependent. # Instead, we just count the number of results). self.assertEqual(len(Tag.objects.order_by('parent__name')), 5) # Empty querysets can be merged with others. self.assertQuerysetEqual( Note.objects.none() | Note.objects.all(), ['<Note: n1>', '<Note: n2>', '<Note: n3>'] ) self.assertQuerysetEqual( Note.objects.all() | Note.objects.none(), ['<Note: n1>', '<Note: n2>', '<Note: n3>'] ) self.assertQuerysetEqual(Note.objects.none() & Note.objects.all(), []) self.assertQuerysetEqual(Note.objects.all() & Note.objects.none(), []) def test_ticket9411(self): # Make sure bump_prefix() (an internal Query method) doesn't (re-)break. It's # sufficient that this query runs without error. qs = Tag.objects.values_list('id', flat=True).order_by('id') qs.query.bump_prefix(qs.query) first = qs[0] self.assertEqual(list(qs), list(range(first, first + 5))) def test_ticket8439(self): # Complex combinations of conjunctions, disjunctions and nullable # relations. self.assertQuerysetEqual( Author.objects.filter(Q(item__note__extrainfo=self.e2) | Q(report=self.r1, name='xyz')), ['<Author: a2>'] ) self.assertQuerysetEqual( Author.objects.filter(Q(report=self.r1, name='xyz') | Q(item__note__extrainfo=self.e2)), ['<Author: a2>'] ) self.assertQuerysetEqual( Annotation.objects.filter(Q(tag__parent=self.t1) | Q(notes__note='n1', name='a1')), ['<Annotation: a1>'] ) xx = ExtraInfo.objects.create(info='xx', note=self.n3) self.assertQuerysetEqual( Note.objects.filter(Q(extrainfo__author=self.a1) | Q(extrainfo=xx)), ['<Note: n1>', '<Note: n3>'] ) q = Note.objects.filter(Q(extrainfo__author=self.a1) | Q(extrainfo=xx)).query self.assertEqual( len([x[2] for x in q.alias_map.values() if x[2] == q.LOUTER and q.alias_refcount[x[1]]]), 1 ) def test_ticket17429(self): """ Ensure that Meta.ordering=None works the same as Meta.ordering=[] """ original_ordering = Tag._meta.ordering Tag._meta.ordering = None try: self.assertQuerysetEqual( Tag.objects.all(), ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'], ordered=False ) finally: Tag._meta.ordering = original_ordering def test_exclude(self): self.assertQuerysetEqual( Item.objects.exclude(tags__name='t4'), [repr(i) for i in Item.objects.filter(~Q(tags__name='t4'))]) self.assertQuerysetEqual( Item.objects.exclude(Q(tags__name='t4') | Q(tags__name='t3')), [repr(i) for i in Item.objects.filter(~(Q(tags__name='t4') | Q(tags__name='t3')))]) self.assertQuerysetEqual( Item.objects.exclude(Q(tags__name='t4') | ~Q(tags__name='t3')), [repr(i) for i in Item.objects.filter(~(Q(tags__name='t4') | ~Q(tags__name='t3')))]) def test_nested_exclude(self): self.assertQuerysetEqual( Item.objects.exclude(~Q(tags__name='t4')), [repr(i) for i in Item.objects.filter(~~Q(tags__name='t4'))]) def test_double_exclude(self): self.assertQuerysetEqual( Item.objects.filter(Q(tags__name='t4')), [repr(i) for i in Item.objects.filter(~~Q(tags__name='t4'))]) self.assertQuerysetEqual( Item.objects.filter(Q(tags__name='t4')), [repr(i) for i in Item.objects.filter(~Q(~Q(tags__name='t4')))]) def test_exclude_in(self): self.assertQuerysetEqual( Item.objects.exclude(Q(tags__name__in=['t4', 't3'])), [repr(i) for i in Item.objects.filter(~Q(tags__name__in=['t4', 't3']))]) self.assertQuerysetEqual( Item.objects.filter(Q(tags__name__in=['t4', 't3'])), [repr(i) for i in Item.objects.filter(~~Q(tags__name__in=['t4', 't3']))]) def test_ticket_10790_1(self): # Querying direct fields with isnull should trim the left outer join. # It also should not create INNER JOIN. q = Tag.objects.filter(parent__isnull=True) self.assertQuerysetEqual(q, ['<Tag: t1>']) self.assertTrue('JOIN' not in str(q.query)) q = Tag.objects.filter(parent__isnull=False) self.assertQuerysetEqual( q, ['<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'], ) self.assertTrue('JOIN' not in str(q.query)) q = Tag.objects.exclude(parent__isnull=True) self.assertQuerysetEqual( q, ['<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'], ) self.assertTrue('JOIN' not in str(q.query)) q = Tag.objects.exclude(parent__isnull=False) self.assertQuerysetEqual(q, ['<Tag: t1>']) self.assertTrue('JOIN' not in str(q.query)) q = Tag.objects.exclude(parent__parent__isnull=False) self.assertQuerysetEqual( q, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'], ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 1) self.assertTrue('INNER JOIN' not in str(q.query)) def test_ticket_10790_2(self): # Querying across several tables should strip only the last outer join, # while preserving the preceding inner joins. q = Tag.objects.filter(parent__parent__isnull=False) self.assertQuerysetEqual( q, ['<Tag: t4>', '<Tag: t5>'], ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q.query).count('INNER JOIN') == 1) # Querying without isnull should not convert anything to left outer join. q = Tag.objects.filter(parent__parent=self.t1) self.assertQuerysetEqual( q, ['<Tag: t4>', '<Tag: t5>'], ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q.query).count('INNER JOIN') == 1) def test_ticket_10790_3(self): # Querying via indirect fields should populate the left outer join q = NamedCategory.objects.filter(tag__isnull=True) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 1) # join to dumbcategory ptr_id self.assertTrue(str(q.query).count('INNER JOIN') == 1) self.assertQuerysetEqual(q, []) # Querying across several tables should strip only the last join, while # preserving the preceding left outer joins. q = NamedCategory.objects.filter(tag__parent__isnull=True) self.assertTrue(str(q.query).count('INNER JOIN') == 1) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 1) self.assertQuerysetEqual(q, ['<NamedCategory: Generic>']) def test_ticket_10790_4(self): # Querying across m2m field should not strip the m2m table from join. q = Author.objects.filter(item__tags__isnull=True) self.assertQuerysetEqual( q, ['<Author: a2>', '<Author: a3>'], ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 2) self.assertTrue('INNER JOIN' not in str(q.query)) q = Author.objects.filter(item__tags__parent__isnull=True) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a2>', '<Author: a2>', '<Author: a3>'], ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 3) self.assertTrue('INNER JOIN' not in str(q.query)) def test_ticket_10790_5(self): # Querying with isnull=False across m2m field should not create outer joins q = Author.objects.filter(item__tags__isnull=False) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a1>', '<Author: a2>', '<Author: a2>', '<Author: a4>'] ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q.query).count('INNER JOIN') == 2) q = Author.objects.filter(item__tags__parent__isnull=False) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a2>', '<Author: a4>'] ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q.query).count('INNER JOIN') == 3) q = Author.objects.filter(item__tags__parent__parent__isnull=False) self.assertQuerysetEqual( q, ['<Author: a4>'] ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q.query).count('INNER JOIN') == 4) def test_ticket_10790_6(self): # Querying with isnull=True across m2m field should not create inner joins # and strip last outer join q = Author.objects.filter(item__tags__parent__parent__isnull=True) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a1>', '<Author: a2>', '<Author: a2>', '<Author: a2>', '<Author: a3>'] ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 4) self.assertTrue(str(q.query).count('INNER JOIN') == 0) q = Author.objects.filter(item__tags__parent__isnull=True) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a2>', '<Author: a2>', '<Author: a3>'] ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 3) self.assertTrue(str(q.query).count('INNER JOIN') == 0) def test_ticket_10790_7(self): # Reverse querying with isnull should not strip the join q = Author.objects.filter(item__isnull=True) self.assertQuerysetEqual( q, ['<Author: a3>'] ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 1) self.assertTrue(str(q.query).count('INNER JOIN') == 0) q = Author.objects.filter(item__isnull=False) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a2>', '<Author: a2>', '<Author: a4>'] ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q.query).count('INNER JOIN') == 1) def test_ticket_10790_8(self): # Querying with combined q-objects should also strip the left outer join q = Tag.objects.filter(Q(parent__isnull=True) | Q(parent=self.t1)) self.assertQuerysetEqual( q, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'] ) self.assertTrue(str(q.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q.query).count('INNER JOIN') == 0) def test_ticket_10790_combine(self): # Combining queries should not re-populate the left outer join q1 = Tag.objects.filter(parent__isnull=True) q2 = Tag.objects.filter(parent__isnull=False) q3 = q1 | q2 self.assertQuerysetEqual( q3, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'], ) self.assertTrue(str(q3.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q3.query).count('INNER JOIN') == 0) q3 = q1 & q2 self.assertQuerysetEqual(q3, []) self.assertTrue(str(q3.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q3.query).count('INNER JOIN') == 0) q2 = Tag.objects.filter(parent=self.t1) q3 = q1 | q2 self.assertQuerysetEqual( q3, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'] ) self.assertTrue(str(q3.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q3.query).count('INNER JOIN') == 0) q3 = q2 | q1 self.assertQuerysetEqual( q3, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'] ) self.assertTrue(str(q3.query).count('LEFT OUTER JOIN') == 0) self.assertTrue(str(q3.query).count('INNER JOIN') == 0) q1 = Tag.objects.filter(parent__isnull=True) q2 = Tag.objects.filter(parent__parent__isnull=True) q3 = q1 | q2 self.assertQuerysetEqual( q3, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'] ) self.assertTrue(str(q3.query).count('LEFT OUTER JOIN') == 1) self.assertTrue(str(q3.query).count('INNER JOIN') == 0) q3 = q2 | q1 self.assertQuerysetEqual( q3, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'] ) self.assertTrue(str(q3.query).count('LEFT OUTER JOIN') == 1) self.assertTrue(str(q3.query).count('INNER JOIN') == 0) def test_ticket19672(self): self.assertQuerysetEqual( Report.objects.filter(Q(creator__isnull=False) & ~Q(creator__extra__value=41)), ['<Report: r1>'] ) def test_ticket_20250(self): # A negated Q along with an annotated queryset failed in Django 1.4 qs = Author.objects.annotate(Count('item')) qs = qs.filter(~Q(extra__value=0)) self.assertTrue('SELECT' in str(qs.query)) self.assertQuerysetEqual( qs, ['<Author: a1>', '<Author: a2>', '<Author: a3>', '<Author: a4>'] ) def test_callable_args(self): with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') qs = Tag.objects.filter(name__startswith=lambda: 't') self.assertQuerysetEqual( qs, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'] ) self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[0].category, PendingDeprecationWarning)) class Queries2Tests(TestCase): def setUp(self): Number.objects.create(num=4) Number.objects.create(num=8) Number.objects.create(num=12) def test_ticket4289(self): # A slight variation on the restricting the filtering choices by the # lookup constraints. self.assertQuerysetEqual(Number.objects.filter(num__lt=4), []) self.assertQuerysetEqual(Number.objects.filter(num__gt=8, num__lt=12), []) self.assertQuerysetEqual( Number.objects.filter(num__gt=8, num__lt=13), ['<Number: 12>'] ) self.assertQuerysetEqual( Number.objects.filter(Q(num__lt=4) | Q(num__gt=8, num__lt=12)), [] ) self.assertQuerysetEqual( Number.objects.filter(Q(num__gt=8, num__lt=12) | Q(num__lt=4)), [] ) self.assertQuerysetEqual( Number.objects.filter(Q(num__gt=8) & Q(num__lt=12) | Q(num__lt=4)), [] ) self.assertQuerysetEqual( Number.objects.filter(Q(num__gt=7) & Q(num__lt=12) | Q(num__lt=4)), ['<Number: 8>'] ) def test_ticket12239(self): # Float was being rounded to integer on gte queries on integer field. Tests # show that gt, lt, gte, and lte work as desired. Note that the fix changes # get_prep_lookup for gte and lt queries only. self.assertQuerysetEqual( Number.objects.filter(num__gt=11.9), ['<Number: 12>'] ) self.assertQuerysetEqual(Number.objects.filter(num__gt=12), []) self.assertQuerysetEqual(Number.objects.filter(num__gt=12.0), []) self.assertQuerysetEqual(Number.objects.filter(num__gt=12.1), []) self.assertQuerysetEqual( Number.objects.filter(num__lt=12), ['<Number: 4>', '<Number: 8>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lt=12.0), ['<Number: 4>', '<Number: 8>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lt=12.1), ['<Number: 4>', '<Number: 8>', '<Number: 12>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__gte=11.9), ['<Number: 12>'] ) self.assertQuerysetEqual( Number.objects.filter(num__gte=12), ['<Number: 12>'] ) self.assertQuerysetEqual( Number.objects.filter(num__gte=12.0), ['<Number: 12>'] ) self.assertQuerysetEqual(Number.objects.filter(num__gte=12.1), []) self.assertQuerysetEqual(Number.objects.filter(num__gte=12.9), []) self.assertQuerysetEqual( Number.objects.filter(num__lte=11.9), ['<Number: 4>', '<Number: 8>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lte=12), ['<Number: 4>', '<Number: 8>', '<Number: 12>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lte=12.0), ['<Number: 4>', '<Number: 8>', '<Number: 12>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lte=12.1), ['<Number: 4>', '<Number: 8>', '<Number: 12>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lte=12.9), ['<Number: 4>', '<Number: 8>', '<Number: 12>'], ordered=False ) def test_ticket7759(self): # Count should work with a partially read result set. count = Number.objects.count() qs = Number.objects.all() def run(): for obj in qs: return qs.count() == count self.assertTrue(run()) class Queries3Tests(BaseQuerysetTest): def test_ticket7107(self): # This shouldn't create an infinite loop. self.assertQuerysetEqual(Valid.objects.all(), []) def test_ticket8683(self): # Raise proper error when a DateQuerySet gets passed a wrong type of # field self.assertRaisesMessage( AssertionError, "'name' isn't a DateTimeField.", Item.objects.datetimes, 'name', 'month' ) def test_ticket22023(self): # only() and defer() are not applicable for ValuesQuerySet with self.assertRaisesMessage(NotImplementedError, "ValuesQuerySet does not implement only()"): Valid.objects.values().only() with self.assertRaisesMessage(NotImplementedError, "ValuesQuerySet does not implement defer()"): Valid.objects.values().defer() class Queries4Tests(BaseQuerysetTest): def setUp(self): generic = NamedCategory.objects.create(name="Generic") self.t1 = Tag.objects.create(name='t1', category=generic) n1 = Note.objects.create(note='n1', misc='foo', id=1) n2 = Note.objects.create(note='n2', misc='bar', id=2) e1 = ExtraInfo.objects.create(info='e1', note=n1) e2 = ExtraInfo.objects.create(info='e2', note=n2) self.a1 = Author.objects.create(name='a1', num=1001, extra=e1) self.a3 = Author.objects.create(name='a3', num=3003, extra=e2) self.r1 = Report.objects.create(name='r1', creator=self.a1) self.r2 = Report.objects.create(name='r2', creator=self.a3) self.r3 = Report.objects.create(name='r3') Item.objects.create(name='i1', created=datetime.datetime.now(), note=n1, creator=self.a1) Item.objects.create(name='i2', created=datetime.datetime.now(), note=n1, creator=self.a3) def test_ticket11811(self): unsaved_category = NamedCategory(name="Other") with six.assertRaisesRegex(self, ValueError, 'Unsaved model instance <NamedCategory: Other> ' 'cannot be used in an ORM query.'): Tag.objects.filter(pk=self.t1.pk).update(category=unsaved_category) def test_ticket14876(self): # Note: when combining the query we need to have information available # about the join type of the trimmed "creator__isnull" join. If we # don't have that information, then the join is created as INNER JOIN # and results will be incorrect. q1 = Report.objects.filter(Q(creator__isnull=True) | Q(creator__extra__info='e1')) q2 = Report.objects.filter(Q(creator__isnull=True)) | Report.objects.filter(Q(creator__extra__info='e1')) self.assertQuerysetEqual(q1, ["<Report: r1>", "<Report: r3>"], ordered=False) self.assertEqual(str(q1.query), str(q2.query)) q1 = Report.objects.filter(Q(creator__extra__info='e1') | Q(creator__isnull=True)) q2 = Report.objects.filter(Q(creator__extra__info='e1')) | Report.objects.filter(Q(creator__isnull=True)) self.assertQuerysetEqual(q1, ["<Report: r1>", "<Report: r3>"], ordered=False) self.assertEqual(str(q1.query), str(q2.query)) q1 = Item.objects.filter(Q(creator=self.a1) | Q(creator__report__name='r1')).order_by() q2 = Item.objects.filter(Q(creator=self.a1)).order_by() | Item.objects.filter(Q(creator__report__name='r1')).order_by() self.assertQuerysetEqual(q1, ["<Item: i1>"]) self.assertEqual(str(q1.query), str(q2.query)) q1 = Item.objects.filter(Q(creator__report__name='e1') | Q(creator=self.a1)).order_by() q2 = Item.objects.filter(Q(creator__report__name='e1')).order_by() | Item.objects.filter(Q(creator=self.a1)).order_by() self.assertQuerysetEqual(q1, ["<Item: i1>"]) self.assertEqual(str(q1.query), str(q2.query)) def test_combine_join_reuse(self): # Test that we correctly recreate joins having identical connections # in the rhs query, in case the query is ORed together. Related to # ticket #18748 Report.objects.create(name='r4', creator=self.a1) q1 = Author.objects.filter(report__name='r5') q2 = Author.objects.filter(report__name='r4').filter(report__name='r1') combined = q1 | q2 self.assertEqual(str(combined.query).count('JOIN'), 2) self.assertEqual(len(combined), 1) self.assertEqual(combined[0].name, 'a1') def test_ticket7095(self): # Updates that are filtered on the model being updated are somewhat # tricky in MySQL. This exercises that case. ManagedModel.objects.create(data='mm1', tag=self.t1, public=True) self.assertEqual(ManagedModel.objects.update(data='mm'), 1) # A values() or values_list() query across joined models must use outer # joins appropriately. # Note: In Oracle, we expect a null CharField to return '' instead of # None. if connection.features.interprets_empty_strings_as_nulls: expected_null_charfield_repr = '' else: expected_null_charfield_repr = None self.assertValueQuerysetEqual( Report.objects.values_list("creator__extra__info", flat=True).order_by("name"), ['e1', 'e2', expected_null_charfield_repr], ) # Similarly for select_related(), joins beyond an initial nullable join # must use outer joins so that all results are included. self.assertQuerysetEqual( Report.objects.select_related("creator", "creator__extra").order_by("name"), ['<Report: r1>', '<Report: r2>', '<Report: r3>'] ) # When there are multiple paths to a table from another table, we have # to be careful not to accidentally reuse an inappropriate join when # using select_related(). We used to return the parent's Detail record # here by mistake. d1 = Detail.objects.create(data="d1") d2 = Detail.objects.create(data="d2") m1 = Member.objects.create(name="m1", details=d1) m2 = Member.objects.create(name="m2", details=d2) Child.objects.create(person=m2, parent=m1) obj = m1.children.select_related("person__details")[0] self.assertEqual(obj.person.details.data, 'd2') def test_order_by_resetting(self): # Calling order_by() with no parameters removes any existing ordering on the # model. But it should still be possible to add new ordering after that. qs = Author.objects.order_by().order_by('name') self.assertTrue('ORDER BY' in qs.query.get_compiler(qs.db).as_sql()[0]) def test_order_by_reverse_fk(self): # It is possible to order by reverse of foreign key, although that can lead # to duplicate results. c1 = SimpleCategory.objects.create(name="category1") c2 = SimpleCategory.objects.create(name="category2") CategoryItem.objects.create(category=c1) CategoryItem.objects.create(category=c2) CategoryItem.objects.create(category=c1) self.assertQuerysetEqual( SimpleCategory.objects.order_by('categoryitem', 'pk'), [c1, c2, c1], lambda x: x) def test_ticket10181(self): # Avoid raising an EmptyResultSet if an inner query is probably # empty (and hence, not executed). self.assertQuerysetEqual( Tag.objects.filter(id__in=Tag.objects.filter(id__in=[])), [] ) def test_ticket15316_filter_false(self): c1 = SimpleCategory.objects.create(name="category1") c2 = SpecialCategory.objects.create(name="named category1", special_name="special1") c3 = SpecialCategory.objects.create(name="named category2", special_name="special2") CategoryItem.objects.create(category=c1) ci2 = CategoryItem.objects.create(category=c2) ci3 = CategoryItem.objects.create(category=c3) qs = CategoryItem.objects.filter(category__specialcategory__isnull=False) self.assertEqual(qs.count(), 2) self.assertQuerysetEqual(qs, [ci2.pk, ci3.pk], lambda x: x.pk, False) def test_ticket15316_exclude_false(self): c1 = SimpleCategory.objects.create(name="category1") c2 = SpecialCategory.objects.create(name="named category1", special_name="special1") c3 = SpecialCategory.objects.create(name="named category2", special_name="special2") ci1 = CategoryItem.objects.create(category=c1) CategoryItem.objects.create(category=c2) CategoryItem.objects.create(category=c3) qs = CategoryItem.objects.exclude(category__specialcategory__isnull=False) self.assertEqual(qs.count(), 1) self.assertQuerysetEqual(qs, [ci1.pk], lambda x: x.pk) def test_ticket15316_filter_true(self): c1 = SimpleCategory.objects.create(name="category1") c2 = SpecialCategory.objects.create(name="named category1", special_name="special1") c3 = SpecialCategory.objects.create(name="named category2", special_name="special2") ci1 = CategoryItem.objects.create(category=c1) CategoryItem.objects.create(category=c2) CategoryItem.objects.create(category=c3) qs = CategoryItem.objects.filter(category__specialcategory__isnull=True) self.assertEqual(qs.count(), 1) self.assertQuerysetEqual(qs, [ci1.pk], lambda x: x.pk) def test_ticket15316_exclude_true(self): c1 = SimpleCategory.objects.create(name="category1") c2 = SpecialCategory.objects.create(name="named category1", special_name="special1") c3 = SpecialCategory.objects.create(name="named category2", special_name="special2") CategoryItem.objects.create(category=c1) ci2 = CategoryItem.objects.create(category=c2) ci3 = CategoryItem.objects.create(category=c3) qs = CategoryItem.objects.exclude(category__specialcategory__isnull=True) self.assertEqual(qs.count(), 2) self.assertQuerysetEqual(qs, [ci2.pk, ci3.pk], lambda x: x.pk, False) def test_ticket15316_one2one_filter_false(self): c = SimpleCategory.objects.create(name="cat") c0 = SimpleCategory.objects.create(name="cat0") c1 = SimpleCategory.objects.create(name="category1") OneToOneCategory.objects.create(category=c1, new_name="new1") OneToOneCategory.objects.create(category=c0, new_name="new2") CategoryItem.objects.create(category=c) ci2 = CategoryItem.objects.create(category=c0) ci3 = CategoryItem.objects.create(category=c1) qs = CategoryItem.objects.filter(category__onetoonecategory__isnull=False) self.assertEqual(qs.count(), 2) self.assertQuerysetEqual(qs, [ci2.pk, ci3.pk], lambda x: x.pk, False) def test_ticket15316_one2one_exclude_false(self): c = SimpleCategory.objects.create(name="cat") c0 = SimpleCategory.objects.create(name="cat0") c1 = SimpleCategory.objects.create(name="category1") OneToOneCategory.objects.create(category=c1, new_name="new1") OneToOneCategory.objects.create(category=c0, new_name="new2") ci1 = CategoryItem.objects.create(category=c) CategoryItem.objects.create(category=c0) CategoryItem.objects.create(category=c1) qs = CategoryItem.objects.exclude(category__onetoonecategory__isnull=False) self.assertEqual(qs.count(), 1) self.assertQuerysetEqual(qs, [ci1.pk], lambda x: x.pk) def test_ticket15316_one2one_filter_true(self): c = SimpleCategory.objects.create(name="cat") c0 = SimpleCategory.objects.create(name="cat0") c1 = SimpleCategory.objects.create(name="category1") OneToOneCategory.objects.create(category=c1, new_name="new1") OneToOneCategory.objects.create(category=c0, new_name="new2") ci1 = CategoryItem.objects.create(category=c) CategoryItem.objects.create(category=c0) CategoryItem.objects.create(category=c1) qs = CategoryItem.objects.filter(category__onetoonecategory__isnull=True) self.assertEqual(qs.count(), 1) self.assertQuerysetEqual(qs, [ci1.pk], lambda x: x.pk) def test_ticket15316_one2one_exclude_true(self): c = SimpleCategory.objects.create(name="cat") c0 = SimpleCategory.objects.create(name="cat0") c1 = SimpleCategory.objects.create(name="category1") OneToOneCategory.objects.create(category=c1, new_name="new1") OneToOneCategory.objects.create(category=c0, new_name="new2") CategoryItem.objects.create(category=c) ci2 = CategoryItem.objects.create(category=c0) ci3 = CategoryItem.objects.create(category=c1) qs = CategoryItem.objects.exclude(category__onetoonecategory__isnull=True) self.assertEqual(qs.count(), 2) self.assertQuerysetEqual(qs, [ci2.pk, ci3.pk], lambda x: x.pk, False) class Queries5Tests(TestCase): def setUp(self): # Ordering by 'rank' gives us rank2, rank1, rank3. Ordering by the # Meta.ordering will be rank3, rank2, rank1. n1 = Note.objects.create(note='n1', misc='foo', id=1) n2 = Note.objects.create(note='n2', misc='bar', id=2) e1 = ExtraInfo.objects.create(info='e1', note=n1) e2 = ExtraInfo.objects.create(info='e2', note=n2) a1 = Author.objects.create(name='a1', num=1001, extra=e1) a2 = Author.objects.create(name='a2', num=2002, extra=e1) a3 = Author.objects.create(name='a3', num=3003, extra=e2) self.rank1 = Ranking.objects.create(rank=2, author=a2) Ranking.objects.create(rank=1, author=a3) Ranking.objects.create(rank=3, author=a1) def test_ordering(self): # Cross model ordering is possible in Meta, too. self.assertQuerysetEqual( Ranking.objects.all(), ['<Ranking: 3: a1>', '<Ranking: 2: a2>', '<Ranking: 1: a3>'] ) self.assertQuerysetEqual( Ranking.objects.all().order_by('rank'), ['<Ranking: 1: a3>', '<Ranking: 2: a2>', '<Ranking: 3: a1>'] ) # Ordering of extra() pieces is possible, too and you can mix extra # fields and model fields in the ordering. self.assertQuerysetEqual( Ranking.objects.extra(tables=['django_site'], order_by=['-django_site.id', 'rank']), ['<Ranking: 1: a3>', '<Ranking: 2: a2>', '<Ranking: 3: a1>'] ) qs = Ranking.objects.extra(select={'good': 'case when rank > 2 then 1 else 0 end'}) self.assertEqual( [o.good for o in qs.extra(order_by=('-good',))], [True, False, False] ) self.assertQuerysetEqual( qs.extra(order_by=('-good', 'id')), ['<Ranking: 3: a1>', '<Ranking: 2: a2>', '<Ranking: 1: a3>'] ) # Despite having some extra aliases in the query, we can still omit # them in a values() query. dicts = qs.values('id', 'rank').order_by('id') self.assertEqual( [d['rank'] for d in dicts], [2, 1, 3] ) def test_ticket7256(self): # An empty values() call includes all aliases, including those from an # extra() qs = Ranking.objects.extra(select={'good': 'case when rank > 2 then 1 else 0 end'}) dicts = qs.values().order_by('id') for d in dicts: del d['id'] del d['author_id'] self.assertEqual( [sorted(d.items()) for d in dicts], [[('good', 0), ('rank', 2)], [('good', 0), ('rank', 1)], [('good', 1), ('rank', 3)]] ) def test_ticket7045(self): # Extra tables used to crash SQL construction on the second use. qs = Ranking.objects.extra(tables=['django_site']) qs.query.get_compiler(qs.db).as_sql() # test passes if this doesn't raise an exception. qs.query.get_compiler(qs.db).as_sql() def test_ticket9848(self): # Make sure that updates which only filter on sub-tables don't # inadvertently update the wrong records (bug #9848). # Make sure that the IDs from different tables don't happen to match. self.assertQuerysetEqual( Ranking.objects.filter(author__name='a1'), ['<Ranking: 3: a1>'] ) self.assertEqual( Ranking.objects.filter(author__name='a1').update(rank='4'), 1 ) r = Ranking.objects.filter(author__name='a1')[0] self.assertNotEqual(r.id, r.author.id) self.assertEqual(r.rank, 4) r.rank = 3 r.save() self.assertQuerysetEqual( Ranking.objects.all(), ['<Ranking: 3: a1>', '<Ranking: 2: a2>', '<Ranking: 1: a3>'] ) def test_ticket5261(self): # Test different empty excludes. self.assertQuerysetEqual( Note.objects.exclude(Q()), ['<Note: n1>', '<Note: n2>'] ) self.assertQuerysetEqual( Note.objects.filter(~Q()), ['<Note: n1>', '<Note: n2>'] ) self.assertQuerysetEqual( Note.objects.filter(~Q() | ~Q()), ['<Note: n1>', '<Note: n2>'] ) self.assertQuerysetEqual( Note.objects.exclude(~Q() & ~Q()), ['<Note: n1>', '<Note: n2>'] ) class SelectRelatedTests(TestCase): def test_tickets_3045_3288(self): # Once upon a time, select_related() with circular relations would loop # infinitely if you forgot to specify "depth". Now we set an arbitrary # default upper bound. self.assertQuerysetEqual(X.objects.all(), []) self.assertQuerysetEqual(X.objects.select_related(), []) class SubclassFKTests(TestCase): def test_ticket7778(self): # Model subclasses could not be deleted if a nullable foreign key # relates to a model that relates back. num_celebs = Celebrity.objects.count() tvc = TvChef.objects.create(name="Huey") self.assertEqual(Celebrity.objects.count(), num_celebs + 1) Fan.objects.create(fan_of=tvc) Fan.objects.create(fan_of=tvc) tvc.delete() # The parent object should have been deleted as well. self.assertEqual(Celebrity.objects.count(), num_celebs) class CustomPkTests(TestCase): def test_ticket7371(self): self.assertQuerysetEqual(Related.objects.order_by('custom'), []) class NullableRelOrderingTests(TestCase): def test_ticket10028(self): # Ordering by model related to nullable relations(!) should use outer # joins, so that all results are included. Plaything.objects.create(name="p1") self.assertQuerysetEqual( Plaything.objects.all(), ['<Plaything: p1>'] ) def test_join_already_in_query(self): # Ordering by model related to nullable relations should not change # the join type of already existing joins. Plaything.objects.create(name="p1") s = SingleObject.objects.create(name='s') r = RelatedObject.objects.create(single=s, f=1) Plaything.objects.create(name="p2", others=r) qs = Plaything.objects.all().filter(others__isnull=False).order_by('pk') self.assertTrue('JOIN' not in str(qs.query)) qs = Plaything.objects.all().filter(others__f__isnull=False).order_by('pk') self.assertTrue('INNER' in str(qs.query)) qs = qs.order_by('others__single__name') # The ordering by others__single__pk will add one new join (to single) # and that join must be LEFT join. The already existing join to related # objects must be kept INNER. So, we have both an INNER and a LEFT join # in the query. self.assertEqual(str(qs.query).count('LEFT'), 1) self.assertEqual(str(qs.query).count('INNER'), 1) self.assertQuerysetEqual( qs, ['<Plaything: p2>'] ) class DisjunctiveFilterTests(TestCase): def setUp(self): self.n1 = Note.objects.create(note='n1', misc='foo', id=1) ExtraInfo.objects.create(info='e1', note=self.n1) def test_ticket7872(self): # Another variation on the disjunctive filtering theme. # For the purposes of this regression test, it's important that there is no # Join object releated to the LeafA we create. LeafA.objects.create(data='first') self.assertQuerysetEqual(LeafA.objects.all(), ['<LeafA: first>']) self.assertQuerysetEqual( LeafA.objects.filter(Q(data='first') | Q(join__b__data='second')), ['<LeafA: first>'] ) def test_ticket8283(self): # Checking that applying filters after a disjunction works correctly. self.assertQuerysetEqual( (ExtraInfo.objects.filter(note=self.n1) | ExtraInfo.objects.filter(info='e2')).filter(note=self.n1), ['<ExtraInfo: e1>'] ) self.assertQuerysetEqual( (ExtraInfo.objects.filter(info='e2') | ExtraInfo.objects.filter(note=self.n1)).filter(note=self.n1), ['<ExtraInfo: e1>'] ) class Queries6Tests(TestCase): def setUp(self): generic = NamedCategory.objects.create(name="Generic") t1 = Tag.objects.create(name='t1', category=generic) Tag.objects.create(name='t2', parent=t1, category=generic) t3 = Tag.objects.create(name='t3', parent=t1) t4 = Tag.objects.create(name='t4', parent=t3) Tag.objects.create(name='t5', parent=t3) n1 = Note.objects.create(note='n1', misc='foo', id=1) ann1 = Annotation.objects.create(name='a1', tag=t1) ann1.notes.add(n1) Annotation.objects.create(name='a2', tag=t4) def test_parallel_iterators(self): # Test that parallel iterators work. qs = Tag.objects.all() i1, i2 = iter(qs), iter(qs) self.assertEqual(repr(next(i1)), '<Tag: t1>') self.assertEqual(repr(next(i1)), '<Tag: t2>') self.assertEqual(repr(next(i2)), '<Tag: t1>') self.assertEqual(repr(next(i2)), '<Tag: t2>') self.assertEqual(repr(next(i2)), '<Tag: t3>') self.assertEqual(repr(next(i1)), '<Tag: t3>') qs = X.objects.all() self.assertEqual(bool(qs), False) self.assertEqual(bool(qs), False) def test_nested_queries_sql(self): # Nested queries should not evaluate the inner query as part of constructing the # SQL (so we should see a nested query here, indicated by two "SELECT" calls). qs = Annotation.objects.filter(notes__in=Note.objects.filter(note="xyzzy")) self.assertEqual( qs.query.get_compiler(qs.db).as_sql()[0].count('SELECT'), 2 ) def test_tickets_8921_9188(self): # Incorrect SQL was being generated for certain types of exclude() # queries that crossed multi-valued relations (#8921, #9188 and some # pre-emptively discovered cases). self.assertQuerysetEqual( PointerA.objects.filter(connection__pointerb__id=1), [] ) self.assertQuerysetEqual( PointerA.objects.exclude(connection__pointerb__id=1), [] ) self.assertQuerysetEqual( Tag.objects.exclude(children=None), ['<Tag: t1>', '<Tag: t3>'] ) # This example is tricky because the parent could be NULL, so only checking # parents with annotations omits some results (tag t1, in this case). self.assertQuerysetEqual( Tag.objects.exclude(parent__annotation__name="a1"), ['<Tag: t1>', '<Tag: t4>', '<Tag: t5>'] ) # The annotation->tag link is single values and tag->children links is # multi-valued. So we have to split the exclude filter in the middle # and then optimize the inner query without losing results. self.assertQuerysetEqual( Annotation.objects.exclude(tag__children__name="t2"), ['<Annotation: a2>'] ) # Nested queries are possible (although should be used with care, since # they have performance problems on backends like MySQL. self.assertQuerysetEqual( Annotation.objects.filter(notes__in=Note.objects.filter(note="n1")), ['<Annotation: a1>'] ) def test_ticket3739(self): # The all() method on querysets returns a copy of the queryset. q1 = Tag.objects.order_by('name') self.assertIsNot(q1, q1.all()) def test_ticket_11320(self): qs = Tag.objects.exclude(category=None).exclude(category__name='foo') self.assertEqual(str(qs.query).count(' INNER JOIN '), 1) class RawQueriesTests(TestCase): def setUp(self): Note.objects.create(note='n1', misc='foo', id=1) def test_ticket14729(self): # Test representation of raw query with one or few parameters passed as list query = "SELECT * FROM queries_note WHERE note = %s" params = ['n1'] qs = Note.objects.raw(query, params=params) self.assertEqual(repr(qs), str_prefix("<RawQuerySet: %(_)s'SELECT * FROM queries_note WHERE note = n1'>")) query = "SELECT * FROM queries_note WHERE note = %s and misc = %s" params = ['n1', 'foo'] qs = Note.objects.raw(query, params=params) self.assertEqual(repr(qs), str_prefix("<RawQuerySet: %(_)s'SELECT * FROM queries_note WHERE note = n1 and misc = foo'>")) class GeneratorExpressionTests(TestCase): def test_ticket10432(self): # Using an empty generator expression as the rvalue for an "__in" # lookup is legal. self.assertQuerysetEqual( Note.objects.filter(pk__in=(x for x in ())), [] ) class ComparisonTests(TestCase): def setUp(self): self.n1 = Note.objects.create(note='n1', misc='foo', id=1) e1 = ExtraInfo.objects.create(info='e1', note=self.n1) self.a2 = Author.objects.create(name='a2', num=2002, extra=e1) def test_ticket8597(self): # Regression tests for case-insensitive comparisons Item.objects.create(name="a_b", created=datetime.datetime.now(), creator=self.a2, note=self.n1) Item.objects.create(name="x%y", created=datetime.datetime.now(), creator=self.a2, note=self.n1) self.assertQuerysetEqual( Item.objects.filter(name__iexact="A_b"), ['<Item: a_b>'] ) self.assertQuerysetEqual( Item.objects.filter(name__iexact="x%Y"), ['<Item: x%y>'] ) self.assertQuerysetEqual( Item.objects.filter(name__istartswith="A_b"), ['<Item: a_b>'] ) self.assertQuerysetEqual( Item.objects.filter(name__iendswith="A_b"), ['<Item: a_b>'] ) class ExistsSql(TestCase): def test_exists(self): with CaptureQueriesContext(connection) as captured_queries: self.assertFalse(Tag.objects.exists()) # Ok - so the exist query worked - but did it include too many columns? self.assertEqual(len(captured_queries), 1) qstr = captured_queries[0] id, name = connection.ops.quote_name('id'), connection.ops.quote_name('name') self.assertTrue(id not in qstr and name not in qstr) def test_ticket_18414(self): Article.objects.create(name='one', created=datetime.datetime.now()) Article.objects.create(name='one', created=datetime.datetime.now()) Article.objects.create(name='two', created=datetime.datetime.now()) self.assertTrue(Article.objects.exists()) self.assertTrue(Article.objects.distinct().exists()) self.assertTrue(Article.objects.distinct()[1:3].exists()) self.assertFalse(Article.objects.distinct()[1:1].exists()) @unittest.skipUnless(connection.features.can_distinct_on_fields, 'Uses distinct(fields)') def test_ticket_18414_distinct_on(self): Article.objects.create(name='one', created=datetime.datetime.now()) Article.objects.create(name='one', created=datetime.datetime.now()) Article.objects.create(name='two', created=datetime.datetime.now()) self.assertTrue(Article.objects.distinct('name').exists()) self.assertTrue(Article.objects.distinct('name')[1:2].exists()) self.assertFalse(Article.objects.distinct('name')[2:3].exists()) class QuerysetOrderedTests(unittest.TestCase): """ Tests for the Queryset.ordered attribute. """ def test_no_default_or_explicit_ordering(self): self.assertEqual(Annotation.objects.all().ordered, False) def test_cleared_default_ordering(self): self.assertEqual(Tag.objects.all().ordered, True) self.assertEqual(Tag.objects.all().order_by().ordered, False) def test_explicit_ordering(self): self.assertEqual(Annotation.objects.all().order_by('id').ordered, True) def test_order_by_extra(self): self.assertEqual(Annotation.objects.all().extra(order_by=['id']).ordered, True) def test_annotated_ordering(self): qs = Annotation.objects.annotate(num_notes=Count('notes')) self.assertEqual(qs.ordered, False) self.assertEqual(qs.order_by('num_notes').ordered, True) @skipUnlessDBFeature('allow_sliced_subqueries') class SubqueryTests(TestCase): def setUp(self): DumbCategory.objects.create(id=1) DumbCategory.objects.create(id=2) DumbCategory.objects.create(id=3) DumbCategory.objects.create(id=4) def test_ordered_subselect(self): "Subselects honor any manual ordering" query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[0:2]) self.assertEqual(set(query.values_list('id', flat=True)), set([3, 4])) query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[:2]) self.assertEqual(set(query.values_list('id', flat=True)), set([3, 4])) query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:2]) self.assertEqual(set(query.values_list('id', flat=True)), set([3])) query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[2:]) self.assertEqual(set(query.values_list('id', flat=True)), set([1, 2])) def test_slice_subquery_and_query(self): """ Slice a query that has a sliced subquery """ query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[0:2])[0:2] self.assertEqual(set([x.id for x in query]), set([3, 4])) query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:3])[1:3] self.assertEqual(set([x.id for x in query]), set([3])) query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[2:])[1:] self.assertEqual(set([x.id for x in query]), set([2])) def test_related_sliced_subquery(self): """ Related objects constraints can safely contain sliced subqueries. refs #22434 """ generic = NamedCategory.objects.create(name="Generic") t1 = Tag.objects.create(name='t1', category=generic) t2 = Tag.objects.create(name='t2', category=generic) ManagedModel.objects.create(data='mm1', tag=t1, public=True) mm2 = ManagedModel.objects.create(data='mm2', tag=t2, public=True) query = ManagedModel.normal_manager.filter( tag__in=Tag.objects.order_by('-id')[:1] ) self.assertEqual(set([x.id for x in query]), set([mm2.id])) def test_sliced_delete(self): "Delete queries can safely contain sliced subqueries" DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[0:1]).delete() self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), set([1, 2, 3])) DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:2]).delete() self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), set([1, 3])) DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:]).delete() self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), set([3])) class CloneTests(TestCase): def test_evaluated_queryset_as_argument(self): "#13227 -- If a queryset is already evaluated, it can still be used as a query arg" n = Note(note='Test1', misc='misc') n.save() e = ExtraInfo(info='good', note=n) e.save() n_list = Note.objects.all() # Evaluate the Note queryset, populating the query cache list(n_list) # Use the note queryset in a query, and evaluate # that query in a way that involves cloning. self.assertEqual(ExtraInfo.objects.filter(note__in=n_list)[0].info, 'good') def test_no_model_options_cloning(self): """ Test that cloning a queryset does not get out of hand. While complete testing is impossible, this is a sanity check against invalid use of deepcopy. refs #16759. """ opts_class = type(Note._meta) note_deepcopy = getattr(opts_class, "__deepcopy__", None) opts_class.__deepcopy__ = lambda obj, memo: self.fail("Model options shouldn't be cloned.") try: Note.objects.filter(pk__lte=F('pk') + 1).all() finally: if note_deepcopy is None: delattr(opts_class, "__deepcopy__") else: opts_class.__deepcopy__ = note_deepcopy def test_no_fields_cloning(self): """ Test that cloning a queryset does not get out of hand. While complete testing is impossible, this is a sanity check against invalid use of deepcopy. refs #16759. """ opts_class = type(Note._meta.get_field_by_name("misc")[0]) note_deepcopy = getattr(opts_class, "__deepcopy__", None) opts_class.__deepcopy__ = lambda obj, memo: self.fail("Model fields shouldn't be cloned") try: Note.objects.filter(note=F('misc')).all() finally: if note_deepcopy is None: delattr(opts_class, "__deepcopy__") else: opts_class.__deepcopy__ = note_deepcopy class EmptyQuerySetTests(TestCase): def test_emptyqueryset_values(self): # #14366 -- Calling .values() on an empty QuerySet and then cloning # that should not cause an error self.assertQuerysetEqual( Number.objects.none().values('num').order_by('num'), [] ) def test_values_subquery(self): self.assertQuerysetEqual( Number.objects.filter(pk__in=Number.objects.none().values("pk")), [] ) self.assertQuerysetEqual( Number.objects.filter(pk__in=Number.objects.none().values_list("pk")), [] ) def test_ticket_19151(self): # #19151 -- Calling .values() or .values_list() on an empty QuerySet # should return an empty QuerySet and not cause an error. q = Author.objects.none() self.assertQuerysetEqual(q.values(), []) self.assertQuerysetEqual(q.values_list(), []) class ValuesQuerysetTests(BaseQuerysetTest): def setUp(self): Number.objects.create(num=72) self.identity = lambda x: x def test_flat_values_list(self): qs = Number.objects.values_list("num") qs = qs.values_list("num", flat=True) self.assertValueQuerysetEqual(qs, [72]) def test_extra_values(self): # testing for ticket 14930 issues qs = Number.objects.extra(select=OrderedDict([('value_plus_x', 'num+%s'), ('value_minus_x', 'num-%s')]), select_params=(1, 2)) qs = qs.order_by('value_minus_x') qs = qs.values('num') self.assertQuerysetEqual(qs, [{'num': 72}], self.identity) def test_extra_values_order_twice(self): # testing for ticket 14930 issues qs = Number.objects.extra(select={'value_plus_one': 'num+1', 'value_minus_one': 'num-1'}) qs = qs.order_by('value_minus_one').order_by('value_plus_one') qs = qs.values('num') self.assertQuerysetEqual(qs, [{'num': 72}], self.identity) def test_extra_values_order_multiple(self): # Postgres doesn't allow constants in order by, so check for that. qs = Number.objects.extra(select={ 'value_plus_one': 'num+1', 'value_minus_one': 'num-1', 'constant_value': '1' }) qs = qs.order_by('value_plus_one', 'value_minus_one', 'constant_value') qs = qs.values('num') self.assertQuerysetEqual(qs, [{'num': 72}], self.identity) def test_extra_values_order_in_extra(self): # testing for ticket 14930 issues qs = Number.objects.extra( select={'value_plus_one': 'num+1', 'value_minus_one': 'num-1'}, order_by=['value_minus_one']) qs = qs.values('num') def test_extra_select_params_values_order_in_extra(self): # testing for 23259 issue qs = Number.objects.extra( select={'value_plus_x': 'num+%s'}, select_params=[1], order_by=['value_plus_x']) qs = qs.filter(num=72) qs = qs.values('num') self.assertQuerysetEqual(qs, [{'num': 72}], self.identity) def test_extra_multiple_select_params_values_order_by(self): # testing for 23259 issue qs = Number.objects.extra(select=OrderedDict([('value_plus_x', 'num+%s'), ('value_minus_x', 'num-%s')]), select_params=(72, 72)) qs = qs.order_by('value_minus_x') qs = qs.filter(num=1) qs = qs.values('num') self.assertQuerysetEqual(qs, [], self.identity) def test_extra_values_list(self): # testing for ticket 14930 issues qs = Number.objects.extra(select={'value_plus_one': 'num+1'}) qs = qs.order_by('value_plus_one') qs = qs.values_list('num') self.assertQuerysetEqual(qs, [(72,)], self.identity) def test_flat_extra_values_list(self): # testing for ticket 14930 issues qs = Number.objects.extra(select={'value_plus_one': 'num+1'}) qs = qs.order_by('value_plus_one') qs = qs.values_list('num', flat=True) self.assertQuerysetEqual(qs, [72], self.identity) class WeirdQuerysetSlicingTests(BaseQuerysetTest): def setUp(self): Number.objects.create(num=1) Number.objects.create(num=2) Article.objects.create(name='one', created=datetime.datetime.now()) Article.objects.create(name='two', created=datetime.datetime.now()) Article.objects.create(name='three', created=datetime.datetime.now()) Article.objects.create(name='four', created=datetime.datetime.now()) def test_tickets_7698_10202(self): # People like to slice with '0' as the high-water mark. self.assertQuerysetEqual(Article.objects.all()[0:0], []) self.assertQuerysetEqual(Article.objects.all()[0:0][:10], []) self.assertEqual(Article.objects.all()[:0].count(), 0) self.assertRaisesMessage( AssertionError, 'Cannot change a query once a slice has been taken.', Article.objects.all()[:0].latest, 'created' ) def test_empty_resultset_sql(self): # ticket #12192 self.assertNumQueries(0, lambda: list(Number.objects.all()[1:1])) class EscapingTests(TestCase): def test_ticket_7302(self): # Reserved names are appropriately escaped ReservedName.objects.create(name='a', order=42) ReservedName.objects.create(name='b', order=37) self.assertQuerysetEqual( ReservedName.objects.all().order_by('order'), ['<ReservedName: b>', '<ReservedName: a>'] ) self.assertQuerysetEqual( ReservedName.objects.extra(select={'stuff': 'name'}, order_by=('order', 'stuff')), ['<ReservedName: b>', '<ReservedName: a>'] ) class ToFieldTests(TestCase): def test_in_query(self): apple = Food.objects.create(name="apple") pear = Food.objects.create(name="pear") lunch = Eaten.objects.create(food=apple, meal="lunch") dinner = Eaten.objects.create(food=pear, meal="dinner") self.assertEqual( set(Eaten.objects.filter(food__in=[apple, pear])), set([lunch, dinner]), ) def test_reverse_in(self): apple = Food.objects.create(name="apple") pear = Food.objects.create(name="pear") lunch_apple = Eaten.objects.create(food=apple, meal="lunch") lunch_pear = Eaten.objects.create(food=pear, meal="dinner") self.assertEqual( set(Food.objects.filter(eaten__in=[lunch_apple, lunch_pear])), set([apple, pear]) ) def test_single_object(self): apple = Food.objects.create(name="apple") lunch = Eaten.objects.create(food=apple, meal="lunch") dinner = Eaten.objects.create(food=apple, meal="dinner") self.assertEqual( set(Eaten.objects.filter(food=apple)), set([lunch, dinner]) ) def test_single_object_reverse(self): apple = Food.objects.create(name="apple") lunch = Eaten.objects.create(food=apple, meal="lunch") self.assertEqual( set(Food.objects.filter(eaten=lunch)), set([apple]) ) def test_recursive_fk(self): node1 = Node.objects.create(num=42) node2 = Node.objects.create(num=1, parent=node1) self.assertEqual( list(Node.objects.filter(parent=node1)), [node2] ) def test_recursive_fk_reverse(self): node1 = Node.objects.create(num=42) node2 = Node.objects.create(num=1, parent=node1) self.assertEqual( list(Node.objects.filter(node=node2)), [node1] ) class ConditionalTests(BaseQuerysetTest): """Tests whose execution depend on different environment conditions like Python version or DB backend features""" def setUp(self): generic = NamedCategory.objects.create(name="Generic") t1 = Tag.objects.create(name='t1', category=generic) Tag.objects.create(name='t2', parent=t1, category=generic) t3 = Tag.objects.create(name='t3', parent=t1) Tag.objects.create(name='t4', parent=t3) Tag.objects.create(name='t5', parent=t3) def test_infinite_loop(self): # If you're not careful, it's possible to introduce infinite loops via # default ordering on foreign keys in a cycle. We detect that. self.assertRaisesMessage( FieldError, 'Infinite loop caused by ordering.', lambda: list(LoopX.objects.all()) # Force queryset evaluation with list() ) self.assertRaisesMessage( FieldError, 'Infinite loop caused by ordering.', lambda: list(LoopZ.objects.all()) # Force queryset evaluation with list() ) # Note that this doesn't cause an infinite loop, since the default # ordering on the Tag model is empty (and thus defaults to using "id" # for the related field). self.assertEqual(len(Tag.objects.order_by('parent')), 5) # ... but you can still order in a non-recursive fashion among linked # fields (the previous test failed because the default ordering was # recursive). self.assertQuerysetEqual( LoopX.objects.all().order_by('y__x__y__x__id'), [] ) # When grouping without specifying ordering, we add an explicit "ORDER BY NULL" # portion in MySQL to prevent unnecessary sorting. @skipUnlessDBFeature('requires_explicit_null_ordering_when_grouping') def test_null_ordering_added(self): query = Tag.objects.values_list('parent_id', flat=True).order_by().query query.group_by = ['parent_id'] sql = query.get_compiler(DEFAULT_DB_ALIAS).as_sql()[0] fragment = "ORDER BY " pos = sql.find(fragment) self.assertEqual(sql.find(fragment, pos + 1), -1) self.assertEqual(sql.find("NULL", pos + len(fragment)), pos + len(fragment)) # Sqlite 3 does not support passing in more than 1000 parameters except by # changing a parameter at compilation time. @skipUnlessDBFeature('supports_1000_query_parameters') def test_ticket14244(self): # Test that the "in" lookup works with lists of 1000 items or more. # The numbers amount is picked to force three different IN batches # for Oracle, yet to be less than 2100 parameter limit for MSSQL. numbers = list(range(2050)) Number.objects.all().delete() Number.objects.bulk_create(Number(num=num) for num in numbers) self.assertEqual( Number.objects.filter(num__in=numbers[:1000]).count(), 1000 ) self.assertEqual( Number.objects.filter(num__in=numbers[:1001]).count(), 1001 ) self.assertEqual( Number.objects.filter(num__in=numbers[:2000]).count(), 2000 ) self.assertEqual( Number.objects.filter(num__in=numbers).count(), len(numbers) ) class UnionTests(unittest.TestCase): """ Tests for the union of two querysets. Bug #12252. """ def setUp(self): objectas = [] objectbs = [] objectcs = [] a_info = ['one', 'two', 'three'] for name in a_info: o = ObjectA(name=name) o.save() objectas.append(o) b_info = [('un', 1, objectas[0]), ('deux', 2, objectas[0]), ('trois', 3, objectas[2])] for name, number, objecta in b_info: o = ObjectB(name=name, num=number, objecta=objecta) o.save() objectbs.append(o) c_info = [('ein', objectas[2], objectbs[2]), ('zwei', objectas[1], objectbs[1])] for name, objecta, objectb in c_info: o = ObjectC(name=name, objecta=objecta, objectb=objectb) o.save() objectcs.append(o) def check_union(self, model, Q1, Q2): filter = model.objects.filter self.assertEqual(set(filter(Q1) | filter(Q2)), set(filter(Q1 | Q2))) self.assertEqual(set(filter(Q2) | filter(Q1)), set(filter(Q1 | Q2))) def test_A_AB(self): Q1 = Q(name='two') Q2 = Q(objectb__name='deux') self.check_union(ObjectA, Q1, Q2) def test_A_AB2(self): Q1 = Q(name='two') Q2 = Q(objectb__name='deux', objectb__num=2) self.check_union(ObjectA, Q1, Q2) def test_AB_ACB(self): Q1 = Q(objectb__name='deux') Q2 = Q(objectc__objectb__name='deux') self.check_union(ObjectA, Q1, Q2) def test_BAB_BAC(self): Q1 = Q(objecta__objectb__name='deux') Q2 = Q(objecta__objectc__name='ein') self.check_union(ObjectB, Q1, Q2) def test_BAB_BACB(self): Q1 = Q(objecta__objectb__name='deux') Q2 = Q(objecta__objectc__objectb__name='trois') self.check_union(ObjectB, Q1, Q2) def test_BA_BCA__BAB_BAC_BCA(self): Q1 = Q(objecta__name='one', objectc__objecta__name='two') Q2 = Q(objecta__objectc__name='ein', objectc__objecta__name='three', objecta__objectb__name='trois') self.check_union(ObjectB, Q1, Q2) class DefaultValuesInsertTest(TestCase): def test_no_extra_params(self): # Ticket #17056 -- affects Oracle try: DumbCategory.objects.create() except TypeError: self.fail("Creation of an instance of a model with only the PK field shouldn't error out after bulk insert refactoring (#17056)") class ExcludeTests(TestCase): def setUp(self): f1 = Food.objects.create(name='apples') Food.objects.create(name='oranges') Eaten.objects.create(food=f1, meal='dinner') j1 = Job.objects.create(name='Manager') r1 = Responsibility.objects.create(description='Playing golf') j2 = Job.objects.create(name='Programmer') r2 = Responsibility.objects.create(description='Programming') JobResponsibilities.objects.create(job=j1, responsibility=r1) JobResponsibilities.objects.create(job=j2, responsibility=r2) def test_to_field(self): self.assertQuerysetEqual( Food.objects.exclude(eaten__meal='dinner'), ['<Food: oranges>']) self.assertQuerysetEqual( Job.objects.exclude(responsibilities__description='Playing golf'), ['<Job: Programmer>']) self.assertQuerysetEqual( Responsibility.objects.exclude(jobs__name='Manager'), ['<Responsibility: Programming>']) def test_ticket14511(self): alex = Person.objects.get_or_create(name='Alex')[0] jane = Person.objects.get_or_create(name='Jane')[0] oracle = Company.objects.get_or_create(name='Oracle')[0] google = Company.objects.get_or_create(name='Google')[0] microsoft = Company.objects.get_or_create(name='Microsoft')[0] intel = Company.objects.get_or_create(name='Intel')[0] def employ(employer, employee, title): Employment.objects.get_or_create(employee=employee, employer=employer, title=title) employ(oracle, alex, 'Engineer') employ(oracle, alex, 'Developer') employ(google, alex, 'Engineer') employ(google, alex, 'Manager') employ(microsoft, alex, 'Manager') employ(intel, alex, 'Manager') employ(microsoft, jane, 'Developer') employ(intel, jane, 'Manager') alex_tech_employers = alex.employers.filter( employment__title__in=('Engineer', 'Developer')).distinct().order_by('name') self.assertQuerysetEqual(alex_tech_employers, [google, oracle], lambda x: x) alex_nontech_employers = alex.employers.exclude( employment__title__in=('Engineer', 'Developer')).distinct().order_by('name') self.assertQuerysetEqual(alex_nontech_employers, [google, intel, microsoft], lambda x: x) class ExcludeTest17600(TestCase): """ Some regressiontests for ticket #17600. Some of these likely duplicate other existing tests. """ def setUp(self): # Create a few Orders. self.o1 = Order.objects.create(pk=1) self.o2 = Order.objects.create(pk=2) self.o3 = Order.objects.create(pk=3) # Create some OrderItems for the first order with homogeneous # status_id values self.oi1 = OrderItem.objects.create(order=self.o1, status=1) self.oi2 = OrderItem.objects.create(order=self.o1, status=1) self.oi3 = OrderItem.objects.create(order=self.o1, status=1) # Create some OrderItems for the second order with heterogeneous # status_id values self.oi4 = OrderItem.objects.create(order=self.o2, status=1) self.oi5 = OrderItem.objects.create(order=self.o2, status=2) self.oi6 = OrderItem.objects.create(order=self.o2, status=3) # Create some OrderItems for the second order with heterogeneous # status_id values self.oi7 = OrderItem.objects.create(order=self.o3, status=2) self.oi8 = OrderItem.objects.create(order=self.o3, status=3) self.oi9 = OrderItem.objects.create(order=self.o3, status=4) def test_exclude_plain(self): """ This should exclude Orders which have some items with status 1 """ self.assertQuerysetEqual( Order.objects.exclude(items__status=1), ['<Order: 3>']) def test_exclude_plain_distinct(self): """ This should exclude Orders which have some items with status 1 """ self.assertQuerysetEqual( Order.objects.exclude(items__status=1).distinct(), ['<Order: 3>']) def test_exclude_with_q_object_distinct(self): """ This should exclude Orders which have some items with status 1 """ self.assertQuerysetEqual( Order.objects.exclude(Q(items__status=1)).distinct(), ['<Order: 3>']) def test_exclude_with_q_object_no_distinct(self): """ This should exclude Orders which have some items with status 1 """ self.assertQuerysetEqual( Order.objects.exclude(Q(items__status=1)), ['<Order: 3>']) def test_exclude_with_q_is_equal_to_plain_exclude(self): """ Using exclude(condition) and exclude(Q(condition)) should yield the same QuerySet """ self.assertEqual( list(Order.objects.exclude(items__status=1).distinct()), list(Order.objects.exclude(Q(items__status=1)).distinct())) def test_exclude_with_q_is_equal_to_plain_exclude_variation(self): """ Using exclude(condition) and exclude(Q(condition)) should yield the same QuerySet """ self.assertEqual( list(Order.objects.exclude(items__status=1)), list(Order.objects.exclude(Q(items__status=1)).distinct())) @unittest.expectedFailure def test_only_orders_with_all_items_having_status_1(self): """ This should only return orders having ALL items set to status 1, or those items not having any orders at all. The correct way to write this query in SQL seems to be using two nested subqueries. """ self.assertQuerysetEqual( Order.objects.exclude(~Q(items__status=1)).distinct(), ['<Order: 1>']) class Exclude15786(TestCase): """Regression test for #15786""" def test_ticket15786(self): c1 = SimpleCategory.objects.create(name='c1') c2 = SimpleCategory.objects.create(name='c2') OneToOneCategory.objects.create(category=c1) OneToOneCategory.objects.create(category=c2) rel = CategoryRelationship.objects.create(first=c1, second=c2) self.assertEqual( CategoryRelationship.objects.exclude( first__onetoonecategory=F('second__onetoonecategory') ).get(), rel ) class NullInExcludeTest(TestCase): def setUp(self): NullableName.objects.create(name='i1') NullableName.objects.create() def test_null_in_exclude_qs(self): none_val = '' if connection.features.interprets_empty_strings_as_nulls else None self.assertQuerysetEqual( NullableName.objects.exclude(name__in=[]), ['i1', none_val], attrgetter('name')) self.assertQuerysetEqual( NullableName.objects.exclude(name__in=['i1']), [none_val], attrgetter('name')) self.assertQuerysetEqual( NullableName.objects.exclude(name__in=['i3']), ['i1', none_val], attrgetter('name')) inner_qs = NullableName.objects.filter(name='i1').values_list('name') self.assertQuerysetEqual( NullableName.objects.exclude(name__in=inner_qs), [none_val], attrgetter('name')) # Check that the inner queryset wasn't executed - it should be turned # into subquery above self.assertIs(inner_qs._result_cache, None) @unittest.expectedFailure def test_col_not_in_list_containing_null(self): """ The following case is not handled properly because SQL's COL NOT IN (list containing null) handling is too weird to abstract away. """ self.assertQuerysetEqual( NullableName.objects.exclude(name__in=[None]), ['i1'], attrgetter('name')) def test_double_exclude(self): self.assertEqual( list(NullableName.objects.filter(~~Q(name='i1'))), list(NullableName.objects.filter(Q(name='i1')))) self.assertNotIn( 'IS NOT NULL', str(NullableName.objects.filter(~~Q(name='i1')).query)) class EmptyStringsAsNullTest(TestCase): """ Test that filtering on non-null character fields works as expected. The reason for these tests is that Oracle treats '' as NULL, and this can cause problems in query construction. Refs #17957. """ def setUp(self): self.nc = NamedCategory.objects.create(name='') def test_direct_exclude(self): self.assertQuerysetEqual( NamedCategory.objects.exclude(name__in=['nonexisting']), [self.nc.pk], attrgetter('pk') ) def test_joined_exclude(self): self.assertQuerysetEqual( DumbCategory.objects.exclude(namedcategory__name__in=['nonexisting']), [self.nc.pk], attrgetter('pk') ) def test_21001(self): foo = NamedCategory.objects.create(name='foo') self.assertQuerysetEqual( NamedCategory.objects.exclude(name=''), [foo.pk], attrgetter('pk') ) class ProxyQueryCleanupTest(TestCase): def test_evaluated_proxy_count(self): """ Test that generating the query string doesn't alter the query's state in irreversible ways. Refs #18248. """ ProxyCategory.objects.create() qs = ProxyCategory.objects.all() self.assertEqual(qs.count(), 1) str(qs.query) self.assertEqual(qs.count(), 1) class WhereNodeTest(TestCase): class DummyNode(object): def as_sql(self, qn, connection): return 'dummy', [] class MockCompiler(object): def compile(self, node): return node.as_sql(self, connection) def __call__(self, name): return connection.ops.quote_name(name) def test_empty_full_handling_conjunction(self): qn = WhereNodeTest.MockCompiler() w = WhereNode(children=[EverythingNode()]) self.assertEqual(w.as_sql(qn, connection), ('', [])) w.negate() self.assertRaises(EmptyResultSet, w.as_sql, qn, connection) w = WhereNode(children=[NothingNode()]) self.assertRaises(EmptyResultSet, w.as_sql, qn, connection) w.negate() self.assertEqual(w.as_sql(qn, connection), ('', [])) w = WhereNode(children=[EverythingNode(), EverythingNode()]) self.assertEqual(w.as_sql(qn, connection), ('', [])) w.negate() self.assertRaises(EmptyResultSet, w.as_sql, qn, connection) w = WhereNode(children=[EverythingNode(), self.DummyNode()]) self.assertEqual(w.as_sql(qn, connection), ('dummy', [])) w = WhereNode(children=[self.DummyNode(), self.DummyNode()]) self.assertEqual(w.as_sql(qn, connection), ('(dummy AND dummy)', [])) w.negate() self.assertEqual(w.as_sql(qn, connection), ('NOT (dummy AND dummy)', [])) w = WhereNode(children=[NothingNode(), self.DummyNode()]) self.assertRaises(EmptyResultSet, w.as_sql, qn, connection) w.negate() self.assertEqual(w.as_sql(qn, connection), ('', [])) def test_empty_full_handling_disjunction(self): qn = WhereNodeTest.MockCompiler() w = WhereNode(children=[EverythingNode()], connector='OR') self.assertEqual(w.as_sql(qn, connection), ('', [])) w.negate() self.assertRaises(EmptyResultSet, w.as_sql, qn, connection) w = WhereNode(children=[NothingNode()], connector='OR') self.assertRaises(EmptyResultSet, w.as_sql, qn, connection) w.negate() self.assertEqual(w.as_sql(qn, connection), ('', [])) w = WhereNode(children=[EverythingNode(), EverythingNode()], connector='OR') self.assertEqual(w.as_sql(qn, connection), ('', [])) w.negate() self.assertRaises(EmptyResultSet, w.as_sql, qn, connection) w = WhereNode(children=[EverythingNode(), self.DummyNode()], connector='OR') self.assertEqual(w.as_sql(qn, connection), ('', [])) w.negate() self.assertRaises(EmptyResultSet, w.as_sql, qn, connection) w = WhereNode(children=[self.DummyNode(), self.DummyNode()], connector='OR') self.assertEqual(w.as_sql(qn, connection), ('(dummy OR dummy)', [])) w.negate() self.assertEqual(w.as_sql(qn, connection), ('NOT (dummy OR dummy)', [])) w = WhereNode(children=[NothingNode(), self.DummyNode()], connector='OR') self.assertEqual(w.as_sql(qn, connection), ('dummy', [])) w.negate() self.assertEqual(w.as_sql(qn, connection), ('NOT (dummy)', [])) def test_empty_nodes(self): qn = WhereNodeTest.MockCompiler() empty_w = WhereNode() w = WhereNode(children=[empty_w, empty_w]) self.assertEqual(w.as_sql(qn, connection), (None, [])) w.negate() self.assertEqual(w.as_sql(qn, connection), (None, [])) w.connector = 'OR' self.assertEqual(w.as_sql(qn, connection), (None, [])) w.negate() self.assertEqual(w.as_sql(qn, connection), (None, [])) w = WhereNode(children=[empty_w, NothingNode()], connector='OR') self.assertRaises(EmptyResultSet, w.as_sql, qn, connection) class IteratorExceptionsTest(TestCase): def test_iter_exceptions(self): qs = ExtraInfo.objects.only('author') with self.assertRaises(AttributeError): list(qs) def test_invalid_qs_list(self): # Test for #19895 - second iteration over invalid queryset # raises errors. qs = Article.objects.order_by('invalid_column') self.assertRaises(FieldError, list, qs) self.assertRaises(FieldError, list, qs) class NullJoinPromotionOrTest(TestCase): def setUp(self): self.d1 = ModelD.objects.create(name='foo') d2 = ModelD.objects.create(name='bar') self.a1 = ModelA.objects.create(name='a1', d=self.d1) c = ModelC.objects.create(name='c') b = ModelB.objects.create(name='b', c=c) self.a2 = ModelA.objects.create(name='a2', b=b, d=d2) def test_ticket_17886(self): # The first Q-object is generating the match, the rest of the filters # should not remove the match even if they do not match anything. The # problem here was that b__name generates a LOUTER JOIN, then # b__c__name generates join to c, which the ORM tried to promote but # failed as that join isn't nullable. q_obj = ( Q(d__name='foo') | Q(b__name='foo') | Q(b__c__name='foo') ) qset = ModelA.objects.filter(q_obj) self.assertEqual(list(qset), [self.a1]) # We generate one INNER JOIN to D. The join is direct and not nullable # so we can use INNER JOIN for it. However, we can NOT use INNER JOIN # for the b->c join, as a->b is nullable. self.assertEqual(str(qset.query).count('INNER JOIN'), 1) def test_isnull_filter_promotion(self): qs = ModelA.objects.filter(Q(b__name__isnull=True)) self.assertEqual(str(qs.query).count('LEFT OUTER'), 1) self.assertEqual(list(qs), [self.a1]) qs = ModelA.objects.filter(~Q(b__name__isnull=True)) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(list(qs), [self.a2]) qs = ModelA.objects.filter(~~Q(b__name__isnull=True)) self.assertEqual(str(qs.query).count('LEFT OUTER'), 1) self.assertEqual(list(qs), [self.a1]) qs = ModelA.objects.filter(Q(b__name__isnull=False)) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(list(qs), [self.a2]) qs = ModelA.objects.filter(~Q(b__name__isnull=False)) self.assertEqual(str(qs.query).count('LEFT OUTER'), 1) self.assertEqual(list(qs), [self.a1]) qs = ModelA.objects.filter(~~Q(b__name__isnull=False)) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(list(qs), [self.a2]) def test_null_join_demotion(self): qs = ModelA.objects.filter(Q(b__name__isnull=False) & Q(b__name__isnull=True)) self.assertTrue(' INNER JOIN ' in str(qs.query)) qs = ModelA.objects.filter(Q(b__name__isnull=True) & Q(b__name__isnull=False)) self.assertTrue(' INNER JOIN ' in str(qs.query)) qs = ModelA.objects.filter(Q(b__name__isnull=False) | Q(b__name__isnull=True)) self.assertTrue(' LEFT OUTER JOIN ' in str(qs.query)) qs = ModelA.objects.filter(Q(b__name__isnull=True) | Q(b__name__isnull=False)) self.assertTrue(' LEFT OUTER JOIN ' in str(qs.query)) def test_ticket_21366(self): n = Note.objects.create(note='n', misc='m') e = ExtraInfo.objects.create(info='info', note=n) a = Author.objects.create(name='Author1', num=1, extra=e) Ranking.objects.create(rank=1, author=a) r1 = Report.objects.create(name='Foo', creator=a) r2 = Report.objects.create(name='Bar') Report.objects.create(name='Bar', creator=a) qs = Report.objects.filter( Q(creator__ranking__isnull=True) | Q(creator__ranking__rank=1, name='Foo') ) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) self.assertEqual(str(qs.query).count(' JOIN '), 2) self.assertQuerysetEqual( qs.order_by('name'), [r2, r1], lambda x: x) def test_ticket_21748(self): i1 = Identifier.objects.create(name='i1') i2 = Identifier.objects.create(name='i2') i3 = Identifier.objects.create(name='i3') Program.objects.create(identifier=i1) Channel.objects.create(identifier=i1) Program.objects.create(identifier=i2) self.assertQuerysetEqual( Identifier.objects.filter(program=None, channel=None), [i3], lambda x: x) self.assertQuerysetEqual( Identifier.objects.exclude(program=None, channel=None).order_by('name'), [i1, i2], lambda x: x) def test_ticket_21748_double_negated_and(self): i1 = Identifier.objects.create(name='i1') i2 = Identifier.objects.create(name='i2') Identifier.objects.create(name='i3') p1 = Program.objects.create(identifier=i1) c1 = Channel.objects.create(identifier=i1) Program.objects.create(identifier=i2) # Check the ~~Q() (or equivalently .exclude(~Q)) works like Q() for # join promotion. qs1_doubleneg = Identifier.objects.exclude(~Q(program__id=p1.id, channel__id=c1.id)).order_by('pk') qs1_filter = Identifier.objects.filter(program__id=p1.id, channel__id=c1.id).order_by('pk') self.assertQuerysetEqual(qs1_doubleneg, qs1_filter, lambda x: x) self.assertEqual(str(qs1_filter.query).count('JOIN'), str(qs1_doubleneg.query).count('JOIN')) self.assertEqual(2, str(qs1_doubleneg.query).count('INNER JOIN')) self.assertEqual(str(qs1_filter.query).count('INNER JOIN'), str(qs1_doubleneg.query).count('INNER JOIN')) def test_ticket_21748_double_negated_or(self): i1 = Identifier.objects.create(name='i1') i2 = Identifier.objects.create(name='i2') Identifier.objects.create(name='i3') p1 = Program.objects.create(identifier=i1) c1 = Channel.objects.create(identifier=i1) p2 = Program.objects.create(identifier=i2) # Test OR + doubleneq. The expected result is that channel is LOUTER # joined, program INNER joined qs1_filter = Identifier.objects.filter( Q(program__id=p2.id, channel__id=c1.id) | Q(program__id=p1.id) ).order_by('pk') qs1_doubleneg = Identifier.objects.exclude( ~Q(Q(program__id=p2.id, channel__id=c1.id) | Q(program__id=p1.id)) ).order_by('pk') self.assertQuerysetEqual(qs1_doubleneg, qs1_filter, lambda x: x) self.assertEqual(str(qs1_filter.query).count('JOIN'), str(qs1_doubleneg.query).count('JOIN')) self.assertEqual(1, str(qs1_doubleneg.query).count('INNER JOIN')) self.assertEqual(str(qs1_filter.query).count('INNER JOIN'), str(qs1_doubleneg.query).count('INNER JOIN')) def test_ticket_21748_complex_filter(self): i1 = Identifier.objects.create(name='i1') i2 = Identifier.objects.create(name='i2') Identifier.objects.create(name='i3') p1 = Program.objects.create(identifier=i1) c1 = Channel.objects.create(identifier=i1) p2 = Program.objects.create(identifier=i2) # Finally, a more complex case, one time in a way where each # NOT is pushed to lowest level in the boolean tree, and # another query where this isn't done. qs1 = Identifier.objects.filter( ~Q(~Q(program__id=p2.id, channel__id=c1.id) & Q(program__id=p1.id))).order_by('pk') qs2 = Identifier.objects.filter( Q(Q(program__id=p2.id, channel__id=c1.id) | ~Q(program__id=p1.id))).order_by('pk') self.assertQuerysetEqual(qs1, qs2, lambda x: x) self.assertEqual(str(qs1.query).count('JOIN'), str(qs2.query).count('JOIN')) self.assertEqual(0, str(qs1.query).count('INNER JOIN')) self.assertEqual(str(qs1.query).count('INNER JOIN'), str(qs2.query).count('INNER JOIN')) class ReverseJoinTrimmingTest(TestCase): def test_reverse_trimming(self): # Check that we don't accidentally trim reverse joins - we can't know # if there is anything on the other side of the join, so trimming # reverse joins can't be done, ever. t = Tag.objects.create() qs = Tag.objects.filter(annotation__tag=t.pk) self.assertIn('INNER JOIN', str(qs.query)) self.assertEqual(list(qs), []) class JoinReuseTest(TestCase): """ Test that the queries reuse joins sensibly (for example, direct joins are always reused). """ def test_fk_reuse(self): qs = Annotation.objects.filter(tag__name='foo').filter(tag__name='bar') self.assertEqual(str(qs.query).count('JOIN'), 1) def test_fk_reuse_select_related(self): qs = Annotation.objects.filter(tag__name='foo').select_related('tag') self.assertEqual(str(qs.query).count('JOIN'), 1) def test_fk_reuse_annotation(self): qs = Annotation.objects.filter(tag__name='foo').annotate(cnt=Count('tag__name')) self.assertEqual(str(qs.query).count('JOIN'), 1) def test_fk_reuse_disjunction(self): qs = Annotation.objects.filter(Q(tag__name='foo') | Q(tag__name='bar')) self.assertEqual(str(qs.query).count('JOIN'), 1) def test_fk_reuse_order_by(self): qs = Annotation.objects.filter(tag__name='foo').order_by('tag__name') self.assertEqual(str(qs.query).count('JOIN'), 1) def test_revo2o_reuse(self): qs = Detail.objects.filter(member__name='foo').filter(member__name='foo') self.assertEqual(str(qs.query).count('JOIN'), 1) def test_revfk_noreuse(self): qs = Author.objects.filter(report__name='r4').filter(report__name='r1') self.assertEqual(str(qs.query).count('JOIN'), 2) class DisjunctionPromotionTests(TestCase): def test_disjuction_promotion_select_related(self): fk1 = FK1.objects.create(f1='f1', f2='f2') basea = BaseA.objects.create(a=fk1) qs = BaseA.objects.filter(Q(a=fk1) | Q(b=2)) self.assertEqual(str(qs.query).count(' JOIN '), 0) qs = qs.select_related('a', 'b') self.assertEqual(str(qs.query).count(' INNER JOIN '), 0) self.assertEqual(str(qs.query).count(' LEFT OUTER JOIN '), 2) with self.assertNumQueries(1): self.assertQuerysetEqual(qs, [basea], lambda x: x) self.assertEqual(qs[0].a, fk1) self.assertIs(qs[0].b, None) def test_disjunction_promotion1(self): # Pre-existing join, add two ORed filters to the same join, # all joins can be INNER JOINS. qs = BaseA.objects.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) qs = qs.filter(Q(b__f1='foo') | Q(b__f2='foo')) self.assertEqual(str(qs.query).count('INNER JOIN'), 2) # Reverse the order of AND and OR filters. qs = BaseA.objects.filter(Q(b__f1='foo') | Q(b__f2='foo')) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) qs = qs.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 2) def test_disjunction_promotion2(self): qs = BaseA.objects.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) # Now we have two different joins in an ORed condition, these # must be OUTER joins. The pre-existing join should remain INNER. qs = qs.filter(Q(b__f1='foo') | Q(c__f2='foo')) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) # Reverse case. qs = BaseA.objects.filter(Q(b__f1='foo') | Q(c__f2='foo')) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) qs = qs.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) def test_disjunction_promotion3(self): qs = BaseA.objects.filter(a__f2='bar') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) # The ANDed a__f2 filter allows us to use keep using INNER JOIN # even inside the ORed case. If the join to a__ returns nothing, # the ANDed filter for a__f2 can't be true. qs = qs.filter(Q(a__f1='foo') | Q(b__f2='foo')) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) def test_disjunction_promotion3_demote(self): # This one needs demotion logic: the first filter causes a to be # outer joined, the second filter makes it inner join again. qs = BaseA.objects.filter( Q(a__f1='foo') | Q(b__f2='foo')).filter(a__f2='bar') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) def test_disjunction_promotion4_demote(self): qs = BaseA.objects.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('JOIN'), 0) # Demote needed for the "a" join. It is marked as outer join by # above filter (even if it is trimmed away). qs = qs.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) def test_disjunction_promotion4(self): qs = BaseA.objects.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) qs = qs.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) def test_disjunction_promotion5_demote(self): qs = BaseA.objects.filter(Q(a=1) | Q(a=2)) # Note that the above filters on a force the join to an # inner join even if it is trimmed. self.assertEqual(str(qs.query).count('JOIN'), 0) qs = qs.filter(Q(a__f1='foo') | Q(b__f1='foo')) # So, now the a__f1 join doesn't need promotion. self.assertEqual(str(qs.query).count('INNER JOIN'), 1) # But b__f1 does. self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) qs = BaseA.objects.filter(Q(a__f1='foo') | Q(b__f1='foo')) # Now the join to a is created as LOUTER self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) qs = qs.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) def test_disjunction_promotion6(self): qs = BaseA.objects.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('JOIN'), 0) qs = BaseA.objects.filter(Q(a__f1='foo') & Q(b__f1='foo')) self.assertEqual(str(qs.query).count('INNER JOIN'), 2) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 0) qs = BaseA.objects.filter(Q(a__f1='foo') & Q(b__f1='foo')) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(qs.query).count('INNER JOIN'), 2) qs = qs.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('INNER JOIN'), 2) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 0) def test_disjunction_promotion7(self): qs = BaseA.objects.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('JOIN'), 0) qs = BaseA.objects.filter(Q(a__f1='foo') | (Q(b__f1='foo') & Q(a__f1='bar'))) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) qs = BaseA.objects.filter( (Q(a__f1='foo') | Q(b__f1='foo')) & (Q(a__f1='bar') | Q(c__f1='foo')) ) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 3) self.assertEqual(str(qs.query).count('INNER JOIN'), 0) qs = BaseA.objects.filter( (Q(a__f1='foo') | (Q(a__f1='bar')) & (Q(b__f1='bar') | Q(c__f1='foo'))) ) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) def test_disjunction_promotion_fexpression(self): qs = BaseA.objects.filter(Q(a__f1=F('b__f1')) | Q(b__f1='foo')) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) qs = BaseA.objects.filter(Q(a__f1=F('c__f1')) | Q(b__f1='foo')) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 3) qs = BaseA.objects.filter(Q(a__f1=F('b__f1')) | Q(a__f2=F('b__f2')) | Q(c__f1='foo')) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 3) qs = BaseA.objects.filter(Q(a__f1=F('c__f1')) | (Q(pk=1) & Q(pk=2))) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) self.assertEqual(str(qs.query).count('INNER JOIN'), 0) class ManyToManyExcludeTest(TestCase): def test_exclude_many_to_many(self): Identifier.objects.create(name='extra') program = Program.objects.create(identifier=Identifier.objects.create(name='program')) channel = Channel.objects.create(identifier=Identifier.objects.create(name='channel')) channel.programs.add(program) # channel contains 'program1', so all Identifiers except that one # should be returned self.assertQuerysetEqual( Identifier.objects.exclude(program__channel=channel).order_by('name'), ['<Identifier: channel>', '<Identifier: extra>'] ) self.assertQuerysetEqual( Identifier.objects.exclude(program__channel=None).order_by('name'), ['<Identifier: program>'] ) def test_ticket_12823(self): pg3 = Page.objects.create(text='pg3') pg2 = Page.objects.create(text='pg2') pg1 = Page.objects.create(text='pg1') pa1 = Paragraph.objects.create(text='pa1') pa1.page = [pg1, pg2] pa2 = Paragraph.objects.create(text='pa2') pa2.page = [pg2, pg3] pa3 = Paragraph.objects.create(text='pa3') ch1 = Chapter.objects.create(title='ch1', paragraph=pa1) ch2 = Chapter.objects.create(title='ch2', paragraph=pa2) ch3 = Chapter.objects.create(title='ch3', paragraph=pa3) b1 = Book.objects.create(title='b1', chapter=ch1) b2 = Book.objects.create(title='b2', chapter=ch2) b3 = Book.objects.create(title='b3', chapter=ch3) q = Book.objects.exclude(chapter__paragraph__page__text='pg1') self.assertNotIn('IS NOT NULL', str(q.query)) self.assertEqual(len(q), 2) self.assertNotIn(b1, q) self.assertIn(b2, q) self.assertIn(b3, q) class RelabelCloneTest(TestCase): def test_ticket_19964(self): my1 = MyObject.objects.create(data='foo') my1.parent = my1 my1.save() my2 = MyObject.objects.create(data='bar', parent=my1) parents = MyObject.objects.filter(parent=F('id')) children = MyObject.objects.filter(parent__in=parents).exclude(parent=F('id')) self.assertEqual(list(parents), [my1]) # Evaluating the children query (which has parents as part of it) does # not change results for the parents query. self.assertEqual(list(children), [my2]) self.assertEqual(list(parents), [my1]) class Ticket20101Tests(TestCase): def test_ticket_20101(self): """ Tests QuerySet ORed combining in exclude subquery case. """ t = Tag.objects.create(name='foo') a1 = Annotation.objects.create(tag=t, name='a1') a2 = Annotation.objects.create(tag=t, name='a2') a3 = Annotation.objects.create(tag=t, name='a3') n = Note.objects.create(note='foo', misc='bar') qs1 = Note.objects.exclude(annotation__in=[a1, a2]) qs2 = Note.objects.filter(annotation__in=[a3]) self.assertTrue(n in qs1) self.assertFalse(n in qs2) self.assertTrue(n in (qs1 | qs2)) class EmptyStringPromotionTests(TestCase): def test_empty_string_promotion(self): qs = RelatedObject.objects.filter(single__name='') if connection.features.interprets_empty_strings_as_nulls: self.assertIn('LEFT OUTER JOIN', str(qs.query)) else: self.assertNotIn('LEFT OUTER JOIN', str(qs.query)) class ValuesSubqueryTests(TestCase): def test_values_in_subquery(self): # Check that if a values() queryset is used, then the given values # will be used instead of forcing use of the relation's field. o1 = Order.objects.create(id=-2) o2 = Order.objects.create(id=-1) oi1 = OrderItem.objects.create(order=o1, status=0) oi1.status = oi1.pk oi1.save() OrderItem.objects.create(order=o2, status=0) # The query below should match o1 as it has related order_item # with id == status. self.assertQuerysetEqual( Order.objects.filter(items__in=OrderItem.objects.values_list('status')), [o1.pk], lambda x: x.pk) class DoubleInSubqueryTests(TestCase): def test_double_subquery_in(self): lfa1 = LeafA.objects.create(data='foo') lfa2 = LeafA.objects.create(data='bar') lfb1 = LeafB.objects.create(data='lfb1') lfb2 = LeafB.objects.create(data='lfb2') Join.objects.create(a=lfa1, b=lfb1) Join.objects.create(a=lfa2, b=lfb2) leaf_as = LeafA.objects.filter(data='foo').values_list('pk', flat=True) joins = Join.objects.filter(a__in=leaf_as).values_list('b__id', flat=True) qs = LeafB.objects.filter(pk__in=joins) self.assertQuerysetEqual( qs, [lfb1], lambda x: x) class Ticket18785Tests(TestCase): def test_ticket_18785(self): # Test join trimming from ticket18785 qs = Item.objects.exclude( note__isnull=False ).filter( name='something', creator__extra__isnull=True ).order_by() self.assertEqual(1, str(qs.query).count('INNER JOIN')) self.assertEqual(0, str(qs.query).count('OUTER JOIN')) class Ticket20788Tests(TestCase): def test_ticket_20788(self): Paragraph.objects.create() paragraph = Paragraph.objects.create() page = paragraph.page.create() chapter = Chapter.objects.create(paragraph=paragraph) Book.objects.create(chapter=chapter) paragraph2 = Paragraph.objects.create() Page.objects.create() chapter2 = Chapter.objects.create(paragraph=paragraph2) book2 = Book.objects.create(chapter=chapter2) sentences_not_in_pub = Book.objects.exclude( chapter__paragraph__page=page) self.assertQuerysetEqual( sentences_not_in_pub, [book2], lambda x: x) class Ticket12807Tests(TestCase): def test_ticket_12807(self): p1 = Paragraph.objects.create() p2 = Paragraph.objects.create() # The ORed condition below should have no effect on the query - the # ~Q(pk__in=[]) will always be True. qs = Paragraph.objects.filter((Q(pk=p2.pk) | ~Q(pk__in=[])) & Q(pk=p1.pk)) self.assertQuerysetEqual(qs, [p1], lambda x: x) class RelatedLookupTypeTests(TestCase): def test_wrong_type_lookup(self): oa = ObjectA.objects.create(name="oa") wrong_type = Order.objects.create(id=oa.pk) ob = ObjectB.objects.create(name="ob", objecta=oa, num=1) # Currently Django doesn't care if the object is of correct # type, it will just use the objecta's related fields attribute # (id) for model lookup. Making things more restrictive could # be a good idea... self.assertQuerysetEqual( ObjectB.objects.filter(objecta=wrong_type), [ob], lambda x: x) self.assertQuerysetEqual( ObjectB.objects.filter(objecta__in=[wrong_type]), [ob], lambda x: x) class Ticket14056Tests(TestCase): def test_ticket_14056(self): s1 = SharedConnection.objects.create(data='s1') s2 = SharedConnection.objects.create(data='s2') s3 = SharedConnection.objects.create(data='s3') PointerA.objects.create(connection=s2) expected_ordering = ( [s1, s3, s2] if connection.features.nulls_order_largest else [s2, s1, s3] ) self.assertQuerysetEqual( SharedConnection.objects.order_by('-pointera__connection', 'pk'), expected_ordering, lambda x: x ) class Ticket20955Tests(TestCase): def test_ticket_20955(self): jack = Staff.objects.create(name='jackstaff') jackstaff = StaffUser.objects.create(staff=jack) jill = Staff.objects.create(name='jillstaff') jillstaff = StaffUser.objects.create(staff=jill) task = Task.objects.create(creator=jackstaff, owner=jillstaff, title="task") task_get = Task.objects.get(pk=task.pk) # Load data so that assertNumQueries doesn't complain about the get # version's queries. task_get.creator.staffuser.staff task_get.owner.staffuser.staff task_select_related = Task.objects.select_related( 'creator__staffuser__staff', 'owner__staffuser__staff').get(pk=task.pk) with self.assertNumQueries(0): self.assertEqual(task_select_related.creator.staffuser.staff, task_get.creator.staffuser.staff) self.assertEqual(task_select_related.owner.staffuser.staff, task_get.owner.staffuser.staff) class Ticket21203Tests(TestCase): def test_ticket_21203(self): p = Ticket21203Parent.objects.create(parent_bool=True) c = Ticket21203Child.objects.create(parent=p) qs = Ticket21203Child.objects.select_related('parent').defer('parent__created') self.assertQuerysetEqual(qs, [c], lambda x: x) self.assertIs(qs[0].parent.parent_bool, True) class ValuesJoinPromotionTests(TestCase): def test_values_no_promotion_for_existing(self): qs = Node.objects.filter(parent__parent__isnull=False) self.assertTrue(' INNER JOIN ' in str(qs.query)) qs = qs.values('parent__parent__id') self.assertTrue(' INNER JOIN ' in str(qs.query)) # Make sure there is a left outer join without the filter. qs = Node.objects.values('parent__parent__id') self.assertTrue(' LEFT OUTER JOIN ' in str(qs.query)) def test_non_nullable_fk_not_promoted(self): qs = ObjectB.objects.values('objecta__name') self.assertTrue(' INNER JOIN ' in str(qs.query)) def test_ticket_21376(self): a = ObjectA.objects.create() ObjectC.objects.create(objecta=a) qs = ObjectC.objects.filter( Q(objecta=a) | Q(objectb__objecta=a), ) qs = qs.filter( Q(objectb=1) | Q(objecta=a), ) self.assertEqual(qs.count(), 1) tblname = connection.ops.quote_name(ObjectB._meta.db_table) self.assertTrue(' LEFT OUTER JOIN %s' % tblname in str(qs.query)) class ForeignKeyToBaseExcludeTests(TestCase): def test_ticket_21787(self): sc1 = SpecialCategory.objects.create(special_name='sc1', name='sc1') sc2 = SpecialCategory.objects.create(special_name='sc2', name='sc2') sc3 = SpecialCategory.objects.create(special_name='sc3', name='sc3') c1 = CategoryItem.objects.create(category=sc1) CategoryItem.objects.create(category=sc2) self.assertQuerysetEqual( SpecialCategory.objects.exclude( categoryitem__id=c1.pk).order_by('name'), [sc2, sc3], lambda x: x ) self.assertQuerysetEqual( SpecialCategory.objects.filter(categoryitem__id=c1.pk), [sc1], lambda x: x ) class ReverseM2MCustomPkTests(TestCase): def test_ticket_21879(self): cpt1 = CustomPkTag.objects.create(id='cpt1', tag='cpt1') cp1 = CustomPk.objects.create(name='cp1', extra='extra') cp1.custompktag_set.add(cpt1) self.assertQuerysetEqual( CustomPk.objects.filter(custompktag=cpt1), [cp1], lambda x: x) self.assertQuerysetEqual( CustomPkTag.objects.filter(custom_pk=cp1), [cpt1], lambda x: x) class Ticket22429Tests(TestCase): def test_ticket_22429(self): sc1 = School.objects.create() st1 = Student.objects.create(school=sc1) sc2 = School.objects.create() st2 = Student.objects.create(school=sc2) cr = Classroom.objects.create(school=sc1) cr.students.add(st1) queryset = Student.objects.filter(~Q(classroom__school=F('school'))) self.assertQuerysetEqual(queryset, [st2], lambda x: x) class Ticket23605Tests(TestCase): def test_ticket_23605(self): # Test filtering on a complicated q-object from ticket's report. # The query structure is such that we have multiple nested subqueries. # The original problem was that the inner queries weren't relabeled # correctly. a1 = Ticket23605A.objects.create() a2 = Ticket23605A.objects.create() c1 = Ticket23605C.objects.create(field_c0=10000.0) Ticket23605B.objects.create( field_b0=10000.0, field_b1=True, modelc_fk=c1, modela_fk=a1) complex_q = Q(pk__in=Ticket23605A.objects.filter( Q( # True for a1 as field_b0 = 10000, field_c0=10000 # False for a2 as no ticket23605b found ticket23605b__field_b0__gte=1000000 / F("ticket23605b__modelc_fk__field_c0") ) & # True for a1 (field_b1=True) Q(ticket23605b__field_b1=True) & ~Q(ticket23605b__pk__in=Ticket23605B.objects.filter( ~( # Same filters as above commented filters, but # double-negated (one for Q() above, one for # parentheses). So, again a1 match, a2 not. Q(field_b1=True) & Q(field_b0__gte=1000000 / F("modelc_fk__field_c0")) ) ))).filter(ticket23605b__field_b1=True)) qs1 = Ticket23605A.objects.filter(complex_q) self.assertQuerysetEqual(qs1, [a1], lambda x: x) qs2 = Ticket23605A.objects.exclude(complex_q) self.assertQuerysetEqual(qs2, [a2], lambda x: x) class TestTicket24605(TestCase): def test_ticket_24605(self): """ Subquery table names should be quoted. """ i1 = Individual.objects.create(alive=True) RelatedIndividual.objects.create(related=i1) i2 = Individual.objects.create(alive=False) RelatedIndividual.objects.create(related=i2) i3 = Individual.objects.create(alive=True) i4 = Individual.objects.create(alive=False) self.assertQuerysetEqual( Individual.objects.filter(Q(alive=False), Q(related_individual__isnull=True)), [i4], lambda x: x ) self.assertQuerysetEqual( Individual.objects.exclude( Q(alive=False), Q(related_individual__isnull=True) ).order_by('pk'), [i1, i2, i3], lambda x: x )
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 5927, 199, 646, 2882, 199, 646, 3598, 199, 504, 5055, 492, 8773, 199, 504, 4182, 492, 21829, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 697, 492, 6186, 63, 2846, 63, 12644, 12, 1950, 199, 504, 1639, 14, 697, 14, 992, 492, 481, 12, 1413, 12, 14826, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 23004, 492, 9630, 21722, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 4509, 492, 18414, 2127, 1716, 12, 20550, 1716, 12, 17685, 1716, 199, 504, 1639, 14, 396, 492, 7640, 12, 3372, 5524, 18093, 199, 504, 1639, 14, 396, 14, 1208, 492, 29828, 13611, 2998, 12, 620, 63, 1861, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 1425, 199, 199, 504, 1275, 992, 492, 334, 272, 18821, 17, 12, 1323, 12, 30793, 12, 8281, 12, 6529, 12, 3523, 33, 12, 8944, 12, 13573, 2081, 12, 272, 13573, 21096, 12, 445, 8081, 9660, 369, 12, 17270, 12, 2799, 4185, 12, 12988, 12, 8089, 11245, 12, 272, 15878, 12, 1849, 422, 12, 8388, 29619, 12, 8388, 29619, 1931, 12, 13302, 12, 577, 4295, 7841, 12, 662, 323, 78, 12, 272, 662, 311, 7775, 12, 11177, 2354, 12, 481, 290, 12, 481, 23521, 12, 23285, 12, 1010, 15067, 12, 7020, 12, 15057, 12, 272, 15057, 1322, 678, 23422, 12, 25733, 12, 27836, 33, 12, 27836, 34, 12, 18175, 56, 12, 18175, 58, 12, 4688, 6028, 1685, 12, 272, 14409, 12, 5822, 33, 12, 5822, 34, 12, 5822, 35, 12, 5822, 36, 12, 4932, 1692, 12, 16198, 7841, 12, 5013, 12, 272, 3390, 12, 12119, 461, 985, 12, 4860, 12, 6935, 33, 12, 6935, 34, 12, 6935, 35, 12, 7309, 10939, 7841, 12, 272, 9240, 12, 9240, 2081, 12, 10331, 12, 2235, 7109, 12, 8028, 12, 16527, 2127, 12, 28833, 33, 12, 18841, 12, 272, 12373, 7841, 12, 31536, 316, 12, 20116, 12, 20116, 28604, 12, 20116, 1692, 12, 11774, 12, 272, 5702, 985, 12, 3591, 678, 4783, 12, 428, 15089, 12, 23752, 3225, 12, 5870, 7841, 12, 272, 13050, 1692, 12, 12568, 7841, 12, 25910, 12, 25910, 1899, 12, 17246, 12, 8053, 12, 8495, 12, 272, 21932, 11722, 1644, 3493, 12, 21932, 11722, 1644, 6652, 12, 21932, 10008, 1717, 33, 12, 21932, 10008, 1717, 34, 12, 272, 21932, 10008, 1717, 35, 12, 377, 86, 20335, 70, 12, 4821, 12, 199, 9, 421, 199, 533, 3523, 6940, 774, 8, 1746, 304, 272, 347, 702, 1110, 7072, 8, 277, 12, 6377, 12, 1338, 304, 267, 372, 291, 14, 7108, 8, 6177, 12, 1338, 12, 5793, 29, 2734, 671, 26, 671, 9, 421, 199, 533, 5843, 5460, 17, 2925, 8, 1563, 6940, 774, 304, 272, 347, 3613, 8, 277, 304, 267, 7809, 275, 16198, 7841, 14, 1462, 14, 981, 8, 354, 628, 9417, 531, 267, 291, 14, 84, 17, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 17, 297, 4637, 29, 6767, 9, 267, 291, 14, 84, 18, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 18, 297, 1676, 29, 277, 14, 84, 17, 12, 4637, 29, 6767, 9, 267, 291, 14, 84, 19, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 19, 297, 1676, 29, 277, 14, 84, 17, 9, 267, 307, 20, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 20, 297, 1676, 29, 277, 14, 84, 19, 9, 267, 291, 14, 84, 21, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 21, 297, 1676, 29, 277, 14, 84, 19, 9, 398, 291, 14, 78, 17, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 17, 297, 18576, 534, 1421, 297, 1305, 29, 17, 9, 267, 302, 18, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 18, 297, 18576, 534, 1700, 297, 1305, 29, 18, 9, 267, 291, 14, 78, 19, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 19, 297, 18576, 534, 1421, 297, 1305, 29, 19, 9, 398, 21172, 17, 275, 30793, 14, 1462, 14, 981, 8, 354, 534, 65, 17, 297, 1947, 29, 277, 14, 84, 17, 9, 267, 21172, 17, 14, 5983, 14, 525, 8, 277, 14, 78, 17, 9, 267, 21172, 18, 275, 30793, 14, 1462, 14, 981, 8, 354, 534, 65, 18, 297, 1947, 29, 84, 20, 9, 267, 21172, 18, 14, 5983, 14, 525, 8, 78, 18, 12, 291, 14, 78, 19, 9, 398, 327, 2790, 3520, 734, 402, 1865, 880, 626, 13351, 701, 283, 344, 7, 911, 506, 3365, 370, 13351, 267, 327, 701, 283, 815, 1370, 869, 352, 1190, 9696, 2005, 8826, 2945, 14, 267, 291, 14, 69, 18, 275, 11177, 2354, 14, 1462, 14, 981, 8, 815, 534, 69, 18, 297, 5317, 29, 78, 18, 12, 574, 29, 2953, 9, 267, 325, 17, 275, 11177, 2354, 14, 1462, 14, 981, 8, 815, 534, 69, 17, 297, 5317, 29, 277, 14, 78, 17, 12, 574, 29, 2260, 9, 398, 291, 14, 65, 17, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 17, 297, 1967, 29, 22167, 12, 2402, 29, 69, 17, 9, 267, 291, 14, 65, 18, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 18, 297, 1967, 29, 15135, 12, 2402, 29, 69, 17, 9, 267, 282, 19, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 19, 297, 1967, 29, 5863, 19, 12, 2402, 29, 277, 14, 69, 18, 9, 267, 291, 14, 65, 20, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 20, 297, 1967, 29, 5303, 20, 12, 2402, 29, 277, 14, 69, 18, 9, 398, 291, 14, 521, 17, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 5851, 12, 6928, 12, 5661, 12, 378, 9, 267, 291, 14, 521, 18, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 5851, 12, 7829, 12, 378, 12, 378, 9, 267, 900, 19, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 3388, 12, 6928, 12, 5661, 12, 378, 9, 267, 900, 20, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 3388, 12, 7829, 12 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 5927, 199, 646, 2882, 199, 646, 3598, 199, 504, 5055, 492, 8773, 199, 504, 4182, 492, 21829, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 697, 492, 6186, 63, 2846, 63, 12644, 12, 1950, 199, 504, 1639, 14, 697, 14, 992, 492, 481, 12, 1413, 12, 14826, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 23004, 492, 9630, 21722, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 4509, 492, 18414, 2127, 1716, 12, 20550, 1716, 12, 17685, 1716, 199, 504, 1639, 14, 396, 492, 7640, 12, 3372, 5524, 18093, 199, 504, 1639, 14, 396, 14, 1208, 492, 29828, 13611, 2998, 12, 620, 63, 1861, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 1425, 199, 199, 504, 1275, 992, 492, 334, 272, 18821, 17, 12, 1323, 12, 30793, 12, 8281, 12, 6529, 12, 3523, 33, 12, 8944, 12, 13573, 2081, 12, 272, 13573, 21096, 12, 445, 8081, 9660, 369, 12, 17270, 12, 2799, 4185, 12, 12988, 12, 8089, 11245, 12, 272, 15878, 12, 1849, 422, 12, 8388, 29619, 12, 8388, 29619, 1931, 12, 13302, 12, 577, 4295, 7841, 12, 662, 323, 78, 12, 272, 662, 311, 7775, 12, 11177, 2354, 12, 481, 290, 12, 481, 23521, 12, 23285, 12, 1010, 15067, 12, 7020, 12, 15057, 12, 272, 15057, 1322, 678, 23422, 12, 25733, 12, 27836, 33, 12, 27836, 34, 12, 18175, 56, 12, 18175, 58, 12, 4688, 6028, 1685, 12, 272, 14409, 12, 5822, 33, 12, 5822, 34, 12, 5822, 35, 12, 5822, 36, 12, 4932, 1692, 12, 16198, 7841, 12, 5013, 12, 272, 3390, 12, 12119, 461, 985, 12, 4860, 12, 6935, 33, 12, 6935, 34, 12, 6935, 35, 12, 7309, 10939, 7841, 12, 272, 9240, 12, 9240, 2081, 12, 10331, 12, 2235, 7109, 12, 8028, 12, 16527, 2127, 12, 28833, 33, 12, 18841, 12, 272, 12373, 7841, 12, 31536, 316, 12, 20116, 12, 20116, 28604, 12, 20116, 1692, 12, 11774, 12, 272, 5702, 985, 12, 3591, 678, 4783, 12, 428, 15089, 12, 23752, 3225, 12, 5870, 7841, 12, 272, 13050, 1692, 12, 12568, 7841, 12, 25910, 12, 25910, 1899, 12, 17246, 12, 8053, 12, 8495, 12, 272, 21932, 11722, 1644, 3493, 12, 21932, 11722, 1644, 6652, 12, 21932, 10008, 1717, 33, 12, 21932, 10008, 1717, 34, 12, 272, 21932, 10008, 1717, 35, 12, 377, 86, 20335, 70, 12, 4821, 12, 199, 9, 421, 199, 533, 3523, 6940, 774, 8, 1746, 304, 272, 347, 702, 1110, 7072, 8, 277, 12, 6377, 12, 1338, 304, 267, 372, 291, 14, 7108, 8, 6177, 12, 1338, 12, 5793, 29, 2734, 671, 26, 671, 9, 421, 199, 533, 5843, 5460, 17, 2925, 8, 1563, 6940, 774, 304, 272, 347, 3613, 8, 277, 304, 267, 7809, 275, 16198, 7841, 14, 1462, 14, 981, 8, 354, 628, 9417, 531, 267, 291, 14, 84, 17, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 17, 297, 4637, 29, 6767, 9, 267, 291, 14, 84, 18, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 18, 297, 1676, 29, 277, 14, 84, 17, 12, 4637, 29, 6767, 9, 267, 291, 14, 84, 19, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 19, 297, 1676, 29, 277, 14, 84, 17, 9, 267, 307, 20, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 20, 297, 1676, 29, 277, 14, 84, 19, 9, 267, 291, 14, 84, 21, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 21, 297, 1676, 29, 277, 14, 84, 19, 9, 398, 291, 14, 78, 17, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 17, 297, 18576, 534, 1421, 297, 1305, 29, 17, 9, 267, 302, 18, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 18, 297, 18576, 534, 1700, 297, 1305, 29, 18, 9, 267, 291, 14, 78, 19, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 19, 297, 18576, 534, 1421, 297, 1305, 29, 19, 9, 398, 21172, 17, 275, 30793, 14, 1462, 14, 981, 8, 354, 534, 65, 17, 297, 1947, 29, 277, 14, 84, 17, 9, 267, 21172, 17, 14, 5983, 14, 525, 8, 277, 14, 78, 17, 9, 267, 21172, 18, 275, 30793, 14, 1462, 14, 981, 8, 354, 534, 65, 18, 297, 1947, 29, 84, 20, 9, 267, 21172, 18, 14, 5983, 14, 525, 8, 78, 18, 12, 291, 14, 78, 19, 9, 398, 327, 2790, 3520, 734, 402, 1865, 880, 626, 13351, 701, 283, 344, 7, 911, 506, 3365, 370, 13351, 267, 327, 701, 283, 815, 1370, 869, 352, 1190, 9696, 2005, 8826, 2945, 14, 267, 291, 14, 69, 18, 275, 11177, 2354, 14, 1462, 14, 981, 8, 815, 534, 69, 18, 297, 5317, 29, 78, 18, 12, 574, 29, 2953, 9, 267, 325, 17, 275, 11177, 2354, 14, 1462, 14, 981, 8, 815, 534, 69, 17, 297, 5317, 29, 277, 14, 78, 17, 12, 574, 29, 2260, 9, 398, 291, 14, 65, 17, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 17, 297, 1967, 29, 22167, 12, 2402, 29, 69, 17, 9, 267, 291, 14, 65, 18, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 18, 297, 1967, 29, 15135, 12, 2402, 29, 69, 17, 9, 267, 282, 19, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 19, 297, 1967, 29, 5863, 19, 12, 2402, 29, 277, 14, 69, 18, 9, 267, 291, 14, 65, 20, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 20, 297, 1967, 29, 5303, 20, 12, 2402, 29, 277, 14, 69, 18, 9, 398, 291, 14, 521, 17, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 5851, 12, 6928, 12, 5661, 12, 378, 9, 267, 291, 14, 521, 18, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 5851, 12, 7829, 12, 378, 12, 378, 9, 267, 900, 19, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 3388, 12, 6928, 12, 5661, 12, 378, 9, 267, 900, 20, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 3388, 12, 7829, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
albertomurillo/ansible
test/units/modules/network/routeros/routeros_module.py
52
2521
# (c) 2016 Red Hat Inc. # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os import json from units.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') fixture_data = {} def load_fixture(name): path = os.path.join(fixture_path, name) if path in fixture_data: return fixture_data[path] with open(path) as f: data = f.read() try: data = json.loads(data) except Exception: pass fixture_data[path] = data return data class TestRouterosModule(ModuleTestCase): def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False): self.load_fixtures(commands) if failed: result = self.failed() self.assertTrue(result['failed'], result) else: result = self.changed(changed) self.assertEqual(result['changed'], changed, result) if commands is not None: if sort: self.assertEqual(sorted(commands), sorted(result['commands']), result['commands']) else: self.assertEqual(commands, result['commands'], result['commands']) return result def failed(self): with self.assertRaises(AnsibleFailJson) as exc: self.module.main() result = exc.exception.args[0] self.assertTrue(result['failed'], result) return result def changed(self, changed=False): with self.assertRaises(AnsibleExitJson) as exc: self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], changed, result) return result def load_fixtures(self, commands=None): pass
gpl-3.0
[ 3, 334, 67, 9, 7800, 9572, 13002, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 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, 646, 747, 199, 646, 2022, 199, 199, 504, 6204, 14, 3112, 14, 1208, 492, 2622, 6699, 9653, 12, 2622, 4874, 9653, 12, 5673, 1746, 421, 199, 5997, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 199, 5997, 63, 576, 275, 1052, 421, 199, 318, 2248, 63, 5997, 8, 354, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 5997, 63, 515, 12, 536, 9, 339, 340, 931, 315, 10949, 63, 576, 26, 267, 372, 10949, 63, 576, 59, 515, 61, 339, 543, 1551, 8, 515, 9, 465, 289, 26, 267, 666, 275, 289, 14, 739, 342, 339, 862, 26, 267, 666, 275, 2022, 14, 3640, 8, 576, 9, 272, 871, 2186, 26, 267, 986, 339, 10949, 63, 576, 59, 515, 61, 275, 666, 272, 372, 666, 421, 199, 533, 1379, 7161, 4796, 2377, 8, 2377, 1746, 304, 339, 347, 5341, 63, 578, 8, 277, 12, 3405, 29, 797, 12, 2896, 29, 797, 12, 3718, 29, 403, 12, 4069, 29, 549, 12, 4243, 29, 797, 304, 398, 291, 14, 912, 63, 8769, 8, 4405, 9, 398, 340, 3405, 26, 288, 754, 275, 291, 14, 4892, 342, 288, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 587, 26, 288, 754, 275, 291, 14, 2489, 8, 2489, 9, 288, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 398, 340, 3718, 365, 440, 488, 26, 288, 340, 4069, 26, 355, 291, 14, 629, 8, 5917, 8, 4405, 395, 3355, 8, 1099, 459, 4405, 3815, 754, 459, 4405, 1105, 288, 587, 26, 355, 291, 14, 629, 8, 4405, 12, 754, 459, 4405, 995, 754, 459, 4405, 1105, 398, 372, 754, 339, 347, 3405, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 10047, 4874, 9653, 9, 465, 3178, 26, 288, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 372, 754, 339, 347, 2896, 8, 277, 12, 2896, 29, 797, 304, 267, 543, 291, 14, 1855, 8, 10047, 6699, 9653, 9, 465, 3178, 26, 288, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 267, 372, 754, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 334, 67, 9, 7800, 9572, 13002, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 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, 646, 747, 199, 646, 2022, 199, 199, 504, 6204, 14, 3112, 14, 1208, 492, 2622, 6699, 9653, 12, 2622, 4874, 9653, 12, 5673, 1746, 421, 199, 5997, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 199, 5997, 63, 576, 275, 1052, 421, 199, 318, 2248, 63, 5997, 8, 354, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 5997, 63, 515, 12, 536, 9, 339, 340, 931, 315, 10949, 63, 576, 26, 267, 372, 10949, 63, 576, 59, 515, 61, 339, 543, 1551, 8, 515, 9, 465, 289, 26, 267, 666, 275, 289, 14, 739, 342, 339, 862, 26, 267, 666, 275, 2022, 14, 3640, 8, 576, 9, 272, 871, 2186, 26, 267, 986, 339, 10949, 63, 576, 59, 515, 61, 275, 666, 272, 372, 666, 421, 199, 533, 1379, 7161, 4796, 2377, 8, 2377, 1746, 304, 339, 347, 5341, 63, 578, 8, 277, 12, 3405, 29, 797, 12, 2896, 29, 797, 12, 3718, 29, 403, 12, 4069, 29, 549, 12, 4243, 29, 797, 304, 398, 291, 14, 912, 63, 8769, 8, 4405, 9, 398, 340, 3405, 26, 288, 754, 275, 291, 14, 4892, 342, 288, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 587, 26, 288, 754, 275, 291, 14, 2489, 8, 2489, 9, 288, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 398, 340, 3718, 365, 440, 488, 26, 288, 340, 4069, 26, 355, 291, 14, 629, 8, 5917, 8, 4405, 395, 3355, 8, 1099, 459, 4405, 3815, 754, 459, 4405, 1105, 288, 587, 26, 355, 291, 14, 629, 8, 4405, 12, 754, 459, 4405, 995, 754, 459, 4405, 1105, 398, 372, 754, 339, 347, 3405, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 10047, 4874, 9653, 9, 465, 3178, 26, 288, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 372, 754, 339, 347, 2896, 8, 277, 12, 2896, 29, 797, 304, 267, 543, 291, 14, 1855, 8, 10047, 6699, 9653, 9, 465, 3178, 26, 288, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 267, 372, 754, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shahar-stratoscale/nova
nova/api/ec2/inst_state.py
103
1486
# Copyright 2011 Isaku Yamahata <yamahata at valinux co jp> # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. PENDING_CODE = 0 RUNNING_CODE = 16 SHUTTING_DOWN_CODE = 32 TERMINATED_CODE = 48 STOPPING_CODE = 64 STOPPED_CODE = 80 PENDING = 'pending' RUNNING = 'running' SHUTTING_DOWN = 'shutting-down' TERMINATED = 'terminated' STOPPING = 'stopping' STOPPED = 'stopped' # non-ec2 value MIGRATE = 'migrate' RESIZE = 'resize' PAUSE = 'pause' SUSPEND = 'suspend' RESCUE = 'rescue' # EC2 API instance status code _NAME_TO_CODE = { PENDING: PENDING_CODE, RUNNING: RUNNING_CODE, SHUTTING_DOWN: SHUTTING_DOWN_CODE, TERMINATED: TERMINATED_CODE, STOPPING: STOPPING_CODE, STOPPED: STOPPED_CODE, # approximation MIGRATE: RUNNING_CODE, RESIZE: RUNNING_CODE, PAUSE: STOPPED_CODE, SUSPEND: STOPPED_CODE, RESCUE: RUNNING_CODE, } def name_to_code(name): return _NAME_TO_CODE.get(name, PENDING_CODE)
apache-2.0
[ 3, 1898, 7760, 6596, 1151, 85, 1488, 14541, 72, 419, 665, 11552, 391, 72, 419, 737, 1139, 7226, 512, 28921, 30, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 21243, 63, 6012, 275, 378, 199, 17305, 63, 6012, 275, 3193, 199, 24340, 52, 1206, 63, 8819, 63, 6012, 275, 4337, 199, 28376, 6989, 63, 6012, 275, 9615, 199, 11632, 15675, 63, 6012, 275, 5049, 199, 11632, 19359, 63, 6012, 275, 5939, 199, 199, 21243, 275, 283, 6455, 7, 199, 17305, 275, 283, 5720, 7, 199, 24340, 52, 1206, 63, 8819, 275, 283, 609, 337, 1337, 13, 2110, 7, 199, 28376, 6989, 275, 283, 18375, 7, 199, 11632, 15675, 275, 283, 2379, 4073, 7, 199, 11632, 19359, 275, 283, 14661, 7, 199, 199, 3, 2222, 13, 825, 18, 574, 199, 22487, 16553, 275, 283, 8462, 7, 199, 3830, 11025, 275, 283, 8709, 7, 199, 8470, 4701, 275, 283, 11241, 7, 199, 51, 28011, 3902, 275, 283, 14480, 7, 199, 3830, 35, 4187, 275, 283, 23435, 7, 199, 199, 3, 15352, 18, 3261, 1256, 2004, 1233, 199, 63, 2339, 63, 2566, 63, 6012, 275, 469, 272, 510, 15219, 26, 510, 15219, 63, 6012, 12, 272, 21277, 6024, 26, 21277, 6024, 63, 6012, 12, 272, 4410, 934, 52, 1206, 63, 8819, 26, 4410, 934, 52, 1206, 63, 8819, 63, 6012, 12, 272, 31510, 4896, 6989, 26, 31510, 4896, 6989, 63, 6012, 12, 272, 22348, 15675, 26, 22348, 15675, 63, 6012, 12, 272, 22348, 19359, 26, 22348, 19359, 63, 6012, 12, 339, 327, 22772, 272, 603, 1277, 16553, 26, 21277, 6024, 63, 6012, 12, 272, 12565, 11025, 26, 21277, 6024, 63, 6012, 12, 272, 510, 33, 4701, 26, 22348, 19359, 63, 6012, 12, 272, 428, 28011, 3902, 26, 22348, 19359, 63, 6012, 12, 272, 12565, 35, 4187, 26, 21277, 6024, 63, 6012, 12, 199, 93, 421, 199, 318, 536, 63, 475, 63, 600, 8, 354, 304, 272, 372, 485, 2339, 63, 2566, 63, 6012, 14, 362, 8, 354, 12, 510, 15219, 63, 6012, 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 ]
[ 1898, 7760, 6596, 1151, 85, 1488, 14541, 72, 419, 665, 11552, 391, 72, 419, 737, 1139, 7226, 512, 28921, 30, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 21243, 63, 6012, 275, 378, 199, 17305, 63, 6012, 275, 3193, 199, 24340, 52, 1206, 63, 8819, 63, 6012, 275, 4337, 199, 28376, 6989, 63, 6012, 275, 9615, 199, 11632, 15675, 63, 6012, 275, 5049, 199, 11632, 19359, 63, 6012, 275, 5939, 199, 199, 21243, 275, 283, 6455, 7, 199, 17305, 275, 283, 5720, 7, 199, 24340, 52, 1206, 63, 8819, 275, 283, 609, 337, 1337, 13, 2110, 7, 199, 28376, 6989, 275, 283, 18375, 7, 199, 11632, 15675, 275, 283, 2379, 4073, 7, 199, 11632, 19359, 275, 283, 14661, 7, 199, 199, 3, 2222, 13, 825, 18, 574, 199, 22487, 16553, 275, 283, 8462, 7, 199, 3830, 11025, 275, 283, 8709, 7, 199, 8470, 4701, 275, 283, 11241, 7, 199, 51, 28011, 3902, 275, 283, 14480, 7, 199, 3830, 35, 4187, 275, 283, 23435, 7, 199, 199, 3, 15352, 18, 3261, 1256, 2004, 1233, 199, 63, 2339, 63, 2566, 63, 6012, 275, 469, 272, 510, 15219, 26, 510, 15219, 63, 6012, 12, 272, 21277, 6024, 26, 21277, 6024, 63, 6012, 12, 272, 4410, 934, 52, 1206, 63, 8819, 26, 4410, 934, 52, 1206, 63, 8819, 63, 6012, 12, 272, 31510, 4896, 6989, 26, 31510, 4896, 6989, 63, 6012, 12, 272, 22348, 15675, 26, 22348, 15675, 63, 6012, 12, 272, 22348, 19359, 26, 22348, 19359, 63, 6012, 12, 339, 327, 22772, 272, 603, 1277, 16553, 26, 21277, 6024, 63, 6012, 12, 272, 12565, 11025, 26, 21277, 6024, 63, 6012, 12, 272, 510, 33, 4701, 26, 22348, 19359, 63, 6012, 12, 272, 428, 28011, 3902, 26, 22348, 19359, 63, 6012, 12, 272, 12565, 35, 4187, 26, 21277, 6024, 63, 6012, 12, 199, 93, 421, 199, 318, 536, 63, 475, 63, 600, 8, 354, 304, 272, 372, 485, 2339, 63, 2566, 63, 6012, 14, 362, 8, 354, 12, 510, 15219, 63, 6012, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
poppy-project/pypot
pypot/vrep/__init__.py
1
5778
import json import logging from functools import partial from collections import OrderedDict from .io import (VrepIO, close_all_connections, VrepIOError, VrepConnectionError) from .controller import VrepController, VrepObjectTracker from .controller import VrepCollisionTracker, VrepCollisionDetector from ..robot import Robot from ..robot.sensor import ObjectTracker from ..robot.config import motor_from_confignode, make_alias import pypot.utils.pypot_time as pypot_time import time as sys_time logger = logging.getLogger(__name__) class vrep_time(): def __init__(self, vrep_io): self.io = vrep_io def get_time(self, trial=0): t = self.io.get_simulation_current_time() if t == 0: sys_time.sleep(.5) return self.get_time(trial + 1) if trial > 10: raise EnvironmentError('Could not get current simulation time. Make sure the V-REP simulation is running. And that you have added the "time" child script to your scene.') return t def sleep(self, t): if t > 1000: # That's probably due to an error in get_time logger.warning('Big vrep sleep: {}'.format(t)) t = 1 t0 = self.get_time() while (self.get_time() - t0) < t: if self.get_time() < t0: break sys_time.sleep(0.01) def from_vrep(config, vrep_host='127.0.0.1', vrep_port=19997, scene=None, tracked_objects=[], tracked_collisions=[], id=None, shared_vrep_io=None): """ Create a robot from a V-REP instance. :param config: robot configuration (either the path to the json or directly the dictionary) :type config: str or dict :param str vrep_host: host of the V-REP server :param int vrep_port: port of the V-REP server :param str scene: path to the V-REP scene to load and start :param list tracked_objects: list of V-REP dummy object to track :param list tracked_collisions: list of V-REP collision to track :param int id: robot id in simulator (useful when using a scene with multiple robots) :param vrep_io: use an already connected VrepIO (useful when using a scene with multiple robots) :type vrep_io: :class:`~pypot.vrep.io.VrepIO` This function tries to connect to a V-REP instance and expects to find motors with names corresponding as the ones found in the config. .. note:: The :class:`~pypot.robot.robot.Robot` returned will also provide a convenience reset_simulation method which resets the simulation and the robot position to its intial stance. .. note:: Using the same configuration, you should be able to switch from a real to a simulated robot just by switching from :func:`~pypot.robot.config.from_config` to :func:`~pypot.vrep.from_vrep`. For instance:: import json with open('my_config.json') as f: config = json.load(f) from pypot.robot import from_config from pypot.vrep import from_vrep real_robot = from_config(config) simulated_robot = from_vrep(config, '127.0.0.1', 19997, 'poppy.ttt') """ if shared_vrep_io is None: vrep_io = VrepIO(vrep_host, vrep_port) else: vrep_io = shared_vrep_io vreptime = vrep_time(vrep_io) pypot_time.time = vreptime.get_time pypot_time.sleep = vreptime.sleep if isinstance(config, str): with open(config) as f: config = json.load(f, object_pairs_hook=OrderedDict) motors = [motor_from_confignode(config, name) for name in config['motors'].keys()] vc = VrepController(vrep_io, scene, motors, id=id) vc._init_vrep_streaming() sensor_controllers = [] if tracked_objects: sensors = [ObjectTracker(name) for name in tracked_objects] vot = VrepObjectTracker(vrep_io, sensors) sensor_controllers.append(vot) if tracked_collisions: sensors = [VrepCollisionDetector(name) for name in tracked_collisions] vct = VrepCollisionTracker(vrep_io, sensors) sensor_controllers.append(vct) robot = Robot(motor_controllers=[vc], sensor_controllers=sensor_controllers) for m in robot.motors: m.goto_behavior = 'minjerk' init_pos = {m: m.goal_position for m in robot.motors} make_alias(config, robot) def start_simu(): vrep_io.start_simulation() for m, p in init_pos.items(): m.goal_position = p vc.start() if tracked_objects: vot.start() if tracked_collisions: vct.start() while vrep_io.get_simulation_current_time() < 1.: sys_time.sleep(0.1) def stop_simu(): if tracked_objects: vot.stop() if tracked_collisions: vct.stop() vc.stop() vrep_io.stop_simulation() def reset_simu(): stop_simu() sys_time.sleep(0.5) start_simu() robot.start_simulation = start_simu robot.stop_simulation = stop_simu robot.reset_simulation = reset_simu def current_simulation_time(robot): return robot._controllers[0].io.get_simulation_current_time() Robot.current_simulation_time = property(lambda robot: current_simulation_time(robot)) def get_object_position(robot, object, relative_to_object=None): return vrep_io.get_object_position(object, relative_to_object) Robot.get_object_position = partial(get_object_position, robot) def get_object_orientation(robot, object, relative_to_object=None): return vrep_io.get_object_orientation(object, relative_to_object) Robot.get_object_orientation = partial(get_object_orientation, robot) return robot
gpl-3.0
[ 646, 2022, 199, 646, 2050, 199, 199, 504, 9143, 492, 7417, 199, 504, 5055, 492, 8773, 199, 199, 504, 1275, 2308, 492, 334, 54, 1155, 2090, 12, 4002, 63, 452, 63, 7995, 12, 326, 812, 1155, 13760, 12, 812, 1155, 20349, 9, 199, 199, 504, 1275, 5538, 492, 812, 1155, 7506, 12, 812, 1155, 1692, 13652, 199, 504, 1275, 5538, 492, 812, 1155, 2001, 23656, 13652, 12, 812, 1155, 2001, 23656, 24402, 199, 199, 504, 2508, 9751, 492, 820, 17800, 199, 504, 2508, 9751, 14, 8956, 492, 6935, 13652, 199, 504, 2508, 9751, 14, 888, 492, 28496, 63, 504, 63, 888, 932, 12, 1852, 63, 3620, 421, 199, 646, 1134, 14173, 14, 1208, 14, 647, 14173, 63, 521, 465, 1134, 14173, 63, 521, 199, 646, 900, 465, 984, 63, 521, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 373, 1155, 63, 521, 837, 272, 347, 636, 826, 721, 277, 12, 373, 1155, 63, 2308, 304, 267, 291, 14, 2308, 275, 373, 1155, 63, 2308, 339, 347, 664, 63, 521, 8, 277, 12, 16324, 29, 16, 304, 267, 307, 275, 291, 14, 2308, 14, 362, 63, 22930, 63, 1818, 63, 521, 342, 398, 340, 307, 508, 378, 26, 288, 984, 63, 521, 14, 4532, 13417, 21, 9, 288, 372, 291, 14, 362, 63, 521, 8, 14443, 435, 413, 9, 398, 340, 16324, 690, 1616, 26, 288, 746, 25139, 360, 6531, 440, 664, 1453, 17625, 900, 14, 4155, 3238, 314, 812, 13, 22554, 17625, 365, 3879, 14, 6061, 626, 1265, 1172, 3483, 314, 298, 521, 2, 1982, 2884, 370, 2195, 13856, 2659, 398, 372, 307, 339, 347, 9435, 8, 277, 12, 307, 304, 267, 340, 307, 690, 5198, 26, 221, 327, 10314, 1159, 8646, 7037, 370, 376, 1125, 315, 664, 63, 521, 288, 2512, 14, 3764, 360, 7279, 373, 1155, 9435, 26, 9499, 908, 8, 84, 430, 288, 307, 275, 413, 398, 307, 16, 275, 291, 14, 362, 63, 521, 342, 267, 1830, 334, 277, 14, 362, 63, 521, 342, 446, 307, 16, 9, 665, 307, 26, 288, 340, 291, 14, 362, 63, 521, 342, 665, 307, 16, 26, 355, 2059, 288, 984, 63, 521, 14, 4532, 8, 16, 14, 614, 9, 421, 199, 318, 687, 63, 86, 1155, 8, 888, 12, 373, 1155, 63, 1102, 534, 4195, 14, 16, 14, 16, 14, 17, 297, 373, 1155, 63, 719, 29, 7155, 2576, 12, 13856, 29, 403, 12, 1598, 23268, 63, 1462, 6034, 23268, 63, 761, 317, 1356, 6034, 1598, 1305, 29, 403, 12, 5709, 63, 86, 1155, 63, 2308, 29, 403, 304, 272, 408, 2790, 282, 14544, 687, 282, 812, 13, 22554, 1256, 14, 339, 520, 635, 1101, 26, 14544, 2897, 334, 22051, 314, 931, 370, 314, 2022, 503, 5370, 314, 2600, 9, 272, 520, 466, 1101, 26, 620, 503, 1211, 272, 520, 635, 620, 373, 1155, 63, 1102, 26, 1591, 402, 314, 812, 13, 22554, 1654, 272, 520, 635, 1109, 373, 1155, 63, 719, 26, 1844, 402, 314, 812, 13, 22554, 1654, 272, 520, 635, 620, 13856, 26, 931, 370, 314, 812, 13, 22554, 13856, 370, 2248, 436, 1343, 272, 520, 635, 769, 23268, 63, 1462, 26, 769, 402, 812, 13, 22554, 7283, 909, 370, 4426, 272, 520, 635, 769, 23268, 63, 761, 317, 1356, 26, 769, 402, 812, 13, 22554, 25061, 370, 4426, 272, 520, 635, 1109, 1305, 26, 14544, 1305, 315, 15797, 334, 1180, 1893, 1380, 1808, 282, 13856, 543, 3663, 14544, 83, 9, 272, 520, 635, 373, 1155, 63, 2308, 26, 675, 376, 2575, 8539, 812, 1155, 2090, 334, 1180, 1893, 1380, 1808, 282, 13856, 543, 3663, 14544, 83, 9, 272, 520, 466, 373, 1155, 63, 2308, 26, 520, 533, 6054, 647, 14173, 14, 86, 1155, 14, 2308, 14, 54, 1155, 2090, 64, 339, 961, 805, 11275, 370, 4907, 370, 282, 812, 13, 22554, 1256, 436, 14292, 370, 2342, 333, 357, 1384, 543, 1561, 5226, 465, 314, 7869, 1911, 315, 314, 1101, 14, 339, 2508, 5317, 447, 710, 520, 533, 6054, 647, 14173, 14, 9751, 14, 9751, 14, 21823, 64, 2138, 911, 2597, 5647, 282, 16777, 5305, 63, 22930, 1083, 1314, 295, 2193, 314, 17625, 436, 314, 14544, 3421, 370, 2399, 315, 1009, 410, 554, 14, 339, 2508, 5317, 447, 11719, 314, 2011, 2897, 12, 1265, 1077, 506, 7688, 370, 6258, 687, 282, 3363, 370, 282, 4389, 8097, 14544, 2951, 701, 31620, 687, 520, 1532, 6054, 647, 14173, 14, 9751, 14, 888, 14, 504, 63, 888, 64, 370, 520, 1532, 6054, 647, 14173, 14, 86, 1155, 14, 504, 63, 86, 1155, 2313, 267, 2104, 1256, 447, 953, 492, 2022, 953, 543, 1551, 360, 1662, 63, 888, 14, 1001, 358, 465, 289, 26, 355, 1101, 275, 2022, 14, 912, 8, 70, 9, 953, 687, 1134, 14173, 14, 9751, 492, 687, 63, 888, 288, 687, 1134, 14173, 14, 86, 1155, 492, 687, 63, 86, 1155, 953, 3363, 63, 9751, 275, 687, 63, 888, 8, 888, 9, 288, 4389, 8097, 63, 9751, 275, 687, 63, 86, 1155, 8, 888, 12, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 9013, 2576, 12, 283, 1935, 647, 14, 6215, 84, 358, 339, 408, 272, 340, 5709, 63, 86, 1155, 63, 2308, 365, 488, 26, 267, 373, 1155, 63, 2308, 275, 812, 1155, 2090, 8, 86, 1155, 63, 1102, 12, 373, 1155, 63, 719, 9, 272, 587, 26, 267, 373, 1155, 63, 2308, 275, 5709, 63, 86, 1155, 63, 2308, 339, 373, 1155, 521, 275, 373, 1155, 63, 521, 8, 86, 1155, 63, 2308, 9, 272, 1134, 14173, 63, 521, 14, 521, 275, 373, 1155, 521, 14, 362, 63, 521, 272, 1134, 14173, 63, 521, 14, 4532, 275, 373, 1155, 521, 14, 4532, 339, 340, 1228, 8, 888, 12, 620, 304, 267, 543, 1551, 8, 888, 9, 465, 289, 26, 288, 1101, 275, 2022, 14, 912, 8, 70, 12, 909, 63, 7322, 63, 3664, 29, 16882, 9, 339, 333, 357, 1384, 275, 359, 27840, 63, 504, 63, 888, 932, 8, 888, 12, 536, 9, 1598, 367, 536, 315, 1101, 459, 30034, 1384, 2278, 1612, 5106, 339, 16548, 275, 812, 1155, 7506, 8, 86, 1155, 63, 2308, 12, 13856, 12, 333, 357, 1384, 12, 1305, 29, 344, 9, 272, 16548, 423, 826, 63, 86 ]
[ 2022, 199, 646, 2050, 199, 199, 504, 9143, 492, 7417, 199, 504, 5055, 492, 8773, 199, 199, 504, 1275, 2308, 492, 334, 54, 1155, 2090, 12, 4002, 63, 452, 63, 7995, 12, 326, 812, 1155, 13760, 12, 812, 1155, 20349, 9, 199, 199, 504, 1275, 5538, 492, 812, 1155, 7506, 12, 812, 1155, 1692, 13652, 199, 504, 1275, 5538, 492, 812, 1155, 2001, 23656, 13652, 12, 812, 1155, 2001, 23656, 24402, 199, 199, 504, 2508, 9751, 492, 820, 17800, 199, 504, 2508, 9751, 14, 8956, 492, 6935, 13652, 199, 504, 2508, 9751, 14, 888, 492, 28496, 63, 504, 63, 888, 932, 12, 1852, 63, 3620, 421, 199, 646, 1134, 14173, 14, 1208, 14, 647, 14173, 63, 521, 465, 1134, 14173, 63, 521, 199, 646, 900, 465, 984, 63, 521, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 373, 1155, 63, 521, 837, 272, 347, 636, 826, 721, 277, 12, 373, 1155, 63, 2308, 304, 267, 291, 14, 2308, 275, 373, 1155, 63, 2308, 339, 347, 664, 63, 521, 8, 277, 12, 16324, 29, 16, 304, 267, 307, 275, 291, 14, 2308, 14, 362, 63, 22930, 63, 1818, 63, 521, 342, 398, 340, 307, 508, 378, 26, 288, 984, 63, 521, 14, 4532, 13417, 21, 9, 288, 372, 291, 14, 362, 63, 521, 8, 14443, 435, 413, 9, 398, 340, 16324, 690, 1616, 26, 288, 746, 25139, 360, 6531, 440, 664, 1453, 17625, 900, 14, 4155, 3238, 314, 812, 13, 22554, 17625, 365, 3879, 14, 6061, 626, 1265, 1172, 3483, 314, 298, 521, 2, 1982, 2884, 370, 2195, 13856, 2659, 398, 372, 307, 339, 347, 9435, 8, 277, 12, 307, 304, 267, 340, 307, 690, 5198, 26, 221, 327, 10314, 1159, 8646, 7037, 370, 376, 1125, 315, 664, 63, 521, 288, 2512, 14, 3764, 360, 7279, 373, 1155, 9435, 26, 9499, 908, 8, 84, 430, 288, 307, 275, 413, 398, 307, 16, 275, 291, 14, 362, 63, 521, 342, 267, 1830, 334, 277, 14, 362, 63, 521, 342, 446, 307, 16, 9, 665, 307, 26, 288, 340, 291, 14, 362, 63, 521, 342, 665, 307, 16, 26, 355, 2059, 288, 984, 63, 521, 14, 4532, 8, 16, 14, 614, 9, 421, 199, 318, 687, 63, 86, 1155, 8, 888, 12, 373, 1155, 63, 1102, 534, 4195, 14, 16, 14, 16, 14, 17, 297, 373, 1155, 63, 719, 29, 7155, 2576, 12, 13856, 29, 403, 12, 1598, 23268, 63, 1462, 6034, 23268, 63, 761, 317, 1356, 6034, 1598, 1305, 29, 403, 12, 5709, 63, 86, 1155, 63, 2308, 29, 403, 304, 272, 408, 2790, 282, 14544, 687, 282, 812, 13, 22554, 1256, 14, 339, 520, 635, 1101, 26, 14544, 2897, 334, 22051, 314, 931, 370, 314, 2022, 503, 5370, 314, 2600, 9, 272, 520, 466, 1101, 26, 620, 503, 1211, 272, 520, 635, 620, 373, 1155, 63, 1102, 26, 1591, 402, 314, 812, 13, 22554, 1654, 272, 520, 635, 1109, 373, 1155, 63, 719, 26, 1844, 402, 314, 812, 13, 22554, 1654, 272, 520, 635, 620, 13856, 26, 931, 370, 314, 812, 13, 22554, 13856, 370, 2248, 436, 1343, 272, 520, 635, 769, 23268, 63, 1462, 26, 769, 402, 812, 13, 22554, 7283, 909, 370, 4426, 272, 520, 635, 769, 23268, 63, 761, 317, 1356, 26, 769, 402, 812, 13, 22554, 25061, 370, 4426, 272, 520, 635, 1109, 1305, 26, 14544, 1305, 315, 15797, 334, 1180, 1893, 1380, 1808, 282, 13856, 543, 3663, 14544, 83, 9, 272, 520, 635, 373, 1155, 63, 2308, 26, 675, 376, 2575, 8539, 812, 1155, 2090, 334, 1180, 1893, 1380, 1808, 282, 13856, 543, 3663, 14544, 83, 9, 272, 520, 466, 373, 1155, 63, 2308, 26, 520, 533, 6054, 647, 14173, 14, 86, 1155, 14, 2308, 14, 54, 1155, 2090, 64, 339, 961, 805, 11275, 370, 4907, 370, 282, 812, 13, 22554, 1256, 436, 14292, 370, 2342, 333, 357, 1384, 543, 1561, 5226, 465, 314, 7869, 1911, 315, 314, 1101, 14, 339, 2508, 5317, 447, 710, 520, 533, 6054, 647, 14173, 14, 9751, 14, 9751, 14, 21823, 64, 2138, 911, 2597, 5647, 282, 16777, 5305, 63, 22930, 1083, 1314, 295, 2193, 314, 17625, 436, 314, 14544, 3421, 370, 2399, 315, 1009, 410, 554, 14, 339, 2508, 5317, 447, 11719, 314, 2011, 2897, 12, 1265, 1077, 506, 7688, 370, 6258, 687, 282, 3363, 370, 282, 4389, 8097, 14544, 2951, 701, 31620, 687, 520, 1532, 6054, 647, 14173, 14, 9751, 14, 888, 14, 504, 63, 888, 64, 370, 520, 1532, 6054, 647, 14173, 14, 86, 1155, 14, 504, 63, 86, 1155, 2313, 267, 2104, 1256, 447, 953, 492, 2022, 953, 543, 1551, 360, 1662, 63, 888, 14, 1001, 358, 465, 289, 26, 355, 1101, 275, 2022, 14, 912, 8, 70, 9, 953, 687, 1134, 14173, 14, 9751, 492, 687, 63, 888, 288, 687, 1134, 14173, 14, 86, 1155, 492, 687, 63, 86, 1155, 953, 3363, 63, 9751, 275, 687, 63, 888, 8, 888, 9, 288, 4389, 8097, 63, 9751, 275, 687, 63, 86, 1155, 8, 888, 12, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 9013, 2576, 12, 283, 1935, 647, 14, 6215, 84, 358, 339, 408, 272, 340, 5709, 63, 86, 1155, 63, 2308, 365, 488, 26, 267, 373, 1155, 63, 2308, 275, 812, 1155, 2090, 8, 86, 1155, 63, 1102, 12, 373, 1155, 63, 719, 9, 272, 587, 26, 267, 373, 1155, 63, 2308, 275, 5709, 63, 86, 1155, 63, 2308, 339, 373, 1155, 521, 275, 373, 1155, 63, 521, 8, 86, 1155, 63, 2308, 9, 272, 1134, 14173, 63, 521, 14, 521, 275, 373, 1155, 521, 14, 362, 63, 521, 272, 1134, 14173, 63, 521, 14, 4532, 275, 373, 1155, 521, 14, 4532, 339, 340, 1228, 8, 888, 12, 620, 304, 267, 543, 1551, 8, 888, 9, 465, 289, 26, 288, 1101, 275, 2022, 14, 912, 8, 70, 12, 909, 63, 7322, 63, 3664, 29, 16882, 9, 339, 333, 357, 1384, 275, 359, 27840, 63, 504, 63, 888, 932, 8, 888, 12, 536, 9, 1598, 367, 536, 315, 1101, 459, 30034, 1384, 2278, 1612, 5106, 339, 16548, 275, 812, 1155, 7506, 8, 86, 1155, 63, 2308, 12, 13856, 12, 333, 357, 1384, 12, 1305, 29, 344, 9, 272, 16548, 423, 826, 63, 86, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mushtaqak/edx-platform
common/djangoapps/student/migrations/0003_auto__add_usertestgroup.py
188
8942
# 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): # Adding model 'UserTestGroup' db.create_table('student_usertestgroup', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('name', self.gf('django.db.models.fields.CharField')(max_length=32, db_index=True)), ('description', self.gf('django.db.models.fields.TextField')(blank=True)), )) db.send_create_signal('student', ['UserTestGroup']) # Adding M2M table for field users on 'UserTestGroup' db.create_table('student_usertestgroup_users', ( ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), ('usertestgroup', models.ForeignKey(orm['student.usertestgroup'], null=False)), ('user', models.ForeignKey(orm['auth.user'], null=False)) )) db.create_unique('student_usertestgroup_users', ['usertestgroup_id', 'user_id']) def backwards(self, orm): # Deleting model 'UserTestGroup' db.delete_table('student_usertestgroup') # Removing M2M table for field users on 'UserTestGroup' db.delete_table('student_usertestgroup_users') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, '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'}) }, 'student.registration': { 'Meta': {'object_name': 'Registration', 'db_table': "'auth_registration'"}, 'activation_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'}) }, 'student.userprofile': { 'Meta': {'object_name': 'UserProfile', 'db_table': "'auth_userprofile'"}, 'courseware': ('django.db.models.fields.CharField', [], {'default': "'course.xml'", 'max_length': '255', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'language': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), 'location': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), 'meta': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'}) }, 'student.usertestgroup': { 'Meta': {'object_name': 'UserTestGroup'}, 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'}), 'users': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.User']", 'db_index': 'True', 'symmetrical': 'False'}) } } complete_apps = ['student']
agpl-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, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 12934, 1402, 283, 1899, 774, 2448, 7, 267, 1592, 14, 981, 63, 1224, 360, 5500, 63, 751, 396, 923, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 354, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 708, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 1802, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 5500, 297, 788, 1899, 774, 2448, 1105, 398, 327, 12934, 603, 18, 45, 1817, 367, 901, 4390, 641, 283, 1899, 774, 2448, 7, 267, 1592, 14, 981, 63, 1224, 360, 5500, 63, 751, 396, 923, 63, 3707, 297, 334, 288, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 5062, 63, 498, 29, 549, 12, 2599, 63, 3966, 29, 549, 1826, 288, 661, 751, 396, 923, 297, 1709, 14, 3190, 8, 1025, 459, 5500, 14, 751, 396, 923, 995, 2973, 29, 797, 1826, 288, 661, 751, 297, 1709, 14, 3190, 8, 1025, 459, 1178, 14, 751, 995, 2973, 29, 797, 430, 267, 5082, 267, 1592, 14, 981, 63, 3235, 360, 5500, 63, 751, 396, 923, 63, 3707, 297, 788, 751, 396, 923, 63, 344, 297, 283, 751, 63, 344, 1105, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 15920, 1402, 283, 1899, 774, 2448, 7, 267, 1592, 14, 1807, 63, 1224, 360, 5500, 63, 751, 396, 923, 358, 398, 327, 29343, 603, 18, 45, 1817, 367, 901, 4390, 641, 283, 1899, 774, 2448, 7, 267, 1592, 14, 1807, 63, 1224, 360, 5500, 63, 751, 396, 923, 63, 3707, 358, 339, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 10254, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 356, 283, 549, 1604, 288, 283, 14584, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 885, 356, 3546, 78, 4662, 283, 988, 63, 1267, 356, 283, 17, 1604, 288, 283, 66, 2641, 806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 388, 19068, 63, 4899, 63, 5427, 63, 835, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 6063, 356, 661, 1176, 63, 23598, 14, 955, 14, 17393, 792, 297, 990, 791, 988, 63, 1267, 356, 283, 18, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 602, 63, 1618, 63, 10907, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 297, 990, 791, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2918, 63, 1450, 63, 1541, 63, 8590, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2123, 63, 374, 1078, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2123, 63, 498, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 708, 297, 283, 2307, 356, 283, 549, 1604, 288, 283, 2123, 63, 1450, 63, 1541, 63, 8590, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 17, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 23628, 356, 661, 1176 ]
[ 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, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 12934, 1402, 283, 1899, 774, 2448, 7, 267, 1592, 14, 981, 63, 1224, 360, 5500, 63, 751, 396, 923, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 354, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 708, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 1802, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 5500, 297, 788, 1899, 774, 2448, 1105, 398, 327, 12934, 603, 18, 45, 1817, 367, 901, 4390, 641, 283, 1899, 774, 2448, 7, 267, 1592, 14, 981, 63, 1224, 360, 5500, 63, 751, 396, 923, 63, 3707, 297, 334, 288, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 5062, 63, 498, 29, 549, 12, 2599, 63, 3966, 29, 549, 1826, 288, 661, 751, 396, 923, 297, 1709, 14, 3190, 8, 1025, 459, 5500, 14, 751, 396, 923, 995, 2973, 29, 797, 1826, 288, 661, 751, 297, 1709, 14, 3190, 8, 1025, 459, 1178, 14, 751, 995, 2973, 29, 797, 430, 267, 5082, 267, 1592, 14, 981, 63, 3235, 360, 5500, 63, 751, 396, 923, 63, 3707, 297, 788, 751, 396, 923, 63, 344, 297, 283, 751, 63, 344, 1105, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 15920, 1402, 283, 1899, 774, 2448, 7, 267, 1592, 14, 1807, 63, 1224, 360, 5500, 63, 751, 396, 923, 358, 398, 327, 29343, 603, 18, 45, 1817, 367, 901, 4390, 641, 283, 1899, 774, 2448, 7, 267, 1592, 14, 1807, 63, 1224, 360, 5500, 63, 751, 396, 923, 63, 3707, 358, 339, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 10254, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 356, 283, 549, 1604, 288, 283, 14584, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 885, 356, 3546, 78, 4662, 283, 988, 63, 1267, 356, 283, 17, 1604, 288, 283, 66, 2641, 806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 388, 19068, 63, 4899, 63, 5427, 63, 835, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 6063, 356, 661, 1176, 63, 23598, 14, 955, 14, 17393, 792, 297, 990, 791, 988, 63, 1267, 356, 283, 18, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 602, 63, 1618, 63, 10907, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 297, 990, 791, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2918, 63, 1450, 63, 1541, 63, 8590, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2123, 63, 374, 1078, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2123, 63, 498, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 708, 297, 283, 2307, 356, 283, 549, 1604, 288, 283, 2123, 63, 1450, 63, 1541, 63, 8590, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 17, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 23628, 356, 661, 1176, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ChrisChinchilla/compose
tests/acceptance/cli_test.py
2
32568
from __future__ import absolute_import import os import shlex import signal import subprocess import time from collections import namedtuple from operator import attrgetter from docker import errors from .. import mock from compose.cli.command import get_project from compose.cli.docker_client import docker_client from compose.container import Container from tests.integration.testcases import DockerClientTestCase from tests.integration.testcases import pull_busybox ProcessResult = namedtuple('ProcessResult', 'stdout stderr') BUILD_CACHE_TEXT = 'Using cache' BUILD_PULL_TEXT = 'Status: Image is up to date for busybox:latest' def start_process(base_dir, options): proc = subprocess.Popen( ['docker-compose'] + options, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=base_dir) print("Running process: %s" % proc.pid) return proc def wait_on_process(proc, returncode=0): stdout, stderr = proc.communicate() if proc.returncode != returncode: print(stderr.decode('utf-8')) assert proc.returncode == returncode return ProcessResult(stdout.decode('utf-8'), stderr.decode('utf-8')) def wait_on_condition(condition, delay=0.1, timeout=5): start_time = time.time() while not condition(): if time.time() - start_time > timeout: raise AssertionError("Timeout: %s" % condition) time.sleep(delay) class ContainerCountCondition(object): def __init__(self, project, expected): self.project = project self.expected = expected def __call__(self): return len(self.project.containers()) == self.expected def __str__(self): return "waiting for counter count == %s" % self.expected class ContainerStateCondition(object): def __init__(self, client, name, running): self.client = client self.name = name self.running = running # State.Running == true def __call__(self): try: container = self.client.inspect_container(self.name) return container['State']['Running'] == self.running except errors.APIError: return False def __str__(self): return "waiting for container to have state %s" % self.expected class CLITestCase(DockerClientTestCase): def setUp(self): super(CLITestCase, self).setUp() self.base_dir = 'tests/fixtures/simple-composefile' def tearDown(self): self.project.kill() self.project.remove_stopped() for container in self.project.containers(stopped=True, one_off=True): container.remove(force=True) super(CLITestCase, self).tearDown() @property def project(self): # Hack: allow project to be overridden if not hasattr(self, '_project'): self._project = get_project(self.base_dir) return self._project def dispatch(self, options, project_options=None, returncode=0): project_options = project_options or [] proc = start_process(self.base_dir, project_options + options) return wait_on_process(proc, returncode=returncode) def test_help(self): old_base_dir = self.base_dir self.base_dir = 'tests/fixtures/no-composefile' result = self.dispatch(['help', 'up'], returncode=1) assert 'Usage: up [options] [SERVICE...]' in result.stderr # self.project.kill() fails during teardown # unless there is a composefile. self.base_dir = old_base_dir def test_ps(self): self.project.get_service('simple').create_container() result = self.dispatch(['ps']) assert 'simplecomposefile_simple_1' in result.stdout def test_ps_default_composefile(self): self.base_dir = 'tests/fixtures/multiple-composefiles' self.dispatch(['up', '-d']) result = self.dispatch(['ps']) self.assertIn('multiplecomposefiles_simple_1', result.stdout) self.assertIn('multiplecomposefiles_another_1', result.stdout) self.assertNotIn('multiplecomposefiles_yetanother_1', result.stdout) def test_ps_alternate_composefile(self): config_path = os.path.abspath( 'tests/fixtures/multiple-composefiles/compose2.yml') self._project = get_project(self.base_dir, [config_path]) self.base_dir = 'tests/fixtures/multiple-composefiles' self.dispatch(['-f', 'compose2.yml', 'up', '-d']) result = self.dispatch(['-f', 'compose2.yml', 'ps']) self.assertNotIn('multiplecomposefiles_simple_1', result.stdout) self.assertNotIn('multiplecomposefiles_another_1', result.stdout) self.assertIn('multiplecomposefiles_yetanother_1', result.stdout) def test_pull(self): result = self.dispatch(['pull']) assert sorted(result.stderr.split('\n'))[1:] == [ 'Pulling another (busybox:latest)...', 'Pulling simple (busybox:latest)...', ] def test_pull_with_digest(self): result = self.dispatch(['-f', 'digest.yml', 'pull']) assert 'Pulling simple (busybox:latest)...' in result.stderr assert ('Pulling digest (busybox@' 'sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b520' '04ee8502d)...') in result.stderr def test_pull_with_ignore_pull_failures(self): result = self.dispatch([ '-f', 'ignore-pull-failures.yml', 'pull', '--ignore-pull-failures']) assert 'Pulling simple (busybox:latest)...' in result.stderr assert 'Pulling another (nonexisting-image:latest)...' in result.stderr assert 'Error: image library/nonexisting-image:latest not found' in result.stderr def test_build_plain(self): self.base_dir = 'tests/fixtures/simple-dockerfile' self.dispatch(['build', 'simple']) result = self.dispatch(['build', 'simple']) assert BUILD_CACHE_TEXT in result.stdout assert BUILD_PULL_TEXT not in result.stdout def test_build_no_cache(self): self.base_dir = 'tests/fixtures/simple-dockerfile' self.dispatch(['build', 'simple']) result = self.dispatch(['build', '--no-cache', 'simple']) assert BUILD_CACHE_TEXT not in result.stdout assert BUILD_PULL_TEXT not in result.stdout def test_build_pull(self): # Make sure we have the latest busybox already pull_busybox(self.client) self.base_dir = 'tests/fixtures/simple-dockerfile' self.dispatch(['build', 'simple'], None) result = self.dispatch(['build', '--pull', 'simple']) assert BUILD_CACHE_TEXT in result.stdout assert BUILD_PULL_TEXT in result.stdout def test_build_no_cache_pull(self): # Make sure we have the latest busybox already pull_busybox(self.client) self.base_dir = 'tests/fixtures/simple-dockerfile' self.dispatch(['build', 'simple']) result = self.dispatch(['build', '--no-cache', '--pull', 'simple']) assert BUILD_CACHE_TEXT not in result.stdout assert BUILD_PULL_TEXT in result.stdout def test_build_failed(self): self.base_dir = 'tests/fixtures/simple-failing-dockerfile' self.dispatch(['build', 'simple'], returncode=1) labels = ["com.docker.compose.test_failing_image=true"] containers = [ Container.from_ps(self.project.client, c) for c in self.project.client.containers( all=True, filters={"label": labels}) ] assert len(containers) == 1 def test_build_failed_forcerm(self): self.base_dir = 'tests/fixtures/simple-failing-dockerfile' self.dispatch(['build', '--force-rm', 'simple'], returncode=1) labels = ["com.docker.compose.test_failing_image=true"] containers = [ Container.from_ps(self.project.client, c) for c in self.project.client.containers( all=True, filters={"label": labels}) ] assert not containers def test_up_detached(self): self.dispatch(['up', '-d']) service = self.project.get_service('simple') another = self.project.get_service('another') self.assertEqual(len(service.containers()), 1) self.assertEqual(len(another.containers()), 1) # Ensure containers don't have stdin and stdout connected in -d mode container, = service.containers() self.assertFalse(container.get('Config.AttachStderr')) self.assertFalse(container.get('Config.AttachStdout')) self.assertFalse(container.get('Config.AttachStdin')) def test_up_attached(self): self.base_dir = 'tests/fixtures/echo-services' result = self.dispatch(['up', '--no-color']) assert 'simple_1 | simple' in result.stdout assert 'another_1 | another' in result.stdout def test_up_without_networking(self): self.require_api_version('1.21') self.base_dir = 'tests/fixtures/links-composefile' self.dispatch(['up', '-d'], None) client = docker_client(version='1.21') networks = client.networks(names=[self.project.name]) self.assertEqual(len(networks), 0) for service in self.project.get_services(): containers = service.containers() self.assertEqual(len(containers), 1) self.assertNotEqual(containers[0].get('Config.Hostname'), service.name) web_container = self.project.get_service('web').containers()[0] self.assertTrue(web_container.get('HostConfig.Links')) def test_up_with_networking(self): self.require_api_version('1.21') self.base_dir = 'tests/fixtures/links-composefile' self.dispatch(['--x-networking', 'up', '-d'], None) client = docker_client(version='1.21') services = self.project.get_services() networks = client.networks(names=[self.project.name]) for n in networks: self.addCleanup(client.remove_network, n['Id']) self.assertEqual(len(networks), 1) self.assertEqual(networks[0]['Driver'], 'bridge') network = client.inspect_network(networks[0]['Id']) self.assertEqual(len(network['Containers']), len(services)) for service in services: containers = service.containers() self.assertEqual(len(containers), 1) self.assertIn(containers[0].id, network['Containers']) web_container = self.project.get_service('web').containers()[0] self.assertFalse(web_container.get('HostConfig.Links')) def test_up_with_links(self): self.base_dir = 'tests/fixtures/links-composefile' self.dispatch(['up', '-d', 'web'], None) web = self.project.get_service('web') db = self.project.get_service('db') console = self.project.get_service('console') self.assertEqual(len(web.containers()), 1) self.assertEqual(len(db.containers()), 1) self.assertEqual(len(console.containers()), 0) def test_up_with_no_deps(self): self.base_dir = 'tests/fixtures/links-composefile' self.dispatch(['up', '-d', '--no-deps', 'web'], None) web = self.project.get_service('web') db = self.project.get_service('db') console = self.project.get_service('console') self.assertEqual(len(web.containers()), 1) self.assertEqual(len(db.containers()), 0) self.assertEqual(len(console.containers()), 0) def test_up_with_force_recreate(self): self.dispatch(['up', '-d'], None) service = self.project.get_service('simple') self.assertEqual(len(service.containers()), 1) old_ids = [c.id for c in service.containers()] self.dispatch(['up', '-d', '--force-recreate'], None) self.assertEqual(len(service.containers()), 1) new_ids = [c.id for c in service.containers()] self.assertNotEqual(old_ids, new_ids) def test_up_with_no_recreate(self): self.dispatch(['up', '-d'], None) service = self.project.get_service('simple') self.assertEqual(len(service.containers()), 1) old_ids = [c.id for c in service.containers()] self.dispatch(['up', '-d', '--no-recreate'], None) self.assertEqual(len(service.containers()), 1) new_ids = [c.id for c in service.containers()] self.assertEqual(old_ids, new_ids) def test_up_with_force_recreate_and_no_recreate(self): self.dispatch( ['up', '-d', '--force-recreate', '--no-recreate'], returncode=1) def test_up_with_timeout(self): self.dispatch(['up', '-d', '-t', '1']) service = self.project.get_service('simple') another = self.project.get_service('another') self.assertEqual(len(service.containers()), 1) self.assertEqual(len(another.containers()), 1) # Ensure containers don't have stdin and stdout connected in -d mode config = service.containers()[0].inspect()['Config'] self.assertFalse(config['AttachStderr']) self.assertFalse(config['AttachStdout']) self.assertFalse(config['AttachStdin']) def test_up_handles_sigint(self): proc = start_process(self.base_dir, ['up', '-t', '2']) wait_on_condition(ContainerCountCondition(self.project, 2)) os.kill(proc.pid, signal.SIGINT) wait_on_condition(ContainerCountCondition(self.project, 0)) def test_up_handles_sigterm(self): proc = start_process(self.base_dir, ['up', '-t', '2']) wait_on_condition(ContainerCountCondition(self.project, 2)) os.kill(proc.pid, signal.SIGTERM) wait_on_condition(ContainerCountCondition(self.project, 0)) def test_run_service_without_links(self): self.base_dir = 'tests/fixtures/links-composefile' self.dispatch(['run', 'console', '/bin/true']) self.assertEqual(len(self.project.containers()), 0) # Ensure stdin/out was open container = self.project.containers(stopped=True, one_off=True)[0] config = container.inspect()['Config'] self.assertTrue(config['AttachStderr']) self.assertTrue(config['AttachStdout']) self.assertTrue(config['AttachStdin']) def test_run_service_with_links(self): self.base_dir = 'tests/fixtures/links-composefile' self.dispatch(['run', 'web', '/bin/true'], None) db = self.project.get_service('db') console = self.project.get_service('console') self.assertEqual(len(db.containers()), 1) self.assertEqual(len(console.containers()), 0) def test_run_with_no_deps(self): self.base_dir = 'tests/fixtures/links-composefile' self.dispatch(['run', '--no-deps', 'web', '/bin/true']) db = self.project.get_service('db') self.assertEqual(len(db.containers()), 0) def test_run_does_not_recreate_linked_containers(self): self.base_dir = 'tests/fixtures/links-composefile' self.dispatch(['up', '-d', 'db']) db = self.project.get_service('db') self.assertEqual(len(db.containers()), 1) old_ids = [c.id for c in db.containers()] self.dispatch(['run', 'web', '/bin/true'], None) self.assertEqual(len(db.containers()), 1) new_ids = [c.id for c in db.containers()] self.assertEqual(old_ids, new_ids) def test_run_without_command(self): self.base_dir = 'tests/fixtures/commands-composefile' self.check_build('tests/fixtures/simple-dockerfile', tag='composetest_test') self.dispatch(['run', 'implicit']) service = self.project.get_service('implicit') containers = service.containers(stopped=True, one_off=True) self.assertEqual( [c.human_readable_command for c in containers], [u'/bin/sh -c echo "success"'], ) self.dispatch(['run', 'explicit']) service = self.project.get_service('explicit') containers = service.containers(stopped=True, one_off=True) self.assertEqual( [c.human_readable_command for c in containers], [u'/bin/true'], ) def test_run_service_with_entrypoint_overridden(self): self.base_dir = 'tests/fixtures/dockerfile_with_entrypoint' name = 'service' self.dispatch(['run', '--entrypoint', '/bin/echo', name, 'helloworld']) service = self.project.get_service(name) container = service.containers(stopped=True, one_off=True)[0] self.assertEqual( shlex.split(container.human_readable_command), [u'/bin/echo', u'helloworld'], ) def test_run_service_with_user_overridden(self): self.base_dir = 'tests/fixtures/user-composefile' name = 'service' user = 'sshd' self.dispatch(['run', '--user={user}'.format(user=user), name], returncode=1) service = self.project.get_service(name) container = service.containers(stopped=True, one_off=True)[0] self.assertEqual(user, container.get('Config.User')) def test_run_service_with_user_overridden_short_form(self): self.base_dir = 'tests/fixtures/user-composefile' name = 'service' user = 'sshd' self.dispatch(['run', '-u', user, name], returncode=1) service = self.project.get_service(name) container = service.containers(stopped=True, one_off=True)[0] self.assertEqual(user, container.get('Config.User')) def test_run_service_with_environement_overridden(self): name = 'service' self.base_dir = 'tests/fixtures/environment-composefile' self.dispatch([ 'run', '-e', 'foo=notbar', '-e', 'allo=moto=bobo', '-e', 'alpha=beta', name, '/bin/true', ]) service = self.project.get_service(name) container = service.containers(stopped=True, one_off=True)[0] # env overriden self.assertEqual('notbar', container.environment['foo']) # keep environement from yaml self.assertEqual('world', container.environment['hello']) # added option from command line self.assertEqual('beta', container.environment['alpha']) # make sure a value with a = don't crash out self.assertEqual('moto=bobo', container.environment['allo']) def test_run_service_without_map_ports(self): # create one off container self.base_dir = 'tests/fixtures/ports-composefile' self.dispatch(['run', '-d', 'simple']) container = self.project.get_service('simple').containers(one_off=True)[0] # get port information port_random = container.get_local_port(3000) port_assigned = container.get_local_port(3001) # close all one off containers we just created container.stop() # check the ports self.assertEqual(port_random, None) self.assertEqual(port_assigned, None) def test_run_service_with_map_ports(self): # create one off container self.base_dir = 'tests/fixtures/ports-composefile' self.dispatch(['run', '-d', '--service-ports', 'simple']) container = self.project.get_service('simple').containers(one_off=True)[0] # get port information port_random = container.get_local_port(3000) port_assigned = container.get_local_port(3001) port_range = container.get_local_port(3002), container.get_local_port(3003) # close all one off containers we just created container.stop() # check the ports self.assertNotEqual(port_random, None) self.assertIn("0.0.0.0", port_random) self.assertEqual(port_assigned, "0.0.0.0:49152") self.assertEqual(port_range[0], "0.0.0.0:49153") self.assertEqual(port_range[1], "0.0.0.0:49154") def test_run_service_with_explicitly_maped_ports(self): # create one off container self.base_dir = 'tests/fixtures/ports-composefile' self.dispatch(['run', '-d', '-p', '30000:3000', '--publish', '30001:3001', 'simple']) container = self.project.get_service('simple').containers(one_off=True)[0] # get port information port_short = container.get_local_port(3000) port_full = container.get_local_port(3001) # close all one off containers we just created container.stop() # check the ports self.assertEqual(port_short, "0.0.0.0:30000") self.assertEqual(port_full, "0.0.0.0:30001") def test_run_service_with_explicitly_maped_ip_ports(self): # create one off container self.base_dir = 'tests/fixtures/ports-composefile' self.dispatch(['run', '-d', '-p', '127.0.0.1:30000:3000', '--publish', '127.0.0.1:30001:3001', 'simple'], None) container = self.project.get_service('simple').containers(one_off=True)[0] # get port information port_short = container.get_local_port(3000) port_full = container.get_local_port(3001) # close all one off containers we just created container.stop() # check the ports self.assertEqual(port_short, "127.0.0.1:30000") self.assertEqual(port_full, "127.0.0.1:30001") def test_run_with_custom_name(self): self.base_dir = 'tests/fixtures/environment-composefile' name = 'the-container-name' self.dispatch(['run', '--name', name, 'service', '/bin/true']) service = self.project.get_service('service') container, = service.containers(stopped=True, one_off=True) self.assertEqual(container.name, name) def test_run_with_networking(self): self.require_api_version('1.21') client = docker_client(version='1.21') self.base_dir = 'tests/fixtures/simple-dockerfile' self.dispatch(['--x-networking', 'run', 'simple', 'true'], None) service = self.project.get_service('simple') container, = service.containers(stopped=True, one_off=True) networks = client.networks(names=[self.project.name]) for n in networks: self.addCleanup(client.remove_network, n['Id']) self.assertEqual(len(networks), 1) self.assertEqual(container.human_readable_command, u'true') def test_run_handles_sigint(self): proc = start_process(self.base_dir, ['run', '-T', 'simple', 'top']) wait_on_condition(ContainerStateCondition( self.project.client, 'simplecomposefile_simple_run_1', running=True)) os.kill(proc.pid, signal.SIGINT) wait_on_condition(ContainerStateCondition( self.project.client, 'simplecomposefile_simple_run_1', running=False)) def test_run_handles_sigterm(self): proc = start_process(self.base_dir, ['run', '-T', 'simple', 'top']) wait_on_condition(ContainerStateCondition( self.project.client, 'simplecomposefile_simple_run_1', running=True)) os.kill(proc.pid, signal.SIGTERM) wait_on_condition(ContainerStateCondition( self.project.client, 'simplecomposefile_simple_run_1', running=False)) def test_rm(self): service = self.project.get_service('simple') service.create_container() service.kill() self.assertEqual(len(service.containers(stopped=True)), 1) self.dispatch(['rm', '--force'], None) self.assertEqual(len(service.containers(stopped=True)), 0) service = self.project.get_service('simple') service.create_container() service.kill() self.assertEqual(len(service.containers(stopped=True)), 1) self.dispatch(['rm', '-f'], None) self.assertEqual(len(service.containers(stopped=True)), 0) def test_stop(self): self.dispatch(['up', '-d'], None) service = self.project.get_service('simple') self.assertEqual(len(service.containers()), 1) self.assertTrue(service.containers()[0].is_running) self.dispatch(['stop', '-t', '1'], None) self.assertEqual(len(service.containers(stopped=True)), 1) self.assertFalse(service.containers(stopped=True)[0].is_running) def test_pause_unpause(self): self.dispatch(['up', '-d'], None) service = self.project.get_service('simple') self.assertFalse(service.containers()[0].is_paused) self.dispatch(['pause'], None) self.assertTrue(service.containers()[0].is_paused) self.dispatch(['unpause'], None) self.assertFalse(service.containers()[0].is_paused) def test_logs_invalid_service_name(self): self.dispatch(['logs', 'madeupname'], returncode=1) def test_kill(self): self.dispatch(['up', '-d'], None) service = self.project.get_service('simple') self.assertEqual(len(service.containers()), 1) self.assertTrue(service.containers()[0].is_running) self.dispatch(['kill'], None) self.assertEqual(len(service.containers(stopped=True)), 1) self.assertFalse(service.containers(stopped=True)[0].is_running) def test_kill_signal_sigstop(self): self.dispatch(['up', '-d'], None) service = self.project.get_service('simple') self.assertEqual(len(service.containers()), 1) self.assertTrue(service.containers()[0].is_running) self.dispatch(['kill', '-s', 'SIGSTOP'], None) self.assertEqual(len(service.containers()), 1) # The container is still running. It has only been paused self.assertTrue(service.containers()[0].is_running) def test_kill_stopped_service(self): self.dispatch(['up', '-d'], None) service = self.project.get_service('simple') self.dispatch(['kill', '-s', 'SIGSTOP'], None) self.assertTrue(service.containers()[0].is_running) self.dispatch(['kill', '-s', 'SIGKILL'], None) self.assertEqual(len(service.containers(stopped=True)), 1) self.assertFalse(service.containers(stopped=True)[0].is_running) def test_restart(self): service = self.project.get_service('simple') container = service.create_container() container.start() started_at = container.dictionary['State']['StartedAt'] self.dispatch(['restart', '-t', '1'], None) container.inspect() self.assertNotEqual( container.dictionary['State']['FinishedAt'], '0001-01-01T00:00:00Z', ) self.assertNotEqual( container.dictionary['State']['StartedAt'], started_at, ) def test_restart_stopped_container(self): service = self.project.get_service('simple') container = service.create_container() container.start() container.kill() self.assertEqual(len(service.containers(stopped=True)), 1) self.dispatch(['restart', '-t', '1'], None) self.assertEqual(len(service.containers(stopped=False)), 1) def test_scale(self): project = self.project self.dispatch(['scale', 'simple=1']) self.assertEqual(len(project.get_service('simple').containers()), 1) self.dispatch(['scale', 'simple=3', 'another=2']) self.assertEqual(len(project.get_service('simple').containers()), 3) self.assertEqual(len(project.get_service('another').containers()), 2) self.dispatch(['scale', 'simple=1', 'another=1']) self.assertEqual(len(project.get_service('simple').containers()), 1) self.assertEqual(len(project.get_service('another').containers()), 1) self.dispatch(['scale', 'simple=1', 'another=1']) self.assertEqual(len(project.get_service('simple').containers()), 1) self.assertEqual(len(project.get_service('another').containers()), 1) self.dispatch(['scale', 'simple=0', 'another=0']) self.assertEqual(len(project.get_service('simple').containers()), 0) self.assertEqual(len(project.get_service('another').containers()), 0) def test_port(self): self.base_dir = 'tests/fixtures/ports-composefile' self.dispatch(['up', '-d'], None) container = self.project.get_service('simple').get_container() def get_port(number): result = self.dispatch(['port', 'simple', str(number)]) return result.stdout.rstrip() self.assertEqual(get_port(3000), container.get_local_port(3000)) self.assertEqual(get_port(3001), "0.0.0.0:49152") self.assertEqual(get_port(3002), "0.0.0.0:49153") def test_port_with_scale(self): self.base_dir = 'tests/fixtures/ports-composefile-scale' self.dispatch(['scale', 'simple=2'], None) containers = sorted( self.project.containers(service_names=['simple']), key=attrgetter('name')) def get_port(number, index=None): if index is None: result = self.dispatch(['port', 'simple', str(number)]) else: result = self.dispatch(['port', '--index=' + str(index), 'simple', str(number)]) return result.stdout.rstrip() self.assertEqual(get_port(3000), containers[0].get_local_port(3000)) self.assertEqual(get_port(3000, index=1), containers[0].get_local_port(3000)) self.assertEqual(get_port(3000, index=2), containers[1].get_local_port(3000)) self.assertEqual(get_port(3002), "") def test_env_file_relative_to_compose_file(self): config_path = os.path.abspath('tests/fixtures/env-file/docker-compose.yml') self.dispatch(['-f', config_path, 'up', '-d'], None) self._project = get_project(self.base_dir, [config_path]) containers = self.project.containers(stopped=True) self.assertEqual(len(containers), 1) self.assertIn("FOO=1", containers[0].get('Config.Env')) @mock.patch.dict(os.environ) def test_home_and_env_var_in_volume_path(self): os.environ['VOLUME_NAME'] = 'my-volume' os.environ['HOME'] = '/tmp/home-dir' self.base_dir = 'tests/fixtures/volume-path-interpolation' self.dispatch(['up', '-d'], None) container = self.project.containers(stopped=True)[0] actual_host_path = container.get('Volumes')['/container-path'] components = actual_host_path.split('/') assert components[-2:] == ['home-dir', 'my-volume'] def test_up_with_default_override_file(self): self.base_dir = 'tests/fixtures/override-files' self.dispatch(['up', '-d'], None) containers = self.project.containers() self.assertEqual(len(containers), 2) web, db = containers self.assertEqual(web.human_readable_command, 'top') self.assertEqual(db.human_readable_command, 'top') def test_up_with_multiple_files(self): self.base_dir = 'tests/fixtures/override-files' config_paths = [ 'docker-compose.yml', 'docker-compose.override.yml', 'extra.yml', ] self._project = get_project(self.base_dir, config_paths) self.dispatch( [ '-f', config_paths[0], '-f', config_paths[1], '-f', config_paths[2], 'up', '-d', ], None) containers = self.project.containers() self.assertEqual(len(containers), 3) web, other, db = containers self.assertEqual(web.human_readable_command, 'top') self.assertTrue({'db', 'other'} <= set(web.links())) self.assertEqual(db.human_readable_command, 'top') self.assertEqual(other.human_readable_command, 'top') def test_up_with_extends(self): self.base_dir = 'tests/fixtures/extends' self.dispatch(['up', '-d'], None) self.assertEqual( set([s.name for s in self.project.services]), set(['mydb', 'myweb']), ) # Sort by name so we get [db, web] containers = sorted( self.project.containers(stopped=True), key=lambda c: c.name, ) self.assertEqual(len(containers), 2) web = containers[1] self.assertEqual(set(web.links()), set(['db', 'mydb_1', 'extends_mydb_1'])) expected_env = set([ "FOO=1", "BAR=2", "BAZ=2", ]) self.assertTrue(expected_env <= set(web.get('Config.Env')))
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 747, 199, 646, 16701, 199, 646, 4673, 199, 646, 3873, 199, 646, 900, 199, 504, 5055, 492, 12863, 199, 504, 4182, 492, 21829, 199, 199, 504, 12424, 492, 2552, 199, 199, 504, 2508, 492, 1683, 199, 504, 23366, 14, 2764, 14, 1531, 492, 664, 63, 1715, 199, 504, 23366, 14, 2764, 14, 9991, 63, 1258, 492, 12424, 63, 1258, 199, 504, 23366, 14, 3600, 492, 15395, 199, 504, 2295, 14, 15092, 14, 396, 9403, 492, 22067, 3041, 1746, 199, 504, 2295, 14, 15092, 14, 396, 9403, 492, 10299, 63, 25265, 1977, 421, 199, 3498, 2889, 275, 12863, 360, 3498, 2889, 297, 283, 2703, 4635, 358, 421, 199, 8248, 63, 8677, 63, 3876, 275, 283, 10369, 2581, 7, 199, 8248, 63, 48, 3785, 63, 3876, 275, 283, 3694, 26, 6047, 365, 1536, 370, 1434, 367, 10414, 89, 1977, 26, 7410, 7, 421, 199, 318, 1343, 63, 1412, 8, 1095, 63, 694, 12, 1511, 304, 272, 6499, 275, 3873, 14, 7942, 8, 267, 788, 9991, 13, 12607, 418, 435, 1511, 12, 267, 3839, 29, 5781, 14, 6089, 12, 267, 4635, 29, 5781, 14, 6089, 12, 267, 8288, 29, 1095, 63, 694, 9, 272, 870, 480, 9602, 2112, 26, 450, 83, 2, 450, 6499, 14, 3150, 9, 272, 372, 6499, 421, 199, 318, 3618, 63, 265, 63, 1412, 8, 4687, 12, 17630, 29, 16, 304, 272, 3839, 12, 4635, 275, 6499, 14, 10664, 342, 272, 340, 6499, 14, 9913, 1137, 17630, 26, 267, 870, 8, 3083, 14, 2708, 360, 1624, 13, 24, 1333, 267, 702, 6499, 14, 9913, 508, 17630, 272, 372, 7132, 2889, 8, 2703, 14, 2708, 360, 1624, 13, 24, 659, 4635, 14, 2708, 360, 1624, 13, 24, 1333, 421, 199, 318, 3618, 63, 265, 63, 5394, 8, 5394, 12, 7339, 29, 16, 14, 17, 12, 2653, 29, 21, 304, 272, 1343, 63, 521, 275, 900, 14, 521, 342, 272, 1830, 440, 5558, 837, 267, 340, 900, 14, 521, 342, 446, 1343, 63, 521, 690, 2653, 26, 288, 746, 9070, 480, 6372, 26, 450, 83, 2, 450, 5558, 9, 267, 900, 14, 4532, 8, 5814, 9, 421, 199, 533, 15395, 2353, 9558, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2199, 12, 1420, 304, 267, 291, 14, 1715, 275, 2199, 267, 291, 14, 2062, 275, 1420, 339, 347, 636, 1250, 721, 277, 304, 267, 372, 822, 8, 277, 14, 1715, 14, 13577, 1012, 508, 291, 14, 2062, 339, 347, 636, 495, 721, 277, 304, 267, 372, 298, 14093, 367, 7055, 2338, 508, 450, 83, 2, 450, 291, 14, 2062, 421, 199, 533, 15395, 2223, 9558, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 536, 12, 3879, 304, 267, 291, 14, 1258, 275, 1890, 267, 291, 14, 354, 275, 536, 267, 291, 14, 5720, 275, 3879, 339, 327, 8511, 14, 9602, 508, 2549, 272, 347, 636, 1250, 721, 277, 304, 267, 862, 26, 288, 3970, 275, 291, 14, 1258, 14, 10955, 63, 3600, 8, 277, 14, 354, 9, 288, 372, 3970, 459, 2223, 2545, 9602, 418, 508, 291, 14, 5720, 267, 871, 2552, 14, 3735, 547, 26, 288, 372, 756, 339, 347, 636, 495, 721, 277, 304, 267, 372, 298, 14093, 367, 3970, 370, 1172, 1174, 450, 83, 2, 450, 291, 14, 2062, 421, 199, 533, 13354, 649, 27309, 8, 31463, 3041, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 1981, 649, 27309, 12, 291, 680, 5996, 342, 267, 291, 14, 1095, 63, 694, 275, 283, 2219, 15, 8769, 15, 4129, 13, 12607, 493, 7, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1715, 14, 8997, 342, 267, 291, 14, 1715, 14, 2168, 63, 14661, 342, 267, 367, 3970, 315, 291, 14, 1715, 14, 13577, 8, 14661, 29, 549, 12, 1373, 63, 1997, 29, 549, 304, 288, 3970, 14, 2168, 8, 3990, 29, 549, 9, 267, 1613, 8, 1981, 649, 27309, 12, 291, 680, 12336, 342, 339, 768, 1829, 272, 347, 2199, 8, 277, 304, 267, 327, 30802, 26, 2040, 2199, 370, 506, 10087, 267, 340, 440, 2688, 8, 277, 12, 2513, 1715, 735, 288, 291, 423, 1715, 275, 664, 63, 1715, 8, 277, 14, 1095, 63, 694, 9, 267, 372, 291, 423, 1715, 339, 347, 7634, 8, 277, 12, 1511, 12, 2199, 63, 1419, 29, 403, 12, 17630, 29, 16, 304, 267, 2199, 63, 1419, 275, 2199, 63, 1419, 503, 942, 267, 6499, 275, 1343, 63, 1412, 8, 277, 14, 1095, 63, 694, 12, 2199, 63, 1419, 435, 1511, 9, 267, 372, 3618, 63, 265, 63, 1412, 8, 4687, 12, 17630, 29, 9913, 9, 339, 347, 511, 63, 3437, 8, 277, 304, 267, 2269, 63, 1095, 63, 694, 275, 291, 14, 1095, 63, 694, 267, 291, 14, 1095, 63, 694, 275, 283, 2219, 15, 8769, 15, 889, 13, 12607, 493, 7, 267, 754, 275, 291, 14, 6052, 2941, 3437, 297, 283, 384, 995, 17630, 29, 17, 9, 267, 702, 283, 7692, 26, 1536, 359, 1419, 61, 359, 10486, 1396, 6616, 315, 754, 14, 3083, 267, 327, 291, 14, 1715, 14, 8997, 342, 6918, 5309, 17558, 267, 327, 7444, 2337, 365, 282, 23366, 493, 14, 267, 291, 14, 1095, 63, 694, 275, 2269, 63, 1095, 63, 694, 339, 347, 511, 63, 1190, 8, 277, 304, 267, 291, 14, 1715, 14, 362, 63, 1364, 360, 4129, 1959, 981, 63, 3600, 342, 267, 754, 275, 291, 14, 6052, 2941, 1190, 1105, 267, 702, 283, 4129, 12607, 493, 63, 4129, 63, 17, 7, 315, 754, 14, 2703, 339, 347, 511, 63, 1190, 63, 885, 63, 12607, 493, 8, 277, 304, 267, 291, 14, 1095, 63, 694, 275, 283, 2219, 15, 8769, 15, 6048, 13, 12607, 1725, 7, 267, 291, 14, 6052, 2941, 384, 297, 2475, 68, 1105, 267, 754, 275, 291, 14, 6052, 2941, 1190, 1105, 398, 291, 14, 4080, 360, 6048, 12607, 1725, 63, 4129, 63, 17, 297, 754, 14, 2703, 9, 267, 291, 14, 4080, 360, 6048, 12607, 1725, 63, 13565, 63, 17, 297, 754, 14, 2703, 9, 267, 291, 14, 8795, 360, 6048, 12607, 1725, 63, 28064, 13565, 63, 17, 297, 754, 14, 2703, 9, 339, 347, 511, 63, 1190, 63, 17170, 63, 12607, 493 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 747, 199, 646, 16701, 199, 646, 4673, 199, 646, 3873, 199, 646, 900, 199, 504, 5055, 492, 12863, 199, 504, 4182, 492, 21829, 199, 199, 504, 12424, 492, 2552, 199, 199, 504, 2508, 492, 1683, 199, 504, 23366, 14, 2764, 14, 1531, 492, 664, 63, 1715, 199, 504, 23366, 14, 2764, 14, 9991, 63, 1258, 492, 12424, 63, 1258, 199, 504, 23366, 14, 3600, 492, 15395, 199, 504, 2295, 14, 15092, 14, 396, 9403, 492, 22067, 3041, 1746, 199, 504, 2295, 14, 15092, 14, 396, 9403, 492, 10299, 63, 25265, 1977, 421, 199, 3498, 2889, 275, 12863, 360, 3498, 2889, 297, 283, 2703, 4635, 358, 421, 199, 8248, 63, 8677, 63, 3876, 275, 283, 10369, 2581, 7, 199, 8248, 63, 48, 3785, 63, 3876, 275, 283, 3694, 26, 6047, 365, 1536, 370, 1434, 367, 10414, 89, 1977, 26, 7410, 7, 421, 199, 318, 1343, 63, 1412, 8, 1095, 63, 694, 12, 1511, 304, 272, 6499, 275, 3873, 14, 7942, 8, 267, 788, 9991, 13, 12607, 418, 435, 1511, 12, 267, 3839, 29, 5781, 14, 6089, 12, 267, 4635, 29, 5781, 14, 6089, 12, 267, 8288, 29, 1095, 63, 694, 9, 272, 870, 480, 9602, 2112, 26, 450, 83, 2, 450, 6499, 14, 3150, 9, 272, 372, 6499, 421, 199, 318, 3618, 63, 265, 63, 1412, 8, 4687, 12, 17630, 29, 16, 304, 272, 3839, 12, 4635, 275, 6499, 14, 10664, 342, 272, 340, 6499, 14, 9913, 1137, 17630, 26, 267, 870, 8, 3083, 14, 2708, 360, 1624, 13, 24, 1333, 267, 702, 6499, 14, 9913, 508, 17630, 272, 372, 7132, 2889, 8, 2703, 14, 2708, 360, 1624, 13, 24, 659, 4635, 14, 2708, 360, 1624, 13, 24, 1333, 421, 199, 318, 3618, 63, 265, 63, 5394, 8, 5394, 12, 7339, 29, 16, 14, 17, 12, 2653, 29, 21, 304, 272, 1343, 63, 521, 275, 900, 14, 521, 342, 272, 1830, 440, 5558, 837, 267, 340, 900, 14, 521, 342, 446, 1343, 63, 521, 690, 2653, 26, 288, 746, 9070, 480, 6372, 26, 450, 83, 2, 450, 5558, 9, 267, 900, 14, 4532, 8, 5814, 9, 421, 199, 533, 15395, 2353, 9558, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2199, 12, 1420, 304, 267, 291, 14, 1715, 275, 2199, 267, 291, 14, 2062, 275, 1420, 339, 347, 636, 1250, 721, 277, 304, 267, 372, 822, 8, 277, 14, 1715, 14, 13577, 1012, 508, 291, 14, 2062, 339, 347, 636, 495, 721, 277, 304, 267, 372, 298, 14093, 367, 7055, 2338, 508, 450, 83, 2, 450, 291, 14, 2062, 421, 199, 533, 15395, 2223, 9558, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 536, 12, 3879, 304, 267, 291, 14, 1258, 275, 1890, 267, 291, 14, 354, 275, 536, 267, 291, 14, 5720, 275, 3879, 339, 327, 8511, 14, 9602, 508, 2549, 272, 347, 636, 1250, 721, 277, 304, 267, 862, 26, 288, 3970, 275, 291, 14, 1258, 14, 10955, 63, 3600, 8, 277, 14, 354, 9, 288, 372, 3970, 459, 2223, 2545, 9602, 418, 508, 291, 14, 5720, 267, 871, 2552, 14, 3735, 547, 26, 288, 372, 756, 339, 347, 636, 495, 721, 277, 304, 267, 372, 298, 14093, 367, 3970, 370, 1172, 1174, 450, 83, 2, 450, 291, 14, 2062, 421, 199, 533, 13354, 649, 27309, 8, 31463, 3041, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 1981, 649, 27309, 12, 291, 680, 5996, 342, 267, 291, 14, 1095, 63, 694, 275, 283, 2219, 15, 8769, 15, 4129, 13, 12607, 493, 7, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1715, 14, 8997, 342, 267, 291, 14, 1715, 14, 2168, 63, 14661, 342, 267, 367, 3970, 315, 291, 14, 1715, 14, 13577, 8, 14661, 29, 549, 12, 1373, 63, 1997, 29, 549, 304, 288, 3970, 14, 2168, 8, 3990, 29, 549, 9, 267, 1613, 8, 1981, 649, 27309, 12, 291, 680, 12336, 342, 339, 768, 1829, 272, 347, 2199, 8, 277, 304, 267, 327, 30802, 26, 2040, 2199, 370, 506, 10087, 267, 340, 440, 2688, 8, 277, 12, 2513, 1715, 735, 288, 291, 423, 1715, 275, 664, 63, 1715, 8, 277, 14, 1095, 63, 694, 9, 267, 372, 291, 423, 1715, 339, 347, 7634, 8, 277, 12, 1511, 12, 2199, 63, 1419, 29, 403, 12, 17630, 29, 16, 304, 267, 2199, 63, 1419, 275, 2199, 63, 1419, 503, 942, 267, 6499, 275, 1343, 63, 1412, 8, 277, 14, 1095, 63, 694, 12, 2199, 63, 1419, 435, 1511, 9, 267, 372, 3618, 63, 265, 63, 1412, 8, 4687, 12, 17630, 29, 9913, 9, 339, 347, 511, 63, 3437, 8, 277, 304, 267, 2269, 63, 1095, 63, 694, 275, 291, 14, 1095, 63, 694, 267, 291, 14, 1095, 63, 694, 275, 283, 2219, 15, 8769, 15, 889, 13, 12607, 493, 7, 267, 754, 275, 291, 14, 6052, 2941, 3437, 297, 283, 384, 995, 17630, 29, 17, 9, 267, 702, 283, 7692, 26, 1536, 359, 1419, 61, 359, 10486, 1396, 6616, 315, 754, 14, 3083, 267, 327, 291, 14, 1715, 14, 8997, 342, 6918, 5309, 17558, 267, 327, 7444, 2337, 365, 282, 23366, 493, 14, 267, 291, 14, 1095, 63, 694, 275, 2269, 63, 1095, 63, 694, 339, 347, 511, 63, 1190, 8, 277, 304, 267, 291, 14, 1715, 14, 362, 63, 1364, 360, 4129, 1959, 981, 63, 3600, 342, 267, 754, 275, 291, 14, 6052, 2941, 1190, 1105, 267, 702, 283, 4129, 12607, 493, 63, 4129, 63, 17, 7, 315, 754, 14, 2703, 339, 347, 511, 63, 1190, 63, 885, 63, 12607, 493, 8, 277, 304, 267, 291, 14, 1095, 63, 694, 275, 283, 2219, 15, 8769, 15, 6048, 13, 12607, 1725, 7, 267, 291, 14, 6052, 2941, 384, 297, 2475, 68, 1105, 267, 754, 275, 291, 14, 6052, 2941, 1190, 1105, 398, 291, 14, 4080, 360, 6048, 12607, 1725, 63, 4129, 63, 17, 297, 754, 14, 2703, 9, 267, 291, 14, 4080, 360, 6048, 12607, 1725, 63, 13565, 63, 17, 297, 754, 14, 2703, 9, 267, 291, 14, 8795, 360, 6048, 12607, 1725, 63, 28064, 13565, 63, 17, 297, 754, 14, 2703, 9, 339, 347, 511, 63, 1190, 63, 17170, 63, 12607, 493, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
childsish/lhc-python
setup.py
1
1367
import os from subprocess import Popen, PIPE from setuptools import setup, find_packages, Extension bitap_extension = Extension( 'lhc.misc.bitap', ['lib/bitap/bitapmodule.cpp', 'lib/bitap/bitap.cpp'], include_dirs=['lib/bitap']) with open('README.rst', encoding='utf-8') if os.path.exists('README.rst') else \ open('README.md', encoding='utf-8') as fileobj: long_description = fileobj.read() prc = Popen(['git', 'describe', '--tags', '--dirty'], stdout=PIPE, cwd=os.path.dirname(os.path.realpath(__file__))) version, _ = prc.communicate() setup( name='lhc-python', version=version.decode(encoding='utf-8').strip(), author='Liam H. Childs', author_email='liam.h.childs@gmail.com', packages=find_packages(exclude=['docs', 'test*']), scripts=[], url='https://github.com/childsish/lhc-python', license='LICENSE.txt', description='My python library of classes and functions that help me work', long_description=long_description, long_description_content_type='text/markdown', install_requires=['sortedcontainers == 2.1.0', 'numpy == 1.18.1', 'pysam == 0.15.4'], classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Science/Research', 'Topic :: Scientific/Engineering :: Bio-Informatics'], ext_modules=[bitap_extension] )
gpl-2.0
[ 646, 747, 199, 199, 504, 3873, 492, 13995, 12, 22773, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 12, 13282, 421, 199, 2075, 439, 63, 3435, 275, 13282, 8, 272, 283, 76, 15907, 14, 9923, 14, 2075, 439, 297, 272, 788, 773, 15, 2075, 439, 15, 2075, 439, 578, 14, 5910, 297, 283, 773, 15, 2075, 439, 15, 2075, 439, 14, 5910, 995, 272, 2387, 63, 3220, 2968, 773, 15, 2075, 439, 1105, 199, 199, 1045, 1551, 360, 18195, 14, 8332, 297, 2644, 534, 1624, 13, 24, 358, 340, 747, 14, 515, 14, 2444, 360, 18195, 14, 8332, 358, 587, 971, 267, 1551, 360, 18195, 14, 1064, 297, 2644, 534, 1624, 13, 24, 358, 465, 11099, 26, 272, 1846, 63, 1802, 275, 11099, 14, 739, 342, 199, 199, 80, 1195, 275, 13995, 2941, 3187, 297, 283, 11935, 297, 2850, 2969, 297, 2850, 8799, 995, 288, 3839, 29, 6089, 12, 288, 8288, 29, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 29658, 199, 1023, 12, 485, 275, 299, 1195, 14, 10664, 342, 199, 199, 2758, 8, 272, 536, 534, 76, 15907, 13, 1548, 297, 272, 1015, 29, 1023, 14, 2708, 8, 2991, 534, 1624, 13, 24, 1959, 1913, 1062, 272, 4132, 534, 13009, 455, 869, 14, 12988, 83, 297, 272, 4132, 63, 2123, 534, 317, 455, 14, 72, 14, 1739, 83, 32, 6799, 14, 957, 297, 272, 6117, 29, 1623, 63, 5154, 8, 5473, 2968, 4757, 297, 283, 396, 10, 3815, 272, 10554, 6034, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 1739, 338, 609, 15, 76, 15907, 13, 1548, 297, 272, 4190, 534, 3961, 14, 2424, 297, 272, 1369, 534, 5713, 2366, 3555, 402, 3992, 436, 3423, 626, 1720, 562, 1736, 297, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 272, 1846, 63, 1802, 63, 1317, 63, 466, 534, 505, 15, 15653, 297, 272, 3907, 63, 6537, 2968, 5917, 13577, 508, 499, 14, 17, 14, 16, 297, 283, 4714, 508, 413, 14, 1085, 14, 17, 297, 283, 15983, 455, 508, 378, 14, 1046, 14, 20, 995, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 841, 446, 29521, 297, 267, 283, 23910, 23975, 3800, 27491, 15, 497, 1733, 297, 267, 283, 12157, 3800, 16578, 23509, 15, 8524, 15663, 3800, 699, 2308, 13, 607, 509, 3889, 83, 995, 272, 1599, 63, 3112, 1524, 2075, 439, 63, 3435, 61, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 199, 504, 3873, 492, 13995, 12, 22773, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 12, 13282, 421, 199, 2075, 439, 63, 3435, 275, 13282, 8, 272, 283, 76, 15907, 14, 9923, 14, 2075, 439, 297, 272, 788, 773, 15, 2075, 439, 15, 2075, 439, 578, 14, 5910, 297, 283, 773, 15, 2075, 439, 15, 2075, 439, 14, 5910, 995, 272, 2387, 63, 3220, 2968, 773, 15, 2075, 439, 1105, 199, 199, 1045, 1551, 360, 18195, 14, 8332, 297, 2644, 534, 1624, 13, 24, 358, 340, 747, 14, 515, 14, 2444, 360, 18195, 14, 8332, 358, 587, 971, 267, 1551, 360, 18195, 14, 1064, 297, 2644, 534, 1624, 13, 24, 358, 465, 11099, 26, 272, 1846, 63, 1802, 275, 11099, 14, 739, 342, 199, 199, 80, 1195, 275, 13995, 2941, 3187, 297, 283, 11935, 297, 2850, 2969, 297, 2850, 8799, 995, 288, 3839, 29, 6089, 12, 288, 8288, 29, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 29658, 199, 1023, 12, 485, 275, 299, 1195, 14, 10664, 342, 199, 199, 2758, 8, 272, 536, 534, 76, 15907, 13, 1548, 297, 272, 1015, 29, 1023, 14, 2708, 8, 2991, 534, 1624, 13, 24, 1959, 1913, 1062, 272, 4132, 534, 13009, 455, 869, 14, 12988, 83, 297, 272, 4132, 63, 2123, 534, 317, 455, 14, 72, 14, 1739, 83, 32, 6799, 14, 957, 297, 272, 6117, 29, 1623, 63, 5154, 8, 5473, 2968, 4757, 297, 283, 396, 10, 3815, 272, 10554, 6034, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 1739, 338, 609, 15, 76, 15907, 13, 1548, 297, 272, 4190, 534, 3961, 14, 2424, 297, 272, 1369, 534, 5713, 2366, 3555, 402, 3992, 436, 3423, 626, 1720, 562, 1736, 297, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 272, 1846, 63, 1802, 63, 1317, 63, 466, 534, 505, 15, 15653, 297, 272, 3907, 63, 6537, 2968, 5917, 13577, 508, 499, 14, 17, 14, 16, 297, 283, 4714, 508, 413, 14, 1085, 14, 17, 297, 283, 15983, 455, 508, 378, 14, 1046, 14, 20, 995, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 841, 446, 29521, 297, 267, 283, 23910, 23975, 3800, 27491, 15, 497, 1733, 297, 267, 283, 12157, 3800, 16578, 23509, 15, 8524, 15663, 3800, 699, 2308, 13, 607, 509, 3889, 83, 995, 272, 1599, 63, 3112, 1524, 2075, 439, 63, 3435, 61, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
realsobek/freeipa
ipatests/test_xmlrpc/tracker/group_plugin.py
4
9655
# # Copyright (C) 2015 FreeIPA Contributors see COPYING for license # from ipatests.test_xmlrpc import objectclasses from ipatests.test_xmlrpc.xmlrpc_test import fuzzy_digits, fuzzy_uuid from ipatests.test_xmlrpc.tracker.base import Tracker from ipatests.util import assert_deepequal, get_group_dn class GroupTracker(Tracker): """ Class for host plugin like tests """ retrieve_keys = {u'dn', u'cn', u'gidnumber', u'member_user', u'member_group', u'description', u'memberof_group', u'memberofindirect_group', u'memberindirect_group', u'memberindirect_user'} retrieve_all_keys = retrieve_keys | {u'ipauniqueid', u'objectclass'} create_keys = retrieve_all_keys update_keys = retrieve_keys - {u'dn'} add_member_keys = retrieve_keys | {u'description'} def __init__(self, name, description=u'Group desc'): super(GroupTracker, self).__init__(default_version=None) self.cn = name self.description = description self.dn = get_group_dn(self.cn) def make_create_command(self, nonposix=False, external=False, *args, **kwargs): """ Make function that creates a group using 'group-add' """ return self.make_command('group_add', self.cn, description=self.description, nonposix=nonposix, external=external, *args, **kwargs) def make_delete_command(self): """ Make function that deletes a group using 'group-del' """ return self.make_command('group_del', self.cn) def make_retrieve_command(self, all=False, raw=False): """ Make function that retrieves a group using 'group-show' """ return self.make_command('group_show', self.cn, all=all) def make_find_command(self, *args, **kwargs): """ Make function that searches for a group using 'group-find' """ return self.make_command('group_find', *args, **kwargs) def make_update_command(self, updates): """ Make function that updates a group using 'group-mod' """ return self.make_command('group_mod', self.cn, **updates) def make_add_member_command(self, options={}): """ Make function that adds a member to a group """ self.adds = options return self.make_command('group_add_member', self.cn, **options) def make_remove_member_command(self, options={}): """ Make function that removes a member from a group """ return self.make_command('group_remove_member', self.cn, **options) def make_detach_command(self): """ Make function that detaches a managed group using 'group-detach' """ self.exists = True return self.make_command('group_detach', self.cn) def track_create(self): """ Updates expected state for group creation""" self.attrs = dict( dn=get_group_dn(self.cn), cn=[self.cn], description=[self.description], gidnumber=[fuzzy_digits], ipauniqueid=[fuzzy_uuid], objectclass=objectclasses.posixgroup, ) self.exists = True def update(self, updates, expected_updates=None): """Helper function to update the group and check the result Overriding Tracker method for setting self.attrs correctly; * most attributes stores its value in list * the rest can be overridden by expected_updates * allow deleting parametrs if update value is None """ if expected_updates is None: expected_updates = {} self.ensure_exists() command = self.make_update_command(updates) result = command() for key, value in updates.items(): if value is None: del self.attrs[key] else: self.attrs[key] = [value] for key, value in expected_updates.items(): if value is None: del self.attrs[key] else: self.attrs[key] = value self.check_update( result, extra_keys=set(updates.keys()) | set(expected_updates.keys()) ) def add_member(self, options): """ Add a member (group OR user) and performs check """ if u'user' in options: try: self.attrs[u'member_user'] =\ self.attrs[u'member_user'] + [options[u'user']] except KeyError: self.attrs[u'member_user'] = [options[u'user']] elif u'group' in options: try: self.attrs[u'member_group'] =\ self.attrs[u'member_group'] + [options[u'group']] except KeyError: self.attrs[u'member_group'] = [options[u'group']] command = self.make_add_member_command(options) result = command() self.check_add_member(result) def remove_member(self, options): """ Remove a member (group OR user) and performs check """ if u'user' in options: self.attrs[u'member_user'].remove(options[u'user']) elif u'group' in options: self.attrs[u'member_group'].remove(options[u'group']) try: if not self.attrs[u'member_user']: del self.attrs[u'member_user'] except KeyError: pass try: if not self.attrs[u'member_group']: del self.attrs[u'member_group'] except KeyError: pass command = self.make_remove_member_command(options) result = command() self.check_remove_member(result) def check_create(self, result): """ Checks 'group_add' command result """ assert_deepequal(dict( value=self.cn, summary=u'Added group "%s"' % self.cn, result=self.filter_attrs(self.create_keys) ), result) def check_delete(self, result): """ Checks 'group_del' command result """ assert_deepequal(dict( value=[self.cn], summary=u'Deleted group "%s"' % self.cn, result=dict(failed=[]), ), result) def check_retrieve(self, result, all=False, raw=False): """ Checks 'group_show' command result """ if all: expected = self.filter_attrs(self.retrieve_all_keys) else: expected = self.filter_attrs(self.retrieve_keys) assert_deepequal(dict( value=self.cn, summary=None, result=expected ), result) def check_find(self, result, all=False, raw=False): """ Checks 'group_find' command result """ if all: expected = self.filter_attrs(self.retrieve_all_keys) else: expected = self.filter_attrs(self.retrieve_keys) assert_deepequal(dict( count=1, truncated=False, summary=u'1 group matched', result=[expected], ), result) def check_update(self, result, extra_keys={}): """ Checks 'group_mod' command result """ assert_deepequal(dict( value=self.cn, summary=u'Modified group "%s"' % self.cn, result=self.filter_attrs(self.update_keys | set(extra_keys)) ), result) def check_add_member(self, result): """ Checks 'group_add_member' command result """ assert_deepequal(dict( completed=1, failed={u'member': {u'group': (), u'user': ()}}, result=self.filter_attrs(self.add_member_keys) ), result) def check_add_member_negative(self, result, options={}): """ Checks 'group_add_member' command result when expected result is failure of the operation""" expected = dict( completed=0, failed={u'member': {u'group': (), u'user': ()}}, result=self.filter_attrs(self.add_member_keys) ) if not options: try: options = self.adds except NameError: pass if u'user' in options: expected[u'failed'][u'member'][u'user'] = [( options[u'user'], u'no such entry')] elif u'group' in options: expected[u'failed'][u'member'][u'group'] = [( options[u'group'], u'no such entry')] assert_deepequal(expected, result) def check_remove_member_negative(self, result, options): """ Checks 'group_remove_member' command result when expected result is failure of the operation""" expected = dict( completed=0, failed={u'member': {u'group': (), u'user': ()}}, result=self.filter_attrs(self.add_member_keys) ) if u'user' in options: expected[u'failed'][u'member'][u'user'] = [( options[u'user'], u'This entry is not a member')] elif u'group' in options: expected[u'failed'][u'member'][u'group'] = [( options[u'group'], u'This entry is not a member')] assert_deepequal(expected, result) def check_remove_member(self, result): """ Checks 'group_remove_member' command result """ self.check_add_member(result) def check_detach(self, result): """ Checks 'group_detach' command result """ assert_deepequal(dict( value=self.cn, summary=u'Detached group "%s" from user "%s"' % ( self.cn, self.cn), result=True ), result)
gpl-3.0
[ 3, 199, 3, 1898, 334, 35, 9, 6900, 221, 2868, 1772, 33, 23212, 1937, 9685, 367, 4190, 199, 3, 199, 199, 504, 3384, 323, 10329, 14, 396, 63, 17596, 492, 909, 2888, 199, 504, 3384, 323, 10329, 14, 396, 63, 17596, 14, 17596, 63, 396, 492, 24101, 63, 7022, 12, 24101, 63, 2580, 199, 199, 504, 3384, 323, 10329, 14, 396, 63, 17596, 14, 8877, 14, 1095, 492, 17507, 281, 199, 504, 3384, 323, 10329, 14, 1974, 492, 702, 63, 11192, 321, 537, 12, 664, 63, 923, 63, 4272, 421, 199, 533, 5611, 13652, 8, 13652, 304, 272, 408, 8089, 367, 1591, 3589, 2839, 2295, 408, 272, 8044, 63, 1612, 275, 469, 85, 5121, 78, 297, 399, 7, 6413, 297, 399, 7, 8787, 1955, 297, 399, 6704, 69, 976, 63, 751, 297, 2151, 399, 6704, 69, 976, 63, 923, 297, 399, 5121, 397, 4802, 297, 2151, 399, 6704, 69, 976, 1618, 63, 923, 297, 399, 6704, 69, 976, 1618, 29306, 63, 923, 297, 2151, 399, 6704, 69, 976, 29306, 63, 923, 297, 399, 6704, 69, 976, 29306, 63, 751, 936, 339, 8044, 63, 452, 63, 1612, 275, 8044, 63, 1612, 1204, 469, 85, 7, 20014, 3235, 344, 297, 399, 7, 785, 533, 936, 339, 1218, 63, 1612, 275, 8044, 63, 452, 63, 1612, 272, 1678, 63, 1612, 275, 8044, 63, 1612, 446, 469, 85, 5121, 78, 936, 339, 1050, 63, 1114, 63, 1612, 275, 8044, 63, 1612, 1204, 469, 85, 5121, 397, 4802, 936, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1369, 29, 85, 7, 2448, 4328, 735, 267, 1613, 8, 2448, 13652, 12, 291, 2843, 826, 721, 885, 63, 1023, 29, 403, 9, 267, 291, 14, 6413, 275, 536, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 4272, 275, 664, 63, 923, 63, 4272, 8, 277, 14, 6413, 9, 339, 347, 1852, 63, 981, 63, 1531, 8, 277, 12, 2222, 9228, 29, 797, 12, 5957, 29, 797, 12, 1169, 627, 589, 12, 1011, 958, 304, 267, 408, 4155, 805, 626, 8491, 282, 1572, 1808, 283, 923, 13, 525, 7, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 525, 297, 291, 14, 6413, 12, 639, 1369, 29, 277, 14, 1802, 12, 639, 2222, 9228, 29, 2865, 9228, 12, 5957, 29, 5159, 12, 639, 627, 589, 12, 1011, 958, 9, 339, 347, 1852, 63, 1807, 63, 1531, 8, 277, 304, 267, 408, 4155, 805, 626, 21812, 282, 1572, 1808, 283, 923, 13, 2264, 7, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 2264, 297, 291, 14, 6413, 9, 339, 347, 1852, 63, 14270, 63, 1531, 8, 277, 12, 1006, 29, 797, 12, 3066, 29, 797, 304, 267, 408, 4155, 805, 626, 9619, 2310, 282, 1572, 1808, 283, 923, 13, 2384, 7, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 2384, 297, 291, 14, 6413, 12, 1006, 29, 452, 9, 339, 347, 1852, 63, 1623, 63, 1531, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 4155, 805, 626, 21858, 367, 282, 1572, 1808, 283, 923, 13, 1623, 7, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 1623, 297, 627, 589, 12, 1011, 958, 9, 339, 347, 1852, 63, 873, 63, 1531, 8, 277, 12, 7029, 304, 267, 408, 4155, 805, 626, 7029, 282, 1572, 1808, 283, 923, 13, 1494, 7, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 1494, 297, 291, 14, 6413, 12, 1011, 7618, 9, 339, 347, 1852, 63, 525, 63, 1114, 63, 1531, 8, 277, 12, 1511, 16420, 267, 408, 4155, 805, 626, 9584, 282, 3653, 370, 282, 1572, 408, 267, 291, 14, 525, 83, 275, 1511, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 525, 63, 1114, 297, 291, 14, 6413, 12, 1011, 1419, 9, 339, 347, 1852, 63, 2168, 63, 1114, 63, 1531, 8, 277, 12, 1511, 16420, 267, 408, 4155, 805, 626, 14185, 282, 3653, 687, 282, 1572, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 2168, 63, 1114, 297, 291, 14, 6413, 12, 1011, 1419, 9, 339, 347, 1852, 63, 14481, 63, 1531, 8, 277, 304, 267, 408, 4155, 805, 626, 21236, 397, 282, 12883, 1572, 1808, 267, 283, 923, 13, 14481, 7, 408, 267, 291, 14, 2444, 275, 715, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 14481, 297, 291, 14, 6413, 9, 339, 347, 4426, 63, 981, 8, 277, 304, 267, 408, 24663, 1420, 1174, 367, 1572, 7143, 624, 267, 291, 14, 3288, 275, 1211, 8, 288, 14052, 29, 362, 63, 923, 63, 4272, 8, 277, 14, 6413, 395, 288, 20087, 1524, 277, 14, 6413, 467, 288, 1369, 1524, 277, 14, 1802, 467, 288, 15122, 1955, 1524, 24529, 63, 7022, 467, 288, 18210, 3235, 344, 1524, 24529, 63, 2580, 467, 288, 909, 533, 29, 785, 2888, 14, 9228, 923, 12, 288, 776, 267, 291, 14, 2444, 275, 715, 339, 347, 1678, 8, 277, 12, 7029, 12, 1420, 63, 7618, 29, 403, 304, 267, 408, 4433, 805, 370, 1678, 314, 1572, 436, 1104, 314, 754, 398, 7259, 15526, 17507, 281, 1083, 367, 4260, 291, 14, 3288, 6657, 27, 268, 627, 4750, 3004, 14086, 2399, 574, 315, 769, 268, 627, 314, 4618, 883, 506, 10087, 701, 1420, 63, 7618, 268, 627, 2040, 13794, 18117, 454, 83, 340, 1678, 574, 365, 488, 267, 408, 267, 340, 1420, 63, 7618, 365, 488, 26, 288, 1420, 63, 7618, 275, 1052, 398, 291, 14, 7505, 63, 2444, 342, 267, 1414, 275, 291, 14, 1875, 63, 873, 63, 1531, 8, 7618, 9, 267, 754, 275, 1414, 342, 398, 367, 790, 12, 574, 315, 7029, 14, 1744, 837, 288, 340, 574, 365, 488, 26, 355, 2150, 291, 14, 3288, 59, 498, 61, 288, 587, 26, 355, 291, 14, 3288, 59, 498, 61, 275, 359, 585, 61, 267, 367, 790, 12, 574, 315, 1420, 63, 7618, 14, 1744, 837, 288, 340, 574, 365, 488, 26, 355, 2150, 291, 14, 3288, 59, 498, 61, 288, 587, 26, 355, 291, 14, 3288, 59, 498, 61, 275, 574, 398, 291, 14, 1074, 63, 873, 8, 288, 754, 12, 288, 2402, 63, 1612, 29, 409, 8, 7618, 14, 1612, 1012, 1204, 663 ]
[ 199, 3, 1898, 334, 35, 9, 6900, 221, 2868, 1772, 33, 23212, 1937, 9685, 367, 4190, 199, 3, 199, 199, 504, 3384, 323, 10329, 14, 396, 63, 17596, 492, 909, 2888, 199, 504, 3384, 323, 10329, 14, 396, 63, 17596, 14, 17596, 63, 396, 492, 24101, 63, 7022, 12, 24101, 63, 2580, 199, 199, 504, 3384, 323, 10329, 14, 396, 63, 17596, 14, 8877, 14, 1095, 492, 17507, 281, 199, 504, 3384, 323, 10329, 14, 1974, 492, 702, 63, 11192, 321, 537, 12, 664, 63, 923, 63, 4272, 421, 199, 533, 5611, 13652, 8, 13652, 304, 272, 408, 8089, 367, 1591, 3589, 2839, 2295, 408, 272, 8044, 63, 1612, 275, 469, 85, 5121, 78, 297, 399, 7, 6413, 297, 399, 7, 8787, 1955, 297, 399, 6704, 69, 976, 63, 751, 297, 2151, 399, 6704, 69, 976, 63, 923, 297, 399, 5121, 397, 4802, 297, 2151, 399, 6704, 69, 976, 1618, 63, 923, 297, 399, 6704, 69, 976, 1618, 29306, 63, 923, 297, 2151, 399, 6704, 69, 976, 29306, 63, 923, 297, 399, 6704, 69, 976, 29306, 63, 751, 936, 339, 8044, 63, 452, 63, 1612, 275, 8044, 63, 1612, 1204, 469, 85, 7, 20014, 3235, 344, 297, 399, 7, 785, 533, 936, 339, 1218, 63, 1612, 275, 8044, 63, 452, 63, 1612, 272, 1678, 63, 1612, 275, 8044, 63, 1612, 446, 469, 85, 5121, 78, 936, 339, 1050, 63, 1114, 63, 1612, 275, 8044, 63, 1612, 1204, 469, 85, 5121, 397, 4802, 936, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1369, 29, 85, 7, 2448, 4328, 735, 267, 1613, 8, 2448, 13652, 12, 291, 2843, 826, 721, 885, 63, 1023, 29, 403, 9, 267, 291, 14, 6413, 275, 536, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 4272, 275, 664, 63, 923, 63, 4272, 8, 277, 14, 6413, 9, 339, 347, 1852, 63, 981, 63, 1531, 8, 277, 12, 2222, 9228, 29, 797, 12, 5957, 29, 797, 12, 1169, 627, 589, 12, 1011, 958, 304, 267, 408, 4155, 805, 626, 8491, 282, 1572, 1808, 283, 923, 13, 525, 7, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 525, 297, 291, 14, 6413, 12, 639, 1369, 29, 277, 14, 1802, 12, 639, 2222, 9228, 29, 2865, 9228, 12, 5957, 29, 5159, 12, 639, 627, 589, 12, 1011, 958, 9, 339, 347, 1852, 63, 1807, 63, 1531, 8, 277, 304, 267, 408, 4155, 805, 626, 21812, 282, 1572, 1808, 283, 923, 13, 2264, 7, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 2264, 297, 291, 14, 6413, 9, 339, 347, 1852, 63, 14270, 63, 1531, 8, 277, 12, 1006, 29, 797, 12, 3066, 29, 797, 304, 267, 408, 4155, 805, 626, 9619, 2310, 282, 1572, 1808, 283, 923, 13, 2384, 7, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 2384, 297, 291, 14, 6413, 12, 1006, 29, 452, 9, 339, 347, 1852, 63, 1623, 63, 1531, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 4155, 805, 626, 21858, 367, 282, 1572, 1808, 283, 923, 13, 1623, 7, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 1623, 297, 627, 589, 12, 1011, 958, 9, 339, 347, 1852, 63, 873, 63, 1531, 8, 277, 12, 7029, 304, 267, 408, 4155, 805, 626, 7029, 282, 1572, 1808, 283, 923, 13, 1494, 7, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 1494, 297, 291, 14, 6413, 12, 1011, 7618, 9, 339, 347, 1852, 63, 525, 63, 1114, 63, 1531, 8, 277, 12, 1511, 16420, 267, 408, 4155, 805, 626, 9584, 282, 3653, 370, 282, 1572, 408, 267, 291, 14, 525, 83, 275, 1511, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 525, 63, 1114, 297, 291, 14, 6413, 12, 1011, 1419, 9, 339, 347, 1852, 63, 2168, 63, 1114, 63, 1531, 8, 277, 12, 1511, 16420, 267, 408, 4155, 805, 626, 14185, 282, 3653, 687, 282, 1572, 408, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 2168, 63, 1114, 297, 291, 14, 6413, 12, 1011, 1419, 9, 339, 347, 1852, 63, 14481, 63, 1531, 8, 277, 304, 267, 408, 4155, 805, 626, 21236, 397, 282, 12883, 1572, 1808, 267, 283, 923, 13, 14481, 7, 408, 267, 291, 14, 2444, 275, 715, 267, 372, 291, 14, 1875, 63, 1531, 360, 923, 63, 14481, 297, 291, 14, 6413, 9, 339, 347, 4426, 63, 981, 8, 277, 304, 267, 408, 24663, 1420, 1174, 367, 1572, 7143, 624, 267, 291, 14, 3288, 275, 1211, 8, 288, 14052, 29, 362, 63, 923, 63, 4272, 8, 277, 14, 6413, 395, 288, 20087, 1524, 277, 14, 6413, 467, 288, 1369, 1524, 277, 14, 1802, 467, 288, 15122, 1955, 1524, 24529, 63, 7022, 467, 288, 18210, 3235, 344, 1524, 24529, 63, 2580, 467, 288, 909, 533, 29, 785, 2888, 14, 9228, 923, 12, 288, 776, 267, 291, 14, 2444, 275, 715, 339, 347, 1678, 8, 277, 12, 7029, 12, 1420, 63, 7618, 29, 403, 304, 267, 408, 4433, 805, 370, 1678, 314, 1572, 436, 1104, 314, 754, 398, 7259, 15526, 17507, 281, 1083, 367, 4260, 291, 14, 3288, 6657, 27, 268, 627, 4750, 3004, 14086, 2399, 574, 315, 769, 268, 627, 314, 4618, 883, 506, 10087, 701, 1420, 63, 7618, 268, 627, 2040, 13794, 18117, 454, 83, 340, 1678, 574, 365, 488, 267, 408, 267, 340, 1420, 63, 7618, 365, 488, 26, 288, 1420, 63, 7618, 275, 1052, 398, 291, 14, 7505, 63, 2444, 342, 267, 1414, 275, 291, 14, 1875, 63, 873, 63, 1531, 8, 7618, 9, 267, 754, 275, 1414, 342, 398, 367, 790, 12, 574, 315, 7029, 14, 1744, 837, 288, 340, 574, 365, 488, 26, 355, 2150, 291, 14, 3288, 59, 498, 61, 288, 587, 26, 355, 291, 14, 3288, 59, 498, 61, 275, 359, 585, 61, 267, 367, 790, 12, 574, 315, 1420, 63, 7618, 14, 1744, 837, 288, 340, 574, 365, 488, 26, 355, 2150, 291, 14, 3288, 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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 ]
siriuscoin/siriuscoin
contrib/testgen/base58.py
2139
2818
''' Bitcoin base58 encoding and decoding. Based on https://bitcointalk.org/index.php?topic=1026.0 (public domain) ''' import hashlib # for compatibility with following code... class SHA256: new = hashlib.sha256 if str != bytes: # Python 3.x def ord(c): return c def chr(n): return bytes( (n,) ) __b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' __b58base = len(__b58chars) b58chars = __b58chars def b58encode(v): """ encode v, which is a string of bytes, to base58. """ long_value = 0 for (i, c) in enumerate(v[::-1]): long_value += (256**i) * ord(c) result = '' while long_value >= __b58base: div, mod = divmod(long_value, __b58base) result = __b58chars[mod] + result long_value = div result = __b58chars[long_value] + result # Bitcoin does a little leading-zero-compression: # leading 0-bytes in the input become leading-1s nPad = 0 for c in v: if c == '\0': nPad += 1 else: break return (__b58chars[0]*nPad) + result def b58decode(v, length = None): """ decode v into a string of len bytes """ long_value = 0 for (i, c) in enumerate(v[::-1]): long_value += __b58chars.find(c) * (__b58base**i) result = bytes() while long_value >= 256: div, mod = divmod(long_value, 256) result = chr(mod) + result long_value = div result = chr(long_value) + result nPad = 0 for c in v: if c == __b58chars[0]: nPad += 1 else: break result = chr(0)*nPad + result if length is not None and len(result) != length: return None return result def checksum(v): """Return 32-bit checksum based on SHA256""" return SHA256.new(SHA256.new(v).digest()).digest()[0:4] def b58encode_chk(v): """b58encode a string, with 32-bit checksum""" return b58encode(v + checksum(v)) def b58decode_chk(v): """decode a base58 string, check and remove checksum""" result = b58decode(v) if result is None: return None h3 = checksum(result[:-4]) if result[-4:] == checksum(result[:-4]): return result[:-4] else: return None def get_bcaddress_version(strAddress): """ Returns None if strAddress is invalid. Otherwise returns integer version of address. """ addr = b58decode_chk(strAddress) if addr is None or len(addr)!=21: return None version = addr[0] return ord(version) if __name__ == '__main__': # Test case (from http://gitorious.org/bitcoin/python-base58.git) assert get_bcaddress_version('15VjRaDX9zpbA8LVnbrCAFzrVzN7ixHNsC') is 0 _ohai = 'o hai'.encode('ascii') _tmp = b58encode(_ohai) assert _tmp == 'DYB3oMS' assert b58decode(_tmp, 5) == _ohai print("Tests passed")
mit
[ 2344, 199, 4734, 9061, 1300, 2010, 2644, 436, 15952, 14, 199, 199, 20409, 641, 4178, 921, 2075, 331, 442, 4878, 14, 1308, 15, 1080, 14, 8624, 31, 5746, 29, 32351, 14, 16, 334, 3455, 2881, 9, 199, 2344, 199, 646, 8337, 199, 199, 3, 367, 7163, 543, 2569, 1233, 1396, 199, 533, 12002, 3912, 26, 272, 892, 275, 8337, 14, 4835, 3912, 199, 199, 692, 620, 1137, 2783, 26, 272, 327, 2018, 650, 14, 88, 272, 347, 6206, 8, 67, 304, 267, 372, 286, 272, 347, 8678, 8, 78, 304, 267, 372, 2783, 8, 334, 78, 4258, 776, 199, 199, 363, 66, 2010, 6574, 275, 283, 11272, 22897, 22313, 14307, 45, 14970, 26018, 18677, 75, 19748, 21832, 7, 199, 363, 66, 2010, 1095, 275, 822, 3460, 66, 2010, 6574, 9, 199, 66, 2010, 6574, 275, 636, 66, 2010, 6574, 199, 199, 318, 330, 2010, 2143, 8, 86, 304, 272, 408, 3752, 373, 12, 1314, 365, 282, 1059, 402, 2783, 12, 370, 1300, 2010, 14, 272, 408, 272, 1846, 63, 585, 275, 378, 272, 367, 334, 73, 12, 286, 9, 315, 3874, 8, 86, 14172, 17, 4682, 267, 1846, 63, 585, 847, 334, 3912, 538, 73, 9, 627, 6206, 8, 67, 9, 339, 754, 275, 2125, 272, 1830, 1846, 63, 585, 2356, 636, 66, 2010, 1095, 26, 267, 9073, 12, 3413, 275, 16438, 8, 2809, 63, 585, 12, 636, 66, 2010, 1095, 9, 267, 754, 275, 636, 66, 2010, 6574, 59, 1494, 61, 435, 754, 267, 1846, 63, 585, 275, 9073, 272, 754, 275, 636, 66, 2010, 6574, 59, 2809, 63, 585, 61, 435, 754, 339, 327, 21158, 1630, 282, 12050, 9186, 13, 4262, 13, 12849, 26, 272, 327, 9186, 378, 13, 2394, 315, 314, 1324, 8649, 9186, 13, 17, 83, 272, 302, 18584, 275, 378, 272, 367, 286, 315, 373, 26, 267, 340, 286, 508, 1557, 16, 356, 302, 18584, 847, 413, 267, 587, 26, 2059, 339, 372, 25373, 66, 2010, 6574, 59, 16, 3672, 78, 18584, 9, 435, 754, 199, 199, 318, 330, 2010, 2708, 8, 86, 12, 2582, 275, 488, 304, 272, 408, 4849, 373, 1901, 282, 1059, 402, 822, 2783, 272, 408, 272, 1846, 63, 585, 275, 378, 272, 367, 334, 73, 12, 286, 9, 315, 3874, 8, 86, 14172, 17, 4682, 267, 1846, 63, 585, 847, 636, 66, 2010, 6574, 14, 1623, 8, 67, 9, 627, 25373, 66, 2010, 1095, 538, 73, 9, 339, 754, 275, 2783, 342, 272, 1830, 1846, 63, 585, 2356, 7633, 26, 267, 9073, 12, 3413, 275, 16438, 8, 2809, 63, 585, 12, 7633, 9, 267, 754, 275, 8678, 8, 1494, 9, 435, 754, 267, 1846, 63, 585, 275, 9073, 272, 754, 275, 8678, 8, 2809, 63, 585, 9, 435, 754, 339, 302, 18584, 275, 378, 272, 367, 286, 315, 373, 26, 267, 340, 286, 508, 636, 66, 2010, 6574, 59, 16, 2189, 302, 18584, 847, 413, 267, 587, 26, 2059, 339, 754, 275, 8678, 8, 16, 3342, 78, 18584, 435, 754, 272, 340, 2582, 365, 440, 488, 436, 822, 8, 1099, 9, 1137, 2582, 26, 267, 372, 488, 339, 372, 754, 199, 199, 318, 9040, 8, 86, 304, 272, 408, 1767, 4337, 13, 2075, 9040, 4079, 641, 12002, 3912, 624, 272, 372, 12002, 3912, 14, 1222, 8, 8461, 3912, 14, 1222, 8, 86, 680, 5671, 8801, 5671, 3430, 16, 26, 20, 61, 199, 199, 318, 330, 2010, 2143, 63, 14823, 8, 86, 304, 272, 408, 66, 2010, 2143, 282, 1059, 12, 543, 4337, 13, 2075, 9040, 624, 272, 372, 330, 2010, 2143, 8, 86, 435, 9040, 8, 86, 430, 199, 199, 318, 330, 2010, 2708, 63, 14823, 8, 86, 304, 272, 408, 2708, 282, 1300, 2010, 1059, 12, 1104, 436, 2813, 9040, 624, 272, 754, 275, 330, 2010, 2708, 8, 86, 9, 272, 340, 754, 365, 488, 26, 267, 372, 488, 272, 394, 19, 275, 9040, 8, 1099, 4439, 20, 566, 272, 340, 754, 1988, 20, 2938, 508, 9040, 8, 1099, 4439, 20, 4682, 267, 372, 754, 4439, 20, 61, 272, 587, 26, 267, 372, 488, 199, 199, 318, 664, 63, 3776, 1562, 63, 1023, 8, 495, 1476, 304, 272, 408, 1803, 488, 340, 620, 1476, 365, 3866, 14, 221, 6630, 2529, 3000, 1015, 402, 2287, 14, 408, 272, 5552, 275, 330, 2010, 2708, 63, 14823, 8, 495, 1476, 9, 272, 340, 5552, 365, 488, 503, 822, 8, 2697, 9, 1111, 2025, 26, 372, 488, 272, 1015, 275, 5552, 59, 16, 61, 272, 372, 6206, 8, 1023, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 1379, 1930, 334, 504, 1455, 921, 3187, 16039, 1785, 14, 1308, 15, 22816, 15, 1548, 13, 1095, 2010, 14, 3187, 9, 272, 702, 664, 63, 3776, 1562, 63, 1023, 360, 1046, 54, 74, 1537, 19596, 25, 90, 3317, 33, 24, 18750, 23299, 3263, 38, 32605, 54, 90, 46, 23, 1148, 40, 2438, 35, 358, 365, 378, 272, 485, 79, 17945, 275, 283, 79, 394, 5789, 1370, 2143, 360, 4371, 358, 272, 485, 2791, 275, 330, 2010, 2143, 1547, 79, 17945, 9, 272, 702, 485, 2791, 508, 283, 11446, 34, 19, 79, 3053, 7, 272, 702, 330, 2010, 2708, 1547, 2791, 12, 959, 9, 508, 485, 79, 17945, 272, 870, 480, 2925, 3032, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 4734, 9061, 1300, 2010, 2644, 436, 15952, 14, 199, 199, 20409, 641, 4178, 921, 2075, 331, 442, 4878, 14, 1308, 15, 1080, 14, 8624, 31, 5746, 29, 32351, 14, 16, 334, 3455, 2881, 9, 199, 2344, 199, 646, 8337, 199, 199, 3, 367, 7163, 543, 2569, 1233, 1396, 199, 533, 12002, 3912, 26, 272, 892, 275, 8337, 14, 4835, 3912, 199, 199, 692, 620, 1137, 2783, 26, 272, 327, 2018, 650, 14, 88, 272, 347, 6206, 8, 67, 304, 267, 372, 286, 272, 347, 8678, 8, 78, 304, 267, 372, 2783, 8, 334, 78, 4258, 776, 199, 199, 363, 66, 2010, 6574, 275, 283, 11272, 22897, 22313, 14307, 45, 14970, 26018, 18677, 75, 19748, 21832, 7, 199, 363, 66, 2010, 1095, 275, 822, 3460, 66, 2010, 6574, 9, 199, 66, 2010, 6574, 275, 636, 66, 2010, 6574, 199, 199, 318, 330, 2010, 2143, 8, 86, 304, 272, 408, 3752, 373, 12, 1314, 365, 282, 1059, 402, 2783, 12, 370, 1300, 2010, 14, 272, 408, 272, 1846, 63, 585, 275, 378, 272, 367, 334, 73, 12, 286, 9, 315, 3874, 8, 86, 14172, 17, 4682, 267, 1846, 63, 585, 847, 334, 3912, 538, 73, 9, 627, 6206, 8, 67, 9, 339, 754, 275, 2125, 272, 1830, 1846, 63, 585, 2356, 636, 66, 2010, 1095, 26, 267, 9073, 12, 3413, 275, 16438, 8, 2809, 63, 585, 12, 636, 66, 2010, 1095, 9, 267, 754, 275, 636, 66, 2010, 6574, 59, 1494, 61, 435, 754, 267, 1846, 63, 585, 275, 9073, 272, 754, 275, 636, 66, 2010, 6574, 59, 2809, 63, 585, 61, 435, 754, 339, 327, 21158, 1630, 282, 12050, 9186, 13, 4262, 13, 12849, 26, 272, 327, 9186, 378, 13, 2394, 315, 314, 1324, 8649, 9186, 13, 17, 83, 272, 302, 18584, 275, 378, 272, 367, 286, 315, 373, 26, 267, 340, 286, 508, 1557, 16, 356, 302, 18584, 847, 413, 267, 587, 26, 2059, 339, 372, 25373, 66, 2010, 6574, 59, 16, 3672, 78, 18584, 9, 435, 754, 199, 199, 318, 330, 2010, 2708, 8, 86, 12, 2582, 275, 488, 304, 272, 408, 4849, 373, 1901, 282, 1059, 402, 822, 2783, 272, 408, 272, 1846, 63, 585, 275, 378, 272, 367, 334, 73, 12, 286, 9, 315, 3874, 8, 86, 14172, 17, 4682, 267, 1846, 63, 585, 847, 636, 66, 2010, 6574, 14, 1623, 8, 67, 9, 627, 25373, 66, 2010, 1095, 538, 73, 9, 339, 754, 275, 2783, 342, 272, 1830, 1846, 63, 585, 2356, 7633, 26, 267, 9073, 12, 3413, 275, 16438, 8, 2809, 63, 585, 12, 7633, 9, 267, 754, 275, 8678, 8, 1494, 9, 435, 754, 267, 1846, 63, 585, 275, 9073, 272, 754, 275, 8678, 8, 2809, 63, 585, 9, 435, 754, 339, 302, 18584, 275, 378, 272, 367, 286, 315, 373, 26, 267, 340, 286, 508, 636, 66, 2010, 6574, 59, 16, 2189, 302, 18584, 847, 413, 267, 587, 26, 2059, 339, 754, 275, 8678, 8, 16, 3342, 78, 18584, 435, 754, 272, 340, 2582, 365, 440, 488, 436, 822, 8, 1099, 9, 1137, 2582, 26, 267, 372, 488, 339, 372, 754, 199, 199, 318, 9040, 8, 86, 304, 272, 408, 1767, 4337, 13, 2075, 9040, 4079, 641, 12002, 3912, 624, 272, 372, 12002, 3912, 14, 1222, 8, 8461, 3912, 14, 1222, 8, 86, 680, 5671, 8801, 5671, 3430, 16, 26, 20, 61, 199, 199, 318, 330, 2010, 2143, 63, 14823, 8, 86, 304, 272, 408, 66, 2010, 2143, 282, 1059, 12, 543, 4337, 13, 2075, 9040, 624, 272, 372, 330, 2010, 2143, 8, 86, 435, 9040, 8, 86, 430, 199, 199, 318, 330, 2010, 2708, 63, 14823, 8, 86, 304, 272, 408, 2708, 282, 1300, 2010, 1059, 12, 1104, 436, 2813, 9040, 624, 272, 754, 275, 330, 2010, 2708, 8, 86, 9, 272, 340, 754, 365, 488, 26, 267, 372, 488, 272, 394, 19, 275, 9040, 8, 1099, 4439, 20, 566, 272, 340, 754, 1988, 20, 2938, 508, 9040, 8, 1099, 4439, 20, 4682, 267, 372, 754, 4439, 20, 61, 272, 587, 26, 267, 372, 488, 199, 199, 318, 664, 63, 3776, 1562, 63, 1023, 8, 495, 1476, 304, 272, 408, 1803, 488, 340, 620, 1476, 365, 3866, 14, 221, 6630, 2529, 3000, 1015, 402, 2287, 14, 408, 272, 5552, 275, 330, 2010, 2708, 63, 14823, 8, 495, 1476, 9, 272, 340, 5552, 365, 488, 503, 822, 8, 2697, 9, 1111, 2025, 26, 372, 488, 272, 1015, 275, 5552, 59, 16, 61, 272, 372, 6206, 8, 1023, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 1379, 1930, 334, 504, 1455, 921, 3187, 16039, 1785, 14, 1308, 15, 22816, 15, 1548, 13, 1095, 2010, 14, 3187, 9, 272, 702, 664, 63, 3776, 1562, 63, 1023, 360, 1046, 54, 74, 1537, 19596, 25, 90, 3317, 33, 24, 18750, 23299, 3263, 38, 32605, 54, 90, 46, 23, 1148, 40, 2438, 35, 358, 365, 378, 272, 485, 79, 17945, 275, 283, 79, 394, 5789, 1370, 2143, 360, 4371, 358, 272, 485, 2791, 275, 330, 2010, 2143, 1547, 79, 17945, 9, 272, 702, 485, 2791, 508, 283, 11446, 34, 19, 79, 3053, 7, 272, 702, 330, 2010, 2708, 1547, 2791, 12, 959, 9, 508, 485, 79, 17945, 272, 870, 480, 2925, 3032, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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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 ]
edoko/android_lg_mako
tools/perf/scripts/python/check-perf-trace.py
11214
2503
# perf script event handlers, generated by perf script -g python # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # This script tests basic functionality such as flag and symbol # strings, common_xxx() calls back into perf, begin, end, unhandled # events, etc. Basically, if this script runs successfully and # displays expected results, Python scripting support should be ok. import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from Core import * from perf_trace_context import * unhandled = autodict() def trace_begin(): print "trace_begin" pass def trace_end(): print_unhandled() def irq__softirq_entry(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, vec): print_header(event_name, common_cpu, common_secs, common_nsecs, common_pid, common_comm) print_uncommon(context) print "vec=%s\n" % \ (symbol_str("irq__softirq_entry", "vec", vec)), def kmem__kmalloc(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, call_site, ptr, bytes_req, bytes_alloc, gfp_flags): print_header(event_name, common_cpu, common_secs, common_nsecs, common_pid, common_comm) print_uncommon(context) print "call_site=%u, ptr=%u, bytes_req=%u, " \ "bytes_alloc=%u, gfp_flags=%s\n" % \ (call_site, ptr, bytes_req, bytes_alloc, flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)), def trace_unhandled(event_name, context, event_fields_dict): try: unhandled[event_name] += 1 except TypeError: unhandled[event_name] = 1 def print_header(event_name, cpu, secs, nsecs, pid, comm): print "%-20s %5u %05u.%09u %8u %-20s " % \ (event_name, cpu, secs, nsecs, pid, comm), # print trace fields not included in handler args def print_uncommon(context): print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \ % (common_pc(context), trace_flag_str(common_flags(context)), \ common_lock_depth(context)) def print_unhandled(): keys = unhandled.keys() if not keys: return print "\nunhandled events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "-----------"), for event_name in keys: print "%-40s %10d\n" % (event_name, unhandled[event_name])
gpl-2.0
[ 3, 8582, 2884, 1566, 8297, 12, 4046, 701, 8582, 2884, 446, 71, 2366, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 961, 2884, 2295, 5678, 9330, 4066, 465, 3305, 436, 5272, 199, 3, 3326, 12, 2863, 63, 10013, 342, 4882, 1771, 1901, 8582, 12, 5386, 12, 1284, 12, 23090, 199, 3, 4474, 12, 5423, 14, 221, 10082, 1183, 12, 340, 642, 2884, 7858, 8792, 436, 199, 3, 17561, 1420, 2058, 12, 2018, 2884, 316, 2291, 1077, 506, 4112, 14, 199, 199, 646, 747, 199, 646, 984, 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, 199, 504, 11672, 492, 627, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 199, 23648, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 3446, 63, 5037, 2, 199, 198, 1529, 199, 199, 318, 3307, 63, 500, 837, 267, 870, 63, 23648, 342, 199, 199, 318, 10476, 363, 18316, 63, 2373, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 6046, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 6046, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 5155, 63, 495, 480, 7277, 363, 18316, 63, 2373, 401, 298, 6046, 401, 10782, 1826, 199, 199, 318, 1022, 5286, 363, 75, 23981, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 199, 198, 71, 3997, 63, 2469, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 1250, 63, 2124, 2458, 85, 12, 12448, 2458, 85, 12, 2783, 63, 2103, 2458, 85, 12, 298, 971, 507, 198, 2, 2394, 63, 9373, 2458, 85, 12, 486, 3997, 63, 2469, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 2742, 198, 4173, 63, 495, 480, 75, 5286, 363, 75, 23981, 401, 298, 71, 3997, 63, 2469, 401, 486, 3997, 63, 2469, 1826, 199, 199, 318, 3307, 63, 23648, 8, 1430, 63, 354, 12, 1067, 12, 1566, 63, 955, 63, 807, 304, 272, 862, 26, 267, 23090, 59, 1430, 63, 354, 61, 847, 413, 272, 871, 3146, 26, 267, 23090, 59, 1430, 63, 354, 61, 275, 413, 199, 199, 318, 870, 63, 1291, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 304, 199, 198, 1361, 18301, 1165, 83, 450, 21, 85, 450, 1717, 85, 4111, 1643, 85, 450, 24, 85, 19752, 1165, 83, 298, 450, 971, 199, 198, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 395, 199, 199, 3, 870, 3307, 1504, 440, 5120, 315, 3016, 1249, 199, 318, 870, 63, 324, 2330, 8, 1100, 304, 272, 870, 298, 2330, 63, 657, 19046, 63, 835, 2458, 68, 12, 2863, 63, 2469, 2458, 83, 12, 2863, 63, 831, 63, 4631, 2458, 68, 12, 298, 971, 267, 450, 334, 2330, 63, 2352, 8, 1100, 395, 3307, 63, 4173, 63, 495, 8, 2330, 63, 2469, 8, 1100, 1826, 971, 2049, 2863, 63, 831, 63, 4631, 8, 1100, 430, 199, 199, 318, 870, 63, 23648, 837, 272, 2883, 275, 23090, 14, 1612, 342, 272, 340, 440, 2883, 26, 267, 372, 339, 870, 1867, 78, 23648, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1566, 63, 354, 315, 2883, 26, 199, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 1430, 63, 354, 12, 23090, 59, 1430, 63, 354, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8582, 2884, 1566, 8297, 12, 4046, 701, 8582, 2884, 446, 71, 2366, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 961, 2884, 2295, 5678, 9330, 4066, 465, 3305, 436, 5272, 199, 3, 3326, 12, 2863, 63, 10013, 342, 4882, 1771, 1901, 8582, 12, 5386, 12, 1284, 12, 23090, 199, 3, 4474, 12, 5423, 14, 221, 10082, 1183, 12, 340, 642, 2884, 7858, 8792, 436, 199, 3, 17561, 1420, 2058, 12, 2018, 2884, 316, 2291, 1077, 506, 4112, 14, 199, 199, 646, 747, 199, 646, 984, 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, 199, 504, 11672, 492, 627, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 199, 23648, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 3446, 63, 5037, 2, 199, 198, 1529, 199, 199, 318, 3307, 63, 500, 837, 267, 870, 63, 23648, 342, 199, 199, 318, 10476, 363, 18316, 63, 2373, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 6046, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 6046, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 5155, 63, 495, 480, 7277, 363, 18316, 63, 2373, 401, 298, 6046, 401, 10782, 1826, 199, 199, 318, 1022, 5286, 363, 75, 23981, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 199, 198, 71, 3997, 63, 2469, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 1250, 63, 2124, 2458, 85, 12, 12448, 2458, 85, 12, 2783, 63, 2103, 2458, 85, 12, 298, 971, 507, 198, 2, 2394, 63, 9373, 2458, 85, 12, 486, 3997, 63, 2469, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 2742, 198, 4173, 63, 495, 480, 75, 5286, 363, 75, 23981, 401, 298, 71, 3997, 63, 2469, 401, 486, 3997, 63, 2469, 1826, 199, 199, 318, 3307, 63, 23648, 8, 1430, 63, 354, 12, 1067, 12, 1566, 63, 955, 63, 807, 304, 272, 862, 26, 267, 23090, 59, 1430, 63, 354, 61, 847, 413, 272, 871, 3146, 26, 267, 23090, 59, 1430, 63, 354, 61, 275, 413, 199, 199, 318, 870, 63, 1291, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 304, 199, 198, 1361, 18301, 1165, 83, 450, 21, 85, 450, 1717, 85, 4111, 1643, 85, 450, 24, 85, 19752, 1165, 83, 298, 450, 971, 199, 198, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 395, 199, 199, 3, 870, 3307, 1504, 440, 5120, 315, 3016, 1249, 199, 318, 870, 63, 324, 2330, 8, 1100, 304, 272, 870, 298, 2330, 63, 657, 19046, 63, 835, 2458, 68, 12, 2863, 63, 2469, 2458, 83, 12, 2863, 63, 831, 63, 4631, 2458, 68, 12, 298, 971, 267, 450, 334, 2330, 63, 2352, 8, 1100, 395, 3307, 63, 4173, 63, 495, 8, 2330, 63, 2469, 8, 1100, 1826, 971, 2049, 2863, 63, 831, 63, 4631, 8, 1100, 430, 199, 199, 318, 870, 63, 23648, 837, 272, 2883, 275, 23090, 14, 1612, 342, 272, 340, 440, 2883, 26, 267, 372, 339, 870, 1867, 78, 23648, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1566, 63, 354, 315, 2883, 26, 199, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 1430, 63, 354, 12, 23090, 59, 1430, 63, 354, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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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 ]
chaubold/hytra
empryonic/learning/quantification.py
1
34287
import unittest as _ut import numpy as np from empryonic import io as _io import math ### ### Events as members of sets for the calculation of performance measures ### class Event( object ): @property def setid( self ): return self._setid @property def timestep( self ): return self._timestep def __init__( self, ids, timestep, setid='base' ): self._ids = tuple(ids) self._timestep = timestep self._setid = setid def __eq__(self, other): '''Attention: operator is not commutative!''' if isinstance(other, self.__class__): return self.ids == other.ids and self.timestep == other.timestep else: return False def __ne__( self, other): return not(self == other) def __hash__( self ): return hash((self._ids, self._timestep, self.__class__, self._setid)) @property def ids( self ): return self._ids def translate( self, origin_match, to_match ): ''' Create a new equivalent event. ''' raise NotImplementedError def equivalent_to(self, origin_match, to_match, other): '''Check, if the 'other' Event corresponds to the given one. Other event should be in a different basic set (either 'base' or 'contestant') *_match - { events_id: match_to_id } other - Event ''' raise NotImplementedError def visible_in_other(self, origin_match, to_match): '''Check if Event could be tracked in other basic set, because the participating cells were at least detected. *_match - { events_id: match_to_id } ''' raise NotImplementedError def traxels_contained_in(self, traxel_list): ''' Check if all traxels that are used in this event are present in the traxel_list. traxel_list - list of (timestep, traxelID) tuples Overwrite this method if not all traxels of an Event are in the same timestep! (Move, disappearance and Division reference previous timesteps!) ''' for i in self._ids: if not (self.timestep, i) in traxel_list: return False return True ### debugging def is_matched(self, origin_match, to_match): raise NotImplementedError class Move( Event ): def translate( self, origin_match, to_match, setid ): origin_translated = origin_match[self.ids[0]] to_translated = to_match[self.ids[1]] return Move( (origin_translated, to_translated), self.timestep, setid) def equivalent_to( self, origin_match, to_match, other): origin_translated = origin_match[self.ids[0]] to_translated = to_match[self.ids[1]] translated_move = Move((origin_translated, to_translated), self.timestep, other.setid) return translated_move == other def visible_in_other( self, origin_match, to_match): return origin_match[self.ids[0]] and to_match[self.ids[1]] def is_matched(self, origin_match, to_match): if origin_match.has_key(self.ids[0]) and to_match.has_key(self.ids[1]): return True else: return False def traxels_contained_in(self, traxel_list): if not (self.timestep - 1, self._ids[0]) in traxel_list: return False elif not (self.timestep, self._ids[1]) in traxel_list: return False else: return True def __repr__( self ): return "Move((" + str(self.ids[0]) + ", "+ str(self.ids[1])+ "))" class Merger( Event ): def translate( self, origin_match, to_match, setid ): if self.ids[0] != to_match[self.ids[0]]: raise RuntimeError('translate: translation not supported') return Merger( tuple(self.ids), self.timestep, setid ) def equivalent_to( self, origin_match, to_match, other): if self.ids[0] != to_match[self.ids[0]]: raise RuntimeError('equivalent_to: translation not supported') return (self == other) def visible_in_other( self, origin_match, to_match): return True def is_matched(self,origin_match, to_match): if to_match.has_key(self.ids[0]): return True else: return False def __repr__( self ): return "Merger((" + str(self.ids[0]) + ", "+ str(self.ids[1])+ "))" class MultiFrameMove( Event ): def translate( self, origin_match, to_match, setid ): if self.ids[1] != to_match[self.ids[1]]: raise RuntimeError('translate: translation not supported') return MultiFrameMove( tuple(self.ids), self.timestep, setid ) def equivalent_to( self, origin_match, to_match, other): if self.ids[1] != to_match[self.ids[1]]: raise RuntimeError('equivalent_to: translation not supported') return (self == other) def visible_in_other( self, origin_match, to_match): return True def is_matched(self,origin_match, to_match): if to_match.has_key(self.ids[1]): return True else: return False def __repr__( self ): return "MultiFrameMove((" + str(self.ids[0]) + ", "+ str(self.ids[1]) + "," + str(self.ids[2]) + "))" class Division( Event ): def __init__( self, ids, timestep, setid='base' ): children = list(ids[1:3]) children.sort() self._ids = (ids[0], children[0], children[1]) self._timestep = timestep self._setid = setid def translate( self, origin_match, to_match, setid ): origin_translated = origin_match[self.ids[0]] to1_translated = to_match[self.ids[1]] to2_translated = to_match[self.ids[2]] return Division( (origin_translated, to1_translated, to2_translated), self.timestep, setid ) def equivalent_to( self, origin_match, to_match, other): origin_translated = origin_match[self.ids[0]] to1_translated = to_match[self.ids[1]] to2_translated = to_match[self.ids[2]] translated_division = Division( (origin_translated, to1_translated, to2_translated), self.timestep, other.setid ) return translated_division == other def visible_in_other( self, origin_match, to_match): return origin_match[self.ids[0]] and to_match[self.ids[1]] and to_match[self.ids[2]] def is_matched(self,origin_match, to_match): if origin_match.has_key(self.ids[0]) and to_match.has_key(self.ids[1]) and to_match.has_key(self.ids[2]): return True else: return False def traxels_contained_in(self, traxel_list): if not (self.timestep - 1, self._ids[0]) in traxel_list: return False elif not (self.timestep, self._ids[1]) in traxel_list or not (self.timestep, self._ids[2]) in traxel_list: return False else: return True def __repr__( self ): return "Division((" + str(self.ids[0]) + ", "+ str(self.ids[1])+", "+ str(self.ids[2])+ "))" class Appearance( Event ): def translate( self, origin_match, to_match, setid): origin_translated = to_match[self.ids[0]] return Appearance( (origin_translated,), self.timestep, setid ) def equivalent_to( self, origin_match, to_match, other): origin_translated = to_match[self.ids[0]] translated_appearance = Appearance( (origin_translated,), self.timestep, other.setid ) return translated_appearance == other def visible_in_other( self, origin_match, to_match): return to_match[self.ids[0]] def is_matched(self,origin_match, to_match): if to_match.has_key(self.ids[0]): return True else: return False def __repr__( self ): return "Appearance((" + str(self.ids[0]) + ",))" class Disappearance( Event ): def translate( self, origin_match, to_match, setid): origin_translated = origin_match[self.ids[0]] return Disappearance( (origin_translated,), self.timestep, setid ) def equivalent_to( self, origin_match, to_match, other): origin_translated = origin_match[self.ids[0]] translated_disappearance = Disappearance( (origin_translated,), self.timestep, other.setid ) return translated_disappearance == other def visible_in_other( self, origin_match, to_match): return origin_match[self.ids[0]] def is_matched(self,origin_match, to_match): if origin_match.has_key(self.ids[0]): return True else: return False def traxels_contained_in(self, traxel_list): if not (self.timestep - 1, self._ids[0]) in traxel_list: return False else: return True def __repr__( self ): return "Disappearance((" + str(self.ids[0]) + ",))" ### ### routines to create and work with Event Sets ### def event_set_from( lineageH5, setid='base' ): '''Extract tracking results from a lineageH5 file as Events. Tracking information has to be present, of course. Returns a Set of Event objects. ''' events = set() mov_ids = lineageH5.get_moves() for mov in mov_ids: e = Move((mov[0], mov[1]), lineageH5.timestep, setid) events.add(e) merg_ids = lineageH5.get_mergers() for merg in merg_ids: e = Merger((merg[0], merg[1]), lineageH5.timestep, setid) events.add(e) mult_ids = lineageH5.get_multiFrameMoves() for mult in mult_ids: e = MultiFrameMove((mult[0], mult[1], mult[2]), lineageH5.timestep, setid) events.add(e) div_ids = lineageH5.get_divisions() for div in div_ids: e = Division((div[0], div[1], div[2]), lineageH5.timestep, setid) events.add(e) app_ids = lineageH5.get_appearances() for app in app_ids: if isinstance(app, np.ndarray): app = app[0] e = Appearance((app,), lineageH5.timestep, setid) events.add(e) dis_ids = lineageH5.get_disappearances() for dis in dis_ids: if isinstance(dis, np.ndarray): dis = dis[0] e = Disappearance((dis,), lineageH5.timestep, setid) events.add(e) return events def subset_by_correspondence(match_prev, match_curr, events, other_events): '''Divide set into matched and unmatched events. events - set to be divided other_events - set to compare to match_* - { events_id: match_to_id } Return subset of matched events. ''' ret = set() if not other_events: return ret for oe in other_events: setid = oe.setid break def reducer( e ): translated = e.translate(match_prev, match_curr, setid) if translated and translated in other_events: ret.add(e) map(reducer, events) #for e in events: # translated = e.translate(match_prev, match_curr) # if translated and translated in list(other_events): # sets compare by hash, lists by eq # ret.add(e) return ret def subset_by_visibility(match_prev, match_curr, events): '''Divide set by matching detections in the other set. Correspondence by visibility is a precondition for full correspondence. events - set to be divided match_* - { events_id: match_to_id } Return the subset of events, that are potentially detectable in the other set. ''' ret = set() for e in events: if e.visible_in_other(match_prev, match_curr): ret.add(e) return ret def by_type( events, type=Event ): '''Filter iterable events by type (Move, Division etc.) and return a list of passed Events.''' s = set([ e for e in events if isinstance(e, type) ]) return s ### ### Classification of Events and performance measures ### class Taxonomy( object ): '''Classification of elements in base and contestant event sets.''' def __init__( self, s ): '''The following sets are expected to be present as keys in the 's' dictionary:: - base_basic # all Events in base set - cont_basic # all Events in contestant set - base_v # Events are visible in contestant set - base_c # Events have corresponding Events in contestant set - cont_v - cont_c - base_d # deficient due to tracking or detection error - base_dd # deficient due to detection error - base_dt # deficient due to tracking error - cont_d - cont_dd - cont_dt ''' self.base_basic = s["base_basic"] self.cont_basic = s["cont_basic"] self.base_v = s["base_v"] self.base_c = s["base_c"] self.cont_v = s["cont_v"] self.cont_c = s["cont_c"] self.base_d = s["base_d"] self.base_dd = s["base_dd"] self.base_dt = s["base_dt"] self.cont_d = s["cont_d"] self.cont_dd = s["cont_dd"] self.cont_dt = s["cont_dt"] if not self._is_valid(): raise Exception("Taxonomy::__init__: (sub)-sets don't fit together") def _is_valid( self ): '''Test if (sub)-sets fit together.''' b = [] b.append(len(self.base_c) == len(self.cont_c)) b.append(self.base_c.issubset(self.base_v)) b.append(self.cont_c.issubset(self.cont_v)) b.append(self.cont_d == self.cont_dd.union(self.cont_dt)) b.append(self.base_d == self.base_dd.union(self.base_dt)) if not reduce(lambda r, v: r == v, b): return False else: return True def union( self, other ): '''Return a union between this and another Taxonomy.''' if not other._is_valid(): raise Exception("Taxonomy::union(): other is not a valid Taxonomy)") s = { 'base_basic': self.base_basic.union( other.base_basic ), 'cont_basic': self.cont_basic.union( other.cont_basic ), 'base_v': self.base_v.union( other.base_v ), 'base_c': self.base_c.union( other.base_c ), 'cont_v': self.cont_v.union( other.cont_v ), 'cont_c': self.cont_c.union( other.cont_c ), 'base_d': self.base_d.union( other.base_d ), 'base_dd': self.base_dd.union( other.base_dd ), 'base_dt': self.base_dt.union( other.base_dt ), 'cont_d': self.cont_d.union( other.cont_d ), 'cont_dd': self.cont_dd.union( other.cont_dd ), 'cont_dt': self.cont_dt.union( other.cont_dt ) } return Taxonomy( s ) @staticmethod def _safe_frac(enum, denom): if enum == 0 and denom == 0: return float('nan') else: return 1.0 * enum/denom def precision(self, type=Event): enum = len(by_type(self.cont_c, type)) denom = len(by_type(self.cont_basic, type)) return self._safe_frac(enum, denom) def precision_given_visibility(self, type=Event): enum = len(by_type(self.cont_c, type)) denom = len(by_type(self.cont_basic, type)) - len(by_type(self.cont_dd, type)) return self._safe_frac(enum, denom) def recall(self, type=Event): enum = len(by_type(self.base_c, type)) denom = len(by_type(self.base_basic, type)) return self._safe_frac(enum, denom) def recall_given_visibility(self, type=Event): enum = len(by_type(self.base_c, type)) denom = len(by_type(self.base_basic, type)) - len(by_type(self.base_dd, type)) return self._safe_frac(enum, denom) def f_measure(self, type=Event): enum = len(by_type(self.base_c, type).union(by_type(self.cont_c, type))) a = (len(by_type(self.base_c, type)) + len(by_type(self.cont_c, type))) assert(enum == a ), str(enum) + " " + str(a) denom = len(by_type(self.base_basic, type).union(by_type(self.cont_basic, type))) f = self._safe_frac(enum, denom) #if not math.isnan(f): # f_check = 2 * self.precision(type) * self.recall(type) / (self.precision(type) + self.recall(type)) # if not math.isnan(f_check): # assert( abs(f - f_check) < 0.0000001), str(f) + " - " + str(f_check) return f def f_measure_given_visibility(self, type=Event): enum = len(by_type(self.base_c, type).union(by_type(self.cont_c, type))) denom = len(by_type(self.base_basic, type).union(by_type(self.cont_basic, type))) \ - len(by_type(self.base_dd, type)) \ - len(by_type(self.cont_dd, type)) return self._safe_frac(enum, denom) def all_stats( self ): """Fill a dictionary with all kinds of stats.""" return { "n_base": len(self.base_basic), "n_cont": len(self.cont_basic), "precision": self.precision(), "recall": self.recall(), "f_measure": self.f_measure(), "mov_n_base": len(by_type(self.base_basic, Move)), "mov_n_cont": len(by_type(self.cont_basic, Move)), "mov_prec": self.precision(Move), "mov_rec": self.recall(Move), "mov_f": self.f_measure(Move), "merg_n_base": len(by_type(self.base_basic, Merger)), "merg_n_cont": len(by_type(self.cont_basic, Merger)), "merg_prec": self.precision(Merger), "merg_rec": self.recall(Merger), "merg_f": self.f_measure(Merger), "mult_n_base": len(by_type(self.base_basic, MultiFrameMove)), "mult_n_cont": len(by_type(self.cont_basic, MultiFrameMove)), "mult_prec": self.precision(MultiFrameMove), "mult_rec": self.recall(MultiFrameMove), "mult_f": self.f_measure(MultiFrameMove), "div_n_base": len(by_type(self.base_basic, Division)), "div_n_cont": len(by_type(self.cont_basic, Division)), "div_prec": self.precision(Division), "div_rec": self.recall(Division), "div_f": self.f_measure(Division), "app_n_base": len(by_type(self.base_basic, Appearance)), "app_n_cont": len(by_type(self.cont_basic, Appearance)), "app_prec": self.precision(Appearance), "app_rec": self.recall(Appearance), "app_f": self.f_measure(Appearance), "dis_n_base": len(by_type(self.base_basic, Disappearance)), "dis_n_cont": len(by_type(self.cont_basic, Disappearance)), "dis_prec": self.precision(Disappearance), "dis_rec": self.recall(Disappearance), "dis_f": self.f_measure(Disappearance), "n_base_v": len(self.base_v), "n_cont_v": len(self.cont_v), "precision_v": self.precision_given_visibility(), "recall_v": self.recall_given_visibility(), "f_measure_v": self.f_measure_given_visibility(), "mov_n_base_v": len(by_type(self.base_v, Move)), "mov_n_cont_v": len(by_type(self.cont_v, Move)), "mov_prec_v": self.precision_given_visibility(Move), "mov_rec_v": self.recall_given_visibility(Move), "mov_f_v": self.f_measure_given_visibility(Move), "merg_n_base_v": len(by_type(self.base_v, Merger)), "merg_n_cont_v": len(by_type(self.cont_v, Merger)), "merg_prec_v": self.precision_given_visibility(Merger), "merg_rec_v": self.recall_given_visibility(Merger), "merg_f_v": self.f_measure_given_visibility(Merger), "mult_n_base_v": len(by_type(self.base_v, MultiFrameMove)), "mult_n_cont_v": len(by_type(self.cont_v, MultiFrameMove)), "mult_prec_v": self.precision_given_visibility(MultiFrameMove), "mult_rec_v": self.recall_given_visibility(MultiFrameMove), "mult_f_v": self.f_measure_given_visibility(MultiFrameMove), "div_n_base_v": len(by_type(self.base_v, Division)), "div_n_cont_v": len(by_type(self.cont_v, Division)), "div_prec_v": self.precision_given_visibility(Division), "div_rec_v": self.recall_given_visibility(Division), "div_f_v": self.f_measure_given_visibility(Division), "app_n_base_v": len(by_type(self.base_v, Appearance)), "app_n_cont_v": len(by_type(self.cont_v, Appearance)), "app_prec_v": self.precision_given_visibility(Appearance), "app_rec_v": self.recall_given_visibility(Appearance), "app_f_v": self.f_measure_given_visibility(Appearance), "dis_n_base_v": len(by_type(self.base_v, Disappearance)), "dis_n_cont_v": len(by_type(self.cont_v, Disappearance)), "dis_prec_v": self.precision_given_visibility(Disappearance), "dis_rec_v": self.recall_given_visibility(Disappearance), "dis_f_v": self.f_measure_given_visibility(Disappearance) } def to_line( self ): line = '%(n_base)d,%(n_cont)d,%(precision).4f,%(recall).4f,%(f_measure).4f,%(mov_n_base)d,%(mov_n_cont)d,%(mov_prec).4f,%(mov_rec).4f,%(mov_f).4f,%(merg_n_base)d,%(merg_n_cont)d,%(merg_prec).4f,%(merg_rec).4f,%(merg_f).4f,%(div_n_base)d,%(div_n_cont)d,%(div_prec).4f,%(div_rec).4f,%(div_f).4f,%(app_n_base)d,%(app_n_cont)d,%(app_prec).4f,%(app_rec).4f,%(app_f).4f,%(dis_n_base)d,%(dis_n_cont)d,%(dis_prec).4f,%(dis_rec).4f,%(dis_f).4f,%(mult_n_base)d,%(mult_n_cont)d,%(mult_prec).4f,%(mult_rec).4f,%(mult_f).4f' % self.all_stats() return line def __str__( self ): pretty = \ '''[overall] n_base = %(n_base)d n_contestant = %(n_cont)d precision = %(precision).4f recall = %(recall).4f f_measure = %(f_measure).4f: [move] n_base = %(mov_n_base)d n_contestant = %(mov_n_cont)d precision = %(mov_prec).4f recall = %(mov_rec).4f f_measure = %(mov_f).4f [merger] n_base = %(merg_n_base)d n_contestant = %(merg_n_cont)d precision = %(merg_prec).4f recall = %(merg_rec).4f f_measure = %(merg_f).4f [multiFrameMove] n_base = %(mult_n_base)d n_contestant = %(mult_n_cont)d precision = %(mult_prec).4f recall = %(mult_rec).4f f_measure = %(mult_f).4f [division] n_base = %(div_n_base)d n_contestant = %(div_n_cont)d precision = %(div_prec).4f recall = %(div_rec).4f f_measure = %(div_f).4f [appearance] n_base = %(app_n_base)d n_contestant = %(app_n_cont)d precision = %(app_prec).4f recall = %(app_rec).4f f_measure = %(app_f).4f [disappearance] n_base = %(dis_n_base)d n_contestant = %(dis_n_cont)d precision = %(dis_prec).4f recall = %(dis_rec).4f f_measure = %(dis_f).4f [overall|visibility] n_base = %(n_base_v)d n_contestant = %(n_cont_v)d precision = %(precision_v).4f recall = %(recall_v).4f f_measure = %(f_measure_v).4f [move|visibility] n_base = %(mov_n_base_v)d n_contestant = %(mov_n_cont_v)d precision = %(mov_prec_v).4f recall = %(mov_rec_v).4f f_measure = %(mov_f_v).4f [division|visibility] n_base = %(div_n_base_v)d n_contestant = %(div_n_cont_v)d precision = %(div_prec_v).4f recall = %(div_rec_v).4f f_measure = %(div_f_v).4f [appearance|visibility] n_base = %(app_n_base_v)d n_contestant = %(app_n_cont_v)d precision = %(app_prec_v).4f recall = %(app_rec_v).4f f_measure = %(app_f_v).4f [disappearance|visibility] n_base = %(dis_n_base_v)d n_contestant = %(dis_n_cont_v)d precision = %(dis_prec_v).4f recall = %(dis_rec_v).4f f_measure = %(dis_f_v).4f ''' % self.all_stats() return pretty def classify_event_sets(base_events, cont_events, prev_assoc, curr_assoc): '''Return a Taxonomy of the elements in base and contestant set. *_events - Set of Event *_assoc - {'lhs': { base_id: cont_id}, 'rhs': { cont_id: base_id}} (in general, 'lhs' is considered as base and 'rhs' is contestant) ''' t = dict() t["base_basic"] = base_events t["cont_basic"] = cont_events # 'positive' sets, that contain (partially) matched events t["base_v"] = subset_by_visibility(prev_assoc['lhs'], curr_assoc['lhs'], t["base_basic"]) t["base_c"] = subset_by_correspondence(prev_assoc['lhs'], curr_assoc['lhs'], t["base_basic"], t["cont_basic"]) t["cont_v"] = subset_by_visibility(prev_assoc['rhs'], curr_assoc['rhs'], t["cont_basic"]) t["cont_c"] = subset_by_correspondence(prev_assoc['rhs'], curr_assoc['rhs'], t["cont_basic"], t["base_basic"]) assert(len(t["base_c"]) == len(t["cont_c"])), str(len(t["base_c"])) + " " +str(len(t["cont_c"])) # intersections from the 'positive' sets, that contain spurious events # dd: deficient due to detection error # dt: deficient due to tracking error (given correct detection) # d: deficient due to tracking or detection error t["base_d"] = t["base_basic"].difference(t["base_c"]) t["base_dd"] = t["base_basic"].difference(t["base_v"]) t["base_dt"] = t["base_v"].difference(t["base_c"]) t["cont_d"] = t["cont_basic"].difference(t["cont_c"]) t["cont_dd"] = t["cont_basic"].difference(t["cont_v"]) t["cont_dt"] = t["cont_v"].difference(t["cont_c"]) return Taxonomy(t) def compute_taxonomy(prev_assoc, curr_assoc, base_fn, cont_fn, timestep=0): ''' Convenience function around 'classify_event_sets'. *_fn - LineageH5 filename ''' with _io.LineageH5(base_fn, 'r', timestep=timestep) as f: base_events = event_set_from( f, 'base' ) del f with _io.LineageH5(cont_fn, 'r', timestep=timestep) as f: cont_events = event_set_from( f, 'cont' ) del f # check, if events and assocs fit together for e in base_events: if not e.is_matched(prev_assoc['lhs'], curr_assoc['lhs']): raise Exception("Base Event %s: id(s) not present in assocs" % str(e)) for e in cont_events: if not e.is_matched(prev_assoc['rhs'], curr_assoc['rhs']): raise Exception("Contestant Event %s: id(s) not present in assocs" % str(e)) return classify_event_sets(base_events, cont_events, prev_assoc, curr_assoc) def compute_filtered_taxonomy(prev_assoc, curr_assoc, base_fn, cont_fn, cont_traxels, timestep=0): ''' Convenience function around 'classify_event_sets'. *_fn - LineageH5 filename cont_traxels: is a list of traxels to which the evaluation is restricted. The events of the contestant will be filtered to contain only those traxels. ''' with _io.LineageH5(base_fn, 'r', timestep=timestep) as f: base_events = event_set_from( f, 'base' ) del f with _io.LineageH5(cont_fn, 'r', timestep=timestep) as f: cont_events = event_set_from( f, 'cont' ) del f # event filtering base_traxels = [(t_time, curr_assoc['rhs'][t_id]) for t_time, t_id in cont_traxels if t_time == timestep and t_id in curr_assoc['rhs']] base_traxels += [(t_time, prev_assoc['rhs'][t_id]) for t_time, t_id in cont_traxels if t_time == timestep - 1 and t_id in prev_assoc['rhs']] filtered_base_events = set() for e in base_events: if e.traxels_contained_in(base_traxels): filtered_base_events.add(e) filtered_cont_events = set() for e in cont_events: if e.traxels_contained_in(cont_traxels): filtered_cont_events.add(e) # check, if events and assocs fit together for e in filtered_base_events: if not e.is_matched(prev_assoc['lhs'], curr_assoc['lhs']): raise Exception("Base Event %s: id(s) not present in assocs" % str(e)) for e in filtered_cont_events: if not e.is_matched(prev_assoc['rhs'], curr_assoc['rhs']): raise Exception("Contestant Event %s: id(s) not present in assocs" % str(e)) return classify_event_sets(filtered_base_events, filtered_cont_events, prev_assoc, curr_assoc) ### ### Tests ### class TestDivision( _ut.TestCase ): def testEq( self ): d1 = Division([11,15,17], 0) d2 = Division([11,17,15], 0) d3 = Division([15,11,17], 0) d4 = Division([15,11,17], 1) self.assertTrue(d1 == d1) self.assertTrue(d1 == d2) self.assertFalse(d1 == d3) self.assertFalse(d1 == d4) class TestTraxelContainedInMethod(_ut.TestCase): def testMove(self): m = Move((1, 1), 1) # no traxel in, should return false traxels = [] self.assertFalse(m.traxels_contained_in(traxels)) traxels = [(123, 312)] self.assertFalse(m.traxels_contained_in(traxels)) # only one traxel in, should return false traxels = [(1, 1)] self.assertFalse(m.traxels_contained_in(traxels)) traxels = [(0, 1)] self.assertFalse(m.traxels_contained_in(traxels)) # both traxels in traxels = [(0, 1), (1, 1)] self.assertTrue(m.traxels_contained_in(traxels)) def testDivision(self): d = Division((1, 1, 2), 1) # no traxel in, should return false traxels = [] self.assertFalse(d.traxels_contained_in(traxels)) traxels = [(123, 312)] self.assertFalse(d.traxels_contained_in(traxels)) # only one traxel in, should return false traxels = [(1, 1)] self.assertFalse(d.traxels_contained_in(traxels)) traxels = [(0, 1)] self.assertFalse(d.traxels_contained_in(traxels)) # all traxels in traxels = [(0, 1), (1, 1), (1, 2)] self.assertTrue(d.traxels_contained_in(traxels)) def testAppearance(self): a = Appearance((3,), 1) # no traxel in, should return false traxels = [] self.assertFalse(a.traxels_contained_in(traxels)) traxels = [(123, 312)] self.assertFalse(a.traxels_contained_in(traxels)) # all traxels in traxels = [(1, 3), (1, 1), (1, 2)] self.assertTrue(a.traxels_contained_in(traxels)) def testDisappearance(self): a = Disappearance((3,), 1) # no traxel in, should return false traxels = [] self.assertFalse(a.traxels_contained_in(traxels)) traxels = [(123, 312)] self.assertFalse(a.traxels_contained_in(traxels)) # all traxels in traxels = [(0, 3)] self.assertTrue(a.traxels_contained_in(traxels)) class TestTaxonomy( _ut.TestCase ): def setUp( self ): self.empty = { 'base_basic': set(), 'cont_basic': set(), 'base_v': set(), 'base_c': set(), 'cont_v': set(), 'cont_c': set(), 'base_d': set(), 'base_dd': set(), 'base_dt': set(), 'cont_d': set(), 'cont_dd': set(), 'cont_dt': set(), } self.typical = { 'base_basic': set((1,2,3,4,5)), 'cont_basic': set((6,7,8,9)), 'base_v': set((1,2,4,5)), 'base_c': set((1,2)), 'cont_v': set((6,7,9)), 'cont_c': set((6,7)), 'base_d': set((3,4,5)), 'base_dd': set((3,)), 'base_dt': set((4,5)), 'cont_d': set((8,9)), 'cont_dd': set((8,)), 'cont_dt': set((9,)), } def test_constructor( self ): # shouldn't throw Taxonomy(self.empty) Taxonomy(self.typical) def test_precision( self ): t = Taxonomy(self.typical) self.assertEqual(t.precision(type=int), 2./4.) def test_precision_given_visibility( self ): t = Taxonomy(self.typical) self.assertEqual(t.precision_given_visibility(type=int), 2./3.) def test_recall( self ): t = Taxonomy(self.typical) self.assertEqual(t.recall(type=int), 2./5.) def test_recall_given_visibility( self ): t = Taxonomy(self.typical) self.assertEqual(t.recall_given_visibility(type=int), 2./4.) def test_f_measure( self ): t = Taxonomy(self.typical) self.assertEqual(t.f_measure(type=int), 4./9.) def test_f_measure_given_visibility( self ): t = Taxonomy(self.typical) self.assertEqual(t.f_measure_given_visibility(type=int), 4./7.) class Test_classify_event_sets( _ut.TestCase ): def test_typical( self ): base_events = set(( Move((1,1), 0), Disappearance((2,), 0), Appearance((3,), 0), Division((4,5,6), 0), Appearance((7,), 0) )) cont_events = set(( Move((10,10), 0), Move((20,30), 0), Division((40,50,60), 0), Move((80,90), 0) )) prev_assoc = { 'lhs': { 1: 10, 2: 20, 4: 40 }, 'rhs': { 10: 1, 20: 2, 40: 4, 80: None}} curr_assoc = { 'lhs': { 1: 10, 3: 30, 5: 50, 6: 60, 7: None }, 'rhs': { 10: 1, 30: 3, 50: 5, 60: 6, 90: None }} t = classify_event_sets(base_events, cont_events, prev_assoc, curr_assoc) import math self.assertEqual(t.precision(), 2./4.) self.assertEqual(t.recall(), 2./5.) self.assertEqual(t.f_measure(), 4./9.) self.assertEqual(t.precision(Move), 1./3.) self.assertEqual(t.recall(Move), 1.) self.assertEqual(t.f_measure(Move), 2./4.) self.assertEqual(t.precision(Division), 1.) self.assertEqual(t.recall(Division), 1.) self.assertEqual(t.f_measure(Division), 2./2.) self.assertTrue(math.isnan(t.precision(Appearance))) self.assertEqual(t.recall(Appearance), 0.) self.assertEqual(t.f_measure(Appearance), 0.) self.assertTrue(math.isnan(t.precision(Disappearance))) self.assertEqual(t.recall(Disappearance), 0.) self.assertEqual(t.f_measure(Disappearance), 0.) if __name__ == '__main__': _ut.main()
mit
[ 646, 2882, 465, 485, 337, 199, 646, 2680, 465, 980, 199, 504, 9052, 651, 12732, 492, 5890, 465, 485, 2308, 199, 646, 3473, 199, 199, 5680, 199, 5680, 27982, 465, 7556, 402, 5951, 367, 314, 15232, 402, 10238, 17616, 1482, 199, 5680, 199, 533, 6763, 8, 909, 3461, 272, 768, 1829, 272, 347, 542, 5700, 8, 291, 3461, 267, 372, 291, 423, 261, 5700, 339, 768, 1829, 272, 347, 900, 2926, 8, 291, 3461, 267, 372, 291, 423, 521, 2926, 339, 347, 636, 826, 721, 291, 12, 2762, 12, 900, 2926, 12, 542, 5700, 534, 1095, 7, 3461, 267, 291, 423, 1580, 275, 2008, 8, 1580, 9, 267, 291, 423, 521, 2926, 275, 900, 2926, 267, 291, 423, 261, 5700, 275, 542, 5700, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 1449, 1271, 9553, 26, 4182, 365, 440, 1923, 28177, 1, 2344, 267, 340, 1228, 8, 1848, 12, 291, 855, 533, 18580, 288, 372, 291, 14, 1580, 508, 1163, 14, 1580, 436, 291, 14, 521, 2926, 508, 1163, 14, 521, 2926, 267, 587, 26, 288, 372, 756, 272, 347, 636, 685, 721, 291, 12, 1163, 304, 267, 372, 440, 8, 277, 508, 1163, 9, 339, 347, 636, 2227, 721, 291, 3461, 267, 372, 2631, 1332, 277, 423, 1580, 12, 291, 423, 521, 2926, 12, 291, 855, 533, 3108, 291, 423, 261, 5700, 430, 339, 768, 1829, 272, 347, 2762, 8, 291, 3461, 267, 372, 291, 423, 1580, 339, 347, 9028, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 3461, 267, 1449, 2790, 282, 892, 7353, 1566, 14, 1449, 267, 746, 4279, 339, 347, 7353, 63, 475, 8, 277, 12, 6330, 63, 1431, 12, 370, 63, 1431, 12, 1163, 304, 267, 1449, 1799, 12, 340, 314, 283, 1848, 7, 6763, 13718, 370, 314, 1627, 1373, 14, 398, 5439, 1566, 1077, 506, 315, 282, 3365, 5678, 663, 334, 22051, 283, 1095, 7, 503, 267, 283, 388, 396, 867, 358, 2728, 20841, 1431, 446, 469, 4474, 63, 344, 26, 1336, 63, 475, 63, 344, 221, 789, 267, 1163, 446, 6763, 267, 1449, 267, 746, 4279, 339, 347, 8917, 63, 262, 63, 1848, 8, 277, 12, 6330, 63, 1431, 12, 370, 63, 1431, 304, 267, 1449, 1799, 340, 6763, 4293, 506, 23268, 315, 1163, 5678, 663, 12, 2952, 314, 623, 10479, 1958, 4960, 10106, 4898, 737, 5210, 10501, 14, 398, 20841, 1431, 446, 469, 4474, 63, 344, 26, 1336, 63, 475, 63, 344, 221, 789, 267, 1449, 267, 746, 4279, 339, 347, 1468, 88, 18099, 63, 30288, 63, 262, 8, 277, 12, 1468, 31418, 63, 513, 304, 267, 1449, 267, 2670, 340, 1006, 1468, 88, 18099, 626, 787, 1202, 315, 642, 1566, 787, 3451, 315, 314, 1468, 31418, 63, 513, 14, 267, 1468, 31418, 63, 513, 446, 769, 402, 334, 521, 2926, 12, 1468, 31418, 998, 9, 6346, 398, 7259, 952, 642, 1083, 340, 440, 1006, 1468, 88, 18099, 402, 376, 6763, 787, 315, 314, 2011, 900, 2926, 1, 267, 334, 10370, 12, 2153, 27307, 554, 436, 3757, 2317, 3659, 4136, 900, 5895, 21866, 267, 1449, 267, 367, 284, 315, 291, 423, 1580, 26, 288, 340, 440, 334, 277, 14, 521, 2926, 12, 284, 9, 315, 1468, 31418, 63, 513, 26, 355, 372, 756, 267, 372, 715, 339, 6754, 10201, 272, 347, 365, 63, 10151, 8, 277, 12, 6330, 63, 1431, 12, 370, 63, 1431, 304, 267, 746, 4279, 199, 199, 533, 14171, 8, 6763, 3461, 272, 347, 9028, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 12, 542, 5700, 3461, 267, 6330, 63, 18065, 275, 6330, 63, 1431, 59, 277, 14, 1580, 59, 16, 2677, 267, 370, 63, 18065, 275, 370, 63, 1431, 59, 277, 14, 1580, 59, 17, 2677, 267, 372, 14171, 8, 334, 6493, 63, 18065, 12, 370, 63, 18065, 395, 291, 14, 521, 2926, 12, 542, 5700, 9, 5493, 347, 7353, 63, 475, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 12, 1163, 304, 267, 6330, 63, 18065, 275, 6330, 63, 1431, 59, 277, 14, 1580, 59, 16, 2677, 267, 370, 63, 18065, 275, 370, 63, 1431, 59, 277, 14, 1580, 59, 17, 2677, 267, 14598, 63, 1185, 275, 14171, 1332, 6493, 63, 18065, 12, 370, 63, 18065, 395, 291, 14, 521, 2926, 12, 1163, 14, 261, 5700, 9, 267, 372, 14598, 63, 1185, 508, 1163, 339, 347, 8917, 63, 262, 63, 1848, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 304, 267, 372, 6330, 63, 1431, 59, 277, 14, 1580, 59, 16, 2677, 436, 370, 63, 1431, 59, 277, 14, 1580, 59, 17, 2677, 339, 347, 365, 63, 10151, 8, 277, 12, 6330, 63, 1431, 12, 370, 63, 1431, 304, 267, 340, 6330, 63, 1431, 14, 1989, 63, 498, 8, 277, 14, 1580, 59, 16, 566, 436, 370, 63, 1431, 14, 1989, 63, 498, 8, 277, 14, 1580, 59, 17, 4682, 288, 372, 715, 267, 587, 26, 288, 372, 756, 339, 347, 1468, 88, 18099, 63, 30288, 63, 262, 8, 277, 12, 1468, 31418, 63, 513, 304, 267, 340, 440, 334, 277, 14, 521, 2926, 446, 413, 12, 291, 423, 1580, 59, 16, 566, 315, 1468, 31418, 63, 513, 26, 288, 372, 756, 267, 916, 440, 334, 277, 14, 521, 2926, 12, 291, 423, 1580, 59, 17, 566, 315, 1468, 31418, 63, 513, 26, 288, 372, 756, 267, 587, 26, 288, 372, 715, 339, 347, 636, 2722, 721, 291, 3461, 267, 372, 298, 10370, 9313, 435, 620, 8, 277, 14, 1580, 59, 16, 566, 435, 3872, 7210, 620, 8, 277, 14, 1580, 59, 17, 29030, 26725, 2, 199, 199, 533, 18880, 836, 8, 6763, 3461, 272, 347, 9028, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 12, 542, 5700, 3461, 267, 340, 291, 14, 1580, 59, 16, 61, 1137, 370, 63, 1431, 59, 277, 14, 1580, 59, 16, 27589, 288, 746, 6064, 360, 5275, 26, 7761, 440, 3748, 358, 2728, 372, 18880, 836, 8, 2008, 8, 277, 14, 1580, 395, 291, 14, 521, 2926, 12, 542, 5700, 776, 5493, 347, 7353, 63, 475, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 12, 1163, 304, 267, 340, 291, 14, 1580, 59, 16, 61, 1137, 370, 63, 1431, 59, 277, 14 ]
[ 2882, 465, 485, 337, 199, 646, 2680, 465, 980, 199, 504, 9052, 651, 12732, 492, 5890, 465, 485, 2308, 199, 646, 3473, 199, 199, 5680, 199, 5680, 27982, 465, 7556, 402, 5951, 367, 314, 15232, 402, 10238, 17616, 1482, 199, 5680, 199, 533, 6763, 8, 909, 3461, 272, 768, 1829, 272, 347, 542, 5700, 8, 291, 3461, 267, 372, 291, 423, 261, 5700, 339, 768, 1829, 272, 347, 900, 2926, 8, 291, 3461, 267, 372, 291, 423, 521, 2926, 339, 347, 636, 826, 721, 291, 12, 2762, 12, 900, 2926, 12, 542, 5700, 534, 1095, 7, 3461, 267, 291, 423, 1580, 275, 2008, 8, 1580, 9, 267, 291, 423, 521, 2926, 275, 900, 2926, 267, 291, 423, 261, 5700, 275, 542, 5700, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 1449, 1271, 9553, 26, 4182, 365, 440, 1923, 28177, 1, 2344, 267, 340, 1228, 8, 1848, 12, 291, 855, 533, 18580, 288, 372, 291, 14, 1580, 508, 1163, 14, 1580, 436, 291, 14, 521, 2926, 508, 1163, 14, 521, 2926, 267, 587, 26, 288, 372, 756, 272, 347, 636, 685, 721, 291, 12, 1163, 304, 267, 372, 440, 8, 277, 508, 1163, 9, 339, 347, 636, 2227, 721, 291, 3461, 267, 372, 2631, 1332, 277, 423, 1580, 12, 291, 423, 521, 2926, 12, 291, 855, 533, 3108, 291, 423, 261, 5700, 430, 339, 768, 1829, 272, 347, 2762, 8, 291, 3461, 267, 372, 291, 423, 1580, 339, 347, 9028, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 3461, 267, 1449, 2790, 282, 892, 7353, 1566, 14, 1449, 267, 746, 4279, 339, 347, 7353, 63, 475, 8, 277, 12, 6330, 63, 1431, 12, 370, 63, 1431, 12, 1163, 304, 267, 1449, 1799, 12, 340, 314, 283, 1848, 7, 6763, 13718, 370, 314, 1627, 1373, 14, 398, 5439, 1566, 1077, 506, 315, 282, 3365, 5678, 663, 334, 22051, 283, 1095, 7, 503, 267, 283, 388, 396, 867, 358, 2728, 20841, 1431, 446, 469, 4474, 63, 344, 26, 1336, 63, 475, 63, 344, 221, 789, 267, 1163, 446, 6763, 267, 1449, 267, 746, 4279, 339, 347, 8917, 63, 262, 63, 1848, 8, 277, 12, 6330, 63, 1431, 12, 370, 63, 1431, 304, 267, 1449, 1799, 340, 6763, 4293, 506, 23268, 315, 1163, 5678, 663, 12, 2952, 314, 623, 10479, 1958, 4960, 10106, 4898, 737, 5210, 10501, 14, 398, 20841, 1431, 446, 469, 4474, 63, 344, 26, 1336, 63, 475, 63, 344, 221, 789, 267, 1449, 267, 746, 4279, 339, 347, 1468, 88, 18099, 63, 30288, 63, 262, 8, 277, 12, 1468, 31418, 63, 513, 304, 267, 1449, 267, 2670, 340, 1006, 1468, 88, 18099, 626, 787, 1202, 315, 642, 1566, 787, 3451, 315, 314, 1468, 31418, 63, 513, 14, 267, 1468, 31418, 63, 513, 446, 769, 402, 334, 521, 2926, 12, 1468, 31418, 998, 9, 6346, 398, 7259, 952, 642, 1083, 340, 440, 1006, 1468, 88, 18099, 402, 376, 6763, 787, 315, 314, 2011, 900, 2926, 1, 267, 334, 10370, 12, 2153, 27307, 554, 436, 3757, 2317, 3659, 4136, 900, 5895, 21866, 267, 1449, 267, 367, 284, 315, 291, 423, 1580, 26, 288, 340, 440, 334, 277, 14, 521, 2926, 12, 284, 9, 315, 1468, 31418, 63, 513, 26, 355, 372, 756, 267, 372, 715, 339, 6754, 10201, 272, 347, 365, 63, 10151, 8, 277, 12, 6330, 63, 1431, 12, 370, 63, 1431, 304, 267, 746, 4279, 199, 199, 533, 14171, 8, 6763, 3461, 272, 347, 9028, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 12, 542, 5700, 3461, 267, 6330, 63, 18065, 275, 6330, 63, 1431, 59, 277, 14, 1580, 59, 16, 2677, 267, 370, 63, 18065, 275, 370, 63, 1431, 59, 277, 14, 1580, 59, 17, 2677, 267, 372, 14171, 8, 334, 6493, 63, 18065, 12, 370, 63, 18065, 395, 291, 14, 521, 2926, 12, 542, 5700, 9, 5493, 347, 7353, 63, 475, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 12, 1163, 304, 267, 6330, 63, 18065, 275, 6330, 63, 1431, 59, 277, 14, 1580, 59, 16, 2677, 267, 370, 63, 18065, 275, 370, 63, 1431, 59, 277, 14, 1580, 59, 17, 2677, 267, 14598, 63, 1185, 275, 14171, 1332, 6493, 63, 18065, 12, 370, 63, 18065, 395, 291, 14, 521, 2926, 12, 1163, 14, 261, 5700, 9, 267, 372, 14598, 63, 1185, 508, 1163, 339, 347, 8917, 63, 262, 63, 1848, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 304, 267, 372, 6330, 63, 1431, 59, 277, 14, 1580, 59, 16, 2677, 436, 370, 63, 1431, 59, 277, 14, 1580, 59, 17, 2677, 339, 347, 365, 63, 10151, 8, 277, 12, 6330, 63, 1431, 12, 370, 63, 1431, 304, 267, 340, 6330, 63, 1431, 14, 1989, 63, 498, 8, 277, 14, 1580, 59, 16, 566, 436, 370, 63, 1431, 14, 1989, 63, 498, 8, 277, 14, 1580, 59, 17, 4682, 288, 372, 715, 267, 587, 26, 288, 372, 756, 339, 347, 1468, 88, 18099, 63, 30288, 63, 262, 8, 277, 12, 1468, 31418, 63, 513, 304, 267, 340, 440, 334, 277, 14, 521, 2926, 446, 413, 12, 291, 423, 1580, 59, 16, 566, 315, 1468, 31418, 63, 513, 26, 288, 372, 756, 267, 916, 440, 334, 277, 14, 521, 2926, 12, 291, 423, 1580, 59, 17, 566, 315, 1468, 31418, 63, 513, 26, 288, 372, 756, 267, 587, 26, 288, 372, 715, 339, 347, 636, 2722, 721, 291, 3461, 267, 372, 298, 10370, 9313, 435, 620, 8, 277, 14, 1580, 59, 16, 566, 435, 3872, 7210, 620, 8, 277, 14, 1580, 59, 17, 29030, 26725, 2, 199, 199, 533, 18880, 836, 8, 6763, 3461, 272, 347, 9028, 8, 291, 12, 6330, 63, 1431, 12, 370, 63, 1431, 12, 542, 5700, 3461, 267, 340, 291, 14, 1580, 59, 16, 61, 1137, 370, 63, 1431, 59, 277, 14, 1580, 59, 16, 27589, 288, 746, 6064, 360, 5275, 26, 7761, 440, 3748, 358, 2728, 372, 18880, 836, 8, 2008, 8, 277, 14, 1580, 395, 291, 14, 521, 2926, 12, 542, 5700, 776, 5493, 347, 7353, 63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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 ]
chaubold/hytra
scripts/train_transition_classifier.py
1
17108
# pythonpath modification to make hytra and empryonic available # for import without requiring it to be installed from __future__ import print_function, absolute_import, nested_scopes, generators, division, with_statement, unicode_literals import os import sys sys.path.insert(0, os.path.abspath('..')) # standard imports from compiler.ast import flatten import logging import glob import vigra from vigra import numpy as np import h5py from sklearn.neighbors import KDTree from hytra.pluginsystem.plugin_manager import TrackingPluginManager import hytra.util.axesconversion logger = logging.getLogger('TransitionClassifier') logger.setLevel(logging.DEBUG) np.seterr(all='raise') # read in 'n2-n1' of images def read_in_images(n1, n2, files, axes): gt_labelimage = [vigra.impex.readHDF5(f, 'segmentation/labels') for f in files[n1:n2]] gt_labelimage = [hytra.util.axesconversion.adjustOrder(img, axes, 'xyzc') for img in gt_labelimage] logger.info("Found segmentation of shape {}".format(gt_labelimage[0].shape)) return gt_labelimage # compute features from input data and return them def compute_features(raw_image, labeled_image, n1, n2, pluginManager, filepath): # perhaps there is an elegant way to get into the RegionFeatureAccumulator. # For now, the new feature are a separate vector allFeat = [] for i in range(0, n2 - n1): moreFeats, _ = pluginManager.applyObjectFeatureComputationPlugins( len(raw_image.squeeze().shape)-1, raw_image[..., i, 0], labeled_image[i][..., 0], i, filepath) frameFeatureItems = [] for f in moreFeats: frameFeatureItems = frameFeatureItems + f.items() allFeat.append(dict(frameFeatureItems)) return allFeat # read in 'n2-n1' of labels def read_positiveLabels(n1, n2, files): gt_moves = [vigra.impex.readHDF5(f, 'tracking/Moves') for f in files[n1+1:n2]] return gt_moves def getValidRegionCentersAndTheirIDs(featureDict, countFeatureName='Count', regionCenterName='RegionCenter'): """ From the feature dictionary of a certain frame, find all objects with pixel count > 0, and return their region centers and ids. """ validObjectMask = featureDict[countFeatureName] > 0 validObjectMask[0] = False regionCenters = featureDict[regionCenterName][validObjectMask, :] objectIds = list(np.where(validObjectMask)[0]) return regionCenters, objectIds def negativeLabels(features, positiveLabels): """ Compute negative labels by finding 3 nearest neighbors in the next frame, and filtering out those pairings that are part of the positiveLabels. **Returns** a list of lists of pairs of indices, where there are as many inner lists as there are pairs of consecutive frames ordered by time, e.g. for frame pairs (0,1), (1,2), ... (n-1,n). Each pair in such a list then contains an index into the earlier frame of the pair, and one index into the later frame. """ numFrames = len(features) neg_lab = [] for i in range(1, numFrames): # for all frames but the first logger.debug("Frame {}\n".format(i)) frameNegLab = [] # build kdtree for frame i centersAtI, objectIdsAtI = getValidRegionCentersAndTheirIDs(features[i]) kdt = KDTree(centersAtI, metric='euclidean') # find k=3 nearest neighbors of each object of frame i-1 in frame i centersAtIMinusOne, objectIdsAtIMinusOne = getValidRegionCentersAndTheirIDs(features[i - 1]) neighb = kdt.query(centersAtIMinusOne, k=3, return_distance=False) for j in range(0, neighb.shape[0]): # for all valid objects in frame i-1 logger.debug('looking at neighbors of {} at position {}'.format( objectIdsAtIMinusOne[j], features[i - 1]['RegionCenter'][objectIdsAtIMinusOne[j], ...])) for m in range(0, neighb.shape[1]): # for all neighbors pair = [objectIdsAtIMinusOne[j], objectIdsAtI[neighb[j][m]]] if pair not in positiveLabels[i - 1].tolist(): # add one because we've removed the first element when creating the KD tree frameNegLab.append(pair) logger.debug("Adding negative example: {} at position {}".format( pair, features[i]['RegionCenter'][objectIdsAtI[neighb[j][m]], ...])) else: logger.debug("Discarding negative example {} which is a positive annotation".format(pair)) neg_lab.append(frameNegLab) return neg_lab def find_features_without_NaNs(features): """ Remove all features from the list of selected features which have NaNs """ selectedFeatures = features[0].keys() for featuresPerFrame in features: for key, value in featuresPerFrame.items(): if not isinstance(value, list) and (np.any(np.isnan(value)) or np.any(np.isinf(value))): try: selectedFeatures.remove(key) except: pass # has already been deleted forbidden = ["Global<Maximum >", "Global<Minimum >", 'Histogram', 'Polygon', 'Defect Center', 'Center', 'Input Center', 'Weighted<RegionCenter>'] for f in forbidden: if f in selectedFeatures: selectedFeatures.remove(f) selectedFeatures.sort() return selectedFeatures class TransitionClassifier: def __init__(self, selectedFeatures, numSamples=None): """ Set up a transition classifier class that makes it easy to add samples, train and store the RF. :param selectedFeatures: list of feature names that are supposed to be used :param numSamples: if given, the data array for the samples is allocated with the proper dimensions, otherwise it needs to be resized whenever new samples are added. """ self.rf = vigra.learning.RandomForest() self.mydata = None self.labels = [] self.selectedFeatures = selectedFeatures self._numSamples = numSamples self._nextIdx = 0 # TODO: check whether prediction here and in hypotheses graph script are the same! def addSample(self, f1, f2, label, pluginManager): # if self.labels == []: self.labels.append(label) # else: # self.labels = np.concatenate((np.array(self.labels),label)) # for adding batches of features features = self.constructSampleFeatureVector(f1, f2, pluginManager) if self._numSamples is None: # use vstack if self.mydata is None: self.mydata = features else: self.mydata = np.vstack((self.mydata, features)) else: # allocate full array once, then fill in row by row if self.mydata is None: self.mydata = np.zeros((self._numSamples, features.shape[0])) assert(self._nextIdx < self._numSamples) self.mydata[self._nextIdx, :] = features self._nextIdx += 1 def constructSampleFeatureVector(self, f1, f2, pluginManager): featVec = pluginManager.applyTransitionFeatureVectorConstructionPlugins(f1, f2, self.selectedFeatures) return np.array(featVec) # adding a comfortable function, where one can easily introduce the data def add_allData(self, mydata, labels): self.mydata = mydata self.labels = labels def train(self, withFeatureImportance=False): logger.info( "Training classifier from {} positive and {} negative labels".format( np.count_nonzero(np.asarray(self.labels)), len(self.labels) - np.count_nonzero(np.asarray(self.labels)))) logger.info("Training classifier from a feature vector of length {}".format(self.mydata.shape)) if withFeatureImportance: oob, featImportance = self.rf.learnRFWithFeatureSelection( self.mydata.astype("float32"), (np.asarray(self.labels)).astype("uint32").reshape(-1, 1)) logger.debug("RF feature importance: {}".format(featImportance)) # logger.debug('Feature names: {}'.format(self.featureNames)) else: oob = self.rf.learnRF( self.mydata.astype("float32"), (np.asarray(self.labels)).astype("uint32").reshape(-1, 1)) logger.info("RF trained with OOB Error {}".format(oob)) # def predictSample(self, test_data=None, f1=None, f2=None): # if test_data is not None: # return self.rf.predictLabels(test_data.astype('float32')) # else: # data = self.constructSampleFeatureVector(f1, f2) # if len(data.shape) < 2: # data = np.expand_dims(data, axis=0) # return self.rf.predictLabels(data.astype('float32')) # def predictProbabilities(self, test_data=None, f1=None, f2=None): # if test_data is not None: # return self.rf.predictProbabilities(test_data.astype('float32')) # else: # data = self.constructSampleFeatureVector(f1, f2) # print(data) # if len(data.shape) < 2: # data = np.expand_dims(data, axis=0) # return self.rf.predictProbabilities(data.astype('float32')) def predictLabels(self, test_data, threshold=0.5): prob = self.rf.predictProbabilities(test_data.astype('float32')) res = np.copy(prob) for i in range(0, len(prob)): if prob[i][1] >= threshold: res[i] = 1. else: res[i] = 0 return np.delete(res, 0, 1) def writeRF(self, outputFilename): self.rf.writeHDF5(outputFilename, pathInFile='/ClassifierForests/Forest0000') # write selected features with h5py.File(outputFilename, 'r+') as f: featureNamesH5 = f.create_group('SelectedFeatures') featureNamesH5 = featureNamesH5.create_group('Standard Object Features') for feature in self.selectedFeatures: featureNamesH5.create_group(feature) if __name__ == '__main__': import configargparse as argparse parser = argparse.ArgumentParser(description="trainRF", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('-c', '--config', is_config_file=True, help='config file path') parser.add_argument("--groundtruth", dest='filepath', type=str, nargs='+', help="read ground truth from this folder. Can be also a list of paths, to train from more datasets.", metavar="FILE") parser.add_argument("--groundtruth-axes", dest='groundtruth_axes', type=str, nargs='+', default=['xyzc'], help="axes ordering of the ground truth segmentations per frame (no t!), e.g. xyzc", metavar="FILE") parser.add_argument("--raw-data-file", dest='rawimage_filename', type=str, nargs='+', help="filepath+name of the raw image. Can be a list of paths, to train from more datasets.", metavar="FILE") parser.add_argument("--raw-data-path", dest='rawimage_h5_path', type=str, help="Path inside the rawimage HDF5 file", default='volume/data') parser.add_argument("--raw-data-axes", dest='rawimage_axes', type=str, nargs='+', default=['txyzc'], help="axes ordering of the raw image, e.g. xyztc. Can be a list of paths, to train from more datasets.", metavar="FILE") parser.add_argument("--init-frame", default=0, type=int, dest='initFrame', help="where to begin reading the frames") parser.add_argument("--end-frame", default=-1, type=int, dest='endFrame', help="where to end frames") parser.add_argument("--transition-classifier-file", dest='outputFilename', type=str, help="save RF into file", metavar="FILE") parser.add_argument("--filepattern", dest='filepattern', type=str, nargs='+', default=['0*.h5'], help="File pattern of the ground truth files. Can be also a list of paths, to train from more datasets.") parser.add_argument("--verbose", dest='verbose', action='store_true', default=False) parser.add_argument('--plugin-paths', dest='pluginPaths', type=str, nargs='+', default=[os.path.abspath('../hytra/plugins')], help='A list of paths to search for plugins for the tracking pipeline.') args, unknown = parser.parse_known_args() logging.basicConfig(level=logging.INFO) if args.verbose: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) logging.debug("Ignoring unknown parameters: {}".format(unknown)) assert len(args.rawimage_filename) == len(args.rawimage_axes) == len(args.filepattern) == len(args.filepath) == len(args.groundtruth_axes) # read raw image numSamples = 0 mlabels = None for dataset in range(len(args.rawimage_filename)): rawimage_filename = args.rawimage_filename[dataset] with h5py.File(rawimage_filename, 'r') as h5raw: rawimage = h5raw[args.rawimage_h5_path].value # transform such that the order is the following: X,Y,(Z),T, C rawimage = hytra.util.axesconversion.adjustOrder(rawimage, args.rawimage_axes[dataset], 'xyztc') logger.info('Done loading raw data from dataset {} of shape {}'.format(dataset, rawimage.shape)) # find ground truth files # filepath is now a list of filepaths' filepath = args.filepath[dataset] # filepattern is now a list of filepatterns files = glob.glob(os.path.join(filepath, args.filepattern[dataset])) files.sort() initFrame = args.initFrame endFrame = args.endFrame if endFrame < 0: endFrame += len(files) # compute features trackingPluginManager = TrackingPluginManager(verbose=args.verbose, pluginPaths=args.pluginPaths) features = compute_features(rawimage, read_in_images(initFrame, endFrame, files, args.groundtruth_axes[dataset]), initFrame, endFrame, trackingPluginManager, rawimage_filename) logger.info('Done computing features from dataset {}'.format(dataset)) selectedFeatures = find_features_without_NaNs(features) pos_labels = read_positiveLabels(initFrame, endFrame, files) neg_labels = negativeLabels(features, pos_labels) numSamples += 2 * sum([len(l) for l in pos_labels]) + sum([len(l) for l in neg_labels]) logger.info('Done extracting {} samples'.format(numSamples)) TC = TransitionClassifier(selectedFeatures, numSamples) if dataset > 0: TC.labels = mlabels # restore labels overwritten by constructor # compute featuresA for each object A from the feature matrix from Vigra def compute_ObjFeatures(features, obj): featureDict = {} for key in features: if key == "Global<Maximum >" or key == "Global<Minimum >": # this ones have only one element featureDict[key] = features[key] else: featureDict[key] = features[key][obj] return featureDict for k in range(0, len(features) - 1): for i in pos_labels[k]: # positive logger.debug("Adding positive sample {} from pos {} to {}".format( i, features[k]['RegionCenter'][i[0]], features[k + 1]['RegionCenter'][i[1]])) TC.addSample(compute_ObjFeatures( features[k], i[0]), compute_ObjFeatures(features[k + 1], i[1]), 1, trackingPluginManager) TC.addSample(compute_ObjFeatures( features[k + 1], i[1]), compute_ObjFeatures(features[k], i[0]), 1, trackingPluginManager) for i in neg_labels[k]: # negative logger.debug("Adding negative sample {} from pos {} to {}".format(i, features[k]['RegionCenter'][i[0]], features[k + 1]['RegionCenter'][i[1]])) TC.addSample(compute_ObjFeatures( features[k], i[0]), compute_ObjFeatures(features[k + 1], i[1]), 0, trackingPluginManager) mlabels =TC.labels logger.info('Done adding samples to RF. Beginning training...') TC.train() logger.info('Done training RF') srcObject = compute_ObjFeatures(features[0], 1) destObject = compute_ObjFeatures(features[1], 2) # delete file before writing if os.path.exists(args.outputFilename): os.remove(args.outputFilename) TC.writeRF(args.outputFilename) # writes learned RF to disk
mit
[ 3, 2366, 515, 7100, 370, 1852, 7188, 1239, 436, 9052, 651, 12732, 2808, 221, 199, 3, 367, 492, 1928, 29963, 652, 370, 506, 4903, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 3679, 63, 646, 12, 6032, 63, 14129, 12, 16952, 12, 4629, 12, 543, 63, 6242, 12, 2649, 63, 5955, 199, 646, 747, 199, 646, 984, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24893, 1333, 199, 3, 4465, 8925, 199, 504, 6365, 14, 1810, 492, 9378, 199, 646, 2050, 199, 646, 5739, 199, 646, 373, 528, 345, 199, 504, 373, 528, 345, 492, 2680, 465, 980, 199, 646, 394, 21, 647, 199, 504, 6357, 14, 11113, 492, 31368, 3987, 199, 504, 7188, 1239, 14, 2718, 2253, 14, 2718, 63, 2609, 492, 17507, 316, 5061, 2988, 199, 646, 7188, 1239, 14, 1974, 14, 6402, 15083, 199, 199, 2921, 275, 2050, 14, 5572, 360, 21881, 8508, 358, 199, 2921, 14, 13548, 8, 4806, 14, 5287, 9, 199, 199, 1590, 14, 261, 22406, 8, 452, 534, 3730, 358, 199, 199, 3, 1586, 315, 283, 78, 18, 13, 78, 17, 7, 402, 5935, 199, 318, 1586, 63, 262, 63, 4782, 8, 78, 17, 12, 302, 18, 12, 1584, 12, 7824, 304, 272, 16484, 63, 5561, 18865, 960, 275, 359, 433, 926, 14, 3236, 476, 14, 739, 30165, 21, 8, 70, 12, 283, 26926, 15, 3512, 358, 367, 289, 315, 1584, 59, 78, 17, 26, 78, 18, 2677, 272, 16484, 63, 5561, 18865, 960, 275, 359, 3577, 1239, 14, 1974, 14, 6402, 15083, 14, 10917, 4738, 8, 4060, 12, 7824, 12, 283, 8568, 67, 358, 367, 6050, 315, 16484, 63, 5561, 18865, 960, 61, 272, 2512, 14, 815, 480, 3601, 27315, 402, 2215, 8352, 908, 8, 3308, 63, 5561, 18865, 960, 59, 16, 1055, 1392, 430, 272, 372, 16484, 63, 5561, 18865, 960, 199, 199, 3, 4526, 4534, 687, 1324, 666, 436, 372, 3062, 199, 318, 4526, 63, 3179, 8, 1773, 63, 1569, 12, 23677, 63, 1569, 12, 302, 17, 12, 302, 18, 12, 3589, 2988, 12, 9911, 304, 272, 327, 25358, 2337, 365, 376, 325, 4170, 867, 4340, 370, 664, 1901, 314, 22240, 5968, 23384, 6109, 14, 272, 327, 2104, 3063, 12, 314, 892, 3878, 787, 282, 7396, 5477, 272, 1006, 24927, 275, 942, 272, 367, 284, 315, 1425, 8, 16, 12, 302, 18, 446, 302, 17, 304, 267, 1655, 3456, 1956, 12, 485, 275, 3589, 2988, 14, 4998, 1692, 5968, 2404, 10326, 19330, 8, 288, 822, 8, 1773, 63, 1569, 14, 16597, 1252, 1392, 7216, 17, 12, 3066, 63, 1569, 18999, 284, 12, 378, 467, 23677, 63, 1569, 59, 73, 1527, 11577, 378, 467, 284, 12, 9911, 9, 267, 2787, 5968, 7412, 275, 942, 267, 367, 289, 315, 1655, 3456, 1956, 26, 288, 2787, 5968, 7412, 275, 2787, 5968, 7412, 435, 289, 14, 1744, 342, 267, 1006, 24927, 14, 740, 8, 807, 8, 1943, 5968, 7412, 430, 272, 372, 1006, 24927, 199, 199, 3, 1586, 315, 283, 78, 18, 13, 78, 17, 7, 402, 3628, 199, 318, 1586, 63, 8965, 14016, 8, 78, 17, 12, 302, 18, 12, 1584, 304, 272, 16484, 63, 4912, 275, 359, 433, 926, 14, 3236, 476, 14, 739, 30165, 21, 8, 70, 12, 283, 14428, 15, 3716, 2310, 358, 367, 289, 315, 1584, 59, 78, 17, 11, 17, 26, 78, 18, 2677, 272, 372, 16484, 63, 4912, 199, 199, 318, 664, 3490, 10708, 18345, 878, 3325, 1918, 723, 12818, 8, 4445, 2141, 12, 221, 3660, 2338, 5968, 985, 534, 2353, 297, 221, 3660, 4897, 13551, 985, 534, 10708, 13551, 735, 272, 408, 272, 11606, 314, 3878, 2600, 402, 282, 9842, 2787, 12, 5591, 2342, 1006, 2251, 543, 7148, 2338, 690, 378, 12, 436, 372, 3932, 272, 4897, 19190, 436, 2762, 14, 272, 408, 272, 1686, 1692, 5144, 275, 3878, 2141, 59, 835, 5968, 985, 61, 690, 378, 272, 1686, 1692, 5144, 59, 16, 61, 275, 756, 2286, 4897, 18345, 878, 275, 3878, 2141, 59, 4551, 13551, 985, 1527, 1078, 1692, 5144, 12, 12228, 272, 909, 11506, 275, 769, 8, 1590, 14, 4509, 8, 1078, 1692, 5144, 2788, 16, 566, 272, 372, 4897, 18345, 878, 12, 909, 11506, 199, 199, 318, 6946, 14016, 8, 3179, 12, 7317, 14016, 304, 272, 408, 272, 8354, 6946, 3628, 701, 17196, 650, 17173, 15845, 315, 314, 2163, 2787, 12, 436, 272, 14545, 734, 5204, 4092, 780, 626, 787, 1777, 402, 314, 7317, 14016, 14, 339, 1011, 3407, 538, 282, 769, 402, 5548, 402, 6342, 402, 4918, 12, 2382, 2337, 787, 465, 5002, 6506, 5548, 272, 465, 2337, 787, 6342, 402, 23376, 11223, 7741, 701, 900, 12, 5591, 325, 14, 71, 14, 367, 2787, 6342, 334, 16, 12, 17, 395, 334, 17, 12, 18, 395, 2263, 334, 78, 13, 17, 12, 78, 680, 272, 7048, 4092, 315, 4066, 282, 769, 2066, 3509, 376, 1478, 1901, 314, 14119, 2787, 402, 314, 4092, 12, 5591, 436, 1373, 1478, 1901, 314, 2945, 2787, 14, 272, 408, 272, 1967, 22024, 275, 822, 8, 3179, 9, 272, 14158, 63, 5561, 275, 942, 272, 367, 284, 315, 1425, 8, 17, 12, 1967, 22024, 304, 221, 327, 367, 1006, 11223, 1325, 314, 1642, 267, 2512, 14, 1757, 480, 3160, 22902, 78, 1674, 908, 8, 73, 430, 267, 2787, 27814, 22511, 275, 942, 267, 327, 1900, 1022, 68, 2350, 367, 2787, 284, 267, 19190, 1271, 41, 12, 909, 11506, 1271, 41, 275, 664, 3490, 10708, 18345, 878, 3325, 1918, 723, 12818, 8, 3179, 59, 73, 566, 267, 1022, 3583, 275, 31368, 3987, 8, 15660, 1271, 41, 12, 6370, 534, 26479, 358, 267, 327, 2342, 1022, 29, 19, 17173, 15845, 402, 1924, 909, 402, 2787, 284, 13, 17, 315, 2787, 284, 267, 19190, 1271, 1469, 262, 527, 4395, 12, 909, 11506, 1271, 1469, 262, 527, 4395, 275, 664, 3490, 10708, 18345, 878, 3325, 1918, 723, 12818, 8, 3179, 59, 73, 446, 413, 566, 267, 1279, 4594, 275, 1022, 3583, 14, 1131, 8, 15660, 1271, 1469, 262, 527, 4395, 12, 1022, 29, 19, 12, 372, 63, 5590, 29, 797, 9, 267, 367, 1335, 315, 1425, 8, 16, 12, 1279, 4594, 14, 1392, 59, 16, 4682, 221, 327, 367, 1006, 1686, 2251, 315, 2787, 284, 13, 17, 288, 2512 ]
[ 2366, 515, 7100, 370, 1852, 7188, 1239, 436, 9052, 651, 12732, 2808, 221, 199, 3, 367, 492, 1928, 29963, 652, 370, 506, 4903, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 3679, 63, 646, 12, 6032, 63, 14129, 12, 16952, 12, 4629, 12, 543, 63, 6242, 12, 2649, 63, 5955, 199, 646, 747, 199, 646, 984, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24893, 1333, 199, 3, 4465, 8925, 199, 504, 6365, 14, 1810, 492, 9378, 199, 646, 2050, 199, 646, 5739, 199, 646, 373, 528, 345, 199, 504, 373, 528, 345, 492, 2680, 465, 980, 199, 646, 394, 21, 647, 199, 504, 6357, 14, 11113, 492, 31368, 3987, 199, 504, 7188, 1239, 14, 2718, 2253, 14, 2718, 63, 2609, 492, 17507, 316, 5061, 2988, 199, 646, 7188, 1239, 14, 1974, 14, 6402, 15083, 199, 199, 2921, 275, 2050, 14, 5572, 360, 21881, 8508, 358, 199, 2921, 14, 13548, 8, 4806, 14, 5287, 9, 199, 199, 1590, 14, 261, 22406, 8, 452, 534, 3730, 358, 199, 199, 3, 1586, 315, 283, 78, 18, 13, 78, 17, 7, 402, 5935, 199, 318, 1586, 63, 262, 63, 4782, 8, 78, 17, 12, 302, 18, 12, 1584, 12, 7824, 304, 272, 16484, 63, 5561, 18865, 960, 275, 359, 433, 926, 14, 3236, 476, 14, 739, 30165, 21, 8, 70, 12, 283, 26926, 15, 3512, 358, 367, 289, 315, 1584, 59, 78, 17, 26, 78, 18, 2677, 272, 16484, 63, 5561, 18865, 960, 275, 359, 3577, 1239, 14, 1974, 14, 6402, 15083, 14, 10917, 4738, 8, 4060, 12, 7824, 12, 283, 8568, 67, 358, 367, 6050, 315, 16484, 63, 5561, 18865, 960, 61, 272, 2512, 14, 815, 480, 3601, 27315, 402, 2215, 8352, 908, 8, 3308, 63, 5561, 18865, 960, 59, 16, 1055, 1392, 430, 272, 372, 16484, 63, 5561, 18865, 960, 199, 199, 3, 4526, 4534, 687, 1324, 666, 436, 372, 3062, 199, 318, 4526, 63, 3179, 8, 1773, 63, 1569, 12, 23677, 63, 1569, 12, 302, 17, 12, 302, 18, 12, 3589, 2988, 12, 9911, 304, 272, 327, 25358, 2337, 365, 376, 325, 4170, 867, 4340, 370, 664, 1901, 314, 22240, 5968, 23384, 6109, 14, 272, 327, 2104, 3063, 12, 314, 892, 3878, 787, 282, 7396, 5477, 272, 1006, 24927, 275, 942, 272, 367, 284, 315, 1425, 8, 16, 12, 302, 18, 446, 302, 17, 304, 267, 1655, 3456, 1956, 12, 485, 275, 3589, 2988, 14, 4998, 1692, 5968, 2404, 10326, 19330, 8, 288, 822, 8, 1773, 63, 1569, 14, 16597, 1252, 1392, 7216, 17, 12, 3066, 63, 1569, 18999, 284, 12, 378, 467, 23677, 63, 1569, 59, 73, 1527, 11577, 378, 467, 284, 12, 9911, 9, 267, 2787, 5968, 7412, 275, 942, 267, 367, 289, 315, 1655, 3456, 1956, 26, 288, 2787, 5968, 7412, 275, 2787, 5968, 7412, 435, 289, 14, 1744, 342, 267, 1006, 24927, 14, 740, 8, 807, 8, 1943, 5968, 7412, 430, 272, 372, 1006, 24927, 199, 199, 3, 1586, 315, 283, 78, 18, 13, 78, 17, 7, 402, 3628, 199, 318, 1586, 63, 8965, 14016, 8, 78, 17, 12, 302, 18, 12, 1584, 304, 272, 16484, 63, 4912, 275, 359, 433, 926, 14, 3236, 476, 14, 739, 30165, 21, 8, 70, 12, 283, 14428, 15, 3716, 2310, 358, 367, 289, 315, 1584, 59, 78, 17, 11, 17, 26, 78, 18, 2677, 272, 372, 16484, 63, 4912, 199, 199, 318, 664, 3490, 10708, 18345, 878, 3325, 1918, 723, 12818, 8, 4445, 2141, 12, 221, 3660, 2338, 5968, 985, 534, 2353, 297, 221, 3660, 4897, 13551, 985, 534, 10708, 13551, 735, 272, 408, 272, 11606, 314, 3878, 2600, 402, 282, 9842, 2787, 12, 5591, 2342, 1006, 2251, 543, 7148, 2338, 690, 378, 12, 436, 372, 3932, 272, 4897, 19190, 436, 2762, 14, 272, 408, 272, 1686, 1692, 5144, 275, 3878, 2141, 59, 835, 5968, 985, 61, 690, 378, 272, 1686, 1692, 5144, 59, 16, 61, 275, 756, 2286, 4897, 18345, 878, 275, 3878, 2141, 59, 4551, 13551, 985, 1527, 1078, 1692, 5144, 12, 12228, 272, 909, 11506, 275, 769, 8, 1590, 14, 4509, 8, 1078, 1692, 5144, 2788, 16, 566, 272, 372, 4897, 18345, 878, 12, 909, 11506, 199, 199, 318, 6946, 14016, 8, 3179, 12, 7317, 14016, 304, 272, 408, 272, 8354, 6946, 3628, 701, 17196, 650, 17173, 15845, 315, 314, 2163, 2787, 12, 436, 272, 14545, 734, 5204, 4092, 780, 626, 787, 1777, 402, 314, 7317, 14016, 14, 339, 1011, 3407, 538, 282, 769, 402, 5548, 402, 6342, 402, 4918, 12, 2382, 2337, 787, 465, 5002, 6506, 5548, 272, 465, 2337, 787, 6342, 402, 23376, 11223, 7741, 701, 900, 12, 5591, 325, 14, 71, 14, 367, 2787, 6342, 334, 16, 12, 17, 395, 334, 17, 12, 18, 395, 2263, 334, 78, 13, 17, 12, 78, 680, 272, 7048, 4092, 315, 4066, 282, 769, 2066, 3509, 376, 1478, 1901, 314, 14119, 2787, 402, 314, 4092, 12, 5591, 436, 1373, 1478, 1901, 314, 2945, 2787, 14, 272, 408, 272, 1967, 22024, 275, 822, 8, 3179, 9, 272, 14158, 63, 5561, 275, 942, 272, 367, 284, 315, 1425, 8, 17, 12, 1967, 22024, 304, 221, 327, 367, 1006, 11223, 1325, 314, 1642, 267, 2512, 14, 1757, 480, 3160, 22902, 78, 1674, 908, 8, 73, 430, 267, 2787, 27814, 22511, 275, 942, 267, 327, 1900, 1022, 68, 2350, 367, 2787, 284, 267, 19190, 1271, 41, 12, 909, 11506, 1271, 41, 275, 664, 3490, 10708, 18345, 878, 3325, 1918, 723, 12818, 8, 3179, 59, 73, 566, 267, 1022, 3583, 275, 31368, 3987, 8, 15660, 1271, 41, 12, 6370, 534, 26479, 358, 267, 327, 2342, 1022, 29, 19, 17173, 15845, 402, 1924, 909, 402, 2787, 284, 13, 17, 315, 2787, 284, 267, 19190, 1271, 1469, 262, 527, 4395, 12, 909, 11506, 1271, 1469, 262, 527, 4395, 275, 664, 3490, 10708, 18345, 878, 3325, 1918, 723, 12818, 8, 3179, 59, 73, 446, 413, 566, 267, 1279, 4594, 275, 1022, 3583, 14, 1131, 8, 15660, 1271, 1469, 262, 527, 4395, 12, 1022, 29, 19, 12, 372, 63, 5590, 29, 797, 9, 267, 367, 1335, 315, 1425, 8, 16, 12, 1279, 4594, 14, 1392, 59, 16, 4682, 221, 327, 367, 1006, 1686, 2251, 315, 2787, 284, 13, 17, 288, 2512, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cogeorg/black_rhino
examples/degroot/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality_subset.py
75
7708
#!/usr/bin/env python from nose.tools import * from nose import SkipTest import networkx from nose.plugins.attrib import attr from networkx import edge_current_flow_betweenness_centrality \ as edge_current_flow from networkx import edge_current_flow_betweenness_centrality_subset \ as edge_current_flow_subset class TestFlowBetweennessCentrality(object): numpy=1 # nosetests attribute, use nosetests -a 'not numpy' to skip test @classmethod def setupClass(cls): global np try: import numpy as np import scipy except ImportError: raise SkipTest('NumPy not available.') def test_K4_normalized(self): """Betweenness centrality: K4""" G=networkx.complete_graph(4) b=networkx.current_flow_betweenness_centrality_subset(G, G.nodes(), G.nodes(), normalized=True) b_answer=networkx.current_flow_betweenness_centrality(G,normalized=True) for n in sorted(G): assert_almost_equal(b[n],b_answer[n]) def test_K4(self): """Betweenness centrality: K4""" G=networkx.complete_graph(4) b=networkx.current_flow_betweenness_centrality_subset(G, G.nodes(), G.nodes(), normalized=True) b_answer=networkx.current_flow_betweenness_centrality(G,normalized=True) for n in sorted(G): assert_almost_equal(b[n],b_answer[n]) # test weighted network G.add_edge(0,1,{'weight':0.5,'other':0.3}) b=networkx.current_flow_betweenness_centrality_subset(G, G.nodes(), G.nodes(), normalized=True, weight=None) for n in sorted(G): assert_almost_equal(b[n],b_answer[n]) b=networkx.current_flow_betweenness_centrality_subset(G, G.nodes(), G.nodes(), normalized=True) b_answer=networkx.current_flow_betweenness_centrality(G,normalized=True) for n in sorted(G): assert_almost_equal(b[n],b_answer[n]) b=networkx.current_flow_betweenness_centrality_subset(G, G.nodes(), G.nodes(), normalized=True, weight='other') b_answer=networkx.current_flow_betweenness_centrality(G,normalized=True,weight='other') for n in sorted(G): assert_almost_equal(b[n],b_answer[n]) def test_P4_normalized(self): """Betweenness centrality: P4 normalized""" G=networkx.path_graph(4) b=networkx.current_flow_betweenness_centrality_subset(G, G.nodes(), G.nodes(), normalized=True) b_answer=networkx.current_flow_betweenness_centrality(G,normalized=True) for n in sorted(G): assert_almost_equal(b[n],b_answer[n]) def test_P4(self): """Betweenness centrality: P4""" G=networkx.path_graph(4) b=networkx.current_flow_betweenness_centrality_subset(G, G.nodes(), G.nodes(), normalized=True) b_answer=networkx.current_flow_betweenness_centrality(G,normalized=True) for n in sorted(G): assert_almost_equal(b[n],b_answer[n]) def test_star(self): """Betweenness centrality: star """ G=networkx.Graph() G.add_star(['a','b','c','d']) b=networkx.current_flow_betweenness_centrality_subset(G, G.nodes(), G.nodes(), normalized=True) b_answer=networkx.current_flow_betweenness_centrality(G,normalized=True) for n in sorted(G): assert_almost_equal(b[n],b_answer[n]) # class TestWeightedFlowBetweennessCentrality(): # pass class TestEdgeFlowBetweennessCentrality(object): numpy=1 # nosetests attribute, use nosetests -a 'not numpy' to skip test @classmethod def setupClass(cls): global np try: import numpy as np import scipy except ImportError: raise SkipTest('NumPy not available.') def test_K4_normalized(self): """Betweenness centrality: K4""" G=networkx.complete_graph(4) b=edge_current_flow_subset(G,G.nodes(),G.nodes(),normalized=True) b_answer=edge_current_flow(G,normalized=True) for (s,t),v1 in b_answer.items(): v2=b.get((s,t),b.get((t,s))) assert_almost_equal(v1,v2) def test_K4(self): """Betweenness centrality: K4""" G=networkx.complete_graph(4) b=edge_current_flow_subset(G,G.nodes(),G.nodes(),normalized=False) b_answer=edge_current_flow(G,normalized=False) for (s,t),v1 in b_answer.items(): v2=b.get((s,t),b.get((t,s))) assert_almost_equal(v1,v2) # test weighted network G.add_edge(0,1,{'weight':0.5,'other':0.3}) b=edge_current_flow_subset(G,G.nodes(),G.nodes(),normalized=False,weight=None) # weight is None => same as unweighted network for (s,t),v1 in b_answer.items(): v2=b.get((s,t),b.get((t,s))) assert_almost_equal(v1,v2) b=edge_current_flow_subset(G,G.nodes(),G.nodes(),normalized=False) b_answer=edge_current_flow(G,normalized=False) for (s,t),v1 in b_answer.items(): v2=b.get((s,t),b.get((t,s))) assert_almost_equal(v1,v2) b=edge_current_flow_subset(G,G.nodes(),G.nodes(),normalized=False,weight='other') b_answer=edge_current_flow(G,normalized=False,weight='other') for (s,t),v1 in b_answer.items(): v2=b.get((s,t),b.get((t,s))) assert_almost_equal(v1,v2) def test_C4(self): """Edge betweenness centrality: C4""" G=networkx.cycle_graph(4) b=edge_current_flow_subset(G,G.nodes(),G.nodes(),normalized=True) b_answer=edge_current_flow(G,normalized=True) for (s,t),v1 in b_answer.items(): v2=b.get((s,t),b.get((t,s))) assert_almost_equal(v1,v2) def test_P4(self): """Edge betweenness centrality: P4""" G=networkx.path_graph(4) b=edge_current_flow_subset(G,G.nodes(),G.nodes(),normalized=True) b_answer=edge_current_flow(G,normalized=True) for (s,t),v1 in b_answer.items(): v2=b.get((s,t),b.get((t,s))) assert_almost_equal(v1,v2)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 11354, 14, 2537, 492, 627, 199, 504, 11354, 492, 18795, 199, 646, 24313, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 24313, 492, 6275, 63, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 971, 272, 465, 6275, 63, 1818, 63, 1659, 199, 199, 504, 24313, 492, 6275, 63, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 971, 272, 465, 6275, 63, 1818, 63, 1659, 63, 9401, 199, 199, 533, 1379, 5060, 24472, 3109, 4171, 18345, 28602, 8, 785, 304, 272, 2680, 29, 17, 327, 11354, 2219, 2225, 12, 675, 11354, 2219, 446, 65, 283, 1397, 2680, 7, 370, 3372, 511, 272, 768, 3744, 272, 347, 3272, 2543, 8, 1886, 304, 267, 2288, 980, 267, 862, 26, 288, 492, 2680, 465, 980, 288, 492, 7026, 267, 871, 3545, 26, 288, 746, 18795, 360, 5667, 2713, 440, 2808, 2659, 199, 5493, 347, 511, 63, 43, 20, 63, 12916, 8, 277, 304, 267, 408, 24472, 3109, 4171, 9679, 28602, 26, 1804, 20, 624, 267, 598, 29, 1200, 88, 14, 4883, 63, 2180, 8, 20, 9, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 2378, 347, 511, 63, 43, 20, 8, 277, 304, 267, 408, 24472, 3109, 4171, 9679, 28602, 26, 1804, 20, 624, 267, 598, 29, 1200, 88, 14, 4883, 63, 2180, 8, 20, 9, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 267, 327, 511, 14609, 2784, 267, 598, 14, 525, 63, 5173, 8, 16, 12, 17, 12, 1445, 3463, 356, 16, 14, 21, 2584, 1848, 356, 16, 14, 19, 1552, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 12, 16854, 5401, 29, 403, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 12, 16854, 5401, 534, 1848, 358, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 12, 3463, 534, 1848, 358, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 2378, 347, 511, 63, 48, 20, 63, 12916, 8, 277, 304, 267, 408, 24472, 3109, 4171, 9679, 28602, 26, 510, 20, 9657, 624, 267, 598, 29, 1200, 88, 14, 515, 63, 2180, 8, 20, 9, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 2378, 347, 511, 63, 48, 20, 8, 277, 304, 267, 408, 24472, 3109, 4171, 9679, 28602, 26, 510, 20, 624, 267, 598, 29, 1200, 88, 14, 515, 63, 2180, 8, 20, 9, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 339, 347, 511, 63, 7848, 8, 277, 304, 267, 408, 24472, 3109, 4171, 9679, 28602, 26, 14664, 408, 267, 598, 29, 1200, 88, 14, 4578, 342, 267, 598, 14, 525, 63, 7848, 2941, 65, 1673, 66, 1673, 67, 1673, 68, 1105, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 4388, 199, 3, 1021 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 504, 11354, 14, 2537, 492, 627, 199, 504, 11354, 492, 18795, 199, 646, 24313, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 24313, 492, 6275, 63, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 971, 272, 465, 6275, 63, 1818, 63, 1659, 199, 199, 504, 24313, 492, 6275, 63, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 971, 272, 465, 6275, 63, 1818, 63, 1659, 63, 9401, 199, 199, 533, 1379, 5060, 24472, 3109, 4171, 18345, 28602, 8, 785, 304, 272, 2680, 29, 17, 327, 11354, 2219, 2225, 12, 675, 11354, 2219, 446, 65, 283, 1397, 2680, 7, 370, 3372, 511, 272, 768, 3744, 272, 347, 3272, 2543, 8, 1886, 304, 267, 2288, 980, 267, 862, 26, 288, 492, 2680, 465, 980, 288, 492, 7026, 267, 871, 3545, 26, 288, 746, 18795, 360, 5667, 2713, 440, 2808, 2659, 199, 5493, 347, 511, 63, 43, 20, 63, 12916, 8, 277, 304, 267, 408, 24472, 3109, 4171, 9679, 28602, 26, 1804, 20, 624, 267, 598, 29, 1200, 88, 14, 4883, 63, 2180, 8, 20, 9, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 2378, 347, 511, 63, 43, 20, 8, 277, 304, 267, 408, 24472, 3109, 4171, 9679, 28602, 26, 1804, 20, 624, 267, 598, 29, 1200, 88, 14, 4883, 63, 2180, 8, 20, 9, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 267, 327, 511, 14609, 2784, 267, 598, 14, 525, 63, 5173, 8, 16, 12, 17, 12, 1445, 3463, 356, 16, 14, 21, 2584, 1848, 356, 16, 14, 19, 1552, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 12, 16854, 5401, 29, 403, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 12, 16854, 5401, 534, 1848, 358, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 12, 3463, 534, 1848, 358, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 2378, 347, 511, 63, 48, 20, 63, 12916, 8, 277, 304, 267, 408, 24472, 3109, 4171, 9679, 28602, 26, 510, 20, 9657, 624, 267, 598, 29, 1200, 88, 14, 515, 63, 2180, 8, 20, 9, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 2378, 347, 511, 63, 48, 20, 8, 277, 304, 267, 408, 24472, 3109, 4171, 9679, 28602, 26, 510, 20, 624, 267, 598, 29, 1200, 88, 14, 515, 63, 2180, 8, 20, 9, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 339, 347, 511, 63, 7848, 8, 277, 304, 267, 408, 24472, 3109, 4171, 9679, 28602, 26, 14664, 408, 267, 598, 29, 1200, 88, 14, 4578, 342, 267, 598, 14, 525, 63, 7848, 2941, 65, 1673, 66, 1673, 67, 1673, 68, 1105, 267, 330, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 63, 9401, 8, 39, 12, 16854, 598, 14, 2415, 1062, 16854, 598, 14, 2415, 1062, 16854, 9657, 29, 549, 9, 267, 330, 63, 5934, 29, 1200, 88, 14, 1818, 63, 1659, 63, 13007, 4171, 63, 2497, 28602, 8, 39, 12, 12916, 29, 549, 9, 267, 367, 302, 315, 3355, 8, 39, 304, 288, 702, 63, 4398, 63, 1452, 8, 66, 59, 78, 467, 66, 63, 5934, 59, 78, 566, 4388, 199, 3, 1021, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
csrocha/OpenUpgrade
addons/account_followup/report/account_followup_print.py
7
5990
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import time from collections import defaultdict from openerp.osv import osv from openerp.report import report_sxw class report_rappel(report_sxw.rml_parse): _name = "account_followup.report.rappel" def __init__(self, cr, uid, name, context=None): super(report_rappel, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, 'ids_to_objects': self._ids_to_objects, 'getLines': self._lines_get, 'get_text': self._get_text }) def _ids_to_objects(self, ids): all_lines = [] for line in self.pool['account_followup.stat.by.partner'].browse(self.cr, self.uid, ids): if line not in all_lines: all_lines.append(line) return all_lines def _lines_get(self, stat_by_partner_line): return self._lines_get_with_partner(stat_by_partner_line.partner_id, stat_by_partner_line.company_id.id) def _lines_get_with_partner(self, partner, company_id): moveline_obj = self.pool['account.move.line'] moveline_ids = moveline_obj.search(self.cr, self.uid, [ ('partner_id', '=', partner.id), ('account_id.type', '=', 'receivable'), ('reconcile_id', '=', False), ('state', '!=', 'draft'), ('company_id', '=', company_id), ]) # lines_per_currency = {currency: [line data, ...], ...} lines_per_currency = defaultdict(list) for line in moveline_obj.browse(self.cr, self.uid, moveline_ids): currency = line.currency_id or line.company_id.currency_id line_data = { 'name': line.move_id.name, 'ref': line.ref, 'date': line.date, 'date_maturity': line.date_maturity, 'balance': line.amount_currency if currency != line.company_id.currency_id else line.debit - line.credit, 'blocked': line.blocked, 'currency_id': currency, } lines_per_currency[currency].append(line_data) return [{'line': lines, 'currency': currency} for currency, lines in lines_per_currency.items()] def _get_text(self, stat_line, followup_id, context=None): context = dict(context or {}, lang=stat_line.partner_id.lang) fp_obj = self.pool['account_followup.followup'] fp_line = fp_obj.browse(self.cr, self.uid, followup_id, context=context).followup_line if not fp_line: raise osv.except_osv(_('Error!'),_("The followup plan defined for the current company does not have any followup action.")) #the default text will be the first fp_line in the sequence with a description. default_text = '' li_delay = [] for line in fp_line: if not default_text and line.description: default_text = line.description li_delay.append(line.delay) li_delay.sort(reverse=True) a = {} #look into the lines of the partner that already have a followup level, and take the description of the higher level for which it is available partner_line_ids = self.pool['account.move.line'].search(self.cr, self.uid, [('partner_id','=',stat_line.partner_id.id),('reconcile_id','=',False),('company_id','=',stat_line.company_id.id),('blocked','=',False),('state','!=','draft'),('debit','!=',False),('account_id.type','=','receivable'),('followup_line_id','!=',False)]) partner_max_delay = 0 partner_max_text = '' for i in self.pool['account.move.line'].browse(self.cr, self.uid, partner_line_ids, context=context): if i.followup_line_id.delay > partner_max_delay and i.followup_line_id.description: partner_max_delay = i.followup_line_id.delay partner_max_text = i.followup_line_id.description text = partner_max_delay and partner_max_text or default_text if text: lang_obj = self.pool['res.lang'] lang_ids = lang_obj.search(self.cr, self.uid, [('code', '=', stat_line.partner_id.lang)], context=context) date_format = lang_ids and lang_obj.browse(self.cr, self.uid, lang_ids[0], context=context).date_format or '%Y-%m-%d' text = text % { 'partner_name': stat_line.partner_id.name, 'date': time.strftime(date_format), 'company_name': stat_line.company_id.name, 'user_signature': self.pool['res.users'].browse(self.cr, self.uid, self.uid, context).signature or '', } return text class report_followup(osv.AbstractModel): _name = 'report.account_followup.report_followup' _inherit = 'report.abstract_report' _template = 'account_followup.report_followup' _wrapped_report_class = report_rappel # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 504, 5055, 492, 10018, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 3070, 492, 3622, 63, 20851, 421, 199, 533, 3622, 63, 5034, 76, 8, 3070, 63, 20851, 14, 16300, 63, 1122, 304, 272, 485, 354, 275, 298, 2048, 63, 25872, 14, 3070, 14, 5034, 76, 2, 339, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 29, 403, 304, 267, 1613, 8, 3070, 63, 5034, 76, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 29, 1100, 9, 267, 291, 14, 17886, 14, 873, 2561, 288, 283, 521, 356, 900, 12, 288, 283, 1580, 63, 475, 63, 1462, 356, 291, 423, 1580, 63, 475, 63, 1462, 12, 288, 283, 362, 9863, 356, 291, 423, 1278, 63, 362, 12, 288, 283, 362, 63, 505, 356, 291, 423, 362, 63, 505, 267, 3828, 339, 347, 485, 1580, 63, 475, 63, 1462, 8, 277, 12, 2762, 304, 267, 1006, 63, 1278, 275, 942, 267, 367, 1004, 315, 291, 14, 2293, 459, 2048, 63, 25872, 14, 3736, 14, 991, 14, 3899, 2278, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 2762, 304, 288, 340, 1004, 440, 315, 1006, 63, 1278, 26, 355, 1006, 63, 1278, 14, 740, 8, 604, 9, 267, 372, 1006, 63, 1278, 339, 347, 485, 1278, 63, 362, 8, 277, 12, 5672, 63, 991, 63, 3899, 63, 604, 304, 267, 372, 291, 423, 1278, 63, 362, 63, 1045, 63, 3899, 8, 3736, 63, 991, 63, 3899, 63, 604, 14, 3899, 63, 344, 12, 5672, 63, 991, 63, 3899, 63, 604, 14, 4627, 63, 344, 14, 344, 9, 339, 347, 485, 1278, 63, 362, 63, 1045, 63, 3899, 8, 277, 12, 5854, 12, 7233, 63, 344, 304, 267, 1303, 1090, 1132, 63, 1113, 275, 291, 14, 2293, 459, 2048, 14, 1185, 14, 604, 418, 267, 1303, 1090, 1132, 63, 1580, 275, 1303, 1090, 1132, 63, 1113, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 359, 1169, 661, 3899, 63, 344, 297, 6291, 5854, 14, 344, 395, 1169, 661, 2048, 63, 344, 14, 466, 297, 6291, 283, 24890, 461, 659, 1169, 661, 18403, 63, 344, 297, 6291, 756, 395, 1169, 661, 929, 297, 31326, 283, 7185, 659, 1169, 661, 4627, 63, 344, 297, 6291, 7233, 63, 344, 395, 717, 4794, 398, 327, 2385, 63, 529, 63, 4968, 275, 469, 4968, 26, 359, 604, 666, 12, 2263, 467, 2263, 93, 267, 2385, 63, 529, 63, 4968, 275, 10018, 8, 513, 9, 267, 367, 1004, 315, 1303, 1090, 1132, 63, 1113, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 1303, 1090, 1132, 63, 1580, 304, 288, 9952, 275, 1004, 14, 4968, 63, 344, 503, 1004, 14, 4627, 63, 344, 14, 4968, 63, 344, 288, 1004, 63, 576, 275, 469, 355, 283, 354, 356, 1004, 14, 1185, 63, 344, 14, 354, 12, 355, 283, 1121, 356, 1004, 14, 1121, 12, 355, 283, 602, 356, 1004, 14, 602, 12, 355, 283, 602, 63, 569, 5581, 356, 1004, 14, 602, 63, 569, 5581, 12, 355, 283, 7358, 356, 1004, 14, 4606, 63, 4968, 340, 9952, 1137, 1004, 14, 4627, 63, 344, 14, 4968, 63, 344, 587, 1004, 14, 12964, 446, 1004, 14, 9365, 12, 355, 283, 17726, 356, 1004, 14, 17726, 12, 355, 283, 4968, 63, 344, 356, 9952, 12, 288, 789, 288, 2385, 63, 529, 63, 4968, 59, 4968, 1055, 740, 8, 604, 63, 576, 9, 398, 372, 9016, 604, 356, 2385, 12, 283, 4968, 356, 9952, 93, 367, 9952, 12, 2385, 315, 2385, 63, 529, 63, 4968, 14, 1744, 5106, 339, 347, 485, 362, 63, 505, 8, 277, 12, 5672, 63, 604, 12, 2035, 384, 63, 344, 12, 1067, 29, 403, 304, 267, 1067, 275, 1211, 8, 1100, 503, 5479, 6339, 29, 3736, 63, 604, 14, 3899, 63, 344, 14, 4159, 9, 267, 4090, 63, 1113, 275, 291, 14, 2293, 459, 2048, 63, 25872, 14, 25872, 418, 267, 4090, 63, 604, 275, 4090, 63, 1113, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 2035, 384, 63, 344, 12, 1067, 29, 1100, 680, 25872, 63, 604, 267, 340, 440, 4090, 63, 604, 26, 288, 746, 9506, 14, 2590, 63, 4795, 6723, 547, 15659, 14332, 1918, 2035, 384, 8683, 3247, 367, 314, 1453, 7233, 1630, 440, 1172, 1263, 2035, 384, 1595, 13853, 267, 327, 1589, 849, 1318, 911, 506, 314, 1642, 4090, 63, 604, 315, 314, 3414, 543, 282, 1369, 14, 267, 849, 63, 505, 275, 2125, 267, 1212, 63, 5814, 275, 942, 267, 367, 1004, 315, 4090, 63, 604, 26, 288, 340, 440, 849, 63, 505, 436, 1004, 14, 1802, 26, 355, 849, 63, 505, 275, 1004, 14, 1802, 288, 1212, 63, 5814, 14, 740, 8, 604, 14, 5814, 9, 267, 1212, 63, 5814, 14, 3191, 8, 4471, 29, 549, 9, 267, 282, 275, 1052, 267, 327, 11660, 1901, 314, 2385, 402, 314, 5854, 626, 2575 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 504, 5055, 492, 10018, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 3070, 492, 3622, 63, 20851, 421, 199, 533, 3622, 63, 5034, 76, 8, 3070, 63, 20851, 14, 16300, 63, 1122, 304, 272, 485, 354, 275, 298, 2048, 63, 25872, 14, 3070, 14, 5034, 76, 2, 339, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 29, 403, 304, 267, 1613, 8, 3070, 63, 5034, 76, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 29, 1100, 9, 267, 291, 14, 17886, 14, 873, 2561, 288, 283, 521, 356, 900, 12, 288, 283, 1580, 63, 475, 63, 1462, 356, 291, 423, 1580, 63, 475, 63, 1462, 12, 288, 283, 362, 9863, 356, 291, 423, 1278, 63, 362, 12, 288, 283, 362, 63, 505, 356, 291, 423, 362, 63, 505, 267, 3828, 339, 347, 485, 1580, 63, 475, 63, 1462, 8, 277, 12, 2762, 304, 267, 1006, 63, 1278, 275, 942, 267, 367, 1004, 315, 291, 14, 2293, 459, 2048, 63, 25872, 14, 3736, 14, 991, 14, 3899, 2278, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 2762, 304, 288, 340, 1004, 440, 315, 1006, 63, 1278, 26, 355, 1006, 63, 1278, 14, 740, 8, 604, 9, 267, 372, 1006, 63, 1278, 339, 347, 485, 1278, 63, 362, 8, 277, 12, 5672, 63, 991, 63, 3899, 63, 604, 304, 267, 372, 291, 423, 1278, 63, 362, 63, 1045, 63, 3899, 8, 3736, 63, 991, 63, 3899, 63, 604, 14, 3899, 63, 344, 12, 5672, 63, 991, 63, 3899, 63, 604, 14, 4627, 63, 344, 14, 344, 9, 339, 347, 485, 1278, 63, 362, 63, 1045, 63, 3899, 8, 277, 12, 5854, 12, 7233, 63, 344, 304, 267, 1303, 1090, 1132, 63, 1113, 275, 291, 14, 2293, 459, 2048, 14, 1185, 14, 604, 418, 267, 1303, 1090, 1132, 63, 1580, 275, 1303, 1090, 1132, 63, 1113, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 359, 1169, 661, 3899, 63, 344, 297, 6291, 5854, 14, 344, 395, 1169, 661, 2048, 63, 344, 14, 466, 297, 6291, 283, 24890, 461, 659, 1169, 661, 18403, 63, 344, 297, 6291, 756, 395, 1169, 661, 929, 297, 31326, 283, 7185, 659, 1169, 661, 4627, 63, 344, 297, 6291, 7233, 63, 344, 395, 717, 4794, 398, 327, 2385, 63, 529, 63, 4968, 275, 469, 4968, 26, 359, 604, 666, 12, 2263, 467, 2263, 93, 267, 2385, 63, 529, 63, 4968, 275, 10018, 8, 513, 9, 267, 367, 1004, 315, 1303, 1090, 1132, 63, 1113, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 1303, 1090, 1132, 63, 1580, 304, 288, 9952, 275, 1004, 14, 4968, 63, 344, 503, 1004, 14, 4627, 63, 344, 14, 4968, 63, 344, 288, 1004, 63, 576, 275, 469, 355, 283, 354, 356, 1004, 14, 1185, 63, 344, 14, 354, 12, 355, 283, 1121, 356, 1004, 14, 1121, 12, 355, 283, 602, 356, 1004, 14, 602, 12, 355, 283, 602, 63, 569, 5581, 356, 1004, 14, 602, 63, 569, 5581, 12, 355, 283, 7358, 356, 1004, 14, 4606, 63, 4968, 340, 9952, 1137, 1004, 14, 4627, 63, 344, 14, 4968, 63, 344, 587, 1004, 14, 12964, 446, 1004, 14, 9365, 12, 355, 283, 17726, 356, 1004, 14, 17726, 12, 355, 283, 4968, 63, 344, 356, 9952, 12, 288, 789, 288, 2385, 63, 529, 63, 4968, 59, 4968, 1055, 740, 8, 604, 63, 576, 9, 398, 372, 9016, 604, 356, 2385, 12, 283, 4968, 356, 9952, 93, 367, 9952, 12, 2385, 315, 2385, 63, 529, 63, 4968, 14, 1744, 5106, 339, 347, 485, 362, 63, 505, 8, 277, 12, 5672, 63, 604, 12, 2035, 384, 63, 344, 12, 1067, 29, 403, 304, 267, 1067, 275, 1211, 8, 1100, 503, 5479, 6339, 29, 3736, 63, 604, 14, 3899, 63, 344, 14, 4159, 9, 267, 4090, 63, 1113, 275, 291, 14, 2293, 459, 2048, 63, 25872, 14, 25872, 418, 267, 4090, 63, 604, 275, 4090, 63, 1113, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 2035, 384, 63, 344, 12, 1067, 29, 1100, 680, 25872, 63, 604, 267, 340, 440, 4090, 63, 604, 26, 288, 746, 9506, 14, 2590, 63, 4795, 6723, 547, 15659, 14332, 1918, 2035, 384, 8683, 3247, 367, 314, 1453, 7233, 1630, 440, 1172, 1263, 2035, 384, 1595, 13853, 267, 327, 1589, 849, 1318, 911, 506, 314, 1642, 4090, 63, 604, 315, 314, 3414, 543, 282, 1369, 14, 267, 849, 63, 505, 275, 2125, 267, 1212, 63, 5814, 275, 942, 267, 367, 1004, 315, 4090, 63, 604, 26, 288, 340, 440, 849, 63, 505, 436, 1004, 14, 1802, 26, 355, 849, 63, 505, 275, 1004, 14, 1802, 288, 1212, 63, 5814, 14, 740, 8, 604, 14, 5814, 9, 267, 1212, 63, 5814, 14, 3191, 8, 4471, 29, 549, 9, 267, 282, 275, 1052, 267, 327, 11660, 1901, 314, 2385, 402, 314, 5854, 626, 2575, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chanderbgoel/pybrain
examples/supervised/backprop/parityrnn.py
26
2046
from __future__ import print_function #!/usr/bin/env python """ A simple recurrent neural network that detects parity for arbitrary sequences. """ __author__ = 'Tom Schaul (tom@idsia.ch)' from datasets import ParityDataSet #@UnresolvedImport from pybrain.supervised.trainers.backprop import BackpropTrainer from pybrain.structure import RecurrentNetwork, LinearLayer, TanhLayer, BiasUnit, FullConnection def buildParityNet(): net = RecurrentNetwork() net.addInputModule(LinearLayer(1, name = 'i')) net.addModule(TanhLayer(2, name = 'h')) net.addModule(BiasUnit('bias')) net.addOutputModule(TanhLayer(1, name = 'o')) net.addConnection(FullConnection(net['i'], net['h'])) net.addConnection(FullConnection(net['bias'], net['h'])) net.addConnection(FullConnection(net['bias'], net['o'])) net.addConnection(FullConnection(net['h'], net['o'])) net.addRecurrentConnection(FullConnection(net['o'], net['h'])) net.sortModules() p = net.params p[:] = [-0.5, -1.5, 1, 1, -1, 1, 1, -1, 1] p *= 10. return net def evalRnnOnSeqDataset(net, DS, verbose = False, silent = False): """ evaluate the network on all the sequences of a dataset. """ r = 0. samples = 0. for seq in DS: net.reset() for i, t in seq: res = net.activate(i) if verbose: print(t, res) r += sum((t-res)**2) samples += 1 if verbose: print('-'*20) r /= samples if not silent: print('MSE:', r) return r if __name__ == "__main__": N = buildParityNet() DS = ParityDataSet() evalRnnOnSeqDataset(N, DS, verbose = True) print('(preset weights)') N.randomize() evalRnnOnSeqDataset(N, DS) print('(random weights)') # Backprop improves the network performance, and sometimes even finds the global optimum. N.reset() bp = BackpropTrainer(N, DS, verbose = True) bp.trainEpochs(5000) evalRnnOnSeqDataset(N, DS) print('(backprop-trained weights)')
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 437, 3486, 295, 1818, 1279, 4889, 2784, 626, 477, 28853, 623, 1209, 367, 9697, 8013, 14, 408, 199, 199, 363, 2502, 363, 275, 283, 52, 676, 428, 9518, 348, 334, 3151, 32, 344, 10971, 14, 335, 3171, 199, 199, 504, 13148, 492, 510, 7945, 30720, 9213, 1358, 13697, 6295, 199, 504, 1134, 22246, 14, 4792, 17311, 14, 2834, 1192, 14, 31113, 492, 10257, 4469, 2437, 16187, 199, 504, 1134, 22246, 14, 6976, 492, 799, 1818, 4491, 12, 12489, 5003, 12, 377, 290, 72, 5003, 12, 699, 2241, 5072, 12, 16579, 3225, 421, 199, 318, 1900, 48, 7945, 2480, 837, 272, 1851, 275, 799, 1818, 4491, 342, 272, 1851, 14, 525, 3205, 2377, 8, 10608, 5003, 8, 17, 12, 536, 275, 283, 73, 1333, 272, 1851, 14, 525, 2377, 8, 52, 290, 72, 5003, 8, 18, 12, 536, 275, 283, 72, 1333, 272, 1851, 14, 525, 2377, 8, 34, 2241, 5072, 360, 8160, 1333, 272, 1851, 14, 525, 2959, 2377, 8, 52, 290, 72, 5003, 8, 17, 12, 536, 275, 283, 79, 1333, 272, 1851, 14, 525, 3225, 8, 9042, 3225, 8, 846, 459, 73, 995, 1851, 459, 72, 5156, 272, 1851, 14, 525, 3225, 8, 9042, 3225, 8, 846, 459, 8160, 995, 1851, 459, 72, 5156, 272, 1851, 14, 525, 3225, 8, 9042, 3225, 8, 846, 459, 8160, 995, 1851, 459, 79, 5156, 272, 1851, 14, 525, 3225, 8, 9042, 3225, 8, 846, 459, 72, 995, 1851, 459, 79, 5156, 272, 1851, 14, 525, 497, 1818, 3225, 8, 9042, 3225, 8, 846, 459, 79, 995, 1851, 459, 72, 5156, 272, 1851, 14, 3191, 17981, 342, 339, 299, 275, 1851, 14, 1162, 272, 299, 5873, 275, 5243, 16, 14, 21, 12, 446, 17, 14, 21, 12, 413, 12, 413, 12, 446, 17, 12, 413, 12, 413, 12, 446, 17, 12, 413, 61, 272, 299, 9000, 1616, 14, 339, 372, 1851, 199, 199, 318, 3468, 50, 4411, 3314, 11205, 9271, 8, 846, 12, 577, 51, 12, 3376, 275, 756, 12, 10866, 275, 756, 304, 272, 408, 9352, 314, 2784, 641, 1006, 314, 8013, 402, 282, 4789, 14, 408, 272, 519, 275, 378, 14, 272, 5845, 275, 378, 14, 272, 367, 5412, 315, 577, 51, 26, 267, 1851, 14, 3958, 342, 267, 367, 284, 12, 307, 315, 5412, 26, 288, 522, 275, 1851, 14, 8222, 8, 73, 9, 288, 340, 3376, 26, 355, 870, 8, 84, 12, 522, 9, 288, 519, 847, 3089, 1332, 84, 13, 470, 6422, 18, 9, 288, 5845, 847, 413, 267, 340, 3376, 26, 288, 870, 3654, 16804, 1165, 9, 272, 519, 12257, 5845, 272, 340, 440, 10866, 26, 267, 870, 360, 45, 899, 6536, 519, 9, 272, 372, 519, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 653, 275, 1900, 48, 7945, 2480, 342, 272, 577, 51, 275, 510, 7945, 30720, 342, 272, 3468, 50, 4411, 3314, 11205, 9271, 8, 46, 12, 577, 51, 12, 3376, 275, 715, 9, 272, 870, 14097, 25701, 4931, 5942, 272, 653, 14, 28610, 342, 272, 3468, 50, 4411, 3314, 11205, 9271, 8, 46, 12, 577, 51, 9, 272, 870, 14097, 2355, 4931, 5942, 2378, 327, 10257, 4469, 1742, 293, 2310, 314, 2784, 10238, 12, 436, 15026, 2755, 17651, 314, 2288, 5323, 453, 14, 272, 653, 14, 3958, 342, 272, 13292, 275, 10257, 4469, 2437, 16187, 8, 46, 12, 577, 51, 12, 3376, 275, 715, 9, 272, 13292, 14, 2834, 29322, 83, 8, 13128, 9, 272, 3468, 50, 4411, 3314, 11205, 9271, 8, 46, 12, 577, 51, 9, 272, 870, 14097, 31113, 13, 23782, 4931, 5942, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 437, 3486, 295, 1818, 1279, 4889, 2784, 626, 477, 28853, 623, 1209, 367, 9697, 8013, 14, 408, 199, 199, 363, 2502, 363, 275, 283, 52, 676, 428, 9518, 348, 334, 3151, 32, 344, 10971, 14, 335, 3171, 199, 199, 504, 13148, 492, 510, 7945, 30720, 9213, 1358, 13697, 6295, 199, 504, 1134, 22246, 14, 4792, 17311, 14, 2834, 1192, 14, 31113, 492, 10257, 4469, 2437, 16187, 199, 504, 1134, 22246, 14, 6976, 492, 799, 1818, 4491, 12, 12489, 5003, 12, 377, 290, 72, 5003, 12, 699, 2241, 5072, 12, 16579, 3225, 421, 199, 318, 1900, 48, 7945, 2480, 837, 272, 1851, 275, 799, 1818, 4491, 342, 272, 1851, 14, 525, 3205, 2377, 8, 10608, 5003, 8, 17, 12, 536, 275, 283, 73, 1333, 272, 1851, 14, 525, 2377, 8, 52, 290, 72, 5003, 8, 18, 12, 536, 275, 283, 72, 1333, 272, 1851, 14, 525, 2377, 8, 34, 2241, 5072, 360, 8160, 1333, 272, 1851, 14, 525, 2959, 2377, 8, 52, 290, 72, 5003, 8, 17, 12, 536, 275, 283, 79, 1333, 272, 1851, 14, 525, 3225, 8, 9042, 3225, 8, 846, 459, 73, 995, 1851, 459, 72, 5156, 272, 1851, 14, 525, 3225, 8, 9042, 3225, 8, 846, 459, 8160, 995, 1851, 459, 72, 5156, 272, 1851, 14, 525, 3225, 8, 9042, 3225, 8, 846, 459, 8160, 995, 1851, 459, 79, 5156, 272, 1851, 14, 525, 3225, 8, 9042, 3225, 8, 846, 459, 72, 995, 1851, 459, 79, 5156, 272, 1851, 14, 525, 497, 1818, 3225, 8, 9042, 3225, 8, 846, 459, 79, 995, 1851, 459, 72, 5156, 272, 1851, 14, 3191, 17981, 342, 339, 299, 275, 1851, 14, 1162, 272, 299, 5873, 275, 5243, 16, 14, 21, 12, 446, 17, 14, 21, 12, 413, 12, 413, 12, 446, 17, 12, 413, 12, 413, 12, 446, 17, 12, 413, 61, 272, 299, 9000, 1616, 14, 339, 372, 1851, 199, 199, 318, 3468, 50, 4411, 3314, 11205, 9271, 8, 846, 12, 577, 51, 12, 3376, 275, 756, 12, 10866, 275, 756, 304, 272, 408, 9352, 314, 2784, 641, 1006, 314, 8013, 402, 282, 4789, 14, 408, 272, 519, 275, 378, 14, 272, 5845, 275, 378, 14, 272, 367, 5412, 315, 577, 51, 26, 267, 1851, 14, 3958, 342, 267, 367, 284, 12, 307, 315, 5412, 26, 288, 522, 275, 1851, 14, 8222, 8, 73, 9, 288, 340, 3376, 26, 355, 870, 8, 84, 12, 522, 9, 288, 519, 847, 3089, 1332, 84, 13, 470, 6422, 18, 9, 288, 5845, 847, 413, 267, 340, 3376, 26, 288, 870, 3654, 16804, 1165, 9, 272, 519, 12257, 5845, 272, 340, 440, 10866, 26, 267, 870, 360, 45, 899, 6536, 519, 9, 272, 372, 519, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 653, 275, 1900, 48, 7945, 2480, 342, 272, 577, 51, 275, 510, 7945, 30720, 342, 272, 3468, 50, 4411, 3314, 11205, 9271, 8, 46, 12, 577, 51, 12, 3376, 275, 715, 9, 272, 870, 14097, 25701, 4931, 5942, 272, 653, 14, 28610, 342, 272, 3468, 50, 4411, 3314, 11205, 9271, 8, 46, 12, 577, 51, 9, 272, 870, 14097, 2355, 4931, 5942, 2378, 327, 10257, 4469, 1742, 293, 2310, 314, 2784, 10238, 12, 436, 15026, 2755, 17651, 314, 2288, 5323, 453, 14, 272, 653, 14, 3958, 342, 272, 13292, 275, 10257, 4469, 2437, 16187, 8, 46, 12, 577, 51, 12, 3376, 275, 715, 9, 272, 13292, 14, 2834, 29322, 83, 8, 13128, 9, 272, 3468, 50, 4411, 3314, 11205, 9271, 8, 46, 12, 577, 51, 9, 272, 870, 14097, 31113, 13, 23782, 4931, 5942, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
nemesiscodex/JukyOS-sugar
extensions/deviceicon/speech.py
1
5531
# Copyright (C) 2011 One Laptop Per Child # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import gettext as _ import glib import gtk import gconf import gobject from sugar.graphics.icon import Icon from sugar.graphics.tray import TrayIcon from sugar.graphics.palette import Palette from sugar.graphics.xocolor import XoColor from sugar.graphics.menuitem import MenuItem from sugar.graphics import style from jarabe.frame.frameinvoker import FrameWidgetInvoker from jarabe.model import speech _ICON_NAME = 'microphone' class SpeechDeviceView(TrayIcon): FRAME_POSITION_RELATIVE = 150 def __init__(self): client = gconf.client_get_default() self._color = XoColor(client.get_string('/desktop/sugar/user/color')) TrayIcon.__init__(self, icon_name=_ICON_NAME, xo_color=self._color) self.set_palette_invoker(FrameWidgetInvoker(self)) self._manager = speech.get_speech_manager() self._icon_widget.connect('button-release-event', self.__button_release_event_cb) def create_palette(self): label = glib.markup_escape_text(_('Speech')) palette = SpeechPalette(label, manager=self._manager) palette.set_group_id('frame') return palette def __button_release_event_cb(self, widget, event): self.palette_invoker.notify_right_click() return True class SpeechPalette(Palette): def __init__(self, primary_text, manager): Palette.__init__(self, label=primary_text) self._manager = manager self._manager.connect('play', self._set_menu_state, 'play') self._manager.connect('stop', self._set_menu_state, 'stop') self._manager.connect('pause', self._set_menu_state, 'pause') vbox = gtk.VBox() self.set_content(vbox) self._play_icon = Icon(icon_name='player_play') self._pause_icon = Icon(icon_name='player_pause') self._play_pause_menu = MenuItem(text_label=_('Say selected text')) self._play_pause_menu.set_image(self._play_icon) self._play_pause_menu.connect('activate', self.__play_activated_cb) self._play_pause_menu.show() self._stop_menu = MenuItem(icon_name='player_stop', text_label=_('Stop playback')) self._stop_menu.connect('activate', self.__stop_activated_cb) self._stop_menu.set_sensitive(False) self._stop_menu.show() self.menu.append(self._play_pause_menu) self.menu.append(self._stop_menu) self._adj_pitch = gtk.Adjustment(value=self._manager.get_pitch(), lower=self._manager.MIN_PITCH, upper=self._manager.MAX_PITCH) self._hscale_pitch = gtk.HScale(self._adj_pitch) self._hscale_pitch.set_draw_value(False) vbox.pack_start(gtk.Label(_('Pitch')), padding=style.DEFAULT_PADDING) vbox.pack_start(self._hscale_pitch) self._adj_rate = gtk.Adjustment(value=self._manager.get_rate(), lower=self._manager.MIN_RATE, upper=self._manager.MAX_RATE) self._hscale_rate = gtk.HScale(self._adj_rate) self._hscale_rate.set_draw_value(False) vbox.pack_start(gtk.Label(_('Rate')), padding=style.DEFAULT_PADDING) vbox.pack_start(self._hscale_rate) vbox.show_all() self._adj_pitch.connect('value_changed', self.__adj_pitch_changed_cb) self._adj_rate.connect('value_changed', self.__adj_rate_changed_cb) def __adj_pitch_changed_cb(self, adjustement): self._manager.set_pitch(int(adjustement.value)) def __adj_rate_changed_cb(self, adjustement): self._manager.set_rate(int(adjustement.value)) def __play_activated_cb(self, widget): if self._manager.is_paused: self._manager.restart() elif not self._manager.is_playing: self._manager.say_selected_text() else: self._manager.pause() def __stop_activated_cb(self, widget): self._manager.stop() def _set_menu_state(self, manager, signal): if signal == 'play': self._play_pause_menu.set_image(self._pause_icon) self._play_pause_menu.set_label(_('Pause playback')) self._stop_menu.set_sensitive(True) elif signal == 'pause': self._play_pause_menu.set_image(self._play_icon) self._play_pause_menu.set_label(_('Say selected text')) self._stop_menu.set_sensitive(True) elif signal == 'stop': self._play_pause_menu.set_image(self._play_icon) self._play_pause_menu.set_label(_('Say selected text')) self._stop_menu.set_sensitive(False) def setup(tray): tray.add_device(SpeechDeviceView())
gpl-2.0
[ 3, 1898, 334, 35, 9, 7760, 7309, 491, 439, 2119, 3492, 12988, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 199, 504, 9796, 492, 9796, 465, 485, 199, 199, 646, 486, 773, 199, 646, 8116, 199, 646, 486, 2190, 199, 646, 25595, 199, 199, 504, 308, 21922, 14, 15707, 14, 4677, 492, 473, 388, 199, 504, 308, 21922, 14, 15707, 14, 84, 803, 492, 377, 803, 8954, 199, 504, 308, 21922, 14, 15707, 14, 16506, 492, 510, 22116, 199, 504, 308, 21922, 14, 15707, 14, 15987, 2326, 492, 1323, 79, 4117, 199, 504, 308, 21922, 14, 15707, 14, 4470, 1053, 492, 18281, 2081, 199, 504, 308, 21922, 14, 15707, 492, 3449, 199, 199, 504, 16290, 7570, 14, 1943, 14, 1943, 5350, 26790, 492, 11726, 3339, 14883, 26790, 199, 504, 16290, 7570, 14, 1238, 492, 32093, 421, 199, 63, 15903, 63, 2339, 275, 283, 6453, 9339, 7, 421, 199, 533, 428, 321, 12736, 2510, 2768, 8, 52, 803, 8954, 304, 339, 28671, 1991, 63, 15717, 63, 13604, 14277, 275, 14711, 339, 347, 636, 826, 721, 277, 304, 267, 1890, 275, 486, 2190, 14, 1258, 63, 362, 63, 885, 342, 267, 291, 423, 2326, 275, 1323, 79, 4117, 8, 1258, 14, 362, 63, 875, 2336, 14487, 15, 83, 21922, 15, 751, 15, 2326, 1333, 267, 377, 803, 8954, 855, 826, 721, 277, 12, 7016, 63, 354, 3699, 15903, 63, 2339, 12, 671, 79, 63, 2326, 29, 277, 423, 2326, 9, 267, 291, 14, 409, 63, 16506, 63, 5350, 26790, 8, 3160, 3339, 14883, 26790, 8, 277, 430, 267, 291, 423, 2609, 275, 32093, 14, 362, 63, 23660, 63, 2609, 342, 267, 291, 423, 4677, 63, 3440, 14, 2242, 360, 3887, 13, 3221, 13, 1430, 297, 3303, 291, 855, 3887, 63, 3221, 63, 1430, 63, 2894, 9, 339, 347, 1218, 63, 16506, 8, 277, 304, 267, 1768, 275, 486, 773, 14, 10131, 63, 3765, 63, 505, 6723, 27047, 12736, 1333, 267, 17986, 275, 428, 321, 12736, 24500, 8, 1302, 12, 5256, 29, 277, 423, 2609, 9, 267, 17986, 14, 409, 63, 923, 63, 344, 360, 1943, 358, 267, 372, 17986, 339, 347, 636, 3887, 63, 3221, 63, 1430, 63, 2894, 8, 277, 12, 3938, 12, 1566, 304, 267, 291, 14, 16506, 63, 5350, 26790, 14, 6814, 63, 1019, 63, 4891, 342, 267, 372, 715, 421, 199, 533, 428, 321, 12736, 24500, 8, 24500, 304, 339, 347, 636, 826, 721, 277, 12, 5062, 63, 505, 12, 5256, 304, 267, 510, 22116, 855, 826, 721, 277, 12, 1768, 29, 3327, 63, 505, 9, 398, 291, 423, 2609, 275, 5256, 267, 291, 423, 2609, 14, 2242, 360, 2802, 297, 291, 423, 409, 63, 4470, 63, 929, 12, 283, 2802, 358, 267, 291, 423, 2609, 14, 2242, 360, 2379, 297, 291, 423, 409, 63, 4470, 63, 929, 12, 283, 2379, 358, 267, 291, 423, 2609, 14, 2242, 360, 11241, 297, 291, 423, 409, 63, 4470, 63, 929, 12, 283, 11241, 358, 398, 20163, 275, 8116, 14, 54, 3532, 342, 267, 291, 14, 409, 63, 1317, 8, 19508, 9, 398, 291, 423, 2802, 63, 4677, 275, 473, 388, 8, 4677, 63, 354, 534, 6147, 63, 2802, 358, 267, 291, 423, 11241, 63, 4677, 275, 473, 388, 8, 4677, 63, 354, 534, 6147, 63, 11241, 358, 267, 291, 423, 2802, 63, 11241, 63, 4470, 275, 18281, 2081, 8, 505, 63, 1302, 12397, 51, 1187, 4895, 1318, 1333, 267, 291, 423, 2802, 63, 11241, 63, 4470, 14, 409, 63, 1569, 8, 277, 423, 2802, 63, 4677, 9, 267, 291, 423, 2802, 63, 11241, 63, 4470, 14, 2242, 360, 8222, 297, 291, 855, 2802, 63, 18218, 63, 2894, 9, 267, 291, 423, 2802, 63, 11241, 63, 4470, 14, 2384, 342, 398, 291, 423, 2379, 63, 4470, 275, 18281, 2081, 8, 4677, 63, 354, 534, 6147, 63, 2379, 297, 355, 1318, 63, 1302, 12397, 6293, 5232, 894, 1333, 267, 291, 423, 2379, 63, 4470, 14, 2242, 360, 8222, 297, 291, 855, 2379, 63, 18218, 63, 2894, 9, 267, 291, 423, 2379, 63, 4470, 14, 409, 63, 7361, 8, 797, 9, 267, 291, 423, 2379, 63, 4470, 14, 2384, 342, 398, 291, 14, 4470, 14, 740, 8, 277, 423, 2802, 63, 11241, 63, 4470, 9, 267, 291, 14, 4470, 14, 740, 8, 277, 423, 2379, 63, 4470, 9, 398, 291, 423, 12551, 63, 16966, 275, 8116, 14, 17977, 434, 8, 585, 29, 277, 423, 2609, 14, 362, 63, 16966, 1062, 5101, 5117, 29, 277, 423, 2609, 14, 4896, 63, 48, 15894, 12, 5101, 7008, 29, 277, 423, 2609, 14, 4283, 63, 48, 15894, 9, 267, 291, 423, 72, 3467, 63, 16966, 275, 8116, 14, 40, 9944, 8, 277, 423, 12551, 63, 16966, 9, 267, 291, 423, 72, 3467, 63, 16966, 14, 409, 63, 5485, 63, 585, 8, 797, 9, 398, 20163, 14, 1389, 63, 928, 8, 12275, 14, 4314, 6723, 48, 9414, 3855, 6273, 29, 2487, 14, 3472, 63, 48, 9732, 1206, 9, 267, 20163, 14, 1389, 63, 928, 8, 277, 423, 72, 3467, 63, 16966, 9, 398, 291, 423, 12551, 63, 1866, 275, 8116, 14, 17977, 434, 8, 585, 29, 277, 423, 2609, 14, 362, 63, 1866, 1062, 5101, 5117, 29, 277, 423, 2609, 14, 4896, 63, 16553, 12, 5101, 7008, 29, 277, 423, 2609, 14, 4283, 63 ]
[ 1898, 334, 35, 9, 7760, 7309, 491, 439, 2119, 3492, 12988, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 199, 504, 9796, 492, 9796, 465, 485, 199, 199, 646, 486, 773, 199, 646, 8116, 199, 646, 486, 2190, 199, 646, 25595, 199, 199, 504, 308, 21922, 14, 15707, 14, 4677, 492, 473, 388, 199, 504, 308, 21922, 14, 15707, 14, 84, 803, 492, 377, 803, 8954, 199, 504, 308, 21922, 14, 15707, 14, 16506, 492, 510, 22116, 199, 504, 308, 21922, 14, 15707, 14, 15987, 2326, 492, 1323, 79, 4117, 199, 504, 308, 21922, 14, 15707, 14, 4470, 1053, 492, 18281, 2081, 199, 504, 308, 21922, 14, 15707, 492, 3449, 199, 199, 504, 16290, 7570, 14, 1943, 14, 1943, 5350, 26790, 492, 11726, 3339, 14883, 26790, 199, 504, 16290, 7570, 14, 1238, 492, 32093, 421, 199, 63, 15903, 63, 2339, 275, 283, 6453, 9339, 7, 421, 199, 533, 428, 321, 12736, 2510, 2768, 8, 52, 803, 8954, 304, 339, 28671, 1991, 63, 15717, 63, 13604, 14277, 275, 14711, 339, 347, 636, 826, 721, 277, 304, 267, 1890, 275, 486, 2190, 14, 1258, 63, 362, 63, 885, 342, 267, 291, 423, 2326, 275, 1323, 79, 4117, 8, 1258, 14, 362, 63, 875, 2336, 14487, 15, 83, 21922, 15, 751, 15, 2326, 1333, 267, 377, 803, 8954, 855, 826, 721, 277, 12, 7016, 63, 354, 3699, 15903, 63, 2339, 12, 671, 79, 63, 2326, 29, 277, 423, 2326, 9, 267, 291, 14, 409, 63, 16506, 63, 5350, 26790, 8, 3160, 3339, 14883, 26790, 8, 277, 430, 267, 291, 423, 2609, 275, 32093, 14, 362, 63, 23660, 63, 2609, 342, 267, 291, 423, 4677, 63, 3440, 14, 2242, 360, 3887, 13, 3221, 13, 1430, 297, 3303, 291, 855, 3887, 63, 3221, 63, 1430, 63, 2894, 9, 339, 347, 1218, 63, 16506, 8, 277, 304, 267, 1768, 275, 486, 773, 14, 10131, 63, 3765, 63, 505, 6723, 27047, 12736, 1333, 267, 17986, 275, 428, 321, 12736, 24500, 8, 1302, 12, 5256, 29, 277, 423, 2609, 9, 267, 17986, 14, 409, 63, 923, 63, 344, 360, 1943, 358, 267, 372, 17986, 339, 347, 636, 3887, 63, 3221, 63, 1430, 63, 2894, 8, 277, 12, 3938, 12, 1566, 304, 267, 291, 14, 16506, 63, 5350, 26790, 14, 6814, 63, 1019, 63, 4891, 342, 267, 372, 715, 421, 199, 533, 428, 321, 12736, 24500, 8, 24500, 304, 339, 347, 636, 826, 721, 277, 12, 5062, 63, 505, 12, 5256, 304, 267, 510, 22116, 855, 826, 721, 277, 12, 1768, 29, 3327, 63, 505, 9, 398, 291, 423, 2609, 275, 5256, 267, 291, 423, 2609, 14, 2242, 360, 2802, 297, 291, 423, 409, 63, 4470, 63, 929, 12, 283, 2802, 358, 267, 291, 423, 2609, 14, 2242, 360, 2379, 297, 291, 423, 409, 63, 4470, 63, 929, 12, 283, 2379, 358, 267, 291, 423, 2609, 14, 2242, 360, 11241, 297, 291, 423, 409, 63, 4470, 63, 929, 12, 283, 11241, 358, 398, 20163, 275, 8116, 14, 54, 3532, 342, 267, 291, 14, 409, 63, 1317, 8, 19508, 9, 398, 291, 423, 2802, 63, 4677, 275, 473, 388, 8, 4677, 63, 354, 534, 6147, 63, 2802, 358, 267, 291, 423, 11241, 63, 4677, 275, 473, 388, 8, 4677, 63, 354, 534, 6147, 63, 11241, 358, 267, 291, 423, 2802, 63, 11241, 63, 4470, 275, 18281, 2081, 8, 505, 63, 1302, 12397, 51, 1187, 4895, 1318, 1333, 267, 291, 423, 2802, 63, 11241, 63, 4470, 14, 409, 63, 1569, 8, 277, 423, 2802, 63, 4677, 9, 267, 291, 423, 2802, 63, 11241, 63, 4470, 14, 2242, 360, 8222, 297, 291, 855, 2802, 63, 18218, 63, 2894, 9, 267, 291, 423, 2802, 63, 11241, 63, 4470, 14, 2384, 342, 398, 291, 423, 2379, 63, 4470, 275, 18281, 2081, 8, 4677, 63, 354, 534, 6147, 63, 2379, 297, 355, 1318, 63, 1302, 12397, 6293, 5232, 894, 1333, 267, 291, 423, 2379, 63, 4470, 14, 2242, 360, 8222, 297, 291, 855, 2379, 63, 18218, 63, 2894, 9, 267, 291, 423, 2379, 63, 4470, 14, 409, 63, 7361, 8, 797, 9, 267, 291, 423, 2379, 63, 4470, 14, 2384, 342, 398, 291, 14, 4470, 14, 740, 8, 277, 423, 2802, 63, 11241, 63, 4470, 9, 267, 291, 14, 4470, 14, 740, 8, 277, 423, 2379, 63, 4470, 9, 398, 291, 423, 12551, 63, 16966, 275, 8116, 14, 17977, 434, 8, 585, 29, 277, 423, 2609, 14, 362, 63, 16966, 1062, 5101, 5117, 29, 277, 423, 2609, 14, 4896, 63, 48, 15894, 12, 5101, 7008, 29, 277, 423, 2609, 14, 4283, 63, 48, 15894, 9, 267, 291, 423, 72, 3467, 63, 16966, 275, 8116, 14, 40, 9944, 8, 277, 423, 12551, 63, 16966, 9, 267, 291, 423, 72, 3467, 63, 16966, 14, 409, 63, 5485, 63, 585, 8, 797, 9, 398, 20163, 14, 1389, 63, 928, 8, 12275, 14, 4314, 6723, 48, 9414, 3855, 6273, 29, 2487, 14, 3472, 63, 48, 9732, 1206, 9, 267, 20163, 14, 1389, 63, 928, 8, 277, 423, 72, 3467, 63, 16966, 9, 398, 291, 423, 12551, 63, 1866, 275, 8116, 14, 17977, 434, 8, 585, 29, 277, 423, 2609, 14, 362, 63, 1866, 1062,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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 ]
sunny94/temp
sympy/plotting/pygletplot/plot_controller.py
120
6965
from __future__ import print_function, division from pyglet.window import key from pyglet.window.mouse import LEFT, RIGHT, MIDDLE from util import get_direction_vectors, get_basis_vectors class PlotController(object): normal_mouse_sensitivity = 4.0 modified_mouse_sensitivity = 1.0 normal_key_sensitivity = 160.0 modified_key_sensitivity = 40.0 keymap = { key.LEFT: 'left', key.A: 'left', key.NUM_4: 'left', key.RIGHT: 'right', key.D: 'right', key.NUM_6: 'right', key.UP: 'up', key.W: 'up', key.NUM_8: 'up', key.DOWN: 'down', key.S: 'down', key.NUM_2: 'down', key.Z: 'rotate_z_neg', key.NUM_1: 'rotate_z_neg', key.C: 'rotate_z_pos', key.NUM_3: 'rotate_z_pos', key.Q: 'spin_left', key.NUM_7: 'spin_left', key.E: 'spin_right', key.NUM_9: 'spin_right', key.X: 'reset_camera', key.NUM_5: 'reset_camera', key.NUM_ADD: 'zoom_in', key.PAGEUP: 'zoom_in', key.R: 'zoom_in', key.NUM_SUBTRACT: 'zoom_out', key.PAGEDOWN: 'zoom_out', key.F: 'zoom_out', key.RSHIFT: 'modify_sensitivity', key.LSHIFT: 'modify_sensitivity', key.F1: 'rot_preset_xy', key.F2: 'rot_preset_xz', key.F3: 'rot_preset_yz', key.F4: 'rot_preset_perspective', key.F5: 'toggle_axes', key.F6: 'toggle_axe_colors', key.F8: 'save_image' } def __init__(self, window, **kwargs): self.invert_mouse_zoom = kwargs.pop('invert_mouse_zoom', False) self.window = window self.camera = window.camera self.action = { # Rotation around the view Y (up) vector 'left': False, 'right': False, # Rotation around the view X vector 'up': False, 'down': False, # Rotation around the view Z vector 'spin_left': False, 'spin_right': False, # Rotation around the model Z vector 'rotate_z_neg': False, 'rotate_z_pos': False, # Reset to the default rotation 'reset_camera': False, # Performs camera z-translation 'zoom_in': False, 'zoom_out': False, # Use alternative sensitivity (speed) 'modify_sensitivity': False, # Rotation presets 'rot_preset_xy': False, 'rot_preset_xz': False, 'rot_preset_yz': False, 'rot_preset_perspective': False, # axes 'toggle_axes': False, 'toggle_axe_colors': False, # screenshot 'save_image': False } def update(self, dt): z = 0 if self.action['zoom_out']: z -= 1 if self.action['zoom_in']: z += 1 if z != 0: self.camera.zoom_relative(z/10.0, self.get_key_sensitivity()/10.0) dx, dy, dz = 0, 0, 0 if self.action['left']: dx -= 1 if self.action['right']: dx += 1 if self.action['up']: dy -= 1 if self.action['down']: dy += 1 if self.action['spin_left']: dz += 1 if self.action['spin_right']: dz -= 1 if not self.is_2D(): if dx != 0: self.camera.euler_rotate(dx*dt*self.get_key_sensitivity(), *(get_direction_vectors()[1])) if dy != 0: self.camera.euler_rotate(dy*dt*self.get_key_sensitivity(), *(get_direction_vectors()[0])) if dz != 0: self.camera.euler_rotate(dz*dt*self.get_key_sensitivity(), *(get_direction_vectors()[2])) else: self.camera.mouse_translate(0, 0, dx*dt*self.get_key_sensitivity(), -dy*dt*self.get_key_sensitivity()) rz = 0 if self.action['rotate_z_neg'] and not self.is_2D(): rz -= 1 if self.action['rotate_z_pos'] and not self.is_2D(): rz += 1 if rz != 0: self.camera.euler_rotate(rz*dt*self.get_key_sensitivity(), *(get_basis_vectors()[2])) if self.action['reset_camera']: self.camera.reset() if self.action['rot_preset_xy']: self.camera.set_rot_preset('xy') if self.action['rot_preset_xz']: self.camera.set_rot_preset('xz') if self.action['rot_preset_yz']: self.camera.set_rot_preset('yz') if self.action['rot_preset_perspective']: self.camera.set_rot_preset('perspective') if self.action['toggle_axes']: self.action['toggle_axes'] = False self.camera.axes.toggle_visible() if self.action['toggle_axe_colors']: self.action['toggle_axe_colors'] = False self.camera.axes.toggle_colors() if self.action['save_image']: self.action['save_image'] = False self.window.plot.saveimage() return True def get_mouse_sensitivity(self): if self.action['modify_sensitivity']: return self.modified_mouse_sensitivity else: return self.normal_mouse_sensitivity def get_key_sensitivity(self): if self.action['modify_sensitivity']: return self.modified_key_sensitivity else: return self.normal_key_sensitivity def on_key_press(self, symbol, modifiers): if symbol in self.keymap: self.action[self.keymap[symbol]] = True def on_key_release(self, symbol, modifiers): if symbol in self.keymap: self.action[self.keymap[symbol]] = False def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers): if buttons & LEFT: if self.is_2D(): self.camera.mouse_translate(x, y, dx, dy) else: self.camera.spherical_rotate((x - dx, y - dy), (x, y), self.get_mouse_sensitivity()) if buttons & MIDDLE: self.camera.zoom_relative([1, -1][self.invert_mouse_zoom]*dy, self.get_mouse_sensitivity()/20.0) if buttons & RIGHT: self.camera.mouse_translate(x, y, dx, dy) def on_mouse_scroll(self, x, y, dx, dy): self.camera.zoom_relative([1, -1][self.invert_mouse_zoom]*dy, self.get_mouse_sensitivity()) def is_2D(self): functions = self.window.plot._functions for i in functions: if len(functions[i].i_vars) > 1 or len(functions[i].d_vars) > 2: return False return True
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 23409, 14, 3806, 492, 790, 199, 504, 23409, 14, 3806, 14, 10544, 492, 6578, 12, 7052, 12, 30041, 199, 504, 4884, 492, 664, 63, 6874, 63, 12280, 12, 664, 63, 19220, 63, 12280, 421, 199, 533, 14794, 7506, 8, 785, 304, 339, 3293, 63, 10544, 63, 2464, 20635, 275, 841, 14, 16, 272, 6042, 63, 10544, 63, 2464, 20635, 275, 413, 14, 16, 339, 3293, 63, 498, 63, 2464, 20635, 275, 21235, 14, 16, 272, 6042, 63, 498, 63, 2464, 20635, 275, 6335, 14, 16, 339, 790, 1130, 275, 469, 267, 790, 14, 9894, 26, 283, 3039, 297, 267, 790, 14, 33, 26, 283, 3039, 297, 267, 790, 14, 7125, 63, 20, 26, 283, 3039, 297, 398, 790, 14, 12811, 26, 283, 1019, 297, 267, 790, 14, 36, 26, 283, 1019, 297, 267, 790, 14, 7125, 63, 22, 26, 283, 1019, 297, 398, 790, 14, 2160, 26, 283, 384, 297, 267, 790, 14, 55, 26, 283, 384, 297, 267, 790, 14, 7125, 63, 24, 26, 283, 384, 297, 398, 790, 14, 8819, 26, 283, 2110, 297, 267, 790, 14, 51, 26, 283, 2110, 297, 267, 790, 14, 7125, 63, 18, 26, 283, 2110, 297, 398, 790, 14, 58, 26, 283, 12873, 63, 90, 63, 8705, 297, 267, 790, 14, 7125, 63, 17, 26, 283, 12873, 63, 90, 63, 8705, 297, 398, 790, 14, 35, 26, 283, 12873, 63, 90, 63, 1712, 297, 267, 790, 14, 7125, 63, 19, 26, 283, 12873, 63, 90, 63, 1712, 297, 398, 790, 14, 49, 26, 283, 14809, 63, 3039, 297, 267, 790, 14, 7125, 63, 23, 26, 283, 14809, 63, 3039, 297, 267, 790, 14, 37, 26, 283, 14809, 63, 1019, 297, 267, 790, 14, 7125, 63, 25, 26, 283, 14809, 63, 1019, 297, 398, 790, 14, 56, 26, 283, 3958, 63, 11928, 297, 267, 790, 14, 7125, 63, 21, 26, 283, 3958, 63, 11928, 297, 398, 790, 14, 7125, 63, 9732, 26, 283, 10598, 63, 262, 297, 267, 790, 14, 12898, 2160, 26, 283, 10598, 63, 262, 297, 267, 790, 14, 50, 26, 283, 10598, 63, 262, 297, 398, 790, 14, 7125, 63, 6348, 22280, 26, 283, 10598, 63, 548, 297, 267, 790, 14, 48, 1254, 1149, 47, 3705, 26, 283, 10598, 63, 548, 297, 267, 790, 14, 38, 26, 283, 10598, 63, 548, 297, 398, 790, 14, 50, 18013, 26, 283, 8951, 63, 2464, 20635, 297, 267, 790, 14, 44, 18013, 26, 283, 8951, 63, 2464, 20635, 297, 398, 790, 14, 38, 17, 26, 283, 4571, 63, 25701, 63, 1702, 297, 267, 790, 14, 38, 18, 26, 283, 4571, 63, 25701, 63, 19196, 297, 267, 790, 14, 38, 19, 26, 283, 4571, 63, 25701, 63, 19873, 297, 267, 790, 14, 38, 20, 26, 283, 4571, 63, 25701, 63, 529, 16657, 297, 398, 790, 14, 38, 21, 26, 283, 13396, 63, 6402, 297, 267, 790, 14, 38, 22, 26, 283, 13396, 63, 1219, 69, 63, 7120, 297, 398, 790, 14, 38, 24, 26, 283, 2117, 63, 1569, 7, 272, 789, 339, 347, 636, 826, 721, 277, 12, 4353, 12, 1011, 958, 304, 267, 291, 14, 18957, 63, 10544, 63, 10598, 275, 2074, 14, 1935, 360, 18957, 63, 10544, 63, 10598, 297, 756, 9, 267, 291, 14, 3806, 275, 4353, 267, 291, 14, 11928, 275, 4353, 14, 11928, 267, 291, 14, 1287, 275, 469, 288, 327, 28642, 6818, 314, 2455, 1488, 334, 384, 9, 5477, 288, 283, 3039, 356, 756, 12, 288, 283, 1019, 356, 756, 12, 288, 327, 28642, 6818, 314, 2455, 1323, 5477, 288, 283, 384, 356, 756, 12, 288, 283, 2110, 356, 756, 12, 288, 327, 28642, 6818, 314, 2455, 3107, 5477, 288, 283, 14809, 63, 3039, 356, 756, 12, 288, 283, 14809, 63, 1019, 356, 756, 12, 288, 327, 28642, 6818, 314, 1402, 3107, 5477, 288, 283, 12873, 63, 90, 63, 8705, 356, 756, 12, 288, 283, 12873, 63, 90, 63, 1712, 356, 756, 12, 288, 327, 15510, 370, 314, 849, 13038, 288, 283, 3958, 63, 11928, 356, 756, 12, 288, 327, 29822, 15177, 1315, 13, 6893, 288, 283, 10598, 63, 262, 356, 756, 12, 288, 283, 10598, 63, 548, 356, 756, 12, 288, 327, 3645, 13943, 4334, 20635, 334, 7625, 9, 288, 283, 8951, 63, 2464, 20635, 356, 756, 12, 288, 327, 28642, 876, 2193, 288, 283, 4571, 63, 25701, 63, 1702, 356, 756, 12, 288, 283, 4571, 63, 25701, 63, 19196, 356, 756, 12, 288, 283, 4571, 63, 25701, 63, 19873, 356, 756, 12, 288, 283, 4571, 63, 25701, 63, 529, 16657, 356, 756, 12, 288, 327, 7824, 288, 283, 13396, 63, 6402, 356, 756, 12, 288, 283, 13396, 63, 1219, 69, 63, 7120, 356, 756, 12, 288, 327, 27981, 288, 283, 2117, 63, 1569, 356, 756, 267, 789, 339, 347, 1678, 8, 277, 12, 4487, 304, 267, 1315, 275, 378, 267, 340, 291, 14, 1287, 459, 10598, 63, 548, 2565, 288, 1315, 4862, 413, 267, 340, 291, 14, 1287, 459, 10598, 63, 262, 2565, 288, 1315, 847, 413, 267, 340, 1315, 1137, 378, 26, 288, 291, 14, 11928, 14, 10598, 63, 6188, 8, 90, 15, 709, 14, 16, 12, 291, 14, 362, 63, 498, 63, 2464, 20635, 29728, 709, 14, 16, 9, 398, 11868, 12, 13119, 12, 366, 90, 275, 378, 12, 378, 12, 378, 267, 340, 291, 14, 1287, 459, 3039, 2565, 288, 11868, 4862, 413, 267, 340, 291, 14, 1287, 459, 1019, 2565, 288, 11868, 847, 413, 267, 340, 291, 14, 1287, 459, 384, 2565, 288, 13119, 4862, 413, 267, 340, 291, 14, 1287, 459, 2110, 2565, 288, 13119, 847, 413, 267, 340, 291, 14, 1287, 459, 14809, 63, 3039, 2565, 288, 366, 90, 847, 413, 267, 340, 291, 14, 1287, 459, 14809, 63, 1019, 2565, 288, 366, 90, 4862, 413, 398, 340, 440, 291, 14, 374, 63, 18, 36, 837, 288, 340, 11868, 1137, 378, 26, 355, 291, 14, 11928, 14, 69, 19345, 63, 12873, 8, 8373, 10, 3583, 10, 277, 14, 362, 63, 498, 63, 2464, 20635, 1062, 1460, 26534, 362, 63, 6874, 63, 12280, 3430, 17, 2459, 288, 340, 13119, 1137, 378, 26, 355, 291, 14, 11928, 14, 69, 19345, 63, 12873, 8 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 23409, 14, 3806, 492, 790, 199, 504, 23409, 14, 3806, 14, 10544, 492, 6578, 12, 7052, 12, 30041, 199, 504, 4884, 492, 664, 63, 6874, 63, 12280, 12, 664, 63, 19220, 63, 12280, 421, 199, 533, 14794, 7506, 8, 785, 304, 339, 3293, 63, 10544, 63, 2464, 20635, 275, 841, 14, 16, 272, 6042, 63, 10544, 63, 2464, 20635, 275, 413, 14, 16, 339, 3293, 63, 498, 63, 2464, 20635, 275, 21235, 14, 16, 272, 6042, 63, 498, 63, 2464, 20635, 275, 6335, 14, 16, 339, 790, 1130, 275, 469, 267, 790, 14, 9894, 26, 283, 3039, 297, 267, 790, 14, 33, 26, 283, 3039, 297, 267, 790, 14, 7125, 63, 20, 26, 283, 3039, 297, 398, 790, 14, 12811, 26, 283, 1019, 297, 267, 790, 14, 36, 26, 283, 1019, 297, 267, 790, 14, 7125, 63, 22, 26, 283, 1019, 297, 398, 790, 14, 2160, 26, 283, 384, 297, 267, 790, 14, 55, 26, 283, 384, 297, 267, 790, 14, 7125, 63, 24, 26, 283, 384, 297, 398, 790, 14, 8819, 26, 283, 2110, 297, 267, 790, 14, 51, 26, 283, 2110, 297, 267, 790, 14, 7125, 63, 18, 26, 283, 2110, 297, 398, 790, 14, 58, 26, 283, 12873, 63, 90, 63, 8705, 297, 267, 790, 14, 7125, 63, 17, 26, 283, 12873, 63, 90, 63, 8705, 297, 398, 790, 14, 35, 26, 283, 12873, 63, 90, 63, 1712, 297, 267, 790, 14, 7125, 63, 19, 26, 283, 12873, 63, 90, 63, 1712, 297, 398, 790, 14, 49, 26, 283, 14809, 63, 3039, 297, 267, 790, 14, 7125, 63, 23, 26, 283, 14809, 63, 3039, 297, 267, 790, 14, 37, 26, 283, 14809, 63, 1019, 297, 267, 790, 14, 7125, 63, 25, 26, 283, 14809, 63, 1019, 297, 398, 790, 14, 56, 26, 283, 3958, 63, 11928, 297, 267, 790, 14, 7125, 63, 21, 26, 283, 3958, 63, 11928, 297, 398, 790, 14, 7125, 63, 9732, 26, 283, 10598, 63, 262, 297, 267, 790, 14, 12898, 2160, 26, 283, 10598, 63, 262, 297, 267, 790, 14, 50, 26, 283, 10598, 63, 262, 297, 398, 790, 14, 7125, 63, 6348, 22280, 26, 283, 10598, 63, 548, 297, 267, 790, 14, 48, 1254, 1149, 47, 3705, 26, 283, 10598, 63, 548, 297, 267, 790, 14, 38, 26, 283, 10598, 63, 548, 297, 398, 790, 14, 50, 18013, 26, 283, 8951, 63, 2464, 20635, 297, 267, 790, 14, 44, 18013, 26, 283, 8951, 63, 2464, 20635, 297, 398, 790, 14, 38, 17, 26, 283, 4571, 63, 25701, 63, 1702, 297, 267, 790, 14, 38, 18, 26, 283, 4571, 63, 25701, 63, 19196, 297, 267, 790, 14, 38, 19, 26, 283, 4571, 63, 25701, 63, 19873, 297, 267, 790, 14, 38, 20, 26, 283, 4571, 63, 25701, 63, 529, 16657, 297, 398, 790, 14, 38, 21, 26, 283, 13396, 63, 6402, 297, 267, 790, 14, 38, 22, 26, 283, 13396, 63, 1219, 69, 63, 7120, 297, 398, 790, 14, 38, 24, 26, 283, 2117, 63, 1569, 7, 272, 789, 339, 347, 636, 826, 721, 277, 12, 4353, 12, 1011, 958, 304, 267, 291, 14, 18957, 63, 10544, 63, 10598, 275, 2074, 14, 1935, 360, 18957, 63, 10544, 63, 10598, 297, 756, 9, 267, 291, 14, 3806, 275, 4353, 267, 291, 14, 11928, 275, 4353, 14, 11928, 267, 291, 14, 1287, 275, 469, 288, 327, 28642, 6818, 314, 2455, 1488, 334, 384, 9, 5477, 288, 283, 3039, 356, 756, 12, 288, 283, 1019, 356, 756, 12, 288, 327, 28642, 6818, 314, 2455, 1323, 5477, 288, 283, 384, 356, 756, 12, 288, 283, 2110, 356, 756, 12, 288, 327, 28642, 6818, 314, 2455, 3107, 5477, 288, 283, 14809, 63, 3039, 356, 756, 12, 288, 283, 14809, 63, 1019, 356, 756, 12, 288, 327, 28642, 6818, 314, 1402, 3107, 5477, 288, 283, 12873, 63, 90, 63, 8705, 356, 756, 12, 288, 283, 12873, 63, 90, 63, 1712, 356, 756, 12, 288, 327, 15510, 370, 314, 849, 13038, 288, 283, 3958, 63, 11928, 356, 756, 12, 288, 327, 29822, 15177, 1315, 13, 6893, 288, 283, 10598, 63, 262, 356, 756, 12, 288, 283, 10598, 63, 548, 356, 756, 12, 288, 327, 3645, 13943, 4334, 20635, 334, 7625, 9, 288, 283, 8951, 63, 2464, 20635, 356, 756, 12, 288, 327, 28642, 876, 2193, 288, 283, 4571, 63, 25701, 63, 1702, 356, 756, 12, 288, 283, 4571, 63, 25701, 63, 19196, 356, 756, 12, 288, 283, 4571, 63, 25701, 63, 19873, 356, 756, 12, 288, 283, 4571, 63, 25701, 63, 529, 16657, 356, 756, 12, 288, 327, 7824, 288, 283, 13396, 63, 6402, 356, 756, 12, 288, 283, 13396, 63, 1219, 69, 63, 7120, 356, 756, 12, 288, 327, 27981, 288, 283, 2117, 63, 1569, 356, 756, 267, 789, 339, 347, 1678, 8, 277, 12, 4487, 304, 267, 1315, 275, 378, 267, 340, 291, 14, 1287, 459, 10598, 63, 548, 2565, 288, 1315, 4862, 413, 267, 340, 291, 14, 1287, 459, 10598, 63, 262, 2565, 288, 1315, 847, 413, 267, 340, 1315, 1137, 378, 26, 288, 291, 14, 11928, 14, 10598, 63, 6188, 8, 90, 15, 709, 14, 16, 12, 291, 14, 362, 63, 498, 63, 2464, 20635, 29728, 709, 14, 16, 9, 398, 11868, 12, 13119, 12, 366, 90, 275, 378, 12, 378, 12, 378, 267, 340, 291, 14, 1287, 459, 3039, 2565, 288, 11868, 4862, 413, 267, 340, 291, 14, 1287, 459, 1019, 2565, 288, 11868, 847, 413, 267, 340, 291, 14, 1287, 459, 384, 2565, 288, 13119, 4862, 413, 267, 340, 291, 14, 1287, 459, 2110, 2565, 288, 13119, 847, 413, 267, 340, 291, 14, 1287, 459, 14809, 63, 3039, 2565, 288, 366, 90, 847, 413, 267, 340, 291, 14, 1287, 459, 14809, 63, 1019, 2565, 288, 366, 90, 4862, 413, 398, 340, 440, 291, 14, 374, 63, 18, 36, 837, 288, 340, 11868, 1137, 378, 26, 355, 291, 14, 11928, 14, 69, 19345, 63, 12873, 8, 8373, 10, 3583, 10, 277, 14, 362, 63, 498, 63, 2464, 20635, 1062, 1460, 26534, 362, 63, 6874, 63, 12280, 3430, 17, 2459, 288, 340, 13119, 1137, 378, 26, 355, 291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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
robotcator/gensim
gensim/examples/dmlcz/sources.py
83
12976
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) 2010 Radim Rehurek <radimrehurek@seznam.cz> # Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl.html """ This module contains implementations (= different classes) which encapsulate the idea of a Digital Library document source. A document source is basically a collection of articles sharing the same format, same location (type of access), same way of parsing them etc. Different sources can be aggregated into a single corpus, which is what the `DmlCorpus` class does (see the `dmlcorpus` module). """ import logging import os import os.path import re import xml.sax # for parsing arxmliv articles from gensim import utils PAT_TAG = re.compile('<(.*?)>(.*)</.*?>') logger = logging.getLogger('gensim.corpora.sources') class ArticleSource(object): """ Objects of this class describe a single source of articles. A source is an abstraction over where the documents reside (the findArticles() method), how to retrieve their fulltexts, their metadata, how to tokenize the articles and how to normalize the tokens. What is NOT abstracted away (ie. must hold for all sources) is the idea of article identifiers (URIs), which uniquely identify each article within one source. This class is just an ABC interface; see eg. DmlSource or ArxmlivSource classes for concrete instances. """ def __init__(self, sourceId): self.sourceId = sourceId def __str__(self): return self.sourceId def findArticles(self): raise NotImplementedError('Abstract Base Class') def getContent(self, uri): raise NotImplementedError('Abstract Base Class') def getMeta(self, uri): raise NotImplementedError('Abstract Base Class') def tokenize(self, content): raise NotImplementedError('Abstract Base Class') def normalizeWord(self, word): raise NotImplementedError('Abstract Base Class') #endclass ArticleSource class DmlSource(ArticleSource): """ Article source for articles in DML format (DML-CZ, Numdam): 1) articles = directories starting with '#' 2) content is stored in fulltext.txt 3) metadata are stored in meta.xml Article URI is currently (a part of) the article's path on filesystem. See the ArticleSource class for general info on sources. """ def __init__(self, sourceId, baseDir): self.sourceId = sourceId self.baseDir = os.path.normpath(baseDir) def __str__(self): return self.sourceId @classmethod def parseDmlMeta(cls, xmlfile): """ Parse out all fields from meta.xml, return them as a dictionary. """ result = {} xml = open(xmlfile) for line in xml: if line.find('<article>') >= 0: # skip until the beginning of <article> tag break for line in xml: if line.find('</article>') >= 0: # end of <article>, we're done break p = re.search(PAT_TAG, line) # HAX assumes one element = one line; proper xml parsing probably better... but who cares if p: name, cont = p.groups() name = name.split()[0] name, cont = name.strip(), cont.strip() if name == 'msc': if len(cont) != 5: logger.warning('invalid MSC=%s in %s' % (cont, xmlfile)) result.setdefault('msc', []).append(cont) continue if name == 'idMR': cont = cont[2:] # omit MR from MR123456 if name and cont: result[name] = cont xml.close() return result def idFromDir(self, path): assert len(path) > len(self.baseDir) intId = path[1 + path.rfind('#') : ] pathId = path[len(self.baseDir) + 1 : ] return (intId, pathId) def isArticle(self, path): # in order to be valid, the article directory must start with '#' if not os.path.basename(path).startswith('#'): return False # and contain the fulltext.txt file if not os.path.exists(os.path.join(path, 'fulltext.txt')): logger.info('missing fulltext in %s' % path) return False # and also the meta.xml file if not os.path.exists(os.path.join(path, 'meta.xml')): logger.info('missing meta.xml in %s' % path) return False return True def findArticles(self): dirTotal = artAccepted = 0 logger.info("looking for '%s' articles inside %s" % (self.sourceId, self.baseDir)) for root, dirs, files in os.walk(self.baseDir): dirTotal += 1 root = os.path.normpath(root) if self.isArticle(root): artAccepted += 1 yield self.idFromDir(root) logger.info('%i directories processed, found %i articles' % (dirTotal, artAccepted)) def getContent(self, uri): """ Return article content as a single large string. """ intId, pathId = uri filename = os.path.join(self.baseDir, pathId, 'fulltext.txt') return open(filename).read() def getMeta(self, uri): """ Return article metadata as a attribute->value dictionary. """ intId, pathId = uri filename = os.path.join(self.baseDir, pathId, 'meta.xml') return DmlSource.parseDmlMeta(filename) def tokenize(self, content): return [token.encode('utf8') for token in utils.tokenize(content, errors = 'ignore') if not token.isdigit()] def normalizeWord(self, word): wordU = unicode(word, 'utf8') return wordU.lower().encode('utf8') # lowercase and then convert back to bytestring #endclass DmlSource class DmlCzSource(DmlSource): """ Article source for articles in DML-CZ format: 1) articles = directories starting with '#' 2) content is stored in fulltext.txt or fulltext_dspace.txt 3) there exists a dspace_id file, containing internal dmlcz id 3) metadata are stored in meta.xml See the ArticleSource class for general info on sources. """ def idFromDir(self, path): assert len(path) > len(self.baseDir) dmlczId = open(os.path.join(path, 'dspace_id')).read().strip() pathId = path[len(self.baseDir) + 1 : ] return (dmlczId, pathId) def isArticle(self, path): # in order to be valid, the article directory must start with '#' if not os.path.basename(path).startswith('#'): return False # and contain a dspace_id file if not (os.path.exists(os.path.join(path, 'dspace_id'))): logger.info('missing dspace_id in %s' % path) return False # and contain either fulltext.txt or fulltext_dspace.txt file if not (os.path.exists(os.path.join(path, 'fulltext.txt')) or os.path.exists(os.path.join(path, 'fulltext-dspace.txt'))): logger.info('missing fulltext in %s' % path) return False # and contain the meta.xml file if not os.path.exists(os.path.join(path, 'meta.xml')): logger.info('missing meta.xml in %s' % path) return False return True def getContent(self, uri): """ Return article content as a single large string. """ intId, pathId = uri filename1 = os.path.join(self.baseDir, pathId, 'fulltext.txt') filename2 = os.path.join(self.baseDir, pathId, 'fulltext-dspace.txt') if os.path.exists(filename1) and os.path.exists(filename2): # if both fulltext and dspace files exist, pick the larger one if os.path.getsize(filename1) < os.path.getsize(filename2): filename = filename2 else: filename = filename1 elif os.path.exists(filename1): filename = filename1 else: assert os.path.exists(filename2) filename = filename2 return open(filename).read() #endclass DmlCzSource class ArxmlivSource(ArticleSource): """ Article source for articles in arxmliv format: 1) articles = directories starting with '#' 2) content is stored in tex.xml 3) metadata in special tags within tex.xml Article URI is currently (a part of) the article's path on filesystem. See the ArticleSource class for general info on sources. """ class ArxmlivContentHandler(xml.sax.handler.ContentHandler): def __init__(self): self.path = [''] # help structure for sax event parsing self.tokens = [] # will contain tokens once parsing is finished def startElement(self, name, attr): # for math tokens, we only care about Math elements directly below <p> if name == 'Math' and self.path[-1] == 'p' and attr.get('mode', '') == 'inline': tex = attr.get('tex', '') if tex and not tex.isdigit(): self.tokens.append('$%s$' % tex.encode('utf8')) self.path.append(name) def endElement(self, name): self.path.pop() def characters(self, text): # for text, we only care about tokens directly within the <p> tag if self.path[-1] == 'p': tokens = [token.encode('utf8') for token in utils.tokenize(text, errors = 'ignore') if not token.isdigit()] self.tokens.extend(tokens) #endclass ArxmlivHandler class ArxmlivErrorHandler(xml.sax.handler.ErrorHandler): # Python2.5 implementation of xml.sax is broken -- character streams and # byte encodings of InputSource are ignored, bad things sometimes happen # in buffering of multi-byte files (such as utf8), characters get cut in # the middle, resulting in invalid tokens... # This is not really a problem with arxmliv xml files themselves, so ignore # these errors silently. def error(self, exception): pass # logger.debug("SAX error parsing xml: %s" % exception) warning = fatalError = error #endclass ArxmlivErrorHandler def __init__(self, sourceId, baseDir): self.sourceId = sourceId self.baseDir = os.path.normpath(baseDir) def __str__(self): return self.sourceId def idFromDir(self, path): assert len(path) > len(self.baseDir) intId = path[1 + path.rfind('#') : ] pathId = path[len(self.baseDir) + 1 : ] return (intId, pathId) def isArticle(self, path): # in order to be valid, the article directory must start with '#' if not os.path.basename(path).startswith('#'): return False # and contain the tex.xml file if not os.path.exists(os.path.join(path, 'tex.xml')): logger.warning('missing tex.xml in %s' % path) return False return True def findArticles(self): dirTotal = artAccepted = 0 logger.info("looking for '%s' articles inside %s" % (self.sourceId, self.baseDir)) for root, dirs, files in os.walk(self.baseDir): dirTotal += 1 root = os.path.normpath(root) if self.isArticle(root): artAccepted += 1 yield self.idFromDir(root) logger.info('%i directories processed, found %i articles' % (dirTotal, artAccepted)) def getContent(self, uri): """ Return article content as a single large string. """ intId, pathId = uri filename = os.path.join(self.baseDir, pathId, 'tex.xml') return open(filename).read() def getMeta(self, uri): """ Return article metadata as an attribute->value dictionary. """ # intId, pathId = uri # filename = os.path.join(self.baseDir, pathId, 'tex.xml') return {'language': 'eng'} # TODO maybe parse out some meta; but currently not needed for anything... def tokenize(self, content): """ Parse tokens out of xml. There are two types of token: normal text and mathematics. Both are returned interspersed in a single list, in the same order as they appeared in the content. The math tokens will be returned in the form $tex_expression$, ie. with a dollar sign prefix and suffix. """ handler = ArxmlivSource.ArxmlivContentHandler() xml.sax.parseString(content, handler, ArxmlivSource.ArxmlivErrorHandler()) return handler.tokens def normalizeWord(self, word): if word[0] == '$': # ignore math tokens return word wordU = unicode(word, 'utf8') return wordU.lower().encode('utf8') # lowercase and then convert back to bytestring #endclass ArxmlivSource
lgpl-2.1
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 3898, 3572, 799, 72, 608, 75, 665, 345, 3572, 264, 72, 608, 75, 32, 261, 90, 17811, 14, 16823, 30, 199, 3, 3909, 1334, 314, 1664, 32426, 373, 18, 14, 17, 446, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 199, 199, 624, 199, 2765, 859, 3509, 12591, 24649, 3365, 3992, 9, 1314, 22667, 5434, 314, 199, 2655, 65, 402, 282, 29979, 11243, 2213, 1350, 14, 199, 199, 33, 2213, 1350, 365, 26014, 282, 3245, 402, 23242, 26994, 314, 2011, 1475, 12, 199, 7191, 2909, 334, 466, 402, 2879, 395, 2011, 4340, 402, 6057, 3062, 5423, 14, 199, 199, 31409, 5274, 883, 506, 26913, 1901, 282, 2849, 16831, 12, 1314, 365, 4052, 314, 199, 64, 36, 757, 26424, 64, 1021, 1630, 334, 3239, 314, 658, 68, 757, 16780, 64, 859, 680, 199, 624, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 199, 646, 2748, 14, 14338, 327, 367, 6057, 601, 10198, 317, 86, 23242, 199, 199, 504, 3805, 5206, 492, 3778, 421, 199, 2805, 63, 6967, 275, 295, 14, 2014, 4827, 17140, 13032, 8, 12432, 1108, 6697, 5971, 199, 2921, 275, 2050, 14, 5572, 360, 2268, 5206, 14, 20504, 65, 14, 4553, 358, 421, 199, 533, 8281, 2980, 8, 785, 304, 272, 408, 272, 26794, 402, 642, 1021, 13743, 282, 2849, 1350, 402, 23242, 14, 339, 437, 1350, 365, 376, 2236, 29639, 1806, 2382, 314, 8247, 295, 2441, 334, 1589, 2342, 7221, 83, 342, 272, 1083, 395, 4212, 370, 8044, 3932, 2615, 19517, 12, 3932, 3341, 12, 4212, 370, 13343, 314, 272, 23242, 436, 4212, 370, 7666, 314, 4645, 14, 339, 14791, 365, 2845, 2236, 14183, 1522, 13437, 334, 1873, 14, 1471, 10266, 367, 1006, 5274, 9, 365, 314, 16819, 402, 272, 9772, 14154, 334, 1230, 1831, 395, 1314, 28727, 10405, 1924, 9772, 4453, 272, 1373, 1350, 14, 339, 961, 1021, 365, 2951, 376, 17281, 3217, 27, 1937, 11837, 14, 577, 757, 2980, 503, 1952, 10198, 317, 86, 2980, 3992, 272, 367, 13801, 4454, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1350, 1304, 304, 267, 291, 14, 1365, 1304, 275, 1350, 1304, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1365, 1304, 339, 347, 2342, 7221, 83, 8, 277, 304, 267, 746, 4279, 360, 8458, 3523, 8089, 358, 339, 347, 664, 2714, 8, 277, 12, 5108, 304, 267, 746, 4279, 360, 8458, 3523, 8089, 358, 339, 347, 664, 3396, 8, 277, 12, 5108, 304, 267, 746, 4279, 360, 8458, 3523, 8089, 358, 339, 347, 13343, 8, 277, 12, 1564, 304, 267, 746, 4279, 360, 8458, 3523, 8089, 358, 339, 347, 7666, 10155, 8, 277, 12, 4349, 304, 267, 746, 4279, 360, 8458, 3523, 8089, 358, 199, 3, 500, 533, 8281, 2980, 4388, 199, 533, 577, 757, 2980, 8, 7221, 2980, 304, 272, 408, 272, 8281, 1350, 367, 23242, 315, 577, 1698, 1475, 334, 36, 1698, 13, 27808, 12, 16817, 68, 455, 304, 272, 413, 9, 23242, 275, 6602, 6617, 543, 19619, 272, 499, 9, 1564, 365, 5489, 315, 2615, 505, 14, 2424, 272, 650, 9, 3341, 787, 5489, 315, 3404, 14, 1652, 339, 8281, 9022, 365, 5544, 334, 65, 1777, 402, 9, 314, 9772, 1159, 931, 641, 10036, 14, 339, 1666, 314, 8281, 2980, 1021, 367, 8605, 2256, 641, 5274, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1350, 1304, 12, 1300, 3567, 304, 267, 291, 14, 1365, 1304, 275, 1350, 1304, 267, 291, 14, 1095, 3567, 275, 747, 14, 515, 14, 9267, 8, 1095, 3567, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1365, 1304, 339, 768, 3744, 272, 347, 2198, 36, 757, 3396, 8, 1886, 12, 17725, 12059, 304, 267, 408, 267, 6077, 734, 1006, 1504, 687, 3404, 14, 1652, 12, 372, 3062, 465, 282, 2600, 14, 267, 408, 267, 754, 275, 1052, 267, 2748, 275, 1551, 8, 10198, 12059, 9, 267, 367, 1004, 315, 2748, 26, 288, 340, 1004, 14, 1623, 4827, 6934, 5971, 2356, 378, 26, 327, 3372, 5133, 314, 9608, 402, 665, 6934, 30, 1947, 355, 2059, 267, 367, 1004, 315, 2748, 26, 288, 340, 1004, 14, 1623, 14264, 6934, 5971, 2356, 378, 26, 327, 1284, 402, 665, 6934, 6244, 781, 3984, 4224, 355, 2059, 288, 299, 275, 295, 14, 1733, 8, 2805, 63, 6967, 12, 1004, 9, 327, 869, 9839, 15194, 1373, 1819, 275, 1373, 1004, 27, 5576, 2748, 6057, 8646, 8034, 1396, 1325, 3963, 1704, 470, 288, 340, 299, 26, 355, 536, 12, 13770, 275, 299, 14, 2634, 342, 355, 536, 275, 536, 14, 1294, 3430, 16, 61, 355, 536, 12, 13770, 275, 536, 14, 1913, 1062, 13770, 14, 1913, 342, 355, 340, 536, 508, 283, 77, 551, 356, 490, 340, 822, 8, 11096, 9, 1137, 959, 26, 717, 2512, 14, 3764, 360, 3197, 603, 5153, 2458, 83, 315, 450, 83, 7, 450, 334, 11096, 12, 17725, 12059, 430, 490, 754, 14, 5486, 360, 77, 551, 297, 15364, 740, 8, 11096, 9, 490, 1980, 355, 340, 536, 508, 283, 344, 22153, 356, 490, 13770, 275, 13770, 59, 18, 2938, 327, 19413, 603, 50, 687, 603, 50, 19060, 355, 340, 536, 436, 13770, 26, 490, 754, 59, 354, 61, 275, 13770, 267, 2748, 14, 1600, 342, 267, 372, 754, 2378, 347, 1305, 2532, 3567, 8, 277, 12, 931, 304, 267, 702, 822, 8, 515, 9, 690, 822, 8, 277, 14, 1095, 3567, 9, 267, 1109, 1304, 275, 931, 59, 17, 435, 931, 14, 14542, 7863, 358, 520, 1622, 267, 931, 1304, 275, 931, 59, 552, 8, 277, 14, 1095, 3567, 9, 435, 413, 520, 1622, 267, 372, 334, 442, 1304, 12, 931, 1304, 9, 2378, 347, 365, 7221, 8, 277, 12, 931, 304, 267, 327, 315, 1865, 370, 506, 1686, 12, 314, 9772, 2082, 1471, 1343, 543, 19619, 267, 340, 440, 747, 14, 515, 14, 4846, 8, 515, 680, 2460, 7863, 735, 288, 372, 756, 267, 327, 436, 1395, 314, 2615, 505, 14, 2424, 570, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 736, 14, 515 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 3898, 3572, 799, 72, 608, 75, 665, 345, 3572, 264, 72, 608, 75, 32, 261, 90, 17811, 14, 16823, 30, 199, 3, 3909, 1334, 314, 1664, 32426, 373, 18, 14, 17, 446, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 199, 199, 624, 199, 2765, 859, 3509, 12591, 24649, 3365, 3992, 9, 1314, 22667, 5434, 314, 199, 2655, 65, 402, 282, 29979, 11243, 2213, 1350, 14, 199, 199, 33, 2213, 1350, 365, 26014, 282, 3245, 402, 23242, 26994, 314, 2011, 1475, 12, 199, 7191, 2909, 334, 466, 402, 2879, 395, 2011, 4340, 402, 6057, 3062, 5423, 14, 199, 199, 31409, 5274, 883, 506, 26913, 1901, 282, 2849, 16831, 12, 1314, 365, 4052, 314, 199, 64, 36, 757, 26424, 64, 1021, 1630, 334, 3239, 314, 658, 68, 757, 16780, 64, 859, 680, 199, 624, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 199, 646, 2748, 14, 14338, 327, 367, 6057, 601, 10198, 317, 86, 23242, 199, 199, 504, 3805, 5206, 492, 3778, 421, 199, 2805, 63, 6967, 275, 295, 14, 2014, 4827, 17140, 13032, 8, 12432, 1108, 6697, 5971, 199, 2921, 275, 2050, 14, 5572, 360, 2268, 5206, 14, 20504, 65, 14, 4553, 358, 421, 199, 533, 8281, 2980, 8, 785, 304, 272, 408, 272, 26794, 402, 642, 1021, 13743, 282, 2849, 1350, 402, 23242, 14, 339, 437, 1350, 365, 376, 2236, 29639, 1806, 2382, 314, 8247, 295, 2441, 334, 1589, 2342, 7221, 83, 342, 272, 1083, 395, 4212, 370, 8044, 3932, 2615, 19517, 12, 3932, 3341, 12, 4212, 370, 13343, 314, 272, 23242, 436, 4212, 370, 7666, 314, 4645, 14, 339, 14791, 365, 2845, 2236, 14183, 1522, 13437, 334, 1873, 14, 1471, 10266, 367, 1006, 5274, 9, 365, 314, 16819, 402, 272, 9772, 14154, 334, 1230, 1831, 395, 1314, 28727, 10405, 1924, 9772, 4453, 272, 1373, 1350, 14, 339, 961, 1021, 365, 2951, 376, 17281, 3217, 27, 1937, 11837, 14, 577, 757, 2980, 503, 1952, 10198, 317, 86, 2980, 3992, 272, 367, 13801, 4454, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1350, 1304, 304, 267, 291, 14, 1365, 1304, 275, 1350, 1304, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1365, 1304, 339, 347, 2342, 7221, 83, 8, 277, 304, 267, 746, 4279, 360, 8458, 3523, 8089, 358, 339, 347, 664, 2714, 8, 277, 12, 5108, 304, 267, 746, 4279, 360, 8458, 3523, 8089, 358, 339, 347, 664, 3396, 8, 277, 12, 5108, 304, 267, 746, 4279, 360, 8458, 3523, 8089, 358, 339, 347, 13343, 8, 277, 12, 1564, 304, 267, 746, 4279, 360, 8458, 3523, 8089, 358, 339, 347, 7666, 10155, 8, 277, 12, 4349, 304, 267, 746, 4279, 360, 8458, 3523, 8089, 358, 199, 3, 500, 533, 8281, 2980, 4388, 199, 533, 577, 757, 2980, 8, 7221, 2980, 304, 272, 408, 272, 8281, 1350, 367, 23242, 315, 577, 1698, 1475, 334, 36, 1698, 13, 27808, 12, 16817, 68, 455, 304, 272, 413, 9, 23242, 275, 6602, 6617, 543, 19619, 272, 499, 9, 1564, 365, 5489, 315, 2615, 505, 14, 2424, 272, 650, 9, 3341, 787, 5489, 315, 3404, 14, 1652, 339, 8281, 9022, 365, 5544, 334, 65, 1777, 402, 9, 314, 9772, 1159, 931, 641, 10036, 14, 339, 1666, 314, 8281, 2980, 1021, 367, 8605, 2256, 641, 5274, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1350, 1304, 12, 1300, 3567, 304, 267, 291, 14, 1365, 1304, 275, 1350, 1304, 267, 291, 14, 1095, 3567, 275, 747, 14, 515, 14, 9267, 8, 1095, 3567, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1365, 1304, 339, 768, 3744, 272, 347, 2198, 36, 757, 3396, 8, 1886, 12, 17725, 12059, 304, 267, 408, 267, 6077, 734, 1006, 1504, 687, 3404, 14, 1652, 12, 372, 3062, 465, 282, 2600, 14, 267, 408, 267, 754, 275, 1052, 267, 2748, 275, 1551, 8, 10198, 12059, 9, 267, 367, 1004, 315, 2748, 26, 288, 340, 1004, 14, 1623, 4827, 6934, 5971, 2356, 378, 26, 327, 3372, 5133, 314, 9608, 402, 665, 6934, 30, 1947, 355, 2059, 267, 367, 1004, 315, 2748, 26, 288, 340, 1004, 14, 1623, 14264, 6934, 5971, 2356, 378, 26, 327, 1284, 402, 665, 6934, 6244, 781, 3984, 4224, 355, 2059, 288, 299, 275, 295, 14, 1733, 8, 2805, 63, 6967, 12, 1004, 9, 327, 869, 9839, 15194, 1373, 1819, 275, 1373, 1004, 27, 5576, 2748, 6057, 8646, 8034, 1396, 1325, 3963, 1704, 470, 288, 340, 299, 26, 355, 536, 12, 13770, 275, 299, 14, 2634, 342, 355, 536, 275, 536, 14, 1294, 3430, 16, 61, 355, 536, 12, 13770, 275, 536, 14, 1913, 1062, 13770, 14, 1913, 342, 355, 340, 536, 508, 283, 77, 551, 356, 490, 340, 822, 8, 11096, 9, 1137, 959, 26, 717, 2512, 14, 3764, 360, 3197, 603, 5153, 2458, 83, 315, 450, 83, 7, 450, 334, 11096, 12, 17725, 12059, 430, 490, 754, 14, 5486, 360, 77, 551, 297, 15364, 740, 8, 11096, 9, 490, 1980, 355, 340, 536, 508, 283, 344, 22153, 356, 490, 13770, 275, 13770, 59, 18, 2938, 327, 19413, 603, 50, 687, 603, 50, 19060, 355, 340, 536, 436, 13770, 26, 490, 754, 59, 354, 61, 275, 13770, 267, 2748, 14, 1600, 342, 267, 372, 754, 2378, 347, 1305, 2532, 3567, 8, 277, 12, 931, 304, 267, 702, 822, 8, 515, 9, 690, 822, 8, 277, 14, 1095, 3567, 9, 267, 1109, 1304, 275, 931, 59, 17, 435, 931, 14, 14542, 7863, 358, 520, 1622, 267, 931, 1304, 275, 931, 59, 552, 8, 277, 14, 1095, 3567, 9, 435, 413, 520, 1622, 267, 372, 334, 442, 1304, 12, 931, 1304, 9, 2378, 347, 365, 7221, 8, 277, 12, 931, 304, 267, 327, 315, 1865, 370, 506, 1686, 12, 314, 9772, 2082, 1471, 1343, 543, 19619, 267, 340, 440, 747, 14, 515, 14, 4846, 8, 515, 680, 2460, 7863, 735, 288, 372, 756, 267, 327, 436, 1395, 314, 2615, 505, 14, 2424, 570, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1 ]
abn/coreemu
daemon/examples/netns/iperf-performance-chain.py
11
3196
#!/usr/bin/python # Copyright (c)2013 the Boeing Company. # See the LICENSE file included in this distribution. # This script creates a CORE session, that will connect n nodes together # in a chain, with static routes between nodes # number of nodes / number of hops # 2 0 # 3 1 # 4 2 # n n - 2 # # Use core-cleanup to clean up after this script as the session is left running. # import sys, datetime, optparse from core import pycore from core.misc import ipaddr from core.constants import * # node list (count from 1) n = [None] def main(): usagestr = "usage: %prog [-h] [options] [args]" parser = optparse.OptionParser(usage = usagestr) parser.set_defaults(numnodes = 5) parser.add_option("-n", "--numnodes", dest = "numnodes", type = int, help = "number of nodes") def usage(msg = None, err = 0): sys.stdout.write("\n") if msg: sys.stdout.write(msg + "\n\n") parser.print_help() sys.exit(err) # parse command line options (options, args) = parser.parse_args() if options.numnodes < 1: usage("invalid number of nodes: %s" % options.numnodes) if options.numnodes >= 255: usage("invalid number of nodes: %s" % options.numnodes) for a in args: sys.stderr.write("ignoring command line argument: '%s'\n" % a) start = datetime.datetime.now() session = pycore.Session(persistent=True) if 'server' in globals(): server.addsession(session) print "creating %d nodes" % options.numnodes left = None prefix = None for i in xrange(1, options.numnodes + 1): tmp = session.addobj(cls = pycore.nodes.CoreNode, name = "n%d" % i, objid=i) if left: tmp.newnetif(left, ["%s/%s" % (prefix.addr(2), prefix.prefixlen)]) prefix = ipaddr.IPv4Prefix("10.83.%d.0/24" % i) # limit: i < 255 right = session.addobj(cls = pycore.nodes.PtpNet) tmp.newnetif(right, ["%s/%s" % (prefix.addr(1), prefix.prefixlen)]) tmp.cmd([SYSCTL_BIN, "net.ipv4.icmp_echo_ignore_broadcasts=0"]) tmp.cmd([SYSCTL_BIN, "net.ipv4.conf.all.forwarding=1"]) tmp.cmd([SYSCTL_BIN, "net.ipv4.conf.default.rp_filter=0"]) tmp.setposition(x=100*i,y=150) n.append(tmp) left = right prefixes = map(lambda(x): ipaddr.IPv4Prefix("10.83.%d.0/24" % x), xrange(1, options.numnodes + 1)) # set up static routing in the chain for i in xrange(1, options.numnodes + 1): for j in xrange(1, options.numnodes + 1): if j < i - 1: gw = prefixes[i-2].addr(1) elif j > i: if i > len(prefixes) - 1: continue gw = prefixes[i-1].addr(2) else: continue net = prefixes[j-1] n[i].cmd([IP_BIN, "route", "add", str(net), "via", str(gw)]) print "elapsed time: %s" % (datetime.datetime.now() - start) if __name__ == "__main__" or __name__ == "__builtin__": main()
bsd-2-clause
[ 3381, 2647, 15, 1393, 15, 1548, 9948, 199, 3, 1898, 334, 67, 9, 6965, 314, 5088, 69, 316, 15878, 14, 199, 3, 1666, 314, 5113, 570, 5120, 315, 642, 4084, 14, 199, 199, 3, 961, 2884, 8491, 282, 445, 5788, 2351, 12, 626, 911, 4907, 302, 3380, 10451, 199, 3, 315, 282, 6036, 12, 543, 2955, 15777, 3382, 3380, 199, 3, 259, 1329, 402, 3380, 1182, 1329, 402, 394, 1483, 199, 3, 3322, 499, 3322, 378, 199, 3, 3322, 650, 3322, 413, 199, 3, 3322, 841, 3322, 499, 199, 3, 3322, 302, 3515, 302, 446, 499, 199, 3, 199, 3, 3645, 6170, 13, 7661, 370, 3633, 1536, 2410, 642, 2884, 465, 314, 2351, 365, 3602, 3879, 14, 199, 3, 199, 199, 646, 984, 12, 2197, 12, 8691, 199, 199, 504, 6170, 492, 1134, 1018, 199, 504, 6170, 14, 9923, 492, 21249, 199, 504, 6170, 14, 5559, 492, 627, 199, 199, 3, 1031, 769, 334, 835, 687, 413, 9, 199, 78, 275, 359, 403, 61, 199, 199, 318, 2446, 837, 272, 4503, 495, 275, 298, 3807, 26, 450, 6595, 5243, 72, 61, 359, 1419, 61, 359, 589, 8480, 272, 1798, 275, 8691, 14, 14553, 8, 3807, 275, 4503, 495, 9, 272, 1798, 14, 409, 63, 4322, 8, 1507, 2415, 275, 959, 9, 339, 1798, 14, 525, 63, 1422, 6096, 78, 401, 4320, 1507, 2415, 401, 2053, 275, 298, 1507, 2415, 401, 730, 275, 1109, 12, 1993, 1720, 275, 298, 1955, 402, 3380, 531, 339, 347, 4503, 8, 1328, 275, 488, 12, 2329, 275, 378, 304, 267, 984, 14, 2703, 14, 952, 4582, 78, 531, 267, 340, 1499, 26, 288, 984, 14, 2703, 14, 952, 8, 1328, 435, 1867, 78, 60, 78, 531, 267, 1798, 14, 1361, 63, 3437, 342, 267, 984, 14, 2224, 8, 1508, 9, 339, 327, 2198, 1414, 1004, 1511, 272, 334, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 339, 340, 1511, 14, 1507, 2415, 665, 413, 26, 267, 4503, 480, 3197, 1329, 402, 3380, 26, 450, 83, 2, 450, 1511, 14, 1507, 2415, 9, 339, 340, 1511, 14, 1507, 2415, 2356, 5450, 26, 267, 4503, 480, 3197, 1329, 402, 3380, 26, 450, 83, 2, 450, 1511, 14, 1507, 2415, 9, 339, 367, 282, 315, 1249, 26, 267, 984, 14, 3083, 14, 952, 480, 1030, 6854, 1414, 1004, 1423, 26, 1543, 83, 1154, 78, 2, 450, 282, 9, 339, 1343, 275, 2197, 14, 2083, 14, 2131, 342, 339, 2351, 275, 1134, 1018, 14, 4434, 8, 18539, 29, 549, 9, 272, 340, 283, 1000, 7, 315, 7992, 837, 267, 1654, 14, 525, 1730, 8, 1730, 9, 272, 870, 298, 20358, 450, 68, 3380, 2, 221, 450, 1511, 14, 1507, 2415, 272, 3602, 275, 488, 272, 2403, 275, 488, 272, 367, 284, 315, 4945, 8, 17, 12, 1511, 14, 1507, 2415, 435, 413, 304, 267, 3529, 275, 2351, 14, 525, 1113, 8, 1886, 275, 1134, 1018, 14, 2415, 14, 5402, 1716, 12, 536, 275, 298, 78, 5, 68, 2, 450, 284, 12, 2490, 1559, 344, 29, 73, 9, 267, 340, 3602, 26, 288, 3529, 14, 1222, 20869, 8, 3039, 12, 28585, 83, 3149, 83, 2, 450, 334, 1861, 14, 2697, 8, 18, 395, 2403, 14, 16089, 3948, 398, 2403, 275, 21249, 14, 12179, 20, 4793, 480, 709, 14, 2658, 4111, 68, 14, 16, 15, 1194, 2, 450, 284, 9, 327, 2304, 26, 284, 665, 5450, 267, 2451, 275, 2351, 14, 525, 1113, 8, 1886, 275, 1134, 1018, 14, 2415, 14, 48, 683, 2480, 9, 267, 3529, 14, 1222, 20869, 8, 1019, 12, 28585, 83, 3149, 83, 2, 450, 334, 1861, 14, 2697, 8, 17, 395, 2403, 14, 16089, 3948, 267, 3529, 14, 1760, 779, 13326, 23745, 63, 9431, 12, 298, 846, 14, 4774, 20, 14, 18799, 63, 7878, 63, 4247, 63, 10786, 83, 29, 16, 3135, 267, 3529, 14, 1760, 779, 13326, 23745, 63, 9431, 12, 298, 846, 14, 4774, 20, 14, 2190, 14, 452, 14, 21513, 29, 17, 3135, 267, 3529, 14, 1760, 779, 13326, 23745, 63, 9431, 12, 298, 846, 14, 4774, 20, 14, 2190, 14, 885, 14, 4599, 63, 1541, 29, 16, 3135, 267, 3529, 14, 409, 3124, 8, 88, 29, 1960, 10, 73, 12, 89, 29, 8251, 9, 267, 302, 14, 740, 8, 2791, 9, 267, 3602, 275, 2451, 2286, 13158, 275, 2341, 8, 2734, 8, 88, 304, 21249, 14, 12179, 20, 4793, 480, 709, 14, 2658, 4111, 68, 14, 16, 15, 1194, 2, 450, 671, 395, 673, 4945, 8, 17, 12, 1511, 14, 1507, 2415, 435, 413, 430, 490, 272, 327, 663, 1536, 2955, 14870, 315, 314, 6036, 272, 367, 284, 315, 4945, 8, 17, 12, 1511, 14, 1507, 2415, 435, 413, 304, 267, 367, 1335, 315, 4945, 8, 17, 12, 1511, 14, 1507, 2415, 435, 413, 304, 288, 340, 1335, 665, 284, 446, 413, 26, 355, 22192, 275, 13158, 59, 73, 13, 18, 1055, 2697, 8, 17, 9, 288, 916, 1335, 690, 284, 26, 355, 340, 284, 690, 822, 8, 14124, 9, 446, 413, 26, 490, 1980, 355, 22192, 275, 13158, 59, 73, 13, 17, 1055, 2697, 8, 18, 9, 288, 587, 26, 355, 1980, 288, 1851, 275, 13158, 59, 74, 13, 17, 61, 288, 302, 59, 73, 1055, 1760, 779, 1772, 63, 9431, 12, 298, 4449, 401, 298, 525, 401, 620, 8, 846, 395, 298, 12897, 401, 620, 8, 8392, 3948, 2378, 870, 298, 16691, 900, 26, 450, 83, 2, 450, 334, 2083, 14, 2083, 14, 2131, 342, 446, 1343, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 16526, 503, 636, 354, 363, 508, 4396, 5351, 5727, 272, 2446, 342, 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 ]
[ 2647, 15, 1393, 15, 1548, 9948, 199, 3, 1898, 334, 67, 9, 6965, 314, 5088, 69, 316, 15878, 14, 199, 3, 1666, 314, 5113, 570, 5120, 315, 642, 4084, 14, 199, 199, 3, 961, 2884, 8491, 282, 445, 5788, 2351, 12, 626, 911, 4907, 302, 3380, 10451, 199, 3, 315, 282, 6036, 12, 543, 2955, 15777, 3382, 3380, 199, 3, 259, 1329, 402, 3380, 1182, 1329, 402, 394, 1483, 199, 3, 3322, 499, 3322, 378, 199, 3, 3322, 650, 3322, 413, 199, 3, 3322, 841, 3322, 499, 199, 3, 3322, 302, 3515, 302, 446, 499, 199, 3, 199, 3, 3645, 6170, 13, 7661, 370, 3633, 1536, 2410, 642, 2884, 465, 314, 2351, 365, 3602, 3879, 14, 199, 3, 199, 199, 646, 984, 12, 2197, 12, 8691, 199, 199, 504, 6170, 492, 1134, 1018, 199, 504, 6170, 14, 9923, 492, 21249, 199, 504, 6170, 14, 5559, 492, 627, 199, 199, 3, 1031, 769, 334, 835, 687, 413, 9, 199, 78, 275, 359, 403, 61, 199, 199, 318, 2446, 837, 272, 4503, 495, 275, 298, 3807, 26, 450, 6595, 5243, 72, 61, 359, 1419, 61, 359, 589, 8480, 272, 1798, 275, 8691, 14, 14553, 8, 3807, 275, 4503, 495, 9, 272, 1798, 14, 409, 63, 4322, 8, 1507, 2415, 275, 959, 9, 339, 1798, 14, 525, 63, 1422, 6096, 78, 401, 4320, 1507, 2415, 401, 2053, 275, 298, 1507, 2415, 401, 730, 275, 1109, 12, 1993, 1720, 275, 298, 1955, 402, 3380, 531, 339, 347, 4503, 8, 1328, 275, 488, 12, 2329, 275, 378, 304, 267, 984, 14, 2703, 14, 952, 4582, 78, 531, 267, 340, 1499, 26, 288, 984, 14, 2703, 14, 952, 8, 1328, 435, 1867, 78, 60, 78, 531, 267, 1798, 14, 1361, 63, 3437, 342, 267, 984, 14, 2224, 8, 1508, 9, 339, 327, 2198, 1414, 1004, 1511, 272, 334, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 339, 340, 1511, 14, 1507, 2415, 665, 413, 26, 267, 4503, 480, 3197, 1329, 402, 3380, 26, 450, 83, 2, 450, 1511, 14, 1507, 2415, 9, 339, 340, 1511, 14, 1507, 2415, 2356, 5450, 26, 267, 4503, 480, 3197, 1329, 402, 3380, 26, 450, 83, 2, 450, 1511, 14, 1507, 2415, 9, 339, 367, 282, 315, 1249, 26, 267, 984, 14, 3083, 14, 952, 480, 1030, 6854, 1414, 1004, 1423, 26, 1543, 83, 1154, 78, 2, 450, 282, 9, 339, 1343, 275, 2197, 14, 2083, 14, 2131, 342, 339, 2351, 275, 1134, 1018, 14, 4434, 8, 18539, 29, 549, 9, 272, 340, 283, 1000, 7, 315, 7992, 837, 267, 1654, 14, 525, 1730, 8, 1730, 9, 272, 870, 298, 20358, 450, 68, 3380, 2, 221, 450, 1511, 14, 1507, 2415, 272, 3602, 275, 488, 272, 2403, 275, 488, 272, 367, 284, 315, 4945, 8, 17, 12, 1511, 14, 1507, 2415, 435, 413, 304, 267, 3529, 275, 2351, 14, 525, 1113, 8, 1886, 275, 1134, 1018, 14, 2415, 14, 5402, 1716, 12, 536, 275, 298, 78, 5, 68, 2, 450, 284, 12, 2490, 1559, 344, 29, 73, 9, 267, 340, 3602, 26, 288, 3529, 14, 1222, 20869, 8, 3039, 12, 28585, 83, 3149, 83, 2, 450, 334, 1861, 14, 2697, 8, 18, 395, 2403, 14, 16089, 3948, 398, 2403, 275, 21249, 14, 12179, 20, 4793, 480, 709, 14, 2658, 4111, 68, 14, 16, 15, 1194, 2, 450, 284, 9, 327, 2304, 26, 284, 665, 5450, 267, 2451, 275, 2351, 14, 525, 1113, 8, 1886, 275, 1134, 1018, 14, 2415, 14, 48, 683, 2480, 9, 267, 3529, 14, 1222, 20869, 8, 1019, 12, 28585, 83, 3149, 83, 2, 450, 334, 1861, 14, 2697, 8, 17, 395, 2403, 14, 16089, 3948, 267, 3529, 14, 1760, 779, 13326, 23745, 63, 9431, 12, 298, 846, 14, 4774, 20, 14, 18799, 63, 7878, 63, 4247, 63, 10786, 83, 29, 16, 3135, 267, 3529, 14, 1760, 779, 13326, 23745, 63, 9431, 12, 298, 846, 14, 4774, 20, 14, 2190, 14, 452, 14, 21513, 29, 17, 3135, 267, 3529, 14, 1760, 779, 13326, 23745, 63, 9431, 12, 298, 846, 14, 4774, 20, 14, 2190, 14, 885, 14, 4599, 63, 1541, 29, 16, 3135, 267, 3529, 14, 409, 3124, 8, 88, 29, 1960, 10, 73, 12, 89, 29, 8251, 9, 267, 302, 14, 740, 8, 2791, 9, 267, 3602, 275, 2451, 2286, 13158, 275, 2341, 8, 2734, 8, 88, 304, 21249, 14, 12179, 20, 4793, 480, 709, 14, 2658, 4111, 68, 14, 16, 15, 1194, 2, 450, 671, 395, 673, 4945, 8, 17, 12, 1511, 14, 1507, 2415, 435, 413, 430, 490, 272, 327, 663, 1536, 2955, 14870, 315, 314, 6036, 272, 367, 284, 315, 4945, 8, 17, 12, 1511, 14, 1507, 2415, 435, 413, 304, 267, 367, 1335, 315, 4945, 8, 17, 12, 1511, 14, 1507, 2415, 435, 413, 304, 288, 340, 1335, 665, 284, 446, 413, 26, 355, 22192, 275, 13158, 59, 73, 13, 18, 1055, 2697, 8, 17, 9, 288, 916, 1335, 690, 284, 26, 355, 340, 284, 690, 822, 8, 14124, 9, 446, 413, 26, 490, 1980, 355, 22192, 275, 13158, 59, 73, 13, 17, 1055, 2697, 8, 18, 9, 288, 587, 26, 355, 1980, 288, 1851, 275, 13158, 59, 74, 13, 17, 61, 288, 302, 59, 73, 1055, 1760, 779, 1772, 63, 9431, 12, 298, 4449, 401, 298, 525, 401, 620, 8, 846, 395, 298, 12897, 401, 620, 8, 8392, 3948, 2378, 870, 298, 16691, 900, 26, 450, 83, 2, 450, 334, 2083, 14, 2083, 14, 2131, 342, 446, 1343, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 16526, 503, 636, 354, 363, 508, 4396, 5351, 5727, 272, 2446, 342, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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608
# -*- coding: utf-8 -*- """ requests.adapters ~~~~~~~~~~~~~~~~~ This module contains the transport adapters that Requests uses to define and maintain connections. """ import socket from .models import Response from .packages.urllib3.poolmanager import PoolManager, proxy_from_url from .packages.urllib3.response import HTTPResponse from .packages.urllib3.util import Timeout as TimeoutSauce from .compat import urlparse, basestring, urldefrag, unquote from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers, prepend_scheme_if_needed, get_auth_from_url) from .structures import CaseInsensitiveDict from .packages.urllib3.exceptions import MaxRetryError from .packages.urllib3.exceptions import TimeoutError from .packages.urllib3.exceptions import SSLError as _SSLError from .packages.urllib3.exceptions import HTTPError as _HTTPError from .packages.urllib3.exceptions import ProxyError as _ProxyError from .cookies import extract_cookies_to_jar from .exceptions import ConnectionError, Timeout, SSLError, ProxyError from .auth import _basic_auth_str DEFAULT_POOLBLOCK = False DEFAULT_POOLSIZE = 10 DEFAULT_RETRIES = 0 class BaseAdapter(object): """The Base Transport Adapter""" def __init__(self): super(BaseAdapter, self).__init__() def send(self): raise NotImplementedError def close(self): raise NotImplementedError class HTTPAdapter(BaseAdapter): """The built-in HTTP Adapter for urllib3. Provides a general-case interface for Requests sessions to contact HTTP and HTTPS urls by implementing the Transport Adapter interface. This class will usually be created by the :class:`Session <Session>` class under the covers. :param pool_connections: The number of urllib3 connection pools to cache. :param pool_maxsize: The maximum number of connections to save in the pool. :param int max_retries: The maximum number of retries each connection should attempt. Note, this applies only to failed connections and timeouts, never to requests where the server returns a response. :param pool_block: Whether the connection pool should block for connections. Usage:: >>> import requests >>> s = requests.Session() >>> a = requests.adapters.HTTPAdapter(max_retries=3) >>> s.mount('http://', a) """ __attrs__ = ['max_retries', 'config', '_pool_connections', '_pool_maxsize', '_pool_block'] def __init__(self, pool_connections=DEFAULT_POOLSIZE, pool_maxsize=DEFAULT_POOLSIZE, max_retries=DEFAULT_RETRIES, pool_block=DEFAULT_POOLBLOCK): self.max_retries = max_retries self.config = {} self.proxy_manager = {} super(HTTPAdapter, self).__init__() self._pool_connections = pool_connections self._pool_maxsize = pool_maxsize self._pool_block = pool_block self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block) def __getstate__(self): return dict((attr, getattr(self, attr, None)) for attr in self.__attrs__) def __setstate__(self, state): # Can't handle by adding 'proxy_manager' to self.__attrs__ because # because self.poolmanager uses a lambda function, which isn't pickleable. self.proxy_manager = {} self.config = {} for attr, value in state.items(): setattr(self, attr, value) self.init_poolmanager(self._pool_connections, self._pool_maxsize, block=self._pool_block) def init_poolmanager(self, connections, maxsize, block=DEFAULT_POOLBLOCK): """Initializes a urllib3 PoolManager. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param connections: The number of urllib3 connection pools to cache. :param maxsize: The maximum number of connections to save in the pool. :param block: Block when no free connections are available. """ # save these values for pickling self._pool_connections = connections self._pool_maxsize = maxsize self._pool_block = block self.poolmanager = PoolManager(num_pools=connections, maxsize=maxsize, block=block) def cert_verify(self, conn, url, verify, cert): """Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param conn: The urllib3 connection object associated with the cert. :param url: The requested URL. :param verify: Whether we should actually verify the certificate. :param cert: The SSL certificate to verify. """ if url.lower().startswith('https') and verify: cert_loc = None # Allow self-specified cert location. if verify is not True: cert_loc = verify if not cert_loc: cert_loc = DEFAULT_CA_BUNDLE_PATH if not cert_loc: raise Exception("Could not find a suitable SSL CA certificate bundle.") conn.cert_reqs = 'CERT_REQUIRED' conn.ca_certs = cert_loc else: conn.cert_reqs = 'CERT_NONE' conn.ca_certs = None if cert: if not isinstance(cert, basestring): conn.cert_file = cert[0] conn.key_file = cert[1] else: conn.cert_file = cert def build_response(self, req, resp): """Builds a :class:`Response <requests.Response>` object from a urllib3 response. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>` :param req: The :class:`PreparedRequest <PreparedRequest>` used to generate the response. :param resp: The urllib3 response object. """ response = Response() # Fallback to None if there's no status_code, for whatever reason. response.status_code = getattr(resp, 'status', None) # Make headers case-insensitive. response.headers = CaseInsensitiveDict(getattr(resp, 'headers', {})) # Set encoding. response.encoding = get_encoding_from_headers(response.headers) response.raw = resp response.reason = response.raw.reason if isinstance(req.url, bytes): response.url = req.url.decode('utf-8') else: response.url = req.url # Add new cookies from the server. extract_cookies_to_jar(response.cookies, req, resp) # Give the Response some context. response.request = req response.connection = self return response def get_connection(self, url, proxies=None): """Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param url: The URL to connect to. :param proxies: (optional) A Requests-style dictionary of proxies used on this request. """ proxies = proxies or {} proxy = proxies.get(urlparse(url.lower()).scheme) if proxy: proxy = prepend_scheme_if_needed(proxy, 'http') proxy_headers = self.proxy_headers(proxy) if not proxy in self.proxy_manager: self.proxy_manager[proxy] = proxy_from_url( proxy, proxy_headers=proxy_headers, num_pools=self._pool_connections, maxsize=self._pool_maxsize, block=self._pool_block) conn = self.proxy_manager[proxy].connection_from_url(url) else: # Only scheme should be lower case parsed = urlparse(url) url = parsed.geturl() conn = self.poolmanager.connection_from_url(url) return conn def close(self): """Disposes of any internal state. Currently, this just closes the PoolManager, which closes pooled connections. """ self.poolmanager.clear() def request_url(self, request, proxies): """Obtain the url to use when making the final request. If the message is being sent through a HTTP proxy, the full URL has to be used. Otherwise, we should only use the path portion of the URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param proxies: A dictionary of schemes to proxy URLs. """ proxies = proxies or {} scheme = urlparse(request.url).scheme proxy = proxies.get(scheme) if proxy and scheme != 'https': url, _ = urldefrag(request.url) else: url = request.path_url return url def add_headers(self, request, **kwargs): """Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param request: The :class:`PreparedRequest <PreparedRequest>` to add headers to. :param kwargs: The keyword arguments from the call to send(). """ pass def proxy_headers(self, proxy): """Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param proxies: The url of the proxy being used for this request. :param kwargs: Optional additional keyword arguments. """ headers = {} username, password = get_auth_from_url(proxy) if username and password: headers['Proxy-Authorization'] = _basic_auth_str(username, password) return headers def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None): """Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request content. :param timeout: (optional) The timeout on the request. :param verify: (optional) Whether to verify SSL certificates. :param cert: (optional) Any user-provided SSL certificate to be trusted. :param proxies: (optional) The proxies dictionary to apply to the request. """ conn = self.get_connection(request.url, proxies) self.cert_verify(conn, request.url, verify, cert) url = self.request_url(request, proxies) self.add_headers(request) chunked = not (request.body is None or 'Content-Length' in request.headers) timeout = TimeoutSauce(connect=timeout, read=timeout) try: if not chunked: resp = conn.urlopen( method=request.method, url=url, body=request.body, headers=request.headers, redirect=False, assert_same_host=False, preload_content=False, decode_content=False, retries=self.max_retries, timeout=timeout ) # Send the request. else: if hasattr(conn, 'proxy_pool'): conn = conn.proxy_pool low_conn = conn._get_conn(timeout=timeout) try: low_conn.putrequest(request.method, url, skip_accept_encoding=True) for header, value in request.headers.items(): low_conn.putheader(header, value) low_conn.endheaders() for i in request.body: low_conn.send(hex(len(i))[2:].encode('utf-8')) low_conn.send(b'\r\n') low_conn.send(i) low_conn.send(b'\r\n') low_conn.send(b'0\r\n\r\n') r = low_conn.getresponse() resp = HTTPResponse.from_httplib( r, pool=conn, connection=low_conn, preload_content=False, decode_content=False ) except: # If we hit any problems here, clean up the connection. # Then, reraise so that we can handle the actual exception. low_conn.close() raise else: # All is well, return the connection to the pool. conn._put_conn(low_conn) except socket.error as sockerr: raise ConnectionError(sockerr, request=request) except MaxRetryError as e: raise ConnectionError(e, request=request) except _ProxyError as e: raise ProxyError(e) except (_SSLError, _HTTPError) as e: if isinstance(e, _SSLError): raise SSLError(e, request=request) elif isinstance(e, TimeoutError): raise Timeout(e, request=request) else: raise return self.build_response(request, resp)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 6615, 14, 21680, 199, 9753, 94, 199, 199, 2765, 859, 3509, 314, 7773, 1503, 12552, 626, 20260, 4440, 370, 5627, 199, 460, 11075, 6947, 14, 199, 624, 199, 199, 646, 2838, 199, 199, 504, 1275, 992, 492, 7232, 199, 504, 1275, 5154, 14, 4078, 19, 14, 2293, 2609, 492, 15553, 2988, 12, 4566, 63, 504, 63, 633, 199, 504, 1275, 5154, 14, 4078, 19, 14, 1310, 492, 29034, 199, 504, 1275, 5154, 14, 4078, 19, 14, 1974, 492, 12878, 465, 12878, 12226, 3683, 199, 504, 1275, 5819, 492, 7097, 12, 7116, 12, 1166, 318, 2527, 12, 14342, 199, 504, 1275, 1208, 492, 334, 3472, 63, 3263, 63, 32044, 906, 63, 3243, 12, 664, 63, 2991, 63, 504, 63, 2139, 12, 490, 18213, 63, 5512, 63, 692, 63, 11368, 12, 664, 63, 1178, 63, 504, 63, 633, 9, 199, 504, 1275, 13547, 492, 12425, 32697, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 8228, 12989, 547, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 31886, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 7799, 547, 465, 485, 27102, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 15050, 465, 485, 12815, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 12373, 547, 465, 485, 4936, 547, 199, 504, 1275, 7792, 492, 5536, 63, 7792, 63, 475, 63, 7338, 199, 504, 1275, 3924, 492, 25417, 12, 12878, 12, 7799, 547, 12, 12373, 547, 199, 504, 1275, 1178, 492, 485, 4316, 63, 1178, 63, 495, 199, 199, 3472, 63, 19693, 8475, 275, 756, 199, 3472, 63, 19693, 4305, 275, 1616, 199, 3472, 63, 32528, 275, 378, 421, 199, 533, 3523, 10200, 8, 785, 304, 272, 408, 1918, 3523, 27018, 4431, 4185, 624, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 1563, 10200, 12, 291, 2843, 826, 4533, 339, 347, 3222, 8, 277, 304, 267, 746, 4279, 339, 347, 4002, 8, 277, 304, 267, 746, 4279, 421, 199, 533, 3101, 10200, 8, 1563, 10200, 304, 272, 408, 1918, 6137, 13, 262, 3101, 4431, 4185, 367, 4011, 19, 14, 339, 21552, 282, 8605, 13, 2546, 3217, 367, 20260, 12184, 370, 8966, 3101, 436, 272, 14147, 8187, 701, 18234, 314, 27018, 4431, 4185, 3217, 14, 961, 1021, 911, 272, 9987, 506, 2737, 701, 314, 520, 533, 1705, 4434, 665, 4434, 8637, 1021, 1334, 314, 272, 25858, 14, 339, 520, 635, 4203, 63, 7995, 26, 710, 1329, 402, 4011, 19, 1950, 20092, 370, 2581, 14, 272, 520, 635, 4203, 63, 13634, 26, 710, 5696, 1329, 402, 6947, 370, 3354, 315, 314, 4203, 14, 272, 520, 635, 1109, 1390, 63, 10937, 26, 710, 5696, 1329, 402, 10086, 1924, 1950, 267, 1077, 7427, 14, 3390, 12, 642, 12966, 1454, 370, 3405, 6947, 436, 267, 25870, 12, 7078, 370, 4145, 2382, 314, 1654, 2529, 282, 1177, 14, 272, 520, 635, 4203, 63, 1457, 26, 7480, 314, 1950, 4203, 1077, 1853, 367, 6947, 14, 339, 11028, 447, 2541, 1306, 492, 4145, 489, 1306, 308, 275, 4145, 14, 4434, 342, 489, 1306, 282, 275, 4145, 14, 21680, 14, 2856, 10200, 8, 988, 63, 10937, 29, 19, 9, 489, 1306, 308, 14, 3956, 360, 1014, 921, 297, 282, 9, 272, 408, 272, 636, 3288, 363, 275, 788, 988, 63, 10937, 297, 283, 888, 297, 2513, 2293, 63, 7995, 297, 2513, 2293, 63, 13634, 297, 326, 2513, 2293, 63, 1457, 418, 339, 347, 636, 826, 721, 277, 12, 4203, 63, 7995, 29, 3472, 63, 19693, 4305, 12, 326, 4203, 63, 13634, 29, 3472, 63, 19693, 4305, 12, 1390, 63, 10937, 29, 3472, 63, 32528, 12, 326, 4203, 63, 1457, 29, 3472, 63, 19693, 8475, 304, 267, 291, 14, 988, 63, 10937, 275, 1390, 63, 10937, 267, 291, 14, 888, 275, 1052, 267, 291, 14, 3280, 63, 2609, 275, 1052, 398, 1613, 8, 2856, 10200, 12, 291, 2843, 826, 4533, 398, 291, 423, 2293, 63, 7995, 275, 4203, 63, 7995, 267, 291, 423, 2293, 63, 13634, 275, 4203, 63, 13634, 267, 291, 423, 2293, 63, 1457, 275, 4203, 63, 1457, 398, 291, 14, 826, 63, 2293, 2609, 8, 2293, 63, 7995, 12, 4203, 63, 13634, 12, 1853, 29, 2293, 63, 1457, 9, 339, 347, 636, 16011, 721, 277, 304, 267, 372, 1211, 1332, 962, 12, 2519, 8, 277, 12, 1921, 12, 488, 430, 367, 1921, 315, 490, 291, 855, 3288, 3368, 339, 347, 636, 17212, 721, 277, 12, 1174, 304, 267, 327, 6855, 1133, 2429, 701, 7791, 283, 3280, 63, 2609, 7, 370, 291, 855, 3288, 363, 2952, 267, 327, 2952, 291, 14, 2293, 2609, 4440, 282, 2400, 805, 12, 1314, 5712, 1133, 5927, 461, 14, 267, 291, 14, 3280, 63, 2609, 275, 1052, 267, 291, 14, 888, 275, 1052, 398, 367, 1921, 12, 574, 315, 1174, 14, 1744, 837, 288, 5371, 8, 277, 12, 1921, 12, 574, 9, 398, 291, 14, 826, 63, 2293, 2609, 8, 277, 423, 2293, 63, 7995, 12, 291, 423, 2293, 63, 13634, 12, 2892, 1853, 29, 277, 423, 2293, 63, 1457, 9, 339, 347, 4205, 63, 2293, 2609, 8, 277, 12, 6947, 12, 19791, 12, 1853, 29, 3472, 63, 19693, 8475, 304, 267, 408, 23489, 282, 4011, 19, 15553, 2988, 14, 961, 1083, 1077, 440, 506, 2797, 267, 687, 922, 1233, 12, 436, 365, 1454, 19282, 367, 675, 1380, 24572, 314, 267, 520, 533, 1705, 2856, 10200, 665, 6615, 14, 21680, 14, 2856, 10200, 14943, 398, 520, 635, 6947, 26, 710, 1329, 402, 4011, 19, 1950, 20092, 370, 2581, 14, 267, 520, 635, 19791, 26, 710, 5696, 1329, 402, 6947, 370, 3354, 315, 314, 4203, 14, 267, 520, 635, 1853, 26, 8651, 1380, 949, 2867, 6947, 787, 2808, 14, 267, 408, 267, 327, 3354, 3520, 1338, 367, 24394, 267, 291, 423, 2293, 63, 7995, 275, 6947, 267, 291, 423, 2293, 63, 13634, 275, 19791, 267, 291, 423, 2293, 63, 1457, 275, 1853, 398, 291, 14, 2293, 2609, 275, 15553, 2988, 8, 1507, 63, 12406, 29, 7995, 12, 19791, 29, 13634, 12, 4318, 1853, 29, 1457, 9, 339, 347, 6250, 63, 4712, 8, 277, 12, 2557, 12, 1166, 12, 4911, 12, 6250, 304, 267, 408, 7496, 282, 7799, 5897, 14, 961, 1083 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 6615, 14, 21680, 199, 9753, 94, 199, 199, 2765, 859, 3509, 314, 7773, 1503, 12552, 626, 20260, 4440, 370, 5627, 199, 460, 11075, 6947, 14, 199, 624, 199, 199, 646, 2838, 199, 199, 504, 1275, 992, 492, 7232, 199, 504, 1275, 5154, 14, 4078, 19, 14, 2293, 2609, 492, 15553, 2988, 12, 4566, 63, 504, 63, 633, 199, 504, 1275, 5154, 14, 4078, 19, 14, 1310, 492, 29034, 199, 504, 1275, 5154, 14, 4078, 19, 14, 1974, 492, 12878, 465, 12878, 12226, 3683, 199, 504, 1275, 5819, 492, 7097, 12, 7116, 12, 1166, 318, 2527, 12, 14342, 199, 504, 1275, 1208, 492, 334, 3472, 63, 3263, 63, 32044, 906, 63, 3243, 12, 664, 63, 2991, 63, 504, 63, 2139, 12, 490, 18213, 63, 5512, 63, 692, 63, 11368, 12, 664, 63, 1178, 63, 504, 63, 633, 9, 199, 504, 1275, 13547, 492, 12425, 32697, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 8228, 12989, 547, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 31886, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 7799, 547, 465, 485, 27102, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 15050, 465, 485, 12815, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 12373, 547, 465, 485, 4936, 547, 199, 504, 1275, 7792, 492, 5536, 63, 7792, 63, 475, 63, 7338, 199, 504, 1275, 3924, 492, 25417, 12, 12878, 12, 7799, 547, 12, 12373, 547, 199, 504, 1275, 1178, 492, 485, 4316, 63, 1178, 63, 495, 199, 199, 3472, 63, 19693, 8475, 275, 756, 199, 3472, 63, 19693, 4305, 275, 1616, 199, 3472, 63, 32528, 275, 378, 421, 199, 533, 3523, 10200, 8, 785, 304, 272, 408, 1918, 3523, 27018, 4431, 4185, 624, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 1563, 10200, 12, 291, 2843, 826, 4533, 339, 347, 3222, 8, 277, 304, 267, 746, 4279, 339, 347, 4002, 8, 277, 304, 267, 746, 4279, 421, 199, 533, 3101, 10200, 8, 1563, 10200, 304, 272, 408, 1918, 6137, 13, 262, 3101, 4431, 4185, 367, 4011, 19, 14, 339, 21552, 282, 8605, 13, 2546, 3217, 367, 20260, 12184, 370, 8966, 3101, 436, 272, 14147, 8187, 701, 18234, 314, 27018, 4431, 4185, 3217, 14, 961, 1021, 911, 272, 9987, 506, 2737, 701, 314, 520, 533, 1705, 4434, 665, 4434, 8637, 1021, 1334, 314, 272, 25858, 14, 339, 520, 635, 4203, 63, 7995, 26, 710, 1329, 402, 4011, 19, 1950, 20092, 370, 2581, 14, 272, 520, 635, 4203, 63, 13634, 26, 710, 5696, 1329, 402, 6947, 370, 3354, 315, 314, 4203, 14, 272, 520, 635, 1109, 1390, 63, 10937, 26, 710, 5696, 1329, 402, 10086, 1924, 1950, 267, 1077, 7427, 14, 3390, 12, 642, 12966, 1454, 370, 3405, 6947, 436, 267, 25870, 12, 7078, 370, 4145, 2382, 314, 1654, 2529, 282, 1177, 14, 272, 520, 635, 4203, 63, 1457, 26, 7480, 314, 1950, 4203, 1077, 1853, 367, 6947, 14, 339, 11028, 447, 2541, 1306, 492, 4145, 489, 1306, 308, 275, 4145, 14, 4434, 342, 489, 1306, 282, 275, 4145, 14, 21680, 14, 2856, 10200, 8, 988, 63, 10937, 29, 19, 9, 489, 1306, 308, 14, 3956, 360, 1014, 921, 297, 282, 9, 272, 408, 272, 636, 3288, 363, 275, 788, 988, 63, 10937, 297, 283, 888, 297, 2513, 2293, 63, 7995, 297, 2513, 2293, 63, 13634, 297, 326, 2513, 2293, 63, 1457, 418, 339, 347, 636, 826, 721, 277, 12, 4203, 63, 7995, 29, 3472, 63, 19693, 4305, 12, 326, 4203, 63, 13634, 29, 3472, 63, 19693, 4305, 12, 1390, 63, 10937, 29, 3472, 63, 32528, 12, 326, 4203, 63, 1457, 29, 3472, 63, 19693, 8475, 304, 267, 291, 14, 988, 63, 10937, 275, 1390, 63, 10937, 267, 291, 14, 888, 275, 1052, 267, 291, 14, 3280, 63, 2609, 275, 1052, 398, 1613, 8, 2856, 10200, 12, 291, 2843, 826, 4533, 398, 291, 423, 2293, 63, 7995, 275, 4203, 63, 7995, 267, 291, 423, 2293, 63, 13634, 275, 4203, 63, 13634, 267, 291, 423, 2293, 63, 1457, 275, 4203, 63, 1457, 398, 291, 14, 826, 63, 2293, 2609, 8, 2293, 63, 7995, 12, 4203, 63, 13634, 12, 1853, 29, 2293, 63, 1457, 9, 339, 347, 636, 16011, 721, 277, 304, 267, 372, 1211, 1332, 962, 12, 2519, 8, 277, 12, 1921, 12, 488, 430, 367, 1921, 315, 490, 291, 855, 3288, 3368, 339, 347, 636, 17212, 721, 277, 12, 1174, 304, 267, 327, 6855, 1133, 2429, 701, 7791, 283, 3280, 63, 2609, 7, 370, 291, 855, 3288, 363, 2952, 267, 327, 2952, 291, 14, 2293, 2609, 4440, 282, 2400, 805, 12, 1314, 5712, 1133, 5927, 461, 14, 267, 291, 14, 3280, 63, 2609, 275, 1052, 267, 291, 14, 888, 275, 1052, 398, 367, 1921, 12, 574, 315, 1174, 14, 1744, 837, 288, 5371, 8, 277, 12, 1921, 12, 574, 9, 398, 291, 14, 826, 63, 2293, 2609, 8, 277, 423, 2293, 63, 7995, 12, 291, 423, 2293, 63, 13634, 12, 2892, 1853, 29, 277, 423, 2293, 63, 1457, 9, 339, 347, 4205, 63, 2293, 2609, 8, 277, 12, 6947, 12, 19791, 12, 1853, 29, 3472, 63, 19693, 8475, 304, 267, 408, 23489, 282, 4011, 19, 15553, 2988, 14, 961, 1083, 1077, 440, 506, 2797, 267, 687, 922, 1233, 12, 436, 365, 1454, 19282, 367, 675, 1380, 24572, 314, 267, 520, 533, 1705, 2856, 10200, 665, 6615, 14, 21680, 14, 2856, 10200, 14943, 398, 520, 635, 6947, 26, 710, 1329, 402, 4011, 19, 1950, 20092, 370, 2581, 14, 267, 520, 635, 19791, 26, 710, 5696, 1329, 402, 6947, 370, 3354, 315, 314, 4203, 14, 267, 520, 635, 1853, 26, 8651, 1380, 949, 2867, 6947, 787, 2808, 14, 267, 408, 267, 327, 3354, 3520, 1338, 367, 24394, 267, 291, 423, 2293, 63, 7995, 275, 6947, 267, 291, 423, 2293, 63, 13634, 275, 19791, 267, 291, 423, 2293, 63, 1457, 275, 1853, 398, 291, 14, 2293, 2609, 275, 15553, 2988, 8, 1507, 63, 12406, 29, 7995, 12, 19791, 29, 13634, 12, 4318, 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 ]
openstack/heat
heat/engine/resources/openstack/heat/remote_stack.py
1
18516
# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from oslo_log import log as logging from oslo_serialization import jsonutils import tempfile from heat.common import auth_plugin from heat.common import context from heat.common import exception from heat.common.i18n import _ from heat.common import template_format from heat.engine import attributes from heat.engine import environment from heat.engine import properties from heat.engine import resource from heat.engine import support from heat.engine import template LOG = logging.getLogger(__name__) class TempCACertFile(object): def __init__(self, ca_cert): self._cacert = ca_cert self._cacert_temp_file = None def __enter__(self): self.tempfile_path = self._store_temp_ca_cert() return self.tempfile_path def __exit__(self, type, value, traceback): if self._cacert_temp_file: self._cacert_temp_file.close() def _store_temp_ca_cert(self): if self._cacert: try: self._cacert_temp_file = tempfile.NamedTemporaryFile() self._cacert_temp_file.write( str(self._cacert).encode('utf-8')) # Add seek func to make sure the writen context will flush to # tempfile with python 2.7. we can use flush() for python 2.7 # but not 3.5. self._cacert_temp_file.seek(0) file_path = self._cacert_temp_file.name return file_path except Exception: LOG.exception("Error when create template file for CA cert") if self._cacert_temp_file: self._cacert_temp_file.close() raise class RemoteStack(resource.Resource): """A Resource representing a stack. A resource that allowing for the creating stack, where should be defined stack template in HOT format, parameters (if template has any parameters with no default value), and timeout of creating. After creating current stack will have remote stack. """ default_client_name = 'heat' entity = 'stacks' PROPERTIES = ( CONTEXT, TEMPLATE, TIMEOUT, PARAMETERS, ) = ( 'context', 'template', 'timeout', 'parameters', ) ATTRIBUTES = ( NAME_ATTR, OUTPUTS, ) = ( 'stack_name', 'outputs', ) _CONTEXT_KEYS = ( REGION_NAME, CREDENTIAL_SECRET_ID, CA_CERT, SSL_INSECURE ) = ( 'region_name', 'credential_secret_id', 'ca_cert', 'insecure' ) properties_schema = { CONTEXT: properties.Schema( properties.Schema.MAP, _('Context for this stack.'), update_allowed=True, schema={ REGION_NAME: properties.Schema( properties.Schema.STRING, _('Region name in which this stack will be created.'), required=False, ), CREDENTIAL_SECRET_ID: properties.Schema( properties.Schema.STRING, _('A Barbican secret ID. The Barbican secret should ' 'contain an OpenStack credential that can be used to ' 'access a remote cloud.'), required=False, update_allowed=True, support_status=support.SupportStatus(version='12.0.0'), ), CA_CERT: properties.Schema( properties.Schema.STRING, _('CA Cert for SSL.'), required=False, update_allowed=True, support_status=support.SupportStatus(version='12.0.0'), ), SSL_INSECURE: properties.Schema( properties.Schema.BOOLEAN, _("If set, then the server's certificate will not be " "verified."), default=False, required=False, update_allowed=True, support_status=support.SupportStatus(version='12.0.0'), ), } ), TEMPLATE: properties.Schema( properties.Schema.STRING, _('Template that specifies the stack to be created as ' 'a resource.'), required=True, update_allowed=True ), TIMEOUT: properties.Schema( properties.Schema.INTEGER, _('Number of minutes to wait for this stack creation.'), update_allowed=True ), PARAMETERS: properties.Schema( properties.Schema.MAP, _('Set of parameters passed to this stack.'), default={}, update_allowed=True ), } attributes_schema = { NAME_ATTR: attributes.Schema( _('Name of the stack.'), type=attributes.Schema.STRING ), OUTPUTS: attributes.Schema( _('A dict of key-value pairs output from the stack.'), type=attributes.Schema.MAP ), } def __init__(self, name, definition, stack): super(RemoteStack, self).__init__(name, definition, stack) self._region_name = None self._local_context = None self._ssl_verify = None self._cacert = None @property def cacert(self): ctx_props = self.properties.get(self.CONTEXT) if ctx_props: self._cacert = ctx_props[self.CA_CERT] return self._cacert def _get_from_secret(self, key): result = super(RemoteStack, self).client_plugin( 'barbican').get_secret_payload_by_ref( secret_ref='secrets/%s' % (key)) return result def _context(self, cacert_path=None): need_reassign = False # To get ctx_props first, since cacert_path might change each time we # call _context ctx_props = self.properties.get(self.CONTEXT) if ctx_props: self._credential = ctx_props[self.CREDENTIAL_SECRET_ID] self._region_name = ctx_props[self.REGION_NAME] if ctx_props[ self.REGION_NAME] else self.context.region_name _insecure = ctx_props[self.SSL_INSECURE] _ssl_verify = False if _insecure else ( cacert_path or True) need_reassign = self._ssl_verify != _ssl_verify if need_reassign: self._ssl_verify = _ssl_verify else: self._credential = None self._region_name = self.context.region_name if self._local_context and not need_reassign: return self._local_context if ctx_props and self._credential: return self._prepare_cloud_context() else: return self._prepare_region_context() def _fetch_barbican_credential(self): """Fetch credential information and return context dict.""" auth = self._get_from_secret(self._credential) return auth def _prepare_cloud_context(self): """Prepare context for remote cloud.""" auth = self._fetch_barbican_credential() dict_ctxt = self.context.to_dict() dict_ctxt.update({ 'request_id': dict_ctxt['request_id'], 'global_request_id': dict_ctxt['global_request_id'], 'show_deleted': dict_ctxt['show_deleted'] }) self._local_context = context.RequestContext.from_dict(dict_ctxt) if self._ssl_verify is not None: self._local_context.keystone_session.verify = self._ssl_verify self._local_context._auth_plugin = ( auth_plugin.get_keystone_plugin_loader( auth, self._local_context.keystone_session)) return self._local_context def _prepare_region_context(self): # Build RequestContext from existing one dict_ctxt = self.context.to_dict() dict_ctxt.update({'region_name': self._region_name, 'overwrite': False}) self._local_context = context.RequestContext.from_dict(dict_ctxt) if self._ssl_verify is not None: self._local_context.keystone_session.verify = self._ssl_verify return self._local_context def heat(self, cacert_path): # A convenience method overriding Resource.heat() return self._context( cacert_path).clients.client(self.default_client_name) def client_plugin(self): # A convenience method overriding Resource.client_plugin() return self._context().clients.client_plugin(self.default_client_name) def validate(self): super(RemoteStack, self).validate() try: with TempCACertFile(self.cacert) as cacert_path: self.heat(cacert_path) except Exception as ex: if self._credential: location = "remote cloud" else: location = 'region "%s"' % self._region_name exc_info = dict(location=location, exc=str(ex)) msg = _('Cannot establish connection to Heat endpoint at ' '%(location)s due to "%(exc)s"') % exc_info raise exception.StackValidationFailed(message=msg) try: params = self.properties[self.PARAMETERS] env = environment.get_child_environment(self.stack.env, params) tmpl = template_format.parse(self.properties[self.TEMPLATE]) args = { 'template': tmpl, 'files': self.stack.t.files, 'environment': env.user_env_as_dict(), } with TempCACertFile(self.cacert) as cacert_path: self.heat(cacert_path).stacks.validate(**args) except Exception as ex: if self._credential: location = "remote cloud" else: location = 'region "%s"' % self._region_name exc_info = dict(location=location, exc=str(ex)) msg = _('Failed validating stack template using Heat endpoint at ' '%(location)s due to "%(exc)s"') % exc_info raise exception.StackValidationFailed(message=msg) def handle_create(self): params = self.properties[self.PARAMETERS] env = environment.get_child_environment(self.stack.env, params) tmpl = template_format.parse(self.properties[self.TEMPLATE]) args = { 'stack_name': self.physical_resource_name_or_FnGetRefId(), 'template': tmpl, 'timeout_mins': self.properties[self.TIMEOUT], 'disable_rollback': True, 'parameters': params, 'files': self.stack.t.files, 'environment': env.user_env_as_dict(), } with TempCACertFile(self.cacert) as cacert_path: remote_stack_id = self.heat( cacert_path).stacks.create(**args)['stack']['id'] self.resource_id_set(remote_stack_id) def handle_delete(self): if self.resource_id is not None: with self.client_plugin().ignore_not_found: with TempCACertFile(self.cacert) as cacert_path: self.heat( cacert_path).stacks.delete(stack_id=self.resource_id) return self.resource_id return None def handle_resume(self): if self.resource_id is None: raise exception.Error(_('Cannot resume %s, resource not found') % self.name) with TempCACertFile(self.cacert) as cacert_path: self.heat(cacert_path).actions.resume(stack_id=self.resource_id) def handle_suspend(self): if self.resource_id is None: raise exception.Error(_('Cannot suspend %s, resource not found') % self.name) with TempCACertFile(self.cacert) as cacert_path: self.heat(cacert_path).actions.suspend(stack_id=self.resource_id) def handle_snapshot(self): with TempCACertFile(self.cacert) as cacert_path: snapshot = self.heat( cacert_path).stacks.snapshot(stack_id=self.resource_id) self.data_set('snapshot_id', snapshot['id']) def handle_restore(self, defn, restore_data): snapshot_id = restore_data['resource_data']['snapshot_id'] with TempCACertFile(self.cacert) as cacert_path: snapshot = self.heat( cacert_path).stacks.snapshot_show(self.resource_id, snapshot_id) s_data = snapshot['snapshot']['data'] env = environment.Environment(s_data['environment']) files = s_data['files'] tmpl = template.Template(s_data['template'], env=env, files=files) props = dict((k, v) for k, v in self.properties.items() if k in self.properties.data) props[self.TEMPLATE] = jsonutils.dumps(tmpl.t) props[self.PARAMETERS] = env.params return defn.freeze(properties=props) def handle_check(self): with TempCACertFile(self.cacert) as cacert_path: self.heat(cacert_path).actions.check(stack_id=self.resource_id) def _needs_update(self, after, before, after_props, before_props, prev_resource, check_init_complete=True): # If resource is in CHECK_FAILED state, raise UpdateReplace # to replace the failed stack. if self.state == (self.CHECK, self.FAILED): raise resource.UpdateReplace(self) # Always issue an update to the remote stack and let the individual # resources in it decide if they need updating. return True def handle_update(self, json_snippet, tmpl_diff, prop_diff): # Always issue an update to the remote stack and let the individual # resources in it decide if they need updating. if self.resource_id: self.properties = json_snippet.properties(self.properties_schema, self.context) params = self.properties[self.PARAMETERS] env = environment.get_child_environment(self.stack.env, params) tmpl = template_format.parse(self.properties[self.TEMPLATE]) fields = { 'stack_id': self.resource_id, 'parameters': params, 'template': tmpl, 'timeout_mins': self.properties[self.TIMEOUT], 'disable_rollback': self.stack.disable_rollback, 'files': self.stack.t.files, 'environment': env.user_env_as_dict(), } with TempCACertFile(self.cacert) as cacert_path: self.heat(cacert_path).stacks.update(**fields) def _check_action_complete(self, action): with TempCACertFile(self.cacert) as cacert_path: stack = self.heat( cacert_path).stacks.get(stack_id=self.resource_id) if stack.action != action: return False if stack.status == self.IN_PROGRESS: return False elif stack.status == self.COMPLETE: return True elif stack.status == self.FAILED: raise exception.ResourceInError( resource_status=stack.stack_status, status_reason=stack.stack_status_reason) else: # Note: this should never happen, so it really means that # the resource/engine is in serious problem if it happens. raise exception.ResourceUnknownStatus( resource_status=stack.stack_status, status_reason=stack.stack_status_reason) def check_create_complete(self, *args): return self._check_action_complete(action=self.CREATE) def check_delete_complete(self, deleting_resource_id=None): if deleting_resource_id is not None: with self.client_plugin().ignore_not_found: return self._check_action_complete(action=self.DELETE) return True def check_resume_complete(self, *args): return self._check_action_complete(action=self.RESUME) def check_suspend_complete(self, *args): return self._check_action_complete(action=self.SUSPEND) def check_update_complete(self, *args): return self._check_action_complete(action=self.UPDATE) def check_snapshot_complete(self, *args): return self._check_action_complete(action=self.SNAPSHOT) def check_check_complete(self, *args): return self._check_action_complete(action=self.CHECK) def _resolve_attribute(self, name): if self.resource_id is None: return with TempCACertFile(self.cacert) as cacert_path: stack = self.heat( cacert_path).stacks.get(stack_id=self.resource_id) if name == self.NAME_ATTR: value = getattr(stack, name, None) return value or self.physical_resource_name_or_FnGetRefId() if name == self.OUTPUTS: outputs = stack.outputs return dict((output['output_key'], output['output_value']) for output in outputs) def get_reference_id(self): return self.resource_id def needs_replace_with_prop_diff(self, changed_properties_set, after_props, before_props): """Needs replace based on prop_diff.""" # If region_name changed, trigger UpdateReplace. # `context` now set update_allowed=True, but `region_name` is not. if self.CONTEXT in changed_properties_set and ( after_props.get(self.CONTEXT).get( 'region_name') != before_props.get(self.CONTEXT).get( 'region_name')): return True return False def resource_mapping(): return { 'OS::Heat::Stack': RemoteStack, }
apache-2.0
[ 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 12161, 492, 18705, 199, 646, 5549, 199, 199, 504, 20408, 14, 2330, 492, 1790, 63, 2718, 199, 504, 20408, 14, 2330, 492, 1067, 199, 504, 20408, 14, 2330, 492, 1919, 199, 504, 20408, 14, 2330, 14, 73, 1085, 78, 492, 485, 199, 504, 20408, 14, 2330, 492, 1978, 63, 908, 199, 504, 20408, 14, 3908, 492, 3004, 199, 504, 20408, 14, 3908, 492, 3734, 199, 504, 20408, 14, 3908, 492, 4382, 199, 504, 20408, 14, 3908, 492, 2073, 199, 504, 20408, 14, 3908, 492, 2291, 199, 504, 20408, 14, 3908, 492, 1978, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 12540, 29154, 15299, 1173, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1704, 63, 4736, 304, 267, 291, 423, 11055, 15299, 275, 1704, 63, 4736, 267, 291, 423, 11055, 15299, 63, 808, 63, 493, 275, 488, 339, 347, 636, 4200, 721, 277, 304, 267, 291, 14, 17336, 63, 515, 275, 291, 423, 1617, 63, 808, 63, 696, 63, 4736, 342, 267, 372, 291, 14, 17336, 63, 515, 339, 347, 636, 2224, 721, 277, 12, 730, 12, 574, 12, 5190, 304, 267, 340, 291, 423, 11055, 15299, 63, 808, 63, 493, 26, 288, 291, 423, 11055, 15299, 63, 808, 63, 493, 14, 1600, 342, 339, 347, 485, 1617, 63, 808, 63, 696, 63, 4736, 8, 277, 304, 267, 340, 291, 423, 11055, 15299, 26, 288, 862, 26, 355, 291, 423, 11055, 15299, 63, 808, 63, 493, 275, 5549, 14, 19320, 342, 355, 291, 423, 11055, 15299, 63, 808, 63, 493, 14, 952, 8, 490, 620, 8, 277, 423, 11055, 15299, 680, 2143, 360, 1624, 13, 24, 1333, 355, 327, 2654, 12005, 2562, 370, 1852, 3238, 314, 2211, 724, 1067, 911, 8976, 370, 355, 327, 5549, 543, 2366, 499, 14, 23, 14, 781, 883, 675, 8976, 342, 367, 2366, 499, 14, 23, 355, 327, 1325, 440, 650, 14, 21, 14, 355, 291, 423, 11055, 15299, 63, 808, 63, 493, 14, 5507, 8, 16, 9, 355, 570, 63, 515, 275, 291, 423, 11055, 15299, 63, 808, 63, 493, 14, 354, 355, 372, 570, 63, 515, 288, 871, 2186, 26, 355, 5051, 14, 1971, 480, 547, 1380, 1218, 1978, 570, 367, 7240, 6250, 531, 355, 340, 291, 423, 11055, 15299, 63, 808, 63, 493, 26, 490, 291, 423, 11055, 15299, 63, 808, 63, 493, 14, 1600, 342, 355, 746, 421, 199, 533, 17283, 4851, 8, 1927, 14, 4031, 304, 272, 408, 33, 7337, 6144, 282, 3464, 14, 339, 437, 2073, 626, 17266, 367, 314, 6425, 3464, 12, 2382, 1077, 506, 3247, 272, 3464, 1978, 315, 869, 1387, 1475, 12, 2633, 334, 692, 1978, 965, 1263, 2633, 272, 543, 949, 849, 574, 395, 436, 2653, 402, 6425, 14, 12836, 6425, 1453, 272, 3464, 911, 1172, 3982, 3464, 14, 272, 408, 272, 849, 63, 1258, 63, 354, 275, 283, 16614, 7, 339, 4642, 275, 283, 21707, 7, 339, 3611, 4227, 29807, 275, 334, 267, 1868, 3876, 12, 24877, 12, 29998, 12, 23710, 12, 272, 776, 275, 334, 267, 283, 1100, 297, 283, 1160, 297, 283, 2593, 297, 283, 3214, 297, 272, 776, 339, 10762, 16883, 275, 334, 267, 13637, 63, 5280, 12, 18746, 51, 12, 272, 776, 275, 334, 267, 283, 2340, 63, 354, 297, 283, 4467, 297, 272, 776, 339, 485, 9059, 63, 17434, 275, 334, 267, 14142, 1075, 63, 2339, 12, 445, 7387, 8246, 63, 12961, 63, 998, 12, 7240, 63, 11163, 12, 7799, 63, 568, 20696, 272, 776, 275, 334, 267, 283, 4551, 63, 354, 297, 283, 15591, 63, 4731, 63, 344, 297, 283, 696, 63, 4736, 297, 283, 24824, 7, 272, 776, 339, 4382, 63, 3629, 275, 469, 267, 1868, 3876, 26, 4382, 14, 6700, 8, 288, 4382, 14, 6700, 14, 5443, 12, 288, 4018, 2998, 367, 642, 3464, 8038, 288, 1678, 63, 6541, 29, 549, 12, 288, 4177, 3126, 355, 14142, 1075, 63, 2339, 26, 4382, 14, 6700, 8, 490, 4382, 14, 6700, 14, 5353, 12, 490, 4018, 10708, 536, 315, 1314, 642, 3464, 911, 506, 2737, 8038, 490, 1415, 29, 797, 12, 355, 2318, 355, 445, 7387, 8246, 63, 12961, 63, 998, 26, 4382, 14, 6700, 8, 490, 4382, 14, 6700, 14, 5353, 12, 490, 4018, 33, 699, 10325, 530, 290, 7565, 2870, 14, 710, 699, 10325, 530, 290, 7565, 1077, 283, 1993, 283, 7747, 376, 14260, 16338, 626, 883, 506, 1202, 370, 283, 1993, 283, 2732, 282, 3982, 8002, 8038, 490, 1415, 29, 797, 12, 490, 1678, 63, 6541, 29, 549, 12, 490, 2291, 63, 1205, 29, 4058, 14, 11532, 3694, 8, 1023, 534, 713, 14, 16, 14, 16, 659, 355, 2318, 355, 7240, 63, 11163, 26, 4382, 14, 6700, 8, 490, 4382, 14, 6700, 14, 5353, 12, 490, 4018, 3263, 11002, 84, 367, 7799, 8038, 490, 1415, 29, 797, 12, 490, 1678, 63, 6541, 29, 549, 12, 490, 2291, 63, 1205, 29, 4058, 14, 11532, 3694, 8, 1023, 534, 713, 14, 16, 14, 16, 659, 355, 2318, 355, 7799, 63, 568, 20696, 26, 4382, 14, 6700, 8, 490, 4382, 14, 6700, 14, 25312, 12, 490, 3824, 3917, 663, 12, 2066, 314, 1654, 1159, 5897, 911, 440, 506, 298, 1993, 298, 12949, 7651, 490, 849, 29, 797, 12, 490, 1415, 29, 797, 12, 490, 1678, 63, 6541, 29, 549, 12, 490, 2291, 63, 1205 ]
[ 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 12161, 492, 18705, 199, 646, 5549, 199, 199, 504, 20408, 14, 2330, 492, 1790, 63, 2718, 199, 504, 20408, 14, 2330, 492, 1067, 199, 504, 20408, 14, 2330, 492, 1919, 199, 504, 20408, 14, 2330, 14, 73, 1085, 78, 492, 485, 199, 504, 20408, 14, 2330, 492, 1978, 63, 908, 199, 504, 20408, 14, 3908, 492, 3004, 199, 504, 20408, 14, 3908, 492, 3734, 199, 504, 20408, 14, 3908, 492, 4382, 199, 504, 20408, 14, 3908, 492, 2073, 199, 504, 20408, 14, 3908, 492, 2291, 199, 504, 20408, 14, 3908, 492, 1978, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 12540, 29154, 15299, 1173, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1704, 63, 4736, 304, 267, 291, 423, 11055, 15299, 275, 1704, 63, 4736, 267, 291, 423, 11055, 15299, 63, 808, 63, 493, 275, 488, 339, 347, 636, 4200, 721, 277, 304, 267, 291, 14, 17336, 63, 515, 275, 291, 423, 1617, 63, 808, 63, 696, 63, 4736, 342, 267, 372, 291, 14, 17336, 63, 515, 339, 347, 636, 2224, 721, 277, 12, 730, 12, 574, 12, 5190, 304, 267, 340, 291, 423, 11055, 15299, 63, 808, 63, 493, 26, 288, 291, 423, 11055, 15299, 63, 808, 63, 493, 14, 1600, 342, 339, 347, 485, 1617, 63, 808, 63, 696, 63, 4736, 8, 277, 304, 267, 340, 291, 423, 11055, 15299, 26, 288, 862, 26, 355, 291, 423, 11055, 15299, 63, 808, 63, 493, 275, 5549, 14, 19320, 342, 355, 291, 423, 11055, 15299, 63, 808, 63, 493, 14, 952, 8, 490, 620, 8, 277, 423, 11055, 15299, 680, 2143, 360, 1624, 13, 24, 1333, 355, 327, 2654, 12005, 2562, 370, 1852, 3238, 314, 2211, 724, 1067, 911, 8976, 370, 355, 327, 5549, 543, 2366, 499, 14, 23, 14, 781, 883, 675, 8976, 342, 367, 2366, 499, 14, 23, 355, 327, 1325, 440, 650, 14, 21, 14, 355, 291, 423, 11055, 15299, 63, 808, 63, 493, 14, 5507, 8, 16, 9, 355, 570, 63, 515, 275, 291, 423, 11055, 15299, 63, 808, 63, 493, 14, 354, 355, 372, 570, 63, 515, 288, 871, 2186, 26, 355, 5051, 14, 1971, 480, 547, 1380, 1218, 1978, 570, 367, 7240, 6250, 531, 355, 340, 291, 423, 11055, 15299, 63, 808, 63, 493, 26, 490, 291, 423, 11055, 15299, 63, 808, 63, 493, 14, 1600, 342, 355, 746, 421, 199, 533, 17283, 4851, 8, 1927, 14, 4031, 304, 272, 408, 33, 7337, 6144, 282, 3464, 14, 339, 437, 2073, 626, 17266, 367, 314, 6425, 3464, 12, 2382, 1077, 506, 3247, 272, 3464, 1978, 315, 869, 1387, 1475, 12, 2633, 334, 692, 1978, 965, 1263, 2633, 272, 543, 949, 849, 574, 395, 436, 2653, 402, 6425, 14, 12836, 6425, 1453, 272, 3464, 911, 1172, 3982, 3464, 14, 272, 408, 272, 849, 63, 1258, 63, 354, 275, 283, 16614, 7, 339, 4642, 275, 283, 21707, 7, 339, 3611, 4227, 29807, 275, 334, 267, 1868, 3876, 12, 24877, 12, 29998, 12, 23710, 12, 272, 776, 275, 334, 267, 283, 1100, 297, 283, 1160, 297, 283, 2593, 297, 283, 3214, 297, 272, 776, 339, 10762, 16883, 275, 334, 267, 13637, 63, 5280, 12, 18746, 51, 12, 272, 776, 275, 334, 267, 283, 2340, 63, 354, 297, 283, 4467, 297, 272, 776, 339, 485, 9059, 63, 17434, 275, 334, 267, 14142, 1075, 63, 2339, 12, 445, 7387, 8246, 63, 12961, 63, 998, 12, 7240, 63, 11163, 12, 7799, 63, 568, 20696, 272, 776, 275, 334, 267, 283, 4551, 63, 354, 297, 283, 15591, 63, 4731, 63, 344, 297, 283, 696, 63, 4736, 297, 283, 24824, 7, 272, 776, 339, 4382, 63, 3629, 275, 469, 267, 1868, 3876, 26, 4382, 14, 6700, 8, 288, 4382, 14, 6700, 14, 5443, 12, 288, 4018, 2998, 367, 642, 3464, 8038, 288, 1678, 63, 6541, 29, 549, 12, 288, 4177, 3126, 355, 14142, 1075, 63, 2339, 26, 4382, 14, 6700, 8, 490, 4382, 14, 6700, 14, 5353, 12, 490, 4018, 10708, 536, 315, 1314, 642, 3464, 911, 506, 2737, 8038, 490, 1415, 29, 797, 12, 355, 2318, 355, 445, 7387, 8246, 63, 12961, 63, 998, 26, 4382, 14, 6700, 8, 490, 4382, 14, 6700, 14, 5353, 12, 490, 4018, 33, 699, 10325, 530, 290, 7565, 2870, 14, 710, 699, 10325, 530, 290, 7565, 1077, 283, 1993, 283, 7747, 376, 14260, 16338, 626, 883, 506, 1202, 370, 283, 1993, 283, 2732, 282, 3982, 8002, 8038, 490, 1415, 29, 797, 12, 490, 1678, 63, 6541, 29, 549, 12, 490, 2291, 63, 1205, 29, 4058, 14, 11532, 3694, 8, 1023, 534, 713, 14, 16, 14, 16, 659, 355, 2318, 355, 7240, 63, 11163, 26, 4382, 14, 6700, 8, 490, 4382, 14, 6700, 14, 5353, 12, 490, 4018, 3263, 11002, 84, 367, 7799, 8038, 490, 1415, 29, 797, 12, 490, 1678, 63, 6541, 29, 549, 12, 490, 2291, 63, 1205, 29, 4058, 14, 11532, 3694, 8, 1023, 534, 713, 14, 16, 14, 16, 659, 355, 2318, 355, 7799, 63, 568, 20696, 26, 4382, 14, 6700, 8, 490, 4382, 14, 6700, 14, 25312, 12, 490, 3824, 3917, 663, 12, 2066, 314, 1654, 1159, 5897, 911, 440, 506, 298, 1993, 298, 12949, 7651, 490, 849, 29, 797, 12, 490, 1415, 29, 797, 12, 490, 1678, 63, 6541, 29, 549, 12, 490, 2291, 63, 1205, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pgroudas/pants
tests/python/pants_test/tasks/test_listtargets.py
1
5725
# coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, unicode_literals, with_statement) import os from textwrap import dedent from pants.backend.core.targets.dependencies import Dependencies from pants.backend.core.tasks.listtargets import ListTargets from pants.backend.jvm.artifact import Artifact from pants.backend.jvm.repository import Repository from pants.backend.jvm.targets.java_library import JavaLibrary from pants.base.build_file_aliases import BuildFileAliases from pants_test.tasks.task_test_base import ConsoleTaskTestBase class BaseListTargetsTest(ConsoleTaskTestBase): @classmethod def task_type(cls): return ListTargets class ListTargetsTestEmpty(BaseListTargetsTest): def test_list_all_empty(self): self.assertEqual('', self.execute_task()) self.assertEqual('', self.execute_task(options={ 'sep': '###' })) self.assertEqual([], self.execute_console_task()) class ListTargetsTest(BaseListTargetsTest): @property def alias_groups(self): return BuildFileAliases.create( targets={ 'target': Dependencies, 'java_library': JavaLibrary, }, objects={ 'pants': lambda x: x, 'artifact': Artifact, 'public': Repository(name='public', url='http://maven.example.com', push_db_basedir='/tmp'), } ) def setUp(self): super(ListTargetsTest, self).setUp() # Setup a BUILD tree for various list tests class Lib(object): def __init__(self, name, provides=False): self.name = name self.provides = dedent(""" artifact( org='com.example', name='{0}', repo=public ) """.format(name)).strip() if provides else 'None' def create_library(path, *libs): libs = libs or [Lib(os.path.basename(os.path.dirname(self.build_path(path))))] for lib in libs: target = "java_library(name='{name}', provides={provides}, sources=[])\n".format( name=lib.name, provides=lib.provides) self.add_to_build_file(path, target) create_library('a') create_library('a/b', Lib('b', provides=True)) create_library('a/b/c', Lib('c'), Lib('c2', provides=True), Lib('c3')) create_library('a/b/d') create_library('a/b/e', Lib('e1')) self.add_to_build_file('f', dedent(''' target( name='alias', dependencies=[ 'a/b/c:c3', 'a/b/d:d', ], description = """ Exercises alias resolution. Further description. """, ) ''')) # TODO: Remove this once with_description has been removed self.add_to_build_file('g', dedent(''' target( name='g', dependencies=[ 'a', ], ).with_description("""the description"""), ''')) def test_list_path(self): self.assert_console_output('a/b:b', targets=[self.target('a/b')]) def test_list_siblings(self): self.assert_console_output('a/b:b', targets=self.targets('a/b:')) self.assert_console_output('a/b/c:c', 'a/b/c:c2', 'a/b/c:c3', targets=self.targets('a/b/c/:')) def test_list_descendants(self): self.assert_console_output('a/b/c:c', 'a/b/c:c2', 'a/b/c:c3', targets=self.targets('a/b/c/::')) self.assert_console_output( 'a/b:b', 'a/b/c:c', 'a/b/c:c2', 'a/b/c:c3', 'a/b/d:d', 'a/b/e:e1', targets=self.targets('a/b::')) def test_list_all(self): self.assert_entries('\n', 'a:a', 'a/b:b', 'a/b/c:c', 'a/b/c:c2', 'a/b/c:c3', 'a/b/d:d', 'a/b/e:e1', 'f:alias', 'g:g') self.assert_entries(', ', 'a:a', 'a/b:b', 'a/b/c:c', 'a/b/c:c2', 'a/b/c:c3', 'a/b/d:d', 'a/b/e:e1', 'f:alias', 'g:g', options={ 'sep': ', ' }) self.assert_console_output( 'a:a', 'a/b:b', 'a/b/c:c', 'a/b/c:c2', 'a/b/c:c3', 'a/b/d:d', 'a/b/e:e1', 'f:alias', 'g:g') def test_list_provides(self): self.assert_console_output( 'a/b:b com.example#b', 'a/b/c:c2 com.example#c2', options={'provides': True }) def test_list_provides_customcols(self): self.assert_console_output( '/tmp a/b:b http://maven.example.com public com.example#b', '/tmp a/b/c:c2 http://maven.example.com public com.example#c2', options={ 'provides': True, 'provides_columns': 'push_db_basedir,address,repo_url,repo_name,artifact_id'} ) def test_list_dedups(self): targets = [] targets.extend(self.targets('a/b/d/::')) targets.extend(self.target('f:alias').dependencies) self.assertEquals(3, len(targets), "Expected a duplicate of a/b/d:d") self.assert_console_output( 'a/b/c:c3', 'a/b/d:d', targets=targets ) def test_list_documented(self): self.assert_console_output( # Confirm empty listing targets=[self.target('a/b')], options={'documented': True }, ) self.assert_console_output( dedent(""" f:alias Exercises alias resolution. Further description. """).strip(), dedent(""" g:g the description """).strip(), options={ 'documented': True } )
apache-2.0
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 1898, 6927, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 16952, 12, 6032, 63, 14129, 12, 870, 63, 1593, 12, 717, 2649, 63, 5955, 12, 543, 63, 6242, 9, 199, 199, 646, 747, 199, 504, 13390, 492, 22622, 199, 199, 504, 18081, 14, 4620, 14, 1018, 14, 4684, 14, 5714, 492, 1487, 3209, 199, 504, 18081, 14, 4620, 14, 1018, 14, 5054, 14, 513, 4684, 492, 3820, 14126, 199, 504, 18081, 14, 4620, 14, 15813, 14, 16154, 492, 1952, 10048, 199, 504, 18081, 14, 4620, 14, 15813, 14, 8421, 492, 24426, 199, 504, 18081, 14, 4620, 14, 15813, 14, 4684, 14, 6138, 63, 4342, 492, 9586, 7424, 199, 504, 18081, 14, 1095, 14, 1506, 63, 493, 63, 8602, 492, 6516, 1173, 6985, 3274, 199, 504, 18081, 63, 396, 14, 5054, 14, 1765, 63, 396, 63, 1095, 492, 19809, 4476, 14440, 421, 199, 533, 3523, 1296, 14126, 774, 8, 9270, 4476, 14440, 304, 523, 768, 3744, 523, 347, 2120, 63, 466, 8, 1886, 304, 272, 372, 3820, 14126, 421, 199, 533, 3820, 14126, 774, 4699, 8, 1563, 1296, 14126, 774, 304, 523, 347, 511, 63, 513, 63, 452, 63, 1667, 8, 277, 304, 272, 291, 14, 629, 8594, 291, 14, 2526, 63, 1765, 1012, 272, 291, 14, 629, 8594, 291, 14, 2526, 63, 1765, 8, 1419, 3126, 283, 4127, 356, 283, 5680, 7, 23451, 272, 291, 14, 629, 8798, 291, 14, 2526, 63, 6614, 63, 1765, 1012, 421, 199, 533, 3820, 14126, 774, 8, 1563, 1296, 14126, 774, 304, 523, 768, 1829, 523, 347, 5162, 63, 2634, 8, 277, 304, 272, 372, 6516, 1173, 6985, 3274, 14, 981, 8, 489, 4545, 3126, 267, 283, 1375, 356, 1487, 3209, 12, 267, 283, 6138, 63, 4342, 356, 9586, 7424, 12, 489, 1660, 489, 2251, 3126, 267, 283, 21970, 356, 2400, 671, 26, 671, 12, 267, 283, 16154, 356, 1952, 10048, 12, 267, 283, 3455, 356, 24426, 8, 354, 534, 3455, 297, 2490, 1166, 534, 1014, 921, 391, 1856, 14, 2694, 14, 957, 297, 2490, 6675, 63, 697, 63, 12484, 8805, 2791, 659, 489, 789, 272, 776, 819, 347, 3613, 8, 277, 304, 272, 1613, 8, 1296, 14126, 774, 12, 291, 680, 5996, 342, 339, 327, 12439, 282, 22974, 3123, 367, 7750, 769, 2295, 272, 1021, 8003, 8, 785, 304, 489, 347, 636, 826, 721, 277, 12, 536, 12, 6571, 29, 797, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 20121, 275, 22622, 4852, 288, 18115, 8, 1598, 5981, 534, 957, 14, 2694, 297, 1598, 536, 32134, 16, 7293, 1598, 3831, 29, 3455, 288, 776, 288, 30512, 908, 8, 354, 4992, 1913, 342, 340, 6571, 587, 283, 403, 7, 339, 347, 1218, 63, 4342, 8, 515, 12, 627, 8450, 304, 489, 20314, 275, 20314, 503, 359, 4728, 8, 736, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 3475, 8, 277, 14, 1506, 63, 515, 8, 515, 7845, 61, 489, 367, 1973, 315, 20314, 26, 267, 1347, 275, 298, 6138, 63, 4342, 8, 354, 32134, 354, 7293, 6571, 3126, 20121, 1386, 5274, 14285, 60, 78, 1674, 908, 8, 881, 536, 29, 773, 14, 354, 12, 6571, 29, 773, 14, 20121, 9, 267, 291, 14, 525, 63, 475, 63, 1506, 63, 493, 8, 515, 12, 1347, 9, 339, 1218, 63, 4342, 360, 65, 358, 272, 1218, 63, 4342, 360, 65, 15, 66, 297, 8003, 360, 66, 297, 6571, 29, 549, 430, 272, 1218, 63, 4342, 360, 65, 15, 66, 15, 67, 297, 8003, 360, 67, 659, 8003, 360, 67, 18, 297, 6571, 29, 549, 395, 8003, 360, 67, 19, 1333, 272, 1218, 63, 4342, 360, 65, 15, 66, 15, 68, 358, 272, 1218, 63, 4342, 360, 65, 15, 66, 15, 69, 297, 8003, 360, 69, 17, 1333, 272, 291, 14, 525, 63, 475, 63, 1506, 63, 493, 360, 70, 297, 22622, 10505, 267, 1347, 8, 881, 536, 534, 3620, 297, 881, 5124, 1524, 288, 283, 65, 15, 66, 15, 67, 26, 67, 19, 297, 288, 283, 65, 15, 66, 15, 68, 26, 68, 297, 881, 2156, 881, 1369, 275, 408, 267, 1316, 281, 559, 874, 5162, 12401, 14, 267, 28876, 1369, 14, 881, 10327, 267, 776, 267, 2125, 1333, 339, 327, 3254, 26, 5852, 642, 5403, 543, 63, 1802, 965, 2757, 4829, 272, 291, 14, 525, 63, 475, 63, 1506, 63, 493, 360, 71, 297, 22622, 10505, 267, 1347, 8, 881, 536, 534, 71, 297, 881, 5124, 1524, 288, 283, 65, 297, 881, 2156, 267, 7092, 1045, 63, 1802, 4852, 1589, 1369, 624, 395, 267, 2125, 1333, 8330, 347, 511, 63, 513, 63, 515, 8, 277, 304, 272, 291, 14, 479, 63, 6614, 63, 1199, 360, 65, 15, 66, 26, 66, 297, 4545, 1524, 277, 14, 1375, 360, 65, 15, 66, 2023, 819, 347, 511, 63, 513, 63, 338, 3345, 780, 8, 277, 304, 272, 291, 14, 479, 63, 6614, 63, 1199, 360, 65, 15, 66, 26, 66, 297, 4545, 29, 277, 14, 4684, 360, 65, 15, 66, 26, 1333, 272, 291, 14, 479, 63, 6614, 63, 1199, 360, 65, 15, 66, 15, 67, 26, 67, 297, 283, 65, 15, 66, 15, 67, 26, 67, 18, 297, 283, 65, 15, 66, 15, 67, 26, 67, 19, 297, 3044, 4545, 29, 277, 14, 4684, 360, 65, 15, 66, 15, 67, 22075, 1333, 819, 347, 511, 63, 513, 63, 29041, 8, 277, 304, 272, 291, 14, 479, 63, 6614, 63, 1199, 360, 65, 15, 66, 15, 67, 26, 67, 297, 283, 65, 15, 66, 15, 67, 26, 67, 18, 297, 283, 65, 15, 66, 15, 67, 26, 67, 19, 297, 3044, 4545, 29, 277, 14, 4684, 360, 65, 15, 66, 15, 67, 15, 447, 1333, 339, 291, 14, 479, 63, 6614, 63, 1199, 8, 267, 283, 65, 15, 66, 26, 66, 297, 267, 283, 65, 15, 66, 15, 67, 26, 67, 297, 267, 283, 65, 15, 66, 15, 67, 26, 67, 18, 297, 267, 283, 65, 15, 66, 15, 67, 26, 67, 19, 297, 267, 283, 65, 15, 66 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 1898, 6927, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 16952, 12, 6032, 63, 14129, 12, 870, 63, 1593, 12, 717, 2649, 63, 5955, 12, 543, 63, 6242, 9, 199, 199, 646, 747, 199, 504, 13390, 492, 22622, 199, 199, 504, 18081, 14, 4620, 14, 1018, 14, 4684, 14, 5714, 492, 1487, 3209, 199, 504, 18081, 14, 4620, 14, 1018, 14, 5054, 14, 513, 4684, 492, 3820, 14126, 199, 504, 18081, 14, 4620, 14, 15813, 14, 16154, 492, 1952, 10048, 199, 504, 18081, 14, 4620, 14, 15813, 14, 8421, 492, 24426, 199, 504, 18081, 14, 4620, 14, 15813, 14, 4684, 14, 6138, 63, 4342, 492, 9586, 7424, 199, 504, 18081, 14, 1095, 14, 1506, 63, 493, 63, 8602, 492, 6516, 1173, 6985, 3274, 199, 504, 18081, 63, 396, 14, 5054, 14, 1765, 63, 396, 63, 1095, 492, 19809, 4476, 14440, 421, 199, 533, 3523, 1296, 14126, 774, 8, 9270, 4476, 14440, 304, 523, 768, 3744, 523, 347, 2120, 63, 466, 8, 1886, 304, 272, 372, 3820, 14126, 421, 199, 533, 3820, 14126, 774, 4699, 8, 1563, 1296, 14126, 774, 304, 523, 347, 511, 63, 513, 63, 452, 63, 1667, 8, 277, 304, 272, 291, 14, 629, 8594, 291, 14, 2526, 63, 1765, 1012, 272, 291, 14, 629, 8594, 291, 14, 2526, 63, 1765, 8, 1419, 3126, 283, 4127, 356, 283, 5680, 7, 23451, 272, 291, 14, 629, 8798, 291, 14, 2526, 63, 6614, 63, 1765, 1012, 421, 199, 533, 3820, 14126, 774, 8, 1563, 1296, 14126, 774, 304, 523, 768, 1829, 523, 347, 5162, 63, 2634, 8, 277, 304, 272, 372, 6516, 1173, 6985, 3274, 14, 981, 8, 489, 4545, 3126, 267, 283, 1375, 356, 1487, 3209, 12, 267, 283, 6138, 63, 4342, 356, 9586, 7424, 12, 489, 1660, 489, 2251, 3126, 267, 283, 21970, 356, 2400, 671, 26, 671, 12, 267, 283, 16154, 356, 1952, 10048, 12, 267, 283, 3455, 356, 24426, 8, 354, 534, 3455, 297, 2490, 1166, 534, 1014, 921, 391, 1856, 14, 2694, 14, 957, 297, 2490, 6675, 63, 697, 63, 12484, 8805, 2791, 659, 489, 789, 272, 776, 819, 347, 3613, 8, 277, 304, 272, 1613, 8, 1296, 14126, 774, 12, 291, 680, 5996, 342, 339, 327, 12439, 282, 22974, 3123, 367, 7750, 769, 2295, 272, 1021, 8003, 8, 785, 304, 489, 347, 636, 826, 721, 277, 12, 536, 12, 6571, 29, 797, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 20121, 275, 22622, 4852, 288, 18115, 8, 1598, 5981, 534, 957, 14, 2694, 297, 1598, 536, 32134, 16, 7293, 1598, 3831, 29, 3455, 288, 776, 288, 30512, 908, 8, 354, 4992, 1913, 342, 340, 6571, 587, 283, 403, 7, 339, 347, 1218, 63, 4342, 8, 515, 12, 627, 8450, 304, 489, 20314, 275, 20314, 503, 359, 4728, 8, 736, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 3475, 8, 277, 14, 1506, 63, 515, 8, 515, 7845, 61, 489, 367, 1973, 315, 20314, 26, 267, 1347, 275, 298, 6138, 63, 4342, 8, 354, 32134, 354, 7293, 6571, 3126, 20121, 1386, 5274, 14285, 60, 78, 1674, 908, 8, 881, 536, 29, 773, 14, 354, 12, 6571, 29, 773, 14, 20121, 9, 267, 291, 14, 525, 63, 475, 63, 1506, 63, 493, 8, 515, 12, 1347, 9, 339, 1218, 63, 4342, 360, 65, 358, 272, 1218, 63, 4342, 360, 65, 15, 66, 297, 8003, 360, 66, 297, 6571, 29, 549, 430, 272, 1218, 63, 4342, 360, 65, 15, 66, 15, 67, 297, 8003, 360, 67, 659, 8003, 360, 67, 18, 297, 6571, 29, 549, 395, 8003, 360, 67, 19, 1333, 272, 1218, 63, 4342, 360, 65, 15, 66, 15, 68, 358, 272, 1218, 63, 4342, 360, 65, 15, 66, 15, 69, 297, 8003, 360, 69, 17, 1333, 272, 291, 14, 525, 63, 475, 63, 1506, 63, 493, 360, 70, 297, 22622, 10505, 267, 1347, 8, 881, 536, 534, 3620, 297, 881, 5124, 1524, 288, 283, 65, 15, 66, 15, 67, 26, 67, 19, 297, 288, 283, 65, 15, 66, 15, 68, 26, 68, 297, 881, 2156, 881, 1369, 275, 408, 267, 1316, 281, 559, 874, 5162, 12401, 14, 267, 28876, 1369, 14, 881, 10327, 267, 776, 267, 2125, 1333, 339, 327, 3254, 26, 5852, 642, 5403, 543, 63, 1802, 965, 2757, 4829, 272, 291, 14, 525, 63, 475, 63, 1506, 63, 493, 360, 71, 297, 22622, 10505, 267, 1347, 8, 881, 536, 534, 71, 297, 881, 5124, 1524, 288, 283, 65, 297, 881, 2156, 267, 7092, 1045, 63, 1802, 4852, 1589, 1369, 624, 395, 267, 2125, 1333, 8330, 347, 511, 63, 513, 63, 515, 8, 277, 304, 272, 291, 14, 479, 63, 6614, 63, 1199, 360, 65, 15, 66, 26, 66, 297, 4545, 1524, 277, 14, 1375, 360, 65, 15, 66, 2023, 819, 347, 511, 63, 513, 63, 338, 3345, 780, 8, 277, 304, 272, 291, 14, 479, 63, 6614, 63, 1199, 360, 65, 15, 66, 26, 66, 297, 4545, 29, 277, 14, 4684, 360, 65, 15, 66, 26, 1333, 272, 291, 14, 479, 63, 6614, 63, 1199, 360, 65, 15, 66, 15, 67, 26, 67, 297, 283, 65, 15, 66, 15, 67, 26, 67, 18, 297, 283, 65, 15, 66, 15, 67, 26, 67, 19, 297, 3044, 4545, 29, 277, 14, 4684, 360, 65, 15, 66, 15, 67, 22075, 1333, 819, 347, 511, 63, 513, 63, 29041, 8, 277, 304, 272, 291, 14, 479, 63, 6614, 63, 1199, 360, 65, 15, 66, 15, 67, 26, 67, 297, 283, 65, 15, 66, 15, 67, 26, 67, 18, 297, 283, 65, 15, 66, 15, 67, 26, 67, 19, 297, 3044, 4545, 29, 277, 14, 4684, 360, 65, 15, 66, 15, 67, 15, 447, 1333, 339, 291, 14, 479, 63, 6614, 63, 1199, 8, 267, 283, 65, 15, 66, 26, 66, 297, 267, 283, 65, 15, 66, 15, 67, 26, 67, 297, 267, 283, 65, 15, 66, 15, 67, 26, 67, 18, 297, 267, 283, 65, 15, 66, 15, 67, 26, 67, 19, 297, 267, 283, 65, 15, 66, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
louisLouL/pair_trading
capstone_env/lib/python3.6/site-packages/pandas/compat/__init__.py
6
11686
""" compat ====== Cross-compatible functions for Python 2 and 3. Key items to import for 2/3 compatible code: * iterators: range(), map(), zip(), filter(), reduce() * lists: lrange(), lmap(), lzip(), lfilter() * unicode: u() [u"" is a syntax error in Python 3.0-3.2] * longs: long (int in Python 3) * callable * iterable method compatibility: iteritems, iterkeys, itervalues * Uses the original method if available, otherwise uses items, keys, values. * types: * text_type: unicode in Python 2, str in Python 3 * binary_type: str in Python 2, bytes in Python 3 * string_types: basestring in Python 2, str in Python 3 * bind_method: binds functions to classes * add_metaclass(metaclass) - class decorator that recreates class with with the given metaclass instead (and avoids intermediary class creation) Other items: * OrderedDefaultDict * platform checker """ # pylint disable=W0611 # flake8: noqa import functools import itertools from distutils.version import LooseVersion from itertools import product import sys import types from unicodedata import east_asian_width import struct import inspect from collections import namedtuple PY2 = sys.version_info[0] == 2 PY3 = (sys.version_info[0] >= 3) PY35 = (sys.version_info >= (3, 5)) PY36 = (sys.version_info >= (3, 6)) try: import __builtin__ as builtins # not writeable when instantiated with string, doesn't handle unicode well from cStringIO import StringIO as cStringIO # always writeable from StringIO import StringIO BytesIO = StringIO import cPickle import httplib except ImportError: import builtins from io import StringIO, BytesIO cStringIO = StringIO import pickle as cPickle import http.client as httplib from pandas.compat.chainmap import DeepChainMap if PY3: def isidentifier(s): return s.isidentifier() def str_to_bytes(s, encoding=None): return s.encode(encoding or 'ascii') def bytes_to_str(b, encoding=None): return b.decode(encoding or 'utf-8') # The signature version below is directly copied from Django, # https://github.com/django/django/pull/4846 def signature(f): sig = inspect.signature(f) args = [ p.name for p in sig.parameters.values() if p.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD ] varargs = [ p.name for p in sig.parameters.values() if p.kind == inspect.Parameter.VAR_POSITIONAL ] varargs = varargs[0] if varargs else None keywords = [ p.name for p in sig.parameters.values() if p.kind == inspect.Parameter.VAR_KEYWORD ] keywords = keywords[0] if keywords else None defaults = [ p.default for p in sig.parameters.values() if p.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD and p.default is not p.empty ] or None argspec = namedtuple('Signature', ['args', 'defaults', 'varargs', 'keywords']) return argspec(args, defaults, varargs, keywords) # have to explicitly put builtins into the namespace range = range map = map zip = zip filter = filter intern = sys.intern reduce = functools.reduce long = int unichr = chr # This was introduced in Python 3.3, but we don't support # Python 3.x < 3.4, so checking PY3 is safe. FileNotFoundError = FileNotFoundError # list-producing versions of the major Python iterating functions def lrange(*args, **kwargs): return list(range(*args, **kwargs)) def lzip(*args, **kwargs): return list(zip(*args, **kwargs)) def lmap(*args, **kwargs): return list(map(*args, **kwargs)) def lfilter(*args, **kwargs): return list(filter(*args, **kwargs)) else: # Python 2 import re _name_re = re.compile(r"[a-zA-Z_][a-zA-Z0-9_]*$") FileNotFoundError = IOError def isidentifier(s, dotted=False): return bool(_name_re.match(s)) def str_to_bytes(s, encoding='ascii'): return s def bytes_to_str(b, encoding='ascii'): return b def signature(f): return inspect.getargspec(f) # import iterator versions of these functions range = xrange intern = intern zip = itertools.izip filter = itertools.ifilter map = itertools.imap reduce = reduce long = long unichr = unichr # Python 2-builtin ranges produce lists lrange = builtins.range lzip = builtins.zip lmap = builtins.map lfilter = builtins.filter if PY2: def iteritems(obj, **kw): return obj.iteritems(**kw) def iterkeys(obj, **kw): return obj.iterkeys(**kw) def itervalues(obj, **kw): return obj.itervalues(**kw) next = lambda it: it.next() else: def iteritems(obj, **kw): return iter(obj.items(**kw)) def iterkeys(obj, **kw): return iter(obj.keys(**kw)) def itervalues(obj, **kw): return iter(obj.values(**kw)) next = next def bind_method(cls, name, func): """Bind a method to class, python 2 and python 3 compatible. Parameters ---------- cls : type class to receive bound method name : basestring name of method on class instance func : function function to be bound as method Returns ------- None """ # only python 2 has bound/unbound method issue if not PY3: setattr(cls, name, types.MethodType(func, None, cls)) else: setattr(cls, name, func) # ---------------------------------------------------------------------------- # functions largely based / taken from the six module # Much of the code in this module comes from Benjamin Peterson's six library. # The license for this library can be found in LICENSES/SIX and the code can be # found at https://bitbucket.org/gutworth/six # Definition of East Asian Width # http://unicode.org/reports/tr11/ # Ambiguous width can be changed by option _EAW_MAP = {'Na': 1, 'N': 1, 'W': 2, 'F': 2, 'H': 1} if PY3: string_types = str, integer_types = int, class_types = type, text_type = str binary_type = bytes def u(s): return s def u_safe(s): return s def strlen(data, encoding=None): # encoding is for compat with PY2 return len(data) def east_asian_len(data, encoding=None, ambiguous_width=1): """ Calculate display width considering unicode East Asian Width """ if isinstance(data, text_type): return sum([_EAW_MAP.get(east_asian_width(c), ambiguous_width) for c in data]) else: return len(data) def import_lzma(): """ import lzma from the std library """ import lzma return lzma def set_function_name(f, name, cls): """ Bind the name/qualname attributes of the function """ f.__name__ = name f.__qualname__ = '{klass}.{name}'.format( klass=cls.__name__, name=name) f.__module__ = cls.__module__ return f ResourceWarning = ResourceWarning else: string_types = basestring, integer_types = (int, long) class_types = (type, types.ClassType) text_type = unicode binary_type = str def u(s): return unicode(s, "unicode_escape") def u_safe(s): try: return unicode(s, "unicode_escape") except: return s def strlen(data, encoding=None): try: data = data.decode(encoding) except UnicodeError: pass return len(data) def east_asian_len(data, encoding=None, ambiguous_width=1): """ Calculate display width considering unicode East Asian Width """ if isinstance(data, text_type): try: data = data.decode(encoding) except UnicodeError: pass return sum([_EAW_MAP.get(east_asian_width(c), ambiguous_width) for c in data]) else: return len(data) def import_lzma(): """ import the backported lzma library or raise ImportError if not available """ from backports import lzma return lzma def set_function_name(f, name, cls): """ Bind the name attributes of the function """ f.__name__ = name return f class ResourceWarning(Warning): pass string_and_binary_types = string_types + (binary_type,) try: # callable reintroduced in later versions of Python callable = callable except NameError: def callable(obj): return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) def add_metaclass(metaclass): """Class decorator for creating a class with a metaclass.""" def wrapper(cls): orig_vars = cls.__dict__.copy() orig_vars.pop('__dict__', None) orig_vars.pop('__weakref__', None) for slots_var in orig_vars.get('__slots__', ()): orig_vars.pop(slots_var) return metaclass(cls.__name__, cls.__bases__, orig_vars) return wrapper from collections import OrderedDict, Counter if PY3: def raise_with_traceback(exc, traceback=Ellipsis): if traceback == Ellipsis: _, _, traceback = sys.exc_info() raise exc.with_traceback(traceback) else: # this version of raise is a syntax error in Python 3 exec(""" def raise_with_traceback(exc, traceback=Ellipsis): if traceback == Ellipsis: _, _, traceback = sys.exc_info() raise exc, None, traceback """) raise_with_traceback.__doc__ = """Raise exception with existing traceback. If traceback is not passed, uses sys.exc_info() to get traceback.""" # http://stackoverflow.com/questions/4126348 # Thanks to @martineau at SO from dateutil import parser as _date_parser import dateutil if LooseVersion(dateutil.__version__) < '2.0': @functools.wraps(_date_parser.parse) def parse_date(timestr, *args, **kwargs): timestr = bytes(timestr) return _date_parser.parse(timestr, *args, **kwargs) elif PY2 and LooseVersion(dateutil.__version__) == '2.0': # dateutil brokenness raise Exception('dateutil 2.0 incompatible with Python 2.x, you must ' 'install version 1.5 or 2.1+!') else: parse_date = _date_parser.parse class OrderedDefaultdict(OrderedDict): def __init__(self, *args, **kwargs): newdefault = None newargs = () if args: newdefault = args[0] if not (newdefault is None or callable(newdefault)): raise TypeError('first argument must be callable or None') newargs = args[1:] self.default_factory = newdefault super(self.__class__, self).__init__(*newargs, **kwargs) def __missing__(self, key): if self.default_factory is None: raise KeyError(key) self[key] = value = self.default_factory() return value def __reduce__(self): # optional, for pickle support args = self.default_factory if self.default_factory else tuple() return type(self), args, None, None, list(self.items()) # https://github.com/pandas-dev/pandas/pull/9123 def is_platform_little_endian(): """ am I little endian """ return sys.byteorder == 'little' def is_platform_windows(): return sys.platform == 'win32' or sys.platform == 'cygwin' def is_platform_linux(): return sys.platform == 'linux2' def is_platform_mac(): return sys.platform == 'darwin' def is_platform_32bit(): return struct.calcsize("P") * 8 < 64
mit
[ 624, 199, 5819, 199, 23476, 199, 199, 14072, 13, 6490, 3423, 367, 2018, 499, 436, 650, 14, 199, 199, 1197, 2974, 370, 492, 367, 499, 15, 19, 9025, 1233, 26, 199, 10, 28241, 26, 1425, 1062, 2341, 1062, 3482, 1062, 2457, 1062, 7114, 342, 199, 10, 5548, 26, 634, 1842, 1062, 634, 1130, 1062, 634, 3065, 1062, 14642, 3518, 342, 199, 10, 2649, 26, 399, 342, 359, 85, 341, 365, 282, 6302, 1125, 315, 2018, 650, 14, 16, 13, 19, 14, 18, 61, 199, 10, 6132, 458, 26, 1846, 334, 442, 315, 2018, 650, 9, 199, 10, 4550, 199, 10, 6076, 1083, 7163, 26, 10849, 12, 25706, 12, 24451, 523, 627, 14911, 314, 3379, 1083, 340, 2808, 12, 4257, 4440, 2974, 12, 2883, 12, 1338, 14, 199, 10, 2943, 26, 272, 627, 1318, 63, 466, 26, 2649, 315, 2018, 499, 12, 620, 315, 2018, 650, 272, 627, 3366, 63, 466, 26, 620, 315, 2018, 499, 12, 2783, 315, 2018, 650, 272, 627, 1059, 63, 1313, 26, 7116, 315, 2018, 499, 12, 620, 315, 2018, 650, 199, 10, 5398, 63, 765, 26, 5398, 83, 3423, 370, 3992, 199, 10, 1050, 63, 6577, 8, 6577, 9, 446, 1021, 7531, 626, 23959, 83, 1021, 543, 543, 314, 523, 1627, 17074, 3140, 334, 460, 23674, 1640, 30747, 1021, 7143, 9, 199, 199, 8632, 2974, 26, 199, 10, 17649, 2698, 2141, 199, 10, 4298, 7739, 199, 624, 199, 3, 4287, 3507, 29, 55, 1690, 845, 199, 3, 27510, 24, 26, 8151, 199, 199, 646, 9143, 199, 646, 7975, 199, 504, 7065, 14, 1023, 492, 18462, 199, 504, 7975, 492, 3336, 199, 646, 984, 199, 646, 2943, 199, 504, 23128, 492, 30254, 63, 305, 5653, 63, 2063, 199, 646, 2702, 199, 646, 6485, 199, 504, 5055, 492, 12863, 199, 199, 4521, 18, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 199, 4521, 19, 275, 334, 1274, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 9, 199, 4521, 1276, 275, 334, 1274, 14, 1023, 63, 815, 2356, 334, 19, 12, 959, 430, 199, 4521, 1344, 275, 334, 1274, 14, 1023, 63, 815, 2356, 334, 19, 12, 1227, 430, 199, 199, 893, 26, 272, 492, 636, 5351, 363, 465, 12963, 272, 327, 440, 2218, 461, 1380, 17544, 543, 1059, 12, 3181, 1133, 2429, 2649, 5521, 272, 687, 15073, 492, 5228, 465, 15073, 272, 327, 3544, 2218, 461, 272, 687, 5228, 492, 5228, 272, 11808, 275, 5228, 272, 492, 17572, 272, 492, 8809, 199, 2590, 3545, 26, 272, 492, 12963, 272, 687, 5890, 492, 5228, 12, 11808, 272, 15073, 275, 5228, 272, 492, 5927, 465, 17572, 272, 492, 1455, 14, 1258, 465, 8809, 199, 199, 504, 10634, 14, 5819, 14, 4429, 1130, 492, 577, 7840, 10720, 2956, 421, 199, 692, 7843, 19, 26, 272, 347, 24353, 2841, 8, 83, 304, 267, 372, 308, 14, 29022, 2841, 342, 339, 347, 620, 63, 475, 63, 2394, 8, 83, 12, 2644, 29, 403, 304, 267, 372, 308, 14, 2143, 8, 2991, 503, 283, 4371, 358, 339, 347, 2783, 63, 475, 63, 495, 8, 66, 12, 2644, 29, 403, 304, 267, 372, 330, 14, 2708, 8, 2991, 503, 283, 1624, 13, 24, 358, 339, 327, 710, 4955, 1015, 5084, 365, 5370, 8876, 687, 5634, 12, 272, 327, 4178, 921, 5031, 14, 957, 15, 1176, 15, 1176, 15, 9302, 15, 20, 16134, 272, 347, 4955, 8, 70, 304, 267, 5259, 275, 6485, 14, 5233, 8, 70, 9, 267, 1249, 275, 359, 288, 299, 14, 354, 367, 299, 315, 5259, 14, 3214, 14, 1459, 342, 288, 340, 299, 14, 5091, 508, 6485, 14, 4720, 14, 31175, 63, 726, 63, 17714, 267, 1622, 267, 23377, 275, 359, 288, 299, 14, 354, 367, 299, 315, 5259, 14, 3214, 14, 1459, 342, 288, 340, 299, 14, 5091, 508, 6485, 14, 4720, 14, 5568, 63, 31175, 267, 1622, 267, 23377, 275, 23377, 59, 16, 61, 340, 23377, 587, 488, 267, 7681, 275, 359, 288, 299, 14, 354, 367, 299, 315, 5259, 14, 3214, 14, 1459, 342, 288, 340, 299, 14, 5091, 508, 6485, 14, 4720, 14, 5568, 63, 17714, 267, 1622, 267, 7681, 275, 7681, 59, 16, 61, 340, 7681, 587, 488, 267, 4243, 275, 359, 288, 299, 14, 885, 367, 299, 315, 5259, 14, 3214, 14, 1459, 342, 288, 340, 299, 14, 5091, 508, 6485, 14, 4720, 14, 31175, 63, 726, 63, 17714, 288, 436, 299, 14, 885, 365, 440, 299, 14, 1667, 267, 1622, 503, 488, 267, 26632, 275, 12863, 360, 10014, 297, 788, 589, 297, 283, 4322, 297, 5644, 283, 27367, 297, 283, 7511, 1105, 267, 372, 26632, 8, 589, 12, 4243, 12, 23377, 12, 7681, 9, 339, 327, 1172, 370, 7662, 5324, 12963, 1901, 314, 3231, 272, 1425, 275, 1425, 272, 2341, 275, 2341, 272, 3482, 275, 3482, 272, 2457, 275, 2457, 272, 10757, 275, 984, 14, 4404, 272, 7114, 275, 9143, 14, 5270, 272, 1846, 275, 1109, 272, 17742, 275, 8678, 339, 327, 961, 1990, 21399, 315, 2018, 650, 14, 19, 12, 1325, 781, 2793, 1133, 2291, 272, 327, 2018, 650, 14, 88, 665, 650, 14, 20, 12, 880, 7907, 7843, 19, 365, 5048, 14, 272, 3814, 10870, 275, 3814, 10870, 339, 327, 769, 13, 496, 14713, 5459, 402, 314, 12160, 2018, 25012, 3423, 272, 347, 634, 1842, 2031, 589, 12, 1011, 958, 304, 267, 372, 769, 8, 1842, 2031, 589, 12, 1011, 958, 430, 339, 347, 634, 3065, 2031, 589, 12, 1011, 958, 304, 267, 372, 769, 8, 3065, 2031, 589, 12, 1011, 958, 430, 339, 347, 634, 1130, 2031, 589, 12, 1011, 958, 304, 267, 372, 769, 8, 1130, 2031, 589, 12, 1011, 958, 430, 339, 347, 14642, 3518, 2031, 589, 12, 1011, 958, 304, 267, 372, 769, 8, 1541, 2031, 589, 12, 1011, 958, 430, 199, 199, 2836, 26, 272, 327, 2018, 499, 272, 492, 295, 272, 485, 354, 63, 264, 275, 295, 14, 2014, 8, 82, 22774, 65, 13, 6353, 13, 58, 17900, 65, 13, 6353, 13, 58, 16, 13, 25, 15555, 22550, 339, 3814, 10870, 275, 5925, 339, 347, 24353, 2841, 8, 83, 12, 18947, 29, 797, 304, 267, 372, 2155, 1547, 354, 63, 264, 14, 1431, 8, 83, 430, 339, 347, 620, 63, 475, 63, 2394, 8, 83 ]
[ 199, 5819, 199, 23476, 199, 199, 14072, 13, 6490, 3423, 367, 2018, 499, 436, 650, 14, 199, 199, 1197, 2974, 370, 492, 367, 499, 15, 19, 9025, 1233, 26, 199, 10, 28241, 26, 1425, 1062, 2341, 1062, 3482, 1062, 2457, 1062, 7114, 342, 199, 10, 5548, 26, 634, 1842, 1062, 634, 1130, 1062, 634, 3065, 1062, 14642, 3518, 342, 199, 10, 2649, 26, 399, 342, 359, 85, 341, 365, 282, 6302, 1125, 315, 2018, 650, 14, 16, 13, 19, 14, 18, 61, 199, 10, 6132, 458, 26, 1846, 334, 442, 315, 2018, 650, 9, 199, 10, 4550, 199, 10, 6076, 1083, 7163, 26, 10849, 12, 25706, 12, 24451, 523, 627, 14911, 314, 3379, 1083, 340, 2808, 12, 4257, 4440, 2974, 12, 2883, 12, 1338, 14, 199, 10, 2943, 26, 272, 627, 1318, 63, 466, 26, 2649, 315, 2018, 499, 12, 620, 315, 2018, 650, 272, 627, 3366, 63, 466, 26, 620, 315, 2018, 499, 12, 2783, 315, 2018, 650, 272, 627, 1059, 63, 1313, 26, 7116, 315, 2018, 499, 12, 620, 315, 2018, 650, 199, 10, 5398, 63, 765, 26, 5398, 83, 3423, 370, 3992, 199, 10, 1050, 63, 6577, 8, 6577, 9, 446, 1021, 7531, 626, 23959, 83, 1021, 543, 543, 314, 523, 1627, 17074, 3140, 334, 460, 23674, 1640, 30747, 1021, 7143, 9, 199, 199, 8632, 2974, 26, 199, 10, 17649, 2698, 2141, 199, 10, 4298, 7739, 199, 624, 199, 3, 4287, 3507, 29, 55, 1690, 845, 199, 3, 27510, 24, 26, 8151, 199, 199, 646, 9143, 199, 646, 7975, 199, 504, 7065, 14, 1023, 492, 18462, 199, 504, 7975, 492, 3336, 199, 646, 984, 199, 646, 2943, 199, 504, 23128, 492, 30254, 63, 305, 5653, 63, 2063, 199, 646, 2702, 199, 646, 6485, 199, 504, 5055, 492, 12863, 199, 199, 4521, 18, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 199, 4521, 19, 275, 334, 1274, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 9, 199, 4521, 1276, 275, 334, 1274, 14, 1023, 63, 815, 2356, 334, 19, 12, 959, 430, 199, 4521, 1344, 275, 334, 1274, 14, 1023, 63, 815, 2356, 334, 19, 12, 1227, 430, 199, 199, 893, 26, 272, 492, 636, 5351, 363, 465, 12963, 272, 327, 440, 2218, 461, 1380, 17544, 543, 1059, 12, 3181, 1133, 2429, 2649, 5521, 272, 687, 15073, 492, 5228, 465, 15073, 272, 327, 3544, 2218, 461, 272, 687, 5228, 492, 5228, 272, 11808, 275, 5228, 272, 492, 17572, 272, 492, 8809, 199, 2590, 3545, 26, 272, 492, 12963, 272, 687, 5890, 492, 5228, 12, 11808, 272, 15073, 275, 5228, 272, 492, 5927, 465, 17572, 272, 492, 1455, 14, 1258, 465, 8809, 199, 199, 504, 10634, 14, 5819, 14, 4429, 1130, 492, 577, 7840, 10720, 2956, 421, 199, 692, 7843, 19, 26, 272, 347, 24353, 2841, 8, 83, 304, 267, 372, 308, 14, 29022, 2841, 342, 339, 347, 620, 63, 475, 63, 2394, 8, 83, 12, 2644, 29, 403, 304, 267, 372, 308, 14, 2143, 8, 2991, 503, 283, 4371, 358, 339, 347, 2783, 63, 475, 63, 495, 8, 66, 12, 2644, 29, 403, 304, 267, 372, 330, 14, 2708, 8, 2991, 503, 283, 1624, 13, 24, 358, 339, 327, 710, 4955, 1015, 5084, 365, 5370, 8876, 687, 5634, 12, 272, 327, 4178, 921, 5031, 14, 957, 15, 1176, 15, 1176, 15, 9302, 15, 20, 16134, 272, 347, 4955, 8, 70, 304, 267, 5259, 275, 6485, 14, 5233, 8, 70, 9, 267, 1249, 275, 359, 288, 299, 14, 354, 367, 299, 315, 5259, 14, 3214, 14, 1459, 342, 288, 340, 299, 14, 5091, 508, 6485, 14, 4720, 14, 31175, 63, 726, 63, 17714, 267, 1622, 267, 23377, 275, 359, 288, 299, 14, 354, 367, 299, 315, 5259, 14, 3214, 14, 1459, 342, 288, 340, 299, 14, 5091, 508, 6485, 14, 4720, 14, 5568, 63, 31175, 267, 1622, 267, 23377, 275, 23377, 59, 16, 61, 340, 23377, 587, 488, 267, 7681, 275, 359, 288, 299, 14, 354, 367, 299, 315, 5259, 14, 3214, 14, 1459, 342, 288, 340, 299, 14, 5091, 508, 6485, 14, 4720, 14, 5568, 63, 17714, 267, 1622, 267, 7681, 275, 7681, 59, 16, 61, 340, 7681, 587, 488, 267, 4243, 275, 359, 288, 299, 14, 885, 367, 299, 315, 5259, 14, 3214, 14, 1459, 342, 288, 340, 299, 14, 5091, 508, 6485, 14, 4720, 14, 31175, 63, 726, 63, 17714, 288, 436, 299, 14, 885, 365, 440, 299, 14, 1667, 267, 1622, 503, 488, 267, 26632, 275, 12863, 360, 10014, 297, 788, 589, 297, 283, 4322, 297, 5644, 283, 27367, 297, 283, 7511, 1105, 267, 372, 26632, 8, 589, 12, 4243, 12, 23377, 12, 7681, 9, 339, 327, 1172, 370, 7662, 5324, 12963, 1901, 314, 3231, 272, 1425, 275, 1425, 272, 2341, 275, 2341, 272, 3482, 275, 3482, 272, 2457, 275, 2457, 272, 10757, 275, 984, 14, 4404, 272, 7114, 275, 9143, 14, 5270, 272, 1846, 275, 1109, 272, 17742, 275, 8678, 339, 327, 961, 1990, 21399, 315, 2018, 650, 14, 19, 12, 1325, 781, 2793, 1133, 2291, 272, 327, 2018, 650, 14, 88, 665, 650, 14, 20, 12, 880, 7907, 7843, 19, 365, 5048, 14, 272, 3814, 10870, 275, 3814, 10870, 339, 327, 769, 13, 496, 14713, 5459, 402, 314, 12160, 2018, 25012, 3423, 272, 347, 634, 1842, 2031, 589, 12, 1011, 958, 304, 267, 372, 769, 8, 1842, 2031, 589, 12, 1011, 958, 430, 339, 347, 634, 3065, 2031, 589, 12, 1011, 958, 304, 267, 372, 769, 8, 3065, 2031, 589, 12, 1011, 958, 430, 339, 347, 634, 1130, 2031, 589, 12, 1011, 958, 304, 267, 372, 769, 8, 1130, 2031, 589, 12, 1011, 958, 430, 339, 347, 14642, 3518, 2031, 589, 12, 1011, 958, 304, 267, 372, 769, 8, 1541, 2031, 589, 12, 1011, 958, 430, 199, 199, 2836, 26, 272, 327, 2018, 499, 272, 492, 295, 272, 485, 354, 63, 264, 275, 295, 14, 2014, 8, 82, 22774, 65, 13, 6353, 13, 58, 17900, 65, 13, 6353, 13, 58, 16, 13, 25, 15555, 22550, 339, 3814, 10870, 275, 5925, 339, 347, 24353, 2841, 8, 83, 12, 18947, 29, 797, 304, 267, 372, 2155, 1547, 354, 63, 264, 14, 1431, 8, 83, 430, 339, 347, 620, 63, 475, 63, 2394, 8, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
joongh/robotframework
atest/testresources/listeners/attributeverifyinglistener.py
4
2788
import os import sys if sys.version_info[0] > 2: long = int basestring = str ROBOT_LISTENER_API_VERSION = '2' OUTFILE = open(os.path.join(os.getenv('TEMPDIR'), 'listener_attrs.txt'), 'w') START = 'doc starttime ' END = START + 'endtime elapsedtime status ' SUITE = 'id longname metadata source tests suites totaltests ' TEST = 'id longname tags critical template ' KW = ' kwname libname args assign tags type ' EXPECTED_TYPES = {'elapsedtime': (int, long), 'tags': list, 'args': list, 'assign': list, 'metadata': dict, 'tests': list, 'suites': list, 'totaltests': int} def start_suite(name, attrs): _verify_attrs('START SUITE', attrs, START + SUITE) def end_suite(name, attrs): _verify_attrs('END SUITE', attrs, END + SUITE + 'statistics message') def start_test(name, attrs): _verify_attrs('START TEST', attrs, START + TEST) def end_test(name, attrs): _verify_attrs('END TEST', attrs, END + TEST + 'message') def start_keyword(name, attrs): _verify_attrs('START KEYWORD', attrs, START + KW) _verify_name(name, **attrs) def end_keyword(name, attrs): _verify_attrs('END KEYWORD', attrs, END + KW) _verify_name(name, **attrs) def _verify_attrs(method_name, attrs, names): names = names.split() OUTFILE.write(method_name + '\n') if len(names) != len(attrs): OUTFILE.write('FAILED: wrong number of attributes\n') OUTFILE.write('Expected: %s\nActual: %s\n' % (names, attrs.keys())) return for name in names: value = attrs[name] exp_type = EXPECTED_TYPES.get(name, basestring) if isinstance(value, exp_type): OUTFILE.write('PASSED | %s: %s\n' % (name, _format(value))) else: OUTFILE.write('FAILED | %s: %r, Expected: %s, Actual: %s\n' % (name, value, exp_type, type(value))) def _format(value): if isinstance(value, basestring): return value if isinstance(value, (int, long)): return str(value) if isinstance(value, list): return '[%s]' % ', '.join(_format(item) for item in value) if isinstance(value, dict): return '{%s}' % ', '.join('%s: %s' % (_format(k), _format(v)) for k, v in value.items()) raise ValueError(value) def _verify_name(name, kwname=None, libname=None, **ignored): if libname: if name != '%s.%s' % (libname, kwname): OUTFILE.write("FAILED | KW NAME: '%s' != '%s.%s'\n" % (name, libname, kwname)) else: if name != kwname: OUTFILE.write("FAILED | KW NAME: '%s' != '%s'\n" % (name, kwname)) if libname != '': OUTFILE.write("FAILED | LIB NAME: '%s' != ''\n" % libname) def close(): OUTFILE.close()
apache-2.0
[ 646, 747, 199, 646, 984, 421, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 690, 499, 26, 272, 1846, 275, 1109, 272, 7116, 275, 620, 421, 199, 1092, 11372, 63, 4924, 742, 540, 63, 3735, 63, 4612, 275, 283, 18, 7, 199, 199, 1877, 3817, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 12959, 360, 12510, 3022, 659, 283, 9799, 63, 3288, 14, 2424, 659, 283, 87, 358, 199, 7363, 275, 283, 1301, 1343, 521, 283, 199, 3902, 275, 13910, 435, 283, 500, 521, 14439, 521, 2004, 283, 199, 6195, 4427, 275, 283, 344, 1846, 354, 3341, 1350, 2295, 24203, 3141, 2219, 283, 199, 2864, 275, 283, 344, 1846, 354, 3762, 19698, 1978, 283, 199, 25114, 275, 283, 4775, 354, 1973, 354, 1249, 5090, 3762, 730, 283, 199, 22358, 63, 7893, 275, 791, 16691, 521, 356, 334, 442, 12, 1846, 395, 283, 2969, 356, 769, 12, 283, 589, 356, 769, 12, 2116, 283, 5038, 356, 769, 12, 283, 2343, 356, 1211, 12, 283, 2219, 356, 769, 12, 2116, 283, 27034, 356, 769, 12, 283, 2923, 2219, 356, 1109, 93, 421, 199, 318, 1343, 63, 5768, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 7363, 5698, 4427, 297, 3290, 12, 13910, 435, 5698, 4427, 9, 421, 199, 318, 1284, 63, 5768, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 3902, 5698, 4427, 297, 3290, 12, 7729, 435, 5698, 4427, 435, 283, 13724, 1245, 358, 421, 199, 318, 1343, 63, 396, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 7363, 7393, 297, 3290, 12, 13910, 435, 7393, 9, 421, 199, 318, 1284, 63, 396, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 3902, 7393, 297, 3290, 12, 7729, 435, 7393, 435, 283, 1188, 358, 421, 199, 318, 1343, 63, 6691, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 7363, 9301, 5172, 297, 3290, 12, 13910, 435, 1804, 55, 9, 272, 485, 4712, 63, 354, 8, 354, 12, 1011, 3288, 9, 421, 199, 318, 1284, 63, 6691, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 3902, 9301, 5172, 297, 3290, 12, 7729, 435, 1804, 55, 9, 272, 485, 4712, 63, 354, 8, 354, 12, 1011, 3288, 9, 421, 199, 318, 485, 4712, 63, 3288, 8, 765, 63, 354, 12, 3290, 12, 1561, 304, 272, 1561, 275, 1561, 14, 1294, 342, 272, 5738, 3817, 14, 952, 8, 765, 63, 354, 435, 1557, 78, 358, 272, 340, 822, 8, 1247, 9, 1137, 822, 8, 3288, 304, 267, 5738, 3817, 14, 952, 360, 12299, 26, 6835, 1329, 402, 3004, 60, 78, 358, 267, 5738, 3817, 14, 952, 360, 6964, 26, 450, 83, 60, 78, 30141, 26, 450, 83, 60, 78, 7, 450, 334, 1247, 12, 3290, 14, 1612, 4059, 267, 372, 272, 367, 536, 315, 1561, 26, 267, 574, 275, 3290, 59, 354, 61, 267, 1437, 63, 466, 275, 20464, 1149, 63, 7893, 14, 362, 8, 354, 12, 7116, 9, 267, 340, 1228, 8, 585, 12, 1437, 63, 466, 304, 288, 5738, 3817, 14, 952, 360, 48, 32032, 1204, 450, 83, 26, 450, 83, 60, 78, 7, 450, 334, 354, 12, 485, 908, 8, 585, 1724, 267, 587, 26, 288, 5738, 3817, 14, 952, 360, 12299, 1204, 450, 83, 26, 450, 82, 12, 13796, 26, 450, 83, 12, 18982, 1061, 26, 450, 83, 60, 78, 7, 2079, 450, 334, 354, 12, 574, 12, 1437, 63, 466, 12, 730, 8, 585, 1724, 199, 199, 318, 485, 908, 8, 585, 304, 272, 340, 1228, 8, 585, 12, 7116, 304, 267, 372, 574, 272, 340, 1228, 8, 585, 12, 334, 442, 12, 1846, 2298, 267, 372, 620, 8, 585, 9, 272, 340, 1228, 8, 585, 12, 769, 304, 267, 372, 30423, 83, 6616, 450, 1656, 1987, 904, 1547, 908, 8, 1053, 9, 367, 1242, 315, 574, 9, 272, 340, 1228, 8, 585, 12, 1211, 304, 267, 372, 12100, 83, 6834, 450, 1656, 1987, 904, 3508, 83, 26, 450, 83, 7, 450, 6110, 908, 8, 75, 395, 485, 908, 8, 86, 430, 3303, 367, 1022, 12, 373, 315, 574, 14, 1744, 1012, 272, 746, 1722, 8, 585, 9, 421, 199, 318, 485, 4712, 63, 354, 8, 354, 12, 4775, 354, 29, 403, 12, 1973, 354, 29, 403, 12, 1011, 11996, 304, 272, 340, 1973, 354, 26, 267, 340, 536, 1137, 1543, 83, 4111, 83, 7, 450, 334, 773, 354, 12, 4775, 354, 304, 288, 5738, 3817, 14, 952, 480, 12299, 1204, 1804, 55, 13637, 26, 1543, 83, 7, 1137, 1543, 83, 4111, 83, 1154, 78, 2, 450, 334, 354, 12, 1973, 354, 12, 4775, 354, 430, 272, 587, 26, 267, 340, 536, 1137, 4775, 354, 26, 288, 5738, 3817, 14, 952, 480, 12299, 1204, 1804, 55, 13637, 26, 1543, 83, 7, 1137, 1543, 83, 1154, 78, 2, 450, 334, 354, 12, 4775, 354, 430, 267, 340, 1973, 354, 1137, 8061, 288, 5738, 3817, 14, 952, 480, 12299, 1204, 25764, 13637, 26, 1543, 83, 7, 1137, 283, 1154, 78, 2, 450, 1973, 354, 9, 421, 199, 318, 4002, 837, 272, 5738, 3817, 14, 1600, 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 ]
[ 747, 199, 646, 984, 421, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 690, 499, 26, 272, 1846, 275, 1109, 272, 7116, 275, 620, 421, 199, 1092, 11372, 63, 4924, 742, 540, 63, 3735, 63, 4612, 275, 283, 18, 7, 199, 199, 1877, 3817, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 12959, 360, 12510, 3022, 659, 283, 9799, 63, 3288, 14, 2424, 659, 283, 87, 358, 199, 7363, 275, 283, 1301, 1343, 521, 283, 199, 3902, 275, 13910, 435, 283, 500, 521, 14439, 521, 2004, 283, 199, 6195, 4427, 275, 283, 344, 1846, 354, 3341, 1350, 2295, 24203, 3141, 2219, 283, 199, 2864, 275, 283, 344, 1846, 354, 3762, 19698, 1978, 283, 199, 25114, 275, 283, 4775, 354, 1973, 354, 1249, 5090, 3762, 730, 283, 199, 22358, 63, 7893, 275, 791, 16691, 521, 356, 334, 442, 12, 1846, 395, 283, 2969, 356, 769, 12, 283, 589, 356, 769, 12, 2116, 283, 5038, 356, 769, 12, 283, 2343, 356, 1211, 12, 283, 2219, 356, 769, 12, 2116, 283, 27034, 356, 769, 12, 283, 2923, 2219, 356, 1109, 93, 421, 199, 318, 1343, 63, 5768, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 7363, 5698, 4427, 297, 3290, 12, 13910, 435, 5698, 4427, 9, 421, 199, 318, 1284, 63, 5768, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 3902, 5698, 4427, 297, 3290, 12, 7729, 435, 5698, 4427, 435, 283, 13724, 1245, 358, 421, 199, 318, 1343, 63, 396, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 7363, 7393, 297, 3290, 12, 13910, 435, 7393, 9, 421, 199, 318, 1284, 63, 396, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 3902, 7393, 297, 3290, 12, 7729, 435, 7393, 435, 283, 1188, 358, 421, 199, 318, 1343, 63, 6691, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 7363, 9301, 5172, 297, 3290, 12, 13910, 435, 1804, 55, 9, 272, 485, 4712, 63, 354, 8, 354, 12, 1011, 3288, 9, 421, 199, 318, 1284, 63, 6691, 8, 354, 12, 3290, 304, 272, 485, 4712, 63, 3288, 360, 3902, 9301, 5172, 297, 3290, 12, 7729, 435, 1804, 55, 9, 272, 485, 4712, 63, 354, 8, 354, 12, 1011, 3288, 9, 421, 199, 318, 485, 4712, 63, 3288, 8, 765, 63, 354, 12, 3290, 12, 1561, 304, 272, 1561, 275, 1561, 14, 1294, 342, 272, 5738, 3817, 14, 952, 8, 765, 63, 354, 435, 1557, 78, 358, 272, 340, 822, 8, 1247, 9, 1137, 822, 8, 3288, 304, 267, 5738, 3817, 14, 952, 360, 12299, 26, 6835, 1329, 402, 3004, 60, 78, 358, 267, 5738, 3817, 14, 952, 360, 6964, 26, 450, 83, 60, 78, 30141, 26, 450, 83, 60, 78, 7, 450, 334, 1247, 12, 3290, 14, 1612, 4059, 267, 372, 272, 367, 536, 315, 1561, 26, 267, 574, 275, 3290, 59, 354, 61, 267, 1437, 63, 466, 275, 20464, 1149, 63, 7893, 14, 362, 8, 354, 12, 7116, 9, 267, 340, 1228, 8, 585, 12, 1437, 63, 466, 304, 288, 5738, 3817, 14, 952, 360, 48, 32032, 1204, 450, 83, 26, 450, 83, 60, 78, 7, 450, 334, 354, 12, 485, 908, 8, 585, 1724, 267, 587, 26, 288, 5738, 3817, 14, 952, 360, 12299, 1204, 450, 83, 26, 450, 82, 12, 13796, 26, 450, 83, 12, 18982, 1061, 26, 450, 83, 60, 78, 7, 2079, 450, 334, 354, 12, 574, 12, 1437, 63, 466, 12, 730, 8, 585, 1724, 199, 199, 318, 485, 908, 8, 585, 304, 272, 340, 1228, 8, 585, 12, 7116, 304, 267, 372, 574, 272, 340, 1228, 8, 585, 12, 334, 442, 12, 1846, 2298, 267, 372, 620, 8, 585, 9, 272, 340, 1228, 8, 585, 12, 769, 304, 267, 372, 30423, 83, 6616, 450, 1656, 1987, 904, 1547, 908, 8, 1053, 9, 367, 1242, 315, 574, 9, 272, 340, 1228, 8, 585, 12, 1211, 304, 267, 372, 12100, 83, 6834, 450, 1656, 1987, 904, 3508, 83, 26, 450, 83, 7, 450, 6110, 908, 8, 75, 395, 485, 908, 8, 86, 430, 3303, 367, 1022, 12, 373, 315, 574, 14, 1744, 1012, 272, 746, 1722, 8, 585, 9, 421, 199, 318, 485, 4712, 63, 354, 8, 354, 12, 4775, 354, 29, 403, 12, 1973, 354, 29, 403, 12, 1011, 11996, 304, 272, 340, 1973, 354, 26, 267, 340, 536, 1137, 1543, 83, 4111, 83, 7, 450, 334, 773, 354, 12, 4775, 354, 304, 288, 5738, 3817, 14, 952, 480, 12299, 1204, 1804, 55, 13637, 26, 1543, 83, 7, 1137, 1543, 83, 4111, 83, 1154, 78, 2, 450, 334, 354, 12, 1973, 354, 12, 4775, 354, 430, 272, 587, 26, 267, 340, 536, 1137, 4775, 354, 26, 288, 5738, 3817, 14, 952, 480, 12299, 1204, 1804, 55, 13637, 26, 1543, 83, 7, 1137, 1543, 83, 1154, 78, 2, 450, 334, 354, 12, 4775, 354, 430, 267, 340, 1973, 354, 1137, 8061, 288, 5738, 3817, 14, 952, 480, 12299, 1204, 25764, 13637, 26, 1543, 83, 7, 1137, 283, 1154, 78, 2, 450, 1973, 354, 9, 421, 199, 318, 4002, 837, 272, 5738, 3817, 14, 1600, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
encukou/freeipa
ipatests/test_integration/test_forced_client_reenrollment.py
2
11881
# Authors: # Ana Krivokapic <akrivoka@redhat.com> # # Copyright (C) 2013 Red Hat # see file 'COPYING' for use and warranty information # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from __future__ import absolute_import import logging import os import subprocess from ipaplatform.paths import paths import pytest from ipatests.test_integration.base import IntegrationTest from ipatests.pytest_ipa.integration import tasks logger = logging.getLogger(__name__) CLIENT_KEYTAB = paths.KRB5_KEYTAB class TestForcedClientReenrollment(IntegrationTest): """ Forced client re-enrollment http://www.freeipa.org/page/V3/Forced_client_re-enrollment#Test_Plan """ num_replicas = 1 num_clients = 1 @classmethod def install(cls, mh): super(TestForcedClientReenrollment, cls).install(mh) tasks.install_master(cls.master) cls.client_dom = cls.clients[0].hostname.split('.', 1)[1] if cls.client_dom != cls.master.domain.name: # In cases where client is managed by upstream DNS server we # overlap its zone so we can save DNS records (e.g. SSHFP) for # comparison. servers = [cls.master] + cls.replicas tasks.add_dns_zone(cls.master, cls.client_dom, skip_overlap_check=True, dynamic_update=True, add_a_record_hosts=servers ) tasks.install_replica(cls.master, cls.replicas[0], setup_ca=False) cls.BACKUP_KEYTAB = os.path.join( cls.master.config.test_dir, 'krb5.keytab' ) def test_reenroll_with_force_join(self, client): """ Client re-enrollment using admin credentials (--force-join) """ sshfp_record_pre = self.get_sshfp_record() self.restore_client() self.check_client_host_entry() self.reenroll_client(force_join=True) sshfp_record_post = self.get_sshfp_record() assert sshfp_record_pre == sshfp_record_post def test_reenroll_with_keytab(self, client): """ Client re-enrollment using keytab """ self.backup_keytab() sshfp_record_pre = self.get_sshfp_record() self.restore_client() self.check_client_host_entry() self.restore_keytab() self.reenroll_client(keytab=self.BACKUP_KEYTAB) sshfp_record_post = self.get_sshfp_record() assert sshfp_record_pre == sshfp_record_post def test_reenroll_with_both_force_join_and_keytab(self, client): """ Client re-enrollment using both --force-join and --keytab options """ self.backup_keytab() sshfp_record_pre = self.get_sshfp_record() self.restore_client() self.check_client_host_entry() self.restore_keytab() self.reenroll_client(force_join=True, keytab=self.BACKUP_KEYTAB) sshfp_record_post = self.get_sshfp_record() assert sshfp_record_pre == sshfp_record_post def test_reenroll_to_replica(self, client): """ Client re-enrollment using keytab, to a replica """ self.backup_keytab() sshfp_record_pre = self.get_sshfp_record() self.restore_client() self.check_client_host_entry() self.restore_keytab() self.reenroll_client(keytab=self.BACKUP_KEYTAB, to_replica=True) sshfp_record_post = self.get_sshfp_record() assert sshfp_record_pre == sshfp_record_post def test_try_to_reenroll_with_disabled_host(self, client): """ Client re-enrollment using keytab, with disabled host """ self.backup_keytab() self.disable_client_host_entry() self.restore_client() self.check_client_host_entry(enabled=False) self.restore_keytab() self.reenroll_client(keytab=self.BACKUP_KEYTAB, expect_fail=True) def test_try_to_reenroll_with_uninstalled_host(self, client): """ Client re-enrollment using keytab, with uninstalled host """ self.backup_keytab() self.uninstall_client() self.restore_client() self.check_client_host_entry(enabled=False) self.restore_keytab() self.reenroll_client(keytab=self.BACKUP_KEYTAB, expect_fail=True) def test_try_to_reenroll_with_deleted_host(self, client): """ Client re-enrollment using keytab, with deleted host """ self.backup_keytab() self.delete_client_host_entry() self.restore_client() self.check_client_host_entry(not_found=True) self.restore_keytab() self.reenroll_client(keytab=self.BACKUP_KEYTAB, expect_fail=True) def test_try_to_reenroll_with_incorrect_keytab(self, client): """ Client re-enrollment using keytab, with incorrect keytab file """ EMPTY_KEYTAB = os.path.join( self.clients[0].config.test_dir, 'empty.keytab' ) self.restore_client() self.check_client_host_entry() self.clients[0].run_command(['touch', EMPTY_KEYTAB]) self.reenroll_client(keytab=EMPTY_KEYTAB, expect_fail=True) def test_try_to_reenroll_with_empty_keytab(self, client): """ Client re-enrollment with invalid (empty) client keytab file """ self.restore_client() self.check_client_host_entry() try: os.remove(CLIENT_KEYTAB) except OSError: pass self.clients[0].run_command(['touch', CLIENT_KEYTAB]) self.reenroll_client(force_join=True) def uninstall_client(self, unshare=False): """Uninstall client Set unshare to unshare the network namespace. This means that the uninstall command will not have network access. """ args = [] if unshare: args = ['unshare', '--net'] args.extend(['ipa-client-install', '--uninstall', '-U']) self.clients[0].run_command( args, set_env=False, raiseonerr=False ) def restore_client(self): # As machine-level backup and restore is difficult to automate for # testing purposes, restoring the client from backup can be simulated # by performing the following step: # unshare -n ip ipa-client-install --uninstall -U # Or the following steps: # iptables -A INPUT -j REJECT -p all --source $MASTER_IP # ipa-client-install --uninstall -U # iptables -F # The steps described above will sever communication between server # and client, and then uninstall the client. As a consequence, the # client's host entry will remain on the server, ensuring that the # forced re-enrollment feature works. self.uninstall_client(unshare=True) def reenroll_client(self, keytab=None, to_replica=False, force_join=False, expect_fail=False): server = self.replicas[0] if to_replica else self.master client = self.clients[0] self.fix_resolv_conf(client, server) args = [ 'ipa-client-install', '-U', '--server', server.hostname, '--domain', server.domain.name ] if force_join: args.append('--force-join') if keytab: args.extend(['--keytab', keytab]) else: args.extend([ '-p', client.config.admin_name, '-w', client.config.admin_password ]) result = client.run_command( args, set_env=False, raiseonerr=not expect_fail ) assert 'IPA Server: %s' % server.hostname in result.stderr_text if expect_fail: err_msg = "Kerberos authentication failed: " assert result.returncode == 1 assert err_msg in result.stderr_text elif force_join and keytab: warn_msg = ("Option 'force-join' has no additional effect " "when used with together with option 'keytab'.") assert warn_msg in result.stderr_text def check_client_host_entry(self, enabled=True, not_found=False): result = self.master.run_command( ['ipa', 'host-show', self.clients[0].hostname], raiseonerr=not not_found ) if not_found: assert result.returncode == 2 assert 'host not found' in result.stderr_text elif enabled: assert 'Certificate:' not in result.stdout_text assert 'Keytab: True' in result.stdout_text else: assert 'Certificate:' not in result.stdout_text assert 'Keytab: False' in result.stdout_text def disable_client_host_entry(self): self.master.run_command( ['ipa', 'host-disable', self.clients[0].hostname] ) @classmethod def delete_client_host_entry(cls): try: cls.master.run_command( ['ipa', 'host-del', cls.clients[0].hostname] ) except subprocess.CalledProcessError as e: if e.returncode != 2: raise def get_sshfp_record(self): sshfp_record = '' client_host = self.clients[0].hostname.split('.')[0] result = self.master.run_command( ['ipa', 'dnsrecord-show', self.client_dom, client_host] ) lines = result.stdout_text.splitlines() for line in lines: if 'SSHFP record:' in line: sshfp_record = line.replace('SSHFP record:', '').strip() assert sshfp_record, 'SSHFP record not found' sshfp_record = set(sshfp_record.split(', ')) logger.debug("SSHFP record for host %s: %s", client_host, str(sshfp_record)) return sshfp_record def backup_keytab(self): contents = self.clients[0].get_file_contents(CLIENT_KEYTAB) self.master.put_file_contents(self.BACKUP_KEYTAB, contents) def restore_keytab(self): contents = self.master.get_file_contents(self.BACKUP_KEYTAB) self.clients[0].put_file_contents(self.BACKUP_KEYTAB, contents) @classmethod def fix_resolv_conf(cls, client, server): """ Put server's ip address at the top of resolv.conf """ contents = client.get_file_contents(paths.RESOLV_CONF, encoding='utf-8') nameserver = 'nameserver %s\n' % server.ip if not contents.startswith(nameserver): contents = nameserver + contents.replace(nameserver, '') client.put_file_contents(paths.RESOLV_CONF, contents) @pytest.fixture() def client(request): # Here we call "fix_resolv_conf" method before every ipa-client-install so # we get the client pointing to ipa master as DNS server. request.cls.fix_resolv_conf(request.cls.clients[0], request.cls.master) tasks.install_client(request.cls.master, request.cls.clients[0]) def teardown_client(): tasks.uninstall_client(request.cls.clients[0]) request.cls.delete_client_host_entry() request.addfinalizer(teardown_client)
gpl-3.0
[ 3, 6642, 26, 199, 3, 257, 1626, 65, 1804, 322, 86, 745, 20789, 665, 1151, 322, 86, 745, 65, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 1898, 334, 35, 9, 6171, 221, 9572, 13002, 199, 3, 1937, 570, 283, 16188, 1206, 7, 367, 675, 436, 3750, 2556, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 3873, 199, 504, 18210, 3246, 14, 3771, 492, 3792, 199, 646, 4613, 199, 199, 504, 3384, 323, 10329, 14, 396, 63, 15092, 14, 1095, 492, 27561, 774, 199, 504, 3384, 323, 10329, 14, 4462, 63, 20014, 14, 15092, 492, 6527, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 9901, 63, 3078, 10129, 275, 3792, 14, 43, 16567, 21, 63, 3078, 10129, 421, 199, 533, 1379, 30548, 3041, 497, 12214, 8, 20405, 774, 304, 272, 408, 272, 2104, 6867, 1890, 295, 13, 12214, 272, 1455, 921, 1544, 14, 4624, 20014, 14, 1308, 15, 1606, 15, 54, 19, 15, 30548, 63, 1258, 63, 264, 13, 12214, 3, 774, 63, 13375, 272, 408, 272, 1967, 63, 16755, 275, 413, 272, 1967, 63, 14555, 275, 413, 339, 768, 3744, 272, 347, 3907, 8, 1886, 12, 333, 72, 304, 267, 1613, 8, 774, 30548, 3041, 497, 12214, 12, 843, 680, 3174, 8, 17077, 9, 267, 6527, 14, 3174, 63, 4133, 8, 1886, 14, 4133, 9, 398, 843, 14, 1258, 63, 4556, 275, 843, 14, 14555, 59, 16, 1055, 4269, 14, 1294, 14078, 413, 2788, 17, 61, 267, 340, 843, 14, 1258, 63, 4556, 1137, 843, 14, 4133, 14, 2261, 14, 354, 26, 288, 327, 1010, 5560, 2382, 1890, 365, 12883, 701, 18932, 10237, 1654, 781, 288, 327, 15145, 2399, 5718, 880, 781, 883, 3354, 10237, 5767, 334, 69, 14, 71, 14, 12027, 17095, 9, 367, 288, 327, 9132, 14, 288, 8037, 275, 359, 1886, 14, 4133, 61, 435, 843, 14, 16755, 288, 6527, 14, 525, 63, 5797, 63, 2619, 8, 1886, 14, 4133, 12, 843, 14, 1258, 63, 4556, 12, 3044, 3372, 63, 16736, 63, 1074, 29, 549, 12, 3044, 8336, 63, 873, 29, 549, 12, 3044, 1050, 63, 65, 63, 3059, 63, 5146, 29, 5871, 3044, 776, 398, 6527, 14, 3174, 63, 12317, 8, 1886, 14, 4133, 12, 843, 14, 16755, 59, 16, 467, 3272, 63, 696, 29, 797, 9, 267, 843, 14, 31752, 63, 3078, 10129, 275, 747, 14, 515, 14, 904, 8, 288, 843, 14, 4133, 14, 888, 14, 396, 63, 694, 12, 288, 283, 75, 4848, 21, 14, 498, 2902, 7, 267, 776, 339, 347, 511, 63, 3441, 2827, 63, 1045, 63, 3990, 63, 904, 8, 277, 12, 1890, 304, 267, 408, 267, 6810, 295, 13, 12214, 1808, 4628, 6235, 334, 306, 3990, 13, 904, 9, 267, 408, 267, 8635, 3997, 63, 3059, 63, 657, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 291, 14, 8011, 63, 1258, 342, 267, 291, 14, 1074, 63, 1258, 63, 1102, 63, 2373, 342, 267, 291, 14, 3441, 2827, 63, 1258, 8, 3990, 63, 904, 29, 549, 9, 267, 8635, 3997, 63, 3059, 63, 1932, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 702, 8635, 3997, 63, 3059, 63, 657, 508, 8635, 3997, 63, 3059, 63, 1932, 339, 347, 511, 63, 3441, 2827, 63, 1045, 63, 498, 2902, 8, 277, 12, 1890, 304, 267, 408, 267, 6810, 295, 13, 12214, 1808, 790, 2902, 267, 408, 267, 291, 14, 5751, 63, 498, 2902, 342, 267, 8635, 3997, 63, 3059, 63, 657, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 291, 14, 8011, 63, 1258, 342, 267, 291, 14, 1074, 63, 1258, 63, 1102, 63, 2373, 342, 267, 291, 14, 8011, 63, 498, 2902, 342, 267, 291, 14, 3441, 2827, 63, 1258, 8, 498, 2902, 29, 277, 14, 31752, 63, 3078, 10129, 9, 267, 8635, 3997, 63, 3059, 63, 1932, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 702, 8635, 3997, 63, 3059, 63, 657, 508, 8635, 3997, 63, 3059, 63, 1932, 339, 347, 511, 63, 3441, 2827, 63, 1045, 63, 10727, 63, 3990, 63, 904, 63, 460, 63, 498, 2902, 8, 277, 12, 1890, 304, 267, 408, 267, 6810, 295, 13, 12214, 1808, 3865, 1553, 3990, 13, 904, 436, 1553, 498, 2902, 1511, 267, 408, 267, 291, 14, 5751, 63, 498, 2902, 342, 267, 8635, 3997, 63, 3059, 63, 657, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 291, 14, 8011, 63, 1258, 342, 267, 291, 14, 1074, 63, 1258, 63, 1102, 63, 2373, 342, 267, 291, 14, 8011, 63, 498, 2902, 342, 267, 291, 14, 3441, 2827, 63, 1258, 8, 3990, 63, 904, 29, 549, 12, 790, 2902, 29, 277, 14, 31752, 63, 3078, 10129, 9, 267, 8635, 3997, 63, 3059, 63, 1932, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 702, 8635, 3997, 63, 3059, 63, 657, 508, 8635, 3997, 63, 3059, 63, 1932, 339, 347, 511, 63, 3441, 2827, 63, 475, 63, 12317, 8, 277, 12, 1890, 304, 267, 408, 267, 6810, 295, 13, 12214, 1808, 790, 2902, 12, 370, 282, 16234, 267, 408, 267, 291, 14, 5751, 63, 498, 2902, 342, 267, 8635, 3997, 63, 3059, 63, 657, 275, 291, 14, 362, 63, 5510, 3997 ]
[ 6642, 26, 199, 3, 257, 1626, 65, 1804, 322, 86, 745, 20789, 665, 1151, 322, 86, 745, 65, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 1898, 334, 35, 9, 6171, 221, 9572, 13002, 199, 3, 1937, 570, 283, 16188, 1206, 7, 367, 675, 436, 3750, 2556, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 3873, 199, 504, 18210, 3246, 14, 3771, 492, 3792, 199, 646, 4613, 199, 199, 504, 3384, 323, 10329, 14, 396, 63, 15092, 14, 1095, 492, 27561, 774, 199, 504, 3384, 323, 10329, 14, 4462, 63, 20014, 14, 15092, 492, 6527, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 9901, 63, 3078, 10129, 275, 3792, 14, 43, 16567, 21, 63, 3078, 10129, 421, 199, 533, 1379, 30548, 3041, 497, 12214, 8, 20405, 774, 304, 272, 408, 272, 2104, 6867, 1890, 295, 13, 12214, 272, 1455, 921, 1544, 14, 4624, 20014, 14, 1308, 15, 1606, 15, 54, 19, 15, 30548, 63, 1258, 63, 264, 13, 12214, 3, 774, 63, 13375, 272, 408, 272, 1967, 63, 16755, 275, 413, 272, 1967, 63, 14555, 275, 413, 339, 768, 3744, 272, 347, 3907, 8, 1886, 12, 333, 72, 304, 267, 1613, 8, 774, 30548, 3041, 497, 12214, 12, 843, 680, 3174, 8, 17077, 9, 267, 6527, 14, 3174, 63, 4133, 8, 1886, 14, 4133, 9, 398, 843, 14, 1258, 63, 4556, 275, 843, 14, 14555, 59, 16, 1055, 4269, 14, 1294, 14078, 413, 2788, 17, 61, 267, 340, 843, 14, 1258, 63, 4556, 1137, 843, 14, 4133, 14, 2261, 14, 354, 26, 288, 327, 1010, 5560, 2382, 1890, 365, 12883, 701, 18932, 10237, 1654, 781, 288, 327, 15145, 2399, 5718, 880, 781, 883, 3354, 10237, 5767, 334, 69, 14, 71, 14, 12027, 17095, 9, 367, 288, 327, 9132, 14, 288, 8037, 275, 359, 1886, 14, 4133, 61, 435, 843, 14, 16755, 288, 6527, 14, 525, 63, 5797, 63, 2619, 8, 1886, 14, 4133, 12, 843, 14, 1258, 63, 4556, 12, 3044, 3372, 63, 16736, 63, 1074, 29, 549, 12, 3044, 8336, 63, 873, 29, 549, 12, 3044, 1050, 63, 65, 63, 3059, 63, 5146, 29, 5871, 3044, 776, 398, 6527, 14, 3174, 63, 12317, 8, 1886, 14, 4133, 12, 843, 14, 16755, 59, 16, 467, 3272, 63, 696, 29, 797, 9, 267, 843, 14, 31752, 63, 3078, 10129, 275, 747, 14, 515, 14, 904, 8, 288, 843, 14, 4133, 14, 888, 14, 396, 63, 694, 12, 288, 283, 75, 4848, 21, 14, 498, 2902, 7, 267, 776, 339, 347, 511, 63, 3441, 2827, 63, 1045, 63, 3990, 63, 904, 8, 277, 12, 1890, 304, 267, 408, 267, 6810, 295, 13, 12214, 1808, 4628, 6235, 334, 306, 3990, 13, 904, 9, 267, 408, 267, 8635, 3997, 63, 3059, 63, 657, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 291, 14, 8011, 63, 1258, 342, 267, 291, 14, 1074, 63, 1258, 63, 1102, 63, 2373, 342, 267, 291, 14, 3441, 2827, 63, 1258, 8, 3990, 63, 904, 29, 549, 9, 267, 8635, 3997, 63, 3059, 63, 1932, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 702, 8635, 3997, 63, 3059, 63, 657, 508, 8635, 3997, 63, 3059, 63, 1932, 339, 347, 511, 63, 3441, 2827, 63, 1045, 63, 498, 2902, 8, 277, 12, 1890, 304, 267, 408, 267, 6810, 295, 13, 12214, 1808, 790, 2902, 267, 408, 267, 291, 14, 5751, 63, 498, 2902, 342, 267, 8635, 3997, 63, 3059, 63, 657, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 291, 14, 8011, 63, 1258, 342, 267, 291, 14, 1074, 63, 1258, 63, 1102, 63, 2373, 342, 267, 291, 14, 8011, 63, 498, 2902, 342, 267, 291, 14, 3441, 2827, 63, 1258, 8, 498, 2902, 29, 277, 14, 31752, 63, 3078, 10129, 9, 267, 8635, 3997, 63, 3059, 63, 1932, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 702, 8635, 3997, 63, 3059, 63, 657, 508, 8635, 3997, 63, 3059, 63, 1932, 339, 347, 511, 63, 3441, 2827, 63, 1045, 63, 10727, 63, 3990, 63, 904, 63, 460, 63, 498, 2902, 8, 277, 12, 1890, 304, 267, 408, 267, 6810, 295, 13, 12214, 1808, 3865, 1553, 3990, 13, 904, 436, 1553, 498, 2902, 1511, 267, 408, 267, 291, 14, 5751, 63, 498, 2902, 342, 267, 8635, 3997, 63, 3059, 63, 657, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 291, 14, 8011, 63, 1258, 342, 267, 291, 14, 1074, 63, 1258, 63, 1102, 63, 2373, 342, 267, 291, 14, 8011, 63, 498, 2902, 342, 267, 291, 14, 3441, 2827, 63, 1258, 8, 3990, 63, 904, 29, 549, 12, 790, 2902, 29, 277, 14, 31752, 63, 3078, 10129, 9, 267, 8635, 3997, 63, 3059, 63, 1932, 275, 291, 14, 362, 63, 5510, 3997, 63, 3059, 342, 267, 702, 8635, 3997, 63, 3059, 63, 657, 508, 8635, 3997, 63, 3059, 63, 1932, 339, 347, 511, 63, 3441, 2827, 63, 475, 63, 12317, 8, 277, 12, 1890, 304, 267, 408, 267, 6810, 295, 13, 12214, 1808, 790, 2902, 12, 370, 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 ]
KontorConsulting/odoo
addons/hr_timesheet_invoice/wizard/__init__.py
433
1159
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import hr_timesheet_invoice_create import hr_timesheet_analytic_profit import hr_timesheet_final_invoice_create # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 16140, 63, 17739, 63, 5404, 63, 981, 199, 646, 16140, 63, 17739, 63, 9782, 63, 496, 3269, 199, 646, 16140, 63, 17739, 63, 5094, 63, 5404, 63, 981, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 16140, 63, 17739, 63, 5404, 63, 981, 199, 646, 16140, 63, 17739, 63, 9782, 63, 496, 3269, 199, 646, 16140, 63, 17739, 63, 5094, 63, 5404, 63, 981, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ownport/ansible-lookups
src/lookups/lookup/first_found.py
1
5368
from __future__ import (absolute_import, division, print_function) __metaclass__ = type # take a list of files and (optionally) a list of paths # return the first existing file found in the paths # [file1, file2, file3], [path1, path2, path3] # search order is: # path1/file1 # path1/file2 # path1/file3 # path2/file1 # path2/file2 # path2/file3 # path3/file1 # path3/file2 # path3/file3 # first file found with os.path.exists() is returned # no file matches raises ansibleerror # EXAMPLES # - name: copy first existing file found to /some/file # action: copy src=$item dest=/some/file # with_first_found: # - files: foo ${inventory_hostname} bar # paths: /tmp/production /tmp/staging # that will look for files in this order: # /tmp/production/foo # ${inventory_hostname} # bar # /tmp/staging/foo # ${inventory_hostname} # bar # - name: copy first existing file found to /some/file # action: copy src=$item dest=/some/file # with_first_found: # - files: /some/place/foo ${inventory_hostname} /some/place/else # that will look for files in this order: # /some/place/foo # $relative_path/${inventory_hostname} # /some/place/else # example - including tasks: # tasks: # - include: $item # with_first_found: # - files: generic # paths: tasks/staging tasks/production # this will include the tasks in the file generic where it is found first (staging or production) # example simple file lists #tasks: #- name: first found file # action: copy src=$item dest=/etc/file.cfg # with_first_found: # - files: foo.${inventory_hostname} foo # example skipping if no matched files # First_found also offers the ability to control whether or not failing # to find a file returns an error or not # #- name: first found file - or skip # action: copy src=$item dest=/etc/file.cfg # with_first_found: # - files: foo.${inventory_hostname} # skip: true # example a role with default configuration and configuration per host # you can set multiple terms with their own files and paths to look through. # consider a role that sets some configuration per host falling back on a default config. # #- name: some configuration template # template: src={{ item }} dest=/etc/file.cfg mode=0444 owner=root group=root # with_first_found: # - files: # - ${inventory_hostname}/etc/file.cfg # paths: # - ../../../templates.overwrites # - ../../../templates # - files: # - etc/file.cfg # paths: # - templates # the above will return an empty list if the files cannot be found at all # if skip is unspecificed or if it is set to false then it will return a list # error which can be caught bye ignore_errors: true for that action. # finally - if you want you can use it, in place to replace first_available_file: # you simply cannot use the - files, path or skip options. simply replace # first_available_file with with_first_found and leave the file listing in place # # # - name: with_first_found like first_available_file # action: copy src=$item dest=/tmp/faftest # with_first_found: # - ../files/foo # - ../files/bar # - ../files/baz # ignore_errors: true import os from lookups.lookup import LookupError from lookups.lookup import LookupBase from lookups.utils.boolean import boolean class LookupModule(LookupBase): def run(self, terms, variables={}, **kwargs): anydict = False skip = False for term in terms: if isinstance(term, dict): anydict = True total_search = [] if anydict: for term in terms: if isinstance(term, dict): files = term.get('files', []) paths = term.get('paths', []) skip = boolean(term.get('skip', False)) filelist = files if isinstance(files, basestring): files = files.replace(',', ' ') files = files.replace(';', ' ') filelist = files.split(' ') pathlist = paths if paths: if isinstance(paths, basestring): paths = paths.replace(',', ' ') paths = paths.replace(':', ' ') paths = paths.replace(';', ' ') pathlist = paths.split(' ') if not pathlist: total_search = filelist else: for path in pathlist: for fn in filelist: f = os.path.join(path, fn) total_search.append(f) else: total_search.append(term) else: total_search = self._flatten(terms) for fn in total_search: if os.path.isabs(fn) and os.path.exists(fn): return [fn] else: if skip: return [] else: err = "No file was found when using with_first_found. " + \ "Use the 'skip: true' option to allow this task to be skipped if no files are found" raise LookupError(err)
gpl-3.0
[ 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 3, 5452, 282, 769, 402, 1584, 436, 334, 1422, 1183, 9, 282, 769, 402, 3792, 199, 3, 372, 314, 1642, 3411, 570, 1911, 315, 314, 3792, 199, 3, 359, 493, 17, 12, 570, 18, 12, 570, 19, 467, 359, 515, 17, 12, 931, 18, 12, 931, 19, 61, 199, 3, 2754, 1865, 365, 26, 199, 3, 931, 17, 15, 493, 17, 199, 3, 931, 17, 15, 493, 18, 199, 3, 931, 17, 15, 493, 19, 199, 3, 931, 18, 15, 493, 17, 199, 3, 931, 18, 15, 493, 18, 199, 3, 931, 18, 15, 493, 19, 199, 3, 931, 19, 15, 493, 17, 199, 3, 931, 19, 15, 493, 18, 199, 3, 931, 19, 15, 493, 19, 199, 199, 3, 1642, 570, 1911, 543, 747, 14, 515, 14, 2444, 342, 365, 2138, 199, 3, 949, 570, 4450, 6534, 3242, 705, 199, 3, 3651, 8236, 199, 3, 221, 446, 536, 26, 1331, 1642, 3411, 570, 1911, 370, 1182, 3972, 15, 493, 199, 3, 259, 1595, 26, 1331, 2928, 28617, 1053, 2053, 13043, 3972, 15, 493, 199, 3, 259, 543, 63, 2246, 63, 4214, 26, 221, 199, 3, 258, 446, 1584, 26, 3925, 10839, 7212, 63, 4269, 93, 4681, 199, 3, 755, 3792, 26, 1182, 2791, 15, 10777, 1182, 2791, 15, 26840, 199, 199, 3, 626, 911, 3648, 367, 1584, 315, 642, 1865, 26, 199, 3, 1182, 2791, 15, 10777, 15, 1421, 199, 3, 463, 10839, 7212, 63, 4269, 93, 199, 3, 463, 4681, 199, 3, 1182, 2791, 15, 26840, 15, 1421, 199, 3, 4519, 10839, 7212, 63, 4269, 93, 199, 3, 4519, 4681, 673, 199, 3, 221, 446, 536, 26, 1331, 1642, 3411, 570, 1911, 370, 1182, 3972, 15, 493, 199, 3, 259, 1595, 26, 1331, 2928, 28617, 1053, 2053, 13043, 3972, 15, 493, 199, 3, 259, 543, 63, 2246, 63, 4214, 26, 221, 199, 3, 258, 446, 1584, 26, 1182, 3972, 15, 2778, 15, 1421, 10839, 7212, 63, 4269, 93, 1182, 3972, 15, 2778, 15, 2836, 199, 199, 3, 221, 626, 911, 3648, 367, 1584, 315, 642, 1865, 26, 199, 3, 221, 1182, 3972, 15, 2778, 15, 1421, 199, 3, 221, 2672, 6188, 63, 515, 15, 10545, 7212, 63, 4269, 93, 199, 3, 221, 1182, 3972, 15, 2778, 15, 2836, 199, 199, 3, 2893, 446, 5893, 6527, 26, 199, 3, 221, 6527, 26, 199, 3, 221, 446, 2387, 26, 2672, 1053, 199, 3, 259, 543, 63, 2246, 63, 4214, 26, 199, 3, 258, 446, 1584, 26, 7809, 199, 3, 755, 3792, 26, 6527, 15, 26840, 6527, 15, 10777, 199, 3, 642, 911, 2387, 314, 6527, 315, 314, 570, 7809, 2382, 652, 365, 1911, 1642, 334, 26840, 503, 9920, 9, 199, 199, 3, 2893, 3486, 570, 5548, 199, 3, 5054, 26, 199, 3, 13, 536, 26, 1642, 1911, 570, 199, 3, 221, 1595, 26, 1331, 2928, 28617, 1053, 2053, 13043, 6839, 15, 493, 14, 4128, 199, 3, 221, 543, 63, 2246, 63, 4214, 26, 199, 3, 221, 446, 1584, 26, 3925, 14, 10545, 7212, 63, 4269, 93, 3925, 421, 199, 3, 2893, 16068, 340, 949, 7838, 1584, 199, 3, 7758, 63, 4214, 2597, 32563, 314, 21255, 370, 3304, 3775, 503, 440, 18648, 199, 3, 370, 2342, 282, 570, 2529, 376, 1125, 503, 440, 199, 3, 199, 3, 13, 536, 26, 1642, 1911, 570, 446, 503, 3372, 199, 3, 221, 1595, 26, 1331, 2928, 28617, 1053, 2053, 13043, 6839, 15, 493, 14, 4128, 199, 3, 221, 543, 63, 2246, 63, 4214, 26, 199, 3, 221, 446, 1584, 26, 3925, 14, 10545, 7212, 63, 4269, 93, 199, 3, 259, 3372, 26, 2549, 199, 199, 3, 2893, 282, 4719, 543, 849, 2897, 436, 2897, 1126, 1591, 199, 3, 1265, 883, 663, 3663, 2895, 543, 3932, 5705, 1584, 436, 3792, 370, 3648, 4012, 14, 199, 3, 11201, 282, 4719, 626, 5951, 2005, 2897, 1126, 1591, 32039, 1771, 641, 282, 849, 1101, 14, 199, 3, 199, 3, 13, 536, 26, 2005, 2897, 1978, 199, 3, 221, 1978, 26, 2928, 3126, 91, 1242, 3586, 2053, 13043, 6839, 15, 493, 14, 4128, 818, 29, 966, 1602, 5771, 29, 1231, 1572, 29, 1231, 199, 3, 221, 543, 63, 2246, 63, 4214, 26, 199, 3, 257, 446, 1584, 26, 199, 3, 420, 446, 10839, 7212, 63, 4269, 5995, 6839, 15, 493, 14, 4128, 199, 3, 258, 3792, 26, 199, 3, 420, 446, 24272, 9707, 5876, 14, 1883, 16334, 199, 3, 420, 446, 24272, 9707, 5876, 199, 3, 257, 446, 1584, 26, 199, 3, 420, 446, 5423, 15, 493, 14, 4128, 199, 3, 258, 3792, 26, 199, 3, 420, 446, 7009, 199, 199, 3, 314, 3432, 911, 372, 376, 2701, 769, 340, 314, 1584, 3913, 506, 1911, 737, 1006, 199, 3, 340, 3372, 365, 625, 3017, 329, 6867, 503, 340, 652, 365, 663, 370, 3055, 2066, 652, 911, 372, 282, 769, 221, 199, 3, 1125, 1314, 883, 506, 15604, 701, 69, 3686, 63, 2550, 26, 2549, 367, 626, 1595, 14, 199, 199, 3, 3753, 446, 340, 1265, 2934, 1265, 883, 675, 652, 12, 315, 4192, 370, 3350, 1642, 63, 4561, 63, 493, 26, 199, 3, 1265, 9329, 3913, 675, 314, 446, 1584, 12, 931, 503, 3372, 1511, 14, 9329, 3350, 199, 3, 1642, 63, 4561, 63, 493, 543, 543, 63, 2246, 63, 4214, 436, 10137, 314, 570, 13778, 315, 4192, 199, 3, 199, 3, 199, 3, 221, 446, 536, 26, 543, 63, 2246, 63, 4214, 2839, 1642, 63, 4561, 63, 493, 199, 3, 259, 1595, 26, 1331, 2928, 28617, 1053, 2053, 13043, 2791, 15, 667, 30627, 199, 3, 259, 543, 63, 2246, 63, 4214, 26, 199, 3, 258, 446, 24272, 1725, 15, 1421, 199, 3, 258, 446, 24272, 1725, 15, 1700, 199, 3, 258, 446, 24272, 1725, 15, 6185, 199, 3, 259, 3686, 63, 2550, 26, 2549, 421, 199, 646, 747, 199, 199, 504, 16807, 14, 3892, 492, 19021, 199, 504, 16807, 14, 3892, 492, 12785, 1563, 199, 504, 16807, 14, 1208, 14, 4871, 492, 5046, 421, 199, 533, 12785, 2377, 8, 7521, 1563, 304, 339, 347, 1255, 8, 277, 12, 2895, 12, 2860, 10324, 1011, 958, 304, 398, 1263, 807 ]
[ 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 3, 5452, 282, 769, 402, 1584, 436, 334, 1422, 1183, 9, 282, 769, 402, 3792, 199, 3, 372, 314, 1642, 3411, 570, 1911, 315, 314, 3792, 199, 3, 359, 493, 17, 12, 570, 18, 12, 570, 19, 467, 359, 515, 17, 12, 931, 18, 12, 931, 19, 61, 199, 3, 2754, 1865, 365, 26, 199, 3, 931, 17, 15, 493, 17, 199, 3, 931, 17, 15, 493, 18, 199, 3, 931, 17, 15, 493, 19, 199, 3, 931, 18, 15, 493, 17, 199, 3, 931, 18, 15, 493, 18, 199, 3, 931, 18, 15, 493, 19, 199, 3, 931, 19, 15, 493, 17, 199, 3, 931, 19, 15, 493, 18, 199, 3, 931, 19, 15, 493, 19, 199, 199, 3, 1642, 570, 1911, 543, 747, 14, 515, 14, 2444, 342, 365, 2138, 199, 3, 949, 570, 4450, 6534, 3242, 705, 199, 3, 3651, 8236, 199, 3, 221, 446, 536, 26, 1331, 1642, 3411, 570, 1911, 370, 1182, 3972, 15, 493, 199, 3, 259, 1595, 26, 1331, 2928, 28617, 1053, 2053, 13043, 3972, 15, 493, 199, 3, 259, 543, 63, 2246, 63, 4214, 26, 221, 199, 3, 258, 446, 1584, 26, 3925, 10839, 7212, 63, 4269, 93, 4681, 199, 3, 755, 3792, 26, 1182, 2791, 15, 10777, 1182, 2791, 15, 26840, 199, 199, 3, 626, 911, 3648, 367, 1584, 315, 642, 1865, 26, 199, 3, 1182, 2791, 15, 10777, 15, 1421, 199, 3, 463, 10839, 7212, 63, 4269, 93, 199, 3, 463, 4681, 199, 3, 1182, 2791, 15, 26840, 15, 1421, 199, 3, 4519, 10839, 7212, 63, 4269, 93, 199, 3, 4519, 4681, 673, 199, 3, 221, 446, 536, 26, 1331, 1642, 3411, 570, 1911, 370, 1182, 3972, 15, 493, 199, 3, 259, 1595, 26, 1331, 2928, 28617, 1053, 2053, 13043, 3972, 15, 493, 199, 3, 259, 543, 63, 2246, 63, 4214, 26, 221, 199, 3, 258, 446, 1584, 26, 1182, 3972, 15, 2778, 15, 1421, 10839, 7212, 63, 4269, 93, 1182, 3972, 15, 2778, 15, 2836, 199, 199, 3, 221, 626, 911, 3648, 367, 1584, 315, 642, 1865, 26, 199, 3, 221, 1182, 3972, 15, 2778, 15, 1421, 199, 3, 221, 2672, 6188, 63, 515, 15, 10545, 7212, 63, 4269, 93, 199, 3, 221, 1182, 3972, 15, 2778, 15, 2836, 199, 199, 3, 2893, 446, 5893, 6527, 26, 199, 3, 221, 6527, 26, 199, 3, 221, 446, 2387, 26, 2672, 1053, 199, 3, 259, 543, 63, 2246, 63, 4214, 26, 199, 3, 258, 446, 1584, 26, 7809, 199, 3, 755, 3792, 26, 6527, 15, 26840, 6527, 15, 10777, 199, 3, 642, 911, 2387, 314, 6527, 315, 314, 570, 7809, 2382, 652, 365, 1911, 1642, 334, 26840, 503, 9920, 9, 199, 199, 3, 2893, 3486, 570, 5548, 199, 3, 5054, 26, 199, 3, 13, 536, 26, 1642, 1911, 570, 199, 3, 221, 1595, 26, 1331, 2928, 28617, 1053, 2053, 13043, 6839, 15, 493, 14, 4128, 199, 3, 221, 543, 63, 2246, 63, 4214, 26, 199, 3, 221, 446, 1584, 26, 3925, 14, 10545, 7212, 63, 4269, 93, 3925, 421, 199, 3, 2893, 16068, 340, 949, 7838, 1584, 199, 3, 7758, 63, 4214, 2597, 32563, 314, 21255, 370, 3304, 3775, 503, 440, 18648, 199, 3, 370, 2342, 282, 570, 2529, 376, 1125, 503, 440, 199, 3, 199, 3, 13, 536, 26, 1642, 1911, 570, 446, 503, 3372, 199, 3, 221, 1595, 26, 1331, 2928, 28617, 1053, 2053, 13043, 6839, 15, 493, 14, 4128, 199, 3, 221, 543, 63, 2246, 63, 4214, 26, 199, 3, 221, 446, 1584, 26, 3925, 14, 10545, 7212, 63, 4269, 93, 199, 3, 259, 3372, 26, 2549, 199, 199, 3, 2893, 282, 4719, 543, 849, 2897, 436, 2897, 1126, 1591, 199, 3, 1265, 883, 663, 3663, 2895, 543, 3932, 5705, 1584, 436, 3792, 370, 3648, 4012, 14, 199, 3, 11201, 282, 4719, 626, 5951, 2005, 2897, 1126, 1591, 32039, 1771, 641, 282, 849, 1101, 14, 199, 3, 199, 3, 13, 536, 26, 2005, 2897, 1978, 199, 3, 221, 1978, 26, 2928, 3126, 91, 1242, 3586, 2053, 13043, 6839, 15, 493, 14, 4128, 818, 29, 966, 1602, 5771, 29, 1231, 1572, 29, 1231, 199, 3, 221, 543, 63, 2246, 63, 4214, 26, 199, 3, 257, 446, 1584, 26, 199, 3, 420, 446, 10839, 7212, 63, 4269, 5995, 6839, 15, 493, 14, 4128, 199, 3, 258, 3792, 26, 199, 3, 420, 446, 24272, 9707, 5876, 14, 1883, 16334, 199, 3, 420, 446, 24272, 9707, 5876, 199, 3, 257, 446, 1584, 26, 199, 3, 420, 446, 5423, 15, 493, 14, 4128, 199, 3, 258, 3792, 26, 199, 3, 420, 446, 7009, 199, 199, 3, 314, 3432, 911, 372, 376, 2701, 769, 340, 314, 1584, 3913, 506, 1911, 737, 1006, 199, 3, 340, 3372, 365, 625, 3017, 329, 6867, 503, 340, 652, 365, 663, 370, 3055, 2066, 652, 911, 372, 282, 769, 221, 199, 3, 1125, 1314, 883, 506, 15604, 701, 69, 3686, 63, 2550, 26, 2549, 367, 626, 1595, 14, 199, 199, 3, 3753, 446, 340, 1265, 2934, 1265, 883, 675, 652, 12, 315, 4192, 370, 3350, 1642, 63, 4561, 63, 493, 26, 199, 3, 1265, 9329, 3913, 675, 314, 446, 1584, 12, 931, 503, 3372, 1511, 14, 9329, 3350, 199, 3, 1642, 63, 4561, 63, 493, 543, 543, 63, 2246, 63, 4214, 436, 10137, 314, 570, 13778, 315, 4192, 199, 3, 199, 3, 199, 3, 221, 446, 536, 26, 543, 63, 2246, 63, 4214, 2839, 1642, 63, 4561, 63, 493, 199, 3, 259, 1595, 26, 1331, 2928, 28617, 1053, 2053, 13043, 2791, 15, 667, 30627, 199, 3, 259, 543, 63, 2246, 63, 4214, 26, 199, 3, 258, 446, 24272, 1725, 15, 1421, 199, 3, 258, 446, 24272, 1725, 15, 1700, 199, 3, 258, 446, 24272, 1725, 15, 6185, 199, 3, 259, 3686, 63, 2550, 26, 2549, 421, 199, 646, 747, 199, 199, 504, 16807, 14, 3892, 492, 19021, 199, 504, 16807, 14, 3892, 492, 12785, 1563, 199, 504, 16807, 14, 1208, 14, 4871, 492, 5046, 421, 199, 533, 12785, 2377, 8, 7521, 1563, 304, 339, 347, 1255, 8, 277, 12, 2895, 12, 2860, 10324, 1011, 958, 304, 398, 1263, 807, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
FreeFighter77/venom-xbmc-addons-beta
plugin.video.vstream/resources/sites/trash/moviemaze_de.py
4
10148
from resources.lib.util import cUtil from resources.lib.handler.outputParameterHandler import cOutputParameterHandler from resources.lib.handler.inputParameterHandler import cInputParameterHandler from resources.lib.parser import cParser from resources.lib.handler.requestHandler import cRequestHandler from resources.lib.gui.guiElement import cGuiElement from resources.lib.gui.gui import cGui from resources.lib.gui.hoster import cHosterGui from resources.lib.handler.hosterHandler import cHosterHandler SITE_IDENTIFIER = 'moviemaze_de' SITE_NAME = 'MovieMaze.de' URL_MAIN = 'http://www.moviemaze.de' URL_ARCHIV = 'http://www.moviemaze.de/media/trailer/archiv.phtml' URL_UPDATES_ALL = 'http://www.moviemaze.de/media/trailer/' URL_UPDATES_HD = 'http://www.moviemaze.de/media/trailer/index.phtml?update=hd' URL_TRAILER = 'http://www.moviemaze.de/media/trailer/' URL_SEARCH = 'http://www.moviemaze.de/suche/result.phtml' def load(): cGui().showInfo('HS', SITE_NAME, 5) return False oGui = cGui() __createMainMenuItem(oGui, 'Letzte Updates (Alle)', URL_UPDATES_ALL, 'listVideos', 'Letzte Updates') __createMainMenuItem(oGui, 'Letzte Updates (HD)', URL_UPDATES_HD, 'listVideos', 'Letzte Updates') __createMainMenuItem(oGui, 'User Top 10', URL_UPDATES_ALL, 'listVideos', 'User Top 10') __createMainMenuItem(oGui, 'Archive', URL_ARCHIV, 'showCharacters') __createMainMenuItem(oGui, 'Suche', URL_SEARCH, 'showSearch') oGui.setEndOfDirectory() def __createMainMenuItem(oGui, sTitle, sUrl, sFunction = '', sHeader = ''): oGuiElement = cGuiElement() oGuiElement.setSiteName(SITE_IDENTIFIER) oGuiElement.setFunction(sFunction) oGuiElement.setTitle(sTitle) oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('sUrl', sUrl) oOutputParameterHandler.addParameter('sHeader', sHeader) oGui.addFolder(oGuiElement, oOutputParameterHandler) def showCharacters(): oGui = cGui() __createCharacters(oGui, 'A') __createCharacters(oGui, 'B') __createCharacters(oGui, 'C') __createCharacters(oGui, 'D') __createCharacters(oGui, 'E') __createCharacters(oGui, 'F') __createCharacters(oGui, 'G') __createCharacters(oGui, 'H') __createCharacters(oGui, 'I') __createCharacters(oGui, 'J') __createCharacters(oGui, 'K') __createCharacters(oGui, 'L') __createCharacters(oGui, 'N') __createCharacters(oGui, 'O') __createCharacters(oGui, 'Q') __createCharacters(oGui, 'R') __createCharacters(oGui, 'S') __createCharacters(oGui, 'T') __createCharacters(oGui, 'U') __createCharacters(oGui, 'V') __createCharacters(oGui, 'W') __createCharacters(oGui, 'XYZ') __createCharacters(oGui, '0-9') oGui.setEndOfDirectory() def __createCharacters(oGui, sCharacter): oGuiElement = cGuiElement() oGuiElement.setSiteName(SITE_IDENTIFIER) oGuiElement.setFunction('showArchive') oGuiElement.setTitle(sCharacter) oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('sUrl', URL_ARCHIV) oOutputParameterHandler.addParameter('sCharacter', sCharacter) oGui.addFolder(oGuiElement, oOutputParameterHandler) def showSearch(): oGui = cGui() sSearchText = oGui.showKeyBoard() if (sSearchText != False): __callSearch(sSearchText) oGui.setEndOfDirectory() def __callSearch(sSearchText): oGui = cGui() oRequest = cRequestHandler(URL_SEARCH) oRequest.setRequestType(cRequestHandler.REQUEST_TYPE_POST) oRequest.addParameters('searchword', sSearchText) oRequest.addParameters('x', 0) oRequest.addParameters('y', 0) sHtmlContent = oRequest.request() sPattern = '<tr.+?<a href="([^"]+)"><b style="font-size:9pt;font-weight:bold;">(.*?)<nobr>.+?<a href="([^"]+)">Trailer</a></td>' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): for aEntry in aResult[1]: oGuiElement = cGuiElement() oGuiElement.setSiteName(SITE_IDENTIFIER) oGuiElement.setFunction('showTrailerDetails') sTitle = str(aEntry[1]) sTitle = sTitle.replace('<br />', ' ') sTitle = cUtil().removeHtmlTags(sTitle) oGuiElement.setTitle(sTitle) sTrailerUrl = URL_MAIN + str(aEntry[2]) oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('sUrl', sTrailerUrl) oGui.addFolder(oGuiElement, oOutputParameterHandler) oGui.setEndOfDirectory() def showArchive(): oGui = cGui() oInputParameterHandler = cInputParameterHandler() if (oInputParameterHandler.exist('sUrl') and oInputParameterHandler.exist('sCharacter')): sUrl = oInputParameterHandler.getValue('sUrl') sCharacter = oInputParameterHandler.getValue('sCharacter') oRequest = cRequestHandler(sUrl) sHtmlContent = oRequest.request() sPattern = '<span class="h2">' + str(sCharacter) + '</span>.*?</tr> <tr>.*?<table(.*?)</table>' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): sHtmlContent = aResult[1][0] sPattern = '<a href="/media/trailer/([^"]+)">([^<]+)</a>' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): for aEntry in aResult[1]: oGuiElement = cGuiElement() oGuiElement.setSiteName(SITE_IDENTIFIER) oGuiElement.setFunction('showTrailerDetails') oGuiElement.setTitle(aEntry[1]) sTrailerUrl = URL_TRAILER + str(aEntry[0]) oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('sUrl', sTrailerUrl) oGui.addFolder(oGuiElement, oOutputParameterHandler) oGui.setEndOfDirectory() def listVideos(): oGui = cGui() oInputParameterHandler = cInputParameterHandler() if (oInputParameterHandler.exist('sUrl')): sUrl = oInputParameterHandler.getValue('sUrl') sHeader = oInputParameterHandler.getValue('sHeader') oRequest = cRequestHandler(sUrl) sHtmlContent = oRequest.request() sPattern = str(sHeader) + '</h2>.*?</table>' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): sHtmlContent = aResult[1][0] sPattern = '<td width=100% style="text-align:left;"><a href="/media/trailer/([^"]+)">([^<]+)</a> <span class="small_grey">([^<]+)</span></td>' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): for aEntry in aResult[1]: oGuiElement = cGuiElement() oGuiElement.setSiteName(SITE_IDENTIFIER) oGuiElement.setFunction('showTrailerDetails') sTitle = str(aEntry[1]) + ' ' + str(aEntry[2]) oGuiElement.setTitle(sTitle) sTrailerUrl = URL_TRAILER + str(aEntry[0]) oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('sUrl', sTrailerUrl) oGui.addFolder(oGuiElement, oOutputParameterHandler) oGui.setEndOfDirectory() def showTrailerDetails(): oGui = cGui() oInputParameterHandler = cInputParameterHandler() if (oInputParameterHandler.exist('sUrl')): sUrl = oInputParameterHandler.getValue('sUrl') oRequest = cRequestHandler(sUrl) sHtmlContent = oRequest.request() sPattern = 'src="([^"]+?)" width="150".*?</h3></a><span class="standard_justify">(.*?)</span><br /><br />' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): for aEntry in aResult[1]: sThumbnail = aEntry[0] sDescription = aEntry[1] sDescription = cUtil().removeHtmlTags(sDescription); oGuiElement = cGuiElement() oGuiElement.setSiteName(SITE_IDENTIFIER) oGuiElement.setFunction('dummyFunction') oGuiElement.setTitle('Info') oGuiElement.setThumbnail(URL_MAIN + sThumbnail) oGuiElement.setDescription(sDescription) oGui.addFolder(oGuiElement) sPattern = 'Sprache: de(.*?)</table>' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): sHtmlContentPartDE = aResult[1] __createTrailerMenuEntry(oGui, sHtmlContentPartDE, 'DE') sPattern = 'Sprache: en(.*?)</table>' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): sHtmlContentPartEN = aResult[1] __createTrailerMenuEntry(oGui, sHtmlContentPartEN, 'EN') oGui.setEndOfDirectory() def __createTrailerMenuEntry(oGui, sHtmlContent, sLanguage): sPattern = '<a href="([^"]+)" target="_blank" title="([^"]+)".*?>' oParser = cParser() aResult = oParser.parse(str(sHtmlContent), sPattern) if (aResult[0] == True): for aEntry in aResult[1]: oHoster = cHosterHandler().getHoster('moviemaze') sTitle = __createTitle(aEntry[1]) + ' (' + sLanguage + ')' oHoster.setDisplayName(sTitle) oHoster.setFileName(sTitle) sUrl = URL_MAIN + str(aEntry[0]) cHosterGui().showHoster(oGui, oHoster, sUrl) def __createTitle(sTitle): iPosition = sTitle.rfind('-') if (iPosition == -1): return sTitle return sTitle[0:iPosition] def dummyFunction(): oGui = cGui() oGui.setEndOfDirectory()
gpl-2.0
[ 504, 5944, 14, 773, 14, 1974, 492, 286, 9562, 199, 504, 5944, 14, 773, 14, 2232, 14, 1199, 4720, 2461, 492, 286, 2959, 4720, 2461, 199, 504, 5944, 14, 773, 14, 2232, 14, 1210, 4720, 2461, 492, 286, 3205, 4720, 2461, 199, 504, 5944, 14, 773, 14, 2087, 492, 286, 2842, 199, 504, 5944, 14, 773, 14, 2232, 14, 1069, 2461, 492, 286, 11149, 199, 504, 5944, 14, 773, 14, 5885, 14, 5885, 2162, 492, 286, 4324, 2162, 199, 504, 5944, 14, 773, 14, 5885, 14, 5885, 492, 286, 4324, 199, 504, 5944, 14, 773, 14, 5885, 14, 526, 11652, 492, 286, 40, 29895, 4324, 199, 504, 5944, 14, 773, 14, 2232, 14, 526, 11652, 2461, 492, 286, 40, 29895, 2461, 199, 199, 7917, 63, 22698, 275, 283, 10888, 391, 806, 63, 271, 7, 199, 7917, 63, 2339, 275, 283, 19088, 11903, 806, 14, 271, 7, 199, 199, 2632, 63, 5848, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 7, 199, 2632, 63, 7762, 6882, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 15, 4603, 15, 21606, 15, 1047, 1003, 14, 80, 1360, 7, 199, 2632, 63, 23612, 654, 63, 1761, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 15, 4603, 15, 21606, 4805, 199, 2632, 63, 23612, 654, 63, 14903, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 15, 4603, 15, 21606, 15, 1080, 14, 80, 1360, 31, 873, 29, 7952, 7, 199, 2632, 63, 1766, 6593, 540, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 15, 4603, 15, 21606, 4805, 199, 2632, 63, 15962, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 15, 9648, 595, 15, 1099, 14, 80, 1360, 7, 199, 199, 318, 2248, 837, 2286, 286, 4324, 1252, 2384, 2354, 360, 15467, 297, 428, 4427, 63, 2339, 12, 959, 9, 272, 372, 756, 2286, 312, 4324, 275, 286, 4324, 342, 272, 636, 981, 6756, 20973, 8, 79, 4324, 12, 283, 15314, 90, 266, 24663, 334, 2439, 274, 3196, 2851, 63, 23612, 654, 63, 1761, 12, 283, 513, 2201, 18808, 297, 283, 15314, 90, 266, 24663, 358, 272, 636, 981, 6756, 20973, 8, 79, 4324, 12, 283, 15314, 90, 266, 24663, 334, 14903, 3196, 2851, 63, 23612, 654, 63, 14903, 12, 283, 513, 2201, 18808, 297, 283, 15314, 90, 266, 24663, 358, 272, 636, 981, 6756, 20973, 8, 79, 4324, 12, 283, 1899, 14132, 1616, 297, 2851, 63, 23612, 654, 63, 1761, 12, 283, 513, 2201, 18808, 297, 283, 1899, 14132, 1616, 358, 272, 636, 981, 6756, 20973, 8, 79, 4324, 12, 283, 13042, 297, 2851, 63, 7762, 6882, 12, 283, 2384, 9272, 358, 272, 636, 981, 6756, 20973, 8, 79, 4324, 12, 283, 27032, 595, 297, 2851, 63, 15962, 12, 283, 2384, 5278, 358, 339, 312, 4324, 14, 409, 3005, 3466, 6231, 342, 199, 199, 318, 636, 981, 6756, 20973, 8, 79, 4324, 12, 308, 6888, 12, 308, 6417, 12, 308, 3481, 275, 3260, 308, 2567, 275, 21019, 272, 312, 4324, 2162, 275, 286, 4324, 2162, 342, 272, 312, 4324, 2162, 14, 409, 8972, 985, 8, 7917, 63, 22698, 9, 272, 312, 4324, 2162, 14, 409, 3481, 8, 83, 3481, 9, 272, 312, 4324, 2162, 14, 31675, 8, 83, 6888, 9, 272, 312, 2959, 4720, 2461, 275, 286, 2959, 4720, 2461, 342, 272, 312, 2959, 4720, 2461, 14, 26895, 360, 83, 6417, 297, 308, 6417, 9, 272, 312, 2959, 4720, 2461, 14, 26895, 360, 83, 2567, 297, 308, 2567, 9, 259, 272, 312, 4324, 14, 525, 7850, 8, 79, 4324, 2162, 12, 312, 2959, 4720, 2461, 9, 199, 199, 318, 2498, 9272, 837, 272, 312, 4324, 275, 286, 4324, 342, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 33, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 34, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 35, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 36, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 37, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 38, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 39, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 40, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 41, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 42, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 43, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 44, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 46, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 47, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 49, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 50, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 51, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 52, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 53, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 54, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 55, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 16694, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 16, 13, 25, 358, 272, 312, 4324, 14, 409, 3005, 3466, 6231, 342, 199, 199, 318, 636, 981, 9272, 8, 79, 4324, 12, 308, 14852, 304, 272, 312, 4324, 2162, 275, 286, 4324, 2162, 342, 272, 312, 4324, 2162, 14, 409, 8972, 985, 8, 7917, 63, 22698, 9, 272, 312, 4324, 2162, 14, 409, 3481, 360, 2384, 13042, 358, 272, 312, 4324, 2162, 14, 31675, 8, 83, 14852, 9, 339, 312, 2959, 4720, 2461, 275, 286, 2959, 4720, 2461, 342, 272, 312, 2959, 4720, 2461, 14, 26895, 360, 83, 6417, 297, 2851, 63, 7762, 6882, 9, 272, 312, 2959, 4720, 2461, 14, 26895, 360, 83, 14852, 297, 308, 14852, 9, 272, 312, 4324, 14, 525, 7850, 8, 79, 4324, 2162, 12, 312, 2959, 4720, 2461, 9, 199, 199, 318, 2498, 5278, 837, 272, 312, 4324, 275, 286, 4324, 342, 339, 308, 5278, 1872, 275, 312, 4324, 14, 2384, 1197, 18995, 342, 272, 340, 334, 83, 5278, 1872, 1137, 756, 304, 267 ]
[ 5944, 14, 773, 14, 1974, 492, 286, 9562, 199, 504, 5944, 14, 773, 14, 2232, 14, 1199, 4720, 2461, 492, 286, 2959, 4720, 2461, 199, 504, 5944, 14, 773, 14, 2232, 14, 1210, 4720, 2461, 492, 286, 3205, 4720, 2461, 199, 504, 5944, 14, 773, 14, 2087, 492, 286, 2842, 199, 504, 5944, 14, 773, 14, 2232, 14, 1069, 2461, 492, 286, 11149, 199, 504, 5944, 14, 773, 14, 5885, 14, 5885, 2162, 492, 286, 4324, 2162, 199, 504, 5944, 14, 773, 14, 5885, 14, 5885, 492, 286, 4324, 199, 504, 5944, 14, 773, 14, 5885, 14, 526, 11652, 492, 286, 40, 29895, 4324, 199, 504, 5944, 14, 773, 14, 2232, 14, 526, 11652, 2461, 492, 286, 40, 29895, 2461, 199, 199, 7917, 63, 22698, 275, 283, 10888, 391, 806, 63, 271, 7, 199, 7917, 63, 2339, 275, 283, 19088, 11903, 806, 14, 271, 7, 199, 199, 2632, 63, 5848, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 7, 199, 2632, 63, 7762, 6882, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 15, 4603, 15, 21606, 15, 1047, 1003, 14, 80, 1360, 7, 199, 2632, 63, 23612, 654, 63, 1761, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 15, 4603, 15, 21606, 4805, 199, 2632, 63, 23612, 654, 63, 14903, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 15, 4603, 15, 21606, 15, 1080, 14, 80, 1360, 31, 873, 29, 7952, 7, 199, 2632, 63, 1766, 6593, 540, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 15, 4603, 15, 21606, 4805, 199, 2632, 63, 15962, 275, 283, 1014, 921, 1544, 14, 10888, 391, 806, 14, 271, 15, 9648, 595, 15, 1099, 14, 80, 1360, 7, 199, 199, 318, 2248, 837, 2286, 286, 4324, 1252, 2384, 2354, 360, 15467, 297, 428, 4427, 63, 2339, 12, 959, 9, 272, 372, 756, 2286, 312, 4324, 275, 286, 4324, 342, 272, 636, 981, 6756, 20973, 8, 79, 4324, 12, 283, 15314, 90, 266, 24663, 334, 2439, 274, 3196, 2851, 63, 23612, 654, 63, 1761, 12, 283, 513, 2201, 18808, 297, 283, 15314, 90, 266, 24663, 358, 272, 636, 981, 6756, 20973, 8, 79, 4324, 12, 283, 15314, 90, 266, 24663, 334, 14903, 3196, 2851, 63, 23612, 654, 63, 14903, 12, 283, 513, 2201, 18808, 297, 283, 15314, 90, 266, 24663, 358, 272, 636, 981, 6756, 20973, 8, 79, 4324, 12, 283, 1899, 14132, 1616, 297, 2851, 63, 23612, 654, 63, 1761, 12, 283, 513, 2201, 18808, 297, 283, 1899, 14132, 1616, 358, 272, 636, 981, 6756, 20973, 8, 79, 4324, 12, 283, 13042, 297, 2851, 63, 7762, 6882, 12, 283, 2384, 9272, 358, 272, 636, 981, 6756, 20973, 8, 79, 4324, 12, 283, 27032, 595, 297, 2851, 63, 15962, 12, 283, 2384, 5278, 358, 339, 312, 4324, 14, 409, 3005, 3466, 6231, 342, 199, 199, 318, 636, 981, 6756, 20973, 8, 79, 4324, 12, 308, 6888, 12, 308, 6417, 12, 308, 3481, 275, 3260, 308, 2567, 275, 21019, 272, 312, 4324, 2162, 275, 286, 4324, 2162, 342, 272, 312, 4324, 2162, 14, 409, 8972, 985, 8, 7917, 63, 22698, 9, 272, 312, 4324, 2162, 14, 409, 3481, 8, 83, 3481, 9, 272, 312, 4324, 2162, 14, 31675, 8, 83, 6888, 9, 272, 312, 2959, 4720, 2461, 275, 286, 2959, 4720, 2461, 342, 272, 312, 2959, 4720, 2461, 14, 26895, 360, 83, 6417, 297, 308, 6417, 9, 272, 312, 2959, 4720, 2461, 14, 26895, 360, 83, 2567, 297, 308, 2567, 9, 259, 272, 312, 4324, 14, 525, 7850, 8, 79, 4324, 2162, 12, 312, 2959, 4720, 2461, 9, 199, 199, 318, 2498, 9272, 837, 272, 312, 4324, 275, 286, 4324, 342, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 33, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 34, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 35, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 36, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 37, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 38, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 39, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 40, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 41, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 42, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 43, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 44, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 46, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 47, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 49, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 50, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 51, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 52, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 53, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 54, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 55, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 16694, 358, 272, 636, 981, 9272, 8, 79, 4324, 12, 283, 16, 13, 25, 358, 272, 312, 4324, 14, 409, 3005, 3466, 6231, 342, 199, 199, 318, 636, 981, 9272, 8, 79, 4324, 12, 308, 14852, 304, 272, 312, 4324, 2162, 275, 286, 4324, 2162, 342, 272, 312, 4324, 2162, 14, 409, 8972, 985, 8, 7917, 63, 22698, 9, 272, 312, 4324, 2162, 14, 409, 3481, 360, 2384, 13042, 358, 272, 312, 4324, 2162, 14, 31675, 8, 83, 14852, 9, 339, 312, 2959, 4720, 2461, 275, 286, 2959, 4720, 2461, 342, 272, 312, 2959, 4720, 2461, 14, 26895, 360, 83, 6417, 297, 2851, 63, 7762, 6882, 9, 272, 312, 2959, 4720, 2461, 14, 26895, 360, 83, 14852, 297, 308, 14852, 9, 272, 312, 4324, 14, 525, 7850, 8, 79, 4324, 2162, 12, 312, 2959, 4720, 2461, 9, 199, 199, 318, 2498, 5278, 837, 272, 312, 4324, 275, 286, 4324, 342, 339, 308, 5278, 1872, 275, 312, 4324, 14, 2384, 1197, 18995, 342, 272, 340, 334, 83, 5278, 1872, 1137, 756, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
geimer/easybuild-framework
easybuild/tools/build_log.py
1
5969
# # # Copyright 2009-2014 Ghent University # # This file is part of EasyBuild, # originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), # with support of Ghent University (http://ugent.be/hpc), # the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en), # the Hercules foundation (http://www.herculesstichting.be/in_English) # and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). # # http://github.com/hpcugent/easybuild # # EasyBuild is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation v2. # # EasyBuild is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. # # """ EasyBuild logger and log utilities, including our own EasybuildError class. @author: Stijn De Weirdt (Ghent University) @author: Dries Verdegem (Ghent University) @author: Kenneth Hoste (Ghent University) @author: Pieter De Baets (Ghent University) @author: Jens Timmerman (Ghent University) """ import os import sys from copy import copy from vsc.utils import fancylogger from easybuild.tools.version import VERSION # EasyBuild message prefix EB_MSG_PREFIX = "==" # the version seen by log.deprecated CURRENT_VERSION = VERSION # allow some experimental experimental code EXPERIMENTAL = False class EasyBuildError(Exception): """ EasyBuildError is thrown when EasyBuild runs into something horribly wrong. """ def __init__(self, msg): Exception.__init__(self, msg) self.msg = msg def __str__(self): return repr(self.msg) class EasyBuildLog(fancylogger.FancyLogger): """ The EasyBuild logger, with its own error and exception functions. """ # self.raiseError can be set to False disable raising the exception which is # necessary because logging.Logger.exception calls self.error raiseError = True def caller_info(self): """Return string with caller info.""" (filepath, line, function_name) = self.findCaller() filepath_dirs = filepath.split(os.path.sep) for dirName in copy(filepath_dirs): if dirName != "easybuild": filepath_dirs.remove(dirName) else: break if not filepath_dirs: filepath_dirs = ['?'] return "(at %s:%s in %s)" % (os.path.join(*filepath_dirs), line, function_name) def experimental(self, msg, *args, **kwargs): """Handle experimental functionality if EXPERIMENTAL is True, otherwise log error""" if EXPERIMENTAL: msg = 'Experimental functionality. Behaviour might change/be removed later. ' + msg self.warning(msg, *args, **kwargs) else: msg = 'Experimental functionality. Behaviour might change/be removed later (use --experimental option to enable). ' + msg self.error(msg, *args) def deprecated(self, msg, max_ver): """Print deprecation warning or raise an EasyBuildError, depending on max version allowed.""" fancylogger.FancyLogger.deprecated(self, msg, str(CURRENT_VERSION), max_ver, exception=EasyBuildError) def error(self, msg, *args, **kwargs): """Print error message and raise an EasyBuildError.""" newMsg = "EasyBuild crashed with an error %s: %s" % (self.caller_info(), msg) fancylogger.FancyLogger.error(self, newMsg, *args, **kwargs) if self.raiseError: raise EasyBuildError(newMsg) def exception(self, msg, *args): """Print exception message and raise EasyBuildError.""" # don't raise the exception from within error newMsg = "EasyBuild encountered an exception %s: %s" % (self.caller_info(), msg) self.raiseError = False fancylogger.FancyLogger.exception(self, newMsg, *args) self.raiseError = True raise EasyBuildError(newMsg) # set format for logger LOGGING_FORMAT = EB_MSG_PREFIX + ' %(asctime)s %(name)s %(levelname)s %(message)s' fancylogger.setLogFormat(LOGGING_FORMAT) # set the default LoggerClass to EasyBuildLog fancylogger.logging.setLoggerClass(EasyBuildLog) # you can't easily set another LoggerClass before fancylogger calls getLogger on import _init_fancylog = fancylogger.getLogger(fname=False) del _init_fancylog.manager.loggerDict[_init_fancylog.name] # we need to make sure there is a handler fancylogger.logToFile(filename=os.devnull) # EasyBuildLog _init_easybuildlog = fancylogger.getLogger(fname=False) def get_log(name=None): """ Generate logger object """ # fname is always get_log, useless log = fancylogger.getLogger(name, fname=False) log.info("Logger started for %s." % name) log.deprecated("get_log", "2.0") return log def print_msg(msg, log=None, silent=False, prefix=True): """ Print a message to stdout. """ if log: log.info(msg) if not silent: if prefix: print "%s %s" % (EB_MSG_PREFIX, msg) else: print msg def print_error(message, log=None, exitCode=1, opt_parser=None, exit_on_error=True, silent=False): """ Print error message and exit EasyBuild """ if exit_on_error: if not silent: print_msg("ERROR: %s\n" % message) if opt_parser: opt_parser.print_shorthelp() print_msg("ERROR: %s\n" % message) sys.exit(exitCode) elif log is not None: log.error(message) def print_warning(message, silent=False): """ Print warning message. """ print_msg("WARNING: %s\n" % message, silent=silent)
gpl-2.0
[ 3, 327, 199, 3, 1898, 8937, 13, 7280, 598, 72, 484, 15904, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 30025, 12, 199, 3, 20657, 2737, 701, 314, 869, 4222, 8099, 402, 598, 72, 484, 15904, 334, 1014, 921, 1518, 484, 14, 1235, 15, 72, 2352, 15, 287, 395, 199, 3, 543, 2291, 402, 598, 72, 484, 15904, 334, 1014, 921, 1518, 484, 14, 1235, 15, 72, 2352, 395, 199, 3, 314, 481, 274, 1292, 72, 17897, 23805, 30610, 264, 334, 54, 5153, 9, 334, 2859, 921, 86, 10845, 454, 453, 14, 1235, 15, 7530, 15, 287, 395, 199, 3, 314, 18769, 67, 443, 83, 1911, 425, 334, 1014, 921, 1544, 14, 2523, 67, 443, 83, 270, 1158, 1337, 14, 1235, 15, 262, 63, 19410, 9, 199, 3, 436, 314, 1487, 12493, 402, 662, 25129, 89, 12, 27491, 436, 1010, 889, 4255, 334, 37, 18759, 9, 334, 1014, 921, 1544, 14, 546, 73, 13, 86, 416, 290, 271, 828, 14, 1235, 15, 287, 680, 199, 3, 199, 3, 1455, 921, 5031, 14, 957, 15, 72, 2352, 1518, 484, 15, 13581, 1506, 199, 3, 199, 3, 30025, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 373, 18, 14, 199, 3, 199, 3, 30025, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 30025, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 327, 199, 624, 199, 28326, 3425, 2512, 436, 943, 15841, 12, 5893, 4154, 5705, 18951, 1506, 547, 1021, 14, 199, 199, 32, 2502, 26, 428, 280, 24016, 1487, 2136, 723, 3583, 334, 39, 72, 484, 15904, 9, 199, 32, 2502, 26, 577, 1996, 5444, 271, 303, 77, 334, 39, 72, 484, 15904, 9, 199, 32, 2502, 26, 1804, 287, 685, 273, 869, 736, 266, 334, 39, 72, 484, 15904, 9, 199, 32, 2502, 26, 510, 1873, 351, 1487, 699, 65, 8716, 334, 39, 72, 484, 15904, 9, 199, 32, 2502, 26, 1603, 8764, 26244, 2626, 1237, 334, 39, 72, 484, 15904, 9, 199, 624, 199, 646, 747, 199, 646, 984, 199, 504, 1331, 492, 1331, 199, 504, 373, 551, 14, 1208, 492, 27571, 2921, 199, 199, 504, 8837, 1506, 14, 2537, 14, 1023, 492, 15945, 421, 199, 3, 30025, 1245, 2403, 199, 14138, 63, 9740, 63, 6351, 275, 298, 11800, 199, 199, 3, 314, 1015, 6775, 701, 943, 14, 6667, 199, 14211, 63, 4612, 275, 15945, 199, 199, 3, 2040, 2005, 22820, 22820, 1233, 199, 28722, 1309, 748, 275, 756, 421, 199, 533, 30025, 547, 8, 1726, 304, 272, 408, 272, 30025, 547, 365, 14031, 1380, 30025, 7858, 1901, 6020, 394, 269, 30759, 590, 6835, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1499, 304, 267, 2186, 855, 826, 721, 277, 12, 1499, 9, 267, 291, 14, 1328, 275, 1499, 339, 347, 636, 495, 721, 277, 304, 267, 372, 4700, 8, 277, 14, 1328, 9, 421, 199, 533, 30025, 2445, 8, 25352, 2921, 14, 38, 9844, 4455, 304, 272, 408, 272, 710, 30025, 2512, 12, 543, 2399, 5705, 1125, 436, 1919, 3423, 14, 272, 408, 339, 327, 291, 14, 3730, 547, 883, 506, 663, 370, 756, 3507, 17026, 314, 1919, 1314, 365, 272, 327, 5784, 2952, 2050, 14, 4455, 14, 1971, 4882, 291, 14, 705, 272, 746, 547, 275, 715, 339, 347, 8025, 63, 815, 8, 277, 304, 267, 408, 1767, 1059, 543, 8025, 2256, 1041, 267, 334, 7218, 12, 1004, 12, 805, 63, 354, 9, 275, 291, 14, 1623, 6584, 1435, 342, 267, 9911, 63, 3220, 275, 9911, 14, 1294, 8, 736, 14, 515, 14, 4127, 9, 398, 367, 2935, 985, 315, 1331, 8, 7218, 63, 3220, 304, 288, 340, 2935, 985, 1137, 298, 13581, 1506, 582, 355, 9911, 63, 3220, 14, 2168, 8, 694, 985, 9, 288, 587, 26, 355, 2059, 288, 340, 440, 9911, 63, 3220, 26, 355, 9911, 63, 3220, 275, 788, 31, 418, 267, 372, 7340, 292, 450, 83, 2689, 83, 315, 450, 83, 2924, 450, 334, 736, 14, 515, 14, 904, 2031, 7218, 63, 3220, 395, 1004, 12, 805, 63, 354, 9, 339, 347, 22820, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 5940, 22820, 9330, 340, 3651, 25731, 1309, 748, 365, 715, 12, 4257, 943, 1125, 624, 267, 340, 3651, 25731, 1309, 748, 26, 288, 1499, 275, 283, 20781, 279, 9330, 14, 6423, 4425, 567, 5594, 1570, 15, 1235, 4829, 2945, 14, 283, 435, 1499, 288, 291, 14, 3764, 8, 1328, 12, 627, 589, 12, 1011, 958, 9, 267, 587, 26, 288, 1499, 275, 283, 20781, 279, 9330, 14, 6423, 4425, 567, 5594, 1570, 15, 1235, 4829, 2945, 334, 1180, 1553, 18924, 945, 370, 4756, 680, 283, 435, 1499, 288, 291, 14, 705, 8, 1328, 12, 627, 589, 9, 339, 347, 5906, 8, 277, 12, 1499, 12, 1390, 63, 422, 304, 267, 408, 5375, 17831, 5721, 503, 746, 376, 30025, 547, 12, 10298, 641, 1390, 1015, 4370, 1041, 267, 27571, 2921, 14, 38, 9844, 4455, 14, 6667, 8, 277, 12, 1499, 12, 620, 8, 14211, 63, 4612, 395, 1390, 63, 422, 12, 1919, 29, 28326, 3425, 547, 9, 339, 347, 1125, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 5375, 1125, 1245, 436, 746, 376, 30025, 547, 1041, 267, 892, 6173, 275, 298, 28326, 3425, 12420, 379, 543, 376, 1125, 450, 83, 26, 450, 83, 2, 450, 334, 277, 14, 11219, 63, 815, 1062, 1499, 9, 267, 27571, 2921, 14, 38, 9844, 4455, 14, 705, 8, 277, 12, 892, 6173, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 291, 14, 3730, 547, 26, 288, 746, 30025, 547, 8, 1222, 6173, 9, 339, 347, 1919, 8, 277, 12, 1499, 12 ]
[ 327, 199, 3, 1898, 8937, 13, 7280, 598, 72, 484, 15904, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 30025, 12, 199, 3, 20657, 2737, 701, 314, 869, 4222, 8099, 402, 598, 72, 484, 15904, 334, 1014, 921, 1518, 484, 14, 1235, 15, 72, 2352, 15, 287, 395, 199, 3, 543, 2291, 402, 598, 72, 484, 15904, 334, 1014, 921, 1518, 484, 14, 1235, 15, 72, 2352, 395, 199, 3, 314, 481, 274, 1292, 72, 17897, 23805, 30610, 264, 334, 54, 5153, 9, 334, 2859, 921, 86, 10845, 454, 453, 14, 1235, 15, 7530, 15, 287, 395, 199, 3, 314, 18769, 67, 443, 83, 1911, 425, 334, 1014, 921, 1544, 14, 2523, 67, 443, 83, 270, 1158, 1337, 14, 1235, 15, 262, 63, 19410, 9, 199, 3, 436, 314, 1487, 12493, 402, 662, 25129, 89, 12, 27491, 436, 1010, 889, 4255, 334, 37, 18759, 9, 334, 1014, 921, 1544, 14, 546, 73, 13, 86, 416, 290, 271, 828, 14, 1235, 15, 287, 680, 199, 3, 199, 3, 1455, 921, 5031, 14, 957, 15, 72, 2352, 1518, 484, 15, 13581, 1506, 199, 3, 199, 3, 30025, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 373, 18, 14, 199, 3, 199, 3, 30025, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 30025, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 327, 199, 624, 199, 28326, 3425, 2512, 436, 943, 15841, 12, 5893, 4154, 5705, 18951, 1506, 547, 1021, 14, 199, 199, 32, 2502, 26, 428, 280, 24016, 1487, 2136, 723, 3583, 334, 39, 72, 484, 15904, 9, 199, 32, 2502, 26, 577, 1996, 5444, 271, 303, 77, 334, 39, 72, 484, 15904, 9, 199, 32, 2502, 26, 1804, 287, 685, 273, 869, 736, 266, 334, 39, 72, 484, 15904, 9, 199, 32, 2502, 26, 510, 1873, 351, 1487, 699, 65, 8716, 334, 39, 72, 484, 15904, 9, 199, 32, 2502, 26, 1603, 8764, 26244, 2626, 1237, 334, 39, 72, 484, 15904, 9, 199, 624, 199, 646, 747, 199, 646, 984, 199, 504, 1331, 492, 1331, 199, 504, 373, 551, 14, 1208, 492, 27571, 2921, 199, 199, 504, 8837, 1506, 14, 2537, 14, 1023, 492, 15945, 421, 199, 3, 30025, 1245, 2403, 199, 14138, 63, 9740, 63, 6351, 275, 298, 11800, 199, 199, 3, 314, 1015, 6775, 701, 943, 14, 6667, 199, 14211, 63, 4612, 275, 15945, 199, 199, 3, 2040, 2005, 22820, 22820, 1233, 199, 28722, 1309, 748, 275, 756, 421, 199, 533, 30025, 547, 8, 1726, 304, 272, 408, 272, 30025, 547, 365, 14031, 1380, 30025, 7858, 1901, 6020, 394, 269, 30759, 590, 6835, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1499, 304, 267, 2186, 855, 826, 721, 277, 12, 1499, 9, 267, 291, 14, 1328, 275, 1499, 339, 347, 636, 495, 721, 277, 304, 267, 372, 4700, 8, 277, 14, 1328, 9, 421, 199, 533, 30025, 2445, 8, 25352, 2921, 14, 38, 9844, 4455, 304, 272, 408, 272, 710, 30025, 2512, 12, 543, 2399, 5705, 1125, 436, 1919, 3423, 14, 272, 408, 339, 327, 291, 14, 3730, 547, 883, 506, 663, 370, 756, 3507, 17026, 314, 1919, 1314, 365, 272, 327, 5784, 2952, 2050, 14, 4455, 14, 1971, 4882, 291, 14, 705, 272, 746, 547, 275, 715, 339, 347, 8025, 63, 815, 8, 277, 304, 267, 408, 1767, 1059, 543, 8025, 2256, 1041, 267, 334, 7218, 12, 1004, 12, 805, 63, 354, 9, 275, 291, 14, 1623, 6584, 1435, 342, 267, 9911, 63, 3220, 275, 9911, 14, 1294, 8, 736, 14, 515, 14, 4127, 9, 398, 367, 2935, 985, 315, 1331, 8, 7218, 63, 3220, 304, 288, 340, 2935, 985, 1137, 298, 13581, 1506, 582, 355, 9911, 63, 3220, 14, 2168, 8, 694, 985, 9, 288, 587, 26, 355, 2059, 288, 340, 440, 9911, 63, 3220, 26, 355, 9911, 63, 3220, 275, 788, 31, 418, 267, 372, 7340, 292, 450, 83, 2689, 83, 315, 450, 83, 2924, 450, 334, 736, 14, 515, 14, 904, 2031, 7218, 63, 3220, 395, 1004, 12, 805, 63, 354, 9, 339, 347, 22820, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 5940, 22820, 9330, 340, 3651, 25731, 1309, 748, 365, 715, 12, 4257, 943, 1125, 624, 267, 340, 3651, 25731, 1309, 748, 26, 288, 1499, 275, 283, 20781, 279, 9330, 14, 6423, 4425, 567, 5594, 1570, 15, 1235, 4829, 2945, 14, 283, 435, 1499, 288, 291, 14, 3764, 8, 1328, 12, 627, 589, 12, 1011, 958, 9, 267, 587, 26, 288, 1499, 275, 283, 20781, 279, 9330, 14, 6423, 4425, 567, 5594, 1570, 15, 1235, 4829, 2945, 334, 1180, 1553, 18924, 945, 370, 4756, 680, 283, 435, 1499, 288, 291, 14, 705, 8, 1328, 12, 627, 589, 9, 339, 347, 5906, 8, 277, 12, 1499, 12, 1390, 63, 422, 304, 267, 408, 5375, 17831, 5721, 503, 746, 376, 30025, 547, 12, 10298, 641, 1390, 1015, 4370, 1041, 267, 27571, 2921, 14, 38, 9844, 4455, 14, 6667, 8, 277, 12, 1499, 12, 620, 8, 14211, 63, 4612, 395, 1390, 63, 422, 12, 1919, 29, 28326, 3425, 547, 9, 339, 347, 1125, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 5375, 1125, 1245, 436, 746, 376, 30025, 547, 1041, 267, 892, 6173, 275, 298, 28326, 3425, 12420, 379, 543, 376, 1125, 450, 83, 26, 450, 83, 2, 450, 334, 277, 14, 11219, 63, 815, 1062, 1499, 9, 267, 27571, 2921, 14, 38, 9844, 4455, 14, 705, 8, 277, 12, 892, 6173, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 291, 14, 3730, 547, 26, 288, 746, 30025, 547, 8, 1222, 6173, 9, 339, 347, 1919, 8, 277, 12, 1499, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
azavea/django-jenkins
django_jenkins/tasks/run_sloccount.py
3
1638
# -*- coding: utf-8 -*- import os import sys from optparse import make_option from django_jenkins.functions import check_output from django_jenkins.tasks import BaseTask, get_apps_locations class Task(BaseTask): option_list = [ make_option("--sloccount-with-migrations", action="store_true", default=False, dest="sloccount_with_migrations", help="Count migrations sloc.")] def __init__(self, test_labels, options): super(Task, self).__init__(test_labels, options) self.test_all = options['test_all'] self.with_migrations = options['sloccount_with_migrations'] if options.get('sloccount_file_output', True): output_dir = options['output_dir'] if not os.path.exists(output_dir): os.makedirs(output_dir) self.output = open(os.path.join(output_dir, 'sloccount.report'), 'w') else: self.output = sys.stdout def teardown_test_environment(self, **kwargs): locations = get_apps_locations(self.test_labels, self.test_all) report_output = check_output( ['sloccount', "--duplicates", "--wide", "--details"] + locations) report_output = report_output.decode('utf-8') if self.with_migrations: self.output.write(report_output.decode('utf-8')) else: for line in report_output.splitlines(): if '/migrations/' in line: continue self.output.write(line) self.output.write('\n')
lgpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 646, 984, 199, 504, 8691, 492, 1852, 63, 1422, 199, 504, 1639, 63, 25622, 14, 5777, 492, 1104, 63, 1199, 199, 504, 1639, 63, 25622, 14, 5054, 492, 3523, 4476, 12, 664, 63, 5181, 63, 8022, 421, 199, 533, 8495, 8, 1563, 4476, 304, 272, 945, 63, 513, 275, 359, 267, 1852, 63, 1422, 6739, 83, 2102, 835, 13, 1045, 13, 7685, 401, 490, 1595, 628, 1617, 63, 2052, 401, 849, 29, 797, 12, 490, 2053, 628, 83, 2102, 835, 63, 1045, 63, 7685, 401, 490, 1720, 628, 2353, 6180, 308, 2102, 2685, 61, 339, 347, 636, 826, 721, 277, 12, 511, 63, 3512, 12, 1511, 304, 267, 1613, 8, 4476, 12, 291, 2843, 826, 721, 396, 63, 3512, 12, 1511, 9, 267, 291, 14, 396, 63, 452, 275, 1511, 459, 396, 63, 452, 418, 267, 291, 14, 1045, 63, 7685, 275, 1511, 459, 83, 2102, 835, 63, 1045, 63, 7685, 418, 398, 340, 1511, 14, 362, 360, 83, 2102, 835, 63, 493, 63, 1199, 297, 715, 304, 288, 1072, 63, 694, 275, 1511, 459, 1199, 63, 694, 418, 288, 340, 440, 747, 14, 515, 14, 2444, 8, 1199, 63, 694, 304, 355, 747, 14, 8347, 8, 1199, 63, 694, 9, 288, 291, 14, 1199, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 1199, 63, 694, 12, 4490, 283, 83, 2102, 835, 14, 3070, 659, 283, 87, 358, 267, 587, 26, 288, 291, 14, 1199, 275, 984, 14, 2703, 339, 347, 17558, 63, 396, 63, 5418, 8, 277, 12, 1011, 958, 304, 267, 9918, 275, 664, 63, 5181, 63, 8022, 8, 277, 14, 396, 63, 3512, 12, 291, 14, 396, 63, 452, 9, 398, 3622, 63, 1199, 275, 1104, 63, 1199, 8, 288, 788, 83, 2102, 835, 297, 4320, 18563, 401, 4320, 13062, 401, 4320, 5087, 937, 435, 9918, 9, 267, 3622, 63, 1199, 275, 3622, 63, 1199, 14, 2708, 360, 1624, 13, 24, 358, 398, 340, 291, 14, 1045, 63, 7685, 26, 288, 291, 14, 1199, 14, 952, 8, 3070, 63, 1199, 14, 2708, 360, 1624, 13, 24, 1333, 267, 587, 26, 288, 367, 1004, 315, 3622, 63, 1199, 14, 7644, 837, 355, 340, 1994, 7685, 4805, 315, 1004, 26, 490, 1980, 355, 291, 14, 1199, 14, 952, 8, 604, 9, 355, 291, 14, 1199, 14, 952, 2258, 78, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 646, 984, 199, 504, 8691, 492, 1852, 63, 1422, 199, 504, 1639, 63, 25622, 14, 5777, 492, 1104, 63, 1199, 199, 504, 1639, 63, 25622, 14, 5054, 492, 3523, 4476, 12, 664, 63, 5181, 63, 8022, 421, 199, 533, 8495, 8, 1563, 4476, 304, 272, 945, 63, 513, 275, 359, 267, 1852, 63, 1422, 6739, 83, 2102, 835, 13, 1045, 13, 7685, 401, 490, 1595, 628, 1617, 63, 2052, 401, 849, 29, 797, 12, 490, 2053, 628, 83, 2102, 835, 63, 1045, 63, 7685, 401, 490, 1720, 628, 2353, 6180, 308, 2102, 2685, 61, 339, 347, 636, 826, 721, 277, 12, 511, 63, 3512, 12, 1511, 304, 267, 1613, 8, 4476, 12, 291, 2843, 826, 721, 396, 63, 3512, 12, 1511, 9, 267, 291, 14, 396, 63, 452, 275, 1511, 459, 396, 63, 452, 418, 267, 291, 14, 1045, 63, 7685, 275, 1511, 459, 83, 2102, 835, 63, 1045, 63, 7685, 418, 398, 340, 1511, 14, 362, 360, 83, 2102, 835, 63, 493, 63, 1199, 297, 715, 304, 288, 1072, 63, 694, 275, 1511, 459, 1199, 63, 694, 418, 288, 340, 440, 747, 14, 515, 14, 2444, 8, 1199, 63, 694, 304, 355, 747, 14, 8347, 8, 1199, 63, 694, 9, 288, 291, 14, 1199, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 1199, 63, 694, 12, 4490, 283, 83, 2102, 835, 14, 3070, 659, 283, 87, 358, 267, 587, 26, 288, 291, 14, 1199, 275, 984, 14, 2703, 339, 347, 17558, 63, 396, 63, 5418, 8, 277, 12, 1011, 958, 304, 267, 9918, 275, 664, 63, 5181, 63, 8022, 8, 277, 14, 396, 63, 3512, 12, 291, 14, 396, 63, 452, 9, 398, 3622, 63, 1199, 275, 1104, 63, 1199, 8, 288, 788, 83, 2102, 835, 297, 4320, 18563, 401, 4320, 13062, 401, 4320, 5087, 937, 435, 9918, 9, 267, 3622, 63, 1199, 275, 3622, 63, 1199, 14, 2708, 360, 1624, 13, 24, 358, 398, 340, 291, 14, 1045, 63, 7685, 26, 288, 291, 14, 1199, 14, 952, 8, 3070, 63, 1199, 14, 2708, 360, 1624, 13, 24, 1333, 267, 587, 26, 288, 367, 1004, 315, 3622, 63, 1199, 14, 7644, 837, 355, 340, 1994, 7685, 4805, 315, 1004, 26, 490, 1980, 355, 291, 14, 1199, 14, 952, 8, 604, 9, 355, 291, 14, 1199, 14, 952, 2258, 78, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
tovrstra/horton
horton/part/mbis.py
4
7124
# -*- coding: utf-8 -*- # HORTON: Helpful Open-source Research TOol for N-fermion systems. # Copyright (C) 2011-2017 The HORTON Development Team # # This file is part of HORTON. # # HORTON 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. # # HORTON is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/> # # -- '''Minimal Basis Iterative Stockholder (MBIS) partitioning''' import numpy as np from horton.log import log, biblio from horton.part.stockholder import StockholderWPart from horton.part.iterstock import IterativeProatomMixin __all__ = ['MBISWPart'] def _get_nshell(number): noble = np.array([2, 10, 18, 36, 54, 86, 118]) return noble.searchsorted(number) + 1 def _get_initial_mbis_propars(number): nshell = _get_nshell(number) propars = np.zeros(2*nshell, float) S0 = 2.0*number if nshell > 1: S1 = 2.0 alpha = (S1/S0)**(1.0/(nshell-1)) else: alpha = 1.0 nel_in_shell = np.array([2.0, 8.0, 8.0, 18.0, 18.0, 32.0, 32.0]) for ishell in xrange(nshell): propars[2*ishell] = nel_in_shell[ishell] propars[2*ishell+1] = S0*alpha**ishell propars[-2] = number - propars[:-2:2].sum() return propars def _opt_mbis_propars(rho, propars, rgrid, threshold): assert len(propars)%2 == 0 nshell = len(propars)/2 r = rgrid.radii terms = np.zeros((nshell, len(r)), float) oldpro = None for irep in xrange(1000): # compute the contributions to the pro-atom for ishell in xrange(nshell): N = propars[2*ishell] S = propars[2*ishell+1] terms[ishell] = (N*S**3/(8*np.pi))*np.exp(-S*r) pro = terms.sum(axis=0) # transform to partitions terms *= rho/pro # the partitions and the updated parameters for ishell in xrange(nshell): m0 = rgrid.integrate(terms[ishell]) m1 = rgrid.integrate(terms[ishell], r) propars[2*ishell] = m0 propars[2*ishell+1] = 3*m0/m1 # check for convergence if oldpro is None: change = 1e100 else: error = oldpro - pro change = np.sqrt(rgrid.integrate(error, error)) if change < threshold: return propars oldpro = pro assert False class MBISWPart(IterativeProatomMixin, StockholderWPart): '''Iterative Stockholder Partitioning with Becke-Lebedev grids''' name = 'mbis' options = ['lmax', 'threshold', 'maxiter'] linear = False def __init__(self, coordinates, numbers, pseudo_numbers, grid, moldens, spindens=None, lmax=3, threshold=1e-6, maxiter=500): ''' **Optional arguments:** (that are not defined in ``WPart``) threshold The procedure is considered to be converged when the maximum change of the charges between two iterations drops below this threshold. maxiter The maximum number of iterations. If no convergence is reached in the end, no warning is given. Reduce the CPU cost at the expense of more memory consumption. ''' self._threshold = threshold self._maxiter = maxiter StockholderWPart.__init__(self, coordinates, numbers, pseudo_numbers, grid, moldens, spindens, True, lmax) def _init_log_scheme(self): if log.do_medium: log.deflist([ ('Scheme', 'Minimal Basis Iterative Stockholder (MBIS)'), ('Convergence threshold', '%.1e' % self._threshold), ('Maximum iterations', self._maxiter), ]) biblio.cite('verstraelen2016', 'the use of MBIS partitioning') def get_rgrid(self, iatom): return self.get_grid(iatom).rgrid def get_proatom_rho(self, iatom, propars=None): if propars is None: propars = self.cache.load('propars') rgrid = self.get_rgrid(iatom) r = rgrid.radii y = np.zeros(len(r), float) d = np.zeros(len(r), float) my_propars = propars[self._ranges[iatom]:self._ranges[iatom+1]] for ishell in xrange(self._nshells[iatom]): N, S = my_propars[2*ishell:2*ishell+2] f = (N*S**3/(8*np.pi))*np.exp(-S*r) y += f d += -S*f return y, d def _init_propars(self): IterativeProatomMixin._init_propars(self) self._ranges = [0] self._nshells = [] for iatom in xrange(self.natom): nshell = _get_nshell(self.numbers[iatom]) self._ranges.append(self._ranges[-1]+2*nshell) self._nshells.append(nshell) ntotal = self._ranges[-1] propars = self.cache.load('propars', alloc=ntotal, tags='o')[0] for iatom in xrange(self.natom): propars[self._ranges[iatom]:self._ranges[iatom+1]] = _get_initial_mbis_propars(self.numbers[iatom]) return propars def _update_propars_atom(self, iatom): # compute spherical average atgrid = self.get_grid(iatom) rgrid = atgrid.rgrid dens = self.get_moldens(iatom) at_weights = self.cache.load('at_weights', iatom) spherical_average = np.clip(atgrid.get_spherical_average(at_weights, dens), 1e-100, np.inf) # assign as new propars my_propars = self.cache.load('propars')[self._ranges[iatom]:self._ranges[iatom+1]] my_propars[:] = _opt_mbis_propars(spherical_average, my_propars.copy(), rgrid, self._threshold) # compute the new charge pseudo_population = rgrid.integrate(spherical_average) charges = self.cache.load('charges', alloc=self.natom, tags='o')[0] charges[iatom] = self.pseudo_numbers[iatom] - pseudo_population def _finalize_propars(self): IterativeProatomMixin._finalize_propars(self) propars = self.cache.load('propars') core_charges = [] valence_charges = [] valence_widths = [] for iatom in xrange(self.natom): my_propars = propars[self._ranges[iatom]:self._ranges[iatom+1]] valence_charges.append(-my_propars[-2]) valence_widths.append(1.0/my_propars[-1]) valence_charges = np.array(valence_charges) valence_widths = np.array(valence_widths) core_charges = self._cache.load('charges') - valence_charges self.cache.dump('core_charges', core_charges, tags='o') self.cache.dump('valence_charges', valence_charges, tags='o') self.cache.dump('valence_widths', valence_widths, tags='o')
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 869, 2596, 615, 26, 15456, 1893, 3232, 13, 1365, 26993, 2296, 393, 367, 653, 13, 2412, 77, 1636, 10460, 14, 199, 3, 1898, 334, 35, 9, 7760, 13, 10680, 710, 869, 2596, 615, 15290, 11682, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 869, 2596, 615, 14, 199, 3, 199, 3, 869, 2596, 615, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 869, 2596, 615, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 3, 1553, 199, 2344, 4649, 7265, 699, 4864, 473, 2967, 857, 28406, 4302, 334, 4567, 1311, 9, 6484, 316, 2344, 421, 199, 646, 2680, 465, 980, 199, 504, 394, 361, 265, 14, 793, 492, 943, 12, 11314, 14437, 199, 504, 394, 361, 265, 14, 2064, 14, 6088, 4302, 492, 28406, 4302, 55, 8416, 199, 504, 394, 361, 265, 14, 2064, 14, 1661, 6088, 492, 473, 2967, 857, 919, 4188, 4256, 421, 199, 363, 452, 363, 275, 788, 4567, 1311, 55, 8416, 418, 421, 199, 318, 485, 362, 63, 561, 72, 1697, 8, 1955, 304, 272, 949, 830, 275, 980, 14, 1144, 779, 18, 12, 1616, 12, 6155, 12, 8780, 12, 13470, 12, 10300, 12, 25760, 566, 272, 372, 949, 830, 14, 31698, 8, 1955, 9, 435, 413, 421, 199, 318, 485, 362, 63, 2747, 63, 887, 374, 63, 496, 21152, 8, 1955, 304, 272, 302, 5641, 275, 485, 362, 63, 561, 72, 1697, 8, 1955, 9, 272, 557, 21152, 275, 980, 14, 4250, 8, 18, 10, 561, 72, 1697, 12, 2069, 9, 272, 428, 16, 275, 499, 14, 16, 10, 1955, 272, 340, 302, 5641, 690, 413, 26, 267, 428, 17, 275, 499, 14, 16, 267, 5131, 275, 334, 51, 17, 15, 51, 16, 25288, 17, 14, 16, 7985, 561, 72, 1697, 13, 17, 430, 272, 587, 26, 267, 5131, 275, 413, 14, 16, 272, 302, 352, 63, 262, 63, 5641, 275, 980, 14, 1144, 779, 18, 14, 16, 12, 1695, 14, 16, 12, 1695, 14, 16, 12, 6155, 14, 16, 12, 6155, 14, 16, 12, 4337, 14, 16, 12, 4337, 14, 16, 566, 272, 367, 365, 72, 1697, 315, 4945, 8, 561, 72, 1697, 304, 267, 557, 21152, 59, 18, 10, 2453, 1697, 61, 275, 302, 352, 63, 262, 63, 5641, 59, 2453, 1697, 61, 267, 557, 21152, 59, 18, 10, 2453, 1697, 11, 17, 61, 275, 428, 16, 10, 4468, 538, 2453, 1697, 272, 557, 21152, 1988, 18, 61, 275, 1329, 446, 557, 21152, 4439, 18, 26, 18, 1055, 1838, 342, 272, 372, 557, 21152, 421, 199, 318, 485, 2992, 63, 887, 374, 63, 496, 21152, 8, 10412, 12, 557, 21152, 12, 519, 3825, 12, 8765, 304, 272, 702, 822, 8, 496, 21152, 19656, 18, 508, 378, 272, 302, 5641, 275, 822, 8, 496, 21152, 2447, 18, 272, 519, 275, 519, 3825, 14, 12841, 73, 272, 2895, 275, 980, 14, 4250, 1332, 561, 72, 1697, 12, 822, 8, 82, 1826, 2069, 9, 272, 2269, 496, 275, 488, 272, 367, 284, 1155, 315, 4945, 8, 5279, 304, 267, 327, 4526, 314, 406, 26675, 370, 314, 557, 13, 4188, 267, 367, 365, 72, 1697, 315, 4945, 8, 561, 72, 1697, 304, 288, 653, 275, 557, 21152, 59, 18, 10, 2453, 1697, 61, 288, 428, 275, 557, 21152, 59, 18, 10, 2453, 1697, 11, 17, 61, 288, 2895, 59, 2453, 1697, 61, 275, 334, 46, 10, 51, 538, 19, 7985, 24, 10, 1590, 14, 1038, 19198, 1590, 14, 1474, 2801, 51, 10, 82, 9, 267, 557, 275, 2895, 14, 1838, 8, 3127, 29, 16, 9, 267, 327, 5793, 370, 16394, 267, 2895, 9000, 17908, 15, 496, 267, 327, 314, 16394, 436, 314, 4588, 2633, 267, 367, 365, 72, 1697, 315, 4945, 8, 561, 72, 1697, 304, 288, 333, 16, 275, 519, 3825, 14, 26248, 8, 9187, 59, 2453, 1697, 566, 288, 333, 17, 275, 519, 3825, 14, 26248, 8, 9187, 59, 2453, 1697, 467, 519, 9, 288, 557, 21152, 59, 18, 10, 2453, 1697, 61, 275, 333, 16, 288, 557, 21152, 59, 18, 10, 2453, 1697, 11, 17, 61, 275, 650, 10, 77, 16, 15, 77, 17, 267, 327, 1104, 367, 21346, 267, 340, 2269, 496, 365, 488, 26, 288, 1570, 275, 413, 69, 1960, 267, 587, 26, 288, 1125, 275, 2269, 496, 446, 557, 288, 1570, 275, 980, 14, 5079, 8, 82, 3825, 14, 26248, 8, 705, 12, 1125, 430, 267, 340, 1570, 665, 8765, 26, 288, 372, 557, 21152, 267, 2269, 496, 275, 557, 272, 702, 756, 421, 199, 533, 19487, 1311, 55, 8416, 8, 41, 2967, 857, 919, 4188, 4256, 12, 28406, 4302, 55, 8416, 304, 272, 1449, 41, 2967, 857, 28406, 4302, 27353, 316, 543, 6423, 21531, 13, 2553, 1235, 2374, 27591, 795, 2344, 272, 536, 275, 283, 887, 374, 7, 272, 1511, 275, 788, 76, 988, 297, 283, 7227, 297, 283, 988, 1661, 418, 272, 7798, 275, 756, 339, 347, 636, 826, 721, 277, 12, 8983, 12, 5579, 12, 15984, 63, 10548, 12, 6068, 12, 22956, 28509, 12, 326, 20749, 28509, 29, 403, 12, 634, 988, 29, 19, 12, 8765, 29, 17, 69, 13, 22, 12, 27150, 29, 5783, 304, 267, 1449, 1779, 1011, 7012, 2368, 19003, 334, 9099, 787, 440, 3247, 315, 1124, 55, 8416, 16580, 13596, 8765, 355, 710, 17782, 365, 8652, 370, 506, 3818, 3046, 1380, 314, 5696, 355, 1570, 402, 314, 1495, 3389, 3382, 2877, 10615, 366, 26307, 5084, 642, 355, 8765, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 869, 2596, 615, 26, 15456, 1893, 3232, 13, 1365, 26993, 2296, 393, 367, 653, 13, 2412, 77, 1636, 10460, 14, 199, 3, 1898, 334, 35, 9, 7760, 13, 10680, 710, 869, 2596, 615, 15290, 11682, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 869, 2596, 615, 14, 199, 3, 199, 3, 869, 2596, 615, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 869, 2596, 615, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 3, 1553, 199, 2344, 4649, 7265, 699, 4864, 473, 2967, 857, 28406, 4302, 334, 4567, 1311, 9, 6484, 316, 2344, 421, 199, 646, 2680, 465, 980, 199, 504, 394, 361, 265, 14, 793, 492, 943, 12, 11314, 14437, 199, 504, 394, 361, 265, 14, 2064, 14, 6088, 4302, 492, 28406, 4302, 55, 8416, 199, 504, 394, 361, 265, 14, 2064, 14, 1661, 6088, 492, 473, 2967, 857, 919, 4188, 4256, 421, 199, 363, 452, 363, 275, 788, 4567, 1311, 55, 8416, 418, 421, 199, 318, 485, 362, 63, 561, 72, 1697, 8, 1955, 304, 272, 949, 830, 275, 980, 14, 1144, 779, 18, 12, 1616, 12, 6155, 12, 8780, 12, 13470, 12, 10300, 12, 25760, 566, 272, 372, 949, 830, 14, 31698, 8, 1955, 9, 435, 413, 421, 199, 318, 485, 362, 63, 2747, 63, 887, 374, 63, 496, 21152, 8, 1955, 304, 272, 302, 5641, 275, 485, 362, 63, 561, 72, 1697, 8, 1955, 9, 272, 557, 21152, 275, 980, 14, 4250, 8, 18, 10, 561, 72, 1697, 12, 2069, 9, 272, 428, 16, 275, 499, 14, 16, 10, 1955, 272, 340, 302, 5641, 690, 413, 26, 267, 428, 17, 275, 499, 14, 16, 267, 5131, 275, 334, 51, 17, 15, 51, 16, 25288, 17, 14, 16, 7985, 561, 72, 1697, 13, 17, 430, 272, 587, 26, 267, 5131, 275, 413, 14, 16, 272, 302, 352, 63, 262, 63, 5641, 275, 980, 14, 1144, 779, 18, 14, 16, 12, 1695, 14, 16, 12, 1695, 14, 16, 12, 6155, 14, 16, 12, 6155, 14, 16, 12, 4337, 14, 16, 12, 4337, 14, 16, 566, 272, 367, 365, 72, 1697, 315, 4945, 8, 561, 72, 1697, 304, 267, 557, 21152, 59, 18, 10, 2453, 1697, 61, 275, 302, 352, 63, 262, 63, 5641, 59, 2453, 1697, 61, 267, 557, 21152, 59, 18, 10, 2453, 1697, 11, 17, 61, 275, 428, 16, 10, 4468, 538, 2453, 1697, 272, 557, 21152, 1988, 18, 61, 275, 1329, 446, 557, 21152, 4439, 18, 26, 18, 1055, 1838, 342, 272, 372, 557, 21152, 421, 199, 318, 485, 2992, 63, 887, 374, 63, 496, 21152, 8, 10412, 12, 557, 21152, 12, 519, 3825, 12, 8765, 304, 272, 702, 822, 8, 496, 21152, 19656, 18, 508, 378, 272, 302, 5641, 275, 822, 8, 496, 21152, 2447, 18, 272, 519, 275, 519, 3825, 14, 12841, 73, 272, 2895, 275, 980, 14, 4250, 1332, 561, 72, 1697, 12, 822, 8, 82, 1826, 2069, 9, 272, 2269, 496, 275, 488, 272, 367, 284, 1155, 315, 4945, 8, 5279, 304, 267, 327, 4526, 314, 406, 26675, 370, 314, 557, 13, 4188, 267, 367, 365, 72, 1697, 315, 4945, 8, 561, 72, 1697, 304, 288, 653, 275, 557, 21152, 59, 18, 10, 2453, 1697, 61, 288, 428, 275, 557, 21152, 59, 18, 10, 2453, 1697, 11, 17, 61, 288, 2895, 59, 2453, 1697, 61, 275, 334, 46, 10, 51, 538, 19, 7985, 24, 10, 1590, 14, 1038, 19198, 1590, 14, 1474, 2801, 51, 10, 82, 9, 267, 557, 275, 2895, 14, 1838, 8, 3127, 29, 16, 9, 267, 327, 5793, 370, 16394, 267, 2895, 9000, 17908, 15, 496, 267, 327, 314, 16394, 436, 314, 4588, 2633, 267, 367, 365, 72, 1697, 315, 4945, 8, 561, 72, 1697, 304, 288, 333, 16, 275, 519, 3825, 14, 26248, 8, 9187, 59, 2453, 1697, 566, 288, 333, 17, 275, 519, 3825, 14, 26248, 8, 9187, 59, 2453, 1697, 467, 519, 9, 288, 557, 21152, 59, 18, 10, 2453, 1697, 61, 275, 333, 16, 288, 557, 21152, 59, 18, 10, 2453, 1697, 11, 17, 61, 275, 650, 10, 77, 16, 15, 77, 17, 267, 327, 1104, 367, 21346, 267, 340, 2269, 496, 365, 488, 26, 288, 1570, 275, 413, 69, 1960, 267, 587, 26, 288, 1125, 275, 2269, 496, 446, 557, 288, 1570, 275, 980, 14, 5079, 8, 82, 3825, 14, 26248, 8, 705, 12, 1125, 430, 267, 340, 1570, 665, 8765, 26, 288, 372, 557, 21152, 267, 2269, 496, 275, 557, 272, 702, 756, 421, 199, 533, 19487, 1311, 55, 8416, 8, 41, 2967, 857, 919, 4188, 4256, 12, 28406, 4302, 55, 8416, 304, 272, 1449, 41, 2967, 857, 28406, 4302, 27353, 316, 543, 6423, 21531, 13, 2553, 1235, 2374, 27591, 795, 2344, 272, 536, 275, 283, 887, 374, 7, 272, 1511, 275, 788, 76, 988, 297, 283, 7227, 297, 283, 988, 1661, 418, 272, 7798, 275, 756, 339, 347, 636, 826, 721, 277, 12, 8983, 12, 5579, 12, 15984, 63, 10548, 12, 6068, 12, 22956, 28509, 12, 326, 20749, 28509, 29, 403, 12, 634, 988, 29, 19, 12, 8765, 29, 17, 69, 13, 22, 12, 27150, 29, 5783, 304, 267, 1449, 1779, 1011, 7012, 2368, 19003, 334, 9099, 787, 440, 3247, 315, 1124, 55, 8416, 16580, 13596, 8765, 355, 710, 17782, 365, 8652, 370, 506, 3818, 3046, 1380, 314, 5696, 355, 1570, 402, 314, 1495, 3389, 3382, 2877, 10615, 366, 26307, 5084, 642, 355, 8765, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
textioHQ/pattern
pattern/vector/svm/liblinear.py
4
10842
#!/usr/bin/env python from ctypes import * from ctypes.util import find_library from os import path import sys # For unix the prefix 'lib' is not considered. if find_library('linear'): liblinear = CDLL(find_library('linear')) elif find_library('liblinear'): liblinear = CDLL(find_library('liblinear')) else: b = False for v in ("liblinear-1.93",): # LIBLINEAR 1.93 for binary in ( # If you have OS X 32-bit, you need a 32-bit Python and liblinear-mac32.so. # If you have OS X 32-bit with 64-bit Python, # it will try to load liblinear-mac64.so which fails since OS X is 32-bit. # It won't load liblinear-mac32.so since Python is 64-bit. "liblinear-win64.dll", # 1) 64-bit Windows "liblinear-win32.dll", # 2) 32-bit Windows "liblinear-mac32.so", # 3) 32-bit Mac OS X "liblinear-mac64.so", # 4) 64-bit Mac OS X "liblinear-ubuntu64.so", # 5) 64-bit Linux Ubuntu "liblinear.so", # 6) User-compiled Mac / Linux "liblinear.dll"): # 7) User-compiled Windows if sys.platform.startswith("win") and binary.endswith(".so"): continue try: liblinear = CDLL(path.join(path.dirname(__file__), v, binary)) b = True break except OSError as e: continue if b: break if not b: raise ImportError("can't import liblinear (%sbit-%s)" % ( sizeof(c_voidp) * 8, sys.platform )) # Construct constants SOLVER_TYPE = ['L2R_LR', 'L2R_L2LOSS_SVC_DUAL', 'L2R_L2LOSS_SVC', 'L2R_L1LOSS_SVC_DUAL', 'MCSVM_CS', 'L1R_L2LOSS_SVC', 'L1R_LR', 'L2R_LR_DUAL', None, None, None, 'L2R_L2LOSS_SVR', 'L2R_L2LOSS_SVR_DUAL', 'L2R_L1LOSS_SVR_DUAL'] for i, s in enumerate(SOLVER_TYPE): if s is not None: exec("%s = %d" % (s, i)) PRINT_STRING_FUN = CFUNCTYPE(None, c_char_p) def print_null(s): return def genFields(names, types): return list(zip(names, types)) def fillprototype(f, restype, argtypes): f.restype = restype f.argtypes = argtypes class feature_node(Structure): _names = ["index", "value"] _types = [c_int, c_double] _fields_ = genFields(_names, _types) def __str__(self): return '%d:%g' % (self.index, self.value) def gen_feature_nodearray(xi, feature_max=None, issparse=True): if isinstance(xi, dict): index_range = xi.keys() elif isinstance(xi, (list, tuple)): xi = [0] + xi # idx should start from 1 index_range = range(1, len(xi)) else: raise TypeError('xi should be a dictionary, list or tuple') if feature_max: assert(isinstance(feature_max, int)) index_range = filter(lambda j: j <= feature_max, index_range) if issparse: index_range = filter(lambda j: xi[j] != 0, index_range) index_range = sorted(index_range) ret = (feature_node * (len(index_range) + 2))() ret[-1].index = -1 # for bias term ret[-2].index = -1 for idx, j in enumerate(index_range): ret[idx].index = j ret[idx].value = xi[j] max_idx = 0 if index_range: max_idx = index_range[-1] return ret, max_idx class problem(Structure): _names = ["l", "n", "y", "x", "bias"] _types = [c_int, c_int, POINTER(c_double), POINTER( POINTER(feature_node)), c_double] _fields_ = genFields(_names, _types) def __init__(self, y, x, bias=-1): if len(y) != len(x): raise ValueError("len(y) != len(x)") self.l = l = len(y) self.bias = -1 max_idx = 0 x_space = self.x_space = [] for i, xi in enumerate(x): tmp_xi, tmp_idx = gen_feature_nodearray(xi) x_space += [tmp_xi] max_idx = max(max_idx, tmp_idx) self.n = max_idx self.y = (c_double * l)() for i, yi in enumerate(y): self.y[i] = y[i] self.x = (POINTER(feature_node) * l)() for i, xi in enumerate(self.x_space): self.x[i] = xi self.set_bias(bias) def set_bias(self, bias): if self.bias == bias: return if bias >= 0 and self.bias < 0: self.n += 1 node = feature_node(self.n, bias) if bias < 0 and self.bias >= 0: self.n -= 1 node = feature_node(-1, bias) for xi in self.x_space: xi[-2] = node self.bias = bias class parameter(Structure): _names = ["solver_type", "eps", "C", "nr_weight", "weight_label", "weight", "p"] _types = [c_int, c_double, c_double, c_int, POINTER(c_int), POINTER(c_double), c_double] _fields_ = genFields(_names, _types) def __init__(self, options=None): if options == None: options = '' self.parse_options(options) def __str__(self): s = '' attrs = parameter._names + list(self.__dict__.keys()) values = map(lambda attr: getattr(self, attr), attrs) for attr, val in zip(attrs, values): s += (' %s: %s\n' % (attr, val)) s = s.strip() return s def set_to_default_values(self): self.solver_type = L2R_L2LOSS_SVC_DUAL self.eps = float('inf') self.C = 1 self.p = 0.1 self.nr_weight = 0 self.weight_label = (c_int * 0)() self.weight = (c_double * 0)() self.bias = -1 self.cross_validation = False self.nr_fold = 0 self.print_func = None def parse_options(self, options): if isinstance(options, list): argv = options elif isinstance(options, str): argv = options.split() else: raise TypeError("arg 1 should be a list or a str.") self.set_to_default_values() self.print_func = cast(None, PRINT_STRING_FUN) weight_label = [] weight = [] i = 0 while i < len(argv): if argv[i] == "-s": i = i + 1 self.solver_type = int(argv[i]) elif argv[i] == "-c": i = i + 1 self.C = float(argv[i]) elif argv[i] == "-p": i = i + 1 self.p = float(argv[i]) elif argv[i] == "-e": i = i + 1 self.eps = float(argv[i]) elif argv[i] == "-B": i = i + 1 self.bias = float(argv[i]) elif argv[i] == "-v": i = i + 1 self.cross_validation = 1 self.nr_fold = int(argv[i]) if self.nr_fold < 2: raise ValueError("n-fold cross validation: n must >= 2") elif argv[i].startswith("-w"): i = i + 1 self.nr_weight += 1 nr_weight = self.nr_weight weight_label += [int(argv[i - 1][2:])] weight += [float(argv[i])] elif argv[i] == "-q": self.print_func = PRINT_STRING_FUN(print_null) else: raise ValueError("Wrong options") i += 1 liblinear.set_print_string_function(self.print_func) self.weight_label = (c_int * self.nr_weight)() self.weight = (c_double * self.nr_weight)() for i in range(self.nr_weight): self.weight[i] = weight[i] self.weight_label[i] = weight_label[i] if self.eps == float('inf'): if self.solver_type in [L2R_LR, L2R_L2LOSS_SVC]: self.eps = 0.01 elif self.solver_type in [L2R_L2LOSS_SVR]: self.eps = 0.001 elif self.solver_type in [L2R_L2LOSS_SVC_DUAL, L2R_L1LOSS_SVC_DUAL, MCSVM_CS, L2R_LR_DUAL]: self.eps = 0.1 elif self.solver_type in [L1R_L2LOSS_SVC, L1R_LR]: self.eps = 0.01 elif self.solver_type in [L2R_L2LOSS_SVR_DUAL, L2R_L1LOSS_SVR_DUAL]: self.eps = 0.1 class model(Structure): _names = ["param", "nr_class", "nr_feature", "w", "label", "bias"] _types = [parameter, c_int, c_int, POINTER( c_double), POINTER(c_int), c_double] _fields_ = genFields(_names, _types) def __init__(self): self.__createfrom__ = 'python' def __del__(self): # free memory created by C to avoid memory leak if hasattr(self, '__createfrom__') and self.__createfrom__ == 'C': liblinear.free_and_destroy_model(pointer(self)) def get_nr_feature(self): return liblinear.get_nr_feature(self) def get_nr_class(self): return liblinear.get_nr_class(self) def get_labels(self): nr_class = self.get_nr_class() labels = (c_int * nr_class)() liblinear.get_labels(self, labels) return labels[:nr_class] def is_probability_model(self): return (liblinear.check_probability_model(self) == 1) def toPyModel(model_ptr): """ toPyModel(model_ptr) -> model Convert a ctypes POINTER(model) to a Python model """ if bool(model_ptr) == False: raise ValueError("Null pointer") m = model_ptr.contents m.__createfrom__ = 'C' return m fillprototype(liblinear.train, POINTER( model), [POINTER(problem), POINTER(parameter)]) fillprototype(liblinear.cross_validation, None, [ POINTER(problem), POINTER(parameter), c_int, POINTER(c_double)]) fillprototype(liblinear.predict_values, c_double, [ POINTER(model), POINTER(feature_node), POINTER(c_double)]) fillprototype( liblinear.predict, c_double, [POINTER(model), POINTER(feature_node)]) fillprototype(liblinear.predict_probability, c_double, [ POINTER(model), POINTER(feature_node), POINTER(c_double)]) fillprototype(liblinear.save_model, c_int, [c_char_p, POINTER(model)]) fillprototype(liblinear.load_model, POINTER(model), [c_char_p]) fillprototype(liblinear.get_nr_feature, c_int, [POINTER(model)]) fillprototype(liblinear.get_nr_class, c_int, [POINTER(model)]) fillprototype(liblinear.get_labels, None, [POINTER(model), POINTER(c_int)]) fillprototype(liblinear.free_model_content, None, [POINTER(model)]) fillprototype( liblinear.free_and_destroy_model, None, [POINTER(POINTER(model))]) fillprototype(liblinear.destroy_param, None, [POINTER(parameter)]) fillprototype(liblinear.check_parameter, c_char_p, [POINTER(problem), POINTER(parameter)]) fillprototype(liblinear.check_probability_model, c_int, [POINTER(model)]) fillprototype( liblinear.set_print_string_function, None, [CFUNCTYPE(None, c_char_p)])
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 5577, 492, 627, 199, 504, 5577, 14, 1974, 492, 2342, 63, 4342, 199, 504, 747, 492, 931, 199, 646, 984, 199, 199, 3, 2104, 16572, 314, 2403, 283, 773, 7, 365, 440, 8652, 14, 199, 692, 2342, 63, 4342, 360, 6676, 735, 272, 1973, 6676, 275, 445, 15982, 8, 1623, 63, 4342, 360, 6676, 1333, 199, 4164, 2342, 63, 4342, 360, 773, 6676, 735, 272, 1973, 6676, 275, 445, 15982, 8, 1623, 63, 4342, 360, 773, 6676, 1333, 199, 2836, 26, 272, 330, 275, 756, 272, 367, 373, 315, 1689, 773, 6676, 13, 17, 14, 3129, 401, 304, 221, 327, 25764, 6174, 689, 413, 14, 3129, 267, 367, 3366, 315, 334, 355, 327, 982, 1265, 1172, 4403, 1323, 4337, 13, 2075, 12, 1265, 1929, 282, 4337, 13, 2075, 2018, 436, 1973, 6676, 13, 3088, 708, 14, 1152, 14, 355, 327, 982, 1265, 1172, 4403, 1323, 4337, 13, 2075, 543, 5049, 13, 2075, 2018, 12, 355, 327, 652, 911, 862, 370, 2248, 1973, 6676, 13, 3088, 772, 14, 1152, 1314, 6918, 3967, 4403, 1323, 365, 4337, 13, 2075, 14, 355, 327, 2779, 7859, 1133, 2248, 1973, 6676, 13, 3088, 708, 14, 1152, 3967, 2018, 365, 5049, 13, 2075, 14, 355, 298, 773, 6676, 13, 2676, 772, 14, 9259, 401, 257, 327, 413, 9, 5049, 13, 2075, 5417, 355, 298, 773, 6676, 13, 2676, 708, 14, 9259, 401, 257, 327, 499, 9, 4337, 13, 2075, 5417, 355, 298, 773, 6676, 13, 3088, 708, 14, 1152, 401, 259, 327, 650, 9, 4337, 13, 2075, 10444, 4403, 1323, 355, 298, 773, 6676, 13, 3088, 772, 14, 1152, 401, 259, 327, 841, 9, 5049, 13, 2075, 10444, 4403, 1323, 355, 298, 773, 6676, 13, 21151, 772, 14, 1152, 401, 221, 327, 959, 9, 5049, 13, 2075, 10130, 31631, 355, 298, 773, 6676, 14, 1152, 401, 3515, 327, 1227, 9, 2876, 13, 8427, 10444, 1182, 10130, 355, 298, 773, 6676, 14, 9259, 2349, 263, 327, 1520, 9, 2876, 13, 8427, 5417, 288, 340, 984, 14, 3246, 14, 2460, 480, 2676, 531, 436, 3366, 14, 4130, 9520, 1152, 2349, 355, 1980, 288, 862, 26, 355, 1973, 6676, 275, 445, 15982, 8, 515, 14, 904, 8, 515, 14, 3475, 3460, 493, 10139, 373, 12, 3366, 430, 355, 330, 275, 715, 355, 2059, 288, 871, 6440, 465, 325, 26, 355, 1980, 267, 340, 330, 26, 288, 2059, 272, 340, 440, 330, 26, 267, 746, 3545, 480, 2425, 1133, 492, 1973, 6676, 4366, 83, 2075, 3295, 83, 2924, 450, 334, 288, 13855, 8, 67, 63, 1647, 80, 9, 627, 1695, 12, 288, 984, 14, 3246, 267, 5082, 199, 199, 3, 9215, 5262, 199, 15096, 2111, 63, 2711, 275, 788, 44, 18, 50, 63, 17665, 297, 283, 44, 18, 50, 63, 44, 18, 28010, 63, 17675, 63, 4980, 748, 297, 283, 44, 18, 50, 63, 44, 18, 28010, 63, 17675, 297, 283, 44, 18, 50, 63, 44, 17, 28010, 63, 17675, 63, 4980, 748, 297, 2049, 283, 45, 3298, 6849, 63, 3298, 297, 283, 44, 17, 50, 63, 44, 18, 28010, 63, 17675, 297, 283, 44, 17, 50, 63, 17665, 297, 283, 44, 18, 50, 63, 17665, 63, 4980, 748, 297, 2049, 488, 12, 488, 12, 488, 12, 2049, 283, 44, 18, 50, 63, 44, 18, 28010, 63, 4985, 50, 297, 283, 44, 18, 50, 63, 44, 18, 28010, 63, 4985, 50, 63, 4980, 748, 297, 283, 44, 18, 50, 63, 44, 17, 28010, 63, 4985, 50, 63, 4980, 748, 418, 199, 509, 284, 12, 308, 315, 3874, 8, 15096, 2111, 63, 2711, 304, 272, 340, 308, 365, 440, 488, 26, 267, 2146, 3647, 83, 275, 450, 68, 2, 450, 334, 83, 12, 284, 430, 199, 199, 21754, 63, 5353, 63, 9309, 275, 11093, 8, 403, 12, 286, 63, 1560, 63, 80, 9, 421, 199, 318, 870, 63, 2307, 8, 83, 304, 272, 372, 421, 199, 318, 3805, 7304, 8, 1247, 12, 2943, 304, 272, 372, 769, 8, 3065, 8, 1247, 12, 2943, 430, 421, 199, 318, 5554, 16141, 8, 70, 12, 4618, 514, 12, 29669, 304, 272, 289, 14, 9990, 275, 4618, 514, 272, 289, 14, 10025, 275, 29669, 421, 199, 533, 3878, 63, 932, 8, 10766, 304, 272, 485, 1247, 275, 2097, 1080, 401, 298, 585, 937, 272, 485, 1313, 275, 359, 67, 63, 442, 12, 286, 63, 3157, 61, 272, 485, 955, 63, 275, 3805, 7304, 1547, 1247, 12, 485, 1313, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 68, 2689, 71, 7, 450, 334, 277, 14, 1080, 12, 291, 14, 585, 9, 421, 199, 318, 3805, 63, 4445, 63, 932, 1144, 8, 6865, 12, 3878, 63, 988, 29, 403, 12, 365, 4421, 29, 549, 304, 272, 340, 1228, 8, 6865, 12, 1211, 304, 267, 1478, 63, 1842, 275, 19905, 14, 1612, 342, 272, 916, 1228, 8, 6865, 12, 334, 513, 12, 2008, 2298, 267, 19905, 275, 359, 16, 61, 435, 19905, 221, 327, 4280, 1077, 1343, 687, 413, 267, 1478, 63, 1842, 275, 1425, 8, 17, 12, 822, 8, 6865, 430, 272, 587, 26, 267, 746, 3146, 360, 6865, 1077, 506, 282, 2600, 12, 769, 503, 2008, 358, 339, 340, 3878, 63, 988, 26, 267, 702, 8, 6074, 8, 4445, 63, 988, 12, 1109, 430, 267, 1478, 63, 1842, 275, 2457, 8, 2734, 1335, 26, 1335, 2695, 3878, 63, 988, 12, 1478, 63, 1842, 9, 272, 340, 365, 4421, 26, 267, 1478, 63, 1842, 275, 2457, 8, 2734, 1335, 26, 19905, 59, 74, 61, 1137, 378, 12, 1478, 63, 1842, 9, 339, 1478, 63, 1842, 275, 3355, 8, 1080, 63, 1842, 9, 272, 2203, 275, 334, 4445, 63, 932, 627, 334, 552, 8, 1080, 63, 1842, 9, 435, 499, 430, 342, 272, 2203, 1988, 17, 1055, 1080, 275, 446, 17, 221, 327, 367, 10671, 6707, 272, 2203, 1988, 18, 1055, 1080, 275, 446, 17, 272, 367, 4280, 12, 1335, 315, 3874, 8, 1080, 63, 1842, 304, 267, 2203, 59, 2996, 1055, 1080, 275, 1335, 267, 2203, 59, 2996, 1055, 585, 275, 19905, 59, 74, 61, 272, 1390, 63, 2996, 275, 378, 272, 340, 1478, 63, 1842, 26, 267, 1390, 63, 2996, 275, 1478, 63, 1842, 1988, 17, 61 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 5577, 492, 627, 199, 504, 5577, 14, 1974, 492, 2342, 63, 4342, 199, 504, 747, 492, 931, 199, 646, 984, 199, 199, 3, 2104, 16572, 314, 2403, 283, 773, 7, 365, 440, 8652, 14, 199, 692, 2342, 63, 4342, 360, 6676, 735, 272, 1973, 6676, 275, 445, 15982, 8, 1623, 63, 4342, 360, 6676, 1333, 199, 4164, 2342, 63, 4342, 360, 773, 6676, 735, 272, 1973, 6676, 275, 445, 15982, 8, 1623, 63, 4342, 360, 773, 6676, 1333, 199, 2836, 26, 272, 330, 275, 756, 272, 367, 373, 315, 1689, 773, 6676, 13, 17, 14, 3129, 401, 304, 221, 327, 25764, 6174, 689, 413, 14, 3129, 267, 367, 3366, 315, 334, 355, 327, 982, 1265, 1172, 4403, 1323, 4337, 13, 2075, 12, 1265, 1929, 282, 4337, 13, 2075, 2018, 436, 1973, 6676, 13, 3088, 708, 14, 1152, 14, 355, 327, 982, 1265, 1172, 4403, 1323, 4337, 13, 2075, 543, 5049, 13, 2075, 2018, 12, 355, 327, 652, 911, 862, 370, 2248, 1973, 6676, 13, 3088, 772, 14, 1152, 1314, 6918, 3967, 4403, 1323, 365, 4337, 13, 2075, 14, 355, 327, 2779, 7859, 1133, 2248, 1973, 6676, 13, 3088, 708, 14, 1152, 3967, 2018, 365, 5049, 13, 2075, 14, 355, 298, 773, 6676, 13, 2676, 772, 14, 9259, 401, 257, 327, 413, 9, 5049, 13, 2075, 5417, 355, 298, 773, 6676, 13, 2676, 708, 14, 9259, 401, 257, 327, 499, 9, 4337, 13, 2075, 5417, 355, 298, 773, 6676, 13, 3088, 708, 14, 1152, 401, 259, 327, 650, 9, 4337, 13, 2075, 10444, 4403, 1323, 355, 298, 773, 6676, 13, 3088, 772, 14, 1152, 401, 259, 327, 841, 9, 5049, 13, 2075, 10444, 4403, 1323, 355, 298, 773, 6676, 13, 21151, 772, 14, 1152, 401, 221, 327, 959, 9, 5049, 13, 2075, 10130, 31631, 355, 298, 773, 6676, 14, 1152, 401, 3515, 327, 1227, 9, 2876, 13, 8427, 10444, 1182, 10130, 355, 298, 773, 6676, 14, 9259, 2349, 263, 327, 1520, 9, 2876, 13, 8427, 5417, 288, 340, 984, 14, 3246, 14, 2460, 480, 2676, 531, 436, 3366, 14, 4130, 9520, 1152, 2349, 355, 1980, 288, 862, 26, 355, 1973, 6676, 275, 445, 15982, 8, 515, 14, 904, 8, 515, 14, 3475, 3460, 493, 10139, 373, 12, 3366, 430, 355, 330, 275, 715, 355, 2059, 288, 871, 6440, 465, 325, 26, 355, 1980, 267, 340, 330, 26, 288, 2059, 272, 340, 440, 330, 26, 267, 746, 3545, 480, 2425, 1133, 492, 1973, 6676, 4366, 83, 2075, 3295, 83, 2924, 450, 334, 288, 13855, 8, 67, 63, 1647, 80, 9, 627, 1695, 12, 288, 984, 14, 3246, 267, 5082, 199, 199, 3, 9215, 5262, 199, 15096, 2111, 63, 2711, 275, 788, 44, 18, 50, 63, 17665, 297, 283, 44, 18, 50, 63, 44, 18, 28010, 63, 17675, 63, 4980, 748, 297, 283, 44, 18, 50, 63, 44, 18, 28010, 63, 17675, 297, 283, 44, 18, 50, 63, 44, 17, 28010, 63, 17675, 63, 4980, 748, 297, 2049, 283, 45, 3298, 6849, 63, 3298, 297, 283, 44, 17, 50, 63, 44, 18, 28010, 63, 17675, 297, 283, 44, 17, 50, 63, 17665, 297, 283, 44, 18, 50, 63, 17665, 63, 4980, 748, 297, 2049, 488, 12, 488, 12, 488, 12, 2049, 283, 44, 18, 50, 63, 44, 18, 28010, 63, 4985, 50, 297, 283, 44, 18, 50, 63, 44, 18, 28010, 63, 4985, 50, 63, 4980, 748, 297, 283, 44, 18, 50, 63, 44, 17, 28010, 63, 4985, 50, 63, 4980, 748, 418, 199, 509, 284, 12, 308, 315, 3874, 8, 15096, 2111, 63, 2711, 304, 272, 340, 308, 365, 440, 488, 26, 267, 2146, 3647, 83, 275, 450, 68, 2, 450, 334, 83, 12, 284, 430, 199, 199, 21754, 63, 5353, 63, 9309, 275, 11093, 8, 403, 12, 286, 63, 1560, 63, 80, 9, 421, 199, 318, 870, 63, 2307, 8, 83, 304, 272, 372, 421, 199, 318, 3805, 7304, 8, 1247, 12, 2943, 304, 272, 372, 769, 8, 3065, 8, 1247, 12, 2943, 430, 421, 199, 318, 5554, 16141, 8, 70, 12, 4618, 514, 12, 29669, 304, 272, 289, 14, 9990, 275, 4618, 514, 272, 289, 14, 10025, 275, 29669, 421, 199, 533, 3878, 63, 932, 8, 10766, 304, 272, 485, 1247, 275, 2097, 1080, 401, 298, 585, 937, 272, 485, 1313, 275, 359, 67, 63, 442, 12, 286, 63, 3157, 61, 272, 485, 955, 63, 275, 3805, 7304, 1547, 1247, 12, 485, 1313, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 68, 2689, 71, 7, 450, 334, 277, 14, 1080, 12, 291, 14, 585, 9, 421, 199, 318, 3805, 63, 4445, 63, 932, 1144, 8, 6865, 12, 3878, 63, 988, 29, 403, 12, 365, 4421, 29, 549, 304, 272, 340, 1228, 8, 6865, 12, 1211, 304, 267, 1478, 63, 1842, 275, 19905, 14, 1612, 342, 272, 916, 1228, 8, 6865, 12, 334, 513, 12, 2008, 2298, 267, 19905, 275, 359, 16, 61, 435, 19905, 221, 327, 4280, 1077, 1343, 687, 413, 267, 1478, 63, 1842, 275, 1425, 8, 17, 12, 822, 8, 6865, 430, 272, 587, 26, 267, 746, 3146, 360, 6865, 1077, 506, 282, 2600, 12, 769, 503, 2008, 358, 339, 340, 3878, 63, 988, 26, 267, 702, 8, 6074, 8, 4445, 63, 988, 12, 1109, 430, 267, 1478, 63, 1842, 275, 2457, 8, 2734, 1335, 26, 1335, 2695, 3878, 63, 988, 12, 1478, 63, 1842, 9, 272, 340, 365, 4421, 26, 267, 1478, 63, 1842, 275, 2457, 8, 2734, 1335, 26, 19905, 59, 74, 61, 1137, 378, 12, 1478, 63, 1842, 9, 339, 1478, 63, 1842, 275, 3355, 8, 1080, 63, 1842, 9, 272, 2203, 275, 334, 4445, 63, 932, 627, 334, 552, 8, 1080, 63, 1842, 9, 435, 499, 430, 342, 272, 2203, 1988, 17, 1055, 1080, 275, 446, 17, 221, 327, 367, 10671, 6707, 272, 2203, 1988, 18, 1055, 1080, 275, 446, 17,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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 ]
mdworks2016/work_development
Python/05_FirstPython/Chapter8_ThirdParty/fpython_develop/lib/python3.7/site-packages/bs4/builder/__init__.py
2
19839
# Use of this source code is governed by the MIT license. __license__ = "MIT" from collections import defaultdict import itertools import sys from bs4.element import ( CharsetMetaAttributeValue, ContentMetaAttributeValue, Stylesheet, Script, TemplateString, nonwhitespace_re ) __all__ = [ 'HTMLTreeBuilder', 'SAXTreeBuilder', 'TreeBuilder', 'TreeBuilderRegistry', ] # Some useful features for a TreeBuilder to have. FAST = 'fast' PERMISSIVE = 'permissive' STRICT = 'strict' XML = 'xml' HTML = 'html' HTML_5 = 'html5' class TreeBuilderRegistry(object): """A way of looking up TreeBuilder subclasses by their name or by desired features. """ def __init__(self): self.builders_for_feature = defaultdict(list) self.builders = [] def register(self, treebuilder_class): """Register a treebuilder based on its advertised features. :param treebuilder_class: A subclass of Treebuilder. its .features attribute should list its features. """ for feature in treebuilder_class.features: self.builders_for_feature[feature].insert(0, treebuilder_class) self.builders.insert(0, treebuilder_class) def lookup(self, *features): """Look up a TreeBuilder subclass with the desired features. :param features: A list of features to look for. If none are provided, the most recently registered TreeBuilder subclass will be used. :return: A TreeBuilder subclass, or None if there's no registered subclass with all the requested features. """ if len(self.builders) == 0: # There are no builders at all. return None if len(features) == 0: # They didn't ask for any features. Give them the most # recently registered builder. return self.builders[0] # Go down the list of features in order, and eliminate any builders # that don't match every feature. features = list(features) features.reverse() candidates = None candidate_set = None while len(features) > 0: feature = features.pop() we_have_the_feature = self.builders_for_feature.get(feature, []) if len(we_have_the_feature) > 0: if candidates is None: candidates = we_have_the_feature candidate_set = set(candidates) else: # Eliminate any candidates that don't have this feature. candidate_set = candidate_set.intersection( set(we_have_the_feature)) # The only valid candidates are the ones in candidate_set. # Go through the original list of candidates and pick the first one # that's in candidate_set. if candidate_set is None: return None for candidate in candidates: if candidate in candidate_set: return candidate return None # The BeautifulSoup class will take feature lists from developers and use them # to look up builders in this registry. builder_registry = TreeBuilderRegistry() class TreeBuilder(object): """Turn a textual document into a Beautiful Soup object tree.""" NAME = "[Unknown tree builder]" ALTERNATE_NAMES = [] features = [] is_xml = False picklable = False empty_element_tags = None # A tag will be considered an empty-element # tag when and only when it has no contents. # A value for these tag/attribute combinations is a space- or # comma-separated list of CDATA, rather than a single CDATA. DEFAULT_CDATA_LIST_ATTRIBUTES = {} # Whitespace should be preserved inside these tags. DEFAULT_PRESERVE_WHITESPACE_TAGS = set() # The textual contents of tags with these names should be # instantiated with some class other than NavigableString. DEFAULT_STRING_CONTAINERS = {} USE_DEFAULT = object() # Most parsers don't keep track of line numbers. TRACKS_LINE_NUMBERS = False def __init__(self, multi_valued_attributes=USE_DEFAULT, preserve_whitespace_tags=USE_DEFAULT, store_line_numbers=USE_DEFAULT, string_containers=USE_DEFAULT, ): """Constructor. :param multi_valued_attributes: If this is set to None, the TreeBuilder will not turn any values for attributes like 'class' into lists. Setting this to a dictionary will customize this behavior; look at DEFAULT_CDATA_LIST_ATTRIBUTES for an example. Internally, these are called "CDATA list attributes", but that probably doesn't make sense to an end-user, so the argument name is `multi_valued_attributes`. :param preserve_whitespace_tags: A list of tags to treat the way <pre> tags are treated in HTML. Tags in this list are immune from pretty-printing; their contents will always be output as-is. :param string_containers: A dictionary mapping tag names to the classes that should be instantiated to contain the textual contents of those tags. The default is to use NavigableString for every tag, no matter what the name. You can override the default by changing DEFAULT_STRING_CONTAINERS. :param store_line_numbers: If the parser keeps track of the line numbers and positions of the original markup, that information will, by default, be stored in each corresponding `Tag` object. You can turn this off by passing store_line_numbers=False. If the parser you're using doesn't keep track of this information, then setting store_line_numbers=True will do nothing. """ self.soup = None if multi_valued_attributes is self.USE_DEFAULT: multi_valued_attributes = self.DEFAULT_CDATA_LIST_ATTRIBUTES self.cdata_list_attributes = multi_valued_attributes if preserve_whitespace_tags is self.USE_DEFAULT: preserve_whitespace_tags = self.DEFAULT_PRESERVE_WHITESPACE_TAGS self.preserve_whitespace_tags = preserve_whitespace_tags if store_line_numbers == self.USE_DEFAULT: store_line_numbers = self.TRACKS_LINE_NUMBERS self.store_line_numbers = store_line_numbers if string_containers == self.USE_DEFAULT: string_containers = self.DEFAULT_STRING_CONTAINERS self.string_containers = string_containers def initialize_soup(self, soup): """The BeautifulSoup object has been initialized and is now being associated with the TreeBuilder. :param soup: A BeautifulSoup object. """ self.soup = soup def reset(self): """Do any work necessary to reset the underlying parser for a new document. By default, this does nothing. """ pass def can_be_empty_element(self, tag_name): """Might a tag with this name be an empty-element tag? The final markup may or may not actually present this tag as self-closing. For instance: an HTMLBuilder does not consider a <p> tag to be an empty-element tag (it's not in HTMLBuilder.empty_element_tags). This means an empty <p> tag will be presented as "<p></p>", not "<p/>" or "<p>". The default implementation has no opinion about which tags are empty-element tags, so a tag will be presented as an empty-element tag if and only if it has no children. "<foo></foo>" will become "<foo/>", and "<foo>bar</foo>" will be left alone. :param tag_name: The name of a markup tag. """ if self.empty_element_tags is None: return True return tag_name in self.empty_element_tags def feed(self, markup): """Run some incoming markup through some parsing process, populating the `BeautifulSoup` object in self.soup. This method is not implemented in TreeBuilder; it must be implemented in subclasses. :return: None. """ raise NotImplementedError() def prepare_markup(self, markup, user_specified_encoding=None, document_declared_encoding=None, exclude_encodings=None): """Run any preliminary steps necessary to make incoming markup acceptable to the parser. :param markup: Some markup -- probably a bytestring. :param user_specified_encoding: The user asked to try this encoding. :param document_declared_encoding: The markup itself claims to be in this encoding. :param exclude_encodings: The user asked _not_ to try any of these encodings. :yield: A series of 4-tuples: (markup, encoding, declared encoding, has undergone character replacement) Each 4-tuple represents a strategy for converting the document to Unicode and parsing it. Each strategy will be tried in turn. By default, the only strategy is to parse the markup as-is. See `LXMLTreeBuilderForXML` and `HTMLParserTreeBuilder` for implementations that take into account the quirks of particular parsers. """ yield markup, None, None, False def test_fragment_to_document(self, fragment): """Wrap an HTML fragment to make it look like a document. Different parsers do this differently. For instance, lxml introduces an empty <head> tag, and html5lib doesn't. Abstracting this away lets us write simple tests which run HTML fragments through the parser and compare the results against other HTML fragments. This method should not be used outside of tests. :param fragment: A string -- fragment of HTML. :return: A string -- a full HTML document. """ return fragment def set_up_substitutions(self, tag): """Set up any substitutions that will need to be performed on a `Tag` when it's output as a string. By default, this does nothing. See `HTMLTreeBuilder` for a case where this is used. :param tag: A `Tag` :return: Whether or not a substitution was performed. """ return False def _replace_cdata_list_attribute_values(self, tag_name, attrs): """When an attribute value is associated with a tag that can have multiple values for that attribute, convert the string value to a list of strings. Basically, replaces class="foo bar" with class=["foo", "bar"] NOTE: This method modifies its input in place. :param tag_name: The name of a tag. :param attrs: A dictionary containing the tag's attributes. Any appropriate attribute values will be modified in place. """ if not attrs: return attrs if self.cdata_list_attributes: universal = self.cdata_list_attributes.get('*', []) tag_specific = self.cdata_list_attributes.get( tag_name.lower(), None) for attr in list(attrs.keys()): if attr in universal or (tag_specific and attr in tag_specific): # We have a "class"-type attribute whose string # value is a whitespace-separated list of # values. Split it into a list. value = attrs[attr] if isinstance(value, str): values = nonwhitespace_re.findall(value) else: # html5lib sometimes calls setAttributes twice # for the same tag when rearranging the parse # tree. On the second call the attribute value # here is already a list. If this happens, # leave the value alone rather than trying to # split it again. values = value attrs[attr] = values return attrs class SAXTreeBuilder(TreeBuilder): """A Beautiful Soup treebuilder that listens for SAX events. This is not currently used for anything, but it demonstrates how a simple TreeBuilder would work. """ def feed(self, markup): raise NotImplementedError() def close(self): pass def startElement(self, name, attrs): attrs = dict((key[1], value) for key, value in list(attrs.items())) #print "Start %s, %r" % (name, attrs) self.soup.handle_starttag(name, attrs) def endElement(self, name): #print "End %s" % name self.soup.handle_endtag(name) def startElementNS(self, nsTuple, nodeName, attrs): # Throw away (ns, nodeName) for now. self.startElement(nodeName, attrs) def endElementNS(self, nsTuple, nodeName): # Throw away (ns, nodeName) for now. self.endElement(nodeName) #handler.endElementNS((ns, node.nodeName), node.nodeName) def startPrefixMapping(self, prefix, nodeValue): # Ignore the prefix for now. pass def endPrefixMapping(self, prefix): # Ignore the prefix for now. # handler.endPrefixMapping(prefix) pass def characters(self, content): self.soup.handle_data(content) def startDocument(self): pass def endDocument(self): pass class HTMLTreeBuilder(TreeBuilder): """This TreeBuilder knows facts about HTML. Such as which tags are empty-element tags. """ empty_element_tags = set([ # These are from HTML5. 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr', # These are from earlier versions of HTML and are removed in HTML5. 'basefont', 'bgsound', 'command', 'frame', 'image', 'isindex', 'nextid', 'spacer' ]) # The HTML standard defines these as block-level elements. Beautiful # Soup does not treat these elements differently from other elements, # but it may do so eventually, and this information is available if # you need to use it. block_elements = set(["address", "article", "aside", "blockquote", "canvas", "dd", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hr", "li", "main", "nav", "noscript", "ol", "output", "p", "pre", "section", "table", "tfoot", "ul", "video"]) # The HTML standard defines an unusual content model for these tags. # We represent this by using a string class other than NavigableString # inside these tags. # # I made this list by going through the HTML spec # (https://html.spec.whatwg.org/#metadata-content) and looking for # "metadata content" elements that can contain strings. # # TODO: Arguably <noscript> could go here but it seems # qualitatively different from the other tags. DEFAULT_STRING_CONTAINERS = { 'style': Stylesheet, 'script': Script, 'template': TemplateString, } # The HTML standard defines these attributes as containing a # space-separated list of values, not a single value. That is, # class="foo bar" means that the 'class' attribute has two values, # 'foo' and 'bar', not the single value 'foo bar'. When we # encounter one of these attributes, we will parse its value into # a list of values if possible. Upon output, the list will be # converted back into a string. DEFAULT_CDATA_LIST_ATTRIBUTES = { "*" : ['class', 'accesskey', 'dropzone'], "a" : ['rel', 'rev'], "link" : ['rel', 'rev'], "td" : ["headers"], "th" : ["headers"], "td" : ["headers"], "form" : ["accept-charset"], "object" : ["archive"], # These are HTML5 specific, as are *.accesskey and *.dropzone above. "area" : ["rel"], "icon" : ["sizes"], "iframe" : ["sandbox"], "output" : ["for"], } DEFAULT_PRESERVE_WHITESPACE_TAGS = set(['pre', 'textarea']) def set_up_substitutions(self, tag): """Replace the declared encoding in a <meta> tag with a placeholder, to be substituted when the tag is output to a string. An HTML document may come in to Beautiful Soup as one encoding, but exit in a different encoding, and the <meta> tag needs to be changed to reflect this. :param tag: A `Tag` :return: Whether or not a substitution was performed. """ # We are only interested in <meta> tags if tag.name != 'meta': return False http_equiv = tag.get('http-equiv') content = tag.get('content') charset = tag.get('charset') # We are interested in <meta> tags that say what encoding the # document was originally in. This means HTML 5-style <meta> # tags that provide the "charset" attribute. It also means # HTML 4-style <meta> tags that provide the "content" # attribute and have "http-equiv" set to "content-type". # # In both cases we will replace the value of the appropriate # attribute with a standin object that can take on any # encoding. meta_encoding = None if charset is not None: # HTML 5 style: # <meta charset="utf8"> meta_encoding = charset tag['charset'] = CharsetMetaAttributeValue(charset) elif (content is not None and http_equiv is not None and http_equiv.lower() == 'content-type'): # HTML 4 style: # <meta http-equiv="content-type" content="text/html; charset=utf8"> tag['content'] = ContentMetaAttributeValue(content) return (meta_encoding is not None) def register_treebuilders_from(module): """Copy TreeBuilders from the given module into this module.""" # I'm fairly sure this is not the best way to do this. this_module = sys.modules['bs4.builder'] for name in module.__all__: obj = getattr(module, name) if issubclass(obj, TreeBuilder): setattr(this_module, name, obj) this_module.__all__.append(name) # Register the builder while we're at it. this_module.builder_registry.register(obj) class ParserRejectedMarkup(Exception): """An Exception to be raised when the underlying parser simply refuses to parse the given markup. """ def __init__(self, message_or_exception): """Explain why the parser rejected the given markup, either with a textual explanation or another exception. """ if isinstance(message_or_exception, Exception): e = message_or_exception message_or_exception = "%s: %s" % (e.__class__.__name__, str(e)) super(ParserRejectedMarkup, self).__init__(message_or_exception) # Builders are registered in reverse order of priority, so that custom # builder registrations will take precedence. In general, we want lxml # to take precedence over html5lib, because it's faster. And we only # want to use HTMLParser as a last resort. from . import _htmlparser register_treebuilders_from(_htmlparser) try: from . import _html5lib register_treebuilders_from(_html5lib) except ImportError: # They don't have html5lib installed. pass try: from . import _lxml register_treebuilders_from(_lxml) except ImportError: # They don't have lxml installed. pass
apache-2.0
[ 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 314, 10697, 4190, 14, 199, 363, 1682, 363, 275, 298, 13965, 2, 199, 199, 504, 5055, 492, 10018, 199, 646, 7975, 199, 646, 984, 199, 504, 9922, 20, 14, 2108, 492, 334, 272, 29392, 3396, 4016, 12, 272, 6646, 3396, 4016, 12, 272, 428, 369, 2978, 3797, 12, 272, 14914, 12, 272, 5458, 1558, 12, 272, 2222, 8506, 63, 264, 199, 9, 199, 199, 363, 452, 363, 275, 359, 272, 283, 4943, 20437, 297, 272, 283, 4251, 56, 20437, 297, 272, 283, 20437, 297, 272, 283, 20437, 10899, 297, 272, 1622, 199, 199, 3, 6601, 2997, 4534, 367, 282, 12178, 6437, 370, 1172, 14, 199, 24661, 275, 283, 7015, 7, 199, 4227, 9674, 2684, 2524, 275, 283, 529, 32237, 7, 199, 3027, 6196, 275, 283, 4768, 7, 199, 4317, 275, 283, 1652, 7, 199, 4943, 275, 283, 1360, 7, 199, 4943, 63, 21, 275, 283, 1360, 21, 7, 421, 199, 533, 12178, 6437, 10899, 8, 785, 304, 272, 408, 33, 4340, 402, 10023, 1536, 12178, 6437, 9180, 701, 3932, 536, 503, 701, 6387, 272, 4534, 14, 272, 408, 2286, 347, 636, 826, 721, 277, 304, 267, 291, 14, 20968, 63, 509, 63, 4445, 275, 10018, 8, 513, 9, 267, 291, 14, 20968, 275, 942, 339, 347, 2274, 8, 277, 12, 3123, 5649, 63, 533, 304, 267, 408, 7099, 282, 3123, 5649, 4079, 641, 2399, 19613, 939, 4534, 14, 398, 520, 635, 3123, 5649, 63, 533, 26, 437, 5516, 402, 12178, 5649, 14, 2399, 1275, 3179, 1779, 2225, 1077, 769, 2399, 4534, 14, 267, 408, 267, 367, 3878, 315, 3123, 5649, 63, 533, 14, 3179, 26, 288, 291, 14, 20968, 63, 509, 63, 4445, 59, 4445, 1055, 3176, 8, 16, 12, 3123, 5649, 63, 533, 9, 267, 291, 14, 20968, 14, 3176, 8, 16, 12, 3123, 5649, 63, 533, 9, 339, 347, 4237, 8, 277, 12, 627, 3179, 304, 267, 408, 20926, 1536, 282, 12178, 6437, 5516, 543, 314, 6387, 4534, 14, 398, 520, 635, 4534, 26, 437, 769, 402, 4534, 370, 3648, 367, 14, 982, 7179, 787, 288, 2741, 12, 314, 4750, 23568, 7264, 12178, 6437, 5516, 288, 911, 506, 1202, 14, 267, 520, 1107, 26, 437, 12178, 6437, 5516, 12, 503, 488, 340, 2337, 1159, 949, 288, 7264, 5516, 543, 1006, 314, 5839, 4534, 14, 267, 408, 267, 340, 822, 8, 277, 14, 20968, 9, 508, 378, 26, 288, 327, 6006, 787, 949, 27378, 737, 1006, 14, 288, 372, 488, 398, 340, 822, 8, 3179, 9, 508, 378, 26, 288, 327, 9322, 9980, 1133, 7198, 367, 1263, 4534, 14, 25495, 3062, 314, 4750, 288, 327, 23568, 7264, 6545, 14, 288, 372, 291, 14, 20968, 59, 16, 61, 398, 327, 3971, 3224, 314, 769, 402, 4534, 315, 1865, 12, 436, 20714, 323, 1263, 27378, 267, 327, 626, 2793, 1133, 1336, 4036, 3878, 14, 267, 4534, 275, 769, 8, 3179, 9, 267, 4534, 14, 4471, 342, 267, 15101, 275, 488, 267, 7627, 63, 409, 275, 488, 267, 1830, 822, 8, 3179, 9, 690, 378, 26, 288, 3878, 275, 4534, 14, 1935, 342, 288, 781, 63, 7804, 63, 1589, 63, 4445, 275, 291, 14, 20968, 63, 509, 63, 4445, 14, 362, 8, 4445, 12, 3073, 288, 340, 822, 8, 1129, 63, 7804, 63, 1589, 63, 4445, 9, 690, 378, 26, 355, 340, 15101, 365, 488, 26, 490, 15101, 275, 781, 63, 7804, 63, 1589, 63, 4445, 490, 7627, 63, 409, 275, 663, 8, 16389, 9, 355, 587, 26, 490, 327, 662, 13769, 323, 1263, 15101, 626, 2793, 1133, 1172, 642, 3878, 14, 490, 7627, 63, 409, 275, 7627, 63, 409, 14, 12569, 8, 717, 663, 8, 1129, 63, 7804, 63, 1589, 63, 4445, 430, 398, 327, 710, 1454, 1686, 15101, 787, 314, 7869, 315, 7627, 63, 409, 14, 267, 327, 3971, 4012, 314, 3379, 769, 402, 15101, 436, 3732, 314, 1642, 1373, 267, 327, 626, 1159, 315, 7627, 63, 409, 14, 267, 340, 7627, 63, 409, 365, 488, 26, 288, 372, 488, 267, 367, 7627, 315, 15101, 26, 288, 340, 7627, 315, 7627, 63, 409, 26, 355, 372, 7627, 267, 372, 488, 199, 199, 3, 710, 17132, 1021, 911, 5452, 3878, 5548, 687, 19782, 436, 675, 3062, 199, 3, 370, 3648, 1536, 27378, 315, 642, 7086, 14, 199, 5649, 63, 5189, 275, 12178, 6437, 10899, 342, 199, 199, 533, 12178, 6437, 8, 785, 304, 272, 408, 16838, 282, 25884, 2213, 1901, 282, 14562, 28028, 909, 3123, 1041, 339, 13637, 275, 7369, 5912, 3123, 6545, 8480, 272, 12112, 7689, 1951, 63, 14546, 275, 942, 272, 4534, 275, 942, 339, 365, 63, 1652, 275, 756, 272, 3732, 76, 461, 275, 756, 272, 2701, 63, 2108, 63, 2969, 275, 488, 327, 437, 1947, 911, 506, 8652, 376, 2701, 13, 2108, 2892, 327, 1947, 1380, 436, 1454, 1380, 652, 965, 949, 4072, 14, 2286, 327, 437, 574, 367, 3520, 1947, 15, 3215, 15821, 365, 282, 4601, 13, 503, 272, 327, 10029, 13, 12794, 769, 402, 445, 3998, 12, 7830, 2419, 282, 2849, 445, 3998, 14, 272, 6186, 63, 14049, 63, 4924, 63, 18166, 275, 1052, 339, 327, 24403, 1077, 506, 17731, 6272, 3520, 3762, 14, 272, 6186, 63, 14956, 540, 2524, 63, 20620, 63, 17626, 275, 663, 342, 339, 327, 710, 25884, 4072, 402, 3762, 543, 3520, 1561, 1077, 506, 272, 327, 17544, 543, 2005, 1021, 1163, 2419, 20721, 16725, 1558, 14, 272, 6186, 63, 5353, 63, 25207, 3960, 275, 1052, 2286, 4815, 63, 3472, 275, 909, 342, 339, 327, 17536, 21295, 2793, 1133, 4215, 4426, 402, 1004, 5579, 14, 272, 9074, 3099, 51, 63, 6174, 63, 8861, 3960, 275, 756, 2286, 347, 636, 826, 721, 277, 12, 3510, 63, 16611, 63, 2987, 29, 4701, 63, 3472, 12, 326, 11211, 63, 8506, 63, 2969, 29, 4701, 63, 3472, 12, 326, 3877, 63, 604, 63, 10548, 29, 4701, 63, 3472, 12, 326, 1059, 63, 13577, 29, 4701, 63, 3472, 12, 272, 3461, 267, 408, 11447, 14, 398, 520, 635, 3510, 63, 16611, 63, 2987, 26, 982, 642, 365, 663, 370, 488, 12, 314, 268, 12178, 6437, 911, 440, 7485, 1263, 1338, 367, 3004, 2839, 268, 283, 533, 7, 1901, 5548, 14, 13510, 642, 370, 282, 2600, 911, 268, 17551, 642, 5953, 27 ]
[ 3645, 402, 642, 1350, 1233, 365, 10413, 701, 314, 10697, 4190, 14, 199, 363, 1682, 363, 275, 298, 13965, 2, 199, 199, 504, 5055, 492, 10018, 199, 646, 7975, 199, 646, 984, 199, 504, 9922, 20, 14, 2108, 492, 334, 272, 29392, 3396, 4016, 12, 272, 6646, 3396, 4016, 12, 272, 428, 369, 2978, 3797, 12, 272, 14914, 12, 272, 5458, 1558, 12, 272, 2222, 8506, 63, 264, 199, 9, 199, 199, 363, 452, 363, 275, 359, 272, 283, 4943, 20437, 297, 272, 283, 4251, 56, 20437, 297, 272, 283, 20437, 297, 272, 283, 20437, 10899, 297, 272, 1622, 199, 199, 3, 6601, 2997, 4534, 367, 282, 12178, 6437, 370, 1172, 14, 199, 24661, 275, 283, 7015, 7, 199, 4227, 9674, 2684, 2524, 275, 283, 529, 32237, 7, 199, 3027, 6196, 275, 283, 4768, 7, 199, 4317, 275, 283, 1652, 7, 199, 4943, 275, 283, 1360, 7, 199, 4943, 63, 21, 275, 283, 1360, 21, 7, 421, 199, 533, 12178, 6437, 10899, 8, 785, 304, 272, 408, 33, 4340, 402, 10023, 1536, 12178, 6437, 9180, 701, 3932, 536, 503, 701, 6387, 272, 4534, 14, 272, 408, 2286, 347, 636, 826, 721, 277, 304, 267, 291, 14, 20968, 63, 509, 63, 4445, 275, 10018, 8, 513, 9, 267, 291, 14, 20968, 275, 942, 339, 347, 2274, 8, 277, 12, 3123, 5649, 63, 533, 304, 267, 408, 7099, 282, 3123, 5649, 4079, 641, 2399, 19613, 939, 4534, 14, 398, 520, 635, 3123, 5649, 63, 533, 26, 437, 5516, 402, 12178, 5649, 14, 2399, 1275, 3179, 1779, 2225, 1077, 769, 2399, 4534, 14, 267, 408, 267, 367, 3878, 315, 3123, 5649, 63, 533, 14, 3179, 26, 288, 291, 14, 20968, 63, 509, 63, 4445, 59, 4445, 1055, 3176, 8, 16, 12, 3123, 5649, 63, 533, 9, 267, 291, 14, 20968, 14, 3176, 8, 16, 12, 3123, 5649, 63, 533, 9, 339, 347, 4237, 8, 277, 12, 627, 3179, 304, 267, 408, 20926, 1536, 282, 12178, 6437, 5516, 543, 314, 6387, 4534, 14, 398, 520, 635, 4534, 26, 437, 769, 402, 4534, 370, 3648, 367, 14, 982, 7179, 787, 288, 2741, 12, 314, 4750, 23568, 7264, 12178, 6437, 5516, 288, 911, 506, 1202, 14, 267, 520, 1107, 26, 437, 12178, 6437, 5516, 12, 503, 488, 340, 2337, 1159, 949, 288, 7264, 5516, 543, 1006, 314, 5839, 4534, 14, 267, 408, 267, 340, 822, 8, 277, 14, 20968, 9, 508, 378, 26, 288, 327, 6006, 787, 949, 27378, 737, 1006, 14, 288, 372, 488, 398, 340, 822, 8, 3179, 9, 508, 378, 26, 288, 327, 9322, 9980, 1133, 7198, 367, 1263, 4534, 14, 25495, 3062, 314, 4750, 288, 327, 23568, 7264, 6545, 14, 288, 372, 291, 14, 20968, 59, 16, 61, 398, 327, 3971, 3224, 314, 769, 402, 4534, 315, 1865, 12, 436, 20714, 323, 1263, 27378, 267, 327, 626, 2793, 1133, 1336, 4036, 3878, 14, 267, 4534, 275, 769, 8, 3179, 9, 267, 4534, 14, 4471, 342, 267, 15101, 275, 488, 267, 7627, 63, 409, 275, 488, 267, 1830, 822, 8, 3179, 9, 690, 378, 26, 288, 3878, 275, 4534, 14, 1935, 342, 288, 781, 63, 7804, 63, 1589, 63, 4445, 275, 291, 14, 20968, 63, 509, 63, 4445, 14, 362, 8, 4445, 12, 3073, 288, 340, 822, 8, 1129, 63, 7804, 63, 1589, 63, 4445, 9, 690, 378, 26, 355, 340, 15101, 365, 488, 26, 490, 15101, 275, 781, 63, 7804, 63, 1589, 63, 4445, 490, 7627, 63, 409, 275, 663, 8, 16389, 9, 355, 587, 26, 490, 327, 662, 13769, 323, 1263, 15101, 626, 2793, 1133, 1172, 642, 3878, 14, 490, 7627, 63, 409, 275, 7627, 63, 409, 14, 12569, 8, 717, 663, 8, 1129, 63, 7804, 63, 1589, 63, 4445, 430, 398, 327, 710, 1454, 1686, 15101, 787, 314, 7869, 315, 7627, 63, 409, 14, 267, 327, 3971, 4012, 314, 3379, 769, 402, 15101, 436, 3732, 314, 1642, 1373, 267, 327, 626, 1159, 315, 7627, 63, 409, 14, 267, 340, 7627, 63, 409, 365, 488, 26, 288, 372, 488, 267, 367, 7627, 315, 15101, 26, 288, 340, 7627, 315, 7627, 63, 409, 26, 355, 372, 7627, 267, 372, 488, 199, 199, 3, 710, 17132, 1021, 911, 5452, 3878, 5548, 687, 19782, 436, 675, 3062, 199, 3, 370, 3648, 1536, 27378, 315, 642, 7086, 14, 199, 5649, 63, 5189, 275, 12178, 6437, 10899, 342, 199, 199, 533, 12178, 6437, 8, 785, 304, 272, 408, 16838, 282, 25884, 2213, 1901, 282, 14562, 28028, 909, 3123, 1041, 339, 13637, 275, 7369, 5912, 3123, 6545, 8480, 272, 12112, 7689, 1951, 63, 14546, 275, 942, 272, 4534, 275, 942, 339, 365, 63, 1652, 275, 756, 272, 3732, 76, 461, 275, 756, 272, 2701, 63, 2108, 63, 2969, 275, 488, 327, 437, 1947, 911, 506, 8652, 376, 2701, 13, 2108, 2892, 327, 1947, 1380, 436, 1454, 1380, 652, 965, 949, 4072, 14, 2286, 327, 437, 574, 367, 3520, 1947, 15, 3215, 15821, 365, 282, 4601, 13, 503, 272, 327, 10029, 13, 12794, 769, 402, 445, 3998, 12, 7830, 2419, 282, 2849, 445, 3998, 14, 272, 6186, 63, 14049, 63, 4924, 63, 18166, 275, 1052, 339, 327, 24403, 1077, 506, 17731, 6272, 3520, 3762, 14, 272, 6186, 63, 14956, 540, 2524, 63, 20620, 63, 17626, 275, 663, 342, 339, 327, 710, 25884, 4072, 402, 3762, 543, 3520, 1561, 1077, 506, 272, 327, 17544, 543, 2005, 1021, 1163, 2419, 20721, 16725, 1558, 14, 272, 6186, 63, 5353, 63, 25207, 3960, 275, 1052, 2286, 4815, 63, 3472, 275, 909, 342, 339, 327, 17536, 21295, 2793, 1133, 4215, 4426, 402, 1004, 5579, 14, 272, 9074, 3099, 51, 63, 6174, 63, 8861, 3960, 275, 756, 2286, 347, 636, 826, 721, 277, 12, 3510, 63, 16611, 63, 2987, 29, 4701, 63, 3472, 12, 326, 11211, 63, 8506, 63, 2969, 29, 4701, 63, 3472, 12, 326, 3877, 63, 604, 63, 10548, 29, 4701, 63, 3472, 12, 326, 1059, 63, 13577, 29, 4701, 63, 3472, 12, 272, 3461, 267, 408, 11447, 14, 398, 520, 635, 3510, 63, 16611, 63, 2987, 26, 982, 642, 365, 663, 370, 488, 12, 314, 268, 12178, 6437, 911, 440, 7485, 1263, 1338, 367, 3004, 2839, 268, 283, 533, 7, 1901, 5548, 14, 13510, 642, 370, 282, 2600, 911, 268, 17551, 642, 5953, 27, 0 ]
[ 1, 1, 1, 1, 1,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test-suite
misc/webapi-service-tests/inst.py
5
3206
#!/usr/bin/env python import os import shutil import glob import time import sys import subprocess from optparse import OptionParser, make_option SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) PARAMETERS = None ADB_CMD = "adb" def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it print "-->> \"%s\"" % cmd output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: output_line = cmd_proc.stdout.readline().strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break sys.stdout.write("%s\n" % output_line) sys.stdout.flush() output.append(output_line) return (cmd_return_code, output) def uninstPKGs(): action_status = True for root, dirs, files in os.walk(SCRIPT_DIR): for file in files: if file.endswith(".apk"): cmd = "%s -s %s uninstall org.xwalk.%s" % ( ADB_CMD, PARAMETERS.device, os.path.basename(os.path.splitext(file)[0])) print cmd (return_code, output) = doCMD(cmd) for line in output: if "Failure" in line: action_status = False break return action_status def instPKGs(): action_status = True for root, dirs, files in os.walk(SCRIPT_DIR): for file in files: if file.endswith(".apk"): cmd = "%s -s %s install %s" % (ADB_CMD, PARAMETERS.device, os.path.join(root, file)) (return_code, output) = doCMD(cmd) for line in output: if "Failure" in line: action_status = False break return action_status def main(): try: usage = "usage: inst.py -i" opts_parser = OptionParser(usage=usage) opts_parser.add_option( "-s", dest="device", action="store", help="Specify device") opts_parser.add_option( "-i", dest="binstpkg", action="store_true", help="Install package") opts_parser.add_option( "-u", dest="buninstpkg", action="store_true", help="Uninstall package") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() except Exception, e: print "Got wrong option: %s, exit ..." % e sys.exit(1) if not PARAMETERS.device: (return_code, output) = doCMD("adb devices") for line in output: if str.find(line, "\tdevice") != -1: PARAMETERS.device = line.split("\t")[0] break if not PARAMETERS.device: print "No device found" sys.exit(1) if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: print "-i and -u are conflict" sys.exit(1) if PARAMETERS.buninstpkg: if not uninstPKGs(): sys.exit(1) else: if not instPKGs(): sys.exit(1) if __name__ == "__main__": main() sys.exit(0)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 5739, 199, 646, 900, 199, 646, 984, 199, 646, 3873, 199, 504, 8691, 492, 13491, 12, 1852, 63, 1422, 421, 199, 10484, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 24014, 275, 488, 199, 1554, 34, 63, 9744, 275, 298, 13741, 2, 421, 199, 318, 886, 9744, 8, 1760, 304, 272, 327, 4226, 440, 1929, 2429, 2653, 315, 642, 3974, 2884, 12, 4691, 4744, 886, 652, 272, 870, 4320, 1140, 18321, 83, 18781, 450, 2088, 272, 1072, 275, 942, 272, 2088, 63, 1107, 63, 600, 275, 413, 272, 2088, 63, 4687, 275, 3873, 14, 7942, 8, 267, 2088, 12, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 13850, 12, 5218, 29, 549, 9, 339, 1830, 715, 26, 267, 1072, 63, 604, 275, 2088, 63, 4687, 14, 2703, 14, 6407, 1252, 1913, 4582, 82, 60, 78, 531, 267, 2088, 63, 1107, 63, 600, 275, 2088, 63, 4687, 14, 6843, 342, 267, 340, 1072, 63, 604, 508, 2125, 436, 2088, 63, 1107, 63, 600, 1137, 488, 26, 288, 2059, 267, 984, 14, 2703, 14, 952, 3647, 83, 60, 78, 2, 450, 1072, 63, 604, 9, 267, 984, 14, 2703, 14, 4939, 342, 267, 1072, 14, 740, 8, 1199, 63, 604, 9, 339, 372, 334, 1760, 63, 1107, 63, 600, 12, 1072, 9, 421, 199, 318, 625, 3615, 18150, 83, 837, 272, 1595, 63, 1205, 275, 715, 272, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 10484, 63, 3022, 304, 267, 367, 570, 315, 1584, 26, 288, 340, 570, 14, 4130, 9520, 23582, 2349, 355, 2088, 275, 2071, 83, 446, 83, 450, 83, 22199, 5981, 14, 88, 7757, 4111, 83, 2, 450, 334, 490, 437, 2846, 63, 9744, 12, 23710, 14, 1782, 12, 747, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 7973, 8, 493, 2788, 16, 2459, 355, 870, 2088, 355, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 355, 367, 1004, 315, 1072, 26, 490, 340, 298, 6782, 2, 315, 1004, 26, 717, 1595, 63, 1205, 275, 756, 717, 2059, 272, 372, 1595, 63, 1205, 421, 199, 318, 2727, 18150, 83, 837, 272, 1595, 63, 1205, 275, 715, 272, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 10484, 63, 3022, 304, 267, 367, 570, 315, 1584, 26, 288, 340, 570, 14, 4130, 9520, 23582, 2349, 355, 2088, 275, 2071, 83, 446, 83, 450, 83, 3907, 450, 83, 2, 450, 334, 1554, 34, 63, 9744, 12, 6901, 23710, 14, 1782, 12, 747, 14, 515, 14, 904, 8, 1231, 12, 570, 430, 355, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 355, 367, 1004, 315, 1072, 26, 490, 340, 298, 6782, 2, 315, 1004, 26, 717, 1595, 63, 1205, 275, 756, 717, 2059, 272, 372, 1595, 63, 1205, 421, 199, 318, 2446, 837, 272, 862, 26, 267, 4503, 275, 298, 3807, 26, 2727, 14, 647, 446, 73, 2, 267, 3999, 63, 2087, 275, 13491, 8, 3807, 29, 3807, 9, 267, 3999, 63, 2087, 14, 525, 63, 1422, 8, 288, 3905, 83, 401, 2053, 628, 1782, 401, 1595, 628, 1617, 401, 1720, 628, 17768, 2243, 531, 267, 3999, 63, 2087, 14, 525, 63, 1422, 8, 288, 3905, 73, 401, 2053, 628, 1393, 270, 4600, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 8154, 2559, 531, 267, 3999, 63, 2087, 14, 525, 63, 1422, 8, 288, 3905, 85, 401, 2053, 628, 66, 324, 3615, 4600, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 1358, 3174, 2559, 531, 267, 2288, 23710, 267, 334, 24014, 12, 1249, 9, 275, 3999, 63, 2087, 14, 1122, 63, 589, 342, 272, 871, 2186, 12, 325, 26, 267, 870, 298, 13662, 6835, 945, 26, 450, 83, 12, 4458, 21742, 450, 325, 267, 984, 14, 2224, 8, 17, 9, 339, 340, 440, 23710, 14, 1782, 26, 267, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 480, 13741, 7256, 531, 267, 367, 1004, 315, 1072, 26, 288, 340, 620, 14, 1623, 8, 604, 12, 1867, 84, 1782, 531, 1137, 446, 17, 26, 355, 23710, 14, 1782, 275, 1004, 14, 1294, 4582, 84, 9981, 16, 61, 355, 2059, 339, 340, 440, 23710, 14, 1782, 26, 267, 870, 298, 1944, 2243, 1911, 2, 267, 984, 14, 2224, 8, 17, 9, 339, 340, 23710, 14, 1393, 270, 4600, 436, 23710, 14, 66, 324, 3615, 4600, 26, 267, 870, 3905, 73, 436, 446, 85, 787, 12395, 2, 267, 984, 14, 2224, 8, 17, 9, 339, 340, 23710, 14, 66, 324, 3615, 4600, 26, 267, 340, 440, 625, 3615, 18150, 83, 837, 288, 984, 14, 2224, 8, 17, 9, 272, 587, 26, 267, 340, 440, 2727, 18150, 83, 837, 288, 984, 14, 2224, 8, 17, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 272, 984, 14, 2224, 8, 16, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 5739, 199, 646, 900, 199, 646, 984, 199, 646, 3873, 199, 504, 8691, 492, 13491, 12, 1852, 63, 1422, 421, 199, 10484, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 24014, 275, 488, 199, 1554, 34, 63, 9744, 275, 298, 13741, 2, 421, 199, 318, 886, 9744, 8, 1760, 304, 272, 327, 4226, 440, 1929, 2429, 2653, 315, 642, 3974, 2884, 12, 4691, 4744, 886, 652, 272, 870, 4320, 1140, 18321, 83, 18781, 450, 2088, 272, 1072, 275, 942, 272, 2088, 63, 1107, 63, 600, 275, 413, 272, 2088, 63, 4687, 275, 3873, 14, 7942, 8, 267, 2088, 12, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 13850, 12, 5218, 29, 549, 9, 339, 1830, 715, 26, 267, 1072, 63, 604, 275, 2088, 63, 4687, 14, 2703, 14, 6407, 1252, 1913, 4582, 82, 60, 78, 531, 267, 2088, 63, 1107, 63, 600, 275, 2088, 63, 4687, 14, 6843, 342, 267, 340, 1072, 63, 604, 508, 2125, 436, 2088, 63, 1107, 63, 600, 1137, 488, 26, 288, 2059, 267, 984, 14, 2703, 14, 952, 3647, 83, 60, 78, 2, 450, 1072, 63, 604, 9, 267, 984, 14, 2703, 14, 4939, 342, 267, 1072, 14, 740, 8, 1199, 63, 604, 9, 339, 372, 334, 1760, 63, 1107, 63, 600, 12, 1072, 9, 421, 199, 318, 625, 3615, 18150, 83, 837, 272, 1595, 63, 1205, 275, 715, 272, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 10484, 63, 3022, 304, 267, 367, 570, 315, 1584, 26, 288, 340, 570, 14, 4130, 9520, 23582, 2349, 355, 2088, 275, 2071, 83, 446, 83, 450, 83, 22199, 5981, 14, 88, 7757, 4111, 83, 2, 450, 334, 490, 437, 2846, 63, 9744, 12, 23710, 14, 1782, 12, 747, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 7973, 8, 493, 2788, 16, 2459, 355, 870, 2088, 355, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 355, 367, 1004, 315, 1072, 26, 490, 340, 298, 6782, 2, 315, 1004, 26, 717, 1595, 63, 1205, 275, 756, 717, 2059, 272, 372, 1595, 63, 1205, 421, 199, 318, 2727, 18150, 83, 837, 272, 1595, 63, 1205, 275, 715, 272, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 10484, 63, 3022, 304, 267, 367, 570, 315, 1584, 26, 288, 340, 570, 14, 4130, 9520, 23582, 2349, 355, 2088, 275, 2071, 83, 446, 83, 450, 83, 3907, 450, 83, 2, 450, 334, 1554, 34, 63, 9744, 12, 6901, 23710, 14, 1782, 12, 747, 14, 515, 14, 904, 8, 1231, 12, 570, 430, 355, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 355, 367, 1004, 315, 1072, 26, 490, 340, 298, 6782, 2, 315, 1004, 26, 717, 1595, 63, 1205, 275, 756, 717, 2059, 272, 372, 1595, 63, 1205, 421, 199, 318, 2446, 837, 272, 862, 26, 267, 4503, 275, 298, 3807, 26, 2727, 14, 647, 446, 73, 2, 267, 3999, 63, 2087, 275, 13491, 8, 3807, 29, 3807, 9, 267, 3999, 63, 2087, 14, 525, 63, 1422, 8, 288, 3905, 83, 401, 2053, 628, 1782, 401, 1595, 628, 1617, 401, 1720, 628, 17768, 2243, 531, 267, 3999, 63, 2087, 14, 525, 63, 1422, 8, 288, 3905, 73, 401, 2053, 628, 1393, 270, 4600, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 8154, 2559, 531, 267, 3999, 63, 2087, 14, 525, 63, 1422, 8, 288, 3905, 85, 401, 2053, 628, 66, 324, 3615, 4600, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 1358, 3174, 2559, 531, 267, 2288, 23710, 267, 334, 24014, 12, 1249, 9, 275, 3999, 63, 2087, 14, 1122, 63, 589, 342, 272, 871, 2186, 12, 325, 26, 267, 870, 298, 13662, 6835, 945, 26, 450, 83, 12, 4458, 21742, 450, 325, 267, 984, 14, 2224, 8, 17, 9, 339, 340, 440, 23710, 14, 1782, 26, 267, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 480, 13741, 7256, 531, 267, 367, 1004, 315, 1072, 26, 288, 340, 620, 14, 1623, 8, 604, 12, 1867, 84, 1782, 531, 1137, 446, 17, 26, 355, 23710, 14, 1782, 275, 1004, 14, 1294, 4582, 84, 9981, 16, 61, 355, 2059, 339, 340, 440, 23710, 14, 1782, 26, 267, 870, 298, 1944, 2243, 1911, 2, 267, 984, 14, 2224, 8, 17, 9, 339, 340, 23710, 14, 1393, 270, 4600, 436, 23710, 14, 66, 324, 3615, 4600, 26, 267, 870, 3905, 73, 436, 446, 85, 787, 12395, 2, 267, 984, 14, 2224, 8, 17, 9, 339, 340, 23710, 14, 66, 324, 3615, 4600, 26, 267, 340, 440, 625, 3615, 18150, 83, 837, 288, 984, 14, 2224, 8, 17, 9, 272, 587, 26, 267, 340, 440, 2727, 18150, 83, 837, 288, 984, 14, 2224, 8, 17, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 272, 984, 14, 2224, 8, 16, 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, 0 ]
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0 ]
Brett777/Predict-Risk
ApprovalModel.py
1
1979
# coding: utf-8 # In[ ]: import h2o import pandas as pd # initialize the model scoring server h2o.init(nthreads=1,max_mem_size=1, start_h2o=True, strict_version_check = False) def approve_loan(Loan_Amount,Term,Interest_Rate,Employment_Years,Home_Ownership,Annual_Income,Verification_Status,Loan_Purpose,State, Debt_to_Income,Delinquent_2yr,Revolving_Cr_Util,Total_Accounts,Longest_Credit_Length): # connect to the model scoring service h2o.connect() # open the downloaded model ChurnPredictor = h2o.load_model(path='DRF_model_1496459915419_4') # define a feature vector to evaluate with the model newData = pd.DataFrame({'Loan_Amount' : Loan_Amount, 'Term' : Term, 'Interest_Rate' : Interest_Rate, 'Employment_Years' : Employment_Years, 'Home_Ownership' : Home_Ownership, 'Annual_Income' : Annual_Income, 'Verification_Status' : Verification_Status, 'Loan_Purpose' : Loan_Purpose, 'State' : State, 'Debt_to_Income' : Debt_to_Income, 'Delinquent_2yr' : Delinquent_2yr, 'Revolving_Cr_Util' : Revolving_Cr_Util, 'Total_Accounts' : Total_Accounts, 'Longest_Credit_Length' : Longest_Credit_Length}, index=[0]) # evaluate the feature vector using the model predictions = ChurnPredictor.predict(h2o.H2OFrame(newData)) predictionsOut = h2o.as_list(predictions, use_pandas=False) prediction = predictionsOut[1][0] probabilityBad = predictionsOut[1][1] probabilityGood = predictionsOut[1][2] return "Prediction: " + str(prediction) + " |Probability of Bad Loan: " + str(probabilityBad) + " |Probability of Good Loan: " + str(probabilityGood)
apache-2.0
[ 199, 3, 2803, 26, 2774, 13, 24, 199, 199, 3, 1010, 59, 16246, 199, 199, 646, 394, 18, 79, 199, 646, 10634, 465, 6454, 199, 199, 3, 8265, 314, 1402, 24153, 1654, 199, 72, 18, 79, 14, 826, 8, 78, 6962, 29, 17, 12, 988, 63, 5286, 63, 890, 29, 17, 12, 1343, 63, 72, 18, 79, 29, 549, 12, 7478, 63, 1023, 63, 1074, 275, 756, 9, 199, 199, 318, 4286, 432, 63, 320, 290, 8, 2041, 290, 63, 18785, 12, 21676, 12, 8309, 3911, 63, 6621, 12, 37, 311, 7775, 63, 15731, 83, 12, 12054, 63, 14919, 3319, 12, 2493, 78, 1061, 63, 607, 4352, 12, 22595, 63, 3694, 12, 2041, 290, 63, 14959, 4070, 12, 2223, 12, 326, 1487, 13061, 63, 475, 63, 607, 4352, 12, 6994, 262, 9333, 63, 18, 21897, 12, 497, 5650, 4007, 63, 17345, 63, 9562, 12, 7316, 63, 30682, 12, 31253, 3199, 63, 27228, 63, 4625, 304, 272, 327, 4907, 370, 314, 1402, 24153, 2435, 272, 394, 18, 79, 14, 2242, 342, 339, 327, 1551, 314, 13557, 1402, 272, 2799, 349, 14730, 630, 275, 394, 18, 79, 14, 912, 63, 1238, 8, 515, 534, 4564, 38, 63, 1238, 63, 10721, 13067, 1020, 10478, 1167, 63, 20, 358, 18407, 327, 5627, 282, 3878, 5477, 370, 9352, 543, 314, 1402, 272, 892, 1451, 275, 6454, 14, 9205, 3252, 2041, 290, 63, 18785, 7, 520, 3835, 290, 63, 18785, 12, 1169, 283, 21676, 7, 520, 13861, 77, 12, 1169, 283, 8309, 3911, 63, 6621, 7, 520, 8883, 3911, 63, 6621, 12, 1169, 283, 37, 311, 7775, 63, 15731, 83, 7, 520, 662, 311, 7775, 63, 15731, 83, 12, 1169, 283, 12054, 63, 14919, 3319, 7, 520, 14621, 63, 14919, 3319, 12, 1169, 283, 2493, 78, 1061, 63, 607, 4352, 7, 520, 1626, 78, 1061, 63, 607, 4352, 12, 1169, 283, 22595, 63, 3694, 7, 520, 5444, 7313, 63, 3694, 12, 1169, 283, 2041, 290, 63, 14959, 4070, 7, 520, 3835, 290, 63, 14959, 4070, 12, 1169, 283, 2223, 7, 520, 8511, 12, 1169, 283, 872, 13061, 63, 475, 63, 607, 4352, 7, 520, 1487, 13061, 63, 475, 63, 607, 4352, 12, 1169, 283, 6994, 262, 9333, 63, 18, 21897, 7, 520, 18464, 262, 9333, 63, 18, 21897, 12, 1169, 283, 497, 5650, 4007, 63, 17345, 63, 9562, 7, 520, 799, 5650, 4007, 63, 17345, 63, 9562, 12, 1169, 283, 7316, 63, 30682, 7, 520, 19271, 63, 30682, 12, 1169, 283, 31253, 3199, 63, 27228, 63, 4625, 7, 520, 491, 265, 3199, 63, 27228, 63, 4625, 1386, 1478, 1524, 16, 566, 2286, 327, 9352, 314, 3878, 5477, 1808, 314, 1402, 272, 7914, 275, 2799, 349, 14730, 630, 14, 6892, 8, 72, 18, 79, 14, 40, 18, 47, 3160, 8, 1222, 1451, 430, 272, 7914, 2204, 275, 394, 18, 79, 14, 305, 63, 513, 8, 9869, 12, 675, 63, 15718, 29, 797, 9, 272, 12044, 275, 7914, 2204, 59, 17, 1527, 16, 61, 272, 12224, 5725, 275, 7914, 2204, 59, 17, 1527, 17, 61, 272, 12224, 20652, 275, 7914, 2204, 59, 17, 1527, 18, 61, 272, 372, 298, 24261, 26, 298, 435, 620, 8, 14845, 9, 435, 298, 1204, 20122, 3616, 402, 8857, 3835, 290, 26, 298, 435, 620, 8, 17210, 5725, 9, 435, 298, 1204, 20122, 3616, 402, 22311, 3835, 290, 26, 298, 435, 620, 8, 17210, 20652, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3, 2803, 26, 2774, 13, 24, 199, 199, 3, 1010, 59, 16246, 199, 199, 646, 394, 18, 79, 199, 646, 10634, 465, 6454, 199, 199, 3, 8265, 314, 1402, 24153, 1654, 199, 72, 18, 79, 14, 826, 8, 78, 6962, 29, 17, 12, 988, 63, 5286, 63, 890, 29, 17, 12, 1343, 63, 72, 18, 79, 29, 549, 12, 7478, 63, 1023, 63, 1074, 275, 756, 9, 199, 199, 318, 4286, 432, 63, 320, 290, 8, 2041, 290, 63, 18785, 12, 21676, 12, 8309, 3911, 63, 6621, 12, 37, 311, 7775, 63, 15731, 83, 12, 12054, 63, 14919, 3319, 12, 2493, 78, 1061, 63, 607, 4352, 12, 22595, 63, 3694, 12, 2041, 290, 63, 14959, 4070, 12, 2223, 12, 326, 1487, 13061, 63, 475, 63, 607, 4352, 12, 6994, 262, 9333, 63, 18, 21897, 12, 497, 5650, 4007, 63, 17345, 63, 9562, 12, 7316, 63, 30682, 12, 31253, 3199, 63, 27228, 63, 4625, 304, 272, 327, 4907, 370, 314, 1402, 24153, 2435, 272, 394, 18, 79, 14, 2242, 342, 339, 327, 1551, 314, 13557, 1402, 272, 2799, 349, 14730, 630, 275, 394, 18, 79, 14, 912, 63, 1238, 8, 515, 534, 4564, 38, 63, 1238, 63, 10721, 13067, 1020, 10478, 1167, 63, 20, 358, 18407, 327, 5627, 282, 3878, 5477, 370, 9352, 543, 314, 1402, 272, 892, 1451, 275, 6454, 14, 9205, 3252, 2041, 290, 63, 18785, 7, 520, 3835, 290, 63, 18785, 12, 1169, 283, 21676, 7, 520, 13861, 77, 12, 1169, 283, 8309, 3911, 63, 6621, 7, 520, 8883, 3911, 63, 6621, 12, 1169, 283, 37, 311, 7775, 63, 15731, 83, 7, 520, 662, 311, 7775, 63, 15731, 83, 12, 1169, 283, 12054, 63, 14919, 3319, 7, 520, 14621, 63, 14919, 3319, 12, 1169, 283, 2493, 78, 1061, 63, 607, 4352, 7, 520, 1626, 78, 1061, 63, 607, 4352, 12, 1169, 283, 22595, 63, 3694, 7, 520, 5444, 7313, 63, 3694, 12, 1169, 283, 2041, 290, 63, 14959, 4070, 7, 520, 3835, 290, 63, 14959, 4070, 12, 1169, 283, 2223, 7, 520, 8511, 12, 1169, 283, 872, 13061, 63, 475, 63, 607, 4352, 7, 520, 1487, 13061, 63, 475, 63, 607, 4352, 12, 1169, 283, 6994, 262, 9333, 63, 18, 21897, 7, 520, 18464, 262, 9333, 63, 18, 21897, 12, 1169, 283, 497, 5650, 4007, 63, 17345, 63, 9562, 7, 520, 799, 5650, 4007, 63, 17345, 63, 9562, 12, 1169, 283, 7316, 63, 30682, 7, 520, 19271, 63, 30682, 12, 1169, 283, 31253, 3199, 63, 27228, 63, 4625, 7, 520, 491, 265, 3199, 63, 27228, 63, 4625, 1386, 1478, 1524, 16, 566, 2286, 327, 9352, 314, 3878, 5477, 1808, 314, 1402, 272, 7914, 275, 2799, 349, 14730, 630, 14, 6892, 8, 72, 18, 79, 14, 40, 18, 47, 3160, 8, 1222, 1451, 430, 272, 7914, 2204, 275, 394, 18, 79, 14, 305, 63, 513, 8, 9869, 12, 675, 63, 15718, 29, 797, 9, 272, 12044, 275, 7914, 2204, 59, 17, 1527, 16, 61, 272, 12224, 5725, 275, 7914, 2204, 59, 17, 1527, 17, 61, 272, 12224, 20652, 275, 7914, 2204, 59, 17, 1527, 18, 61, 272, 372, 298, 24261, 26, 298, 435, 620, 8, 14845, 9, 435, 298, 1204, 20122, 3616, 402, 8857, 3835, 290, 26, 298, 435, 620, 8, 17210, 5725, 9, 435, 298, 1204, 20122, 3616, 402, 22311, 3835, 290, 26, 298, 435, 620, 8, 17210, 20652, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
jborean93/ntlm-auth
tests/test_compute_hash.py
1
1658
import ntlm_auth.compute_hash as compute_hash class TestComputeHash(object): def test_lmowfv1(self): # 4.2.2.1.1 - LMOWFv1() expected = b"\xe5\x2c\xac\x67\x41\x9a\x9a\x22" \ b"\x4a\x3b\x10\x8f\x3f\xa6\xcb\x6d" actual = compute_hash._lmowfv1("Password") assert actual == expected def test_ntowfv1(self): # 4.2.2.1.2 - NTOWFv1() expected = b"\xa4\xf4\x9c\x40\x65\x10\xbd\xca" \ b"\xb6\x82\x4e\xe7\xc3\x0f\xd8\x52" actual = compute_hash._ntowfv1("Password") assert actual == expected def test_lmofv1_hash(self): # 4.2.2.1.1 - LMOWFv1() expected = b"\xe5\x2c\xac\x67\x41\x9a\x9a\x22" \ b"\x4a\x3b\x10\x8f\x3f\xa6\xcb\x6d" password_hash = "e52cac67419a9a224a3b108f3fa6cb6d:" \ "a4f49c406510bdcab6824ee7c30fd852" actual = compute_hash._lmowfv1(password_hash) assert actual == expected def test_ntowfv1_hash(self): # 4.2.2.1.2 - NTOWFv1() expected = b"\xa4\xf4\x9c\x40\x65\x10\xbd\xca" \ b"\xb6\x82\x4e\xe7\xc3\x0f\xd8\x52" password_hash = "e52cac67419a9a224a3b108f3fa6cb6d:" \ "a4f49c406510bdcab6824ee7c30fd852" actual = compute_hash._ntowfv1(password_hash) assert actual == expected def test_ntowfv2(self): # 4.2.4.1.1 - NTOWFv2() and LMOWFv2() expected = b"\x0c\x86\x8a\x40\x3b\xfd\x7a\x93" \ b"\xa3\x00\x1e\xf2\x2e\xf0\x2e\x3f" actual = compute_hash._ntowfv2("User", "Password", "Domain") assert actual == expected
mit
[ 646, 302, 5019, 77, 63, 1178, 14, 3357, 63, 2227, 465, 4526, 63, 2227, 421, 199, 533, 1379, 8564, 3476, 8, 785, 304, 339, 347, 511, 63, 76, 573, 87, 13692, 17, 8, 277, 304, 267, 327, 841, 14, 18, 14, 18, 14, 17, 14, 17, 446, 491, 2679, 29046, 86, 17, 342, 267, 1420, 275, 330, 3212, 1845, 21, 60, 88, 18, 67, 60, 10104, 60, 88, 1822, 60, 88, 2953, 60, 88, 25, 65, 60, 88, 25, 65, 60, 88, 1081, 2, 971, 673, 330, 3212, 88, 20, 65, 60, 88, 19, 66, 60, 88, 709, 60, 88, 24, 70, 60, 88, 19, 70, 60, 1800, 22, 60, 10351, 60, 88, 22, 68, 2, 267, 3503, 275, 4526, 63, 2227, 423, 76, 573, 87, 13692, 17, 480, 6139, 531, 267, 702, 3503, 508, 1420, 339, 347, 511, 63, 343, 583, 13692, 17, 8, 277, 304, 267, 327, 841, 14, 18, 14, 18, 14, 17, 14, 18, 446, 653, 2566, 29046, 86, 17, 342, 267, 1420, 275, 330, 3212, 1800, 20, 60, 1949, 20, 60, 88, 25, 67, 60, 88, 2167, 60, 88, 2182, 60, 88, 709, 60, 9826, 60, 10768, 2, 971, 673, 330, 3212, 1774, 22, 60, 88, 2564, 60, 88, 20, 69, 60, 1845, 23, 60, 1812, 19, 60, 88, 16, 70, 60, 2207, 24, 60, 88, 2528, 2, 267, 3503, 275, 4526, 63, 2227, 423, 343, 583, 13692, 17, 480, 6139, 531, 267, 702, 3503, 508, 1420, 339, 347, 511, 63, 76, 573, 13692, 17, 63, 2227, 8, 277, 304, 267, 327, 841, 14, 18, 14, 18, 14, 17, 14, 17, 446, 491, 2679, 29046, 86, 17, 342, 267, 1420, 275, 330, 3212, 1845, 21, 60, 88, 18, 67, 60, 10104, 60, 88, 1822, 60, 88, 2953, 60, 88, 25, 65, 60, 88, 25, 65, 60, 88, 1081, 2, 971, 673, 330, 3212, 88, 20, 65, 60, 88, 19, 66, 60, 88, 709, 60, 88, 24, 70, 60, 88, 19, 70, 60, 1800, 22, 60, 10351, 60, 88, 22, 68, 2, 267, 2505, 63, 2227, 275, 298, 69, 2528, 11055, 10393, 1167, 65, 25, 65, 8731, 65, 19, 66, 8079, 70, 19, 667, 22, 2894, 22, 68, 5424, 971, 717, 298, 65, 20, 70, 1887, 67, 13344, 27161, 3691, 26481, 2333, 1194, 1024, 23, 67, 1216, 2592, 22719, 2, 267, 3503, 275, 4526, 63, 2227, 423, 76, 573, 87, 13692, 17, 8, 2060, 63, 2227, 9, 267, 702, 3503, 508, 1420, 339, 347, 511, 63, 343, 583, 13692, 17, 63, 2227, 8, 277, 304, 267, 327, 841, 14, 18, 14, 18, 14, 17, 14, 18, 446, 653, 2566, 29046, 86, 17, 342, 267, 1420, 275, 330, 3212, 1800, 20, 60, 1949, 20, 60, 88, 25, 67, 60, 88, 2167, 60, 88, 2182, 60, 88, 709, 60, 9826, 60, 10768, 2, 971, 673, 330, 3212, 1774, 22, 60, 88, 2564, 60, 88, 20, 69, 60, 1845, 23, 60, 1812, 19, 60, 88, 16, 70, 60, 2207, 24, 60, 88, 2528, 2, 267, 2505, 63, 2227, 275, 298, 69, 2528, 11055, 10393, 1167, 65, 25, 65, 8731, 65, 19, 66, 8079, 70, 19, 667, 22, 2894, 22, 68, 5424, 971, 717, 298, 65, 20, 70, 1887, 67, 13344, 27161, 3691, 26481, 2333, 1194, 1024, 23, 67, 1216, 2592, 22719, 2, 267, 3503, 275, 4526, 63, 2227, 423, 343, 583, 13692, 17, 8, 2060, 63, 2227, 9, 267, 702, 3503, 508, 1420, 339, 347, 511, 63, 343, 583, 13692, 18, 8, 277, 304, 267, 327, 841, 14, 18, 14, 20, 14, 17, 14, 17, 446, 653, 2566, 29046, 86, 18, 342, 436, 491, 2679, 29046, 86, 18, 342, 267, 1420, 275, 330, 3212, 88, 16, 67, 60, 88, 1184, 60, 88, 24, 65, 60, 88, 2167, 60, 88, 19, 66, 60, 11208, 60, 88, 23, 65, 60, 88, 3129, 2, 971, 673, 330, 3212, 1800, 19, 60, 88, 383, 60, 88, 17, 69, 60, 1949, 18, 60, 88, 18, 69, 60, 1949, 16, 60, 88, 18, 69, 60, 88, 19, 70, 2, 267, 3503, 275, 4526, 63, 2227, 423, 343, 583, 13692, 18, 480, 1899, 401, 298, 6139, 401, 298, 7705, 531, 267, 702, 3503, 508, 1420, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 302, 5019, 77, 63, 1178, 14, 3357, 63, 2227, 465, 4526, 63, 2227, 421, 199, 533, 1379, 8564, 3476, 8, 785, 304, 339, 347, 511, 63, 76, 573, 87, 13692, 17, 8, 277, 304, 267, 327, 841, 14, 18, 14, 18, 14, 17, 14, 17, 446, 491, 2679, 29046, 86, 17, 342, 267, 1420, 275, 330, 3212, 1845, 21, 60, 88, 18, 67, 60, 10104, 60, 88, 1822, 60, 88, 2953, 60, 88, 25, 65, 60, 88, 25, 65, 60, 88, 1081, 2, 971, 673, 330, 3212, 88, 20, 65, 60, 88, 19, 66, 60, 88, 709, 60, 88, 24, 70, 60, 88, 19, 70, 60, 1800, 22, 60, 10351, 60, 88, 22, 68, 2, 267, 3503, 275, 4526, 63, 2227, 423, 76, 573, 87, 13692, 17, 480, 6139, 531, 267, 702, 3503, 508, 1420, 339, 347, 511, 63, 343, 583, 13692, 17, 8, 277, 304, 267, 327, 841, 14, 18, 14, 18, 14, 17, 14, 18, 446, 653, 2566, 29046, 86, 17, 342, 267, 1420, 275, 330, 3212, 1800, 20, 60, 1949, 20, 60, 88, 25, 67, 60, 88, 2167, 60, 88, 2182, 60, 88, 709, 60, 9826, 60, 10768, 2, 971, 673, 330, 3212, 1774, 22, 60, 88, 2564, 60, 88, 20, 69, 60, 1845, 23, 60, 1812, 19, 60, 88, 16, 70, 60, 2207, 24, 60, 88, 2528, 2, 267, 3503, 275, 4526, 63, 2227, 423, 343, 583, 13692, 17, 480, 6139, 531, 267, 702, 3503, 508, 1420, 339, 347, 511, 63, 76, 573, 13692, 17, 63, 2227, 8, 277, 304, 267, 327, 841, 14, 18, 14, 18, 14, 17, 14, 17, 446, 491, 2679, 29046, 86, 17, 342, 267, 1420, 275, 330, 3212, 1845, 21, 60, 88, 18, 67, 60, 10104, 60, 88, 1822, 60, 88, 2953, 60, 88, 25, 65, 60, 88, 25, 65, 60, 88, 1081, 2, 971, 673, 330, 3212, 88, 20, 65, 60, 88, 19, 66, 60, 88, 709, 60, 88, 24, 70, 60, 88, 19, 70, 60, 1800, 22, 60, 10351, 60, 88, 22, 68, 2, 267, 2505, 63, 2227, 275, 298, 69, 2528, 11055, 10393, 1167, 65, 25, 65, 8731, 65, 19, 66, 8079, 70, 19, 667, 22, 2894, 22, 68, 5424, 971, 717, 298, 65, 20, 70, 1887, 67, 13344, 27161, 3691, 26481, 2333, 1194, 1024, 23, 67, 1216, 2592, 22719, 2, 267, 3503, 275, 4526, 63, 2227, 423, 76, 573, 87, 13692, 17, 8, 2060, 63, 2227, 9, 267, 702, 3503, 508, 1420, 339, 347, 511, 63, 343, 583, 13692, 17, 63, 2227, 8, 277, 304, 267, 327, 841, 14, 18, 14, 18, 14, 17, 14, 18, 446, 653, 2566, 29046, 86, 17, 342, 267, 1420, 275, 330, 3212, 1800, 20, 60, 1949, 20, 60, 88, 25, 67, 60, 88, 2167, 60, 88, 2182, 60, 88, 709, 60, 9826, 60, 10768, 2, 971, 673, 330, 3212, 1774, 22, 60, 88, 2564, 60, 88, 20, 69, 60, 1845, 23, 60, 1812, 19, 60, 88, 16, 70, 60, 2207, 24, 60, 88, 2528, 2, 267, 2505, 63, 2227, 275, 298, 69, 2528, 11055, 10393, 1167, 65, 25, 65, 8731, 65, 19, 66, 8079, 70, 19, 667, 22, 2894, 22, 68, 5424, 971, 717, 298, 65, 20, 70, 1887, 67, 13344, 27161, 3691, 26481, 2333, 1194, 1024, 23, 67, 1216, 2592, 22719, 2, 267, 3503, 275, 4526, 63, 2227, 423, 343, 583, 13692, 17, 8, 2060, 63, 2227, 9, 267, 702, 3503, 508, 1420, 339, 347, 511, 63, 343, 583, 13692, 18, 8, 277, 304, 267, 327, 841, 14, 18, 14, 20, 14, 17, 14, 17, 446, 653, 2566, 29046, 86, 18, 342, 436, 491, 2679, 29046, 86, 18, 342, 267, 1420, 275, 330, 3212, 88, 16, 67, 60, 88, 1184, 60, 88, 24, 65, 60, 88, 2167, 60, 88, 19, 66, 60, 11208, 60, 88, 23, 65, 60, 88, 3129, 2, 971, 673, 330, 3212, 1800, 19, 60, 88, 383, 60, 88, 17, 69, 60, 1949, 18, 60, 88, 18, 69, 60, 1949, 16, 60, 88, 18, 69, 60, 88, 19, 70, 2, 267, 3503, 275, 4526, 63, 2227, 423, 343, 583, 13692, 18, 480, 1899, 401, 298, 6139, 401, 298, 7705, 531, 267, 702, 3503, 508, 1420, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type from ansible import constants as C from ansible import context from ansible.errors import AnsibleParserError from ansible.playbook.attribute import FieldAttribute from ansible.utils.display import Display display = Display() class Become: # Privilege escalation _become = FieldAttribute(isa='bool', default=context.cliargs_deferred_get('become')) _become_method = FieldAttribute(isa='string', default=context.cliargs_deferred_get('become_method')) _become_user = FieldAttribute(isa='string', default=context.cliargs_deferred_get('become_user')) _become_flags = FieldAttribute(isa='string') def __init__(self): super(Become, self).__init__() def _detect_privilege_escalation_conflict(self, ds): # Fail out if user specifies conflicting privilege escalations has_become = 'become' in ds or 'become_user'in ds has_sudo = 'sudo' in ds or 'sudo_user' in ds has_su = 'su' in ds or 'su_user' in ds if has_become: msg = 'The become params ("become", "become_user") and' if has_sudo: raise AnsibleParserError('%s sudo params ("sudo", "sudo_user") cannot be used together' % msg) elif has_su: raise AnsibleParserError('%s su params ("su", "su_user") cannot be used together' % msg) elif has_sudo and has_su: raise AnsibleParserError('sudo params ("sudo", "sudo_user") and su params ("su", "su_user") cannot be used together') def _preprocess_data_become(self, ds): """Preprocess the playbook data for become attributes This is called from the Base object's preprocess_data() method which in turn is called pretty much anytime any sort of playbook object (plays, tasks, blocks, etc) is created. """ self._detect_privilege_escalation_conflict(ds) # Privilege escalation, backwards compatibility for sudo/su if 'sudo' in ds or 'sudo_user' in ds: ds['become_method'] = 'sudo' if 'sudo' in ds: ds['become'] = ds['sudo'] del ds['sudo'] if 'sudo_user' in ds: ds['become_user'] = ds['sudo_user'] del ds['sudo_user'] display.deprecated("Instead of sudo/sudo_user, use become/become_user and make sure become_method is 'sudo' (default)", '2.9') elif 'su' in ds or 'su_user' in ds: ds['become_method'] = 'su' if 'su' in ds: ds['become'] = ds['su'] del ds['su'] if 'su_user' in ds: ds['become_user'] = ds['su_user'] del ds['su_user'] display.deprecated("Instead of su/su_user, use become/become_user and set become_method to 'su' (default is sudo)", '2.9') return ds
gpl-3.0
[ 3, 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 492, 1067, 199, 504, 3242, 14, 2550, 492, 31775, 199, 504, 3242, 14, 14205, 14, 3215, 492, 5024, 1646, 199, 504, 3242, 14, 1208, 14, 2918, 492, 12175, 199, 199, 2918, 275, 12175, 342, 421, 199, 533, 6423, 4352, 26, 339, 327, 8538, 17228, 325, 4732, 425, 272, 485, 13970, 275, 5024, 1646, 8, 13655, 534, 2245, 297, 849, 29, 1100, 14, 2764, 589, 63, 12116, 63, 362, 360, 13970, 1333, 272, 485, 13970, 63, 765, 275, 5024, 1646, 8, 13655, 534, 875, 297, 849, 29, 1100, 14, 2764, 589, 63, 12116, 63, 362, 360, 13970, 63, 765, 1333, 272, 485, 13970, 63, 751, 275, 5024, 1646, 8, 13655, 534, 875, 297, 849, 29, 1100, 14, 2764, 589, 63, 12116, 63, 362, 360, 13970, 63, 751, 1333, 272, 485, 13970, 63, 2469, 275, 5024, 1646, 8, 13655, 534, 875, 358, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 3655, 4352, 12, 291, 2843, 826, 4533, 339, 347, 485, 13552, 63, 1359, 17228, 63, 397, 915, 425, 63, 15207, 8, 277, 12, 6364, 304, 398, 327, 12176, 734, 340, 922, 9314, 28204, 1979, 17228, 325, 4732, 1298, 267, 965, 63, 13970, 275, 283, 13970, 7, 315, 6364, 503, 283, 13970, 63, 751, 7, 262, 6364, 267, 965, 63, 12095, 275, 283, 12095, 7, 315, 6364, 503, 283, 12095, 63, 751, 7, 315, 6364, 267, 965, 63, 9648, 275, 283, 9648, 7, 315, 6364, 503, 283, 9648, 63, 751, 7, 315, 6364, 398, 340, 965, 63, 13970, 26, 288, 1499, 275, 283, 1918, 8649, 1862, 1689, 13970, 401, 298, 13970, 63, 751, 531, 436, 7, 288, 340, 965, 63, 12095, 26, 355, 746, 31775, 3508, 83, 14682, 1862, 1689, 12095, 401, 298, 12095, 63, 751, 531, 3913, 506, 1202, 10451, 7, 450, 1499, 9, 288, 916, 965, 63, 9648, 26, 355, 746, 31775, 3508, 83, 18741, 1862, 1689, 9648, 401, 298, 9648, 63, 751, 531, 3913, 506, 1202, 10451, 7, 450, 1499, 9, 267, 916, 965, 63, 12095, 436, 965, 63, 9648, 26, 288, 746, 31775, 360, 12095, 1862, 1689, 12095, 401, 298, 12095, 63, 751, 531, 436, 18741, 1862, 1689, 9648, 401, 298, 9648, 63, 751, 531, 3913, 506, 1202, 10451, 358, 339, 347, 485, 17677, 63, 576, 63, 13970, 8, 277, 12, 6364, 304, 267, 408, 26539, 314, 15695, 666, 367, 8649, 3004, 398, 961, 365, 2797, 687, 314, 3523, 909, 1159, 23351, 63, 576, 342, 1083, 1314, 267, 315, 7485, 365, 2797, 7268, 8298, 1263, 521, 1263, 4069, 402, 15695, 909, 267, 334, 20591, 12, 6527, 12, 5664, 12, 5423, 9, 365, 2737, 14, 267, 408, 398, 291, 423, 13552, 63, 1359, 17228, 63, 397, 915, 425, 63, 15207, 8, 795, 9, 398, 327, 8538, 17228, 325, 4732, 425, 12, 8552, 7163, 367, 14682, 15, 9648, 267, 340, 283, 12095, 7, 315, 6364, 503, 283, 12095, 63, 751, 7, 315, 6364, 26, 288, 6364, 459, 13970, 63, 765, 418, 275, 283, 12095, 7, 288, 340, 283, 12095, 7, 315, 6364, 26, 355, 6364, 459, 13970, 418, 275, 6364, 459, 12095, 418, 355, 2150, 6364, 459, 12095, 418, 953, 340, 283, 12095, 63, 751, 7, 315, 6364, 26, 355, 6364, 459, 13970, 63, 751, 418, 275, 6364, 459, 12095, 63, 751, 418, 355, 2150, 6364, 459, 12095, 63, 751, 418, 953, 2929, 14, 6667, 480, 13962, 13558, 402, 14682, 15, 12095, 63, 751, 12, 675, 8649, 15, 13970, 63, 751, 436, 1852, 3238, 8649, 63, 765, 365, 283, 12095, 7, 334, 885, 4186, 283, 18, 14, 25, 358, 398, 916, 283, 9648, 7, 315, 6364, 503, 283, 9648, 63, 751, 7, 315, 6364, 26, 288, 6364, 459, 13970, 63, 765, 418, 275, 283, 9648, 7, 288, 340, 283, 9648, 7, 315, 6364, 26, 355, 6364, 459, 13970, 418, 275, 6364, 459, 9648, 418, 355, 2150, 6364, 459, 9648, 418, 953, 340, 283, 9648, 63, 751, 7, 315, 6364, 26, 355, 6364, 459, 13970, 63, 751, 418, 275, 6364, 459, 9648, 63, 751, 418, 355, 2150, 6364, 459, 9648, 63, 751, 418, 953, 2929, 14, 6667, 480, 13962, 13558, 402, 18741, 15, 9648, 63, 751, 12, 675, 8649, 15, 13970, 63, 751, 436, 663, 8649, 63, 765, 370, 283, 9648, 7, 334, 885, 365, 14682, 4186, 283, 18, 14, 25, 358, 398, 372, 6364, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 492, 1067, 199, 504, 3242, 14, 2550, 492, 31775, 199, 504, 3242, 14, 14205, 14, 3215, 492, 5024, 1646, 199, 504, 3242, 14, 1208, 14, 2918, 492, 12175, 199, 199, 2918, 275, 12175, 342, 421, 199, 533, 6423, 4352, 26, 339, 327, 8538, 17228, 325, 4732, 425, 272, 485, 13970, 275, 5024, 1646, 8, 13655, 534, 2245, 297, 849, 29, 1100, 14, 2764, 589, 63, 12116, 63, 362, 360, 13970, 1333, 272, 485, 13970, 63, 765, 275, 5024, 1646, 8, 13655, 534, 875, 297, 849, 29, 1100, 14, 2764, 589, 63, 12116, 63, 362, 360, 13970, 63, 765, 1333, 272, 485, 13970, 63, 751, 275, 5024, 1646, 8, 13655, 534, 875, 297, 849, 29, 1100, 14, 2764, 589, 63, 12116, 63, 362, 360, 13970, 63, 751, 1333, 272, 485, 13970, 63, 2469, 275, 5024, 1646, 8, 13655, 534, 875, 358, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 3655, 4352, 12, 291, 2843, 826, 4533, 339, 347, 485, 13552, 63, 1359, 17228, 63, 397, 915, 425, 63, 15207, 8, 277, 12, 6364, 304, 398, 327, 12176, 734, 340, 922, 9314, 28204, 1979, 17228, 325, 4732, 1298, 267, 965, 63, 13970, 275, 283, 13970, 7, 315, 6364, 503, 283, 13970, 63, 751, 7, 262, 6364, 267, 965, 63, 12095, 275, 283, 12095, 7, 315, 6364, 503, 283, 12095, 63, 751, 7, 315, 6364, 267, 965, 63, 9648, 275, 283, 9648, 7, 315, 6364, 503, 283, 9648, 63, 751, 7, 315, 6364, 398, 340, 965, 63, 13970, 26, 288, 1499, 275, 283, 1918, 8649, 1862, 1689, 13970, 401, 298, 13970, 63, 751, 531, 436, 7, 288, 340, 965, 63, 12095, 26, 355, 746, 31775, 3508, 83, 14682, 1862, 1689, 12095, 401, 298, 12095, 63, 751, 531, 3913, 506, 1202, 10451, 7, 450, 1499, 9, 288, 916, 965, 63, 9648, 26, 355, 746, 31775, 3508, 83, 18741, 1862, 1689, 9648, 401, 298, 9648, 63, 751, 531, 3913, 506, 1202, 10451, 7, 450, 1499, 9, 267, 916, 965, 63, 12095, 436, 965, 63, 9648, 26, 288, 746, 31775, 360, 12095, 1862, 1689, 12095, 401, 298, 12095, 63, 751, 531, 436, 18741, 1862, 1689, 9648, 401, 298, 9648, 63, 751, 531, 3913, 506, 1202, 10451, 358, 339, 347, 485, 17677, 63, 576, 63, 13970, 8, 277, 12, 6364, 304, 267, 408, 26539, 314, 15695, 666, 367, 8649, 3004, 398, 961, 365, 2797, 687, 314, 3523, 909, 1159, 23351, 63, 576, 342, 1083, 1314, 267, 315, 7485, 365, 2797, 7268, 8298, 1263, 521, 1263, 4069, 402, 15695, 909, 267, 334, 20591, 12, 6527, 12, 5664, 12, 5423, 9, 365, 2737, 14, 267, 408, 398, 291, 423, 13552, 63, 1359, 17228, 63, 397, 915, 425, 63, 15207, 8, 795, 9, 398, 327, 8538, 17228, 325, 4732, 425, 12, 8552, 7163, 367, 14682, 15, 9648, 267, 340, 283, 12095, 7, 315, 6364, 503, 283, 12095, 63, 751, 7, 315, 6364, 26, 288, 6364, 459, 13970, 63, 765, 418, 275, 283, 12095, 7, 288, 340, 283, 12095, 7, 315, 6364, 26, 355, 6364, 459, 13970, 418, 275, 6364, 459, 12095, 418, 355, 2150, 6364, 459, 12095, 418, 953, 340, 283, 12095, 63, 751, 7, 315, 6364, 26, 355, 6364, 459, 13970, 63, 751, 418, 275, 6364, 459, 12095, 63, 751, 418, 355, 2150, 6364, 459, 12095, 63, 751, 418, 953, 2929, 14, 6667, 480, 13962, 13558, 402, 14682, 15, 12095, 63, 751, 12, 675, 8649, 15, 13970, 63, 751, 436, 1852, 3238, 8649, 63, 765, 365, 283, 12095, 7, 334, 885, 4186, 283, 18, 14, 25, 358, 398, 916, 283, 9648, 7, 315, 6364, 503, 283, 9648, 63, 751, 7, 315, 6364, 26, 288, 6364, 459, 13970, 63, 765, 418, 275, 283, 9648, 7, 288, 340, 283, 9648, 7, 315, 6364, 26, 355, 6364, 459, 13970, 418, 275, 6364, 459, 9648, 418, 355, 2150, 6364, 459, 9648, 418, 953, 340, 283, 9648, 63, 751, 7, 315, 6364, 26, 355, 6364, 459, 13970, 63, 751, 418, 275, 6364, 459, 9648, 63, 751, 418, 355, 2150, 6364, 459, 9648, 63, 751, 418, 953, 2929, 14, 6667, 480, 13962, 13558, 402, 18741, 15, 9648, 63, 751, 12, 675, 8649, 15, 13970, 63, 751, 436, 663, 8649, 63, 765, 370, 283, 9648, 7, 334, 885, 365, 14682, 4186, 283, 18, 14, 25, 358, 398, 372, 6364, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
IKholopov/HackUPC2017
hackupc/env/lib/python3.5/site-packages/social_core/backends/line.py
1
3104
# vim:fileencoding=utf-8 import requests import json from .oauth import BaseOAuth2 from ..exceptions import AuthFailed from ..utils import handle_http_errors class LineOAuth2(BaseOAuth2): name = 'line' AUTHORIZATION_URL = 'https://access.line.me/dialog/oauth/weblogin' ACCESS_TOKEN_URL = 'https://api.line.me/v1/oauth/accessToken' BASE_API_URL = 'https://api.line.me' USER_INFO_URL = BASE_API_URL + '/v1/profile' ACCESS_TOKEN_METHOD = 'POST' STATE_PARAMETER = True REDIRECT_STATE = True ID_KEY = 'mid' EXTRA_DATA = [ ('mid', 'id'), ('expire', 'expire'), ('refreshToken', 'refresh_token') ] def auth_params(self, state=None): client_id, client_secret = self.get_key_and_secret() return { 'client_id': client_id, 'redirect_uri': self.get_redirect_uri(), 'response_type': self.RESPONSE_TYPE } def process_error(self, data): error_code = data.get('errorCode') or \ data.get('statusCode') or \ data.get('error') error_message = data.get('errorMessage') or \ data.get('statusMessage') or \ data.get('error_desciption') if error_code is not None or error_message is not None: raise AuthFailed(self, error_message or error_code) @handle_http_errors def auth_complete(self, *args, **kwargs): """Completes login process, must return user instance""" client_id, client_secret = self.get_key_and_secret() code = self.data.get('code') self.process_error(self.data) try: response = self.request_access_token( self.access_token_url(), method=self.ACCESS_TOKEN_METHOD, params={ 'requestToken': code, 'channelSecret': client_secret } ) self.process_error(response) return self.do_auth(response['accessToken'], response=response, *args, **kwargs) except requests.HTTPError as err: self.process_error(json.loads(err.response.content)) def get_user_details(self, response): response.update({ 'fullname': response.get('displayName'), 'picture_url': response.get('pictureUrl') }) return response def get_user_id(self, details, response): """Return a unique ID for the current user, by default from server response.""" return response.get(self.ID_KEY) def user_data(self, access_token, *args, **kwargs): """Loads user data from service""" try: response = self.get_json( self.USER_INFO_URL, headers={ "Authorization": "Bearer {}".format(access_token) } ) self.process_error(response) return response except requests.HTTPError as err: self.process_error(err.response.json())
apache-2.0
[ 3, 6695, 26, 493, 2991, 29, 1624, 13, 24, 199, 646, 4145, 199, 646, 2022, 199, 199, 504, 1275, 6126, 492, 3523, 12906, 18, 199, 504, 2508, 3924, 492, 3590, 4276, 199, 504, 2508, 1208, 492, 2429, 63, 1014, 63, 2550, 421, 199, 533, 7030, 12906, 18, 8, 1563, 12906, 18, 304, 272, 536, 275, 283, 604, 7, 272, 7560, 7123, 2594, 63, 2632, 275, 283, 2859, 921, 2732, 14, 604, 14, 278, 15, 7196, 15, 6126, 15, 2520, 2886, 7, 272, 437, 10203, 63, 8803, 63, 2632, 275, 283, 2859, 921, 1246, 14, 604, 14, 278, 15, 86, 17, 15, 6126, 15, 2732, 3264, 7, 272, 19721, 63, 3735, 63, 2632, 275, 283, 2859, 921, 1246, 14, 604, 14, 278, 7, 272, 13044, 63, 4531, 63, 2632, 275, 19721, 63, 3735, 63, 2632, 435, 1994, 86, 17, 15, 2913, 7, 272, 437, 10203, 63, 8803, 63, 9977, 275, 283, 4030, 7, 272, 11377, 63, 14472, 275, 715, 272, 820, 7458, 4168, 63, 6689, 275, 715, 272, 2870, 63, 3078, 275, 283, 8523, 7, 272, 3651, 13954, 63, 3998, 275, 359, 267, 661, 8523, 297, 283, 344, 659, 267, 661, 14691, 297, 283, 14691, 659, 267, 661, 6635, 3264, 297, 283, 6635, 63, 1418, 358, 272, 1622, 339, 347, 1790, 63, 1162, 8, 277, 12, 1174, 29, 403, 304, 267, 1890, 63, 344, 12, 1890, 63, 4731, 275, 291, 14, 362, 63, 498, 63, 460, 63, 4731, 342, 267, 372, 469, 288, 283, 1258, 63, 344, 356, 1890, 63, 344, 12, 288, 283, 4876, 63, 2302, 356, 291, 14, 362, 63, 4876, 63, 2302, 1062, 288, 283, 1310, 63, 466, 356, 291, 14, 12801, 63, 2711, 267, 789, 339, 347, 2112, 63, 705, 8, 277, 12, 666, 304, 267, 1125, 63, 600, 275, 666, 14, 362, 360, 705, 3034, 358, 503, 971, 2151, 666, 14, 362, 360, 1205, 3034, 358, 503, 971, 2151, 666, 14, 362, 360, 705, 358, 267, 1125, 63, 1188, 275, 666, 14, 362, 360, 705, 2209, 358, 503, 971, 717, 666, 14, 362, 360, 1205, 2209, 358, 503, 971, 717, 666, 14, 362, 360, 705, 63, 3257, 73, 494, 358, 267, 340, 1125, 63, 600, 365, 440, 488, 503, 1125, 63, 1188, 365, 440, 488, 26, 288, 746, 3590, 4276, 8, 277, 12, 1125, 63, 1188, 503, 1125, 63, 600, 9, 339, 768, 2479, 63, 1014, 63, 2550, 272, 347, 1790, 63, 4883, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 6600, 744, 4676, 2112, 12, 1471, 372, 922, 1256, 624, 267, 1890, 63, 344, 12, 1890, 63, 4731, 275, 291, 14, 362, 63, 498, 63, 460, 63, 4731, 342, 267, 1233, 275, 291, 14, 576, 14, 362, 360, 600, 358, 398, 291, 14, 1412, 63, 705, 8, 277, 14, 576, 9, 398, 862, 26, 288, 1177, 275, 291, 14, 1069, 63, 2732, 63, 1418, 8, 355, 291, 14, 2732, 63, 1418, 63, 633, 1062, 355, 1083, 29, 277, 14, 11074, 63, 8803, 63, 9977, 12, 355, 1862, 3126, 490, 283, 1069, 3264, 356, 1233, 12, 490, 283, 2775, 13790, 356, 1890, 63, 4731, 355, 789, 288, 776, 288, 291, 14, 1412, 63, 705, 8, 1310, 9, 953, 372, 291, 14, 1117, 63, 1178, 8, 1310, 459, 2732, 3264, 995, 1177, 29, 1310, 12, 1816, 627, 589, 12, 1011, 958, 9, 267, 871, 4145, 14, 12815, 465, 2329, 26, 288, 291, 14, 1412, 63, 705, 8, 1001, 14, 3640, 8, 1508, 14, 1310, 14, 1317, 430, 339, 347, 664, 63, 751, 63, 5087, 8, 277, 12, 1177, 304, 267, 1177, 14, 873, 2561, 288, 283, 9930, 356, 1177, 14, 362, 360, 2918, 985, 659, 288, 283, 12538, 63, 633, 356, 1177, 14, 362, 360, 12538, 6417, 358, 267, 3828, 267, 372, 1177, 339, 347, 664, 63, 751, 63, 344, 8, 277, 12, 2436, 12, 1177, 304, 267, 408, 1767, 282, 3747, 2870, 367, 314, 1453, 922, 12, 701, 849, 687, 1654, 1177, 1041, 267, 372, 1177, 14, 362, 8, 277, 14, 998, 63, 3078, 9, 339, 347, 922, 63, 576, 8, 277, 12, 2879, 63, 1418, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 30777, 922, 666, 687, 2435, 624, 267, 862, 26, 288, 1177, 275, 291, 14, 362, 63, 1001, 8, 355, 291, 14, 3791, 63, 4531, 63, 2632, 12, 355, 2323, 3126, 490, 298, 11626, 582, 298, 3655, 21462, 8352, 908, 8, 2732, 63, 1418, 9, 355, 789, 288, 776, 288, 291, 14, 1412, 63, 705, 8, 1310, 9, 288, 372, 1177, 267, 871, 4145, 14, 12815, 465, 2329, 26, 288, 291, 14, 1412, 63, 705, 8, 1508, 14, 1310, 14, 1001, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6695, 26, 493, 2991, 29, 1624, 13, 24, 199, 646, 4145, 199, 646, 2022, 199, 199, 504, 1275, 6126, 492, 3523, 12906, 18, 199, 504, 2508, 3924, 492, 3590, 4276, 199, 504, 2508, 1208, 492, 2429, 63, 1014, 63, 2550, 421, 199, 533, 7030, 12906, 18, 8, 1563, 12906, 18, 304, 272, 536, 275, 283, 604, 7, 272, 7560, 7123, 2594, 63, 2632, 275, 283, 2859, 921, 2732, 14, 604, 14, 278, 15, 7196, 15, 6126, 15, 2520, 2886, 7, 272, 437, 10203, 63, 8803, 63, 2632, 275, 283, 2859, 921, 1246, 14, 604, 14, 278, 15, 86, 17, 15, 6126, 15, 2732, 3264, 7, 272, 19721, 63, 3735, 63, 2632, 275, 283, 2859, 921, 1246, 14, 604, 14, 278, 7, 272, 13044, 63, 4531, 63, 2632, 275, 19721, 63, 3735, 63, 2632, 435, 1994, 86, 17, 15, 2913, 7, 272, 437, 10203, 63, 8803, 63, 9977, 275, 283, 4030, 7, 272, 11377, 63, 14472, 275, 715, 272, 820, 7458, 4168, 63, 6689, 275, 715, 272, 2870, 63, 3078, 275, 283, 8523, 7, 272, 3651, 13954, 63, 3998, 275, 359, 267, 661, 8523, 297, 283, 344, 659, 267, 661, 14691, 297, 283, 14691, 659, 267, 661, 6635, 3264, 297, 283, 6635, 63, 1418, 358, 272, 1622, 339, 347, 1790, 63, 1162, 8, 277, 12, 1174, 29, 403, 304, 267, 1890, 63, 344, 12, 1890, 63, 4731, 275, 291, 14, 362, 63, 498, 63, 460, 63, 4731, 342, 267, 372, 469, 288, 283, 1258, 63, 344, 356, 1890, 63, 344, 12, 288, 283, 4876, 63, 2302, 356, 291, 14, 362, 63, 4876, 63, 2302, 1062, 288, 283, 1310, 63, 466, 356, 291, 14, 12801, 63, 2711, 267, 789, 339, 347, 2112, 63, 705, 8, 277, 12, 666, 304, 267, 1125, 63, 600, 275, 666, 14, 362, 360, 705, 3034, 358, 503, 971, 2151, 666, 14, 362, 360, 1205, 3034, 358, 503, 971, 2151, 666, 14, 362, 360, 705, 358, 267, 1125, 63, 1188, 275, 666, 14, 362, 360, 705, 2209, 358, 503, 971, 717, 666, 14, 362, 360, 1205, 2209, 358, 503, 971, 717, 666, 14, 362, 360, 705, 63, 3257, 73, 494, 358, 267, 340, 1125, 63, 600, 365, 440, 488, 503, 1125, 63, 1188, 365, 440, 488, 26, 288, 746, 3590, 4276, 8, 277, 12, 1125, 63, 1188, 503, 1125, 63, 600, 9, 339, 768, 2479, 63, 1014, 63, 2550, 272, 347, 1790, 63, 4883, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 6600, 744, 4676, 2112, 12, 1471, 372, 922, 1256, 624, 267, 1890, 63, 344, 12, 1890, 63, 4731, 275, 291, 14, 362, 63, 498, 63, 460, 63, 4731, 342, 267, 1233, 275, 291, 14, 576, 14, 362, 360, 600, 358, 398, 291, 14, 1412, 63, 705, 8, 277, 14, 576, 9, 398, 862, 26, 288, 1177, 275, 291, 14, 1069, 63, 2732, 63, 1418, 8, 355, 291, 14, 2732, 63, 1418, 63, 633, 1062, 355, 1083, 29, 277, 14, 11074, 63, 8803, 63, 9977, 12, 355, 1862, 3126, 490, 283, 1069, 3264, 356, 1233, 12, 490, 283, 2775, 13790, 356, 1890, 63, 4731, 355, 789, 288, 776, 288, 291, 14, 1412, 63, 705, 8, 1310, 9, 953, 372, 291, 14, 1117, 63, 1178, 8, 1310, 459, 2732, 3264, 995, 1177, 29, 1310, 12, 1816, 627, 589, 12, 1011, 958, 9, 267, 871, 4145, 14, 12815, 465, 2329, 26, 288, 291, 14, 1412, 63, 705, 8, 1001, 14, 3640, 8, 1508, 14, 1310, 14, 1317, 430, 339, 347, 664, 63, 751, 63, 5087, 8, 277, 12, 1177, 304, 267, 1177, 14, 873, 2561, 288, 283, 9930, 356, 1177, 14, 362, 360, 2918, 985, 659, 288, 283, 12538, 63, 633, 356, 1177, 14, 362, 360, 12538, 6417, 358, 267, 3828, 267, 372, 1177, 339, 347, 664, 63, 751, 63, 344, 8, 277, 12, 2436, 12, 1177, 304, 267, 408, 1767, 282, 3747, 2870, 367, 314, 1453, 922, 12, 701, 849, 687, 1654, 1177, 1041, 267, 372, 1177, 14, 362, 8, 277, 14, 998, 63, 3078, 9, 339, 347, 922, 63, 576, 8, 277, 12, 2879, 63, 1418, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 30777, 922, 666, 687, 2435, 624, 267, 862, 26, 288, 1177, 275, 291, 14, 362, 63, 1001, 8, 355, 291, 14, 3791, 63, 4531, 63, 2632, 12, 355, 2323, 3126, 490, 298, 11626, 582, 298, 3655, 21462, 8352, 908, 8, 2732, 63, 1418, 9, 355, 789, 288, 776, 288, 291, 14, 1412, 63, 705, 8, 1310, 9, 288, 372, 1177, 267, 871, 4145, 14, 12815, 465, 2329, 26, 288, 291, 14, 1412, 63, 705, 8, 1508, 14, 1310, 14, 1001, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 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ations/models.py
90
2521
""" 34. Generic relations Generic relations let an object have a foreign key to any object through a content-type/object-id field. A ``GenericForeignKey`` field can point to any object, be it animal, vegetable, or mineral. The canonical example is tags (although this example implementation is *far* from complete). """ from django.contrib.contenttypes import generic from django.contrib.contenttypes.models import ContentType from django.db import models class TaggedItem(models.Model): """A tag on an item.""" tag = models.SlugField() content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey() class Meta: ordering = ["tag", "content_type__name"] def __unicode__(self): return self.tag class ValuableTaggedItem(TaggedItem): value = models.PositiveIntegerField() class Comparison(models.Model): """ A model that tests having multiple GenericForeignKeys """ comparative = models.CharField(max_length=50) content_type1 = models.ForeignKey(ContentType, related_name="comparative1_set") object_id1 = models.PositiveIntegerField() content_type2 = models.ForeignKey(ContentType, related_name="comparative2_set") object_id2 = models.PositiveIntegerField() first_obj = generic.GenericForeignKey(ct_field="content_type1", fk_field="object_id1") other_obj = generic.GenericForeignKey(ct_field="content_type2", fk_field="object_id2") def __unicode__(self): return u"%s is %s than %s" % (self.first_obj, self.comparative, self.other_obj) class Animal(models.Model): common_name = models.CharField(max_length=150) latin_name = models.CharField(max_length=150) tags = generic.GenericRelation(TaggedItem) comparisons = generic.GenericRelation(Comparison, object_id_field="object_id1", content_type_field="content_type1") def __unicode__(self): return self.common_name class Vegetable(models.Model): name = models.CharField(max_length=150) is_yucky = models.BooleanField(default=True) tags = generic.GenericRelation(TaggedItem) def __unicode__(self): return self.name class Mineral(models.Model): name = models.CharField(max_length=150) hardness = models.PositiveSmallIntegerField() # note the lack of an explicit GenericRelation here... def __unicode__(self): return self.name
bsd-3-clause
[ 624, 199, 1082, 14, 8307, 16109, 199, 199, 9417, 16109, 4691, 376, 909, 1172, 282, 11608, 790, 370, 1263, 909, 4012, 282, 199, 1317, 13, 466, 15, 785, 13, 344, 901, 14, 437, 1124, 9417, 3190, 1040, 901, 883, 2376, 370, 1263, 199, 785, 12, 506, 652, 376, 7265, 12, 11199, 362, 461, 12, 503, 1748, 281, 279, 14, 199, 199, 1918, 11358, 2893, 365, 3762, 334, 6130, 4937, 642, 2893, 4514, 365, 627, 15315, 10, 199, 504, 4890, 680, 199, 624, 199, 199, 504, 1639, 14, 2828, 14, 10778, 492, 7809, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 32121, 2081, 8, 992, 14, 1685, 304, 272, 408, 33, 1947, 641, 376, 1242, 1041, 272, 1947, 275, 1709, 14, 17315, 342, 272, 1564, 63, 466, 275, 1709, 14, 3190, 8, 11282, 9, 272, 909, 63, 344, 275, 1709, 14, 8591, 342, 339, 1564, 63, 785, 275, 7809, 14, 9417, 3190, 342, 339, 1021, 6288, 26, 267, 7794, 275, 2097, 1450, 401, 298, 1317, 63, 466, 363, 354, 937, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 1450, 199, 199, 533, 26263, 85, 461, 26403, 2081, 8, 26403, 2081, 304, 272, 574, 275, 1709, 14, 8591, 342, 199, 199, 533, 3599, 5447, 8, 992, 14, 1685, 304, 272, 408, 272, 437, 1402, 626, 2295, 9445, 3663, 8307, 20931, 6340, 272, 408, 272, 1013, 285, 1905, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 1564, 63, 466, 17, 275, 1709, 14, 3190, 8, 11282, 12, 4048, 63, 354, 628, 863, 285, 1905, 17, 63, 409, 531, 272, 909, 63, 344, 17, 275, 1709, 14, 8591, 342, 339, 1564, 63, 466, 18, 275, 1709, 14, 3190, 8, 11282, 12, 221, 4048, 63, 354, 628, 863, 285, 1905, 18, 63, 409, 531, 272, 909, 63, 344, 18, 275, 1709, 14, 8591, 342, 339, 1642, 63, 1113, 275, 7809, 14, 9417, 3190, 8, 319, 63, 698, 628, 1317, 63, 466, 17, 401, 14830, 63, 698, 628, 785, 63, 344, 17, 531, 272, 1163, 63, 1113, 275, 7809, 14, 9417, 3190, 8, 319, 63, 698, 628, 1317, 63, 466, 18, 401, 14830, 63, 698, 628, 785, 63, 344, 18, 531, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 399, 6808, 83, 365, 450, 83, 2419, 450, 83, 2, 450, 334, 277, 14, 2246, 63, 1113, 12, 291, 14, 863, 285, 1905, 12, 291, 14, 1848, 63, 1113, 9, 199, 199, 533, 1626, 7265, 8, 992, 14, 1685, 304, 272, 2863, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 8251, 9, 272, 16899, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 8251, 9, 339, 3762, 275, 7809, 14, 9417, 12617, 8, 26403, 2081, 9, 272, 20448, 275, 7809, 14, 9417, 12617, 8, 25834, 12, 5101, 909, 63, 344, 63, 698, 628, 785, 63, 344, 17, 401, 5101, 1564, 63, 466, 63, 698, 628, 1317, 63, 466, 17, 531, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 2330, 63, 354, 199, 199, 533, 25777, 362, 461, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 8251, 9, 272, 365, 63, 89, 10112, 89, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 339, 3762, 275, 7809, 14, 9417, 12617, 8, 26403, 2081, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 199, 199, 533, 10195, 281, 279, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 8251, 9, 272, 7508, 4171, 275, 1709, 14, 25197, 342, 339, 327, 5317, 314, 29098, 402, 376, 5027, 8307, 12617, 2348, 1396, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 1082, 14, 8307, 16109, 199, 199, 9417, 16109, 4691, 376, 909, 1172, 282, 11608, 790, 370, 1263, 909, 4012, 282, 199, 1317, 13, 466, 15, 785, 13, 344, 901, 14, 437, 1124, 9417, 3190, 1040, 901, 883, 2376, 370, 1263, 199, 785, 12, 506, 652, 376, 7265, 12, 11199, 362, 461, 12, 503, 1748, 281, 279, 14, 199, 199, 1918, 11358, 2893, 365, 3762, 334, 6130, 4937, 642, 2893, 4514, 365, 627, 15315, 10, 199, 504, 4890, 680, 199, 624, 199, 199, 504, 1639, 14, 2828, 14, 10778, 492, 7809, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 32121, 2081, 8, 992, 14, 1685, 304, 272, 408, 33, 1947, 641, 376, 1242, 1041, 272, 1947, 275, 1709, 14, 17315, 342, 272, 1564, 63, 466, 275, 1709, 14, 3190, 8, 11282, 9, 272, 909, 63, 344, 275, 1709, 14, 8591, 342, 339, 1564, 63, 785, 275, 7809, 14, 9417, 3190, 342, 339, 1021, 6288, 26, 267, 7794, 275, 2097, 1450, 401, 298, 1317, 63, 466, 363, 354, 937, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 1450, 199, 199, 533, 26263, 85, 461, 26403, 2081, 8, 26403, 2081, 304, 272, 574, 275, 1709, 14, 8591, 342, 199, 199, 533, 3599, 5447, 8, 992, 14, 1685, 304, 272, 408, 272, 437, 1402, 626, 2295, 9445, 3663, 8307, 20931, 6340, 272, 408, 272, 1013, 285, 1905, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 1564, 63, 466, 17, 275, 1709, 14, 3190, 8, 11282, 12, 4048, 63, 354, 628, 863, 285, 1905, 17, 63, 409, 531, 272, 909, 63, 344, 17, 275, 1709, 14, 8591, 342, 339, 1564, 63, 466, 18, 275, 1709, 14, 3190, 8, 11282, 12, 221, 4048, 63, 354, 628, 863, 285, 1905, 18, 63, 409, 531, 272, 909, 63, 344, 18, 275, 1709, 14, 8591, 342, 339, 1642, 63, 1113, 275, 7809, 14, 9417, 3190, 8, 319, 63, 698, 628, 1317, 63, 466, 17, 401, 14830, 63, 698, 628, 785, 63, 344, 17, 531, 272, 1163, 63, 1113, 275, 7809, 14, 9417, 3190, 8, 319, 63, 698, 628, 1317, 63, 466, 18, 401, 14830, 63, 698, 628, 785, 63, 344, 18, 531, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 399, 6808, 83, 365, 450, 83, 2419, 450, 83, 2, 450, 334, 277, 14, 2246, 63, 1113, 12, 291, 14, 863, 285, 1905, 12, 291, 14, 1848, 63, 1113, 9, 199, 199, 533, 1626, 7265, 8, 992, 14, 1685, 304, 272, 2863, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 8251, 9, 272, 16899, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 8251, 9, 339, 3762, 275, 7809, 14, 9417, 12617, 8, 26403, 2081, 9, 272, 20448, 275, 7809, 14, 9417, 12617, 8, 25834, 12, 5101, 909, 63, 344, 63, 698, 628, 785, 63, 344, 17, 401, 5101, 1564, 63, 466, 63, 698, 628, 1317, 63, 466, 17, 531, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 2330, 63, 354, 199, 199, 533, 25777, 362, 461, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 8251, 9, 272, 365, 63, 89, 10112, 89, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 339, 3762, 275, 7809, 14, 9417, 12617, 8, 26403, 2081, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 199, 199, 533, 10195, 281, 279, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 8251, 9, 272, 7508, 4171, 275, 1709, 14, 25197, 342, 339, 327, 5317, 314, 29098, 402, 376, 5027, 8307, 12617, 2348, 1396, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1,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conda/Miniconda3-x64/Lib/encodings/cp1254.py
272
13502
""" Python Character Mapping Codec cp1254 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1254.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='cp1254', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Table decoding_table = ( '\x00' # 0x00 -> NULL '\x01' # 0x01 -> START OF HEADING '\x02' # 0x02 -> START OF TEXT '\x03' # 0x03 -> END OF TEXT '\x04' # 0x04 -> END OF TRANSMISSION '\x05' # 0x05 -> ENQUIRY '\x06' # 0x06 -> ACKNOWLEDGE '\x07' # 0x07 -> BELL '\x08' # 0x08 -> BACKSPACE '\t' # 0x09 -> HORIZONTAL TABULATION '\n' # 0x0A -> LINE FEED '\x0b' # 0x0B -> VERTICAL TABULATION '\x0c' # 0x0C -> FORM FEED '\r' # 0x0D -> CARRIAGE RETURN '\x0e' # 0x0E -> SHIFT OUT '\x0f' # 0x0F -> SHIFT IN '\x10' # 0x10 -> DATA LINK ESCAPE '\x11' # 0x11 -> DEVICE CONTROL ONE '\x12' # 0x12 -> DEVICE CONTROL TWO '\x13' # 0x13 -> DEVICE CONTROL THREE '\x14' # 0x14 -> DEVICE CONTROL FOUR '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE '\x16' # 0x16 -> SYNCHRONOUS IDLE '\x17' # 0x17 -> END OF TRANSMISSION BLOCK '\x18' # 0x18 -> CANCEL '\x19' # 0x19 -> END OF MEDIUM '\x1a' # 0x1A -> SUBSTITUTE '\x1b' # 0x1B -> ESCAPE '\x1c' # 0x1C -> FILE SEPARATOR '\x1d' # 0x1D -> GROUP SEPARATOR '\x1e' # 0x1E -> RECORD SEPARATOR '\x1f' # 0x1F -> UNIT SEPARATOR ' ' # 0x20 -> SPACE '!' # 0x21 -> EXCLAMATION MARK '"' # 0x22 -> QUOTATION MARK '#' # 0x23 -> NUMBER SIGN '$' # 0x24 -> DOLLAR SIGN '%' # 0x25 -> PERCENT SIGN '&' # 0x26 -> AMPERSAND "'" # 0x27 -> APOSTROPHE '(' # 0x28 -> LEFT PARENTHESIS ')' # 0x29 -> RIGHT PARENTHESIS '*' # 0x2A -> ASTERISK '+' # 0x2B -> PLUS SIGN ',' # 0x2C -> COMMA '-' # 0x2D -> HYPHEN-MINUS '.' # 0x2E -> FULL STOP '/' # 0x2F -> SOLIDUS '0' # 0x30 -> DIGIT ZERO '1' # 0x31 -> DIGIT ONE '2' # 0x32 -> DIGIT TWO '3' # 0x33 -> DIGIT THREE '4' # 0x34 -> DIGIT FOUR '5' # 0x35 -> DIGIT FIVE '6' # 0x36 -> DIGIT SIX '7' # 0x37 -> DIGIT SEVEN '8' # 0x38 -> DIGIT EIGHT '9' # 0x39 -> DIGIT NINE ':' # 0x3A -> COLON ';' # 0x3B -> SEMICOLON '<' # 0x3C -> LESS-THAN SIGN '=' # 0x3D -> EQUALS SIGN '>' # 0x3E -> GREATER-THAN SIGN '?' # 0x3F -> QUESTION MARK '@' # 0x40 -> COMMERCIAL AT 'A' # 0x41 -> LATIN CAPITAL LETTER A 'B' # 0x42 -> LATIN CAPITAL LETTER B 'C' # 0x43 -> LATIN CAPITAL LETTER C 'D' # 0x44 -> LATIN CAPITAL LETTER D 'E' # 0x45 -> LATIN CAPITAL LETTER E 'F' # 0x46 -> LATIN CAPITAL LETTER F 'G' # 0x47 -> LATIN CAPITAL LETTER G 'H' # 0x48 -> LATIN CAPITAL LETTER H 'I' # 0x49 -> LATIN CAPITAL LETTER I 'J' # 0x4A -> LATIN CAPITAL LETTER J 'K' # 0x4B -> LATIN CAPITAL LETTER K 'L' # 0x4C -> LATIN CAPITAL LETTER L 'M' # 0x4D -> LATIN CAPITAL LETTER M 'N' # 0x4E -> LATIN CAPITAL LETTER N 'O' # 0x4F -> LATIN CAPITAL LETTER O 'P' # 0x50 -> LATIN CAPITAL LETTER P 'Q' # 0x51 -> LATIN CAPITAL LETTER Q 'R' # 0x52 -> LATIN CAPITAL LETTER R 'S' # 0x53 -> LATIN CAPITAL LETTER S 'T' # 0x54 -> LATIN CAPITAL LETTER T 'U' # 0x55 -> LATIN CAPITAL LETTER U 'V' # 0x56 -> LATIN CAPITAL LETTER V 'W' # 0x57 -> LATIN CAPITAL LETTER W 'X' # 0x58 -> LATIN CAPITAL LETTER X 'Y' # 0x59 -> LATIN CAPITAL LETTER Y 'Z' # 0x5A -> LATIN CAPITAL LETTER Z '[' # 0x5B -> LEFT SQUARE BRACKET '\\' # 0x5C -> REVERSE SOLIDUS ']' # 0x5D -> RIGHT SQUARE BRACKET '^' # 0x5E -> CIRCUMFLEX ACCENT '_' # 0x5F -> LOW LINE '`' # 0x60 -> GRAVE ACCENT 'a' # 0x61 -> LATIN SMALL LETTER A 'b' # 0x62 -> LATIN SMALL LETTER B 'c' # 0x63 -> LATIN SMALL LETTER C 'd' # 0x64 -> LATIN SMALL LETTER D 'e' # 0x65 -> LATIN SMALL LETTER E 'f' # 0x66 -> LATIN SMALL LETTER F 'g' # 0x67 -> LATIN SMALL LETTER G 'h' # 0x68 -> LATIN SMALL LETTER H 'i' # 0x69 -> LATIN SMALL LETTER I 'j' # 0x6A -> LATIN SMALL LETTER J 'k' # 0x6B -> LATIN SMALL LETTER K 'l' # 0x6C -> LATIN SMALL LETTER L 'm' # 0x6D -> LATIN SMALL LETTER M 'n' # 0x6E -> LATIN SMALL LETTER N 'o' # 0x6F -> LATIN SMALL LETTER O 'p' # 0x70 -> LATIN SMALL LETTER P 'q' # 0x71 -> LATIN SMALL LETTER Q 'r' # 0x72 -> LATIN SMALL LETTER R 's' # 0x73 -> LATIN SMALL LETTER S 't' # 0x74 -> LATIN SMALL LETTER T 'u' # 0x75 -> LATIN SMALL LETTER U 'v' # 0x76 -> LATIN SMALL LETTER V 'w' # 0x77 -> LATIN SMALL LETTER W 'x' # 0x78 -> LATIN SMALL LETTER X 'y' # 0x79 -> LATIN SMALL LETTER Y 'z' # 0x7A -> LATIN SMALL LETTER Z '{' # 0x7B -> LEFT CURLY BRACKET '|' # 0x7C -> VERTICAL LINE '}' # 0x7D -> RIGHT CURLY BRACKET '~' # 0x7E -> TILDE '\x7f' # 0x7F -> DELETE '\u20ac' # 0x80 -> EURO SIGN '\ufffe' # 0x81 -> UNDEFINED '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK '\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS '\u2020' # 0x86 -> DAGGER '\u2021' # 0x87 -> DOUBLE DAGGER '\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT '\u2030' # 0x89 -> PER MILLE SIGN '\u0160' # 0x8A -> LATIN CAPITAL LETTER S WITH CARON '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK '\u0152' # 0x8C -> LATIN CAPITAL LIGATURE OE '\ufffe' # 0x8D -> UNDEFINED '\ufffe' # 0x8E -> UNDEFINED '\ufffe' # 0x8F -> UNDEFINED '\ufffe' # 0x90 -> UNDEFINED '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK '\u2022' # 0x95 -> BULLET '\u2013' # 0x96 -> EN DASH '\u2014' # 0x97 -> EM DASH '\u02dc' # 0x98 -> SMALL TILDE '\u2122' # 0x99 -> TRADE MARK SIGN '\u0161' # 0x9A -> LATIN SMALL LETTER S WITH CARON '\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK '\u0153' # 0x9C -> LATIN SMALL LIGATURE OE '\ufffe' # 0x9D -> UNDEFINED '\ufffe' # 0x9E -> UNDEFINED '\u0178' # 0x9F -> LATIN CAPITAL LETTER Y WITH DIAERESIS '\xa0' # 0xA0 -> NO-BREAK SPACE '\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK '\xa2' # 0xA2 -> CENT SIGN '\xa3' # 0xA3 -> POUND SIGN '\xa4' # 0xA4 -> CURRENCY SIGN '\xa5' # 0xA5 -> YEN SIGN '\xa6' # 0xA6 -> BROKEN BAR '\xa7' # 0xA7 -> SECTION SIGN '\xa8' # 0xA8 -> DIAERESIS '\xa9' # 0xA9 -> COPYRIGHT SIGN '\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK '\xac' # 0xAC -> NOT SIGN '\xad' # 0xAD -> SOFT HYPHEN '\xae' # 0xAE -> REGISTERED SIGN '\xaf' # 0xAF -> MACRON '\xb0' # 0xB0 -> DEGREE SIGN '\xb1' # 0xB1 -> PLUS-MINUS SIGN '\xb2' # 0xB2 -> SUPERSCRIPT TWO '\xb3' # 0xB3 -> SUPERSCRIPT THREE '\xb4' # 0xB4 -> ACUTE ACCENT '\xb5' # 0xB5 -> MICRO SIGN '\xb6' # 0xB6 -> PILCROW SIGN '\xb7' # 0xB7 -> MIDDLE DOT '\xb8' # 0xB8 -> CEDILLA '\xb9' # 0xB9 -> SUPERSCRIPT ONE '\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS '\xbf' # 0xBF -> INVERTED QUESTION MARK '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX '\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS '\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS '\u011e' # 0xD0 -> LATIN CAPITAL LETTER G WITH BREVE '\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE '\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS '\xd7' # 0xD7 -> MULTIPLICATION SIGN '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS '\u0130' # 0xDD -> LATIN CAPITAL LETTER I WITH DOT ABOVE '\u015e' # 0xDE -> LATIN CAPITAL LETTER S WITH CEDILLA '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX '\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE '\xe6' # 0xE6 -> LATIN SMALL LETTER AE '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS '\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS '\u011f' # 0xF0 -> LATIN SMALL LETTER G WITH BREVE '\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE '\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS '\xf7' # 0xF7 -> DIVISION SIGN '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS '\u0131' # 0xFD -> LATIN SMALL LETTER DOTLESS I '\u015f' # 0xFE -> LATIN SMALL LETTER S WITH CEDILLA '\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS ) ### Encoding table encoding_table=codecs.charmap_build(decoding_table)
apache-2.0
[ 624, 2018, 17660, 12340, 13732, 7667, 31195, 4046, 687, 283, 32362, 15, 27839, 4149, 15, 17233, 51, 2161, 15, 20509, 15, 2890, 31195, 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, 1850, 31195, 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, 1557, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 272, 1557, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 272, 1557, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 272, 1557, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 272, 1557, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 272, 1557, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 272, 1557, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 272, 1557, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 272, 1557, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 272, 1557, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 272, 1557, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 272, 1557, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 272, 1557, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 272, 1557, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 272, 1557, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 272, 1557, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 272, 1557, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 272, 1557, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 272, 1557, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 272, 1557, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 272, 1557, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 272, 1557, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 272, 1557, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 272, 1557, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 272, 1557, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 272, 1557, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 272, 1557, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 272, 1557, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 272, 1557, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 272, 1557, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 272, 1557, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 272, 1557, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 272, 283, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 29376, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 14788, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 19619, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 25271, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 26386, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 29285, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 21673, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 16746, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 16107, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 13626, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 20246, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 13647, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 10791, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 7815, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 7324, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 283, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 283, 17, 7, 263, 327, 221, 378, 88, 2192, 1035, 7298, 13051, 272, 283, 18, 7, 263, 327, 221, 378, 88, 708, 1035, 7298, 16562, 272, 283, 19, 7, 263, 327, 221, 378, 88, 1153, 1035, 7298, 16296, 272, 283, 20, 7, 263, 327, 221, 378, 88, 1082, 1035, 7298, 14473, 272, 283, 21, 7, 263, 327, 221, 378, 88, 1276, 1035, 7298, 28194, 272 ]
[ 2018, 17660, 12340, 13732, 7667, 31195, 4046, 687, 283, 32362, 15, 27839, 4149, 15, 17233, 51, 2161, 15, 20509, 15, 2890, 31195, 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, 1850, 31195, 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, 1557, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 272, 1557, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 272, 1557, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 272, 1557, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 272, 1557, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 272, 1557, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 272, 1557, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 272, 1557, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 272, 1557, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 272, 1557, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 272, 1557, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 272, 1557, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 272, 1557, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 272, 1557, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 272, 1557, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 272, 1557, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 272, 1557, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 272, 1557, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 272, 1557, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 272, 1557, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 272, 1557, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 272, 1557, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 272, 1557, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 272, 1557, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 272, 1557, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 272, 1557, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 272, 1557, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 272, 1557, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 272, 1557, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 272, 1557, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 272, 1557, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 272, 1557, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 272, 283, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 29376, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 14788, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 19619, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 25271, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 26386, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 29285, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 21673, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 16746, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 16107, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 13626, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 20246, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 13647, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 10791, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 7815, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 7324, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 283, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 283, 17, 7, 263, 327, 221, 378, 88, 2192, 1035, 7298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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 ]
yamila-moreno/django
django/conf/locale/lt/formats.py
504
1830
# -*- 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'Y \m. E j \d.' TIME_FORMAT = 'H:i' DATETIME_FORMAT = r'Y \m. E j \d., H:i' YEAR_MONTH_FORMAT = r'Y \m. F' MONTH_DAY_FORMAT = r'E j \d.' SHORT_DATE_FORMAT = 'Y-m-d' SHORT_DATETIME_FORMAT = 'Y-m-d 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' ] TIME_INPUT_FORMATS = [ '%H:%M:%S', # '14:30:59' '%H:%M:%S.%f', # '14:30:59.000200' '%H:%M', # '14:30' '%H.%M.%S', # '14.30.59' '%H.%M.%S.%f', # '14.30.59.000200' '%H.%M', # '14.30' ] 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' '%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 %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, 57, 971, 77, 14, 662, 1335, 971, 68, 3530, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 199, 12488, 63, 4807, 275, 519, 7, 57, 971, 77, 14, 662, 1335, 971, 68, 2020, 869, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 519, 7, 57, 971, 77, 14, 481, 7, 199, 16413, 63, 11655, 63, 4807, 275, 519, 7, 37, 1335, 971, 68, 3530, 199, 13003, 63, 5390, 63, 4807, 275, 283, 57, 13, 77, 13, 68, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 57, 13, 77, 13, 68, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 297, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 283, 7968, 13, 709, 13, 821, 297, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 4961, 63, 7321, 63, 14019, 275, 359, 272, 1543, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 1079, 26, 1216, 26, 1427, 7, 272, 1543, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 1079, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 40, 2689, 45, 297, 263, 327, 283, 1079, 26, 1216, 7, 272, 1543, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 1079, 14, 1216, 14, 1427, 7, 272, 1543, 40, 4111, 45, 4111, 51, 4111, 70, 297, 221, 327, 283, 1079, 14, 1216, 14, 1427, 14, 25080, 7, 272, 1543, 40, 4111, 45, 297, 263, 327, 283, 1079, 14, 1216, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 263, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 14, 1216, 14, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 4111, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 4329, 14, 1216, 14, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 14, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 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 ]
[ 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, 57, 971, 77, 14, 662, 1335, 971, 68, 3530, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 199, 12488, 63, 4807, 275, 519, 7, 57, 971, 77, 14, 662, 1335, 971, 68, 2020, 869, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 519, 7, 57, 971, 77, 14, 481, 7, 199, 16413, 63, 11655, 63, 4807, 275, 519, 7, 37, 1335, 971, 68, 3530, 199, 13003, 63, 5390, 63, 4807, 275, 283, 57, 13, 77, 13, 68, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 57, 13, 77, 13, 68, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 297, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 283, 7968, 13, 709, 13, 821, 297, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 4961, 63, 7321, 63, 14019, 275, 359, 272, 1543, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 1079, 26, 1216, 26, 1427, 7, 272, 1543, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 1079, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 40, 2689, 45, 297, 263, 327, 283, 1079, 26, 1216, 7, 272, 1543, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 1079, 14, 1216, 14, 1427, 7, 272, 1543, 40, 4111, 45, 4111, 51, 4111, 70, 297, 221, 327, 283, 1079, 14, 1216, 14, 1427, 14, 25080, 7, 272, 1543, 40, 4111, 45, 297, 263, 327, 283, 1079, 14, 1216, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 263, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 14, 1216, 14, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 4111, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 4329, 14, 1216, 14, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 14, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
thaim/ansible
lib/ansible/modules/storage/purestorage/purefa_connect.py
21
4803
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2018, Simon Dodsley (simon@purestorage.com) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: purefa_connect version_added: '2.9' short_description: Manage replication connections between two FlashArrays description: - Manage array connections to specified target array author: - Pure Storage Ansible Team (@sdodsley) <pure-ansible-team@purestorage.com> options: state: description: - Create or delete array connection default: present type: str choices: [ absent, present ] target_url: description: - Management IP address of remote array. type: str required: true target_api: description: - API token for target array type: str connection: description: Type of connection between arrays. type: str choices: [ sync, async ] default: async extends_documentation_fragment: - purestorage.fa ''' EXAMPLES = r''' - name: Create an async connection to remote array purefa_connect: target_url: 10.10.10.20 target_api: connection: async fa_url: 10.10.10.2 api_token: e31060a7-21fc-e277-6240-25983c6c4592 - name: Delete connection to remote array purefa_connect: state: absent target_url: 10.10.10.20 fa_url: 10.10.10.2 api_token: e31060a7-21fc-e277-6240-25983c6c4592 ''' RETURN = r''' ''' HAS_PURESTORAGE = True try: from purestorage import FlashArray except ImportError: HAS_PURESTORAGE = False import platform from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.pure import get_system, purefa_argument_spec def _check_connected(module, array): connected_arrays = array.list_array_connections() for target in range(0, len(connected_arrays)): if connected_arrays[target]['management_address'] == module.params['target_url'] and \ connected_arrays[target]['connected']: return connected_arrays[target] return None def break_connection(module, array, target_array): """Break connection between arrays""" changed = True if not module.check_mode: source_array = array.get()['array_name'] try: array.disconnect_array(target_array['array_name']) except Exception: module.fail_json(msg="Failed to disconnect {0} from {1}.".format(target_array['array_name'], source_array)) module.exit_json(changed=changed) def create_connection(module, array): """Create connection between arrays""" changed = True if not module.check_mode: remote_array = module.params['target_url'] user_agent = '%(base)s %(class)s/%(version)s (%(platform)s)' % { 'base': 'Ansible', 'class': __name__, 'version': 1.2, 'platform': platform.platform() } try: remote_system = FlashArray(module.params['target_url'], api_token=module.params['target_api'], user_agent=user_agent) connection_key = remote_system.get(connection_key=True)['connection_key'] remote_array = remote_system.get()['array_name'] array.connect_array(module.params['target_url'], connection_key, [module.params['connection']]) except Exception: module.fail_json(msg="Failed to connect to remote array {0}.".format(remote_array)) module.exit_json(changed=changed) def main(): argument_spec = purefa_argument_spec() argument_spec.update(dict( state=dict(type='str', default='present', choices=['absent', 'present']), connection=dict(type='str', default='async', choices=['async', 'sync']), target_url=dict(type='str', required=True), target_api=dict(type='str'), )) required_if = [('state', 'present', ['target_api'])] module = AnsibleModule(argument_spec, required_if=required_if, supports_check_mode=True) if not HAS_PURESTORAGE: module.fail_json(msg='purestorage sdk is required for this module') state = module.params['state'] array = get_system(module) target_array = _check_connected(module, array) if state == 'present' and target_array is None: create_connection(module, array) elif state == 'absent'and target_array is not None: break_connection(module, array, target_array) module.exit_json(changed=False) if __name__ == '__main__': main()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 14894, 12, 10751, 265, 577, 364, 83, 15515, 334, 338, 2106, 32, 5115, 3494, 14, 957, 9, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 15111, 667, 63, 2242, 199, 1023, 63, 3270, 26, 283, 18, 14, 25, 7, 199, 3612, 63, 1802, 26, 14944, 20797, 6947, 3382, 2877, 11040, 1119, 29033, 199, 1802, 26, 199, 13, 14944, 1625, 6947, 370, 2013, 1347, 1625, 199, 2502, 26, 199, 13, 510, 608, 10533, 2622, 11682, 8593, 3893, 364, 83, 15515, 9, 665, 5115, 13, 4853, 13, 5969, 32, 5115, 3494, 14, 957, 30, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 272, 446, 2790, 503, 3145, 1625, 1950, 272, 849, 26, 3451, 272, 730, 26, 620, 272, 3415, 26, 359, 9552, 12, 3451, 1622, 523, 1347, 63, 633, 26, 272, 1369, 26, 272, 446, 8259, 3531, 2287, 402, 3982, 1625, 14, 272, 730, 26, 620, 272, 1415, 26, 2549, 523, 1347, 63, 1246, 26, 272, 1369, 26, 272, 446, 3261, 1526, 367, 1347, 1625, 272, 730, 26, 620, 523, 1950, 26, 272, 1369, 26, 2434, 402, 1950, 3382, 6572, 14, 272, 730, 26, 620, 272, 3415, 26, 359, 7604, 12, 5316, 1622, 272, 849, 26, 5316, 199, 11036, 63, 9970, 63, 7677, 26, 199, 13, 15111, 3494, 14, 667, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2790, 376, 5316, 1950, 370, 3982, 1625, 523, 15111, 667, 63, 2242, 26, 272, 1347, 63, 633, 26, 1616, 14, 709, 14, 709, 14, 1165, 272, 1347, 63, 1246, 26, 272, 1950, 26, 5316, 272, 1433, 63, 633, 26, 1616, 14, 709, 14, 709, 14, 18, 272, 2986, 63, 1418, 26, 325, 18035, 2259, 65, 23, 13, 2025, 3003, 13, 69, 9963, 13, 22, 9873, 13, 11990, 2658, 67, 22, 67, 20, 14098, 199, 199, 13, 536, 26, 8496, 1950, 370, 3982, 1625, 523, 15111, 667, 63, 2242, 26, 272, 1174, 26, 9552, 272, 1347, 63, 633, 26, 1616, 14, 709, 14, 709, 14, 1165, 272, 1433, 63, 633, 26, 1616, 14, 709, 14, 709, 14, 18, 272, 2986, 63, 1418, 26, 325, 18035, 2259, 65, 23, 13, 2025, 3003, 13, 69, 9963, 13, 22, 9873, 13, 11990, 2658, 67, 22, 67, 20, 14098, 199, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 2344, 199, 199, 13533, 63, 48, 1230, 1719, 726, 2962, 275, 715, 199, 893, 26, 272, 687, 15111, 3494, 492, 11040, 1119, 3836, 199, 2590, 3545, 26, 272, 7509, 63, 48, 1230, 1719, 726, 2962, 275, 756, 199, 199, 646, 4298, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 5115, 492, 664, 63, 2253, 12, 15111, 667, 63, 2094, 63, 1650, 421, 199, 318, 485, 1074, 63, 7113, 8, 578, 12, 1625, 304, 272, 8539, 63, 10095, 275, 1625, 14, 513, 63, 1144, 63, 7995, 342, 272, 367, 1347, 315, 1425, 8, 16, 12, 822, 8, 7113, 63, 10095, 2298, 267, 340, 8539, 63, 10095, 59, 1375, 2733, 8110, 63, 1562, 418, 508, 859, 14, 1162, 459, 1375, 63, 633, 418, 436, 971, 1779, 8539, 63, 10095, 59, 1375, 2733, 7113, 2565, 288, 372, 8539, 63, 10095, 59, 1375, 61, 272, 372, 488, 421, 199, 318, 2059, 63, 2105, 8, 578, 12, 1625, 12, 1347, 63, 1144, 304, 272, 408, 13948, 1950, 3382, 6572, 624, 272, 2896, 275, 715, 272, 340, 440, 859, 14, 1074, 63, 632, 26, 267, 1350, 63, 1144, 275, 1625, 14, 362, 12047, 1144, 63, 354, 418, 267, 862, 26, 288, 1625, 14, 10673, 63, 1144, 8, 1375, 63, 1144, 459, 1144, 63, 354, 1105, 267, 871, 2186, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 4276, 370, 17639, 469, 16, 93, 687, 469, 17, 5565, 1674, 908, 8, 1375, 63, 1144, 459, 1144, 63, 354, 995, 1350, 63, 1144, 430, 272, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 9, 421, 199, 318, 1218, 63, 2105, 8, 578, 12, 1625, 304, 272, 408, 2499, 1950, 3382, 6572, 624, 272, 2896, 275, 715, 272, 340, 440, 859, 14, 1074, 63, 632, 26, 267, 3982, 63, 1144, 275, 859, 14, 1162, 459, 1375, 63, 633, 418, 267, 922, 63, 4054, 275, 9487, 1095, 9, 83, 2818, 533, 9, 83, 21275, 1023, 9, 83, 17753, 3246, 9, 83, 3171, 450, 469, 288, 283, 1095, 356, 283, 10047, 297, 288, 283, 533, 356, 636, 354, 3108, 288, 283, 1023, 356, 413, 14, 18, 12, 288, 283, 3246, 356, 4298, 14, 3246, 342, 267, 789, 267, 862, 26, 288, 3982, 63, 2253, 275, 11040, 1119, 3836, 8, 578, 14, 1162, 459, 1375, 63, 633, 995, 4318, 2986, 63, 1418, 29, 578, 14, 1162, 459, 1375, 63, 1246, 995, 4318, 922, 63, 4054, 29, 751, 63, 4054, 9, 288, 1950, 63, 498, 275, 3982, 63, 2253, 14, 362, 8, 2105, 63, 498, 29, 549, 11820, 2105, 63, 498, 418, 288, 3982, 63, 1144, 275, 3982, 63, 2253, 14, 362, 12047, 1144, 63, 354, 418, 288, 1625, 14, 2242, 63, 1144, 8, 578, 14, 1162, 459, 1375, 63, 633, 995, 1950, 63, 498, 12, 359, 578, 14, 1162, 459, 2105, 12121, 267, 871, 2186, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 4276, 370, 4907, 370, 3982, 1625, 469, 16, 5565, 1674, 908, 8, 3846, 63, 1144, 430, 272, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 9, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 15111, 667, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 807 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 14894, 12, 10751, 265, 577, 364, 83, 15515, 334, 338, 2106, 32, 5115, 3494, 14, 957, 9, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 15111, 667, 63, 2242, 199, 1023, 63, 3270, 26, 283, 18, 14, 25, 7, 199, 3612, 63, 1802, 26, 14944, 20797, 6947, 3382, 2877, 11040, 1119, 29033, 199, 1802, 26, 199, 13, 14944, 1625, 6947, 370, 2013, 1347, 1625, 199, 2502, 26, 199, 13, 510, 608, 10533, 2622, 11682, 8593, 3893, 364, 83, 15515, 9, 665, 5115, 13, 4853, 13, 5969, 32, 5115, 3494, 14, 957, 30, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 272, 446, 2790, 503, 3145, 1625, 1950, 272, 849, 26, 3451, 272, 730, 26, 620, 272, 3415, 26, 359, 9552, 12, 3451, 1622, 523, 1347, 63, 633, 26, 272, 1369, 26, 272, 446, 8259, 3531, 2287, 402, 3982, 1625, 14, 272, 730, 26, 620, 272, 1415, 26, 2549, 523, 1347, 63, 1246, 26, 272, 1369, 26, 272, 446, 3261, 1526, 367, 1347, 1625, 272, 730, 26, 620, 523, 1950, 26, 272, 1369, 26, 2434, 402, 1950, 3382, 6572, 14, 272, 730, 26, 620, 272, 3415, 26, 359, 7604, 12, 5316, 1622, 272, 849, 26, 5316, 199, 11036, 63, 9970, 63, 7677, 26, 199, 13, 15111, 3494, 14, 667, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2790, 376, 5316, 1950, 370, 3982, 1625, 523, 15111, 667, 63, 2242, 26, 272, 1347, 63, 633, 26, 1616, 14, 709, 14, 709, 14, 1165, 272, 1347, 63, 1246, 26, 272, 1950, 26, 5316, 272, 1433, 63, 633, 26, 1616, 14, 709, 14, 709, 14, 18, 272, 2986, 63, 1418, 26, 325, 18035, 2259, 65, 23, 13, 2025, 3003, 13, 69, 9963, 13, 22, 9873, 13, 11990, 2658, 67, 22, 67, 20, 14098, 199, 199, 13, 536, 26, 8496, 1950, 370, 3982, 1625, 523, 15111, 667, 63, 2242, 26, 272, 1174, 26, 9552, 272, 1347, 63, 633, 26, 1616, 14, 709, 14, 709, 14, 1165, 272, 1433, 63, 633, 26, 1616, 14, 709, 14, 709, 14, 18, 272, 2986, 63, 1418, 26, 325, 18035, 2259, 65, 23, 13, 2025, 3003, 13, 69, 9963, 13, 22, 9873, 13, 11990, 2658, 67, 22, 67, 20, 14098, 199, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 2344, 199, 199, 13533, 63, 48, 1230, 1719, 726, 2962, 275, 715, 199, 893, 26, 272, 687, 15111, 3494, 492, 11040, 1119, 3836, 199, 2590, 3545, 26, 272, 7509, 63, 48, 1230, 1719, 726, 2962, 275, 756, 199, 199, 646, 4298, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 5115, 492, 664, 63, 2253, 12, 15111, 667, 63, 2094, 63, 1650, 421, 199, 318, 485, 1074, 63, 7113, 8, 578, 12, 1625, 304, 272, 8539, 63, 10095, 275, 1625, 14, 513, 63, 1144, 63, 7995, 342, 272, 367, 1347, 315, 1425, 8, 16, 12, 822, 8, 7113, 63, 10095, 2298, 267, 340, 8539, 63, 10095, 59, 1375, 2733, 8110, 63, 1562, 418, 508, 859, 14, 1162, 459, 1375, 63, 633, 418, 436, 971, 1779, 8539, 63, 10095, 59, 1375, 2733, 7113, 2565, 288, 372, 8539, 63, 10095, 59, 1375, 61, 272, 372, 488, 421, 199, 318, 2059, 63, 2105, 8, 578, 12, 1625, 12, 1347, 63, 1144, 304, 272, 408, 13948, 1950, 3382, 6572, 624, 272, 2896, 275, 715, 272, 340, 440, 859, 14, 1074, 63, 632, 26, 267, 1350, 63, 1144, 275, 1625, 14, 362, 12047, 1144, 63, 354, 418, 267, 862, 26, 288, 1625, 14, 10673, 63, 1144, 8, 1375, 63, 1144, 459, 1144, 63, 354, 1105, 267, 871, 2186, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 4276, 370, 17639, 469, 16, 93, 687, 469, 17, 5565, 1674, 908, 8, 1375, 63, 1144, 459, 1144, 63, 354, 995, 1350, 63, 1144, 430, 272, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 9, 421, 199, 318, 1218, 63, 2105, 8, 578, 12, 1625, 304, 272, 408, 2499, 1950, 3382, 6572, 624, 272, 2896, 275, 715, 272, 340, 440, 859, 14, 1074, 63, 632, 26, 267, 3982, 63, 1144, 275, 859, 14, 1162, 459, 1375, 63, 633, 418, 267, 922, 63, 4054, 275, 9487, 1095, 9, 83, 2818, 533, 9, 83, 21275, 1023, 9, 83, 17753, 3246, 9, 83, 3171, 450, 469, 288, 283, 1095, 356, 283, 10047, 297, 288, 283, 533, 356, 636, 354, 3108, 288, 283, 1023, 356, 413, 14, 18, 12, 288, 283, 3246, 356, 4298, 14, 3246, 342, 267, 789, 267, 862, 26, 288, 3982, 63, 2253, 275, 11040, 1119, 3836, 8, 578, 14, 1162, 459, 1375, 63, 633, 995, 4318, 2986, 63, 1418, 29, 578, 14, 1162, 459, 1375, 63, 1246, 995, 4318, 922, 63, 4054, 29, 751, 63, 4054, 9, 288, 1950, 63, 498, 275, 3982, 63, 2253, 14, 362, 8, 2105, 63, 498, 29, 549, 11820, 2105, 63, 498, 418, 288, 3982, 63, 1144, 275, 3982, 63, 2253, 14, 362, 12047, 1144, 63, 354, 418, 288, 1625, 14, 2242, 63, 1144, 8, 578, 14, 1162, 459, 1375, 63, 633, 995, 1950, 63, 498, 12, 359, 578, 14, 1162, 459, 2105, 12121, 267, 871, 2186, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 4276, 370, 4907, 370, 3982, 1625, 469, 16, 5565, 1674, 908, 8, 3846, 63, 1144, 430, 272, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 9, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 15111, 667, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 807, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Plain-Andy-legacy/android_external_chromium_org
net/tools/testserver/backoff_server.py
189
2760
#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """This is a simple HTTP server for manually testing exponential back-off functionality in Chrome. """ import BaseHTTPServer import sys import urlparse AJAX_TEST_PAGE = ''' <html> <head> <script> function reportResult(txt) { var element = document.createElement('p'); element.innerHTML = txt; document.body.appendChild(element); } function fetch() { var response_code = document.getElementById('response_code'); xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "http://%s:%d/%s?code=" + response_code.value, true); xmlhttp.onreadystatechange = function() { reportResult( 'readyState=' + xmlhttp.readyState + ', status=' + xmlhttp.status); } try { xmlhttp.send(null); } catch (e) { reportResult('Exception: ' + e); } } </script> </head> <body> <form action="javascript:fetch()"> Response code to get: <input id="response_code" type="text" value="503"> <input type="submit"> </form> </body> </html>''' class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): keep_running = True local_ip = '' port = 0 def do_GET(self): if self.path == '/quitquitquit': self.send_response(200) self.send_header('Content-Type', 'text/plain') self.end_headers() self.wfile.write('QUITTING') RequestHandler.keep_running = False return if self.path.startswith('/ajax/'): self.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() self.wfile.write(AJAX_TEST_PAGE % (self.local_ip, self.port, self.path[6:])) return params = urlparse.parse_qs(urlparse.urlparse(self.path).query) if not params or not 'code' in params or params['code'][0] == '200': self.send_response(200) self.send_header('Content-Type', 'text/plain') self.end_headers() self.wfile.write('OK') else: status_code = int(params['code'][0]) self.send_response(status_code) self.end_headers() self.wfile.write('Error %d' % int(status_code)) def main(): if len(sys.argv) != 3: print "Usage: %s LOCAL_IP PORT" % sys.argv[0] sys.exit(1) RequestHandler.local_ip = sys.argv[1] port = int(sys.argv[2]) RequestHandler.port = port print "To stop the server, go to http://localhost:%d/quitquitquit" % port httpd = BaseHTTPServer.HTTPServer(('', port), RequestHandler) while RequestHandler.keep_running: httpd.handle_request() if __name__ == '__main__': main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 2765, 365, 282, 3486, 3101, 1654, 367, 10250, 5343, 23160, 199, 894, 13, 1997, 9330, 315, 16776, 14, 199, 624, 421, 199, 646, 3523, 14938, 199, 646, 984, 199, 646, 7097, 421, 199, 31064, 9839, 63, 2864, 63, 12898, 275, 1449, 199, 28, 1360, 30, 199, 28, 2993, 30, 199, 28, 1579, 30, 199, 199, 1593, 3622, 2889, 8, 2424, 9, 469, 523, 2729, 1819, 275, 2213, 14, 20296, 360, 80, 11339, 523, 1819, 14, 26502, 275, 9444, 27, 523, 2213, 14, 2030, 14, 14988, 8, 2108, 2736, 199, 93, 199, 199, 1593, 5267, 342, 469, 523, 2729, 1177, 63, 600, 275, 2213, 14, 26215, 360, 1310, 63, 600, 11339, 819, 2748, 1014, 275, 892, 4692, 10441, 7303, 523, 2748, 1014, 14, 1490, 480, 2970, 401, 2049, 298, 1014, 13827, 83, 2689, 68, 3149, 83, 31, 600, 628, 435, 1177, 63, 600, 14, 585, 12, 2049, 2549, 2736, 523, 2748, 1014, 14, 265, 2179, 929, 1461, 275, 805, 342, 469, 272, 3622, 2889, 8, 267, 283, 2179, 2223, 534, 435, 2748, 1014, 14, 2179, 2223, 435, 1656, 2004, 534, 435, 2748, 1014, 14, 1205, 2736, 523, 789, 523, 862, 469, 272, 2748, 1014, 14, 2254, 8, 2307, 2736, 523, 789, 8579, 334, 69, 9, 469, 272, 3622, 2889, 360, 1726, 26, 283, 435, 325, 2736, 523, 789, 199, 93, 199, 199, 1108, 1579, 30, 199, 1108, 2993, 30, 199, 28, 2030, 30, 199, 28, 964, 1595, 628, 9554, 26, 3535, 342, 1743, 523, 7232, 1233, 370, 664, 26, 665, 1210, 1305, 628, 1310, 63, 600, 2, 730, 628, 505, 2, 574, 628, 15773, 1743, 523, 665, 1210, 730, 628, 7275, 1743, 199, 1108, 964, 30, 199, 1108, 2030, 30, 199, 1108, 1360, 26934, 421, 199, 533, 4784, 2461, 8, 1563, 14938, 14, 1563, 23518, 304, 523, 4215, 63, 5720, 275, 715, 523, 2257, 63, 711, 275, 2125, 523, 1844, 275, 378, 819, 347, 886, 63, 2970, 8, 277, 304, 272, 340, 291, 14, 515, 508, 1994, 10589, 10589, 10589, 356, 489, 291, 14, 2254, 63, 1310, 8, 1840, 9, 489, 291, 14, 2254, 63, 1291, 360, 2714, 13, 804, 297, 283, 505, 15, 6104, 358, 489, 291, 14, 500, 63, 2139, 342, 489, 291, 14, 18076, 14, 952, 360, 2328, 20779, 1206, 358, 489, 4784, 2461, 14, 3250, 63, 5720, 275, 756, 489, 372, 339, 340, 291, 14, 515, 14, 2460, 2336, 12774, 26985, 489, 291, 14, 2254, 63, 1310, 8, 1840, 9, 489, 291, 14, 2254, 63, 1291, 360, 2714, 13, 804, 297, 283, 505, 15, 1360, 358, 489, 291, 14, 500, 63, 2139, 342, 489, 291, 14, 18076, 14, 952, 8, 31064, 9839, 63, 2864, 63, 12898, 450, 334, 277, 14, 1832, 63, 711, 12, 1460, 291, 14, 719, 12, 1460, 291, 14, 515, 59, 22, 16720, 489, 372, 339, 1862, 275, 7097, 14, 1122, 63, 6177, 8, 10290, 14, 10290, 8, 277, 14, 515, 680, 1131, 9, 339, 340, 440, 1862, 503, 440, 283, 600, 7, 315, 1862, 503, 1862, 459, 600, 3488, 16, 61, 508, 283, 1840, 356, 489, 291, 14, 2254, 63, 1310, 8, 1840, 9, 489, 291, 14, 2254, 63, 1291, 360, 2714, 13, 804, 297, 283, 505, 15, 6104, 358, 489, 291, 14, 500, 63, 2139, 342, 489, 291, 14, 18076, 14, 952, 360, 3593, 358, 272, 587, 26, 489, 2004, 63, 600, 275, 1109, 8, 1162, 459, 600, 3488, 16, 566, 489, 291, 14, 2254, 63, 1310, 8, 1205, 63, 600, 9, 489, 291, 14, 500, 63, 2139, 342, 489, 291, 14, 18076, 14, 952, 360, 547, 450, 68, 7, 450, 1109, 8, 1205, 63, 600, 430, 421, 199, 318, 2446, 837, 523, 340, 822, 8, 1274, 14, 3020, 9, 1137, 650, 26, 272, 870, 298, 7692, 26, 450, 83, 20639, 63, 1772, 25562, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 984, 14, 2224, 8, 17, 9, 523, 4784, 2461, 14, 1832, 63, 711, 275, 984, 14, 3020, 59, 17, 61, 523, 1844, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 523, 4784, 2461, 14, 719, 275, 1844, 523, 870, 298, 1378, 3631, 314, 1654, 12, 2621, 370, 1455, 921, 5967, 2689, 68, 15, 10589, 10589, 10589, 2, 450, 1844, 523, 23913, 275, 3523, 14938, 14, 14938, 4725, 297, 1844, 395, 4784, 2461, 9, 523, 1830, 4784, 2461, 14, 3250, 63, 5720, 26, 272, 23913, 14, 2479, 63, 1069, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 2765, 365, 282, 3486, 3101, 1654, 367, 10250, 5343, 23160, 199, 894, 13, 1997, 9330, 315, 16776, 14, 199, 624, 421, 199, 646, 3523, 14938, 199, 646, 984, 199, 646, 7097, 421, 199, 31064, 9839, 63, 2864, 63, 12898, 275, 1449, 199, 28, 1360, 30, 199, 28, 2993, 30, 199, 28, 1579, 30, 199, 199, 1593, 3622, 2889, 8, 2424, 9, 469, 523, 2729, 1819, 275, 2213, 14, 20296, 360, 80, 11339, 523, 1819, 14, 26502, 275, 9444, 27, 523, 2213, 14, 2030, 14, 14988, 8, 2108, 2736, 199, 93, 199, 199, 1593, 5267, 342, 469, 523, 2729, 1177, 63, 600, 275, 2213, 14, 26215, 360, 1310, 63, 600, 11339, 819, 2748, 1014, 275, 892, 4692, 10441, 7303, 523, 2748, 1014, 14, 1490, 480, 2970, 401, 2049, 298, 1014, 13827, 83, 2689, 68, 3149, 83, 31, 600, 628, 435, 1177, 63, 600, 14, 585, 12, 2049, 2549, 2736, 523, 2748, 1014, 14, 265, 2179, 929, 1461, 275, 805, 342, 469, 272, 3622, 2889, 8, 267, 283, 2179, 2223, 534, 435, 2748, 1014, 14, 2179, 2223, 435, 1656, 2004, 534, 435, 2748, 1014, 14, 1205, 2736, 523, 789, 523, 862, 469, 272, 2748, 1014, 14, 2254, 8, 2307, 2736, 523, 789, 8579, 334, 69, 9, 469, 272, 3622, 2889, 360, 1726, 26, 283, 435, 325, 2736, 523, 789, 199, 93, 199, 199, 1108, 1579, 30, 199, 1108, 2993, 30, 199, 28, 2030, 30, 199, 28, 964, 1595, 628, 9554, 26, 3535, 342, 1743, 523, 7232, 1233, 370, 664, 26, 665, 1210, 1305, 628, 1310, 63, 600, 2, 730, 628, 505, 2, 574, 628, 15773, 1743, 523, 665, 1210, 730, 628, 7275, 1743, 199, 1108, 964, 30, 199, 1108, 2030, 30, 199, 1108, 1360, 26934, 421, 199, 533, 4784, 2461, 8, 1563, 14938, 14, 1563, 23518, 304, 523, 4215, 63, 5720, 275, 715, 523, 2257, 63, 711, 275, 2125, 523, 1844, 275, 378, 819, 347, 886, 63, 2970, 8, 277, 304, 272, 340, 291, 14, 515, 508, 1994, 10589, 10589, 10589, 356, 489, 291, 14, 2254, 63, 1310, 8, 1840, 9, 489, 291, 14, 2254, 63, 1291, 360, 2714, 13, 804, 297, 283, 505, 15, 6104, 358, 489, 291, 14, 500, 63, 2139, 342, 489, 291, 14, 18076, 14, 952, 360, 2328, 20779, 1206, 358, 489, 4784, 2461, 14, 3250, 63, 5720, 275, 756, 489, 372, 339, 340, 291, 14, 515, 14, 2460, 2336, 12774, 26985, 489, 291, 14, 2254, 63, 1310, 8, 1840, 9, 489, 291, 14, 2254, 63, 1291, 360, 2714, 13, 804, 297, 283, 505, 15, 1360, 358, 489, 291, 14, 500, 63, 2139, 342, 489, 291, 14, 18076, 14, 952, 8, 31064, 9839, 63, 2864, 63, 12898, 450, 334, 277, 14, 1832, 63, 711, 12, 1460, 291, 14, 719, 12, 1460, 291, 14, 515, 59, 22, 16720, 489, 372, 339, 1862, 275, 7097, 14, 1122, 63, 6177, 8, 10290, 14, 10290, 8, 277, 14, 515, 680, 1131, 9, 339, 340, 440, 1862, 503, 440, 283, 600, 7, 315, 1862, 503, 1862, 459, 600, 3488, 16, 61, 508, 283, 1840, 356, 489, 291, 14, 2254, 63, 1310, 8, 1840, 9, 489, 291, 14, 2254, 63, 1291, 360, 2714, 13, 804, 297, 283, 505, 15, 6104, 358, 489, 291, 14, 500, 63, 2139, 342, 489, 291, 14, 18076, 14, 952, 360, 3593, 358, 272, 587, 26, 489, 2004, 63, 600, 275, 1109, 8, 1162, 459, 600, 3488, 16, 566, 489, 291, 14, 2254, 63, 1310, 8, 1205, 63, 600, 9, 489, 291, 14, 500, 63, 2139, 342, 489, 291, 14, 18076, 14, 952, 360, 547, 450, 68, 7, 450, 1109, 8, 1205, 63, 600, 430, 421, 199, 318, 2446, 837, 523, 340, 822, 8, 1274, 14, 3020, 9, 1137, 650, 26, 272, 870, 298, 7692, 26, 450, 83, 20639, 63, 1772, 25562, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 984, 14, 2224, 8, 17, 9, 523, 4784, 2461, 14, 1832, 63, 711, 275, 984, 14, 3020, 59, 17, 61, 523, 1844, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 523, 4784, 2461, 14, 719, 275, 1844, 523, 870, 298, 1378, 3631, 314, 1654, 12, 2621, 370, 1455, 921, 5967, 2689, 68, 15, 10589, 10589, 10589, 2, 450, 1844, 523, 23913, 275, 3523, 14938, 14, 14938, 4725, 297, 1844, 395, 4784, 2461, 9, 523, 1830, 4784, 2461, 14, 3250, 63, 5720, 26, 272, 23913, 14, 2479, 63, 1069, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nmoya/whatsapp-parser
wp_parser/parsers/facebook.py
3
1029
from datetime import datetime import message class ParserFacebook(): ''' A line is a dict object in this format: {u'message': u'text text', u'from': u'Username One', u'id': u'3294659605566648_1432085429', u'datetime': u'2015-05-20T01:30:29+0000'} ''' def __init__(self, raw_messages): self.raw_messages = raw_messages def parse(self): list_of_messages = [] set_of_senders = set() for l in self.raw_messages: content = l["message"].encode("utf-8") sender = l["from"].encode("utf-8") datetime_str = l["datetime"].encode("utf-8") date, time = datetime_str.split("T") time = time.replace("+0000", "") msg_date = date + " " + time datetime_obj = datetime.strptime(msg_date, "%Y-%m-%d %H:%M:%S") set_of_senders.add(sender) list_of_messages.append(message.Message(sender, content, date, time, datetime_obj)) return list(set_of_senders), list_of_messages
mit
[ 504, 2197, 492, 2197, 199, 646, 1245, 199, 199, 533, 10191, 13414, 2706, 837, 339, 1449, 437, 1004, 365, 282, 1211, 909, 315, 642, 1475, 26, 272, 469, 85, 6704, 69, 712, 356, 399, 1133, 832, 1318, 297, 399, 7, 504, 356, 399, 7, 13355, 7309, 297, 399, 7, 344, 356, 267, 399, 7, 11685, 2466, 1427, 2259, 1229, 1272, 10552, 63, 1079, 708, 2036, 1477, 1398, 297, 399, 5121, 323, 521, 356, 399, 7, 7806, 13, 1717, 13, 1165, 52, 614, 26, 1216, 26, 1398, 11, 993, 936, 272, 1449, 339, 347, 636, 826, 721, 277, 12, 3066, 63, 3431, 304, 267, 291, 14, 1773, 63, 3431, 275, 3066, 63, 3431, 339, 347, 2198, 8, 277, 304, 267, 769, 63, 1618, 63, 3431, 275, 942, 267, 663, 63, 1618, 63, 2464, 7735, 275, 663, 342, 267, 367, 634, 315, 291, 14, 1773, 63, 3431, 26, 288, 1564, 275, 634, 905, 1188, 4140, 2143, 480, 1624, 13, 24, 531, 288, 8904, 275, 634, 905, 504, 4140, 2143, 480, 1624, 13, 24, 531, 288, 2197, 63, 495, 275, 634, 905, 2083, 4140, 2143, 480, 1624, 13, 24, 531, 288, 1434, 12, 900, 275, 2197, 63, 495, 14, 1294, 480, 52, 531, 288, 900, 275, 900, 14, 1814, 28819, 993, 401, 6899, 288, 1499, 63, 602, 275, 1434, 435, 298, 298, 435, 900, 288, 2197, 63, 1113, 275, 2197, 14, 9866, 8, 1328, 63, 602, 12, 2071, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 953, 663, 63, 1618, 63, 2464, 7735, 14, 525, 8, 8114, 9, 288, 769, 63, 1618, 63, 3431, 14, 740, 8, 1188, 14, 2209, 8, 8114, 12, 1564, 12, 1434, 12, 900, 12, 2197, 63, 1113, 430, 398, 372, 769, 8, 409, 63, 1618, 63, 2464, 7735, 395, 769, 63, 1618, 63, 3431, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2197, 492, 2197, 199, 646, 1245, 199, 199, 533, 10191, 13414, 2706, 837, 339, 1449, 437, 1004, 365, 282, 1211, 909, 315, 642, 1475, 26, 272, 469, 85, 6704, 69, 712, 356, 399, 1133, 832, 1318, 297, 399, 7, 504, 356, 399, 7, 13355, 7309, 297, 399, 7, 344, 356, 267, 399, 7, 11685, 2466, 1427, 2259, 1229, 1272, 10552, 63, 1079, 708, 2036, 1477, 1398, 297, 399, 5121, 323, 521, 356, 399, 7, 7806, 13, 1717, 13, 1165, 52, 614, 26, 1216, 26, 1398, 11, 993, 936, 272, 1449, 339, 347, 636, 826, 721, 277, 12, 3066, 63, 3431, 304, 267, 291, 14, 1773, 63, 3431, 275, 3066, 63, 3431, 339, 347, 2198, 8, 277, 304, 267, 769, 63, 1618, 63, 3431, 275, 942, 267, 663, 63, 1618, 63, 2464, 7735, 275, 663, 342, 267, 367, 634, 315, 291, 14, 1773, 63, 3431, 26, 288, 1564, 275, 634, 905, 1188, 4140, 2143, 480, 1624, 13, 24, 531, 288, 8904, 275, 634, 905, 504, 4140, 2143, 480, 1624, 13, 24, 531, 288, 2197, 63, 495, 275, 634, 905, 2083, 4140, 2143, 480, 1624, 13, 24, 531, 288, 1434, 12, 900, 275, 2197, 63, 495, 14, 1294, 480, 52, 531, 288, 900, 275, 900, 14, 1814, 28819, 993, 401, 6899, 288, 1499, 63, 602, 275, 1434, 435, 298, 298, 435, 900, 288, 2197, 63, 1113, 275, 2197, 14, 9866, 8, 1328, 63, 602, 12, 2071, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 953, 663, 63, 1618, 63, 2464, 7735, 14, 525, 8, 8114, 9, 288, 769, 63, 1618, 63, 3431, 14, 740, 8, 1188, 14, 2209, 8, 8114, 12, 1564, 12, 1434, 12, 900, 12, 2197, 63, 1113, 430, 398, 372, 769, 8, 409, 63, 1618, 63, 2464, 7735, 395, 769, 63, 1618, 63, 3431, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
C-Pro/pgdocgen
pgdocgen/ddlobject/schema.py
1
1808
'''Schema description module''' import copy from pgdocgen.ddlobject.ddlobject import DDLObject from pgdocgen.utils import get_logger class Schema(DDLObject): '''SQL schema class''' contents = [] def read_contents(self, name, conn): '''Read schema tables''' sql = '''select c.relname, d.description, case c.relkind when 'r' then 'table' when 'v' then 'view' when 'm' then 'materialized view' when 'f' then 'foreign table' end as table_type from pg_catalog.pg_class c join pg_catalog.pg_namespace n on n.oid = c.relnamespace left join pg_catalog.pg_description d on (d.objoid = c.oid) where c.relkind in ('r','v','m','f') and n.nspname = %s and n.nspname not like 'pg\_%%' and n.nspname not in ('information_schema') and coalesce(d.objsubid,0) = 0 order by c.relname''' log = get_logger() cur = conn.cursor() cur.execute(sql, [name]) tables = cur.fetchall() from pgdocgen.ddlobject.table import Table for table in tables: table_obj = Table(name, table[0], table[1], table[2], conn) log.debug('{}: {}'.format(table[0], table[1])) self.contents.append(copy.deepcopy(table_obj)) cur.close() def __init__(self, name, comment, conn): '''Schema object constructor''' self.contents = [] self.object_type = 'schema' self.comment = comment self.object_name = name self.read_contents(name, conn)
gpl-2.0
[ 2344, 6700, 1369, 859, 2344, 199, 646, 1331, 199, 504, 10275, 1301, 2268, 14, 617, 27789, 14, 617, 27789, 492, 29662, 30113, 199, 504, 10275, 1301, 2268, 14, 1208, 492, 664, 63, 2921, 421, 199, 533, 13268, 8, 5745, 30113, 304, 272, 1449, 4657, 4177, 1021, 2344, 339, 4072, 275, 942, 339, 347, 1586, 63, 4407, 8, 277, 12, 536, 12, 2557, 304, 267, 1449, 3284, 4177, 6716, 2344, 267, 3875, 275, 1449, 2416, 286, 14, 3369, 354, 12, 717, 366, 14, 1802, 12, 717, 1930, 286, 14, 3369, 5091, 2079, 1380, 283, 82, 7, 2066, 283, 1224, 7, 2079, 1380, 283, 86, 7, 2066, 283, 1345, 7, 2079, 1380, 283, 77, 7, 2066, 283, 9820, 1759, 2455, 7, 2079, 1380, 283, 70, 7, 2066, 283, 6846, 1817, 7, 717, 1284, 465, 1817, 63, 466, 2116, 687, 10275, 63, 7959, 14, 4198, 63, 533, 286, 2116, 4263, 10275, 63, 7959, 14, 4198, 63, 3251, 302, 641, 302, 14, 1170, 275, 286, 14, 3369, 3251, 2116, 3602, 4263, 10275, 63, 7959, 14, 4198, 63, 1802, 366, 641, 334, 68, 14, 1113, 1170, 275, 286, 14, 1170, 9, 355, 2382, 286, 14, 3369, 5091, 315, 661, 82, 1673, 86, 1673, 77, 1673, 70, 358, 436, 1993, 302, 14, 561, 23346, 275, 450, 83, 436, 1993, 302, 14, 561, 23346, 440, 2839, 283, 4198, 60, 4970, 5, 7, 436, 1993, 302, 14, 561, 23346, 440, 315, 661, 11697, 63, 3629, 358, 436, 1993, 512, 29944, 8, 68, 14, 1113, 954, 344, 12, 16, 9, 275, 378, 1467, 1865, 701, 286, 14, 3369, 354, 2344, 267, 943, 275, 664, 63, 2921, 342, 267, 1094, 275, 2557, 14, 3937, 342, 267, 1094, 14, 2526, 8, 3009, 12, 359, 354, 566, 267, 6716, 275, 1094, 14, 10174, 342, 267, 687, 10275, 1301, 2268, 14, 617, 27789, 14, 1224, 492, 6957, 267, 367, 1817, 315, 6716, 26, 288, 1817, 63, 1113, 275, 6957, 8, 354, 12, 1817, 59, 16, 467, 1817, 59, 17, 467, 1817, 59, 18, 467, 2557, 9, 288, 943, 14, 1757, 17519, 26, 9499, 908, 8, 1224, 59, 16, 467, 1817, 59, 17, 2459, 288, 291, 14, 4407, 14, 740, 8, 1574, 14, 8293, 8, 1224, 63, 1113, 430, 267, 1094, 14, 1600, 342, 339, 347, 636, 826, 721, 277, 12, 536, 12, 3721, 12, 2557, 304, 267, 1449, 6700, 909, 3787, 2344, 267, 291, 14, 4407, 275, 942, 267, 291, 14, 785, 63, 466, 275, 283, 3629, 7, 267, 291, 14, 3349, 275, 3721, 267, 291, 14, 785, 63, 354, 275, 536, 267, 291, 14, 739, 63, 4407, 8, 354, 12, 2557, 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 ]
[ 6700, 1369, 859, 2344, 199, 646, 1331, 199, 504, 10275, 1301, 2268, 14, 617, 27789, 14, 617, 27789, 492, 29662, 30113, 199, 504, 10275, 1301, 2268, 14, 1208, 492, 664, 63, 2921, 421, 199, 533, 13268, 8, 5745, 30113, 304, 272, 1449, 4657, 4177, 1021, 2344, 339, 4072, 275, 942, 339, 347, 1586, 63, 4407, 8, 277, 12, 536, 12, 2557, 304, 267, 1449, 3284, 4177, 6716, 2344, 267, 3875, 275, 1449, 2416, 286, 14, 3369, 354, 12, 717, 366, 14, 1802, 12, 717, 1930, 286, 14, 3369, 5091, 2079, 1380, 283, 82, 7, 2066, 283, 1224, 7, 2079, 1380, 283, 86, 7, 2066, 283, 1345, 7, 2079, 1380, 283, 77, 7, 2066, 283, 9820, 1759, 2455, 7, 2079, 1380, 283, 70, 7, 2066, 283, 6846, 1817, 7, 717, 1284, 465, 1817, 63, 466, 2116, 687, 10275, 63, 7959, 14, 4198, 63, 533, 286, 2116, 4263, 10275, 63, 7959, 14, 4198, 63, 3251, 302, 641, 302, 14, 1170, 275, 286, 14, 3369, 3251, 2116, 3602, 4263, 10275, 63, 7959, 14, 4198, 63, 1802, 366, 641, 334, 68, 14, 1113, 1170, 275, 286, 14, 1170, 9, 355, 2382, 286, 14, 3369, 5091, 315, 661, 82, 1673, 86, 1673, 77, 1673, 70, 358, 436, 1993, 302, 14, 561, 23346, 275, 450, 83, 436, 1993, 302, 14, 561, 23346, 440, 2839, 283, 4198, 60, 4970, 5, 7, 436, 1993, 302, 14, 561, 23346, 440, 315, 661, 11697, 63, 3629, 358, 436, 1993, 512, 29944, 8, 68, 14, 1113, 954, 344, 12, 16, 9, 275, 378, 1467, 1865, 701, 286, 14, 3369, 354, 2344, 267, 943, 275, 664, 63, 2921, 342, 267, 1094, 275, 2557, 14, 3937, 342, 267, 1094, 14, 2526, 8, 3009, 12, 359, 354, 566, 267, 6716, 275, 1094, 14, 10174, 342, 267, 687, 10275, 1301, 2268, 14, 617, 27789, 14, 1224, 492, 6957, 267, 367, 1817, 315, 6716, 26, 288, 1817, 63, 1113, 275, 6957, 8, 354, 12, 1817, 59, 16, 467, 1817, 59, 17, 467, 1817, 59, 18, 467, 2557, 9, 288, 943, 14, 1757, 17519, 26, 9499, 908, 8, 1224, 59, 16, 467, 1817, 59, 17, 2459, 288, 291, 14, 4407, 14, 740, 8, 1574, 14, 8293, 8, 1224, 63, 1113, 430, 267, 1094, 14, 1600, 342, 339, 347, 636, 826, 721, 277, 12, 536, 12, 3721, 12, 2557, 304, 267, 1449, 6700, 909, 3787, 2344, 267, 291, 14, 4407, 275, 942, 267, 291, 14, 785, 63, 466, 275, 283, 3629, 7, 267, 291, 14, 3349, 275, 3721, 267, 291, 14, 785, 63, 354, 275, 536, 267, 291, 14, 739, 63, 4407, 8, 354, 12, 2557, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
horczech/coala-bears
bears/python/PyUnusedCodeBear.py
5
1681
import autoflake from coalib.bears.LocalBear import LocalBear from dependency_management.requirements.PipRequirement import PipRequirement from coalib.results.Diff import Diff from coalib.results.Result import Result class PyUnusedCodeBear(LocalBear): LANGUAGES = {'Python', 'Python 2', 'Python 3'} REQUIREMENTS = {PipRequirement('autoflake', '0.6.6')} AUTHORS = {'The coala developers'} AUTHORS_EMAILS = {'coala-devel@googlegroups.com'} LICENSE = 'AGPL-3.0' CAN_DETECT = {'Unused Code'} def run(self, filename, file, remove_all_unused_imports: bool=True, remove_unused_variables: bool=True): """ Detects unused code. By default this functionality is limited to: - Unneeded pass statements. - All unused imports - might have side effects - Unused variables - might have side effects :param remove_all_unused_imports: ``False`` removes only unused builtin imports :param remove_unused_variables: ``False`` keeps unused variables """ corrected = autoflake.fix_code( ''.join(file), additional_imports=None, remove_all_unused_imports=remove_all_unused_imports, remove_unused_variables=remove_unused_variables ).splitlines(True) for diff in Diff.from_string_arrays(file, corrected).split_diff(): yield Result(self, 'This file contains unused source code.', affected_code=(diff.range(filename),), diffs={filename: diff})
agpl-3.0
[ 646, 2599, 14163, 415, 199, 199, 504, 512, 25530, 14, 1235, 4291, 14, 5339, 30860, 492, 10111, 30860, 199, 504, 5936, 63, 8110, 14, 7538, 14, 32457, 17947, 492, 510, 711, 17947, 199, 504, 512, 25530, 14, 2604, 14, 10746, 492, 27134, 199, 504, 512, 25530, 14, 2604, 14, 2889, 492, 10695, 421, 199, 533, 1611, 20782, 3034, 30860, 8, 5339, 30860, 304, 272, 30508, 5383, 275, 791, 4718, 297, 283, 4718, 499, 297, 283, 4718, 650, 936, 272, 17023, 21201, 20967, 275, 469, 32457, 17947, 360, 2495, 14163, 415, 297, 283, 16, 14, 22, 14, 22, 21004, 272, 10610, 275, 791, 1918, 512, 14774, 19782, 936, 272, 10610, 63, 10089, 51, 275, 791, 331, 14774, 13, 27870, 32, 3098, 2634, 14, 957, 936, 272, 5113, 275, 283, 1254, 2749, 13, 19, 14, 16, 7, 272, 29661, 63, 17442, 3582, 275, 791, 20782, 5495, 936, 339, 347, 1255, 8, 277, 12, 1788, 12, 570, 12, 288, 2813, 63, 452, 63, 8618, 63, 12775, 26, 2155, 29, 549, 12, 288, 2813, 63, 8618, 63, 3669, 26, 2155, 29, 549, 304, 267, 408, 267, 1487, 28853, 9563, 1233, 14, 4885, 849, 642, 9330, 365, 13988, 370, 26, 398, 446, 1910, 11368, 986, 9834, 14, 267, 446, 2900, 9563, 8925, 446, 5594, 1172, 5366, 22414, 267, 446, 1910, 2972, 2860, 446, 5594, 1172, 5366, 22414, 398, 520, 635, 2813, 63, 452, 63, 8618, 63, 12775, 26, 288, 1124, 797, 1040, 14185, 1454, 9563, 6762, 8925, 267, 520, 635, 2813, 63, 8618, 63, 3669, 26, 288, 1124, 797, 1040, 18578, 9563, 2860, 267, 408, 398, 30156, 275, 2599, 14163, 415, 14, 970, 63, 600, 8, 2432, 6522, 904, 8, 493, 395, 2432, 4722, 63, 12775, 29, 403, 12, 2432, 2813, 63, 452, 63, 8618, 63, 12775, 29, 2168, 63, 452, 63, 8618, 63, 12775, 12, 2432, 2813, 63, 8618, 63, 3669, 29, 2168, 63, 8618, 63, 3669, 2432, 7092, 7644, 8, 549, 9, 398, 367, 3915, 315, 27134, 14, 504, 63, 875, 63, 10095, 8, 493, 12, 30156, 680, 1294, 63, 3028, 837, 288, 1995, 10695, 8, 277, 12, 586, 283, 2765, 570, 3509, 9563, 1350, 1233, 3130, 586, 16955, 63, 600, 2687, 3028, 14, 1842, 8, 1501, 30148, 586, 14981, 3126, 1501, 26, 3915, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2599, 14163, 415, 199, 199, 504, 512, 25530, 14, 1235, 4291, 14, 5339, 30860, 492, 10111, 30860, 199, 504, 5936, 63, 8110, 14, 7538, 14, 32457, 17947, 492, 510, 711, 17947, 199, 504, 512, 25530, 14, 2604, 14, 10746, 492, 27134, 199, 504, 512, 25530, 14, 2604, 14, 2889, 492, 10695, 421, 199, 533, 1611, 20782, 3034, 30860, 8, 5339, 30860, 304, 272, 30508, 5383, 275, 791, 4718, 297, 283, 4718, 499, 297, 283, 4718, 650, 936, 272, 17023, 21201, 20967, 275, 469, 32457, 17947, 360, 2495, 14163, 415, 297, 283, 16, 14, 22, 14, 22, 21004, 272, 10610, 275, 791, 1918, 512, 14774, 19782, 936, 272, 10610, 63, 10089, 51, 275, 791, 331, 14774, 13, 27870, 32, 3098, 2634, 14, 957, 936, 272, 5113, 275, 283, 1254, 2749, 13, 19, 14, 16, 7, 272, 29661, 63, 17442, 3582, 275, 791, 20782, 5495, 936, 339, 347, 1255, 8, 277, 12, 1788, 12, 570, 12, 288, 2813, 63, 452, 63, 8618, 63, 12775, 26, 2155, 29, 549, 12, 288, 2813, 63, 8618, 63, 3669, 26, 2155, 29, 549, 304, 267, 408, 267, 1487, 28853, 9563, 1233, 14, 4885, 849, 642, 9330, 365, 13988, 370, 26, 398, 446, 1910, 11368, 986, 9834, 14, 267, 446, 2900, 9563, 8925, 446, 5594, 1172, 5366, 22414, 267, 446, 1910, 2972, 2860, 446, 5594, 1172, 5366, 22414, 398, 520, 635, 2813, 63, 452, 63, 8618, 63, 12775, 26, 288, 1124, 797, 1040, 14185, 1454, 9563, 6762, 8925, 267, 520, 635, 2813, 63, 8618, 63, 3669, 26, 288, 1124, 797, 1040, 18578, 9563, 2860, 267, 408, 398, 30156, 275, 2599, 14163, 415, 14, 970, 63, 600, 8, 2432, 6522, 904, 8, 493, 395, 2432, 4722, 63, 12775, 29, 403, 12, 2432, 2813, 63, 452, 63, 8618, 63, 12775, 29, 2168, 63, 452, 63, 8618, 63, 12775, 12, 2432, 2813, 63, 8618, 63, 3669, 29, 2168, 63, 8618, 63, 3669, 2432, 7092, 7644, 8, 549, 9, 398, 367, 3915, 315, 27134, 14, 504, 63, 875, 63, 10095, 8, 493, 12, 30156, 680, 1294, 63, 3028, 837, 288, 1995, 10695, 8, 277, 12, 586, 283, 2765, 570, 3509, 9563, 1350, 1233, 3130, 586, 16955, 63, 600, 2687, 3028, 14, 1842, 8, 1501, 30148, 586, 14981, 3126, 1501, 26, 3915, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
pquentin/libcloud
libcloud/compute/types.py
2
11687
# 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. """ Base types used by other parts of libcloud """ from libcloud.common.types import LibcloudError, MalformedResponseError from libcloud.common.types import InvalidCredsError, InvalidCredsException __all__ = [ "Provider", "NodeState", "DeploymentError", "DeploymentException", # @@TR: should the unused imports below be exported? "LibcloudError", "MalformedResponseError", "InvalidCredsError", "InvalidCredsException", "OLD_CONSTANT_TO_NEW_MAPPING" ] class Type(object): @classmethod def tostring(cls, value): """Return the string representation of the state object attribute :param str value: the state object to turn into string :return: the uppercase string that represents the state object :rtype: str """ return value.upper() @classmethod def fromstring(cls, value): """Return the state object attribute that matches the string :param str value: the string to look up :return: the state object attribute that matches the string :rtype: str """ return getattr(cls, value.upper(), None) class Provider(Type): """ Defines for each of the supported providers Non-Dummy drivers are sorted in alphabetical order. Please preserve this ordering when adding new drivers. :cvar DUMMY: Example provider :cvar ABIQUO: Abiquo driver :cvar ALIYUN_ECS: Aliyun ECS driver. :cvar AURORACOMPUTE: Aurora Compute driver. :cvar AZURE: Azure (classic) driver. :cvar AZURE_ARM: Azure Resource Manager (modern) driver. :cvar BLUEBOX: Bluebox :cvar CLOUDSIGMA: CloudSigma :cvar CLOUDSCALE: cloudscale.ch :cvar CLOUDSTACK: CloudStack :cvar DIMENSIONDATA: Dimension Data Cloud :cvar EC2: Amazon AWS. :cvar ECP: Enomaly :cvar ELASTICHOSTS: ElasticHosts.com :cvar EXOSCALE: Exoscale driver. :cvar GCE: Google Compute Engine :cvar GOGRID: GoGrid :cvar GRIDSPOT: Gridspot driver :cvar IBM: IBM Developer Cloud :cvar IKOULA: Ikoula driver. :cvar JOYENT: Joyent driver :cvar KTUCLOUD: kt ucloud driver :cvar LIBVIRT: Libvirt driver :cvar LINODE: Linode.com :cvar NEPHOSCALE: NephoScale driver :cvar NIMBUS: Nimbus :cvar NINEFOLD: Ninefold :cvar OPENNEBULA: OpenNebula.org :cvar OPSOURCE: Opsource Cloud :cvar OUTSCALE_INC: Outscale INC driver. :cvar OUTSCALE_SAS: Outscale SAS driver. :cvar PROFIT_BRICKS: ProfitBricks driver. :cvar RACKSPACE: Rackspace next-gen OpenStack based Cloud Servers :cvar RACKSPACE_FIRST_GEN: Rackspace First Gen Cloud Servers :cvar RIMUHOSTING: RimuHosting.com :cvar TERREMARK: Terremark :cvar UPCLOUD: UpCloud :cvar VCL: VCL driver :cvar VCLOUD: vmware vCloud :cvar VPSNET: VPS.net :cvar VULTR: vultr driver. """ AZURE = 'azure' AZURE_ARM = 'azure_arm' DUMMY = 'dummy' ABIQUO = 'abiquo' ALIYUN_ECS = 'aliyun_ecs' AURORACOMPUTE = 'aurora_compute' AZURE = 'azure' BLUEBOX = 'bluebox' BRIGHTBOX = 'brightbox' BSNL = 'bsnl' CISCOCCS = 'ciscoccs' CLOUDFRAMES = 'cloudframes' CLOUDSIGMA = 'cloudsigma' CLOUDSCALE = 'cloudscale' CLOUDSTACK = 'cloudstack' CLOUDWATT = 'cloudwatt' DIGITAL_OCEAN = 'digitalocean' DIMENSIONDATA = 'dimensiondata' EC2 = 'ec2' ECP = 'ecp' ELASTICHOSTS = 'elastichosts' EUCALYPTUS = 'eucalyptus' EXOSCALE = 'exoscale' GANDI = 'gandi' GCE = 'gce' GOGRID = 'gogrid' GRIDSPOT = 'gridspot' HOSTVIRTUAL = 'hostvirtual' IBM = 'ibm' IKOULA = 'ikoula' INDOSAT = 'indosat' INTERNETSOLUTIONS = 'internetsolutions' JOYENT = 'joyent' KTUCLOUD = 'ktucloud' LIBVIRT = 'libvirt' LINODE = 'linode' MEDONE = 'medone' NEPHOSCALE = 'nephoscale' NIMBUS = 'nimbus' NINEFOLD = 'ninefold' NTTA = 'ntta' ONEANDONE = 'oneandone' OPENNEBULA = 'opennebula' OPENSTACK = 'openstack' OPSOURCE = 'opsource' OUTSCALE_INC = 'outscale_inc' OUTSCALE_SAS = 'outscale_sas' OVH = 'ovh' PACKET = 'packet' PROFIT_BRICKS = 'profitbricks' RACKSPACE = 'rackspace' RACKSPACE_FIRST_GEN = 'rackspace_first_gen' RIMUHOSTING = 'rimuhosting' RUNABOVE = 'runabove' SERVERLOVE = 'serverlove' SKALICLOUD = 'skalicloud' SOFTLAYER = 'softlayer' TERREMARK = 'terremark' UPCLOUD = 'upcloud' VCL = 'vcl' VCLOUD = 'vcloud' VOXEL = 'voxel' VPSNET = 'vpsnet' VSPHERE = 'vsphere' VULTR = 'vultr' # OpenStack based providers CLOUDWATT = 'cloudwatt' HPCLOUD = 'hpcloud' KILI = 'kili' ONAPP = 'onapp' # Deprecated constants which aren't supported anymore RACKSPACE_UK = 'rackspace_uk' RACKSPACE_NOVA_BETA = 'rackspace_nova_beta' RACKSPACE_NOVA_DFW = 'rackspace_nova_dfw' RACKSPACE_NOVA_LON = 'rackspace_nova_lon' RACKSPACE_NOVA_ORD = 'rackspace_nova_ord' EC2_US_EAST = 'ec2_us_east' EC2_US_EAST_OHIO = 'ec2_us_east_ohio' EC2_EU = 'ec2_eu_west' # deprecated name EC2_EU_WEST = 'ec2_eu_west' EC2_EU_WEST2 = 'ec2_eu_west_london' EC2_US_WEST = 'ec2_us_west' EC2_AP_SOUTHEAST = 'ec2_ap_southeast' EC2_AP_NORTHEAST = 'ec2_ap_northeast' EC2_AP_NORTHEAST1 = 'ec2_ap_northeast_1' EC2_AP_NORTHEAST2 = 'ec2_ap_northeast_2' EC2_US_WEST_OREGON = 'ec2_us_west_oregon' EC2_SA_EAST = 'ec2_sa_east' EC2_AP_SOUTHEAST2 = 'ec2_ap_southeast_2' EC2_CA_CENTRAL1 = 'ec2_ca_central_1' ELASTICHOSTS_UK1 = 'elastichosts_uk1' ELASTICHOSTS_UK2 = 'elastichosts_uk2' ELASTICHOSTS_US1 = 'elastichosts_us1' ELASTICHOSTS_US2 = 'elastichosts_us2' ELASTICHOSTS_US3 = 'elastichosts_us3' ELASTICHOSTS_CA1 = 'elastichosts_ca1' ELASTICHOSTS_AU1 = 'elastichosts_au1' ELASTICHOSTS_CN1 = 'elastichosts_cn1' CLOUDSIGMA_US = 'cloudsigma_us' # Removed # SLICEHOST = 'slicehost' DEPRECATED_RACKSPACE_PROVIDERS = [Provider.RACKSPACE_UK, Provider.RACKSPACE_NOVA_BETA, Provider.RACKSPACE_NOVA_DFW, Provider.RACKSPACE_NOVA_LON, Provider.RACKSPACE_NOVA_ORD] OLD_CONSTANT_TO_NEW_MAPPING = { # Rackspace Provider.RACKSPACE_UK: Provider.RACKSPACE_FIRST_GEN, Provider.RACKSPACE_NOVA_BETA: Provider.RACKSPACE, Provider.RACKSPACE_NOVA_DFW: Provider.RACKSPACE, Provider.RACKSPACE_NOVA_LON: Provider.RACKSPACE, Provider.RACKSPACE_NOVA_ORD: Provider.RACKSPACE, # AWS Provider.EC2_US_EAST: Provider.EC2, Provider.EC2_US_EAST_OHIO: Provider.EC2, Provider.EC2_EU: Provider.EC2, Provider.EC2_EU_WEST: Provider.EC2, Provider.EC2_EU_WEST2: Provider.EC2, Provider.EC2_US_WEST: Provider.EC2, Provider.EC2_AP_SOUTHEAST: Provider.EC2, Provider.EC2_AP_SOUTHEAST2: Provider.EC2, Provider.EC2_AP_NORTHEAST: Provider.EC2, Provider.EC2_AP_NORTHEAST1: Provider.EC2, Provider.EC2_AP_NORTHEAST2: Provider.EC2, Provider.EC2_US_WEST_OREGON: Provider.EC2, Provider.EC2_SA_EAST: Provider.EC2, Provider.EC2_AP_SOUTHEAST: Provider.EC2, Provider.EC2_CA_CENTRAL1: Provider.EC2, # ElasticHosts Provider.ELASTICHOSTS_UK1: Provider.ELASTICHOSTS, Provider.ELASTICHOSTS_UK2: Provider.ELASTICHOSTS, Provider.ELASTICHOSTS_US1: Provider.ELASTICHOSTS, Provider.ELASTICHOSTS_US2: Provider.ELASTICHOSTS, Provider.ELASTICHOSTS_US3: Provider.ELASTICHOSTS, Provider.ELASTICHOSTS_CA1: Provider.ELASTICHOSTS, Provider.ELASTICHOSTS_AU1: Provider.ELASTICHOSTS, Provider.ELASTICHOSTS_CN1: Provider.ELASTICHOSTS, } class NodeState(Type): """ Standard states for a node :cvar RUNNING: Node is running. :cvar STARTING: Node is starting up. :cvar REBOOTING: Node is rebooting. :cvar TERMINATED: Node is terminated. This node can't be started later on. :cvar STOPPING: Node is currently trying to stop. :cvar STOPPED: Node is stopped. This node can be started later on. :cvar PENDING: Node is pending. :cvar SUSPENDED: Node is suspended. :cvar ERROR: Node is an error state. Usually no operations can be performed on the node once it ends up in the error state. :cvar PAUSED: Node is paused. :cvar RECONFIGURING: Node is being reconfigured. :cvar UNKNOWN: Node state is unknown. """ RUNNING = 'running' STARTING = 'starting' REBOOTING = 'rebooting' TERMINATED = 'terminated' PENDING = 'pending' UNKNOWN = 'unknown' STOPPING = 'stopping' STOPPED = 'stopped' SUSPENDED = 'suspended' ERROR = 'error' PAUSED = 'paused' RECONFIGURING = 'reconfiguring' MIGRATING = 'migrating' NORMAL = 'normal' UPDATING = 'updating' class StorageVolumeState(Type): """ Standard states of a StorageVolume """ AVAILABLE = 'available' ERROR = 'error' INUSE = 'inuse' CREATING = 'creating' DELETING = 'deleting' DELETED = 'deleted' BACKUP = 'backup' ATTACHING = 'attaching' UNKNOWN = 'unknown' MIGRATING = 'migrating' UPDATING = 'updating' class VolumeSnapshotState(Type): """ Standard states of VolumeSnapshots """ AVAILABLE = 'available' ERROR = 'error' CREATING = 'creating' DELETING = 'deleting' RESTORING = 'restoring' UNKNOWN = 'unknown' UPDATING = 'updating' class Architecture(object): """ Image and size architectures. :cvar I386: i386 (32 bt) :cvar X86_64: x86_64 (64 bit) """ I386 = 0 X86_X64 = 1 class DeploymentError(LibcloudError): """ Exception used when a Deployment Task failed. :ivar node: :class:`Node` on which this exception happened, you might want to call :func:`Node.destroy` """ def __init__(self, node, original_exception=None, driver=None): self.node = node self.value = original_exception self.driver = driver def __str__(self): return self.__repr__() def __repr__(self): return (('<DeploymentError: node=%s, error=%s, driver=%s>' % (self.node.id, str(self.value), str(self.driver)))) class KeyPairError(LibcloudError): error_type = 'KeyPairError' def __init__(self, name, driver): self.name = name self.value = 'Key pair with name %s does not exist' % (name) super(KeyPairError, self).__init__(value=self.value, driver=driver) def __str__(self): return self.__repr__() def __repr__(self): return ('<%s name=%s, value=%s, driver=%s>' % (self.error_type, self.name, self.value, self.driver.name)) class KeyPairDoesNotExistError(KeyPairError): error_type = 'KeyPairDoesNotExistError' """Deprecated alias of :class:`DeploymentException`""" DeploymentException = DeploymentError
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 199, 1563, 2943, 1202, 701, 1163, 4184, 402, 17069, 199, 624, 199, 199, 504, 17069, 14, 2330, 14, 1313, 492, 8003, 4091, 547, 12, 603, 24012, 19712, 199, 504, 17069, 14, 2330, 14, 1313, 492, 6378, 35, 10428, 547, 12, 6378, 35, 10428, 1726, 199, 199, 363, 452, 363, 275, 359, 272, 298, 6663, 401, 272, 298, 1716, 2223, 401, 272, 298, 25434, 547, 401, 272, 298, 25434, 1726, 401, 339, 327, 13365, 1766, 26, 1077, 314, 9563, 8925, 5084, 506, 16629, 31, 272, 298, 4728, 4091, 547, 401, 272, 298, 29513, 19712, 401, 272, 298, 3364, 35, 10428, 547, 401, 272, 298, 3364, 35, 10428, 1726, 401, 339, 298, 5104, 63, 25825, 63, 2566, 63, 11365, 63, 20351, 2, 199, 61, 421, 199, 533, 2434, 8, 785, 304, 272, 768, 3744, 272, 347, 370, 875, 8, 1886, 12, 574, 304, 267, 408, 1767, 314, 1059, 6025, 402, 314, 1174, 909, 2225, 267, 520, 635, 620, 574, 26, 314, 1174, 909, 370, 7485, 1901, 1059, 267, 520, 1107, 26, 314, 22681, 1059, 626, 8469, 314, 1174, 909, 267, 520, 4500, 26, 620, 267, 408, 267, 372, 574, 14, 4142, 342, 339, 768, 3744, 272, 347, 687, 875, 8, 1886, 12, 574, 304, 267, 408, 1767, 314, 1174, 909, 2225, 626, 4450, 314, 1059, 267, 520, 635, 620, 574, 26, 314, 1059, 370, 3648, 1536, 267, 520, 1107, 26, 314, 1174, 909, 2225, 626, 4450, 314, 1059, 267, 520, 4500, 26, 620, 267, 408, 267, 372, 2519, 8, 1886, 12, 574, 14, 4142, 1062, 488, 9, 421, 199, 533, 18489, 8, 804, 304, 272, 408, 272, 25022, 367, 1924, 402, 314, 3748, 18032, 339, 10172, 13, 11324, 19016, 787, 3355, 315, 23331, 3294, 1865, 14, 7754, 11211, 642, 272, 7794, 1380, 7791, 892, 19016, 14, 339, 520, 26781, 577, 22472, 26, 5679, 5022, 272, 520, 26781, 14840, 41, 2328, 47, 26, 437, 4492, 14209, 5253, 272, 520, 26781, 437, 2673, 57, 1734, 63, 37, 3298, 26, 15170, 89, 324, 662, 3298, 5253, 14, 272, 520, 26781, 437, 1230, 726, 1348, 47, 1658, 4586, 26, 437, 300, 11131, 8354, 5253, 14, 272, 520, 26781, 437, 58, 3942, 26, 15474, 334, 25140, 9, 5253, 14, 272, 520, 26781, 437, 58, 3942, 63, 12482, 26, 15474, 7337, 13537, 334, 632, 11641, 9, 5253, 14, 272, 520, 26781, 31408, 15694, 26, 22447, 1977, 272, 520, 26781, 445, 1484, 53, 3177, 1277, 2054, 26, 8142, 23394, 272, 520, 26781, 445, 1484, 53, 3177, 13329, 37, 26, 8002, 3467, 14, 335, 272, 520, 26781, 445, 1484, 3383, 17014, 26, 8142, 4851, 272, 520, 26781, 577, 1469, 742, 3579, 3998, 26, 25291, 3918, 8142, 272, 520, 26781, 15352, 18, 26, 14347, 10168, 14, 272, 520, 26781, 662, 2890, 26, 3447, 16523, 272, 520, 26781, 662, 16901, 948, 23775, 26, 19509, 19620, 14, 957, 272, 520, 26781, 3651, 3100, 13329, 37, 26, 1316, 79, 3467, 5253, 14, 272, 520, 26781, 31556, 26, 4475, 8354, 12580, 272, 520, 26781, 598, 17275, 998, 26, 3971, 7900, 272, 520, 26781, 21772, 998, 5763, 1387, 26, 16386, 15185, 5253, 272, 520, 26781, 26202, 26, 26202, 9607, 8142, 272, 520, 26781, 473, 24839, 1293, 33, 26, 473, 7697, 7586, 5253, 14, 272, 520, 26781, 1603, 47, 57, 1309, 26, 7135, 89, 484, 5253, 272, 520, 26781, 1804, 21364, 29495, 26, 1022, 84, 399, 4091, 5253, 272, 520, 26781, 25764, 18228, 26, 8003, 4549, 5253, 272, 520, 26781, 491, 568, 9125, 26, 491, 15993, 14, 957, 272, 520, 26781, 653, 6102, 2979, 24333, 26, 653, 1545, 526, 9944, 5253, 272, 520, 26781, 653, 1469, 24753, 26, 653, 1017, 5610, 272, 520, 26781, 28252, 38, 5104, 26, 653, 1132, 14011, 272, 520, 26781, 24164, 6388, 34, 1293, 33, 26, 3232, 46, 2871, 7586, 14, 1308, 272, 520, 26781, 9827, 10187, 26, 593, 1190, 616, 8142, 272, 520, 26781, 5738, 24333, 63, 25205, 26, 6219, 3467, 7839, 5253, 14, 272, 520, 26781, 5738, 24333, 63, 15319, 26, 6219, 3467, 26124, 5253, 14, 272, 520, 26781, 3611, 38, 649, 63, 7184, 13884, 51, 26, 2165, 3269, 34, 322, 5618, 5253, 14, 272, 520, 26781, 820, 3099, 11658, 26, 32679, 2163, 13, 2268, 14260, 4079, 8142, 7146, 83, 272, 520, 26781, 820, 3099, 11658, 63, 12903, 63, 9289, 26, 32679, 7758, 18870, 8142, 7146, 83, 272, 520, 26781, 820, 1469, 53, 5449, 1206, 26, 820, 1017, 85, 4965, 316, 14, 957, 272, 520, 26781, 31510, 907, 10520, 26, 13861, 264, 1657, 272, 520, 26781, 738, 4222, 1484, 3383, 26, 4949, 9089, 272, 520, 26781, 812, 1981, 26, 812, 1981, 5253, 272, 520, 26781, 812, 29495, 26, 19365, 373, 9089, 272, 520, 26781, 812, 5067, 7278, 26, 812, 5067, 14, 846, 272, 520, 26781, 22368, 1766, 26, 373, 427, 82, 5253, 14, 272, 408, 272, 437, 58, 3942, 275, 283, 9078, 7, 272, 437, 58, 3942, 63, 12482, 275, 283, 9078, 63, 5362, 7, 272, 577, 22472, 275, 283, 5869, 7, 272, 14840, 41, 2328, 47, 275, 283, 14677, 14209, 7, 272, 437, 2673, 57, 1734, 63, 37, 3298, 275, 283, 10874, 89, 324, 63, 23075, 7, 272, 437, 1230, 726, 1348, 47, 1658, 4586, 275, 283, 65 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 199, 1563, 2943, 1202, 701, 1163, 4184, 402, 17069, 199, 624, 199, 199, 504, 17069, 14, 2330, 14, 1313, 492, 8003, 4091, 547, 12, 603, 24012, 19712, 199, 504, 17069, 14, 2330, 14, 1313, 492, 6378, 35, 10428, 547, 12, 6378, 35, 10428, 1726, 199, 199, 363, 452, 363, 275, 359, 272, 298, 6663, 401, 272, 298, 1716, 2223, 401, 272, 298, 25434, 547, 401, 272, 298, 25434, 1726, 401, 339, 327, 13365, 1766, 26, 1077, 314, 9563, 8925, 5084, 506, 16629, 31, 272, 298, 4728, 4091, 547, 401, 272, 298, 29513, 19712, 401, 272, 298, 3364, 35, 10428, 547, 401, 272, 298, 3364, 35, 10428, 1726, 401, 339, 298, 5104, 63, 25825, 63, 2566, 63, 11365, 63, 20351, 2, 199, 61, 421, 199, 533, 2434, 8, 785, 304, 272, 768, 3744, 272, 347, 370, 875, 8, 1886, 12, 574, 304, 267, 408, 1767, 314, 1059, 6025, 402, 314, 1174, 909, 2225, 267, 520, 635, 620, 574, 26, 314, 1174, 909, 370, 7485, 1901, 1059, 267, 520, 1107, 26, 314, 22681, 1059, 626, 8469, 314, 1174, 909, 267, 520, 4500, 26, 620, 267, 408, 267, 372, 574, 14, 4142, 342, 339, 768, 3744, 272, 347, 687, 875, 8, 1886, 12, 574, 304, 267, 408, 1767, 314, 1174, 909, 2225, 626, 4450, 314, 1059, 267, 520, 635, 620, 574, 26, 314, 1059, 370, 3648, 1536, 267, 520, 1107, 26, 314, 1174, 909, 2225, 626, 4450, 314, 1059, 267, 520, 4500, 26, 620, 267, 408, 267, 372, 2519, 8, 1886, 12, 574, 14, 4142, 1062, 488, 9, 421, 199, 533, 18489, 8, 804, 304, 272, 408, 272, 25022, 367, 1924, 402, 314, 3748, 18032, 339, 10172, 13, 11324, 19016, 787, 3355, 315, 23331, 3294, 1865, 14, 7754, 11211, 642, 272, 7794, 1380, 7791, 892, 19016, 14, 339, 520, 26781, 577, 22472, 26, 5679, 5022, 272, 520, 26781, 14840, 41, 2328, 47, 26, 437, 4492, 14209, 5253, 272, 520, 26781, 437, 2673, 57, 1734, 63, 37, 3298, 26, 15170, 89, 324, 662, 3298, 5253, 14, 272, 520, 26781, 437, 1230, 726, 1348, 47, 1658, 4586, 26, 437, 300, 11131, 8354, 5253, 14, 272, 520, 26781, 437, 58, 3942, 26, 15474, 334, 25140, 9, 5253, 14, 272, 520, 26781, 437, 58, 3942, 63, 12482, 26, 15474, 7337, 13537, 334, 632, 11641, 9, 5253, 14, 272, 520, 26781, 31408, 15694, 26, 22447, 1977, 272, 520, 26781, 445, 1484, 53, 3177, 1277, 2054, 26, 8142, 23394, 272, 520, 26781, 445, 1484, 53, 3177, 13329, 37, 26, 8002, 3467, 14, 335, 272, 520, 26781, 445, 1484, 3383, 17014, 26, 8142, 4851, 272, 520, 26781, 577, 1469, 742, 3579, 3998, 26, 25291, 3918, 8142, 272, 520, 26781, 15352, 18, 26, 14347, 10168, 14, 272, 520, 26781, 662, 2890, 26, 3447, 16523, 272, 520, 26781, 662, 16901, 948, 23775, 26, 19509, 19620, 14, 957, 272, 520, 26781, 3651, 3100, 13329, 37, 26, 1316, 79, 3467, 5253, 14, 272, 520, 26781, 31556, 26, 4475, 8354, 12580, 272, 520, 26781, 598, 17275, 998, 26, 3971, 7900, 272, 520, 26781, 21772, 998, 5763, 1387, 26, 16386, 15185, 5253, 272, 520, 26781, 26202, 26, 26202, 9607, 8142, 272, 520, 26781, 473, 24839, 1293, 33, 26, 473, 7697, 7586, 5253, 14, 272, 520, 26781, 1603, 47, 57, 1309, 26, 7135, 89, 484, 5253, 272, 520, 26781, 1804, 21364, 29495, 26, 1022, 84, 399, 4091, 5253, 272, 520, 26781, 25764, 18228, 26, 8003, 4549, 5253, 272, 520, 26781, 491, 568, 9125, 26, 491, 15993, 14, 957, 272, 520, 26781, 653, 6102, 2979, 24333, 26, 653, 1545, 526, 9944, 5253, 272, 520, 26781, 653, 1469, 24753, 26, 653, 1017, 5610, 272, 520, 26781, 28252, 38, 5104, 26, 653, 1132, 14011, 272, 520, 26781, 24164, 6388, 34, 1293, 33, 26, 3232, 46, 2871, 7586, 14, 1308, 272, 520, 26781, 9827, 10187, 26, 593, 1190, 616, 8142, 272, 520, 26781, 5738, 24333, 63, 25205, 26, 6219, 3467, 7839, 5253, 14, 272, 520, 26781, 5738, 24333, 63, 15319, 26, 6219, 3467, 26124, 5253, 14, 272, 520, 26781, 3611, 38, 649, 63, 7184, 13884, 51, 26, 2165, 3269, 34, 322, 5618, 5253, 14, 272, 520, 26781, 820, 3099, 11658, 26, 32679, 2163, 13, 2268, 14260, 4079, 8142, 7146, 83, 272, 520, 26781, 820, 3099, 11658, 63, 12903, 63, 9289, 26, 32679, 7758, 18870, 8142, 7146, 83, 272, 520, 26781, 820, 1469, 53, 5449, 1206, 26, 820, 1017, 85, 4965, 316, 14, 957, 272, 520, 26781, 31510, 907, 10520, 26, 13861, 264, 1657, 272, 520, 26781, 738, 4222, 1484, 3383, 26, 4949, 9089, 272, 520, 26781, 812, 1981, 26, 812, 1981, 5253, 272, 520, 26781, 812, 29495, 26, 19365, 373, 9089, 272, 520, 26781, 812, 5067, 7278, 26, 812, 5067, 14, 846, 272, 520, 26781, 22368, 1766, 26, 373, 427, 82, 5253, 14, 272, 408, 272, 437, 58, 3942, 275, 283, 9078, 7, 272, 437, 58, 3942, 63, 12482, 275, 283, 9078, 63, 5362, 7, 272, 577, 22472, 275, 283, 5869, 7, 272, 14840, 41, 2328, 47, 275, 283, 14677, 14209, 7, 272, 437, 2673, 57, 1734, 63, 37, 3298, 275, 283,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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 ]
mitya57/django
tests/shell/tests.py
56
2372
import sys import unittest from unittest import mock from django import __version__ from django.core.management import CommandError, call_command from django.test import SimpleTestCase from django.test.utils import captured_stdin, captured_stdout, patch_logger class ShellCommandTestCase(SimpleTestCase): def test_command_option(self): with patch_logger('test', 'info') as logger: call_command( 'shell', command=( 'import django; from logging import getLogger; ' 'getLogger("test").info(django.__version__)' ), ) self.assertEqual(len(logger), 1) self.assertEqual(logger[0], __version__) @unittest.skipIf(sys.platform == 'win32', "Windows select() doesn't support file descriptors.") @mock.patch('django.core.management.commands.shell.select') def test_stdin_read(self, select): with captured_stdin() as stdin, captured_stdout() as stdout: stdin.write('print(100)\n') stdin.seek(0) call_command('shell') self.assertEqual(stdout.getvalue().strip(), '100') @mock.patch('django.core.management.commands.shell.select.select') # [1] @mock.patch.dict('sys.modules', {'IPython': None}) def test_shell_with_ipython_not_installed(self, select): select.return_value = ([], [], []) with self.assertRaisesMessage(CommandError, "Couldn't import ipython interface."): call_command('shell', interface='ipython') @mock.patch('django.core.management.commands.shell.select.select') # [1] @mock.patch.dict('sys.modules', {'bpython': None}) def test_shell_with_bpython_not_installed(self, select): select.return_value = ([], [], []) with self.assertRaisesMessage(CommandError, "Couldn't import bpython interface."): call_command('shell', interface='bpython') # [1] Patch select to prevent tests failing when when the test suite is run # in parallel mode. The tests are run in a subprocess and the subprocess's # stdin is closed and replaced by /dev/null. Reading from /dev/null always # returns EOF and so select always shows that sys.stdin is ready to read. # This causes problems because of the call to select.select() towards the # end of shell's handle() method.
bsd-3-clause
[ 646, 984, 199, 646, 2882, 199, 504, 2882, 492, 1683, 199, 199, 504, 1639, 492, 636, 1023, 363, 199, 504, 1639, 14, 1018, 14, 8110, 492, 14393, 12, 1240, 63, 1531, 199, 504, 1639, 14, 396, 492, 24424, 199, 504, 1639, 14, 396, 14, 1208, 492, 17487, 63, 6626, 12, 17487, 63, 2703, 12, 3371, 63, 2921, 421, 199, 533, 24599, 3110, 1746, 8, 17968, 304, 339, 347, 511, 63, 1531, 63, 1422, 8, 277, 304, 267, 543, 3371, 63, 2921, 360, 396, 297, 283, 815, 358, 465, 2512, 26, 288, 1240, 63, 1531, 8, 355, 283, 5641, 297, 355, 1414, 2687, 490, 283, 646, 1639, 27, 687, 2050, 492, 28138, 27, 283, 490, 283, 5572, 480, 396, 3471, 815, 8, 1176, 855, 1023, 363, 3171, 355, 2318, 288, 776, 288, 291, 14, 629, 8, 552, 8, 2921, 395, 413, 9, 288, 291, 14, 629, 8, 2921, 59, 16, 467, 636, 1023, 3368, 339, 768, 2796, 14, 15118, 8, 1274, 14, 3246, 508, 283, 2676, 708, 297, 298, 8647, 3504, 342, 3181, 1133, 2291, 570, 15428, 2685, 272, 768, 1805, 14, 2068, 360, 1176, 14, 1018, 14, 8110, 14, 4405, 14, 5641, 14, 2416, 358, 272, 347, 511, 63, 6626, 63, 739, 8, 277, 12, 3504, 304, 267, 543, 17487, 63, 6626, 342, 465, 9009, 12, 17487, 63, 2703, 342, 465, 3839, 26, 288, 9009, 14, 952, 360, 1361, 8, 1960, 2862, 78, 358, 288, 9009, 14, 5507, 8, 16, 9, 288, 1240, 63, 1531, 360, 5641, 358, 267, 291, 14, 629, 8, 2703, 14, 7150, 1252, 1913, 1062, 283, 1960, 358, 339, 768, 1805, 14, 2068, 360, 1176, 14, 1018, 14, 8110, 14, 4405, 14, 5641, 14, 2416, 14, 2416, 358, 221, 327, 359, 17, 61, 272, 768, 1805, 14, 2068, 14, 807, 360, 1274, 14, 3112, 297, 791, 1772, 11361, 356, 488, 1552, 272, 347, 511, 63, 5641, 63, 1045, 63, 22691, 63, 1397, 63, 7657, 8, 277, 12, 3504, 304, 267, 3504, 14, 1107, 63, 585, 275, 23293, 990, 3073, 267, 543, 291, 14, 14638, 8, 31542, 12, 298, 20485, 1133, 492, 284, 1548, 3217, 30946, 288, 1240, 63, 1531, 360, 5641, 297, 3217, 534, 22691, 358, 339, 768, 1805, 14, 2068, 360, 1176, 14, 1018, 14, 8110, 14, 4405, 14, 5641, 14, 2416, 14, 2416, 358, 221, 327, 359, 17, 61, 272, 768, 1805, 14, 2068, 14, 807, 360, 1274, 14, 3112, 297, 791, 66, 1548, 356, 488, 1552, 272, 347, 511, 63, 5641, 63, 1045, 63, 66, 1548, 63, 1397, 63, 7657, 8, 277, 12, 3504, 304, 267, 3504, 14, 1107, 63, 585, 275, 23293, 990, 3073, 267, 543, 291, 14, 14638, 8, 31542, 12, 298, 20485, 1133, 492, 330, 1548, 3217, 30946, 288, 1240, 63, 1531, 360, 5641, 297, 3217, 534, 66, 1548, 358, 339, 327, 359, 17, 61, 19292, 3504, 370, 7981, 2295, 18648, 1380, 1380, 314, 511, 5241, 365, 1255, 272, 327, 315, 9861, 818, 14, 710, 2295, 787, 1255, 315, 282, 3873, 436, 314, 3873, 1159, 272, 327, 9009, 365, 6876, 436, 8717, 701, 1182, 2374, 15, 2307, 14, 799, 5384, 687, 1182, 2374, 15, 2307, 3544, 272, 327, 2529, 9027, 436, 880, 3504, 3544, 13703, 626, 984, 14, 6626, 365, 10144, 370, 1586, 14, 272, 327, 961, 14486, 8826, 2952, 402, 314, 1240, 370, 3504, 14, 2416, 342, 28354, 314, 272, 327, 1284, 402, 5218, 1159, 2429, 342, 1083, 14, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 984, 199, 646, 2882, 199, 504, 2882, 492, 1683, 199, 199, 504, 1639, 492, 636, 1023, 363, 199, 504, 1639, 14, 1018, 14, 8110, 492, 14393, 12, 1240, 63, 1531, 199, 504, 1639, 14, 396, 492, 24424, 199, 504, 1639, 14, 396, 14, 1208, 492, 17487, 63, 6626, 12, 17487, 63, 2703, 12, 3371, 63, 2921, 421, 199, 533, 24599, 3110, 1746, 8, 17968, 304, 339, 347, 511, 63, 1531, 63, 1422, 8, 277, 304, 267, 543, 3371, 63, 2921, 360, 396, 297, 283, 815, 358, 465, 2512, 26, 288, 1240, 63, 1531, 8, 355, 283, 5641, 297, 355, 1414, 2687, 490, 283, 646, 1639, 27, 687, 2050, 492, 28138, 27, 283, 490, 283, 5572, 480, 396, 3471, 815, 8, 1176, 855, 1023, 363, 3171, 355, 2318, 288, 776, 288, 291, 14, 629, 8, 552, 8, 2921, 395, 413, 9, 288, 291, 14, 629, 8, 2921, 59, 16, 467, 636, 1023, 3368, 339, 768, 2796, 14, 15118, 8, 1274, 14, 3246, 508, 283, 2676, 708, 297, 298, 8647, 3504, 342, 3181, 1133, 2291, 570, 15428, 2685, 272, 768, 1805, 14, 2068, 360, 1176, 14, 1018, 14, 8110, 14, 4405, 14, 5641, 14, 2416, 358, 272, 347, 511, 63, 6626, 63, 739, 8, 277, 12, 3504, 304, 267, 543, 17487, 63, 6626, 342, 465, 9009, 12, 17487, 63, 2703, 342, 465, 3839, 26, 288, 9009, 14, 952, 360, 1361, 8, 1960, 2862, 78, 358, 288, 9009, 14, 5507, 8, 16, 9, 288, 1240, 63, 1531, 360, 5641, 358, 267, 291, 14, 629, 8, 2703, 14, 7150, 1252, 1913, 1062, 283, 1960, 358, 339, 768, 1805, 14, 2068, 360, 1176, 14, 1018, 14, 8110, 14, 4405, 14, 5641, 14, 2416, 14, 2416, 358, 221, 327, 359, 17, 61, 272, 768, 1805, 14, 2068, 14, 807, 360, 1274, 14, 3112, 297, 791, 1772, 11361, 356, 488, 1552, 272, 347, 511, 63, 5641, 63, 1045, 63, 22691, 63, 1397, 63, 7657, 8, 277, 12, 3504, 304, 267, 3504, 14, 1107, 63, 585, 275, 23293, 990, 3073, 267, 543, 291, 14, 14638, 8, 31542, 12, 298, 20485, 1133, 492, 284, 1548, 3217, 30946, 288, 1240, 63, 1531, 360, 5641, 297, 3217, 534, 22691, 358, 339, 768, 1805, 14, 2068, 360, 1176, 14, 1018, 14, 8110, 14, 4405, 14, 5641, 14, 2416, 14, 2416, 358, 221, 327, 359, 17, 61, 272, 768, 1805, 14, 2068, 14, 807, 360, 1274, 14, 3112, 297, 791, 66, 1548, 356, 488, 1552, 272, 347, 511, 63, 5641, 63, 1045, 63, 66, 1548, 63, 1397, 63, 7657, 8, 277, 12, 3504, 304, 267, 3504, 14, 1107, 63, 585, 275, 23293, 990, 3073, 267, 543, 291, 14, 14638, 8, 31542, 12, 298, 20485, 1133, 492, 330, 1548, 3217, 30946, 288, 1240, 63, 1531, 360, 5641, 297, 3217, 534, 66, 1548, 358, 339, 327, 359, 17, 61, 19292, 3504, 370, 7981, 2295, 18648, 1380, 1380, 314, 511, 5241, 365, 1255, 272, 327, 315, 9861, 818, 14, 710, 2295, 787, 1255, 315, 282, 3873, 436, 314, 3873, 1159, 272, 327, 9009, 365, 6876, 436, 8717, 701, 1182, 2374, 15, 2307, 14, 799, 5384, 687, 1182, 2374, 15, 2307, 3544, 272, 327, 2529, 9027, 436, 880, 3504, 3544, 13703, 626, 984, 14, 6626, 365, 10144, 370, 1586, 14, 272, 327, 961, 14486, 8826, 2952, 402, 314, 1240, 370, 3504, 14, 2416, 342, 28354, 314, 272, 327, 1284, 402, 5218, 1159, 2429, 342, 1083, 14, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
j-mracek/dnf
tests/test_libcomps.py
5
2463
# -*- coding: utf-8 -*- # Copyright (C) 2014-2018 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the # source code or documentation are not subject to the GNU General Public # License and may only be used or replicated with the express permission of # Red Hat, Inc. # from __future__ import absolute_import import libcomps import tests.support class LibcompsTest(tests.support.TestCase): """Sanity tests of the Libcomps library.""" def test_environment_parse(self): xml = """\ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd"> <comps> <group> <id>somerset</id> <default>true</default> <uservisible>true</uservisible> <display_order>1024</display_order> <name>Solid Ground</name> <description>--</description> <packagelist> <packagereq type="mandatory">pepper</packagereq> <packagereq type="mandatory">trampoline</packagereq> </packagelist> </group> <environment> <id>minimal</id> <name>Min install</name> <description>Basic functionality.</description> <display_order>5</display_order> <grouplist> <groupid>somerset</groupid> </grouplist> </environment> </comps> """ comps = libcomps.Comps() ret = comps.fromxml_str(xml) self.assertGreaterEqual(ret, 0) def test_segv(self): c1 = libcomps.Comps() c2 = libcomps.Comps() c2.fromxml_f(tests.support.COMPS_PATH) c1 + c2 # sigsegved here def test_segv2(self): c1 = libcomps.Comps() c1.fromxml_f(tests.support.COMPS_PATH) c2 = libcomps.Comps() c2.fromxml_f(tests.support.COMPS_PATH) c = c1 + c2 c.groups[0].packages[0].name
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 35, 9, 6927, 13, 12682, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 1331, 31816, 471, 6285, 365, 6326, 2808, 370, 29165, 13809, 316, 370, 675, 12, 199, 3, 2811, 12, 1331, 12, 503, 3604, 652, 5420, 370, 314, 2895, 436, 3704, 402, 199, 3, 314, 1664, 1696, 1684, 844, 373, 14, 18, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 19147, 503, 2478, 12, 5893, 314, 2478, 3712, 1417, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 199, 3, 1684, 844, 367, 1655, 2436, 14, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 199, 3, 1664, 1696, 1684, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 12, 8217, 14, 221, 6184, 9572, 13002, 21032, 10375, 626, 787, 30147, 972, 315, 314, 199, 3, 1350, 1233, 503, 3794, 787, 440, 5420, 370, 314, 1664, 1696, 1684, 199, 3, 844, 436, 1443, 1454, 506, 1202, 503, 32436, 543, 314, 4056, 4983, 402, 199, 3, 9572, 13002, 12, 3277, 14, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 1973, 24344, 199, 199, 646, 2295, 14, 4058, 421, 199, 533, 8003, 24344, 774, 8, 2219, 14, 4058, 14, 1746, 304, 339, 408, 25901, 2295, 402, 314, 8003, 24344, 3555, 1041, 339, 347, 511, 63, 5418, 63, 1122, 8, 277, 304, 267, 2748, 275, 9638, 199, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 11230, 16556, 30594, 21755, 21486, 10858, 13002, 12, 3277, 14, 501, 21156, 3599, 83, 2256, 501, 742, 2, 298, 24344, 14, 15662, 1743, 199, 28, 24344, 30, 523, 665, 923, 30, 2043, 665, 344, 30, 1152, 2626, 409, 1108, 344, 30, 2043, 665, 885, 30, 2052, 1108, 885, 30, 2043, 665, 751, 6604, 30, 2052, 1108, 751, 6604, 30, 2043, 665, 2918, 63, 1648, 30, 7727, 1108, 2918, 63, 1648, 30, 2043, 665, 354, 30, 5158, 7401, 598, 2363, 1108, 354, 30, 2043, 665, 1802, 30, 306, 1108, 1802, 30, 272, 665, 2491, 513, 30, 489, 665, 2491, 2103, 730, 628, 19900, 1743, 12636, 529, 1108, 2491, 2103, 30, 489, 665, 2491, 2103, 730, 628, 19900, 1743, 1239, 311, 393, 1132, 1108, 2491, 2103, 30, 272, 3068, 2491, 513, 30, 523, 3068, 923, 30, 523, 665, 5418, 30, 272, 665, 344, 30, 21508, 1108, 344, 30, 272, 665, 354, 30, 4649, 3907, 1108, 354, 30, 272, 665, 1802, 30, 6845, 9330, 9758, 1802, 30, 272, 665, 2918, 63, 1648, 30, 21, 1108, 2918, 63, 1648, 30, 272, 665, 923, 513, 30, 489, 665, 923, 344, 30, 1152, 2626, 409, 1108, 923, 344, 30, 272, 3068, 923, 513, 30, 523, 3068, 5418, 30, 199, 1108, 24344, 30, 199, 624, 267, 30594, 275, 1973, 24344, 14, 2404, 83, 342, 267, 2203, 275, 30594, 14, 504, 1652, 63, 495, 8, 1652, 9, 267, 291, 14, 26875, 8, 3292, 12, 378, 9, 339, 347, 511, 63, 8359, 86, 8, 277, 304, 267, 286, 17, 275, 1973, 24344, 14, 2404, 83, 342, 267, 286, 18, 275, 1973, 24344, 14, 2404, 83, 342, 267, 286, 18, 14, 504, 1652, 63, 70, 8, 2219, 14, 4058, 14, 6790, 51, 63, 3243, 9, 267, 286, 17, 435, 286, 18, 221, 327, 5259, 8359, 1354, 2348, 339, 347, 511, 63, 8359, 86, 18, 8, 277, 304, 267, 286, 17, 275, 1973, 24344, 14, 2404, 83, 342, 267, 286, 17, 14, 504, 1652, 63, 70, 8, 2219, 14, 4058, 14, 6790, 51, 63, 3243, 9, 398, 286, 18, 275, 1973, 24344, 14, 2404, 83, 342, 267, 286, 18, 14, 504, 1652, 63, 70, 8, 2219, 14, 4058, 14, 6790, 51, 63, 3243, 9, 398, 286, 275, 286, 17, 435, 286, 18, 267, 286, 14, 2634, 59, 16, 1055, 5154, 59, 16, 1055, 354, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 35, 9, 6927, 13, 12682, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 1331, 31816, 471, 6285, 365, 6326, 2808, 370, 29165, 13809, 316, 370, 675, 12, 199, 3, 2811, 12, 1331, 12, 503, 3604, 652, 5420, 370, 314, 2895, 436, 3704, 402, 199, 3, 314, 1664, 1696, 1684, 844, 373, 14, 18, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 19147, 503, 2478, 12, 5893, 314, 2478, 3712, 1417, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 199, 3, 1684, 844, 367, 1655, 2436, 14, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 199, 3, 1664, 1696, 1684, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 12, 8217, 14, 221, 6184, 9572, 13002, 21032, 10375, 626, 787, 30147, 972, 315, 314, 199, 3, 1350, 1233, 503, 3794, 787, 440, 5420, 370, 314, 1664, 1696, 1684, 199, 3, 844, 436, 1443, 1454, 506, 1202, 503, 32436, 543, 314, 4056, 4983, 402, 199, 3, 9572, 13002, 12, 3277, 14, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 1973, 24344, 199, 199, 646, 2295, 14, 4058, 421, 199, 533, 8003, 24344, 774, 8, 2219, 14, 4058, 14, 1746, 304, 339, 408, 25901, 2295, 402, 314, 8003, 24344, 3555, 1041, 339, 347, 511, 63, 5418, 63, 1122, 8, 277, 304, 267, 2748, 275, 9638, 199, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 11230, 16556, 30594, 21755, 21486, 10858, 13002, 12, 3277, 14, 501, 21156, 3599, 83, 2256, 501, 742, 2, 298, 24344, 14, 15662, 1743, 199, 28, 24344, 30, 523, 665, 923, 30, 2043, 665, 344, 30, 1152, 2626, 409, 1108, 344, 30, 2043, 665, 885, 30, 2052, 1108, 885, 30, 2043, 665, 751, 6604, 30, 2052, 1108, 751, 6604, 30, 2043, 665, 2918, 63, 1648, 30, 7727, 1108, 2918, 63, 1648, 30, 2043, 665, 354, 30, 5158, 7401, 598, 2363, 1108, 354, 30, 2043, 665, 1802, 30, 306, 1108, 1802, 30, 272, 665, 2491, 513, 30, 489, 665, 2491, 2103, 730, 628, 19900, 1743, 12636, 529, 1108, 2491, 2103, 30, 489, 665, 2491, 2103, 730, 628, 19900, 1743, 1239, 311, 393, 1132, 1108, 2491, 2103, 30, 272, 3068, 2491, 513, 30, 523, 3068, 923, 30, 523, 665, 5418, 30, 272, 665, 344, 30, 21508, 1108, 344, 30, 272, 665, 354, 30, 4649, 3907, 1108, 354, 30, 272, 665, 1802, 30, 6845, 9330, 9758, 1802, 30, 272, 665, 2918, 63, 1648, 30, 21, 1108, 2918, 63, 1648, 30, 272, 665, 923, 513, 30, 489, 665, 923, 344, 30, 1152, 2626, 409, 1108, 923, 344, 30, 272, 3068, 923, 513, 30, 523, 3068, 5418, 30, 199, 1108, 24344, 30, 199, 624, 267, 30594, 275, 1973, 24344, 14, 2404, 83, 342, 267, 2203, 275, 30594, 14, 504, 1652, 63, 495, 8, 1652, 9, 267, 291, 14, 26875, 8, 3292, 12, 378, 9, 339, 347, 511, 63, 8359, 86, 8, 277, 304, 267, 286, 17, 275, 1973, 24344, 14, 2404, 83, 342, 267, 286, 18, 275, 1973, 24344, 14, 2404, 83, 342, 267, 286, 18, 14, 504, 1652, 63, 70, 8, 2219, 14, 4058, 14, 6790, 51, 63, 3243, 9, 267, 286, 17, 435, 286, 18, 221, 327, 5259, 8359, 1354, 2348, 339, 347, 511, 63, 8359, 86, 18, 8, 277, 304, 267, 286, 17, 275, 1973, 24344, 14, 2404, 83, 342, 267, 286, 17, 14, 504, 1652, 63, 70, 8, 2219, 14, 4058, 14, 6790, 51, 63, 3243, 9, 398, 286, 18, 275, 1973, 24344, 14, 2404, 83, 342, 267, 286, 18, 14, 504, 1652, 63, 70, 8, 2219, 14, 4058, 14, 6790, 51, 63, 3243, 9, 398, 286, 275, 286, 17, 435, 286, 18, 267, 286, 14, 2634, 59, 16, 1055, 5154, 59, 16, 1055, 354, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Alignak-monitoring-contrib/alignak-app
test/test_about_dialog.py
1
2159
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2015-2018: # Matthieu Estrada, ttamalfor@gmail.com # # This file is part of (AlignakApp). # # (AlignakApp) 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. # # (AlignakApp) 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 (AlignakApp). If not, see <http://www.gnu.org/licenses/>. import sys import unittest2 from PyQt5.QtWidgets import QApplication, QLabel from alignak_app.utils.config import settings from alignak_app.utils.installer import Installer from alignak_app.locales.locales import init_localization from alignak_app.qobjects.about import AboutQDialog installer = Installer() installer.check_installation() settings.init_config() init_localization() class TestAboutQDialog(unittest2.TestCase): """ This file test the AboutQDialog classes. """ @classmethod def setUpClass(cls): """Create QApplication""" try: cls.app = QApplication(sys.argv) except: pass def test_about_dialog(self): """Initialize About QDialog""" under_test = AboutQDialog() self.assertEqual('about', under_test.objectName()) self.assertIsNone(under_test.layout()) under_test.initialize() self.assertEqual('about', under_test.objectName()) self.assertIsNotNone(under_test.layout()) def test_get_external_link_label(self): """Get External Link""" about_test = AboutQDialog() link = 'http://demo.alignak.net' under_test = about_test.get_external_link_label(link) self.assertIsInstance(under_test, QLabel) self.assertEqual(link, under_test.toolTip())
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 6900, 13, 12682, 26, 199, 3, 257, 18619, 273, 29364, 662, 14183, 983, 12, 307, 502, 391, 276, 269, 32, 6799, 14, 957, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 334, 9497, 1151, 2640, 680, 199, 3, 199, 3, 334, 9497, 1151, 2640, 9, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 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, 334, 9497, 1151, 2640, 9, 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, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 334, 9497, 1151, 2640, 680, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 984, 199, 199, 646, 2882, 18, 199, 504, 14084, 21, 14, 29081, 492, 29469, 12, 1413, 4314, 199, 199, 504, 6998, 1151, 63, 571, 14, 1208, 14, 888, 492, 2202, 199, 504, 6998, 1151, 63, 571, 14, 1208, 14, 17047, 492, 14089, 9230, 199, 504, 6998, 1151, 63, 571, 14, 24763, 14, 24763, 492, 4205, 63, 1832, 2072, 199, 504, 6998, 1151, 63, 571, 14, 81, 1462, 14, 10254, 492, 25225, 30983, 199, 199, 17047, 275, 14089, 9230, 342, 199, 17047, 14, 1074, 63, 23048, 342, 199, 1751, 14, 826, 63, 888, 342, 199, 826, 63, 1832, 2072, 342, 421, 199, 533, 1379, 18816, 30983, 8, 2796, 18, 14, 1746, 304, 272, 408, 267, 961, 570, 511, 314, 25225, 30983, 3992, 14, 272, 408, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 408, 2499, 29469, 624, 267, 862, 26, 288, 843, 14, 571, 275, 29469, 8, 1274, 14, 3020, 9, 267, 871, 26, 288, 986, 339, 347, 511, 63, 10254, 63, 7196, 8, 277, 304, 267, 408, 9345, 25225, 1413, 5619, 624, 398, 1334, 63, 396, 275, 25225, 30983, 342, 398, 291, 14, 629, 360, 10254, 297, 1334, 63, 396, 14, 785, 985, 1012, 267, 291, 14, 7702, 8, 7138, 63, 396, 14, 4209, 1012, 398, 1334, 63, 396, 14, 8489, 342, 398, 291, 14, 629, 360, 10254, 297, 1334, 63, 396, 14, 785, 985, 1012, 267, 291, 14, 10389, 8, 7138, 63, 396, 14, 4209, 1012, 339, 347, 511, 63, 362, 63, 5159, 63, 1073, 63, 1302, 8, 277, 304, 267, 408, 1002, 18802, 10967, 624, 398, 3595, 63, 396, 275, 25225, 30983, 342, 398, 2142, 275, 283, 1014, 921, 8768, 14, 5743, 1151, 14, 846, 7, 398, 1334, 63, 396, 275, 3595, 63, 396, 14, 362, 63, 5159, 63, 1073, 63, 1302, 8, 1073, 9, 398, 291, 14, 6926, 8, 7138, 63, 396, 12, 1413, 4314, 9, 267, 291, 14, 629, 8, 1073, 12, 1334, 63, 396, 14, 3557, 15915, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 6900, 13, 12682, 26, 199, 3, 257, 18619, 273, 29364, 662, 14183, 983, 12, 307, 502, 391, 276, 269, 32, 6799, 14, 957, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 334, 9497, 1151, 2640, 680, 199, 3, 199, 3, 334, 9497, 1151, 2640, 9, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 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, 334, 9497, 1151, 2640, 9, 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, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 334, 9497, 1151, 2640, 680, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 984, 199, 199, 646, 2882, 18, 199, 504, 14084, 21, 14, 29081, 492, 29469, 12, 1413, 4314, 199, 199, 504, 6998, 1151, 63, 571, 14, 1208, 14, 888, 492, 2202, 199, 504, 6998, 1151, 63, 571, 14, 1208, 14, 17047, 492, 14089, 9230, 199, 504, 6998, 1151, 63, 571, 14, 24763, 14, 24763, 492, 4205, 63, 1832, 2072, 199, 504, 6998, 1151, 63, 571, 14, 81, 1462, 14, 10254, 492, 25225, 30983, 199, 199, 17047, 275, 14089, 9230, 342, 199, 17047, 14, 1074, 63, 23048, 342, 199, 1751, 14, 826, 63, 888, 342, 199, 826, 63, 1832, 2072, 342, 421, 199, 533, 1379, 18816, 30983, 8, 2796, 18, 14, 1746, 304, 272, 408, 267, 961, 570, 511, 314, 25225, 30983, 3992, 14, 272, 408, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 408, 2499, 29469, 624, 267, 862, 26, 288, 843, 14, 571, 275, 29469, 8, 1274, 14, 3020, 9, 267, 871, 26, 288, 986, 339, 347, 511, 63, 10254, 63, 7196, 8, 277, 304, 267, 408, 9345, 25225, 1413, 5619, 624, 398, 1334, 63, 396, 275, 25225, 30983, 342, 398, 291, 14, 629, 360, 10254, 297, 1334, 63, 396, 14, 785, 985, 1012, 267, 291, 14, 7702, 8, 7138, 63, 396, 14, 4209, 1012, 398, 1334, 63, 396, 14, 8489, 342, 398, 291, 14, 629, 360, 10254, 297, 1334, 63, 396, 14, 785, 985, 1012, 267, 291, 14, 10389, 8, 7138, 63, 396, 14, 4209, 1012, 339, 347, 511, 63, 362, 63, 5159, 63, 1073, 63, 1302, 8, 277, 304, 267, 408, 1002, 18802, 10967, 624, 398, 3595, 63, 396, 275, 25225, 30983, 342, 398, 2142, 275, 283, 1014, 921, 8768, 14, 5743, 1151, 14, 846, 7, 398, 1334, 63, 396, 275, 3595, 63, 396, 14, 362, 63, 5159, 63, 1073, 63, 1302, 8, 1073, 9, 398, 291, 14, 6926, 8, 7138, 63, 396, 12, 1413, 4314, 9, 267, 291, 14, 629, 8, 1073, 12, 1334, 63, 396, 14, 3557, 15915, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
75651/kbengine_cloud
kbe/src/lib/python/Lib/lib2to3/fixes/fix_set_literal.py
203
1697
""" Optional fixer to transform set() calls to set literals. """ # Author: Benjamin Peterson from lib2to3 import fixer_base, pytree from lib2to3.fixer_util import token, syms class FixSetLiteral(fixer_base.BaseFix): BM_compatible = True explicit = True PATTERN = """power< 'set' trailer< '(' (atom=atom< '[' (items=listmaker< any ((',' any)* [',']) > | single=any) ']' > | atom< '(' items=testlist_gexp< any ((',' any)* [',']) > ')' > ) ')' > > """ def transform(self, node, results): single = results.get("single") if single: # Make a fake listmaker fake = pytree.Node(syms.listmaker, [single.clone()]) single.replace(fake) items = fake else: items = results["items"] # Build the contents of the literal literal = [pytree.Leaf(token.LBRACE, "{")] literal.extend(n.clone() for n in items.children) literal.append(pytree.Leaf(token.RBRACE, "}")) # Set the prefix of the right brace to that of the ')' or ']' literal[-1].prefix = items.next_sibling.prefix maker = pytree.Node(syms.dictsetmaker, literal) maker.prefix = node.prefix # If the original was a one tuple, we need to remove the extra comma. if len(maker.children) == 4: n = maker.children[2] n.remove() maker.children[-1].prefix = n.prefix # Finally, replace the set call with our shiny new literal. return maker
lgpl-3.0
[ 624, 199, 7012, 24739, 370, 5793, 663, 342, 4882, 370, 663, 18041, 14, 199, 624, 199, 199, 3, 6529, 26, 26844, 16997, 262, 22912, 834, 199, 199, 504, 1973, 18, 475, 19, 492, 24739, 63, 1095, 12, 23353, 199, 504, 1973, 18, 475, 19, 14, 25973, 63, 1974, 492, 1526, 12, 25308, 4388, 199, 533, 14811, 1084, 7621, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 339, 699, 45, 63, 6490, 275, 715, 272, 5027, 275, 715, 339, 31467, 7689, 275, 408, 5652, 28, 283, 409, 7, 17357, 28, 16746, 2151, 334, 4188, 29, 4188, 28, 22640, 334, 1744, 29, 513, 14367, 28, 1263, 3666, 1673, 1263, 3342, 359, 297, 1105, 690, 1816, 1204, 1816, 2849, 29, 1629, 9, 24840, 690, 2151, 1204, 2151, 6222, 28, 16746, 2974, 29, 396, 513, 63, 2145, 80, 28, 1263, 3666, 1673, 1263, 3342, 359, 297, 1105, 690, 16107, 690, 2151, 776, 2151, 16107, 690, 690, 1598, 408, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 2849, 275, 2058, 14, 362, 480, 4780, 531, 267, 340, 2849, 26, 288, 327, 4155, 282, 4026, 769, 14367, 288, 4026, 275, 23353, 14, 1716, 8, 13807, 14, 513, 14367, 12, 359, 4780, 14, 6311, 9383, 288, 2849, 14, 1814, 8, 3183, 9, 288, 2974, 275, 4026, 267, 587, 26, 288, 2974, 275, 2058, 905, 1744, 937, 398, 327, 6516, 314, 4072, 402, 314, 8785, 267, 8785, 275, 359, 647, 2350, 14, 20475, 8, 1418, 14, 44, 29246, 12, 5310, 11323, 267, 8785, 14, 2880, 8, 78, 14, 6311, 342, 367, 302, 315, 2974, 14, 3223, 9, 267, 8785, 14, 740, 8, 647, 2350, 14, 20475, 8, 1418, 14, 50, 29246, 12, 298, 93, 2237, 267, 327, 2494, 314, 2403, 402, 314, 2451, 23549, 370, 626, 402, 314, 16107, 503, 24840, 267, 8785, 1988, 17, 1055, 1861, 275, 2974, 14, 2184, 63, 17285, 14, 1861, 267, 610, 2570, 275, 23353, 14, 1716, 8, 13807, 14, 807, 409, 14367, 12, 8785, 9, 267, 610, 2570, 14, 1861, 275, 1031, 14, 1861, 398, 327, 982, 314, 3379, 1990, 282, 1373, 2008, 12, 781, 1929, 370, 2813, 314, 2402, 10029, 14, 267, 340, 822, 8, 14367, 14, 3223, 9, 508, 841, 26, 288, 302, 275, 610, 2570, 14, 3223, 59, 18, 61, 288, 302, 14, 2168, 342, 288, 610, 2570, 14, 3223, 1988, 17, 1055, 1861, 275, 302, 14, 1861, 398, 327, 19177, 12, 3350, 314, 663, 1240, 543, 4154, 1033, 8952, 892, 8785, 14, 267, 372, 610, 2570, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 7012, 24739, 370, 5793, 663, 342, 4882, 370, 663, 18041, 14, 199, 624, 199, 199, 3, 6529, 26, 26844, 16997, 262, 22912, 834, 199, 199, 504, 1973, 18, 475, 19, 492, 24739, 63, 1095, 12, 23353, 199, 504, 1973, 18, 475, 19, 14, 25973, 63, 1974, 492, 1526, 12, 25308, 4388, 199, 533, 14811, 1084, 7621, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 339, 699, 45, 63, 6490, 275, 715, 272, 5027, 275, 715, 339, 31467, 7689, 275, 408, 5652, 28, 283, 409, 7, 17357, 28, 16746, 2151, 334, 4188, 29, 4188, 28, 22640, 334, 1744, 29, 513, 14367, 28, 1263, 3666, 1673, 1263, 3342, 359, 297, 1105, 690, 1816, 1204, 1816, 2849, 29, 1629, 9, 24840, 690, 2151, 1204, 2151, 6222, 28, 16746, 2974, 29, 396, 513, 63, 2145, 80, 28, 1263, 3666, 1673, 1263, 3342, 359, 297, 1105, 690, 16107, 690, 2151, 776, 2151, 16107, 690, 690, 1598, 408, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 2849, 275, 2058, 14, 362, 480, 4780, 531, 267, 340, 2849, 26, 288, 327, 4155, 282, 4026, 769, 14367, 288, 4026, 275, 23353, 14, 1716, 8, 13807, 14, 513, 14367, 12, 359, 4780, 14, 6311, 9383, 288, 2849, 14, 1814, 8, 3183, 9, 288, 2974, 275, 4026, 267, 587, 26, 288, 2974, 275, 2058, 905, 1744, 937, 398, 327, 6516, 314, 4072, 402, 314, 8785, 267, 8785, 275, 359, 647, 2350, 14, 20475, 8, 1418, 14, 44, 29246, 12, 5310, 11323, 267, 8785, 14, 2880, 8, 78, 14, 6311, 342, 367, 302, 315, 2974, 14, 3223, 9, 267, 8785, 14, 740, 8, 647, 2350, 14, 20475, 8, 1418, 14, 50, 29246, 12, 298, 93, 2237, 267, 327, 2494, 314, 2403, 402, 314, 2451, 23549, 370, 626, 402, 314, 16107, 503, 24840, 267, 8785, 1988, 17, 1055, 1861, 275, 2974, 14, 2184, 63, 17285, 14, 1861, 267, 610, 2570, 275, 23353, 14, 1716, 8, 13807, 14, 807, 409, 14367, 12, 8785, 9, 267, 610, 2570, 14, 1861, 275, 1031, 14, 1861, 398, 327, 982, 314, 3379, 1990, 282, 1373, 2008, 12, 781, 1929, 370, 2813, 314, 2402, 10029, 14, 267, 340, 822, 8, 14367, 14, 3223, 9, 508, 841, 26, 288, 302, 275, 610, 2570, 14, 3223, 59, 18, 61, 288, 302, 14, 2168, 342, 288, 610, 2570, 14, 3223, 1988, 17, 1055, 1861, 275, 302, 14, 1861, 398, 327, 19177, 12, 3350, 314, 663, 1240, 543, 4154, 1033, 8952, 892, 8785, 14, 267, 372, 610, 2570, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
SUSE/azurectl
azurectl/commands/base.py
1
3692
# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import sys import logging # project from azurectl.cli import Cli from azurectl.config.parser import Config from azurectl.help import Help from azurectl.utils.validations import Validations from azurectl.management.request_result import RequestResult class CliTask(object): """ Base class for all task classes, loads the task and provides the interface to the command options and the account to use for the task """ def __init__(self): from azurectl.logger import log self.cli = Cli() # account setup done in command implementation self.account = None # show main help man page if requested if self.cli.show_help(): manual = Help() manual.show('azurectl') sys.exit(0) # load/import task module self.task = self.cli.load_command() # get command specific args self.command_args = self.cli.get_command_args() # get global args self.global_args = self.cli.get_global_args() # set log level if self.global_args['--debug']: log.setLevel(logging.DEBUG) def load_config(self): self.config = Config( self.global_args['--account'], self.global_args['--region'], self.global_args['--storage-account'], self.global_args['--storage-container'], self.global_args['--config'] ) self.config_file = self.config.config_file def validate_min_length(self, cmd_arg, min_length): return Validations.validate_min_length( cmd_arg, self.command_args[cmd_arg], min_length ) def validate_max_length(self, cmd_arg, max_length): return Validations.validate_max_length( cmd_arg, self.command_args[cmd_arg], max_length ) def validate_sas_permissions(self, cmd_arg): return Validations.validate_sas_permissions( cmd_arg, self.command_args[cmd_arg] ) def validate_date(self, cmd_arg): return Validations.validate_date( cmd_arg, self.command_args[cmd_arg] ) def validate_at_least_one_argument_is_set(self, keys): return Validations.validate_at_least_one_argument_is_set( self.command_args, keys ) def request_wait(self, request_id): if self.account: service = self.account.get_management_service() request_result = RequestResult(request_id) request_result.wait_for_request_completion(service) def request_status(self, request_id): if self.account: service = self.account.get_management_service() request_result = RequestResult(request_id) result_status = request_result.status(service) status = {'result': result_status.status} if result_status.status == 'Failed': status['message'] = result_status.error.message return status
apache-2.0
[ 3, 1898, 334, 67, 9, 6900, 428, 4701, 10130, 23428, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 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, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 646, 984, 199, 646, 2050, 199, 199, 3, 2199, 199, 504, 13601, 8077, 14, 2764, 492, 445, 317, 199, 504, 13601, 8077, 14, 888, 14, 2087, 492, 4094, 199, 504, 13601, 8077, 14, 3437, 492, 15456, 199, 504, 13601, 8077, 14, 1208, 14, 1078, 1298, 492, 4821, 1298, 199, 504, 13601, 8077, 14, 8110, 14, 1069, 63, 1099, 492, 4784, 2889, 421, 199, 533, 445, 317, 4476, 8, 785, 304, 272, 408, 267, 3523, 1021, 367, 1006, 2120, 3992, 12, 14404, 314, 2120, 436, 6571, 267, 314, 3217, 370, 314, 1414, 1511, 436, 314, 2933, 370, 675, 267, 367, 314, 2120, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 687, 13601, 8077, 14, 2921, 492, 943, 398, 291, 14, 2764, 275, 445, 317, 342, 398, 327, 2933, 3272, 4224, 315, 1414, 4514, 267, 291, 14, 2048, 275, 488, 398, 327, 2498, 2446, 1720, 2169, 2034, 340, 5839, 267, 340, 291, 14, 2764, 14, 2384, 63, 3437, 837, 288, 8722, 275, 15456, 342, 288, 8722, 14, 2384, 360, 9078, 8077, 358, 288, 984, 14, 2224, 8, 16, 9, 398, 327, 2248, 15, 646, 2120, 859, 267, 291, 14, 1765, 275, 291, 14, 2764, 14, 912, 63, 1531, 342, 398, 327, 664, 1414, 2488, 1249, 267, 291, 14, 1531, 63, 589, 275, 291, 14, 2764, 14, 362, 63, 1531, 63, 589, 342, 398, 327, 664, 2288, 1249, 267, 291, 14, 2966, 63, 589, 275, 291, 14, 2764, 14, 362, 63, 2966, 63, 589, 342, 398, 327, 663, 943, 2166, 267, 340, 291, 14, 2966, 63, 589, 459, 306, 1757, 2565, 288, 943, 14, 13548, 8, 4806, 14, 5287, 9, 339, 347, 2248, 63, 888, 8, 277, 304, 267, 291, 14, 888, 275, 4094, 8, 288, 291, 14, 2966, 63, 589, 459, 306, 2048, 995, 288, 291, 14, 2966, 63, 589, 459, 306, 4551, 995, 288, 291, 14, 2966, 63, 589, 459, 306, 3494, 13, 2048, 995, 288, 291, 14, 2966, 63, 589, 459, 306, 3494, 13, 3600, 995, 288, 291, 14, 2966, 63, 589, 459, 306, 888, 418, 267, 776, 267, 291, 14, 888, 63, 493, 275, 291, 14, 888, 14, 888, 63, 493, 339, 347, 4107, 63, 827, 63, 1267, 8, 277, 12, 2088, 63, 1273, 12, 1748, 63, 1267, 304, 267, 372, 4821, 1298, 14, 3502, 63, 827, 63, 1267, 8, 288, 2088, 63, 1273, 12, 288, 291, 14, 1531, 63, 589, 59, 1760, 63, 1273, 467, 288, 1748, 63, 1267, 267, 776, 339, 347, 4107, 63, 988, 63, 1267, 8, 277, 12, 2088, 63, 1273, 12, 1390, 63, 1267, 304, 267, 372, 4821, 1298, 14, 3502, 63, 988, 63, 1267, 8, 288, 2088, 63, 1273, 12, 288, 291, 14, 1531, 63, 589, 59, 1760, 63, 1273, 467, 288, 1390, 63, 1267, 267, 776, 339, 347, 4107, 63, 22601, 63, 6060, 8, 277, 12, 2088, 63, 1273, 304, 267, 372, 4821, 1298, 14, 3502, 63, 22601, 63, 6060, 8, 288, 2088, 63, 1273, 12, 288, 291, 14, 1531, 63, 589, 59, 1760, 63, 1273, 61, 267, 776, 339, 347, 4107, 63, 602, 8, 277, 12, 2088, 63, 1273, 304, 267, 372, 4821, 1298, 14, 3502, 63, 602, 8, 288, 2088, 63, 1273, 12, 288, 291, 14, 1531, 63, 589, 59, 1760, 63, 1273, 61, 267, 776, 339, 347, 4107, 63, 292, 63, 11790, 63, 368, 63, 2094, 63, 374, 63, 409, 8, 277, 12, 2883, 304, 267, 372, 4821, 1298, 14, 3502, 63, 292, 63, 11790, 63, 368, 63, 2094, 63, 374, 63, 409, 8, 288, 291, 14, 1531, 63, 589, 12, 288, 2883, 267, 776, 339, 347, 1056, 63, 2573, 8, 277, 12, 1056, 63, 344, 304, 267, 340, 291, 14, 2048, 26, 288, 2435, 275, 291, 14, 2048, 14, 362, 63, 8110, 63, 1364, 342, 288, 1056, 63, 1099, 275, 4784, 2889, 8, 1069, 63, 344, 9, 288, 1056, 63, 1099, 14, 2573, 63, 509, 63, 1069, 63, 13207, 8, 1364, 9, 339, 347, 1056, 63, 1205, 8, 277, 12, 1056, 63, 344, 304, 267, 340, 291, 14, 2048, 26, 288, 2435, 275, 291, 14, 2048, 14, 362, 63, 8110, 63, 1364, 342, 288, 1056, 63, 1099, 275, 4784, 2889, 8, 1069, 63, 344, 9, 288, 754, 63, 1205, 275, 1056, 63, 1099, 14, 1205, 8, 1364, 9, 288, 2004, 275, 791, 1099, 356, 754, 63, 1205, 14, 1205, 93, 953, 340, 754, 63, 1205, 14, 1205, 508, 283, 4276, 356, 355, 2004, 459, 1188, 418, 275, 754, 63, 1205, 14, 705, 14, 1188, 953, 372, 2004, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 428, 4701, 10130, 23428, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 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, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 646, 984, 199, 646, 2050, 199, 199, 3, 2199, 199, 504, 13601, 8077, 14, 2764, 492, 445, 317, 199, 504, 13601, 8077, 14, 888, 14, 2087, 492, 4094, 199, 504, 13601, 8077, 14, 3437, 492, 15456, 199, 504, 13601, 8077, 14, 1208, 14, 1078, 1298, 492, 4821, 1298, 199, 504, 13601, 8077, 14, 8110, 14, 1069, 63, 1099, 492, 4784, 2889, 421, 199, 533, 445, 317, 4476, 8, 785, 304, 272, 408, 267, 3523, 1021, 367, 1006, 2120, 3992, 12, 14404, 314, 2120, 436, 6571, 267, 314, 3217, 370, 314, 1414, 1511, 436, 314, 2933, 370, 675, 267, 367, 314, 2120, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 687, 13601, 8077, 14, 2921, 492, 943, 398, 291, 14, 2764, 275, 445, 317, 342, 398, 327, 2933, 3272, 4224, 315, 1414, 4514, 267, 291, 14, 2048, 275, 488, 398, 327, 2498, 2446, 1720, 2169, 2034, 340, 5839, 267, 340, 291, 14, 2764, 14, 2384, 63, 3437, 837, 288, 8722, 275, 15456, 342, 288, 8722, 14, 2384, 360, 9078, 8077, 358, 288, 984, 14, 2224, 8, 16, 9, 398, 327, 2248, 15, 646, 2120, 859, 267, 291, 14, 1765, 275, 291, 14, 2764, 14, 912, 63, 1531, 342, 398, 327, 664, 1414, 2488, 1249, 267, 291, 14, 1531, 63, 589, 275, 291, 14, 2764, 14, 362, 63, 1531, 63, 589, 342, 398, 327, 664, 2288, 1249, 267, 291, 14, 2966, 63, 589, 275, 291, 14, 2764, 14, 362, 63, 2966, 63, 589, 342, 398, 327, 663, 943, 2166, 267, 340, 291, 14, 2966, 63, 589, 459, 306, 1757, 2565, 288, 943, 14, 13548, 8, 4806, 14, 5287, 9, 339, 347, 2248, 63, 888, 8, 277, 304, 267, 291, 14, 888, 275, 4094, 8, 288, 291, 14, 2966, 63, 589, 459, 306, 2048, 995, 288, 291, 14, 2966, 63, 589, 459, 306, 4551, 995, 288, 291, 14, 2966, 63, 589, 459, 306, 3494, 13, 2048, 995, 288, 291, 14, 2966, 63, 589, 459, 306, 3494, 13, 3600, 995, 288, 291, 14, 2966, 63, 589, 459, 306, 888, 418, 267, 776, 267, 291, 14, 888, 63, 493, 275, 291, 14, 888, 14, 888, 63, 493, 339, 347, 4107, 63, 827, 63, 1267, 8, 277, 12, 2088, 63, 1273, 12, 1748, 63, 1267, 304, 267, 372, 4821, 1298, 14, 3502, 63, 827, 63, 1267, 8, 288, 2088, 63, 1273, 12, 288, 291, 14, 1531, 63, 589, 59, 1760, 63, 1273, 467, 288, 1748, 63, 1267, 267, 776, 339, 347, 4107, 63, 988, 63, 1267, 8, 277, 12, 2088, 63, 1273, 12, 1390, 63, 1267, 304, 267, 372, 4821, 1298, 14, 3502, 63, 988, 63, 1267, 8, 288, 2088, 63, 1273, 12, 288, 291, 14, 1531, 63, 589, 59, 1760, 63, 1273, 467, 288, 1390, 63, 1267, 267, 776, 339, 347, 4107, 63, 22601, 63, 6060, 8, 277, 12, 2088, 63, 1273, 304, 267, 372, 4821, 1298, 14, 3502, 63, 22601, 63, 6060, 8, 288, 2088, 63, 1273, 12, 288, 291, 14, 1531, 63, 589, 59, 1760, 63, 1273, 61, 267, 776, 339, 347, 4107, 63, 602, 8, 277, 12, 2088, 63, 1273, 304, 267, 372, 4821, 1298, 14, 3502, 63, 602, 8, 288, 2088, 63, 1273, 12, 288, 291, 14, 1531, 63, 589, 59, 1760, 63, 1273, 61, 267, 776, 339, 347, 4107, 63, 292, 63, 11790, 63, 368, 63, 2094, 63, 374, 63, 409, 8, 277, 12, 2883, 304, 267, 372, 4821, 1298, 14, 3502, 63, 292, 63, 11790, 63, 368, 63, 2094, 63, 374, 63, 409, 8, 288, 291, 14, 1531, 63, 589, 12, 288, 2883, 267, 776, 339, 347, 1056, 63, 2573, 8, 277, 12, 1056, 63, 344, 304, 267, 340, 291, 14, 2048, 26, 288, 2435, 275, 291, 14, 2048, 14, 362, 63, 8110, 63, 1364, 342, 288, 1056, 63, 1099, 275, 4784, 2889, 8, 1069, 63, 344, 9, 288, 1056, 63, 1099, 14, 2573, 63, 509, 63, 1069, 63, 13207, 8, 1364, 9, 339, 347, 1056, 63, 1205, 8, 277, 12, 1056, 63, 344, 304, 267, 340, 291, 14, 2048, 26, 288, 2435, 275, 291, 14, 2048, 14, 362, 63, 8110, 63, 1364, 342, 288, 1056, 63, 1099, 275, 4784, 2889, 8, 1069, 63, 344, 9, 288, 754, 63, 1205, 275, 1056, 63, 1099, 14, 1205, 8, 1364, 9, 288, 2004, 275, 791, 1099, 356, 754, 63, 1205, 14, 1205, 93, 953, 340, 754, 63, 1205, 14, 1205, 508, 283, 4276, 356, 355, 2004, 459, 1188, 418, 275, 754, 63, 1205, 14, 705, 14, 1188, 953, 372, 2004, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ezequielpereira/Time-Line
libs_arm/wx/py/interpreter.py
4
6422
"""Interpreter executes Python commands.""" __author__ = "Patrick K. O'Brien <pobrien@orbtech.com> / " __author__ += "David N. Mashburn <david.n.mashburn@gmail.com>" __cvsid__ = "$Id$" __revision__ = "$Revision$"[11:-2] import os import sys from code import InteractiveInterpreter, compile_command import dispatcher import introspect import wx class Interpreter(InteractiveInterpreter): """Interpreter based on code.InteractiveInterpreter.""" revision = __revision__ def __init__(self, locals=None, rawin=None, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, showInterpIntro=True): """Create an interactive interpreter object.""" InteractiveInterpreter.__init__(self, locals=locals) self.stdin = stdin self.stdout = stdout self.stderr = stderr if rawin: import __builtin__ __builtin__.raw_input = rawin del __builtin__ if showInterpIntro: copyright = 'Type "help", "copyright", "credits" or "license"' copyright += ' for more information.' self.introText = 'Python %s on %s%s%s' % \ (sys.version, sys.platform, os.linesep, copyright) try: sys.ps1 except AttributeError: sys.ps1 = '>>> ' try: sys.ps2 except AttributeError: sys.ps2 = '... ' self.more = 0 # List of lists to support recursive push(). self.commandBuffer = [] self.startupScript = None def push(self, command, astMod=None): """Send command to the interpreter to be executed. Because this may be called recursively, we append a new list onto the commandBuffer list and then append commands into that. If the passed in command is part of a multi-line command we keep appending the pieces to the last list in commandBuffer until we have a complete command. If not, we delete that last list.""" # In case the command is unicode try encoding it if type(command) == unicode: try: command = command.encode(wx.GetDefaultPyEncoding()) except UnicodeEncodeError: pass # otherwise leave it alone if not self.more: try: del self.commandBuffer[-1] except IndexError: pass if not self.more: self.commandBuffer.append([]) self.commandBuffer[-1].append(command) source = '\n'.join(self.commandBuffer[-1]) # If an ast code module is passed, pass it to runModule instead more=False if astMod != None: self.runModule(astMod) self.more=False else: more = self.more = self.runsource(source) dispatcher.send(signal='Interpreter.push', sender=self, command=command, more=more, source=source) return more def runsource(self, source): """Compile and run source code in the interpreter.""" stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr sys.stdin, sys.stdout, sys.stderr = \ self.stdin, self.stdout, self.stderr more = InteractiveInterpreter.runsource(self, source) # this was a cute idea, but didn't work... #more = self.runcode(compile(source,'', # ('exec' if self.useExecMode else 'single'))) # If sys.std* is still what we set it to, then restore it. # But, if the executed source changed sys.std*, assume it was # meant to be changed and leave it. Power to the people. if sys.stdin == self.stdin: sys.stdin = stdin else: self.stdin = sys.stdin if sys.stdout == self.stdout: sys.stdout = stdout else: self.stdout = sys.stdout if sys.stderr == self.stderr: sys.stderr = stderr else: self.stderr = sys.stderr return more def runModule(self, mod): """Compile and run an ast module in the interpreter.""" stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr sys.stdin, sys.stdout, sys.stderr = \ self.stdin, self.stdout, self.stderr self.runcode(compile(mod,'','single')) # If sys.std* is still what we set it to, then restore it. # But, if the executed source changed sys.std*, assume it was # meant to be changed and leave it. Power to the people. if sys.stdin == self.stdin: sys.stdin = stdin else: self.stdin = sys.stdin if sys.stdout == self.stdout: sys.stdout = stdout else: self.stdout = sys.stdout if sys.stderr == self.stderr: sys.stderr = stderr else: self.stderr = sys.stderr return False def getAutoCompleteKeys(self): """Return list of auto-completion keycodes.""" return [ord('.')] def getAutoCompleteList(self, command='', *args, **kwds): """Return list of auto-completion options for a command. The list of options will be based on the locals namespace.""" stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr sys.stdin, sys.stdout, sys.stderr = \ self.stdin, self.stdout, self.stderr l = introspect.getAutoCompleteList(command, self.locals, *args, **kwds) sys.stdin, sys.stdout, sys.stderr = stdin, stdout, stderr return l def getCallTip(self, command='', *args, **kwds): """Return call tip text for a command. Call tip information will be based on the locals namespace.""" return introspect.getCallTip(command, self.locals, *args, **kwds) class InterpreterAlaCarte(Interpreter): """Demo Interpreter.""" def __init__(self, locals, rawin, stdin, stdout, stderr, ps1='main prompt', ps2='continuation prompt'): """Create an interactive interpreter object.""" Interpreter.__init__(self, locals=locals, rawin=rawin, stdin=stdin, stdout=stdout, stderr=stderr) sys.ps1 = ps1 sys.ps2 = ps2
gpl-3.0
[ 624, 2620, 26499, 24956, 2018, 3718, 1041, 199, 199, 363, 2502, 363, 275, 298, 48, 292, 27091, 1804, 14, 593, 7, 34, 322, 287, 665, 555, 9660, 287, 32, 269, 66, 15970, 14, 957, 30, 1182, 298, 199, 363, 2502, 363, 847, 298, 36, 17204, 653, 14, 603, 1119, 30736, 665, 983, 5017, 14, 78, 14, 77, 1119, 30736, 32, 6799, 14, 957, 4335, 199, 363, 5107, 4148, 363, 275, 7880, 1304, 17351, 199, 363, 5792, 363, 275, 7880, 12714, 17351, 59, 845, 6809, 18, 61, 199, 199, 646, 747, 199, 646, 984, 199, 504, 1233, 492, 1010, 7502, 2620, 26499, 12, 6555, 63, 1531, 199, 646, 17475, 199, 646, 1109, 21302, 199, 646, 4818, 199, 199, 533, 6551, 26499, 8, 23879, 2620, 26499, 304, 272, 408, 2620, 26499, 4079, 641, 1233, 14, 23879, 2620, 26499, 1041, 2286, 6974, 275, 636, 5792, 363, 2286, 347, 636, 826, 721, 277, 12, 9480, 29, 403, 12, 660, 2676, 29, 403, 12, 20169, 9009, 29, 1274, 14, 6626, 12, 3839, 29, 1274, 14, 2703, 12, 4635, 29, 1274, 14, 3083, 12, 326, 2498, 2620, 80, 3241, 293, 29, 549, 304, 267, 408, 2499, 376, 12777, 12693, 909, 1041, 267, 1010, 7502, 2620, 26499, 855, 826, 721, 277, 12, 9480, 29, 9350, 9, 267, 291, 14, 6626, 275, 9009, 267, 291, 14, 2703, 275, 3839, 267, 291, 14, 3083, 275, 4635, 267, 340, 660, 2676, 26, 288, 492, 636, 5351, 363, 288, 636, 5351, 4343, 1773, 63, 1210, 275, 660, 2676, 288, 2150, 636, 5351, 363, 267, 340, 2498, 2620, 80, 3241, 293, 26, 288, 4248, 275, 283, 804, 298, 3437, 401, 298, 7307, 401, 298, 22461, 2, 503, 298, 1682, 4507, 288, 4248, 847, 283, 367, 1655, 2556, 3530, 288, 291, 14, 18206, 1872, 275, 283, 4718, 450, 83, 641, 450, 83, 5, 83, 5, 83, 7, 450, 971, 2490, 334, 1274, 14, 1023, 12, 984, 14, 3246, 12, 747, 14, 19254, 12, 4248, 9, 267, 862, 26, 288, 984, 14, 1190, 17, 267, 871, 4281, 26, 288, 984, 14, 1190, 17, 275, 283, 6071, 283, 267, 862, 26, 288, 984, 14, 1190, 18, 267, 871, 4281, 26, 288, 984, 14, 1190, 18, 275, 24352, 283, 267, 291, 14, 6878, 275, 378, 267, 327, 3820, 402, 5548, 370, 2291, 9133, 6675, 1252, 267, 291, 14, 1531, 3299, 275, 942, 267, 291, 14, 16480, 5229, 275, 488, 2286, 347, 6675, 8, 277, 12, 1414, 12, 6073, 9871, 29, 403, 304, 267, 408, 6795, 1414, 370, 314, 12693, 370, 506, 7934, 14, 2728, 13821, 642, 1443, 506, 2797, 15035, 12, 781, 5666, 282, 892, 769, 267, 14602, 314, 1414, 3299, 769, 436, 2066, 5666, 3718, 1901, 267, 626, 14, 221, 982, 314, 3032, 315, 1414, 365, 1777, 402, 282, 3510, 13, 604, 267, 1414, 781, 4215, 24373, 314, 10338, 370, 314, 2061, 769, 315, 267, 1414, 3299, 5133, 781, 1172, 282, 4890, 1414, 14, 982, 440, 12, 781, 267, 3145, 626, 2061, 769, 1041, 2728, 327, 1010, 1930, 314, 1414, 365, 2649, 862, 2644, 652, 267, 340, 730, 8, 1531, 9, 508, 2649, 26, 288, 862, 26, 355, 1414, 275, 1414, 14, 2143, 8, 6323, 14, 1002, 2698, 2713, 7630, 1012, 288, 871, 24094, 26, 355, 986, 327, 4257, 10137, 652, 23016, 21695, 340, 440, 291, 14, 6878, 26, 288, 862, 26, 2150, 291, 14, 1531, 3299, 1988, 17, 61, 288, 871, 7888, 26, 986, 267, 340, 440, 291, 14, 6878, 26, 291, 14, 1531, 3299, 14, 740, 4157, 267, 291, 14, 1531, 3299, 1988, 17, 1055, 740, 8, 1531, 9, 267, 1350, 275, 1557, 78, 1370, 904, 8, 277, 14, 1531, 3299, 1988, 17, 566, 2728, 327, 982, 376, 6073, 1233, 859, 365, 3032, 12, 986, 652, 370, 1255, 2377, 3140, 267, 1655, 29, 797, 267, 340, 6073, 9871, 1137, 488, 26, 288, 291, 14, 1065, 2377, 8, 1810, 9871, 9, 288, 291, 14, 6878, 29, 797, 267, 587, 26, 288, 1655, 275, 291, 14, 6878, 275, 291, 14, 1065, 1365, 8, 1365, 9, 267, 17475, 14, 2254, 8, 4653, 534, 2620, 26499, 14, 5335, 297, 8904, 29, 277, 12, 717, 1414, 29, 1531, 12, 1655, 29, 6878, 12, 1350, 29, 1365, 9, 267, 372, 1655, 5493, 347, 1255, 1365, 8, 277, 12, 1350, 304, 267, 408, 12626, 436, 1255, 1350, 1233, 315, 314, 12693, 1041, 267, 9009, 12, 3839, 12, 4635, 275, 984, 14, 6626, 12, 984, 14, 2703, 12, 984, 14, 3083, 267, 984, 14, 6626, 12, 984, 14, 2703, 12, 984, 14, 3083, 275, 971, 673, 291, 14, 6626, 12, 291, 14, 2703, 12, 291, 14, 3083, 267, 1655, 275, 1010, 7502, 2620, 26499, 14, 1065, 1365, 8, 277, 12, 1350, 9, 267, 327, 642, 1990, 282, 286, 938, 16819, 12, 1325, 9980, 1133, 1736, 1396, 267, 327, 6878, 275, 291, 14, 1065, 600, 8, 2014, 8, 1365, 2584, 297, 267, 327, 5185, 661, 1628, 7, 340, 291, 14, 1180, 4858, 1385, 587, 283, 4780, 7058, 30712, 327, 982, 984, 14, 1516, 10, 365, 5139, 4052, 781, 663, 652, 370, 12, 2066, 9066, 652, 14, 267, 327, 11017, 12, 340, 314, 7934, 1350, 2896, 984, 14, 1516, 10381, 5534, 652, 1990, 267, 327, 18329, 370, 506, 2896, 436, 10137, 652, 14, 18879, 370, 314, 13135, 14, 267, 340, 984, 14, 6626, 508, 291, 14, 6626, 26, 288, 984, 14, 6626, 275, 9009, 267, 587, 26, 288, 291, 14, 6626, 275, 984, 14, 6626, 267, 340, 984, 14, 2703, 508, 291, 14, 2703, 26, 288, 984, 14, 2703, 275, 3839, 267, 587, 26, 288, 291, 14, 2703, 275, 984, 14, 2703, 267, 340, 984, 14, 3083, 508, 291, 14, 3083, 26, 288, 984, 14, 3083, 275, 4635, 267, 587, 26, 288, 291, 14, 3083, 275, 984, 14, 3083, 267, 372, 1655, 5493, 347, 1255, 2377, 8, 277, 12, 3413, 304, 267, 408, 12626, 436, 1255, 376, 6073, 859, 315, 314, 12693, 1041, 267, 9009, 12, 3839, 12, 4635, 275, 984, 14, 6626, 12, 984, 14, 2703, 12, 984, 14, 3083, 267, 984, 14, 6626, 12, 984, 14, 2703, 12, 984, 14, 3083, 275, 971, 673, 291, 14, 6626, 12, 291, 14, 2703, 12, 291, 14, 3083, 267, 291, 14, 1065, 600, 8, 2014, 8, 1494, 2584 ]
[ 2620, 26499, 24956, 2018, 3718, 1041, 199, 199, 363, 2502, 363, 275, 298, 48, 292, 27091, 1804, 14, 593, 7, 34, 322, 287, 665, 555, 9660, 287, 32, 269, 66, 15970, 14, 957, 30, 1182, 298, 199, 363, 2502, 363, 847, 298, 36, 17204, 653, 14, 603, 1119, 30736, 665, 983, 5017, 14, 78, 14, 77, 1119, 30736, 32, 6799, 14, 957, 4335, 199, 363, 5107, 4148, 363, 275, 7880, 1304, 17351, 199, 363, 5792, 363, 275, 7880, 12714, 17351, 59, 845, 6809, 18, 61, 199, 199, 646, 747, 199, 646, 984, 199, 504, 1233, 492, 1010, 7502, 2620, 26499, 12, 6555, 63, 1531, 199, 646, 17475, 199, 646, 1109, 21302, 199, 646, 4818, 199, 199, 533, 6551, 26499, 8, 23879, 2620, 26499, 304, 272, 408, 2620, 26499, 4079, 641, 1233, 14, 23879, 2620, 26499, 1041, 2286, 6974, 275, 636, 5792, 363, 2286, 347, 636, 826, 721, 277, 12, 9480, 29, 403, 12, 660, 2676, 29, 403, 12, 20169, 9009, 29, 1274, 14, 6626, 12, 3839, 29, 1274, 14, 2703, 12, 4635, 29, 1274, 14, 3083, 12, 326, 2498, 2620, 80, 3241, 293, 29, 549, 304, 267, 408, 2499, 376, 12777, 12693, 909, 1041, 267, 1010, 7502, 2620, 26499, 855, 826, 721, 277, 12, 9480, 29, 9350, 9, 267, 291, 14, 6626, 275, 9009, 267, 291, 14, 2703, 275, 3839, 267, 291, 14, 3083, 275, 4635, 267, 340, 660, 2676, 26, 288, 492, 636, 5351, 363, 288, 636, 5351, 4343, 1773, 63, 1210, 275, 660, 2676, 288, 2150, 636, 5351, 363, 267, 340, 2498, 2620, 80, 3241, 293, 26, 288, 4248, 275, 283, 804, 298, 3437, 401, 298, 7307, 401, 298, 22461, 2, 503, 298, 1682, 4507, 288, 4248, 847, 283, 367, 1655, 2556, 3530, 288, 291, 14, 18206, 1872, 275, 283, 4718, 450, 83, 641, 450, 83, 5, 83, 5, 83, 7, 450, 971, 2490, 334, 1274, 14, 1023, 12, 984, 14, 3246, 12, 747, 14, 19254, 12, 4248, 9, 267, 862, 26, 288, 984, 14, 1190, 17, 267, 871, 4281, 26, 288, 984, 14, 1190, 17, 275, 283, 6071, 283, 267, 862, 26, 288, 984, 14, 1190, 18, 267, 871, 4281, 26, 288, 984, 14, 1190, 18, 275, 24352, 283, 267, 291, 14, 6878, 275, 378, 267, 327, 3820, 402, 5548, 370, 2291, 9133, 6675, 1252, 267, 291, 14, 1531, 3299, 275, 942, 267, 291, 14, 16480, 5229, 275, 488, 2286, 347, 6675, 8, 277, 12, 1414, 12, 6073, 9871, 29, 403, 304, 267, 408, 6795, 1414, 370, 314, 12693, 370, 506, 7934, 14, 2728, 13821, 642, 1443, 506, 2797, 15035, 12, 781, 5666, 282, 892, 769, 267, 14602, 314, 1414, 3299, 769, 436, 2066, 5666, 3718, 1901, 267, 626, 14, 221, 982, 314, 3032, 315, 1414, 365, 1777, 402, 282, 3510, 13, 604, 267, 1414, 781, 4215, 24373, 314, 10338, 370, 314, 2061, 769, 315, 267, 1414, 3299, 5133, 781, 1172, 282, 4890, 1414, 14, 982, 440, 12, 781, 267, 3145, 626, 2061, 769, 1041, 2728, 327, 1010, 1930, 314, 1414, 365, 2649, 862, 2644, 652, 267, 340, 730, 8, 1531, 9, 508, 2649, 26, 288, 862, 26, 355, 1414, 275, 1414, 14, 2143, 8, 6323, 14, 1002, 2698, 2713, 7630, 1012, 288, 871, 24094, 26, 355, 986, 327, 4257, 10137, 652, 23016, 21695, 340, 440, 291, 14, 6878, 26, 288, 862, 26, 2150, 291, 14, 1531, 3299, 1988, 17, 61, 288, 871, 7888, 26, 986, 267, 340, 440, 291, 14, 6878, 26, 291, 14, 1531, 3299, 14, 740, 4157, 267, 291, 14, 1531, 3299, 1988, 17, 1055, 740, 8, 1531, 9, 267, 1350, 275, 1557, 78, 1370, 904, 8, 277, 14, 1531, 3299, 1988, 17, 566, 2728, 327, 982, 376, 6073, 1233, 859, 365, 3032, 12, 986, 652, 370, 1255, 2377, 3140, 267, 1655, 29, 797, 267, 340, 6073, 9871, 1137, 488, 26, 288, 291, 14, 1065, 2377, 8, 1810, 9871, 9, 288, 291, 14, 6878, 29, 797, 267, 587, 26, 288, 1655, 275, 291, 14, 6878, 275, 291, 14, 1065, 1365, 8, 1365, 9, 267, 17475, 14, 2254, 8, 4653, 534, 2620, 26499, 14, 5335, 297, 8904, 29, 277, 12, 717, 1414, 29, 1531, 12, 1655, 29, 6878, 12, 1350, 29, 1365, 9, 267, 372, 1655, 5493, 347, 1255, 1365, 8, 277, 12, 1350, 304, 267, 408, 12626, 436, 1255, 1350, 1233, 315, 314, 12693, 1041, 267, 9009, 12, 3839, 12, 4635, 275, 984, 14, 6626, 12, 984, 14, 2703, 12, 984, 14, 3083, 267, 984, 14, 6626, 12, 984, 14, 2703, 12, 984, 14, 3083, 275, 971, 673, 291, 14, 6626, 12, 291, 14, 2703, 12, 291, 14, 3083, 267, 1655, 275, 1010, 7502, 2620, 26499, 14, 1065, 1365, 8, 277, 12, 1350, 9, 267, 327, 642, 1990, 282, 286, 938, 16819, 12, 1325, 9980, 1133, 1736, 1396, 267, 327, 6878, 275, 291, 14, 1065, 600, 8, 2014, 8, 1365, 2584, 297, 267, 327, 5185, 661, 1628, 7, 340, 291, 14, 1180, 4858, 1385, 587, 283, 4780, 7058, 30712, 327, 982, 984, 14, 1516, 10, 365, 5139, 4052, 781, 663, 652, 370, 12, 2066, 9066, 652, 14, 267, 327, 11017, 12, 340, 314, 7934, 1350, 2896, 984, 14, 1516, 10381, 5534, 652, 1990, 267, 327, 18329, 370, 506, 2896, 436, 10137, 652, 14, 18879, 370, 314, 13135, 14, 267, 340, 984, 14, 6626, 508, 291, 14, 6626, 26, 288, 984, 14, 6626, 275, 9009, 267, 587, 26, 288, 291, 14, 6626, 275, 984, 14, 6626, 267, 340, 984, 14, 2703, 508, 291, 14, 2703, 26, 288, 984, 14, 2703, 275, 3839, 267, 587, 26, 288, 291, 14, 2703, 275, 984, 14, 2703, 267, 340, 984, 14, 3083, 508, 291, 14, 3083, 26, 288, 984, 14, 3083, 275, 4635, 267, 587, 26, 288, 291, 14, 3083, 275, 984, 14, 3083, 267, 372, 1655, 5493, 347, 1255, 2377, 8, 277, 12, 3413, 304, 267, 408, 12626, 436, 1255, 376, 6073, 859, 315, 314, 12693, 1041, 267, 9009, 12, 3839, 12, 4635, 275, 984, 14, 6626, 12, 984, 14, 2703, 12, 984, 14, 3083, 267, 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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 ]
nevercast/home-assistant
homeassistant/components/sensor/time_date.py
5
2649
""" homeassistant.components.sensor.time_date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Date and Time service. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.time_date/ """ import logging import homeassistant.util.dt as dt_util from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) OPTION_TYPES = { 'time': 'Time', 'date': 'Date', 'date_time': 'Date & Time', 'time_date': 'Time & Date', 'beat': 'Time (beat)', 'time_utc': 'Time (UTC)', } def setup_platform(hass, config, add_devices, discovery_info=None): """ Get the Time and Date sensor. """ if hass.config.time_zone is None: _LOGGER.error("Timezone is not set in Home Assistant config") return False dev = [] for variable in config['display_options']: if variable not in OPTION_TYPES: _LOGGER.error('Option type: "%s" does not exist', variable) else: dev.append(TimeDateSensor(variable)) add_devices(dev) # pylint: disable=too-few-public-methods class TimeDateSensor(Entity): """ Implements a Time and Date sensor. """ def __init__(self, option_type): self._name = OPTION_TYPES[option_type] self.type = option_type self._state = None self.update() @property def name(self): """ Returns the name of the device. """ return self._name @property def state(self): """ Returns the state of the device. """ return self._state def update(self): """ Gets the latest data and updates the states. """ time_date = dt_util.utcnow() time = dt_util.datetime_to_time_str(dt_util.as_local(time_date)) time_utc = dt_util.datetime_to_time_str(time_date) date = dt_util.datetime_to_date_str(dt_util.as_local(time_date)) # Calculate the beat (Swatch Internet Time) time without date. hours, minutes, seconds = time_date.strftime('%H:%M:%S').split(':') beat = ((int(seconds) + (int(minutes) * 60) + ((int(hours) + 1) * 3600)) / 86.4) if self.type == 'time': self._state = time elif self.type == 'date': self._state = date elif self.type == 'date_time': self._state = date + ', ' + time elif self.type == 'time_date': self._state = time + ', ' + date elif self.type == 'time_utc': self._state = time_utc elif self.type == 'beat': self._state = '{0:.2f}'.format(beat)
mit
[ 624, 199, 22799, 14, 4608, 14, 8956, 14, 521, 63, 602, 199, 30642, 4919, 94, 199, 2506, 436, 4703, 2435, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 8956, 14, 521, 63, 602, 15, 199, 624, 199, 646, 2050, 199, 199, 646, 8846, 14, 1974, 14, 3583, 465, 4487, 63, 1974, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 13352, 63, 7893, 275, 469, 272, 283, 521, 356, 283, 1366, 297, 272, 283, 602, 356, 283, 2506, 297, 272, 283, 602, 63, 521, 356, 283, 2506, 1253, 4703, 297, 272, 283, 521, 63, 602, 356, 283, 1366, 1253, 6148, 297, 272, 283, 12522, 356, 283, 1366, 334, 12522, 3196, 272, 283, 521, 63, 5834, 356, 283, 1366, 334, 11288, 3196, 199, 93, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 2372, 314, 4703, 436, 6148, 8778, 14, 408, 339, 340, 6298, 14, 888, 14, 521, 63, 2619, 365, 488, 26, 267, 485, 10186, 14, 705, 480, 28705, 365, 440, 663, 315, 14621, 3709, 18832, 1101, 531, 267, 372, 756, 339, 4866, 275, 942, 272, 367, 1750, 315, 1101, 459, 2918, 63, 1419, 2565, 267, 340, 1750, 440, 315, 11662, 1075, 63, 7893, 26, 288, 485, 10186, 14, 705, 360, 2602, 730, 26, 2071, 83, 2, 1630, 440, 2187, 297, 1750, 9, 267, 587, 26, 288, 4866, 14, 740, 8, 1366, 2506, 10160, 8, 1975, 430, 339, 1050, 63, 6410, 8, 2374, 9, 421, 199, 3, 4287, 26, 3507, 29, 7354, 13, 70, 546, 13, 3455, 13, 2474, 199, 533, 4703, 2506, 10160, 8, 7302, 304, 272, 408, 24664, 282, 4703, 436, 6148, 8778, 14, 408, 339, 347, 636, 826, 721, 277, 12, 945, 63, 466, 304, 267, 291, 423, 354, 275, 11662, 1075, 63, 7893, 59, 1422, 63, 466, 61, 267, 291, 14, 466, 275, 945, 63, 466, 267, 291, 423, 929, 275, 488, 267, 291, 14, 873, 342, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1803, 314, 536, 402, 314, 2243, 14, 408, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1803, 314, 1174, 402, 314, 2243, 14, 408, 267, 372, 291, 423, 929, 339, 347, 1678, 8, 277, 304, 267, 408, 14509, 314, 8839, 666, 436, 7029, 314, 6363, 14, 408, 398, 900, 63, 602, 275, 4487, 63, 1974, 14, 10779, 342, 267, 900, 275, 4487, 63, 1974, 14, 2083, 63, 475, 63, 521, 63, 495, 8, 3583, 63, 1974, 14, 305, 63, 1832, 8, 521, 63, 602, 430, 267, 900, 63, 5834, 275, 4487, 63, 1974, 14, 2083, 63, 475, 63, 521, 63, 495, 8, 521, 63, 602, 9, 267, 1434, 275, 4487, 63, 1974, 14, 2083, 63, 475, 63, 602, 63, 495, 8, 3583, 63, 1974, 14, 305, 63, 1832, 8, 521, 63, 602, 430, 398, 327, 12707, 314, 506, 292, 334, 51, 6821, 22026, 4703, 9, 900, 1928, 1434, 14, 267, 10857, 12, 9395, 12, 4696, 275, 900, 63, 602, 14, 6205, 3508, 40, 2689, 45, 2689, 51, 1959, 1294, 11633, 267, 506, 292, 275, 3666, 442, 8, 4515, 9, 435, 334, 442, 8, 10430, 9, 627, 5212, 9, 435, 3666, 442, 8, 8419, 9, 435, 413, 9, 627, 10940, 15751, 430, 1182, 10300, 14, 20, 9, 398, 340, 291, 14, 466, 508, 283, 521, 356, 288, 291, 423, 929, 275, 900, 267, 916, 291, 14, 466, 508, 283, 602, 356, 288, 291, 423, 929, 275, 1434, 267, 916, 291, 14, 466, 508, 283, 602, 63, 521, 356, 288, 291, 423, 929, 275, 1434, 435, 1656, 283, 435, 900, 267, 916, 291, 14, 466, 508, 283, 521, 63, 602, 356, 288, 291, 423, 929, 275, 900, 435, 1656, 283, 435, 1434, 267, 916, 291, 14, 466, 508, 283, 521, 63, 5834, 356, 288, 291, 423, 929, 275, 900, 63, 5834, 267, 916, 291, 14, 466, 508, 283, 12522, 356, 288, 291, 423, 929, 275, 5041, 16, 14010, 18, 70, 5285, 908, 8, 12522, 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 ]
[ 199, 22799, 14, 4608, 14, 8956, 14, 521, 63, 602, 199, 30642, 4919, 94, 199, 2506, 436, 4703, 2435, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 8956, 14, 521, 63, 602, 15, 199, 624, 199, 646, 2050, 199, 199, 646, 8846, 14, 1974, 14, 3583, 465, 4487, 63, 1974, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 13352, 63, 7893, 275, 469, 272, 283, 521, 356, 283, 1366, 297, 272, 283, 602, 356, 283, 2506, 297, 272, 283, 602, 63, 521, 356, 283, 2506, 1253, 4703, 297, 272, 283, 521, 63, 602, 356, 283, 1366, 1253, 6148, 297, 272, 283, 12522, 356, 283, 1366, 334, 12522, 3196, 272, 283, 521, 63, 5834, 356, 283, 1366, 334, 11288, 3196, 199, 93, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 2372, 314, 4703, 436, 6148, 8778, 14, 408, 339, 340, 6298, 14, 888, 14, 521, 63, 2619, 365, 488, 26, 267, 485, 10186, 14, 705, 480, 28705, 365, 440, 663, 315, 14621, 3709, 18832, 1101, 531, 267, 372, 756, 339, 4866, 275, 942, 272, 367, 1750, 315, 1101, 459, 2918, 63, 1419, 2565, 267, 340, 1750, 440, 315, 11662, 1075, 63, 7893, 26, 288, 485, 10186, 14, 705, 360, 2602, 730, 26, 2071, 83, 2, 1630, 440, 2187, 297, 1750, 9, 267, 587, 26, 288, 4866, 14, 740, 8, 1366, 2506, 10160, 8, 1975, 430, 339, 1050, 63, 6410, 8, 2374, 9, 421, 199, 3, 4287, 26, 3507, 29, 7354, 13, 70, 546, 13, 3455, 13, 2474, 199, 533, 4703, 2506, 10160, 8, 7302, 304, 272, 408, 24664, 282, 4703, 436, 6148, 8778, 14, 408, 339, 347, 636, 826, 721, 277, 12, 945, 63, 466, 304, 267, 291, 423, 354, 275, 11662, 1075, 63, 7893, 59, 1422, 63, 466, 61, 267, 291, 14, 466, 275, 945, 63, 466, 267, 291, 423, 929, 275, 488, 267, 291, 14, 873, 342, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1803, 314, 536, 402, 314, 2243, 14, 408, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1803, 314, 1174, 402, 314, 2243, 14, 408, 267, 372, 291, 423, 929, 339, 347, 1678, 8, 277, 304, 267, 408, 14509, 314, 8839, 666, 436, 7029, 314, 6363, 14, 408, 398, 900, 63, 602, 275, 4487, 63, 1974, 14, 10779, 342, 267, 900, 275, 4487, 63, 1974, 14, 2083, 63, 475, 63, 521, 63, 495, 8, 3583, 63, 1974, 14, 305, 63, 1832, 8, 521, 63, 602, 430, 267, 900, 63, 5834, 275, 4487, 63, 1974, 14, 2083, 63, 475, 63, 521, 63, 495, 8, 521, 63, 602, 9, 267, 1434, 275, 4487, 63, 1974, 14, 2083, 63, 475, 63, 602, 63, 495, 8, 3583, 63, 1974, 14, 305, 63, 1832, 8, 521, 63, 602, 430, 398, 327, 12707, 314, 506, 292, 334, 51, 6821, 22026, 4703, 9, 900, 1928, 1434, 14, 267, 10857, 12, 9395, 12, 4696, 275, 900, 63, 602, 14, 6205, 3508, 40, 2689, 45, 2689, 51, 1959, 1294, 11633, 267, 506, 292, 275, 3666, 442, 8, 4515, 9, 435, 334, 442, 8, 10430, 9, 627, 5212, 9, 435, 3666, 442, 8, 8419, 9, 435, 413, 9, 627, 10940, 15751, 430, 1182, 10300, 14, 20, 9, 398, 340, 291, 14, 466, 508, 283, 521, 356, 288, 291, 423, 929, 275, 900, 267, 916, 291, 14, 466, 508, 283, 602, 356, 288, 291, 423, 929, 275, 1434, 267, 916, 291, 14, 466, 508, 283, 602, 63, 521, 356, 288, 291, 423, 929, 275, 1434, 435, 1656, 283, 435, 900, 267, 916, 291, 14, 466, 508, 283, 521, 63, 602, 356, 288, 291, 423, 929, 275, 900, 435, 1656, 283, 435, 1434, 267, 916, 291, 14, 466, 508, 283, 521, 63, 5834, 356, 288, 291, 423, 929, 275, 900, 63, 5834, 267, 916, 291, 14, 466, 508, 283, 12522, 356, 288, 291, 423, 929, 275, 5041, 16, 14010, 18, 70, 5285, 908, 8, 12522, 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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