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
sudo87/cm_api
cm_api/endpoints/dashboards.py
7
2494
# Licensed to Cloudera, Inc. under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. Cloudera, Inc. licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from cm_api.endpoints.types import * __docformat__ = "epytext" DASHBOARDS_PATH = "/timeseries/dashboards" def _get_dashboard_path(dashboard_name): return DASHBOARDS_PATH + "/%s" % (dashboard_name) def create_dashboards(resource_root, dashboard_list): """ Creates the list of dashboards. If any of the dashboards already exist this whole command will fail and no dashboards will be created. @since: API v6 @return: The list of dashboards created. """ return call(resource_root.post, DASHBOARDS_PATH, ApiDashboard, \ ret_is_list=True, data=dashboard_list) def get_dashboards(resource_root): """ Returns the list of all dashboards. @since: API v6 @return: A list of API dashboard objects. """ return call(resource_root.get, DASHBOARDS_PATH, ApiDashboard, \ ret_is_list=True) def get_dashboard(resource_root, dashboard_name): """ Returns a dashboard definition for the specified name. This dashboard can be imported with the createDashboards API. @since: API v6 @return: An API dasbhboard object. """ return call(resource_root.get, _get_dashboard_path(dashboard_name), \ ApiDashboard) def delete_dashboard(resource_root, dashboard_name): """ Deletes a dashboard. @since: API v6 @return: The deleted dashboard. """ return call(resource_root.delete, _get_dashboard_path(dashboard_name), \ ApiDashboard) class ApiDashboard(BaseApiResource): _ATTRIBUTES = { 'name' : None, 'json' : None } def __init__(self, resource_root, name=None, json=None): BaseApiObject.init(self, resource_root, locals()) def __str__(self): return "<ApiDashboard>: %s" % (self.name) def _path(self): return _get_dashboard_path(self.name)
apache-2.0
[ 3, 3909, 370, 5980, 3786, 345, 12, 3277, 14, 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, 5980, 3786, 345, 12, 3277, 14, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 6904, 63, 1246, 14, 14461, 14, 1313, 492, 627, 199, 199, 363, 21841, 363, 275, 298, 69, 647, 505, 2, 199, 199, 29019, 3973, 689, 3177, 63, 3243, 275, 3286, 28551, 15, 30424, 2, 199, 199, 318, 485, 362, 63, 9743, 63, 515, 8, 9743, 63, 354, 304, 523, 372, 577, 8100, 3973, 689, 3177, 63, 3243, 435, 298, 3149, 83, 2, 450, 334, 9743, 63, 354, 9, 199, 199, 318, 1218, 63, 30424, 8, 1927, 63, 1231, 12, 17216, 63, 513, 304, 523, 408, 523, 10560, 314, 769, 402, 11847, 19267, 14, 982, 1263, 402, 314, 11847, 19267, 2575, 2187, 523, 642, 8852, 1414, 911, 2449, 436, 949, 11847, 19267, 911, 506, 2737, 14, 523, 768, 8585, 26, 3261, 373, 22, 523, 768, 1107, 26, 710, 769, 402, 11847, 19267, 2737, 14, 523, 408, 523, 372, 1240, 8, 1927, 63, 1231, 14, 1932, 12, 577, 8100, 3973, 689, 3177, 63, 3243, 12, 13986, 30122, 12, 971, 489, 2203, 63, 374, 63, 513, 29, 549, 12, 666, 29, 9743, 63, 513, 9, 199, 199, 318, 664, 63, 30424, 8, 1927, 63, 1231, 304, 523, 408, 523, 1803, 314, 769, 402, 1006, 11847, 19267, 14, 523, 768, 8585, 26, 3261, 373, 22, 523, 768, 1107, 26, 437, 769, 402, 3261, 17216, 2251, 14, 523, 408, 523, 372, 1240, 8, 1927, 63, 1231, 14, 362, 12, 577, 8100, 3973, 689, 3177, 63, 3243, 12, 13986, 30122, 12, 971, 1362, 2203, 63, 374, 63, 513, 29, 549, 9, 199, 199, 318, 664, 63, 9743, 8, 1927, 63, 1231, 12, 17216, 63, 354, 304, 523, 408, 523, 1803, 282, 17216, 5492, 367, 314, 2013, 536, 14, 961, 17216, 523, 883, 506, 8439, 543, 314, 1218, 16659, 19267, 3261, 14, 523, 768, 8585, 26, 3261, 373, 22, 523, 768, 1107, 26, 1626, 3261, 366, 305, 26397, 3576, 909, 14, 523, 408, 523, 372, 1240, 8, 1927, 63, 1231, 14, 362, 12, 485, 362, 63, 9743, 63, 515, 8, 9743, 63, 354, 395, 971, 489, 13986, 30122, 9, 199, 199, 318, 3145, 63, 9743, 8, 1927, 63, 1231, 12, 17216, 63, 354, 304, 523, 408, 523, 28382, 282, 17216, 14, 523, 768, 8585, 26, 3261, 373, 22, 523, 768, 1107, 26, 710, 5463, 17216, 14, 523, 408, 523, 372, 1240, 8, 1927, 63, 1231, 14, 1807, 12, 485, 362, 63, 9743, 63, 515, 8, 9743, 63, 354, 395, 971, 489, 13986, 30122, 9, 199, 199, 533, 13986, 30122, 8, 1563, 7394, 4031, 304, 523, 485, 18166, 275, 469, 272, 283, 354, 7, 221, 520, 488, 12, 272, 283, 1001, 7, 221, 520, 488, 523, 789, 819, 347, 636, 826, 721, 277, 12, 2073, 63, 1231, 12, 536, 29, 403, 12, 2022, 29, 403, 304, 272, 3523, 7394, 1692, 14, 826, 8, 277, 12, 2073, 63, 1231, 12, 9480, 1012, 819, 347, 636, 495, 721, 277, 304, 272, 372, 3886, 7394, 30122, 20020, 450, 83, 2, 450, 334, 277, 14, 354, 9, 819, 347, 485, 515, 8, 277, 304, 272, 372, 485, 362, 63, 9743, 63, 515, 8, 277, 14, 354, 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 ]
[ 3909, 370, 5980, 3786, 345, 12, 3277, 14, 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, 5980, 3786, 345, 12, 3277, 14, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 6904, 63, 1246, 14, 14461, 14, 1313, 492, 627, 199, 199, 363, 21841, 363, 275, 298, 69, 647, 505, 2, 199, 199, 29019, 3973, 689, 3177, 63, 3243, 275, 3286, 28551, 15, 30424, 2, 199, 199, 318, 485, 362, 63, 9743, 63, 515, 8, 9743, 63, 354, 304, 523, 372, 577, 8100, 3973, 689, 3177, 63, 3243, 435, 298, 3149, 83, 2, 450, 334, 9743, 63, 354, 9, 199, 199, 318, 1218, 63, 30424, 8, 1927, 63, 1231, 12, 17216, 63, 513, 304, 523, 408, 523, 10560, 314, 769, 402, 11847, 19267, 14, 982, 1263, 402, 314, 11847, 19267, 2575, 2187, 523, 642, 8852, 1414, 911, 2449, 436, 949, 11847, 19267, 911, 506, 2737, 14, 523, 768, 8585, 26, 3261, 373, 22, 523, 768, 1107, 26, 710, 769, 402, 11847, 19267, 2737, 14, 523, 408, 523, 372, 1240, 8, 1927, 63, 1231, 14, 1932, 12, 577, 8100, 3973, 689, 3177, 63, 3243, 12, 13986, 30122, 12, 971, 489, 2203, 63, 374, 63, 513, 29, 549, 12, 666, 29, 9743, 63, 513, 9, 199, 199, 318, 664, 63, 30424, 8, 1927, 63, 1231, 304, 523, 408, 523, 1803, 314, 769, 402, 1006, 11847, 19267, 14, 523, 768, 8585, 26, 3261, 373, 22, 523, 768, 1107, 26, 437, 769, 402, 3261, 17216, 2251, 14, 523, 408, 523, 372, 1240, 8, 1927, 63, 1231, 14, 362, 12, 577, 8100, 3973, 689, 3177, 63, 3243, 12, 13986, 30122, 12, 971, 1362, 2203, 63, 374, 63, 513, 29, 549, 9, 199, 199, 318, 664, 63, 9743, 8, 1927, 63, 1231, 12, 17216, 63, 354, 304, 523, 408, 523, 1803, 282, 17216, 5492, 367, 314, 2013, 536, 14, 961, 17216, 523, 883, 506, 8439, 543, 314, 1218, 16659, 19267, 3261, 14, 523, 768, 8585, 26, 3261, 373, 22, 523, 768, 1107, 26, 1626, 3261, 366, 305, 26397, 3576, 909, 14, 523, 408, 523, 372, 1240, 8, 1927, 63, 1231, 14, 362, 12, 485, 362, 63, 9743, 63, 515, 8, 9743, 63, 354, 395, 971, 489, 13986, 30122, 9, 199, 199, 318, 3145, 63, 9743, 8, 1927, 63, 1231, 12, 17216, 63, 354, 304, 523, 408, 523, 28382, 282, 17216, 14, 523, 768, 8585, 26, 3261, 373, 22, 523, 768, 1107, 26, 710, 5463, 17216, 14, 523, 408, 523, 372, 1240, 8, 1927, 63, 1231, 14, 1807, 12, 485, 362, 63, 9743, 63, 515, 8, 9743, 63, 354, 395, 971, 489, 13986, 30122, 9, 199, 199, 533, 13986, 30122, 8, 1563, 7394, 4031, 304, 523, 485, 18166, 275, 469, 272, 283, 354, 7, 221, 520, 488, 12, 272, 283, 1001, 7, 221, 520, 488, 523, 789, 819, 347, 636, 826, 721, 277, 12, 2073, 63, 1231, 12, 536, 29, 403, 12, 2022, 29, 403, 304, 272, 3523, 7394, 1692, 14, 826, 8, 277, 12, 2073, 63, 1231, 12, 9480, 1012, 819, 347, 636, 495, 721, 277, 304, 272, 372, 3886, 7394, 30122, 20020, 450, 83, 2, 450, 334, 277, 14, 354, 9, 819, 347, 485, 515, 8, 277, 304, 272, 372, 485, 362, 63, 9743, 63, 515, 8, 277, 14, 354, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
synconics/odoo
addons/website/tests/test_views.py
144
9831
# -*- coding: utf-8 -*- import itertools import unittest2 from lxml import etree as ET, html from lxml.html import builder as h from openerp.tests import common def attrs(**kwargs): return dict(('data-oe-%s' % key, str(value)) for key, value in kwargs.iteritems()) class TestViewSaving(common.TransactionCase): def eq(self, a, b): self.assertEqual(a.tag, b.tag) self.assertEqual(a.attrib, b.attrib) self.assertEqual((a.text or '').strip(), (b.text or '').strip()) self.assertEqual((a.tail or '').strip(), (b.tail or '').strip()) for ca, cb in itertools.izip_longest(a, b): self.eq(ca, cb) def setUp(self): super(TestViewSaving, self).setUp() self.arch = h.DIV( h.DIV( h.H3("Column 1"), h.UL( h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL( h.LI("Item 1"), h.LI(h.SPAN("My Company", attrs(model='res.company', id=1, field='name', type='char'))), h.LI(h.SPAN("+00 00 000 00 0 000", attrs(model='res.company', id=1, field='phone', type='char'))) )) ) self.view_id = self.registry('ir.ui.view').create(self.cr, self.uid, { 'name': "Test View", 'type': 'qweb', 'arch': ET.tostring(self.arch, encoding='utf-8').decode('utf-8') }) def test_embedded_extraction(self): fields = self.registry('ir.ui.view').extract_embedded_fields( self.cr, self.uid, self.arch, context=None) expect = [ h.SPAN("My Company", attrs(model='res.company', id=1, field='name', type='char')), h.SPAN("+00 00 000 00 0 000", attrs(model='res.company', id=1, field='phone', type='char')), ] for actual, expected in itertools.izip_longest(fields, expect): self.eq(actual, expected) def test_embedded_save(self): embedded = h.SPAN("+00 00 000 00 0 000", attrs( model='res.company', id=1, field='phone', type='char')) self.registry('ir.ui.view').save_embedded_field(self.cr, self.uid, embedded) company = self.registry('res.company').browse(self.cr, self.uid, 1) self.assertEqual(company.phone, "+00 00 000 00 0 000") @unittest2.skip("save conflict for embedded (saved by third party or previous version in page) not implemented") def test_embedded_conflict(self): e1 = h.SPAN("My Company", attrs(model='res.company', id=1, field='name')) e2 = h.SPAN("Leeroy Jenkins", attrs(model='res.company', id=1, field='name')) View = self.registry('ir.ui.view') View.save_embedded_field(self.cr, self.uid, e1) # FIXME: more precise exception with self.assertRaises(Exception): View.save_embedded_field(self.cr, self.uid, e2) def test_embedded_to_field_ref(self): View = self.registry('ir.ui.view') embedded = h.SPAN("My Company", attrs(expression="bob")) self.eq( View.to_field_ref(self.cr, self.uid, embedded, context=None), h.SPAN({'t-field': 'bob'}) ) def test_to_field_ref_keep_attributes(self): View = self.registry('ir.ui.view') att = attrs(expression="bob", model="res.company", id=1, field="name") att['id'] = "whop" att['class'] = "foo bar" embedded = h.SPAN("My Company", att) self.eq(View.to_field_ref(self.cr, self.uid, embedded, context=None), h.SPAN({'t-field': 'bob', 'class': 'foo bar', 'id': 'whop'})) def test_replace_arch(self): replacement = h.P("Wheee") result = self.registry('ir.ui.view').replace_arch_section( self.cr, self.uid, self.view_id, None, replacement) self.eq(result, h.DIV("Wheee")) def test_replace_arch_2(self): replacement = h.DIV(h.P("Wheee")) result = self.registry('ir.ui.view').replace_arch_section( self.cr, self.uid, self.view_id, None, replacement) self.eq(result, replacement) def test_fixup_arch(self): replacement = h.H1("I am the greatest title alive!") result = self.registry('ir.ui.view').replace_arch_section( self.cr, self.uid, self.view_id, '/div/div[1]/h3', replacement) self.eq(result, h.DIV( h.DIV( h.H3("I am the greatest title alive!"), h.UL( h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL( h.LI("Item 1"), h.LI(h.SPAN("My Company", attrs(model='res.company', id=1, field='name', type='char'))), h.LI(h.SPAN("+00 00 000 00 0 000", attrs(model='res.company', id=1, field='phone', type='char'))) )) )) def test_multiple_xpath_matches(self): with self.assertRaises(ValueError): self.registry('ir.ui.view').replace_arch_section( self.cr, self.uid, self.view_id, '/div/div/h3', h.H6("Lol nope")) def test_save(self): Company = self.registry('res.company') View = self.registry('ir.ui.view') replacement = ET.tostring(h.DIV( h.H3("Column 2"), h.UL( h.LI("wob wob wob"), h.LI(h.SPAN("Acme Corporation", attrs(model='res.company', id=1, field='name', expression="bob", type='char'))), h.LI(h.SPAN("+12 3456789", attrs(model='res.company', id=1, field='phone', expression="edmund", type='char'))), ) ), encoding='utf-8') View.save(self.cr, self.uid, res_id=self.view_id, value=replacement, xpath='/div/div[2]') company = Company.browse(self.cr, self.uid, 1) self.assertEqual(company.name, "Acme Corporation") self.assertEqual(company.phone, "+12 3456789") self.eq( ET.fromstring(View.browse(self.cr, self.uid, self.view_id).arch.encode('utf-8')), h.DIV( h.DIV( h.H3("Column 1"), h.UL( h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL( h.LI("wob wob wob"), h.LI(h.SPAN({'t-field': "bob"})), h.LI(h.SPAN({'t-field': "edmund"})) )) ) ) def test_save_escaped_text(self): """ Test saving html special chars in text nodes """ view_id = self.registry('ir.ui.view').create(self.cr, self.uid, { 'arch':'<t><p><h1>hello world</h1></p></t>', 'type':'qweb' }) view = self.registry('ir.ui.view').browse(self.cr, self.uid, view_id) # script and style text nodes should not escaped client side replacement = '<script>1 && "hello & world"</script>' view.save(replacement, xpath='/t/p/h1') self.assertIn( replacement.replace('&', '&amp;'), view.arch, 'inline script should be escaped server side' ) self.assertIn( replacement, view.render(), 'inline script should not be escaped when rendering' ) # common text nodes should be be escaped client side replacement = 'world &amp;amp; &amp;lt;b&amp;gt;cie' view.save(replacement, xpath='/t/p') self.assertIn(replacement, view.arch, 'common text node should not be escaped server side') self.assertIn( replacement, view.render().replace('&', '&amp;'), 'text node characters wrongly unescaped when rendering' ) def test_save_only_embedded(self): Company = self.registry('res.company') company_id = 1 Company.write(self.cr, self.uid, company_id, {'name': "Foo Corporation"}) node = html.tostring(h.SPAN( "Acme Corporation", attrs(model='res.company', id=company_id, field="name", expression='bob', type='char'))) self.registry('ir.ui.view').save(self.cr, self.uid, res_id=company_id,value=node) company = Company.browse(self.cr, self.uid, company_id) self.assertEqual(company.name, "Acme Corporation") def test_field_tail(self): View = self.registry('ir.ui.view') replacement = ET.tostring( h.LI(h.SPAN("+12 3456789", attrs( model='res.company', id=1, type='char', field='phone', expression="edmund")), "whop whop" ), encoding="utf-8") View.save(self.cr, self.uid, res_id = self.view_id, value=replacement, xpath='/div/div[2]/ul/li[3]') self.eq( ET.fromstring(View.browse(self.cr, self.uid, self.view_id).arch.encode('utf-8')), h.DIV( h.DIV( h.H3("Column 1"), h.UL( h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL( h.LI("Item 1"), h.LI(h.SPAN("My Company", attrs(model='res.company', id=1, field='name', type='char'))), h.LI(h.SPAN({'t-field': "edmund"}), "whop whop"), )) ) )
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 7975, 199, 199, 646, 2882, 18, 199, 504, 14490, 492, 7559, 465, 12265, 12, 3517, 199, 504, 14490, 14, 1360, 492, 6545, 465, 394, 199, 199, 504, 5166, 14, 2219, 492, 2863, 199, 199, 318, 3290, 3682, 958, 304, 272, 372, 1211, 4725, 576, 13, 13361, 3295, 83, 7, 450, 790, 12, 620, 8, 585, 430, 367, 790, 12, 574, 315, 2074, 14, 4611, 1012, 199, 533, 1379, 2768, 30125, 8, 2330, 14, 10161, 1538, 304, 272, 347, 3850, 8, 277, 12, 282, 12, 330, 304, 267, 291, 14, 629, 8, 65, 14, 1450, 12, 330, 14, 1450, 9, 267, 291, 14, 629, 8, 65, 14, 6640, 12, 330, 14, 6640, 9, 267, 291, 14, 629, 1332, 65, 14, 505, 503, 12548, 1913, 1062, 334, 66, 14, 505, 503, 12548, 1913, 1012, 267, 291, 14, 629, 1332, 65, 14, 1521, 503, 12548, 1913, 1062, 334, 66, 14, 1521, 503, 12548, 1913, 1012, 267, 367, 1704, 12, 7434, 315, 7975, 14, 565, 711, 63, 20820, 8, 65, 12, 330, 304, 288, 291, 14, 4077, 8, 696, 12, 7434, 9, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 2768, 30125, 12, 291, 680, 5996, 342, 267, 291, 14, 1047, 275, 394, 14, 27051, 8, 288, 394, 14, 27051, 8, 355, 394, 14, 40, 19, 480, 4547, 413, 1288, 355, 394, 14, 1293, 8, 490, 394, 14, 2673, 480, 2081, 413, 1288, 490, 394, 14, 2673, 480, 2081, 499, 1288, 490, 394, 14, 2673, 480, 2081, 650, 2237, 395, 288, 394, 14, 27051, 8, 355, 394, 14, 40, 19, 480, 4547, 499, 1288, 355, 394, 14, 1293, 8, 490, 394, 14, 2673, 480, 2081, 413, 1288, 490, 394, 14, 2673, 8, 72, 14, 5763, 879, 480, 5713, 15878, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 354, 297, 730, 534, 1560, 22645, 490, 394, 14, 2673, 8, 72, 14, 5763, 879, 28819, 383, 8733, 21551, 8733, 378, 21551, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 9339, 297, 730, 534, 1560, 7058, 355, 5082, 267, 776, 267, 291, 14, 1345, 63, 344, 275, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 1959, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 469, 288, 283, 354, 356, 298, 774, 10935, 401, 288, 283, 466, 356, 283, 22600, 297, 288, 283, 1047, 356, 12265, 14, 14028, 8, 277, 14, 1047, 12, 2644, 534, 1624, 13, 24, 1959, 2708, 360, 1624, 13, 24, 358, 267, 3828, 339, 347, 511, 63, 18757, 63, 24020, 8, 277, 304, 267, 1504, 275, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 1959, 5005, 63, 18757, 63, 955, 8, 288, 291, 14, 1556, 12, 291, 14, 1535, 12, 291, 14, 1047, 12, 1067, 29, 403, 9, 398, 4282, 275, 359, 288, 394, 14, 5763, 879, 480, 5713, 15878, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 354, 297, 730, 534, 1560, 3855, 288, 394, 14, 5763, 879, 28819, 383, 8733, 21551, 8733, 378, 21551, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 9339, 297, 730, 534, 1560, 3855, 267, 1622, 267, 367, 3503, 12, 1420, 315, 7975, 14, 565, 711, 63, 20820, 8, 955, 12, 4282, 304, 288, 291, 14, 4077, 8, 6514, 12, 1420, 9, 339, 347, 511, 63, 18757, 63, 2117, 8, 277, 304, 267, 12169, 275, 394, 14, 5763, 879, 28819, 383, 8733, 21551, 8733, 378, 21551, 401, 3290, 8, 288, 1402, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 9339, 297, 730, 534, 1560, 1333, 398, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 1959, 2117, 63, 18757, 63, 698, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 12169, 9, 398, 7233, 275, 291, 14, 5189, 360, 470, 14, 4627, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 413, 9, 267, 291, 14, 629, 8, 4627, 14, 9339, 12, 7210, 383, 8733, 21551, 8733, 378, 21551, 531, 339, 768, 2796, 18, 14, 2759, 480, 2117, 12395, 367, 12169, 334, 8420, 701, 10919, 17135, 503, 4136, 1015, 315, 2034, 9, 440, 6366, 531, 272, 347, 511, 63, 18757, 63, 15207, 8, 277, 304, 267, 325, 17, 275, 394, 14, 5763, 879, 480, 5713, 15878, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 354, 1333, 267, 325, 18, 275, 394, 14, 5763, 879, 480, 2553, 3478, 89, 32516, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 354, 1333, 398, 10935, 275, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 358, 398, 10935, 14, 2117, 63, 18757, 63, 698, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 325, 17, 9, 267, 327, 7600, 26, 1655, 28334, 1919, 267, 543, 291, 14, 1855, 8, 1726, 304, 288, 10935, 14, 2117, 63, 18757, 63, 698, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 325, 18, 9, 339, 347, 511, 63, 18757, 63, 475, 63, 698, 63, 1121, 8, 277, 304, 267, 10935, 275, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 358, 267, 12169, 275, 394, 14, 5763, 879, 480, 5713, 15878, 401, 3290, 8, 5599, 628, 7913, 2237, 267, 291, 14, 4077, 8, 288, 10935, 14, 475, 63, 698, 63, 1121, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 12169, 12, 1067, 29, 403, 395, 288, 394, 14, 5763, 879, 3252, 84, 13, 698, 356, 283, 7913, 3071, 267, 776, 339, 347, 511, 63, 475, 63, 698, 63, 1121, 63, 3250, 63, 2987, 8, 277, 304, 267, 10935, 275, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 358, 398, 15115, 275, 3290, 8, 5599, 628, 7913, 401, 1402, 628, 470, 14, 4627, 401, 1305, 29, 17, 12, 901, 628, 354, 531, 267, 15115, 459, 344, 418, 275, 298, 2191, 411, 2, 267, 15115, 459, 533, 418, 275, 298, 1421, 4681, 2, 267, 12169, 275, 394, 14, 5763, 879, 480, 5713, 15878, 401, 15115, 9, 398, 291, 14, 4077, 8, 2768, 14, 475, 63, 698 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 7975, 199, 199, 646, 2882, 18, 199, 504, 14490, 492, 7559, 465, 12265, 12, 3517, 199, 504, 14490, 14, 1360, 492, 6545, 465, 394, 199, 199, 504, 5166, 14, 2219, 492, 2863, 199, 199, 318, 3290, 3682, 958, 304, 272, 372, 1211, 4725, 576, 13, 13361, 3295, 83, 7, 450, 790, 12, 620, 8, 585, 430, 367, 790, 12, 574, 315, 2074, 14, 4611, 1012, 199, 533, 1379, 2768, 30125, 8, 2330, 14, 10161, 1538, 304, 272, 347, 3850, 8, 277, 12, 282, 12, 330, 304, 267, 291, 14, 629, 8, 65, 14, 1450, 12, 330, 14, 1450, 9, 267, 291, 14, 629, 8, 65, 14, 6640, 12, 330, 14, 6640, 9, 267, 291, 14, 629, 1332, 65, 14, 505, 503, 12548, 1913, 1062, 334, 66, 14, 505, 503, 12548, 1913, 1012, 267, 291, 14, 629, 1332, 65, 14, 1521, 503, 12548, 1913, 1062, 334, 66, 14, 1521, 503, 12548, 1913, 1012, 267, 367, 1704, 12, 7434, 315, 7975, 14, 565, 711, 63, 20820, 8, 65, 12, 330, 304, 288, 291, 14, 4077, 8, 696, 12, 7434, 9, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 2768, 30125, 12, 291, 680, 5996, 342, 267, 291, 14, 1047, 275, 394, 14, 27051, 8, 288, 394, 14, 27051, 8, 355, 394, 14, 40, 19, 480, 4547, 413, 1288, 355, 394, 14, 1293, 8, 490, 394, 14, 2673, 480, 2081, 413, 1288, 490, 394, 14, 2673, 480, 2081, 499, 1288, 490, 394, 14, 2673, 480, 2081, 650, 2237, 395, 288, 394, 14, 27051, 8, 355, 394, 14, 40, 19, 480, 4547, 499, 1288, 355, 394, 14, 1293, 8, 490, 394, 14, 2673, 480, 2081, 413, 1288, 490, 394, 14, 2673, 8, 72, 14, 5763, 879, 480, 5713, 15878, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 354, 297, 730, 534, 1560, 22645, 490, 394, 14, 2673, 8, 72, 14, 5763, 879, 28819, 383, 8733, 21551, 8733, 378, 21551, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 9339, 297, 730, 534, 1560, 7058, 355, 5082, 267, 776, 267, 291, 14, 1345, 63, 344, 275, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 1959, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 469, 288, 283, 354, 356, 298, 774, 10935, 401, 288, 283, 466, 356, 283, 22600, 297, 288, 283, 1047, 356, 12265, 14, 14028, 8, 277, 14, 1047, 12, 2644, 534, 1624, 13, 24, 1959, 2708, 360, 1624, 13, 24, 358, 267, 3828, 339, 347, 511, 63, 18757, 63, 24020, 8, 277, 304, 267, 1504, 275, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 1959, 5005, 63, 18757, 63, 955, 8, 288, 291, 14, 1556, 12, 291, 14, 1535, 12, 291, 14, 1047, 12, 1067, 29, 403, 9, 398, 4282, 275, 359, 288, 394, 14, 5763, 879, 480, 5713, 15878, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 354, 297, 730, 534, 1560, 3855, 288, 394, 14, 5763, 879, 28819, 383, 8733, 21551, 8733, 378, 21551, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 9339, 297, 730, 534, 1560, 3855, 267, 1622, 267, 367, 3503, 12, 1420, 315, 7975, 14, 565, 711, 63, 20820, 8, 955, 12, 4282, 304, 288, 291, 14, 4077, 8, 6514, 12, 1420, 9, 339, 347, 511, 63, 18757, 63, 2117, 8, 277, 304, 267, 12169, 275, 394, 14, 5763, 879, 28819, 383, 8733, 21551, 8733, 378, 21551, 401, 3290, 8, 288, 1402, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 9339, 297, 730, 534, 1560, 1333, 398, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 1959, 2117, 63, 18757, 63, 698, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 12169, 9, 398, 7233, 275, 291, 14, 5189, 360, 470, 14, 4627, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 413, 9, 267, 291, 14, 629, 8, 4627, 14, 9339, 12, 7210, 383, 8733, 21551, 8733, 378, 21551, 531, 339, 768, 2796, 18, 14, 2759, 480, 2117, 12395, 367, 12169, 334, 8420, 701, 10919, 17135, 503, 4136, 1015, 315, 2034, 9, 440, 6366, 531, 272, 347, 511, 63, 18757, 63, 15207, 8, 277, 304, 267, 325, 17, 275, 394, 14, 5763, 879, 480, 5713, 15878, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 354, 1333, 267, 325, 18, 275, 394, 14, 5763, 879, 480, 2553, 3478, 89, 32516, 401, 3290, 8, 1238, 534, 470, 14, 4627, 297, 1305, 29, 17, 12, 901, 534, 354, 1333, 398, 10935, 275, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 358, 398, 10935, 14, 2117, 63, 18757, 63, 698, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 325, 17, 9, 267, 327, 7600, 26, 1655, 28334, 1919, 267, 543, 291, 14, 1855, 8, 1726, 304, 288, 10935, 14, 2117, 63, 18757, 63, 698, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 325, 18, 9, 339, 347, 511, 63, 18757, 63, 475, 63, 698, 63, 1121, 8, 277, 304, 267, 10935, 275, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 358, 267, 12169, 275, 394, 14, 5763, 879, 480, 5713, 15878, 401, 3290, 8, 5599, 628, 7913, 2237, 267, 291, 14, 4077, 8, 288, 10935, 14, 475, 63, 698, 63, 1121, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 12169, 12, 1067, 29, 403, 395, 288, 394, 14, 5763, 879, 3252, 84, 13, 698, 356, 283, 7913, 3071, 267, 776, 339, 347, 511, 63, 475, 63, 698, 63, 1121, 63, 3250, 63, 2987, 8, 277, 304, 267, 10935, 275, 291, 14, 5189, 360, 723, 14, 1907, 14, 1345, 358, 398, 15115, 275, 3290, 8, 5599, 628, 7913, 401, 1402, 628, 470, 14, 4627, 401, 1305, 29, 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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 ]
double12gzh/nova
nova/api/metadata/base.py
14
19291
# Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # 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. """Instance Metadata information.""" import base64 import os import posixpath from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils from oslo_utils import importutils from oslo_utils import timeutils import six from nova.api.ec2 import ec2utils from nova.api.metadata import password from nova import availability_zones as az from nova import block_device from nova import context from nova import network from nova import objects from nova.objects import keypair as keypair_obj from nova import utils from nova.virt import netutils metadata_opts = [ cfg.StrOpt('config_drive_skip_versions', default=('1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 ' '2007-12-15 2008-02-01 2008-09-01'), help='List of metadata versions to skip placing into the ' 'config drive'), cfg.StrOpt('vendordata_driver', default='nova.api.metadata.vendordata_json.JsonFileVendorData', help='Driver to use for vendor data'), ] CONF = cfg.CONF CONF.register_opts(metadata_opts) CONF.import_opt('dhcp_domain', 'nova.network.manager') VERSIONS = [ '1.0', '2007-01-19', '2007-03-01', '2007-08-29', '2007-10-10', '2007-12-15', '2008-02-01', '2008-09-01', '2009-04-04', ] FOLSOM = '2012-08-10' GRIZZLY = '2013-04-04' HAVANA = '2013-10-17' OPENSTACK_VERSIONS = [ FOLSOM, GRIZZLY, HAVANA, ] VERSION = "version" CONTENT = "content" CONTENT_DIR = "content" MD_JSON_NAME = "meta_data.json" VD_JSON_NAME = "vendor_data.json" UD_NAME = "user_data" PASS_NAME = "password" MIME_TYPE_TEXT_PLAIN = "text/plain" MIME_TYPE_APPLICATION_JSON = "application/json" LOG = logging.getLogger(__name__) class InvalidMetadataVersion(Exception): pass class InvalidMetadataPath(Exception): pass class InstanceMetadata(object): """Instance metadata.""" def __init__(self, instance, address=None, content=None, extra_md=None, network_info=None, vd_driver=None): """Creation of this object should basically cover all time consuming collection. Methods after that should not cause time delays due to network operations or lengthy cpu operations. The user should then get a single instance and make multiple method calls on it. """ if not content: content = [] ctxt = context.get_admin_context() # The default value of mimeType is set to MIME_TYPE_TEXT_PLAIN self.set_mimetype(MIME_TYPE_TEXT_PLAIN) self.instance = instance self.extra_md = extra_md self.availability_zone = az.get_instance_availability_zone(ctxt, instance) self.security_groups = objects.SecurityGroupList.get_by_instance( ctxt, instance) self.mappings = _format_instance_mapping(ctxt, instance) if instance.user_data is not None: self.userdata_raw = base64.b64decode(instance.user_data) else: self.userdata_raw = None self.address = address # expose instance metadata. self.launch_metadata = utils.instance_meta(instance) self.password = password.extract_password(instance) self.uuid = instance.uuid self.content = {} self.files = [] # get network info, and the rendered network template if network_info is None: network_info = instance.info_cache.network_info self.ip_info = \ ec2utils.get_ip_info_for_instance_from_nw_info(network_info) self.network_config = None cfg = netutils.get_injected_network_template(network_info) if cfg: key = "%04i" % len(self.content) self.content[key] = cfg self.network_config = {"name": "network_config", 'content_path': "/%s/%s" % (CONTENT_DIR, key)} # 'content' is passed in from the configdrive code in # nova/virt/libvirt/driver.py. That's how we get the injected files # (personalities) in. AFAIK they're not stored in the db at all, # so are not available later (web service metadata time). for (path, contents) in content: key = "%04i" % len(self.content) self.files.append({'path': path, 'content_path': "/%s/%s" % (CONTENT_DIR, key)}) self.content[key] = contents if vd_driver is None: vdclass = importutils.import_class(CONF.vendordata_driver) else: vdclass = vd_driver self.vddriver = vdclass(instance=instance, address=address, extra_md=extra_md, network_info=network_info) self.route_configuration = None def _route_configuration(self): if self.route_configuration: return self.route_configuration path_handlers = {UD_NAME: self._user_data, PASS_NAME: self._password, VD_JSON_NAME: self._vendor_data, MD_JSON_NAME: self._metadata_as_json, VERSION: self._handle_version, CONTENT: self._handle_content} self.route_configuration = RouteConfiguration(path_handlers) return self.route_configuration def set_mimetype(self, mime_type): self.md_mimetype = mime_type def get_mimetype(self): return self.md_mimetype def get_ec2_metadata(self, version): if version == "latest": version = VERSIONS[-1] if version not in VERSIONS: raise InvalidMetadataVersion(version) hostname = self._get_hostname() floating_ips = self.ip_info['floating_ips'] floating_ip = floating_ips and floating_ips[0] or '' fixed_ips = self.ip_info['fixed_ips'] fixed_ip = fixed_ips and fixed_ips[0] or '' fmt_sgroups = [x['name'] for x in self.security_groups] meta_data = { 'ami-id': self.instance.ec2_ids.ami_id, 'ami-launch-index': self.instance.launch_index, 'ami-manifest-path': 'FIXME', 'instance-id': self.instance.ec2_ids.instance_id, 'hostname': hostname, 'local-ipv4': fixed_ip or self.address, 'reservation-id': self.instance.reservation_id, 'security-groups': fmt_sgroups} # public keys are strangely rendered in ec2 metadata service # meta-data/public-keys/ returns '0=keyname' (with no trailing /) # and only if there is a public key given. # '0=keyname' means there is a normally rendered dict at # meta-data/public-keys/0 # # meta-data/public-keys/ : '0=%s' % keyname # meta-data/public-keys/0/ : 'openssh-key' # meta-data/public-keys/0/openssh-key : '%s' % publickey if self.instance.key_name: meta_data['public-keys'] = { '0': {'_name': "0=" + self.instance.key_name, 'openssh-key': self.instance.key_data}} if self._check_version('2007-01-19', version): meta_data['local-hostname'] = hostname meta_data['public-hostname'] = hostname meta_data['public-ipv4'] = floating_ip if False and self._check_version('2007-03-01', version): # TODO(vish): store product codes meta_data['product-codes'] = [] if self._check_version('2007-08-29', version): instance_type = self.instance.get_flavor() meta_data['instance-type'] = instance_type['name'] if False and self._check_version('2007-10-10', version): # TODO(vish): store ancestor ids meta_data['ancestor-ami-ids'] = [] if self._check_version('2007-12-15', version): meta_data['block-device-mapping'] = self.mappings if self.instance.ec2_ids.kernel_id: meta_data['kernel-id'] = self.instance.ec2_ids.kernel_id if self.instance.ec2_ids.ramdisk_id: meta_data['ramdisk-id'] = self.instance.ec2_ids.ramdisk_id if self._check_version('2008-02-01', version): meta_data['placement'] = {'availability-zone': self.availability_zone} if self._check_version('2008-09-01', version): meta_data['instance-action'] = 'none' data = {'meta-data': meta_data} if self.userdata_raw is not None: data['user-data'] = self.userdata_raw return data def get_ec2_item(self, path_tokens): # get_ec2_metadata returns dict without top level version data = self.get_ec2_metadata(path_tokens[0]) return find_path_in_tree(data, path_tokens[1:]) def get_openstack_item(self, path_tokens): if path_tokens[0] == CONTENT_DIR: return self._handle_content(path_tokens) return self._route_configuration().handle_path(path_tokens) def _metadata_as_json(self, version, path): metadata = {'uuid': self.uuid} if self.launch_metadata: metadata['meta'] = self.launch_metadata if self.files: metadata['files'] = self.files if self.extra_md: metadata.update(self.extra_md) if self.network_config: metadata['network_config'] = self.network_config if self.instance.key_name: metadata['public_keys'] = { self.instance.key_name: self.instance.key_data } keypair = keypair_obj.KeyPair.get_by_name( context.get_admin_context(), self.instance.user_id, self.instance.key_name) metadata['keys'] = [ {'name': keypair.name, 'type': keypair.type, 'data': keypair.public_key} ] metadata['hostname'] = self._get_hostname() metadata['name'] = self.instance.display_name metadata['launch_index'] = self.instance.launch_index metadata['availability_zone'] = self.availability_zone if self._check_os_version(GRIZZLY, version): metadata['random_seed'] = base64.b64encode(os.urandom(512)) self.set_mimetype(MIME_TYPE_APPLICATION_JSON) return jsonutils.dumps(metadata) def _handle_content(self, path_tokens): if len(path_tokens) == 1: raise KeyError("no listing for %s" % "/".join(path_tokens)) if len(path_tokens) != 2: raise KeyError("Too many tokens for /%s" % CONTENT_DIR) return self.content[path_tokens[1]] def _handle_version(self, version, path): # request for /version, give a list of what is available ret = [MD_JSON_NAME] if self.userdata_raw is not None: ret.append(UD_NAME) if self._check_os_version(GRIZZLY, version): ret.append(PASS_NAME) if self._check_os_version(HAVANA, version): ret.append(VD_JSON_NAME) return ret def _user_data(self, version, path): if self.userdata_raw is None: raise KeyError(path) return self.userdata_raw def _password(self, version, path): if self._check_os_version(GRIZZLY, version): return password.handle_password raise KeyError(path) def _vendor_data(self, version, path): if self._check_os_version(HAVANA, version): self.set_mimetype(MIME_TYPE_APPLICATION_JSON) return jsonutils.dumps(self.vddriver.get()) raise KeyError(path) def _check_version(self, required, requested, versions=VERSIONS): return versions.index(requested) >= versions.index(required) def _check_os_version(self, required, requested): return self._check_version(required, requested, OPENSTACK_VERSIONS) def _get_hostname(self): return "%s%s%s" % (self.instance.hostname, '.' if CONF.dhcp_domain else '', CONF.dhcp_domain) def lookup(self, path): if path == "" or path[0] != "/": path = posixpath.normpath("/" + path) else: path = posixpath.normpath(path) # Set default mimeType. It will be modified only if there is a change self.set_mimetype(MIME_TYPE_TEXT_PLAIN) # fix up requests, prepending /ec2 to anything that does not match path_tokens = path.split('/')[1:] if path_tokens[0] not in ("ec2", "openstack"): if path_tokens[0] == "": # request for / path_tokens = ["ec2"] else: path_tokens = ["ec2"] + path_tokens path = "/" + "/".join(path_tokens) # all values of 'path' input starts with '/' and have no trailing / # specifically handle the top level request if len(path_tokens) == 1: if path_tokens[0] == "openstack": # NOTE(vish): don't show versions that are in the future today = timeutils.utcnow().strftime("%Y-%m-%d") versions = [v for v in OPENSTACK_VERSIONS if v <= today] if OPENSTACK_VERSIONS != versions: LOG.debug("future versions %s hidden in version list", [v for v in OPENSTACK_VERSIONS if v not in versions]) versions += ["latest"] else: versions = VERSIONS + ["latest"] return versions try: if path_tokens[0] == "openstack": data = self.get_openstack_item(path_tokens[1:]) else: data = self.get_ec2_item(path_tokens[1:]) except (InvalidMetadataVersion, KeyError): raise InvalidMetadataPath(path) return data def metadata_for_config_drive(self): """Yields (path, value) tuples for metadata elements.""" # EC2 style metadata for version in VERSIONS + ["latest"]: if version in CONF.config_drive_skip_versions.split(' '): continue data = self.get_ec2_metadata(version) if 'user-data' in data: filepath = os.path.join('ec2', version, 'user-data') yield (filepath, data['user-data']) del data['user-data'] try: del data['public-keys']['0']['_name'] except KeyError: pass filepath = os.path.join('ec2', version, 'meta-data.json') yield (filepath, jsonutils.dumps(data['meta-data'])) ALL_OPENSTACK_VERSIONS = OPENSTACK_VERSIONS + ["latest"] for version in ALL_OPENSTACK_VERSIONS: path = 'openstack/%s/%s' % (version, MD_JSON_NAME) yield (path, self.lookup(path)) path = 'openstack/%s/%s' % (version, UD_NAME) if self.userdata_raw is not None: yield (path, self.lookup(path)) if self._check_version(HAVANA, version, ALL_OPENSTACK_VERSIONS): path = 'openstack/%s/%s' % (version, VD_JSON_NAME) yield (path, self.lookup(path)) for (cid, content) in six.iteritems(self.content): yield ('%s/%s/%s' % ("openstack", CONTENT_DIR, cid), content) class RouteConfiguration(object): """Routes metadata paths to request handlers.""" def __init__(self, path_handler): self.path_handlers = path_handler def _version(self, version): if version == "latest": version = OPENSTACK_VERSIONS[-1] if version not in OPENSTACK_VERSIONS: raise InvalidMetadataVersion(version) return version def handle_path(self, path_tokens): version = self._version(path_tokens[0]) if len(path_tokens) == 1: path = VERSION else: path = '/'.join(path_tokens[1:]) path_handler = self.path_handlers[path] if path_handler is None: raise KeyError(path) return path_handler(version, path) class VendorDataDriver(object): """The base VendorData Drivers should inherit from.""" def __init__(self, *args, **kwargs): """Init method should do all expensive operations.""" self._data = {} def get(self): """Return a dictionary of primitives to be rendered in metadata :return: A dictionary or primitives. """ return self._data def get_metadata_by_address(address): ctxt = context.get_admin_context() fixed_ip = network.API().get_fixed_ip_by_address(ctxt, address) return get_metadata_by_instance_id(fixed_ip['instance_uuid'], address, ctxt) def get_metadata_by_instance_id(instance_id, address, ctxt=None): ctxt = ctxt or context.get_admin_context() instance = objects.Instance.get_by_uuid( ctxt, instance_id, expected_attrs=['ec2_ids', 'flavor', 'info_cache']) return InstanceMetadata(instance, address) def _format_instance_mapping(ctxt, instance): bdms = objects.BlockDeviceMappingList.get_by_instance_uuid( ctxt, instance.uuid) return block_device.instance_block_mapping(instance, bdms) def ec2_md_print(data): if isinstance(data, dict): output = '' for key in sorted(data.keys()): if key == '_name': continue if isinstance(data[key], dict): if '_name' in data[key]: output += str(data[key]['_name']) else: output += key + '/' else: output += key output += '\n' return output[:-1] elif isinstance(data, list): return '\n'.join(data) else: return str(data) def find_path_in_tree(data, path_tokens): # given a dict/list tree, and a path in that tree, return data found there. for i in range(0, len(path_tokens)): if isinstance(data, dict) or isinstance(data, list): if path_tokens[i] in data: data = data[path_tokens[i]] else: raise KeyError("/".join(path_tokens[0:i])) else: if i != len(path_tokens) - 1: raise KeyError("/".join(path_tokens[0:i])) data = data[path_tokens[i]] return data
apache-2.0
[ 3, 1898, 7129, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 3244, 16160, 2556, 1041, 199, 199, 646, 1300, 772, 199, 646, 747, 199, 646, 15454, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 12161, 492, 18705, 199, 504, 11258, 63, 1208, 492, 492, 1208, 199, 504, 11258, 63, 1208, 492, 23011, 199, 646, 3816, 199, 199, 504, 5913, 14, 1246, 14, 825, 18, 492, 7062, 18, 1208, 199, 504, 5913, 14, 1246, 14, 2343, 492, 2505, 199, 504, 5913, 492, 14962, 63, 13325, 465, 24978, 199, 504, 5913, 492, 1853, 63, 1782, 199, 504, 5913, 492, 1067, 199, 504, 5913, 492, 2784, 199, 504, 5913, 492, 2251, 199, 504, 5913, 14, 1462, 492, 23911, 465, 23911, 63, 1113, 199, 504, 5913, 492, 3778, 199, 504, 5913, 14, 4549, 492, 1851, 1208, 421, 199, 2343, 63, 3291, 275, 359, 272, 4810, 14, 19340, 360, 888, 63, 9541, 63, 2759, 63, 6234, 297, 2049, 849, 7782, 17, 14, 16, 10219, 13, 614, 13, 1167, 10219, 13, 1644, 13, 614, 10219, 13, 2036, 13, 1398, 10219, 13, 709, 13, 709, 283, 717, 283, 9488, 13, 713, 13, 1046, 9079, 13, 996, 13, 614, 9079, 13, 1643, 13, 614, 659, 2049, 1720, 534, 1296, 402, 3341, 5459, 370, 3372, 299, 13121, 1901, 314, 283, 490, 283, 888, 12912, 659, 272, 4810, 14, 19340, 360, 9884, 576, 63, 3090, 297, 2049, 849, 534, 6765, 14, 1246, 14, 2343, 14, 9884, 576, 63, 1001, 14, 9653, 1173, 27111, 1451, 297, 2049, 1720, 534, 6158, 370, 675, 367, 20868, 666, 659, 199, 61, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 3291, 8, 2343, 63, 3291, 9, 199, 3103, 14, 646, 63, 2992, 360, 10801, 63, 2261, 297, 283, 6765, 14, 1200, 14, 2609, 358, 199, 199, 26358, 275, 359, 272, 283, 17, 14, 16, 297, 272, 283, 9488, 13, 614, 13, 1167, 297, 272, 283, 9488, 13, 1644, 13, 614, 297, 272, 283, 9488, 13, 2036, 13, 1398, 297, 272, 283, 9488, 13, 709, 13, 709, 297, 272, 283, 9488, 13, 713, 13, 1046, 297, 272, 283, 9300, 13, 996, 13, 614, 297, 272, 283, 9300, 13, 1643, 13, 614, 297, 272, 283, 8664, 13, 966, 13, 966, 297, 199, 61, 199, 199, 38, 2228, 4118, 45, 275, 283, 7409, 13, 2036, 13, 709, 7, 199, 3975, 5357, 58, 6084, 275, 283, 6965, 13, 966, 13, 966, 7, 199, 40, 6087, 879, 33, 275, 283, 6965, 13, 709, 13, 1196, 7, 199, 9935, 17014, 63, 26358, 275, 359, 272, 481, 2228, 4118, 45, 12, 272, 21772, 5357, 58, 6084, 12, 272, 869, 6087, 879, 33, 12, 199, 61, 199, 199, 4612, 275, 298, 1023, 2, 199, 9663, 275, 298, 1317, 2, 199, 9663, 63, 3022, 275, 298, 1317, 2, 199, 5127, 63, 6243, 63, 2339, 275, 298, 2024, 63, 576, 14, 1001, 2, 199, 26197, 63, 6243, 63, 2339, 275, 298, 9884, 63, 576, 14, 1001, 2, 199, 3383, 63, 2339, 275, 298, 751, 63, 576, 2, 199, 6909, 63, 2339, 275, 298, 2060, 2, 199, 17057, 63, 2711, 63, 3876, 63, 2749, 9021, 275, 298, 505, 15, 6104, 2, 199, 17057, 63, 2711, 63, 24051, 63, 6243, 275, 298, 3578, 15, 1001, 2, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 6378, 5142, 3353, 8, 1726, 304, 272, 986, 421, 199, 533, 6378, 5142, 2042, 8, 1726, 304, 272, 986, 421, 199, 533, 10066, 5142, 8, 785, 304, 272, 408, 3244, 3341, 1041, 339, 347, 636, 826, 721, 277, 12, 1256, 12, 2287, 29, 403, 12, 1564, 29, 403, 12, 2402, 63, 1064, 29, 403, 12, 326, 2784, 63, 815, 29, 403, 12, 373, 68, 63, 3090, 29, 403, 304, 267, 408, 13921, 402, 642, 909, 1077, 26014, 8486, 1006, 900, 406, 26745, 267, 3245, 14, 221, 17653, 2410, 626, 1077, 440, 7675, 900, 477, 9316, 7037, 370, 267, 2784, 5331, 503, 2582, 89, 5033, 5331, 14, 398, 710, 922, 1077, 2066, 664, 282, 2849, 1256, 436, 1852, 3663, 1083, 267, 4882, 641, 652, 14, 267, 408, 267, 340, 440, 1564, 26, 288, 1564, 275, 942, 398, 11216, 275, 1067, 14, 362, 63, 2113, 63, 1100, 342, 398, 327, 710, 849, 574, 402, 6660, 804, 365, 663, 370, 14735, 63, 2711, 63, 3876, 63, 2749, 9021, 267, 291, 14, 409, 63, 17450, 8, 17057, 63, 2711, 63, 3876, 63, 2749, 9021, 9, 267, 291, 14, 842, 275, 1256, 267, 291, 14, 2911, 63, 1064, 275, 2402, 63, 1064, 398, 291, 14, 11856, 63, 2619, 275, 24978, 14, 362, 63, 842, 63, 11856, 63, 2619, 8, 6725, 12, 28095, 1256, 9, 398, 291, 14, 4416, 63, 2634, 275, 2251, 14, 19280, 1296, 14, 362, 63, 991, 63, 842, 8, 288, 11216, 12, 1256, 9, 398, 291, 14, 14632, 275, 485, 908, 63, 842, 63, 4745, 8, 6725, 12, 1256, 9, 398, 340, 1256, 14, 751, 63, 576, 365, 440, 488, 26, 288, 291, 14, 751, 576, 63, 1773, 275, 1300, 772, 14, 66, 772, 2708, 8, 842, 14, 751, 63, 576, 9, 267, 587, 26, 288, 291, 14, 751, 576, 63, 1773 ]
[ 1898, 7129, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 3244, 16160, 2556, 1041, 199, 199, 646, 1300, 772, 199, 646, 747, 199, 646, 15454, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 12161, 492, 18705, 199, 504, 11258, 63, 1208, 492, 492, 1208, 199, 504, 11258, 63, 1208, 492, 23011, 199, 646, 3816, 199, 199, 504, 5913, 14, 1246, 14, 825, 18, 492, 7062, 18, 1208, 199, 504, 5913, 14, 1246, 14, 2343, 492, 2505, 199, 504, 5913, 492, 14962, 63, 13325, 465, 24978, 199, 504, 5913, 492, 1853, 63, 1782, 199, 504, 5913, 492, 1067, 199, 504, 5913, 492, 2784, 199, 504, 5913, 492, 2251, 199, 504, 5913, 14, 1462, 492, 23911, 465, 23911, 63, 1113, 199, 504, 5913, 492, 3778, 199, 504, 5913, 14, 4549, 492, 1851, 1208, 421, 199, 2343, 63, 3291, 275, 359, 272, 4810, 14, 19340, 360, 888, 63, 9541, 63, 2759, 63, 6234, 297, 2049, 849, 7782, 17, 14, 16, 10219, 13, 614, 13, 1167, 10219, 13, 1644, 13, 614, 10219, 13, 2036, 13, 1398, 10219, 13, 709, 13, 709, 283, 717, 283, 9488, 13, 713, 13, 1046, 9079, 13, 996, 13, 614, 9079, 13, 1643, 13, 614, 659, 2049, 1720, 534, 1296, 402, 3341, 5459, 370, 3372, 299, 13121, 1901, 314, 283, 490, 283, 888, 12912, 659, 272, 4810, 14, 19340, 360, 9884, 576, 63, 3090, 297, 2049, 849, 534, 6765, 14, 1246, 14, 2343, 14, 9884, 576, 63, 1001, 14, 9653, 1173, 27111, 1451, 297, 2049, 1720, 534, 6158, 370, 675, 367, 20868, 666, 659, 199, 61, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 3291, 8, 2343, 63, 3291, 9, 199, 3103, 14, 646, 63, 2992, 360, 10801, 63, 2261, 297, 283, 6765, 14, 1200, 14, 2609, 358, 199, 199, 26358, 275, 359, 272, 283, 17, 14, 16, 297, 272, 283, 9488, 13, 614, 13, 1167, 297, 272, 283, 9488, 13, 1644, 13, 614, 297, 272, 283, 9488, 13, 2036, 13, 1398, 297, 272, 283, 9488, 13, 709, 13, 709, 297, 272, 283, 9488, 13, 713, 13, 1046, 297, 272, 283, 9300, 13, 996, 13, 614, 297, 272, 283, 9300, 13, 1643, 13, 614, 297, 272, 283, 8664, 13, 966, 13, 966, 297, 199, 61, 199, 199, 38, 2228, 4118, 45, 275, 283, 7409, 13, 2036, 13, 709, 7, 199, 3975, 5357, 58, 6084, 275, 283, 6965, 13, 966, 13, 966, 7, 199, 40, 6087, 879, 33, 275, 283, 6965, 13, 709, 13, 1196, 7, 199, 9935, 17014, 63, 26358, 275, 359, 272, 481, 2228, 4118, 45, 12, 272, 21772, 5357, 58, 6084, 12, 272, 869, 6087, 879, 33, 12, 199, 61, 199, 199, 4612, 275, 298, 1023, 2, 199, 9663, 275, 298, 1317, 2, 199, 9663, 63, 3022, 275, 298, 1317, 2, 199, 5127, 63, 6243, 63, 2339, 275, 298, 2024, 63, 576, 14, 1001, 2, 199, 26197, 63, 6243, 63, 2339, 275, 298, 9884, 63, 576, 14, 1001, 2, 199, 3383, 63, 2339, 275, 298, 751, 63, 576, 2, 199, 6909, 63, 2339, 275, 298, 2060, 2, 199, 17057, 63, 2711, 63, 3876, 63, 2749, 9021, 275, 298, 505, 15, 6104, 2, 199, 17057, 63, 2711, 63, 24051, 63, 6243, 275, 298, 3578, 15, 1001, 2, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 6378, 5142, 3353, 8, 1726, 304, 272, 986, 421, 199, 533, 6378, 5142, 2042, 8, 1726, 304, 272, 986, 421, 199, 533, 10066, 5142, 8, 785, 304, 272, 408, 3244, 3341, 1041, 339, 347, 636, 826, 721, 277, 12, 1256, 12, 2287, 29, 403, 12, 1564, 29, 403, 12, 2402, 63, 1064, 29, 403, 12, 326, 2784, 63, 815, 29, 403, 12, 373, 68, 63, 3090, 29, 403, 304, 267, 408, 13921, 402, 642, 909, 1077, 26014, 8486, 1006, 900, 406, 26745, 267, 3245, 14, 221, 17653, 2410, 626, 1077, 440, 7675, 900, 477, 9316, 7037, 370, 267, 2784, 5331, 503, 2582, 89, 5033, 5331, 14, 398, 710, 922, 1077, 2066, 664, 282, 2849, 1256, 436, 1852, 3663, 1083, 267, 4882, 641, 652, 14, 267, 408, 267, 340, 440, 1564, 26, 288, 1564, 275, 942, 398, 11216, 275, 1067, 14, 362, 63, 2113, 63, 1100, 342, 398, 327, 710, 849, 574, 402, 6660, 804, 365, 663, 370, 14735, 63, 2711, 63, 3876, 63, 2749, 9021, 267, 291, 14, 409, 63, 17450, 8, 17057, 63, 2711, 63, 3876, 63, 2749, 9021, 9, 267, 291, 14, 842, 275, 1256, 267, 291, 14, 2911, 63, 1064, 275, 2402, 63, 1064, 398, 291, 14, 11856, 63, 2619, 275, 24978, 14, 362, 63, 842, 63, 11856, 63, 2619, 8, 6725, 12, 28095, 1256, 9, 398, 291, 14, 4416, 63, 2634, 275, 2251, 14, 19280, 1296, 14, 362, 63, 991, 63, 842, 8, 288, 11216, 12, 1256, 9, 398, 291, 14, 14632, 275, 485, 908, 63, 842, 63, 4745, 8, 6725, 12, 1256, 9, 398, 340, 1256, 14, 751, 63, 576, 365, 440, 488, 26, 288, 291, 14, 751, 576, 63, 1773, 275, 1300, 772, 14, 66, 772, 2708, 8, 842, 14, 751, 63, 576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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dalegregory/odoo
addons/auth_oauth/res_config.py
292
3368
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU 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 openerp.osv import osv, fields import logging _logger = logging.getLogger(__name__) class base_config_settings(osv.TransientModel): _inherit = 'base.config.settings' _columns = { 'auth_oauth_google_enabled' : fields.boolean('Allow users to sign in with Google'), 'auth_oauth_google_client_id' : fields.char('Client ID'), 'auth_oauth_facebook_enabled' : fields.boolean('Allow users to sign in with Facebook'), 'auth_oauth_facebook_client_id' : fields.char('Client ID'), } def default_get(self, cr, uid, fields, context=None): res = super(base_config_settings, self).default_get(cr, uid, fields, context=context) res.update(self.get_oauth_providers(cr, uid, fields, context=context)) return res def get_oauth_providers(self, cr, uid, fields, context=None): google_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_google')[1] facebook_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_facebook')[1] rg = self.pool.get('auth.oauth.provider').read(cr, uid, [google_id], ['enabled','client_id'], context=context) rf = self.pool.get('auth.oauth.provider').read(cr, uid, [facebook_id], ['enabled','client_id'], context=context) return { 'auth_oauth_google_enabled': rg[0]['enabled'], 'auth_oauth_google_client_id': rg[0]['client_id'], 'auth_oauth_facebook_enabled': rf[0]['enabled'], 'auth_oauth_facebook_client_id': rf[0]['client_id'], } def set_oauth_providers(self, cr, uid, ids, context=None): google_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_google')[1] facebook_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_facebook')[1] config = self.browse(cr, uid, ids[0], context=context) rg = { 'enabled':config.auth_oauth_google_enabled, 'client_id':config.auth_oauth_google_client_id, } rf = { 'enabled':config.auth_oauth_facebook_enabled, 'client_id':config.auth_oauth_facebook_client_id, } self.pool.get('auth.oauth.provider').write(cr, uid, [google_id], rg) self.pool.get('auth.oauth.provider').write(cr, uid, [facebook_id], rf)
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, 6029, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 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, 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, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 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, 3133, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9506, 12, 1504, 199, 199, 646, 2050, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 1300, 63, 888, 63, 1751, 8, 4795, 14, 14612, 14928, 1685, 304, 272, 485, 6486, 275, 283, 1095, 14, 888, 14, 1751, 7, 339, 485, 3406, 275, 469, 267, 283, 1178, 63, 6126, 63, 3098, 63, 3827, 7, 520, 1504, 14, 4871, 360, 7852, 4390, 370, 2070, 315, 543, 4475, 659, 267, 283, 1178, 63, 6126, 63, 3098, 63, 1258, 63, 344, 7, 520, 1504, 14, 1560, 360, 3041, 2870, 659, 267, 283, 1178, 63, 6126, 63, 16652, 63, 3827, 7, 520, 1504, 14, 4871, 360, 7852, 4390, 370, 2070, 315, 543, 27107, 659, 267, 283, 1178, 63, 6126, 63, 16652, 63, 1258, 63, 344, 7, 520, 1504, 14, 1560, 360, 3041, 2870, 659, 272, 789, 339, 347, 849, 63, 362, 8, 277, 12, 2467, 12, 1747, 12, 1504, 12, 1067, 29, 403, 304, 267, 522, 275, 1613, 8, 1095, 63, 888, 63, 1751, 12, 291, 680, 885, 63, 362, 8, 1556, 12, 1747, 12, 1504, 12, 1067, 29, 1100, 9, 267, 522, 14, 873, 8, 277, 14, 362, 63, 6126, 63, 9710, 8, 1556, 12, 1747, 12, 1504, 12, 1067, 29, 1100, 430, 267, 372, 522, 339, 347, 664, 63, 6126, 63, 9710, 8, 277, 12, 2467, 12, 1747, 12, 1504, 12, 1067, 29, 403, 304, 267, 6233, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1178, 63, 6126, 297, 283, 3780, 63, 3098, 5832, 17, 61, 267, 8870, 2706, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1178, 63, 6126, 297, 283, 3780, 63, 16652, 5832, 17, 61, 267, 23136, 275, 291, 14, 2293, 14, 362, 360, 1178, 14, 6126, 14, 3780, 1959, 739, 8, 1556, 12, 1747, 12, 359, 3098, 63, 344, 467, 788, 3827, 1673, 1258, 63, 344, 995, 1067, 29, 1100, 9, 267, 17781, 275, 291, 14, 2293, 14, 362, 360, 1178, 14, 6126, 14, 3780, 1959, 739, 8, 1556, 12, 1747, 12, 359, 16652, 63, 344, 467, 788, 3827, 1673, 1258, 63, 344, 995, 1067, 29, 1100, 9, 267, 372, 469, 288, 283, 1178, 63, 6126, 63, 3098, 63, 3827, 356, 23136, 59, 16, 2733, 3827, 995, 288, 283, 1178, 63, 6126, 63, 3098, 63, 1258, 63, 344, 356, 23136, 59, 16, 2733, 1258, 63, 344, 995, 288, 283, 1178, 63, 6126, 63, 16652, 63, 3827, 356, 17781, 59, 16, 2733, 3827, 995, 288, 283, 1178, 63, 6126, 63, 16652, 63, 1258, 63, 344, 356, 17781, 59, 16, 2733, 1258, 63, 344, 995, 267, 789, 339, 347, 663, 63, 6126, 63, 9710, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 6233, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1178, 63, 6126, 297, 283, 3780, 63, 3098, 5832, 17, 61, 267, 8870, 2706, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1178, 63, 6126, 297, 283, 3780, 63, 16652, 5832, 17, 61, 267, 1101, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 59, 16, 467, 1067, 29, 1100, 9, 267, 23136, 275, 469, 288, 283, 3827, 356, 888, 14, 1178, 63, 6126, 63, 3098, 63, 3827, 12, 288, 283, 1258, 63, 344, 356, 888, 14, 1178, 63, 6126, 63, 3098, 63, 1258, 63, 344, 12, 267, 789, 267, 17781, 275, 469, 288, 283, 3827, 356, 888, 14, 1178, 63, 6126, 63, 16652, 63, 3827, 12, 288, 283, 1258, 63, 344, 356, 888, 14, 1178, 63, 6126, 63, 16652, 63, 1258, 63, 344, 12, 267, 789, 267, 291, 14, 2293, 14, 362, 360, 1178, 14, 6126, 14, 3780, 1959, 952, 8, 1556, 12, 1747, 12, 359, 3098, 63, 344, 467, 23136, 9, 267, 291, 14, 2293, 14, 362, 360, 1178, 14, 6126, 14, 3780, 1959, 952, 8, 1556, 12, 1747, 12, 359, 16652, 63, 344, 467, 17781, 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 ]
[ 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, 6029, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 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, 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, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 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, 3133, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9506, 12, 1504, 199, 199, 646, 2050, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 1300, 63, 888, 63, 1751, 8, 4795, 14, 14612, 14928, 1685, 304, 272, 485, 6486, 275, 283, 1095, 14, 888, 14, 1751, 7, 339, 485, 3406, 275, 469, 267, 283, 1178, 63, 6126, 63, 3098, 63, 3827, 7, 520, 1504, 14, 4871, 360, 7852, 4390, 370, 2070, 315, 543, 4475, 659, 267, 283, 1178, 63, 6126, 63, 3098, 63, 1258, 63, 344, 7, 520, 1504, 14, 1560, 360, 3041, 2870, 659, 267, 283, 1178, 63, 6126, 63, 16652, 63, 3827, 7, 520, 1504, 14, 4871, 360, 7852, 4390, 370, 2070, 315, 543, 27107, 659, 267, 283, 1178, 63, 6126, 63, 16652, 63, 1258, 63, 344, 7, 520, 1504, 14, 1560, 360, 3041, 2870, 659, 272, 789, 339, 347, 849, 63, 362, 8, 277, 12, 2467, 12, 1747, 12, 1504, 12, 1067, 29, 403, 304, 267, 522, 275, 1613, 8, 1095, 63, 888, 63, 1751, 12, 291, 680, 885, 63, 362, 8, 1556, 12, 1747, 12, 1504, 12, 1067, 29, 1100, 9, 267, 522, 14, 873, 8, 277, 14, 362, 63, 6126, 63, 9710, 8, 1556, 12, 1747, 12, 1504, 12, 1067, 29, 1100, 430, 267, 372, 522, 339, 347, 664, 63, 6126, 63, 9710, 8, 277, 12, 2467, 12, 1747, 12, 1504, 12, 1067, 29, 403, 304, 267, 6233, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1178, 63, 6126, 297, 283, 3780, 63, 3098, 5832, 17, 61, 267, 8870, 2706, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1178, 63, 6126, 297, 283, 3780, 63, 16652, 5832, 17, 61, 267, 23136, 275, 291, 14, 2293, 14, 362, 360, 1178, 14, 6126, 14, 3780, 1959, 739, 8, 1556, 12, 1747, 12, 359, 3098, 63, 344, 467, 788, 3827, 1673, 1258, 63, 344, 995, 1067, 29, 1100, 9, 267, 17781, 275, 291, 14, 2293, 14, 362, 360, 1178, 14, 6126, 14, 3780, 1959, 739, 8, 1556, 12, 1747, 12, 359, 16652, 63, 344, 467, 788, 3827, 1673, 1258, 63, 344, 995, 1067, 29, 1100, 9, 267, 372, 469, 288, 283, 1178, 63, 6126, 63, 3098, 63, 3827, 356, 23136, 59, 16, 2733, 3827, 995, 288, 283, 1178, 63, 6126, 63, 3098, 63, 1258, 63, 344, 356, 23136, 59, 16, 2733, 1258, 63, 344, 995, 288, 283, 1178, 63, 6126, 63, 16652, 63, 3827, 356, 17781, 59, 16, 2733, 3827, 995, 288, 283, 1178, 63, 6126, 63, 16652, 63, 1258, 63, 344, 356, 17781, 59, 16, 2733, 1258, 63, 344, 995, 267, 789, 339, 347, 663, 63, 6126, 63, 9710, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 6233, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1178, 63, 6126, 297, 283, 3780, 63, 3098, 5832, 17, 61, 267, 8870, 2706, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1178, 63, 6126, 297, 283, 3780, 63, 16652, 5832, 17, 61, 267, 1101, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 59, 16, 467, 1067, 29, 1100, 9, 267, 23136, 275, 469, 288, 283, 3827, 356, 888, 14, 1178, 63, 6126, 63, 3098, 63, 3827, 12, 288, 283, 1258, 63, 344, 356, 888, 14, 1178, 63, 6126, 63, 3098, 63, 1258, 63, 344, 12, 267, 789, 267, 17781, 275, 469, 288, 283, 3827, 356, 888, 14, 1178, 63, 6126, 63, 16652, 63, 3827, 12, 288, 283, 1258, 63, 344, 356, 888, 14, 1178, 63, 6126, 63, 16652, 63, 1258, 63, 344, 12, 267, 789, 267, 291, 14, 2293, 14, 362, 360, 1178, 14, 6126, 14, 3780, 1959, 952, 8, 1556, 12, 1747, 12, 359, 3098, 63, 344, 467, 23136, 9, 267, 291, 14, 2293, 14, 362, 360, 1178, 14, 6126, 14, 3780, 1959, 952, 8, 1556, 12, 1747, 12, 359, 16652, 63, 344, 467, 17781, 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,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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 ]
NL66278/OCB
addons/l10n_sg/__init__.py
669
1059
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2014 Tech Receptives (<http://techreceptives.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## # 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, 6927, 5773, 335, 799, 28448, 7301, 8642, 1014, 921, 15970, 264, 28448, 7301, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6927, 5773, 335, 799, 28448, 7301, 8642, 1014, 921, 15970, 264, 28448, 7301, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
memtoko/django
django/core/management/commands/sqlmigrate.py
463
2715
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.core.management.base import BaseCommand, CommandError from django.db import DEFAULT_DB_ALIAS, connections from django.db.migrations.executor import MigrationExecutor from django.db.migrations.loader import AmbiguityError class Command(BaseCommand): help = "Prints the SQL statements for the named migration." output_transaction = True def add_arguments(self, parser): parser.add_argument('app_label', help='App label of the application containing the migration.') parser.add_argument('migration_name', help='Migration name to print the SQL for.') parser.add_argument('--database', default=DEFAULT_DB_ALIAS, help='Nominates a database to create SQL for. Defaults to the ' '"default" database.') parser.add_argument('--backwards', action='store_true', dest='backwards', default=False, help='Creates SQL to unapply the migration, rather than to apply it') def execute(self, *args, **options): # sqlmigrate doesn't support coloring its output but we need to force # no_color=True so that the BEGIN/COMMIT statements added by # output_transaction don't get colored either. options['no_color'] = True return super(Command, self).execute(*args, **options) def handle(self, *args, **options): # Get the database we're operating from connection = connections[options['database']] # Load up an executor to get all the migration data executor = MigrationExecutor(connection) # Resolve command-line arguments into a migration app_label, migration_name = options['app_label'], options['migration_name'] if app_label not in executor.loader.migrated_apps: raise CommandError("App '%s' does not have migrations" % app_label) try: migration = executor.loader.get_migration_by_prefix(app_label, migration_name) except AmbiguityError: raise CommandError("More than one migration matches '%s' in app '%s'. Please be more specific." % ( migration_name, app_label)) except KeyError: raise CommandError("Cannot find a migration matching '%s' from app '%s'. Is it in INSTALLED_APPS?" % ( migration_name, app_label)) targets = [(app_label, migration.name)] # Make a plan that represents just the requested migrations and show SQL # for it plan = [(executor.loader.graph.nodes[targets[0]], options['backwards'])] sql_statements = executor.collect_sql(plan) return '\n'.join(sql_statements)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 1639, 14, 697, 492, 6186, 63, 2846, 63, 12644, 12, 6947, 199, 504, 1639, 14, 697, 14, 7685, 14, 13471, 492, 12090, 16752, 199, 504, 1639, 14, 697, 14, 7685, 14, 3422, 492, 437, 887, 528, 24180, 547, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 298, 26113, 314, 5385, 9834, 367, 314, 4310, 8367, 2122, 339, 1072, 63, 5945, 275, 715, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 360, 571, 63, 1302, 297, 288, 1720, 534, 2640, 1768, 402, 314, 4223, 3035, 314, 8367, 2659, 267, 1798, 14, 525, 63, 2094, 360, 8998, 63, 354, 297, 288, 1720, 534, 9816, 536, 370, 870, 314, 5385, 367, 2659, 267, 1798, 14, 525, 63, 2094, 4517, 4659, 297, 849, 29, 3472, 63, 2846, 63, 12644, 12, 288, 1720, 534, 46, 676, 262, 2335, 282, 3050, 370, 1218, 5385, 367, 14, 7827, 370, 314, 283, 326, 5522, 885, 2, 3050, 2659, 267, 1798, 14, 525, 63, 2094, 4517, 22269, 297, 1595, 534, 1617, 63, 2052, 297, 2053, 534, 22269, 297, 288, 849, 29, 797, 12, 1720, 534, 10607, 5385, 370, 625, 4998, 314, 8367, 12, 7830, 2419, 370, 4838, 652, 358, 339, 347, 5341, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 327, 3875, 8462, 3181, 1133, 2291, 3164, 316, 2399, 1072, 1325, 781, 1929, 370, 3542, 267, 327, 949, 63, 2326, 29, 549, 880, 626, 314, 16427, 15, 23446, 9834, 3483, 701, 267, 327, 1072, 63, 5945, 2793, 1133, 664, 32076, 1902, 14, 267, 1511, 459, 889, 63, 2326, 418, 275, 715, 267, 372, 1613, 8, 3110, 12, 291, 680, 2526, 2031, 589, 12, 1011, 1419, 9, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 327, 2372, 314, 3050, 781, 3984, 17406, 687, 267, 1950, 275, 6947, 59, 1419, 459, 4659, 6538, 398, 327, 7190, 1536, 376, 13270, 370, 664, 1006, 314, 8367, 666, 267, 13270, 275, 12090, 16752, 8, 2105, 9, 398, 327, 31096, 1414, 13, 604, 2368, 1901, 282, 8367, 267, 1145, 63, 1302, 12, 8367, 63, 354, 275, 1511, 459, 571, 63, 1302, 995, 1511, 459, 8998, 63, 354, 418, 267, 340, 1145, 63, 1302, 440, 315, 13270, 14, 3422, 14, 31544, 63, 5181, 26, 288, 746, 14393, 480, 2640, 1543, 83, 7, 1630, 440, 1172, 6180, 2, 450, 1145, 63, 1302, 9, 267, 862, 26, 288, 8367, 275, 13270, 14, 3422, 14, 362, 63, 8998, 63, 991, 63, 1861, 8, 571, 63, 1302, 12, 8367, 63, 354, 9, 267, 871, 437, 887, 528, 24180, 547, 26, 288, 746, 14393, 480, 11053, 2419, 1373, 8367, 4450, 1543, 83, 7, 315, 1145, 1543, 83, 1370, 7754, 506, 1655, 2488, 2122, 450, 334, 355, 8367, 63, 354, 12, 1145, 63, 1302, 430, 267, 871, 4067, 26, 288, 746, 14393, 480, 6612, 2342, 282, 8367, 4877, 1543, 83, 7, 687, 1145, 1543, 83, 1370, 6596, 652, 315, 31061, 63, 14219, 13472, 450, 334, 355, 8367, 63, 354, 12, 1145, 63, 1302, 430, 267, 4545, 275, 3842, 571, 63, 1302, 12, 8367, 14, 354, 1874, 398, 327, 4155, 282, 8683, 626, 8469, 2951, 314, 5839, 6180, 436, 2498, 5385, 267, 327, 367, 652, 267, 8683, 275, 3842, 13471, 14, 3422, 14, 2180, 14, 2415, 59, 4684, 59, 16, 2365, 1511, 459, 22269, 24437, 267, 3875, 63, 15384, 275, 13270, 14, 7112, 63, 3009, 8, 5140, 9, 267, 372, 1557, 78, 1370, 904, 8, 3009, 63, 15384, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 1639, 14, 697, 492, 6186, 63, 2846, 63, 12644, 12, 6947, 199, 504, 1639, 14, 697, 14, 7685, 14, 13471, 492, 12090, 16752, 199, 504, 1639, 14, 697, 14, 7685, 14, 3422, 492, 437, 887, 528, 24180, 547, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 298, 26113, 314, 5385, 9834, 367, 314, 4310, 8367, 2122, 339, 1072, 63, 5945, 275, 715, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 360, 571, 63, 1302, 297, 288, 1720, 534, 2640, 1768, 402, 314, 4223, 3035, 314, 8367, 2659, 267, 1798, 14, 525, 63, 2094, 360, 8998, 63, 354, 297, 288, 1720, 534, 9816, 536, 370, 870, 314, 5385, 367, 2659, 267, 1798, 14, 525, 63, 2094, 4517, 4659, 297, 849, 29, 3472, 63, 2846, 63, 12644, 12, 288, 1720, 534, 46, 676, 262, 2335, 282, 3050, 370, 1218, 5385, 367, 14, 7827, 370, 314, 283, 326, 5522, 885, 2, 3050, 2659, 267, 1798, 14, 525, 63, 2094, 4517, 22269, 297, 1595, 534, 1617, 63, 2052, 297, 2053, 534, 22269, 297, 288, 849, 29, 797, 12, 1720, 534, 10607, 5385, 370, 625, 4998, 314, 8367, 12, 7830, 2419, 370, 4838, 652, 358, 339, 347, 5341, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 327, 3875, 8462, 3181, 1133, 2291, 3164, 316, 2399, 1072, 1325, 781, 1929, 370, 3542, 267, 327, 949, 63, 2326, 29, 549, 880, 626, 314, 16427, 15, 23446, 9834, 3483, 701, 267, 327, 1072, 63, 5945, 2793, 1133, 664, 32076, 1902, 14, 267, 1511, 459, 889, 63, 2326, 418, 275, 715, 267, 372, 1613, 8, 3110, 12, 291, 680, 2526, 2031, 589, 12, 1011, 1419, 9, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 327, 2372, 314, 3050, 781, 3984, 17406, 687, 267, 1950, 275, 6947, 59, 1419, 459, 4659, 6538, 398, 327, 7190, 1536, 376, 13270, 370, 664, 1006, 314, 8367, 666, 267, 13270, 275, 12090, 16752, 8, 2105, 9, 398, 327, 31096, 1414, 13, 604, 2368, 1901, 282, 8367, 267, 1145, 63, 1302, 12, 8367, 63, 354, 275, 1511, 459, 571, 63, 1302, 995, 1511, 459, 8998, 63, 354, 418, 267, 340, 1145, 63, 1302, 440, 315, 13270, 14, 3422, 14, 31544, 63, 5181, 26, 288, 746, 14393, 480, 2640, 1543, 83, 7, 1630, 440, 1172, 6180, 2, 450, 1145, 63, 1302, 9, 267, 862, 26, 288, 8367, 275, 13270, 14, 3422, 14, 362, 63, 8998, 63, 991, 63, 1861, 8, 571, 63, 1302, 12, 8367, 63, 354, 9, 267, 871, 437, 887, 528, 24180, 547, 26, 288, 746, 14393, 480, 11053, 2419, 1373, 8367, 4450, 1543, 83, 7, 315, 1145, 1543, 83, 1370, 7754, 506, 1655, 2488, 2122, 450, 334, 355, 8367, 63, 354, 12, 1145, 63, 1302, 430, 267, 871, 4067, 26, 288, 746, 14393, 480, 6612, 2342, 282, 8367, 4877, 1543, 83, 7, 687, 1145, 1543, 83, 1370, 6596, 652, 315, 31061, 63, 14219, 13472, 450, 334, 355, 8367, 63, 354, 12, 1145, 63, 1302, 430, 267, 4545, 275, 3842, 571, 63, 1302, 12, 8367, 14, 354, 1874, 398, 327, 4155, 282, 8683, 626, 8469, 2951, 314, 5839, 6180, 436, 2498, 5385, 267, 327, 367, 652, 267, 8683, 275, 3842, 13471, 14, 3422, 14, 2180, 14, 2415, 59, 4684, 59, 16, 2365, 1511, 459, 22269, 24437, 267, 3875, 63, 15384, 275, 13270, 14, 7112, 63, 3009, 8, 5140, 9, 267, 372, 1557, 78, 1370, 904, 8, 3009, 63, 15384, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
romain-dartigues/ansible
lib/ansible/modules/network/netscaler/netscaler_lb_vserver.py
101
72334
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright (c) 2017 Citrix Systems # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: netscaler_lb_vserver short_description: Manage load balancing vserver configuration description: - Manage load balancing vserver configuration - This module is intended to run either on the ansible control node or a bastion (jumpserver) with access to the actual netscaler instance version_added: "2.4" author: George Nikolopoulos (@giorgos-nikolopoulos) options: name: description: - >- Name for the virtual server. Must begin with an ASCII alphanumeric or underscore C(_) character, and must contain only ASCII alphanumeric, underscore, hash C(#), period C(.), space C( ), colon C(:), at sign C(@), equal sign C(=), and hyphen C(-) characters. Can be changed after the virtual server is created. - "Minimum length = 1" servicetype: choices: - 'HTTP' - 'FTP' - 'TCP' - 'UDP' - 'SSL' - 'SSL_BRIDGE' - 'SSL_TCP' - 'DTLS' - 'NNTP' - 'DNS' - 'DHCPRA' - 'ANY' - 'SIP_UDP' - 'SIP_TCP' - 'SIP_SSL' - 'DNS_TCP' - 'RTSP' - 'PUSH' - 'SSL_PUSH' - 'RADIUS' - 'RDP' - 'MYSQL' - 'MSSQL' - 'DIAMETER' - 'SSL_DIAMETER' - 'TFTP' - 'ORACLE' - 'SMPP' - 'SYSLOGTCP' - 'SYSLOGUDP' - 'FIX' - 'SSL_FIX' description: - "Protocol used by the service (also called the service type)." ipv46: description: - "IPv4 or IPv6 address to assign to the virtual server." ippattern: description: - >- IP address pattern, in dotted decimal notation, for identifying packets to be accepted by the virtual server. The IP Mask parameter specifies which part of the destination IP address is matched against the pattern. Mutually exclusive with the IP Address parameter. - >- For example, if the IP pattern assigned to the virtual server is C(198.51.100.0) and the IP mask is C(255.255.240.0) (a forward mask), the first 20 bits in the destination IP addresses are matched with the first 20 bits in the pattern. The virtual server accepts requests with IP addresses that range from C(198.51.96.1) to C(198.51.111.254). You can also use a pattern such as C(0.0.2.2) and a mask such as C(0.0.255.255) (a reverse mask). - >- If a destination IP address matches more than one IP pattern, the pattern with the longest match is selected, and the associated virtual server processes the request. For example, if virtual servers C(vs1) and C(vs2) have the same IP pattern, C(0.0.100.128), but different IP masks of C(0.0.255.255) and C(0.0.224.255), a destination IP address of C(198.51.100.128) has the longest match with the IP pattern of vs1. If a destination IP address matches two or more virtual servers to the same extent, the request is processed by the virtual server whose port number matches the port number in the request. ipmask: description: - >- IP mask, in dotted decimal notation, for the IP Pattern parameter. Can have leading or trailing non-zero octets (for example, C(255.255.240.0) or C(0.0.255.255)). Accordingly, the mask specifies whether the first n bits or the last n bits of the destination IP address in a client request are to be matched with the corresponding bits in the IP pattern. The former is called a forward mask. The latter is called a reverse mask. port: description: - "Port number for the virtual server." - "Range C(1) - C(65535)" - "* in CLI is represented as C(65535) in NITRO API" range: description: - >- Number of IP addresses that the appliance must generate and assign to the virtual server. The virtual server then functions as a network virtual server, accepting traffic on any of the generated IP addresses. The IP addresses are generated automatically, as follows: - >- * For a range of n, the last octet of the address specified by the IP Address parameter increments n-1 times. - "* If the last octet exceeds 255, it rolls over to 0 and the third octet increments by 1." - >- Note: The Range parameter assigns multiple IP addresses to one virtual server. To generate an array of virtual servers, each of which owns only one IP address, use brackets in the IP Address and Name parameters to specify the range. For example: - "add lb vserver my_vserver[1-3] HTTP 192.0.2.[1-3] 80." - "Minimum value = C(1)" - "Maximum value = C(254)" persistencetype: choices: - 'SOURCEIP' - 'COOKIEINSERT' - 'SSLSESSION' - 'RULE' - 'URLPASSIVE' - 'CUSTOMSERVERID' - 'DESTIP' - 'SRCIPDESTIP' - 'CALLID' - 'RTSPSID' - 'DIAMETER' - 'FIXSESSION' - 'NONE' description: - "Type of persistence for the virtual server. Available settings function as follows:" - "* C(SOURCEIP) - Connections from the same client IP address belong to the same persistence session." - >- * C(COOKIEINSERT) - Connections that have the same HTTP Cookie, inserted by a Set-Cookie directive from a server, belong to the same persistence session. - "* C(SSLSESSION) - Connections that have the same SSL Session ID belong to the same persistence session." - >- * C(CUSTOMSERVERID) - Connections with the same server ID form part of the same session. For this persistence type, set the Server ID (CustomServerID) parameter for each service and configure the Rule parameter to identify the server ID in a request. - "* C(RULE) - All connections that match a user defined rule belong to the same persistence session." - >- * C(URLPASSIVE) - Requests that have the same server ID in the URL query belong to the same persistence session. The server ID is the hexadecimal representation of the IP address and port of the service to which the request must be forwarded. This persistence type requires a rule to identify the server ID in the request. - "* C(DESTIP) - Connections to the same destination IP address belong to the same persistence session." - >- * C(SRCIPDESTIP) - Connections that have the same source IP address and destination IP address belong to the same persistence session. - "* C(CALLID) - Connections that have the same CALL-ID SIP header belong to the same persistence session." - "* C(RTSPSID) - Connections that have the same RTSP Session ID belong to the same persistence session." - >- * FIXSESSION - Connections that have the same SenderCompID and TargetCompID values belong to the same persistence session. timeout: description: - "Time period for which a persistence session is in effect." - "Minimum value = C(0)" - "Maximum value = C(1440)" persistencebackup: choices: - 'SOURCEIP' - 'NONE' description: - >- Backup persistence type for the virtual server. Becomes operational if the primary persistence mechanism fails. backuppersistencetimeout: description: - "Time period for which backup persistence is in effect." - "Minimum value = C(2)" - "Maximum value = C(1440)" lbmethod: choices: - 'ROUNDROBIN' - 'LEASTCONNECTION' - 'LEASTRESPONSETIME' - 'URLHASH' - 'DOMAINHASH' - 'DESTINATIONIPHASH' - 'SOURCEIPHASH' - 'SRCIPDESTIPHASH' - 'LEASTBANDWIDTH' - 'LEASTPACKETS' - 'TOKEN' - 'SRCIPSRCPORTHASH' - 'LRTM' - 'CALLIDHASH' - 'CUSTOMLOAD' - 'LEASTREQUEST' - 'AUDITLOGHASH' - 'STATICPROXIMITY' description: - "Load balancing method. The available settings function as follows:" - >- * C(ROUNDROBIN) - Distribute requests in rotation, regardless of the load. Weights can be assigned to services to enforce weighted round robin distribution. - "* C(LEASTCONNECTION) (default) - Select the service with the fewest connections." - "* C(LEASTRESPONSETIME) - Select the service with the lowest average response time." - "* C(LEASTBANDWIDTH) - Select the service currently handling the least traffic." - "* C(LEASTPACKETS) - Select the service currently serving the lowest number of packets per second." - "* C(CUSTOMLOAD) - Base service selection on the SNMP metrics obtained by custom load monitors." - >- * C(LRTM) - Select the service with the lowest response time. Response times are learned through monitoring probes. This method also takes the number of active connections into account. - >- Also available are a number of hashing methods, in which the appliance extracts a predetermined portion of the request, creates a hash of the portion, and then checks whether any previous requests had the same hash value. If it finds a match, it forwards the request to the service that served those previous requests. Following are the hashing methods: - "* C(URLHASH) - Create a hash of the request URL (or part of the URL)." - >- * C(DOMAINHASH) - Create a hash of the domain name in the request (or part of the domain name). The domain name is taken from either the URL or the Host header. If the domain name appears in both locations, the URL is preferred. If the request does not contain a domain name, the load balancing method defaults to C(LEASTCONNECTION). - "* C(DESTINATIONIPHASH) - Create a hash of the destination IP address in the IP header." - "* C(SOURCEIPHASH) - Create a hash of the source IP address in the IP header." - >- * C(TOKEN) - Extract a token from the request, create a hash of the token, and then select the service to which any previous requests with the same token hash value were sent. - >- * C(SRCIPDESTIPHASH) - Create a hash of the string obtained by concatenating the source IP address and destination IP address in the IP header. - "* C(SRCIPSRCPORTHASH) - Create a hash of the source IP address and source port in the IP header." - "* C(CALLIDHASH) - Create a hash of the SIP Call-ID header." hashlength: description: - >- Number of bytes to consider for the hash value used in the URLHASH and DOMAINHASH load balancing methods. - "Minimum value = C(1)" - "Maximum value = C(4096)" netmask: description: - >- IPv4 subnet mask to apply to the destination IP address or source IP address when the load balancing method is C(DESTINATIONIPHASH) or C(SOURCEIPHASH). - "Minimum length = 1" v6netmasklen: description: - >- Number of bits to consider in an IPv6 destination or source IP address, for creating the hash that is required by the C(DESTINATIONIPHASH) and C(SOURCEIPHASH) load balancing methods. - "Minimum value = C(1)" - "Maximum value = C(128)" backuplbmethod: choices: - 'ROUNDROBIN' - 'LEASTCONNECTION' - 'LEASTRESPONSETIME' - 'SOURCEIPHASH' - 'LEASTBANDWIDTH' - 'LEASTPACKETS' - 'CUSTOMLOAD' description: - "Backup load balancing method. Becomes operational if the primary load balancing me" - "thod fails or cannot be used." - "Valid only if the primary method is based on static proximity." cookiename: description: - >- Use this parameter to specify the cookie name for C(COOKIE) peristence type. It specifies the name of cookie with a maximum of 32 characters. If not specified, cookie name is internally generated. listenpolicy: description: - >- Default syntax expression identifying traffic accepted by the virtual server. Can be either an expression (for example, C(CLIENT.IP.DST.IN_SUBNET(192.0.2.0/24)) or the name of a named expression. In the above example, the virtual server accepts all requests whose destination IP address is in the 192.0.2.0/24 subnet. listenpriority: description: - >- Integer specifying the priority of the listen policy. A higher number specifies a lower priority. If a request matches the listen policies of more than one virtual server the virtual server whose listen policy has the highest priority (the lowest priority number) accepts the request. - "Minimum value = C(0)" - "Maximum value = C(101)" resrule: description: - >- Default syntax expression specifying which part of a server's response to use for creating rule based persistence sessions (persistence type RULE). Can be either an expression or the name of a named expression. - "Example:" - "C(HTTP.RES.HEADER(\\"setcookie\\").VALUE(0).TYPECAST_NVLIST_T('=',';').VALUE(\\"server1\\"))." persistmask: description: - "Persistence mask for IP based persistence types, for IPv4 virtual servers." - "Minimum length = 1" v6persistmasklen: description: - "Persistence mask for IP based persistence types, for IPv6 virtual servers." - "Minimum value = C(1)" - "Maximum value = C(128)" rtspnat: description: - "Use network address translation (NAT) for RTSP data connections." type: bool m: choices: - 'IP' - 'MAC' - 'IPTUNNEL' - 'TOS' description: - "Redirection mode for load balancing. Available settings function as follows:" - >- * C(IP) - Before forwarding a request to a server, change the destination IP address to the server's IP address. - >- * C(MAC) - Before forwarding a request to a server, change the destination MAC address to the server's MAC address. The destination IP address is not changed. MAC-based redirection mode is used mostly in firewall load balancing deployments. - >- * C(IPTUNNEL) - Perform IP-in-IP encapsulation for client IP packets. In the outer IP headers, set the destination IP address to the IP address of the server and the source IP address to the subnet IP (SNIP). The client IP packets are not modified. Applicable to both IPv4 and IPv6 packets. - "* C(TOS) - Encode the virtual server's TOS ID in the TOS field of the IP header." - "You can use either the C(IPTUNNEL) or the C(TOS) option to implement Direct Server Return (DSR)." tosid: description: - >- TOS ID of the virtual server. Applicable only when the load balancing redirection mode is set to TOS. - "Minimum value = C(1)" - "Maximum value = C(63)" datalength: description: - >- Length of the token to be extracted from the data segment of an incoming packet, for use in the token method of load balancing. The length of the token, specified in bytes, must not be greater than 24 KB. Applicable to virtual servers of type TCP. - "Minimum value = C(1)" - "Maximum value = C(100)" dataoffset: description: - >- Offset to be considered when extracting a token from the TCP payload. Applicable to virtual servers, of type TCP, using the token method of load balancing. Must be within the first 24 KB of the TCP payload. - "Minimum value = C(0)" - "Maximum value = C(25400)" sessionless: choices: - 'enabled' - 'disabled' description: - >- Perform load balancing on a per-packet basis, without establishing sessions. Recommended for load balancing of intrusion detection system (IDS) servers and scenarios involving direct server return (DSR), where session information is unnecessary. connfailover: choices: - 'DISABLED' - 'STATEFUL' - 'STATELESS' description: - >- Mode in which the connection failover feature must operate for the virtual server. After a failover, established TCP connections and UDP packet flows are kept active and resumed on the secondary appliance. Clients remain connected to the same servers. Available settings function as follows: - >- * C(STATEFUL) - The primary appliance shares state information with the secondary appliance, in real time, resulting in some runtime processing overhead. - >- * C(STATELESS) - State information is not shared, and the new primary appliance tries to re-create the packet flow on the basis of the information contained in the packets it receives. - "* C(DISABLED) - Connection failover does not occur." redirurl: description: - "URL to which to redirect traffic if the virtual server becomes unavailable." - >- WARNING! Make sure that the domain in the URL does not match the domain specified for a content switching policy. If it does, requests are continuously redirected to the unavailable virtual server. - "Minimum length = 1" cacheable: description: - >- Route cacheable requests to a cache redirection virtual server. The load balancing virtual server can forward requests only to a transparent cache redirection virtual server that has an IP address and port combination of *:80, so such a cache redirection virtual server must be configured on the appliance. type: bool clttimeout: description: - "Idle time, in seconds, after which a client connection is terminated." - "Minimum value = C(0)" - "Maximum value = C(31536000)" somethod: choices: - 'CONNECTION' - 'DYNAMICCONNECTION' - 'BANDWIDTH' - 'HEALTH' - 'NONE' description: - "Type of threshold that, when exceeded, triggers spillover. Available settings function as follows:" - "* C(CONNECTION) - Spillover occurs when the number of client connections exceeds the threshold." - >- * DYNAMICCONNECTION - Spillover occurs when the number of client connections at the virtual server exceeds the sum of the maximum client (Max Clients) settings for bound services. Do not specify a spillover threshold for this setting, because the threshold is implied by the Max Clients settings of bound services. - >- * C(BANDWIDTH) - Spillover occurs when the bandwidth consumed by the virtual server's incoming and outgoing traffic exceeds the threshold. - >- * C(HEALTH) - Spillover occurs when the percentage of weights of the services that are UP drops below the threshold. For example, if services svc1, svc2, and svc3 are bound to a virtual server, with weights 1, 2, and 3, and the spillover threshold is 50%, spillover occurs if svc1 and svc3 or svc2 and svc3 transition to DOWN. - "* C(NONE) - Spillover does not occur." sopersistence: choices: - 'enabled' - 'disabled' description: - >- If spillover occurs, maintain source IP address based persistence for both primary and backup virtual servers. sopersistencetimeout: description: - "Timeout for spillover persistence, in minutes." - "Minimum value = C(2)" - "Maximum value = C(1440)" healththreshold: description: - >- Threshold in percent of active services below which vserver state is made down. If this threshold is 0, vserver state will be up even if one bound service is up. - "Minimum value = C(0)" - "Maximum value = C(100)" sothreshold: description: - >- Threshold at which spillover occurs. Specify an integer for the C(CONNECTION) spillover method, a bandwidth value in kilobits per second for the C(BANDWIDTH) method (do not enter the units), or a percentage for the C(HEALTH) method (do not enter the percentage symbol). - "Minimum value = C(1)" - "Maximum value = C(4294967287)" sobackupaction: choices: - 'DROP' - 'ACCEPT' - 'REDIRECT' description: - >- Action to be performed if spillover is to take effect, but no backup chain to spillover is usable or exists. redirectportrewrite: choices: - 'enabled' - 'disabled' description: - "Rewrite the port and change the protocol to ensure successful HTTP redirects from services." downstateflush: choices: - 'enabled' - 'disabled' description: - >- Flush all active transactions associated with a virtual server whose state transitions from UP to DOWN. Do not enable this option for applications that must complete their transactions. disableprimaryondown: choices: - 'enabled' - 'disabled' description: - >- If the primary virtual server goes down, do not allow it to return to primary status until manually enabled. insertvserveripport: choices: - 'OFF' - 'VIPADDR' - 'V6TOV4MAPPING' description: - >- Insert an HTTP header, whose value is the IP address and port number of the virtual server, before forwarding a request to the server. The format of the header is <vipHeader>: <virtual server IP address>_<port number >, where vipHeader is the name that you specify for the header. If the virtual server has an IPv6 address, the address in the header is enclosed in brackets ([ and ]) to separate it from the port number. If you have mapped an IPv4 address to a virtual server's IPv6 address, the value of this parameter determines which IP address is inserted in the header, as follows: - >- * C(VIPADDR) - Insert the IP address of the virtual server in the HTTP header regardless of whether the virtual server has an IPv4 address or an IPv6 address. A mapped IPv4 address, if configured, is ignored. - >- * C(V6TOV4MAPPING) - Insert the IPv4 address that is mapped to the virtual server's IPv6 address. If a mapped IPv4 address is not configured, insert the IPv6 address. - "* C(OFF) - Disable header insertion." vipheader: description: - "Name for the inserted header. The default name is vip-header." - "Minimum length = 1" authenticationhost: description: - >- Fully qualified domain name (FQDN) of the authentication virtual server to which the user must be redirected for authentication. Make sure that the Authentication parameter is set to C(yes). - "Minimum length = 3" - "Maximum length = 252" authentication: description: - "Enable or disable user authentication." type: bool authn401: description: - "Enable or disable user authentication with HTTP 401 responses." type: bool authnvsname: description: - "Name of an authentication virtual server with which to authenticate users." - "Minimum length = 1" - "Maximum length = 252" push: choices: - 'enabled' - 'disabled' description: - "Process traffic with the push virtual server that is bound to this load balancing virtual server." pushvserver: description: - >- Name of the load balancing virtual server, of type PUSH or SSL_PUSH, to which the server pushes updates received on the load balancing virtual server that you are configuring. - "Minimum length = 1" pushlabel: description: - >- Expression for extracting a label from the server's response. Can be either an expression or the name of a named expression. pushmulticlients: description: - >- Allow multiple Web 2.0 connections from the same client to connect to the virtual server and expect updates. type: bool tcpprofilename: description: - "Name of the TCP profile whose settings are to be applied to the virtual server." - "Minimum length = 1" - "Maximum length = 127" httpprofilename: description: - "Name of the HTTP profile whose settings are to be applied to the virtual server." - "Minimum length = 1" - "Maximum length = 127" dbprofilename: description: - "Name of the DB profile whose settings are to be applied to the virtual server." - "Minimum length = 1" - "Maximum length = 127" comment: description: - "Any comments that you might want to associate with the virtual server." l2conn: description: - >- Use Layer 2 parameters (channel number, MAC address, and VLAN ID) in addition to the 4-tuple (<source IP>:<source port>::<destination IP>:<destination port>) that is used to identify a connection. Allows multiple TCP and non-TCP connections with the same 4-tuple to co-exist on the NetScaler appliance. type: bool oracleserverversion: choices: - '10G' - '11G' description: - "Oracle server version." mssqlserverversion: choices: - '70' - '2000' - '2000SP1' - '2005' - '2008' - '2008R2' - '2012' - '2014' description: - >- For a load balancing virtual server of type C(MSSQL), the Microsoft SQL Server version. Set this parameter if you expect some clients to run a version different from the version of the database. This setting provides compatibility between the client-side and server-side connections by ensuring that all communication conforms to the server's version. mysqlprotocolversion: description: - "MySQL protocol version that the virtual server advertises to clients." mysqlserverversion: description: - "MySQL server version string that the virtual server advertises to clients." - "Minimum length = 1" - "Maximum length = 31" mysqlcharacterset: description: - "Character set that the virtual server advertises to clients." mysqlservercapabilities: description: - "Server capabilities that the virtual server advertises to clients." appflowlog: choices: - 'enabled' - 'disabled' description: - "Apply AppFlow logging to the virtual server." netprofile: description: - >- Name of the network profile to associate with the virtual server. If you set this parameter, the virtual server uses only the IP addresses in the network profile as source IP addresses when initiating connections with servers. - "Minimum length = 1" - "Maximum length = 127" icmpvsrresponse: choices: - 'PASSIVE' - 'ACTIVE' description: - >- How the NetScaler appliance responds to ping requests received for an IP address that is common to one or more virtual servers. Available settings function as follows: - >- * If set to C(PASSIVE) on all the virtual servers that share the IP address, the appliance always responds to the ping requests. - >- * If set to C(ACTIVE) on all the virtual servers that share the IP address, the appliance responds to the ping requests if at least one of the virtual servers is UP. Otherwise, the appliance does not respond. - >- * If set to C(ACTIVE) on some virtual servers and PASSIVE on the others, the appliance responds if at least one virtual server with the ACTIVE setting is UP. Otherwise, the appliance does not respond. - >- Note: This parameter is available at the virtual server level. A similar parameter, ICMP Response, is available at the IP address level, for IPv4 addresses of type VIP. To set that parameter, use the add ip command in the CLI or the Create IP dialog box in the GUI. rhistate: choices: - 'PASSIVE' - 'ACTIVE' description: - >- Route Health Injection (RHI) functionality of the NetSaler appliance for advertising the route of the VIP address associated with the virtual server. When Vserver RHI Level (RHI) parameter is set to VSVR_CNTRLD, the following are different RHI behaviors for the VIP address on the basis of RHIstate (RHI STATE) settings on the virtual servers associated with the VIP address: - >- * If you set C(rhistate) to C(PASSIVE) on all virtual servers, the NetScaler ADC always advertises the route for the VIP address. - >- * If you set C(rhistate) to C(ACTIVE) on all virtual servers, the NetScaler ADC advertises the route for the VIP address if at least one of the associated virtual servers is in UP state. - >- * If you set C(rhistate) to C(ACTIVE) on some and PASSIVE on others, the NetScaler ADC advertises the route for the VIP address if at least one of the associated virtual servers, whose C(rhistate) set to C(ACTIVE), is in UP state. newservicerequest: description: - >- Number of requests, or percentage of the load on existing services, by which to increase the load on a new service at each interval in slow-start mode. A non-zero value indicates that slow-start is applicable. A zero value indicates that the global RR startup parameter is applied. Changing the value to zero will cause services currently in slow start to take the full traffic as determined by the LB method. Subsequently, any new services added will use the global RR factor. newservicerequestunit: choices: - 'PER_SECOND' - 'PERCENT' description: - "Units in which to increment load at each interval in slow-start mode." newservicerequestincrementinterval: description: - >- Interval, in seconds, between successive increments in the load on a new service or a service whose state has just changed from DOWN to UP. A value of 0 (zero) specifies manual slow start. - "Minimum value = C(0)" - "Maximum value = C(3600)" minautoscalemembers: description: - "Minimum number of members expected to be present when vserver is used in Autoscale." - "Minimum value = C(0)" - "Maximum value = C(5000)" maxautoscalemembers: description: - "Maximum number of members expected to be present when vserver is used in Autoscale." - "Minimum value = C(0)" - "Maximum value = C(5000)" persistavpno: description: - "Persist AVP number for Diameter Persistency." - "In case this AVP is not defined in Base RFC 3588 and it is nested inside a Grouped AVP," - "define a sequence of AVP numbers (max 3) in order of parent to child. So say persist AVP number X" - "is nested inside AVP Y which is nested in Z, then define the list as Z Y X." - "Minimum value = C(1)" skippersistency: choices: - 'Bypass' - 'ReLb' - 'None' description: - >- This argument decides the behavior incase the service which is selected from an existing persistence session has reached threshold. td: description: - >- Integer value that uniquely identifies the traffic domain in which you want to configure the entity. If you do not specify an ID, the entity becomes part of the default traffic domain, which has an ID of 0. - "Minimum value = C(0)" - "Maximum value = C(4094)" authnprofile: description: - "Name of the authentication profile to be used when authentication is turned on." macmoderetainvlan: choices: - 'enabled' - 'disabled' description: - "This option is used to retain vlan information of incoming packet when macmode is enabled." dbslb: choices: - 'enabled' - 'disabled' description: - "Enable database specific load balancing for MySQL and MSSQL service types." dns64: choices: - 'enabled' - 'disabled' description: - "This argument is for enabling/disabling the C(dns64) on lbvserver." bypassaaaa: description: - >- If this option is enabled while resolving DNS64 query AAAA queries are not sent to back end dns server. type: bool recursionavailable: description: - >- When set to YES, this option causes the DNS replies from this vserver to have the RA bit turned on. Typically one would set this option to YES, when the vserver is load balancing a set of DNS servers thatsupport recursive queries. type: bool processlocal: choices: - 'enabled' - 'disabled' description: - >- By turning on this option packets destined to a vserver in a cluster will not under go any steering. Turn this option for single packet request response mode or when the upstream device is performing a proper RSS for connection based distribution. dnsprofilename: description: - >- Name of the DNS profile to be associated with the VServer. DNS profile properties will be applied to the transactions processed by a VServer. This parameter is valid only for DNS and DNS-TCP VServers. - "Minimum length = 1" - "Maximum length = 127" servicebindings: description: - List of services along with the weights that are load balanced. - The following suboptions are available. suboptions: servicename: description: - "Service to bind to the virtual server." - "Minimum length = 1" weight: description: - "Weight to assign to the specified service." - "Minimum value = C(1)" - "Maximum value = C(100)" servicegroupbindings: description: - List of service groups along with the weights that are load balanced. - The following suboptions are available. suboptions: servicegroupname: description: - "The service group name bound to the selected load balancing virtual server." weight: description: - >- Integer specifying the weight of the service. A larger number specifies a greater weight. Defines the capacity of the service relative to the other services in the load balancing configuration. Determines the priority given to the service in load balancing decisions. - "Minimum value = C(1)" - "Maximum value = C(100)" ssl_certkey: description: - The name of the ssl certificate that is bound to this service. - The ssl certificate must already exist. - Creating the certificate can be done with the M(netscaler_ssl_certkey) module. - This option is only applicable only when C(servicetype) is C(SSL). disabled: description: - When set to C(yes) the lb vserver will be disabled. - When set to C(no) the lb vserver will be enabled. - >- Note that due to limitations of the underlying NITRO API a C(disabled) state change alone does not cause the module result to report a changed status. type: bool default: 'no' extends_documentation_fragment: netscaler requirements: - nitro python sdk ''' EXAMPLES = ''' # Netscaler services service-http-1, service-http-2 must have been already created with the netscaler_service module - name: Create a load balancing vserver bound to services delegate_to: localhost netscaler_lb_vserver: nsip: 172.18.0.2 nitro_user: nsroot nitro_pass: nsroot validate_certs: no state: present name: lb_vserver_1 servicetype: HTTP timeout: 12 ipv46: 6.93.3.3 port: 80 servicebindings: - servicename: service-http-1 weight: 80 - servicename: service-http-2 weight: 20 # Service group service-group-1 must have been already created with the netscaler_servicegroup module - name: Create load balancing vserver bound to servicegroup delegate_to: localhost netscaler_lb_vserver: nsip: 172.18.0.2 nitro_user: nsroot nitro_pass: nsroot validate_certs: no state: present name: lb_vserver_2 servicetype: HTTP ipv46: 6.92.2.2 port: 80 timeout: 10 servicegroupbindings: - servicegroupname: service-group-1 ''' RETURN = ''' loglines: description: list of logged messages by the module returned: always type: list sample: ['message 1', 'message 2'] msg: description: Message detailing the failure reason returned: failure type: str sample: "Action does not exist" diff: description: List of differences between the actual configured object and the configuration specified in the module returned: failure type: dict sample: { 'clttimeout': 'difference. ours: (float) 10.0 other: (float) 20.0' } ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.netscaler.netscaler import ( ConfigProxy, get_nitro_client, netscaler_common_arguments, log, loglines, get_immutables_intersection, ensure_feature_is_enabled ) import copy try: from nssrc.com.citrix.netscaler.nitro.resource.config.lb.lbvserver import lbvserver from nssrc.com.citrix.netscaler.nitro.resource.config.lb.lbvserver_servicegroup_binding import lbvserver_servicegroup_binding from nssrc.com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding import lbvserver_service_binding from nssrc.com.citrix.netscaler.nitro.resource.config.ssl.sslvserver_sslcertkey_binding import sslvserver_sslcertkey_binding from nssrc.com.citrix.netscaler.nitro.exception.nitro_exception import nitro_exception PYTHON_SDK_IMPORTED = True except ImportError as e: IMPORT_ERROR = str(e) PYTHON_SDK_IMPORTED = False def lb_vserver_exists(client, module): log('Checking if lb vserver exists') if lbvserver.count_filtered(client, 'name:%s' % module.params['name']) > 0: return True else: return False def lb_vserver_identical(client, module, lbvserver_proxy): log('Checking if configured lb vserver is identical') lbvserver_list = lbvserver.get_filtered(client, 'name:%s' % module.params['name']) if lbvserver_proxy.has_equal_attributes(lbvserver_list[0]): return True else: return False def lb_vserver_diff(client, module, lbvserver_proxy): lbvserver_list = lbvserver.get_filtered(client, 'name:%s' % module.params['name']) return lbvserver_proxy.diff_object(lbvserver_list[0]) def get_configured_service_bindings(client, module): log('Getting configured service bindings') readwrite_attrs = [ 'weight', 'name', 'servicename', 'servicegroupname' ] readonly_attrs = [ 'preferredlocation', 'vserverid', 'vsvrbindsvcip', 'servicetype', 'cookieipport', 'port', 'vsvrbindsvcport', 'curstate', 'ipv46', 'dynamicweight', ] configured_bindings = {} if 'servicebindings' in module.params and module.params['servicebindings'] is not None: for binding in module.params['servicebindings']: attribute_values_dict = copy.deepcopy(binding) attribute_values_dict['name'] = module.params['name'] key = binding['servicename'].strip() configured_bindings[key] = ConfigProxy( actual=lbvserver_service_binding(), client=client, attribute_values_dict=attribute_values_dict, readwrite_attrs=readwrite_attrs, readonly_attrs=readonly_attrs, ) return configured_bindings def get_configured_servicegroup_bindings(client, module): log('Getting configured service group bindings') readwrite_attrs = [ 'weight', 'name', 'servicename', 'servicegroupname', ] readonly_attrs = [] configured_bindings = {} if 'servicegroupbindings' in module.params and module.params['servicegroupbindings'] is not None: for binding in module.params['servicegroupbindings']: attribute_values_dict = copy.deepcopy(binding) attribute_values_dict['name'] = module.params['name'] key = binding['servicegroupname'].strip() configured_bindings[key] = ConfigProxy( actual=lbvserver_servicegroup_binding(), client=client, attribute_values_dict=attribute_values_dict, readwrite_attrs=readwrite_attrs, readonly_attrs=readonly_attrs, ) return configured_bindings def get_actual_service_bindings(client, module): log('Getting actual service bindings') bindings = {} try: if lbvserver_service_binding.count(client, module.params['name']) == 0: return bindings except nitro_exception as e: if e.errorcode == 258: return bindings else: raise bindigs_list = lbvserver_service_binding.get(client, module.params['name']) for item in bindigs_list: key = item.servicename bindings[key] = item return bindings def get_actual_servicegroup_bindings(client, module): log('Getting actual service group bindings') bindings = {} try: if lbvserver_servicegroup_binding.count(client, module.params['name']) == 0: return bindings except nitro_exception as e: if e.errorcode == 258: return bindings else: raise bindigs_list = lbvserver_servicegroup_binding.get(client, module.params['name']) for item in bindigs_list: key = item.servicegroupname bindings[key] = item return bindings def service_bindings_identical(client, module): log('service_bindings_identical') # Compare service keysets configured_service_bindings = get_configured_service_bindings(client, module) service_bindings = get_actual_service_bindings(client, module) configured_keyset = set(configured_service_bindings.keys()) service_keyset = set(service_bindings.keys()) if len(configured_keyset ^ service_keyset) > 0: return False # Compare service item to item for key in configured_service_bindings.keys(): conf = configured_service_bindings[key] serv = service_bindings[key] log('s diff %s' % conf.diff_object(serv)) if not conf.has_equal_attributes(serv): return False # Fallthrough to success return True def servicegroup_bindings_identical(client, module): log('servicegroup_bindings_identical') # Compare servicegroup keysets configured_servicegroup_bindings = get_configured_servicegroup_bindings(client, module) servicegroup_bindings = get_actual_servicegroup_bindings(client, module) configured_keyset = set(configured_servicegroup_bindings.keys()) service_keyset = set(servicegroup_bindings.keys()) log('len %s' % len(configured_keyset ^ service_keyset)) if len(configured_keyset ^ service_keyset) > 0: return False # Compare servicegroup item to item for key in configured_servicegroup_bindings.keys(): conf = configured_servicegroup_bindings[key] serv = servicegroup_bindings[key] log('sg diff %s' % conf.diff_object(serv)) if not conf.has_equal_attributes(serv): return False # Fallthrough to success return True def sync_service_bindings(client, module): log('sync_service_bindings') actual_bindings = get_actual_service_bindings(client, module) configured_bindigns = get_configured_service_bindings(client, module) # Delete actual but not configured delete_keys = list(set(actual_bindings.keys()) - set(configured_bindigns.keys())) for key in delete_keys: log('Deleting service binding %s' % key) actual_bindings[key].servicegroupname = '' actual_bindings[key].delete(client, actual_bindings[key]) # Add configured but not in actual add_keys = list(set(configured_bindigns.keys()) - set(actual_bindings.keys())) for key in add_keys: log('Adding service binding %s' % key) configured_bindigns[key].add() # Update existing if changed modify_keys = list(set(configured_bindigns.keys()) & set(actual_bindings.keys())) for key in modify_keys: if not configured_bindigns[key].has_equal_attributes(actual_bindings[key]): log('Updating service binding %s' % key) actual_bindings[key].servicegroupname = '' actual_bindings[key].delete(client, actual_bindings[key]) configured_bindigns[key].add() def sync_servicegroup_bindings(client, module): log('sync_servicegroup_bindings') actual_bindings = get_actual_servicegroup_bindings(client, module) configured_bindigns = get_configured_servicegroup_bindings(client, module) # Delete actual but not configured delete_keys = list(set(actual_bindings.keys()) - set(configured_bindigns.keys())) for key in delete_keys: log('Deleting servicegroup binding %s' % key) actual_bindings[key].servicename = None actual_bindings[key].delete(client, actual_bindings[key]) # Add configured but not in actual add_keys = list(set(configured_bindigns.keys()) - set(actual_bindings.keys())) for key in add_keys: log('Adding servicegroup binding %s' % key) configured_bindigns[key].add() # Update existing if changed modify_keys = list(set(configured_bindigns.keys()) & set(actual_bindings.keys())) for key in modify_keys: if not configured_bindigns[key].has_equal_attributes(actual_bindings[key]): log('Updating servicegroup binding %s' % key) actual_bindings[key].servicename = None actual_bindings[key].delete(client, actual_bindings[key]) configured_bindigns[key].add() def ssl_certkey_bindings_identical(client, module): log('Entering ssl_certkey_bindings_identical') vservername = module.params['name'] if sslvserver_sslcertkey_binding.count(client, vservername) == 0: bindings = [] else: bindings = sslvserver_sslcertkey_binding.get(client, vservername) log('Existing certs %s' % bindings) if module.params['ssl_certkey'] is None: if len(bindings) == 0: return True else: return False else: certificate_list = [item.certkeyname for item in bindings] log('certificate_list %s' % certificate_list) if certificate_list == [module.params['ssl_certkey']]: return True else: return False def ssl_certkey_bindings_sync(client, module): log('Syncing ssl certificates') vservername = module.params['name'] if sslvserver_sslcertkey_binding.count(client, vservername) == 0: bindings = [] else: bindings = sslvserver_sslcertkey_binding.get(client, vservername) log('bindings len is %s' % len(bindings)) # Delete existing bindings for binding in bindings: sslvserver_sslcertkey_binding.delete(client, binding) # Add binding if appropriate if module.params['ssl_certkey'] is not None: binding = sslvserver_sslcertkey_binding() binding.vservername = module.params['name'] binding.certkeyname = module.params['ssl_certkey'] sslvserver_sslcertkey_binding.add(client, binding) def do_state_change(client, module, lbvserver_proxy): if module.params['disabled']: log('Disabling lb server') result = lbvserver.disable(client, lbvserver_proxy.actual) else: log('Enabling lb server') result = lbvserver.enable(client, lbvserver_proxy.actual) return result def main(): module_specific_arguments = dict( name=dict(type='str'), servicetype=dict( type='str', choices=[ 'HTTP', 'FTP', 'TCP', 'UDP', 'SSL', 'SSL_BRIDGE', 'SSL_TCP', 'DTLS', 'NNTP', 'DNS', 'DHCPRA', 'ANY', 'SIP_UDP', 'SIP_TCP', 'SIP_SSL', 'DNS_TCP', 'RTSP', 'PUSH', 'SSL_PUSH', 'RADIUS', 'RDP', 'MYSQL', 'MSSQL', 'DIAMETER', 'SSL_DIAMETER', 'TFTP', 'ORACLE', 'SMPP', 'SYSLOGTCP', 'SYSLOGUDP', 'FIX', 'SSL_FIX', ] ), ipv46=dict(type='str'), ippattern=dict(type='str'), ipmask=dict(type='str'), port=dict(type='int'), range=dict(type='float'), persistencetype=dict( type='str', choices=[ 'SOURCEIP', 'COOKIEINSERT', 'SSLSESSION', 'RULE', 'URLPASSIVE', 'CUSTOMSERVERID', 'DESTIP', 'SRCIPDESTIP', 'CALLID', 'RTSPSID', 'DIAMETER', 'FIXSESSION', 'NONE', ] ), timeout=dict(type='float'), persistencebackup=dict( type='str', choices=[ 'SOURCEIP', 'NONE', ] ), backuppersistencetimeout=dict(type='float'), lbmethod=dict( type='str', choices=[ 'ROUNDROBIN', 'LEASTCONNECTION', 'LEASTRESPONSETIME', 'URLHASH', 'DOMAINHASH', 'DESTINATIONIPHASH', 'SOURCEIPHASH', 'SRCIPDESTIPHASH', 'LEASTBANDWIDTH', 'LEASTPACKETS', 'TOKEN', 'SRCIPSRCPORTHASH', 'LRTM', 'CALLIDHASH', 'CUSTOMLOAD', 'LEASTREQUEST', 'AUDITLOGHASH', 'STATICPROXIMITY', ] ), hashlength=dict(type='float'), netmask=dict(type='str'), v6netmasklen=dict(type='float'), backuplbmethod=dict( type='str', choices=[ 'ROUNDROBIN', 'LEASTCONNECTION', 'LEASTRESPONSETIME', 'SOURCEIPHASH', 'LEASTBANDWIDTH', 'LEASTPACKETS', 'CUSTOMLOAD', ] ), cookiename=dict(type='str'), listenpolicy=dict(type='str'), listenpriority=dict(type='float'), persistmask=dict(type='str'), v6persistmasklen=dict(type='float'), rtspnat=dict(type='bool'), m=dict( type='str', choices=[ 'IP', 'MAC', 'IPTUNNEL', 'TOS', ] ), tosid=dict(type='float'), datalength=dict(type='float'), dataoffset=dict(type='float'), sessionless=dict( type='str', choices=[ 'enabled', 'disabled', ] ), connfailover=dict( type='str', choices=[ 'DISABLED', 'STATEFUL', 'STATELESS', ] ), redirurl=dict(type='str'), cacheable=dict(type='bool'), clttimeout=dict(type='float'), somethod=dict( type='str', choices=[ 'CONNECTION', 'DYNAMICCONNECTION', 'BANDWIDTH', 'HEALTH', 'NONE', ] ), sopersistence=dict( type='str', choices=[ 'enabled', 'disabled', ] ), sopersistencetimeout=dict(type='float'), healththreshold=dict(type='float'), sothreshold=dict(type='float'), sobackupaction=dict( type='str', choices=[ 'DROP', 'ACCEPT', 'REDIRECT', ] ), redirectportrewrite=dict( type='str', choices=[ 'enabled', 'disabled', ] ), downstateflush=dict( type='str', choices=[ 'enabled', 'disabled', ] ), disableprimaryondown=dict( type='str', choices=[ 'enabled', 'disabled', ] ), insertvserveripport=dict( type='str', choices=[ 'OFF', 'VIPADDR', 'V6TOV4MAPPING', ] ), vipheader=dict(type='str'), authenticationhost=dict(type='str'), authentication=dict(type='bool'), authn401=dict(type='bool'), authnvsname=dict(type='str'), push=dict( type='str', choices=[ 'enabled', 'disabled', ] ), pushvserver=dict(type='str'), pushlabel=dict(type='str'), pushmulticlients=dict(type='bool'), tcpprofilename=dict(type='str'), httpprofilename=dict(type='str'), dbprofilename=dict(type='str'), comment=dict(type='str'), l2conn=dict(type='bool'), oracleserverversion=dict( type='str', choices=[ '10G', '11G', ] ), mssqlserverversion=dict( type='str', choices=[ '70', '2000', '2000SP1', '2005', '2008', '2008R2', '2012', '2014', ] ), mysqlprotocolversion=dict(type='float'), mysqlserverversion=dict(type='str'), mysqlcharacterset=dict(type='float'), mysqlservercapabilities=dict(type='float'), appflowlog=dict( type='str', choices=[ 'enabled', 'disabled', ] ), netprofile=dict(type='str'), icmpvsrresponse=dict( type='str', choices=[ 'PASSIVE', 'ACTIVE', ] ), rhistate=dict( type='str', choices=[ 'PASSIVE', 'ACTIVE', ] ), newservicerequest=dict(type='float'), newservicerequestunit=dict( type='str', choices=[ 'PER_SECOND', 'PERCENT', ] ), newservicerequestincrementinterval=dict(type='float'), minautoscalemembers=dict(type='float'), maxautoscalemembers=dict(type='float'), skippersistency=dict( type='str', choices=[ 'Bypass', 'ReLb', 'None', ] ), authnprofile=dict(type='str'), macmoderetainvlan=dict( type='str', choices=[ 'enabled', 'disabled', ] ), dbslb=dict( type='str', choices=[ 'enabled', 'disabled', ] ), dns64=dict( type='str', choices=[ 'enabled', 'disabled', ] ), bypassaaaa=dict(type='bool'), recursionavailable=dict(type='bool'), processlocal=dict( type='str', choices=[ 'enabled', 'disabled', ] ), dnsprofilename=dict(type='str'), ) hand_inserted_arguments = dict( servicebindings=dict(type='list'), servicegroupbindings=dict(type='list'), ssl_certkey=dict(type='str'), disabled=dict( type='bool', default=False ), ) argument_spec = dict() argument_spec.update(netscaler_common_arguments) argument_spec.update(module_specific_arguments) argument_spec.update(hand_inserted_arguments) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, ) module_result = dict( changed=False, failed=False, loglines=loglines, ) # Fail the module if imports failed if not PYTHON_SDK_IMPORTED: module.fail_json(msg='Could not load nitro python sdk') # Fallthrough to rest of execution client = get_nitro_client(module) try: client.login() except nitro_exception as e: msg = "nitro exception during login. errorcode=%s, message=%s" % (str(e.errorcode), e.message) module.fail_json(msg=msg) except Exception as e: if str(type(e)) == "<class 'requests.exceptions.ConnectionError'>": module.fail_json(msg='Connection error %s' % str(e)) elif str(type(e)) == "<class 'requests.exceptions.SSLError'>": module.fail_json(msg='SSL Error %s' % str(e)) else: module.fail_json(msg='Unexpected error during login %s' % str(e)) readwrite_attrs = [ 'name', 'servicetype', 'ipv46', 'ippattern', 'ipmask', 'port', 'range', 'persistencetype', 'timeout', 'persistencebackup', 'backuppersistencetimeout', 'lbmethod', 'hashlength', 'netmask', 'v6netmasklen', 'backuplbmethod', 'cookiename', 'listenpolicy', 'listenpriority', 'persistmask', 'v6persistmasklen', 'rtspnat', 'm', 'tosid', 'datalength', 'dataoffset', 'sessionless', 'connfailover', 'redirurl', 'cacheable', 'clttimeout', 'somethod', 'sopersistence', 'sopersistencetimeout', 'healththreshold', 'sothreshold', 'sobackupaction', 'redirectportrewrite', 'downstateflush', 'disableprimaryondown', 'insertvserveripport', 'vipheader', 'authenticationhost', 'authentication', 'authn401', 'authnvsname', 'push', 'pushvserver', 'pushlabel', 'pushmulticlients', 'tcpprofilename', 'httpprofilename', 'dbprofilename', 'comment', 'l2conn', 'oracleserverversion', 'mssqlserverversion', 'mysqlprotocolversion', 'mysqlserverversion', 'mysqlcharacterset', 'mysqlservercapabilities', 'appflowlog', 'netprofile', 'icmpvsrresponse', 'rhistate', 'newservicerequest', 'newservicerequestunit', 'newservicerequestincrementinterval', 'minautoscalemembers', 'maxautoscalemembers', 'skippersistency', 'authnprofile', 'macmoderetainvlan', 'dbslb', 'dns64', 'bypassaaaa', 'recursionavailable', 'processlocal', 'dnsprofilename', ] readonly_attrs = [ 'value', 'ipmapping', 'ngname', 'type', 'curstate', 'effectivestate', 'status', 'lbrrreason', 'redirect', 'precedence', 'homepage', 'dnsvservername', 'domain', 'policyname', 'cachevserver', 'health', 'gotopriorityexpression', 'ruletype', 'groupname', 'cookiedomain', 'map', 'gt2gb', 'consolidatedlconn', 'consolidatedlconngbl', 'thresholdvalue', 'bindpoint', 'invoke', 'labeltype', 'labelname', 'version', 'totalservices', 'activeservices', 'statechangetimesec', 'statechangetimeseconds', 'statechangetimemsec', 'tickssincelaststatechange', 'isgslb', 'vsvrdynconnsothreshold', 'backupvserverstatus', '__count', ] immutable_attrs = [ 'name', 'servicetype', 'ipv46', 'port', 'range', 'state', 'redirurl', 'vipheader', 'newservicerequestunit', 'td', ] transforms = { 'rtspnat': ['bool_on_off'], 'authn401': ['bool_on_off'], 'bypassaaaa': ['bool_yes_no'], 'authentication': ['bool_on_off'], 'cacheable': ['bool_yes_no'], 'l2conn': ['bool_on_off'], 'pushmulticlients': ['bool_yes_no'], 'recursionavailable': ['bool_yes_no'], 'sessionless': [lambda v: v.upper()], 'sopersistence': [lambda v: v.upper()], 'redirectportrewrite': [lambda v: v.upper()], 'downstateflush': [lambda v: v.upper()], 'disableprimaryondown': [lambda v: v.upper()], 'push': [lambda v: v.upper()], 'appflowlog': [lambda v: v.upper()], 'macmoderetainvlan': [lambda v: v.upper()], 'dbslb': [lambda v: v.upper()], 'dns64': [lambda v: v.upper()], 'processlocal': [lambda v: v.upper()], } lbvserver_proxy = ConfigProxy( actual=lbvserver(), client=client, attribute_values_dict=module.params, readwrite_attrs=readwrite_attrs, readonly_attrs=readonly_attrs, immutable_attrs=immutable_attrs, transforms=transforms, ) try: ensure_feature_is_enabled(client, 'LB') if module.params['state'] == 'present': log('Applying actions for state present') if not lb_vserver_exists(client, module): log('Add lb vserver') if not module.check_mode: lbvserver_proxy.add() if module.params['save_config']: client.save_config() module_result['changed'] = True elif not lb_vserver_identical(client, module, lbvserver_proxy): # Check if we try to change value of immutable attributes diff_dict = lb_vserver_diff(client, module, lbvserver_proxy) immutables_changed = get_immutables_intersection(lbvserver_proxy, diff_dict.keys()) if immutables_changed != []: msg = 'Cannot update immutable attributes %s. Must delete and recreate entity.' % (immutables_changed,) module.fail_json(msg=msg, diff=diff_dict, **module_result) log('Update lb vserver') if not module.check_mode: lbvserver_proxy.update() if module.params['save_config']: client.save_config() module_result['changed'] = True else: log('Present noop') if not service_bindings_identical(client, module): if not module.check_mode: sync_service_bindings(client, module) if module.params['save_config']: client.save_config() module_result['changed'] = True if not servicegroup_bindings_identical(client, module): if not module.check_mode: sync_servicegroup_bindings(client, module) if module.params['save_config']: client.save_config() module_result['changed'] = True if module.params['servicetype'] != 'SSL' and module.params['ssl_certkey'] is not None: module.fail_json(msg='ssl_certkey is applicable only to SSL vservers', **module_result) # Check if SSL certkey is sane if module.params['servicetype'] == 'SSL': if not ssl_certkey_bindings_identical(client, module): if not module.check_mode: ssl_certkey_bindings_sync(client, module) module_result['changed'] = True if not module.check_mode: res = do_state_change(client, module, lbvserver_proxy) if res.errorcode != 0: msg = 'Error when setting disabled state. errorcode: %s message: %s' % (res.errorcode, res.message) module.fail_json(msg=msg, **module_result) # Sanity check log('Sanity checks for state present') if not module.check_mode: if not lb_vserver_exists(client, module): module.fail_json(msg='Did not create lb vserver', **module_result) if not lb_vserver_identical(client, module, lbvserver_proxy): msg = 'lb vserver is not configured correctly' module.fail_json(msg=msg, diff=lb_vserver_diff(client, module, lbvserver_proxy), **module_result) if not service_bindings_identical(client, module): module.fail_json(msg='service bindings are not identical', **module_result) if not servicegroup_bindings_identical(client, module): module.fail_json(msg='servicegroup bindings are not identical', **module_result) if module.params['servicetype'] == 'SSL': if not ssl_certkey_bindings_identical(client, module): module.fail_json(msg='sll certkey bindings not identical', **module_result) elif module.params['state'] == 'absent': log('Applying actions for state absent') if lb_vserver_exists(client, module): if not module.check_mode: log('Delete lb vserver') lbvserver_proxy.delete() if module.params['save_config']: client.save_config() module_result['changed'] = True else: log('Absent noop') module_result['changed'] = False # Sanity check log('Sanity checks for state absent') if not module.check_mode: if lb_vserver_exists(client, module): module.fail_json(msg='lb vserver still exists', **module_result) except nitro_exception as e: msg = "nitro exception errorcode=%s, message=%s" % (str(e.errorcode), e.message) module.fail_json(msg=msg, **module_result) client.logout() module.exit_json(**module_result) if __name__ == "__main__": main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 221, 1898, 334, 67, 9, 9708, 445, 390, 1904, 15285, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 26067, 63, 6374, 63, 16120, 199, 3612, 63, 1802, 26, 14944, 2248, 29300, 32398, 2897, 199, 1802, 26, 272, 446, 14944, 2248, 29300, 32398, 2897, 272, 446, 961, 859, 365, 11619, 370, 1255, 1902, 641, 314, 3242, 221, 3304, 1031, 503, 282, 330, 1810, 1636, 334, 11126, 1000, 9, 543, 2879, 370, 314, 3503, 26067, 1256, 199, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 199, 2502, 26, 5346, 24591, 653, 16625, 320, 555, 85, 11560, 8593, 6153, 1308, 736, 13, 78, 16625, 320, 555, 85, 11560, 9, 199, 199, 1419, 26, 339, 536, 26, 267, 1369, 26, 288, 446, 690, 13, 355, 2812, 367, 314, 5791, 1654, 14, 9498, 5386, 543, 376, 10485, 27964, 503, 18888, 445, 1547, 9, 4528, 12, 436, 355, 1471, 1395, 1454, 10485, 27964, 12, 18888, 12, 2631, 445, 27496, 395, 6247, 445, 13417, 395, 4601, 445, 8, 2318, 18307, 445, 8, 26, 395, 737, 2070, 355, 445, 8, 32, 395, 4472, 2070, 445, 8, 29, 395, 436, 7188, 17579, 445, 2801, 9, 4110, 14, 6855, 506, 2896, 2410, 314, 5791, 1654, 365, 2737, 14, 288, 446, 298, 12092, 2582, 275, 413, 2, 339, 2435, 466, 26, 267, 3415, 26, 288, 446, 283, 2856, 7, 288, 446, 283, 15123, 7, 288, 446, 283, 9735, 7, 288, 446, 283, 17457, 7, 288, 446, 283, 5413, 7, 288, 446, 283, 5413, 63, 7184, 998, 4962, 7, 288, 446, 283, 5413, 63, 9735, 7, 288, 446, 283, 7438, 5296, 7, 288, 446, 283, 7178, 6495, 7, 288, 446, 283, 12323, 7, 288, 446, 283, 29977, 2847, 7, 288, 446, 283, 8974, 7, 288, 446, 283, 51, 1772, 63, 17457, 7, 288, 446, 283, 51, 1772, 63, 9735, 7, 288, 446, 283, 51, 1772, 63, 5413, 7, 288, 446, 283, 12323, 63, 9735, 7, 288, 446, 283, 11876, 5763, 7, 288, 446, 283, 21378, 7, 288, 446, 283, 5413, 63, 21378, 7, 288, 446, 283, 19662, 30373, 7, 288, 446, 283, 50, 11741, 7, 288, 446, 283, 12339, 4657, 7, 288, 446, 283, 45, 2300, 2940, 7, 288, 446, 283, 1914, 1156, 775, 540, 7, 288, 446, 283, 5413, 63, 1914, 1156, 775, 540, 7, 288, 446, 283, 52, 15123, 7, 288, 446, 283, 726, 1348, 906, 7, 288, 446, 283, 51, 1658, 48, 7, 288, 446, 283, 13326, 4947, 9735, 7, 288, 446, 283, 13326, 4947, 17457, 7, 288, 446, 283, 5192, 7, 288, 446, 283, 5413, 63, 5192, 7, 267, 1369, 26, 288, 446, 298, 3658, 1202, 701, 314, 2435, 334, 12344, 2797, 314, 2435, 730, 17617, 339, 3278, 2466, 26, 267, 1369, 26, 288, 446, 298, 12179, 20, 503, 6509, 22, 2287, 370, 5090, 370, 314, 5791, 1654, 2122, 339, 284, 802, 2134, 26, 267, 1369, 26, 288, 446, 690, 13, 355, 3531, 2287, 3851, 12, 315, 18947, 6107, 15843, 12, 367, 21119, 14593, 370, 506, 10226, 701, 314, 5791, 355, 1654, 14, 710, 3531, 17581, 2725, 9314, 1314, 1777, 402, 314, 5724, 3531, 2287, 365, 7838, 6169, 355, 314, 3851, 14, 26550, 3163, 13914, 543, 314, 3531, 9906, 2725, 14, 288, 446, 690, 13, 355, 2104, 2893, 12, 340, 314, 3531, 3851, 7943, 370, 314, 5791, 1654, 365, 445, 8, 10905, 14, 2869, 14, 1960, 14, 16, 9, 436, 314, 3531, 3656, 365, 355, 445, 8, 2299, 14, 2299, 14, 9873, 14, 16, 9, 334, 65, 7568, 3656, 395, 314, 1642, 3388, 5821, 315, 314, 5724, 3531, 7149, 787, 7838, 543, 355, 314, 1642, 3388, 5821, 315, 314, 3851, 14, 710, 5791, 1654, 11479, 4145, 543, 3531, 7149, 626, 1425, 355, 687, 445, 8, 10905, 14, 2869, 14, 2534, 14, 17, 9, 370, 445, 8, 10905, 14, 2869, 14, 6673, 14, 8306, 680, 2047, 883, 2597, 675, 282, 3851, 4066, 465, 445, 8, 16, 14, 16, 14, 18, 14, 18, 9, 436, 282, 3656, 4066, 465, 355, 445, 8, 16, 14, 16, 14, 2299, 14, 2299, 9, 334, 65, 3837, 3656, 680, 288, 446, 690, 13, 355, 982, 282, 5724, 3531, 2287, 4450, 1655, 2419, 1373, 3531, 3851, 12, 314, 3851, 543, 314, 21303, 1336, 365, 355, 4895, 12, 436, 314, 4568, 5791, 1654, 10358, 314, 1056, 14, 2104, 2893, 12, 340, 5791, 8037, 355, 445, 8, 3122, 17, 9, 436, 445, 8, 3122, 18, 9, 1172, 314, 2011, 3531, 3851, 12, 445, 8, 16, 14, 16, 14, 1960, 14, 3933, 395, 1325, 3365, 3531, 27996, 402, 445, 8, 16, 14, 16, 14, 2299, 14, 2299, 9, 436, 355, 445, 8, 16, 14, 16, 14, 8731, 14, 2299, 395, 282, 5724, 3531, 2287, 402, 445, 8, 10905, 14, 2869, 14, 1960, 14, 3933, 9, 965, 314, 21303, 1336, 543, 314, 3531, 3851, 402, 355, 8118, 17, 14, 982, 282, 5724, 3531, 2287, 4450, 2877, 503, 1655, 5791, 8037, 370, 314, 2011, 13675, 12, 314, 1056, 355, 365, 7686, 701, 314, 5791, 1654, 7447, 1844, 1329, 4450, 314, 1844, 1329, 315, 314, 1056, 14, 339, 3384, 2629, 26, 267, 1369, 26, 288, 446, 690, 13, 355, 3531, 3656, 12, 315, 18947, 6107, 15843, 12, 367, 314, 3531, 27019, 2725, 14, 6855, 1172, 9186, 503, 8520, 355, 2222, 13, 4262, 27135, 334, 509, 2893, 12, 445, 8, 2299, 14, 2299, 14, 9873, 14, 16, 9, 503, 445, 8, 16, 14, 16, 14, 2299, 14, 2299, 4992, 31970, 590, 12, 314, 3656, 9314, 3775, 355, 314, 1642, 302, 5821, 503, 314, 2061, 302, 5821, 402, 314, 5724, 3531, 2287, 315, 282, 1890, 1056, 787 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 221, 1898, 334, 67, 9, 9708, 445, 390, 1904, 15285, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 26067, 63, 6374, 63, 16120, 199, 3612, 63, 1802, 26, 14944, 2248, 29300, 32398, 2897, 199, 1802, 26, 272, 446, 14944, 2248, 29300, 32398, 2897, 272, 446, 961, 859, 365, 11619, 370, 1255, 1902, 641, 314, 3242, 221, 3304, 1031, 503, 282, 330, 1810, 1636, 334, 11126, 1000, 9, 543, 2879, 370, 314, 3503, 26067, 1256, 199, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 199, 2502, 26, 5346, 24591, 653, 16625, 320, 555, 85, 11560, 8593, 6153, 1308, 736, 13, 78, 16625, 320, 555, 85, 11560, 9, 199, 199, 1419, 26, 339, 536, 26, 267, 1369, 26, 288, 446, 690, 13, 355, 2812, 367, 314, 5791, 1654, 14, 9498, 5386, 543, 376, 10485, 27964, 503, 18888, 445, 1547, 9, 4528, 12, 436, 355, 1471, 1395, 1454, 10485, 27964, 12, 18888, 12, 2631, 445, 27496, 395, 6247, 445, 13417, 395, 4601, 445, 8, 2318, 18307, 445, 8, 26, 395, 737, 2070, 355, 445, 8, 32, 395, 4472, 2070, 445, 8, 29, 395, 436, 7188, 17579, 445, 2801, 9, 4110, 14, 6855, 506, 2896, 2410, 314, 5791, 1654, 365, 2737, 14, 288, 446, 298, 12092, 2582, 275, 413, 2, 339, 2435, 466, 26, 267, 3415, 26, 288, 446, 283, 2856, 7, 288, 446, 283, 15123, 7, 288, 446, 283, 9735, 7, 288, 446, 283, 17457, 7, 288, 446, 283, 5413, 7, 288, 446, 283, 5413, 63, 7184, 998, 4962, 7, 288, 446, 283, 5413, 63, 9735, 7, 288, 446, 283, 7438, 5296, 7, 288, 446, 283, 7178, 6495, 7, 288, 446, 283, 12323, 7, 288, 446, 283, 29977, 2847, 7, 288, 446, 283, 8974, 7, 288, 446, 283, 51, 1772, 63, 17457, 7, 288, 446, 283, 51, 1772, 63, 9735, 7, 288, 446, 283, 51, 1772, 63, 5413, 7, 288, 446, 283, 12323, 63, 9735, 7, 288, 446, 283, 11876, 5763, 7, 288, 446, 283, 21378, 7, 288, 446, 283, 5413, 63, 21378, 7, 288, 446, 283, 19662, 30373, 7, 288, 446, 283, 50, 11741, 7, 288, 446, 283, 12339, 4657, 7, 288, 446, 283, 45, 2300, 2940, 7, 288, 446, 283, 1914, 1156, 775, 540, 7, 288, 446, 283, 5413, 63, 1914, 1156, 775, 540, 7, 288, 446, 283, 52, 15123, 7, 288, 446, 283, 726, 1348, 906, 7, 288, 446, 283, 51, 1658, 48, 7, 288, 446, 283, 13326, 4947, 9735, 7, 288, 446, 283, 13326, 4947, 17457, 7, 288, 446, 283, 5192, 7, 288, 446, 283, 5413, 63, 5192, 7, 267, 1369, 26, 288, 446, 298, 3658, 1202, 701, 314, 2435, 334, 12344, 2797, 314, 2435, 730, 17617, 339, 3278, 2466, 26, 267, 1369, 26, 288, 446, 298, 12179, 20, 503, 6509, 22, 2287, 370, 5090, 370, 314, 5791, 1654, 2122, 339, 284, 802, 2134, 26, 267, 1369, 26, 288, 446, 690, 13, 355, 3531, 2287, 3851, 12, 315, 18947, 6107, 15843, 12, 367, 21119, 14593, 370, 506, 10226, 701, 314, 5791, 355, 1654, 14, 710, 3531, 17581, 2725, 9314, 1314, 1777, 402, 314, 5724, 3531, 2287, 365, 7838, 6169, 355, 314, 3851, 14, 26550, 3163, 13914, 543, 314, 3531, 9906, 2725, 14, 288, 446, 690, 13, 355, 2104, 2893, 12, 340, 314, 3531, 3851, 7943, 370, 314, 5791, 1654, 365, 445, 8, 10905, 14, 2869, 14, 1960, 14, 16, 9, 436, 314, 3531, 3656, 365, 355, 445, 8, 2299, 14, 2299, 14, 9873, 14, 16, 9, 334, 65, 7568, 3656, 395, 314, 1642, 3388, 5821, 315, 314, 5724, 3531, 7149, 787, 7838, 543, 355, 314, 1642, 3388, 5821, 315, 314, 3851, 14, 710, 5791, 1654, 11479, 4145, 543, 3531, 7149, 626, 1425, 355, 687, 445, 8, 10905, 14, 2869, 14, 2534, 14, 17, 9, 370, 445, 8, 10905, 14, 2869, 14, 6673, 14, 8306, 680, 2047, 883, 2597, 675, 282, 3851, 4066, 465, 445, 8, 16, 14, 16, 14, 18, 14, 18, 9, 436, 282, 3656, 4066, 465, 355, 445, 8, 16, 14, 16, 14, 2299, 14, 2299, 9, 334, 65, 3837, 3656, 680, 288, 446, 690, 13, 355, 982, 282, 5724, 3531, 2287, 4450, 1655, 2419, 1373, 3531, 3851, 12, 314, 3851, 543, 314, 21303, 1336, 365, 355, 4895, 12, 436, 314, 4568, 5791, 1654, 10358, 314, 1056, 14, 2104, 2893, 12, 340, 5791, 8037, 355, 445, 8, 3122, 17, 9, 436, 445, 8, 3122, 18, 9, 1172, 314, 2011, 3531, 3851, 12, 445, 8, 16, 14, 16, 14, 1960, 14, 3933, 395, 1325, 3365, 3531, 27996, 402, 445, 8, 16, 14, 16, 14, 2299, 14, 2299, 9, 436, 355, 445, 8, 16, 14, 16, 14, 8731, 14, 2299, 395, 282, 5724, 3531, 2287, 402, 445, 8, 10905, 14, 2869, 14, 1960, 14, 3933, 9, 965, 314, 21303, 1336, 543, 314, 3531, 3851, 402, 355, 8118, 17, 14, 982, 282, 5724, 3531, 2287, 4450, 2877, 503, 1655, 5791, 8037, 370, 314, 2011, 13675, 12, 314, 1056, 355, 365, 7686, 701, 314, 5791, 1654, 7447, 1844, 1329, 4450, 314, 1844, 1329, 315, 314, 1056, 14, 339, 3384, 2629, 26, 267, 1369, 26, 288, 446, 690, 13, 355, 3531, 3656, 12, 315, 18947, 6107, 15843, 12, 367, 314, 3531, 27019, 2725, 14, 6855, 1172, 9186, 503, 8520, 355, 2222, 13, 4262, 27135, 334, 509, 2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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 ]
kingvuplus/nn-gui
lib/python/Components/GUISkin.py
58
3172
from GUIComponent import GUIComponent from skin import applyAllAttributes from Tools.CList import CList from Sources.StaticText import StaticText class GUISkin: __module__ = __name__ def __init__(self): self["Title"] = StaticText() self.onLayoutFinish = [ ] self.summaries = CList() self.instance = None self.desktop = None def createGUIScreen(self, parent, desktop, updateonly = False): for val in self.renderer: if isinstance(val, GUIComponent): if not updateonly: val.GUIcreate(parent) if not val.applySkin(desktop, self): print "warning, skin is missing renderer", val, "in", self for key in self: val = self[key] if isinstance(val, GUIComponent): if not updateonly: val.GUIcreate(parent) depr = val.deprecationInfo if val.applySkin(desktop, self): if depr: print "WARNING: OBSOLETE COMPONENT '%s' USED IN SKIN. USE '%s' INSTEAD!" % (key, depr[0]) print "OBSOLETE COMPONENT WILL BE REMOVED %s, PLEASE UPDATE!" % (depr[1]) elif not depr: print "warning, skin is missing element", key, "in", self for w in self.additionalWidgets: if not updateonly: w.instance = w.widget(parent) # w.instance.thisown = 0 applyAllAttributes(w.instance, desktop, w.skinAttributes, self.scale) for f in self.onLayoutFinish: if type(f) is not type(self.close): # is this the best way to do this? exec(f) in globals(), locals() else: f() def deleteGUIScreen(self): for (name, val) in self.items(): if isinstance(val, GUIComponent): val.GUIdelete() def close(self): self.deleteGUIScreen() def createSummary(self): return None def addSummary(self, summary): self.summaries.append(summary) def removeSummary(self, summary): self.summaries.remove(summary) def setTitle(self, title): if self.instance: self.instance.setTitle(title) self["Title"].text = title self.summaries.setTitle(title) def getTitle(self): return self["Title"].text title = property(getTitle, setTitle) def setDesktop(self, desktop): self.desktop = desktop def applySkin(self): z = 0 baseres = (720, 576) # FIXME: a skin might have set another resolution, which should be the base res idx = 0 skin_title_idx = -1 title = self.title for (key, value) in self.skinAttributes: if key == "zPosition": z = int(value) elif key == "title": skin_title_idx = idx if title: self.skinAttributes[skin_title_idx] = ("title", title) else: self["Title"].text = value self.summaries.setTitle(value) elif key == "baseResolution": baseres = tuple([int(x) for x in value.split(',')]) idx += 1 self.scale = ((baseres[0], baseres[0]), (baseres[1], baseres[1])) if not self.instance: from enigma import eWindow self.instance = eWindow(self.desktop, z) if skin_title_idx == -1 and title: self.skinAttributes.append(("title", title)) # we need to make sure that certain attributes come last self.skinAttributes.sort(key=lambda a: {"position": 1}.get(a[0], 0)) applyAllAttributes(self.instance, self.desktop, self.skinAttributes, self.scale) self.createGUIScreen(self.instance, self.desktop)
gpl-2.0
[ 504, 598, 53, 948, 22527, 1946, 492, 598, 53, 948, 22527, 1946, 199, 504, 28337, 492, 4838, 2422, 5379, 199, 504, 23228, 14, 35, 1296, 492, 445, 1296, 199, 504, 5800, 83, 14, 25289, 492, 13599, 1872, 199, 199, 533, 598, 53, 1311, 19269, 26, 199, 198, 363, 578, 363, 275, 636, 354, 363, 421, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 905, 6888, 937, 275, 13599, 1872, 342, 507, 198, 277, 14, 265, 4798, 22084, 275, 359, 1622, 507, 198, 277, 14, 19883, 275, 445, 1296, 342, 507, 198, 277, 14, 842, 275, 488, 507, 198, 277, 14, 14487, 275, 488, 421, 198, 318, 1218, 17188, 1311, 4463, 8, 277, 12, 1676, 12, 19763, 12, 1678, 2118, 275, 756, 304, 507, 198, 509, 1139, 315, 291, 14, 12471, 26, 686, 198, 692, 1228, 8, 637, 12, 598, 53, 948, 22527, 1946, 304, 1585, 198, 692, 440, 1678, 2118, 26, 1871, 198, 637, 14, 14438, 981, 8, 1708, 9, 1585, 198, 692, 440, 1139, 14, 4998, 14194, 262, 8, 14487, 12, 291, 304, 1871, 198, 1361, 298, 3764, 12, 28337, 365, 4124, 11889, 401, 1139, 12, 298, 262, 401, 291, 2742, 198, 509, 790, 315, 291, 26, 686, 198, 637, 275, 291, 59, 498, 61, 686, 198, 692, 1228, 8, 637, 12, 598, 53, 948, 22527, 1946, 304, 1585, 198, 692, 440, 1678, 2118, 26, 1871, 198, 637, 14, 14438, 981, 8, 1708, 9, 1585, 198, 2601, 82, 275, 1139, 14, 15383, 2354, 1585, 198, 692, 1139, 14, 4998, 14194, 262, 8, 14487, 12, 291, 304, 1871, 198, 692, 2657, 82, 26, 4671, 198, 1361, 298, 9171, 26, 593, 11087, 2228, 5248, 16503, 17877, 1543, 83, 7, 4815, 36, 1621, 20062, 568, 14, 4815, 1543, 83, 7, 20514, 37, 1554, 9539, 450, 334, 498, 12, 2657, 82, 59, 16, 566, 4671, 198, 1361, 298, 5488, 15096, 5248, 16503, 17877, 644, 14961, 6262, 5363, 2679, 14112, 450, 83, 12, 510, 17177, 17148, 9539, 450, 334, 2601, 82, 59, 17, 566, 1585, 198, 4164, 440, 2657, 82, 26, 1871, 198, 1361, 298, 3764, 12, 28337, 365, 4124, 1819, 401, 790, 12, 298, 262, 401, 291, 2742, 198, 509, 336, 315, 291, 14, 8460, 12462, 26, 686, 198, 692, 440, 1678, 2118, 26, 1585, 198, 87, 14, 842, 275, 336, 14, 3440, 8, 1708, 9, 1585, 198, 3, 336, 14, 842, 14, 3749, 944, 275, 378, 686, 198, 4998, 2422, 5379, 8, 87, 14, 842, 12, 19763, 12, 336, 14, 16409, 5379, 12, 291, 14, 3467, 9, 2742, 198, 509, 289, 315, 291, 14, 265, 4798, 22084, 26, 686, 198, 692, 730, 8, 70, 9, 365, 440, 730, 8, 277, 14, 1600, 304, 327, 365, 642, 314, 5526, 4340, 370, 886, 642, 31, 1585, 198, 1628, 8, 70, 9, 315, 7992, 1062, 9480, 342, 686, 198, 2836, 26, 1585, 198, 70, 342, 421, 198, 318, 3145, 17188, 1311, 4463, 8, 277, 304, 507, 198, 509, 334, 354, 12, 1139, 9, 315, 291, 14, 1744, 837, 686, 198, 692, 1228, 8, 637, 12, 598, 53, 948, 22527, 1946, 304, 1585, 198, 637, 14, 14438, 1807, 342, 421, 198, 318, 4002, 8, 277, 304, 507, 198, 277, 14, 1807, 17188, 1311, 4463, 342, 421, 198, 318, 1218, 10407, 8, 277, 304, 507, 198, 1107, 488, 421, 198, 318, 1050, 10407, 8, 277, 12, 6212, 304, 507, 198, 277, 14, 19883, 14, 740, 8, 4705, 9, 421, 198, 318, 2813, 10407, 8, 277, 12, 6212, 304, 507, 198, 277, 14, 19883, 14, 2168, 8, 4705, 9, 421, 198, 318, 663, 6888, 8, 277, 12, 2538, 304, 507, 198, 692, 291, 14, 842, 26, 686, 198, 277, 14, 842, 14, 31675, 8, 1213, 9, 507, 198, 277, 905, 6888, 4140, 505, 275, 2538, 507, 198, 277, 14, 19883, 14, 31675, 8, 1213, 9, 421, 198, 318, 664, 6888, 8, 277, 304, 507, 198, 1107, 291, 905, 6888, 4140, 505, 421, 198, 1213, 275, 3324, 8, 362, 6888, 12, 663, 6888, 9, 421, 198, 318, 663, 20436, 8, 277, 12, 19763, 304, 507, 198, 277, 14, 14487, 275, 19763, 421, 198, 318, 4838, 14194, 262, 8, 277, 304, 507, 198, 90, 275, 378, 507, 198, 1095, 470, 275, 334, 18386, 12, 959, 2114, 9, 327, 7600, 26, 282, 28337, 5594, 1172, 663, 4573, 12401, 12, 1314, 1077, 506, 314, 1300, 522, 507, 198, 2996, 275, 378, 507, 198, 16409, 63, 1213, 63, 2996, 275, 446, 17, 507, 198, 1213, 275, 291, 14, 1213, 507, 198, 509, 334, 498, 12, 574, 9, 315, 291, 14, 16409, 5379, 26, 686, 198, 692, 790, 508, 298, 90, 5625, 582, 1585, 198, 90, 275, 1109, 8, 585, 9, 686, 198, 4164, 790, 508, 298, 1213, 582, 1585, 198, 16409, 63, 1213, 63, 2996, 275, 4280, 1585, 198, 692, 2538, 26, 1871, 198, 277, 14, 16409, 5379, 59, 16409, 63, 1213, 63, 2996, 61, 275, 1689, 1213, 401, 2538, 9, 1585, 198, 2836, 26, 1871, 198, 277, 905, 6888, 4140, 505, 275, 574, 1871, 198, 277, 14, 19883, 14, 31675, 8, 585, 9, 686, 198, 4164, 790, 508, 298, 1095, 18508, 582, 1585, 198, 1095, 470, 275, 2008, 779, 442, 8, 88, 9, 367, 671, 315, 574, 14, 1294, 5102, 2023, 686, 198, 2996, 847, 413, 507, 198, 277, 14, 3467, 275, 3666, 1095, 470, 59, 16, 467, 1300, 470, 59, 16, 2522, 334, 1095, 470, 59, 17, 467, 1300, 470, 59, 17, 2459, 2742, 198, 692, 440, 291, 14, 842, 26, 686, 198, 504, 655, 27021, 492, 325, 4301, 686, 198, 277, 14, 842, 275, 325, 4301, 8, 277, 14, 14487, 12, 1315, 9, 2742, 198, 692, 28337, 63, 1213, 63, 2996, 508, 446, 17, 436, 2538, 26, 686, 198, 277, 14, 16409, 5379, 14, 740, 9313, 1213, 401, 2538, 430, 2742, 198, 3, 781, 1929, 370, 1852, 3238, 626, 9842, 3004, 11492, 2061, 507, 198, 277, 14, 16409, 5379, 14, 3191, 8, 498, 29, 2734, 282, 26, 2420, 3124, 582, 413, 5565, 362, 8, 65, 59, 16, 467, 378, 430, 2742, 198, 4998, 2422, 5379, 8, 277, 14, 842, 12, 291, 14, 14487, 12, 291, 14, 16409, 5379, 12, 291, 14, 3467, 9, 507, 198, 277, 14, 981, 17188, 1311, 4463, 8 ]
[ 598, 53, 948, 22527, 1946, 492, 598, 53, 948, 22527, 1946, 199, 504, 28337, 492, 4838, 2422, 5379, 199, 504, 23228, 14, 35, 1296, 492, 445, 1296, 199, 504, 5800, 83, 14, 25289, 492, 13599, 1872, 199, 199, 533, 598, 53, 1311, 19269, 26, 199, 198, 363, 578, 363, 275, 636, 354, 363, 421, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 905, 6888, 937, 275, 13599, 1872, 342, 507, 198, 277, 14, 265, 4798, 22084, 275, 359, 1622, 507, 198, 277, 14, 19883, 275, 445, 1296, 342, 507, 198, 277, 14, 842, 275, 488, 507, 198, 277, 14, 14487, 275, 488, 421, 198, 318, 1218, 17188, 1311, 4463, 8, 277, 12, 1676, 12, 19763, 12, 1678, 2118, 275, 756, 304, 507, 198, 509, 1139, 315, 291, 14, 12471, 26, 686, 198, 692, 1228, 8, 637, 12, 598, 53, 948, 22527, 1946, 304, 1585, 198, 692, 440, 1678, 2118, 26, 1871, 198, 637, 14, 14438, 981, 8, 1708, 9, 1585, 198, 692, 440, 1139, 14, 4998, 14194, 262, 8, 14487, 12, 291, 304, 1871, 198, 1361, 298, 3764, 12, 28337, 365, 4124, 11889, 401, 1139, 12, 298, 262, 401, 291, 2742, 198, 509, 790, 315, 291, 26, 686, 198, 637, 275, 291, 59, 498, 61, 686, 198, 692, 1228, 8, 637, 12, 598, 53, 948, 22527, 1946, 304, 1585, 198, 692, 440, 1678, 2118, 26, 1871, 198, 637, 14, 14438, 981, 8, 1708, 9, 1585, 198, 2601, 82, 275, 1139, 14, 15383, 2354, 1585, 198, 692, 1139, 14, 4998, 14194, 262, 8, 14487, 12, 291, 304, 1871, 198, 692, 2657, 82, 26, 4671, 198, 1361, 298, 9171, 26, 593, 11087, 2228, 5248, 16503, 17877, 1543, 83, 7, 4815, 36, 1621, 20062, 568, 14, 4815, 1543, 83, 7, 20514, 37, 1554, 9539, 450, 334, 498, 12, 2657, 82, 59, 16, 566, 4671, 198, 1361, 298, 5488, 15096, 5248, 16503, 17877, 644, 14961, 6262, 5363, 2679, 14112, 450, 83, 12, 510, 17177, 17148, 9539, 450, 334, 2601, 82, 59, 17, 566, 1585, 198, 4164, 440, 2657, 82, 26, 1871, 198, 1361, 298, 3764, 12, 28337, 365, 4124, 1819, 401, 790, 12, 298, 262, 401, 291, 2742, 198, 509, 336, 315, 291, 14, 8460, 12462, 26, 686, 198, 692, 440, 1678, 2118, 26, 1585, 198, 87, 14, 842, 275, 336, 14, 3440, 8, 1708, 9, 1585, 198, 3, 336, 14, 842, 14, 3749, 944, 275, 378, 686, 198, 4998, 2422, 5379, 8, 87, 14, 842, 12, 19763, 12, 336, 14, 16409, 5379, 12, 291, 14, 3467, 9, 2742, 198, 509, 289, 315, 291, 14, 265, 4798, 22084, 26, 686, 198, 692, 730, 8, 70, 9, 365, 440, 730, 8, 277, 14, 1600, 304, 327, 365, 642, 314, 5526, 4340, 370, 886, 642, 31, 1585, 198, 1628, 8, 70, 9, 315, 7992, 1062, 9480, 342, 686, 198, 2836, 26, 1585, 198, 70, 342, 421, 198, 318, 3145, 17188, 1311, 4463, 8, 277, 304, 507, 198, 509, 334, 354, 12, 1139, 9, 315, 291, 14, 1744, 837, 686, 198, 692, 1228, 8, 637, 12, 598, 53, 948, 22527, 1946, 304, 1585, 198, 637, 14, 14438, 1807, 342, 421, 198, 318, 4002, 8, 277, 304, 507, 198, 277, 14, 1807, 17188, 1311, 4463, 342, 421, 198, 318, 1218, 10407, 8, 277, 304, 507, 198, 1107, 488, 421, 198, 318, 1050, 10407, 8, 277, 12, 6212, 304, 507, 198, 277, 14, 19883, 14, 740, 8, 4705, 9, 421, 198, 318, 2813, 10407, 8, 277, 12, 6212, 304, 507, 198, 277, 14, 19883, 14, 2168, 8, 4705, 9, 421, 198, 318, 663, 6888, 8, 277, 12, 2538, 304, 507, 198, 692, 291, 14, 842, 26, 686, 198, 277, 14, 842, 14, 31675, 8, 1213, 9, 507, 198, 277, 905, 6888, 4140, 505, 275, 2538, 507, 198, 277, 14, 19883, 14, 31675, 8, 1213, 9, 421, 198, 318, 664, 6888, 8, 277, 304, 507, 198, 1107, 291, 905, 6888, 4140, 505, 421, 198, 1213, 275, 3324, 8, 362, 6888, 12, 663, 6888, 9, 421, 198, 318, 663, 20436, 8, 277, 12, 19763, 304, 507, 198, 277, 14, 14487, 275, 19763, 421, 198, 318, 4838, 14194, 262, 8, 277, 304, 507, 198, 90, 275, 378, 507, 198, 1095, 470, 275, 334, 18386, 12, 959, 2114, 9, 327, 7600, 26, 282, 28337, 5594, 1172, 663, 4573, 12401, 12, 1314, 1077, 506, 314, 1300, 522, 507, 198, 2996, 275, 378, 507, 198, 16409, 63, 1213, 63, 2996, 275, 446, 17, 507, 198, 1213, 275, 291, 14, 1213, 507, 198, 509, 334, 498, 12, 574, 9, 315, 291, 14, 16409, 5379, 26, 686, 198, 692, 790, 508, 298, 90, 5625, 582, 1585, 198, 90, 275, 1109, 8, 585, 9, 686, 198, 4164, 790, 508, 298, 1213, 582, 1585, 198, 16409, 63, 1213, 63, 2996, 275, 4280, 1585, 198, 692, 2538, 26, 1871, 198, 277, 14, 16409, 5379, 59, 16409, 63, 1213, 63, 2996, 61, 275, 1689, 1213, 401, 2538, 9, 1585, 198, 2836, 26, 1871, 198, 277, 905, 6888, 4140, 505, 275, 574, 1871, 198, 277, 14, 19883, 14, 31675, 8, 585, 9, 686, 198, 4164, 790, 508, 298, 1095, 18508, 582, 1585, 198, 1095, 470, 275, 2008, 779, 442, 8, 88, 9, 367, 671, 315, 574, 14, 1294, 5102, 2023, 686, 198, 2996, 847, 413, 507, 198, 277, 14, 3467, 275, 3666, 1095, 470, 59, 16, 467, 1300, 470, 59, 16, 2522, 334, 1095, 470, 59, 17, 467, 1300, 470, 59, 17, 2459, 2742, 198, 692, 440, 291, 14, 842, 26, 686, 198, 504, 655, 27021, 492, 325, 4301, 686, 198, 277, 14, 842, 275, 325, 4301, 8, 277, 14, 14487, 12, 1315, 9, 2742, 198, 692, 28337, 63, 1213, 63, 2996, 508, 446, 17, 436, 2538, 26, 686, 198, 277, 14, 16409, 5379, 14, 740, 9313, 1213, 401, 2538, 430, 2742, 198, 3, 781, 1929, 370, 1852, 3238, 626, 9842, 3004, 11492, 2061, 507, 198, 277, 14, 16409, 5379, 14, 3191, 8, 498, 29, 2734, 282, 26, 2420, 3124, 582, 413, 5565, 362, 8, 65, 59, 16, 467, 378, 430, 2742, 198, 4998, 2422, 5379, 8, 277, 14, 842, 12, 291, 14, 14487, 12, 291, 14, 16409, 5379, 12, 291, 14, 3467, 9, 507, 198, 277, 14, 981, 17188, 1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1, 1, 1, 1, 1, 1 ]
vIiRuS/Lagerregal
users/forms.py
1
1438
from django import forms from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext from users.models import Lageruser, DepartmentUser from Lagerregal import settings class SettingsForm(forms.ModelForm): error_css_class = 'has-error' class Meta: model = Lageruser fields = ["pagelength", "timezone", "theme", "main_department"] help_texts = { "pagelength": _("The number of items displayed on one page in a list."), "main_department": _("Your Main department determines, which department devices you create are assigned to."), } def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["timezone"].choices[0] = ("", ugettext("Default ({0})".format(settings.TIME_ZONE))) self.fields["timezone"].widget.choices[0] = ("", ugettext("Default ({0})".format(settings.TIME_ZONE))) class AvatarForm(forms.ModelForm): error_css_class = 'has-error' avatar_clear = forms.BooleanField(required=False) class Meta: model = Lageruser fields = ["avatar"] widgets = { "avatar": forms.FileInput() } class DepartmentAddUserForm(forms.ModelForm): error_css_class = 'has-error' class Meta: model = DepartmentUser widgets = { "department": forms.HiddenInput() } fields = '__all__'
bsd-3-clause
[ 504, 1639, 492, 4513, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 199, 199, 504, 4390, 14, 992, 492, 491, 1456, 751, 12, 1487, 12493, 1899, 199, 504, 491, 1456, 1135, 279, 492, 2202, 421, 199, 533, 13303, 2821, 8, 3351, 14, 15937, 304, 272, 1125, 63, 3919, 63, 533, 275, 283, 1989, 13, 705, 7, 339, 1021, 6288, 26, 267, 1402, 275, 491, 1456, 751, 267, 1504, 275, 2097, 1606, 1267, 401, 298, 7145, 401, 298, 7915, 401, 298, 973, 63, 19623, 937, 267, 1720, 63, 19517, 275, 469, 288, 298, 1606, 1267, 582, 3824, 1918, 1329, 402, 2974, 9080, 641, 1373, 2034, 315, 282, 769, 7651, 288, 298, 973, 63, 19623, 582, 3824, 14398, 11298, 27669, 16756, 12, 1314, 27669, 7256, 1265, 1218, 787, 7943, 370, 7651, 267, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 955, 905, 7145, 4140, 4577, 59, 16, 61, 275, 24727, 10366, 480, 2698, 11459, 16, 25974, 908, 8, 1751, 14, 4961, 63, 15353, 1724, 267, 291, 14, 955, 905, 7145, 4140, 3440, 14, 4577, 59, 16, 61, 275, 24727, 10366, 480, 2698, 11459, 16, 25974, 908, 8, 1751, 14, 4961, 63, 15353, 1724, 421, 199, 533, 16599, 8535, 2821, 8, 3351, 14, 15937, 304, 272, 1125, 63, 3919, 63, 533, 275, 283, 1989, 13, 705, 7, 272, 20913, 63, 3584, 275, 4513, 14, 5036, 8, 2427, 29, 797, 9, 339, 1021, 6288, 26, 267, 1402, 275, 491, 1456, 751, 267, 1504, 275, 2097, 14584, 937, 267, 11114, 275, 469, 288, 298, 14584, 582, 4513, 14, 1173, 3205, 342, 267, 789, 421, 199, 533, 1487, 12493, 1123, 1899, 2821, 8, 3351, 14, 15937, 304, 272, 1125, 63, 3919, 63, 533, 275, 283, 1989, 13, 705, 7, 339, 1021, 6288, 26, 267, 1402, 275, 1487, 12493, 1899, 267, 11114, 275, 469, 288, 298, 19623, 582, 4513, 14, 25419, 342, 267, 789, 267, 1504, 275, 2560, 452, 12217, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 492, 4513, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 199, 199, 504, 4390, 14, 992, 492, 491, 1456, 751, 12, 1487, 12493, 1899, 199, 504, 491, 1456, 1135, 279, 492, 2202, 421, 199, 533, 13303, 2821, 8, 3351, 14, 15937, 304, 272, 1125, 63, 3919, 63, 533, 275, 283, 1989, 13, 705, 7, 339, 1021, 6288, 26, 267, 1402, 275, 491, 1456, 751, 267, 1504, 275, 2097, 1606, 1267, 401, 298, 7145, 401, 298, 7915, 401, 298, 973, 63, 19623, 937, 267, 1720, 63, 19517, 275, 469, 288, 298, 1606, 1267, 582, 3824, 1918, 1329, 402, 2974, 9080, 641, 1373, 2034, 315, 282, 769, 7651, 288, 298, 973, 63, 19623, 582, 3824, 14398, 11298, 27669, 16756, 12, 1314, 27669, 7256, 1265, 1218, 787, 7943, 370, 7651, 267, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 955, 905, 7145, 4140, 4577, 59, 16, 61, 275, 24727, 10366, 480, 2698, 11459, 16, 25974, 908, 8, 1751, 14, 4961, 63, 15353, 1724, 267, 291, 14, 955, 905, 7145, 4140, 3440, 14, 4577, 59, 16, 61, 275, 24727, 10366, 480, 2698, 11459, 16, 25974, 908, 8, 1751, 14, 4961, 63, 15353, 1724, 421, 199, 533, 16599, 8535, 2821, 8, 3351, 14, 15937, 304, 272, 1125, 63, 3919, 63, 533, 275, 283, 1989, 13, 705, 7, 272, 20913, 63, 3584, 275, 4513, 14, 5036, 8, 2427, 29, 797, 9, 339, 1021, 6288, 26, 267, 1402, 275, 491, 1456, 751, 267, 1504, 275, 2097, 14584, 937, 267, 11114, 275, 469, 288, 298, 14584, 582, 4513, 14, 1173, 3205, 342, 267, 789, 421, 199, 533, 1487, 12493, 1123, 1899, 2821, 8, 3351, 14, 15937, 304, 272, 1125, 63, 3919, 63, 533, 275, 283, 1989, 13, 705, 7, 339, 1021, 6288, 26, 267, 1402, 275, 1487, 12493, 1899, 267, 11114, 275, 469, 288, 298, 19623, 582, 4513, 14, 25419, 342, 267, 789, 267, 1504, 275, 2560, 452, 12217, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0 ]
rjschof/gem5
util/cpt_upgraders/isa-is-simobject.py
29
2624
# The ISA is now a separate SimObject, which means that we serialize # it in a separate section instead of as a part of the ThreadContext. def upgrader(cpt): isa = cpt.get('root','isa') isa_fields = { "alpha" : ( "fpcr", "uniq", "lock_flag", "lock_addr", "ipr" ), "arm" : ( "miscRegs" ), "sparc" : ( "asi", "tick", "fprs", "gsr", "softint", "tick_cmpr", "stick", "stick_cmpr", "tpc", "tnpc", "tstate", "tt", "tba", "pstate", "tl", "pil", "cwp", "gl", "hpstate", "htstate", "hintp", "htba", "hstick_cmpr", "strandStatusReg", "fsr", "priContext", "secContext", "partId", "lsuCtrlReg", "scratchPad", "cpu_mondo_head", "cpu_mondo_tail", "dev_mondo_head", "dev_mondo_tail", "res_error_head", "res_error_tail", "nres_error_head", "nres_error_tail", "tick_intr_sched", "cpu", "tc_num", "tick_cmp", "stick_cmp", "hstick_cmp"), "x86" : ( "regVal" ), } isa_fields = isa_fields.get(isa, []) isa_sections = [] for sec in cpt.sections(): import re re_cpu_match = re.match('^(.*sys.*\.cpu[^.]*)\.xc\.(.+)$', sec) # Search for all the execution contexts if not re_cpu_match: continue if re_cpu_match.group(2) != "0": # This shouldn't happen as we didn't support checkpointing # of in-order and O3 CPUs. raise ValueError("Don't know how to migrate multi-threaded CPUs " "from version 1") isa_section = [] for fspec in isa_fields: for (key, value) in cpt.items(sec, raw=True): if key in isa_fields: isa_section.append((key, value)) name = "%s.isa" % re_cpu_match.group(1) isa_sections.append((name, isa_section)) for (key, value) in isa_section: cpt.remove_option(sec, key) for (sec, options) in isa_sections: # Some intermediate versions of gem5 have empty ISA sections # (after we made the ISA a SimObject, but before we started to # serialize into a separate ISA section). if not cpt.has_section(sec): cpt.add_section(sec) else: if cpt.items(sec): raise ValueError("Unexpected populated ISA section in old " "checkpoint") for (key, value) in options: cpt.set(sec, key, value) legacy_version = 4
bsd-3-clause
[ 3, 710, 2281, 33, 365, 3063, 282, 7396, 10751, 1692, 12, 1314, 4910, 626, 781, 8437, 199, 3, 652, 315, 282, 7396, 3420, 3140, 402, 465, 282, 1777, 402, 314, 11086, 2998, 14, 199, 318, 1536, 17556, 8, 67, 541, 304, 272, 365, 65, 275, 286, 541, 14, 362, 360, 1231, 1673, 13655, 358, 272, 365, 65, 63, 955, 275, 469, 267, 298, 4468, 2, 520, 334, 298, 3997, 1556, 401, 298, 22484, 401, 298, 831, 63, 4173, 401, 298, 831, 63, 2697, 401, 298, 711, 82, 2, 2318, 267, 298, 5362, 2, 520, 334, 298, 9923, 497, 458, 2, 2318, 267, 298, 22502, 67, 2, 520, 334, 298, 24950, 401, 298, 8284, 401, 298, 3997, 2393, 401, 298, 458, 82, 401, 298, 4617, 442, 401, 298, 8284, 63, 5730, 82, 401, 490, 298, 18043, 401, 298, 18043, 63, 5730, 82, 401, 298, 683, 67, 401, 298, 84, 1590, 67, 401, 298, 84, 929, 401, 298, 6215, 401, 490, 298, 84, 2470, 401, 298, 80, 929, 401, 298, 5019, 401, 298, 80, 382, 401, 298, 67, 14649, 401, 298, 3528, 401, 298, 12025, 929, 401, 490, 298, 517, 929, 401, 298, 6479, 80, 401, 298, 517, 2470, 401, 298, 72, 18043, 63, 5730, 82, 401, 490, 298, 30964, 3694, 2872, 401, 298, 2319, 82, 401, 298, 1359, 2998, 401, 298, 3321, 2998, 401, 490, 298, 2064, 1304, 401, 298, 478, 85, 9778, 2872, 401, 298, 27393, 18584, 401, 490, 298, 3541, 63, 2106, 1117, 63, 2993, 401, 298, 3541, 63, 2106, 1117, 63, 1521, 401, 490, 298, 2374, 63, 2106, 1117, 63, 2993, 401, 298, 2374, 63, 2106, 1117, 63, 1521, 401, 490, 298, 470, 63, 705, 63, 2993, 401, 298, 470, 63, 705, 63, 1521, 401, 490, 298, 78, 470, 63, 705, 63, 2993, 401, 298, 78, 470, 63, 705, 63, 1521, 401, 490, 298, 8284, 63, 442, 82, 63, 10487, 401, 490, 298, 3541, 401, 298, 3641, 63, 1507, 401, 298, 8284, 63, 5730, 401, 298, 18043, 63, 5730, 401, 298, 72, 18043, 63, 5730, 1288, 267, 298, 88, 1184, 2, 520, 334, 298, 1135, 7562, 2, 2318, 267, 789, 339, 365, 65, 63, 955, 275, 365, 65, 63, 955, 14, 362, 8, 13655, 12, 3073, 272, 365, 65, 63, 7786, 275, 942, 272, 367, 6513, 315, 286, 541, 14, 7786, 837, 267, 492, 295, 398, 295, 63, 3541, 63, 1431, 275, 295, 14, 1431, 9097, 19276, 1274, 24736, 3541, 4735, 14, 3672, 31477, 1812, 4537, 8, 6977, 29150, 6513, 9, 267, 327, 8730, 367, 1006, 314, 6451, 18191, 267, 340, 440, 295, 63, 3541, 63, 1431, 26, 288, 1980, 398, 340, 295, 63, 3541, 63, 1431, 14, 923, 8, 18, 9, 1137, 298, 16, 582, 288, 327, 961, 9296, 1133, 5992, 465, 781, 9980, 1133, 2291, 9997, 316, 288, 327, 402, 315, 13, 1648, 436, 593, 19, 28504, 14, 288, 746, 1722, 480, 16932, 1133, 5715, 4212, 370, 12810, 3510, 13, 19710, 28504, 298, 2490, 298, 504, 1015, 413, 531, 398, 365, 65, 63, 2792, 275, 942, 267, 367, 289, 1650, 315, 365, 65, 63, 955, 26, 288, 367, 334, 498, 12, 574, 9, 315, 286, 541, 14, 1744, 8, 3321, 12, 3066, 29, 549, 304, 355, 340, 790, 315, 365, 65, 63, 955, 26, 490, 365, 65, 63, 2792, 14, 740, 1332, 498, 12, 574, 430, 398, 536, 275, 2071, 83, 14, 13655, 2, 450, 295, 63, 3541, 63, 1431, 14, 923, 8, 17, 9, 267, 365, 65, 63, 7786, 14, 740, 1332, 354, 12, 365, 65, 63, 2792, 430, 398, 367, 334, 498, 12, 574, 9, 315, 365, 65, 63, 2792, 26, 288, 286, 541, 14, 2168, 63, 1422, 8, 3321, 12, 790, 9, 339, 367, 334, 3321, 12, 1511, 9, 315, 365, 65, 63, 7786, 26, 267, 327, 6601, 13197, 5459, 402, 2312, 77, 21, 1172, 2701, 2281, 33, 10189, 267, 327, 334, 4399, 781, 6326, 314, 2281, 33, 282, 10751, 1692, 12, 1325, 2544, 781, 8239, 370, 267, 327, 8437, 1901, 282, 7396, 2281, 33, 3420, 680, 267, 340, 440, 286, 541, 14, 1989, 63, 2792, 8, 3321, 304, 288, 286, 541, 14, 525, 63, 2792, 8, 3321, 9, 267, 587, 26, 288, 340, 286, 541, 14, 1744, 8, 3321, 304, 355, 746, 1722, 480, 8708, 16460, 2281, 33, 3420, 315, 2269, 298, 639, 298, 10109, 531, 398, 367, 334, 498, 12, 574, 9, 315, 1511, 26, 288, 286, 541, 14, 409, 8, 3321, 12, 790, 12, 574, 9, 199, 199, 10000, 63, 1023, 275, 841, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 710, 2281, 33, 365, 3063, 282, 7396, 10751, 1692, 12, 1314, 4910, 626, 781, 8437, 199, 3, 652, 315, 282, 7396, 3420, 3140, 402, 465, 282, 1777, 402, 314, 11086, 2998, 14, 199, 318, 1536, 17556, 8, 67, 541, 304, 272, 365, 65, 275, 286, 541, 14, 362, 360, 1231, 1673, 13655, 358, 272, 365, 65, 63, 955, 275, 469, 267, 298, 4468, 2, 520, 334, 298, 3997, 1556, 401, 298, 22484, 401, 298, 831, 63, 4173, 401, 298, 831, 63, 2697, 401, 298, 711, 82, 2, 2318, 267, 298, 5362, 2, 520, 334, 298, 9923, 497, 458, 2, 2318, 267, 298, 22502, 67, 2, 520, 334, 298, 24950, 401, 298, 8284, 401, 298, 3997, 2393, 401, 298, 458, 82, 401, 298, 4617, 442, 401, 298, 8284, 63, 5730, 82, 401, 490, 298, 18043, 401, 298, 18043, 63, 5730, 82, 401, 298, 683, 67, 401, 298, 84, 1590, 67, 401, 298, 84, 929, 401, 298, 6215, 401, 490, 298, 84, 2470, 401, 298, 80, 929, 401, 298, 5019, 401, 298, 80, 382, 401, 298, 67, 14649, 401, 298, 3528, 401, 298, 12025, 929, 401, 490, 298, 517, 929, 401, 298, 6479, 80, 401, 298, 517, 2470, 401, 298, 72, 18043, 63, 5730, 82, 401, 490, 298, 30964, 3694, 2872, 401, 298, 2319, 82, 401, 298, 1359, 2998, 401, 298, 3321, 2998, 401, 490, 298, 2064, 1304, 401, 298, 478, 85, 9778, 2872, 401, 298, 27393, 18584, 401, 490, 298, 3541, 63, 2106, 1117, 63, 2993, 401, 298, 3541, 63, 2106, 1117, 63, 1521, 401, 490, 298, 2374, 63, 2106, 1117, 63, 2993, 401, 298, 2374, 63, 2106, 1117, 63, 1521, 401, 490, 298, 470, 63, 705, 63, 2993, 401, 298, 470, 63, 705, 63, 1521, 401, 490, 298, 78, 470, 63, 705, 63, 2993, 401, 298, 78, 470, 63, 705, 63, 1521, 401, 490, 298, 8284, 63, 442, 82, 63, 10487, 401, 490, 298, 3541, 401, 298, 3641, 63, 1507, 401, 298, 8284, 63, 5730, 401, 298, 18043, 63, 5730, 401, 298, 72, 18043, 63, 5730, 1288, 267, 298, 88, 1184, 2, 520, 334, 298, 1135, 7562, 2, 2318, 267, 789, 339, 365, 65, 63, 955, 275, 365, 65, 63, 955, 14, 362, 8, 13655, 12, 3073, 272, 365, 65, 63, 7786, 275, 942, 272, 367, 6513, 315, 286, 541, 14, 7786, 837, 267, 492, 295, 398, 295, 63, 3541, 63, 1431, 275, 295, 14, 1431, 9097, 19276, 1274, 24736, 3541, 4735, 14, 3672, 31477, 1812, 4537, 8, 6977, 29150, 6513, 9, 267, 327, 8730, 367, 1006, 314, 6451, 18191, 267, 340, 440, 295, 63, 3541, 63, 1431, 26, 288, 1980, 398, 340, 295, 63, 3541, 63, 1431, 14, 923, 8, 18, 9, 1137, 298, 16, 582, 288, 327, 961, 9296, 1133, 5992, 465, 781, 9980, 1133, 2291, 9997, 316, 288, 327, 402, 315, 13, 1648, 436, 593, 19, 28504, 14, 288, 746, 1722, 480, 16932, 1133, 5715, 4212, 370, 12810, 3510, 13, 19710, 28504, 298, 2490, 298, 504, 1015, 413, 531, 398, 365, 65, 63, 2792, 275, 942, 267, 367, 289, 1650, 315, 365, 65, 63, 955, 26, 288, 367, 334, 498, 12, 574, 9, 315, 286, 541, 14, 1744, 8, 3321, 12, 3066, 29, 549, 304, 355, 340, 790, 315, 365, 65, 63, 955, 26, 490, 365, 65, 63, 2792, 14, 740, 1332, 498, 12, 574, 430, 398, 536, 275, 2071, 83, 14, 13655, 2, 450, 295, 63, 3541, 63, 1431, 14, 923, 8, 17, 9, 267, 365, 65, 63, 7786, 14, 740, 1332, 354, 12, 365, 65, 63, 2792, 430, 398, 367, 334, 498, 12, 574, 9, 315, 365, 65, 63, 2792, 26, 288, 286, 541, 14, 2168, 63, 1422, 8, 3321, 12, 790, 9, 339, 367, 334, 3321, 12, 1511, 9, 315, 365, 65, 63, 7786, 26, 267, 327, 6601, 13197, 5459, 402, 2312, 77, 21, 1172, 2701, 2281, 33, 10189, 267, 327, 334, 4399, 781, 6326, 314, 2281, 33, 282, 10751, 1692, 12, 1325, 2544, 781, 8239, 370, 267, 327, 8437, 1901, 282, 7396, 2281, 33, 3420, 680, 267, 340, 440, 286, 541, 14, 1989, 63, 2792, 8, 3321, 304, 288, 286, 541, 14, 525, 63, 2792, 8, 3321, 9, 267, 587, 26, 288, 340, 286, 541, 14, 1744, 8, 3321, 304, 355, 746, 1722, 480, 8708, 16460, 2281, 33, 3420, 315, 2269, 298, 639, 298, 10109, 531, 398, 367, 334, 498, 12, 574, 9, 315, 1511, 26, 288, 286, 541, 14, 409, 8, 3321, 12, 790, 12, 574, 9, 199, 199, 10000, 63, 1023, 275, 841, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
taedori81/shoop
shoop/admin/module_registry.py
6
1540
# -*- coding: utf-8 -*- # This file is part of Shoop. # # Copyright (c) 2012-2015, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. import contextlib import six from shoop.apps.provides import get_provide_objects from shoop.utils.importing import load _registry = [] def register(module_class): if isinstance(module_class, six.string_types): module_class = load(module_class, "Admin Module") _registry.append(module_class()) def discover(): for obj in get_provide_objects("admin_module"): register(obj) def get_modules(): """ :rtype: list[shoop.admin.base.AdminModule] """ if not _registry: discover() return iter(_registry) def get_module_urls(): for module in get_modules(): # pragma: no branch for url in module.get_urls(): # pragma: no branch yield url @contextlib.contextmanager def replace_modules(new_module_classes): """ Context manager to temporarily replace all modules with something else. Test utility, mostly. >>> def some_test(): ... with replace_modules(["foo.bar:QuuxModule"]): ... pass # do stuff :param new_module_classes: Iterable of module classes, like you'd pass to `register` """ old_registry = _registry[:] _registry[:] = [] for cls in new_module_classes: register(cls) try: yield finally: _registry[:] = old_registry
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 428, 526, 411, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 6029, 13, 7806, 12, 428, 526, 411, 12126, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 1350, 1233, 365, 18233, 1334, 314, 437, 28863, 19, 4190, 1911, 315, 314, 199, 3, 5113, 570, 315, 314, 1738, 2082, 402, 642, 1350, 3123, 14, 199, 646, 15502, 199, 199, 646, 3816, 199, 199, 504, 930, 411, 14, 5181, 14, 20121, 492, 664, 63, 20824, 63, 1462, 199, 504, 930, 411, 14, 1208, 14, 646, 316, 492, 2248, 199, 199, 63, 5189, 275, 942, 421, 199, 318, 2274, 8, 578, 63, 533, 304, 272, 340, 1228, 8, 578, 63, 533, 12, 3816, 14, 875, 63, 1313, 304, 267, 859, 63, 533, 275, 2248, 8, 578, 63, 533, 12, 298, 4880, 5673, 531, 272, 485, 5189, 14, 740, 8, 578, 63, 533, 1012, 421, 199, 318, 20131, 837, 272, 367, 1559, 315, 664, 63, 20824, 63, 1462, 480, 2113, 63, 578, 2349, 267, 2274, 8, 1113, 9, 421, 199, 318, 664, 63, 3112, 837, 272, 408, 272, 520, 4500, 26, 769, 59, 13927, 411, 14, 2113, 14, 1095, 14, 4880, 2377, 61, 272, 408, 272, 340, 440, 485, 5189, 26, 267, 20131, 342, 272, 372, 2740, 1547, 5189, 9, 421, 199, 318, 664, 63, 578, 63, 3603, 837, 272, 367, 859, 315, 664, 63, 3112, 837, 221, 327, 11942, 26, 949, 5246, 267, 367, 1166, 315, 859, 14, 362, 63, 3603, 837, 221, 327, 11942, 26, 949, 5246, 288, 1995, 1166, 421, 199, 32, 23464, 14, 14237, 199, 318, 3350, 63, 3112, 8, 1222, 63, 578, 63, 2888, 304, 272, 408, 272, 9470, 5256, 370, 22256, 3350, 1006, 4621, 543, 6020, 587, 14, 339, 1379, 11420, 12, 19762, 14, 339, 1306, 347, 2005, 63, 396, 837, 272, 2263, 258, 543, 3350, 63, 3112, 5234, 1421, 14, 1700, 26, 2371, 2521, 2377, 21473, 272, 2263, 260, 986, 327, 886, 8292, 339, 520, 635, 892, 63, 578, 63, 2888, 26, 19937, 402, 859, 3992, 12, 2839, 1265, 5121, 986, 370, 658, 2683, 64, 272, 408, 272, 2269, 63, 5189, 275, 485, 5189, 5873, 272, 485, 5189, 5873, 275, 942, 272, 367, 843, 315, 892, 63, 578, 63, 2888, 26, 267, 2274, 8, 1886, 9, 272, 862, 26, 267, 1995, 272, 3753, 26, 267, 485, 5189, 5873, 275, 2269, 63, 5189, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 961, 570, 365, 1777, 402, 428, 526, 411, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 6029, 13, 7806, 12, 428, 526, 411, 12126, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 1350, 1233, 365, 18233, 1334, 314, 437, 28863, 19, 4190, 1911, 315, 314, 199, 3, 5113, 570, 315, 314, 1738, 2082, 402, 642, 1350, 3123, 14, 199, 646, 15502, 199, 199, 646, 3816, 199, 199, 504, 930, 411, 14, 5181, 14, 20121, 492, 664, 63, 20824, 63, 1462, 199, 504, 930, 411, 14, 1208, 14, 646, 316, 492, 2248, 199, 199, 63, 5189, 275, 942, 421, 199, 318, 2274, 8, 578, 63, 533, 304, 272, 340, 1228, 8, 578, 63, 533, 12, 3816, 14, 875, 63, 1313, 304, 267, 859, 63, 533, 275, 2248, 8, 578, 63, 533, 12, 298, 4880, 5673, 531, 272, 485, 5189, 14, 740, 8, 578, 63, 533, 1012, 421, 199, 318, 20131, 837, 272, 367, 1559, 315, 664, 63, 20824, 63, 1462, 480, 2113, 63, 578, 2349, 267, 2274, 8, 1113, 9, 421, 199, 318, 664, 63, 3112, 837, 272, 408, 272, 520, 4500, 26, 769, 59, 13927, 411, 14, 2113, 14, 1095, 14, 4880, 2377, 61, 272, 408, 272, 340, 440, 485, 5189, 26, 267, 20131, 342, 272, 372, 2740, 1547, 5189, 9, 421, 199, 318, 664, 63, 578, 63, 3603, 837, 272, 367, 859, 315, 664, 63, 3112, 837, 221, 327, 11942, 26, 949, 5246, 267, 367, 1166, 315, 859, 14, 362, 63, 3603, 837, 221, 327, 11942, 26, 949, 5246, 288, 1995, 1166, 421, 199, 32, 23464, 14, 14237, 199, 318, 3350, 63, 3112, 8, 1222, 63, 578, 63, 2888, 304, 272, 408, 272, 9470, 5256, 370, 22256, 3350, 1006, 4621, 543, 6020, 587, 14, 339, 1379, 11420, 12, 19762, 14, 339, 1306, 347, 2005, 63, 396, 837, 272, 2263, 258, 543, 3350, 63, 3112, 5234, 1421, 14, 1700, 26, 2371, 2521, 2377, 21473, 272, 2263, 260, 986, 327, 886, 8292, 339, 520, 635, 892, 63, 578, 63, 2888, 26, 19937, 402, 859, 3992, 12, 2839, 1265, 5121, 986, 370, 658, 2683, 64, 272, 408, 272, 2269, 63, 5189, 275, 485, 5189, 5873, 272, 485, 5189, 5873, 275, 942, 272, 367, 843, 315, 892, 63, 578, 63, 2888, 26, 267, 2274, 8, 1886, 9, 272, 862, 26, 267, 1995, 272, 3753, 26, 267, 485, 5189, 5873, 275, 2269, 63, 5189, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
ssvsergeyev/ZenPacks.zenoss.AWS
src/boto/boto/cognito/identity/exceptions.py
15
1050
# The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # from boto.exception import BotoServerError class LimitExceededException(BotoServerError): pass class ResourceConflictException(BotoServerError): pass class TooManyRequestsException(BotoServerError): pass class InvalidParameterException(BotoServerError): pass class ResourceNotFoundException(BotoServerError): pass class InternalErrorException(BotoServerError): pass class NotAuthorizedException(BotoServerError): pass
gpl-2.0
[ 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 3, 199, 504, 6055, 14, 1971, 492, 24411, 17692, 421, 199, 533, 22672, 24748, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7337, 15919, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 22893, 4089, 16272, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 6378, 4720, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7337, 22646, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 12624, 547, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 2832, 29284, 1726, 8, 20380, 17692, 304, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 3, 199, 504, 6055, 14, 1971, 492, 24411, 17692, 421, 199, 533, 22672, 24748, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7337, 15919, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 22893, 4089, 16272, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 6378, 4720, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7337, 22646, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 12624, 547, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 2832, 29284, 1726, 8, 20380, 17692, 304, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
wolfram74/numerical_methods_iserles_notes
venv/lib/python2.7/site-packages/numpy/lib/tests/test_stride_tricks.py
32
7775
from __future__ import division, absolute_import, print_function import numpy as np from numpy.testing import ( run_module_suite, assert_equal, assert_array_equal, assert_raises ) from numpy.lib.stride_tricks import as_strided, broadcast_arrays def assert_shapes_correct(input_shapes, expected_shape): # Broadcast a list of arrays with the given input shapes and check the # common output shape. inarrays = [np.zeros(s) for s in input_shapes] outarrays = broadcast_arrays(*inarrays) outshapes = [a.shape for a in outarrays] expected = [expected_shape] * len(inarrays) assert_equal(outshapes, expected) def assert_incompatible_shapes_raise(input_shapes): # Broadcast a list of arrays with the given (incompatible) input shapes # and check that they raise a ValueError. inarrays = [np.zeros(s) for s in input_shapes] assert_raises(ValueError, broadcast_arrays, *inarrays) def assert_same_as_ufunc(shape0, shape1, transposed=False, flipped=False): # Broadcast two shapes against each other and check that the data layout # is the same as if a ufunc did the broadcasting. x0 = np.zeros(shape0, dtype=int) # Note that multiply.reduce's identity element is 1.0, so when shape1==(), # this gives the desired n==1. n = int(np.multiply.reduce(shape1)) x1 = np.arange(n).reshape(shape1) if transposed: x0 = x0.T x1 = x1.T if flipped: x0 = x0[::-1] x1 = x1[::-1] # Use the add ufunc to do the broadcasting. Since we're adding 0s to x1, the # result should be exactly the same as the broadcasted view of x1. y = x0 + x1 b0, b1 = broadcast_arrays(x0, x1) assert_array_equal(y, b1) def test_same(): x = np.arange(10) y = np.arange(10) bx, by = broadcast_arrays(x, y) assert_array_equal(x, bx) assert_array_equal(y, by) def test_one_off(): x = np.array([[1, 2, 3]]) y = np.array([[1], [2], [3]]) bx, by = broadcast_arrays(x, y) bx0 = np.array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]) by0 = bx0.T assert_array_equal(bx0, bx) assert_array_equal(by0, by) def test_same_input_shapes(): # Check that the final shape is just the input shape. data = [ (), (1,), (3,), (0, 1), (0, 3), (1, 0), (3, 0), (1, 3), (3, 1), (3, 3), ] for shape in data: input_shapes = [shape] # Single input. assert_shapes_correct(input_shapes, shape) # Double input. input_shapes2 = [shape, shape] assert_shapes_correct(input_shapes2, shape) # Triple input. input_shapes3 = [shape, shape, shape] assert_shapes_correct(input_shapes3, shape) def test_two_compatible_by_ones_input_shapes(): # Check that two different input shapes of the same length, but some have # ones, broadcast to the correct shape. data = [ [[(1,), (3,)], (3,)], [[(1, 3), (3, 3)], (3, 3)], [[(3, 1), (3, 3)], (3, 3)], [[(1, 3), (3, 1)], (3, 3)], [[(1, 1), (3, 3)], (3, 3)], [[(1, 1), (1, 3)], (1, 3)], [[(1, 1), (3, 1)], (3, 1)], [[(1, 0), (0, 0)], (0, 0)], [[(0, 1), (0, 0)], (0, 0)], [[(1, 0), (0, 1)], (0, 0)], [[(1, 1), (0, 0)], (0, 0)], [[(1, 1), (1, 0)], (1, 0)], [[(1, 1), (0, 1)], (0, 1)], ] for input_shapes, expected_shape in data: assert_shapes_correct(input_shapes, expected_shape) # Reverse the input shapes since broadcasting should be symmetric. assert_shapes_correct(input_shapes[::-1], expected_shape) def test_two_compatible_by_prepending_ones_input_shapes(): # Check that two different input shapes (of different lengths) broadcast # to the correct shape. data = [ [[(), (3,)], (3,)], [[(3,), (3, 3)], (3, 3)], [[(3,), (3, 1)], (3, 3)], [[(1,), (3, 3)], (3, 3)], [[(), (3, 3)], (3, 3)], [[(1, 1), (3,)], (1, 3)], [[(1,), (3, 1)], (3, 1)], [[(1,), (1, 3)], (1, 3)], [[(), (1, 3)], (1, 3)], [[(), (3, 1)], (3, 1)], [[(), (0,)], (0,)], [[(0,), (0, 0)], (0, 0)], [[(0,), (0, 1)], (0, 0)], [[(1,), (0, 0)], (0, 0)], [[(), (0, 0)], (0, 0)], [[(1, 1), (0,)], (1, 0)], [[(1,), (0, 1)], (0, 1)], [[(1,), (1, 0)], (1, 0)], [[(), (1, 0)], (1, 0)], [[(), (0, 1)], (0, 1)], ] for input_shapes, expected_shape in data: assert_shapes_correct(input_shapes, expected_shape) # Reverse the input shapes since broadcasting should be symmetric. assert_shapes_correct(input_shapes[::-1], expected_shape) def test_incompatible_shapes_raise_valueerror(): # Check that a ValueError is raised for incompatible shapes. data = [ [(3,), (4,)], [(2, 3), (2,)], [(3,), (3,), (4,)], [(1, 3, 4), (2, 3, 3)], ] for input_shapes in data: assert_incompatible_shapes_raise(input_shapes) # Reverse the input shapes since broadcasting should be symmetric. assert_incompatible_shapes_raise(input_shapes[::-1]) def test_same_as_ufunc(): # Check that the data layout is the same as if a ufunc did the operation. data = [ [[(1,), (3,)], (3,)], [[(1, 3), (3, 3)], (3, 3)], [[(3, 1), (3, 3)], (3, 3)], [[(1, 3), (3, 1)], (3, 3)], [[(1, 1), (3, 3)], (3, 3)], [[(1, 1), (1, 3)], (1, 3)], [[(1, 1), (3, 1)], (3, 1)], [[(1, 0), (0, 0)], (0, 0)], [[(0, 1), (0, 0)], (0, 0)], [[(1, 0), (0, 1)], (0, 0)], [[(1, 1), (0, 0)], (0, 0)], [[(1, 1), (1, 0)], (1, 0)], [[(1, 1), (0, 1)], (0, 1)], [[(), (3,)], (3,)], [[(3,), (3, 3)], (3, 3)], [[(3,), (3, 1)], (3, 3)], [[(1,), (3, 3)], (3, 3)], [[(), (3, 3)], (3, 3)], [[(1, 1), (3,)], (1, 3)], [[(1,), (3, 1)], (3, 1)], [[(1,), (1, 3)], (1, 3)], [[(), (1, 3)], (1, 3)], [[(), (3, 1)], (3, 1)], [[(), (0,)], (0,)], [[(0,), (0, 0)], (0, 0)], [[(0,), (0, 1)], (0, 0)], [[(1,), (0, 0)], (0, 0)], [[(), (0, 0)], (0, 0)], [[(1, 1), (0,)], (1, 0)], [[(1,), (0, 1)], (0, 1)], [[(1,), (1, 0)], (1, 0)], [[(), (1, 0)], (1, 0)], [[(), (0, 1)], (0, 1)], ] for input_shapes, expected_shape in data: assert_same_as_ufunc(input_shapes[0], input_shapes[1], "Shapes: %s %s" % (input_shapes[0], input_shapes[1])) # Reverse the input shapes since broadcasting should be symmetric. assert_same_as_ufunc(input_shapes[1], input_shapes[0]) # Try them transposed, too. assert_same_as_ufunc(input_shapes[0], input_shapes[1], True) # ... and flipped for non-rank-0 inputs in order to test negative # strides. if () not in input_shapes: assert_same_as_ufunc(input_shapes[0], input_shapes[1], False, True) assert_same_as_ufunc(input_shapes[0], input_shapes[1], True, True) def test_as_strided(): a = np.array([None]) a_view = as_strided(a) expected = np.array([None]) assert_array_equal(a_view, np.array([None])) a = np.array([1, 2, 3, 4]) a_view = as_strided(a, shape=(2,), strides=(2 * a.itemsize,)) expected = np.array([1, 3]) assert_array_equal(a_view, expected) a = np.array([1, 2, 3, 4]) a_view = as_strided(a, shape=(3, 4), strides=(0, 1 * a.itemsize)) expected = np.array([[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]) assert_array_equal(a_view, expected) if __name__ == "__main__": run_module_suite()
mit
[ 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 334, 272, 1255, 63, 578, 63, 5768, 12, 702, 63, 1452, 12, 702, 63, 1144, 63, 1452, 12, 272, 702, 63, 3536, 272, 776, 199, 504, 2680, 14, 773, 14, 12318, 63, 599, 5618, 492, 465, 63, 816, 770, 12, 11180, 63, 10095, 421, 199, 318, 702, 63, 9069, 63, 4525, 8, 1210, 63, 9069, 12, 1420, 63, 1392, 304, 272, 327, 699, 5659, 282, 769, 402, 6572, 543, 314, 1627, 1324, 11751, 436, 1104, 314, 272, 327, 2863, 1072, 2215, 14, 339, 315, 10095, 275, 359, 1590, 14, 4250, 8, 83, 9, 367, 308, 315, 1324, 63, 9069, 61, 272, 734, 10095, 275, 11180, 63, 10095, 2031, 262, 10095, 9, 272, 734, 9069, 275, 359, 65, 14, 1392, 367, 282, 315, 734, 10095, 61, 272, 1420, 275, 359, 2062, 63, 1392, 61, 627, 822, 8, 262, 10095, 9, 272, 702, 63, 1452, 8, 548, 9069, 12, 1420, 9, 421, 199, 318, 702, 63, 31787, 63, 9069, 63, 3730, 8, 1210, 63, 9069, 304, 272, 327, 699, 5659, 282, 769, 402, 6572, 543, 314, 1627, 334, 31787, 9, 1324, 11751, 272, 327, 436, 1104, 626, 2985, 746, 282, 1722, 14, 339, 315, 10095, 275, 359, 1590, 14, 4250, 8, 83, 9, 367, 308, 315, 1324, 63, 9069, 61, 272, 702, 63, 3536, 8, 3393, 12, 11180, 63, 10095, 12, 627, 262, 10095, 9, 421, 199, 318, 702, 63, 7191, 63, 305, 63, 18810, 8, 1392, 16, 12, 2215, 17, 12, 1752, 5824, 29, 797, 12, 18761, 1915, 29, 797, 304, 272, 327, 699, 5659, 2877, 11751, 6169, 1924, 1163, 436, 1104, 626, 314, 666, 7054, 272, 327, 365, 314, 2011, 465, 340, 282, 30149, 8103, 314, 32001, 14, 339, 671, 16, 275, 980, 14, 4250, 8, 1392, 16, 12, 2152, 29, 442, 9, 272, 327, 3390, 626, 21699, 14, 5270, 1159, 8503, 1819, 365, 413, 14, 16, 12, 880, 1380, 2215, 17, 389, 1062, 272, 327, 642, 10557, 314, 6387, 302, 389, 17, 14, 272, 302, 275, 1109, 8, 1590, 14, 13710, 14, 5270, 8, 1392, 17, 430, 272, 671, 17, 275, 980, 14, 5605, 8, 78, 680, 5217, 8, 1392, 17, 9, 272, 340, 1752, 5824, 26, 267, 671, 16, 275, 671, 16, 14, 52, 267, 671, 17, 275, 671, 17, 14, 52, 272, 340, 18761, 1915, 26, 267, 671, 16, 275, 671, 16, 14172, 17, 61, 267, 671, 17, 275, 671, 17, 14172, 17, 61, 272, 327, 3645, 314, 1050, 30149, 370, 886, 314, 32001, 14, 9336, 781, 3984, 7791, 378, 83, 370, 671, 17, 12, 314, 272, 327, 754, 1077, 506, 8840, 314, 2011, 465, 314, 330, 5063, 9765, 471, 2455, 402, 671, 17, 14, 272, 612, 275, 671, 16, 435, 671, 17, 272, 330, 16, 12, 330, 17, 275, 11180, 63, 10095, 8, 88, 16, 12, 671, 17, 9, 272, 702, 63, 1144, 63, 1452, 8, 89, 12, 330, 17, 9, 421, 199, 318, 511, 63, 7191, 837, 272, 671, 275, 980, 14, 5605, 8, 709, 9, 272, 612, 275, 980, 14, 5605, 8, 709, 9, 272, 330, 88, 12, 701, 275, 11180, 63, 10095, 8, 88, 12, 612, 9, 272, 702, 63, 1144, 63, 1452, 8, 88, 12, 330, 88, 9, 272, 702, 63, 1144, 63, 1452, 8, 89, 12, 701, 9, 421, 199, 318, 511, 63, 368, 63, 1997, 837, 272, 671, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 650, 3934, 272, 612, 275, 980, 14, 1144, 4038, 17, 467, 359, 18, 467, 359, 19, 3934, 272, 330, 88, 12, 701, 275, 11180, 63, 10095, 8, 88, 12, 612, 9, 272, 330, 88, 16, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 650, 467, 359, 17, 12, 499, 12, 650, 467, 359, 17, 12, 499, 12, 650, 3934, 272, 701, 16, 275, 330, 88, 16, 14, 52, 272, 702, 63, 1144, 63, 1452, 8, 13691, 16, 12, 330, 88, 9, 272, 702, 63, 1144, 63, 1452, 8, 991, 16, 12, 701, 9, 421, 199, 318, 511, 63, 7191, 63, 1210, 63, 9069, 837, 272, 327, 2670, 626, 314, 4242, 2215, 365, 2951, 314, 1324, 2215, 14, 339, 666, 275, 359, 267, 11969, 267, 334, 17, 4706, 267, 334, 19, 4706, 267, 334, 16, 12, 413, 395, 267, 334, 16, 12, 650, 395, 267, 334, 17, 12, 378, 395, 267, 334, 19, 12, 378, 395, 267, 334, 17, 12, 650, 395, 267, 334, 19, 12, 413, 395, 267, 334, 19, 12, 650, 395, 272, 1622, 272, 367, 2215, 315, 666, 26, 267, 1324, 63, 9069, 275, 359, 1392, 61, 267, 327, 13050, 1324, 14, 267, 702, 63, 9069, 63, 4525, 8, 1210, 63, 9069, 12, 2215, 9, 267, 327, 22945, 1324, 14, 267, 1324, 63, 9069, 18, 275, 359, 1392, 12, 2215, 61, 267, 702, 63, 9069, 63, 4525, 8, 1210, 63, 9069, 18, 12, 2215, 9, 267, 327, 12480, 11045, 1324, 14, 267, 1324, 63, 9069, 19, 275, 359, 1392, 12, 2215, 12, 2215, 61, 267, 702, 63, 9069, 63, 4525, 8, 1210, 63, 9069, 19, 12, 2215, 9, 421, 199, 318, 511, 63, 5601, 63, 6490, 63, 991, 63, 4548, 63, 1210, 63, 9069, 837, 272, 327, 2670, 626, 2877, 3365, 1324, 11751, 402, 314, 2011, 2582, 12, 1325, 2005, 1172, 272, 327, 7869, 12, 11180, 370, 314, 3211, 2215, 14, 339, 666, 275, 359, 267, 3474, 8, 17, 4706, 334, 19, 32444, 334, 19, 32444, 267, 3474, 8, 17, 12, 650, 395, 334, 19, 12, 650, 4360, 334, 19, 12, 650, 4360, 267, 3474, 8, 19, 12, 413, 395, 334, 19, 12, 650, 4360, 334, 19, 12, 650, 4360, 267, 3474, 8, 17, 12, 650, 395, 334, 19, 12, 413, 4360, 334, 19, 12, 650, 4360, 267, 3474, 8, 17, 12, 413, 395, 334, 19, 12, 650, 4360, 334, 19, 12, 650, 4360, 267, 3474, 8, 17, 12, 413, 395, 334, 17, 12, 650, 4360, 334, 17, 12, 650, 4360, 267, 3474, 8, 17, 12, 413, 395, 334, 19, 12, 413, 4360, 334, 19, 12, 413, 4360, 267, 3474, 8, 17, 12, 378, 395, 334, 16, 12 ]
[ 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 334, 272, 1255, 63, 578, 63, 5768, 12, 702, 63, 1452, 12, 702, 63, 1144, 63, 1452, 12, 272, 702, 63, 3536, 272, 776, 199, 504, 2680, 14, 773, 14, 12318, 63, 599, 5618, 492, 465, 63, 816, 770, 12, 11180, 63, 10095, 421, 199, 318, 702, 63, 9069, 63, 4525, 8, 1210, 63, 9069, 12, 1420, 63, 1392, 304, 272, 327, 699, 5659, 282, 769, 402, 6572, 543, 314, 1627, 1324, 11751, 436, 1104, 314, 272, 327, 2863, 1072, 2215, 14, 339, 315, 10095, 275, 359, 1590, 14, 4250, 8, 83, 9, 367, 308, 315, 1324, 63, 9069, 61, 272, 734, 10095, 275, 11180, 63, 10095, 2031, 262, 10095, 9, 272, 734, 9069, 275, 359, 65, 14, 1392, 367, 282, 315, 734, 10095, 61, 272, 1420, 275, 359, 2062, 63, 1392, 61, 627, 822, 8, 262, 10095, 9, 272, 702, 63, 1452, 8, 548, 9069, 12, 1420, 9, 421, 199, 318, 702, 63, 31787, 63, 9069, 63, 3730, 8, 1210, 63, 9069, 304, 272, 327, 699, 5659, 282, 769, 402, 6572, 543, 314, 1627, 334, 31787, 9, 1324, 11751, 272, 327, 436, 1104, 626, 2985, 746, 282, 1722, 14, 339, 315, 10095, 275, 359, 1590, 14, 4250, 8, 83, 9, 367, 308, 315, 1324, 63, 9069, 61, 272, 702, 63, 3536, 8, 3393, 12, 11180, 63, 10095, 12, 627, 262, 10095, 9, 421, 199, 318, 702, 63, 7191, 63, 305, 63, 18810, 8, 1392, 16, 12, 2215, 17, 12, 1752, 5824, 29, 797, 12, 18761, 1915, 29, 797, 304, 272, 327, 699, 5659, 2877, 11751, 6169, 1924, 1163, 436, 1104, 626, 314, 666, 7054, 272, 327, 365, 314, 2011, 465, 340, 282, 30149, 8103, 314, 32001, 14, 339, 671, 16, 275, 980, 14, 4250, 8, 1392, 16, 12, 2152, 29, 442, 9, 272, 327, 3390, 626, 21699, 14, 5270, 1159, 8503, 1819, 365, 413, 14, 16, 12, 880, 1380, 2215, 17, 389, 1062, 272, 327, 642, 10557, 314, 6387, 302, 389, 17, 14, 272, 302, 275, 1109, 8, 1590, 14, 13710, 14, 5270, 8, 1392, 17, 430, 272, 671, 17, 275, 980, 14, 5605, 8, 78, 680, 5217, 8, 1392, 17, 9, 272, 340, 1752, 5824, 26, 267, 671, 16, 275, 671, 16, 14, 52, 267, 671, 17, 275, 671, 17, 14, 52, 272, 340, 18761, 1915, 26, 267, 671, 16, 275, 671, 16, 14172, 17, 61, 267, 671, 17, 275, 671, 17, 14172, 17, 61, 272, 327, 3645, 314, 1050, 30149, 370, 886, 314, 32001, 14, 9336, 781, 3984, 7791, 378, 83, 370, 671, 17, 12, 314, 272, 327, 754, 1077, 506, 8840, 314, 2011, 465, 314, 330, 5063, 9765, 471, 2455, 402, 671, 17, 14, 272, 612, 275, 671, 16, 435, 671, 17, 272, 330, 16, 12, 330, 17, 275, 11180, 63, 10095, 8, 88, 16, 12, 671, 17, 9, 272, 702, 63, 1144, 63, 1452, 8, 89, 12, 330, 17, 9, 421, 199, 318, 511, 63, 7191, 837, 272, 671, 275, 980, 14, 5605, 8, 709, 9, 272, 612, 275, 980, 14, 5605, 8, 709, 9, 272, 330, 88, 12, 701, 275, 11180, 63, 10095, 8, 88, 12, 612, 9, 272, 702, 63, 1144, 63, 1452, 8, 88, 12, 330, 88, 9, 272, 702, 63, 1144, 63, 1452, 8, 89, 12, 701, 9, 421, 199, 318, 511, 63, 368, 63, 1997, 837, 272, 671, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 650, 3934, 272, 612, 275, 980, 14, 1144, 4038, 17, 467, 359, 18, 467, 359, 19, 3934, 272, 330, 88, 12, 701, 275, 11180, 63, 10095, 8, 88, 12, 612, 9, 272, 330, 88, 16, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 650, 467, 359, 17, 12, 499, 12, 650, 467, 359, 17, 12, 499, 12, 650, 3934, 272, 701, 16, 275, 330, 88, 16, 14, 52, 272, 702, 63, 1144, 63, 1452, 8, 13691, 16, 12, 330, 88, 9, 272, 702, 63, 1144, 63, 1452, 8, 991, 16, 12, 701, 9, 421, 199, 318, 511, 63, 7191, 63, 1210, 63, 9069, 837, 272, 327, 2670, 626, 314, 4242, 2215, 365, 2951, 314, 1324, 2215, 14, 339, 666, 275, 359, 267, 11969, 267, 334, 17, 4706, 267, 334, 19, 4706, 267, 334, 16, 12, 413, 395, 267, 334, 16, 12, 650, 395, 267, 334, 17, 12, 378, 395, 267, 334, 19, 12, 378, 395, 267, 334, 17, 12, 650, 395, 267, 334, 19, 12, 413, 395, 267, 334, 19, 12, 650, 395, 272, 1622, 272, 367, 2215, 315, 666, 26, 267, 1324, 63, 9069, 275, 359, 1392, 61, 267, 327, 13050, 1324, 14, 267, 702, 63, 9069, 63, 4525, 8, 1210, 63, 9069, 12, 2215, 9, 267, 327, 22945, 1324, 14, 267, 1324, 63, 9069, 18, 275, 359, 1392, 12, 2215, 61, 267, 702, 63, 9069, 63, 4525, 8, 1210, 63, 9069, 18, 12, 2215, 9, 267, 327, 12480, 11045, 1324, 14, 267, 1324, 63, 9069, 19, 275, 359, 1392, 12, 2215, 12, 2215, 61, 267, 702, 63, 9069, 63, 4525, 8, 1210, 63, 9069, 19, 12, 2215, 9, 421, 199, 318, 511, 63, 5601, 63, 6490, 63, 991, 63, 4548, 63, 1210, 63, 9069, 837, 272, 327, 2670, 626, 2877, 3365, 1324, 11751, 402, 314, 2011, 2582, 12, 1325, 2005, 1172, 272, 327, 7869, 12, 11180, 370, 314, 3211, 2215, 14, 339, 666, 275, 359, 267, 3474, 8, 17, 4706, 334, 19, 32444, 334, 19, 32444, 267, 3474, 8, 17, 12, 650, 395, 334, 19, 12, 650, 4360, 334, 19, 12, 650, 4360, 267, 3474, 8, 19, 12, 413, 395, 334, 19, 12, 650, 4360, 334, 19, 12, 650, 4360, 267, 3474, 8, 17, 12, 650, 395, 334, 19, 12, 413, 4360, 334, 19, 12, 650, 4360, 267, 3474, 8, 17, 12, 413, 395, 334, 19, 12, 650, 4360, 334, 19, 12, 650, 4360, 267, 3474, 8, 17, 12, 413, 395, 334, 17, 12, 650, 4360, 334, 17, 12, 650, 4360, 267, 3474, 8, 17, 12, 413, 395, 334, 19, 12, 413, 4360, 334, 19, 12, 413, 4360, 267, 3474, 8, 17, 12, 378, 395, 334, 16, 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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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 ]
matthieucan/debsources
debsources/updater.py
5
29780
# Copyright (C) 2013-2014 The Debsources developers <info@sources.debian.net>. # See the AUTHORS file at the top-level directory of this distribution and at # https://anonscm.debian.org/gitweb/?p=qa/debsources.git;a=blob;f=AUTHORS;hb=HEAD # # This file is part of Debsources. Debsources 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. For more information # see the COPYING file at the top-level directory of this distribution and at # https://anonscm.debian.org/gitweb/?p=qa/debsources.git;a=blob;f=COPYING;hb=HEAD from __future__ import absolute_import from __future__ import division import glob import logging import os import string import subprocess import six from six.moves import map from six.moves import range from datetime import datetime from email.utils import formatdate from sqlalchemy import sql, not_ from debsources import db_storage from debsources import fs_storage from debsources import statistics from . import query as qry from debsources.consts import DEBIAN_RELEASES, SLOCCOUNT_LANGUAGES from debsources.debmirror import SourceMirror, SourcePackage from debsources.models import SuiteInfo, Suite, SuiteAlias, Package, \ HistorySize, HistorySlocCount, HistoryCopyright from debsources.subprocess_workaround import subprocess_setup KNOWN_EVENTS = ['add-package', 'rm-package'] NO_OBSERVERS = dict([(e, []) for e in KNOWN_EVENTS]) # maximum number of pending rows before performing a (bulk) insert BULK_FLUSH_THRESHOLD = 50000 class UpdateStatus(object): """store update status during update runs""" def __init__(self): self._sources = {} @property def sources(self): """entries for the on-disk cache of source packages (AKA sources.txt) sources is a dictionary from pairs <SRC_NAME, SRC_VERSION> to tuples <AREA, DSC, UNPACK_DIR, SUITES>, where SUITES is a list of SUITE_NAMEs """ return self._sources @sources.setter def sources(self, new_sources): self._sources = new_sources # TODO fill tables: BinaryPackage, BinaryVersion # TODO get rid of shell hooks; they shall die a horrible death def notify(conf, event, session, pkg, pkgdir, file_table=None): """notify (Python and shell) hooks of occurred events Currently supported events: * add-package: a package is being added to Debsources; its source files have already been unpacked to the file storage and its metadata have already been added to the database * rm-package: a package is being removed from Debsources; its source files are still part of the file storage and its metadata are still part of the database Python hooks are passed the following arguments, in this order: * session: ongoing database session; failures in hook execution will cause the session to be rolled back, udoing pending database modifications (e.g. the addition/removal of package metadata) * pkg: a debmirror.SourcePackage representation of the package being acted upon * pkgdir: path pointing to the package location in the file storage * file_table: a dictionary mapping file names to DB file identifiers (unique integers). If != None, the hook can rely on the file_table keys to avoid re-scanning the file-system and use the corresponding file IDs. If None, the hook will have to redo the scanning work. Shell hoks re invoked with the following arguments: pkgdir, package name, package version """ logging.debug('notify %s for %s' % (event, pkg)) package, version = pkg['package'], pkg['version'] cmd = ['run-parts', '--exit-on-error', '--arg', pkgdir, '--arg', package, '--arg', version, os.path.join(conf['bin_dir'], event + '.d')] # fire shell hooks try: subprocess.check_output(cmd, stderr=subprocess.STDOUT, preexec_fn=subprocess_setup) except subprocess.CalledProcessError as e: logging.error('shell hooks for %s on %s returned exit code %d.' ' Output: %s' % (event, pkg, e.returncode, e.output)) raise e notify_plugins(conf['observers'], event, session, pkg, pkgdir, file_table=file_table) def notify_plugins(observers, event, session, pkg, pkgdir, triggers=None, dry=False, file_table=None): """notify Python hooks of occurred events If triggers is not None, only Python hooks whose names are listed in them will be triggered. Note: shell hooks will not be triggered in that case. """ for (title, action) in observers[event]: try: if triggers is None: action(session, pkg, pkgdir, file_table) elif (event, title) in triggers: logging.info('notify (forced) %s/%s for %s' % (event, title, pkg)) if not dry: action(session, pkg, pkgdir, file_table) except: logging.error('plugin hooks for %s on %s failed' % (event, pkg)) raise def ensure_dir(dir): if not os.path.exists(dir): os.makedirs(dir) def ensure_cache_dir(conf): ensure_dir(conf['cache_dir']) def ensure_stats_dir(conf): ensure_dir(os.path.join(conf['cache_dir'], 'stats')) def exclude_files(session, pkg, pkgdir, file_table, exclude_specs): """remove files matching `exclude_specs` from storage and exclude them from further processing Side effect: excluded files will be removed from `file_table` """ # enforce spec's Package field specs = [spec for spec in exclude_specs # ignore non file-based exclusion stanzas if 'files' in spec and spec['package'] == pkg['package']] candidates = [] # files eligible for exclusion for spec in specs: # enforce spec's Files field for pat in spec['files'].split(): # ASSUMPTION: `pkgdir` is the CWD; enforced by _add_package for relpath in glob.iglob(pat): candidates.append(relpath) # remove exclusion candidates from FS and DB storage if candidates: logging.info('excluding some files from %s' % pkg) for relpath in candidates: logging.debug('excluding file %s' % relpath) fs_storage.rm_file(pkgdir, relpath) db_storage.rm_file(session, pkg['package'], relpath, file_table) del(file_table[relpath]) def is_excluded_package(pkg, exclude_specs): """check whether a given package match 1+ package exclusion stanzas """ # compute list of *matching* package exclusion stanzas specs = [spec for spec in exclude_specs # ignore non package exclusion stanzas if 'files' not in spec and spec['package'] == pkg['package'] and ('version' not in spec or spec['version'] == pkg['version'])] return bool(specs) def _add_package(pkg, conf, session, sticky=False): """add package `pkg` to both FS and DB storage, and notify plugins handles and logs exceptions """ logging.info('add %s...' % pkg) workdir = os.getcwd() try: pkgdir = pkg.extraction_dir(conf['sources_dir']) if pkgdir is None: logging.warning('package %s has no extracion dir, skipping' % pkg) return if not conf['dry_run'] and 'fs' in conf['backends']: fs_storage.extract_package(pkg, pkgdir) os.chdir(pkgdir) with session.begin_nested(): # single db session for package addition and hook execution: if the # hooks fail, the package won't be added to the db (it will be # tried again at next run) file_table = None if not conf['dry_run'] and 'db' in conf['backends']: file_table = db_storage.add_package(session, pkg, pkgdir, sticky) exclude_files(session, pkg, pkgdir, file_table, conf['exclude']) if not conf['dry_run'] and 'hooks' in conf['backends']: notify(conf, 'add-package', session, pkg, pkgdir, file_table) except: logging.exception('failed to add %s' % pkg) finally: os.chdir(workdir) def _rm_package(pkg, conf, session, db_package=None): """remove package `pkg` from both FS and DB storage, and notify plugins handles and logs exceptions """ logging.info("remove %s..." % pkg) pkgdir = pkg.extraction_dir(conf['sources_dir']) if not db_package: db_package = db_storage.lookup_package(session, pkg['package'], pkg['version']) if not db_package: logging.warn('cannot find package %s, not removing' % pkg) return try: if not conf['dry_run'] and 'hooks' in conf['backends']: notify(conf, 'rm-package', session, pkg, pkgdir) if not conf['dry_run'] and 'fs' in conf['backends']: fs_storage.remove_package(pkg, pkgdir) if not conf['dry_run'] and 'db' in conf['backends']: with session.begin_nested(): db_storage.rm_package(session, pkg, db_package) except: logging.exception('failed to remove %s' % pkg) def _add_suite(conf, session, suite, sticky=False, aliases=[]): """add suite to the table of static suite info """ suite_version = None suite_reldate = None if suite in DEBIAN_RELEASES: suite_info = DEBIAN_RELEASES[suite] suite_version = suite_info['version'] suite_reldate = suite_info['date'] if sticky: assert suite_info['archived'] db_aliases = [SuiteAlias(alias=alias, suite=suite) for alias in aliases] db_suite = SuiteInfo(suite, sticky=sticky, version=suite_version, release_date=suite_reldate, aliases=db_aliases) if not conf['dry_run'] and 'db' in conf['backends']: session.add(db_suite) def extract_new(status, conf, session, mirror): """update stage: list mirror and extract new packages """ ensure_cache_dir(conf) def add_package(pkg): if is_excluded_package(pkg, conf['exclude']): logging.info('skipping excluded package %s' % pkg) return if not db_storage.lookup_package(session, pkg['package'], pkg['version']): # use DB as completion marker: if the package has been inserted, it # means everything went fine last time we tried. If not, we redo # everything, just to be safe _add_package(pkg, conf, session) pkgdir = pkg.extraction_dir(conf['sources_dir']) if conf['force_triggers']: try: notify_plugins(conf['observers'], 'add-package', session, pkg, pkgdir, triggers=conf['force_triggers'], dry=conf['dry_run']) except: logging.exception('trigger failure on %s' % pkg) # add entry for sources.txt, temporarily with no suite associated pkg_id = (pkg['package'], pkg['version']) dsc_rel = os.path.relpath(pkg.dsc_path(), conf['mirror_dir']) pkgdir_rel = os.path.relpath(pkg.extraction_dir(conf['sources_dir']), conf['sources_dir']) status.sources[pkg_id] = pkg.archive_area(), dsc_rel, pkgdir_rel, [] logging.info('add new packages...') for pkg in mirror.ls(): if not conf['single_transaction']: with session.begin(): add_package(pkg) else: add_package(pkg) def garbage_collect(status, conf, session, mirror): """update stage: list db and remove disappeared and expired packages """ logging.info('garbage collection...') for version in session.query(Package).filter(not_(Package.sticky)): pkg = SourcePackage.from_db_model(version) pkg_id = (pkg['package'], pkg['version']) pkgdir = pkg.extraction_dir(conf['sources_dir']) if pkg_id not in mirror.packages: # package is in in Debsources db, but gone from mirror: we # might have to garbage collect it (depending on expiry) expire_days = conf['expire_days'] age = None if os.path.exists(pkgdir): age = datetime.now() - \ datetime.fromtimestamp(os.path.getmtime(pkgdir)) if not age or age.days >= expire_days: _rm_package(pkg, conf, session, db_package=version) else: logging.debug('not removing %s as it is too young' % pkg) if conf['force_triggers']: try: notify_plugins(conf['observers'], 'rm-package', session, pkg, pkgdir, triggers=conf['force_triggers'], dry=conf['dry_run']) except: logging.exception('trigger failure on %s' % pkg) def update_suites(status, conf, session, mirror): """update stage: sweep and recreate suite mappings """ logging.info('update suites mappings...') insert_q = sql.insert(Suite.__table__) insert_params = [] # load suites aliases suites_aliases = mirror.ls_suites_with_aliases() if not conf['dry_run'] and 'db' in conf['backends']: session.query(SuiteAlias).delete() for (suite, pkgs) in six.iteritems(mirror.suites): if not conf['dry_run'] and 'db' in conf['backends']: session.query(Suite).filter_by(suite=suite).delete() for pkg_id in pkgs: (pkg, version) = pkg_id db_package = db_storage.lookup_package(session, pkg, version) if not db_package: logging.warn('package %s/%s not found in suite %s, skipping' % (pkg, version, suite)) else: logging.debug('add suite mapping: %s/%s -> %s' % (pkg, version, suite)) params = {'package_id': db_package.id, 'suite': suite} insert_params.append(params) if pkg_id in status.sources: # fill-in incomplete suite information in status status.sources[pkg_id][-1].append(suite) else: # defensive measure to make update_suites() more reusable logging.warn('cannot find %s/%s during suite update' % (pkg, version)) if not conf['dry_run'] and 'db' in conf['backends'] \ and len(insert_params) >= BULK_FLUSH_THRESHOLD: session.execute(insert_q, insert_params) session.flush() insert_params = [] if not conf['dry_run'] and 'db' in conf['backends']: session.query(SuiteInfo).filter_by(name=suite).delete() _add_suite(conf, session, suite, aliases=suites_aliases[suite]) if not conf['dry_run'] and 'db' in conf['backends'] \ and insert_params: session.execute(insert_q, insert_params) session.flush() # update sources.txt, now that we know the suite mappings src_list_path = os.path.join(conf['cache_dir'], 'sources.txt') with open(src_list_path + '.new', 'w') as src_list: for pkg_id, src_entry in six.iteritems(status.sources): fields = list(pkg_id) fields.extend(src_entry[:-1]) # all except suites fields.append(string.join(src_entry[-1], ',')) src_list.write(string.join(fields, '\t') + '\n') os.rename(src_list_path + '.new', src_list_path) def __target_suites(session, suites=None): if not suites: sticky_suites = statistics.sticky_suites(session) suites = [suite for suite in statistics.suites(session, suites='all') if suite not in sticky_suites] return suites def update_statistics(status, conf, session, suites=None): """update stage: update statistics by default act on all non-sticky, major suites present in the DB. Pass `suites` to override """ logging.info('update statistics...') ensure_cache_dir(conf) suites = __target_suites(session, suites) now = datetime.utcnow() stats_file = os.path.join(conf['cache_dir'], 'stats.data') if os.path.exists(stats_file): # If stats.data exists, load and update it, otherwise start from # scratch. Note: this means that we need to be careful about changing # stats keys, to avoid orphans. # TODO: add check about orphan stats.data entries to debsources-fsck stats = statistics.load_metadata_cache(stats_file) else: stats = {} def store_sloccount_stats(summary, d, prefix, db_obj): """Update stats dictionary `d`, and DB object `db_obj`, with per language sloccount statistics available in `summary`, generating dictionary keys that start with `prefix`. Missing languages in summary will be stored as 0-value entries. """ total_slocs = 0 for lang in SLOCCOUNT_LANGUAGES: k = prefix + '.' + lang v = 0 if lang in summary: v = summary[lang] d[k] = v setattr(db_obj, 'lang_' + lang, v) total_slocs += v d[prefix] = total_slocs # compute overall stats suite = 'ALL' siz = HistorySize(suite, timestamp=now) loc = HistorySlocCount(suite, timestamp=now) for stat in ['disk_usage', 'source_packages', 'source_files', 'ctags']: v = getattr(statistics, stat)(session) stats['total.' + stat] = v setattr(siz, stat, v) store_sloccount_stats(statistics.sloccount_summary(session), stats, 'total.sloccount', loc) if not conf['dry_run'] and 'db' in conf['backends']: session.add(siz) session.add(loc) # Update HistorySize suite_key = 'debian_' hist_siz = dict((suite, HistorySize(suite, timestamp=now)) for suite in suites) for stat in ['disk_usage', 'source_packages', 'source_files', 'ctags']: stats_result = statistics.stats_grouped_by(session, stat) for res in stats_result: if res[0] in suites: stats[suite_key + res[0] + '.' + stat] = res[1] setattr(hist_siz[res[0]], stat, res[1]) if not conf['dry_run'] and 'db' in conf['backends']: for siz in hist_siz.values(): session.add(siz) # update historySlocCount sloccount_res = statistics.stats_grouped_by(session, 'sloccount') hist_loc = dict((suite, HistorySlocCount(suite, timestamp=now)) for suite in suites) for suite in suites: temp = dict((item[1], item[2]) for item in sloccount_res if item[0] == suite) store_sloccount_stats(dict(temp), stats, suite_key + suite + ".sloccount", hist_loc[suite]) if not conf['dry_run'] and 'db' in conf['backends']: for loc in hist_loc.values(): session.add(loc) session.flush() # cache computed stats to on-disk stats file if not conf['dry_run'] and 'fs' in conf['backends']: statistics.save_metadata_cache(stats, stats_file) def update_license_statistics(suites): # compute License stats license_stats_file = os.path.join(conf['cache_dir'], 'license_stats.data') dual_license_file = os.path.join(conf['cache_dir'], 'dual_license.data') license_stats = dict() license_d_stats = dict() hist_lic = dict((suite, HistoryCopyright(suite, timestamp=now)) for suite in suites) results = statistics.get_licenses(session) for suite in suites: temp = dict((item[0], item[2]) for item in results if item[1] == suite) summary = statistics.licenses_summary(temp) for res in summary: license_stats[suite + "." + res.rstrip()] = summary[res] setattr(hist_lic[suite], 'license', res.replace('_', ' ')) setattr(hist_lic[suite], 'files', summary[res]) if not conf['dry_run'] and 'db' in conf['backends']: session.add(hist_lic[suite]) # no historical here, only save to file dual_query = statistics.licenses_summary_w_dual(temp) for res in dual_query: license_d_stats[suite + "." + res.rstrip()] = dual_query[res] # overall dual licenses overall_d_licenses = statistics.licenses_summary_w_dual( statistics.get_licenses(session, 'ALL')) for stat in overall_d_licenses: license_d_stats['overall.' + stat] = overall_d_licenses[stat] # save dual licenses to file if not conf['dry_run'] and 'fs' in conf['backends']: statistics.save_metadata_cache(license_d_stats, dual_license_file) session.flush() overall_licenses = statistics.licenses_summary( statistics.get_licenses(session, 'ALL')) for stat in overall_licenses: lic = HistoryCopyright('ALL', timestamp=now) setattr(lic, 'license', stat.replace('_', ' ')) setattr(lic, 'files', overall_licenses[stat]) license_stats['overall.' + stat] = overall_licenses[stat] if not conf['dry_run'] and 'db' in conf['backends']: session.add(lic) session.flush() if not conf['dry_run'] and 'fs' in conf['backends']: statistics.save_metadata_cache(license_stats, license_stats_file) if 'copyright' in conf['hooks']: update_license_statistics(suites) def update_metadata(status, conf, session): """update stage: update metadata """ logging.info('update metadata...') ensure_cache_dir(conf) # update package prefixes list if not conf['dry_run'] and 'fs' in conf['backends']: prefix_path = os.path.join(conf['cache_dir'], 'pkg-prefixes') with open(prefix_path + '.new', 'w') as out: for prefix in db_storage.pkg_prefixes(session): out.write('%s\n' % prefix) os.rename(prefix_path + '.new', prefix_path) # update timestamp if not conf['dry_run'] and 'fs' in conf['backends']: timestamp_file = os.path.join(conf['cache_dir'], 'last-update') with open(timestamp_file + '.new', 'w') as out: out.write('%s\n' % formatdate()) os.rename(timestamp_file + '.new', timestamp_file) def update_charts(status, conf, session, suites=None): """update stage: rebuild charts""" from debsources import charts logging.info('update charts...') ensure_stats_dir(conf) suites = __target_suites(session, suites) CHARTS = [ # <period, granularity> paris ('1 month', 'hourly'), ('1 year', 'daily'), ('5 years', 'weekly'), ('20 years', 'monthly'), ] # size charts, various metrics for metric in ['source_packages', 'disk_usage', 'source_files', 'ctags']: for (period, granularity) in CHARTS: for suite in suites + ['ALL']: series = getattr(statistics, 'history_size_' + granularity)( session, metric, interval=period, suite=suite) chart_file = os.path.join(conf['cache_dir'], 'stats', '%s-%s-%s.png' % (suite, metric, period.replace(' ', '-'))) if not conf['dry_run']: charts.size_plot(series, chart_file) # sloccount: historical histograms for (period, granularity) in CHARTS: for suite in suites + ['ALL']: # historical histogram mseries = getattr(statistics, 'history_sloc_' + granularity)( session, interval=period, suite=suite) chart_file = os.path.join(conf['cache_dir'], 'stats', '%s-sloc-%s.png' % (suite, period.replace(' ', '-'))) if not conf['dry_run']: charts.multiseries_plot(mseries, chart_file) # sloccount: current pie charts sloc_per_suite = [] for suite in suites + ['ALL']: sloc_suite = suite if sloc_suite == 'ALL': sloc_suite = None slocs = statistics.sloccount_summary(session, suite=sloc_suite) if suite not in ['ALL']: sloc_per_suite.append(slocs) chart_file = os.path.join(conf['cache_dir'], 'stats', '%s-sloc_pie-current.png' % suite) if not conf['dry_run']: charts.pie_chart(slocs, chart_file) # sloccount: bar chart plot if 'charts_top_langs' in conf.keys(): top_langs = int(conf['charts_top_langs']) else: top_langs = 6 chart_file = os.path.join(conf['cache_dir'], 'stats', 'sloc_bar_plot.png') charts.bar_chart(sloc_per_suite, suites, chart_file, top_langs, 'SLOC') def update_license_charts(): # License: historical histogramms for (period, granularity) in CHARTS: for suite in suites + ['ALL']: mseries = getattr(statistics, 'history_copyright_' + granularity)( session, interval=period, suite=suite) chart_file = os.path.join(conf['cache_dir'], 'stats', 'copyright_%s-license-%s.png' % (suite, period.replace(' ', '-'))) if not conf['dry_run']: charts.multiseries_plot(mseries, chart_file, cols=3) # License: overall pie chart overall_licenses = statistics.licenses_summary( statistics.get_licenses(session, 'ALL')) ratio = qry.get_ratio(session) chart_file = os.path.join(conf['cache_dir'], 'stats', 'copyright_overall-license_pie.png') if not conf['dry_run']: charts.pie_chart(overall_licenses, chart_file, ratio) # License: bar chart and per suite pie chart. all_suites = statistics.sticky_suites(session) \ + __target_suites(session, None) licenses_per_suite = [] results = statistics.get_licenses(session) for suite in all_suites: temp = dict((item[0], item[2]) for item in results if item[1] == suite) licenses = statistics.licenses_summary(temp) ratio = qry.get_ratio(session, suite=suite) # draw license pie chart if not conf['dry_run']: chart_file = os.path.join(conf['cache_dir'], 'stats', 'copyright_%s' '-license_pie-current.png' % suite) charts.pie_chart(licenses, chart_file, ratio) licenses_per_suite.append(licenses) chart_file = os.path.join(conf['cache_dir'], 'stats', 'copyright_license_bar_plot.png') if not conf['dry_run']: charts.bar_chart(licenses_per_suite, all_suites, chart_file, top_langs, 'Number of files') # LICENSE CHARTS if 'copyright' in conf['hooks']: update_license_charts() # update stages (STAGE_EXTRACT, STAGE_SUITES, STAGE_GC, STAGE_STATS, STAGE_CACHE, STAGE_CHARTS,) = list(range(1, 7)) __STAGES = { 'extract': STAGE_EXTRACT, 'suites': STAGE_SUITES, 'gc': STAGE_GC, 'stats': STAGE_STATS, 'cache': STAGE_CACHE, 'charts': STAGE_CHARTS, } __STAGE2STR = {v: k for k, v in list(__STAGES.items())} UPDATE_STAGES = set(__STAGES.values()) def parse_stage(s): try: return __STAGES[s] except KeyError: raise ValueError('unknown update stage %s' % s) def parse_stages(stages): return set(map(parse_stage, stages.split())) def pp_stage(stage): try: return __STAGE2STR[stage] except KeyError: raise ValueError('unknown update stage %s' % stage) def update(conf, session, stages=UPDATE_STAGES): """do a full update run """ logging.info('start') logging.info('list mirror packages...') mirror = SourceMirror(conf['mirror_dir']) status = UpdateStatus() if STAGE_EXTRACT in stages: extract_new(status, conf, session, mirror) # stage 1 if STAGE_SUITES in stages: update_suites(status, conf, session, mirror) # stage 2 if STAGE_GC in stages: garbage_collect(status, conf, session, mirror) # stage 3 if STAGE_STATS in stages: update_statistics(status, conf, session) # stage 4 if STAGE_CACHE in stages: update_metadata(status, conf, session) # stage 5 if STAGE_CHARTS in stages: update_charts(status, conf, session) # stage 6 logging.info('finish')
agpl-3.0
[ 3, 1898, 334, 35, 9, 6171, 13, 7280, 221, 710, 1487, 66, 4553, 19782, 665, 815, 32, 4553, 14, 23204, 14, 846, 10827, 199, 3, 1666, 314, 10610, 570, 737, 314, 2746, 13, 1896, 2082, 402, 642, 4084, 436, 737, 199, 3, 4178, 921, 21009, 17143, 14, 23204, 14, 1308, 15, 3187, 2520, 10197, 80, 29, 7096, 15, 16762, 4553, 14, 3187, 27, 65, 29, 6582, 27, 70, 29, 5580, 4149, 27, 16168, 29, 5211, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1487, 66, 4553, 14, 1487, 66, 4553, 365, 2867, 2032, 26, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 199, 3, 1684, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 221, 2104, 1655, 2556, 199, 3, 1937, 314, 9685, 570, 737, 314, 2746, 13, 1896, 2082, 402, 642, 4084, 436, 737, 199, 3, 4178, 921, 21009, 17143, 14, 23204, 14, 1308, 15, 3187, 2520, 10197, 80, 29, 7096, 15, 16762, 4553, 14, 3187, 27, 65, 29, 6582, 27, 70, 29, 16188, 1206, 27, 16168, 29, 5211, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 5739, 199, 646, 2050, 199, 646, 747, 199, 646, 1059, 199, 646, 3873, 199, 199, 646, 3816, 199, 504, 3816, 14, 4912, 492, 2341, 199, 504, 3816, 14, 4912, 492, 1425, 199, 199, 504, 2197, 492, 2197, 199, 504, 3031, 14, 1208, 492, 1475, 602, 199, 504, 8335, 492, 3875, 12, 440, 63, 199, 199, 504, 32610, 4553, 492, 1592, 63, 3494, 199, 504, 32610, 4553, 492, 7449, 63, 3494, 199, 504, 32610, 4553, 492, 11076, 199, 504, 1275, 492, 1827, 465, 1894, 651, 199, 199, 504, 32610, 4553, 14, 20473, 492, 3265, 19419, 879, 63, 907, 906, 21983, 12, 428, 5752, 8760, 63, 26886, 199, 504, 32610, 4553, 14, 16762, 12324, 492, 5800, 28034, 12, 5800, 8599, 199, 504, 32610, 4553, 14, 992, 492, 14453, 2354, 12, 14453, 12, 14453, 14149, 12, 15665, 12, 971, 272, 27829, 2320, 12, 27829, 51, 2102, 2353, 12, 27829, 7384, 199, 504, 32610, 4553, 14, 5781, 63, 800, 11659, 492, 3873, 63, 2758, 199, 199, 20004, 63, 8193, 51, 275, 788, 525, 13, 2491, 297, 283, 5682, 13, 2491, 418, 199, 2826, 63, 5488, 6613, 51, 275, 1211, 7694, 69, 12, 3073, 367, 325, 315, 1804, 9165, 63, 8193, 51, 566, 199, 199, 3, 5696, 1329, 402, 9413, 4730, 2544, 19203, 282, 334, 9377, 9, 5518, 199, 34, 1293, 43, 63, 32762, 63, 19307, 275, 959, 993, 421, 199, 533, 6162, 3694, 8, 785, 304, 272, 408, 1617, 1678, 2004, 5309, 1678, 7858, 624, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 4553, 275, 1052, 339, 768, 1829, 272, 347, 5274, 8, 277, 304, 267, 408, 3189, 367, 314, 641, 13, 4032, 2581, 402, 1350, 6117, 334, 7872, 33, 5274, 14, 2424, 9, 398, 5274, 365, 282, 2600, 687, 6342, 665, 12447, 63, 2339, 12, 428, 8205, 63, 4612, 30, 370, 6346, 267, 665, 28591, 12, 577, 5153, 12, 6778, 6961, 63, 3022, 12, 5698, 649, 654, 6244, 2382, 5698, 649, 654, 365, 282, 769, 402, 5698, 4427, 63, 2339, 83, 398, 408, 267, 372, 291, 423, 4553, 339, 768, 4553, 14, 8345, 272, 347, 5274, 8, 277, 12, 892, 63, 4553, 304, 267, 291, 423, 4553, 275, 892, 63, 4553, 421, 199, 3, 3254, 5554, 6716, 26, 14161, 8599, 12, 14161, 3353, 199, 3, 3254, 664, 16146, 402, 5218, 12604, 27, 2985, 10989, 18833, 282, 394, 269, 322, 830, 477, 1619, 199, 199, 318, 11705, 8, 2190, 12, 1566, 12, 2351, 12, 5496, 12, 5496, 694, 12, 570, 63, 1224, 29, 403, 304, 272, 408, 6814, 334, 4718, 436, 5218, 9, 12604, 402, 8920, 4474, 339, 13550, 3748, 4474, 26, 339, 627, 1050, 13, 2491, 26, 282, 2559, 365, 3769, 3483, 370, 1487, 66, 4553, 27, 2399, 1350, 1584, 489, 1172, 2575, 2757, 23389, 370, 314, 570, 4887, 436, 2399, 3341, 1172, 489, 2575, 2757, 3483, 370, 314, 3050, 339, 627, 14267, 13, 2491, 26, 282, 2559, 365, 3769, 4829, 687, 1487, 66, 4553, 27, 2399, 1350, 1584, 489, 787, 5139, 1777, 402, 314, 570, 4887, 436, 2399, 3341, 787, 5139, 1777, 402, 314, 489, 3050, 339, 2018, 12604, 787, 3032, 314, 2569, 2368, 12, 315, 642, 1865, 26, 339, 627, 2351, 26, 641, 10947, 3050, 2351, 27, 9081, 315, 5759, 6451, 911, 7675, 489, 314, 2351, 370, 506, 20182, 1146, 1771, 12, 399, 1117, 316, 9413, 3050, 23070, 489, 334, 69, 14, 71, 14, 314, 10234, 15, 25818, 402, 2559, 3341, 9, 339, 627, 5496, 26, 282, 32610, 12324, 14, 2980, 8599, 6025, 402, 314, 2559, 3769, 1066, 471, 489, 12188, 339, 627, 5496, 694, 26, 931, 20686, 370, 314, 2559, 2909, 315, 314, 570, 4887, 339, 627, 570, 63, 1224, 26, 282, 2600, 4412, 570, 1561, 370, 6249, 570, 14154, 489, 334, 3235, 9446, 680, 982, 1137, 488, 12, 314, 5759, 883, 19687, 641, 314, 570, 63, 1224, 2883, 489, 370, 5126, 295, 13, 551, 11495, 314, 570, 13, 2253, 436, 675, 314, 5226, 570, 11449, 14, 489, 982, 488, 12, 314, 5759, 911, 1172, 370, 295, 1117, 314, 24928, 1736, 14, 339, 24599, 394, 745, 83, 295, 10302, 543, 314, 2569, 2368, 26, 5496, 694, 12, 2559, 536, 12, 272, 2559, 1015, 339, 408, 272, 2050, 14, 1757, 360, 6814, 450, 83, 367, 450, 83, 7, 450, 334, 1430, 12, 5496, 430, 272, 2559, 12, 1015, 275, 5496, 459, 2491, 995, 5496, 459, 1023, 418, 272, 2088, 275, 788, 1065, 13, 4181, 297, 2850, 2224, 13, 265, 13, 705, 297, 1779, 2850, 1273, 297, 5496, 694, 12, 1779, 2850, 1273, 297, 2559, 12, 1779, 2850, 1273, 297, 1015, 12, 1779, 747, 14, 515, 14, 904, 8, 2190, 459, 1393, 63, 694, 995, 1566, 435, 1987, 68, 5440, 339, 327, 8344, 5218, 12604, 272, 862, 26, 267, 3873, 14, 1074, 63, 1199, 8, 1760, 12, 4635, 29, 5781, 14, 13850, 12, 1816, 876, 1628, 63, 2324, 29, 5781, 63, 2758, 9 ]
[ 1898, 334, 35, 9, 6171, 13, 7280, 221, 710, 1487, 66, 4553, 19782, 665, 815, 32, 4553, 14, 23204, 14, 846, 10827, 199, 3, 1666, 314, 10610, 570, 737, 314, 2746, 13, 1896, 2082, 402, 642, 4084, 436, 737, 199, 3, 4178, 921, 21009, 17143, 14, 23204, 14, 1308, 15, 3187, 2520, 10197, 80, 29, 7096, 15, 16762, 4553, 14, 3187, 27, 65, 29, 6582, 27, 70, 29, 5580, 4149, 27, 16168, 29, 5211, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1487, 66, 4553, 14, 1487, 66, 4553, 365, 2867, 2032, 26, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 199, 3, 1684, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 221, 2104, 1655, 2556, 199, 3, 1937, 314, 9685, 570, 737, 314, 2746, 13, 1896, 2082, 402, 642, 4084, 436, 737, 199, 3, 4178, 921, 21009, 17143, 14, 23204, 14, 1308, 15, 3187, 2520, 10197, 80, 29, 7096, 15, 16762, 4553, 14, 3187, 27, 65, 29, 6582, 27, 70, 29, 16188, 1206, 27, 16168, 29, 5211, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 5739, 199, 646, 2050, 199, 646, 747, 199, 646, 1059, 199, 646, 3873, 199, 199, 646, 3816, 199, 504, 3816, 14, 4912, 492, 2341, 199, 504, 3816, 14, 4912, 492, 1425, 199, 199, 504, 2197, 492, 2197, 199, 504, 3031, 14, 1208, 492, 1475, 602, 199, 504, 8335, 492, 3875, 12, 440, 63, 199, 199, 504, 32610, 4553, 492, 1592, 63, 3494, 199, 504, 32610, 4553, 492, 7449, 63, 3494, 199, 504, 32610, 4553, 492, 11076, 199, 504, 1275, 492, 1827, 465, 1894, 651, 199, 199, 504, 32610, 4553, 14, 20473, 492, 3265, 19419, 879, 63, 907, 906, 21983, 12, 428, 5752, 8760, 63, 26886, 199, 504, 32610, 4553, 14, 16762, 12324, 492, 5800, 28034, 12, 5800, 8599, 199, 504, 32610, 4553, 14, 992, 492, 14453, 2354, 12, 14453, 12, 14453, 14149, 12, 15665, 12, 971, 272, 27829, 2320, 12, 27829, 51, 2102, 2353, 12, 27829, 7384, 199, 504, 32610, 4553, 14, 5781, 63, 800, 11659, 492, 3873, 63, 2758, 199, 199, 20004, 63, 8193, 51, 275, 788, 525, 13, 2491, 297, 283, 5682, 13, 2491, 418, 199, 2826, 63, 5488, 6613, 51, 275, 1211, 7694, 69, 12, 3073, 367, 325, 315, 1804, 9165, 63, 8193, 51, 566, 199, 199, 3, 5696, 1329, 402, 9413, 4730, 2544, 19203, 282, 334, 9377, 9, 5518, 199, 34, 1293, 43, 63, 32762, 63, 19307, 275, 959, 993, 421, 199, 533, 6162, 3694, 8, 785, 304, 272, 408, 1617, 1678, 2004, 5309, 1678, 7858, 624, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 4553, 275, 1052, 339, 768, 1829, 272, 347, 5274, 8, 277, 304, 267, 408, 3189, 367, 314, 641, 13, 4032, 2581, 402, 1350, 6117, 334, 7872, 33, 5274, 14, 2424, 9, 398, 5274, 365, 282, 2600, 687, 6342, 665, 12447, 63, 2339, 12, 428, 8205, 63, 4612, 30, 370, 6346, 267, 665, 28591, 12, 577, 5153, 12, 6778, 6961, 63, 3022, 12, 5698, 649, 654, 6244, 2382, 5698, 649, 654, 365, 282, 769, 402, 5698, 4427, 63, 2339, 83, 398, 408, 267, 372, 291, 423, 4553, 339, 768, 4553, 14, 8345, 272, 347, 5274, 8, 277, 12, 892, 63, 4553, 304, 267, 291, 423, 4553, 275, 892, 63, 4553, 421, 199, 3, 3254, 5554, 6716, 26, 14161, 8599, 12, 14161, 3353, 199, 3, 3254, 664, 16146, 402, 5218, 12604, 27, 2985, 10989, 18833, 282, 394, 269, 322, 830, 477, 1619, 199, 199, 318, 11705, 8, 2190, 12, 1566, 12, 2351, 12, 5496, 12, 5496, 694, 12, 570, 63, 1224, 29, 403, 304, 272, 408, 6814, 334, 4718, 436, 5218, 9, 12604, 402, 8920, 4474, 339, 13550, 3748, 4474, 26, 339, 627, 1050, 13, 2491, 26, 282, 2559, 365, 3769, 3483, 370, 1487, 66, 4553, 27, 2399, 1350, 1584, 489, 1172, 2575, 2757, 23389, 370, 314, 570, 4887, 436, 2399, 3341, 1172, 489, 2575, 2757, 3483, 370, 314, 3050, 339, 627, 14267, 13, 2491, 26, 282, 2559, 365, 3769, 4829, 687, 1487, 66, 4553, 27, 2399, 1350, 1584, 489, 787, 5139, 1777, 402, 314, 570, 4887, 436, 2399, 3341, 787, 5139, 1777, 402, 314, 489, 3050, 339, 2018, 12604, 787, 3032, 314, 2569, 2368, 12, 315, 642, 1865, 26, 339, 627, 2351, 26, 641, 10947, 3050, 2351, 27, 9081, 315, 5759, 6451, 911, 7675, 489, 314, 2351, 370, 506, 20182, 1146, 1771, 12, 399, 1117, 316, 9413, 3050, 23070, 489, 334, 69, 14, 71, 14, 314, 10234, 15, 25818, 402, 2559, 3341, 9, 339, 627, 5496, 26, 282, 32610, 12324, 14, 2980, 8599, 6025, 402, 314, 2559, 3769, 1066, 471, 489, 12188, 339, 627, 5496, 694, 26, 931, 20686, 370, 314, 2559, 2909, 315, 314, 570, 4887, 339, 627, 570, 63, 1224, 26, 282, 2600, 4412, 570, 1561, 370, 6249, 570, 14154, 489, 334, 3235, 9446, 680, 982, 1137, 488, 12, 314, 5759, 883, 19687, 641, 314, 570, 63, 1224, 2883, 489, 370, 5126, 295, 13, 551, 11495, 314, 570, 13, 2253, 436, 675, 314, 5226, 570, 11449, 14, 489, 982, 488, 12, 314, 5759, 911, 1172, 370, 295, 1117, 314, 24928, 1736, 14, 339, 24599, 394, 745, 83, 295, 10302, 543, 314, 2569, 2368, 26, 5496, 694, 12, 2559, 536, 12, 272, 2559, 1015, 339, 408, 272, 2050, 14, 1757, 360, 6814, 450, 83, 367, 450, 83, 7, 450, 334, 1430, 12, 5496, 430, 272, 2559, 12, 1015, 275, 5496, 459, 2491, 995, 5496, 459, 1023, 418, 272, 2088, 275, 788, 1065, 13, 4181, 297, 2850, 2224, 13, 265, 13, 705, 297, 1779, 2850, 1273, 297, 5496, 694, 12, 1779, 2850, 1273, 297, 2559, 12, 1779, 2850, 1273, 297, 1015, 12, 1779, 747, 14, 515, 14, 904, 8, 2190, 459, 1393, 63, 694, 995, 1566, 435, 1987, 68, 5440, 339, 327, 8344, 5218, 12604, 272, 862, 26, 267, 3873, 14, 1074, 63, 1199, 8, 1760, 12, 4635, 29, 5781, 14, 13850, 12, 1816, 876, 1628, 63, 2324, 29, 5781, 63, 2758, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
atreyv/sympy
sympy/physics/vector/tests/test_functions.py
79
18478
from sympy import S, Integral, sin, cos, pi, sqrt, symbols from sympy.physics.vector import (Dyadic, Point, ReferenceFrame, \ Vector) from sympy.physics.vector import (cross, dot, express, \ time_derivative, kinematic_equations, \ outer, partial_velocity, \ get_motion_params) from sympy.physics.vector.functions import dynamicsymbols from sympy.utilities.pytest import raises Vector.simp = True q1, q2, q3, q4, q5 = symbols('q1 q2 q3 q4 q5') N = ReferenceFrame('N') A = N.orientnew('A', 'Axis', [q1, N.z]) B = A.orientnew('B', 'Axis', [q2, A.x]) C = B.orientnew('C', 'Axis', [q3, B.y]) def test_dot(): assert dot(A.x, A.x) == 1 assert dot(A.x, A.y) == 0 assert dot(A.x, A.z) == 0 assert dot(A.y, A.x) == 0 assert dot(A.y, A.y) == 1 assert dot(A.y, A.z) == 0 assert dot(A.z, A.x) == 0 assert dot(A.z, A.y) == 0 assert dot(A.z, A.z) == 1 def test_dot_different_frames(): assert dot(N.x, A.x) == cos(q1) assert dot(N.x, A.y) == -sin(q1) assert dot(N.x, A.z) == 0 assert dot(N.y, A.x) == sin(q1) assert dot(N.y, A.y) == cos(q1) assert dot(N.y, A.z) == 0 assert dot(N.z, A.x) == 0 assert dot(N.z, A.y) == 0 assert dot(N.z, A.z) == 1 assert dot(N.x, A.x + A.y) == sqrt(2)*cos(q1 + pi/4) == dot(A.x + A.y, N.x) assert dot(A.x, C.x) == cos(q3) assert dot(A.x, C.y) == 0 assert dot(A.x, C.z) == sin(q3) assert dot(A.y, C.x) == sin(q2)*sin(q3) assert dot(A.y, C.y) == cos(q2) assert dot(A.y, C.z) == -sin(q2)*cos(q3) assert dot(A.z, C.x) == -cos(q2)*sin(q3) assert dot(A.z, C.y) == sin(q2) assert dot(A.z, C.z) == cos(q2)*cos(q3) def test_cross(): assert cross(A.x, A.x) == 0 assert cross(A.x, A.y) == A.z assert cross(A.x, A.z) == -A.y assert cross(A.y, A.x) == -A.z assert cross(A.y, A.y) == 0 assert cross(A.y, A.z) == A.x assert cross(A.z, A.x) == A.y assert cross(A.z, A.y) == -A.x assert cross(A.z, A.z) == 0 def test_cross_different_frames(): assert cross(N.x, A.x) == sin(q1)*A.z assert cross(N.x, A.y) == cos(q1)*A.z assert cross(N.x, A.z) == -sin(q1)*A.x - cos(q1)*A.y assert cross(N.y, A.x) == -cos(q1)*A.z assert cross(N.y, A.y) == sin(q1)*A.z assert cross(N.y, A.z) == cos(q1)*A.x - sin(q1)*A.y assert cross(N.z, A.x) == A.y assert cross(N.z, A.y) == -A.x assert cross(N.z, A.z) == 0 assert cross(N.x, A.x) == sin(q1)*A.z assert cross(N.x, A.y) == cos(q1)*A.z assert cross(N.x, A.x + A.y) == sin(q1)*A.z + cos(q1)*A.z assert cross(A.x + A.y, N.x) == -sin(q1)*A.z - cos(q1)*A.z assert cross(A.x, C.x) == sin(q3)*C.y assert cross(A.x, C.y) == -sin(q3)*C.x + cos(q3)*C.z assert cross(A.x, C.z) == -cos(q3)*C.y assert cross(C.x, A.x) == -sin(q3)*C.y assert cross(C.y, A.x) == sin(q3)*C.x - cos(q3)*C.z assert cross(C.z, A.x) == cos(q3)*C.y def test_operator_match(): """Test that the output of dot, cross, outer functions match operator behavior. """ A = ReferenceFrame('A') v = A.x + A.y d = v | v zerov = Vector(0) zerod = Dyadic(0) # dot products assert d & d == dot(d, d) assert d & zerod == dot(d, zerod) assert zerod & d == dot(zerod, d) assert d & v == dot(d, v) assert v & d == dot(v, d) assert d & zerov == dot(d, zerov) assert zerov & d == dot(zerov, d) raises(TypeError, lambda: dot(d, S(0))) raises(TypeError, lambda: dot(S(0), d)) raises(TypeError, lambda: dot(d, 0)) raises(TypeError, lambda: dot(0, d)) assert v & v == dot(v, v) assert v & zerov == dot(v, zerov) assert zerov & v == dot(zerov, v) raises(TypeError, lambda: dot(v, S(0))) raises(TypeError, lambda: dot(S(0), v)) raises(TypeError, lambda: dot(v, 0)) raises(TypeError, lambda: dot(0, v)) # cross products raises(TypeError, lambda: cross(d, d)) raises(TypeError, lambda: cross(d, zerod)) raises(TypeError, lambda: cross(zerod, d)) assert d ^ v == cross(d, v) assert v ^ d == cross(v, d) assert d ^ zerov == cross(d, zerov) assert zerov ^ d == cross(zerov, d) assert zerov ^ d == cross(zerov, d) raises(TypeError, lambda: cross(d, S(0))) raises(TypeError, lambda: cross(S(0), d)) raises(TypeError, lambda: cross(d, 0)) raises(TypeError, lambda: cross(0, d)) assert v ^ v == cross(v, v) assert v ^ zerov == cross(v, zerov) assert zerov ^ v == cross(zerov, v) raises(TypeError, lambda: cross(v, S(0))) raises(TypeError, lambda: cross(S(0), v)) raises(TypeError, lambda: cross(v, 0)) raises(TypeError, lambda: cross(0, v)) # outer products raises(TypeError, lambda: outer(d, d)) raises(TypeError, lambda: outer(d, zerod)) raises(TypeError, lambda: outer(zerod, d)) raises(TypeError, lambda: outer(d, v)) raises(TypeError, lambda: outer(v, d)) raises(TypeError, lambda: outer(d, zerov)) raises(TypeError, lambda: outer(zerov, d)) raises(TypeError, lambda: outer(zerov, d)) raises(TypeError, lambda: outer(d, S(0))) raises(TypeError, lambda: outer(S(0), d)) raises(TypeError, lambda: outer(d, 0)) raises(TypeError, lambda: outer(0, d)) assert v | v == outer(v, v) assert v | zerov == outer(v, zerov) assert zerov | v == outer(zerov, v) raises(TypeError, lambda: outer(v, S(0))) raises(TypeError, lambda: outer(S(0), v)) raises(TypeError, lambda: outer(v, 0)) raises(TypeError, lambda: outer(0, v)) def test_express(): assert express(Vector(0), N) == Vector(0) assert express(S(0), N) == S(0) assert express(A.x, C) == cos(q3)*C.x + sin(q3)*C.z assert express(A.y, C) == sin(q2)*sin(q3)*C.x + cos(q2)*C.y - \ sin(q2)*cos(q3)*C.z assert express(A.z, C) == -sin(q3)*cos(q2)*C.x + sin(q2)*C.y + \ cos(q2)*cos(q3)*C.z assert express(A.x, N) == cos(q1)*N.x + sin(q1)*N.y assert express(A.y, N) == -sin(q1)*N.x + cos(q1)*N.y assert express(A.z, N) == N.z assert express(A.x, A) == A.x assert express(A.y, A) == A.y assert express(A.z, A) == A.z assert express(A.x, B) == B.x assert express(A.y, B) == cos(q2)*B.y - sin(q2)*B.z assert express(A.z, B) == sin(q2)*B.y + cos(q2)*B.z assert express(A.x, C) == cos(q3)*C.x + sin(q3)*C.z assert express(A.y, C) == sin(q2)*sin(q3)*C.x + cos(q2)*C.y - \ sin(q2)*cos(q3)*C.z assert express(A.z, C) == -sin(q3)*cos(q2)*C.x + sin(q2)*C.y + \ cos(q2)*cos(q3)*C.z # Check to make sure UnitVectors get converted properly assert express(N.x, N) == N.x assert express(N.y, N) == N.y assert express(N.z, N) == N.z assert express(N.x, A) == (cos(q1)*A.x - sin(q1)*A.y) assert express(N.y, A) == (sin(q1)*A.x + cos(q1)*A.y) assert express(N.z, A) == A.z assert express(N.x, B) == (cos(q1)*B.x - sin(q1)*cos(q2)*B.y + sin(q1)*sin(q2)*B.z) assert express(N.y, B) == (sin(q1)*B.x + cos(q1)*cos(q2)*B.y - sin(q2)*cos(q1)*B.z) assert express(N.z, B) == (sin(q2)*B.y + cos(q2)*B.z) assert express(N.x, C) == ( (cos(q1)*cos(q3) - sin(q1)*sin(q2)*sin(q3))*C.x - sin(q1)*cos(q2)*C.y + (sin(q3)*cos(q1) + sin(q1)*sin(q2)*cos(q3))*C.z) assert express(N.y, C) == ( (sin(q1)*cos(q3) + sin(q2)*sin(q3)*cos(q1))*C.x + cos(q1)*cos(q2)*C.y + (sin(q1)*sin(q3) - sin(q2)*cos(q1)*cos(q3))*C.z) assert express(N.z, C) == (-sin(q3)*cos(q2)*C.x + sin(q2)*C.y + cos(q2)*cos(q3)*C.z) assert express(A.x, N) == (cos(q1)*N.x + sin(q1)*N.y) assert express(A.y, N) == (-sin(q1)*N.x + cos(q1)*N.y) assert express(A.z, N) == N.z assert express(A.x, A) == A.x assert express(A.y, A) == A.y assert express(A.z, A) == A.z assert express(A.x, B) == B.x assert express(A.y, B) == (cos(q2)*B.y - sin(q2)*B.z) assert express(A.z, B) == (sin(q2)*B.y + cos(q2)*B.z) assert express(A.x, C) == (cos(q3)*C.x + sin(q3)*C.z) assert express(A.y, C) == (sin(q2)*sin(q3)*C.x + cos(q2)*C.y - sin(q2)*cos(q3)*C.z) assert express(A.z, C) == (-sin(q3)*cos(q2)*C.x + sin(q2)*C.y + cos(q2)*cos(q3)*C.z) assert express(B.x, N) == (cos(q1)*N.x + sin(q1)*N.y) assert express(B.y, N) == (-sin(q1)*cos(q2)*N.x + cos(q1)*cos(q2)*N.y + sin(q2)*N.z) assert express(B.z, N) == (sin(q1)*sin(q2)*N.x - sin(q2)*cos(q1)*N.y + cos(q2)*N.z) assert express(B.x, A) == A.x assert express(B.y, A) == (cos(q2)*A.y + sin(q2)*A.z) assert express(B.z, A) == (-sin(q2)*A.y + cos(q2)*A.z) assert express(B.x, B) == B.x assert express(B.y, B) == B.y assert express(B.z, B) == B.z assert express(B.x, C) == (cos(q3)*C.x + sin(q3)*C.z) assert express(B.y, C) == C.y assert express(B.z, C) == (-sin(q3)*C.x + cos(q3)*C.z) assert express(C.x, N) == ( (cos(q1)*cos(q3) - sin(q1)*sin(q2)*sin(q3))*N.x + (sin(q1)*cos(q3) + sin(q2)*sin(q3)*cos(q1))*N.y - sin(q3)*cos(q2)*N.z) assert express(C.y, N) == ( -sin(q1)*cos(q2)*N.x + cos(q1)*cos(q2)*N.y + sin(q2)*N.z) assert express(C.z, N) == ( (sin(q3)*cos(q1) + sin(q1)*sin(q2)*cos(q3))*N.x + (sin(q1)*sin(q3) - sin(q2)*cos(q1)*cos(q3))*N.y + cos(q2)*cos(q3)*N.z) assert express(C.x, A) == (cos(q3)*A.x + sin(q2)*sin(q3)*A.y - sin(q3)*cos(q2)*A.z) assert express(C.y, A) == (cos(q2)*A.y + sin(q2)*A.z) assert express(C.z, A) == (sin(q3)*A.x - sin(q2)*cos(q3)*A.y + cos(q2)*cos(q3)*A.z) assert express(C.x, B) == (cos(q3)*B.x - sin(q3)*B.z) assert express(C.y, B) == B.y assert express(C.z, B) == (sin(q3)*B.x + cos(q3)*B.z) assert express(C.x, C) == C.x assert express(C.y, C) == C.y assert express(C.z, C) == C.z == (C.z) # Check to make sure Vectors get converted back to UnitVectors assert N.x == express((cos(q1)*A.x - sin(q1)*A.y), N) assert N.y == express((sin(q1)*A.x + cos(q1)*A.y), N) assert N.x == express((cos(q1)*B.x - sin(q1)*cos(q2)*B.y + sin(q1)*sin(q2)*B.z), N) assert N.y == express((sin(q1)*B.x + cos(q1)*cos(q2)*B.y - sin(q2)*cos(q1)*B.z), N) assert N.z == express((sin(q2)*B.y + cos(q2)*B.z), N) """ These don't really test our code, they instead test the auto simplification (or lack thereof) of SymPy. assert N.x == express(( (cos(q1)*cos(q3)-sin(q1)*sin(q2)*sin(q3))*C.x - sin(q1)*cos(q2)*C.y + (sin(q3)*cos(q1)+sin(q1)*sin(q2)*cos(q3))*C.z), N) assert N.y == express(( (sin(q1)*cos(q3) + sin(q2)*sin(q3)*cos(q1))*C.x + cos(q1)*cos(q2)*C.y + (sin(q1)*sin(q3) - sin(q2)*cos(q1)*cos(q3))*C.z), N) assert N.z == express((-sin(q3)*cos(q2)*C.x + sin(q2)*C.y + cos(q2)*cos(q3)*C.z), N) """ assert A.x == express((cos(q1)*N.x + sin(q1)*N.y), A) assert A.y == express((-sin(q1)*N.x + cos(q1)*N.y), A) assert A.y == express((cos(q2)*B.y - sin(q2)*B.z), A) assert A.z == express((sin(q2)*B.y + cos(q2)*B.z), A) assert A.x == express((cos(q3)*C.x + sin(q3)*C.z), A) # Tripsimp messes up here too. #print express((sin(q2)*sin(q3)*C.x + cos(q2)*C.y - # sin(q2)*cos(q3)*C.z), A) assert A.y == express((sin(q2)*sin(q3)*C.x + cos(q2)*C.y - sin(q2)*cos(q3)*C.z), A) assert A.z == express((-sin(q3)*cos(q2)*C.x + sin(q2)*C.y + cos(q2)*cos(q3)*C.z), A) assert B.x == express((cos(q1)*N.x + sin(q1)*N.y), B) assert B.y == express((-sin(q1)*cos(q2)*N.x + cos(q1)*cos(q2)*N.y + sin(q2)*N.z), B) assert B.z == express((sin(q1)*sin(q2)*N.x - sin(q2)*cos(q1)*N.y + cos(q2)*N.z), B) assert B.y == express((cos(q2)*A.y + sin(q2)*A.z), B) assert B.z == express((-sin(q2)*A.y + cos(q2)*A.z), B) assert B.x == express((cos(q3)*C.x + sin(q3)*C.z), B) assert B.z == express((-sin(q3)*C.x + cos(q3)*C.z), B) """ assert C.x == express(( (cos(q1)*cos(q3)-sin(q1)*sin(q2)*sin(q3))*N.x + (sin(q1)*cos(q3)+sin(q2)*sin(q3)*cos(q1))*N.y - sin(q3)*cos(q2)*N.z), C) assert C.y == express(( -sin(q1)*cos(q2)*N.x + cos(q1)*cos(q2)*N.y + sin(q2)*N.z), C) assert C.z == express(( (sin(q3)*cos(q1)+sin(q1)*sin(q2)*cos(q3))*N.x + (sin(q1)*sin(q3)-sin(q2)*cos(q1)*cos(q3))*N.y + cos(q2)*cos(q3)*N.z), C) """ assert C.x == express((cos(q3)*A.x + sin(q2)*sin(q3)*A.y - sin(q3)*cos(q2)*A.z), C) assert C.y == express((cos(q2)*A.y + sin(q2)*A.z), C) assert C.z == express((sin(q3)*A.x - sin(q2)*cos(q3)*A.y + cos(q2)*cos(q3)*A.z), C) assert C.x == express((cos(q3)*B.x - sin(q3)*B.z), C) assert C.z == express((sin(q3)*B.x + cos(q3)*B.z), C) def test_time_derivative(): #The use of time_derivative for calculations pertaining to scalar #fields has been tested in test_coordinate_vars in test_essential.py A = ReferenceFrame('A') q = dynamicsymbols('q') qd = dynamicsymbols('q', 1) B = A.orientnew('B', 'Axis', [q, A.z]) d = A.x | A.x assert time_derivative(d, B) == (-qd) * (A.y | A.x) + \ (-qd) * (A.x | A.y) d1 = A.x | B.y assert time_derivative(d1, A) == - qd*(A.x|B.x) assert time_derivative(d1, B) == - qd*(A.y|B.y) d2 = A.x | B.x assert time_derivative(d2, A) == qd*(A.x|B.y) assert time_derivative(d2, B) == - qd*(A.y|B.x) d3 = A.x | B.z assert time_derivative(d3, A) == 0 assert time_derivative(d3, B) == - qd*(A.y|B.z) q1, q2, q3, q4 = dynamicsymbols('q1 q2 q3 q4') q1d, q2d, q3d, q4d = dynamicsymbols('q1 q2 q3 q4', 1) q1dd, q2dd, q3dd, q4dd = dynamicsymbols('q1 q2 q3 q4', 2) C = B.orientnew('C', 'Axis', [q4, B.x]) v1 = q1 * A.z v2 = q2*A.x + q3*B.y v3 = q1*A.x + q2*A.y + q3*A.z assert time_derivative(B.x, C) == 0 assert time_derivative(B.y, C) == - q4d*B.z assert time_derivative(B.z, C) == q4d*B.y assert time_derivative(v1, B) == q1d*A.z assert time_derivative(v1, C) == - q1*sin(q)*q4d*A.x + \ q1*cos(q)*q4d*A.y + q1d*A.z assert time_derivative(v2, A) == q2d*A.x - q3*qd*B.x + q3d*B.y assert time_derivative(v2, C) == q2d*A.x - q2*qd*A.y + \ q2*sin(q)*q4d*A.z + q3d*B.y - q3*q4d*B.z assert time_derivative(v3, B) == (q2*qd + q1d)*A.x + \ (-q1*qd + q2d)*A.y + q3d*A.z assert time_derivative(d, C) == - qd*(A.y|A.x) + \ sin(q)*q4d*(A.z|A.x) - qd*(A.x|A.y) + sin(q)*q4d*(A.x|A.z) def test_get_motion_methods(): #Initialization t = dynamicsymbols._t s1, s2, s3 = symbols('s1 s2 s3') S1, S2, S3 = symbols('S1 S2 S3') S4, S5, S6 = symbols('S4 S5 S6') t1, t2 = symbols('t1 t2') a, b, c = dynamicsymbols('a b c') ad, bd, cd = dynamicsymbols('a b c', 1) a2d, b2d, c2d = dynamicsymbols('a b c', 2) v0 = S1*N.x + S2*N.y + S3*N.z v01 = S4*N.x + S5*N.y + S6*N.z v1 = s1*N.x + s2*N.y + s3*N.z v2 = a*N.x + b*N.y + c*N.z v2d = ad*N.x + bd*N.y + cd*N.z v2dd = a2d*N.x + b2d*N.y + c2d*N.z #Test position parameter assert get_motion_params(frame = N) == (0, 0, 0) assert get_motion_params(N, position=v1) == (0, 0, v1) assert get_motion_params(N, position=v2) == (v2dd, v2d, v2) #Test velocity parameter assert get_motion_params(N, velocity=v1) == (0, v1, v1 * t) assert get_motion_params(N, velocity=v1, position=v0, timevalue1=t1) == \ (0, v1, v0 + v1*(t - t1)) answer = get_motion_params(N, velocity=v1, position=v2, timevalue1=t1) answer_expected = (0, v1, v1*t - v1*t1 + v2.subs(t, t1)) assert answer == answer_expected answer = get_motion_params(N, velocity=v2, position=v0, timevalue1=t1) integral_vector = Integral(a, (t, t1, t))*N.x + Integral(b, (t, t1, t))*N.y \ + Integral(c, (t, t1, t))*N.z answer_expected = (v2d, v2, v0 + integral_vector) assert answer == answer_expected #Test acceleration parameter assert get_motion_params(N, acceleration=v1) == \ (v1, v1 * t, v1 * t**2/2) assert get_motion_params(N, acceleration=v1, velocity=v0, position=v2, timevalue1=t1, timevalue2=t2) == \ (v1, (v0 + v1*t - v1*t2), -v0*t1 + v1*t**2/2 + v1*t2*t1 - \ v1*t1**2/2 + t*(v0 - v1*t2) + \ v2.subs(t, t1)) assert get_motion_params(N, acceleration=v1, velocity=v0, position=v01, timevalue1=t1, timevalue2=t2) == \ (v1, v0 + v1*t - v1*t2, -v0*t1 + v01 + v1*t**2/2 + \ v1*t2*t1 - v1*t1**2/2 + \ t*(v0 - v1*t2)) answer = get_motion_params(N, acceleration=a*N.x, velocity=S1*N.x, position=S2*N.x, timevalue1=t1, timevalue2=t2) i1 = Integral(a, (t, t2, t)) answer_expected = (a*N.x, (S1 + i1)*N.x, \ (S2 + Integral(S1 + i1, (t, t1, t)))*N.x) assert answer == answer_expected def test_kin_eqs(): q0, q1, q2, q3 = dynamicsymbols('q0 q1 q2 q3') q0d, q1d, q2d, q3d = dynamicsymbols('q0 q1 q2 q3', 1) u1, u2, u3 = dynamicsymbols('u1 u2 u3') kds = kinematic_equations([u1, u2, u3], [q0, q1, q2, q3], 'quaternion') assert kds == [-0.5 * q0 * u1 - 0.5 * q2 * u3 + 0.5 * q3 * u2 + q1d, -0.5 * q0 * u2 + 0.5 * q1 * u3 - 0.5 * q3 * u1 + q2d, -0.5 * q0 * u3 - 0.5 * q1 * u2 + 0.5 * q2 * u1 + q3d, 0.5 * q1 * u1 + 0.5 * q2 * u2 + 0.5 * q3 * u3 + q0d] def test_partial_velocity(): q1, q2, q3, u1, u2, u3 = dynamicsymbols('q1 q2 q3 u1 u2 u3') u4, u5 = dynamicsymbols('u4, u5') r = symbols('r') N = ReferenceFrame('N') Y = N.orientnew('Y', 'Axis', [q1, N.z]) L = Y.orientnew('L', 'Axis', [q2, Y.x]) R = L.orientnew('R', 'Axis', [q3, L.y]) R.set_ang_vel(N, u1 * L.x + u2 * L.y + u3 * L.z) C = Point('C') C.set_vel(N, u4 * L.x + u5 * (Y.z ^ L.x)) Dmc = C.locatenew('Dmc', r * L.z) Dmc.v2pt_theory(C, N, R) vel_list = [Dmc.vel(N), C.vel(N), R.ang_vel_in(N)] u_list = [u1, u2, u3, u4, u5] assert (partial_velocity(vel_list, u_list, N) == [[- r*L.y, r*L.x, 0, L.x, cos(q2)*L.y - sin(q2)*L.z], [0, 0, 0, L.x, cos(q2)*L.y - sin(q2)*L.z], [L.x, L.y, L.z, 0, 0]])
bsd-3-clause
[ 504, 5840, 492, 428, 12, 23095, 12, 9829, 12, 9794, 12, 6682, 12, 7452, 12, 6698, 199, 504, 5840, 14, 24724, 14, 4106, 492, 334, 36, 11552, 5000, 12, 7584, 12, 10944, 3160, 12, 971, 3303, 11388, 9, 199, 504, 5840, 14, 24724, 14, 4106, 492, 334, 7925, 12, 6308, 12, 4056, 12, 971, 3303, 900, 63, 26851, 12, 1022, 1132, 3889, 63, 15788, 1298, 12, 971, 3303, 6890, 12, 7417, 63, 16350, 12, 971, 3303, 664, 63, 15335, 63, 1162, 9, 199, 504, 5840, 14, 24724, 14, 4106, 14, 5777, 492, 8336, 7450, 199, 504, 5840, 14, 16355, 14, 4462, 492, 6534, 199, 199, 3646, 14, 11184, 275, 715, 199, 81, 17, 12, 1894, 18, 12, 1894, 19, 12, 1894, 20, 12, 1894, 21, 275, 6698, 360, 81, 17, 1894, 18, 1894, 19, 1894, 20, 1894, 21, 358, 199, 46, 275, 10944, 3160, 360, 46, 358, 199, 33, 275, 653, 14, 19676, 1222, 360, 33, 297, 283, 11220, 297, 359, 81, 17, 12, 653, 14, 90, 566, 199, 34, 275, 437, 14, 19676, 1222, 360, 34, 297, 283, 11220, 297, 359, 81, 18, 12, 437, 14, 88, 566, 199, 35, 275, 699, 14, 19676, 1222, 360, 35, 297, 283, 11220, 297, 359, 81, 19, 12, 699, 14, 89, 566, 421, 199, 318, 511, 63, 3287, 837, 272, 702, 6308, 8, 33, 14, 88, 12, 437, 14, 88, 9, 508, 413, 272, 702, 6308, 8, 33, 14, 88, 12, 437, 14, 89, 9, 508, 378, 272, 702, 6308, 8, 33, 14, 88, 12, 437, 14, 90, 9, 508, 378, 339, 702, 6308, 8, 33, 14, 89, 12, 437, 14, 88, 9, 508, 378, 272, 702, 6308, 8, 33, 14, 89, 12, 437, 14, 89, 9, 508, 413, 272, 702, 6308, 8, 33, 14, 89, 12, 437, 14, 90, 9, 508, 378, 339, 702, 6308, 8, 33, 14, 90, 12, 437, 14, 88, 9, 508, 378, 272, 702, 6308, 8, 33, 14, 90, 12, 437, 14, 89, 9, 508, 378, 272, 702, 6308, 8, 33, 14, 90, 12, 437, 14, 90, 9, 508, 413, 421, 199, 318, 511, 63, 3287, 63, 14020, 63, 8444, 837, 272, 702, 6308, 8, 46, 14, 88, 12, 437, 14, 88, 9, 508, 9794, 8, 81, 17, 9, 272, 702, 6308, 8, 46, 14, 88, 12, 437, 14, 89, 9, 508, 446, 5911, 8, 81, 17, 9, 272, 702, 6308, 8, 46, 14, 88, 12, 437, 14, 90, 9, 508, 378, 272, 702, 6308, 8, 46, 14, 89, 12, 437, 14, 88, 9, 508, 9829, 8, 81, 17, 9, 272, 702, 6308, 8, 46, 14, 89, 12, 437, 14, 89, 9, 508, 9794, 8, 81, 17, 9, 272, 702, 6308, 8, 46, 14, 89, 12, 437, 14, 90, 9, 508, 378, 272, 702, 6308, 8, 46, 14, 90, 12, 437, 14, 88, 9, 508, 378, 272, 702, 6308, 8, 46, 14, 90, 12, 437, 14, 89, 9, 508, 378, 272, 702, 6308, 8, 46, 14, 90, 12, 437, 14, 90, 9, 508, 413, 339, 702, 6308, 8, 46, 14, 88, 12, 437, 14, 88, 435, 437, 14, 89, 9, 508, 7452, 8, 18, 3342, 5197, 8, 81, 17, 435, 6682, 15, 20, 9, 508, 6308, 8, 33, 14, 88, 435, 437, 14, 89, 12, 653, 14, 88, 9, 339, 702, 6308, 8, 33, 14, 88, 12, 445, 14, 88, 9, 508, 9794, 8, 81, 19, 9, 272, 702, 6308, 8, 33, 14, 88, 12, 445, 14, 89, 9, 508, 378, 272, 702, 6308, 8, 33, 14, 88, 12, 445, 14, 90, 9, 508, 9829, 8, 81, 19, 9, 272, 702, 6308, 8, 33, 14, 89, 12, 445, 14, 88, 9, 508, 9829, 8, 81, 18, 3342, 5911, 8, 81, 19, 9, 272, 702, 6308, 8, 33, 14, 89, 12, 445, 14, 89, 9, 508, 9794, 8, 81, 18, 9, 272, 702, 6308, 8, 33, 14, 89, 12, 445, 14, 90, 9, 508, 446, 5911, 8, 81, 18, 3342, 5197, 8, 81, 19, 9, 272, 702, 6308, 8, 33, 14, 90, 12, 445, 14, 88, 9, 508, 446, 5197, 8, 81, 18, 3342, 5911, 8, 81, 19, 9, 272, 702, 6308, 8, 33, 14, 90, 12, 445, 14, 89, 9, 508, 9829, 8, 81, 18, 9, 272, 702, 6308, 8, 33, 14, 90, 12, 445, 14, 90, 9, 508, 9794, 8, 81, 18, 3342, 5197, 8, 81, 19, 9, 421, 199, 318, 511, 63, 7925, 837, 272, 702, 8059, 8, 33, 14, 88, 12, 437, 14, 88, 9, 508, 378, 272, 702, 8059, 8, 33, 14, 88, 12, 437, 14, 89, 9, 508, 437, 14, 90, 272, 702, 8059, 8, 33, 14, 88, 12, 437, 14, 90, 9, 508, 446, 33, 14, 89, 339, 702, 8059, 8, 33, 14, 89, 12, 437, 14, 88, 9, 508, 446, 33, 14, 90, 272, 702, 8059, 8, 33, 14, 89, 12, 437, 14, 89, 9, 508, 378, 272, 702, 8059, 8, 33, 14, 89, 12, 437, 14, 90, 9, 508, 437, 14, 88, 339, 702, 8059, 8, 33, 14, 90, 12, 437, 14, 88, 9, 508, 437, 14, 89, 272, 702, 8059, 8, 33, 14, 90, 12, 437, 14, 89, 9, 508, 446, 33, 14, 88, 272, 702, 8059, 8, 33, 14, 90, 12, 437, 14, 90, 9, 508, 378, 421, 199, 318, 511, 63, 7925, 63, 14020, 63, 8444, 837, 272, 702, 8059, 8, 46, 14, 88, 12, 437, 14, 88, 9, 508, 9829, 8, 81, 17, 3342, 33, 14, 90, 272, 702, 8059, 8, 46, 14, 88, 12, 437, 14, 89, 9, 508, 9794, 8, 81, 17, 3342, 33, 14, 90, 272, 702, 8059, 8, 46, 14, 88, 12, 437, 14, 90, 9, 508, 446, 5911, 8, 81, 17, 3342, 33, 14, 88, 446, 9794, 8, 81, 17, 3342, 33, 14, 89, 272, 702, 8059, 8, 46, 14, 89, 12, 437, 14, 88, 9, 508, 446, 5197, 8, 81, 17, 3342, 33, 14, 90, 272, 702, 8059, 8, 46, 14, 89, 12, 437, 14, 89, 9, 508, 9829, 8, 81, 17, 3342, 33, 14, 90, 272, 702, 8059, 8, 46, 14, 89, 12, 437, 14, 90, 9, 508, 9794, 8, 81, 17, 3342, 33, 14, 88, 446, 9829, 8, 81, 17, 3342 ]
[ 5840, 492, 428, 12, 23095, 12, 9829, 12, 9794, 12, 6682, 12, 7452, 12, 6698, 199, 504, 5840, 14, 24724, 14, 4106, 492, 334, 36, 11552, 5000, 12, 7584, 12, 10944, 3160, 12, 971, 3303, 11388, 9, 199, 504, 5840, 14, 24724, 14, 4106, 492, 334, 7925, 12, 6308, 12, 4056, 12, 971, 3303, 900, 63, 26851, 12, 1022, 1132, 3889, 63, 15788, 1298, 12, 971, 3303, 6890, 12, 7417, 63, 16350, 12, 971, 3303, 664, 63, 15335, 63, 1162, 9, 199, 504, 5840, 14, 24724, 14, 4106, 14, 5777, 492, 8336, 7450, 199, 504, 5840, 14, 16355, 14, 4462, 492, 6534, 199, 199, 3646, 14, 11184, 275, 715, 199, 81, 17, 12, 1894, 18, 12, 1894, 19, 12, 1894, 20, 12, 1894, 21, 275, 6698, 360, 81, 17, 1894, 18, 1894, 19, 1894, 20, 1894, 21, 358, 199, 46, 275, 10944, 3160, 360, 46, 358, 199, 33, 275, 653, 14, 19676, 1222, 360, 33, 297, 283, 11220, 297, 359, 81, 17, 12, 653, 14, 90, 566, 199, 34, 275, 437, 14, 19676, 1222, 360, 34, 297, 283, 11220, 297, 359, 81, 18, 12, 437, 14, 88, 566, 199, 35, 275, 699, 14, 19676, 1222, 360, 35, 297, 283, 11220, 297, 359, 81, 19, 12, 699, 14, 89, 566, 421, 199, 318, 511, 63, 3287, 837, 272, 702, 6308, 8, 33, 14, 88, 12, 437, 14, 88, 9, 508, 413, 272, 702, 6308, 8, 33, 14, 88, 12, 437, 14, 89, 9, 508, 378, 272, 702, 6308, 8, 33, 14, 88, 12, 437, 14, 90, 9, 508, 378, 339, 702, 6308, 8, 33, 14, 89, 12, 437, 14, 88, 9, 508, 378, 272, 702, 6308, 8, 33, 14, 89, 12, 437, 14, 89, 9, 508, 413, 272, 702, 6308, 8, 33, 14, 89, 12, 437, 14, 90, 9, 508, 378, 339, 702, 6308, 8, 33, 14, 90, 12, 437, 14, 88, 9, 508, 378, 272, 702, 6308, 8, 33, 14, 90, 12, 437, 14, 89, 9, 508, 378, 272, 702, 6308, 8, 33, 14, 90, 12, 437, 14, 90, 9, 508, 413, 421, 199, 318, 511, 63, 3287, 63, 14020, 63, 8444, 837, 272, 702, 6308, 8, 46, 14, 88, 12, 437, 14, 88, 9, 508, 9794, 8, 81, 17, 9, 272, 702, 6308, 8, 46, 14, 88, 12, 437, 14, 89, 9, 508, 446, 5911, 8, 81, 17, 9, 272, 702, 6308, 8, 46, 14, 88, 12, 437, 14, 90, 9, 508, 378, 272, 702, 6308, 8, 46, 14, 89, 12, 437, 14, 88, 9, 508, 9829, 8, 81, 17, 9, 272, 702, 6308, 8, 46, 14, 89, 12, 437, 14, 89, 9, 508, 9794, 8, 81, 17, 9, 272, 702, 6308, 8, 46, 14, 89, 12, 437, 14, 90, 9, 508, 378, 272, 702, 6308, 8, 46, 14, 90, 12, 437, 14, 88, 9, 508, 378, 272, 702, 6308, 8, 46, 14, 90, 12, 437, 14, 89, 9, 508, 378, 272, 702, 6308, 8, 46, 14, 90, 12, 437, 14, 90, 9, 508, 413, 339, 702, 6308, 8, 46, 14, 88, 12, 437, 14, 88, 435, 437, 14, 89, 9, 508, 7452, 8, 18, 3342, 5197, 8, 81, 17, 435, 6682, 15, 20, 9, 508, 6308, 8, 33, 14, 88, 435, 437, 14, 89, 12, 653, 14, 88, 9, 339, 702, 6308, 8, 33, 14, 88, 12, 445, 14, 88, 9, 508, 9794, 8, 81, 19, 9, 272, 702, 6308, 8, 33, 14, 88, 12, 445, 14, 89, 9, 508, 378, 272, 702, 6308, 8, 33, 14, 88, 12, 445, 14, 90, 9, 508, 9829, 8, 81, 19, 9, 272, 702, 6308, 8, 33, 14, 89, 12, 445, 14, 88, 9, 508, 9829, 8, 81, 18, 3342, 5911, 8, 81, 19, 9, 272, 702, 6308, 8, 33, 14, 89, 12, 445, 14, 89, 9, 508, 9794, 8, 81, 18, 9, 272, 702, 6308, 8, 33, 14, 89, 12, 445, 14, 90, 9, 508, 446, 5911, 8, 81, 18, 3342, 5197, 8, 81, 19, 9, 272, 702, 6308, 8, 33, 14, 90, 12, 445, 14, 88, 9, 508, 446, 5197, 8, 81, 18, 3342, 5911, 8, 81, 19, 9, 272, 702, 6308, 8, 33, 14, 90, 12, 445, 14, 89, 9, 508, 9829, 8, 81, 18, 9, 272, 702, 6308, 8, 33, 14, 90, 12, 445, 14, 90, 9, 508, 9794, 8, 81, 18, 3342, 5197, 8, 81, 19, 9, 421, 199, 318, 511, 63, 7925, 837, 272, 702, 8059, 8, 33, 14, 88, 12, 437, 14, 88, 9, 508, 378, 272, 702, 8059, 8, 33, 14, 88, 12, 437, 14, 89, 9, 508, 437, 14, 90, 272, 702, 8059, 8, 33, 14, 88, 12, 437, 14, 90, 9, 508, 446, 33, 14, 89, 339, 702, 8059, 8, 33, 14, 89, 12, 437, 14, 88, 9, 508, 446, 33, 14, 90, 272, 702, 8059, 8, 33, 14, 89, 12, 437, 14, 89, 9, 508, 378, 272, 702, 8059, 8, 33, 14, 89, 12, 437, 14, 90, 9, 508, 437, 14, 88, 339, 702, 8059, 8, 33, 14, 90, 12, 437, 14, 88, 9, 508, 437, 14, 89, 272, 702, 8059, 8, 33, 14, 90, 12, 437, 14, 89, 9, 508, 446, 33, 14, 88, 272, 702, 8059, 8, 33, 14, 90, 12, 437, 14, 90, 9, 508, 378, 421, 199, 318, 511, 63, 7925, 63, 14020, 63, 8444, 837, 272, 702, 8059, 8, 46, 14, 88, 12, 437, 14, 88, 9, 508, 9829, 8, 81, 17, 3342, 33, 14, 90, 272, 702, 8059, 8, 46, 14, 88, 12, 437, 14, 89, 9, 508, 9794, 8, 81, 17, 3342, 33, 14, 90, 272, 702, 8059, 8, 46, 14, 88, 12, 437, 14, 90, 9, 508, 446, 5911, 8, 81, 17, 3342, 33, 14, 88, 446, 9794, 8, 81, 17, 3342, 33, 14, 89, 272, 702, 8059, 8, 46, 14, 89, 12, 437, 14, 88, 9, 508, 446, 5197, 8, 81, 17, 3342, 33, 14, 90, 272, 702, 8059, 8, 46, 14, 89, 12, 437, 14, 89, 9, 508, 9829, 8, 81, 17, 3342, 33, 14, 90, 272, 702, 8059, 8, 46, 14, 89, 12, 437, 14, 90, 9, 508, 9794, 8, 81, 17, 3342, 33, 14, 88, 446, 9829, 8, 81, 17, 3342, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
krunal3103/servo
tests/wpt/web-platform-tests/tools/html5lib/html5lib/tests/test_stream.py
446
6264
from __future__ import absolute_import, division, unicode_literals from . import support # flake8: noqa import unittest import codecs from io import BytesIO from six.moves import http_client from html5lib.inputstream import (BufferedStream, HTMLInputStream, HTMLUnicodeInputStream, HTMLBinaryInputStream) class BufferedStreamTest(unittest.TestCase): def test_basic(self): s = b"abc" fp = BufferedStream(BytesIO(s)) read = fp.read(10) assert read == s def test_read_length(self): fp = BufferedStream(BytesIO(b"abcdef")) read1 = fp.read(1) assert read1 == b"a" read2 = fp.read(2) assert read2 == b"bc" read3 = fp.read(3) assert read3 == b"def" read4 = fp.read(4) assert read4 == b"" def test_tell(self): fp = BufferedStream(BytesIO(b"abcdef")) read1 = fp.read(1) assert fp.tell() == 1 read2 = fp.read(2) assert fp.tell() == 3 read3 = fp.read(3) assert fp.tell() == 6 read4 = fp.read(4) assert fp.tell() == 6 def test_seek(self): fp = BufferedStream(BytesIO(b"abcdef")) read1 = fp.read(1) assert read1 == b"a" fp.seek(0) read2 = fp.read(1) assert read2 == b"a" read3 = fp.read(2) assert read3 == b"bc" fp.seek(2) read4 = fp.read(2) assert read4 == b"cd" fp.seek(4) read5 = fp.read(2) assert read5 == b"ef" def test_seek_tell(self): fp = BufferedStream(BytesIO(b"abcdef")) read1 = fp.read(1) assert fp.tell() == 1 fp.seek(0) read2 = fp.read(1) assert fp.tell() == 1 read3 = fp.read(2) assert fp.tell() == 3 fp.seek(2) read4 = fp.read(2) assert fp.tell() == 4 fp.seek(4) read5 = fp.read(2) assert fp.tell() == 6 class HTMLUnicodeInputStreamShortChunk(HTMLUnicodeInputStream): _defaultChunkSize = 2 class HTMLBinaryInputStreamShortChunk(HTMLBinaryInputStream): _defaultChunkSize = 2 class HTMLInputStreamTest(unittest.TestCase): def test_char_ascii(self): stream = HTMLInputStream(b"'", encoding='ascii') self.assertEqual(stream.charEncoding[0], 'ascii') self.assertEqual(stream.char(), "'") def test_char_utf8(self): stream = HTMLInputStream('\u2018'.encode('utf-8'), encoding='utf-8') self.assertEqual(stream.charEncoding[0], 'utf-8') self.assertEqual(stream.char(), '\u2018') def test_char_win1252(self): stream = HTMLInputStream("\xa9\xf1\u2019".encode('windows-1252')) self.assertEqual(stream.charEncoding[0], 'windows-1252') self.assertEqual(stream.char(), "\xa9") self.assertEqual(stream.char(), "\xf1") self.assertEqual(stream.char(), "\u2019") def test_bom(self): stream = HTMLInputStream(codecs.BOM_UTF8 + b"'") self.assertEqual(stream.charEncoding[0], 'utf-8') self.assertEqual(stream.char(), "'") def test_utf_16(self): stream = HTMLInputStream((' ' * 1025).encode('utf-16')) self.assertTrue(stream.charEncoding[0] in ['utf-16-le', 'utf-16-be'], stream.charEncoding) self.assertEqual(len(stream.charsUntil(' ', True)), 1025) def test_newlines(self): stream = HTMLBinaryInputStreamShortChunk(codecs.BOM_UTF8 + b"a\nbb\r\nccc\rddddxe") self.assertEqual(stream.position(), (1, 0)) self.assertEqual(stream.charsUntil('c'), "a\nbb\n") self.assertEqual(stream.position(), (3, 0)) self.assertEqual(stream.charsUntil('x'), "ccc\ndddd") self.assertEqual(stream.position(), (4, 4)) self.assertEqual(stream.charsUntil('e'), "x") self.assertEqual(stream.position(), (4, 5)) def test_newlines2(self): size = HTMLUnicodeInputStream._defaultChunkSize stream = HTMLInputStream("\r" * size + "\n") self.assertEqual(stream.charsUntil('x'), "\n" * size) def test_position(self): stream = HTMLBinaryInputStreamShortChunk(codecs.BOM_UTF8 + b"a\nbb\nccc\nddde\nf\ngh") self.assertEqual(stream.position(), (1, 0)) self.assertEqual(stream.charsUntil('c'), "a\nbb\n") self.assertEqual(stream.position(), (3, 0)) stream.unget("\n") self.assertEqual(stream.position(), (2, 2)) self.assertEqual(stream.charsUntil('c'), "\n") self.assertEqual(stream.position(), (3, 0)) stream.unget("\n") self.assertEqual(stream.position(), (2, 2)) self.assertEqual(stream.char(), "\n") self.assertEqual(stream.position(), (3, 0)) self.assertEqual(stream.charsUntil('e'), "ccc\nddd") self.assertEqual(stream.position(), (4, 3)) self.assertEqual(stream.charsUntil('h'), "e\nf\ng") self.assertEqual(stream.position(), (6, 1)) def test_position2(self): stream = HTMLUnicodeInputStreamShortChunk("abc\nd") self.assertEqual(stream.position(), (1, 0)) self.assertEqual(stream.char(), "a") self.assertEqual(stream.position(), (1, 1)) self.assertEqual(stream.char(), "b") self.assertEqual(stream.position(), (1, 2)) self.assertEqual(stream.char(), "c") self.assertEqual(stream.position(), (1, 3)) self.assertEqual(stream.char(), "\n") self.assertEqual(stream.position(), (2, 0)) self.assertEqual(stream.char(), "d") self.assertEqual(stream.position(), (2, 1)) def test_python_issue_20007(self): """ Make sure we have a work-around for Python bug #20007 http://bugs.python.org/issue20007 """ class FakeSocket(object): def makefile(self, _mode, _bufsize=None): return BytesIO(b"HTTP/1.1 200 Ok\r\n\r\nText") source = http_client.HTTPResponse(FakeSocket()) source.begin() stream = HTMLInputStream(source) self.assertEqual(stream.charsUntil(" "), "Text") def buildTestSuite(): return unittest.defaultTestLoader.loadTestsFromName(__name__) def main(): buildTestSuite() unittest.main() if __name__ == '__main__': main()
mpl-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 1275, 492, 2291, 221, 327, 27510, 24, 26, 8151, 199, 646, 2882, 199, 646, 6010, 199, 504, 5890, 492, 11808, 199, 199, 504, 3816, 14, 4912, 492, 1455, 63, 1258, 199, 199, 504, 3517, 21, 773, 14, 1210, 1745, 492, 334, 23139, 3296, 12, 4163, 27611, 12, 3303, 4163, 7087, 27611, 12, 4163, 6636, 27611, 9, 199, 199, 533, 26832, 3296, 774, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 4316, 8, 277, 304, 267, 308, 275, 330, 2, 3175, 2, 267, 4090, 275, 26832, 3296, 8, 15466, 8, 83, 430, 267, 1586, 275, 4090, 14, 739, 8, 709, 9, 267, 702, 1586, 508, 308, 339, 347, 511, 63, 739, 63, 1267, 8, 277, 304, 267, 4090, 275, 26832, 3296, 8, 15466, 8, 66, 2, 10678, 2237, 267, 1586, 17, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 1586, 17, 508, 330, 2, 65, 2, 267, 1586, 18, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 1586, 18, 508, 330, 2, 3776, 2, 267, 1586, 19, 275, 4090, 14, 739, 8, 19, 9, 267, 702, 1586, 19, 508, 330, 2, 318, 2, 267, 1586, 20, 275, 4090, 14, 739, 8, 20, 9, 267, 702, 1586, 20, 508, 330, 341, 339, 347, 511, 63, 9974, 8, 277, 304, 267, 4090, 275, 26832, 3296, 8, 15466, 8, 66, 2, 10678, 2237, 267, 1586, 17, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 4090, 14, 9974, 342, 508, 413, 267, 1586, 18, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 4090, 14, 9974, 342, 508, 650, 267, 1586, 19, 275, 4090, 14, 739, 8, 19, 9, 267, 702, 4090, 14, 9974, 342, 508, 1227, 267, 1586, 20, 275, 4090, 14, 739, 8, 20, 9, 267, 702, 4090, 14, 9974, 342, 508, 1227, 339, 347, 511, 63, 5507, 8, 277, 304, 267, 4090, 275, 26832, 3296, 8, 15466, 8, 66, 2, 10678, 2237, 267, 1586, 17, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 1586, 17, 508, 330, 2, 65, 2, 267, 4090, 14, 5507, 8, 16, 9, 267, 1586, 18, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 1586, 18, 508, 330, 2, 65, 2, 267, 1586, 19, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 1586, 19, 508, 330, 2, 3776, 2, 267, 4090, 14, 5507, 8, 18, 9, 267, 1586, 20, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 1586, 20, 508, 330, 2, 2866, 2, 267, 4090, 14, 5507, 8, 20, 9, 267, 1586, 21, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 1586, 21, 508, 330, 2, 2829, 2, 339, 347, 511, 63, 5507, 63, 9974, 8, 277, 304, 267, 4090, 275, 26832, 3296, 8, 15466, 8, 66, 2, 10678, 2237, 267, 1586, 17, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 4090, 14, 9974, 342, 508, 413, 267, 4090, 14, 5507, 8, 16, 9, 267, 1586, 18, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 4090, 14, 9974, 342, 508, 413, 267, 1586, 19, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 4090, 14, 9974, 342, 508, 650, 267, 4090, 14, 5507, 8, 18, 9, 267, 1586, 20, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 4090, 14, 9974, 342, 508, 841, 267, 4090, 14, 5507, 8, 20, 9, 267, 1586, 21, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 4090, 14, 9974, 342, 508, 1227, 421, 199, 533, 4163, 7087, 27611, 10039, 9856, 8, 4943, 7087, 27611, 304, 272, 485, 885, 9856, 2320, 275, 499, 421, 199, 533, 4163, 6636, 27611, 10039, 9856, 8, 4943, 6636, 27611, 304, 272, 485, 885, 9856, 2320, 275, 499, 421, 199, 533, 4163, 27611, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 1560, 63, 4371, 8, 277, 304, 267, 2547, 275, 4163, 27611, 8, 66, 4507, 401, 2644, 534, 4371, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 7630, 59, 16, 467, 283, 4371, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 3546, 531, 339, 347, 511, 63, 1560, 63, 1624, 24, 8, 277, 304, 267, 2547, 275, 4163, 27611, 2258, 85, 12682, 1370, 2143, 360, 1624, 13, 24, 659, 2644, 534, 1624, 13, 24, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 7630, 59, 16, 467, 283, 1624, 13, 24, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 1557, 85, 12682, 358, 339, 347, 511, 63, 1560, 63, 2676, 19364, 8, 277, 304, 267, 2547, 275, 4163, 27611, 4582, 1800, 25, 60, 1949, 17, 60, 85, 14982, 1674, 2143, 360, 8258, 13, 19364, 1333, 267, 291, 14, 629, 8, 1745, 14, 1560, 7630, 59, 16, 467, 283, 8258, 13, 19364, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 1867, 1800, 25, 531, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 1867, 1949, 17, 531, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 1867, 85, 14982, 531, 339, 347, 511, 63, 16302, 8, 277, 304, 267, 2547, 275, 4163, 27611, 8, 8933, 14, 19550, 63, 6610, 24, 435, 330, 4507, 531, 267, 291, 14, 629, 8, 1745, 14, 1560, 7630, 59, 16, 467, 283, 1624, 13, 24, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 3546, 531, 339, 347, 511, 63, 1624, 63, 975, 8, 277, 304, 267, 2547, 275, 4163, 27611, 4725, 283, 627, 1616, 821, 680, 2143, 360, 1624, 13, 975, 1333, 267, 291, 14, 1815, 8, 1745, 14, 1560, 7630, 59, 16, 61, 315, 788, 1624, 13, 975, 13, 274, 297, 283, 1624, 13, 975, 13, 1235, 995, 2547, 14, 1560, 7630, 9, 267, 291, 14, 629, 8, 552, 8, 1745, 14, 6574, 18667, 360, 1656, 715, 1826, 1616, 821, 9, 339, 347, 511, 63, 13839, 8, 277, 304, 267, 2547, 275, 4163, 6636, 27611, 10039, 9856, 8, 8933, 14, 19550, 63, 6610, 24, 435, 330, 2, 65, 60, 78, 2501, 60, 82, 60, 78, 19504, 60, 82, 17472, 1845, 531, 267, 291, 14, 629, 8, 1745, 14, 3124, 1062, 334, 17, 12, 378, 430, 267, 291, 14, 629, 8, 1745, 14, 6574, 18667, 360, 67 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 1275, 492, 2291, 221, 327, 27510, 24, 26, 8151, 199, 646, 2882, 199, 646, 6010, 199, 504, 5890, 492, 11808, 199, 199, 504, 3816, 14, 4912, 492, 1455, 63, 1258, 199, 199, 504, 3517, 21, 773, 14, 1210, 1745, 492, 334, 23139, 3296, 12, 4163, 27611, 12, 3303, 4163, 7087, 27611, 12, 4163, 6636, 27611, 9, 199, 199, 533, 26832, 3296, 774, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 4316, 8, 277, 304, 267, 308, 275, 330, 2, 3175, 2, 267, 4090, 275, 26832, 3296, 8, 15466, 8, 83, 430, 267, 1586, 275, 4090, 14, 739, 8, 709, 9, 267, 702, 1586, 508, 308, 339, 347, 511, 63, 739, 63, 1267, 8, 277, 304, 267, 4090, 275, 26832, 3296, 8, 15466, 8, 66, 2, 10678, 2237, 267, 1586, 17, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 1586, 17, 508, 330, 2, 65, 2, 267, 1586, 18, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 1586, 18, 508, 330, 2, 3776, 2, 267, 1586, 19, 275, 4090, 14, 739, 8, 19, 9, 267, 702, 1586, 19, 508, 330, 2, 318, 2, 267, 1586, 20, 275, 4090, 14, 739, 8, 20, 9, 267, 702, 1586, 20, 508, 330, 341, 339, 347, 511, 63, 9974, 8, 277, 304, 267, 4090, 275, 26832, 3296, 8, 15466, 8, 66, 2, 10678, 2237, 267, 1586, 17, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 4090, 14, 9974, 342, 508, 413, 267, 1586, 18, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 4090, 14, 9974, 342, 508, 650, 267, 1586, 19, 275, 4090, 14, 739, 8, 19, 9, 267, 702, 4090, 14, 9974, 342, 508, 1227, 267, 1586, 20, 275, 4090, 14, 739, 8, 20, 9, 267, 702, 4090, 14, 9974, 342, 508, 1227, 339, 347, 511, 63, 5507, 8, 277, 304, 267, 4090, 275, 26832, 3296, 8, 15466, 8, 66, 2, 10678, 2237, 267, 1586, 17, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 1586, 17, 508, 330, 2, 65, 2, 267, 4090, 14, 5507, 8, 16, 9, 267, 1586, 18, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 1586, 18, 508, 330, 2, 65, 2, 267, 1586, 19, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 1586, 19, 508, 330, 2, 3776, 2, 267, 4090, 14, 5507, 8, 18, 9, 267, 1586, 20, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 1586, 20, 508, 330, 2, 2866, 2, 267, 4090, 14, 5507, 8, 20, 9, 267, 1586, 21, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 1586, 21, 508, 330, 2, 2829, 2, 339, 347, 511, 63, 5507, 63, 9974, 8, 277, 304, 267, 4090, 275, 26832, 3296, 8, 15466, 8, 66, 2, 10678, 2237, 267, 1586, 17, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 4090, 14, 9974, 342, 508, 413, 267, 4090, 14, 5507, 8, 16, 9, 267, 1586, 18, 275, 4090, 14, 739, 8, 17, 9, 267, 702, 4090, 14, 9974, 342, 508, 413, 267, 1586, 19, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 4090, 14, 9974, 342, 508, 650, 267, 4090, 14, 5507, 8, 18, 9, 267, 1586, 20, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 4090, 14, 9974, 342, 508, 841, 267, 4090, 14, 5507, 8, 20, 9, 267, 1586, 21, 275, 4090, 14, 739, 8, 18, 9, 267, 702, 4090, 14, 9974, 342, 508, 1227, 421, 199, 533, 4163, 7087, 27611, 10039, 9856, 8, 4943, 7087, 27611, 304, 272, 485, 885, 9856, 2320, 275, 499, 421, 199, 533, 4163, 6636, 27611, 10039, 9856, 8, 4943, 6636, 27611, 304, 272, 485, 885, 9856, 2320, 275, 499, 421, 199, 533, 4163, 27611, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 1560, 63, 4371, 8, 277, 304, 267, 2547, 275, 4163, 27611, 8, 66, 4507, 401, 2644, 534, 4371, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 7630, 59, 16, 467, 283, 4371, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 3546, 531, 339, 347, 511, 63, 1560, 63, 1624, 24, 8, 277, 304, 267, 2547, 275, 4163, 27611, 2258, 85, 12682, 1370, 2143, 360, 1624, 13, 24, 659, 2644, 534, 1624, 13, 24, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 7630, 59, 16, 467, 283, 1624, 13, 24, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 1557, 85, 12682, 358, 339, 347, 511, 63, 1560, 63, 2676, 19364, 8, 277, 304, 267, 2547, 275, 4163, 27611, 4582, 1800, 25, 60, 1949, 17, 60, 85, 14982, 1674, 2143, 360, 8258, 13, 19364, 1333, 267, 291, 14, 629, 8, 1745, 14, 1560, 7630, 59, 16, 467, 283, 8258, 13, 19364, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 1867, 1800, 25, 531, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 1867, 1949, 17, 531, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 1867, 85, 14982, 531, 339, 347, 511, 63, 16302, 8, 277, 304, 267, 2547, 275, 4163, 27611, 8, 8933, 14, 19550, 63, 6610, 24, 435, 330, 4507, 531, 267, 291, 14, 629, 8, 1745, 14, 1560, 7630, 59, 16, 467, 283, 1624, 13, 24, 358, 267, 291, 14, 629, 8, 1745, 14, 1560, 1062, 3546, 531, 339, 347, 511, 63, 1624, 63, 975, 8, 277, 304, 267, 2547, 275, 4163, 27611, 4725, 283, 627, 1616, 821, 680, 2143, 360, 1624, 13, 975, 1333, 267, 291, 14, 1815, 8, 1745, 14, 1560, 7630, 59, 16, 61, 315, 788, 1624, 13, 975, 13, 274, 297, 283, 1624, 13, 975, 13, 1235, 995, 2547, 14, 1560, 7630, 9, 267, 291, 14, 629, 8, 552, 8, 1745, 14, 6574, 18667, 360, 1656, 715, 1826, 1616, 821, 9, 339, 347, 511, 63, 13839, 8, 277, 304, 267, 2547, 275, 4163, 6636, 27611, 10039, 9856, 8, 8933, 14, 19550, 63, 6610, 24, 435, 330, 2, 65, 60, 78, 2501, 60, 82, 60, 78, 19504, 60, 82, 17472, 1845, 531, 267, 291, 14, 629, 8, 1745, 14, 3124, 1062, 334, 17, 12, 378, 430, 267, 291, 14, 629, 8, 1745, 14, 6574, 18667, 360, 67, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dednal/chromium.src
third_party/closure_linter/closure_linter/errorrules_test.py
126
3658
#!/usr/bin/env python # Copyright 2013 The Closure Linter Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Medium tests for the gjslint errorrules. Currently its just verifying that warnings can't be disabled. """ import gflags as flags import unittest as googletest from closure_linter import errors from closure_linter import runner from closure_linter.common import erroraccumulator flags.FLAGS.strict = True flags.FLAGS.limited_doc_files = ('dummy.js', 'externs.js') flags.FLAGS.closurized_namespaces = ('goog', 'dummy') class ErrorRulesTest(googletest.TestCase): """Test case to for gjslint errorrules.""" def testNoMaxLineLengthFlagExists(self): """Tests that --max_line_length flag does not exists.""" self.assertTrue('max_line_length' not in flags.FLAGS.FlagDict()) def testGetMaxLineLength(self): """Tests warning are reported for line greater than 80. """ # One line > 100 and one line > 80 and < 100. So should produce two # line too long error. original = [ 'goog.require(\'dummy.aa\');', '', 'function a() {', ' dummy.aa.i = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13' ' + 14 + 15 + 16 + 17 + 18 + 19 + 20;', ' dummy.aa.j = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13' ' + 14 + 15 + 16 + 17 + 18;', '}', '' ] # Expect line too long. expected = [errors.LINE_TOO_LONG, errors.LINE_TOO_LONG] self._AssertErrors(original, expected) def testNoDisableFlagExists(self): """Tests that --disable flag does not exists.""" self.assertTrue('disable' not in flags.FLAGS.FlagDict()) def testWarningsNotDisabled(self): """Tests warnings are reported when nothing is disabled. """ original = [ 'goog.require(\'dummy.aa\');', 'goog.require(\'dummy.Cc\');', 'goog.require(\'dummy.Dd\');', '', 'function a() {', ' dummy.aa.i = 1;', ' dummy.Cc.i = 1;', ' dummy.Dd.i = 1;', '}', ] expected = [errors.GOOG_REQUIRES_NOT_ALPHABETIZED, errors.FILE_MISSING_NEWLINE] self._AssertErrors(original, expected) def _AssertErrors(self, original, expected_errors, include_header=True): """Asserts that the error fixer corrects original to expected.""" if include_header: original = self._GetHeader() + original # Trap gjslint's output parse it to get messages added. error_accumulator = erroraccumulator.ErrorAccumulator() runner.Run('testing.js', error_accumulator, source=original) error_nums = [e.code for e in error_accumulator.GetErrors()] error_nums.sort() expected_errors.sort() self.assertListEqual(error_nums, expected_errors) def _GetHeader(self): """Returns a fake header for a JavaScript file.""" return [ '// Copyright 2011 Google Inc. All Rights Reserved.', '', '/**', ' * @fileoverview Fake file overview.', ' * @author fake@google.com (Fake Person)', ' */', '' ] if __name__ == '__main__': googletest.main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6171, 710, 5980, 3253, 491, 1058, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 26139, 2295, 367, 314, 486, 74, 2482, 442, 1125, 4423, 14, 199, 199, 31499, 2399, 2951, 31866, 626, 3598, 883, 1133, 506, 6980, 14, 199, 624, 4388, 199, 646, 486, 2469, 465, 3285, 199, 646, 2882, 465, 31141, 199, 199, 504, 17903, 63, 25240, 492, 2552, 199, 504, 17903, 63, 25240, 492, 7876, 199, 504, 17903, 63, 25240, 14, 2330, 492, 1125, 21417, 199, 199, 2469, 14, 4831, 14, 4768, 275, 715, 199, 2469, 14, 4831, 14, 14136, 63, 1301, 63, 1725, 275, 661, 5869, 14, 3596, 297, 283, 476, 351, 561, 14, 3596, 358, 199, 2469, 14, 4831, 14, 1251, 5105, 1759, 63, 9247, 275, 661, 28069, 297, 283, 5869, 358, 421, 199, 533, 4520, 12920, 774, 8, 3098, 396, 14, 1746, 304, 523, 408, 774, 1930, 370, 367, 486, 74, 2482, 442, 1125, 4423, 1041, 819, 347, 511, 1944, 4261, 3049, 4625, 5318, 7965, 8, 277, 304, 272, 408, 2925, 626, 1553, 988, 63, 604, 63, 1267, 3305, 1630, 440, 3495, 1041, 272, 291, 14, 1815, 360, 988, 63, 604, 63, 1267, 7, 440, 315, 3285, 14, 4831, 14, 5318, 2141, 1012, 819, 347, 19970, 4261, 3049, 4625, 8, 277, 304, 272, 408, 2925, 5721, 787, 14581, 367, 1004, 8932, 2419, 5939, 14, 272, 408, 339, 327, 7309, 1004, 690, 2948, 436, 1373, 1004, 690, 5939, 436, 665, 2948, 14, 2002, 1077, 7389, 2877, 272, 327, 1004, 4634, 1846, 1125, 14, 272, 3379, 275, 359, 267, 283, 28069, 14, 4365, 30338, 5869, 14, 2158, 60, 358, 10805, 267, 3260, 267, 283, 1593, 282, 342, 469, 297, 267, 283, 221, 7283, 14, 2158, 14, 73, 275, 413, 435, 499, 435, 650, 435, 841, 435, 959, 435, 1227, 435, 1520, 435, 1695, 435, 1749, 435, 1616, 435, 4119, 435, 3144, 435, 4944, 7, 267, 283, 435, 4329, 435, 4114, 435, 3193, 435, 5557, 435, 6155, 435, 5851, 435, 3388, 10805, 267, 283, 221, 7283, 14, 2158, 14, 74, 275, 413, 435, 499, 435, 650, 435, 841, 435, 959, 435, 1227, 435, 1520, 435, 1695, 435, 1749, 435, 1616, 435, 4119, 435, 3144, 435, 4944, 7, 267, 283, 435, 4329, 435, 4114, 435, 3193, 435, 5557, 435, 6155, 10805, 267, 283, 7293, 267, 2125, 267, 1622, 339, 327, 15100, 1004, 4634, 1846, 14, 272, 1420, 275, 359, 2550, 14, 6174, 63, 30947, 63, 12375, 12, 2552, 14, 6174, 63, 30947, 63, 12375, 61, 339, 291, 423, 9699, 9298, 8, 5043, 12, 1420, 9, 819, 347, 511, 1944, 13707, 5318, 7965, 8, 277, 304, 272, 408, 2925, 626, 1553, 5993, 3305, 1630, 440, 3495, 1041, 272, 291, 14, 1815, 360, 5993, 7, 440, 315, 3285, 14, 4831, 14, 5318, 2141, 1012, 819, 347, 511, 15921, 1763, 15049, 8, 277, 304, 272, 408, 2925, 3598, 787, 14581, 1380, 6548, 365, 6980, 14, 272, 408, 272, 3379, 275, 359, 267, 283, 28069, 14, 4365, 30338, 5869, 14, 2158, 60, 358, 10805, 267, 283, 28069, 14, 4365, 30338, 5869, 14, 21426, 60, 358, 10805, 267, 283, 28069, 14, 4365, 30338, 5869, 14, 21793, 60, 358, 10805, 267, 3260, 267, 283, 1593, 282, 342, 469, 297, 267, 283, 221, 7283, 14, 2158, 14, 73, 275, 413, 10805, 267, 283, 221, 7283, 14, 21426, 14, 73, 275, 413, 10805, 267, 283, 221, 7283, 14, 21793, 14, 73, 275, 413, 10805, 267, 283, 7293, 267, 1622, 339, 1420, 275, 359, 2550, 14, 17316, 39, 63, 5255, 41, 3830, 63, 4609, 63, 748, 9791, 1217, 775, 18732, 12, 355, 2552, 14, 3817, 63, 18701, 63, 28758, 61, 339, 291, 423, 9699, 9298, 8, 5043, 12, 1420, 9, 819, 347, 485, 9699, 9298, 8, 277, 12, 3379, 12, 1420, 63, 2550, 12, 2387, 63, 1291, 29, 549, 304, 272, 408, 9699, 83, 626, 314, 1125, 24739, 3211, 83, 3379, 370, 1420, 1041, 272, 340, 2387, 63, 1291, 26, 489, 3379, 275, 291, 423, 1002, 2567, 342, 435, 3379, 339, 327, 377, 1330, 486, 74, 2482, 442, 1159, 1072, 2198, 652, 370, 664, 3788, 3483, 14, 272, 1125, 63, 21417, 275, 1125, 21417, 14, 547, 23384, 6109, 342, 272, 7876, 14, 2540, 360, 4776, 14, 3596, 297, 1125, 63, 21417, 12, 1350, 29, 5043, 9, 272, 1125, 63, 16084, 275, 359, 69, 14, 600, 367, 325, 315, 1125, 63, 21417, 14, 1002, 9298, 5106, 339, 1125, 63, 16084, 14, 3191, 342, 272, 1420, 63, 2550, 14, 3191, 342, 272, 291, 14, 16671, 8, 705, 63, 16084, 12, 1420, 63, 2550, 9, 819, 347, 485, 1002, 2567, 8, 277, 304, 272, 408, 3407, 282, 4026, 1406, 367, 282, 15250, 570, 1041, 272, 372, 359, 267, 18290, 1898, 7760, 4475, 3277, 14, 2900, 5924, 5702, 3130, 267, 3260, 267, 1994, 538, 297, 267, 283, 627, 768, 493, 21753, 7777, 570, 23503, 3130, 267, 283, 627, 768, 2502, 4026, 32, 3098, 14, 957, 334, 8249, 8028, 3196, 267, 283, 627, 3678, 267, 2125, 267, 1622, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 31141, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6171, 710, 5980, 3253, 491, 1058, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 26139, 2295, 367, 314, 486, 74, 2482, 442, 1125, 4423, 14, 199, 199, 31499, 2399, 2951, 31866, 626, 3598, 883, 1133, 506, 6980, 14, 199, 624, 4388, 199, 646, 486, 2469, 465, 3285, 199, 646, 2882, 465, 31141, 199, 199, 504, 17903, 63, 25240, 492, 2552, 199, 504, 17903, 63, 25240, 492, 7876, 199, 504, 17903, 63, 25240, 14, 2330, 492, 1125, 21417, 199, 199, 2469, 14, 4831, 14, 4768, 275, 715, 199, 2469, 14, 4831, 14, 14136, 63, 1301, 63, 1725, 275, 661, 5869, 14, 3596, 297, 283, 476, 351, 561, 14, 3596, 358, 199, 2469, 14, 4831, 14, 1251, 5105, 1759, 63, 9247, 275, 661, 28069, 297, 283, 5869, 358, 421, 199, 533, 4520, 12920, 774, 8, 3098, 396, 14, 1746, 304, 523, 408, 774, 1930, 370, 367, 486, 74, 2482, 442, 1125, 4423, 1041, 819, 347, 511, 1944, 4261, 3049, 4625, 5318, 7965, 8, 277, 304, 272, 408, 2925, 626, 1553, 988, 63, 604, 63, 1267, 3305, 1630, 440, 3495, 1041, 272, 291, 14, 1815, 360, 988, 63, 604, 63, 1267, 7, 440, 315, 3285, 14, 4831, 14, 5318, 2141, 1012, 819, 347, 19970, 4261, 3049, 4625, 8, 277, 304, 272, 408, 2925, 5721, 787, 14581, 367, 1004, 8932, 2419, 5939, 14, 272, 408, 339, 327, 7309, 1004, 690, 2948, 436, 1373, 1004, 690, 5939, 436, 665, 2948, 14, 2002, 1077, 7389, 2877, 272, 327, 1004, 4634, 1846, 1125, 14, 272, 3379, 275, 359, 267, 283, 28069, 14, 4365, 30338, 5869, 14, 2158, 60, 358, 10805, 267, 3260, 267, 283, 1593, 282, 342, 469, 297, 267, 283, 221, 7283, 14, 2158, 14, 73, 275, 413, 435, 499, 435, 650, 435, 841, 435, 959, 435, 1227, 435, 1520, 435, 1695, 435, 1749, 435, 1616, 435, 4119, 435, 3144, 435, 4944, 7, 267, 283, 435, 4329, 435, 4114, 435, 3193, 435, 5557, 435, 6155, 435, 5851, 435, 3388, 10805, 267, 283, 221, 7283, 14, 2158, 14, 74, 275, 413, 435, 499, 435, 650, 435, 841, 435, 959, 435, 1227, 435, 1520, 435, 1695, 435, 1749, 435, 1616, 435, 4119, 435, 3144, 435, 4944, 7, 267, 283, 435, 4329, 435, 4114, 435, 3193, 435, 5557, 435, 6155, 10805, 267, 283, 7293, 267, 2125, 267, 1622, 339, 327, 15100, 1004, 4634, 1846, 14, 272, 1420, 275, 359, 2550, 14, 6174, 63, 30947, 63, 12375, 12, 2552, 14, 6174, 63, 30947, 63, 12375, 61, 339, 291, 423, 9699, 9298, 8, 5043, 12, 1420, 9, 819, 347, 511, 1944, 13707, 5318, 7965, 8, 277, 304, 272, 408, 2925, 626, 1553, 5993, 3305, 1630, 440, 3495, 1041, 272, 291, 14, 1815, 360, 5993, 7, 440, 315, 3285, 14, 4831, 14, 5318, 2141, 1012, 819, 347, 511, 15921, 1763, 15049, 8, 277, 304, 272, 408, 2925, 3598, 787, 14581, 1380, 6548, 365, 6980, 14, 272, 408, 272, 3379, 275, 359, 267, 283, 28069, 14, 4365, 30338, 5869, 14, 2158, 60, 358, 10805, 267, 283, 28069, 14, 4365, 30338, 5869, 14, 21426, 60, 358, 10805, 267, 283, 28069, 14, 4365, 30338, 5869, 14, 21793, 60, 358, 10805, 267, 3260, 267, 283, 1593, 282, 342, 469, 297, 267, 283, 221, 7283, 14, 2158, 14, 73, 275, 413, 10805, 267, 283, 221, 7283, 14, 21426, 14, 73, 275, 413, 10805, 267, 283, 221, 7283, 14, 21793, 14, 73, 275, 413, 10805, 267, 283, 7293, 267, 1622, 339, 1420, 275, 359, 2550, 14, 17316, 39, 63, 5255, 41, 3830, 63, 4609, 63, 748, 9791, 1217, 775, 18732, 12, 355, 2552, 14, 3817, 63, 18701, 63, 28758, 61, 339, 291, 423, 9699, 9298, 8, 5043, 12, 1420, 9, 819, 347, 485, 9699, 9298, 8, 277, 12, 3379, 12, 1420, 63, 2550, 12, 2387, 63, 1291, 29, 549, 304, 272, 408, 9699, 83, 626, 314, 1125, 24739, 3211, 83, 3379, 370, 1420, 1041, 272, 340, 2387, 63, 1291, 26, 489, 3379, 275, 291, 423, 1002, 2567, 342, 435, 3379, 339, 327, 377, 1330, 486, 74, 2482, 442, 1159, 1072, 2198, 652, 370, 664, 3788, 3483, 14, 272, 1125, 63, 21417, 275, 1125, 21417, 14, 547, 23384, 6109, 342, 272, 7876, 14, 2540, 360, 4776, 14, 3596, 297, 1125, 63, 21417, 12, 1350, 29, 5043, 9, 272, 1125, 63, 16084, 275, 359, 69, 14, 600, 367, 325, 315, 1125, 63, 21417, 14, 1002, 9298, 5106, 339, 1125, 63, 16084, 14, 3191, 342, 272, 1420, 63, 2550, 14, 3191, 342, 272, 291, 14, 16671, 8, 705, 63, 16084, 12, 1420, 63, 2550, 9, 819, 347, 485, 1002, 2567, 8, 277, 304, 272, 408, 3407, 282, 4026, 1406, 367, 282, 15250, 570, 1041, 272, 372, 359, 267, 18290, 1898, 7760, 4475, 3277, 14, 2900, 5924, 5702, 3130, 267, 3260, 267, 1994, 538, 297, 267, 283, 627, 768, 493, 21753, 7777, 570, 23503, 3130, 267, 283, 627, 768, 2502, 4026, 32, 3098, 14, 957, 334, 8249, 8028, 3196, 267, 283, 627, 3678, 267, 2125, 267, 1622, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 31141, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
MiLk/youtube-dl
youtube_dl/extractor/justintv.py
5
6037
from __future__ import unicode_literals import json import os import re from .common import InfoExtractor from ..utils import ( compat_str, ExtractorError, formatSeconds, ) class JustinTVIE(InfoExtractor): """Information extractor for justin.tv and twitch.tv""" # TODO: One broadcast may be split into multiple videos. The key # 'broadcast_id' is the same for all parts, and 'broadcast_part' # starts at 1 and increases. Can we treat all parts as one video? _VALID_URL = r"""(?x)^(?:http://)?(?:www\.)?(?:twitch|justin)\.tv/ (?: (?P<channelid>[^/]+)| (?:(?:[^/]+)/b/(?P<videoid>[^/]+))| (?:(?:[^/]+)/c/(?P<chapterid>[^/]+)) ) /?(?:\#.*)?$ """ _JUSTIN_PAGE_LIMIT = 100 IE_NAME = 'justin.tv' IE_DESC = 'justin.tv and twitch.tv' _TEST = { 'url': 'http://www.twitch.tv/thegamedevhub/b/296128360', 'md5': 'ecaa8a790c22a40770901460af191c9a', 'info_dict': { 'id': '296128360', 'ext': 'flv', 'upload_date': '20110927', 'uploader_id': 25114803, 'uploader': 'thegamedevhub', 'title': 'Beginner Series - Scripting With Python Pt.1' } } # Return count of items, list of *valid* items def _parse_page(self, url, video_id): info_json = self._download_webpage(url, video_id, 'Downloading video info JSON', 'unable to download video info JSON') response = json.loads(info_json) if type(response) != list: error_text = response.get('error', 'unknown error') raise ExtractorError('Justin.tv API: %s' % error_text) info = [] for clip in response: video_url = clip['video_file_url'] if video_url: video_extension = os.path.splitext(video_url)[1][1:] video_date = re.sub('-', '', clip['start_time'][:10]) video_uploader_id = clip.get('user_id', clip.get('channel_id')) video_id = clip['id'] video_title = clip.get('title', video_id) info.append({ 'id': compat_str(video_id), 'url': video_url, 'title': video_title, 'uploader': clip.get('channel_name', video_uploader_id), 'uploader_id': video_uploader_id, 'upload_date': video_date, 'ext': video_extension, }) return (len(response), info) def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) api_base = 'http://api.justin.tv' paged = False if mobj.group('channelid'): paged = True video_id = mobj.group('channelid') api = api_base + '/channel/archives/%s.json' % video_id elif mobj.group('chapterid'): chapter_id = mobj.group('chapterid') webpage = self._download_webpage(url, chapter_id) m = re.search(r'PP\.archive_id = "([0-9]+)";', webpage) if not m: raise ExtractorError('Cannot find archive of a chapter') archive_id = m.group(1) api = api_base + '/broadcast/by_chapter/%s.xml' % chapter_id doc = self._download_xml( api, chapter_id, note='Downloading chapter information', errnote='Chapter information download failed') for a in doc.findall('.//archive'): if archive_id == a.find('./id').text: break else: raise ExtractorError('Could not find chapter in chapter information') video_url = a.find('./video_file_url').text video_ext = video_url.rpartition('.')[2] or 'flv' chapter_api_url = 'https://api.twitch.tv/kraken/videos/c' + chapter_id chapter_info = self._download_json( chapter_api_url, 'c' + chapter_id, note='Downloading chapter metadata', errnote='Download of chapter metadata failed') bracket_start = int(doc.find('.//bracket_start').text) bracket_end = int(doc.find('.//bracket_end').text) # TODO determine start (and probably fix up file) # youtube-dl -v http://www.twitch.tv/firmbelief/c/1757457 #video_url += '?start=' + TODO:start_timestamp # bracket_start is 13290, but we want 51670615 self._downloader.report_warning('Chapter detected, but we can just download the whole file. ' 'Chapter starts at %s and ends at %s' % (formatSeconds(bracket_start), formatSeconds(bracket_end))) info = { 'id': 'c' + chapter_id, 'url': video_url, 'ext': video_ext, 'title': chapter_info['title'], 'thumbnail': chapter_info['preview'], 'description': chapter_info['description'], 'uploader': chapter_info['channel']['display_name'], 'uploader_id': chapter_info['channel']['name'], } return info else: video_id = mobj.group('videoid') api = api_base + '/broadcast/by_archive/%s.json' % video_id entries = [] offset = 0 limit = self._JUSTIN_PAGE_LIMIT while True: if paged: self.report_download_page(video_id, offset) page_url = api + ('?offset=%d&limit=%d' % (offset, limit)) page_count, page_info = self._parse_page(page_url, video_id) entries.extend(page_info) if not paged or page_count != limit: break offset += limit return { '_type': 'playlist', 'id': video_id, 'entries': entries, }
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 8434, 63, 495, 12, 272, 19783, 12, 272, 1475, 13165, 12, 199, 9, 421, 199, 533, 13870, 262, 12764, 4332, 8, 18283, 304, 272, 408, 4935, 31295, 367, 2951, 262, 14, 6993, 436, 307, 3111, 14, 6993, 624, 272, 327, 3254, 26, 7309, 11180, 1443, 506, 3715, 1901, 3663, 22010, 14, 710, 790, 272, 327, 283, 10786, 63, 344, 7, 365, 314, 2011, 367, 1006, 4184, 12, 436, 283, 10786, 63, 2064, 7, 272, 327, 9174, 737, 413, 436, 10035, 3274, 14, 6855, 781, 14312, 1006, 4184, 465, 1373, 3991, 31, 339, 485, 5600, 63, 2632, 275, 519, 624, 2229, 88, 18979, 5169, 1014, 921, 5547, 5169, 1544, 20316, 5169, 84, 3111, 92, 4764, 262, 31477, 6993, 15, 267, 16697, 288, 7558, 48, 28, 11984, 685, 7401, 26906, 8636, 288, 16697, 5169, 26285, 2447, 66, 9448, 48, 28, 5624, 1170, 26906, 430, 92, 288, 16697, 5169, 26285, 2447, 67, 9448, 48, 28, 28765, 266, 1677, 26906, 430, 267, 776, 267, 1182, 31, 15840, 3, 2795, 5547, 4, 267, 408, 272, 485, 42, 7698, 568, 63, 12898, 63, 13387, 275, 2948, 272, 15292, 63, 2339, 275, 283, 4764, 262, 14, 6993, 7, 272, 15292, 63, 15119, 275, 283, 4764, 262, 14, 6993, 436, 307, 3111, 14, 6993, 7, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 84, 3111, 14, 6993, 15, 1589, 5097, 2374, 16560, 15, 66, 15, 11700, 3933, 11197, 297, 267, 283, 1064, 21, 356, 283, 69, 32350, 24, 65, 22252, 67, 1081, 65, 2167, 1138, 1643, 10752, 2259, 2756, 12632, 67, 25, 65, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 11700, 3933, 11197, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 5064, 63, 602, 356, 283, 1797, 6996, 1465, 297, 288, 283, 13671, 63, 344, 356, 5661, 7636, 14187, 12, 288, 283, 13671, 356, 283, 1589, 5097, 2374, 16560, 297, 288, 283, 1213, 356, 283, 5595, 1372, 12403, 446, 14914, 316, 8777, 2018, 510, 84, 14, 17, 7, 267, 789, 272, 789, 339, 327, 1432, 2338, 402, 2974, 12, 769, 402, 627, 1078, 10, 2974, 272, 347, 485, 1122, 63, 1606, 8, 277, 12, 1166, 12, 3991, 63, 344, 304, 267, 2256, 63, 1001, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 12, 5644, 283, 18085, 3991, 2256, 4840, 297, 5644, 283, 17200, 370, 5235, 3991, 2256, 4840, 358, 398, 1177, 275, 2022, 14, 3640, 8, 815, 63, 1001, 9, 267, 340, 730, 8, 1310, 9, 1137, 769, 26, 288, 1125, 63, 505, 275, 1177, 14, 362, 360, 705, 297, 283, 5187, 1125, 358, 288, 746, 19783, 360, 22850, 262, 14, 6993, 3261, 26, 450, 83, 7, 450, 1125, 63, 505, 9, 267, 2256, 275, 942, 267, 367, 11353, 315, 1177, 26, 288, 3991, 63, 633, 275, 11353, 459, 3722, 63, 493, 63, 633, 418, 288, 340, 3991, 63, 633, 26, 355, 3991, 63, 3435, 275, 747, 14, 515, 14, 7973, 8, 3722, 63, 633, 2788, 17, 1527, 17, 2938, 355, 3991, 63, 602, 275, 295, 14, 954, 13858, 3260, 11353, 459, 928, 63, 521, 418, 1491, 709, 566, 355, 3991, 63, 13671, 63, 344, 275, 11353, 14, 362, 360, 751, 63, 344, 297, 11353, 14, 362, 360, 2775, 63, 344, 1333, 355, 3991, 63, 344, 275, 11353, 459, 344, 418, 355, 3991, 63, 1213, 275, 11353, 14, 362, 360, 1213, 297, 3991, 63, 344, 9, 355, 2256, 14, 740, 2561, 490, 283, 344, 356, 8434, 63, 495, 8, 3722, 63, 344, 395, 490, 283, 633, 356, 3991, 63, 633, 12, 490, 283, 1213, 356, 3991, 63, 1213, 12, 490, 283, 13671, 356, 11353, 14, 362, 360, 2775, 63, 354, 297, 3991, 63, 13671, 63, 344, 395, 490, 283, 13671, 63, 344, 356, 3991, 63, 13671, 63, 344, 12, 490, 283, 5064, 63, 602, 356, 3991, 63, 602, 12, 490, 283, 832, 356, 3991, 63, 3435, 12, 355, 3828, 267, 372, 334, 552, 8, 1310, 395, 2256, 9, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 398, 2986, 63, 1095, 275, 283, 1014, 921, 1246, 14, 4764, 262, 14, 6993, 7, 267, 2034, 68, 275, 756, 267, 340, 14208, 14, 923, 360, 11984, 685, 7401, 735, 288, 2034, 68, 275, 715, 288, 3991, 63, 344, 275, 14208, 14, 923, 360, 11984, 685, 7401, 358, 288, 2986, 275, 2986, 63, 1095, 435, 1994, 2775, 15, 28067, 3149, 83, 14, 1001, 7, 450, 3991, 63, 344, 267, 916, 14208, 14, 923, 360, 28765, 266, 1677, 735, 288, 17044, 63, 344, 275, 14208, 14, 923, 360, 28765, 266, 1677, 358, 953, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 17044, 63, 344, 9, 288, 333, 275, 295, 14, 1733, 8, 82, 7, 7701, 4537, 6404, 63, 344, 275, 298, 779, 16, 13, 25, 2807, 2924, 10805, 9248, 9, 288, 340, 440, 333, 26, 355, 746, 19783, 360, 6612, 2342, 6359, 402, 282, 17044, 358, 288, 6359, 63, 344, 275, 333, 14, 923, 8, 17, 9, 953, 2986, 275, 2986, 63, 1095, 435, 1994, 10786, 15, 991, 63, 11316, 3149, 83, 14, 1652, 7, 450, 17044, 63, 344, 288, 1382, 275, 291, 423, 4249, 63, 1652, 8, 355, 2986, 12, 17044, 63, 344, 12, 355, 5317, 534, 18085, 17044, 2556, 297, 355, 2329, 4610, 534, 30791, 2556, 5235, 3405, 358, 288, 367, 282, 315, 1382, 14, 6452, 29995, 6404, 735, 355, 340, 6359, 63, 344, 508, 282, 14, 1623, 17371, 344, 1959, 505, 26, 490, 2059, 288, 587, 26, 355, 746, 19783, 360, 6531, 440, 2342, 17044, 315, 17044, 2556, 358, 953, 3991, 63, 633, 275, 282, 14, 1623, 17371, 3722, 63, 493, 63, 633, 1959, 505, 288, 3991, 63, 832, 275, 3991, 63, 633, 14, 25817, 19237, 18, 61, 503, 283, 22753, 7, 953, 17044, 63, 1246, 63, 633, 275, 283, 2859, 921, 1246, 14, 84, 3111, 14, 6993, 15, 75, 345, 917, 15, 11418 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 8434, 63, 495, 12, 272, 19783, 12, 272, 1475, 13165, 12, 199, 9, 421, 199, 533, 13870, 262, 12764, 4332, 8, 18283, 304, 272, 408, 4935, 31295, 367, 2951, 262, 14, 6993, 436, 307, 3111, 14, 6993, 624, 272, 327, 3254, 26, 7309, 11180, 1443, 506, 3715, 1901, 3663, 22010, 14, 710, 790, 272, 327, 283, 10786, 63, 344, 7, 365, 314, 2011, 367, 1006, 4184, 12, 436, 283, 10786, 63, 2064, 7, 272, 327, 9174, 737, 413, 436, 10035, 3274, 14, 6855, 781, 14312, 1006, 4184, 465, 1373, 3991, 31, 339, 485, 5600, 63, 2632, 275, 519, 624, 2229, 88, 18979, 5169, 1014, 921, 5547, 5169, 1544, 20316, 5169, 84, 3111, 92, 4764, 262, 31477, 6993, 15, 267, 16697, 288, 7558, 48, 28, 11984, 685, 7401, 26906, 8636, 288, 16697, 5169, 26285, 2447, 66, 9448, 48, 28, 5624, 1170, 26906, 430, 92, 288, 16697, 5169, 26285, 2447, 67, 9448, 48, 28, 28765, 266, 1677, 26906, 430, 267, 776, 267, 1182, 31, 15840, 3, 2795, 5547, 4, 267, 408, 272, 485, 42, 7698, 568, 63, 12898, 63, 13387, 275, 2948, 272, 15292, 63, 2339, 275, 283, 4764, 262, 14, 6993, 7, 272, 15292, 63, 15119, 275, 283, 4764, 262, 14, 6993, 436, 307, 3111, 14, 6993, 7, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 84, 3111, 14, 6993, 15, 1589, 5097, 2374, 16560, 15, 66, 15, 11700, 3933, 11197, 297, 267, 283, 1064, 21, 356, 283, 69, 32350, 24, 65, 22252, 67, 1081, 65, 2167, 1138, 1643, 10752, 2259, 2756, 12632, 67, 25, 65, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 11700, 3933, 11197, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 5064, 63, 602, 356, 283, 1797, 6996, 1465, 297, 288, 283, 13671, 63, 344, 356, 5661, 7636, 14187, 12, 288, 283, 13671, 356, 283, 1589, 5097, 2374, 16560, 297, 288, 283, 1213, 356, 283, 5595, 1372, 12403, 446, 14914, 316, 8777, 2018, 510, 84, 14, 17, 7, 267, 789, 272, 789, 339, 327, 1432, 2338, 402, 2974, 12, 769, 402, 627, 1078, 10, 2974, 272, 347, 485, 1122, 63, 1606, 8, 277, 12, 1166, 12, 3991, 63, 344, 304, 267, 2256, 63, 1001, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 12, 5644, 283, 18085, 3991, 2256, 4840, 297, 5644, 283, 17200, 370, 5235, 3991, 2256, 4840, 358, 398, 1177, 275, 2022, 14, 3640, 8, 815, 63, 1001, 9, 267, 340, 730, 8, 1310, 9, 1137, 769, 26, 288, 1125, 63, 505, 275, 1177, 14, 362, 360, 705, 297, 283, 5187, 1125, 358, 288, 746, 19783, 360, 22850, 262, 14, 6993, 3261, 26, 450, 83, 7, 450, 1125, 63, 505, 9, 267, 2256, 275, 942, 267, 367, 11353, 315, 1177, 26, 288, 3991, 63, 633, 275, 11353, 459, 3722, 63, 493, 63, 633, 418, 288, 340, 3991, 63, 633, 26, 355, 3991, 63, 3435, 275, 747, 14, 515, 14, 7973, 8, 3722, 63, 633, 2788, 17, 1527, 17, 2938, 355, 3991, 63, 602, 275, 295, 14, 954, 13858, 3260, 11353, 459, 928, 63, 521, 418, 1491, 709, 566, 355, 3991, 63, 13671, 63, 344, 275, 11353, 14, 362, 360, 751, 63, 344, 297, 11353, 14, 362, 360, 2775, 63, 344, 1333, 355, 3991, 63, 344, 275, 11353, 459, 344, 418, 355, 3991, 63, 1213, 275, 11353, 14, 362, 360, 1213, 297, 3991, 63, 344, 9, 355, 2256, 14, 740, 2561, 490, 283, 344, 356, 8434, 63, 495, 8, 3722, 63, 344, 395, 490, 283, 633, 356, 3991, 63, 633, 12, 490, 283, 1213, 356, 3991, 63, 1213, 12, 490, 283, 13671, 356, 11353, 14, 362, 360, 2775, 63, 354, 297, 3991, 63, 13671, 63, 344, 395, 490, 283, 13671, 63, 344, 356, 3991, 63, 13671, 63, 344, 12, 490, 283, 5064, 63, 602, 356, 3991, 63, 602, 12, 490, 283, 832, 356, 3991, 63, 3435, 12, 355, 3828, 267, 372, 334, 552, 8, 1310, 395, 2256, 9, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 398, 2986, 63, 1095, 275, 283, 1014, 921, 1246, 14, 4764, 262, 14, 6993, 7, 267, 2034, 68, 275, 756, 267, 340, 14208, 14, 923, 360, 11984, 685, 7401, 735, 288, 2034, 68, 275, 715, 288, 3991, 63, 344, 275, 14208, 14, 923, 360, 11984, 685, 7401, 358, 288, 2986, 275, 2986, 63, 1095, 435, 1994, 2775, 15, 28067, 3149, 83, 14, 1001, 7, 450, 3991, 63, 344, 267, 916, 14208, 14, 923, 360, 28765, 266, 1677, 735, 288, 17044, 63, 344, 275, 14208, 14, 923, 360, 28765, 266, 1677, 358, 953, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 17044, 63, 344, 9, 288, 333, 275, 295, 14, 1733, 8, 82, 7, 7701, 4537, 6404, 63, 344, 275, 298, 779, 16, 13, 25, 2807, 2924, 10805, 9248, 9, 288, 340, 440, 333, 26, 355, 746, 19783, 360, 6612, 2342, 6359, 402, 282, 17044, 358, 288, 6359, 63, 344, 275, 333, 14, 923, 8, 17, 9, 953, 2986, 275, 2986, 63, 1095, 435, 1994, 10786, 15, 991, 63, 11316, 3149, 83, 14, 1652, 7, 450, 17044, 63, 344, 288, 1382, 275, 291, 423, 4249, 63, 1652, 8, 355, 2986, 12, 17044, 63, 344, 12, 355, 5317, 534, 18085, 17044, 2556, 297, 355, 2329, 4610, 534, 30791, 2556, 5235, 3405, 358, 288, 367, 282, 315, 1382, 14, 6452, 29995, 6404, 735, 355, 340, 6359, 63, 344, 508, 282, 14, 1623, 17371, 344, 1959, 505, 26, 490, 2059, 288, 587, 26, 355, 746, 19783, 360, 6531, 440, 2342, 17044, 315, 17044, 2556, 358, 953, 3991, 63, 633, 275, 282, 14, 1623, 17371, 3722, 63, 493, 63, 633, 1959, 505, 288, 3991, 63, 832, 275, 3991, 63, 633, 14, 25817, 19237, 18, 61, 503, 283, 22753, 7, 953, 17044, 63, 1246, 63, 633, 275, 283, 2859, 921, 1246, 14, 84, 3111, 14, 6993, 15, 75, 345, 917, 15, 11418, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jiajiax/crosswalk-test-suite
usecase/usecase-webapi-xwalk-tests/inst.wgt.py
44
6786
#!/usr/bin/env python import os import shutil import glob import time import sys import subprocess import string from optparse import OptionParser, make_option SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) PKG_NAME = os.path.basename(SCRIPT_DIR) PARAMETERS = None #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" SRC_DIR = "" PKG_SRC_DIR = "" 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 is not None: break sys.stdout.write("%s\n" % output_line) sys.stdout.flush() output.append(output_line) return (cmd_return_code, output) def updateCMD(cmd=None): if "pkgcmd" in cmd: cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) return cmd def getUSERID(): if PARAMETERS.mode == "SDB": cmd = "sdb -s %s shell id -u %s" % ( PARAMETERS.device, PARAMETERS.user) else: cmd = "ssh %s \"id -u %s\"" % ( PARAMETERS.device, PARAMETERS.user) return doCMD(cmd) def getPKGID(pkg_name=None): if PARAMETERS.mode == "SDB": cmd = "sdb -s %s shell %s" % ( PARAMETERS.device, updateCMD('pkgcmd -l')) else: cmd = "ssh %s \"%s\"" % ( PARAMETERS.device, updateCMD('pkgcmd -l')) (return_code, output) = doCMD(cmd) if return_code != 0: return None test_pkg_id = None for line in output: if line.find("[" + pkg_name + "]") != -1: pkgidIndex = line.split().index("pkgid") test_pkg_id = line.split()[pkgidIndex + 1].strip("[]") break return test_pkg_id def doRemoteCMD(cmd=None): if PARAMETERS.mode == "SDB": cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) else: cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) return doCMD(cmd) def doRemoteCopy(src=None, dest=None): if PARAMETERS.mode == "SDB": cmd_prefix = "sdb -s %s push" % PARAMETERS.device cmd = "%s %s %s" % (cmd_prefix, src, dest) else: cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) (return_code, output) = doCMD(cmd) doRemoteCMD("sync") if return_code != 0: return True else: return False def uninstPKGs(): action_status = True for root, dirs, files in os.walk(SCRIPT_DIR): for file in files: if file.endswith(".wgt"): pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) if not pkg_id: action_status = False continue (return_code, output) = doRemoteCMD( "pkgcmd -u -t wgt -q -n %s" % pkg_id) for line in output: if "Failure" in line: action_status = False break (return_code, output) = doRemoteCMD( "rm -rf %s" % PKG_SRC_DIR) if return_code != 0: action_status = False return action_status def instPKGs(): action_status = True (return_code, output) = doRemoteCMD( "mkdir -p %s" % PKG_SRC_DIR) if return_code != 0: action_status = False for root, dirs, files in os.walk(SCRIPT_DIR): for file in files: if file.endswith(".wgt"): if not doRemoteCopy( os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): action_status = False (return_code, output) = doRemoteCMD( "pkgcmd -i -t wgt -q -p %s/%s" % (SRC_DIR, file)) doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) for line in output: if "Failure" in line: action_status = False break for item in glob.glob("%s/*" % SCRIPT_DIR): if item.endswith(".wgt"): continue elif item.endswith("inst.py"): continue else: item_name = os.path.basename(item) if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): # if not doRemoteCopy(item, PKG_SRC_DIR): action_status = False return action_status def main(): try: usage = "usage: inst.py -i" opts_parser = OptionParser(usage=usage) opts_parser.add_option( "-m", dest="mode", action="store", help="Specify mode") 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") opts_parser.add_option( "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() except Exception as e: print "Got wrong option: %s, exit ..." % e sys.exit(1) if not PARAMETERS.user: PARAMETERS.user = "app" global SRC_DIR, PKG_SRC_DIR SRC_DIR = "/home/%s/content" % PARAMETERS.user PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) if not PARAMETERS.mode: PARAMETERS.mode = "SDB" if PARAMETERS.mode == "SDB": if not PARAMETERS.device: (return_code, output) = doCMD("sdb devices") for line in output: if str.find(line, "\tdevice") != -1: PARAMETERS.device = line.split("\t")[0] break else: PARAMETERS.mode = "SSH" if not PARAMETERS.device: print "No device provided" sys.exit(1) user_info = getUSERID() re_code = user_info[0] if re_code == 0: global XW_ENV userid = user_info[1][0] XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket" % str( userid) else: print "[Error] cmd commands error : %s" % str(user_info[1]) 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, 646, 1059, 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, 18150, 63, 2339, 275, 747, 14, 515, 14, 4846, 8, 10484, 63, 3022, 9, 199, 24014, 275, 488, 199, 3, 56, 55, 63, 9984, 275, 298, 3790, 6249, 1668, 63, 12763, 63, 24753, 63, 12368, 29, 11864, 26, 515, 13043, 1065, 15, 751, 15, 13128, 15, 17066, 15, 751, 63, 5610, 63, 3450, 2, 199, 12447, 63, 3022, 275, 3087, 199, 18150, 63, 12447, 63, 3022, 275, 3087, 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, 365, 440, 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, 1678, 9744, 8, 1760, 29, 403, 304, 272, 340, 298, 4600, 1760, 2, 315, 2088, 26, 267, 2088, 275, 298, 9648, 446, 450, 83, 446, 67, 1543, 83, 27, 5, 83, 4065, 450, 334, 24014, 14, 751, 12, 1323, 55, 63, 9984, 12, 2088, 9, 272, 372, 2088, 421, 199, 318, 664, 3791, 998, 837, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 1305, 446, 85, 450, 83, 2, 450, 334, 288, 23710, 14, 1782, 12, 23710, 14, 751, 9, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 8441, 344, 446, 85, 450, 83, 18781, 450, 334, 288, 23710, 14, 1782, 12, 23710, 14, 751, 9, 272, 372, 886, 9744, 8, 1760, 9, 421, 199, 318, 664, 18150, 998, 8, 4600, 63, 354, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 450, 83, 2, 450, 334, 288, 23710, 14, 1782, 12, 1678, 9744, 360, 4600, 1760, 446, 76, 1333, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 18321, 83, 18781, 450, 334, 288, 23710, 14, 1782, 12, 1678, 9744, 360, 4600, 1760, 446, 76, 1333, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 272, 340, 372, 63, 600, 1137, 378, 26, 267, 372, 488, 339, 511, 63, 4600, 63, 344, 275, 488, 272, 367, 1004, 315, 1072, 26, 267, 340, 1004, 14, 1623, 480, 905, 435, 5496, 63, 354, 435, 298, 12523, 1137, 446, 17, 26, 288, 5496, 344, 2681, 275, 1004, 14, 1294, 1252, 1080, 480, 4600, 344, 531, 288, 511, 63, 4600, 63, 344, 275, 1004, 14, 1294, 3430, 4600, 344, 2681, 435, 413, 1055, 1913, 480, 31346, 288, 2059, 272, 372, 511, 63, 4600, 63, 344, 421, 199, 318, 886, 6713, 9744, 8, 1760, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 450, 83, 2, 450, 334, 24014, 14, 1782, 12, 1678, 9744, 8, 1760, 430, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 18321, 83, 18781, 450, 334, 24014, 14, 1782, 12, 1678, 9744, 8, 1760, 430, 339, 372, 886, 9744, 8, 1760, 9, 421, 199, 318, 886, 6713, 5116, 8, 2164, 29, 403, 12, 2053, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 63, 1861, 275, 298, 21624, 446, 83, 450, 83, 6675, 2, 450, 23710, 14, 1782, 267, 2088, 275, 2071, 83, 450, 83, 450, 83, 2, 450, 334, 1760, 63, 1861, 12, 2928, 12, 2053, 9, 272, 587, 26, 267, 2088, 275, 298, 17124, 446, 82, 450, 83, 450, 83, 26, 3149, 83, 2, 450, 334, 2164, 12, 23710, 14, 1782, 12, 2053, 9, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 272, 886, 6713, 9744, 480, 5186, 531, 339, 340, 372, 63, 600, 1137, 378, 26, 267, 372, 715, 272, 587, 26, 267, 372, 756, 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, 87, 3308, 2349, 355, 5496, 63, 344, 275, 664, 18150, 998, 8, 736, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 7973, 8, 493, 2788, 16, 2459, 355, 340, 440, 5496, 63, 344, 26, 490, 1595, 63, 1205, 275, 756, 490, 1980, 355, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 6713, 9744, 8, 490, 298, 4600, 1760, 446, 85, 446, 84, 336, 3308, 446, 81, 446, 78, 450, 83, 2, 450, 5496, 63, 344, 9, 355, 367, 1004, 315, 1072, 26, 490, 340, 298, 6782, 2, 315, 1004, 26, 717, 1595, 63, 1205, 275, 756, 717, 2059, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 6713, 9744, 8, 267, 298, 5682, 446, 3941, 450, 83, 2, 450, 30281, 63, 12447, 63, 3022, 9, 272, 340, 372, 63, 600, 1137, 378, 26, 267, 1595, 63, 1205, 275, 756, 339, 372, 1595, 63, 1205, 421, 199, 318, 2727, 18150, 83, 837, 272, 1595, 63, 1205, 275, 715, 272, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 6713 ]
[ 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, 646, 1059, 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, 18150, 63, 2339, 275, 747, 14, 515, 14, 4846, 8, 10484, 63, 3022, 9, 199, 24014, 275, 488, 199, 3, 56, 55, 63, 9984, 275, 298, 3790, 6249, 1668, 63, 12763, 63, 24753, 63, 12368, 29, 11864, 26, 515, 13043, 1065, 15, 751, 15, 13128, 15, 17066, 15, 751, 63, 5610, 63, 3450, 2, 199, 12447, 63, 3022, 275, 3087, 199, 18150, 63, 12447, 63, 3022, 275, 3087, 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, 365, 440, 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, 1678, 9744, 8, 1760, 29, 403, 304, 272, 340, 298, 4600, 1760, 2, 315, 2088, 26, 267, 2088, 275, 298, 9648, 446, 450, 83, 446, 67, 1543, 83, 27, 5, 83, 4065, 450, 334, 24014, 14, 751, 12, 1323, 55, 63, 9984, 12, 2088, 9, 272, 372, 2088, 421, 199, 318, 664, 3791, 998, 837, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 1305, 446, 85, 450, 83, 2, 450, 334, 288, 23710, 14, 1782, 12, 23710, 14, 751, 9, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 8441, 344, 446, 85, 450, 83, 18781, 450, 334, 288, 23710, 14, 1782, 12, 23710, 14, 751, 9, 272, 372, 886, 9744, 8, 1760, 9, 421, 199, 318, 664, 18150, 998, 8, 4600, 63, 354, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 450, 83, 2, 450, 334, 288, 23710, 14, 1782, 12, 1678, 9744, 360, 4600, 1760, 446, 76, 1333, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 18321, 83, 18781, 450, 334, 288, 23710, 14, 1782, 12, 1678, 9744, 360, 4600, 1760, 446, 76, 1333, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 272, 340, 372, 63, 600, 1137, 378, 26, 267, 372, 488, 339, 511, 63, 4600, 63, 344, 275, 488, 272, 367, 1004, 315, 1072, 26, 267, 340, 1004, 14, 1623, 480, 905, 435, 5496, 63, 354, 435, 298, 12523, 1137, 446, 17, 26, 288, 5496, 344, 2681, 275, 1004, 14, 1294, 1252, 1080, 480, 4600, 344, 531, 288, 511, 63, 4600, 63, 344, 275, 1004, 14, 1294, 3430, 4600, 344, 2681, 435, 413, 1055, 1913, 480, 31346, 288, 2059, 272, 372, 511, 63, 4600, 63, 344, 421, 199, 318, 886, 6713, 9744, 8, 1760, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 275, 298, 21624, 446, 83, 450, 83, 5218, 450, 83, 2, 450, 334, 24014, 14, 1782, 12, 1678, 9744, 8, 1760, 430, 272, 587, 26, 267, 2088, 275, 298, 5510, 450, 83, 18321, 83, 18781, 450, 334, 24014, 14, 1782, 12, 1678, 9744, 8, 1760, 430, 339, 372, 886, 9744, 8, 1760, 9, 421, 199, 318, 886, 6713, 5116, 8, 2164, 29, 403, 12, 2053, 29, 403, 304, 272, 340, 23710, 14, 632, 508, 298, 51, 2846, 582, 267, 2088, 63, 1861, 275, 298, 21624, 446, 83, 450, 83, 6675, 2, 450, 23710, 14, 1782, 267, 2088, 275, 2071, 83, 450, 83, 450, 83, 2, 450, 334, 1760, 63, 1861, 12, 2928, 12, 2053, 9, 272, 587, 26, 267, 2088, 275, 298, 17124, 446, 82, 450, 83, 450, 83, 26, 3149, 83, 2, 450, 334, 2164, 12, 23710, 14, 1782, 12, 2053, 9, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 9744, 8, 1760, 9, 272, 886, 6713, 9744, 480, 5186, 531, 339, 340, 372, 63, 600, 1137, 378, 26, 267, 372, 715, 272, 587, 26, 267, 372, 756, 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, 87, 3308, 2349, 355, 5496, 63, 344, 275, 664, 18150, 998, 8, 736, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 7973, 8, 493, 2788, 16, 2459, 355, 340, 440, 5496, 63, 344, 26, 490, 1595, 63, 1205, 275, 756, 490, 1980, 355, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 6713, 9744, 8, 490, 298, 4600, 1760, 446, 85, 446, 84, 336, 3308, 446, 81, 446, 78, 450, 83, 2, 450, 5496, 63, 344, 9, 355, 367, 1004, 315, 1072, 26, 490, 340, 298, 6782, 2, 315, 1004, 26, 717, 1595, 63, 1205, 275, 756, 717, 2059, 339, 334, 1107, 63, 600, 12, 1072, 9, 275, 886, 6713, 9744, 8, 267, 298, 5682, 446, 3941, 450, 83, 2, 450, 30281, 63, 12447, 63, 3022, 9, 272, 340, 372, 63, 600, 1137, 378, 26, 267, 1595, 63, 1205, 275, 756, 339, 372, 1595, 63, 1205, 421,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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 ]
dmsimard/ansible
lib/ansible/plugins/filter/core.py
1
21532
# (c) 2012, Jeroen Hoekx <jeroen@hoekx.be> # # 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 base64 import glob import hashlib import json import ntpath import os.path import re import sys import time import uuid import yaml import datetime from functools import partial from random import Random, SystemRandom, shuffle from jinja2.filters import environmentfilter, do_groupby as _do_groupby from ansible.errors import AnsibleError, AnsibleFilterError, AnsibleFilterTypeError from ansible.module_utils.six import string_types, integer_types, reraise, text_type from ansible.module_utils.six.moves import shlex_quote from ansible.module_utils._text import to_bytes, to_native, to_text from ansible.module_utils.common.collections import is_sequence from ansible.module_utils.common._collections_compat import Mapping from ansible.parsing.ajson import AnsibleJSONEncoder from ansible.parsing.yaml.dumper import AnsibleDumper from ansible.template import recursive_check_defined from ansible.utils.display import Display from ansible.utils.encrypt import passlib_or_crypt from ansible.utils.hashing import md5s, checksum_s from ansible.utils.unicode import unicode_wrap from ansible.utils.vars import merge_hash display = Display() UUID_NAMESPACE_ANSIBLE = uuid.UUID('361E6D51-FAEC-444A-9079-341386DA8E2E') def to_yaml(a, *args, **kw): '''Make verbose, human readable yaml''' default_flow_style = kw.pop('default_flow_style', None) transformed = yaml.dump(a, Dumper=AnsibleDumper, allow_unicode=True, default_flow_style=default_flow_style, **kw) return to_text(transformed) def to_nice_yaml(a, indent=4, *args, **kw): '''Make verbose, human readable yaml''' transformed = yaml.dump(a, Dumper=AnsibleDumper, indent=indent, allow_unicode=True, default_flow_style=False, **kw) return to_text(transformed) def to_json(a, *args, **kw): ''' Convert the value to JSON ''' return json.dumps(a, cls=AnsibleJSONEncoder, *args, **kw) def to_nice_json(a, indent=4, sort_keys=True, *args, **kw): '''Make verbose, human readable JSON''' return to_json(a, indent=indent, sort_keys=sort_keys, separators=(',', ': '), *args, **kw) def to_bool(a): ''' return a bool for the arg ''' if a is None or isinstance(a, bool): return a if isinstance(a, string_types): a = a.lower() if a in ('yes', 'on', '1', 'true', 1): return True return False def to_datetime(string, format="%Y-%m-%d %H:%M:%S"): return datetime.datetime.strptime(string, format) def strftime(string_format, second=None): ''' return a date string using string. See https://docs.python.org/2/library/time.html#time.strftime for format ''' if second is not None: try: second = float(second) except Exception: raise AnsibleFilterError('Invalid value for epoch value (%s)' % second) return time.strftime(string_format, time.localtime(second)) def quote(a): ''' return its argument quoted for shell usage ''' if a is None: a = u'' return shlex_quote(to_text(a)) def fileglob(pathname): ''' return list of matched regular files for glob ''' return [g for g in glob.glob(pathname) if os.path.isfile(g)] def regex_replace(value='', pattern='', replacement='', ignorecase=False, multiline=False): ''' Perform a `re.sub` returning a string ''' value = to_text(value, errors='surrogate_or_strict', nonstring='simplerepr') flags = 0 if ignorecase: flags |= re.I if multiline: flags |= re.M _re = re.compile(pattern, flags=flags) return _re.sub(replacement, value) def regex_findall(value, regex, multiline=False, ignorecase=False): ''' Perform re.findall and return the list of matches ''' value = to_text(value, errors='surrogate_or_strict', nonstring='simplerepr') flags = 0 if ignorecase: flags |= re.I if multiline: flags |= re.M return re.findall(regex, value, flags) def regex_search(value, regex, *args, **kwargs): ''' Perform re.search and return the list of matches or a backref ''' value = to_text(value, errors='surrogate_or_strict', nonstring='simplerepr') groups = list() for arg in args: if arg.startswith('\\g'): match = re.match(r'\\g<(\S+)>', arg).group(1) groups.append(match) elif arg.startswith('\\'): match = int(re.match(r'\\(\d+)', arg).group(1)) groups.append(match) else: raise AnsibleFilterError('Unknown argument') flags = 0 if kwargs.get('ignorecase'): flags |= re.I if kwargs.get('multiline'): flags |= re.M match = re.search(regex, value, flags) if match: if not groups: return match.group() else: items = list() for item in groups: items.append(match.group(item)) return items def ternary(value, true_val, false_val, none_val=None): ''' value ? true_val : false_val ''' if value is None and none_val is not None: return none_val elif bool(value): return true_val else: return false_val def regex_escape(string, re_type='python'): string = to_text(string, errors='surrogate_or_strict', nonstring='simplerepr') '''Escape all regular expressions special characters from STRING.''' if re_type == 'python': return re.escape(string) elif re_type == 'posix_basic': # list of BRE special chars: # https://en.wikibooks.org/wiki/Regular_Expressions/POSIX_Basic_Regular_Expressions return regex_replace(string, r'([].[^$*\\])', r'\\\1') # TODO: implement posix_extended # It's similar to, but different from python regex, which is similar to, # but different from PCRE. It's possible that re.escape would work here. # https://remram44.github.io/regex-cheatsheet/regex.html#programs elif re_type == 'posix_extended': raise AnsibleFilterError('Regex type (%s) not yet implemented' % re_type) else: raise AnsibleFilterError('Invalid regex type (%s)' % re_type) def from_yaml(data): if isinstance(data, string_types): return yaml.safe_load(data) return data def from_yaml_all(data): if isinstance(data, string_types): return yaml.safe_load_all(data) return data @environmentfilter def rand(environment, end, start=None, step=None, seed=None): if seed is None: r = SystemRandom() else: r = Random(seed) if isinstance(end, integer_types): if not start: start = 0 if not step: step = 1 return r.randrange(start, end, step) elif hasattr(end, '__iter__'): if start or step: raise AnsibleFilterError('start and step can only be used with integer values') return r.choice(end) else: raise AnsibleFilterError('random can only be used on sequences and integers') def randomize_list(mylist, seed=None): try: mylist = list(mylist) if seed: r = Random(seed) r.shuffle(mylist) else: shuffle(mylist) except Exception: pass return mylist def get_hash(data, hashtype='sha1'): try: h = hashlib.new(hashtype) except Exception as e: # hash is not supported? raise AnsibleFilterError(e) h.update(to_bytes(data, errors='surrogate_or_strict')) return h.hexdigest() def get_encrypted_password(password, hashtype='sha512', salt=None, salt_size=None, rounds=None): passlib_mapping = { 'md5': 'md5_crypt', 'blowfish': 'bcrypt', 'sha256': 'sha256_crypt', 'sha512': 'sha512_crypt', } hashtype = passlib_mapping.get(hashtype, hashtype) try: return passlib_or_crypt(password, hashtype, salt=salt, salt_size=salt_size, rounds=rounds) except AnsibleError as e: reraise(AnsibleFilterError, AnsibleFilterError(to_native(e), orig_exc=e), sys.exc_info()[2]) def to_uuid(string, namespace=UUID_NAMESPACE_ANSIBLE): uuid_namespace = namespace if not isinstance(uuid_namespace, uuid.UUID): try: uuid_namespace = uuid.UUID(namespace) except (AttributeError, ValueError) as e: raise AnsibleFilterError("Invalid value '%s' for 'namespace': %s" % (to_native(namespace), to_native(e))) # uuid.uuid5() requires bytes on Python 2 and bytes or text or Python 3 return to_text(uuid.uuid5(uuid_namespace, to_native(string, errors='surrogate_or_strict'))) def mandatory(a, msg=None): from jinja2.runtime import Undefined ''' Make a variable mandatory ''' if isinstance(a, Undefined): if a._undefined_name is not None: name = "'%s' " % to_text(a._undefined_name) else: name = '' if msg is not None: raise AnsibleFilterError(to_native(msg)) else: raise AnsibleFilterError("Mandatory variable %s not defined." % name) return a def combine(*terms, **kwargs): recursive = kwargs.pop('recursive', False) list_merge = kwargs.pop('list_merge', 'replace') if kwargs: raise AnsibleFilterError("'recursive' and 'list_merge' are the only valid keyword arguments") # allow the user to do `[dict1, dict2, ...] | combine` dictionaries = flatten(terms, levels=1) # recursively check that every elements are defined (for jinja2) recursive_check_defined(dictionaries) if not dictionaries: return {} if len(dictionaries) == 1: return dictionaries[0] # merge all the dicts so that the dict at the end of the array have precedence # over the dict at the beginning. # we merge the dicts from the highest to the lowest priority because there is # a huge probability that the lowest priority dict will be the biggest in size # (as the low prio dict will hold the "default" values and the others will be "patches") # and merge_hash create a copy of it's first argument. # so high/right -> low/left is more efficient than low/left -> high/right high_to_low_prio_dict_iterator = reversed(dictionaries) result = next(high_to_low_prio_dict_iterator) for dictionary in high_to_low_prio_dict_iterator: result = merge_hash(dictionary, result, recursive, list_merge) return result def comment(text, style='plain', **kw): # Predefined comment types comment_styles = { 'plain': { 'decoration': '# ' }, 'erlang': { 'decoration': '% ' }, 'c': { 'decoration': '// ' }, 'cblock': { 'beginning': '/*', 'decoration': ' * ', 'end': ' */' }, 'xml': { 'beginning': '<!--', 'decoration': ' - ', 'end': '-->' } } # Pointer to the right comment type style_params = comment_styles[style] if 'decoration' in kw: prepostfix = kw['decoration'] else: prepostfix = style_params['decoration'] # Default params p = { 'newline': '\n', 'beginning': '', 'prefix': (prepostfix).rstrip(), 'prefix_count': 1, 'decoration': '', 'postfix': (prepostfix).rstrip(), 'postfix_count': 1, 'end': '' } # Update default params p.update(style_params) p.update(kw) # Compose substrings for the final string str_beginning = '' if p['beginning']: str_beginning = "%s%s" % (p['beginning'], p['newline']) str_prefix = '' if p['prefix']: if p['prefix'] != p['newline']: str_prefix = str( "%s%s" % (p['prefix'], p['newline'])) * int(p['prefix_count']) else: str_prefix = str( "%s" % (p['newline'])) * int(p['prefix_count']) str_text = ("%s%s" % ( p['decoration'], # Prepend each line of the text with the decorator text.replace( p['newline'], "%s%s" % (p['newline'], p['decoration'])))).replace( # Remove trailing spaces when only decorator is on the line "%s%s" % (p['decoration'], p['newline']), "%s%s" % (p['decoration'].rstrip(), p['newline'])) str_postfix = p['newline'].join( [''] + [p['postfix'] for x in range(p['postfix_count'])]) str_end = '' if p['end']: str_end = "%s%s" % (p['newline'], p['end']) # Return the final string return "%s%s%s%s%s" % ( str_beginning, str_prefix, str_text, str_postfix, str_end) @environmentfilter def extract(environment, item, container, morekeys=None): if morekeys is None: keys = [item] elif isinstance(morekeys, list): keys = [item] + morekeys else: keys = [item, morekeys] value = container for key in keys: value = environment.getitem(value, key) return value @environmentfilter def do_groupby(environment, value, attribute): """Overridden groupby filter for jinja2, to address an issue with jinja2>=2.9.0,<2.9.5 where a namedtuple was returned which has repr that prevents ansible.template.safe_eval.safe_eval from being able to parse and eval the data. jinja2<2.9.0,>=2.9.5 is not affected, as <2.9.0 uses a tuple, and >=2.9.5 uses a standard tuple repr on the namedtuple. The adaptation here, is to run the jinja2 `do_groupby` function, and cast all of the namedtuples to a regular tuple. See https://github.com/ansible/ansible/issues/20098 We may be able to remove this in the future. """ return [tuple(t) for t in _do_groupby(environment, value, attribute)] def b64encode(string, encoding='utf-8'): return to_text(base64.b64encode(to_bytes(string, encoding=encoding, errors='surrogate_or_strict'))) def b64decode(string, encoding='utf-8'): return to_text(base64.b64decode(to_bytes(string, errors='surrogate_or_strict')), encoding=encoding) def flatten(mylist, levels=None, skip_nulls=True): ret = [] for element in mylist: if skip_nulls and element in (None, 'None', 'null'): # ignore null items continue elif is_sequence(element): if levels is None: ret.extend(flatten(element, skip_nulls=skip_nulls)) elif levels >= 1: # decrement as we go down the stack ret.extend(flatten(element, levels=(int(levels) - 1), skip_nulls=skip_nulls)) else: ret.append(element) else: ret.append(element) return ret def subelements(obj, subelements, skip_missing=False): '''Accepts a dict or list of dicts, and a dotted accessor and produces a product of the element and the results of the dotted accessor >>> obj = [{"name": "alice", "groups": ["wheel"], "authorized": ["/tmp/alice/onekey.pub"]}] >>> subelements(obj, 'groups') [({'name': 'alice', 'groups': ['wheel'], 'authorized': ['/tmp/alice/onekey.pub']}, 'wheel')] ''' if isinstance(obj, dict): element_list = list(obj.values()) elif isinstance(obj, list): element_list = obj[:] else: raise AnsibleFilterError('obj must be a list of dicts or a nested dict') if isinstance(subelements, list): subelement_list = subelements[:] elif isinstance(subelements, string_types): subelement_list = subelements.split('.') else: raise AnsibleFilterTypeError('subelements must be a list or a string') results = [] for element in element_list: values = element for subelement in subelement_list: try: values = values[subelement] except KeyError: if skip_missing: values = [] break raise AnsibleFilterError("could not find %r key in iterated item %r" % (subelement, values)) except TypeError: raise AnsibleFilterTypeError("the key %s should point to a dictionary, got '%s'" % (subelement, values)) if not isinstance(values, list): raise AnsibleFilterTypeError("the key %r should point to a list, got %r" % (subelement, values)) for value in values: results.append((element, value)) return results def dict_to_list_of_dict_key_value_elements(mydict, key_name='key', value_name='value'): ''' takes a dictionary and transforms it into a list of dictionaries, with each having a 'key' and 'value' keys that correspond to the keys and values of the original ''' if not isinstance(mydict, Mapping): raise AnsibleFilterTypeError("dict2items requires a dictionary, got %s instead." % type(mydict)) ret = [] for key in mydict: ret.append({key_name: key, value_name: mydict[key]}) return ret def list_of_dict_key_value_elements_to_dict(mylist, key_name='key', value_name='value'): ''' takes a list of dicts with each having a 'key' and 'value' keys, and transforms the list into a dictionary, effectively as the reverse of dict2items ''' if not is_sequence(mylist): raise AnsibleFilterTypeError("items2dict requires a list, got %s instead." % type(mylist)) return dict((item[key_name], item[value_name]) for item in mylist) def path_join(paths): ''' takes a sequence or a string, and return a concatenation of the different members ''' if isinstance(paths, string_types): return os.path.join(paths) elif is_sequence(paths): return os.path.join(*paths) else: raise AnsibleFilterTypeError("|path_join expects string or sequence, got %s instead." % type(paths)) class FilterModule(object): ''' Ansible core jinja2 filters ''' def filters(self): return { # jinja2 overrides 'groupby': do_groupby, # base 64 'b64decode': b64decode, 'b64encode': b64encode, # uuid 'to_uuid': to_uuid, # json 'to_json': to_json, 'to_nice_json': to_nice_json, 'from_json': json.loads, # yaml 'to_yaml': to_yaml, 'to_nice_yaml': to_nice_yaml, 'from_yaml': from_yaml, 'from_yaml_all': from_yaml_all, # path 'basename': partial(unicode_wrap, os.path.basename), 'dirname': partial(unicode_wrap, os.path.dirname), 'expanduser': partial(unicode_wrap, os.path.expanduser), 'expandvars': partial(unicode_wrap, os.path.expandvars), 'path_join': path_join, 'realpath': partial(unicode_wrap, os.path.realpath), 'relpath': partial(unicode_wrap, os.path.relpath), 'splitext': partial(unicode_wrap, os.path.splitext), 'win_basename': partial(unicode_wrap, ntpath.basename), 'win_dirname': partial(unicode_wrap, ntpath.dirname), 'win_splitdrive': partial(unicode_wrap, ntpath.splitdrive), # file glob 'fileglob': fileglob, # types 'bool': to_bool, 'to_datetime': to_datetime, # date formatting 'strftime': strftime, # quote string for shell usage 'quote': quote, # hash filters # md5 hex digest of string 'md5': md5s, # sha1 hex digest of string 'sha1': checksum_s, # checksum of string as used by ansible for checksumming files 'checksum': checksum_s, # generic hashing 'password_hash': get_encrypted_password, 'hash': get_hash, # regex 'regex_replace': regex_replace, 'regex_escape': regex_escape, 'regex_search': regex_search, 'regex_findall': regex_findall, # ? : ; 'ternary': ternary, # random stuff 'random': rand, 'shuffle': randomize_list, # undefined 'mandatory': mandatory, # comment-style decoration 'comment': comment, # debug 'type_debug': lambda o: o.__class__.__name__, # Data structures 'combine': combine, 'extract': extract, 'flatten': flatten, 'dict2items': dict_to_list_of_dict_key_value_elements, 'items2dict': list_of_dict_key_value_elements_to_dict, 'subelements': subelements, 'split': partial(unicode_wrap, text_type.split), }
gpl-3.0
[ 3, 334, 67, 9, 6029, 12, 1603, 3478, 287, 28673, 5711, 88, 665, 74, 3478, 287, 32, 526, 5711, 88, 14, 1235, 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, 646, 1300, 772, 199, 646, 5739, 199, 646, 8337, 199, 646, 2022, 199, 646, 13377, 515, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 984, 199, 646, 900, 199, 646, 5377, 199, 646, 8864, 199, 199, 646, 2197, 199, 504, 9143, 492, 7417, 199, 504, 2196, 492, 9571, 12, 6187, 3883, 12, 13031, 199, 199, 504, 10321, 18, 14, 4273, 492, 3734, 1541, 12, 886, 63, 16968, 465, 485, 1117, 63, 16968, 199, 199, 504, 3242, 14, 2550, 492, 13358, 12, 2622, 4131, 547, 12, 2622, 4131, 4333, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 1059, 63, 1313, 12, 3000, 63, 1313, 12, 24139, 12, 1318, 63, 466, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 14, 4912, 492, 16701, 63, 3513, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 12, 370, 63, 6106, 12, 370, 63, 505, 199, 504, 3242, 14, 578, 63, 1208, 14, 2330, 14, 7882, 492, 365, 63, 4041, 199, 504, 3242, 14, 578, 63, 1208, 14, 2330, 423, 7882, 63, 5819, 492, 12340, 199, 504, 3242, 14, 11059, 14, 65, 1001, 492, 2622, 23069, 199, 504, 3242, 14, 11059, 14, 5963, 14, 2724, 281, 492, 2622, 28593, 199, 504, 3242, 14, 1160, 492, 9133, 63, 1074, 63, 4037, 199, 504, 3242, 14, 1208, 14, 2918, 492, 12175, 199, 504, 3242, 14, 1208, 14, 11929, 492, 986, 773, 63, 269, 63, 4997, 199, 504, 3242, 14, 1208, 14, 2227, 316, 492, 6128, 21, 83, 12, 9040, 63, 83, 199, 504, 3242, 14, 1208, 14, 2975, 492, 2649, 63, 3823, 199, 504, 3242, 14, 1208, 14, 2936, 492, 5389, 63, 2227, 199, 199, 2918, 275, 12175, 342, 199, 199, 8757, 63, 13001, 63, 8490, 275, 5377, 14, 8757, 360, 15702, 37, 22, 36, 2869, 13, 2078, 4220, 13, 18078, 33, 13, 25, 19000, 13, 1082, 969, 1184, 8980, 24, 37, 18, 37, 358, 421, 199, 318, 370, 63, 5963, 8, 65, 12, 627, 589, 12, 1011, 829, 304, 272, 1449, 5483, 3376, 12, 11779, 12701, 8864, 2344, 272, 849, 63, 1659, 63, 2487, 275, 4775, 14, 1935, 360, 885, 63, 1659, 63, 2487, 297, 488, 9, 272, 14834, 275, 8864, 14, 2724, 8, 65, 12, 19460, 281, 29, 10047, 28593, 12, 2040, 63, 2975, 29, 549, 12, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 12, 1011, 829, 9, 272, 372, 370, 63, 505, 8, 20209, 9, 421, 199, 318, 370, 63, 22746, 63, 5963, 8, 65, 12, 4363, 29, 20, 12, 627, 589, 12, 1011, 829, 304, 272, 1449, 5483, 3376, 12, 11779, 12701, 8864, 2344, 272, 14834, 275, 8864, 14, 2724, 8, 65, 12, 19460, 281, 29, 10047, 28593, 12, 4363, 29, 3724, 12, 2040, 63, 2975, 29, 549, 12, 849, 63, 1659, 63, 2487, 29, 797, 12, 1011, 829, 9, 272, 372, 370, 63, 505, 8, 20209, 9, 421, 199, 318, 370, 63, 1001, 8, 65, 12, 627, 589, 12, 1011, 829, 304, 272, 1449, 7905, 314, 574, 370, 4840, 1449, 272, 372, 2022, 14, 4180, 8, 65, 12, 843, 29, 10047, 23069, 12, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 370, 63, 22746, 63, 1001, 8, 65, 12, 4363, 29, 20, 12, 4069, 63, 1612, 29, 549, 12, 627, 589, 12, 1011, 829, 304, 272, 1449, 5483, 3376, 12, 11779, 12701, 4840, 2344, 272, 372, 370, 63, 1001, 8, 65, 12, 4363, 29, 3724, 12, 4069, 63, 1612, 29, 3191, 63, 1612, 12, 17658, 2687, 23324, 7596, 17748, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 370, 63, 2245, 8, 65, 304, 272, 1449, 372, 282, 2155, 367, 314, 1680, 1449, 272, 340, 282, 365, 488, 503, 1228, 8, 65, 12, 2155, 304, 267, 372, 282, 272, 340, 1228, 8, 65, 12, 1059, 63, 1313, 304, 267, 282, 275, 282, 14, 2325, 342, 272, 340, 282, 315, 661, 5066, 297, 283, 265, 297, 283, 17, 297, 283, 2052, 297, 413, 304, 267, 372, 715, 272, 372, 756, 421, 199, 318, 370, 63, 2083, 8, 875, 12, 1475, 5961, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 2349, 272, 372, 2197, 14, 2083, 14, 9866, 8, 875, 12, 1475, 9, 421, 199, 318, 14053, 8, 875, 63, 908, 12, 3499, 29, 403, 304, 272, 1449, 372, 282, 1434, 1059, 1808, 1059, 14, 1666, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 521, 14, 1360, 3, 521, 14, 6205, 367, 1475, 1449, 272, 340, 3499, 365, 440, 488, 26, 267, 862, 26, 288, 3499, 275, 2069, 8, 4375, 9, 267, 871, 2186, 26, 288, 746, 2622, 4131, 547, 360, 3364, 574, 367, 9463, 574, 4366, 83, 3171, 450, 3499, 9, 272, 372, 900, 14, 6205, 8, 875, 63, 908, 12, 900, 14, 15198, 8, 4375, 430, 421, 199, 318, 6313, 8, 65, 304, 272, 1449, 372, 2399, 1423, 10999 ]
[ 334, 67, 9, 6029, 12, 1603, 3478, 287, 28673, 5711, 88, 665, 74, 3478, 287, 32, 526, 5711, 88, 14, 1235, 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, 646, 1300, 772, 199, 646, 5739, 199, 646, 8337, 199, 646, 2022, 199, 646, 13377, 515, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 984, 199, 646, 900, 199, 646, 5377, 199, 646, 8864, 199, 199, 646, 2197, 199, 504, 9143, 492, 7417, 199, 504, 2196, 492, 9571, 12, 6187, 3883, 12, 13031, 199, 199, 504, 10321, 18, 14, 4273, 492, 3734, 1541, 12, 886, 63, 16968, 465, 485, 1117, 63, 16968, 199, 199, 504, 3242, 14, 2550, 492, 13358, 12, 2622, 4131, 547, 12, 2622, 4131, 4333, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 1059, 63, 1313, 12, 3000, 63, 1313, 12, 24139, 12, 1318, 63, 466, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 14, 4912, 492, 16701, 63, 3513, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 12, 370, 63, 6106, 12, 370, 63, 505, 199, 504, 3242, 14, 578, 63, 1208, 14, 2330, 14, 7882, 492, 365, 63, 4041, 199, 504, 3242, 14, 578, 63, 1208, 14, 2330, 423, 7882, 63, 5819, 492, 12340, 199, 504, 3242, 14, 11059, 14, 65, 1001, 492, 2622, 23069, 199, 504, 3242, 14, 11059, 14, 5963, 14, 2724, 281, 492, 2622, 28593, 199, 504, 3242, 14, 1160, 492, 9133, 63, 1074, 63, 4037, 199, 504, 3242, 14, 1208, 14, 2918, 492, 12175, 199, 504, 3242, 14, 1208, 14, 11929, 492, 986, 773, 63, 269, 63, 4997, 199, 504, 3242, 14, 1208, 14, 2227, 316, 492, 6128, 21, 83, 12, 9040, 63, 83, 199, 504, 3242, 14, 1208, 14, 2975, 492, 2649, 63, 3823, 199, 504, 3242, 14, 1208, 14, 2936, 492, 5389, 63, 2227, 199, 199, 2918, 275, 12175, 342, 199, 199, 8757, 63, 13001, 63, 8490, 275, 5377, 14, 8757, 360, 15702, 37, 22, 36, 2869, 13, 2078, 4220, 13, 18078, 33, 13, 25, 19000, 13, 1082, 969, 1184, 8980, 24, 37, 18, 37, 358, 421, 199, 318, 370, 63, 5963, 8, 65, 12, 627, 589, 12, 1011, 829, 304, 272, 1449, 5483, 3376, 12, 11779, 12701, 8864, 2344, 272, 849, 63, 1659, 63, 2487, 275, 4775, 14, 1935, 360, 885, 63, 1659, 63, 2487, 297, 488, 9, 272, 14834, 275, 8864, 14, 2724, 8, 65, 12, 19460, 281, 29, 10047, 28593, 12, 2040, 63, 2975, 29, 549, 12, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 12, 1011, 829, 9, 272, 372, 370, 63, 505, 8, 20209, 9, 421, 199, 318, 370, 63, 22746, 63, 5963, 8, 65, 12, 4363, 29, 20, 12, 627, 589, 12, 1011, 829, 304, 272, 1449, 5483, 3376, 12, 11779, 12701, 8864, 2344, 272, 14834, 275, 8864, 14, 2724, 8, 65, 12, 19460, 281, 29, 10047, 28593, 12, 4363, 29, 3724, 12, 2040, 63, 2975, 29, 549, 12, 849, 63, 1659, 63, 2487, 29, 797, 12, 1011, 829, 9, 272, 372, 370, 63, 505, 8, 20209, 9, 421, 199, 318, 370, 63, 1001, 8, 65, 12, 627, 589, 12, 1011, 829, 304, 272, 1449, 7905, 314, 574, 370, 4840, 1449, 272, 372, 2022, 14, 4180, 8, 65, 12, 843, 29, 10047, 23069, 12, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 370, 63, 22746, 63, 1001, 8, 65, 12, 4363, 29, 20, 12, 4069, 63, 1612, 29, 549, 12, 627, 589, 12, 1011, 829, 304, 272, 1449, 5483, 3376, 12, 11779, 12701, 4840, 2344, 272, 372, 370, 63, 1001, 8, 65, 12, 4363, 29, 3724, 12, 4069, 63, 1612, 29, 3191, 63, 1612, 12, 17658, 2687, 23324, 7596, 17748, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 370, 63, 2245, 8, 65, 304, 272, 1449, 372, 282, 2155, 367, 314, 1680, 1449, 272, 340, 282, 365, 488, 503, 1228, 8, 65, 12, 2155, 304, 267, 372, 282, 272, 340, 1228, 8, 65, 12, 1059, 63, 1313, 304, 267, 282, 275, 282, 14, 2325, 342, 272, 340, 282, 315, 661, 5066, 297, 283, 265, 297, 283, 17, 297, 283, 2052, 297, 413, 304, 267, 372, 715, 272, 372, 756, 421, 199, 318, 370, 63, 2083, 8, 875, 12, 1475, 5961, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 2349, 272, 372, 2197, 14, 2083, 14, 9866, 8, 875, 12, 1475, 9, 421, 199, 318, 14053, 8, 875, 63, 908, 12, 3499, 29, 403, 304, 272, 1449, 372, 282, 1434, 1059, 1808, 1059, 14, 1666, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 521, 14, 1360, 3, 521, 14, 6205, 367, 1475, 1449, 272, 340, 3499, 365, 440, 488, 26, 267, 862, 26, 288, 3499, 275, 2069, 8, 4375, 9, 267, 871, 2186, 26, 288, 746, 2622, 4131, 547, 360, 3364, 574, 367, 9463, 574, 4366, 83, 3171, 450, 3499, 9, 272, 372, 900, 14, 6205, 8, 875, 63, 908, 12, 900, 14, 15198, 8, 4375, 430, 421, 199, 318, 6313, 8, 65, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
apache/beam
sdks/python/apache_beam/transforms/combiners_test.py
5
33747
# # 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. # """Unit tests for our libraries of combine PTransforms.""" # pytype: skip-file import itertools import random import unittest import hamcrest as hc import pytest import apache_beam as beam import apache_beam.transforms.combiners as combine from apache_beam.metrics import Metrics from apache_beam.metrics import MetricsFilter from apache_beam.options.pipeline_options import PipelineOptions from apache_beam.options.pipeline_options import StandardOptions from apache_beam.testing.test_pipeline import TestPipeline from apache_beam.testing.test_stream import TestStream from apache_beam.testing.util import assert_that from apache_beam.testing.util import equal_to from apache_beam.testing.util import equal_to_per_window from apache_beam.transforms import WindowInto from apache_beam.transforms import trigger from apache_beam.transforms import window from apache_beam.transforms.core import CombineGlobally from apache_beam.transforms.core import Create from apache_beam.transforms.core import Map from apache_beam.transforms.display import DisplayData from apache_beam.transforms.display_test import DisplayDataItemMatcher from apache_beam.transforms.ptransform import PTransform from apache_beam.transforms.trigger import AfterAll from apache_beam.transforms.trigger import AfterCount from apache_beam.transforms.trigger import AfterWatermark from apache_beam.transforms.window import FixedWindows from apache_beam.transforms.window import GlobalWindows from apache_beam.transforms.window import TimestampCombiner from apache_beam.transforms.window import TimestampedValue from apache_beam.typehints import TypeCheckError from apache_beam.utils.timestamp import Timestamp class SortedConcatWithCounters(beam.CombineFn): """CombineFn for incrementing three different counters: counter, distribution, gauge, at the same time concatenating words.""" def __init__(self): beam.CombineFn.__init__(self) self.word_counter = Metrics.counter(self.__class__, 'word_counter') self.word_lengths_counter = Metrics.counter(self.__class__, 'word_lengths') self.word_lengths_dist = Metrics.distribution( self.__class__, 'word_len_dist') self.last_word_len = Metrics.gauge(self.__class__, 'last_word_len') def create_accumulator(self): return '' def add_input(self, acc, element): self.word_counter.inc(1) self.word_lengths_counter.inc(len(element)) self.word_lengths_dist.update(len(element)) self.last_word_len.set(len(element)) return acc + element def merge_accumulators(self, accs): return ''.join(accs) def extract_output(self, acc): # The sorted acc became a list of characters # and has to be converted back to a string using join. return ''.join(sorted(acc)) class CombineTest(unittest.TestCase): def test_builtin_combines(self): with TestPipeline() as pipeline: vals = [6, 3, 1, 1, 9, 1, 5, 2, 0, 6] mean = sum(vals) / float(len(vals)) size = len(vals) timestamp = 0 # First for global combines. pcoll = pipeline | 'start' >> Create(vals) result_mean = pcoll | 'mean' >> combine.Mean.Globally() result_count = pcoll | 'count' >> combine.Count.Globally() assert_that(result_mean, equal_to([mean]), label='assert:mean') assert_that(result_count, equal_to([size]), label='assert:size') # Now for global combines without default timestamped = pcoll | Map(lambda x: TimestampedValue(x, timestamp)) windowed = timestamped | 'window' >> WindowInto(FixedWindows(60)) result_windowed_mean = ( windowed | 'mean-wo-defaults' >> combine.Mean.Globally().without_defaults()) assert_that( result_windowed_mean, equal_to([mean]), label='assert:mean-wo-defaults') result_windowed_count = ( windowed | 'count-wo-defaults' >> combine.Count.Globally().without_defaults()) assert_that( result_windowed_count, equal_to([size]), label='assert:count-wo-defaults') # Again for per-key combines. pcoll = pipeline | 'start-perkey' >> Create([('a', x) for x in vals]) result_key_mean = pcoll | 'mean-perkey' >> combine.Mean.PerKey() result_key_count = pcoll | 'count-perkey' >> combine.Count.PerKey() assert_that(result_key_mean, equal_to([('a', mean)]), label='key:mean') assert_that(result_key_count, equal_to([('a', size)]), label='key:size') def test_top(self): with TestPipeline() as pipeline: timestamp = 0 # First for global combines. pcoll = pipeline | 'start' >> Create([6, 3, 1, 1, 9, 1, 5, 2, 0, 6]) result_top = pcoll | 'top' >> combine.Top.Largest(5) result_bot = pcoll | 'bot' >> combine.Top.Smallest(4) assert_that(result_top, equal_to([[9, 6, 6, 5, 3]]), label='assert:top') assert_that(result_bot, equal_to([[0, 1, 1, 1]]), label='assert:bot') # Now for global combines without default timestamped = pcoll | Map(lambda x: TimestampedValue(x, timestamp)) windowed = timestamped | 'window' >> WindowInto(FixedWindows(60)) result_windowed_top = windowed | 'top-wo-defaults' >> combine.Top.Largest( 5, has_defaults=False) result_windowed_bot = ( windowed | 'bot-wo-defaults' >> combine.Top.Smallest(4, has_defaults=False)) assert_that( result_windowed_top, equal_to([[9, 6, 6, 5, 3]]), label='assert:top-wo-defaults') assert_that( result_windowed_bot, equal_to([[0, 1, 1, 1]]), label='assert:bot-wo-defaults') # Again for per-key combines. pcoll = pipeline | 'start-perkey' >> Create( [('a', x) for x in [6, 3, 1, 1, 9, 1, 5, 2, 0, 6]]) result_key_top = pcoll | 'top-perkey' >> combine.Top.LargestPerKey(5) result_key_bot = pcoll | 'bot-perkey' >> combine.Top.SmallestPerKey(4) assert_that( result_key_top, equal_to([('a', [9, 6, 6, 5, 3])]), label='key:top') assert_that( result_key_bot, equal_to([('a', [0, 1, 1, 1])]), label='key:bot') def test_empty_global_top(self): with TestPipeline() as p: assert_that(p | beam.Create([]) | combine.Top.Largest(10), equal_to([[]])) def test_sharded_top(self): elements = list(range(100)) random.shuffle(elements) with TestPipeline() as pipeline: shards = [ pipeline | 'Shard%s' % shard >> beam.Create(elements[shard::7]) for shard in range(7) ] assert_that( shards | beam.Flatten() | combine.Top.Largest(10), equal_to([[99, 98, 97, 96, 95, 94, 93, 92, 91, 90]])) def test_top_key(self): self.assertEqual(['aa', 'bbb', 'c', 'dddd'] | combine.Top.Of(3, key=len), [['dddd', 'bbb', 'aa']]) self.assertEqual(['aa', 'bbb', 'c', 'dddd'] | combine.Top.Of(3, key=len, reverse=True), [['c', 'aa', 'bbb']]) def test_sharded_top_combine_fn(self): def test_combine_fn(combine_fn, shards, expected): accumulators = [ combine_fn.add_inputs(combine_fn.create_accumulator(), shard) for shard in shards ] final_accumulator = combine_fn.merge_accumulators(accumulators) self.assertEqual(combine_fn.extract_output(final_accumulator), expected) test_combine_fn(combine.TopCombineFn(3), [range(10), range(10)], [9, 9, 8]) test_combine_fn( combine.TopCombineFn(5), [range(1000), range(100), range(1001)], [1000, 999, 999, 998, 998]) def test_combine_per_key_top_display_data(self): def individual_test_per_key_dd(combineFn): transform = beam.CombinePerKey(combineFn) dd = DisplayData.create_from(transform) expected_items = [ DisplayDataItemMatcher('combine_fn', combineFn.__class__), DisplayDataItemMatcher('n', combineFn._n), DisplayDataItemMatcher('compare', combineFn._compare.__name__) ] hc.assert_that(dd.items, hc.contains_inanyorder(*expected_items)) individual_test_per_key_dd(combine.Largest(5)) individual_test_per_key_dd(combine.Smallest(3)) individual_test_per_key_dd(combine.TopCombineFn(8)) individual_test_per_key_dd(combine.Largest(5)) def test_combine_sample_display_data(self): def individual_test_per_key_dd(sampleFn, n): trs = [sampleFn(n)] for transform in trs: dd = DisplayData.create_from(transform) hc.assert_that( dd.items, hc.contains_inanyorder(DisplayDataItemMatcher('n', transform._n))) individual_test_per_key_dd(combine.Sample.FixedSizePerKey, 5) individual_test_per_key_dd(combine.Sample.FixedSizeGlobally, 5) def test_combine_globally_display_data(self): transform = beam.CombineGlobally(combine.Smallest(5)) dd = DisplayData.create_from(transform) expected_items = [ DisplayDataItemMatcher('combine_fn', combine.Smallest), DisplayDataItemMatcher('n', 5), DisplayDataItemMatcher('compare', 'gt') ] hc.assert_that(dd.items, hc.contains_inanyorder(*expected_items)) def test_basic_combiners_display_data(self): transform = beam.CombineGlobally( combine.TupleCombineFn(max, combine.MeanCombineFn(), sum)) dd = DisplayData.create_from(transform) expected_items = [ DisplayDataItemMatcher('combine_fn', combine.TupleCombineFn), DisplayDataItemMatcher('combiners', "['max', 'MeanCombineFn', 'sum']") ] hc.assert_that(dd.items, hc.contains_inanyorder(*expected_items)) def test_top_shorthands(self): with TestPipeline() as pipeline: pcoll = pipeline | 'start' >> Create([6, 3, 1, 1, 9, 1, 5, 2, 0, 6]) result_top = pcoll | 'top' >> beam.CombineGlobally(combine.Largest(5)) result_bot = pcoll | 'bot' >> beam.CombineGlobally(combine.Smallest(4)) assert_that(result_top, equal_to([[9, 6, 6, 5, 3]]), label='assert:top') assert_that(result_bot, equal_to([[0, 1, 1, 1]]), label='assert:bot') pcoll = pipeline | 'start-perkey' >> Create( [('a', x) for x in [6, 3, 1, 1, 9, 1, 5, 2, 0, 6]]) result_ktop = pcoll | 'top-perkey' >> beam.CombinePerKey( combine.Largest(5)) result_kbot = pcoll | 'bot-perkey' >> beam.CombinePerKey( combine.Smallest(4)) assert_that(result_ktop, equal_to([('a', [9, 6, 6, 5, 3])]), label='ktop') assert_that(result_kbot, equal_to([('a', [0, 1, 1, 1])]), label='kbot') def test_top_no_compact(self): class TopCombineFnNoCompact(combine.TopCombineFn): def compact(self, accumulator): return accumulator with TestPipeline() as pipeline: pcoll = pipeline | 'Start' >> Create([6, 3, 1, 1, 9, 1, 5, 2, 0, 6]) result_top = pcoll | 'Top' >> beam.CombineGlobally( TopCombineFnNoCompact(5, key=lambda x: x)) result_bot = pcoll | 'Bot' >> beam.CombineGlobally( TopCombineFnNoCompact(4, reverse=True)) assert_that(result_top, equal_to([[9, 6, 6, 5, 3]]), label='Assert:Top') assert_that(result_bot, equal_to([[0, 1, 1, 1]]), label='Assert:Bot') pcoll = pipeline | 'Start-Perkey' >> Create( [('a', x) for x in [6, 3, 1, 1, 9, 1, 5, 2, 0, 6]]) result_ktop = pcoll | 'Top-PerKey' >> beam.CombinePerKey( TopCombineFnNoCompact(5, key=lambda x: x)) result_kbot = pcoll | 'Bot-PerKey' >> beam.CombinePerKey( TopCombineFnNoCompact(4, reverse=True)) assert_that(result_ktop, equal_to([('a', [9, 6, 6, 5, 3])]), label='KTop') assert_that(result_kbot, equal_to([('a', [0, 1, 1, 1])]), label='KBot') def test_global_sample(self): def is_good_sample(actual): assert len(actual) == 1 assert sorted(actual[0]) in [[1, 1, 2], [1, 2, 2]], actual with TestPipeline() as pipeline: timestamp = 0 pcoll = pipeline | 'start' >> Create([1, 1, 2, 2]) # Now for global combines without default timestamped = pcoll | Map(lambda x: TimestampedValue(x, timestamp)) windowed = timestamped | 'window' >> WindowInto(FixedWindows(60)) for ix in range(9): assert_that( pcoll | 'sample-%d' % ix >> combine.Sample.FixedSizeGlobally(3), is_good_sample, label='check-%d' % ix) result_windowed = ( windowed | 'sample-wo-defaults-%d' % ix >> combine.Sample.FixedSizeGlobally(3).without_defaults()) assert_that( result_windowed, is_good_sample, label='check-wo-defaults-%d' % ix) def test_per_key_sample(self): with TestPipeline() as pipeline: pcoll = pipeline | 'start-perkey' >> Create( sum(([(i, 1), (i, 1), (i, 2), (i, 2)] for i in range(9)), [])) result = pcoll | 'sample' >> combine.Sample.FixedSizePerKey(3) def matcher(): def match(actual): for _, samples in actual: equal_to([3])([len(samples)]) num_ones = sum(1 for x in samples if x == 1) num_twos = sum(1 for x in samples if x == 2) equal_to([1, 2])([num_ones, num_twos]) return match assert_that(result, matcher()) def test_tuple_combine_fn(self): with TestPipeline() as p: result = ( p | Create([('a', 100, 0.0), ('b', 10, -1), ('c', 1, 100)]) | beam.CombineGlobally( combine.TupleCombineFn(max, combine.MeanCombineFn(), sum)).without_defaults()) assert_that(result, equal_to([('c', 111.0 / 3, 99.0)])) def test_tuple_combine_fn_without_defaults(self): with TestPipeline() as p: result = ( p | Create([1, 1, 2, 3]) | beam.CombineGlobally( combine.TupleCombineFn( min, combine.MeanCombineFn(), max).with_common_input()).without_defaults()) assert_that(result, equal_to([(1, 7.0 / 4, 3)])) def test_to_list_and_to_dict1(self): with TestPipeline() as pipeline: the_list = [6, 3, 1, 1, 9, 1, 5, 2, 0, 6] timestamp = 0 pcoll = pipeline | 'start' >> Create(the_list) result = pcoll | 'to list' >> combine.ToList() # Now for global combines without default timestamped = pcoll | Map(lambda x: TimestampedValue(x, timestamp)) windowed = timestamped | 'window' >> WindowInto(FixedWindows(60)) result_windowed = ( windowed | 'to list wo defaults' >> combine.ToList().without_defaults()) def matcher(expected): def match(actual): equal_to(expected[0])(actual[0]) return match assert_that(result, matcher([the_list])) assert_that( result_windowed, matcher([the_list]), label='to-list-wo-defaults') def test_to_list_and_to_dict2(self): with TestPipeline() as pipeline: pairs = [(1, 2), (3, 4), (5, 6)] timestamp = 0 pcoll = pipeline | 'start-pairs' >> Create(pairs) result = pcoll | 'to dict' >> combine.ToDict() # Now for global combines without default timestamped = pcoll | Map(lambda x: TimestampedValue(x, timestamp)) windowed = timestamped | 'window' >> WindowInto(FixedWindows(60)) result_windowed = ( windowed | 'to dict wo defaults' >> combine.ToDict().without_defaults()) def matcher(): def match(actual): equal_to([1])([len(actual)]) equal_to(pairs)(actual[0].items()) return match assert_that(result, matcher()) assert_that(result_windowed, matcher(), label='to-dict-wo-defaults') def test_to_set(self): pipeline = TestPipeline() the_list = [6, 3, 1, 1, 9, 1, 5, 2, 0, 6] timestamp = 0 pcoll = pipeline | 'start' >> Create(the_list) result = pcoll | 'to set' >> combine.ToSet() # Now for global combines without default timestamped = pcoll | Map(lambda x: TimestampedValue(x, timestamp)) windowed = timestamped | 'window' >> WindowInto(FixedWindows(60)) result_windowed = ( windowed | 'to set wo defaults' >> combine.ToSet().without_defaults()) def matcher(expected): def match(actual): equal_to(expected[0])(actual[0]) return match assert_that(result, matcher(set(the_list))) assert_that( result_windowed, matcher(set(the_list)), label='to-set-wo-defaults') def test_combine_globally_with_default(self): with TestPipeline() as p: assert_that(p | Create([]) | CombineGlobally(sum), equal_to([0])) def test_combine_globally_without_default(self): with TestPipeline() as p: result = p | Create([]) | CombineGlobally(sum).without_defaults() assert_that(result, equal_to([])) def test_combine_globally_with_default_side_input(self): class SideInputCombine(PTransform): def expand(self, pcoll): side = pcoll | CombineGlobally(sum).as_singleton_view() main = pcoll.pipeline | Create([None]) return main | Map(lambda _, s: s, side) with TestPipeline() as p: result1 = p | 'i1' >> Create([]) | 'c1' >> SideInputCombine() result2 = p | 'i2' >> Create([1, 2, 3, 4]) | 'c2' >> SideInputCombine() assert_that(result1, equal_to([0]), label='r1') assert_that(result2, equal_to([10]), label='r2') def test_hot_key_fanout(self): with TestPipeline() as p: result = ( p | beam.Create(itertools.product(['hot', 'cold'], range(10))) | beam.CombinePerKey(combine.MeanCombineFn()).with_hot_key_fanout( lambda key: (key == 'hot') * 5)) assert_that(result, equal_to([('hot', 4.5), ('cold', 4.5)])) def test_hot_key_fanout_sharded(self): # Lots of elements with the same key with varying/no fanout. with TestPipeline() as p: elements = [(None, e) for e in range(1000)] random.shuffle(elements) shards = [ p | "Shard%s" % shard >> beam.Create(elements[shard::20]) for shard in range(20) ] result = ( shards | beam.Flatten() | beam.CombinePerKey(combine.MeanCombineFn()).with_hot_key_fanout( lambda key: random.randrange(0, 5))) assert_that(result, equal_to([(None, 499.5)])) def test_global_fanout(self): with TestPipeline() as p: result = ( p | beam.Create(range(100)) | beam.CombineGlobally(combine.MeanCombineFn()).with_fanout(11)) assert_that(result, equal_to([49.5])) def test_combining_with_accumulation_mode_and_fanout(self): # PCollection will contain elements from 1 to 5. elements = [i for i in range(1, 6)] ts = TestStream().advance_watermark_to(0) for i in elements: ts.add_elements([i]) ts.advance_watermark_to_infinity() options = PipelineOptions() options.view_as(StandardOptions).streaming = True with TestPipeline(options=options) as p: result = ( p | ts | beam.WindowInto( GlobalWindows(), accumulation_mode=trigger.AccumulationMode.ACCUMULATING, trigger=AfterWatermark(early=AfterAll(AfterCount(1)))) | beam.CombineGlobally(sum).without_defaults().with_fanout(2)) def has_expected_values(actual): from hamcrest.core import assert_that as hamcrest_assert from hamcrest.library.collection import contains from hamcrest.library.collection import only_contains ordered = sorted(actual) # Early firings. hamcrest_assert(ordered[:4], contains(1, 3, 6, 10)) # Different runners have different number of 15s, but there should # be at least one 15. hamcrest_assert(ordered[4:], only_contains(15)) assert_that(result, has_expected_values) def test_MeanCombineFn_combine(self): with TestPipeline() as p: input = ( p | beam.Create([('a', 1), ('a', 1), ('a', 4), ('b', 1), ('b', 13)])) # The mean of all values regardless of key. global_mean = ( input | beam.Values() | beam.CombineGlobally(combine.MeanCombineFn())) # The (key, mean) pairs for all keys. mean_per_key = (input | beam.CombinePerKey(combine.MeanCombineFn())) expected_mean_per_key = [('a', 2), ('b', 7)] assert_that(global_mean, equal_to([4]), label='global mean') assert_that( mean_per_key, equal_to(expected_mean_per_key), label='mean per key') def test_MeanCombineFn_combine_empty(self): # For each element in a PCollection, if it is float('NaN'), then emits # a string 'NaN', otherwise emits str(element). with TestPipeline() as p: input = (p | beam.Create([])) # Compute the mean of all values in the PCollection, # then format the mean. Since the Pcollection is empty, # the mean is float('NaN'), and is formatted to be a string 'NaN'. global_mean = ( input | beam.Values() | beam.CombineGlobally(combine.MeanCombineFn()) | beam.Map(str)) mean_per_key = (input | beam.CombinePerKey(combine.MeanCombineFn())) # We can't compare one float('NaN') with another float('NaN'), # but we can compare one 'nan' string with another string. assert_that(global_mean, equal_to(['nan']), label='global mean') assert_that(mean_per_key, equal_to([]), label='mean per key') def test_sessions_combine(self): with TestPipeline() as p: input = ( p | beam.Create([('c', 1), ('c', 9), ('c', 12), ('d', 2), ('d', 4)]) | beam.MapTuple(lambda k, v: window.TimestampedValue((k, v), v)) | beam.WindowInto(window.Sessions(4))) global_sum = ( input | beam.Values() | beam.CombineGlobally(sum).without_defaults()) sum_per_key = input | beam.CombinePerKey(sum) # The first window has 3 elements: ('c', 1), ('d', 2), ('d', 4). # The second window has 2 elements: ('c', 9), ('c', 12). assert_that(global_sum, equal_to([7, 21]), label='global sum') assert_that( sum_per_key, equal_to([('c', 1), ('c', 21), ('d', 6)]), label='sum per key') def test_fixed_windows_combine(self): with TestPipeline() as p: input = ( p | beam.Create([('c', 1), ('c', 2), ('c', 10), ('d', 5), ('d', 8), ('d', 9)]) | beam.MapTuple(lambda k, v: window.TimestampedValue((k, v), v)) | beam.WindowInto(window.FixedWindows(4))) global_sum = ( input | beam.Values() | beam.CombineGlobally(sum).without_defaults()) sum_per_key = input | beam.CombinePerKey(sum) # The first window has 2 elements: ('c', 1), ('c', 2). # The second window has 1 elements: ('d', 5). # The third window has 3 elements: ('c', 10), ('d', 8), ('d', 9). assert_that(global_sum, equal_to([3, 5, 27]), label='global sum') assert_that( sum_per_key, equal_to([('c', 3), ('c', 10), ('d', 5), ('d', 17)]), label='sum per key') # Test that three different kinds of metrics work with a customized # SortedConcatWithCounters CombineFn. def test_custormized_counters_in_combine_fn(self): p = TestPipeline() input = ( p | beam.Create([('key1', 'a'), ('key1', 'ab'), ('key1', 'abc'), ('key2', 'uvxy'), ('key2', 'uvxyz')])) # The result of concatenating all values regardless of key. global_concat = ( input | beam.Values() | beam.CombineGlobally(SortedConcatWithCounters())) # The (key, concatenated_string) pairs for all keys. concat_per_key = (input | beam.CombinePerKey(SortedConcatWithCounters())) # Verify the concatenated strings are correct. expected_concat_per_key = [('key1', 'aaabbc'), ('key2', 'uuvvxxyyz')] assert_that( global_concat, equal_to(['aaabbcuuvvxxyyz']), label='global concat') assert_that( concat_per_key, equal_to(expected_concat_per_key), label='concat per key') result = p.run() result.wait_until_finish() # Verify the values of metrics are correct. word_counter_filter = MetricsFilter().with_name('word_counter') query_result = result.metrics().query(word_counter_filter) if query_result['counters']: word_counter = query_result['counters'][0] self.assertEqual(word_counter.result, 5) word_lengths_filter = MetricsFilter().with_name('word_lengths') query_result = result.metrics().query(word_lengths_filter) if query_result['counters']: word_lengths = query_result['counters'][0] self.assertEqual(word_lengths.result, 15) word_len_dist_filter = MetricsFilter().with_name('word_len_dist') query_result = result.metrics().query(word_len_dist_filter) if query_result['distributions']: word_len_dist = query_result['distributions'][0] self.assertEqual(word_len_dist.result.mean, 3) last_word_len_filter = MetricsFilter().with_name('last_word_len') query_result = result.metrics().query(last_word_len_filter) if query_result['gauges']: last_word_len = query_result['gauges'][0] self.assertIn(last_word_len.result.value, [1, 2, 3, 4, 5]) # Test that three different kinds of metrics work with the customized # SortedConcatWithCounters CombineFn when the PCollection is empty. def test_custormized_counters_in_combine_fn_empty(self): p = TestPipeline() input = p | beam.Create([]) # The result of concatenating all values regardless of key. global_concat = ( input | beam.Values() | beam.CombineGlobally(SortedConcatWithCounters())) # The (key, concatenated_string) pairs for all keys. concat_per_key = (input | beam.CombinePerKey(SortedConcatWithCounters())) # Verify the concatenated strings are correct. assert_that(global_concat, equal_to(['']), label='global concat') assert_that(concat_per_key, equal_to([]), label='concat per key') result = p.run() result.wait_until_finish() # Verify the values of metrics are correct. word_counter_filter = MetricsFilter().with_name('word_counter') query_result = result.metrics().query(word_counter_filter) if query_result['counters']: word_counter = query_result['counters'][0] self.assertEqual(word_counter.result, 0) word_lengths_filter = MetricsFilter().with_name('word_lengths') query_result = result.metrics().query(word_lengths_filter) if query_result['counters']: word_lengths = query_result['counters'][0] self.assertEqual(word_lengths.result, 0) word_len_dist_filter = MetricsFilter().with_name('word_len_dist') query_result = result.metrics().query(word_len_dist_filter) if query_result['distributions']: word_len_dist = query_result['distributions'][0] self.assertEqual(word_len_dist.result.count, 0) last_word_len_filter = MetricsFilter().with_name('last_word_len') query_result = result.metrics().query(last_word_len_filter) # No element has ever been recorded. self.assertFalse(query_result['gauges']) class LatestTest(unittest.TestCase): def test_globally(self): l = [ window.TimestampedValue(3, 100), window.TimestampedValue(1, 200), window.TimestampedValue(2, 300) ] with TestPipeline() as p: # Map(lambda x: x) PTransform is added after Create here, because when # a PCollection of TimestampedValues is created with Create PTransform, # the timestamps are not assigned to it. Adding a Map forces the # PCollection to go through a DoFn so that the PCollection consists of # the elements with timestamps assigned to them instead of a PCollection # of TimestampedValue(element, timestamp). pcoll = p | Create(l) | Map(lambda x: x) latest = pcoll | combine.Latest.Globally() assert_that(latest, equal_to([2])) # Now for global combines without default windowed = pcoll | 'window' >> WindowInto(FixedWindows(180)) result_windowed = ( windowed | 'latest wo defaults' >> combine.Latest.Globally().without_defaults()) assert_that(result_windowed, equal_to([3, 2]), label='latest-wo-defaults') def test_globally_empty(self): l = [] with TestPipeline() as p: pc = p | Create(l) | Map(lambda x: x) latest = pc | combine.Latest.Globally() assert_that(latest, equal_to([None])) def test_per_key(self): l = [ window.TimestampedValue(('a', 1), 300), window.TimestampedValue(('b', 3), 100), window.TimestampedValue(('a', 2), 200) ] with TestPipeline() as p: pc = p | Create(l) | Map(lambda x: x) latest = pc | combine.Latest.PerKey() assert_that(latest, equal_to([('a', 1), ('b', 3)])) def test_per_key_empty(self): l = [] with TestPipeline() as p: pc = p | Create(l) | Map(lambda x: x) latest = pc | combine.Latest.PerKey() assert_that(latest, equal_to([])) class LatestCombineFnTest(unittest.TestCase): def setUp(self): self.fn = combine.LatestCombineFn() def test_create_accumulator(self): accumulator = self.fn.create_accumulator() self.assertEqual(accumulator, (None, window.MIN_TIMESTAMP)) def test_add_input(self): accumulator = self.fn.create_accumulator() element = (1, 100) new_accumulator = self.fn.add_input(accumulator, element) self.assertEqual(new_accumulator, (1, 100)) def test_merge_accumulators(self): accumulators = [(2, 400), (5, 100), (9, 200)] merged_accumulator = self.fn.merge_accumulators(accumulators) self.assertEqual(merged_accumulator, (2, 400)) def test_extract_output(self): accumulator = (1, 100) output = self.fn.extract_output(accumulator) self.assertEqual(output, 1) def test_with_input_types_decorator_violation(self): l_int = [1, 2, 3] l_dict = [{'a': 3}, {'g': 5}, {'r': 8}] l_3_tuple = [(12, 31, 41), (12, 34, 34), (84, 92, 74)] with self.assertRaises(TypeCheckError): with TestPipeline() as p: pc = p | Create(l_int) _ = pc | beam.CombineGlobally(self.fn) with self.assertRaises(TypeCheckError): with TestPipeline() as p: pc = p | Create(l_dict) _ = pc | beam.CombineGlobally(self.fn) with self.assertRaises(TypeCheckError): with TestPipeline() as p: pc = p | Create(l_3_tuple) _ = pc | beam.CombineGlobally(self.fn) # # Test cases for streaming. # @pytest.mark.it_validatesrunner class TimestampCombinerTest(unittest.TestCase): def test_combiner_earliest(self): """Test TimestampCombiner with EARLIEST.""" options = PipelineOptions(streaming=True) with TestPipeline(options=options) as p: result = ( p | TestStream().add_elements([window.TimestampedValue( ('k', 100), 2)]).add_elements( [window.TimestampedValue( ('k', 400), 7)]).advance_watermark_to_infinity() | beam.WindowInto( window.FixedWindows(10), timestamp_combiner=TimestampCombiner.OUTPUT_AT_EARLIEST) | beam.CombinePerKey(sum)) records = ( result | beam.Map(lambda e, ts=beam.DoFn.TimestampParam: (e, ts))) # All the KV pairs are applied GBK using EARLIEST timestamp for the same # key. expected_window_to_elements = { window.IntervalWindow(0, 10): [ (('k', 500), Timestamp(2)), ], } assert_that( records, equal_to_per_window(expected_window_to_elements), use_global_window=False, label='assert per window') def test_combiner_latest(self): """Test TimestampCombiner with LATEST.""" options = PipelineOptions(streaming=True) with TestPipeline(options=options) as p: result = ( p | TestStream().add_elements([window.TimestampedValue( ('k', 100), 2)]).add_elements( [window.TimestampedValue( ('k', 400), 7)]).advance_watermark_to_infinity() | beam.WindowInto( window.FixedWindows(10), timestamp_combiner=TimestampCombiner.OUTPUT_AT_LATEST) | beam.CombinePerKey(sum)) records = ( result | beam.Map(lambda e, ts=beam.DoFn.TimestampParam: (e, ts))) # All the KV pairs are applied GBK using LATEST timestamp for # the same key. expected_window_to_elements = { window.IntervalWindow(0, 10): [ (('k', 500), Timestamp(7)), ], } assert_that( records, equal_to_per_window(expected_window_to_elements), use_global_window=False, label='assert per window') if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 5072, 2295, 367, 4154, 8363, 402, 13323, 510, 3188, 3351, 1041, 199, 3, 1134, 466, 26, 3372, 13, 493, 199, 199, 646, 7975, 199, 646, 2196, 199, 646, 2882, 199, 199, 646, 24868, 1353, 270, 465, 394, 67, 199, 646, 4613, 199, 199, 646, 17098, 63, 14529, 465, 17453, 199, 646, 17098, 63, 14529, 14, 15133, 14, 6560, 262, 1192, 465, 13323, 199, 504, 17098, 63, 14529, 14, 6759, 492, 10072, 11818, 199, 504, 17098, 63, 14529, 14, 6759, 492, 10072, 11818, 4131, 199, 504, 17098, 63, 14529, 14, 1419, 14, 7379, 63, 1419, 492, 19090, 4558, 199, 504, 17098, 63, 14529, 14, 1419, 14, 7379, 63, 1419, 492, 9739, 4558, 199, 504, 17098, 63, 14529, 14, 4776, 14, 396, 63, 7379, 492, 1379, 17562, 199, 504, 17098, 63, 14529, 14, 4776, 14, 396, 63, 1745, 492, 1379, 3296, 199, 504, 17098, 63, 14529, 14, 4776, 14, 1974, 492, 702, 63, 9099, 199, 504, 17098, 63, 14529, 14, 4776, 14, 1974, 492, 4472, 63, 475, 199, 504, 17098, 63, 14529, 14, 4776, 14, 1974, 492, 4472, 63, 475, 63, 529, 63, 3806, 199, 504, 17098, 63, 14529, 14, 15133, 492, 15689, 19448, 199, 504, 17098, 63, 14529, 14, 15133, 492, 6804, 199, 504, 17098, 63, 14529, 14, 15133, 492, 4353, 199, 504, 17098, 63, 14529, 14, 15133, 14, 1018, 492, 26353, 25954, 1183, 199, 504, 17098, 63, 14529, 14, 15133, 14, 1018, 492, 2790, 199, 504, 17098, 63, 14529, 14, 15133, 14, 1018, 492, 9672, 199, 504, 17098, 63, 14529, 14, 15133, 14, 2918, 492, 12175, 1451, 199, 504, 17098, 63, 14529, 14, 15133, 14, 2918, 63, 396, 492, 12175, 1451, 2081, 16073, 199, 504, 17098, 63, 14529, 14, 15133, 14, 80, 4711, 492, 510, 6939, 199, 504, 17098, 63, 14529, 14, 15133, 14, 7631, 492, 12836, 2422, 199, 504, 17098, 63, 14529, 14, 15133, 14, 7631, 492, 12836, 2353, 199, 504, 17098, 63, 14529, 14, 15133, 14, 7631, 492, 12836, 25103, 1657, 199, 504, 17098, 63, 14529, 14, 15133, 14, 3806, 492, 18659, 8647, 199, 504, 17098, 63, 14529, 14, 15133, 14, 3806, 492, 13641, 8647, 199, 504, 17098, 63, 14529, 14, 15133, 14, 3806, 492, 18267, 17039, 281, 199, 504, 17098, 63, 14529, 14, 15133, 14, 3806, 492, 18267, 379, 1110, 199, 504, 17098, 63, 14529, 14, 466, 12354, 492, 2434, 1799, 547, 199, 504, 17098, 63, 14529, 14, 1208, 14, 3954, 492, 18267, 421, 199, 533, 27432, 25536, 3007, 24532, 878, 8, 14529, 14, 23163, 9656, 304, 523, 408, 23163, 9656, 367, 11609, 316, 7795, 3365, 21272, 26, 1362, 7055, 12, 4084, 12, 486, 30949, 12, 1362, 737, 314, 2011, 900, 16758, 1958, 5932, 1041, 523, 347, 636, 826, 721, 277, 304, 272, 17453, 14, 23163, 9656, 855, 826, 721, 277, 9, 272, 291, 14, 1027, 63, 5337, 275, 10072, 11818, 14, 5337, 8, 277, 855, 533, 3108, 283, 1027, 63, 5337, 358, 272, 291, 14, 1027, 63, 14563, 63, 5337, 275, 10072, 11818, 14, 5337, 8, 277, 855, 533, 3108, 283, 1027, 63, 14563, 358, 272, 291, 14, 1027, 63, 14563, 63, 2686, 275, 10072, 11818, 14, 4972, 8, 267, 291, 855, 533, 3108, 283, 1027, 63, 552, 63, 2686, 358, 272, 291, 14, 2019, 63, 1027, 63, 552, 275, 10072, 11818, 14, 26775, 8, 277, 855, 533, 3108, 283, 2019, 63, 1027, 63, 552, 358, 819, 347, 1218, 63, 21417, 8, 277, 304, 272, 372, 2125, 819, 347, 1050, 63, 1210, 8, 277, 12, 6907, 12, 1819, 304, 272, 291, 14, 1027, 63, 5337, 14, 6559, 8, 17, 9, 272, 291, 14, 1027, 63, 14563, 63, 5337, 14, 6559, 8, 552, 8, 2108, 430, 272, 291, 14, 1027, 63, 14563, 63, 2686, 14, 873, 8, 552, 8, 2108, 430, 272, 291, 14, 2019, 63, 1027, 63, 552, 14, 409, 8, 552, 8, 2108, 430, 339, 372, 6907, 435, 1819, 819, 347, 5389, 63, 13223, 26609, 8, 277, 12, 1066, 1259, 304, 272, 372, 6522, 904, 8, 645, 1259, 9, 819, 347, 5536, 63, 1199, 8, 277, 12, 6907, 304, 272, 327, 710, 3355, 6907, 506, 27467, 282, 769, 402, 4110, 272, 327, 436, 965, 370, 506, 6702, 1771, 370, 282, 1059, 1808, 4263, 14, 272, 372, 6522, 904, 8, 5917, 8, 5470, 430, 421, 199, 533, 26353, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 5351, 63, 6560, 3746, 8, 277, 304, 272, 543, 1379, 17562, 342, 465, 7679, 26, 2541, 5322, 275, 359, 22, 12, 650, 12, 413, 12, 413, 12, 1749, 12, 413, 12, 959, 12, 499, 12, 378, 12, 1227, 61, 489, 4615, 275, 3089, 8, 3643, 9, 1182, 2069, 8, 552, 8, 3643, 430, 489, 1568, 275, 822, 8, 3643, 9, 489, 4913, 275, 378, 2541, 327, 7758, 367, 2288, 5300, 3746, 14, 489, 299, 15772, 275, 7679, 1204, 283, 928, 7, 4331, 2790, 8, 3643, 9, 489, 754, 63, 3670, 275, 299, 15772, 1204, 283, 3670, 7, 4331, 13323, 14, 14825, 14, 25954, 1183, 342, 489, 754, 63, 835, 275, 299, 15772, 1204, 283, 835, 7, 4331, 13323, 14, 2353, 14, 25954, 1183, 342, 489, 702, 63, 9099, 8, 1099, 63 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 5072, 2295, 367, 4154, 8363, 402, 13323, 510, 3188, 3351, 1041, 199, 3, 1134, 466, 26, 3372, 13, 493, 199, 199, 646, 7975, 199, 646, 2196, 199, 646, 2882, 199, 199, 646, 24868, 1353, 270, 465, 394, 67, 199, 646, 4613, 199, 199, 646, 17098, 63, 14529, 465, 17453, 199, 646, 17098, 63, 14529, 14, 15133, 14, 6560, 262, 1192, 465, 13323, 199, 504, 17098, 63, 14529, 14, 6759, 492, 10072, 11818, 199, 504, 17098, 63, 14529, 14, 6759, 492, 10072, 11818, 4131, 199, 504, 17098, 63, 14529, 14, 1419, 14, 7379, 63, 1419, 492, 19090, 4558, 199, 504, 17098, 63, 14529, 14, 1419, 14, 7379, 63, 1419, 492, 9739, 4558, 199, 504, 17098, 63, 14529, 14, 4776, 14, 396, 63, 7379, 492, 1379, 17562, 199, 504, 17098, 63, 14529, 14, 4776, 14, 396, 63, 1745, 492, 1379, 3296, 199, 504, 17098, 63, 14529, 14, 4776, 14, 1974, 492, 702, 63, 9099, 199, 504, 17098, 63, 14529, 14, 4776, 14, 1974, 492, 4472, 63, 475, 199, 504, 17098, 63, 14529, 14, 4776, 14, 1974, 492, 4472, 63, 475, 63, 529, 63, 3806, 199, 504, 17098, 63, 14529, 14, 15133, 492, 15689, 19448, 199, 504, 17098, 63, 14529, 14, 15133, 492, 6804, 199, 504, 17098, 63, 14529, 14, 15133, 492, 4353, 199, 504, 17098, 63, 14529, 14, 15133, 14, 1018, 492, 26353, 25954, 1183, 199, 504, 17098, 63, 14529, 14, 15133, 14, 1018, 492, 2790, 199, 504, 17098, 63, 14529, 14, 15133, 14, 1018, 492, 9672, 199, 504, 17098, 63, 14529, 14, 15133, 14, 2918, 492, 12175, 1451, 199, 504, 17098, 63, 14529, 14, 15133, 14, 2918, 63, 396, 492, 12175, 1451, 2081, 16073, 199, 504, 17098, 63, 14529, 14, 15133, 14, 80, 4711, 492, 510, 6939, 199, 504, 17098, 63, 14529, 14, 15133, 14, 7631, 492, 12836, 2422, 199, 504, 17098, 63, 14529, 14, 15133, 14, 7631, 492, 12836, 2353, 199, 504, 17098, 63, 14529, 14, 15133, 14, 7631, 492, 12836, 25103, 1657, 199, 504, 17098, 63, 14529, 14, 15133, 14, 3806, 492, 18659, 8647, 199, 504, 17098, 63, 14529, 14, 15133, 14, 3806, 492, 13641, 8647, 199, 504, 17098, 63, 14529, 14, 15133, 14, 3806, 492, 18267, 17039, 281, 199, 504, 17098, 63, 14529, 14, 15133, 14, 3806, 492, 18267, 379, 1110, 199, 504, 17098, 63, 14529, 14, 466, 12354, 492, 2434, 1799, 547, 199, 504, 17098, 63, 14529, 14, 1208, 14, 3954, 492, 18267, 421, 199, 533, 27432, 25536, 3007, 24532, 878, 8, 14529, 14, 23163, 9656, 304, 523, 408, 23163, 9656, 367, 11609, 316, 7795, 3365, 21272, 26, 1362, 7055, 12, 4084, 12, 486, 30949, 12, 1362, 737, 314, 2011, 900, 16758, 1958, 5932, 1041, 523, 347, 636, 826, 721, 277, 304, 272, 17453, 14, 23163, 9656, 855, 826, 721, 277, 9, 272, 291, 14, 1027, 63, 5337, 275, 10072, 11818, 14, 5337, 8, 277, 855, 533, 3108, 283, 1027, 63, 5337, 358, 272, 291, 14, 1027, 63, 14563, 63, 5337, 275, 10072, 11818, 14, 5337, 8, 277, 855, 533, 3108, 283, 1027, 63, 14563, 358, 272, 291, 14, 1027, 63, 14563, 63, 2686, 275, 10072, 11818, 14, 4972, 8, 267, 291, 855, 533, 3108, 283, 1027, 63, 552, 63, 2686, 358, 272, 291, 14, 2019, 63, 1027, 63, 552, 275, 10072, 11818, 14, 26775, 8, 277, 855, 533, 3108, 283, 2019, 63, 1027, 63, 552, 358, 819, 347, 1218, 63, 21417, 8, 277, 304, 272, 372, 2125, 819, 347, 1050, 63, 1210, 8, 277, 12, 6907, 12, 1819, 304, 272, 291, 14, 1027, 63, 5337, 14, 6559, 8, 17, 9, 272, 291, 14, 1027, 63, 14563, 63, 5337, 14, 6559, 8, 552, 8, 2108, 430, 272, 291, 14, 1027, 63, 14563, 63, 2686, 14, 873, 8, 552, 8, 2108, 430, 272, 291, 14, 2019, 63, 1027, 63, 552, 14, 409, 8, 552, 8, 2108, 430, 339, 372, 6907, 435, 1819, 819, 347, 5389, 63, 13223, 26609, 8, 277, 12, 1066, 1259, 304, 272, 372, 6522, 904, 8, 645, 1259, 9, 819, 347, 5536, 63, 1199, 8, 277, 12, 6907, 304, 272, 327, 710, 3355, 6907, 506, 27467, 282, 769, 402, 4110, 272, 327, 436, 965, 370, 506, 6702, 1771, 370, 282, 1059, 1808, 4263, 14, 272, 372, 6522, 904, 8, 5917, 8, 5470, 430, 421, 199, 533, 26353, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 5351, 63, 6560, 3746, 8, 277, 304, 272, 543, 1379, 17562, 342, 465, 7679, 26, 2541, 5322, 275, 359, 22, 12, 650, 12, 413, 12, 413, 12, 1749, 12, 413, 12, 959, 12, 499, 12, 378, 12, 1227, 61, 489, 4615, 275, 3089, 8, 3643, 9, 1182, 2069, 8, 552, 8, 3643, 430, 489, 1568, 275, 822, 8, 3643, 9, 489, 4913, 275, 378, 2541, 327, 7758, 367, 2288, 5300, 3746, 14, 489, 299, 15772, 275, 7679, 1204, 283, 928, 7, 4331, 2790, 8, 3643, 9, 489, 754, 63, 3670, 275, 299, 15772, 1204, 283, 3670, 7, 4331, 13323, 14, 14825, 14, 25954, 1183, 342, 489, 754, 63, 835, 275, 299, 15772, 1204, 283, 835, 7, 4331, 13323, 14, 2353, 14, 25954, 1183, 342, 489, 702, 63, 9099, 8, 1099, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
mancoast/CPythonPyc_test
cpython/279_test_socket.py
24
63529
import unittest from test import test_support import errno import itertools import socket import select import time import traceback import Queue import sys import os import array import contextlib import signal import math import weakref try: import _socket except ImportError: _socket = None def try_address(host, port=0, family=socket.AF_INET): """Try to bind a socket on the given host:port and return True if that has been possible.""" try: sock = socket.socket(family, socket.SOCK_STREAM) sock.bind((host, port)) except (socket.error, socket.gaierror): return False else: sock.close() return True HOST = test_support.HOST MSG = b'Michael Gilfix was here\n' SUPPORTS_IPV6 = socket.has_ipv6 and try_address('::1', family=socket.AF_INET6) try: import thread import threading except ImportError: thread = None threading = None HOST = test_support.HOST MSG = 'Michael Gilfix was here\n' class SocketTCPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = test_support.bind_port(self.serv) self.serv.listen(1) def tearDown(self): self.serv.close() self.serv = None class SocketUDPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = test_support.bind_port(self.serv) def tearDown(self): self.serv.close() self.serv = None class ThreadableTest: """Threadable Test class The ThreadableTest class makes it easy to create a threaded client/server pair from an existing unit test. To create a new threaded class from an existing unit test, use multiple inheritance: class NewClass (OldClass, ThreadableTest): pass This class defines two new fixture functions with obvious purposes for overriding: clientSetUp () clientTearDown () Any new test functions within the class must then define tests in pairs, where the test name is preceeded with a '_' to indicate the client portion of the test. Ex: def testFoo(self): # Server portion def _testFoo(self): # Client portion Any exceptions raised by the clients during their tests are caught and transferred to the main thread to alert the testing framework. Note, the server setup function cannot call any blocking functions that rely on the client thread during setup, unless serverExplicitReady() is called just before the blocking call (such as in setting up a client/server connection and performing the accept() in setUp(). """ def __init__(self): # Swap the true setup function self.__setUp = self.setUp self.__tearDown = self.tearDown self.setUp = self._setUp self.tearDown = self._tearDown def serverExplicitReady(self): """This method allows the server to explicitly indicate that it wants the client thread to proceed. This is useful if the server is about to execute a blocking routine that is dependent upon the client thread during its setup routine.""" self.server_ready.set() def _setUp(self): self.server_ready = threading.Event() self.client_ready = threading.Event() self.done = threading.Event() self.queue = Queue.Queue(1) # Do some munging to start the client test. methodname = self.id() i = methodname.rfind('.') methodname = methodname[i+1:] test_method = getattr(self, '_' + methodname) self.client_thread = thread.start_new_thread( self.clientRun, (test_method,)) self.__setUp() if not self.server_ready.is_set(): self.server_ready.set() self.client_ready.wait() def _tearDown(self): self.__tearDown() self.done.wait() if not self.queue.empty(): msg = self.queue.get() self.fail(msg) def clientRun(self, test_func): self.server_ready.wait() self.clientSetUp() self.client_ready.set() if not callable(test_func): raise TypeError("test_func must be a callable function.") try: test_func() except Exception, strerror: self.queue.put(strerror) self.clientTearDown() def clientSetUp(self): raise NotImplementedError("clientSetUp must be implemented.") def clientTearDown(self): self.done.set() thread.exit() class ThreadedTCPSocketTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ThreadedUDPSocketTest(SocketUDPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketUDPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class SocketConnectedTest(ThreadedTCPSocketTest): def __init__(self, methodName='runTest'): ThreadedTCPSocketTest.__init__(self, methodName=methodName) def setUp(self): ThreadedTCPSocketTest.setUp(self) # Indicate explicitly we're ready for the client thread to # proceed and then perform the blocking call to accept self.serverExplicitReady() conn, addr = self.serv.accept() self.cli_conn = conn def tearDown(self): self.cli_conn.close() self.cli_conn = None ThreadedTCPSocketTest.tearDown(self) def clientSetUp(self): ThreadedTCPSocketTest.clientSetUp(self) self.cli.connect((HOST, self.port)) self.serv_conn = self.cli def clientTearDown(self): self.serv_conn.close() self.serv_conn = None ThreadedTCPSocketTest.clientTearDown(self) class SocketPairTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName='runTest'): unittest.TestCase.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def setUp(self): self.serv, self.cli = socket.socketpair() def tearDown(self): self.serv.close() self.serv = None def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) ####################################################################### ## Begin Tests class GeneralModuleTests(unittest.TestCase): @unittest.skipUnless(_socket is not None, 'need _socket module') def test_csocket_repr(self): s = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM) try: expected = ('<socket object, fd=%s, family=%s, type=%s, protocol=%s>' % (s.fileno(), s.family, s.type, s.proto)) self.assertEqual(repr(s), expected) finally: s.close() expected = ('<socket object, fd=-1, family=%s, type=%s, protocol=%s>' % (s.family, s.type, s.proto)) self.assertEqual(repr(s), expected) def test_weakref(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) p = weakref.proxy(s) self.assertEqual(p.fileno(), s.fileno()) s.close() s = None try: p.fileno() except ReferenceError: pass else: self.fail('Socket proxy still exists') def test_weakref__sock(self): s = socket.socket()._sock w = weakref.ref(s) self.assertIs(w(), s) del s test_support.gc_collect() self.assertIsNone(w()) def testSocketError(self): # Testing socket module exceptions def raise_error(*args, **kwargs): raise socket.error def raise_herror(*args, **kwargs): raise socket.herror def raise_gaierror(*args, **kwargs): raise socket.gaierror self.assertRaises(socket.error, raise_error, "Error raising socket exception.") self.assertRaises(socket.error, raise_herror, "Error raising socket exception.") self.assertRaises(socket.error, raise_gaierror, "Error raising socket exception.") def testSendtoErrors(self): # Testing that sendto doens't masks failures. See #10169. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.addCleanup(s.close) s.bind(('', 0)) sockname = s.getsockname() # 2 args with self.assertRaises(UnicodeEncodeError): s.sendto(u'\u2620', sockname) with self.assertRaises(TypeError) as cm: s.sendto(5j, sockname) self.assertIn('not complex', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', None) self.assertIn('not NoneType', str(cm.exception)) # 3 args with self.assertRaises(UnicodeEncodeError): s.sendto(u'\u2620', 0, sockname) with self.assertRaises(TypeError) as cm: s.sendto(5j, 0, sockname) self.assertIn('not complex', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', 0, None) self.assertIn('not NoneType', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', 'bar', sockname) self.assertIn('an integer is required', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', None, None) self.assertIn('an integer is required', str(cm.exception)) # wrong number of args with self.assertRaises(TypeError) as cm: s.sendto('foo') self.assertIn('(1 given)', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', 0, sockname, 4) self.assertIn('(4 given)', str(cm.exception)) def testCrucialConstants(self): # Testing for mission critical constants socket.AF_INET socket.SOCK_STREAM socket.SOCK_DGRAM socket.SOCK_RAW socket.SOCK_RDM socket.SOCK_SEQPACKET socket.SOL_SOCKET socket.SO_REUSEADDR def testHostnameRes(self): # Testing hostname resolution mechanisms hostname = socket.gethostname() try: ip = socket.gethostbyname(hostname) except socket.error: # Probably name lookup wasn't set up right; skip this test self.skipTest('name lookup failure') self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.") try: hname, aliases, ipaddrs = socket.gethostbyaddr(ip) except socket.error: # Probably a similar problem as above; skip this test self.skipTest('address lookup failure') all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn(ip) if not fqhn in all_host_names: self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names))) @unittest.skipUnless(hasattr(sys, 'getrefcount'), 'test needs sys.getrefcount()') def testRefCountGetNameInfo(self): # Testing reference count for getnameinfo try: # On some versions, this loses a reference orig = sys.getrefcount(__name__) socket.getnameinfo(__name__,0) except TypeError: self.assertEqual(sys.getrefcount(__name__), orig, "socket.getnameinfo loses a reference") def testInterpreterCrash(self): # Making sure getnameinfo doesn't crash the interpreter try: # On some versions, this crashes the interpreter. socket.getnameinfo(('x', 0, 0, 0), 0) except socket.error: pass def testNtoH(self): # This just checks that htons etc. are their own inverse, # when looking at the lower 16 or 32 bits. sizes = {socket.htonl: 32, socket.ntohl: 32, socket.htons: 16, socket.ntohs: 16} for func, size in sizes.items(): mask = (1L<<size) - 1 for i in (0, 1, 0xffff, ~0xffff, 2, 0x01234567, 0x76543210): self.assertEqual(i & mask, func(func(i&mask)) & mask) swapped = func(mask) self.assertEqual(swapped & mask, mask) self.assertRaises(OverflowError, func, 1L<<34) def testNtoHErrors(self): good_values = [ 1, 2, 3, 1L, 2L, 3L ] bad_values = [ -1, -2, -3, -1L, -2L, -3L ] for k in good_values: socket.ntohl(k) socket.ntohs(k) socket.htonl(k) socket.htons(k) for k in bad_values: self.assertRaises(OverflowError, socket.ntohl, k) self.assertRaises(OverflowError, socket.ntohs, k) self.assertRaises(OverflowError, socket.htonl, k) self.assertRaises(OverflowError, socket.htons, k) def testGetServBy(self): eq = self.assertEqual # Find one service that exists, then check all the related interfaces. # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. if (sys.platform.startswith('linux') or sys.platform.startswith('freebsd') or sys.platform.startswith('netbsd') or sys.platform == 'darwin'): # avoid the 'echo' service on this platform, as there is an # assumption breaking non-standard port/protocol entry services = ('daytime', 'qotd', 'domain') else: services = ('echo', 'daytime', 'domain') for service in services: try: port = socket.getservbyname(service, 'tcp') break except socket.error: pass else: raise socket.error # Try same call with optional protocol omitted port2 = socket.getservbyname(service) eq(port, port2) # Try udp, but don't barf if it doesn't exist try: udpport = socket.getservbyname(service, 'udp') except socket.error: udpport = None else: eq(udpport, port) # Now make sure the lookup by port returns the same service name eq(socket.getservbyport(port2), service) eq(socket.getservbyport(port, 'tcp'), service) if udpport is not None: eq(socket.getservbyport(udpport, 'udp'), service) # Make sure getservbyport does not accept out of range ports. self.assertRaises(OverflowError, socket.getservbyport, -1) self.assertRaises(OverflowError, socket.getservbyport, 65536) def testDefaultTimeout(self): # Testing default timeout # The default timeout should initially be None self.assertEqual(socket.getdefaulttimeout(), None) s = socket.socket() self.assertEqual(s.gettimeout(), None) s.close() # Set the default timeout to 10, and see if it propagates socket.setdefaulttimeout(10) self.assertEqual(socket.getdefaulttimeout(), 10) s = socket.socket() self.assertEqual(s.gettimeout(), 10) s.close() # Reset the default timeout to None, and see if it propagates socket.setdefaulttimeout(None) self.assertEqual(socket.getdefaulttimeout(), None) s = socket.socket() self.assertEqual(s.gettimeout(), None) s.close() # Check that setting it to an invalid value raises ValueError self.assertRaises(ValueError, socket.setdefaulttimeout, -1) # Check that setting it to an invalid type raises TypeError self.assertRaises(TypeError, socket.setdefaulttimeout, "spam") @unittest.skipUnless(hasattr(socket, 'inet_aton'), 'test needs socket.inet_aton()') def testIPv4_inet_aton_fourbytes(self): # Test that issue1008086 and issue767150 are fixed. # It must return 4 bytes. self.assertEqual('\x00'*4, socket.inet_aton('0.0.0.0')) self.assertEqual('\xff'*4, socket.inet_aton('255.255.255.255')) @unittest.skipUnless(hasattr(socket, 'inet_pton'), 'test needs socket.inet_pton()') def testIPv4toString(self): from socket import inet_aton as f, inet_pton, AF_INET g = lambda a: inet_pton(AF_INET, a) self.assertEqual('\x00\x00\x00\x00', f('0.0.0.0')) self.assertEqual('\xff\x00\xff\x00', f('255.0.255.0')) self.assertEqual('\xaa\xaa\xaa\xaa', f('170.170.170.170')) self.assertEqual('\x01\x02\x03\x04', f('1.2.3.4')) self.assertEqual('\xff\xff\xff\xff', f('255.255.255.255')) self.assertEqual('\x00\x00\x00\x00', g('0.0.0.0')) self.assertEqual('\xff\x00\xff\x00', g('255.0.255.0')) self.assertEqual('\xaa\xaa\xaa\xaa', g('170.170.170.170')) self.assertEqual('\xff\xff\xff\xff', g('255.255.255.255')) @unittest.skipUnless(hasattr(socket, 'inet_pton'), 'test needs socket.inet_pton()') def testIPv6toString(self): try: from socket import inet_pton, AF_INET6, has_ipv6 if not has_ipv6: self.skipTest('IPv6 not available') except ImportError: self.skipTest('could not import needed symbols from socket') f = lambda a: inet_pton(AF_INET6, a) self.assertEqual('\x00' * 16, f('::')) self.assertEqual('\x00' * 16, f('0::0')) self.assertEqual('\x00\x01' + '\x00' * 14, f('1::')) self.assertEqual( '\x45\xef\x76\xcb\x00\x1a\x56\xef\xaf\xeb\x0b\xac\x19\x24\xae\xae', f('45ef:76cb:1a:56ef:afeb:bac:1924:aeae') ) @unittest.skipUnless(hasattr(socket, 'inet_ntop'), 'test needs socket.inet_ntop()') def testStringToIPv4(self): from socket import inet_ntoa as f, inet_ntop, AF_INET g = lambda a: inet_ntop(AF_INET, a) self.assertEqual('1.0.1.0', f('\x01\x00\x01\x00')) self.assertEqual('170.85.170.85', f('\xaa\x55\xaa\x55')) self.assertEqual('255.255.255.255', f('\xff\xff\xff\xff')) self.assertEqual('1.2.3.4', f('\x01\x02\x03\x04')) self.assertEqual('1.0.1.0', g('\x01\x00\x01\x00')) self.assertEqual('170.85.170.85', g('\xaa\x55\xaa\x55')) self.assertEqual('255.255.255.255', g('\xff\xff\xff\xff')) @unittest.skipUnless(hasattr(socket, 'inet_ntop'), 'test needs socket.inet_ntop()') def testStringToIPv6(self): try: from socket import inet_ntop, AF_INET6, has_ipv6 if not has_ipv6: self.skipTest('IPv6 not available') except ImportError: self.skipTest('could not import needed symbols from socket') f = lambda a: inet_ntop(AF_INET6, a) self.assertEqual('::', f('\x00' * 16)) self.assertEqual('::1', f('\x00' * 15 + '\x01')) self.assertEqual( 'aef:b01:506:1001:ffff:9997:55:170', f('\x0a\xef\x0b\x01\x05\x06\x10\x01\xff\xff\x99\x97\x00\x55\x01\x70') ) # XXX The following don't test module-level functionality... def _get_unused_port(self, bind_address='0.0.0.0'): """Use a temporary socket to elicit an unused ephemeral port. Args: bind_address: Hostname or IP address to search for a port on. Returns: A most likely to be unused port. """ tempsock = socket.socket() tempsock.bind((bind_address, 0)) host, port = tempsock.getsockname() tempsock.close() return port def testSockName(self): # Testing getsockname() port = self._get_unused_port() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(sock.close) sock.bind(("0.0.0.0", port)) name = sock.getsockname() # XXX(nnorwitz): http://tinyurl.com/os5jz seems to indicate # it reasonable to get the host's addr in addition to 0.0.0.0. # At least for eCos. This is required for the S/390 to pass. try: my_ip_addr = socket.gethostbyname(socket.gethostname()) except socket.error: # Probably name lookup wasn't set up right; skip this test self.skipTest('name lookup failure') self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0]) self.assertEqual(name[1], port) def testGetSockOpt(self): # Testing getsockopt() # We know a socket should start without reuse==0 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(sock.close) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) self.assertFalse(reuse != 0, "initial mode is reuse") def testSetSockOpt(self): # Testing setsockopt() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(sock.close) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) self.assertFalse(reuse == 0, "failed to set reuse mode") def testSendAfterClose(self): # testing send() after close() with timeout sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(1) sock.close() self.assertRaises(socket.error, sock.send, "spam") def testNewAttributes(self): # testing .family, .type and .protocol sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.assertEqual(sock.family, socket.AF_INET) self.assertEqual(sock.type, socket.SOCK_STREAM) self.assertEqual(sock.proto, 0) sock.close() def test_getsockaddrarg(self): sock = socket.socket() self.addCleanup(sock.close) port = test_support.find_unused_port() big_port = port + 65536 neg_port = port - 65536 self.assertRaises(OverflowError, sock.bind, (HOST, big_port)) self.assertRaises(OverflowError, sock.bind, (HOST, neg_port)) # Since find_unused_port() is inherently subject to race conditions, we # call it a couple times if necessary. for i in itertools.count(): port = test_support.find_unused_port() try: sock.bind((HOST, port)) except OSError as e: if e.errno != errno.EADDRINUSE or i == 5: raise else: break @unittest.skipUnless(os.name == "nt", "Windows specific") def test_sock_ioctl(self): self.assertTrue(hasattr(socket.socket, 'ioctl')) self.assertTrue(hasattr(socket, 'SIO_RCVALL')) self.assertTrue(hasattr(socket, 'RCVALL_ON')) self.assertTrue(hasattr(socket, 'RCVALL_OFF')) self.assertTrue(hasattr(socket, 'SIO_KEEPALIVE_VALS')) s = socket.socket() self.addCleanup(s.close) self.assertRaises(ValueError, s.ioctl, -1, None) s.ioctl(socket.SIO_KEEPALIVE_VALS, (1, 100, 100)) def testGetaddrinfo(self): try: socket.getaddrinfo('localhost', 80) except socket.gaierror as err: if err.errno == socket.EAI_SERVICE: # see http://bugs.python.org/issue1282647 self.skipTest("buggy libc version") raise # len of every sequence is supposed to be == 5 for info in socket.getaddrinfo(HOST, None): self.assertEqual(len(info), 5) # host can be a domain name, a string representation of an # IPv4/v6 address or None socket.getaddrinfo('localhost', 80) socket.getaddrinfo('127.0.0.1', 80) socket.getaddrinfo(None, 80) if SUPPORTS_IPV6: socket.getaddrinfo('::1', 80) # port can be a string service name such as "http", a numeric # port number (int or long), or None socket.getaddrinfo(HOST, "http") socket.getaddrinfo(HOST, 80) socket.getaddrinfo(HOST, 80L) socket.getaddrinfo(HOST, None) # test family and socktype filters infos = socket.getaddrinfo(HOST, None, socket.AF_INET) for family, _, _, _, _ in infos: self.assertEqual(family, socket.AF_INET) infos = socket.getaddrinfo(HOST, None, 0, socket.SOCK_STREAM) for _, socktype, _, _, _ in infos: self.assertEqual(socktype, socket.SOCK_STREAM) # test proto and flags arguments socket.getaddrinfo(HOST, None, 0, 0, socket.SOL_TCP) socket.getaddrinfo(HOST, None, 0, 0, 0, socket.AI_PASSIVE) # a server willing to support both IPv4 and IPv6 will # usually do this socket.getaddrinfo(None, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE) # Issue 17269: test workaround for OS X platform bug segfault if hasattr(socket, 'AI_NUMERICSERV'): try: # The arguments here are undefined and the call may succeed # or fail. All we care here is that it doesn't segfault. socket.getaddrinfo("localhost", None, 0, 0, 0, socket.AI_NUMERICSERV) except socket.gaierror: pass def check_sendall_interrupted(self, with_timeout): # socketpair() is not stricly required, but it makes things easier. if not hasattr(signal, 'alarm') or not hasattr(socket, 'socketpair'): self.skipTest("signal.alarm and socket.socketpair required for this test") # Our signal handlers clobber the C errno by calling a math function # with an invalid domain value. def ok_handler(*args): self.assertRaises(ValueError, math.acosh, 0) def raising_handler(*args): self.assertRaises(ValueError, math.acosh, 0) 1 // 0 c, s = socket.socketpair() old_alarm = signal.signal(signal.SIGALRM, raising_handler) try: if with_timeout: # Just above the one second minimum for signal.alarm c.settimeout(1.5) with self.assertRaises(ZeroDivisionError): signal.alarm(1) c.sendall(b"x" * test_support.SOCK_MAX_SIZE) if with_timeout: signal.signal(signal.SIGALRM, ok_handler) signal.alarm(1) self.assertRaises(socket.timeout, c.sendall, b"x" * test_support.SOCK_MAX_SIZE) finally: signal.signal(signal.SIGALRM, old_alarm) c.close() s.close() def test_sendall_interrupted(self): self.check_sendall_interrupted(False) def test_sendall_interrupted_with_timeout(self): self.check_sendall_interrupted(True) def test_listen_backlog(self): for backlog in 0, -1: srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) srv.bind((HOST, 0)) srv.listen(backlog) srv.close() @test_support.cpython_only def test_listen_backlog_overflow(self): # Issue 15989 import _testcapi srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) srv.bind((HOST, 0)) self.assertRaises(OverflowError, srv.listen, _testcapi.INT_MAX + 1) srv.close() @unittest.skipUnless(SUPPORTS_IPV6, 'IPv6 required for this test.') def test_flowinfo(self): self.assertRaises(OverflowError, socket.getnameinfo, ('::1',0, 0xffffffff), 0) s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) try: self.assertRaises(OverflowError, s.bind, ('::1', 0, -10)) finally: s.close() @unittest.skipUnless(thread, 'Threading required for this test.') class BasicTCPTest(SocketConnectedTest): def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def testRecv(self): # Testing large receive over TCP msg = self.cli_conn.recv(1024) self.assertEqual(msg, MSG) def _testRecv(self): self.serv_conn.send(MSG) def testOverFlowRecv(self): # Testing receive in chunks over TCP seg1 = self.cli_conn.recv(len(MSG) - 3) seg2 = self.cli_conn.recv(1024) msg = seg1 + seg2 self.assertEqual(msg, MSG) def _testOverFlowRecv(self): self.serv_conn.send(MSG) def testRecvFrom(self): # Testing large recvfrom() over TCP msg, addr = self.cli_conn.recvfrom(1024) self.assertEqual(msg, MSG) def _testRecvFrom(self): self.serv_conn.send(MSG) def testOverFlowRecvFrom(self): # Testing recvfrom() in chunks over TCP seg1, addr = self.cli_conn.recvfrom(len(MSG)-3) seg2, addr = self.cli_conn.recvfrom(1024) msg = seg1 + seg2 self.assertEqual(msg, MSG) def _testOverFlowRecvFrom(self): self.serv_conn.send(MSG) def testSendAll(self): # Testing sendall() with a 2048 byte string over TCP msg = '' while 1: read = self.cli_conn.recv(1024) if not read: break msg += read self.assertEqual(msg, 'f' * 2048) def _testSendAll(self): big_chunk = 'f' * 2048 self.serv_conn.sendall(big_chunk) @unittest.skipUnless(hasattr(socket, 'fromfd'), 'socket.fromfd not availble') def testFromFd(self): # Testing fromfd() fd = self.cli_conn.fileno() sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(sock.close) msg = sock.recv(1024) self.assertEqual(msg, MSG) def _testFromFd(self): self.serv_conn.send(MSG) def testDup(self): # Testing dup() sock = self.cli_conn.dup() self.addCleanup(sock.close) msg = sock.recv(1024) self.assertEqual(msg, MSG) def _testDup(self): self.serv_conn.send(MSG) def testShutdown(self): # Testing shutdown() msg = self.cli_conn.recv(1024) self.assertEqual(msg, MSG) # wait for _testShutdown to finish: on OS X, when the server # closes the connection the client also becomes disconnected, # and the client's shutdown call will fail. (Issue #4397.) self.done.wait() def _testShutdown(self): self.serv_conn.send(MSG) self.serv_conn.shutdown(2) testShutdown_overflow = test_support.cpython_only(testShutdown) @test_support.cpython_only def _testShutdown_overflow(self): import _testcapi self.serv_conn.send(MSG) # Issue 15989 self.assertRaises(OverflowError, self.serv_conn.shutdown, _testcapi.INT_MAX + 1) self.assertRaises(OverflowError, self.serv_conn.shutdown, 2 + (_testcapi.UINT_MAX + 1)) self.serv_conn.shutdown(2) @unittest.skipUnless(thread, 'Threading required for this test.') class BasicUDPTest(ThreadedUDPSocketTest): def __init__(self, methodName='runTest'): ThreadedUDPSocketTest.__init__(self, methodName=methodName) def testSendtoAndRecv(self): # Testing sendto() and Recv() over UDP msg = self.serv.recv(len(MSG)) self.assertEqual(msg, MSG) def _testSendtoAndRecv(self): self.cli.sendto(MSG, 0, (HOST, self.port)) def testRecvFrom(self): # Testing recvfrom() over UDP msg, addr = self.serv.recvfrom(len(MSG)) self.assertEqual(msg, MSG) def _testRecvFrom(self): self.cli.sendto(MSG, 0, (HOST, self.port)) def testRecvFromNegative(self): # Negative lengths passed to recvfrom should give ValueError. self.assertRaises(ValueError, self.serv.recvfrom, -1) def _testRecvFromNegative(self): self.cli.sendto(MSG, 0, (HOST, self.port)) @unittest.skipUnless(thread, 'Threading required for this test.') class TCPCloserTest(ThreadedTCPSocketTest): def testClose(self): conn, addr = self.serv.accept() conn.close() sd = self.cli read, write, err = select.select([sd], [], [], 1.0) self.assertEqual(read, [sd]) self.assertEqual(sd.recv(1), '') def _testClose(self): self.cli.connect((HOST, self.port)) time.sleep(1.0) @unittest.skipUnless(hasattr(socket, 'socketpair'), 'test needs socket.socketpair()') @unittest.skipUnless(thread, 'Threading required for this test.') class BasicSocketPairTest(SocketPairTest): def __init__(self, methodName='runTest'): SocketPairTest.__init__(self, methodName=methodName) def testRecv(self): msg = self.serv.recv(1024) self.assertEqual(msg, MSG) def _testRecv(self): self.cli.send(MSG) def testSend(self): self.serv.send(MSG) def _testSend(self): msg = self.cli.recv(1024) self.assertEqual(msg, MSG) @unittest.skipUnless(thread, 'Threading required for this test.') class NonBlockingTCPTests(ThreadedTCPSocketTest): def __init__(self, methodName='runTest'): ThreadedTCPSocketTest.__init__(self, methodName=methodName) def testSetBlocking(self): # Testing whether set blocking works self.serv.setblocking(True) self.assertIsNone(self.serv.gettimeout()) self.serv.setblocking(False) self.assertEqual(self.serv.gettimeout(), 0.0) start = time.time() try: self.serv.accept() except socket.error: pass end = time.time() self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.") def _testSetBlocking(self): pass @test_support.cpython_only def testSetBlocking_overflow(self): # Issue 15989 import _testcapi if _testcapi.UINT_MAX >= _testcapi.ULONG_MAX: self.skipTest('needs UINT_MAX < ULONG_MAX') self.serv.setblocking(False) self.assertEqual(self.serv.gettimeout(), 0.0) self.serv.setblocking(_testcapi.UINT_MAX + 1) self.assertIsNone(self.serv.gettimeout()) _testSetBlocking_overflow = test_support.cpython_only(_testSetBlocking) def testAccept(self): # Testing non-blocking accept self.serv.setblocking(0) try: conn, addr = self.serv.accept() except socket.error: pass else: self.fail("Error trying to do non-blocking accept.") read, write, err = select.select([self.serv], [], []) if self.serv in read: conn, addr = self.serv.accept() conn.close() else: self.fail("Error trying to do accept after select.") def _testAccept(self): time.sleep(0.1) self.cli.connect((HOST, self.port)) def testConnect(self): # Testing non-blocking connect conn, addr = self.serv.accept() conn.close() def _testConnect(self): self.cli.settimeout(10) self.cli.connect((HOST, self.port)) def testRecv(self): # Testing non-blocking recv conn, addr = self.serv.accept() conn.setblocking(0) try: msg = conn.recv(len(MSG)) except socket.error: pass else: self.fail("Error trying to do non-blocking recv.") read, write, err = select.select([conn], [], []) if conn in read: msg = conn.recv(len(MSG)) conn.close() self.assertEqual(msg, MSG) else: self.fail("Error during select call to non-blocking socket.") def _testRecv(self): self.cli.connect((HOST, self.port)) time.sleep(0.1) self.cli.send(MSG) @unittest.skipUnless(thread, 'Threading required for this test.') class FileObjectClassTestCase(SocketConnectedTest): bufsize = -1 # Use default buffer size def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def setUp(self): SocketConnectedTest.setUp(self) self.serv_file = self.cli_conn.makefile('rb', self.bufsize) def tearDown(self): self.serv_file.close() self.assertTrue(self.serv_file.closed) SocketConnectedTest.tearDown(self) self.serv_file = None def clientSetUp(self): SocketConnectedTest.clientSetUp(self) self.cli_file = self.serv_conn.makefile('wb') def clientTearDown(self): self.cli_file.close() self.assertTrue(self.cli_file.closed) self.cli_file = None SocketConnectedTest.clientTearDown(self) def testSmallRead(self): # Performing small file read test first_seg = self.serv_file.read(len(MSG)-3) second_seg = self.serv_file.read(3) msg = first_seg + second_seg self.assertEqual(msg, MSG) def _testSmallRead(self): self.cli_file.write(MSG) self.cli_file.flush() def testFullRead(self): # read until EOF msg = self.serv_file.read() self.assertEqual(msg, MSG) def _testFullRead(self): self.cli_file.write(MSG) self.cli_file.close() def testUnbufferedRead(self): # Performing unbuffered file read test buf = '' while 1: char = self.serv_file.read(1) if not char: break buf += char self.assertEqual(buf, MSG) def _testUnbufferedRead(self): self.cli_file.write(MSG) self.cli_file.flush() def testReadline(self): # Performing file readline test line = self.serv_file.readline() self.assertEqual(line, MSG) def _testReadline(self): self.cli_file.write(MSG) self.cli_file.flush() def testReadlineAfterRead(self): a_baloo_is = self.serv_file.read(len("A baloo is")) self.assertEqual("A baloo is", a_baloo_is) _a_bear = self.serv_file.read(len(" a bear")) self.assertEqual(" a bear", _a_bear) line = self.serv_file.readline() self.assertEqual("\n", line) line = self.serv_file.readline() self.assertEqual("A BALOO IS A BEAR.\n", line) line = self.serv_file.readline() self.assertEqual(MSG, line) def _testReadlineAfterRead(self): self.cli_file.write("A baloo is a bear\n") self.cli_file.write("A BALOO IS A BEAR.\n") self.cli_file.write(MSG) self.cli_file.flush() def testReadlineAfterReadNoNewline(self): end_of_ = self.serv_file.read(len("End Of ")) self.assertEqual("End Of ", end_of_) line = self.serv_file.readline() self.assertEqual("Line", line) def _testReadlineAfterReadNoNewline(self): self.cli_file.write("End Of Line") def testClosedAttr(self): self.assertTrue(not self.serv_file.closed) def _testClosedAttr(self): self.assertTrue(not self.cli_file.closed) class FileObjectInterruptedTestCase(unittest.TestCase): """Test that the file object correctly handles EINTR internally.""" class MockSocket(object): def __init__(self, recv_funcs=()): # A generator that returns callables that we'll call for each # call to recv(). self._recv_step = iter(recv_funcs) def recv(self, size): return self._recv_step.next()() @staticmethod def _raise_eintr(): raise socket.error(errno.EINTR) def _test_readline(self, size=-1, **kwargs): mock_sock = self.MockSocket(recv_funcs=[ lambda : "This is the first line\nAnd the sec", self._raise_eintr, lambda : "ond line is here\n", lambda : "", ]) fo = socket._fileobject(mock_sock, **kwargs) self.assertEqual(fo.readline(size), "This is the first line\n") self.assertEqual(fo.readline(size), "And the second line is here\n") def _test_read(self, size=-1, **kwargs): mock_sock = self.MockSocket(recv_funcs=[ lambda : "This is the first line\nAnd the sec", self._raise_eintr, lambda : "ond line is here\n", lambda : "", ]) fo = socket._fileobject(mock_sock, **kwargs) self.assertEqual(fo.read(size), "This is the first line\n" "And the second line is here\n") def test_default(self): self._test_readline() self._test_readline(size=100) self._test_read() self._test_read(size=100) def test_with_1k_buffer(self): self._test_readline(bufsize=1024) self._test_readline(size=100, bufsize=1024) self._test_read(bufsize=1024) self._test_read(size=100, bufsize=1024) def _test_readline_no_buffer(self, size=-1): mock_sock = self.MockSocket(recv_funcs=[ lambda : "aa", lambda : "\n", lambda : "BB", self._raise_eintr, lambda : "bb", lambda : "", ]) fo = socket._fileobject(mock_sock, bufsize=0) self.assertEqual(fo.readline(size), "aa\n") self.assertEqual(fo.readline(size), "BBbb") def test_no_buffer(self): self._test_readline_no_buffer() self._test_readline_no_buffer(size=4) self._test_read(bufsize=0) self._test_read(size=100, bufsize=0) class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase): """Repeat the tests from FileObjectClassTestCase with bufsize==0. In this case (and in this case only), it should be possible to create a file object, read a line from it, create another file object, read another line from it, without loss of data in the first file object's buffer. Note that httplib relies on this when reading multiple requests from the same socket.""" bufsize = 0 # Use unbuffered mode def testUnbufferedReadline(self): # Read a line, create a new file object, read another line with it line = self.serv_file.readline() # first line self.assertEqual(line, "A. " + MSG) # first line self.serv_file = self.cli_conn.makefile('rb', 0) line = self.serv_file.readline() # second line self.assertEqual(line, "B. " + MSG) # second line def _testUnbufferedReadline(self): self.cli_file.write("A. " + MSG) self.cli_file.write("B. " + MSG) self.cli_file.flush() class LineBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 1 # Default-buffered for reading; line-buffered for writing class SocketMemo(object): """A wrapper to keep track of sent data, needed to examine write behaviour""" def __init__(self, sock): self._sock = sock self.sent = [] def send(self, data, flags=0): n = self._sock.send(data, flags) self.sent.append(data[:n]) return n def sendall(self, data, flags=0): self._sock.sendall(data, flags) self.sent.append(data) def __getattr__(self, attr): return getattr(self._sock, attr) def getsent(self): return [e.tobytes() if isinstance(e, memoryview) else e for e in self.sent] def setUp(self): FileObjectClassTestCase.setUp(self) self.serv_file._sock = self.SocketMemo(self.serv_file._sock) def testLinebufferedWrite(self): # Write two lines, in small chunks msg = MSG.strip() print >> self.serv_file, msg, print >> self.serv_file, msg # second line: print >> self.serv_file, msg, print >> self.serv_file, msg, print >> self.serv_file, msg # third line print >> self.serv_file, '' self.serv_file.flush() msg1 = "%s %s\n"%(msg, msg) msg2 = "%s %s %s\n"%(msg, msg, msg) msg3 = "\n" self.assertEqual(self.serv_file._sock.getsent(), [msg1, msg2, msg3]) def _testLinebufferedWrite(self): msg = MSG.strip() msg1 = "%s %s\n"%(msg, msg) msg2 = "%s %s %s\n"%(msg, msg, msg) msg3 = "\n" l1 = self.cli_file.readline() self.assertEqual(l1, msg1) l2 = self.cli_file.readline() self.assertEqual(l2, msg2) l3 = self.cli_file.readline() self.assertEqual(l3, msg3) class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 2 # Exercise the buffering code class NetworkConnectionTest(object): """Prove network connection.""" def clientSetUp(self): # We're inherited below by BasicTCPTest2, which also inherits # BasicTCPTest, which defines self.port referenced below. self.cli = socket.create_connection((HOST, self.port)) self.serv_conn = self.cli class BasicTCPTest2(NetworkConnectionTest, BasicTCPTest): """Tests that NetworkConnection does not break existing TCP functionality. """ class NetworkConnectionNoServer(unittest.TestCase): class MockSocket(socket.socket): def connect(self, *args): raise socket.timeout('timed out') @contextlib.contextmanager def mocked_socket_module(self): """Return a socket which times out on connect""" old_socket = socket.socket socket.socket = self.MockSocket try: yield finally: socket.socket = old_socket def test_connect(self): port = test_support.find_unused_port() cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(cli.close) with self.assertRaises(socket.error) as cm: cli.connect((HOST, port)) self.assertEqual(cm.exception.errno, errno.ECONNREFUSED) def test_create_connection(self): # Issue #9792: errors raised by create_connection() should have # a proper errno attribute. port = test_support.find_unused_port() with self.assertRaises(socket.error) as cm: socket.create_connection((HOST, port)) # Issue #16257: create_connection() calls getaddrinfo() against # 'localhost'. This may result in an IPV6 addr being returned # as well as an IPV4 one: # >>> socket.getaddrinfo('localhost', port, 0, SOCK_STREAM) # >>> [(2, 2, 0, '', ('127.0.0.1', 41230)), # (26, 2, 0, '', ('::1', 41230, 0, 0))] # # create_connection() enumerates through all the addresses returned # and if it doesn't successfully bind to any of them, it propagates # the last exception it encountered. # # On Solaris, ENETUNREACH is returned in this circumstance instead # of ECONNREFUSED. So, if that errno exists, add it to our list of # expected errnos. expected_errnos = [ errno.ECONNREFUSED, ] if hasattr(errno, 'ENETUNREACH'): expected_errnos.append(errno.ENETUNREACH) self.assertIn(cm.exception.errno, expected_errnos) def test_create_connection_timeout(self): # Issue #9792: create_connection() should not recast timeout errors # as generic socket errors. with self.mocked_socket_module(): with self.assertRaises(socket.timeout): socket.create_connection((HOST, 1234)) @unittest.skipUnless(thread, 'Threading required for this test.') class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.source_port = test_support.find_unused_port() def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) def _justAccept(self): conn, addr = self.serv.accept() conn.close() testFamily = _justAccept def _testFamily(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.addCleanup(self.cli.close) self.assertEqual(self.cli.family, 2) testSourceAddress = _justAccept def _testSourceAddress(self): self.cli = socket.create_connection((HOST, self.port), timeout=30, source_address=('', self.source_port)) self.addCleanup(self.cli.close) self.assertEqual(self.cli.getsockname()[1], self.source_port) # The port number being used is sufficient to show that the bind() # call happened. testTimeoutDefault = _justAccept def _testTimeoutDefault(self): # passing no explicit timeout uses socket's global default self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(42) try: self.cli = socket.create_connection((HOST, self.port)) self.addCleanup(self.cli.close) finally: socket.setdefaulttimeout(None) self.assertEqual(self.cli.gettimeout(), 42) testTimeoutNone = _justAccept def _testTimeoutNone(self): # None timeout means the same as sock.settimeout(None) self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: self.cli = socket.create_connection((HOST, self.port), timeout=None) self.addCleanup(self.cli.close) finally: socket.setdefaulttimeout(None) self.assertEqual(self.cli.gettimeout(), None) testTimeoutValueNamed = _justAccept def _testTimeoutValueNamed(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.assertEqual(self.cli.gettimeout(), 30) testTimeoutValueNonamed = _justAccept def _testTimeoutValueNonamed(self): self.cli = socket.create_connection((HOST, self.port), 30) self.addCleanup(self.cli.close) self.assertEqual(self.cli.gettimeout(), 30) @unittest.skipUnless(thread, 'Threading required for this test.') class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) def testInsideTimeout(self): conn, addr = self.serv.accept() self.addCleanup(conn.close) time.sleep(3) conn.send("done!") testOutsideTimeout = testInsideTimeout def _testInsideTimeout(self): self.cli = sock = socket.create_connection((HOST, self.port)) data = sock.recv(5) self.assertEqual(data, "done!") def _testOutsideTimeout(self): self.cli = sock = socket.create_connection((HOST, self.port), timeout=1) self.assertRaises(socket.timeout, lambda: sock.recv(5)) class Urllib2FileobjectTest(unittest.TestCase): # urllib2.HTTPHandler has "borrowed" socket._fileobject, and requires that # it close the socket if the close c'tor argument is true def testClose(self): class MockSocket: closed = False def flush(self): pass def close(self): self.closed = True # must not close unless we request it: the original use of _fileobject # by module socket requires that the underlying socket not be closed until # the _socketobject that created the _fileobject is closed s = MockSocket() f = socket._fileobject(s) f.close() self.assertTrue(not s.closed) s = MockSocket() f = socket._fileobject(s, close=True) f.close() self.assertTrue(s.closed) class TCPTimeoutTest(SocketTCPTest): def testTCPTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.accept() self.assertRaises(socket.timeout, raise_timeout, "Error generating a timeout exception (TCP)") def testTimeoutZero(self): ok = False try: self.serv.settimeout(0.0) foo = self.serv.accept() except socket.timeout: self.fail("caught timeout instead of error (TCP)") except socket.error: ok = True except: self.fail("caught unexpected exception (TCP)") if not ok: self.fail("accept() returned success when we did not expect it") @unittest.skipUnless(hasattr(signal, 'alarm'), 'test needs signal.alarm()') def testInterruptedTimeout(self): # XXX I don't know how to do this test on MSWindows or any other # plaform that doesn't support signal.alarm() or os.kill(), though # the bug should have existed on all platforms. self.serv.settimeout(5.0) # must be longer than alarm class Alarm(Exception): pass def alarm_handler(signal, frame): raise Alarm old_alarm = signal.signal(signal.SIGALRM, alarm_handler) try: signal.alarm(2) # POSIX allows alarm to be up to 1 second early try: foo = self.serv.accept() except socket.timeout: self.fail("caught timeout instead of Alarm") except Alarm: pass except: self.fail("caught other exception instead of Alarm:" " %s(%s):\n%s" % (sys.exc_info()[:2] + (traceback.format_exc(),))) else: self.fail("nothing caught") finally: signal.alarm(0) # shut off alarm except Alarm: self.fail("got Alarm in wrong place") finally: # no alarm can be pending. Safe to restore old handler. signal.signal(signal.SIGALRM, old_alarm) class UDPTimeoutTest(SocketUDPTest): def testUDPTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.recv(1024) self.assertRaises(socket.timeout, raise_timeout, "Error generating a timeout exception (UDP)") def testTimeoutZero(self): ok = False try: self.serv.settimeout(0.0) foo = self.serv.recv(1024) except socket.timeout: self.fail("caught timeout instead of error (UDP)") except socket.error: ok = True except: self.fail("caught unexpected exception (UDP)") if not ok: self.fail("recv() returned success when we did not expect it") class TestExceptions(unittest.TestCase): def testExceptionTree(self): self.assertTrue(issubclass(socket.error, Exception)) self.assertTrue(issubclass(socket.herror, socket.error)) self.assertTrue(issubclass(socket.gaierror, socket.error)) self.assertTrue(issubclass(socket.timeout, socket.error)) @unittest.skipUnless(sys.platform == 'linux', 'Linux specific test') class TestLinuxAbstractNamespace(unittest.TestCase): UNIX_PATH_MAX = 108 def testLinuxAbstractNamespace(self): address = "\x00python-test-hello\x00\xff" s1 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s1.bind(address) s1.listen(1) s2 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s2.connect(s1.getsockname()) s1.accept() self.assertEqual(s1.getsockname(), address) self.assertEqual(s2.getpeername(), address) def testMaxName(self): address = "\x00" + "h" * (self.UNIX_PATH_MAX - 1) s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.bind(address) self.assertEqual(s.getsockname(), address) def testNameOverflow(self): address = "\x00" + "h" * self.UNIX_PATH_MAX s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.assertRaises(socket.error, s.bind, address) @unittest.skipUnless(thread, 'Threading required for this test.') class BufferIOTest(SocketConnectedTest): """ Test the buffer versions of socket.recv() and socket.send(). """ def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def testRecvIntoArray(self): buf = array.array('c', ' '*1024) nbytes = self.cli_conn.recv_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf.tostring()[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvIntoArray(self): with test_support.check_py3k_warnings(): buf = buffer(MSG) self.serv_conn.send(buf) def testRecvIntoBytearray(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvIntoBytearray = _testRecvIntoArray def testRecvIntoMemoryview(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(memoryview(buf)) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvIntoMemoryview = _testRecvIntoArray def testRecvFromIntoArray(self): buf = array.array('c', ' '*1024) nbytes, addr = self.cli_conn.recvfrom_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf.tostring()[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvFromIntoArray(self): with test_support.check_py3k_warnings(): buf = buffer(MSG) self.serv_conn.send(buf) def testRecvFromIntoBytearray(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvFromIntoBytearray = _testRecvFromIntoArray def testRecvFromIntoMemoryview(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(memoryview(buf)) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvFromIntoMemoryview = _testRecvFromIntoArray def testRecvFromIntoSmallBuffer(self): # See issue #20246. buf = bytearray(8) self.assertRaises(ValueError, self.cli_conn.recvfrom_into, buf, 1024) def _testRecvFromIntoSmallBuffer(self): with test_support.check_py3k_warnings(): buf = buffer(MSG) self.serv_conn.send(buf) def testRecvFromIntoEmptyBuffer(self): buf = bytearray() self.cli_conn.recvfrom_into(buf) self.cli_conn.recvfrom_into(buf, 0) _testRecvFromIntoEmptyBuffer = _testRecvFromIntoArray TIPC_STYPE = 2000 TIPC_LOWER = 200 TIPC_UPPER = 210 def isTipcAvailable(): """Check if the TIPC module is loaded The TIPC module is not loaded automatically on Ubuntu and probably other Linux distros. """ if not hasattr(socket, "AF_TIPC"): return False if not os.path.isfile("/proc/modules"): return False with open("/proc/modules") as f: for line in f: if line.startswith("tipc "): return True return False @unittest.skipUnless(isTipcAvailable(), "TIPC module is not loaded, please 'sudo modprobe tipc'") class TIPCTest(unittest.TestCase): def testRDM(self): srv = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) cli = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE, TIPC_LOWER, TIPC_UPPER) srv.bind(srvaddr) sendaddr = (socket.TIPC_ADDR_NAME, TIPC_STYPE, TIPC_LOWER + (TIPC_UPPER - TIPC_LOWER) / 2, 0) cli.sendto(MSG, sendaddr) msg, recvaddr = srv.recvfrom(1024) self.assertEqual(cli.getsockname(), recvaddr) self.assertEqual(msg, MSG) @unittest.skipUnless(isTipcAvailable(), "TIPC module is not loaded, please 'sudo modprobe tipc'") class TIPCThreadableTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName = 'runTest'): unittest.TestCase.__init__(self, methodName = methodName) ThreadableTest.__init__(self) def setUp(self): self.srv = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM) self.srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE, TIPC_LOWER, TIPC_UPPER) self.srv.bind(srvaddr) self.srv.listen(5) self.serverExplicitReady() self.conn, self.connaddr = self.srv.accept() def clientSetUp(self): # The is a hittable race between serverExplicitReady() and the # accept() call; sleep a little while to avoid it, otherwise # we could get an exception time.sleep(0.1) self.cli = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM) addr = (socket.TIPC_ADDR_NAME, TIPC_STYPE, TIPC_LOWER + (TIPC_UPPER - TIPC_LOWER) / 2, 0) self.cli.connect(addr) self.cliaddr = self.cli.getsockname() def testStream(self): msg = self.conn.recv(1024) self.assertEqual(msg, MSG) self.assertEqual(self.cliaddr, self.connaddr) def _testStream(self): self.cli.send(MSG) self.cli.close() def test_main(): tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest, TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ] tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, FileObjectInterruptedTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase, Urllib2FileobjectTest, NetworkConnectionNoServer, NetworkConnectionAttributesTest, NetworkConnectionBehaviourTest, ]) tests.append(BasicSocketPairTest) tests.append(TestLinuxAbstractNamespace) tests.extend([TIPCTest, TIPCThreadableTest]) thread_info = test_support.threading_setup() test_support.run_unittest(*tests) test_support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main()
gpl-3.0
[ 646, 2882, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 646, 7554, 199, 646, 7975, 199, 646, 2838, 199, 646, 3504, 199, 646, 900, 199, 646, 5190, 199, 646, 10703, 199, 646, 984, 199, 646, 747, 199, 646, 1625, 199, 646, 15502, 199, 646, 4673, 199, 646, 3473, 199, 646, 13852, 199, 893, 26, 272, 492, 485, 3450, 199, 2590, 3545, 26, 272, 485, 3450, 275, 488, 421, 199, 318, 862, 63, 1562, 8, 1102, 12, 1844, 29, 16, 12, 9614, 29, 3450, 14, 5699, 63, 11367, 304, 272, 408, 12357, 370, 5398, 282, 2838, 641, 314, 1627, 1591, 26, 719, 436, 372, 715, 272, 340, 626, 965, 2757, 3962, 1041, 272, 862, 26, 267, 6771, 275, 2838, 14, 3450, 8, 6606, 12, 2838, 14, 9469, 63, 9484, 9, 267, 6771, 14, 3409, 1332, 1102, 12, 1844, 430, 272, 871, 334, 3450, 14, 705, 12, 2838, 14, 5294, 73, 705, 304, 267, 372, 756, 272, 587, 26, 267, 6771, 14, 1600, 342, 267, 372, 715, 199, 199, 5449, 275, 511, 63, 4058, 14, 5449, 199, 9740, 275, 330, 7, 45, 11781, 598, 17588, 1148, 1990, 2348, 60, 78, 7, 199, 10640, 51, 63, 11253, 22, 275, 2838, 14, 1989, 63, 4774, 22, 436, 862, 63, 1562, 29539, 17, 297, 9614, 29, 3450, 14, 5699, 63, 11367, 22, 9, 199, 199, 893, 26, 272, 492, 2462, 272, 492, 5796, 199, 2590, 3545, 26, 272, 2462, 275, 488, 272, 5796, 275, 488, 199, 199, 5449, 275, 511, 63, 4058, 14, 5449, 199, 9740, 275, 283, 45, 11781, 598, 17588, 1148, 1990, 2348, 60, 78, 7, 199, 199, 533, 17766, 9735, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 7297, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 267, 291, 14, 719, 275, 511, 63, 4058, 14, 3409, 63, 719, 8, 277, 14, 7297, 9, 267, 291, 14, 7297, 14, 5859, 8, 17, 9, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 7297, 14, 1600, 342, 267, 291, 14, 7297, 275, 488, 199, 199, 533, 17766, 17457, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 7297, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 25351, 9, 267, 291, 14, 719, 275, 511, 63, 4058, 14, 3409, 63, 719, 8, 277, 14, 7297, 9, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 7297, 14, 1600, 342, 267, 291, 14, 7297, 275, 488, 199, 199, 533, 11086, 461, 774, 26, 272, 408, 4436, 461, 1379, 1021, 339, 710, 11086, 461, 774, 1021, 7704, 652, 8837, 370, 1218, 282, 25396, 272, 1890, 15, 1000, 4092, 687, 376, 3411, 4137, 511, 14, 4005, 1218, 282, 272, 892, 25396, 1021, 687, 376, 3411, 4137, 511, 12, 675, 3663, 272, 15433, 26, 398, 1021, 7053, 2543, 334, 16411, 2543, 12, 11086, 461, 774, 304, 288, 986, 339, 961, 1021, 7890, 2877, 892, 10949, 3423, 543, 25259, 272, 12901, 367, 18972, 26, 398, 1890, 19845, 6248, 267, 1890, 30711, 6248, 339, 6184, 892, 511, 3423, 4453, 314, 1021, 1471, 2066, 5627, 272, 2295, 315, 6342, 12, 2382, 314, 511, 536, 365, 9222, 6133, 543, 282, 272, 14135, 370, 6623, 314, 1890, 18046, 402, 314, 511, 14, 1316, 26, 398, 347, 511, 5686, 8, 277, 304, 288, 327, 7146, 18046, 398, 347, 485, 396, 5686, 8, 277, 304, 288, 327, 6810, 18046, 339, 6184, 4967, 4915, 701, 314, 13431, 5309, 3932, 2295, 272, 787, 15604, 436, 1752, 5057, 370, 314, 2446, 2462, 370, 10459, 272, 314, 5343, 10059, 14, 339, 3390, 12, 314, 1654, 3272, 805, 3913, 1240, 1263, 14592, 272, 3423, 626, 19687, 641, 314, 1890, 2462, 5309, 3272, 12, 272, 7444, 1654, 26090, 17960, 342, 365, 2797, 2951, 2544, 272, 314, 14592, 1240, 334, 10180, 465, 315, 4260, 1536, 282, 1890, 15, 1000, 272, 1950, 436, 19203, 314, 4729, 342, 315, 3613, 1252, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 327, 16666, 439, 314, 2549, 3272, 805, 267, 291, 855, 5996, 275, 291, 14, 5996, 267, 291, 855, 12336, 275, 291, 14, 12336, 267, 291, 14, 5996, 275, 291, 423, 5996, 267, 291, 14, 12336, 275, 291, 423, 12336, 339, 347, 1654, 26090, 17960, 8, 277, 304, 267, 408, 2765, 1083, 6127, 314, 1654, 370, 7662, 6623, 626, 267, 652, 15061, 314, 1890, 2462, 370, 20320, 14, 961, 365, 2997, 340, 314, 267, 1654, 365, 3595, 370, 5341, 282, 14592, 12981, 626, 365, 267, 11410, 12188, 314, 1890, 2462, 5309, 2399, 3272, 12981, 1041, 267, 291, 14, 1000, 63, 2179, 14, 409, 342, 339, 347, 485, 5996, 8, 277, 304, 267, 291, 14, 1000, 63, 2179, 275, 5796, 14, 2390, 342, 267, 291, 14, 1258, 63, 2179, 275, 5796, 14, 2390, 342, 267, 291, 14, 4456, 275, 5796, 14, 2390, 342, 267, 291, 14, 1825, 275, 10703, 14, 3737, 8, 17, 9, 398, 327, 4226, 2005, 333, 324, 1540, 370, 1343, 314, 1890, 511, 14, 267, 28009, 275, 291, 14, 344, 342, 267, 284, 275, 28009, 14, 14542, 7563, 267, 28009, 275, 28009, 59, 73, 11, 17, 2938, 267, 511, 63, 765, 275, 2519, 8, 277, 12, 14135, 435, 28009, 9, 267, 291, 14, 1258, 63, 2671, 275, 2462, 14, 928, 63, 1222, 63, 2671, 8, 288, 291, 14, 1258, 2540, 12, 334, 396, 63, 765, 4641, 398, 291, 855, 5996, 342, 267, 340, 440, 291, 14, 1000, 63, 2179, 14, 374, 63, 409, 837, 288, 291, 14, 1000, 63, 2179, 14, 409, 342, 267, 291, 14, 1258, 63, 2179, 14, 2573, 342, 339, 347, 485, 12336, 8, 277, 304, 267, 291, 855, 12336, 342, 267, 291, 14, 4456, 14, 2573, 342, 398, 340, 440, 291, 14, 1825, 14, 1667, 837, 288, 1499, 275, 291, 14, 1825, 14, 362, 342, 288, 291, 14, 1633, 8, 1328, 9, 339, 347, 1890, 2540, 8, 277, 12, 511, 63, 1532, 304, 267, 291, 14, 1000, 63, 2179, 14, 2573, 342, 267, 291, 14, 1258, 19845, 342, 267, 291, 14, 1258, 63, 2179, 14, 409, 342, 267, 340, 440, 4550, 8, 396, 63, 1532, 304, 288, 746, 3146, 480, 396, 63 ]
[ 2882, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 646, 7554, 199, 646, 7975, 199, 646, 2838, 199, 646, 3504, 199, 646, 900, 199, 646, 5190, 199, 646, 10703, 199, 646, 984, 199, 646, 747, 199, 646, 1625, 199, 646, 15502, 199, 646, 4673, 199, 646, 3473, 199, 646, 13852, 199, 893, 26, 272, 492, 485, 3450, 199, 2590, 3545, 26, 272, 485, 3450, 275, 488, 421, 199, 318, 862, 63, 1562, 8, 1102, 12, 1844, 29, 16, 12, 9614, 29, 3450, 14, 5699, 63, 11367, 304, 272, 408, 12357, 370, 5398, 282, 2838, 641, 314, 1627, 1591, 26, 719, 436, 372, 715, 272, 340, 626, 965, 2757, 3962, 1041, 272, 862, 26, 267, 6771, 275, 2838, 14, 3450, 8, 6606, 12, 2838, 14, 9469, 63, 9484, 9, 267, 6771, 14, 3409, 1332, 1102, 12, 1844, 430, 272, 871, 334, 3450, 14, 705, 12, 2838, 14, 5294, 73, 705, 304, 267, 372, 756, 272, 587, 26, 267, 6771, 14, 1600, 342, 267, 372, 715, 199, 199, 5449, 275, 511, 63, 4058, 14, 5449, 199, 9740, 275, 330, 7, 45, 11781, 598, 17588, 1148, 1990, 2348, 60, 78, 7, 199, 10640, 51, 63, 11253, 22, 275, 2838, 14, 1989, 63, 4774, 22, 436, 862, 63, 1562, 29539, 17, 297, 9614, 29, 3450, 14, 5699, 63, 11367, 22, 9, 199, 199, 893, 26, 272, 492, 2462, 272, 492, 5796, 199, 2590, 3545, 26, 272, 2462, 275, 488, 272, 5796, 275, 488, 199, 199, 5449, 275, 511, 63, 4058, 14, 5449, 199, 9740, 275, 283, 45, 11781, 598, 17588, 1148, 1990, 2348, 60, 78, 7, 199, 199, 533, 17766, 9735, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 7297, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 267, 291, 14, 719, 275, 511, 63, 4058, 14, 3409, 63, 719, 8, 277, 14, 7297, 9, 267, 291, 14, 7297, 14, 5859, 8, 17, 9, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 7297, 14, 1600, 342, 267, 291, 14, 7297, 275, 488, 199, 199, 533, 17766, 17457, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 7297, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 25351, 9, 267, 291, 14, 719, 275, 511, 63, 4058, 14, 3409, 63, 719, 8, 277, 14, 7297, 9, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 7297, 14, 1600, 342, 267, 291, 14, 7297, 275, 488, 199, 199, 533, 11086, 461, 774, 26, 272, 408, 4436, 461, 1379, 1021, 339, 710, 11086, 461, 774, 1021, 7704, 652, 8837, 370, 1218, 282, 25396, 272, 1890, 15, 1000, 4092, 687, 376, 3411, 4137, 511, 14, 4005, 1218, 282, 272, 892, 25396, 1021, 687, 376, 3411, 4137, 511, 12, 675, 3663, 272, 15433, 26, 398, 1021, 7053, 2543, 334, 16411, 2543, 12, 11086, 461, 774, 304, 288, 986, 339, 961, 1021, 7890, 2877, 892, 10949, 3423, 543, 25259, 272, 12901, 367, 18972, 26, 398, 1890, 19845, 6248, 267, 1890, 30711, 6248, 339, 6184, 892, 511, 3423, 4453, 314, 1021, 1471, 2066, 5627, 272, 2295, 315, 6342, 12, 2382, 314, 511, 536, 365, 9222, 6133, 543, 282, 272, 14135, 370, 6623, 314, 1890, 18046, 402, 314, 511, 14, 1316, 26, 398, 347, 511, 5686, 8, 277, 304, 288, 327, 7146, 18046, 398, 347, 485, 396, 5686, 8, 277, 304, 288, 327, 6810, 18046, 339, 6184, 4967, 4915, 701, 314, 13431, 5309, 3932, 2295, 272, 787, 15604, 436, 1752, 5057, 370, 314, 2446, 2462, 370, 10459, 272, 314, 5343, 10059, 14, 339, 3390, 12, 314, 1654, 3272, 805, 3913, 1240, 1263, 14592, 272, 3423, 626, 19687, 641, 314, 1890, 2462, 5309, 3272, 12, 272, 7444, 1654, 26090, 17960, 342, 365, 2797, 2951, 2544, 272, 314, 14592, 1240, 334, 10180, 465, 315, 4260, 1536, 282, 1890, 15, 1000, 272, 1950, 436, 19203, 314, 4729, 342, 315, 3613, 1252, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 327, 16666, 439, 314, 2549, 3272, 805, 267, 291, 855, 5996, 275, 291, 14, 5996, 267, 291, 855, 12336, 275, 291, 14, 12336, 267, 291, 14, 5996, 275, 291, 423, 5996, 267, 291, 14, 12336, 275, 291, 423, 12336, 339, 347, 1654, 26090, 17960, 8, 277, 304, 267, 408, 2765, 1083, 6127, 314, 1654, 370, 7662, 6623, 626, 267, 652, 15061, 314, 1890, 2462, 370, 20320, 14, 961, 365, 2997, 340, 314, 267, 1654, 365, 3595, 370, 5341, 282, 14592, 12981, 626, 365, 267, 11410, 12188, 314, 1890, 2462, 5309, 2399, 3272, 12981, 1041, 267, 291, 14, 1000, 63, 2179, 14, 409, 342, 339, 347, 485, 5996, 8, 277, 304, 267, 291, 14, 1000, 63, 2179, 275, 5796, 14, 2390, 342, 267, 291, 14, 1258, 63, 2179, 275, 5796, 14, 2390, 342, 267, 291, 14, 4456, 275, 5796, 14, 2390, 342, 267, 291, 14, 1825, 275, 10703, 14, 3737, 8, 17, 9, 398, 327, 4226, 2005, 333, 324, 1540, 370, 1343, 314, 1890, 511, 14, 267, 28009, 275, 291, 14, 344, 342, 267, 284, 275, 28009, 14, 14542, 7563, 267, 28009, 275, 28009, 59, 73, 11, 17, 2938, 267, 511, 63, 765, 275, 2519, 8, 277, 12, 14135, 435, 28009, 9, 267, 291, 14, 1258, 63, 2671, 275, 2462, 14, 928, 63, 1222, 63, 2671, 8, 288, 291, 14, 1258, 2540, 12, 334, 396, 63, 765, 4641, 398, 291, 855, 5996, 342, 267, 340, 440, 291, 14, 1000, 63, 2179, 14, 374, 63, 409, 837, 288, 291, 14, 1000, 63, 2179, 14, 409, 342, 267, 291, 14, 1258, 63, 2179, 14, 2573, 342, 339, 347, 485, 12336, 8, 277, 304, 267, 291, 855, 12336, 342, 267, 291, 14, 4456, 14, 2573, 342, 398, 340, 440, 291, 14, 1825, 14, 1667, 837, 288, 1499, 275, 291, 14, 1825, 14, 362, 342, 288, 291, 14, 1633, 8, 1328, 9, 339, 347, 1890, 2540, 8, 277, 12, 511, 63, 1532, 304, 267, 291, 14, 1000, 63, 2179, 14, 2573, 342, 267, 291, 14, 1258, 19845, 342, 267, 291, 14, 1258, 63, 2179, 14, 409, 342, 267, 340, 440, 4550, 8, 396, 63, 1532, 304, 288, 746, 3146, 480, 396, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
jacky-young/crosswalk-test-suite
stability/stability-iterative-android-tests/inst.apk.py
903
3180
#!/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])) (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, 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, 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, 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, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
farhaanbukhsh/sympy
sympy/physics/unitsystems/systems/natural.py
91
1785
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*- """ Naturalunit system. The natural system comes from "setting c = 1, hbar = 1". From the computer point of view it means that we use velocity and action instead of length and time. Moreover instead of mass we use energy. """ from __future__ import division from sympy.physics.unitsystems.dimensions import Dimension, DimensionSystem from sympy.physics.unitsystems.units import Unit, Constant, UnitSystem from sympy.physics.unitsystems.prefixes import PREFIXES, prefix_unit # base dimensions action = Dimension(name="action", symbol="A", length=2, mass=1, time=-1) energy = Dimension(name="energy", symbol="E", length=2, mass=1, time=-2) velocity = Dimension(name="velocity", symbol="V", length=1, time=-1) # derived dimensions length = Dimension(name="length", symbol="L", length=1) mass = Dimension(name="mass", symbol="M", mass=1) time = Dimension(name="time", symbol="T", time=1) acceleration = Dimension(name="acceleration", length=1, time=-2) momentum = Dimension(name="momentum", mass=1, length=1, time=-1) force = Dimension(name="force", symbol="F", mass=1, length=1, time=-2) power = Dimension(name="power", length=2, mass=1, time=-3) frequency = Dimension(name="frequency", symbol="f", time=-1) dims = (length, mass, time, momentum, force, energy, power, frequency) # dimension system natural_dim = DimensionSystem(base=(action, energy, velocity), dims=dims, name="Natural system") # base units hbar = Constant(action, factor=1.05457266e-34, abbrev="hbar") eV = Unit(energy, factor=1.60219e-19, abbrev="eV") c = Constant(velocity, factor=299792458, abbrev="c") units = prefix_unit(eV, PREFIXES) # unit system natural = UnitSystem(base=(hbar, eV, c), units=units, name="Natural system")
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 23604, 4889, 3248, 2656, 14, 199, 199, 1918, 19981, 2656, 12477, 687, 298, 6031, 286, 275, 413, 12, 394, 1700, 275, 413, 1674, 11606, 314, 24189, 199, 1403, 402, 2455, 652, 4910, 626, 781, 675, 20508, 436, 1595, 3140, 402, 2582, 436, 199, 521, 14, 16917, 1883, 3140, 402, 12250, 781, 675, 12304, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 504, 5840, 14, 24724, 14, 3248, 19135, 14, 13320, 492, 25291, 12, 25291, 3989, 199, 504, 5840, 14, 24724, 14, 3248, 19135, 14, 5260, 492, 12008, 12, 19991, 12, 12008, 3989, 199, 504, 5840, 14, 24724, 14, 3248, 19135, 14, 14124, 492, 27884, 654, 12, 2403, 63, 3248, 199, 199, 3, 1300, 7365, 199, 1287, 275, 25291, 8, 354, 628, 1287, 401, 5272, 628, 33, 401, 2582, 29, 18, 12, 12250, 29, 17, 12, 900, 4022, 17, 9, 199, 8443, 275, 25291, 8, 354, 628, 8443, 401, 5272, 628, 37, 401, 2582, 29, 18, 12, 12250, 29, 17, 12, 900, 4022, 18, 9, 199, 16350, 275, 25291, 8, 354, 628, 16350, 401, 5272, 628, 54, 401, 2582, 29, 17, 12, 900, 4022, 17, 9, 199, 199, 3, 7131, 7365, 199, 1267, 275, 25291, 8, 354, 628, 1267, 401, 5272, 628, 44, 401, 2582, 29, 17, 9, 199, 11535, 275, 25291, 8, 354, 628, 11535, 401, 5272, 628, 45, 401, 12250, 29, 17, 9, 199, 521, 275, 25291, 8, 354, 628, 521, 401, 5272, 628, 52, 401, 900, 29, 17, 9, 199, 645, 29765, 275, 25291, 8, 354, 628, 645, 29765, 401, 2582, 29, 17, 12, 900, 4022, 18, 9, 199, 25710, 275, 25291, 8, 354, 628, 25710, 401, 12250, 29, 17, 12, 2582, 29, 17, 12, 900, 4022, 17, 9, 199, 3990, 275, 25291, 8, 354, 628, 3990, 401, 5272, 628, 38, 401, 12250, 29, 17, 12, 2582, 29, 17, 12, 900, 4022, 18, 9, 199, 5652, 275, 25291, 8, 354, 628, 5652, 401, 2582, 29, 18, 12, 12250, 29, 17, 12, 900, 4022, 19, 9, 199, 11132, 275, 25291, 8, 354, 628, 11132, 401, 5272, 628, 70, 401, 900, 4022, 17, 9, 199, 199, 5380, 275, 334, 1267, 12, 12250, 12, 900, 12, 23887, 12, 3542, 12, 12304, 12, 7074, 12, 9857, 9, 199, 199, 3, 6240, 2656, 199, 15759, 63, 3572, 275, 25291, 3989, 8, 1095, 2687, 1287, 12, 12304, 12, 20508, 395, 17476, 29, 5380, 12, 2892, 536, 628, 23604, 4889, 2656, 531, 199, 199, 3, 1300, 6204, 199, 72, 1700, 275, 19991, 8, 1287, 12, 6535, 29, 17, 14, 22663, 1641, 9969, 69, 13, 1082, 12, 2236, 66, 4964, 628, 72, 1700, 531, 199, 27786, 275, 12008, 8, 8443, 12, 6535, 29, 17, 14, 28384, 1167, 69, 13, 1167, 12, 2236, 66, 4964, 628, 27786, 531, 199, 67, 275, 19991, 8, 16350, 12, 6535, 29, 10488, 1965, 1194, 2010, 12, 2236, 66, 4964, 628, 67, 531, 199, 199, 5260, 275, 2403, 63, 3248, 8, 27786, 12, 27884, 654, 9, 199, 199, 3, 4137, 2656, 199, 15759, 275, 12008, 3989, 8, 1095, 2687, 72, 1700, 12, 325, 54, 12, 286, 395, 6204, 29, 5260, 12, 536, 628, 23604, 4889, 2656, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 23604, 4889, 3248, 2656, 14, 199, 199, 1918, 19981, 2656, 12477, 687, 298, 6031, 286, 275, 413, 12, 394, 1700, 275, 413, 1674, 11606, 314, 24189, 199, 1403, 402, 2455, 652, 4910, 626, 781, 675, 20508, 436, 1595, 3140, 402, 2582, 436, 199, 521, 14, 16917, 1883, 3140, 402, 12250, 781, 675, 12304, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 504, 5840, 14, 24724, 14, 3248, 19135, 14, 13320, 492, 25291, 12, 25291, 3989, 199, 504, 5840, 14, 24724, 14, 3248, 19135, 14, 5260, 492, 12008, 12, 19991, 12, 12008, 3989, 199, 504, 5840, 14, 24724, 14, 3248, 19135, 14, 14124, 492, 27884, 654, 12, 2403, 63, 3248, 199, 199, 3, 1300, 7365, 199, 1287, 275, 25291, 8, 354, 628, 1287, 401, 5272, 628, 33, 401, 2582, 29, 18, 12, 12250, 29, 17, 12, 900, 4022, 17, 9, 199, 8443, 275, 25291, 8, 354, 628, 8443, 401, 5272, 628, 37, 401, 2582, 29, 18, 12, 12250, 29, 17, 12, 900, 4022, 18, 9, 199, 16350, 275, 25291, 8, 354, 628, 16350, 401, 5272, 628, 54, 401, 2582, 29, 17, 12, 900, 4022, 17, 9, 199, 199, 3, 7131, 7365, 199, 1267, 275, 25291, 8, 354, 628, 1267, 401, 5272, 628, 44, 401, 2582, 29, 17, 9, 199, 11535, 275, 25291, 8, 354, 628, 11535, 401, 5272, 628, 45, 401, 12250, 29, 17, 9, 199, 521, 275, 25291, 8, 354, 628, 521, 401, 5272, 628, 52, 401, 900, 29, 17, 9, 199, 645, 29765, 275, 25291, 8, 354, 628, 645, 29765, 401, 2582, 29, 17, 12, 900, 4022, 18, 9, 199, 25710, 275, 25291, 8, 354, 628, 25710, 401, 12250, 29, 17, 12, 2582, 29, 17, 12, 900, 4022, 17, 9, 199, 3990, 275, 25291, 8, 354, 628, 3990, 401, 5272, 628, 38, 401, 12250, 29, 17, 12, 2582, 29, 17, 12, 900, 4022, 18, 9, 199, 5652, 275, 25291, 8, 354, 628, 5652, 401, 2582, 29, 18, 12, 12250, 29, 17, 12, 900, 4022, 19, 9, 199, 11132, 275, 25291, 8, 354, 628, 11132, 401, 5272, 628, 70, 401, 900, 4022, 17, 9, 199, 199, 5380, 275, 334, 1267, 12, 12250, 12, 900, 12, 23887, 12, 3542, 12, 12304, 12, 7074, 12, 9857, 9, 199, 199, 3, 6240, 2656, 199, 15759, 63, 3572, 275, 25291, 3989, 8, 1095, 2687, 1287, 12, 12304, 12, 20508, 395, 17476, 29, 5380, 12, 2892, 536, 628, 23604, 4889, 2656, 531, 199, 199, 3, 1300, 6204, 199, 72, 1700, 275, 19991, 8, 1287, 12, 6535, 29, 17, 14, 22663, 1641, 9969, 69, 13, 1082, 12, 2236, 66, 4964, 628, 72, 1700, 531, 199, 27786, 275, 12008, 8, 8443, 12, 6535, 29, 17, 14, 28384, 1167, 69, 13, 1167, 12, 2236, 66, 4964, 628, 27786, 531, 199, 67, 275, 19991, 8, 16350, 12, 6535, 29, 10488, 1965, 1194, 2010, 12, 2236, 66, 4964, 628, 67, 531, 199, 199, 5260, 275, 2403, 63, 3248, 8, 27786, 12, 27884, 654, 9, 199, 199, 3, 4137, 2656, 199, 15759, 275, 12008, 3989, 8, 1095, 2687, 72, 1700, 12, 325, 54, 12, 286, 395, 6204, 29, 5260, 12, 536, 628, 23604, 4889, 2656, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bonethrown/azure-sdk-for-python
azure-nspkg/setup.py
4
2040
#!/usr/bin/env python #------------------------------------------------------------------------- # Copyright (c) Microsoft. 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 setuptools import setup # azure v0.x is not compatible with this package # azure v0.x used to have a __version__ attribute (newer versions don't) try: import azure try: ver = azure.__version__ raise Exception( 'This package is incompatible with azure=={}. '.format(ver) + 'Uninstall it with "pip uninstall azure".' ) except AttributeError: pass except ImportError: pass setup( name='azure-nspkg', version='1.0.0', description='Microsoft Azure Namespace Package [Internal]', long_description=open('README.rst', 'r').read(), license='Apache License 2.0', author='Microsoft Corporation', author_email='ptvshelp@microsoft.com', url='https://github.com/Azure/azure-sdk-for-python', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'License :: OSI Approved :: Apache Software License', ], zip_safe=False, packages=[ 'azure', ], )
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 25812, 199, 3, 1898, 334, 67, 9, 15332, 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, 7656, 9460, 199, 199, 504, 9116, 492, 3272, 199, 199, 3, 13601, 373, 16, 14, 88, 365, 440, 9025, 543, 642, 2559, 199, 3, 13601, 373, 16, 14, 88, 1202, 370, 1172, 282, 636, 1023, 363, 2225, 334, 1222, 281, 5459, 2793, 1133, 9, 199, 893, 26, 272, 492, 13601, 272, 862, 26, 267, 809, 275, 13601, 855, 1023, 363, 267, 746, 2186, 8, 288, 283, 2765, 2559, 365, 18457, 543, 13601, 389, 31270, 1987, 908, 8, 422, 9, 435, 288, 283, 1358, 3174, 652, 543, 298, 9983, 22199, 13601, 24217, 267, 776, 272, 871, 4281, 26, 267, 986, 199, 2590, 3545, 26, 272, 986, 199, 199, 2758, 8, 272, 536, 534, 9078, 13, 561, 4600, 297, 272, 1015, 534, 17, 14, 16, 14, 16, 297, 272, 1369, 534, 12940, 15474, 19317, 15665, 359, 8405, 4300, 272, 1846, 63, 1802, 29, 1490, 360, 18195, 14, 8332, 297, 283, 82, 1959, 739, 1062, 272, 4190, 534, 28993, 844, 499, 14, 16, 297, 272, 4132, 534, 12940, 11098, 297, 272, 4132, 63, 2123, 534, 541, 86, 609, 1357, 32, 17040, 14, 957, 297, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 22386, 15, 9078, 13, 9277, 13, 509, 13, 1548, 297, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 297, 267, 283, 11411, 8466, 3800, 2018, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 3668, 2290, 844, 297, 272, 2156, 272, 3482, 63, 3489, 29, 797, 12, 272, 6117, 1524, 267, 283, 9078, 297, 272, 2156, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 25812, 199, 3, 1898, 334, 67, 9, 15332, 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, 7656, 9460, 199, 199, 504, 9116, 492, 3272, 199, 199, 3, 13601, 373, 16, 14, 88, 365, 440, 9025, 543, 642, 2559, 199, 3, 13601, 373, 16, 14, 88, 1202, 370, 1172, 282, 636, 1023, 363, 2225, 334, 1222, 281, 5459, 2793, 1133, 9, 199, 893, 26, 272, 492, 13601, 272, 862, 26, 267, 809, 275, 13601, 855, 1023, 363, 267, 746, 2186, 8, 288, 283, 2765, 2559, 365, 18457, 543, 13601, 389, 31270, 1987, 908, 8, 422, 9, 435, 288, 283, 1358, 3174, 652, 543, 298, 9983, 22199, 13601, 24217, 267, 776, 272, 871, 4281, 26, 267, 986, 199, 2590, 3545, 26, 272, 986, 199, 199, 2758, 8, 272, 536, 534, 9078, 13, 561, 4600, 297, 272, 1015, 534, 17, 14, 16, 14, 16, 297, 272, 1369, 534, 12940, 15474, 19317, 15665, 359, 8405, 4300, 272, 1846, 63, 1802, 29, 1490, 360, 18195, 14, 8332, 297, 283, 82, 1959, 739, 1062, 272, 4190, 534, 28993, 844, 499, 14, 16, 297, 272, 4132, 534, 12940, 11098, 297, 272, 4132, 63, 2123, 534, 541, 86, 609, 1357, 32, 17040, 14, 957, 297, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 22386, 15, 9078, 13, 9277, 13, 509, 13, 1548, 297, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 297, 267, 283, 11411, 8466, 3800, 2018, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 3668, 2290, 844, 297, 272, 2156, 272, 3482, 63, 3489, 29, 797, 12, 272, 6117, 1524, 267, 283, 9078, 297, 272, 2156, 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, 32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 0, 0, 0, 0, 0, 0 ]
ErickMurillo/ciat_plataforma
comunicacion/notas/migrations/0001_initial.py
3
7549
# -*- coding: utf-8 -*- from south.utils import datetime_utils as 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 'Temas' db.create_table(u'notas_temas', ( (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('nombre', self.gf('django.db.models.fields.CharField')(max_length=250)), )) db.send_create_signal(u'notas', ['Temas']) # Adding model 'Notas' db.create_table(u'notas_notas', ( (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('titulo', self.gf('django.db.models.fields.CharField')(max_length=200)), ('slug', self.gf('django.db.models.fields.SlugField')(max_length=200)), ('fecha', self.gf('django.db.models.fields.DateField')(auto_now_add=True, blank=True)), ('contenido', self.gf('ckeditor.fields.RichTextField')()), ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), )) db.send_create_signal(u'notas', ['Notas']) # Adding M2M table for field temas on 'Notas' m2m_table_name = db.shorten_name(u'notas_notas_temas') db.create_table(m2m_table_name, ( ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), ('notas', models.ForeignKey(orm[u'notas.notas'], null=False)), ('temas', models.ForeignKey(orm[u'notas.temas'], null=False)) )) db.create_unique(m2m_table_name, ['notas_id', 'temas_id']) # Adding model 'ComentarioNotas' db.create_table(u'notas_comentarionotas', ( (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('nota', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['notas.Notas'])), ('fecha', self.gf('django.db.models.fields.DateField')(default=datetime.datetime(2015, 1, 28, 0, 0))), ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), ('comentario', self.gf('ckeditor.fields.RichTextField')()), )) db.send_create_signal(u'notas', ['ComentarioNotas']) def backwards(self, orm): # Deleting model 'Temas' db.delete_table(u'notas_temas') # Deleting model 'Notas' db.delete_table(u'notas_notas') # Removing M2M table for field temas on 'Notas' db.delete_table(db.shorten_name(u'notas_notas_temas')) # Deleting model 'ComentarioNotas' db.delete_table(u'notas_comentarionotas') models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, u'auth.permission': { 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, u'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, u'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'}), u'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'}) }, u'notas.comentarionotas': { 'Meta': {'object_name': 'ComentarioNotas'}, 'comentario': ('ckeditor.fields.RichTextField', [], {}), 'fecha': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2015, 1, 28, 0, 0)'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'nota': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['notas.Notas']"}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}) }, u'notas.notas': { 'Meta': {'ordering': "['-fecha', '-id']", 'object_name': 'Notas'}, 'contenido': ('ckeditor.fields.RichTextField', [], {}), 'fecha': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '200'}), 'temas': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['notas.Temas']", 'symmetrical': 'False'}), 'titulo': ('django.db.models.fields.CharField', [], {'max_length': '200'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}) }, u'notas.temas': { 'Meta': {'object_name': 'Temas'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'nombre': ('django.db.models.fields.CharField', [], {'max_length': '250'}) } } complete_apps = ['notas']
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 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, 267, 327, 12934, 1402, 283, 52, 5633, 305, 7, 267, 1592, 14, 981, 63, 1224, 8, 85, 7, 1397, 305, 63, 563, 305, 297, 334, 288, 334, 85, 7, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 15998, 10205, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 7991, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 8, 85, 7, 1397, 305, 297, 788, 52, 5633, 305, 1105, 398, 327, 12934, 1402, 283, 1763, 305, 7, 267, 1592, 14, 981, 63, 1224, 8, 85, 7, 1397, 305, 63, 1397, 305, 297, 334, 288, 334, 85, 7, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 6403, 13957, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 1840, 1826, 288, 661, 5464, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 17315, 7533, 988, 63, 1267, 29, 1840, 1826, 288, 661, 771, 9518, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 7533, 2495, 63, 2131, 63, 525, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 388, 724, 31090, 297, 291, 14, 7102, 360, 346, 7515, 14, 955, 14, 50, 1158, 6254, 358, 4000, 288, 661, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 8, 85, 7, 1397, 305, 297, 788, 1763, 305, 1105, 398, 327, 12934, 603, 18, 45, 1817, 367, 901, 29072, 305, 641, 283, 1763, 305, 7, 267, 333, 18, 77, 63, 1224, 63, 354, 275, 1592, 14, 30686, 63, 354, 8, 85, 7, 1397, 305, 63, 1397, 305, 63, 563, 305, 358, 267, 1592, 14, 981, 63, 1224, 8, 77, 18, 77, 63, 1224, 63, 354, 12, 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, 1397, 305, 297, 1709, 14, 3190, 8, 1025, 59, 85, 7, 1397, 305, 14, 1397, 305, 995, 2973, 29, 797, 1826, 288, 661, 563, 305, 297, 1709, 14, 3190, 8, 1025, 59, 85, 7, 1397, 305, 14, 563, 305, 995, 2973, 29, 797, 430, 267, 5082, 267, 1592, 14, 981, 63, 3235, 8, 77, 18, 77, 63, 1224, 63, 354, 12, 788, 1397, 305, 63, 344, 297, 283, 563, 305, 63, 344, 1105, 398, 327, 12934, 1402, 283, 967, 434, 6936, 1763, 305, 7, 267, 1592, 14, 981, 63, 1224, 8, 85, 7, 1397, 305, 63, 331, 434, 759, 265, 357, 305, 297, 334, 288, 334, 85, 7, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 1397, 65, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1397, 305, 14, 1763, 305, 16607, 288, 661, 771, 9518, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 7533, 885, 29, 2083, 14, 2083, 8, 7806, 12, 413, 12, 7294, 12, 378, 12, 378, 11508, 288, 661, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 288, 661, 331, 434, 6936, 297, 291, 14, 7102, 360, 346, 7515, 14, 955, 14, 50, 1158, 6254, 358, 4000, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 8, 85, 7, 1397, 305, 297, 788, 967, 434, 6936, 1763, 305, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 52, 5633, 305, 7, 267, 1592, 14, 1807, 63, 1224, 8, 85, 7, 1397, 305, 63, 563, 305, 358, 398, 327, 15920, 1402, 283, 1763, 305, 7, 267, 1592, 14, 1807, 63, 1224, 8, 85, 7, 1397, 305, 63, 1397, 305, 358, 398, 327, 29343, 603, 18, 45, 1817, 367, 901, 29072, 305, 641, 283, 1763, 305, 7, 267, 1592, 14, 1807, 63, 1224, 8, 697, 14, 30686, 63, 354, 8, 85, 7, 1397, 305, 63, 1397, 305, 63, 563, 305, 1333, 398, 327, 15920, 1402, 283, 967, 434, 6936, 1763, 305, 7, 267, 1592, 14, 1807, 63, 1224, 8, 85, 7, 1397, 305, 63, 331, 434, 759, 265, 357, 305, 358, 2378, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 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, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 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, 267, 327, 12934, 1402, 283, 52, 5633, 305, 7, 267, 1592, 14, 981, 63, 1224, 8, 85, 7, 1397, 305, 63, 563, 305, 297, 334, 288, 334, 85, 7, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 15998, 10205, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 7991, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 8, 85, 7, 1397, 305, 297, 788, 52, 5633, 305, 1105, 398, 327, 12934, 1402, 283, 1763, 305, 7, 267, 1592, 14, 981, 63, 1224, 8, 85, 7, 1397, 305, 63, 1397, 305, 297, 334, 288, 334, 85, 7, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 6403, 13957, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 1840, 1826, 288, 661, 5464, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 17315, 7533, 988, 63, 1267, 29, 1840, 1826, 288, 661, 771, 9518, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 7533, 2495, 63, 2131, 63, 525, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 388, 724, 31090, 297, 291, 14, 7102, 360, 346, 7515, 14, 955, 14, 50, 1158, 6254, 358, 4000, 288, 661, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 8, 85, 7, 1397, 305, 297, 788, 1763, 305, 1105, 398, 327, 12934, 603, 18, 45, 1817, 367, 901, 29072, 305, 641, 283, 1763, 305, 7, 267, 333, 18, 77, 63, 1224, 63, 354, 275, 1592, 14, 30686, 63, 354, 8, 85, 7, 1397, 305, 63, 1397, 305, 63, 563, 305, 358, 267, 1592, 14, 981, 63, 1224, 8, 77, 18, 77, 63, 1224, 63, 354, 12, 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, 1397, 305, 297, 1709, 14, 3190, 8, 1025, 59, 85, 7, 1397, 305, 14, 1397, 305, 995, 2973, 29, 797, 1826, 288, 661, 563, 305, 297, 1709, 14, 3190, 8, 1025, 59, 85, 7, 1397, 305, 14, 563, 305, 995, 2973, 29, 797, 430, 267, 5082, 267, 1592, 14, 981, 63, 3235, 8, 77, 18, 77, 63, 1224, 63, 354, 12, 788, 1397, 305, 63, 344, 297, 283, 563, 305, 63, 344, 1105, 398, 327, 12934, 1402, 283, 967, 434, 6936, 1763, 305, 7, 267, 1592, 14, 981, 63, 1224, 8, 85, 7, 1397, 305, 63, 331, 434, 759, 265, 357, 305, 297, 334, 288, 334, 85, 7, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 1397, 65, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1397, 305, 14, 1763, 305, 16607, 288, 661, 771, 9518, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 7533, 885, 29, 2083, 14, 2083, 8, 7806, 12, 413, 12, 7294, 12, 378, 12, 378, 11508, 288, 661, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 288, 661, 331, 434, 6936, 297, 291, 14, 7102, 360, 346, 7515, 14, 955, 14, 50, 1158, 6254, 358, 4000, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 8, 85, 7, 1397, 305, 297, 788, 967, 434, 6936, 1763, 305, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 52, 5633, 305, 7, 267, 1592, 14, 1807, 63, 1224, 8, 85, 7, 1397, 305, 63, 563, 305, 358, 398, 327, 15920, 1402, 283, 1763, 305, 7, 267, 1592, 14, 1807, 63, 1224, 8, 85, 7, 1397, 305, 63, 1397, 305, 358, 398, 327, 29343, 603, 18, 45, 1817, 367, 901, 29072, 305, 641, 283, 1763, 305, 7, 267, 1592, 14, 1807, 63, 1224, 8, 697, 14, 30686, 63, 354, 8, 85, 7, 1397, 305, 63, 1397, 305, 63, 563, 305, 1333, 398, 327, 15920, 1402, 283, 967, 434, 6936, 1763, 305, 7, 267, 1592, 14, 1807, 63, 1224, 8, 85, 7, 1397, 305, 63, 331, 434, 759, 265, 357, 305, 358, 2378, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 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, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jesmorc/Proyecto-IV
lib/python2.7/site-packages/werkzeug/debug/tbtools.py
147
16913
# -*- coding: utf-8 -*- """ werkzeug.debug.tbtools ~~~~~~~~~~~~~~~~~~~~~~ This module provides various traceback related utility functions. :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details. :license: BSD. """ import re import os import sys import json import inspect import traceback import codecs from tokenize import TokenError from werkzeug.utils import cached_property, escape from werkzeug.debug.console import Console from werkzeug._compat import range_type, PY2, text_type, string_types, \ to_native, to_unicode _coding_re = re.compile(br'coding[:=]\s*([-\w.]+)') _line_re = re.compile(br'^(.*?)$(?m)') _funcdef_re = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)') UTF8_COOKIE = b'\xef\xbb\xbf' system_exceptions = (SystemExit, KeyboardInterrupt) try: system_exceptions += (GeneratorExit,) except NameError: pass HEADER = u'''\ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>%(title)s // Werkzeug Debugger</title> <link rel="stylesheet" href="?__debugger__=yes&amp;cmd=resource&amp;f=style.css" type="text/css"> <!-- We need to make sure this has a favicon so that the debugger does not by accident trigger a request to /favicon.ico which might change the application state. --> <link rel="shortcut icon" href="?__debugger__=yes&amp;cmd=resource&amp;f=console.png"> <script type="text/javascript" src="?__debugger__=yes&amp;cmd=resource&amp;f=jquery.js"></script> <script type="text/javascript" src="?__debugger__=yes&amp;cmd=resource&amp;f=debugger.js"></script> <script type="text/javascript"> var TRACEBACK = %(traceback_id)d, CONSOLE_MODE = %(console)s, EVALEX = %(evalex)s, SECRET = "%(secret)s"; </script> </head> <body> <div class="debugger"> ''' FOOTER = u'''\ <div class="footer"> Brought to you by <strong class="arthur">DON'T PANIC</strong>, your friendly Werkzeug powered traceback interpreter. </div> </div> </body> </html> ''' PAGE_HTML = HEADER + u'''\ <h1>%(exception_type)s</h1> <div class="detail"> <p class="errormsg">%(exception)s</p> </div> <h2 class="traceback">Traceback <em>(most recent call last)</em></h2> %(summary)s <div class="plain"> <form action="/?__debugger__=yes&amp;cmd=paste" method="post"> <p> <input type="hidden" name="language" value="pytb"> This is the Copy/Paste friendly version of the traceback. <span class="pastemessage">You can also paste this traceback into a <a href="https://gist.github.com/">gist</a>: <input type="submit" value="create paste"></span> </p> <textarea cols="50" rows="10" name="code" readonly>%(plaintext)s</textarea> </form> </div> <div class="explanation"> The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error. <span class="nojavascript"> If you enable JavaScript you can also use additional features such as code execution (if the evalex feature is enabled), automatic pasting of the exceptions and much more.</span> </div> ''' + FOOTER + ''' <!-- %(plaintext_cs)s --> ''' CONSOLE_HTML = HEADER + u'''\ <h1>Interactive Console</h1> <div class="explanation"> In this console you can execute Python expressions in the context of the application. The initial namespace was created by the debugger automatically. </div> <div class="console"><div class="inner">The Console requires JavaScript.</div></div> ''' + FOOTER SUMMARY_HTML = u'''\ <div class="%(classes)s"> %(title)s <ul>%(frames)s</ul> %(description)s </div> ''' FRAME_HTML = u'''\ <div class="frame" id="frame-%(id)d"> <h4>File <cite class="filename">"%(filename)s"</cite>, line <em class="line">%(lineno)s</em>, in <code class="function">%(function_name)s</code></h4> <pre>%(current_line)s</pre> </div> ''' SOURCE_TABLE_HTML = u'<table class=source>%s</table>' SOURCE_LINE_HTML = u'''\ <tr class="%(classes)s"> <td class=lineno>%(lineno)s</td> <td>%(code)s</td> </tr> ''' def render_console_html(secret): return CONSOLE_HTML % { 'evalex': 'true', 'console': 'true', 'title': 'Console', 'secret': secret, 'traceback_id': -1 } def get_current_traceback(ignore_system_exceptions=False, show_hidden_frames=False, skip=0): """Get the current exception info as `Traceback` object. Per default calling this method will reraise system exceptions such as generator exit, system exit or others. This behavior can be disabled by passing `False` to the function as first parameter. """ exc_type, exc_value, tb = sys.exc_info() if ignore_system_exceptions and exc_type in system_exceptions: raise for x in range_type(skip): if tb.tb_next is None: break tb = tb.tb_next tb = Traceback(exc_type, exc_value, tb) if not show_hidden_frames: tb.filter_hidden_frames() return tb class Line(object): """Helper for the source renderer.""" __slots__ = ('lineno', 'code', 'in_frame', 'current') def __init__(self, lineno, code): self.lineno = lineno self.code = code self.in_frame = False self.current = False def classes(self): rv = ['line'] if self.in_frame: rv.append('in-frame') if self.current: rv.append('current') return rv classes = property(classes) def render(self): return SOURCE_LINE_HTML % { 'classes': u' '.join(self.classes), 'lineno': self.lineno, 'code': escape(self.code) } class Traceback(object): """Wraps a traceback.""" def __init__(self, exc_type, exc_value, tb): self.exc_type = exc_type self.exc_value = exc_value if not isinstance(exc_type, str): exception_type = exc_type.__name__ if exc_type.__module__ not in ('__builtin__', 'exceptions'): exception_type = exc_type.__module__ + '.' + exception_type else: exception_type = exc_type self.exception_type = exception_type # we only add frames to the list that are not hidden. This follows # the the magic variables as defined by paste.exceptions.collector self.frames = [] while tb: self.frames.append(Frame(exc_type, exc_value, tb)) tb = tb.tb_next def filter_hidden_frames(self): """Remove the frames according to the paste spec.""" if not self.frames: return new_frames = [] hidden = False for frame in self.frames: hide = frame.hide if hide in ('before', 'before_and_this'): new_frames = [] hidden = False if hide == 'before_and_this': continue elif hide in ('reset', 'reset_and_this'): hidden = False if hide == 'reset_and_this': continue elif hide in ('after', 'after_and_this'): hidden = True if hide == 'after_and_this': continue elif hide or hidden: continue new_frames.append(frame) # if we only have one frame and that frame is from the codeop # module, remove it. if len(new_frames) == 1 and self.frames[0].module == 'codeop': del self.frames[:] # if the last frame is missing something went terrible wrong :( elif self.frames[-1] in new_frames: self.frames[:] = new_frames def is_syntax_error(self): """Is it a syntax error?""" return isinstance(self.exc_value, SyntaxError) is_syntax_error = property(is_syntax_error) def exception(self): """String representation of the exception.""" buf = traceback.format_exception_only(self.exc_type, self.exc_value) rv = ''.join(buf).strip() return rv.decode('utf-8', 'replace') if PY2 else rv exception = property(exception) def log(self, logfile=None): """Log the ASCII traceback into a file object.""" if logfile is None: logfile = sys.stderr tb = self.plaintext.rstrip() + u'\n' if PY2: tb = tb.encode('utf-8', 'replace') logfile.write(tb) def paste(self): """Create a paste and return the paste id.""" data = json.dumps({ 'description': 'Werkzeug Internal Server Error', 'public': False, 'files': { 'traceback.txt': { 'content': self.plaintext } } }).encode('utf-8') try: from urllib2 import urlopen except ImportError: from urllib.request import urlopen rv = urlopen('https://api.github.com/gists', data=data) resp = json.loads(rv.read().decode('utf-8')) rv.close() return { 'url': resp['html_url'], 'id': resp['id'] } def render_summary(self, include_title=True): """Render the traceback for the interactive console.""" title = '' frames = [] classes = ['traceback'] if not self.frames: classes.append('noframe-traceback') if include_title: if self.is_syntax_error: title = u'Syntax Error' else: title = u'Traceback <em>(most recent call last)</em>:' for frame in self.frames: frames.append(u'<li%s>%s' % ( frame.info and u' title="%s"' % escape(frame.info) or u'', frame.render() )) if self.is_syntax_error: description_wrapper = u'<pre class=syntaxerror>%s</pre>' else: description_wrapper = u'<blockquote>%s</blockquote>' return SUMMARY_HTML % { 'classes': u' '.join(classes), 'title': title and u'<h3>%s</h3>' % title or u'', 'frames': u'\n'.join(frames), 'description': description_wrapper % escape(self.exception) } def render_full(self, evalex=False, secret=None): """Render the Full HTML page with the traceback info.""" exc = escape(self.exception) return PAGE_HTML % { 'evalex': evalex and 'true' or 'false', 'console': 'false', 'title': exc, 'exception': exc, 'exception_type': escape(self.exception_type), 'summary': self.render_summary(include_title=False), 'plaintext': self.plaintext, 'plaintext_cs': re.sub('-{2,}', '-', self.plaintext), 'traceback_id': self.id, 'secret': secret } def generate_plaintext_traceback(self): """Like the plaintext attribute but returns a generator""" yield u'Traceback (most recent call last):' for frame in self.frames: yield u' File "%s", line %s, in %s' % ( frame.filename, frame.lineno, frame.function_name ) yield u' ' + frame.current_line.strip() yield self.exception def plaintext(self): return u'\n'.join(self.generate_plaintext_traceback()) plaintext = cached_property(plaintext) id = property(lambda x: id(x)) class Frame(object): """A single frame in a traceback.""" def __init__(self, exc_type, exc_value, tb): self.lineno = tb.tb_lineno self.function_name = tb.tb_frame.f_code.co_name self.locals = tb.tb_frame.f_locals self.globals = tb.tb_frame.f_globals fn = inspect.getsourcefile(tb) or inspect.getfile(tb) if fn[-4:] in ('.pyo', '.pyc'): fn = fn[:-1] # if it's a file on the file system resolve the real filename. if os.path.isfile(fn): fn = os.path.realpath(fn) self.filename = to_unicode(fn, sys.getfilesystemencoding()) self.module = self.globals.get('__name__') self.loader = self.globals.get('__loader__') self.code = tb.tb_frame.f_code # support for paste's traceback extensions self.hide = self.locals.get('__traceback_hide__', False) info = self.locals.get('__traceback_info__') if info is not None: try: info = text_type(info) except UnicodeError: info = str(info).decode('utf-8', 'replace') self.info = info def render(self): """Render a single frame in a traceback.""" return FRAME_HTML % { 'id': self.id, 'filename': escape(self.filename), 'lineno': self.lineno, 'function_name': escape(self.function_name), 'current_line': escape(self.current_line.strip()) } def get_annotated_lines(self): """Helper function that returns lines with extra information.""" lines = [Line(idx + 1, x) for idx, x in enumerate(self.sourcelines)] # find function definition and mark lines if hasattr(self.code, 'co_firstlineno'): lineno = self.code.co_firstlineno - 1 while lineno > 0: if _funcdef_re.match(lines[lineno].code): break lineno -= 1 try: offset = len(inspect.getblock([x.code + '\n' for x in lines[lineno:]])) except TokenError: offset = 0 for line in lines[lineno:lineno + offset]: line.in_frame = True # mark current line try: lines[self.lineno - 1].current = True except IndexError: pass return lines def render_source(self): """Render the sourcecode.""" return SOURCE_TABLE_HTML % u'\n'.join(line.render() for line in self.get_annotated_lines()) def eval(self, code, mode='single'): """Evaluate code in the context of the frame.""" if isinstance(code, string_types): if PY2 and isinstance(code, unicode): code = UTF8_COOKIE + code.encode('utf-8') code = compile(code, '<interactive>', mode) return eval(code, self.globals, self.locals) @cached_property def sourcelines(self): """The sourcecode of the file as list of unicode strings.""" # get sourcecode from loader or file source = None if self.loader is not None: try: if hasattr(self.loader, 'get_source'): source = self.loader.get_source(self.module) elif hasattr(self.loader, 'get_source_by_code'): source = self.loader.get_source_by_code(self.code) except Exception: # we munch the exception so that we don't cause troubles # if the loader is broken. pass if source is None: try: f = open(self.filename, mode='rb') except IOError: return [] try: source = f.read() finally: f.close() # already unicode? return right away if isinstance(source, text_type): return source.splitlines() # yes. it should be ascii, but we don't want to reject too many # characters in the debugger if something breaks charset = 'utf-8' if source.startswith(UTF8_COOKIE): source = source[3:] else: for idx, match in enumerate(_line_re.finditer(source)): match = _coding_re.search(match.group()) if match is not None: charset = match.group(1) break if idx > 1: break # on broken cookies we fall back to utf-8 too charset = to_native(charset) try: codecs.lookup(charset) except LookupError: charset = 'utf-8' return source.decode(charset, 'replace').splitlines() @property def current_line(self): try: return self.sourcelines[self.lineno - 1] except IndexError: return u'' @cached_property def console(self): return Console(self.globals, self.locals) id = property(lambda x: id(x))
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 1757, 14, 5842, 2537, 272, 18294, 2878, 1714, 339, 961, 859, 6571, 7750, 5190, 4048, 11420, 3423, 14, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 646, 295, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2022, 199, 646, 6485, 199, 646, 5190, 199, 646, 6010, 199, 504, 13343, 492, 8767, 547, 199, 199, 504, 10380, 14, 1208, 492, 6328, 63, 1829, 12, 4772, 199, 504, 10380, 14, 1757, 14, 6614, 492, 19809, 199, 504, 10380, 423, 5819, 492, 1425, 63, 466, 12, 7843, 18, 12, 1318, 63, 466, 12, 1059, 63, 1313, 12, 971, 272, 370, 63, 6106, 12, 370, 63, 2975, 421, 199, 63, 1523, 63, 264, 275, 295, 14, 2014, 8, 3289, 7, 1523, 1491, 29, 7272, 83, 10, 779, 2696, 87, 32455, 5942, 199, 63, 604, 63, 264, 275, 295, 14, 2014, 8, 3289, 4289, 17140, 9, 4, 2229, 77, 5942, 199, 63, 1532, 318, 63, 264, 275, 295, 14, 2014, 8, 82, 31344, 83, 10, 318, 60, 83, 8636, 19276, 2229, 11230, 60, 87, 9, 2734, 8, 26, 6113, 83, 430, 92, 62, 2961, 83, 10, 32, 5942, 199, 6610, 24, 63, 13665, 275, 330, 1154, 9532, 60, 9932, 60, 9566, 7, 199, 199, 2253, 63, 3924, 275, 334, 24738, 12, 13483, 9, 199, 893, 26, 272, 2656, 63, 3924, 847, 334, 7599, 6699, 4258, 199, 2590, 12746, 26, 272, 986, 421, 199, 7311, 275, 399, 891, 1154, 199, 11230, 16556, 4163, 21755, 21486, 55, 19, 35, 501, 21156, 4163, 841, 14, 614, 19894, 1588, 279, 501, 742, 2, 523, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 1360, 20, 15, 320, 3362, 14, 15662, 1743, 199, 28, 1360, 30, 523, 665, 2993, 30, 272, 665, 1213, 19418, 1213, 9, 83, 5001, 22798, 14245, 836, 1108, 1213, 30, 272, 665, 1073, 4668, 628, 15479, 2, 4369, 628, 31, 363, 17612, 363, 29, 5066, 6, 5282, 27, 1760, 29, 1927, 6, 5282, 27, 70, 29, 2487, 14, 3919, 2, 730, 628, 505, 15, 3919, 1743, 272, 28253, 2136, 1929, 370, 1852, 3238, 642, 965, 282, 29139, 880, 626, 314, 14958, 1630, 440, 701, 268, 24634, 6804, 282, 1056, 370, 1182, 22229, 14, 12802, 1314, 5594, 1570, 314, 4223, 268, 1174, 14, 10541, 272, 665, 1073, 4668, 628, 24231, 7016, 2, 4369, 628, 31, 363, 17612, 363, 29, 5066, 6, 5282, 27, 1760, 29, 1927, 6, 5282, 27, 70, 29, 6614, 14, 4524, 1743, 272, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 31, 363, 17612, 363, 29, 5066, 6, 5282, 27, 1760, 29, 1927, 6, 5282, 27, 70, 29, 22324, 14, 3596, 10070, 1579, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 31, 363, 17612, 363, 29, 5066, 6, 5282, 27, 1760, 29, 1927, 6, 5282, 27, 70, 29, 17612, 14, 3596, 10070, 1579, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 1743, 489, 2729, 9074, 4121, 7111, 275, 2818, 6894, 63, 344, 9, 68, 12, 881, 1868, 26792, 63, 6963, 275, 2818, 6614, 9, 83, 12, 881, 662, 3204, 1438, 275, 2818, 6857, 24421, 9, 83, 12, 881, 5795, 11771, 275, 11792, 4731, 9, 83, 11436, 272, 3068, 1579, 30, 523, 3068, 2993, 30, 523, 665, 2030, 30, 272, 665, 3015, 1021, 628, 17612, 1743, 199, 2344, 199, 13046, 1157, 275, 399, 891, 1154, 489, 665, 3015, 1021, 628, 12781, 1743, 267, 699, 7930, 913, 370, 1265, 701, 665, 9370, 1021, 628, 19677, 300, 1743, 36, 615, 7, 52, 510, 879, 948, 1108, 9370, 6244, 2195, 267, 21428, 22798, 13131, 16179, 5190, 12693, 14, 489, 3068, 3015, 30, 272, 3068, 3015, 30, 523, 3068, 2030, 30, 199, 1108, 1360, 30, 199, 2344, 199, 199, 12898, 63, 4943, 275, 13053, 540, 435, 399, 891, 1154, 199, 28, 72, 17, 19418, 1971, 63, 466, 9, 83, 1108, 72, 17, 30, 199, 28, 3015, 1021, 628, 5506, 1743, 523, 665, 80, 1021, 628, 705, 1328, 1743, 2840, 1971, 9, 83, 1108, 80, 30, 199, 1108, 3015, 30, 199, 28, 72, 18, 1021, 628, 6894, 1743, 15905, 665, 5633, 13661, 2786, 8058, 1240, 2061, 15939, 5633, 2957, 72, 18, 30, 199, 2840, 4705, 9, 83, 199, 28, 3015, 1021, 628, 6104, 1743, 523, 665, 964, 1595, 9555, 31, 363, 17612, 363, 29, 5066, 6, 5282, 27, 1760, 29, 16586, 2, 1083, 628, 1932, 1743, 272, 665, 80, 30, 489, 665, 1210, 730, 628, 5642, 2, 536, 628, 3671, 2, 574, 628, 647, 5842, 1743, 489, 961, 365, 314, 11247, 15, 48, 9209, 21428, 1015, 402, 314, 5190, 14, 221, 665, 3751, 489, 1021, 628, 16586, 1188, 1743, 5556, 883, 2597, 20901, 642, 5190, 1901, 489, 282, 665, 65, 4369, 628, 2859, 921, 71, 631, 14, 5031, 14, 957, 26049, 71, 631, 1108, 65, 20020, 489, 665, 1210, 730, 628, 7275, 2, 574, 628, 981, 20901, 10070, 3751, 30, 272, 3068, 80, 30, 272, 665, 20895, 8850, 628, 1400, 2, 4730, 628, 709, 2, 536, 628, 600, 2, 6863, 19418, 17426, 9, 83, 1108, 20895, 30, 523, 3068, 964, 30, 199, 1108, 3015, 30, 199, 28, 3015, 1021, 628, 15228, 1743, 523, 710, 14958, 15604, 376, 1919, 315, 2195, 9279, 4223, 14, 221, 2047, 883, 3063, 523, 3648, 737, 314, 5190, 1314, 29239, 370, 314, 1125, 14, 221, 665, 3751, 1021, 628, 889, 9554, 1743, 523, 982, 1265, 4756, 15250, 1265, 883, 2597, 675, 4722, 4534, 4066, 465, 1233, 523, 6451, 334, 692, 314, 8145, 24421, 3878, 365, 5223, 395, 4834, 13541, 316, 402, 314, 523, 4967, 436, 8298, 1655, 9758, 3751, 30, 199, 1108, 3015, 30, 199, 2344, 435, 27704, 1157, 435, 1449, 199, 25273, 199, 199, 2840, 17426, 63, 1259, 9, 83, 199, 199, 31647, 199, 2344, 199, 199, 31774, 63, 4943, 275, 13053, 540, 435, 399, 891, 1154, 199, 28, 72, 17, 30, 23879, 19809, 1108, 72, 17, 30, 199, 28, 3015, 1021, 628, 15228, 1743, 199, 607, 642, 8559, 1265, 883, 5341, 2018, 8455, 315, 314, 1067, 402, 314, 199, 3578, 14, 221, 710, 2536 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 1757, 14, 5842, 2537, 272, 18294, 2878, 1714, 339, 961, 859, 6571, 7750, 5190, 4048, 11420, 3423, 14, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 646, 295, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2022, 199, 646, 6485, 199, 646, 5190, 199, 646, 6010, 199, 504, 13343, 492, 8767, 547, 199, 199, 504, 10380, 14, 1208, 492, 6328, 63, 1829, 12, 4772, 199, 504, 10380, 14, 1757, 14, 6614, 492, 19809, 199, 504, 10380, 423, 5819, 492, 1425, 63, 466, 12, 7843, 18, 12, 1318, 63, 466, 12, 1059, 63, 1313, 12, 971, 272, 370, 63, 6106, 12, 370, 63, 2975, 421, 199, 63, 1523, 63, 264, 275, 295, 14, 2014, 8, 3289, 7, 1523, 1491, 29, 7272, 83, 10, 779, 2696, 87, 32455, 5942, 199, 63, 604, 63, 264, 275, 295, 14, 2014, 8, 3289, 4289, 17140, 9, 4, 2229, 77, 5942, 199, 63, 1532, 318, 63, 264, 275, 295, 14, 2014, 8, 82, 31344, 83, 10, 318, 60, 83, 8636, 19276, 2229, 11230, 60, 87, 9, 2734, 8, 26, 6113, 83, 430, 92, 62, 2961, 83, 10, 32, 5942, 199, 6610, 24, 63, 13665, 275, 330, 1154, 9532, 60, 9932, 60, 9566, 7, 199, 199, 2253, 63, 3924, 275, 334, 24738, 12, 13483, 9, 199, 893, 26, 272, 2656, 63, 3924, 847, 334, 7599, 6699, 4258, 199, 2590, 12746, 26, 272, 986, 421, 199, 7311, 275, 399, 891, 1154, 199, 11230, 16556, 4163, 21755, 21486, 55, 19, 35, 501, 21156, 4163, 841, 14, 614, 19894, 1588, 279, 501, 742, 2, 523, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 1360, 20, 15, 320, 3362, 14, 15662, 1743, 199, 28, 1360, 30, 523, 665, 2993, 30, 272, 665, 1213, 19418, 1213, 9, 83, 5001, 22798, 14245, 836, 1108, 1213, 30, 272, 665, 1073, 4668, 628, 15479, 2, 4369, 628, 31, 363, 17612, 363, 29, 5066, 6, 5282, 27, 1760, 29, 1927, 6, 5282, 27, 70, 29, 2487, 14, 3919, 2, 730, 628, 505, 15, 3919, 1743, 272, 28253, 2136, 1929, 370, 1852, 3238, 642, 965, 282, 29139, 880, 626, 314, 14958, 1630, 440, 701, 268, 24634, 6804, 282, 1056, 370, 1182, 22229, 14, 12802, 1314, 5594, 1570, 314, 4223, 268, 1174, 14, 10541, 272, 665, 1073, 4668, 628, 24231, 7016, 2, 4369, 628, 31, 363, 17612, 363, 29, 5066, 6, 5282, 27, 1760, 29, 1927, 6, 5282, 27, 70, 29, 6614, 14, 4524, 1743, 272, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 31, 363, 17612, 363, 29, 5066, 6, 5282, 27, 1760, 29, 1927, 6, 5282, 27, 70, 29, 22324, 14, 3596, 10070, 1579, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 31, 363, 17612, 363, 29, 5066, 6, 5282, 27, 1760, 29, 1927, 6, 5282, 27, 70, 29, 17612, 14, 3596, 10070, 1579, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 1743, 489, 2729, 9074, 4121, 7111, 275, 2818, 6894, 63, 344, 9, 68, 12, 881, 1868, 26792, 63, 6963, 275, 2818, 6614, 9, 83, 12, 881, 662, 3204, 1438, 275, 2818, 6857, 24421, 9, 83, 12, 881, 5795, 11771, 275, 11792, 4731, 9, 83, 11436, 272, 3068, 1579, 30, 523, 3068, 2993, 30, 523, 665, 2030, 30, 272, 665, 3015, 1021, 628, 17612, 1743, 199, 2344, 199, 13046, 1157, 275, 399, 891, 1154, 489, 665, 3015, 1021, 628, 12781, 1743, 267, 699, 7930, 913, 370, 1265, 701, 665, 9370, 1021, 628, 19677, 300, 1743, 36, 615, 7, 52, 510, 879, 948, 1108, 9370, 6244, 2195, 267, 21428, 22798, 13131, 16179, 5190, 12693, 14, 489, 3068, 3015, 30, 272, 3068, 3015, 30, 523, 3068, 2030, 30, 199, 1108, 1360, 30, 199, 2344, 199, 199, 12898, 63, 4943, 275, 13053, 540, 435, 399, 891, 1154, 199, 28, 72, 17, 19418, 1971, 63, 466, 9, 83, 1108, 72, 17, 30, 199, 28, 3015, 1021, 628, 5506, 1743, 523, 665, 80, 1021, 628, 705, 1328, 1743, 2840, 1971, 9, 83, 1108, 80, 30, 199, 1108, 3015, 30, 199, 28, 72, 18, 1021, 628, 6894, 1743, 15905, 665, 5633, 13661, 2786, 8058, 1240, 2061, 15939, 5633, 2957, 72, 18, 30, 199, 2840, 4705, 9, 83, 199, 28, 3015, 1021, 628, 6104, 1743, 523, 665, 964, 1595, 9555, 31, 363, 17612, 363, 29, 5066, 6, 5282, 27, 1760, 29, 16586, 2, 1083, 628, 1932, 1743, 272, 665, 80, 30, 489, 665, 1210, 730, 628, 5642, 2, 536, 628, 3671, 2, 574, 628, 647, 5842, 1743, 489, 961, 365, 314, 11247, 15, 48, 9209, 21428, 1015, 402, 314, 5190, 14, 221, 665, 3751, 489, 1021, 628, 16586, 1188, 1743, 5556, 883, 2597, 20901, 642, 5190, 1901, 489, 282, 665, 65, 4369, 628, 2859, 921, 71, 631, 14, 5031, 14, 957, 26049, 71, 631, 1108, 65, 20020, 489, 665, 1210, 730, 628, 7275, 2, 574, 628, 981, 20901, 10070, 3751, 30, 272, 3068, 80, 30, 272, 665, 20895, 8850, 628, 1400, 2, 4730, 628, 709, 2, 536, 628, 600, 2, 6863, 19418, 17426, 9, 83, 1108, 20895, 30, 523, 3068, 964, 30, 199, 1108, 3015, 30, 199, 28, 3015, 1021, 628, 15228, 1743, 523, 710, 14958, 15604, 376, 1919, 315, 2195, 9279, 4223, 14, 221, 2047, 883, 3063, 523, 3648, 737, 314, 5190, 1314, 29239, 370, 314, 1125, 14, 221, 665, 3751, 1021, 628, 889, 9554, 1743, 523, 982, 1265, 4756, 15250, 1265, 883, 2597, 675, 4722, 4534, 4066, 465, 1233, 523, 6451, 334, 692, 314, 8145, 24421, 3878, 365, 5223, 395, 4834, 13541, 316, 402, 314, 523, 4967, 436, 8298, 1655, 9758, 3751, 30, 199, 1108, 3015, 30, 199, 2344, 435, 27704, 1157, 435, 1449, 199, 25273, 199, 199, 2840, 17426, 63, 1259, 9, 83, 199, 199, 31647, 199, 2344, 199, 199, 31774, 63, 4943, 275, 13053, 540, 435, 399, 891, 1154, 199, 28, 72, 17, 30, 23879, 19809, 1108, 72, 17, 30, 199, 28, 3015, 1021, 628, 15228, 1743, 199, 607, 642, 8559, 1265, 883, 5341, 2018, 8455, 315, 314, 1067, 402, 314, 199, 3578, 14, 221, 710, 2536, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
WillGuan105/django
tests/migrations/test_multidb.py
366
6909
import unittest from django.db import connection, migrations, models from django.db.migrations.state import ProjectState from django.test import override_settings from .test_operations import OperationTestBase try: import sqlparse except ImportError: sqlparse = None class AgnosticRouter(object): """ A router that doesn't have an opinion regarding migrating. """ def allow_migrate(self, db, app_label, **hints): return None class MigrateNothingRouter(object): """ A router that doesn't allow migrating. """ def allow_migrate(self, db, app_label, **hints): return False class MigrateEverythingRouter(object): """ A router that always allows migrating. """ def allow_migrate(self, db, app_label, **hints): return True class MigrateWhenFooRouter(object): """ A router that allows migrating depending on a hint. """ def allow_migrate(self, db, app_label, **hints): return hints.get('foo', False) class MultiDBOperationTests(OperationTestBase): multi_db = True def _test_create_model(self, app_label, should_run): """ Tests that CreateModel honours multi-db settings. """ operation = migrations.CreateModel( "Pony", [("id", models.AutoField(primary_key=True))], ) # Test the state alteration project_state = ProjectState() new_state = project_state.clone() operation.state_forwards(app_label, new_state) # Test the database alteration self.assertTableNotExists("%s_pony" % app_label) with connection.schema_editor() as editor: operation.database_forwards(app_label, editor, project_state, new_state) if should_run: self.assertTableExists("%s_pony" % app_label) else: self.assertTableNotExists("%s_pony" % app_label) # And test reversal with connection.schema_editor() as editor: operation.database_backwards(app_label, editor, new_state, project_state) self.assertTableNotExists("%s_pony" % app_label) @override_settings(DATABASE_ROUTERS=[AgnosticRouter()]) def test_create_model(self): """ Test when router doesn't have an opinion (i.e. CreateModel should run). """ self._test_create_model("test_mltdb_crmo", should_run=True) @override_settings(DATABASE_ROUTERS=[MigrateNothingRouter()]) def test_create_model2(self): """ Test when router returns False (i.e. CreateModel shouldn't run). """ self._test_create_model("test_mltdb_crmo2", should_run=False) @override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]) def test_create_model3(self): """ Test when router returns True (i.e. CreateModel should run). """ self._test_create_model("test_mltdb_crmo3", should_run=True) def test_create_model4(self): """ Test multiple routers. """ with override_settings(DATABASE_ROUTERS=[AgnosticRouter(), AgnosticRouter()]): self._test_create_model("test_mltdb_crmo4", should_run=True) with override_settings(DATABASE_ROUTERS=[MigrateNothingRouter(), MigrateEverythingRouter()]): self._test_create_model("test_mltdb_crmo4", should_run=False) with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter(), MigrateNothingRouter()]): self._test_create_model("test_mltdb_crmo4", should_run=True) def _test_run_sql(self, app_label, should_run, hints=None): with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]): project_state = self.set_up_test_model(app_label) sql = """ INSERT INTO {0}_pony (pink, weight) VALUES (1, 3.55); INSERT INTO {0}_pony (pink, weight) VALUES (3, 5.0); """.format(app_label) operation = migrations.RunSQL(sql, hints=hints or {}) # Test the state alteration does nothing new_state = project_state.clone() operation.state_forwards(app_label, new_state) self.assertEqual(new_state, project_state) # Test the database alteration self.assertEqual(project_state.apps.get_model(app_label, "Pony").objects.count(), 0) with connection.schema_editor() as editor: operation.database_forwards(app_label, editor, project_state, new_state) Pony = project_state.apps.get_model(app_label, "Pony") if should_run: self.assertEqual(Pony.objects.count(), 2) else: self.assertEqual(Pony.objects.count(), 0) @unittest.skipIf(sqlparse is None and connection.features.requires_sqlparse_for_splitting, "Missing sqlparse") @override_settings(DATABASE_ROUTERS=[MigrateNothingRouter()]) def test_run_sql(self): self._test_run_sql("test_mltdb_runsql", should_run=False) @unittest.skipIf(sqlparse is None and connection.features.requires_sqlparse_for_splitting, "Missing sqlparse") @override_settings(DATABASE_ROUTERS=[MigrateWhenFooRouter()]) def test_run_sql2(self): self._test_run_sql("test_mltdb_runsql2", should_run=False) self._test_run_sql("test_mltdb_runsql2", should_run=True, hints={'foo': True}) def _test_run_python(self, app_label, should_run, hints=None): with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]): project_state = self.set_up_test_model(app_label) # Create the operation def inner_method(models, schema_editor): Pony = models.get_model(app_label, "Pony") Pony.objects.create(pink=1, weight=3.55) Pony.objects.create(weight=5) operation = migrations.RunPython(inner_method, hints=hints or {}) # Test the state alteration does nothing new_state = project_state.clone() operation.state_forwards(app_label, new_state) self.assertEqual(new_state, project_state) # Test the database alteration self.assertEqual(project_state.apps.get_model(app_label, "Pony").objects.count(), 0) with connection.schema_editor() as editor: operation.database_forwards(app_label, editor, project_state, new_state) Pony = project_state.apps.get_model(app_label, "Pony") if should_run: self.assertEqual(Pony.objects.count(), 2) else: self.assertEqual(Pony.objects.count(), 0) @override_settings(DATABASE_ROUTERS=[MigrateNothingRouter()]) def test_run_python(self): self._test_run_python("test_mltdb_runpython", should_run=False) @override_settings(DATABASE_ROUTERS=[MigrateWhenFooRouter()]) def test_run_python2(self): self._test_run_python("test_mltdb_runpython2", should_run=False) self._test_run_python("test_mltdb_runpython2", should_run=True, hints={'foo': True})
bsd-3-clause
[ 646, 2882, 199, 199, 504, 1639, 14, 697, 492, 1950, 12, 6180, 12, 1709, 199, 504, 1639, 14, 697, 14, 7685, 14, 929, 492, 7290, 2223, 199, 504, 1639, 14, 396, 492, 4278, 63, 1751, 199, 199, 504, 1275, 396, 63, 8170, 492, 17954, 14440, 199, 199, 893, 26, 272, 492, 3875, 1122, 199, 2590, 3545, 26, 272, 3875, 1122, 275, 488, 421, 199, 533, 437, 784, 941, 530, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3181, 1133, 1172, 376, 1687, 262, 1636, 12602, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 488, 421, 199, 533, 28195, 1866, 19627, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3181, 1133, 2040, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 756, 421, 199, 533, 28195, 1866, 24527, 2127, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3544, 6127, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 715, 421, 199, 533, 28195, 1866, 11423, 5686, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 6127, 3952, 10417, 10298, 641, 282, 8328, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 18069, 14, 362, 360, 1421, 297, 756, 9, 421, 199, 533, 6879, 2846, 6044, 2925, 8, 6044, 14440, 304, 272, 3510, 63, 697, 275, 715, 339, 347, 485, 396, 63, 981, 63, 1238, 8, 277, 12, 1145, 63, 1302, 12, 1077, 63, 1065, 304, 267, 408, 267, 6496, 626, 2790, 1685, 394, 265, 16363, 3510, 13, 697, 2202, 14, 267, 408, 267, 3439, 275, 6180, 14, 14907, 8, 288, 298, 24442, 401, 288, 10003, 344, 401, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 25106, 267, 776, 267, 327, 1379, 314, 1174, 741, 5388, 267, 2199, 63, 929, 275, 7290, 2223, 342, 267, 892, 63, 929, 275, 2199, 63, 929, 14, 6311, 342, 267, 3439, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 892, 63, 929, 9, 267, 327, 1379, 314, 3050, 741, 5388, 267, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 3439, 14, 4659, 63, 19159, 8, 571, 63, 1302, 12, 8823, 12, 2199, 63, 929, 12, 892, 63, 929, 9, 267, 340, 1077, 63, 1065, 26, 288, 291, 14, 23550, 7965, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 587, 26, 288, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 327, 6061, 511, 295, 16222, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 3439, 14, 4659, 63, 22269, 8, 571, 63, 1302, 12, 8823, 12, 892, 63, 929, 12, 2199, 63, 929, 9, 267, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 33, 784, 941, 530, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 3181, 1133, 1172, 376, 1687, 262, 1636, 334, 73, 14, 69, 14, 2790, 1685, 1077, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 401, 1077, 63, 1065, 29, 549, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 19627, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 18, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 2529, 756, 334, 73, 14, 69, 14, 2790, 1685, 9296, 1133, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 18, 401, 1077, 63, 1065, 29, 797, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 19, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 2529, 715, 334, 73, 14, 69, 14, 2790, 1685, 1077, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 19, 401, 1077, 63, 1065, 29, 549, 9, 339, 347, 511, 63, 981, 63, 1238, 20, 8, 277, 304, 267, 408, 267, 1379, 3663, 24464, 14, 267, 408, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 33, 784, 941, 530, 11691, 1062, 437, 784, 941, 530, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 549, 9, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 19627, 11691, 1062, 28195, 1866, 24527, 2127, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 797, 9, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 1062, 28195, 1866, 19627, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 549, 9, 339, 347, 485, 396, 63, 1065, 63, 3009, 8, 277, 12, 1145, 63, 1302, 12, 1077, 63, 1065, 12, 18069, 29, 403, 304, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 342, 4682, 288, 2199, 63, 929, 275, 291, 14, 409, 63, 384, 63, 396, 63, 1238, 8, 571, 63, 1302, 9, 398, 3875, 275, 408, 267, 22542, 12872, 469, 16, 12585, 18881, 334, 26591, 12, 5401, 9, 13992, 334, 17, 12, 650, 14, 1229, 2736, 267, 22542, 12872, 469, 16, 12585, 18881, 334, 26591, 12, 5401, 9, 13992, 334, 19, 12, 959, 14, 16, 2736, 267, 30512, 908, 8, 571, 63, 1302, 9, 398, 3439, 275, 6180, 14, 2540, 4657, 8, 3009 ]
[ 2882, 199, 199, 504, 1639, 14, 697, 492, 1950, 12, 6180, 12, 1709, 199, 504, 1639, 14, 697, 14, 7685, 14, 929, 492, 7290, 2223, 199, 504, 1639, 14, 396, 492, 4278, 63, 1751, 199, 199, 504, 1275, 396, 63, 8170, 492, 17954, 14440, 199, 199, 893, 26, 272, 492, 3875, 1122, 199, 2590, 3545, 26, 272, 3875, 1122, 275, 488, 421, 199, 533, 437, 784, 941, 530, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3181, 1133, 1172, 376, 1687, 262, 1636, 12602, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 488, 421, 199, 533, 28195, 1866, 19627, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3181, 1133, 2040, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 756, 421, 199, 533, 28195, 1866, 24527, 2127, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3544, 6127, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 715, 421, 199, 533, 28195, 1866, 11423, 5686, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 6127, 3952, 10417, 10298, 641, 282, 8328, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 18069, 14, 362, 360, 1421, 297, 756, 9, 421, 199, 533, 6879, 2846, 6044, 2925, 8, 6044, 14440, 304, 272, 3510, 63, 697, 275, 715, 339, 347, 485, 396, 63, 981, 63, 1238, 8, 277, 12, 1145, 63, 1302, 12, 1077, 63, 1065, 304, 267, 408, 267, 6496, 626, 2790, 1685, 394, 265, 16363, 3510, 13, 697, 2202, 14, 267, 408, 267, 3439, 275, 6180, 14, 14907, 8, 288, 298, 24442, 401, 288, 10003, 344, 401, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 25106, 267, 776, 267, 327, 1379, 314, 1174, 741, 5388, 267, 2199, 63, 929, 275, 7290, 2223, 342, 267, 892, 63, 929, 275, 2199, 63, 929, 14, 6311, 342, 267, 3439, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 892, 63, 929, 9, 267, 327, 1379, 314, 3050, 741, 5388, 267, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 3439, 14, 4659, 63, 19159, 8, 571, 63, 1302, 12, 8823, 12, 2199, 63, 929, 12, 892, 63, 929, 9, 267, 340, 1077, 63, 1065, 26, 288, 291, 14, 23550, 7965, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 587, 26, 288, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 327, 6061, 511, 295, 16222, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 3439, 14, 4659, 63, 22269, 8, 571, 63, 1302, 12, 8823, 12, 892, 63, 929, 12, 2199, 63, 929, 9, 267, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 33, 784, 941, 530, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 3181, 1133, 1172, 376, 1687, 262, 1636, 334, 73, 14, 69, 14, 2790, 1685, 1077, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 401, 1077, 63, 1065, 29, 549, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 19627, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 18, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 2529, 756, 334, 73, 14, 69, 14, 2790, 1685, 9296, 1133, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 18, 401, 1077, 63, 1065, 29, 797, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 19, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 2529, 715, 334, 73, 14, 69, 14, 2790, 1685, 1077, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 19, 401, 1077, 63, 1065, 29, 549, 9, 339, 347, 511, 63, 981, 63, 1238, 20, 8, 277, 304, 267, 408, 267, 1379, 3663, 24464, 14, 267, 408, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 33, 784, 941, 530, 11691, 1062, 437, 784, 941, 530, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 549, 9, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 19627, 11691, 1062, 28195, 1866, 24527, 2127, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 797, 9, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 1062, 28195, 1866, 19627, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 549, 9, 339, 347, 485, 396, 63, 1065, 63, 3009, 8, 277, 12, 1145, 63, 1302, 12, 1077, 63, 1065, 12, 18069, 29, 403, 304, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 342, 4682, 288, 2199, 63, 929, 275, 291, 14, 409, 63, 384, 63, 396, 63, 1238, 8, 571, 63, 1302, 9, 398, 3875, 275, 408, 267, 22542, 12872, 469, 16, 12585, 18881, 334, 26591, 12, 5401, 9, 13992, 334, 17, 12, 650, 14, 1229, 2736, 267, 22542, 12872, 469, 16, 12585, 18881, 334, 26591, 12, 5401, 9, 13992, 334, 19, 12, 959, 14, 16, 2736, 267, 30512, 908, 8, 571, 63, 1302, 9, 398, 3439, 275, 6180, 14, 2540, 4657, 8, 3009, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
SilverLiningSystems/cxmanage-test
cxmanage_api/decorators.py
4
2599
# pylint: disable=useless-else-on-loop # Copyright (c) 2012-2013, Calxeda 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 Calxeda 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 HOLDERS 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. """ Decorators used in cxmanage_api """ from functools import wraps def retry(count, allowed_errors=Exception): """ Create a decorator that retries a function call up to 'count' times. :param count: Max retry count :type count: integer :param allowed_errors: Types of errors to allow :type allowed_errors: Exception or iterable :return: Function decorator that retries the wrapped function :rtype: function """ try: allowed_errors = tuple(allowed_errors) except TypeError: allowed_errors = (allowed_errors,) def decorator(function): """ The decorator """ @wraps(function) def wrapper(*args, **kwargs): """ The wrapper function """ for _ in range(count): try: return function(*args, **kwargs) except tuple(allowed_errors): pass else: return function(*args, **kwargs) return wrapper return decorator
bsd-3-clause
[ 3, 4287, 26, 3507, 29, 1180, 2003, 13, 2836, 13, 265, 13, 3813, 199, 199, 3, 1898, 334, 67, 9, 6029, 13, 6965, 12, 8256, 7887, 65, 3277, 14, 199, 3, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 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, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 627, 11443, 314, 536, 402, 8256, 7887, 65, 3277, 14, 6590, 314, 1561, 402, 2399, 8417, 199, 3, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 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, 199, 3, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 5877, 8164, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 199, 3, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 199, 3, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 3, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 199, 3, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 199, 3, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 199, 3, 9784, 14, 199, 199, 624, 13966, 269, 2750, 1202, 315, 17280, 9053, 63, 1246, 408, 199, 199, 504, 9143, 492, 14018, 421, 199, 318, 7269, 8, 835, 12, 4370, 63, 2550, 29, 1726, 304, 272, 408, 2790, 282, 7531, 626, 10086, 282, 805, 1240, 1536, 370, 283, 835, 7, 5431, 14, 339, 520, 635, 2338, 26, 8228, 7269, 2338, 272, 520, 466, 2338, 26, 3000, 272, 520, 635, 4370, 63, 2550, 26, 18851, 402, 2552, 370, 2040, 272, 520, 466, 4370, 63, 2550, 26, 2186, 503, 6076, 339, 520, 1107, 26, 6801, 7531, 626, 10086, 314, 8072, 805, 272, 520, 4500, 26, 805, 339, 408, 272, 862, 26, 267, 4370, 63, 2550, 275, 2008, 8, 6541, 63, 2550, 9, 272, 871, 3146, 26, 267, 4370, 63, 2550, 275, 334, 6541, 63, 2550, 4258, 339, 347, 7531, 8, 1593, 304, 267, 408, 710, 7531, 408, 267, 768, 13582, 8, 1593, 9, 267, 347, 4975, 2031, 589, 12, 1011, 958, 304, 288, 408, 710, 4975, 805, 408, 288, 367, 485, 315, 1425, 8, 835, 304, 355, 862, 26, 490, 372, 805, 2031, 589, 12, 1011, 958, 9, 355, 871, 2008, 8, 6541, 63, 2550, 304, 490, 986, 288, 587, 26, 355, 372, 805, 2031, 589, 12, 1011, 958, 9, 398, 372, 4975, 339, 372, 7531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4287, 26, 3507, 29, 1180, 2003, 13, 2836, 13, 265, 13, 3813, 199, 199, 3, 1898, 334, 67, 9, 6029, 13, 6965, 12, 8256, 7887, 65, 3277, 14, 199, 3, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 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, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 627, 11443, 314, 536, 402, 8256, 7887, 65, 3277, 14, 6590, 314, 1561, 402, 2399, 8417, 199, 3, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 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, 199, 3, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 5877, 8164, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 199, 3, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 199, 3, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 3, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 199, 3, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 199, 3, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 199, 3, 9784, 14, 199, 199, 624, 13966, 269, 2750, 1202, 315, 17280, 9053, 63, 1246, 408, 199, 199, 504, 9143, 492, 14018, 421, 199, 318, 7269, 8, 835, 12, 4370, 63, 2550, 29, 1726, 304, 272, 408, 2790, 282, 7531, 626, 10086, 282, 805, 1240, 1536, 370, 283, 835, 7, 5431, 14, 339, 520, 635, 2338, 26, 8228, 7269, 2338, 272, 520, 466, 2338, 26, 3000, 272, 520, 635, 4370, 63, 2550, 26, 18851, 402, 2552, 370, 2040, 272, 520, 466, 4370, 63, 2550, 26, 2186, 503, 6076, 339, 520, 1107, 26, 6801, 7531, 626, 10086, 314, 8072, 805, 272, 520, 4500, 26, 805, 339, 408, 272, 862, 26, 267, 4370, 63, 2550, 275, 2008, 8, 6541, 63, 2550, 9, 272, 871, 3146, 26, 267, 4370, 63, 2550, 275, 334, 6541, 63, 2550, 4258, 339, 347, 7531, 8, 1593, 304, 267, 408, 710, 7531, 408, 267, 768, 13582, 8, 1593, 9, 267, 347, 4975, 2031, 589, 12, 1011, 958, 304, 288, 408, 710, 4975, 805, 408, 288, 367, 485, 315, 1425, 8, 835, 304, 355, 862, 26, 490, 372, 805, 2031, 589, 12, 1011, 958, 9, 355, 871, 2008, 8, 6541, 63, 2550, 304, 490, 986, 288, 587, 26, 355, 372, 805, 2031, 589, 12, 1011, 958, 9, 398, 372, 4975, 339, 372, 7531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
taotie12010/bigfour
lms/djangoapps/shoppingcart/migrations/0027_add_invoice_history.py
102
22387
# -*- coding: 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 'InvoiceHistory' db.create_table('shoppingcart_invoicehistory', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, db_index=True, blank=True)), ('invoice', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['shoppingcart.Invoice'])), ('snapshot', self.gf('django.db.models.fields.TextField')(blank=True)), )) db.send_create_signal('shoppingcart', ['InvoiceHistory']) def backwards(self, orm): # Deleting model 'InvoiceHistory' db.delete_table('shoppingcart_invoicehistory') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'shoppingcart.certificateitem': { 'Meta': {'object_name': 'CertificateItem', '_ormbases': ['shoppingcart.OrderItem']}, 'course_enrollment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['student.CourseEnrollment']"}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '128', 'db_index': 'True'}), 'mode': ('django.db.models.fields.SlugField', [], {'max_length': '50'}), 'orderitem_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shoppingcart.OrderItem']", 'unique': 'True', 'primary_key': 'True'}) }, 'shoppingcart.coupon': { 'Meta': {'object_name': 'Coupon'}, 'code': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255'}), 'created_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2015, 2, 8, 0, 0)'}), 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'expiration_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'percentage_discount': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'shoppingcart.couponredemption': { 'Meta': {'object_name': 'CouponRedemption'}, 'coupon': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Coupon']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'order': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Order']"}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'shoppingcart.courseregcodeitem': { 'Meta': {'object_name': 'CourseRegCodeItem', '_ormbases': ['shoppingcart.OrderItem']}, 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '128', 'db_index': 'True'}), 'mode': ('django.db.models.fields.SlugField', [], {'default': "'honor'", 'max_length': '50'}), 'orderitem_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shoppingcart.OrderItem']", 'unique': 'True', 'primary_key': 'True'}) }, 'shoppingcart.courseregcodeitemannotation': { 'Meta': {'object_name': 'CourseRegCodeItemAnnotation'}, 'annotation': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'unique': 'True', 'max_length': '128', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, 'shoppingcart.courseregistrationcode': { 'Meta': {'object_name': 'CourseRegistrationCode'}, 'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'db_index': 'True'}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255', 'db_index': 'True'}), 'created_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2015, 2, 8, 0, 0)'}), 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_by_user'", 'to': "orm['auth.User']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'invoice': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Invoice']", 'null': 'True'}), 'invoice_item': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.CourseRegistrationCodeInvoiceItem']", 'null': 'True'}), 'mode_slug': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'}), 'order': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'purchase_order'", 'null': 'True', 'to': "orm['shoppingcart.Order']"}) }, 'shoppingcart.courseregistrationcodeinvoiceitem': { 'Meta': {'object_name': 'CourseRegistrationCodeInvoiceItem', '_ormbases': ['shoppingcart.InvoiceItem']}, 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '128', 'db_index': 'True'}), 'invoiceitem_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shoppingcart.InvoiceItem']", 'unique': 'True', 'primary_key': 'True'}) }, 'shoppingcart.donation': { 'Meta': {'object_name': 'Donation', '_ormbases': ['shoppingcart.OrderItem']}, 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255', 'db_index': 'True'}), 'donation_type': ('django.db.models.fields.CharField', [], {'default': "'general'", 'max_length': '32'}), 'orderitem_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shoppingcart.OrderItem']", 'unique': 'True', 'primary_key': 'True'}) }, 'shoppingcart.donationconfiguration': { 'Meta': {'object_name': 'DonationConfiguration'}, 'change_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'changed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'on_delete': 'models.PROTECT'}), 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, 'shoppingcart.invoice': { 'Meta': {'object_name': 'Invoice'}, 'address_line_1': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'address_line_2': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'address_line_3': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), 'company_contact_email': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'company_contact_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'company_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'country': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255', 'db_index': 'True'}), 'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), 'customer_reference_number': ('django.db.models.fields.CharField', [], {'max_length': '63', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'internal_reference': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'is_valid': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), 'recipient_email': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'recipient_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'state': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), 'total_amount': ('django.db.models.fields.FloatField', [], {}), 'zip': ('django.db.models.fields.CharField', [], {'max_length': '15', 'null': 'True'}) }, 'shoppingcart.invoicehistory': { 'Meta': {'object_name': 'InvoiceHistory'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'invoice': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Invoice']"}), 'snapshot': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'timestamp': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}) }, 'shoppingcart.invoiceitem': { 'Meta': {'object_name': 'InvoiceItem'}, 'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), 'currency': ('django.db.models.fields.CharField', [], {'default': "'usd'", 'max_length': '8'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'invoice': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Invoice']"}), 'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), 'qty': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'unit_price': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'max_digits': '30', 'decimal_places': '2'}) }, 'shoppingcart.invoicetransaction': { 'Meta': {'object_name': 'InvoiceTransaction'}, 'amount': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'max_digits': '30', 'decimal_places': '2'}), 'comments': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'currency': ('django.db.models.fields.CharField', [], {'default': "'usd'", 'max_length': '8'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'invoice': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Invoice']"}), 'last_modified_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'last_modified_by_user'", 'to': "orm['auth.User']"}), 'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'started'", 'max_length': '32'}) }, 'shoppingcart.order': { 'Meta': {'object_name': 'Order'}, 'bill_to_cardtype': ('django.db.models.fields.CharField', [], {'max_length': '32', 'blank': 'True'}), 'bill_to_ccnum': ('django.db.models.fields.CharField', [], {'max_length': '8', 'blank': 'True'}), 'bill_to_city': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_country': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_first': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_last': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_postalcode': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), 'bill_to_state': ('django.db.models.fields.CharField', [], {'max_length': '8', 'blank': 'True'}), 'bill_to_street1': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), 'bill_to_street2': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), 'company_contact_email': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'company_contact_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'company_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'currency': ('django.db.models.fields.CharField', [], {'default': "'usd'", 'max_length': '8'}), 'customer_reference_number': ('django.db.models.fields.CharField', [], {'max_length': '63', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'order_type': ('django.db.models.fields.CharField', [], {'default': "'personal'", 'max_length': '32'}), 'processor_reply_dump': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'purchase_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'recipient_email': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'recipient_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'refunded_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'cart'", 'max_length': '32'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'shoppingcart.orderitem': { 'Meta': {'object_name': 'OrderItem'}, 'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), 'currency': ('django.db.models.fields.CharField', [], {'default': "'usd'", 'max_length': '8'}), 'fulfilled_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'line_desc': ('django.db.models.fields.CharField', [], {'default': "'Misc. Item'", 'max_length': '1024'}), 'list_price': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '30', 'decimal_places': '2'}), 'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), 'order': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Order']"}), 'qty': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'refund_requested_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}), 'report_comments': ('django.db.models.fields.TextField', [], {'default': "''"}), 'service_fee': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'max_digits': '30', 'decimal_places': '2'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'cart'", 'max_length': '32', 'db_index': 'True'}), 'unit_cost': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'max_digits': '30', 'decimal_places': '2'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'shoppingcart.paidcourseregistration': { 'Meta': {'object_name': 'PaidCourseRegistration', '_ormbases': ['shoppingcart.OrderItem']}, 'course_enrollment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['student.CourseEnrollment']", 'null': 'True'}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '128', 'db_index': 'True'}), 'mode': ('django.db.models.fields.SlugField', [], {'default': "'honor'", 'max_length': '50'}), 'orderitem_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shoppingcart.OrderItem']", 'unique': 'True', 'primary_key': 'True'}) }, 'shoppingcart.paidcourseregistrationannotation': { 'Meta': {'object_name': 'PaidCourseRegistrationAnnotation'}, 'annotation': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'unique': 'True', 'max_length': '128', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, 'shoppingcart.registrationcoderedemption': { 'Meta': {'object_name': 'RegistrationCodeRedemption'}, 'course_enrollment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['student.CourseEnrollment']", 'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'order': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Order']", 'null': 'True'}), 'redeemed_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2015, 2, 8, 0, 0)', 'null': 'True'}), 'redeemed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'registration_code': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.CourseRegistrationCode']"}) }, 'student.courseenrollment': { 'Meta': {'ordering': "('user', 'course_id')", 'unique_together': "(('user', 'course_id'),)", 'object_name': 'CourseEnrollment'}, 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255', 'db_index': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'mode': ('django.db.models.fields.CharField', [], {'default': "'honor'", 'max_length': '100'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) } } complete_apps = ['shoppingcart']
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 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, 267, 327, 12934, 1402, 283, 21092, 12114, 7, 267, 1592, 14, 981, 63, 1224, 360, 17788, 63, 5404, 5570, 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, 3954, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 12, 1592, 63, 1080, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 5404, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 17788, 14, 21092, 16607, 288, 661, 4753, 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, 17788, 297, 788, 21092, 12114, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 21092, 12114, 7, 267, 1592, 14, 1807, 63, 1224, 360, 17788, 63, 5404, 5570, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 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, 267, 327, 12934, 1402, 283, 21092, 12114, 7, 267, 1592, 14, 981, 63, 1224, 360, 17788, 63, 5404, 5570, 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, 3954, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 12, 1592, 63, 1080, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 5404, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 17788, 14, 21092, 16607, 288, 661, 4753, 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, 17788, 297, 788, 21092, 12114, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 21092, 12114, 7, 267, 1592, 14, 1807, 63, 1224, 360, 17788, 63, 5404, 5570, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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/auth/handlers/modpython.py
436
1899
from mod_python import apache import os def authenhandler(req, **kwargs): """ Authentication handler that checks against Django's auth database. """ # mod_python fakes the environ, and thus doesn't process SetEnv. This fixes # that so that the following import works os.environ.update(req.subprocess_env) # apache 2.2 requires a call to req.get_basic_auth_pw() before # req.user and friends are available. req.get_basic_auth_pw() # check for PythonOptions _str_to_bool = lambda s: s.lower() in ('1', 'true', 'on', 'yes') options = req.get_options() permission_name = options.get('DjangoPermissionName', None) staff_only = _str_to_bool(options.get('DjangoRequireStaffStatus', "on")) superuser_only = _str_to_bool(options.get('DjangoRequireSuperuserStatus', "off")) settings_module = options.get('DJANGO_SETTINGS_MODULE', None) if settings_module: os.environ['DJANGO_SETTINGS_MODULE'] = settings_module from django.contrib.auth.models import User from django import db db.reset_queries() # check that the username is valid kwargs = {'username': req.user, 'is_active': True} if staff_only: kwargs['is_staff'] = True if superuser_only: kwargs['is_superuser'] = True try: try: user = User.objects.get(**kwargs) except User.DoesNotExist: return apache.HTTP_UNAUTHORIZED # check the password and any permission given if user.check_password(req.get_basic_auth_pw()): if permission_name: if user.has_perm(permission_name): return apache.OK else: return apache.HTTP_UNAUTHORIZED else: return apache.OK else: return apache.HTTP_UNAUTHORIZED finally: db.connection.close()
apache-2.0
[ 504, 3413, 63, 1548, 492, 17098, 199, 646, 747, 199, 199, 318, 1790, 287, 2232, 8, 2103, 12, 1011, 958, 304, 272, 408, 272, 15995, 3016, 626, 5920, 6169, 5634, 1159, 1790, 3050, 14, 272, 408, 339, 327, 3413, 63, 1548, 14063, 314, 6160, 12, 436, 12850, 3181, 1133, 2112, 2494, 7744, 14, 221, 961, 25079, 272, 327, 626, 880, 626, 314, 2569, 492, 5419, 272, 747, 14, 2314, 14, 873, 8, 2103, 14, 5781, 63, 1813, 9, 339, 327, 17098, 499, 14, 18, 5074, 282, 1240, 370, 2648, 14, 362, 63, 4316, 63, 1178, 63, 8796, 342, 2544, 5591, 327, 2648, 14, 751, 436, 26157, 787, 2808, 14, 272, 2648, 14, 362, 63, 4316, 63, 1178, 63, 8796, 342, 339, 327, 1104, 367, 2018, 4558, 272, 485, 495, 63, 475, 63, 2245, 275, 2400, 308, 26, 308, 14, 2325, 342, 315, 661, 17, 297, 283, 2052, 297, 283, 265, 297, 283, 5066, 358, 339, 1511, 275, 2648, 14, 362, 63, 1419, 342, 272, 4983, 63, 354, 275, 1511, 14, 362, 360, 9323, 7980, 985, 297, 488, 9, 272, 12622, 63, 2118, 275, 485, 495, 63, 475, 63, 2245, 8, 1419, 14, 362, 360, 9323, 13902, 18963, 3694, 297, 298, 265, 2237, 272, 32590, 63, 2118, 275, 485, 495, 63, 475, 63, 2245, 8, 1419, 14, 362, 360, 9323, 13902, 11823, 751, 3694, 297, 298, 1997, 2237, 272, 2202, 63, 578, 275, 1511, 14, 362, 360, 22848, 63, 13931, 63, 10001, 297, 488, 9, 272, 340, 2202, 63, 578, 26, 267, 747, 14, 2314, 459, 22848, 63, 13931, 63, 10001, 418, 275, 2202, 63, 578, 339, 687, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 272, 687, 1639, 492, 1592, 272, 1592, 14, 3958, 63, 10590, 342, 339, 327, 1104, 626, 314, 3434, 365, 1686, 272, 2074, 275, 791, 2473, 356, 2648, 14, 751, 12, 283, 374, 63, 2682, 356, 715, 93, 272, 340, 12622, 63, 2118, 26, 267, 2074, 459, 374, 63, 7018, 418, 275, 715, 272, 340, 32590, 63, 2118, 26, 267, 2074, 459, 374, 63, 11434, 418, 275, 715, 272, 862, 26, 267, 862, 26, 288, 922, 275, 2876, 14, 1462, 14, 362, 3682, 958, 9, 267, 871, 2876, 14, 7400, 26, 288, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 13857, 327, 1104, 314, 2505, 436, 1263, 4983, 1627, 267, 340, 922, 14, 1074, 63, 2060, 8, 2103, 14, 362, 63, 4316, 63, 1178, 63, 8796, 5109, 288, 340, 4983, 63, 354, 26, 355, 340, 922, 14, 1989, 63, 8220, 8, 5693, 63, 354, 304, 490, 372, 17098, 14, 3593, 355, 587, 26, 490, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 288, 587, 26, 355, 372, 17098, 14, 3593, 267, 587, 26, 288, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 272, 3753, 26, 267, 1592, 14, 2105, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3413, 63, 1548, 492, 17098, 199, 646, 747, 199, 199, 318, 1790, 287, 2232, 8, 2103, 12, 1011, 958, 304, 272, 408, 272, 15995, 3016, 626, 5920, 6169, 5634, 1159, 1790, 3050, 14, 272, 408, 339, 327, 3413, 63, 1548, 14063, 314, 6160, 12, 436, 12850, 3181, 1133, 2112, 2494, 7744, 14, 221, 961, 25079, 272, 327, 626, 880, 626, 314, 2569, 492, 5419, 272, 747, 14, 2314, 14, 873, 8, 2103, 14, 5781, 63, 1813, 9, 339, 327, 17098, 499, 14, 18, 5074, 282, 1240, 370, 2648, 14, 362, 63, 4316, 63, 1178, 63, 8796, 342, 2544, 5591, 327, 2648, 14, 751, 436, 26157, 787, 2808, 14, 272, 2648, 14, 362, 63, 4316, 63, 1178, 63, 8796, 342, 339, 327, 1104, 367, 2018, 4558, 272, 485, 495, 63, 475, 63, 2245, 275, 2400, 308, 26, 308, 14, 2325, 342, 315, 661, 17, 297, 283, 2052, 297, 283, 265, 297, 283, 5066, 358, 339, 1511, 275, 2648, 14, 362, 63, 1419, 342, 272, 4983, 63, 354, 275, 1511, 14, 362, 360, 9323, 7980, 985, 297, 488, 9, 272, 12622, 63, 2118, 275, 485, 495, 63, 475, 63, 2245, 8, 1419, 14, 362, 360, 9323, 13902, 18963, 3694, 297, 298, 265, 2237, 272, 32590, 63, 2118, 275, 485, 495, 63, 475, 63, 2245, 8, 1419, 14, 362, 360, 9323, 13902, 11823, 751, 3694, 297, 298, 1997, 2237, 272, 2202, 63, 578, 275, 1511, 14, 362, 360, 22848, 63, 13931, 63, 10001, 297, 488, 9, 272, 340, 2202, 63, 578, 26, 267, 747, 14, 2314, 459, 22848, 63, 13931, 63, 10001, 418, 275, 2202, 63, 578, 339, 687, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 272, 687, 1639, 492, 1592, 272, 1592, 14, 3958, 63, 10590, 342, 339, 327, 1104, 626, 314, 3434, 365, 1686, 272, 2074, 275, 791, 2473, 356, 2648, 14, 751, 12, 283, 374, 63, 2682, 356, 715, 93, 272, 340, 12622, 63, 2118, 26, 267, 2074, 459, 374, 63, 7018, 418, 275, 715, 272, 340, 32590, 63, 2118, 26, 267, 2074, 459, 374, 63, 11434, 418, 275, 715, 272, 862, 26, 267, 862, 26, 288, 922, 275, 2876, 14, 1462, 14, 362, 3682, 958, 9, 267, 871, 2876, 14, 7400, 26, 288, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 13857, 327, 1104, 314, 2505, 436, 1263, 4983, 1627, 267, 340, 922, 14, 1074, 63, 2060, 8, 2103, 14, 362, 63, 4316, 63, 1178, 63, 8796, 5109, 288, 340, 4983, 63, 354, 26, 355, 340, 922, 14, 1989, 63, 8220, 8, 5693, 63, 354, 304, 490, 372, 17098, 14, 3593, 355, 587, 26, 490, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 288, 587, 26, 355, 372, 17098, 14, 3593, 267, 587, 26, 288, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 272, 3753, 26, 267, 1592, 14, 2105, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
stormi/tsunami
src/secondaires/familier/editeurs/famedit/__init__.py
1
6790
# -*-coding:Utf-8 -* # Copyright (c) 2014 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder 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. """Package contenant l'éditeur 'famedit'. Si des redéfinitions de contexte-éditeur standard doivent être faites, elles seront placées dans ce package """ from primaires.interpreteur.editeur.choix import Choix from primaires.interpreteur.editeur.flag import Flag from primaires.interpreteur.editeur.entier import Entier from primaires.interpreteur.editeur.presentation import Presentation from primaires.interpreteur.editeur.selection import Selection from primaires.interpreteur.editeur.uniligne import Uniligne from primaires.scripting.editeurs.edt_script import EdtScript from secondaires.familier.constantes import * class EdtFamedit(Presentation): """Classe définissant l'éditeur de fiche de familier famedit.""" nom = "famedit" def __init__(self, personnage, fiche): """Constructeur de l'éditeur""" if personnage: instance_connexion = personnage.instance_connexion else: instance_connexion = None Presentation.__init__(self, instance_connexion, fiche) if personnage and fiche: self.construire(fiche) def __getnewargs__(self): return (None, None) def construire(self, fiche): """Construction de l'éditeur""" # Régimes regime = self.ajouter_choix("régime alimentaire", "r", Choix, fiche, "regime", REGIMES) regime.parent = self regime.prompt = "Régime alimentaire du familier : " regime.apercu = "{objet.regime}" regime.aide_courte = \ "Entrez le |ent|régime|ff| du familier ou |cmd|/|ff| pour revenir " \ "à la fenêtre parente.\n\nRégimes disponibles : {}.\n\n" \ "Régime actuel : |bc|{{objet.regime}}|ff|".format( ", ".join(REGIMES)) # Harnachements supportés harnachements = self.ajouter_choix("harnachement supportés", "h", Selection, fiche, "harnachements", TYPES_HARNACHEMENT) harnachements.parent = self harnachements.prompt = "Harnachements supportés : " harnachements.apercu = "{objet.str_harnachements}" harnachements.aide_courte = \ "Entrez un |ent|harnachement supporté|ff| pour l'ajouter " \ "ou le retirer\nou |cmd|/|ff| pour revenir à la fenêtre " \ "parente.\n\nHarnachements possibles : " + \ ", ".join(sorted(TYPES_HARNACHEMENT)) + "\nHarnachements " \ "supportés actuellement : {objet.str_harnachements}" # Stats pouvant progresser stats = self.ajouter_choix("stats pouvant progresser", "st", Selection, fiche, "stats_progres", ["force", "agilite", "robustesse", "intelligence", "charisme", "sensibilite"]) stats.parent = self stats.prompt = "Stats pouvant augmenter automatiquement : " stats.apercu = "{objet.str_stats_progres}" stats.aide_courte = \ "Entrez un |ent|nom de stat|ff| pour l'ajouter " \ "ou le retirer\nou |cmd|/|ff| pour revenir à la fenêtre " \ "parente.\n\nQuand le familier gagne un niveau, il va " \ "choisir aléatoirement parmi ces stats et les\naugmenter " \ "si il a des points d'entraînement disponibles\n\nStats " \ "automatiques actuelles : {objet.str_stats_progres}" # Monture monture = self.ajouter_choix("peut être monté", "m", Flag, fiche, "monture") monture.parent = self # Sorties verticales verticales = self.ajouter_choix( "peut emprunter les sorties verticales", "v", Flag, fiche, "sorties_verticales") verticales.parent = self # Aller en intérieur interieur = self.ajouter_choix("peut aller en intérieur", "l", Flag, fiche, "aller_interieur") interieur.parent = self # Difficulté d'apprivoisement difficulte = self.ajouter_choix("difficulté d'apprivoisement", "d", Entier, fiche, "difficulte_apprivoisement") difficulte.parent = self difficulte.apercu = "{objet.difficulte_apprivoisement}%" difficulte.prompt = "Entrez la difficulté d'apprivoisement du " \ "familier : " difficulte.aide_courte = \ "Entrez |ent|la difficulté d'apprivoisement|ff| du familier\n" \ "(entre |ent|1|ff| et |ent|100|ff|) ou |cmd|/|ff| pour " \ "revenir à la fenêtre parente.\n\nDifficulté actuelle : " \ "{objet.difficulte_apprivoisement}%" # Prix unitaire prix = self.ajouter_choix("prix unitaire", "u", Entier, fiche, "m_valeur") prix.parent = self prix.apercu = "{objet.m_valeur} pièces de bronze" prix.prompt = "Entrez le prix unitaire du familier : " prix.aide_courte = \ "Entrez |ent|le prix unitaire|ff| du familier" \ "ou |cmd|/|ff| pour revenir à la fenêtre parente.\n\n" \ "Prix unitaire actuel : {objet.m_valeur}" # Script scripts = self.ajouter_choix("scripts", "sc", EdtScript, fiche.script) scripts.parent = self
bsd-3-clause
[ 3, 1882, 1523, 26, 11561, 13, 24, 446, 10, 199, 199, 3, 1898, 334, 67, 9, 6927, 6124, 598, 7517, 28882, 2946, 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, 7647, 26, 199, 3, 199, 3, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 257, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 257, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 257, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 627, 11443, 314, 536, 402, 314, 4248, 16712, 6590, 314, 1561, 402, 2399, 8417, 199, 3, 257, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 257, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 6483, 6262, 199, 3, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 199, 3, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 199, 3, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 199, 3, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 199, 3, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 199, 3, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 199, 3, 9726, 1634, 9712, 9784, 14, 421, 199, 624, 8599, 406, 4647, 634, 7, 5741, 328, 266, 300, 283, 70, 313, 1741, 1370, 199, 199, 18934, 18618, 8992, 5741, 7295, 852, 477, 406, 3858, 266, 13, 5741, 328, 266, 300, 4465, 886, 73, 782, 13333, 104, 18468, 1433, 4033, 12, 579, 2978, 199, 332, 1888, 299, 416, 67, 5741, 397, 366, 796, 10142, 2559, 199, 199, 624, 199, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 2239, 1148, 492, 8802, 1148, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 4173, 492, 18241, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 287, 13949, 492, 3447, 13949, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 31993, 492, 5543, 1150, 425, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 5592, 492, 3240, 1486, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 324, 1638, 71, 685, 492, 1910, 1638, 71, 685, 199, 504, 1979, 391, 73, 470, 14, 1579, 316, 14, 6297, 266, 21050, 14, 379, 84, 63, 1579, 492, 662, 3583, 5229, 199, 504, 542, 23463, 73, 470, 14, 18493, 1638, 281, 14, 1297, 290, 744, 492, 627, 199, 199, 533, 662, 3583, 38, 313, 1741, 8, 19794, 425, 304, 339, 408, 1968, 305, 261, 366, 5741, 2408, 19857, 867, 634, 7, 5741, 328, 266, 300, 477, 5883, 595, 477, 21450, 1638, 281, 289, 313, 1741, 1041, 339, 17468, 275, 298, 70, 313, 1741, 2, 339, 347, 636, 826, 721, 277, 12, 4954, 78, 474, 12, 5883, 595, 304, 267, 408, 714, 9853, 266, 300, 477, 634, 7, 5741, 328, 266, 300, 624, 267, 340, 4954, 78, 474, 26, 288, 1256, 63, 1631, 476, 1636, 275, 4954, 78, 474, 14, 842, 63, 1631, 476, 1636, 267, 587, 26, 288, 1256, 63, 1631, 476, 1636, 275, 488, 398, 5543, 1150, 425, 855, 826, 721, 277, 12, 1256, 63, 1631, 476, 1636, 12, 5883, 595, 9, 267, 340, 4954, 78, 474, 436, 5883, 595, 26, 288, 291, 14, 388, 1281, 3621, 8, 329, 595, 9, 339, 347, 636, 18768, 589, 721, 277, 304, 267, 372, 334, 403, 12, 488, 9, 339, 347, 406, 1281, 3621, 8, 277, 12, 5883, 595, 304, 267, 408, 10264, 477, 634, 7, 5741, 328, 266, 300, 624, 267, 327, 820, 5741, 71, 29778, 267, 1295, 1036, 275, 291, 14, 65, 743, 2699, 63, 2239, 1148, 480, 82, 5741, 71, 1036, 21165, 434, 65, 3621, 401, 298, 82, 401, 8802, 1148, 12, 5883, 595, 12, 355, 298, 1135, 1036, 401, 14142, 1469, 654, 9, 267, 1295, 1036, 14, 1708, 275, 291, 267, 1295, 1036, 14, 7650, 275, 298, 50, 5741, 71, 1036, 21165, 434, 65, 3621, 15776, 21450, 1638, 281, 520, 298, 267, 1295, 1036, 14, 9804, 15140, 275, 5310, 1113, 386, 14, 1135, 1036, 7063, 267, 1295, 1036, 14, 65, 2655, 63, 25715, 266, 275, 971, 288, 298, 11154, 25409, 1026, 1204, 484, 92, 82, 5741, 71, 1036, 92, 556, 92, 15776, 21450, 1638, 281, 29934, 1204, 1760, 92, 15, 92, 556, 92, 299, 567, 295, 1856, 723, 298, 971, 288, 298, 26482, 1127, 289, 287, 28413, 18468, 13566, 266, 3134, 78, 60, 78, 50, 5741, 71, 29778, 2153, 678, 7247, 83, 520, 1052, 3134, 78, 60, 78, 2, 971, 288, 298, 50, 5741, 71, 1036, 2454, 13086, 520, 1204, 3776, 92, 3638, 1113, 386, 14, 1135, 1036, 4863, 92, 556, 92, 1674, 908, 8, 288, 3872, 3680, 904, 8, 5616, 1469, 654, 430, 398, 327, 869, 1060, 21481, 1470, 2291, 5741, 83, 267, 394, 1060, 21481, 1470, 275, 291, 14, 65, 743, 2699, 63, 2239, 1148, 480, 72, 1060, 21481, 434, 2291, 5741, 83, 401, 298, 72, 401, 355, 3240, 1486, 12, 5883, 595, 12, 298, 72, 1060, 21481, 1470, 401, 32317, 63, 30958, 7170, 1244, 9591, 9, 267, 394, 1060, 21481, 1470, 14, 1708, 275, 291, 267, 394, 1060, 21481, 1470, 14, 7650, 275, 298, 40, 1060, 21481, 1470, 2291, 5741, 83, 520, 298, 267, 394, 1060, 21481, 1470, 14, 9804, 15140, 275 ]
[ 1882, 1523, 26, 11561, 13, 24, 446, 10, 199, 199, 3, 1898, 334, 67, 9, 6927, 6124, 598, 7517, 28882, 2946, 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, 7647, 26, 199, 3, 199, 3, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 257, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 257, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 257, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 627, 11443, 314, 536, 402, 314, 4248, 16712, 6590, 314, 1561, 402, 2399, 8417, 199, 3, 257, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 257, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 6483, 6262, 199, 3, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 199, 3, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 199, 3, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 199, 3, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 199, 3, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 199, 3, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 199, 3, 9726, 1634, 9712, 9784, 14, 421, 199, 624, 8599, 406, 4647, 634, 7, 5741, 328, 266, 300, 283, 70, 313, 1741, 1370, 199, 199, 18934, 18618, 8992, 5741, 7295, 852, 477, 406, 3858, 266, 13, 5741, 328, 266, 300, 4465, 886, 73, 782, 13333, 104, 18468, 1433, 4033, 12, 579, 2978, 199, 332, 1888, 299, 416, 67, 5741, 397, 366, 796, 10142, 2559, 199, 199, 624, 199, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 2239, 1148, 492, 8802, 1148, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 4173, 492, 18241, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 287, 13949, 492, 3447, 13949, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 31993, 492, 5543, 1150, 425, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 5592, 492, 3240, 1486, 199, 504, 1979, 391, 73, 470, 14, 12108, 266, 300, 14, 6297, 266, 300, 14, 324, 1638, 71, 685, 492, 1910, 1638, 71, 685, 199, 504, 1979, 391, 73, 470, 14, 1579, 316, 14, 6297, 266, 21050, 14, 379, 84, 63, 1579, 492, 662, 3583, 5229, 199, 504, 542, 23463, 73, 470, 14, 18493, 1638, 281, 14, 1297, 290, 744, 492, 627, 199, 199, 533, 662, 3583, 38, 313, 1741, 8, 19794, 425, 304, 339, 408, 1968, 305, 261, 366, 5741, 2408, 19857, 867, 634, 7, 5741, 328, 266, 300, 477, 5883, 595, 477, 21450, 1638, 281, 289, 313, 1741, 1041, 339, 17468, 275, 298, 70, 313, 1741, 2, 339, 347, 636, 826, 721, 277, 12, 4954, 78, 474, 12, 5883, 595, 304, 267, 408, 714, 9853, 266, 300, 477, 634, 7, 5741, 328, 266, 300, 624, 267, 340, 4954, 78, 474, 26, 288, 1256, 63, 1631, 476, 1636, 275, 4954, 78, 474, 14, 842, 63, 1631, 476, 1636, 267, 587, 26, 288, 1256, 63, 1631, 476, 1636, 275, 488, 398, 5543, 1150, 425, 855, 826, 721, 277, 12, 1256, 63, 1631, 476, 1636, 12, 5883, 595, 9, 267, 340, 4954, 78, 474, 436, 5883, 595, 26, 288, 291, 14, 388, 1281, 3621, 8, 329, 595, 9, 339, 347, 636, 18768, 589, 721, 277, 304, 267, 372, 334, 403, 12, 488, 9, 339, 347, 406, 1281, 3621, 8, 277, 12, 5883, 595, 304, 267, 408, 10264, 477, 634, 7, 5741, 328, 266, 300, 624, 267, 327, 820, 5741, 71, 29778, 267, 1295, 1036, 275, 291, 14, 65, 743, 2699, 63, 2239, 1148, 480, 82, 5741, 71, 1036, 21165, 434, 65, 3621, 401, 298, 82, 401, 8802, 1148, 12, 5883, 595, 12, 355, 298, 1135, 1036, 401, 14142, 1469, 654, 9, 267, 1295, 1036, 14, 1708, 275, 291, 267, 1295, 1036, 14, 7650, 275, 298, 50, 5741, 71, 1036, 21165, 434, 65, 3621, 15776, 21450, 1638, 281, 520, 298, 267, 1295, 1036, 14, 9804, 15140, 275, 5310, 1113, 386, 14, 1135, 1036, 7063, 267, 1295, 1036, 14, 65, 2655, 63, 25715, 266, 275, 971, 288, 298, 11154, 25409, 1026, 1204, 484, 92, 82, 5741, 71, 1036, 92, 556, 92, 15776, 21450, 1638, 281, 29934, 1204, 1760, 92, 15, 92, 556, 92, 299, 567, 295, 1856, 723, 298, 971, 288, 298, 26482, 1127, 289, 287, 28413, 18468, 13566, 266, 3134, 78, 60, 78, 50, 5741, 71, 29778, 2153, 678, 7247, 83, 520, 1052, 3134, 78, 60, 78, 2, 971, 288, 298, 50, 5741, 71, 1036, 2454, 13086, 520, 1204, 3776, 92, 3638, 1113, 386, 14, 1135, 1036, 4863, 92, 556, 92, 1674, 908, 8, 288, 3872, 3680, 904, 8, 5616, 1469, 654, 430, 398, 327, 869, 1060, 21481, 1470, 2291, 5741, 83, 267, 394, 1060, 21481, 1470, 275, 291, 14, 65, 743, 2699, 63, 2239, 1148, 480, 72, 1060, 21481, 434, 2291, 5741, 83, 401, 298, 72, 401, 355, 3240, 1486, 12, 5883, 595, 12, 298, 72, 1060, 21481, 1470, 401, 32317, 63, 30958, 7170, 1244, 9591, 9, 267, 394, 1060, 21481, 1470, 14, 1708, 275, 291, 267, 394, 1060, 21481, 1470, 14, 7650, 275, 298, 40, 1060, 21481, 1470, 2291, 5741, 83, 520, 298, 267, 394, 1060, 21481, 1470, 14, 9804, 15140, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shskyinfo/android_kernel_lge_e610
scripts/build-all.py
1250
9474
#! /usr/bin/env python # Copyright (c) 2009-2011, Code Aurora Forum. 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 Code Aurora nor # the names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Build the kernel for all targets using the Android build environment. # # TODO: Accept arguments to indicate what to build. import glob from optparse import OptionParser import subprocess import os import os.path import shutil import sys version = 'build-all.py, version 0.01' build_dir = '../all-kernels' make_command = ["vmlinux", "modules"] make_env = os.environ make_env.update({ 'ARCH': 'arm', 'CROSS_COMPILE': 'arm-none-linux-gnueabi-', 'KCONFIG_NOTIMESTAMP': 'true' }) all_options = {} def error(msg): sys.stderr.write("error: %s\n" % msg) def fail(msg): """Fail with a user-printed message""" error(msg) sys.exit(1) def check_kernel(): """Ensure that PWD is a kernel directory""" if (not os.path.isfile('MAINTAINERS') or not os.path.isfile('arch/arm/mach-msm/Kconfig')): fail("This doesn't seem to be an MSM kernel dir") def check_build(): """Ensure that the build directory is present.""" if not os.path.isdir(build_dir): try: os.makedirs(build_dir) except OSError as exc: if exc.errno == errno.EEXIST: pass else: raise def update_config(file, str): print 'Updating %s with \'%s\'\n' % (file, str) defconfig = open(file, 'a') defconfig.write(str + '\n') defconfig.close() def scan_configs(): """Get the full list of defconfigs appropriate for this tree.""" names = {} for n in glob.glob('arch/arm/configs/[fm]sm[0-9-]*_defconfig'): names[os.path.basename(n)[:-10]] = n for n in glob.glob('arch/arm/configs/qsd*_defconfig'): names[os.path.basename(n)[:-10]] = n for n in glob.glob('arch/arm/configs/apq*_defconfig'): names[os.path.basename(n)[:-10]] = n return names class Builder: def __init__(self, logname): self.logname = logname self.fd = open(logname, 'w') def run(self, args): devnull = open('/dev/null', 'r') proc = subprocess.Popen(args, stdin=devnull, env=make_env, bufsize=0, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) count = 0 # for line in proc.stdout: rawfd = proc.stdout.fileno() while True: line = os.read(rawfd, 1024) if not line: break self.fd.write(line) self.fd.flush() if all_options.verbose: sys.stdout.write(line) sys.stdout.flush() else: for i in range(line.count('\n')): count += 1 if count == 64: count = 0 print sys.stdout.write('.') sys.stdout.flush() print result = proc.wait() self.fd.close() return result failed_targets = [] def build(target): dest_dir = os.path.join(build_dir, target) log_name = '%s/log-%s.log' % (build_dir, target) print 'Building %s in %s log %s' % (target, dest_dir, log_name) if not os.path.isdir(dest_dir): os.mkdir(dest_dir) defconfig = 'arch/arm/configs/%s_defconfig' % target dotconfig = '%s/.config' % dest_dir savedefconfig = '%s/defconfig' % dest_dir shutil.copyfile(defconfig, dotconfig) devnull = open('/dev/null', 'r') subprocess.check_call(['make', 'O=%s' % dest_dir, '%s_defconfig' % target], env=make_env, stdin=devnull) devnull.close() if not all_options.updateconfigs: build = Builder(log_name) result = build.run(['make', 'O=%s' % dest_dir] + make_command) if result != 0: if all_options.keep_going: failed_targets.append(target) fail_or_error = error else: fail_or_error = fail fail_or_error("Failed to build %s, see %s" % (target, build.logname)) # Copy the defconfig back. if all_options.configs or all_options.updateconfigs: devnull = open('/dev/null', 'r') subprocess.check_call(['make', 'O=%s' % dest_dir, 'savedefconfig'], env=make_env, stdin=devnull) devnull.close() shutil.copyfile(savedefconfig, defconfig) def build_many(allconf, targets): print "Building %d target(s)" % len(targets) for target in targets: if all_options.updateconfigs: update_config(allconf[target], all_options.updateconfigs) build(target) if failed_targets: fail('\n '.join(["Failed targets:"] + [target for target in failed_targets])) def main(): global make_command check_kernel() check_build() configs = scan_configs() usage = (""" %prog [options] all -- Build all targets %prog [options] target target ... -- List specific targets %prog [options] perf -- Build all perf targets %prog [options] noperf -- Build all non-perf targets""") parser = OptionParser(usage=usage, version=version) parser.add_option('--configs', action='store_true', dest='configs', help="Copy configs back into tree") parser.add_option('--list', action='store_true', dest='list', help='List available targets') parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='Output to stdout in addition to log file') parser.add_option('--oldconfig', action='store_true', dest='oldconfig', help='Only process "make oldconfig"') parser.add_option('--updateconfigs', dest='updateconfigs', help="Update defconfigs with provided option setting, " "e.g. --updateconfigs=\'CONFIG_USE_THING=y\'") parser.add_option('-j', '--jobs', type='int', dest="jobs", help="Number of simultaneous jobs") parser.add_option('-l', '--load-average', type='int', dest='load_average', help="Don't start multiple jobs unless load is below LOAD_AVERAGE") parser.add_option('-k', '--keep-going', action='store_true', dest='keep_going', default=False, help="Keep building other targets if a target fails") parser.add_option('-m', '--make-target', action='append', help='Build the indicated make target (default: %s)' % ' '.join(make_command)) (options, args) = parser.parse_args() global all_options all_options = options if options.list: print "Available targets:" for target in configs.keys(): print " %s" % target sys.exit(0) if options.oldconfig: make_command = ["oldconfig"] elif options.make_target: make_command = options.make_target if options.jobs: make_command.append("-j%d" % options.jobs) if options.load_average: make_command.append("-l%d" % options.load_average) if args == ['all']: build_many(configs, configs.keys()) elif args == ['perf']: targets = [] for t in configs.keys(): if "perf" in t: targets.append(t) build_many(configs, targets) elif args == ['noperf']: targets = [] for t in configs.keys(): if "perf" not in t: targets.append(t) build_many(configs, targets) elif len(args) > 0: targets = [] for t in args: if t not in configs.keys(): parser.error("Target '%s' not one of %s" % (t, configs.keys())) targets.append(t) build_many(configs, targets) else: parser.error("Must specify a target to build, or 'all'") if __name__ == "__main__": main()
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 8937, 13, 8128, 12, 5495, 437, 300, 11131, 2104, 453, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 5495, 437, 300, 11131, 6590, 199, 3, 755, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 755, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 755, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 11214, 13, 12799, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 6516, 314, 5114, 367, 1006, 4545, 1808, 314, 14694, 1900, 3734, 14, 199, 3, 199, 3, 3254, 26, 15506, 2368, 370, 6623, 4052, 370, 1900, 14, 199, 199, 646, 5739, 199, 504, 8691, 492, 13491, 199, 646, 3873, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 5145, 199, 646, 984, 199, 199, 1023, 275, 283, 1506, 13, 452, 14, 647, 12, 1015, 378, 14, 614, 7, 199, 199, 1506, 63, 694, 275, 20644, 452, 13, 29824, 7, 199, 1875, 63, 1531, 275, 2097, 2611, 5135, 401, 298, 3112, 937, 199, 1875, 63, 1813, 275, 747, 14, 2314, 199, 1875, 63, 1813, 14, 873, 2561, 267, 283, 7762, 356, 283, 5362, 297, 267, 283, 28368, 63, 29911, 356, 283, 5362, 13, 3592, 13, 5135, 13, 784, 310, 14677, 14382, 267, 283, 43, 5569, 63, 4609, 1469, 16260, 356, 283, 2052, 7, 3828, 199, 452, 63, 1419, 275, 1052, 199, 199, 318, 1125, 8, 1328, 304, 272, 984, 14, 3083, 14, 952, 480, 705, 26, 450, 83, 60, 78, 2, 450, 1499, 9, 199, 199, 318, 2449, 8, 1328, 304, 272, 408, 4874, 543, 282, 922, 13, 27131, 1245, 624, 272, 1125, 8, 1328, 9, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 318, 1104, 63, 4989, 837, 272, 408, 13913, 626, 510, 16698, 365, 282, 5114, 2082, 624, 272, 340, 334, 1397, 747, 14, 515, 14, 6292, 360, 2054, 2919, 9021, 3960, 358, 503, 267, 440, 747, 14, 515, 14, 6292, 360, 1047, 15, 5362, 15, 14121, 13, 706, 77, 15, 28033, 8109, 267, 2449, 480, 2765, 3181, 1133, 17021, 370, 506, 376, 603, 4029, 5114, 2935, 531, 199, 199, 318, 1104, 63, 1506, 837, 272, 408, 13913, 626, 314, 1900, 2082, 365, 3451, 1041, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 1506, 63, 694, 304, 267, 862, 26, 288, 747, 14, 8347, 8, 1506, 63, 694, 9, 267, 871, 6440, 465, 3178, 26, 288, 340, 3178, 14, 7931, 508, 7554, 14, 28596, 26, 355, 986, 288, 587, 26, 355, 746, 199, 199, 318, 1678, 63, 888, 8, 493, 12, 620, 304, 272, 870, 283, 24993, 450, 83, 543, 19095, 83, 24908, 78, 7, 450, 334, 493, 12, 620, 9, 272, 347, 888, 275, 1551, 8, 493, 12, 283, 65, 358, 272, 347, 888, 14, 952, 8, 495, 435, 1557, 78, 358, 272, 347, 888, 14, 1600, 342, 199, 199, 318, 8000, 63, 7532, 837, 272, 408, 1002, 314, 2615, 769, 402, 347, 7532, 5827, 367, 642, 3123, 1041, 272, 1561, 275, 1052, 272, 367, 302, 315, 5739, 14, 6463, 360, 1047, 15, 5362, 15, 7532, 32418, 10886, 61, 3300, 59, 16, 13, 25, 13, 3672, 63, 26022, 735, 267, 1561, 59, 736, 14, 515, 14, 4846, 8, 78, 31280, 709, 2677, 275, 302, 272, 367, 302, 315, 5739, 14, 6463, 360, 1047, 15, 5362, 15, 7532, 15, 81, 3893, 10, 63, 26022, 735, 267, 1561, 59, 736, 14, 515, 14, 4846, 8, 78, 31280, 709, 2677, 275, 302, 272, 367, 302, 315, 5739, 14, 6463, 360, 1047, 15, 5362, 15, 7532, 15, 439, 81, 10, 63, 26022, 735, 267, 1561, 59, 736, 14, 515, 14, 4846, 8, 78, 31280, 709, 2677, 275, 302, 272, 372, 1561, 199, 199, 533, 19286, 26, 272, 347, 636, 826, 721, 277, 12, 943, 354, 304, 267, 291, 14, 793, 354, 275, 943, 354, 267, 291, 14, 2592, 275, 1551, 8, 793, 354, 12, 283, 87, 358, 339, 347, 1255, 8, 277, 12, 1249, 304, 267, 4866, 2307, 275, 1551, 2336, 2374, 15, 2307, 297, 283, 82, 358, 267, 6499, 275, 3873, 14, 7942, 8, 589, 12, 9009, 29, 19778, 12, 355, 2589, 29, 1875, 63, 1813, 12, 355, 17080, 29, 16, 12, 355, 3839, 29, 5781, 14, 6089, 12, 355, 4635, 29, 5781, 14, 13850, 9, 267, 2338, 275, 378, 267, 327, 367, 1004, 315, 6499, 14, 2703, 26, 267, 3066, 2592, 275, 6499, 14, 2703, 14, 9843, 342, 267, 1830, 715, 26, 288, 1004, 275, 747, 14, 739, 8, 1773, 2592, 12, 6619, 9, 288, 340, 440, 1004, 26, 355, 2059, 288, 291, 14 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 8937, 13, 8128, 12, 5495, 437, 300, 11131, 2104, 453, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 5495, 437, 300, 11131, 6590, 199, 3, 755, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 755, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 755, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 11214, 13, 12799, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 6516, 314, 5114, 367, 1006, 4545, 1808, 314, 14694, 1900, 3734, 14, 199, 3, 199, 3, 3254, 26, 15506, 2368, 370, 6623, 4052, 370, 1900, 14, 199, 199, 646, 5739, 199, 504, 8691, 492, 13491, 199, 646, 3873, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 5145, 199, 646, 984, 199, 199, 1023, 275, 283, 1506, 13, 452, 14, 647, 12, 1015, 378, 14, 614, 7, 199, 199, 1506, 63, 694, 275, 20644, 452, 13, 29824, 7, 199, 1875, 63, 1531, 275, 2097, 2611, 5135, 401, 298, 3112, 937, 199, 1875, 63, 1813, 275, 747, 14, 2314, 199, 1875, 63, 1813, 14, 873, 2561, 267, 283, 7762, 356, 283, 5362, 297, 267, 283, 28368, 63, 29911, 356, 283, 5362, 13, 3592, 13, 5135, 13, 784, 310, 14677, 14382, 267, 283, 43, 5569, 63, 4609, 1469, 16260, 356, 283, 2052, 7, 3828, 199, 452, 63, 1419, 275, 1052, 199, 199, 318, 1125, 8, 1328, 304, 272, 984, 14, 3083, 14, 952, 480, 705, 26, 450, 83, 60, 78, 2, 450, 1499, 9, 199, 199, 318, 2449, 8, 1328, 304, 272, 408, 4874, 543, 282, 922, 13, 27131, 1245, 624, 272, 1125, 8, 1328, 9, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 318, 1104, 63, 4989, 837, 272, 408, 13913, 626, 510, 16698, 365, 282, 5114, 2082, 624, 272, 340, 334, 1397, 747, 14, 515, 14, 6292, 360, 2054, 2919, 9021, 3960, 358, 503, 267, 440, 747, 14, 515, 14, 6292, 360, 1047, 15, 5362, 15, 14121, 13, 706, 77, 15, 28033, 8109, 267, 2449, 480, 2765, 3181, 1133, 17021, 370, 506, 376, 603, 4029, 5114, 2935, 531, 199, 199, 318, 1104, 63, 1506, 837, 272, 408, 13913, 626, 314, 1900, 2082, 365, 3451, 1041, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 1506, 63, 694, 304, 267, 862, 26, 288, 747, 14, 8347, 8, 1506, 63, 694, 9, 267, 871, 6440, 465, 3178, 26, 288, 340, 3178, 14, 7931, 508, 7554, 14, 28596, 26, 355, 986, 288, 587, 26, 355, 746, 199, 199, 318, 1678, 63, 888, 8, 493, 12, 620, 304, 272, 870, 283, 24993, 450, 83, 543, 19095, 83, 24908, 78, 7, 450, 334, 493, 12, 620, 9, 272, 347, 888, 275, 1551, 8, 493, 12, 283, 65, 358, 272, 347, 888, 14, 952, 8, 495, 435, 1557, 78, 358, 272, 347, 888, 14, 1600, 342, 199, 199, 318, 8000, 63, 7532, 837, 272, 408, 1002, 314, 2615, 769, 402, 347, 7532, 5827, 367, 642, 3123, 1041, 272, 1561, 275, 1052, 272, 367, 302, 315, 5739, 14, 6463, 360, 1047, 15, 5362, 15, 7532, 32418, 10886, 61, 3300, 59, 16, 13, 25, 13, 3672, 63, 26022, 735, 267, 1561, 59, 736, 14, 515, 14, 4846, 8, 78, 31280, 709, 2677, 275, 302, 272, 367, 302, 315, 5739, 14, 6463, 360, 1047, 15, 5362, 15, 7532, 15, 81, 3893, 10, 63, 26022, 735, 267, 1561, 59, 736, 14, 515, 14, 4846, 8, 78, 31280, 709, 2677, 275, 302, 272, 367, 302, 315, 5739, 14, 6463, 360, 1047, 15, 5362, 15, 7532, 15, 439, 81, 10, 63, 26022, 735, 267, 1561, 59, 736, 14, 515, 14, 4846, 8, 78, 31280, 709, 2677, 275, 302, 272, 372, 1561, 199, 199, 533, 19286, 26, 272, 347, 636, 826, 721, 277, 12, 943, 354, 304, 267, 291, 14, 793, 354, 275, 943, 354, 267, 291, 14, 2592, 275, 1551, 8, 793, 354, 12, 283, 87, 358, 339, 347, 1255, 8, 277, 12, 1249, 304, 267, 4866, 2307, 275, 1551, 2336, 2374, 15, 2307, 297, 283, 82, 358, 267, 6499, 275, 3873, 14, 7942, 8, 589, 12, 9009, 29, 19778, 12, 355, 2589, 29, 1875, 63, 1813, 12, 355, 17080, 29, 16, 12, 355, 3839, 29, 5781, 14, 6089, 12, 355, 4635, 29, 5781, 14, 13850, 9, 267, 2338, 275, 378, 267, 327, 367, 1004, 315, 6499, 14, 2703, 26, 267, 3066, 2592, 275, 6499, 14, 2703, 14, 9843, 342, 267, 1830, 715, 26, 288, 1004, 275, 747, 14, 739, 8, 1773, 2592, 12, 6619, 9, 288, 340, 440, 1004, 26, 355, 2059, 288, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
wido/libcloud
libcloud/test/compute/test_ecp.py
46
5159
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys import unittest from libcloud.utils.py3 import httplib from libcloud.compute.drivers.ecp import ECPNodeDriver from libcloud.compute.types import NodeState from libcloud.test import MockHttp from libcloud.test.compute import TestCaseMixin from libcloud.test.file_fixtures import ComputeFileFixtures from libcloud.test.secrets import ECP_PARAMS class ECPTests(unittest.TestCase, TestCaseMixin): def setUp(self): ECPNodeDriver.connectionCls.conn_classes = (None, ECPMockHttp) self.driver = ECPNodeDriver(*ECP_PARAMS) def test_list_nodes(self): nodes = self.driver.list_nodes() self.assertEqual(len(nodes), 2) node = nodes[0] self.assertEqual(node.id, '1') self.assertEqual(node.name, 'dummy-1') self.assertEqual(node.public_ips[0], "42.78.124.75") self.assertEqual(node.state, NodeState.RUNNING) def test_list_sizes(self): sizes = self.driver.list_sizes() self.assertEqual(len(sizes), 3) size = sizes[0] self.assertEqual(size.id, '1') self.assertEqual(size.ram, 512) self.assertEqual(size.disk, 0) self.assertEqual(size.bandwidth, 0) self.assertEqual(size.price, 0) def test_list_images(self): images = self.driver.list_images() self.assertEqual(len(images), 2) self.assertEqual( images[0].name, "centos54: AUTO import from /opt/enomalism2/repo/5d407a68-c76c-11de-86e5-000475cb7577.xvm2") self.assertEqual(images[0].id, "1") name = "centos54 two: AUTO import from /opt/enomalism2/repo/5d407a68-c76c-11de-86e5-000475cb7577.xvm2" self.assertEqual(images[1].name, name) self.assertEqual(images[1].id, "2") def test_reboot_node(self): # Raises exception on failure node = self.driver.list_nodes()[0] self.driver.reboot_node(node) def test_destroy_node(self): # Raises exception on failure node = self.driver.list_nodes()[0] self.driver.destroy_node(node) def test_create_node(self): # Raises exception on failure size = self.driver.list_sizes()[0] image = self.driver.list_images()[0] node = self.driver.create_node( name="api.ivan.net.nz", image=image, size=size) self.assertEqual(node.name, "api.ivan.net.nz") self.assertEqual(node.id, "1234") class ECPMockHttp(MockHttp): fixtures = ComputeFileFixtures('ecp') def _modules_hosting(self, method, url, body, headers): headers = {} headers['set-cookie'] = 'vcloud-token=testtoken' body = 'Anything' return (httplib.OK, body, headers, httplib.responses[httplib.OK]) def _rest_hosting_vm_1(self, method, url, body, headers): if method == 'GET': body = self.fixtures.load('vm_1_get.json') if method == 'POST': if body.find('delete', 0): body = self.fixtures.load('vm_1_action_delete.json') if body.find('stop', 0): body = self.fixtures.load('vm_1_action_stop.json') if body.find('start', 0): body = self.fixtures.load('vm_1_action_start.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _rest_hosting_vm(self, method, url, body, headers): if method == 'PUT': body = self.fixtures.load('vm_put.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _rest_hosting_vm_list(self, method, url, body, headers): body = self.fixtures.load('vm_list.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _rest_hosting_htemplate_list(self, method, url, body, headers): body = self.fixtures.load('htemplate_list.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _rest_hosting_network_list(self, method, url, body, headers): body = self.fixtures.load('network_list.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _rest_hosting_ptemplate_list(self, method, url, body, headers): body = self.fixtures.load('ptemplate_list.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) if __name__ == '__main__': sys.exit(unittest.main())
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, 646, 984, 199, 646, 2882, 199, 504, 17069, 14, 1208, 14, 647, 19, 492, 8809, 199, 199, 504, 17069, 14, 3357, 14, 13337, 14, 825, 80, 492, 662, 2890, 1716, 6158, 199, 504, 17069, 14, 3357, 14, 1313, 492, 5013, 2223, 199, 199, 504, 17069, 14, 396, 492, 4420, 5779, 199, 504, 17069, 14, 396, 14, 3357, 492, 7640, 4256, 199, 504, 17069, 14, 396, 14, 493, 63, 8769, 492, 8354, 1173, 9047, 6969, 199, 199, 504, 17069, 14, 396, 14, 16153, 492, 662, 2890, 63, 17978, 421, 199, 533, 662, 2890, 2925, 8, 2796, 14, 1746, 12, 7640, 4256, 304, 339, 347, 3613, 8, 277, 304, 267, 662, 2890, 1716, 6158, 14, 2105, 24342, 14, 1631, 63, 2888, 275, 334, 403, 12, 8105, 662, 2890, 3346, 5779, 9, 267, 291, 14, 3090, 275, 662, 2890, 1716, 6158, 2031, 37, 2890, 63, 17978, 9, 339, 347, 511, 63, 513, 63, 2415, 8, 277, 304, 267, 3380, 275, 291, 14, 3090, 14, 513, 63, 2415, 342, 267, 291, 14, 629, 8, 552, 8, 2415, 395, 499, 9, 267, 1031, 275, 3380, 59, 16, 61, 267, 291, 14, 629, 8, 932, 14, 344, 12, 283, 17, 358, 267, 291, 14, 629, 8, 932, 14, 354, 12, 283, 5869, 13, 17, 358, 267, 291, 14, 629, 8, 932, 14, 3455, 63, 6142, 59, 16, 467, 298, 2260, 14, 2277, 14, 7214, 14, 2194, 531, 267, 291, 14, 629, 8, 932, 14, 929, 12, 5013, 2223, 14, 17305, 9, 339, 347, 511, 63, 513, 63, 7723, 8, 277, 304, 267, 10627, 275, 291, 14, 3090, 14, 513, 63, 7723, 342, 267, 291, 14, 629, 8, 552, 8, 7723, 395, 650, 9, 267, 1568, 275, 10627, 59, 16, 61, 267, 291, 14, 629, 8, 890, 14, 344, 12, 283, 17, 358, 267, 291, 14, 629, 8, 890, 14, 5975, 12, 10574, 9, 267, 291, 14, 629, 8, 890, 14, 4032, 12, 378, 9, 267, 291, 14, 629, 8, 890, 14, 18358, 12, 378, 9, 267, 291, 14, 629, 8, 890, 14, 4777, 12, 378, 9, 339, 347, 511, 63, 513, 63, 4782, 8, 277, 304, 267, 5935, 275, 291, 14, 3090, 14, 513, 63, 4782, 342, 267, 291, 14, 629, 8, 552, 8, 4782, 395, 499, 9, 267, 291, 14, 629, 8, 288, 5935, 59, 16, 1055, 354, 12, 298, 2497, 14543, 1477, 26, 25420, 492, 687, 1182, 2992, 15, 287, 676, 279, 19185, 18, 15, 3417, 15, 21, 68, 12641, 65, 2333, 13, 67, 2114, 67, 13, 845, 271, 13, 1184, 69, 21, 13, 16643, 2194, 2894, 2194, 1138, 14, 88, 2611, 18, 531, 267, 291, 14, 629, 8, 4782, 59, 16, 1055, 344, 12, 298, 17, 531, 398, 536, 275, 298, 2497, 14543, 1477, 2877, 26, 25420, 492, 687, 1182, 2992, 15, 287, 676, 279, 19185, 18, 15, 3417, 15, 21, 68, 12641, 65, 2333, 13, 67, 2114, 67, 13, 845, 271, 13, 1184, 69, 21, 13, 16643, 2194, 2894, 2194, 1138, 14, 88, 2611, 18, 2, 267, 291, 14, 629, 8, 4782, 59, 17, 1055, 354, 12, 536, 9, 267, 291, 14, 629, 8, 4782, 59, 17, 1055, 344, 12, 298, 18, 531, 339, 347, 511, 63, 15051, 63, 932, 8, 277, 304, 267, 327, 6218, 1919, 641, 5988, 267, 1031, 275, 291, 14, 3090, 14, 513, 63, 2415, 3430, 16, 61, 267, 291, 14, 3090, 14, 15051, 63, 932, 8, 932, 9, 339, 347, 511, 63, 7237, 63, 932, 8, 277, 304, 267, 327, 6218, 1919, 641, 5988, 267, 1031, 275, 291, 14, 3090, 14, 513, 63, 2415, 3430, 16, 61, 267, 291, 14, 3090, 14, 7237, 63, 932, 8, 932, 9, 339, 347, 511, 63, 981, 63, 932, 8, 277, 304, 267, 327, 6218, 1919, 641, 5988, 267, 1568, 275, 291, 14, 3090, 14, 513, 63, 7723, 3430, 16, 61, 267, 1834, 275, 291, 14, 3090, 14, 513, 63, 4782, 3430, 16, 61, 267, 1031, 275, 291, 14, 3090, 14, 981, 63, 932, 8, 288, 536, 628, 1246, 14, 1003, 290, 14, 846, 14, 15291, 401, 1834, 29, 1569, 12, 1568, 29, 890, 9, 267, 291, 14, 629, 8, 932, 14, 354, 12, 298, 1246, 14, 1003, 290, 14, 846, 14, 15291, 531, 267, 291, 14, 629, 8, 932, 14, 344, 12, 298, 4321, 531, 421, 199, 533, 662, 2890, 3346, 5779, 8, 3346, 5779, 304, 339, 15188, 275, 8354, 1173, 9047, 6969, 360, 825, 80, 358, 339, 347, 485, 3112, 63, 29138, 8, 277, 12, 1083, 12, 1166, 12, 2396, 12, 2323, 304, 267, 2323, 275, 1052, 267, 2323, 459, 409, 13, 5306, 418, 275, 283, 86, 4091, 13, 1418, 29, 396, 1418, 7, 267, 2396, 275, 283, 9874, 2127, 7, 267, 372, 334, 12942, 14, 3593, 12, 2396, 12, 2323, 12, 8809, 14, 10360, 59, 12942, 14, 3593, 566, 339, 347, 485, 3911, 63, 29138, 63, 2611, 63, 17, 8, 277, 12, 1083, 12, 1166, 12, 2396, 12, 2323, 304, 267, 340, 1083, 508, 283, 2970, 356, 288, 2396, 275, 291, 14, 8769, 14, 912, 360, 2611, 63, 17, 63, 362, 14, 1001, 358, 267, 340, 1083, 508, 283, 4030, 356, 288, 340, 2396, 14, 1623, 360 ]
[ 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, 646, 984, 199, 646, 2882, 199, 504, 17069, 14, 1208, 14, 647, 19, 492, 8809, 199, 199, 504, 17069, 14, 3357, 14, 13337, 14, 825, 80, 492, 662, 2890, 1716, 6158, 199, 504, 17069, 14, 3357, 14, 1313, 492, 5013, 2223, 199, 199, 504, 17069, 14, 396, 492, 4420, 5779, 199, 504, 17069, 14, 396, 14, 3357, 492, 7640, 4256, 199, 504, 17069, 14, 396, 14, 493, 63, 8769, 492, 8354, 1173, 9047, 6969, 199, 199, 504, 17069, 14, 396, 14, 16153, 492, 662, 2890, 63, 17978, 421, 199, 533, 662, 2890, 2925, 8, 2796, 14, 1746, 12, 7640, 4256, 304, 339, 347, 3613, 8, 277, 304, 267, 662, 2890, 1716, 6158, 14, 2105, 24342, 14, 1631, 63, 2888, 275, 334, 403, 12, 8105, 662, 2890, 3346, 5779, 9, 267, 291, 14, 3090, 275, 662, 2890, 1716, 6158, 2031, 37, 2890, 63, 17978, 9, 339, 347, 511, 63, 513, 63, 2415, 8, 277, 304, 267, 3380, 275, 291, 14, 3090, 14, 513, 63, 2415, 342, 267, 291, 14, 629, 8, 552, 8, 2415, 395, 499, 9, 267, 1031, 275, 3380, 59, 16, 61, 267, 291, 14, 629, 8, 932, 14, 344, 12, 283, 17, 358, 267, 291, 14, 629, 8, 932, 14, 354, 12, 283, 5869, 13, 17, 358, 267, 291, 14, 629, 8, 932, 14, 3455, 63, 6142, 59, 16, 467, 298, 2260, 14, 2277, 14, 7214, 14, 2194, 531, 267, 291, 14, 629, 8, 932, 14, 929, 12, 5013, 2223, 14, 17305, 9, 339, 347, 511, 63, 513, 63, 7723, 8, 277, 304, 267, 10627, 275, 291, 14, 3090, 14, 513, 63, 7723, 342, 267, 291, 14, 629, 8, 552, 8, 7723, 395, 650, 9, 267, 1568, 275, 10627, 59, 16, 61, 267, 291, 14, 629, 8, 890, 14, 344, 12, 283, 17, 358, 267, 291, 14, 629, 8, 890, 14, 5975, 12, 10574, 9, 267, 291, 14, 629, 8, 890, 14, 4032, 12, 378, 9, 267, 291, 14, 629, 8, 890, 14, 18358, 12, 378, 9, 267, 291, 14, 629, 8, 890, 14, 4777, 12, 378, 9, 339, 347, 511, 63, 513, 63, 4782, 8, 277, 304, 267, 5935, 275, 291, 14, 3090, 14, 513, 63, 4782, 342, 267, 291, 14, 629, 8, 552, 8, 4782, 395, 499, 9, 267, 291, 14, 629, 8, 288, 5935, 59, 16, 1055, 354, 12, 298, 2497, 14543, 1477, 26, 25420, 492, 687, 1182, 2992, 15, 287, 676, 279, 19185, 18, 15, 3417, 15, 21, 68, 12641, 65, 2333, 13, 67, 2114, 67, 13, 845, 271, 13, 1184, 69, 21, 13, 16643, 2194, 2894, 2194, 1138, 14, 88, 2611, 18, 531, 267, 291, 14, 629, 8, 4782, 59, 16, 1055, 344, 12, 298, 17, 531, 398, 536, 275, 298, 2497, 14543, 1477, 2877, 26, 25420, 492, 687, 1182, 2992, 15, 287, 676, 279, 19185, 18, 15, 3417, 15, 21, 68, 12641, 65, 2333, 13, 67, 2114, 67, 13, 845, 271, 13, 1184, 69, 21, 13, 16643, 2194, 2894, 2194, 1138, 14, 88, 2611, 18, 2, 267, 291, 14, 629, 8, 4782, 59, 17, 1055, 354, 12, 536, 9, 267, 291, 14, 629, 8, 4782, 59, 17, 1055, 344, 12, 298, 18, 531, 339, 347, 511, 63, 15051, 63, 932, 8, 277, 304, 267, 327, 6218, 1919, 641, 5988, 267, 1031, 275, 291, 14, 3090, 14, 513, 63, 2415, 3430, 16, 61, 267, 291, 14, 3090, 14, 15051, 63, 932, 8, 932, 9, 339, 347, 511, 63, 7237, 63, 932, 8, 277, 304, 267, 327, 6218, 1919, 641, 5988, 267, 1031, 275, 291, 14, 3090, 14, 513, 63, 2415, 3430, 16, 61, 267, 291, 14, 3090, 14, 7237, 63, 932, 8, 932, 9, 339, 347, 511, 63, 981, 63, 932, 8, 277, 304, 267, 327, 6218, 1919, 641, 5988, 267, 1568, 275, 291, 14, 3090, 14, 513, 63, 7723, 3430, 16, 61, 267, 1834, 275, 291, 14, 3090, 14, 513, 63, 4782, 3430, 16, 61, 267, 1031, 275, 291, 14, 3090, 14, 981, 63, 932, 8, 288, 536, 628, 1246, 14, 1003, 290, 14, 846, 14, 15291, 401, 1834, 29, 1569, 12, 1568, 29, 890, 9, 267, 291, 14, 629, 8, 932, 14, 354, 12, 298, 1246, 14, 1003, 290, 14, 846, 14, 15291, 531, 267, 291, 14, 629, 8, 932, 14, 344, 12, 298, 4321, 531, 421, 199, 533, 662, 2890, 3346, 5779, 8, 3346, 5779, 304, 339, 15188, 275, 8354, 1173, 9047, 6969, 360, 825, 80, 358, 339, 347, 485, 3112, 63, 29138, 8, 277, 12, 1083, 12, 1166, 12, 2396, 12, 2323, 304, 267, 2323, 275, 1052, 267, 2323, 459, 409, 13, 5306, 418, 275, 283, 86, 4091, 13, 1418, 29, 396, 1418, 7, 267, 2396, 275, 283, 9874, 2127, 7, 267, 372, 334, 12942, 14, 3593, 12, 2396, 12, 2323, 12, 8809, 14, 10360, 59, 12942, 14, 3593, 566, 339, 347, 485, 3911, 63, 29138, 63, 2611, 63, 17, 8, 277, 12, 1083, 12, 1166, 12, 2396, 12, 2323, 304,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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 ]
fangxingli/hue
desktop/core/ext-py/markdown/regression-tests.py
44
8693
#!/usr/bin/python """ Python-Markdown Regression Tests ================================ Tests of the various APIs with the python markdown lib. """ import unittest from doctest import DocTestSuite import os import markdown class TestMarkdown(unittest.TestCase): """ Tests basics of the Markdown class. """ def setUp(self): """ Create instance of Markdown. """ self.md = markdown.Markdown() def testBlankInput(self): """ Test blank input. """ self.assertEqual(self.md.convert(''), '') def testWhitespaceOnly(self): """ Test input of only whitespace. """ self.assertEqual(self.md.convert(' '), '') def testSimpleInput(self): """ Test simple input. """ self.assertEqual(self.md.convert('foo'), '<p>foo</p>') class TestBlockParser(unittest.TestCase): """ Tests of the BlockParser class. """ def setUp(self): """ Create instance of BlockParser. """ self.parser = markdown.Markdown().parser def testParseChunk(self): """ Test BlockParser.parseChunk. """ root = markdown.etree.Element("div") text = 'foo' self.parser.parseChunk(root, text) self.assertEqual(markdown.etree.tostring(root), "<div><p>foo</p></div>") def testParseDocument(self): """ Test BlockParser.parseDocument. """ lines = ['#foo', '', 'bar', '', ' baz'] tree = self.parser.parseDocument(lines) self.assert_(isinstance(tree, markdown.etree.ElementTree)) self.assert_(markdown.etree.iselement(tree.getroot())) self.assertEqual(markdown.etree.tostring(tree.getroot()), "<div><h1>foo</h1><p>bar</p><pre><code>baz\n</code></pre></div>") class TestBlockParserState(unittest.TestCase): """ Tests of the State class for BlockParser. """ def setUp(self): self.state = markdown.blockparser.State() def testBlankState(self): """ Test State when empty. """ self.assertEqual(self.state, []) def testSetSate(self): """ Test State.set(). """ self.state.set('a_state') self.assertEqual(self.state, ['a_state']) self.state.set('state2') self.assertEqual(self.state, ['a_state', 'state2']) def testIsSate(self): """ Test State.isstate(). """ self.assertEqual(self.state.isstate('anything'), False) self.state.set('a_state') self.assertEqual(self.state.isstate('a_state'), True) self.state.set('state2') self.assertEqual(self.state.isstate('state2'), True) self.assertEqual(self.state.isstate('a_state'), False) self.assertEqual(self.state.isstate('missing'), False) def testReset(self): """ Test State.reset(). """ self.state.set('a_state') self.state.reset() self.assertEqual(self.state, []) self.state.set('state1') self.state.set('state2') self.state.reset() self.assertEqual(self.state, ['state1']) class TestHtmlStash(unittest.TestCase): """ Test Markdown's HtmlStash. """ def setUp(self): self.stash = markdown.preprocessors.HtmlStash() self.placeholder = self.stash.store('foo') def testSimpleStore(self): """ Test HtmlStash.store. """ self.assertEqual(self.placeholder, markdown.preprocessors.HTML_PLACEHOLDER % 0) self.assertEqual(self.stash.html_counter, 1) self.assertEqual(self.stash.rawHtmlBlocks, [('foo', False)]) def testStoreMore(self): """ Test HtmlStash.store with additional blocks. """ placeholder = self.stash.store('bar') self.assertEqual(placeholder, markdown.preprocessors.HTML_PLACEHOLDER % 1) self.assertEqual(self.stash.html_counter, 2) self.assertEqual(self.stash.rawHtmlBlocks, [('foo', False), ('bar', False)]) def testSafeStore(self): """ Test HtmlStash.store with 'safe' html. """ self.stash.store('bar', True) self.assertEqual(self.stash.rawHtmlBlocks, [('foo', False), ('bar', True)]) def testReset(self): """ Test HtmlStash.reset. """ self.stash.reset() self.assertEqual(self.stash.html_counter, 0) self.assertEqual(self.stash.rawHtmlBlocks, []) class TestOrderedDict(unittest.TestCase): """ Test OrderedDict storage class. """ def setUp(self): self.odict = markdown.odict.OrderedDict() self.odict['first'] = 'This' self.odict['third'] = 'a' self.odict['fourth'] = 'self' self.odict['fifth'] = 'test' def testValues(self): """ Test output of OrderedDict.values(). """ self.assertEqual(self.odict.values(), ['This', 'a', 'self', 'test']) def testKeys(self): """ Test output of OrderedDict.keys(). """ self.assertEqual(self.odict.keys(), ['first', 'third', 'fourth', 'fifth']) def testItems(self): """ Test output of OrderedDict.items(). """ self.assertEqual(self.odict.items(), [('first', 'This'), ('third', 'a'), ('fourth', 'self'), ('fifth', 'test')]) def testAddBefore(self): """ Test adding an OrderedDict item before a given key. """ self.odict.add('second', 'is', '<third') self.assertEqual(self.odict.items(), [('first', 'This'), ('second', 'is'), ('third', 'a'), ('fourth', 'self'), ('fifth', 'test')]) def testAddAfter(self): """ Test adding an OrderDict item after a given key. """ self.odict.add('second', 'is', '>first') self.assertEqual(self.odict.items(), [('first', 'This'), ('second', 'is'), ('third', 'a'), ('fourth', 'self'), ('fifth', 'test')]) def testAddAfterEnd(self): """ Test adding an OrderedDict item after the last key. """ self.odict.add('sixth', '.', '>fifth') self.assertEqual(self.odict.items(), [('first', 'This'), ('third', 'a'), ('fourth', 'self'), ('fifth', 'test'), ('sixth', '.')]) def testAdd_begin(self): """ Test adding an OrderedDict item using "_begin". """ self.odict.add('zero', 'CRAZY', '_begin') self.assertEqual(self.odict.items(), [('zero', 'CRAZY'), ('first', 'This'), ('third', 'a'), ('fourth', 'self'), ('fifth', 'test')]) def testAdd_end(self): """ Test adding an OrderedDict item using "_end". """ self.odict.add('sixth', '.', '_end') self.assertEqual(self.odict.items(), [('first', 'This'), ('third', 'a'), ('fourth', 'self'), ('fifth', 'test'), ('sixth', '.')]) def testAddBadLocation(self): """ Test Error on bad location in OrderedDict.add(). """ self.assertRaises(ValueError, self.odict.add, 'sixth', '.', '<seventh') self.assertRaises(ValueError, self.odict.add, 'second', 'is', 'third') def testDeleteItem(self): """ Test deletion of an OrderedDict item. """ del self.odict['fourth'] self.assertEqual(self.odict.items(), [('first', 'This'), ('third', 'a'), ('fifth', 'test')]) def testChangeValue(self): """ Test OrderedDict change value. """ self.odict['fourth'] = 'CRAZY' self.assertEqual(self.odict.items(), [('first', 'This'), ('third', 'a'), ('fourth', 'CRAZY'), ('fifth', 'test')]) def testChangeOrder(self): """ Test OrderedDict change order. """ self.odict.link('fourth', '<third') self.assertEqual(self.odict.items(), [('first', 'This'), ('fourth', 'self'), ('third', 'a'), ('fifth', 'test')]) def suite(): """ Build a test suite of the above tests and extension doctests. """ suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestMarkdown)) suite.addTest(unittest.makeSuite(TestBlockParser)) suite.addTest(unittest.makeSuite(TestBlockParserState)) suite.addTest(unittest.makeSuite(TestHtmlStash)) suite.addTest(unittest.makeSuite(TestOrderedDict)) for filename in os.listdir('markdown/extensions'): if filename.endswith('.py'): module = 'markdown.extensions.%s' % filename[:-3] try: suite.addTest(DocTestSuite(module)) except: ValueError # No tests return suite if __name__ == '__main__': unittest.TextTestRunner(verbosity=2).run(suite())
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 624, 199, 4718, 13, 30916, 13262, 6496, 199, 2486, 199, 199, 2925, 402, 314, 7750, 15913, 543, 314, 2366, 18502, 1973, 14, 199, 199, 624, 199, 199, 646, 2882, 199, 504, 8868, 492, 5454, 10591, 199, 646, 747, 199, 646, 18502, 199, 199, 533, 1379, 30916, 8, 2796, 14, 1746, 304, 272, 408, 6496, 5678, 83, 402, 314, 24537, 1021, 14, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 2790, 1256, 402, 24537, 14, 408, 267, 291, 14, 1064, 275, 18502, 14, 30916, 342, 339, 347, 511, 28083, 3205, 8, 277, 304, 267, 408, 1379, 4596, 1324, 14, 408, 267, 291, 14, 629, 8, 277, 14, 1064, 14, 3916, 31150, 4074, 339, 347, 511, 16552, 5903, 8, 277, 304, 267, 408, 1379, 1324, 402, 1454, 8139, 14, 408, 267, 291, 14, 629, 8, 277, 14, 1064, 14, 3916, 360, 17748, 4074, 339, 347, 511, 3184, 3205, 8, 277, 304, 267, 408, 1379, 3486, 1324, 14, 408, 267, 291, 14, 629, 8, 277, 14, 1064, 14, 3916, 360, 1421, 659, 2650, 80, 30, 1421, 1108, 80, 5971, 199, 199, 533, 1379, 3142, 2842, 8, 2796, 14, 1746, 304, 272, 408, 6496, 402, 314, 8651, 2842, 1021, 14, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 2790, 1256, 402, 8651, 2842, 14, 408, 267, 291, 14, 2087, 275, 18502, 14, 30916, 1252, 2087, 339, 347, 511, 4003, 9856, 8, 277, 304, 267, 408, 1379, 8651, 2842, 14, 1122, 9856, 14, 408, 267, 1738, 275, 18502, 14, 9464, 14, 2162, 480, 3015, 531, 267, 1318, 275, 283, 1421, 7, 267, 291, 14, 2087, 14, 1122, 9856, 8, 1231, 12, 1318, 9, 267, 291, 14, 629, 8, 15653, 14, 9464, 14, 14028, 8, 1231, 395, 3886, 3015, 2535, 80, 30, 1421, 1108, 80, 2957, 3015, 9579, 339, 347, 511, 4003, 5564, 8, 277, 304, 267, 408, 1379, 8651, 2842, 14, 1122, 5564, 14, 408, 267, 2385, 275, 788, 3, 1421, 297, 3260, 283, 1700, 297, 3260, 283, 259, 15507, 418, 267, 3123, 275, 291, 14, 2087, 14, 1122, 5564, 8, 1278, 9, 267, 291, 14, 479, 2531, 6074, 8, 2350, 12, 18502, 14, 9464, 14, 15325, 430, 267, 291, 14, 479, 2531, 15653, 14, 9464, 14, 572, 968, 8, 2350, 14, 24544, 4059, 267, 291, 14, 629, 8, 15653, 14, 9464, 14, 14028, 8, 2350, 14, 24544, 4000, 288, 3886, 3015, 2535, 72, 17, 30, 1421, 1108, 72, 17, 2535, 80, 30, 1700, 1108, 80, 2535, 657, 2535, 600, 30, 6185, 60, 78, 1108, 600, 2957, 657, 2957, 3015, 9579, 421, 199, 533, 1379, 3142, 2842, 2223, 8, 2796, 14, 1746, 304, 272, 408, 6496, 402, 314, 8511, 1021, 367, 8651, 2842, 14, 408, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 929, 275, 18502, 14, 1457, 2087, 14, 2223, 342, 339, 347, 511, 28083, 2223, 8, 277, 304, 267, 408, 1379, 8511, 1380, 2701, 14, 408, 267, 291, 14, 629, 8, 277, 14, 929, 12, 3073, 339, 347, 511, 1084, 51, 323, 8, 277, 304, 267, 408, 1379, 8511, 14, 409, 1252, 408, 267, 291, 14, 929, 14, 409, 360, 65, 63, 929, 358, 267, 291, 14, 629, 8, 277, 14, 929, 12, 788, 65, 63, 929, 1105, 267, 291, 14, 929, 14, 409, 360, 929, 18, 358, 267, 291, 14, 629, 8, 277, 14, 929, 12, 788, 65, 63, 929, 297, 283, 929, 18, 1105, 339, 347, 511, 1831, 51, 323, 8, 277, 304, 267, 408, 1379, 8511, 14, 374, 929, 1252, 408, 267, 291, 14, 629, 8, 277, 14, 929, 14, 374, 929, 360, 25058, 659, 756, 9, 267, 291, 14, 929, 14, 409, 360, 65, 63, 929, 358, 267, 291, 14, 629, 8, 277, 14, 929, 14, 374, 929, 360, 65, 63, 929, 659, 715, 9, 267, 291, 14, 929, 14, 409, 360, 929, 18, 358, 267, 291, 14, 629, 8, 277, 14, 929, 14, 374, 929, 360, 929, 18, 659, 715, 9, 267, 291, 14, 629, 8, 277, 14, 929, 14, 374, 929, 360, 65, 63, 929, 659, 756, 9, 267, 291, 14, 629, 8, 277, 14, 929, 14, 374, 929, 360, 4752, 659, 756, 9, 339, 347, 511, 9637, 8, 277, 304, 267, 408, 1379, 8511, 14, 3958, 1252, 408, 267, 291, 14, 929, 14, 409, 360, 65, 63, 929, 358, 267, 291, 14, 929, 14, 3958, 342, 267, 291, 14, 629, 8, 277, 14, 929, 12, 3073, 267, 291, 14, 929, 14, 409, 360, 929, 17, 358, 267, 291, 14, 929, 14, 409, 360, 929, 18, 358, 267, 291, 14, 929, 14, 3958, 342, 267, 291, 14, 629, 8, 277, 14, 929, 12, 788, 929, 17, 1105, 199, 199, 533, 1379, 12957, 933, 1119, 8, 2796, 14, 1746, 304, 272, 408, 1379, 24537, 1159, 20880, 933, 1119, 14, 408, 2286, 347, 3613, 8, 277, 304, 267, 291, 14, 27145, 275, 18502, 14, 657, 10547, 14, 12957, 933, 1119, 342, 267, 291, 14, 6199, 275, 291, 14, 27145, 14, 1617, 360, 1421, 358, 339, 347, 511, 3184, 5502, 8, 277, 304, 267, 408, 1379, 20880, 933, 1119, 14, 1617, 14, 408, 267, 291, 14, 629, 8, 277, 14, 6199, 12, 221, 586, 18502, 14, 657, 10547, 14, 4943, 63, 23068, 40, 15744, 450, 378, 9, 267, 291, 14, 629, 8, 277, 14, 27145, 14, 1360, 63, 5337, 12, 413, 9, 267, 291, 14, 629, 8, 277, 14, 27145, 14, 1773, 12957, 24996, 12, 4274, 1421, 297, 756, 3948, 339, 347, 511, 5502, 11053, 8, 277, 304, 267, 408, 1379, 20880, 933, 1119, 14, 1617, 543, 4722, 5664, 14, 408, 267, 10069, 275, 291, 14, 27145, 14, 1617, 360, 1700, 358, 267, 291, 14, 629, 8, 6199, 12, 221, 586, 18502, 14, 657, 10547, 14, 4943, 63, 23068, 40, 15744, 450, 413, 9, 267, 291, 14, 629, 8, 277, 14, 27145, 14, 1360, 63, 5337, 12, 499, 9, 267, 291, 14, 629, 8, 277, 14, 27145, 14, 1773, 12957, 24996, 12, 12723, 4274, 1421, 297, 756, 395, 661, 1700, 297, 756, 3948, 339, 347, 511, 11090, 5502, 8, 277, 304, 267, 408, 1379, 20880, 933, 1119, 14, 1617, 543, 283, 3489, 7, 3517, 14, 408, 267, 291, 14, 27145, 14, 1617, 360, 1700 ]
[ 2647, 15, 1393, 15, 1548, 199, 624, 199, 4718, 13, 30916, 13262, 6496, 199, 2486, 199, 199, 2925, 402, 314, 7750, 15913, 543, 314, 2366, 18502, 1973, 14, 199, 199, 624, 199, 199, 646, 2882, 199, 504, 8868, 492, 5454, 10591, 199, 646, 747, 199, 646, 18502, 199, 199, 533, 1379, 30916, 8, 2796, 14, 1746, 304, 272, 408, 6496, 5678, 83, 402, 314, 24537, 1021, 14, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 2790, 1256, 402, 24537, 14, 408, 267, 291, 14, 1064, 275, 18502, 14, 30916, 342, 339, 347, 511, 28083, 3205, 8, 277, 304, 267, 408, 1379, 4596, 1324, 14, 408, 267, 291, 14, 629, 8, 277, 14, 1064, 14, 3916, 31150, 4074, 339, 347, 511, 16552, 5903, 8, 277, 304, 267, 408, 1379, 1324, 402, 1454, 8139, 14, 408, 267, 291, 14, 629, 8, 277, 14, 1064, 14, 3916, 360, 17748, 4074, 339, 347, 511, 3184, 3205, 8, 277, 304, 267, 408, 1379, 3486, 1324, 14, 408, 267, 291, 14, 629, 8, 277, 14, 1064, 14, 3916, 360, 1421, 659, 2650, 80, 30, 1421, 1108, 80, 5971, 199, 199, 533, 1379, 3142, 2842, 8, 2796, 14, 1746, 304, 272, 408, 6496, 402, 314, 8651, 2842, 1021, 14, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 2790, 1256, 402, 8651, 2842, 14, 408, 267, 291, 14, 2087, 275, 18502, 14, 30916, 1252, 2087, 339, 347, 511, 4003, 9856, 8, 277, 304, 267, 408, 1379, 8651, 2842, 14, 1122, 9856, 14, 408, 267, 1738, 275, 18502, 14, 9464, 14, 2162, 480, 3015, 531, 267, 1318, 275, 283, 1421, 7, 267, 291, 14, 2087, 14, 1122, 9856, 8, 1231, 12, 1318, 9, 267, 291, 14, 629, 8, 15653, 14, 9464, 14, 14028, 8, 1231, 395, 3886, 3015, 2535, 80, 30, 1421, 1108, 80, 2957, 3015, 9579, 339, 347, 511, 4003, 5564, 8, 277, 304, 267, 408, 1379, 8651, 2842, 14, 1122, 5564, 14, 408, 267, 2385, 275, 788, 3, 1421, 297, 3260, 283, 1700, 297, 3260, 283, 259, 15507, 418, 267, 3123, 275, 291, 14, 2087, 14, 1122, 5564, 8, 1278, 9, 267, 291, 14, 479, 2531, 6074, 8, 2350, 12, 18502, 14, 9464, 14, 15325, 430, 267, 291, 14, 479, 2531, 15653, 14, 9464, 14, 572, 968, 8, 2350, 14, 24544, 4059, 267, 291, 14, 629, 8, 15653, 14, 9464, 14, 14028, 8, 2350, 14, 24544, 4000, 288, 3886, 3015, 2535, 72, 17, 30, 1421, 1108, 72, 17, 2535, 80, 30, 1700, 1108, 80, 2535, 657, 2535, 600, 30, 6185, 60, 78, 1108, 600, 2957, 657, 2957, 3015, 9579, 421, 199, 533, 1379, 3142, 2842, 2223, 8, 2796, 14, 1746, 304, 272, 408, 6496, 402, 314, 8511, 1021, 367, 8651, 2842, 14, 408, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 929, 275, 18502, 14, 1457, 2087, 14, 2223, 342, 339, 347, 511, 28083, 2223, 8, 277, 304, 267, 408, 1379, 8511, 1380, 2701, 14, 408, 267, 291, 14, 629, 8, 277, 14, 929, 12, 3073, 339, 347, 511, 1084, 51, 323, 8, 277, 304, 267, 408, 1379, 8511, 14, 409, 1252, 408, 267, 291, 14, 929, 14, 409, 360, 65, 63, 929, 358, 267, 291, 14, 629, 8, 277, 14, 929, 12, 788, 65, 63, 929, 1105, 267, 291, 14, 929, 14, 409, 360, 929, 18, 358, 267, 291, 14, 629, 8, 277, 14, 929, 12, 788, 65, 63, 929, 297, 283, 929, 18, 1105, 339, 347, 511, 1831, 51, 323, 8, 277, 304, 267, 408, 1379, 8511, 14, 374, 929, 1252, 408, 267, 291, 14, 629, 8, 277, 14, 929, 14, 374, 929, 360, 25058, 659, 756, 9, 267, 291, 14, 929, 14, 409, 360, 65, 63, 929, 358, 267, 291, 14, 629, 8, 277, 14, 929, 14, 374, 929, 360, 65, 63, 929, 659, 715, 9, 267, 291, 14, 929, 14, 409, 360, 929, 18, 358, 267, 291, 14, 629, 8, 277, 14, 929, 14, 374, 929, 360, 929, 18, 659, 715, 9, 267, 291, 14, 629, 8, 277, 14, 929, 14, 374, 929, 360, 65, 63, 929, 659, 756, 9, 267, 291, 14, 629, 8, 277, 14, 929, 14, 374, 929, 360, 4752, 659, 756, 9, 339, 347, 511, 9637, 8, 277, 304, 267, 408, 1379, 8511, 14, 3958, 1252, 408, 267, 291, 14, 929, 14, 409, 360, 65, 63, 929, 358, 267, 291, 14, 929, 14, 3958, 342, 267, 291, 14, 629, 8, 277, 14, 929, 12, 3073, 267, 291, 14, 929, 14, 409, 360, 929, 17, 358, 267, 291, 14, 929, 14, 409, 360, 929, 18, 358, 267, 291, 14, 929, 14, 3958, 342, 267, 291, 14, 629, 8, 277, 14, 929, 12, 788, 929, 17, 1105, 199, 199, 533, 1379, 12957, 933, 1119, 8, 2796, 14, 1746, 304, 272, 408, 1379, 24537, 1159, 20880, 933, 1119, 14, 408, 2286, 347, 3613, 8, 277, 304, 267, 291, 14, 27145, 275, 18502, 14, 657, 10547, 14, 12957, 933, 1119, 342, 267, 291, 14, 6199, 275, 291, 14, 27145, 14, 1617, 360, 1421, 358, 339, 347, 511, 3184, 5502, 8, 277, 304, 267, 408, 1379, 20880, 933, 1119, 14, 1617, 14, 408, 267, 291, 14, 629, 8, 277, 14, 6199, 12, 221, 586, 18502, 14, 657, 10547, 14, 4943, 63, 23068, 40, 15744, 450, 378, 9, 267, 291, 14, 629, 8, 277, 14, 27145, 14, 1360, 63, 5337, 12, 413, 9, 267, 291, 14, 629, 8, 277, 14, 27145, 14, 1773, 12957, 24996, 12, 4274, 1421, 297, 756, 3948, 339, 347, 511, 5502, 11053, 8, 277, 304, 267, 408, 1379, 20880, 933, 1119, 14, 1617, 543, 4722, 5664, 14, 408, 267, 10069, 275, 291, 14, 27145, 14, 1617, 360, 1700, 358, 267, 291, 14, 629, 8, 6199, 12, 221, 586, 18502, 14, 657, 10547, 14, 4943, 63, 23068, 40, 15744, 450, 413, 9, 267, 291, 14, 629, 8, 277, 14, 27145, 14, 1360, 63, 5337, 12, 499, 9, 267, 291, 14, 629, 8, 277, 14, 27145, 14, 1773, 12957, 24996, 12, 12723, 4274, 1421, 297, 756, 395, 661, 1700, 297, 756, 3948, 339, 347, 511, 11090, 5502, 8, 277, 304, 267, 408, 1379, 20880, 933, 1119, 14, 1617, 543, 283, 3489, 7, 3517, 14, 408, 267, 291, 14, 27145, 14, 1617, 360, 1700, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rderradi/AliPhysics
PWGJE/EMCALJetTasks/Tracks/analysis/base/struct/TriggerPatchTHnSparse.py
41
3251
#************************************************************************** #* Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. * #* * #* Author: The ALICE Off-line Project. * #* Contributors are mentioned in the code where appropriate. * #* * #* Permission to use, copy, modify and distribute this software and its * #* documentation strictly for non-commercial purposes is hereby granted * #* without fee, provided that the above copyright notice appears in all * #* copies and that both the copyright notice and this permission notice * #* appear in the supporting documentation. The authors make no claims * #* about the suitability of this software for any purpose. It is * #* provided "as is" without express or implied warranty. * #************************************************************************** from PWGJE.EMCALJetTasks.Tracks.analysis.base.struct.THnSparseWrapper import THnSparseWrapper, AxisFormat from copy import copy, deepcopy class AxisFormatTriggerPatches(AxisFormat): ''' Axis definition used in the trigger patch THnSparse ''' def __init__(self): ''' Constructor ''' AxisFormat.__init__(self, "patches") self._axes["energy"] = 0 self._axes["energyRough"] = 1 self._axes["amplitude"] = 2 self._axes["eta"] = 3 self._axes["phi"] = 4 self._axes["isMain"] = 5 def __copy__(self): ''' Shallow copy constructor ''' newobj = AxisFormatTriggerPatches() newobj._Copy(self) return newobj def __deepcopy__(self, memo): ''' Deep copy constructor ''' newobj = AxisFormatTriggerPatches() newobj._Deepcopy(self, memo) return newobj class TriggerPatchTHnSparse(THnSparseWrapper): ''' Representation of Patch THnSparse with axes - Offline Energy - Rough Energy - Amplitude - eta - phi - isMain ''' def __init__(self, roothist): ''' Constructor ''' THnSparseWrapper.__init__(self, roothist) self._axisdefinition = AxisFormatTriggerPatches() def __copy__(self): ''' Shallow copy constructor ''' result = TriggerPatchTHnSparse(copy(self._rootthnsparse)) result.CopyCuts(self, False) return result def __deepcopy__(self, memo): ''' Deep copy constructor ''' result = TriggerPatchTHnSparse(deepcopy(self._rootthnsparse)) result.CopyCuts(self, True) return result def SetEtaCut(self, etamin, etamax): ''' Apply cut in eta ''' self.ApplyCut("eta",etamin,etamax) def SetPhiCut(self, phimin, phimax): ''' Apply cut in phi ''' self.ApplyCut("phi", phimin, phimax) def SetMainPatch(self): ''' Request main patches ''' self.ApplyCut("isMain", 1, 1)
bsd-3-clause
[ 3, 14355, 538, 199, 15002, 1898, 8, 67, 9, 19960, 13, 7280, 12, 437, 2507, 37, 23997, 737, 24354, 12, 2900, 4481, 4644, 14, 627, 199, 15002, 6208, 263, 627, 199, 15002, 6529, 26, 710, 437, 2507, 37, 28856, 13, 604, 7290, 14, 27503, 627, 199, 15002, 23212, 787, 26239, 315, 314, 1233, 2382, 5827, 14, 4519, 627, 199, 15002, 6208, 263, 627, 199, 15002, 8779, 370, 675, 12, 1331, 12, 2811, 436, 11207, 642, 2032, 436, 2399, 257, 627, 199, 15002, 3794, 22699, 367, 2222, 13, 957, 23012, 12901, 365, 11882, 10009, 257, 627, 199, 15002, 1928, 14751, 12, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 1006, 257, 627, 199, 15002, 6866, 436, 626, 3865, 314, 4248, 4245, 436, 642, 4983, 4245, 257, 627, 199, 15002, 7468, 315, 314, 21038, 3794, 14, 710, 11462, 1852, 949, 6108, 11171, 258, 627, 199, 15002, 3595, 314, 308, 4993, 3616, 402, 642, 2032, 367, 1263, 12016, 14, 2779, 365, 3515, 627, 199, 15002, 2741, 298, 305, 365, 2, 1928, 4056, 503, 2478, 3750, 14, 8295, 627, 199, 3, 14355, 538, 199, 504, 510, 55, 39, 25074, 14, 2769, 13329, 42, 386, 19295, 14, 2437, 5618, 14, 10466, 14, 1095, 14, 1820, 14, 2080, 78, 8629, 4590, 492, 4221, 78, 8629, 4590, 12, 23205, 3484, 199, 504, 1331, 492, 1331, 12, 14800, 199, 199, 533, 23205, 3484, 16276, 11173, 397, 8, 11220, 3484, 304, 272, 1449, 272, 23205, 5492, 1202, 315, 314, 6804, 3371, 4221, 78, 8629, 272, 1449, 2286, 347, 636, 826, 721, 277, 304, 267, 1449, 267, 20297, 267, 1449, 267, 23205, 3484, 855, 826, 721, 277, 12, 298, 11350, 531, 267, 291, 423, 6402, 905, 8443, 937, 275, 378, 4960, 291, 423, 6402, 905, 8443, 50, 4937, 937, 275, 413, 267, 291, 423, 6402, 905, 31928, 937, 275, 499, 267, 291, 423, 6402, 905, 1841, 937, 275, 650, 267, 291, 423, 6402, 905, 10909, 937, 275, 841, 267, 291, 423, 6402, 905, 374, 6756, 937, 275, 959, 5493, 347, 636, 1574, 721, 277, 304, 267, 1449, 267, 5244, 3306, 1331, 3787, 267, 1449, 267, 892, 1113, 275, 23205, 3484, 16276, 11173, 397, 342, 267, 892, 1113, 423, 5116, 8, 277, 9, 267, 372, 892, 1113, 2286, 347, 636, 8293, 721, 277, 12, 11955, 304, 267, 1449, 267, 577, 7840, 1331, 3787, 267, 1449, 267, 892, 1113, 275, 23205, 3484, 16276, 11173, 397, 342, 267, 892, 1113, 423, 872, 6806, 8, 277, 12, 11955, 9, 267, 372, 892, 1113, 199, 199, 533, 24015, 11173, 2080, 78, 8629, 8, 2080, 78, 8629, 4590, 304, 272, 1449, 272, 17634, 425, 402, 19292, 4221, 78, 8629, 543, 7824, 272, 446, 28856, 604, 662, 1372, 4312, 272, 446, 820, 4937, 662, 1372, 4312, 272, 446, 437, 311, 18601, 272, 446, 20356, 5591, 446, 14524, 272, 446, 365, 6756, 272, 1449, 339, 347, 636, 826, 721, 277, 12, 882, 79, 273, 631, 304, 267, 1449, 267, 20297, 267, 1449, 267, 4221, 78, 8629, 4590, 855, 826, 721, 277, 12, 882, 79, 273, 631, 9, 267, 291, 423, 3127, 7463, 275, 23205, 3484, 16276, 11173, 397, 342, 5493, 347, 636, 1574, 721, 277, 304, 267, 1449, 267, 5244, 3306, 1331, 3787, 267, 1449, 267, 754, 275, 24015, 11173, 2080, 78, 8629, 8, 1574, 8, 277, 423, 1231, 273, 561, 1122, 430, 267, 754, 14, 5116, 35, 14608, 8, 277, 12, 756, 9, 267, 372, 754, 2286, 347, 636, 8293, 721, 277, 12, 11955, 304, 267, 1449, 267, 577, 7840, 1331, 3787, 267, 1449, 267, 754, 275, 24015, 11173, 2080, 78, 8629, 8, 8293, 8, 277, 423, 1231, 273, 561, 1122, 430, 267, 754, 14, 5116, 35, 14608, 8, 277, 12, 715, 9, 267, 372, 754, 5493, 347, 2494, 37, 502, 23498, 8, 277, 12, 10844, 32374, 12, 20356, 988, 304, 267, 1449, 267, 14618, 10415, 315, 20356, 267, 1449, 267, 291, 14, 16581, 23498, 480, 1841, 401, 386, 32374, 12, 1841, 988, 9, 2286, 347, 2494, 5663, 73, 23498, 8, 277, 12, 14524, 827, 12, 3945, 5744, 304, 267, 1449, 267, 14618, 10415, 315, 14524, 267, 1449, 267, 291, 14, 16581, 23498, 480, 10909, 401, 14524, 827, 12, 3945, 5744, 9, 5493, 347, 2494, 6756, 11173, 8, 277, 304, 267, 1449, 267, 4784, 2446, 12385, 267, 1449, 267, 291, 14, 16581, 23498, 480, 374, 6756, 401, 413, 12, 413, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 14355, 538, 199, 15002, 1898, 8, 67, 9, 19960, 13, 7280, 12, 437, 2507, 37, 23997, 737, 24354, 12, 2900, 4481, 4644, 14, 627, 199, 15002, 6208, 263, 627, 199, 15002, 6529, 26, 710, 437, 2507, 37, 28856, 13, 604, 7290, 14, 27503, 627, 199, 15002, 23212, 787, 26239, 315, 314, 1233, 2382, 5827, 14, 4519, 627, 199, 15002, 6208, 263, 627, 199, 15002, 8779, 370, 675, 12, 1331, 12, 2811, 436, 11207, 642, 2032, 436, 2399, 257, 627, 199, 15002, 3794, 22699, 367, 2222, 13, 957, 23012, 12901, 365, 11882, 10009, 257, 627, 199, 15002, 1928, 14751, 12, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 1006, 257, 627, 199, 15002, 6866, 436, 626, 3865, 314, 4248, 4245, 436, 642, 4983, 4245, 257, 627, 199, 15002, 7468, 315, 314, 21038, 3794, 14, 710, 11462, 1852, 949, 6108, 11171, 258, 627, 199, 15002, 3595, 314, 308, 4993, 3616, 402, 642, 2032, 367, 1263, 12016, 14, 2779, 365, 3515, 627, 199, 15002, 2741, 298, 305, 365, 2, 1928, 4056, 503, 2478, 3750, 14, 8295, 627, 199, 3, 14355, 538, 199, 504, 510, 55, 39, 25074, 14, 2769, 13329, 42, 386, 19295, 14, 2437, 5618, 14, 10466, 14, 1095, 14, 1820, 14, 2080, 78, 8629, 4590, 492, 4221, 78, 8629, 4590, 12, 23205, 3484, 199, 504, 1331, 492, 1331, 12, 14800, 199, 199, 533, 23205, 3484, 16276, 11173, 397, 8, 11220, 3484, 304, 272, 1449, 272, 23205, 5492, 1202, 315, 314, 6804, 3371, 4221, 78, 8629, 272, 1449, 2286, 347, 636, 826, 721, 277, 304, 267, 1449, 267, 20297, 267, 1449, 267, 23205, 3484, 855, 826, 721, 277, 12, 298, 11350, 531, 267, 291, 423, 6402, 905, 8443, 937, 275, 378, 4960, 291, 423, 6402, 905, 8443, 50, 4937, 937, 275, 413, 267, 291, 423, 6402, 905, 31928, 937, 275, 499, 267, 291, 423, 6402, 905, 1841, 937, 275, 650, 267, 291, 423, 6402, 905, 10909, 937, 275, 841, 267, 291, 423, 6402, 905, 374, 6756, 937, 275, 959, 5493, 347, 636, 1574, 721, 277, 304, 267, 1449, 267, 5244, 3306, 1331, 3787, 267, 1449, 267, 892, 1113, 275, 23205, 3484, 16276, 11173, 397, 342, 267, 892, 1113, 423, 5116, 8, 277, 9, 267, 372, 892, 1113, 2286, 347, 636, 8293, 721, 277, 12, 11955, 304, 267, 1449, 267, 577, 7840, 1331, 3787, 267, 1449, 267, 892, 1113, 275, 23205, 3484, 16276, 11173, 397, 342, 267, 892, 1113, 423, 872, 6806, 8, 277, 12, 11955, 9, 267, 372, 892, 1113, 199, 199, 533, 24015, 11173, 2080, 78, 8629, 8, 2080, 78, 8629, 4590, 304, 272, 1449, 272, 17634, 425, 402, 19292, 4221, 78, 8629, 543, 7824, 272, 446, 28856, 604, 662, 1372, 4312, 272, 446, 820, 4937, 662, 1372, 4312, 272, 446, 437, 311, 18601, 272, 446, 20356, 5591, 446, 14524, 272, 446, 365, 6756, 272, 1449, 339, 347, 636, 826, 721, 277, 12, 882, 79, 273, 631, 304, 267, 1449, 267, 20297, 267, 1449, 267, 4221, 78, 8629, 4590, 855, 826, 721, 277, 12, 882, 79, 273, 631, 9, 267, 291, 423, 3127, 7463, 275, 23205, 3484, 16276, 11173, 397, 342, 5493, 347, 636, 1574, 721, 277, 304, 267, 1449, 267, 5244, 3306, 1331, 3787, 267, 1449, 267, 754, 275, 24015, 11173, 2080, 78, 8629, 8, 1574, 8, 277, 423, 1231, 273, 561, 1122, 430, 267, 754, 14, 5116, 35, 14608, 8, 277, 12, 756, 9, 267, 372, 754, 2286, 347, 636, 8293, 721, 277, 12, 11955, 304, 267, 1449, 267, 577, 7840, 1331, 3787, 267, 1449, 267, 754, 275, 24015, 11173, 2080, 78, 8629, 8, 8293, 8, 277, 423, 1231, 273, 561, 1122, 430, 267, 754, 14, 5116, 35, 14608, 8, 277, 12, 715, 9, 267, 372, 754, 5493, 347, 2494, 37, 502, 23498, 8, 277, 12, 10844, 32374, 12, 20356, 988, 304, 267, 1449, 267, 14618, 10415, 315, 20356, 267, 1449, 267, 291, 14, 16581, 23498, 480, 1841, 401, 386, 32374, 12, 1841, 988, 9, 2286, 347, 2494, 5663, 73, 23498, 8, 277, 12, 14524, 827, 12, 3945, 5744, 304, 267, 1449, 267, 14618, 10415, 315, 14524, 267, 1449, 267, 291, 14, 16581, 23498, 480, 10909, 401, 14524, 827, 12, 3945, 5744, 9, 5493, 347, 2494, 6756, 11173, 8, 277, 304, 267, 1449, 267, 4784, 2446, 12385, 267, 1449, 267, 291, 14, 16581, 23498, 480, 374, 6756, 401, 413, 12, 413, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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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 ]
camilonova/django
tests/utils_tests/test_decorators.py
93
4792
from django.http import HttpResponse from django.template import engines from django.template.response import TemplateResponse from django.test import RequestFactory, SimpleTestCase from django.utils.decorators import classproperty, decorator_from_middleware class ProcessViewMiddleware: def process_view(self, request, view_func, view_args, view_kwargs): pass process_view_dec = decorator_from_middleware(ProcessViewMiddleware) @process_view_dec def process_view(request): return HttpResponse() class ClassProcessView: def __call__(self, request): return HttpResponse() class_process_view = process_view_dec(ClassProcessView()) class FullMiddleware: def process_request(self, request): request.process_request_reached = True def process_view(self, request, view_func, view_args, view_kwargs): request.process_view_reached = True def process_template_response(self, request, response): request.process_template_response_reached = True return response def process_response(self, request, response): # This should never receive unrendered content. request.process_response_content = response.content request.process_response_reached = True return response full_dec = decorator_from_middleware(FullMiddleware) class DecoratorFromMiddlewareTests(SimpleTestCase): """ Tests for view decorators created using ``django.utils.decorators.decorator_from_middleware``. """ rf = RequestFactory() def test_process_view_middleware(self): """ Test a middleware that implements process_view. """ process_view(self.rf.get('/')) def test_callable_process_view_middleware(self): """ Test a middleware that implements process_view, operating on a callable class. """ class_process_view(self.rf.get('/')) def test_full_dec_normal(self): """ All methods of middleware are called for normal HttpResponses """ @full_dec def normal_view(request): template = engines['django'].from_string("Hello world") return HttpResponse(template.render()) request = self.rf.get('/') normal_view(request) self.assertTrue(getattr(request, 'process_request_reached', False)) self.assertTrue(getattr(request, 'process_view_reached', False)) # process_template_response must not be called for HttpResponse self.assertFalse(getattr(request, 'process_template_response_reached', False)) self.assertTrue(getattr(request, 'process_response_reached', False)) def test_full_dec_templateresponse(self): """ All methods of middleware are called for TemplateResponses in the right sequence. """ @full_dec def template_response_view(request): template = engines['django'].from_string("Hello world") return TemplateResponse(request, template) request = self.rf.get('/') response = template_response_view(request) self.assertTrue(getattr(request, 'process_request_reached', False)) self.assertTrue(getattr(request, 'process_view_reached', False)) self.assertTrue(getattr(request, 'process_template_response_reached', False)) # response must not be rendered yet. self.assertFalse(response._is_rendered) # process_response must not be called until after response is rendered, # otherwise some decorators like csrf_protect and gzip_page will not # work correctly. See #16004 self.assertFalse(getattr(request, 'process_response_reached', False)) response.render() self.assertTrue(getattr(request, 'process_response_reached', False)) # process_response saw the rendered content self.assertEqual(request.process_response_content, b"Hello world") class ClassPropertyTest(SimpleTestCase): def test_getter(self): class Foo: foo_attr = 123 def __init__(self): self.foo_attr = 456 @classproperty def foo(cls): return cls.foo_attr class Bar: bar = classproperty() @bar.getter def bar(cls): return 123 self.assertEqual(Foo.foo, 123) self.assertEqual(Foo().foo, 123) self.assertEqual(Bar.bar, 123) self.assertEqual(Bar().bar, 123) def test_override_getter(self): class Foo: @classproperty def foo(cls): return 123 @foo.getter def foo(cls): return 456 self.assertEqual(Foo.foo, 456) self.assertEqual(Foo().foo, 456)
bsd-3-clause
[ 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 1160, 492, 28156, 199, 504, 1639, 14, 1160, 14, 1310, 492, 29264, 199, 504, 1639, 14, 396, 492, 18638, 12, 24424, 199, 504, 1639, 14, 1208, 14, 11582, 492, 1021, 1829, 12, 7531, 63, 504, 63, 5754, 421, 199, 533, 7132, 24060, 26, 272, 347, 2112, 63, 1345, 8, 277, 12, 1056, 12, 2455, 63, 1532, 12, 2455, 63, 589, 12, 2455, 63, 958, 304, 267, 986, 421, 199, 1412, 63, 1345, 63, 7778, 275, 7531, 63, 504, 63, 5754, 8, 3498, 24060, 9, 421, 199, 32, 1412, 63, 1345, 63, 7778, 199, 318, 2112, 63, 1345, 8, 1069, 304, 272, 372, 6183, 342, 421, 199, 533, 8089, 3498, 2768, 26, 272, 347, 636, 1250, 721, 277, 12, 1056, 304, 267, 372, 6183, 342, 421, 199, 533, 63, 1412, 63, 1345, 275, 2112, 63, 1345, 63, 7778, 8, 2543, 3498, 2768, 1012, 421, 199, 533, 16579, 6608, 26, 272, 347, 2112, 63, 1069, 8, 277, 12, 1056, 304, 267, 1056, 14, 1412, 63, 1069, 63, 30931, 275, 715, 339, 347, 2112, 63, 1345, 8, 277, 12, 1056, 12, 2455, 63, 1532, 12, 2455, 63, 589, 12, 2455, 63, 958, 304, 267, 1056, 14, 1412, 63, 1345, 63, 30931, 275, 715, 339, 347, 2112, 63, 1160, 63, 1310, 8, 277, 12, 1056, 12, 1177, 304, 267, 1056, 14, 1412, 63, 1160, 63, 1310, 63, 30931, 275, 715, 267, 372, 1177, 339, 347, 2112, 63, 1310, 8, 277, 12, 1056, 12, 1177, 304, 267, 327, 961, 1077, 7078, 9128, 625, 16841, 1564, 14, 267, 1056, 14, 1412, 63, 1310, 63, 1317, 275, 1177, 14, 1317, 267, 1056, 14, 1412, 63, 1310, 63, 30931, 275, 715, 267, 372, 1177, 421, 199, 2861, 63, 7778, 275, 7531, 63, 504, 63, 5754, 8, 9042, 6608, 9, 421, 199, 533, 30684, 2532, 6608, 2925, 8, 17968, 304, 272, 408, 272, 6496, 367, 2455, 20419, 2737, 1808, 272, 1124, 1176, 14, 1208, 14, 11582, 14, 11547, 63, 504, 63, 5754, 4345, 272, 408, 272, 17781, 275, 18638, 342, 339, 347, 511, 63, 1412, 63, 1345, 63, 5754, 8, 277, 304, 267, 408, 267, 1379, 282, 10816, 626, 9031, 2112, 63, 1345, 14, 267, 408, 267, 2112, 63, 1345, 8, 277, 14, 3941, 14, 362, 28684, 339, 347, 511, 63, 8296, 63, 1412, 63, 1345, 63, 5754, 8, 277, 304, 267, 408, 267, 1379, 282, 10816, 626, 9031, 2112, 63, 1345, 12, 17406, 641, 282, 4550, 1021, 14, 267, 408, 267, 1021, 63, 1412, 63, 1345, 8, 277, 14, 3941, 14, 362, 28684, 339, 347, 511, 63, 2861, 63, 7778, 63, 3302, 8, 277, 304, 267, 408, 267, 2900, 3102, 402, 10816, 787, 2797, 367, 3293, 6183, 83, 267, 408, 267, 768, 2861, 63, 7778, 267, 347, 3293, 63, 1345, 8, 1069, 304, 288, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 480, 6257, 6701, 531, 288, 372, 6183, 8, 1160, 14, 3352, 1012, 398, 1056, 275, 291, 14, 3941, 14, 362, 7825, 267, 3293, 63, 1345, 8, 1069, 9, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1069, 63, 30931, 297, 756, 430, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1345, 63, 30931, 297, 756, 430, 267, 327, 2112, 63, 1160, 63, 1310, 1471, 440, 506, 2797, 367, 6183, 267, 291, 14, 3334, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1160, 63, 1310, 63, 30931, 297, 756, 430, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1310, 63, 30931, 297, 756, 430, 339, 347, 511, 63, 2861, 63, 7778, 63, 1160, 1310, 8, 277, 304, 267, 408, 267, 2900, 3102, 402, 10816, 787, 2797, 367, 29264, 83, 315, 267, 314, 2451, 3414, 14, 267, 408, 267, 768, 2861, 63, 7778, 267, 347, 1978, 63, 1310, 63, 1345, 8, 1069, 304, 288, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 480, 6257, 6701, 531, 288, 372, 29264, 8, 1069, 12, 1978, 9, 398, 1056, 275, 291, 14, 3941, 14, 362, 7825, 267, 1177, 275, 1978, 63, 1310, 63, 1345, 8, 1069, 9, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1069, 63, 30931, 297, 756, 430, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1345, 63, 30931, 297, 756, 430, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1160, 63, 1310, 63, 30931, 297, 756, 430, 267, 327, 1177, 1471, 440, 506, 8018, 5966, 14, 267, 291, 14, 3334, 8, 1310, 423, 374, 63, 16841, 9, 267, 327, 2112, 63, 1310, 1471, 440, 506, 2797, 5133, 2410, 1177, 365, 8018, 12, 267, 327, 4257, 2005, 20419, 2839, 19213, 63, 18292, 436, 11756, 63, 1606, 911, 440, 267, 327, 1736, 6657, 14, 1666, 327, 975, 7979, 267, 291, 14, 3334, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1310, 63, 30931, 297, 756, 430, 267, 1177, 14, 3352, 342, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1310, 63, 30931, 297, 756, 430, 267, 327, 2112, 63, 1310, 28454, 314, 8018, 1564, 267, 291, 14, 629, 8, 1069, 14, 1412, 63, 1310, 63, 1317, 12, 330, 2, 6257, 6701, 531, 421, 199, 533, 8089, 3697, 774, 8, 17968, 304, 272, 347, 511, 63, 7416, 8, 277, 304, 267, 1021, 8024, 26, 288, 3925, 63, 962, 275, 11869, 953, 347, 636, 826, 721, 277, 304, 355, 291, 14, 1421, 63, 962, 275, 31944, 953, 768, 533, 1829, 288, 347, 3925, 8, 1886, 304, 355, 372, 843, 14, 1421, 63, 962, 398, 1021, 12377, 26, 288, 4681, 275, 1021, 1829, 342, 953, 768, 1700, 14, 7416, 288, 347, 4681, 8, 1886, 304, 355, 372, 11869, 398, 291, 14, 629, 8, 5686, 14, 1421, 12, 11869, 9, 267, 291, 14, 629, 8, 5686, 1252, 1421, 12, 11869, 9, 267, 291, 14, 629, 8, 5281, 14, 1700, 12, 11869, 9, 267, 291, 14, 629, 8, 5281, 1252, 1700, 12, 11869, 9, 339, 347, 511, 63, 4415, 63, 7416, 8, 277, 304, 267, 1021, 8024, 26, 288, 768, 533, 1829, 288, 347, 3925, 8, 1886, 304, 355, 372, 11869, 953, 768, 1421, 14, 7416, 288, 347 ]
[ 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 1160, 492, 28156, 199, 504, 1639, 14, 1160, 14, 1310, 492, 29264, 199, 504, 1639, 14, 396, 492, 18638, 12, 24424, 199, 504, 1639, 14, 1208, 14, 11582, 492, 1021, 1829, 12, 7531, 63, 504, 63, 5754, 421, 199, 533, 7132, 24060, 26, 272, 347, 2112, 63, 1345, 8, 277, 12, 1056, 12, 2455, 63, 1532, 12, 2455, 63, 589, 12, 2455, 63, 958, 304, 267, 986, 421, 199, 1412, 63, 1345, 63, 7778, 275, 7531, 63, 504, 63, 5754, 8, 3498, 24060, 9, 421, 199, 32, 1412, 63, 1345, 63, 7778, 199, 318, 2112, 63, 1345, 8, 1069, 304, 272, 372, 6183, 342, 421, 199, 533, 8089, 3498, 2768, 26, 272, 347, 636, 1250, 721, 277, 12, 1056, 304, 267, 372, 6183, 342, 421, 199, 533, 63, 1412, 63, 1345, 275, 2112, 63, 1345, 63, 7778, 8, 2543, 3498, 2768, 1012, 421, 199, 533, 16579, 6608, 26, 272, 347, 2112, 63, 1069, 8, 277, 12, 1056, 304, 267, 1056, 14, 1412, 63, 1069, 63, 30931, 275, 715, 339, 347, 2112, 63, 1345, 8, 277, 12, 1056, 12, 2455, 63, 1532, 12, 2455, 63, 589, 12, 2455, 63, 958, 304, 267, 1056, 14, 1412, 63, 1345, 63, 30931, 275, 715, 339, 347, 2112, 63, 1160, 63, 1310, 8, 277, 12, 1056, 12, 1177, 304, 267, 1056, 14, 1412, 63, 1160, 63, 1310, 63, 30931, 275, 715, 267, 372, 1177, 339, 347, 2112, 63, 1310, 8, 277, 12, 1056, 12, 1177, 304, 267, 327, 961, 1077, 7078, 9128, 625, 16841, 1564, 14, 267, 1056, 14, 1412, 63, 1310, 63, 1317, 275, 1177, 14, 1317, 267, 1056, 14, 1412, 63, 1310, 63, 30931, 275, 715, 267, 372, 1177, 421, 199, 2861, 63, 7778, 275, 7531, 63, 504, 63, 5754, 8, 9042, 6608, 9, 421, 199, 533, 30684, 2532, 6608, 2925, 8, 17968, 304, 272, 408, 272, 6496, 367, 2455, 20419, 2737, 1808, 272, 1124, 1176, 14, 1208, 14, 11582, 14, 11547, 63, 504, 63, 5754, 4345, 272, 408, 272, 17781, 275, 18638, 342, 339, 347, 511, 63, 1412, 63, 1345, 63, 5754, 8, 277, 304, 267, 408, 267, 1379, 282, 10816, 626, 9031, 2112, 63, 1345, 14, 267, 408, 267, 2112, 63, 1345, 8, 277, 14, 3941, 14, 362, 28684, 339, 347, 511, 63, 8296, 63, 1412, 63, 1345, 63, 5754, 8, 277, 304, 267, 408, 267, 1379, 282, 10816, 626, 9031, 2112, 63, 1345, 12, 17406, 641, 282, 4550, 1021, 14, 267, 408, 267, 1021, 63, 1412, 63, 1345, 8, 277, 14, 3941, 14, 362, 28684, 339, 347, 511, 63, 2861, 63, 7778, 63, 3302, 8, 277, 304, 267, 408, 267, 2900, 3102, 402, 10816, 787, 2797, 367, 3293, 6183, 83, 267, 408, 267, 768, 2861, 63, 7778, 267, 347, 3293, 63, 1345, 8, 1069, 304, 288, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 480, 6257, 6701, 531, 288, 372, 6183, 8, 1160, 14, 3352, 1012, 398, 1056, 275, 291, 14, 3941, 14, 362, 7825, 267, 3293, 63, 1345, 8, 1069, 9, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1069, 63, 30931, 297, 756, 430, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1345, 63, 30931, 297, 756, 430, 267, 327, 2112, 63, 1160, 63, 1310, 1471, 440, 506, 2797, 367, 6183, 267, 291, 14, 3334, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1160, 63, 1310, 63, 30931, 297, 756, 430, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1310, 63, 30931, 297, 756, 430, 339, 347, 511, 63, 2861, 63, 7778, 63, 1160, 1310, 8, 277, 304, 267, 408, 267, 2900, 3102, 402, 10816, 787, 2797, 367, 29264, 83, 315, 267, 314, 2451, 3414, 14, 267, 408, 267, 768, 2861, 63, 7778, 267, 347, 1978, 63, 1310, 63, 1345, 8, 1069, 304, 288, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 480, 6257, 6701, 531, 288, 372, 29264, 8, 1069, 12, 1978, 9, 398, 1056, 275, 291, 14, 3941, 14, 362, 7825, 267, 1177, 275, 1978, 63, 1310, 63, 1345, 8, 1069, 9, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1069, 63, 30931, 297, 756, 430, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1345, 63, 30931, 297, 756, 430, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1160, 63, 1310, 63, 30931, 297, 756, 430, 267, 327, 1177, 1471, 440, 506, 8018, 5966, 14, 267, 291, 14, 3334, 8, 1310, 423, 374, 63, 16841, 9, 267, 327, 2112, 63, 1310, 1471, 440, 506, 2797, 5133, 2410, 1177, 365, 8018, 12, 267, 327, 4257, 2005, 20419, 2839, 19213, 63, 18292, 436, 11756, 63, 1606, 911, 440, 267, 327, 1736, 6657, 14, 1666, 327, 975, 7979, 267, 291, 14, 3334, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1310, 63, 30931, 297, 756, 430, 267, 1177, 14, 3352, 342, 267, 291, 14, 1815, 8, 5675, 8, 1069, 12, 283, 1412, 63, 1310, 63, 30931, 297, 756, 430, 267, 327, 2112, 63, 1310, 28454, 314, 8018, 1564, 267, 291, 14, 629, 8, 1069, 14, 1412, 63, 1310, 63, 1317, 12, 330, 2, 6257, 6701, 531, 421, 199, 533, 8089, 3697, 774, 8, 17968, 304, 272, 347, 511, 63, 7416, 8, 277, 304, 267, 1021, 8024, 26, 288, 3925, 63, 962, 275, 11869, 953, 347, 636, 826, 721, 277, 304, 355, 291, 14, 1421, 63, 962, 275, 31944, 953, 768, 533, 1829, 288, 347, 3925, 8, 1886, 304, 355, 372, 843, 14, 1421, 63, 962, 398, 1021, 12377, 26, 288, 4681, 275, 1021, 1829, 342, 953, 768, 1700, 14, 7416, 288, 347, 4681, 8, 1886, 304, 355, 372, 11869, 398, 291, 14, 629, 8, 5686, 14, 1421, 12, 11869, 9, 267, 291, 14, 629, 8, 5686, 1252, 1421, 12, 11869, 9, 267, 291, 14, 629, 8, 5281, 14, 1700, 12, 11869, 9, 267, 291, 14, 629, 8, 5281, 1252, 1700, 12, 11869, 9, 339, 347, 511, 63, 4415, 63, 7416, 8, 277, 304, 267, 1021, 8024, 26, 288, 768, 533, 1829, 288, 347, 3925, 8, 1886, 304, 355, 372, 11869, 953, 768, 1421, 14, 7416, 288, 347, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sestrella/ansible
lib/ansible/modules/storage/netapp/netapp_e_iscsi_target.py
24
10686
#!/usr/bin/python # (c) 2018, NetApp, Inc # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = """ --- module: netapp_e_iscsi_target short_description: NetApp E-Series manage iSCSI target configuration description: - Configure the settings of an E-Series iSCSI target version_added: '2.7' author: Michael Price (@lmprice) extends_documentation_fragment: - netapp.eseries options: name: description: - The name/alias to assign to the iSCSI target. - This alias is often used by the initiator software in order to make an iSCSI target easier to identify. aliases: - alias ping: description: - Enable ICMP ping responses from the configured iSCSI ports. type: bool default: yes chap_secret: description: - Enable Challenge-Handshake Authentication Protocol (CHAP), utilizing this value as the password. - When this value is specified, we will always trigger an update (changed=True). We have no way of verifying whether or not the password has changed. - The chap secret may only use ascii characters with values between 32 and 126 decimal. - The chap secret must be no less than 12 characters, but no greater than 57 characters in length. - The chap secret is cleared when not specified or an empty string. aliases: - chap - password unnamed_discovery: description: - When an initiator initiates a discovery session to an initiator port, it is considered an unnamed discovery session if the iSCSI target iqn is not specified in the request. - This option may be disabled to increase security if desired. type: bool default: yes log_path: description: - A local path (on the Ansible controller), to a file to be used for debug logging. required: no notes: - Check mode is supported. - Some of the settings are dependent on the settings applied to the iSCSI interfaces. These can be configured using M(netapp_e_iscsi_interface). - This module requires a Web Services API version of >= 1.3. """ EXAMPLES = """ - name: Enable ping responses and unnamed discovery sessions for all iSCSI ports netapp_e_iscsi_target: api_url: "https://localhost:8443/devmgr/v2" api_username: admin api_password: myPassword ssid: "1" validate_certs: no name: myTarget ping: yes unnamed_discovery: yes - name: Set the target alias and the CHAP secret netapp_e_iscsi_target: ssid: "{{ ssid }}" api_url: "{{ netapp_api_url }}" api_username: "{{ netapp_api_username }}" api_password: "{{ netapp_api_password }}" name: myTarget chap: password1234 """ RETURN = """ msg: description: Success message returned: on success type: str sample: The iSCSI target settings have been updated. alias: description: - The alias assigned to the iSCSI target. returned: on success sample: myArray type: str iqn: description: - The iqn (iSCSI Qualified Name), assigned to the iSCSI target. returned: on success sample: iqn.1992-08.com.netapp:2800.000a132000b006d2000000005a0e8f45 type: str """ import json import logging from pprint import pformat from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.netapp import request, eseries_host_argument_spec from ansible.module_utils._text import to_native HEADERS = { "Content-Type": "application/json", "Accept": "application/json", } class IscsiTarget(object): def __init__(self): argument_spec = eseries_host_argument_spec() argument_spec.update(dict( name=dict(type='str', required=False, aliases=['alias']), ping=dict(type='bool', required=False, default=True), chap_secret=dict(type='str', required=False, aliases=['chap', 'password'], no_log=True), unnamed_discovery=dict(type='bool', required=False, default=True), log_path=dict(type='str', required=False), )) self.module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True, ) args = self.module.params self.name = args['name'] self.ping = args['ping'] self.chap_secret = args['chap_secret'] self.unnamed_discovery = args['unnamed_discovery'] self.ssid = args['ssid'] self.url = args['api_url'] self.creds = dict(url_password=args['api_password'], validate_certs=args['validate_certs'], url_username=args['api_username'], ) self.check_mode = self.module.check_mode self.post_body = dict() self.controllers = list() log_path = args['log_path'] # logging setup self._logger = logging.getLogger(self.__class__.__name__) if log_path: logging.basicConfig( level=logging.DEBUG, filename=log_path, filemode='w', format='%(relativeCreated)dms %(levelname)s %(module)s.%(funcName)s:%(lineno)d\n %(message)s') if not self.url.endswith('/'): self.url += '/' if self.chap_secret: if len(self.chap_secret) < 12 or len(self.chap_secret) > 57: self.module.fail_json(msg="The provided CHAP secret is not valid, it must be between 12 and 57" " characters in length.") for c in self.chap_secret: ordinal = ord(c) if ordinal < 32 or ordinal > 126: self.module.fail_json(msg="The provided CHAP secret is not valid, it may only utilize ascii" " characters with decimal values between 32 and 126.") @property def target(self): """Provide information on the iSCSI Target configuration Sample: { 'alias': 'myCustomName', 'ping': True, 'unnamed_discovery': True, 'chap': False, 'iqn': 'iqn.1992-08.com.netapp:2800.000a132000b006d2000000005a0e8f45', } """ target = dict() try: (rc, data) = request(self.url + 'storage-systems/%s/graph/xpath-filter?query=/storagePoolBundle/target' % self.ssid, headers=HEADERS, **self.creds) # This likely isn't an iSCSI-enabled system if not data: self.module.fail_json( msg="This storage-system doesn't appear to have iSCSI interfaces. Array Id [%s]." % (self.ssid)) data = data[0] chap = any( [auth for auth in data['configuredAuthMethods']['authMethodData'] if auth['authMethod'] == 'chap']) target.update(dict(alias=data['alias']['iscsiAlias'], iqn=data['nodeName']['iscsiNodeName'], chap=chap)) (rc, data) = request(self.url + 'storage-systems/%s/graph/xpath-filter?query=/sa/iscsiEntityData' % self.ssid, headers=HEADERS, **self.creds) data = data[0] target.update(dict(ping=data['icmpPingResponseEnabled'], unnamed_discovery=data['unnamedDiscoverySessionsEnabled'])) except Exception as err: self.module.fail_json( msg="Failed to retrieve the iSCSI target information. Array Id [%s]. Error [%s]." % (self.ssid, to_native(err))) return target def apply_iscsi_settings(self): """Update the iSCSI target alias and CHAP settings""" update = False target = self.target body = dict() if self.name is not None and self.name != target['alias']: update = True body['alias'] = self.name # If the CHAP secret was provided, we trigger an update. if self.chap_secret: update = True body.update(dict(enableChapAuthentication=True, chapSecret=self.chap_secret)) # If no secret was provided, then we disable chap elif target['chap']: update = True body.update(dict(enableChapAuthentication=False)) if update and not self.check_mode: try: request(self.url + 'storage-systems/%s/iscsi/target-settings' % self.ssid, method='POST', data=json.dumps(body), headers=HEADERS, **self.creds) except Exception as err: self.module.fail_json( msg="Failed to update the iSCSI target settings. Array Id [%s]. Error [%s]." % (self.ssid, to_native(err))) return update def apply_target_changes(self): update = False target = self.target body = dict() if self.ping != target['ping']: update = True body['icmpPingResponseEnabled'] = self.ping if self.unnamed_discovery != target['unnamed_discovery']: update = True body['unnamedDiscoverySessionsEnabled'] = self.unnamed_discovery self._logger.info(pformat(body)) if update and not self.check_mode: try: request(self.url + 'storage-systems/%s/iscsi/entity' % self.ssid, method='POST', data=json.dumps(body), timeout=60, headers=HEADERS, **self.creds) except Exception as err: self.module.fail_json( msg="Failed to update the iSCSI target settings. Array Id [%s]. Error [%s]." % (self.ssid, to_native(err))) return update def update(self): update = self.apply_iscsi_settings() update = self.apply_target_changes() or update target = self.target data = dict((key, target[key]) for key in target if key in ['iqn', 'alias']) self.module.exit_json(msg="The interface settings have been updated.", changed=update, **data) def __call__(self, *args, **kwargs): self.update() def main(): iface = IscsiTarget() iface() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 334, 67, 9, 14894, 12, 28076, 12, 3277, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 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, 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, 408, 199, 2595, 199, 578, 26, 15742, 63, 69, 63, 17139, 63, 1375, 199, 3612, 63, 1802, 26, 28076, 662, 13, 9641, 9635, 284, 16958, 1347, 2897, 199, 1802, 26, 272, 446, 15453, 314, 2202, 402, 376, 662, 13, 9641, 284, 16958, 1347, 199, 1023, 63, 3270, 26, 283, 18, 14, 23, 7, 199, 2502, 26, 16922, 20276, 8593, 76, 311, 322, 301, 9, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 15742, 14, 69, 5602, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 710, 536, 15, 3620, 370, 5090, 370, 314, 284, 16958, 1347, 14, 288, 446, 961, 5162, 365, 14115, 1202, 701, 314, 22094, 2032, 315, 1865, 370, 1852, 376, 284, 16958, 1347, 14905, 370, 10405, 14, 267, 5481, 26, 288, 446, 5162, 272, 18249, 26, 267, 1369, 26, 288, 446, 12030, 473, 23181, 18249, 9320, 687, 314, 7526, 284, 16958, 8873, 14, 267, 730, 26, 2155, 267, 849, 26, 9456, 272, 682, 439, 63, 4731, 26, 267, 1369, 26, 288, 446, 12030, 2799, 8537, 13, 26392, 15995, 11557, 334, 1244, 1282, 395, 7678, 19030, 316, 642, 574, 465, 314, 2505, 14, 288, 446, 3979, 642, 574, 365, 2013, 12, 781, 911, 3544, 6804, 376, 1678, 334, 2489, 29, 549, 680, 2136, 1172, 949, 4340, 402, 31866, 1598, 3775, 503, 440, 314, 2505, 965, 2896, 14, 288, 446, 710, 682, 439, 7565, 1443, 1454, 675, 13294, 4110, 543, 1338, 3382, 4337, 436, 21572, 6107, 14, 288, 446, 710, 682, 439, 7565, 1471, 506, 949, 6656, 2419, 3144, 4110, 12, 1325, 949, 8932, 2419, 12699, 4110, 315, 2582, 14, 288, 446, 710, 682, 439, 7565, 365, 20518, 1380, 440, 2013, 503, 376, 2701, 1059, 14, 267, 5481, 26, 288, 446, 682, 439, 288, 446, 2505, 272, 625, 4579, 63, 14859, 26, 267, 1369, 26, 288, 446, 3979, 376, 22094, 11023, 2335, 282, 13172, 2351, 370, 376, 22094, 1844, 12, 652, 365, 8652, 376, 625, 4579, 1598, 13172, 2351, 340, 314, 284, 16958, 1347, 284, 15156, 365, 440, 2013, 315, 314, 1056, 14, 288, 446, 961, 945, 1443, 506, 6980, 370, 19781, 6391, 340, 6387, 14, 267, 730, 26, 2155, 267, 849, 26, 9456, 272, 943, 63, 515, 26, 267, 1369, 26, 288, 446, 437, 2257, 931, 334, 265, 314, 2622, 7614, 395, 370, 282, 570, 370, 506, 1202, 367, 3105, 2050, 14, 267, 1415, 26, 949, 199, 5983, 26, 272, 446, 2670, 818, 365, 3748, 14, 272, 446, 6601, 402, 314, 2202, 787, 11410, 641, 314, 2202, 6781, 370, 314, 284, 16958, 8386, 14, 5723, 883, 506, 7526, 1808, 489, 603, 8, 25830, 63, 69, 63, 17139, 63, 3266, 680, 272, 446, 961, 859, 5074, 282, 6001, 21813, 3261, 1015, 402, 2356, 413, 14, 19, 14, 199, 624, 199, 199, 8918, 275, 408, 272, 446, 536, 26, 12030, 18249, 9320, 436, 625, 4579, 13172, 12184, 367, 1006, 284, 16958, 8873, 489, 15742, 63, 69, 63, 17139, 63, 1375, 26, 267, 2986, 63, 633, 26, 298, 2859, 921, 5967, 26, 1349, 2824, 15, 2374, 7755, 15, 86, 18, 2, 267, 2986, 63, 2473, 26, 4628, 267, 2986, 63, 2060, 26, 3002, 6139, 267, 25891, 26, 298, 17, 2, 267, 4107, 63, 8356, 26, 949, 267, 536, 26, 3002, 4277, 267, 18249, 26, 9456, 267, 625, 4579, 63, 14859, 26, 9456, 339, 446, 536, 26, 2494, 314, 1347, 5162, 436, 314, 6624, 1282, 7565, 489, 15742, 63, 69, 63, 17139, 63, 1375, 26, 267, 25891, 26, 7370, 25891, 7820, 267, 2986, 63, 633, 26, 7370, 15742, 63, 1246, 63, 633, 7820, 267, 2986, 63, 2473, 26, 7370, 15742, 63, 1246, 63, 2473, 7820, 267, 2986, 63, 2060, 26, 7370, 15742, 63, 1246, 63, 2060, 7820, 267, 536, 26, 3002, 4277, 267, 682, 439, 26, 2505, 4321, 199, 624, 199, 199, 9677, 275, 408, 199, 1328, 26, 272, 1369, 26, 22318, 1245, 272, 2138, 26, 641, 3182, 272, 730, 26, 620, 272, 2690, 26, 710, 284, 16958, 1347, 2202, 1172, 2757, 4588, 14, 199, 3620, 26, 272, 1369, 26, 267, 446, 710, 5162, 7943, 370, 314, 284, 16958, 1347, 14, 272, 2138, 26, 641, 3182, 272, 2690, 26, 3002, 3836, 272, 730, 26, 620, 199, 27071, 26, 272, 1369, 26, 267, 446, 710, 284, 15156, 334, 21534, 19933, 4541, 2812, 395, 7943, 370, 314, 284, 16958, 1347, 14, 272, 2138, 26, 641, 3182, 272, 2690, 26, 284, 15156, 14, 7155, 18, 13, 2036, 14, 957, 14, 25830, 26, 1651, 383, 14, 1493, 65, 6557, 1493, 66, 8010, 68, 18, 3607, 21, 65, 16, 69, 24, 70, 2322, 272, 730, 26, 620, 199, 624, 199, 646, 2022, 199, 646, 2050, 199, 504, 10933, 492, 30843, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 25830, 492, 1056, 12, 325, 5602, 63, 1102, 63, 2094, 63, 1650, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 199, 199, 21178, 275, 469, 272, 298, 2714, 13, 804, 582, 298, 3578, 15, 1001, 401, 272, 298, 8422, 582, 298, 3578, 15, 1001, 401, 199, 93, 421, 199, 533, 473, 15873, 4277, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1423, 63, 1650, 275, 325, 5602, 63, 1102, 63, 2094, 63, 1650, 342, 267, 1423, 63, 1650, 14, 873, 8, 807, 8, 288, 536, 29, 807, 8, 466, 534, 495, 297, 1415, 29, 797, 12, 5481, 2968, 3620, 3815, 288, 18249, 29, 807, 8, 466, 534, 2245, 297, 1415, 29, 797, 12, 849, 29, 549, 395, 288, 682, 439, 63 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 334, 67, 9, 14894, 12, 28076, 12, 3277, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 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, 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, 408, 199, 2595, 199, 578, 26, 15742, 63, 69, 63, 17139, 63, 1375, 199, 3612, 63, 1802, 26, 28076, 662, 13, 9641, 9635, 284, 16958, 1347, 2897, 199, 1802, 26, 272, 446, 15453, 314, 2202, 402, 376, 662, 13, 9641, 284, 16958, 1347, 199, 1023, 63, 3270, 26, 283, 18, 14, 23, 7, 199, 2502, 26, 16922, 20276, 8593, 76, 311, 322, 301, 9, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 15742, 14, 69, 5602, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 710, 536, 15, 3620, 370, 5090, 370, 314, 284, 16958, 1347, 14, 288, 446, 961, 5162, 365, 14115, 1202, 701, 314, 22094, 2032, 315, 1865, 370, 1852, 376, 284, 16958, 1347, 14905, 370, 10405, 14, 267, 5481, 26, 288, 446, 5162, 272, 18249, 26, 267, 1369, 26, 288, 446, 12030, 473, 23181, 18249, 9320, 687, 314, 7526, 284, 16958, 8873, 14, 267, 730, 26, 2155, 267, 849, 26, 9456, 272, 682, 439, 63, 4731, 26, 267, 1369, 26, 288, 446, 12030, 2799, 8537, 13, 26392, 15995, 11557, 334, 1244, 1282, 395, 7678, 19030, 316, 642, 574, 465, 314, 2505, 14, 288, 446, 3979, 642, 574, 365, 2013, 12, 781, 911, 3544, 6804, 376, 1678, 334, 2489, 29, 549, 680, 2136, 1172, 949, 4340, 402, 31866, 1598, 3775, 503, 440, 314, 2505, 965, 2896, 14, 288, 446, 710, 682, 439, 7565, 1443, 1454, 675, 13294, 4110, 543, 1338, 3382, 4337, 436, 21572, 6107, 14, 288, 446, 710, 682, 439, 7565, 1471, 506, 949, 6656, 2419, 3144, 4110, 12, 1325, 949, 8932, 2419, 12699, 4110, 315, 2582, 14, 288, 446, 710, 682, 439, 7565, 365, 20518, 1380, 440, 2013, 503, 376, 2701, 1059, 14, 267, 5481, 26, 288, 446, 682, 439, 288, 446, 2505, 272, 625, 4579, 63, 14859, 26, 267, 1369, 26, 288, 446, 3979, 376, 22094, 11023, 2335, 282, 13172, 2351, 370, 376, 22094, 1844, 12, 652, 365, 8652, 376, 625, 4579, 1598, 13172, 2351, 340, 314, 284, 16958, 1347, 284, 15156, 365, 440, 2013, 315, 314, 1056, 14, 288, 446, 961, 945, 1443, 506, 6980, 370, 19781, 6391, 340, 6387, 14, 267, 730, 26, 2155, 267, 849, 26, 9456, 272, 943, 63, 515, 26, 267, 1369, 26, 288, 446, 437, 2257, 931, 334, 265, 314, 2622, 7614, 395, 370, 282, 570, 370, 506, 1202, 367, 3105, 2050, 14, 267, 1415, 26, 949, 199, 5983, 26, 272, 446, 2670, 818, 365, 3748, 14, 272, 446, 6601, 402, 314, 2202, 787, 11410, 641, 314, 2202, 6781, 370, 314, 284, 16958, 8386, 14, 5723, 883, 506, 7526, 1808, 489, 603, 8, 25830, 63, 69, 63, 17139, 63, 3266, 680, 272, 446, 961, 859, 5074, 282, 6001, 21813, 3261, 1015, 402, 2356, 413, 14, 19, 14, 199, 624, 199, 199, 8918, 275, 408, 272, 446, 536, 26, 12030, 18249, 9320, 436, 625, 4579, 13172, 12184, 367, 1006, 284, 16958, 8873, 489, 15742, 63, 69, 63, 17139, 63, 1375, 26, 267, 2986, 63, 633, 26, 298, 2859, 921, 5967, 26, 1349, 2824, 15, 2374, 7755, 15, 86, 18, 2, 267, 2986, 63, 2473, 26, 4628, 267, 2986, 63, 2060, 26, 3002, 6139, 267, 25891, 26, 298, 17, 2, 267, 4107, 63, 8356, 26, 949, 267, 536, 26, 3002, 4277, 267, 18249, 26, 9456, 267, 625, 4579, 63, 14859, 26, 9456, 339, 446, 536, 26, 2494, 314, 1347, 5162, 436, 314, 6624, 1282, 7565, 489, 15742, 63, 69, 63, 17139, 63, 1375, 26, 267, 25891, 26, 7370, 25891, 7820, 267, 2986, 63, 633, 26, 7370, 15742, 63, 1246, 63, 633, 7820, 267, 2986, 63, 2473, 26, 7370, 15742, 63, 1246, 63, 2473, 7820, 267, 2986, 63, 2060, 26, 7370, 15742, 63, 1246, 63, 2060, 7820, 267, 536, 26, 3002, 4277, 267, 682, 439, 26, 2505, 4321, 199, 624, 199, 199, 9677, 275, 408, 199, 1328, 26, 272, 1369, 26, 22318, 1245, 272, 2138, 26, 641, 3182, 272, 730, 26, 620, 272, 2690, 26, 710, 284, 16958, 1347, 2202, 1172, 2757, 4588, 14, 199, 3620, 26, 272, 1369, 26, 267, 446, 710, 5162, 7943, 370, 314, 284, 16958, 1347, 14, 272, 2138, 26, 641, 3182, 272, 2690, 26, 3002, 3836, 272, 730, 26, 620, 199, 27071, 26, 272, 1369, 26, 267, 446, 710, 284, 15156, 334, 21534, 19933, 4541, 2812, 395, 7943, 370, 314, 284, 16958, 1347, 14, 272, 2138, 26, 641, 3182, 272, 2690, 26, 284, 15156, 14, 7155, 18, 13, 2036, 14, 957, 14, 25830, 26, 1651, 383, 14, 1493, 65, 6557, 1493, 66, 8010, 68, 18, 3607, 21, 65, 16, 69, 24, 70, 2322, 272, 730, 26, 620, 199, 624, 199, 646, 2022, 199, 646, 2050, 199, 504, 10933, 492, 30843, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 25830, 492, 1056, 12, 325, 5602, 63, 1102, 63, 2094, 63, 1650, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 199, 199, 21178, 275, 469, 272, 298, 2714, 13, 804, 582, 298, 3578, 15, 1001, 401, 272, 298, 8422, 582, 298, 3578, 15, 1001, 401, 199, 93, 421, 199, 533, 473, 15873, 4277, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1423, 63, 1650, 275, 325, 5602, 63, 1102, 63, 2094, 63, 1650, 342, 267, 1423, 63, 1650, 14, 873, 8, 807, 8, 288, 536, 29, 807, 8, 466, 534, 495, 297, 1415, 29, 797, 12, 5481, 2968, 3620, 3815, 288, 18249, 29, 807, 8, 466, 534, 2245, 297, 1415, 29, 797, 12, 849, 29, 549, 395, 288, 682, 439, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Sorsly/subtle
google-cloud-sdk/lib/surface/compute/groups/create.py
3
2213
# Copyright 2015 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Command for creating groups.""" from googlecloudsdk.api_lib.compute import base_classes class Create(base_classes.BaseAsyncCreator): """Create Google Compute Engine groups.""" @staticmethod def Args(parser): parser.add_argument( 'names', metavar='NAME', nargs='+', help='The name of the group to create.') parser.add_argument( '--description', help='An optional, textual description for the group being created.') @property def service(self): return self.clouduseraccounts.groups @property def method(self): return 'Insert' @property def resource_type(self): return 'groups' @property def messages(self): return self.clouduseraccounts.MESSAGES_MODULE def CreateRequests(self, args): """Returns a list of requests necessary for adding users.""" group_refs = [self.clouduseraccounts_resources.Parse( group, collection='clouduseraccounts.groups') for group in args.names] requests = [] for group_ref in group_refs: group = self.messages.Group( name=group_ref.Name(), description=args.description, ) request = self.messages.ClouduseraccountsGroupsInsertRequest( project=self.project, group=group) requests.append(request) return requests Create.detailed_help = { 'brief': 'Create Google Compute Engine groups', 'DESCRIPTION': """\ *{command}* creates Google Compute Engine groups. """, 'EXAMPLES': """\ To create a group, run: $ {command} example-group """, }
mit
[ 3, 1898, 6900, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 3110, 367, 6425, 4652, 1041, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 3357, 492, 1300, 63, 2888, 421, 199, 533, 2790, 8, 1095, 63, 2888, 14, 1563, 12807, 17523, 304, 523, 408, 2499, 4475, 8354, 12580, 4652, 1041, 819, 768, 4639, 523, 347, 3033, 8, 2087, 304, 272, 1798, 14, 525, 63, 2094, 8, 267, 283, 1247, 297, 267, 8214, 534, 2339, 297, 267, 9237, 534, 7386, 267, 1720, 534, 1918, 536, 402, 314, 1572, 370, 1218, 2659, 339, 1798, 14, 525, 63, 2094, 8, 267, 2850, 1802, 297, 267, 1720, 534, 2493, 2716, 12, 25884, 1369, 367, 314, 1572, 3769, 2737, 2659, 819, 768, 1829, 523, 347, 2435, 8, 277, 304, 272, 372, 291, 14, 4091, 751, 8370, 14, 2634, 819, 768, 1829, 523, 347, 1083, 8, 277, 304, 272, 372, 283, 9971, 7, 819, 768, 1829, 523, 347, 2073, 63, 466, 8, 277, 304, 272, 372, 283, 2634, 7, 819, 768, 1829, 523, 347, 3788, 8, 277, 304, 272, 372, 291, 14, 4091, 751, 8370, 14, 23229, 63, 10001, 819, 347, 2790, 16272, 8, 277, 12, 1249, 304, 272, 408, 3407, 282, 769, 402, 4145, 5784, 367, 7791, 4390, 1041, 339, 1572, 63, 7655, 275, 359, 277, 14, 4091, 751, 8370, 63, 4435, 14, 4003, 8, 267, 1572, 12, 3245, 534, 4091, 751, 8370, 14, 2634, 358, 367, 1572, 315, 1249, 14, 1247, 61, 339, 4145, 275, 942, 272, 367, 1572, 63, 1121, 315, 1572, 63, 7655, 26, 2541, 1572, 275, 291, 14, 3431, 14, 2448, 8, 881, 536, 29, 923, 63, 1121, 14, 985, 1062, 881, 1369, 29, 589, 14, 1802, 12, 489, 776, 2541, 1056, 275, 291, 14, 3431, 14, 9089, 751, 8370, 10177, 9971, 2017, 8, 881, 2199, 29, 277, 14, 1715, 12, 881, 1572, 29, 923, 9, 489, 4145, 14, 740, 8, 1069, 9, 339, 372, 4145, 421, 199, 2499, 14, 19170, 63, 3437, 275, 469, 272, 283, 19127, 356, 283, 2499, 4475, 8354, 12580, 4652, 297, 272, 283, 17705, 356, 9638, 267, 627, 91, 1531, 93, 10, 8491, 4475, 8354, 12580, 4652, 14, 267, 10327, 272, 283, 8918, 356, 9638, 267, 4005, 1218, 282, 1572, 12, 1255, 26, 8592, 2672, 469, 1531, 93, 2893, 13, 923, 267, 10327, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6900, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 3110, 367, 6425, 4652, 1041, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 3357, 492, 1300, 63, 2888, 421, 199, 533, 2790, 8, 1095, 63, 2888, 14, 1563, 12807, 17523, 304, 523, 408, 2499, 4475, 8354, 12580, 4652, 1041, 819, 768, 4639, 523, 347, 3033, 8, 2087, 304, 272, 1798, 14, 525, 63, 2094, 8, 267, 283, 1247, 297, 267, 8214, 534, 2339, 297, 267, 9237, 534, 7386, 267, 1720, 534, 1918, 536, 402, 314, 1572, 370, 1218, 2659, 339, 1798, 14, 525, 63, 2094, 8, 267, 2850, 1802, 297, 267, 1720, 534, 2493, 2716, 12, 25884, 1369, 367, 314, 1572, 3769, 2737, 2659, 819, 768, 1829, 523, 347, 2435, 8, 277, 304, 272, 372, 291, 14, 4091, 751, 8370, 14, 2634, 819, 768, 1829, 523, 347, 1083, 8, 277, 304, 272, 372, 283, 9971, 7, 819, 768, 1829, 523, 347, 2073, 63, 466, 8, 277, 304, 272, 372, 283, 2634, 7, 819, 768, 1829, 523, 347, 3788, 8, 277, 304, 272, 372, 291, 14, 4091, 751, 8370, 14, 23229, 63, 10001, 819, 347, 2790, 16272, 8, 277, 12, 1249, 304, 272, 408, 3407, 282, 769, 402, 4145, 5784, 367, 7791, 4390, 1041, 339, 1572, 63, 7655, 275, 359, 277, 14, 4091, 751, 8370, 63, 4435, 14, 4003, 8, 267, 1572, 12, 3245, 534, 4091, 751, 8370, 14, 2634, 358, 367, 1572, 315, 1249, 14, 1247, 61, 339, 4145, 275, 942, 272, 367, 1572, 63, 1121, 315, 1572, 63, 7655, 26, 2541, 1572, 275, 291, 14, 3431, 14, 2448, 8, 881, 536, 29, 923, 63, 1121, 14, 985, 1062, 881, 1369, 29, 589, 14, 1802, 12, 489, 776, 2541, 1056, 275, 291, 14, 3431, 14, 9089, 751, 8370, 10177, 9971, 2017, 8, 881, 2199, 29, 277, 14, 1715, 12, 881, 1572, 29, 923, 9, 489, 4145, 14, 740, 8, 1069, 9, 339, 372, 4145, 421, 199, 2499, 14, 19170, 63, 3437, 275, 469, 272, 283, 19127, 356, 283, 2499, 4475, 8354, 12580, 4652, 297, 272, 283, 17705, 356, 9638, 267, 627, 91, 1531, 93, 10, 8491, 4475, 8354, 12580, 4652, 14, 267, 10327, 272, 283, 8918, 356, 9638, 267, 4005, 1218, 282, 1572, 12, 1255, 26, 8592, 2672, 469, 1531, 93, 2893, 13, 923, 267, 10327, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
charmander/livestreamer
src/livestreamer/stream/segmented.py
36
5517
from concurrent import futures from threading import Thread, Event from .stream import StreamIO from ..buffers import RingBuffer from ..compat import queue class SegmentedStreamWorker(Thread): """The general worker thread. This thread is responsible for queueing up segments in the writer thread. """ def __init__(self, reader): self.closed = False self.reader = reader self.writer = reader.writer self.stream = reader.stream self.session = reader.stream.session self.logger = reader.logger self._wait = None Thread.__init__(self) self.daemon = True def close(self): """Shuts down the thread.""" if not self.closed: self.logger.debug("Closing worker thread") self.closed = True if self._wait: self._wait.set() def wait(self, time): """Pauses the thread for a specified time. Returns False if interrupted by another thread and True if the time runs out normally. """ self._wait = Event() return not self._wait.wait(time) def iter_segments(self): """The iterator that generates segments for the worker thread. Should be overridden by the inheriting class. """ return yield def run(self): for segment in self.iter_segments(): self.writer.put(segment) # End of stream, tells the writer to exit self.writer.put(None) self.close() class SegmentedStreamWriter(Thread): """The writer thread. This thread is responsible for fetching segments, processing them and finally writing the data to the buffer. """ def __init__(self, reader, size=20, retries=None, threads=None, timeout=None): self.closed = False self.reader = reader self.stream = reader.stream self.session = reader.stream.session self.logger = reader.logger if not retries: retries = self.session.options.get("stream-segment-attempts") if not threads: threads = self.session.options.get("stream-segment-threads") if not timeout: timeout = self.session.options.get("stream-segment-timeout") self.retries = retries self.timeout = timeout self.executor = futures.ThreadPoolExecutor(max_workers=threads) self.futures = queue.Queue(size) Thread.__init__(self) self.daemon = True def close(self): """Shuts down the thread.""" if not self.closed: self.logger.debug("Closing writer thread") self.closed = True self.reader.buffer.close() self.executor.shutdown(wait=True) def put(self, segment): """Adds a segment to the download pool and write queue.""" if self.closed: return if segment is not None: future = self.executor.submit(self.fetch, segment, retries=self.retries) else: future = None self.queue(self.futures, (segment, future)) def queue(self, queue_, value): """Puts a value into a queue but aborts if this thread is closed.""" while not self.closed: try: queue_.put(value, block=True, timeout=1) break except queue.Full: continue def fetch(self, segment): """Fetches a segment. Should be overridden by the inheriting class. """ pass def write(self, segment, result): """Writes a segment to the buffer. Should be overridden by the inheriting class. """ pass def run(self): while not self.closed: try: segment, future = self.futures.get(block=True, timeout=0.5) except queue.Empty: continue # End of stream if future is None: break while not self.closed: try: result = future.result(timeout=0.5) except futures.TimeoutError: continue except futures.CancelledError: break if result is not None: self.write(segment, result) break self.close() class SegmentedStreamReader(StreamIO): __worker__ = SegmentedStreamWorker __writer__ = SegmentedStreamWriter def __init__(self, stream, timeout=None): StreamIO.__init__(self) self.session = stream.session self.stream = stream if not timeout: timeout = self.session.options.get("stream-timeout") self.timeout = timeout def open(self): buffer_size = self.session.get_option("ringbuffer-size") self.buffer = RingBuffer(buffer_size) self.writer = self.__writer__(self) self.worker = self.__worker__(self) self.writer.start() self.worker.start() def close(self): self.worker.close() self.writer.close() for thread in (self.worker, self.writer): if thread.is_alive(): thread.join() self.buffer.close() def read(self, size): if not self.buffer: return b"" return self.buffer.read(size, block=self.writer.is_alive(), timeout=self.timeout)
bsd-2-clause
[ 504, 23002, 492, 27471, 199, 504, 5796, 492, 11086, 12, 6763, 199, 199, 504, 1275, 1745, 492, 8271, 2090, 199, 504, 2508, 17389, 492, 820, 316, 3299, 199, 504, 2508, 5819, 492, 4126, 421, 199, 533, 3240, 71, 2509, 3296, 12678, 8, 4436, 304, 272, 408, 1918, 8605, 7239, 2462, 14, 339, 961, 2462, 365, 17845, 367, 4126, 316, 1536, 11998, 315, 314, 272, 7060, 2462, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 7002, 304, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 5503, 275, 7002, 267, 291, 14, 5491, 275, 7002, 14, 5491, 267, 291, 14, 1745, 275, 7002, 14, 1745, 267, 291, 14, 1730, 275, 7002, 14, 1745, 14, 1730, 267, 291, 14, 2921, 275, 7002, 14, 2921, 398, 291, 423, 2573, 275, 488, 398, 11086, 855, 826, 721, 277, 9, 267, 291, 14, 10824, 275, 715, 339, 347, 4002, 8, 277, 304, 267, 408, 2662, 14608, 3224, 314, 2462, 1041, 267, 340, 440, 291, 14, 5938, 26, 288, 291, 14, 2921, 14, 1757, 480, 18433, 7239, 2462, 531, 398, 291, 14, 5938, 275, 715, 267, 340, 291, 423, 2573, 26, 288, 291, 423, 2573, 14, 409, 342, 339, 347, 3618, 8, 277, 12, 900, 304, 267, 408, 48, 3844, 874, 314, 2462, 367, 282, 2013, 900, 14, 398, 1803, 756, 340, 31366, 701, 4573, 2462, 436, 715, 340, 314, 267, 900, 7858, 734, 12252, 14, 267, 408, 267, 291, 423, 2573, 275, 6763, 342, 267, 372, 440, 291, 423, 2573, 14, 2573, 8, 521, 9, 339, 347, 2740, 63, 13879, 8, 277, 304, 267, 408, 1918, 6122, 626, 12821, 11998, 367, 314, 7239, 2462, 14, 398, 7719, 506, 10087, 701, 314, 29927, 1021, 14, 267, 408, 267, 372, 267, 1995, 339, 347, 1255, 8, 277, 304, 267, 367, 8135, 315, 291, 14, 1661, 63, 13879, 837, 288, 291, 14, 5491, 14, 524, 8, 9255, 9, 398, 327, 9599, 402, 2547, 12, 26544, 314, 7060, 370, 4458, 267, 291, 14, 5491, 14, 524, 8, 403, 9, 267, 291, 14, 1600, 342, 421, 199, 533, 3240, 71, 2509, 16551, 8, 4436, 304, 272, 408, 1918, 7060, 2462, 14, 339, 961, 2462, 365, 17845, 367, 21239, 11998, 12, 6661, 3062, 272, 436, 3753, 3575, 314, 666, 370, 314, 3335, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 7002, 12, 1568, 29, 1165, 12, 10086, 29, 403, 12, 7183, 29, 403, 12, 2653, 29, 403, 304, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 5503, 275, 7002, 267, 291, 14, 1745, 275, 7002, 14, 1745, 267, 291, 14, 1730, 275, 7002, 14, 1745, 14, 1730, 267, 291, 14, 2921, 275, 7002, 14, 2921, 398, 340, 440, 10086, 26, 288, 10086, 275, 291, 14, 1730, 14, 1419, 14, 362, 480, 1745, 13, 9255, 13, 13143, 531, 398, 340, 440, 7183, 26, 288, 7183, 275, 291, 14, 1730, 14, 1419, 14, 362, 480, 1745, 13, 9255, 13, 6962, 531, 398, 340, 440, 2653, 26, 288, 2653, 275, 291, 14, 1730, 14, 1419, 14, 362, 480, 1745, 13, 9255, 13, 2593, 531, 398, 291, 14, 10937, 275, 10086, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 13471, 275, 27471, 14, 4436, 5453, 16752, 8, 988, 63, 11009, 29, 6962, 9, 267, 291, 14, 25513, 275, 4126, 14, 3737, 8, 890, 9, 398, 11086, 855, 826, 721, 277, 9, 267, 291, 14, 10824, 275, 715, 339, 347, 4002, 8, 277, 304, 267, 408, 2662, 14608, 3224, 314, 2462, 1041, 267, 340, 440, 291, 14, 5938, 26, 288, 291, 14, 2921, 14, 1757, 480, 18433, 7060, 2462, 531, 398, 291, 14, 5938, 275, 715, 267, 291, 14, 5503, 14, 2738, 14, 1600, 342, 267, 291, 14, 13471, 14, 8831, 8, 2573, 29, 549, 9, 339, 347, 5324, 8, 277, 12, 8135, 304, 267, 408, 14995, 282, 8135, 370, 314, 5235, 4203, 436, 2218, 4126, 1041, 267, 340, 291, 14, 5938, 26, 288, 372, 398, 340, 8135, 365, 440, 488, 26, 288, 6466, 275, 291, 14, 13471, 14, 7275, 8, 277, 14, 3535, 12, 8135, 12, 5101, 10086, 29, 277, 14, 10937, 9, 267, 587, 26, 288, 6466, 275, 488, 398, 291, 14, 1825, 8, 277, 14, 25513, 12, 334, 9255, 12, 6466, 430, 339, 347, 4126, 8, 277, 12, 4126, 3131, 574, 304, 267, 408, 48, 14608, 282, 574, 1901, 282, 4126, 1325, 12004, 83, 340, 642, 2462, 365, 6876, 1041, 267, 1830, 440, 291, 14, 5938, 26, 288, 862, 26, 355, 4126, 3754, 524, 8, 585, 12, 1853, 29, 549, 12, 2653, 29, 17, 9, 355, 2059, 288, 871, 4126, 14, 9042, 26, 355, 1980, 339, 347, 5267, 8, 277, 12, 8135, 304, 267, 408, 11135, 397, 282, 8135, 14, 398, 7719, 506, 10087, 701, 314, 29927, 1021, 14, 267, 408, 267, 986, 339, 347, 2218, 8, 277, 12, 8135, 12, 754, 304, 267, 408, 20908, 282, 8135, 370, 314, 3335, 14, 398, 7719, 506, 10087, 701, 314, 29927, 1021, 14, 267, 408, 267, 986, 339, 347, 1255, 8, 277, 304, 267, 1830, 440, 291, 14, 5938, 26, 288, 862, 26, 355, 8135, 12, 6466, 275, 291, 14, 25513, 14, 362, 8, 1457, 29, 549, 12, 2653, 29, 16, 14, 21, 9, 288, 871, 4126, 14, 4699, 26, 355, 1980, 953, 327, 9599, 402, 2547, 288, 340, 6466, 365, 488, 26, 355, 2059, 953, 1830, 440, 291, 14, 5938, 26, 355, 862, 26, 490, 754, 275, 6466, 14, 1099, 8, 2593, 29, 16, 14, 21, 9, 355, 871, 27471, 14, 19382, 26, 490, 1980, 355, 871, 27471, 14, 22127, 547, 26, 490, 2059, 2234, 340, 754, 365, 440, 488, 26, 490, 291, 14, 952, 8, 9255, 12, 754, 9, 2234, 2059, 398, 291, 14, 1600, 342, 421, 199, 533, 3240, 71, 2509, 16132, 8, 3296, 2090, 304, 272, 636, 6599, 363, 275, 3240, 71, 2509, 3296, 12678, 272, 636, 5491, 363, 275, 3240, 71, 2509, 16551, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 2653, 29, 403, 304, 267, 8271, 2090, 855, 826, 721, 277, 9, 267, 291, 14, 1730, 275, 2547, 14, 1730, 267, 291, 14, 1745, 275, 2547, 398, 340, 440, 2653, 26, 288, 2653, 275, 291, 14, 1730, 14, 1419, 14, 362, 480, 1745, 13, 2593, 531 ]
[ 23002, 492, 27471, 199, 504, 5796, 492, 11086, 12, 6763, 199, 199, 504, 1275, 1745, 492, 8271, 2090, 199, 504, 2508, 17389, 492, 820, 316, 3299, 199, 504, 2508, 5819, 492, 4126, 421, 199, 533, 3240, 71, 2509, 3296, 12678, 8, 4436, 304, 272, 408, 1918, 8605, 7239, 2462, 14, 339, 961, 2462, 365, 17845, 367, 4126, 316, 1536, 11998, 315, 314, 272, 7060, 2462, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 7002, 304, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 5503, 275, 7002, 267, 291, 14, 5491, 275, 7002, 14, 5491, 267, 291, 14, 1745, 275, 7002, 14, 1745, 267, 291, 14, 1730, 275, 7002, 14, 1745, 14, 1730, 267, 291, 14, 2921, 275, 7002, 14, 2921, 398, 291, 423, 2573, 275, 488, 398, 11086, 855, 826, 721, 277, 9, 267, 291, 14, 10824, 275, 715, 339, 347, 4002, 8, 277, 304, 267, 408, 2662, 14608, 3224, 314, 2462, 1041, 267, 340, 440, 291, 14, 5938, 26, 288, 291, 14, 2921, 14, 1757, 480, 18433, 7239, 2462, 531, 398, 291, 14, 5938, 275, 715, 267, 340, 291, 423, 2573, 26, 288, 291, 423, 2573, 14, 409, 342, 339, 347, 3618, 8, 277, 12, 900, 304, 267, 408, 48, 3844, 874, 314, 2462, 367, 282, 2013, 900, 14, 398, 1803, 756, 340, 31366, 701, 4573, 2462, 436, 715, 340, 314, 267, 900, 7858, 734, 12252, 14, 267, 408, 267, 291, 423, 2573, 275, 6763, 342, 267, 372, 440, 291, 423, 2573, 14, 2573, 8, 521, 9, 339, 347, 2740, 63, 13879, 8, 277, 304, 267, 408, 1918, 6122, 626, 12821, 11998, 367, 314, 7239, 2462, 14, 398, 7719, 506, 10087, 701, 314, 29927, 1021, 14, 267, 408, 267, 372, 267, 1995, 339, 347, 1255, 8, 277, 304, 267, 367, 8135, 315, 291, 14, 1661, 63, 13879, 837, 288, 291, 14, 5491, 14, 524, 8, 9255, 9, 398, 327, 9599, 402, 2547, 12, 26544, 314, 7060, 370, 4458, 267, 291, 14, 5491, 14, 524, 8, 403, 9, 267, 291, 14, 1600, 342, 421, 199, 533, 3240, 71, 2509, 16551, 8, 4436, 304, 272, 408, 1918, 7060, 2462, 14, 339, 961, 2462, 365, 17845, 367, 21239, 11998, 12, 6661, 3062, 272, 436, 3753, 3575, 314, 666, 370, 314, 3335, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 7002, 12, 1568, 29, 1165, 12, 10086, 29, 403, 12, 7183, 29, 403, 12, 2653, 29, 403, 304, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 5503, 275, 7002, 267, 291, 14, 1745, 275, 7002, 14, 1745, 267, 291, 14, 1730, 275, 7002, 14, 1745, 14, 1730, 267, 291, 14, 2921, 275, 7002, 14, 2921, 398, 340, 440, 10086, 26, 288, 10086, 275, 291, 14, 1730, 14, 1419, 14, 362, 480, 1745, 13, 9255, 13, 13143, 531, 398, 340, 440, 7183, 26, 288, 7183, 275, 291, 14, 1730, 14, 1419, 14, 362, 480, 1745, 13, 9255, 13, 6962, 531, 398, 340, 440, 2653, 26, 288, 2653, 275, 291, 14, 1730, 14, 1419, 14, 362, 480, 1745, 13, 9255, 13, 2593, 531, 398, 291, 14, 10937, 275, 10086, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 13471, 275, 27471, 14, 4436, 5453, 16752, 8, 988, 63, 11009, 29, 6962, 9, 267, 291, 14, 25513, 275, 4126, 14, 3737, 8, 890, 9, 398, 11086, 855, 826, 721, 277, 9, 267, 291, 14, 10824, 275, 715, 339, 347, 4002, 8, 277, 304, 267, 408, 2662, 14608, 3224, 314, 2462, 1041, 267, 340, 440, 291, 14, 5938, 26, 288, 291, 14, 2921, 14, 1757, 480, 18433, 7060, 2462, 531, 398, 291, 14, 5938, 275, 715, 267, 291, 14, 5503, 14, 2738, 14, 1600, 342, 267, 291, 14, 13471, 14, 8831, 8, 2573, 29, 549, 9, 339, 347, 5324, 8, 277, 12, 8135, 304, 267, 408, 14995, 282, 8135, 370, 314, 5235, 4203, 436, 2218, 4126, 1041, 267, 340, 291, 14, 5938, 26, 288, 372, 398, 340, 8135, 365, 440, 488, 26, 288, 6466, 275, 291, 14, 13471, 14, 7275, 8, 277, 14, 3535, 12, 8135, 12, 5101, 10086, 29, 277, 14, 10937, 9, 267, 587, 26, 288, 6466, 275, 488, 398, 291, 14, 1825, 8, 277, 14, 25513, 12, 334, 9255, 12, 6466, 430, 339, 347, 4126, 8, 277, 12, 4126, 3131, 574, 304, 267, 408, 48, 14608, 282, 574, 1901, 282, 4126, 1325, 12004, 83, 340, 642, 2462, 365, 6876, 1041, 267, 1830, 440, 291, 14, 5938, 26, 288, 862, 26, 355, 4126, 3754, 524, 8, 585, 12, 1853, 29, 549, 12, 2653, 29, 17, 9, 355, 2059, 288, 871, 4126, 14, 9042, 26, 355, 1980, 339, 347, 5267, 8, 277, 12, 8135, 304, 267, 408, 11135, 397, 282, 8135, 14, 398, 7719, 506, 10087, 701, 314, 29927, 1021, 14, 267, 408, 267, 986, 339, 347, 2218, 8, 277, 12, 8135, 12, 754, 304, 267, 408, 20908, 282, 8135, 370, 314, 3335, 14, 398, 7719, 506, 10087, 701, 314, 29927, 1021, 14, 267, 408, 267, 986, 339, 347, 1255, 8, 277, 304, 267, 1830, 440, 291, 14, 5938, 26, 288, 862, 26, 355, 8135, 12, 6466, 275, 291, 14, 25513, 14, 362, 8, 1457, 29, 549, 12, 2653, 29, 16, 14, 21, 9, 288, 871, 4126, 14, 4699, 26, 355, 1980, 953, 327, 9599, 402, 2547, 288, 340, 6466, 365, 488, 26, 355, 2059, 953, 1830, 440, 291, 14, 5938, 26, 355, 862, 26, 490, 754, 275, 6466, 14, 1099, 8, 2593, 29, 16, 14, 21, 9, 355, 871, 27471, 14, 19382, 26, 490, 1980, 355, 871, 27471, 14, 22127, 547, 26, 490, 2059, 2234, 340, 754, 365, 440, 488, 26, 490, 291, 14, 952, 8, 9255, 12, 754, 9, 2234, 2059, 398, 291, 14, 1600, 342, 421, 199, 533, 3240, 71, 2509, 16132, 8, 3296, 2090, 304, 272, 636, 6599, 363, 275, 3240, 71, 2509, 3296, 12678, 272, 636, 5491, 363, 275, 3240, 71, 2509, 16551, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 2653, 29, 403, 304, 267, 8271, 2090, 855, 826, 721, 277, 9, 267, 291, 14, 1730, 275, 2547, 14, 1730, 267, 291, 14, 1745, 275, 2547, 398, 340, 440, 2653, 26, 288, 2653, 275, 291, 14, 1730, 14, 1419, 14, 362, 480, 1745, 13, 2593, 531, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
msduketown/SublimeKodi
libs-mac/lxml/html/_diffcommand.py
93
2084
import optparse import sys import re import os from lxml.html.diff import htmldiff description = """\ """ parser = optparse.OptionParser( usage="%prog [OPTIONS] FILE1 FILE2\n" "%prog --annotate [OPTIONS] INFO1 FILE1 INFO2 FILE2 ...", description=description, ) parser.add_option( '-o', '--output', metavar="FILE", dest="output", default="-", help="File to write the difference to", ) parser.add_option( '-a', '--annotation', action="store_true", dest="annotation", help="Do an annotation") def main(args=None): if args is None: args = sys.argv[1:] options, args = parser.parse_args(args) if options.annotation: return annotate(options, args) if len(args) != 2: print('Error: you must give two files') parser.print_help() sys.exit(1) file1, file2 = args input1 = read_file(file1) input2 = read_file(file2) body1 = split_body(input1)[1] pre, body2, post = split_body(input2) result = htmldiff(body1, body2) result = pre + result + post if options.output == '-': if not result.endswith('\n'): result += '\n' sys.stdout.write(result) else: f = open(options.output, 'wb') f.write(result) f.close() def read_file(filename): if filename == '-': c = sys.stdin.read() elif not os.path.exists(filename): raise OSError( "Input file %s does not exist" % filename) else: f = open(filename, 'rb') c = f.read() f.close() return c body_start_re = re.compile( r"<body.*?>", re.I|re.S) body_end_re = re.compile( r"</body.*?>", re.I|re.S) def split_body(html): match = body_start_re.search(html) if match: pre = html[:match.end()] html = html[match.end():] match = body_end_re.search(html) if match: post = html[match.start():] html = html[:match.start()] return pre, html, post def annotate(options, args): print("Not yet implemented") sys.exit(1)
gpl-3.0
[ 646, 8691, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 504, 14490, 14, 1360, 14, 3028, 492, 3517, 3028, 199, 199, 1802, 275, 9638, 199, 624, 199, 199, 2087, 275, 8691, 14, 14553, 8, 272, 4503, 5961, 6595, 359, 8808, 61, 13024, 17, 13024, 18, 60, 78, 2, 272, 2071, 6595, 1553, 10898, 359, 8808, 61, 24008, 17, 13024, 17, 24008, 18, 13024, 18, 2263, 401, 272, 1369, 29, 1802, 12, 272, 776, 199, 199, 2087, 14, 525, 63, 1422, 8, 272, 2475, 79, 297, 2850, 1199, 297, 272, 8214, 628, 3817, 401, 272, 2053, 628, 1199, 401, 272, 849, 27295, 401, 272, 1720, 628, 1173, 370, 2218, 314, 8865, 370, 401, 272, 776, 199, 199, 2087, 14, 525, 63, 1422, 8, 272, 2475, 65, 297, 2850, 9340, 297, 272, 1595, 628, 1617, 63, 2052, 401, 272, 2053, 628, 9340, 401, 272, 1720, 628, 2585, 376, 11262, 531, 199, 199, 318, 2446, 8, 589, 29, 403, 304, 272, 340, 1249, 365, 488, 26, 267, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 8, 589, 9, 272, 340, 1511, 14, 9340, 26, 267, 372, 28987, 8, 1419, 12, 1249, 9, 272, 340, 822, 8, 589, 9, 1137, 499, 26, 267, 870, 360, 547, 26, 1265, 1471, 8120, 2877, 1584, 358, 267, 1798, 14, 1361, 63, 3437, 342, 267, 984, 14, 2224, 8, 17, 9, 272, 570, 17, 12, 570, 18, 275, 1249, 272, 1324, 17, 275, 1586, 63, 493, 8, 493, 17, 9, 272, 1324, 18, 275, 1586, 63, 493, 8, 493, 18, 9, 272, 2396, 17, 275, 3715, 63, 2030, 8, 1210, 17, 2788, 17, 61, 272, 876, 12, 2396, 18, 12, 2963, 275, 3715, 63, 2030, 8, 1210, 18, 9, 272, 754, 275, 3517, 3028, 8, 2030, 17, 12, 2396, 18, 9, 272, 754, 275, 876, 435, 754, 435, 2963, 272, 340, 1511, 14, 1199, 508, 20905, 267, 340, 440, 754, 14, 4130, 2258, 78, 735, 288, 754, 847, 1557, 78, 7, 267, 984, 14, 2703, 14, 952, 8, 1099, 9, 272, 587, 26, 267, 289, 275, 1551, 8, 1419, 14, 1199, 12, 283, 6603, 358, 267, 289, 14, 952, 8, 1099, 9, 267, 289, 14, 1600, 342, 199, 199, 318, 1586, 63, 493, 8, 1501, 304, 272, 340, 1788, 508, 20905, 267, 286, 275, 984, 14, 6626, 14, 739, 342, 272, 916, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 267, 746, 6440, 8, 288, 298, 3205, 570, 450, 83, 1630, 440, 2187, 2, 450, 1788, 9, 272, 587, 26, 267, 289, 275, 1551, 8, 1501, 12, 283, 4848, 358, 267, 286, 275, 289, 14, 739, 342, 267, 289, 14, 1600, 342, 272, 372, 286, 199, 199, 2030, 63, 928, 63, 264, 275, 295, 14, 2014, 8, 272, 519, 17030, 2030, 6697, 7166, 295, 14, 41, 92, 264, 14, 51, 9, 199, 2030, 63, 500, 63, 264, 275, 295, 14, 2014, 8, 272, 519, 2, 1108, 2030, 6697, 7166, 295, 14, 41, 92, 264, 14, 51, 9, 1362, 199, 318, 3715, 63, 2030, 8, 1360, 304, 272, 1336, 275, 2396, 63, 928, 63, 264, 14, 1733, 8, 1360, 9, 272, 340, 1336, 26, 267, 876, 275, 3517, 1491, 1431, 14, 500, 5106, 267, 3517, 275, 3517, 59, 1431, 14, 500, 837, 61, 272, 1336, 275, 2396, 63, 500, 63, 264, 14, 1733, 8, 1360, 9, 272, 340, 1336, 26, 267, 2963, 275, 3517, 59, 1431, 14, 928, 837, 61, 267, 3517, 275, 3517, 1491, 1431, 14, 928, 5106, 272, 372, 876, 12, 3517, 12, 2963, 199, 199, 318, 28987, 8, 1419, 12, 1249, 304, 272, 870, 480, 1763, 5966, 6366, 531, 272, 984, 14, 2224, 8, 17, 9, 16872, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8691, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 504, 14490, 14, 1360, 14, 3028, 492, 3517, 3028, 199, 199, 1802, 275, 9638, 199, 624, 199, 199, 2087, 275, 8691, 14, 14553, 8, 272, 4503, 5961, 6595, 359, 8808, 61, 13024, 17, 13024, 18, 60, 78, 2, 272, 2071, 6595, 1553, 10898, 359, 8808, 61, 24008, 17, 13024, 17, 24008, 18, 13024, 18, 2263, 401, 272, 1369, 29, 1802, 12, 272, 776, 199, 199, 2087, 14, 525, 63, 1422, 8, 272, 2475, 79, 297, 2850, 1199, 297, 272, 8214, 628, 3817, 401, 272, 2053, 628, 1199, 401, 272, 849, 27295, 401, 272, 1720, 628, 1173, 370, 2218, 314, 8865, 370, 401, 272, 776, 199, 199, 2087, 14, 525, 63, 1422, 8, 272, 2475, 65, 297, 2850, 9340, 297, 272, 1595, 628, 1617, 63, 2052, 401, 272, 2053, 628, 9340, 401, 272, 1720, 628, 2585, 376, 11262, 531, 199, 199, 318, 2446, 8, 589, 29, 403, 304, 272, 340, 1249, 365, 488, 26, 267, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 8, 589, 9, 272, 340, 1511, 14, 9340, 26, 267, 372, 28987, 8, 1419, 12, 1249, 9, 272, 340, 822, 8, 589, 9, 1137, 499, 26, 267, 870, 360, 547, 26, 1265, 1471, 8120, 2877, 1584, 358, 267, 1798, 14, 1361, 63, 3437, 342, 267, 984, 14, 2224, 8, 17, 9, 272, 570, 17, 12, 570, 18, 275, 1249, 272, 1324, 17, 275, 1586, 63, 493, 8, 493, 17, 9, 272, 1324, 18, 275, 1586, 63, 493, 8, 493, 18, 9, 272, 2396, 17, 275, 3715, 63, 2030, 8, 1210, 17, 2788, 17, 61, 272, 876, 12, 2396, 18, 12, 2963, 275, 3715, 63, 2030, 8, 1210, 18, 9, 272, 754, 275, 3517, 3028, 8, 2030, 17, 12, 2396, 18, 9, 272, 754, 275, 876, 435, 754, 435, 2963, 272, 340, 1511, 14, 1199, 508, 20905, 267, 340, 440, 754, 14, 4130, 2258, 78, 735, 288, 754, 847, 1557, 78, 7, 267, 984, 14, 2703, 14, 952, 8, 1099, 9, 272, 587, 26, 267, 289, 275, 1551, 8, 1419, 14, 1199, 12, 283, 6603, 358, 267, 289, 14, 952, 8, 1099, 9, 267, 289, 14, 1600, 342, 199, 199, 318, 1586, 63, 493, 8, 1501, 304, 272, 340, 1788, 508, 20905, 267, 286, 275, 984, 14, 6626, 14, 739, 342, 272, 916, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 267, 746, 6440, 8, 288, 298, 3205, 570, 450, 83, 1630, 440, 2187, 2, 450, 1788, 9, 272, 587, 26, 267, 289, 275, 1551, 8, 1501, 12, 283, 4848, 358, 267, 286, 275, 289, 14, 739, 342, 267, 289, 14, 1600, 342, 272, 372, 286, 199, 199, 2030, 63, 928, 63, 264, 275, 295, 14, 2014, 8, 272, 519, 17030, 2030, 6697, 7166, 295, 14, 41, 92, 264, 14, 51, 9, 199, 2030, 63, 500, 63, 264, 275, 295, 14, 2014, 8, 272, 519, 2, 1108, 2030, 6697, 7166, 295, 14, 41, 92, 264, 14, 51, 9, 1362, 199, 318, 3715, 63, 2030, 8, 1360, 304, 272, 1336, 275, 2396, 63, 928, 63, 264, 14, 1733, 8, 1360, 9, 272, 340, 1336, 26, 267, 876, 275, 3517, 1491, 1431, 14, 500, 5106, 267, 3517, 275, 3517, 59, 1431, 14, 500, 837, 61, 272, 1336, 275, 2396, 63, 500, 63, 264, 14, 1733, 8, 1360, 9, 272, 340, 1336, 26, 267, 2963, 275, 3517, 59, 1431, 14, 928, 837, 61, 267, 3517, 275, 3517, 1491, 1431, 14, 928, 5106, 272, 372, 876, 12, 3517, 12, 2963, 199, 199, 318, 28987, 8, 1419, 12, 1249, 304, 272, 870, 480, 1763, 5966, 6366, 531, 272, 984, 14, 2224, 8, 17, 9, 16872, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
cshallue/models
research/minigo/features_test.py
2
3096
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for features.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf # pylint: disable=g-bad-import-order import features import go import numpy as np import utils_test tf.logging.set_verbosity(tf.logging.ERROR) EMPTY_ROW = '.' * utils_test.BOARD_SIZE + '\n' TEST_BOARD = utils_test.load_board(''' .X.....OO X........ XXXXXXXXX ''' + EMPTY_ROW * 6) TEST_POSITION = go.Position( utils_test.BOARD_SIZE, board=TEST_BOARD, n=3, komi=6.5, caps=(1, 2), ko=None, recent=(go.PlayerMove(go.BLACK, (0, 1)), go.PlayerMove(go.WHITE, (0, 8)), go.PlayerMove(go.BLACK, (1, 0))), to_play=go.BLACK, ) TEST_BOARD2 = utils_test.load_board(''' .XOXXOO.. XO.OXOX.. XXO..X... ''' + EMPTY_ROW * 6) TEST_POSITION2 = go.Position( utils_test.BOARD_SIZE, board=TEST_BOARD2, n=0, komi=6.5, caps=(0, 0), ko=None, recent=tuple(), to_play=go.BLACK, ) TEST_POSITION3 = go.Position(utils_test.BOARD_SIZE) for coord in ((0, 0), (0, 1), (0, 2), (0, 3), (1, 1)): TEST_POSITION3.play_move(coord, mutate=True) # resulting position should look like this: # X.XO..... # .X....... # ......... class TestFeatureExtraction(utils_test.MiniGoUnitTest): def test_stone_features(self): f = features.stone_features(utils_test.BOARD_SIZE, TEST_POSITION3) self.assertEqual(TEST_POSITION3.to_play, go.WHITE) self.assertEqual(f.shape, (9, 9, 16)) self.assertEqualNPArray(f[:, :, 0], utils_test.load_board(''' ...X..... .........''' + EMPTY_ROW * 7)) self.assertEqualNPArray(f[:, :, 1], utils_test.load_board(''' X.X...... .X.......''' + EMPTY_ROW * 7)) self.assertEqualNPArray(f[:, :, 2], utils_test.load_board(''' .X.X..... .........''' + EMPTY_ROW * 7)) self.assertEqualNPArray(f[:, :, 3], utils_test.load_board(''' X.X...... .........''' + EMPTY_ROW * 7)) self.assertEqualNPArray(f[:, :, 4], utils_test.load_board(''' .X....... .........''' + EMPTY_ROW * 7)) self.assertEqualNPArray(f[:, :, 5], utils_test.load_board(''' X.X...... .........''' + EMPTY_ROW * 7)) for i in range(10, 16): self.assertEqualNPArray( f[:, :, i], np.zeros([utils_test.BOARD_SIZE, utils_test.BOARD_SIZE])) if __name__ == '__main__': tf.test.main()
apache-2.0
[ 3, 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 4534, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 3228, 465, 2833, 221, 327, 4287, 26, 3507, 29, 71, 13, 4087, 13, 646, 13, 1648, 199, 199, 646, 4534, 199, 646, 2621, 199, 646, 2680, 465, 980, 199, 646, 3778, 63, 396, 199, 199, 3249, 14, 4806, 14, 409, 63, 9833, 8, 3249, 14, 4806, 14, 3170, 9, 199, 199, 13993, 63, 11415, 275, 7815, 627, 3778, 63, 396, 14, 23368, 63, 4305, 435, 1557, 78, 7, 199, 2864, 63, 23368, 275, 3778, 63, 396, 14, 912, 63, 3576, 10505, 199, 14, 56, 703, 1396, 5757, 199, 56, 7955, 199, 13312, 56, 199, 2344, 435, 16589, 63, 11415, 627, 1227, 9, 199, 199, 2864, 63, 15717, 275, 2621, 14, 5625, 8, 272, 3778, 63, 396, 14, 23368, 63, 4305, 12, 272, 13811, 29, 2864, 63, 23368, 12, 272, 302, 29, 19, 12, 272, 1022, 676, 73, 29, 22, 14, 21, 12, 272, 22053, 2687, 17, 12, 499, 395, 272, 20817, 29, 403, 12, 272, 8058, 2687, 1939, 14, 10921, 10370, 8, 1939, 14, 23113, 12, 334, 16, 12, 413, 1826, 288, 2621, 14, 10921, 10370, 8, 1939, 14, 18817, 12, 334, 16, 12, 1695, 1826, 288, 2621, 14, 10921, 10370, 8, 1939, 14, 23113, 12, 334, 17, 12, 378, 11508, 272, 370, 63, 2802, 29, 1939, 14, 23113, 12, 199, 9, 199, 199, 2864, 63, 23368, 18, 275, 3778, 63, 396, 14, 912, 63, 3576, 10505, 199, 14, 56, 47, 2483, 5757, 703, 199, 56, 47, 14, 29544, 29544, 703, 199, 2483, 47, 703, 56, 1396, 199, 2344, 435, 16589, 63, 11415, 627, 1227, 9, 199, 199, 2864, 63, 15717, 18, 275, 2621, 14, 5625, 8, 272, 3778, 63, 396, 14, 23368, 63, 4305, 12, 272, 13811, 29, 2864, 63, 23368, 18, 12, 272, 302, 29, 16, 12, 272, 1022, 676, 73, 29, 22, 14, 21, 12, 272, 22053, 2687, 16, 12, 378, 395, 272, 20817, 29, 403, 12, 272, 8058, 29, 2960, 1062, 272, 370, 63, 2802, 29, 1939, 14, 23113, 12, 199, 9, 421, 199, 2864, 63, 15717, 19, 275, 2621, 14, 5625, 8, 1208, 63, 396, 14, 23368, 63, 4305, 9, 199, 509, 11021, 315, 3666, 16, 12, 378, 395, 334, 16, 12, 413, 395, 334, 16, 12, 499, 395, 334, 16, 12, 650, 395, 334, 17, 12, 413, 2298, 523, 7393, 63, 15717, 19, 14, 2802, 63, 1185, 8, 7988, 12, 31173, 29, 549, 9, 199, 3, 9183, 3421, 1077, 3648, 2839, 642, 26, 199, 3, 1323, 14, 56, 47, 703, 1396, 199, 3, 1275, 56, 4496, 1396, 199, 3, 2508, 4496, 1396, 421, 199, 533, 1379, 5968, 4942, 6156, 8, 1208, 63, 396, 14, 26822, 7250, 29037, 304, 819, 347, 511, 63, 8361, 63, 3179, 8, 277, 304, 272, 289, 275, 4534, 14, 8361, 63, 3179, 8, 1208, 63, 396, 14, 23368, 63, 4305, 12, 7393, 63, 15717, 19, 9, 272, 291, 14, 629, 8, 2864, 63, 15717, 19, 14, 475, 63, 2802, 12, 2621, 14, 18817, 9, 272, 291, 14, 629, 8, 70, 14, 1392, 12, 334, 25, 12, 1749, 12, 3193, 430, 272, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 378, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 2263, 56, 703, 1396, 489, 2508, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 413, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 1323, 14, 56, 32478, 489, 1275, 56, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 499, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 1275, 56, 14, 56, 703, 1396, 489, 2508, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 650, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 1323, 14, 56, 32478, 489, 2508, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 841, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 1275, 56, 4496, 1396, 489, 2508, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 959, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 1323, 14, 56, 32478, 489, 2508, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 367, 284, 315, 1425, 8, 709, 12, 3193, 304, 489, 291, 14, 629, 14970, 3836, 8, 881, 289, 3981, 13785, 284, 467, 980, 14, 4250, 779, 1208, 63, 396, 14, 23368, 63, 4305, 12, 3778, 63, 396, 14, 23368, 63, 4305, 2459, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2833, 14, 396, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 4534, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 3228, 465, 2833, 221, 327, 4287, 26, 3507, 29, 71, 13, 4087, 13, 646, 13, 1648, 199, 199, 646, 4534, 199, 646, 2621, 199, 646, 2680, 465, 980, 199, 646, 3778, 63, 396, 199, 199, 3249, 14, 4806, 14, 409, 63, 9833, 8, 3249, 14, 4806, 14, 3170, 9, 199, 199, 13993, 63, 11415, 275, 7815, 627, 3778, 63, 396, 14, 23368, 63, 4305, 435, 1557, 78, 7, 199, 2864, 63, 23368, 275, 3778, 63, 396, 14, 912, 63, 3576, 10505, 199, 14, 56, 703, 1396, 5757, 199, 56, 7955, 199, 13312, 56, 199, 2344, 435, 16589, 63, 11415, 627, 1227, 9, 199, 199, 2864, 63, 15717, 275, 2621, 14, 5625, 8, 272, 3778, 63, 396, 14, 23368, 63, 4305, 12, 272, 13811, 29, 2864, 63, 23368, 12, 272, 302, 29, 19, 12, 272, 1022, 676, 73, 29, 22, 14, 21, 12, 272, 22053, 2687, 17, 12, 499, 395, 272, 20817, 29, 403, 12, 272, 8058, 2687, 1939, 14, 10921, 10370, 8, 1939, 14, 23113, 12, 334, 16, 12, 413, 1826, 288, 2621, 14, 10921, 10370, 8, 1939, 14, 18817, 12, 334, 16, 12, 1695, 1826, 288, 2621, 14, 10921, 10370, 8, 1939, 14, 23113, 12, 334, 17, 12, 378, 11508, 272, 370, 63, 2802, 29, 1939, 14, 23113, 12, 199, 9, 199, 199, 2864, 63, 23368, 18, 275, 3778, 63, 396, 14, 912, 63, 3576, 10505, 199, 14, 56, 47, 2483, 5757, 703, 199, 56, 47, 14, 29544, 29544, 703, 199, 2483, 47, 703, 56, 1396, 199, 2344, 435, 16589, 63, 11415, 627, 1227, 9, 199, 199, 2864, 63, 15717, 18, 275, 2621, 14, 5625, 8, 272, 3778, 63, 396, 14, 23368, 63, 4305, 12, 272, 13811, 29, 2864, 63, 23368, 18, 12, 272, 302, 29, 16, 12, 272, 1022, 676, 73, 29, 22, 14, 21, 12, 272, 22053, 2687, 16, 12, 378, 395, 272, 20817, 29, 403, 12, 272, 8058, 29, 2960, 1062, 272, 370, 63, 2802, 29, 1939, 14, 23113, 12, 199, 9, 421, 199, 2864, 63, 15717, 19, 275, 2621, 14, 5625, 8, 1208, 63, 396, 14, 23368, 63, 4305, 9, 199, 509, 11021, 315, 3666, 16, 12, 378, 395, 334, 16, 12, 413, 395, 334, 16, 12, 499, 395, 334, 16, 12, 650, 395, 334, 17, 12, 413, 2298, 523, 7393, 63, 15717, 19, 14, 2802, 63, 1185, 8, 7988, 12, 31173, 29, 549, 9, 199, 3, 9183, 3421, 1077, 3648, 2839, 642, 26, 199, 3, 1323, 14, 56, 47, 703, 1396, 199, 3, 1275, 56, 4496, 1396, 199, 3, 2508, 4496, 1396, 421, 199, 533, 1379, 5968, 4942, 6156, 8, 1208, 63, 396, 14, 26822, 7250, 29037, 304, 819, 347, 511, 63, 8361, 63, 3179, 8, 277, 304, 272, 289, 275, 4534, 14, 8361, 63, 3179, 8, 1208, 63, 396, 14, 23368, 63, 4305, 12, 7393, 63, 15717, 19, 9, 272, 291, 14, 629, 8, 2864, 63, 15717, 19, 14, 475, 63, 2802, 12, 2621, 14, 18817, 9, 272, 291, 14, 629, 8, 70, 14, 1392, 12, 334, 25, 12, 1749, 12, 3193, 430, 272, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 378, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 2263, 56, 703, 1396, 489, 2508, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 413, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 1323, 14, 56, 32478, 489, 1275, 56, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 499, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 1275, 56, 14, 56, 703, 1396, 489, 2508, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 650, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 1323, 14, 56, 32478, 489, 2508, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 841, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 1275, 56, 4496, 1396, 489, 2508, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 291, 14, 629, 14970, 3836, 8, 70, 3981, 13785, 959, 467, 3778, 63, 396, 14, 912, 63, 3576, 10505, 489, 1323, 14, 56, 32478, 489, 2508, 4496, 1396, 2344, 435, 16589, 63, 11415, 627, 1520, 430, 339, 367, 284, 315, 1425, 8, 709, 12, 3193, 304, 489, 291, 14, 629, 14970, 3836, 8, 881, 289, 3981, 13785, 284, 467, 980, 14, 4250, 779, 1208, 63, 396, 14, 23368, 63, 4305, 12, 3778, 63, 396, 14, 23368, 63, 4305, 2459, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2833, 14, 396, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
0k/OpenUpgrade
openerp/addons/test_new_api/tests/test_new_fields.py
51
15560
# # test cases for new-style fields # from datetime import date, datetime from collections import defaultdict from openerp.tests import common from openerp.exceptions import except_orm class TestNewFields(common.TransactionCase): def test_00_basics(self): """ test accessing new fields """ # find a discussion discussion = self.env.ref('test_new_api.discussion_0') # read field as a record attribute or as a record item self.assertIsInstance(discussion.name, basestring) self.assertIsInstance(discussion['name'], basestring) self.assertEqual(discussion['name'], discussion.name) # read it with method read() values = discussion.read(['name'])[0] self.assertEqual(values['name'], discussion.name) def test_01_basic_get_assertion(self): """ test item getter """ # field access works on single record record = self.env.ref('test_new_api.message_0_0') self.assertEqual(len(record), 1) ok = record.body # field access fails on multiple records records = self.env['test_new_api.message'].search([]) assert len(records) > 1 with self.assertRaises(except_orm): faulty = records.body def test_01_basic_set_assertion(self): """ test item setter """ # field assignment works on single record record = self.env.ref('test_new_api.message_0_0') self.assertEqual(len(record), 1) record.body = 'OK' # field assignment fails on multiple records records = self.env['test_new_api.message'].search([]) assert len(records) > 1 with self.assertRaises(except_orm): records.body = 'Faulty' def test_10_computed(self): """ check definition of computed fields """ # by default function fields are not stored and readonly field = self.env['test_new_api.message']._fields['size'] self.assertFalse(field.store) self.assertTrue(field.readonly) field = self.env['test_new_api.message']._fields['name'] self.assertTrue(field.store) self.assertTrue(field.readonly) def test_10_non_stored(self): """ test non-stored fields """ # find messages for message in self.env['test_new_api.message'].search([]): # check definition of field self.assertEqual(message.size, len(message.body or '')) # check recomputation after record is modified size = message.size message.write({'body': (message.body or '') + "!!!"}) self.assertEqual(message.size, size + 3) # special case: computed field without dependency must be computed record = self.env['test_new_api.mixed'].create({}) self.assertTrue(record.now) def test_11_stored(self): """ test stored fields """ # find the demo discussion discussion = self.env.ref('test_new_api.discussion_0') self.assertTrue(len(discussion.messages) > 0) # check messages name0 = discussion.name or "" for message in discussion.messages: self.assertEqual(message.name, "[%s] %s" % (name0, message.author.name)) # modify discussion name, and check again messages discussion.name = name1 = 'Talking about stuff...' for message in discussion.messages: self.assertEqual(message.name, "[%s] %s" % (name1, message.author.name)) # switch message from discussion, and check again name2 = 'Another discussion' discussion2 = discussion.copy({'name': name2}) message2 = discussion.messages[0] message2.discussion = discussion2 for message in discussion2.messages: self.assertEqual(message.name, "[%s] %s" % (name2, message.author.name)) def test_12_recursive(self): """ test recursively dependent fields """ Category = self.env['test_new_api.category'] abel = Category.create({'name': 'Abel'}) beth = Category.create({'name': 'Bethany'}) cath = Category.create({'name': 'Catherine'}) dean = Category.create({'name': 'Dean'}) ewan = Category.create({'name': 'Ewan'}) finn = Category.create({'name': 'Finnley'}) gabe = Category.create({'name': 'Gabriel'}) cath.parent = finn.parent = gabe abel.parent = beth.parent = cath dean.parent = ewan.parent = finn self.assertEqual(abel.display_name, "Gabriel / Catherine / Abel") self.assertEqual(beth.display_name, "Gabriel / Catherine / Bethany") self.assertEqual(cath.display_name, "Gabriel / Catherine") self.assertEqual(dean.display_name, "Gabriel / Finnley / Dean") self.assertEqual(ewan.display_name, "Gabriel / Finnley / Ewan") self.assertEqual(finn.display_name, "Gabriel / Finnley") self.assertEqual(gabe.display_name, "Gabriel") ewan.parent = cath self.assertEqual(ewan.display_name, "Gabriel / Catherine / Ewan") cath.parent = finn self.assertEqual(ewan.display_name, "Gabriel / Finnley / Catherine / Ewan") def test_12_cascade(self): """ test computed field depending on computed field """ message = self.env.ref('test_new_api.message_0_0') message.invalidate_cache() double_size = message.double_size self.assertEqual(double_size, message.size) def test_13_inverse(self): """ test inverse computation of fields """ Category = self.env['test_new_api.category'] abel = Category.create({'name': 'Abel'}) beth = Category.create({'name': 'Bethany'}) cath = Category.create({'name': 'Catherine'}) dean = Category.create({'name': 'Dean'}) ewan = Category.create({'name': 'Ewan'}) finn = Category.create({'name': 'Finnley'}) gabe = Category.create({'name': 'Gabriel'}) self.assertEqual(ewan.display_name, "Ewan") ewan.display_name = "Abel / Bethany / Catherine / Erwan" self.assertEqual(beth.parent, abel) self.assertEqual(cath.parent, beth) self.assertEqual(ewan.parent, cath) self.assertEqual(ewan.name, "Erwan") def test_14_search(self): """ test search on computed fields """ discussion = self.env.ref('test_new_api.discussion_0') # determine message sizes sizes = set(message.size for message in discussion.messages) # search for messages based on their size for size in sizes: messages0 = self.env['test_new_api.message'].search( [('discussion', '=', discussion.id), ('size', '<=', size)]) messages1 = self.env['test_new_api.message'].browse() for message in discussion.messages: if message.size <= size: messages1 += message self.assertEqual(messages0, messages1) def test_15_constraint(self): """ test new-style Python constraints """ discussion = self.env.ref('test_new_api.discussion_0') # remove oneself from discussion participants: we can no longer create # messages in discussion discussion.participants -= self.env.user with self.assertRaises(Exception): self.env['test_new_api.message'].create({'discussion': discussion.id, 'body': 'Whatever'}) # put back oneself into discussion participants: now we can create # messages in discussion discussion.participants += self.env.user self.env['test_new_api.message'].create({'discussion': discussion.id, 'body': 'Whatever'}) def test_20_float(self): """ test float fields """ record = self.env['test_new_api.mixed'].create({}) # assign value, and expect rounding record.write({'number': 2.4999999999999996}) self.assertEqual(record.number, 2.50) # same with field setter record.number = 2.4999999999999996 self.assertEqual(record.number, 2.50) def test_21_date(self): """ test date fields """ record = self.env['test_new_api.mixed'].create({}) # one may assign False or None record.date = None self.assertFalse(record.date) # one may assign date and datetime objects record.date = date(2012, 05, 01) self.assertEqual(record.date, '2012-05-01') record.date = datetime(2012, 05, 01, 10, 45, 00) self.assertEqual(record.date, '2012-05-01') # one may assign dates in the default format, and it must be checked record.date = '2012-05-01' self.assertEqual(record.date, '2012-05-01') with self.assertRaises(ValueError): record.date = '12-5-1' def test_22_selection(self): """ test selection fields """ record = self.env['test_new_api.mixed'].create({}) # one may assign False or None record.lang = None self.assertFalse(record.lang) # one may assign a value, and it must be checked for language in self.env['res.lang'].search([]): record.lang = language.code with self.assertRaises(ValueError): record.lang = 'zz_ZZ' def test_23_relation(self): """ test relation fields """ demo = self.env.ref('base.user_demo') message = self.env.ref('test_new_api.message_0_0') # check environment of record and related records self.assertEqual(message.env, self.env) self.assertEqual(message.discussion.env, self.env) demo_env = self.env(user=demo) self.assertNotEqual(demo_env, self.env) # check environment of record and related records self.assertEqual(message.env, self.env) self.assertEqual(message.discussion.env, self.env) # "migrate" message into demo_env, and check again demo_message = message.sudo(demo) self.assertEqual(demo_message.env, demo_env) self.assertEqual(demo_message.discussion.env, demo_env) # assign record's parent to a record in demo_env message.discussion = message.discussion.copy({'name': 'Copy'}) # both message and its parent field must be in self.env self.assertEqual(message.env, self.env) self.assertEqual(message.discussion.env, self.env) def test_24_reference(self): """ test reference fields. """ record = self.env['test_new_api.mixed'].create({}) # one may assign False or None record.reference = None self.assertFalse(record.reference) # one may assign a user or a partner... record.reference = self.env.user self.assertEqual(record.reference, self.env.user) record.reference = self.env.user.partner_id self.assertEqual(record.reference, self.env.user.partner_id) # ... but no record from a model that starts with 'ir.' with self.assertRaises(ValueError): record.reference = self.env['ir.model'].search([], limit=1) def test_25_related(self): """ test related fields. """ message = self.env.ref('test_new_api.message_0_0') discussion = message.discussion # by default related fields are not stored field = message._fields['discussion_name'] self.assertFalse(field.store) self.assertTrue(field.readonly) # check value of related field self.assertEqual(message.discussion_name, discussion.name) # change discussion name, and check result discussion.name = 'Foo' self.assertEqual(message.discussion_name, 'Foo') # change discussion name via related field, and check result message.discussion_name = 'Bar' self.assertEqual(discussion.name, 'Bar') self.assertEqual(message.discussion_name, 'Bar') # search on related field, and check result search_on_related = self.env['test_new_api.message'].search([('discussion_name', '=', 'Bar')]) search_on_regular = self.env['test_new_api.message'].search([('discussion.name', '=', 'Bar')]) self.assertEqual(search_on_related, search_on_regular) # check that field attributes are copied message_field = message.fields_get(['discussion_name'])['discussion_name'] discussion_field = discussion.fields_get(['name'])['name'] self.assertEqual(message_field['help'], discussion_field['help']) def test_26_inherited(self): """ test inherited fields. """ # a bunch of fields are inherited from res_partner for user in self.env['res.users'].search([]): partner = user.partner_id for field in ('is_company', 'name', 'email', 'country_id'): self.assertEqual(getattr(user, field), getattr(partner, field)) self.assertEqual(user[field], partner[field]) def test_30_read(self): """ test computed fields as returned by read(). """ discussion = self.env.ref('test_new_api.discussion_0') for message in discussion.messages: display_name = message.display_name size = message.size data = message.read(['display_name', 'size'])[0] self.assertEqual(data['display_name'], display_name) self.assertEqual(data['size'], size) def test_40_new(self): """ test new records. """ discussion = self.env.ref('test_new_api.discussion_0') # create a new message message = self.env['test_new_api.message'].new() self.assertFalse(message.id) # assign some fields; should have no side effect message.discussion = discussion message.body = BODY = "May the Force be with you." self.assertEqual(message.discussion, discussion) self.assertEqual(message.body, BODY) self.assertNotIn(message, discussion.messages) # check computed values of fields user = self.env.user self.assertEqual(message.author, user) self.assertEqual(message.name, "[%s] %s" % (discussion.name, user.name)) self.assertEqual(message.size, len(BODY)) def test_41_defaults(self): """ test default values. """ fields = ['discussion', 'body', 'author', 'size'] defaults = self.env['test_new_api.message'].default_get(fields) self.assertEqual(defaults, {'author': self.env.uid, 'size': 0}) defaults = self.env['test_new_api.mixed'].default_get(['number']) self.assertEqual(defaults, {'number': 3.14}) class TestMagicFields(common.TransactionCase): def test_write_date(self): record = self.env['test_new_api.discussion'].create({'name': 'Booba'}) self.assertEqual(record.create_uid, self.env.user) self.assertEqual(record.write_uid, self.env.user) class TestInherits(common.TransactionCase): def test_inherits(self): """ Check that a many2one field with delegate=True adds an entry in _inherits """ Talk = self.env['test_new_api.talk'] self.assertEqual(Talk._inherits, {'test_new_api.discussion': 'parent'}) self.assertIn('name', Talk._fields) self.assertEqual(Talk._fields['name'].related, ('parent', 'name')) talk = Talk.create({'name': 'Foo'}) discussion = talk.parent self.assertTrue(discussion) self.assertEqual(talk._name, 'test_new_api.talk') self.assertEqual(discussion._name, 'test_new_api.discussion') self.assertEqual(talk.name, discussion.name)
agpl-3.0
[ 3, 199, 3, 511, 5560, 367, 892, 13, 2487, 1504, 199, 3, 199, 504, 2197, 492, 1434, 12, 2197, 199, 504, 5055, 492, 10018, 199, 199, 504, 5166, 14, 2219, 492, 2863, 199, 504, 5166, 14, 3924, 492, 871, 63, 1025, 421, 199, 533, 1379, 4665, 7304, 8, 2330, 14, 10161, 1538, 304, 339, 347, 511, 63, 383, 63, 4316, 83, 8, 277, 304, 267, 408, 511, 18549, 892, 1504, 408, 267, 327, 2342, 282, 16582, 267, 16582, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 1222, 63, 1246, 14, 14410, 63, 16, 358, 398, 327, 1586, 901, 465, 282, 2777, 2225, 503, 465, 282, 2777, 1242, 267, 291, 14, 6926, 8, 14410, 14, 354, 12, 7116, 9, 267, 291, 14, 6926, 8, 14410, 459, 354, 995, 7116, 9, 267, 291, 14, 629, 8, 14410, 459, 354, 995, 16582, 14, 354, 9, 398, 327, 1586, 652, 543, 1083, 1586, 342, 267, 1338, 275, 16582, 14, 739, 2941, 354, 25945, 16, 61, 267, 291, 14, 629, 8, 1459, 459, 354, 995, 16582, 14, 354, 9, 339, 347, 511, 63, 614, 63, 4316, 63, 362, 63, 18487, 8, 277, 304, 267, 408, 511, 1242, 15917, 408, 267, 327, 901, 2879, 5419, 641, 2849, 2777, 267, 2777, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 1222, 63, 1246, 14, 1188, 63, 16, 63, 16, 358, 267, 291, 14, 629, 8, 552, 8, 3059, 395, 413, 9, 267, 4112, 275, 2777, 14, 2030, 398, 327, 901, 2879, 6918, 641, 3663, 5767, 267, 5767, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 1188, 2278, 1733, 4157, 267, 702, 822, 8, 6502, 9, 690, 413, 267, 543, 291, 14, 1855, 8, 2590, 63, 1025, 304, 288, 1433, 17323, 275, 5767, 14, 2030, 339, 347, 511, 63, 614, 63, 4316, 63, 409, 63, 18487, 8, 277, 304, 267, 408, 511, 1242, 18743, 408, 267, 327, 901, 9801, 5419, 641, 2849, 2777, 267, 2777, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 1222, 63, 1246, 14, 1188, 63, 16, 63, 16, 358, 267, 291, 14, 629, 8, 552, 8, 3059, 395, 413, 9, 267, 2777, 14, 2030, 275, 283, 3593, 7, 398, 327, 901, 9801, 6918, 641, 3663, 5767, 267, 5767, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 1188, 2278, 1733, 4157, 267, 702, 822, 8, 6502, 9, 690, 413, 267, 543, 291, 14, 1855, 8, 2590, 63, 1025, 304, 288, 5767, 14, 2030, 275, 283, 1906, 17323, 7, 339, 347, 511, 63, 709, 63, 14378, 8, 277, 304, 267, 408, 1104, 5492, 402, 9235, 1504, 408, 267, 327, 701, 849, 805, 1504, 787, 440, 5489, 436, 6863, 267, 901, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 1188, 26099, 955, 459, 890, 418, 267, 291, 14, 3334, 8, 698, 14, 1617, 9, 267, 291, 14, 1815, 8, 698, 14, 6753, 9, 398, 901, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 1188, 26099, 955, 459, 354, 418, 267, 291, 14, 1815, 8, 698, 14, 1617, 9, 267, 291, 14, 1815, 8, 698, 14, 6753, 9, 339, 347, 511, 63, 709, 63, 2865, 63, 16431, 8, 277, 304, 267, 408, 511, 2222, 13, 16431, 1504, 408, 267, 327, 2342, 3788, 267, 367, 1245, 315, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 1188, 2278, 1733, 779, 4682, 288, 327, 1104, 5492, 402, 901, 288, 291, 14, 629, 8, 1188, 14, 890, 12, 822, 8, 1188, 14, 2030, 503, 12381, 953, 327, 1104, 295, 31598, 2410, 2777, 365, 6042, 288, 1568, 275, 1245, 14, 890, 288, 1245, 14, 952, 3252, 2030, 356, 334, 1188, 14, 2030, 503, 4074, 435, 298, 21512, 5984, 288, 291, 14, 629, 8, 1188, 14, 890, 12, 1568, 435, 650, 9, 398, 327, 4539, 1930, 26, 9235, 901, 1928, 5936, 1471, 506, 9235, 267, 2777, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 10455, 2278, 981, 14079, 267, 291, 14, 1815, 8, 3059, 14, 2131, 9, 339, 347, 511, 63, 845, 63, 16431, 8, 277, 304, 267, 408, 511, 5489, 1504, 408, 267, 327, 2342, 314, 14779, 16582, 267, 16582, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 1222, 63, 1246, 14, 14410, 63, 16, 358, 267, 291, 14, 1815, 8, 552, 8, 14410, 14, 3431, 9, 690, 378, 9, 398, 327, 1104, 3788, 267, 536, 16, 275, 16582, 14, 354, 503, 3087, 267, 367, 1245, 315, 16582, 14, 3431, 26, 288, 291, 14, 629, 8, 1188, 14, 354, 12, 26503, 83, 61, 450, 83, 2, 450, 334, 354, 16, 12, 1245, 14, 2502, 14, 354, 430, 398, 327, 2811, 16582, 536, 12, 436, 1104, 4020, 3788, 267, 16582, 14, 354, 275, 536, 17, 275, 283, 52, 4878, 316, 3595, 8292, 13698, 267, 367, 1245, 315, 16582, 14, 3431, 26, 288, 291, 14, 629, 8, 1188, 14, 354, 12, 26503, 83, 61, 450, 83, 2, 450, 334, 354, 17, 12, 1245, 14, 2502, 14, 354, 430, 398, 327, 6258, 1245, 687, 16582, 12, 436, 1104, 4020, 267, 536, 18, 275, 283, 23296, 16582, 7, 267, 16582, 18, 275, 16582, 14, 1574, 3252, 354, 356, 536, 18, 1552, 267, 1245, 18, 275, 16582, 14, 3431, 59, 16, 61, 267, 1245, 18, 14, 14410, 275, 16582, 18, 267, 367, 1245, 315, 16582, 18, 14, 3431, 26, 288, 291, 14, 629, 8, 1188, 14, 354, 12, 26503, 83, 61, 450, 83, 2, 450, 334, 354, 18, 12, 1245, 14, 2502, 14, 354, 430, 339, 347, 511, 63, 713, 63, 9931, 8, 277, 304, 267, 408, 511, 15035, 11410, 1504, 408, 267, 13573, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 3710, 418, 267, 2236, 352, 275, 13573, 14, 981, 3252, 354, 356, 283, 5583, 352, 3071, 267, 506, 273, 275, 13573, 14, 981, 3252, 354, 356, 283, 3655, 273, 1629, 3071, 267, 286, 1619, 275, 13573, 14, 981, 3252, 354, 356, 283, 3630, 728, 1132, 3071, 267, 477, 290, 275, 13573, 14, 981, 3252, 354, 356, 283, 872, 290, 3071, 267, 325, 20444, 275, 13573, 14, 981, 3252, 354, 356, 283, 37, 20444, 3071, 267, 2583, 78, 275, 13573, 14, 981, 3252, 354, 356, 283, 8694, 78 ]
[ 199, 3, 511, 5560, 367, 892, 13, 2487, 1504, 199, 3, 199, 504, 2197, 492, 1434, 12, 2197, 199, 504, 5055, 492, 10018, 199, 199, 504, 5166, 14, 2219, 492, 2863, 199, 504, 5166, 14, 3924, 492, 871, 63, 1025, 421, 199, 533, 1379, 4665, 7304, 8, 2330, 14, 10161, 1538, 304, 339, 347, 511, 63, 383, 63, 4316, 83, 8, 277, 304, 267, 408, 511, 18549, 892, 1504, 408, 267, 327, 2342, 282, 16582, 267, 16582, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 1222, 63, 1246, 14, 14410, 63, 16, 358, 398, 327, 1586, 901, 465, 282, 2777, 2225, 503, 465, 282, 2777, 1242, 267, 291, 14, 6926, 8, 14410, 14, 354, 12, 7116, 9, 267, 291, 14, 6926, 8, 14410, 459, 354, 995, 7116, 9, 267, 291, 14, 629, 8, 14410, 459, 354, 995, 16582, 14, 354, 9, 398, 327, 1586, 652, 543, 1083, 1586, 342, 267, 1338, 275, 16582, 14, 739, 2941, 354, 25945, 16, 61, 267, 291, 14, 629, 8, 1459, 459, 354, 995, 16582, 14, 354, 9, 339, 347, 511, 63, 614, 63, 4316, 63, 362, 63, 18487, 8, 277, 304, 267, 408, 511, 1242, 15917, 408, 267, 327, 901, 2879, 5419, 641, 2849, 2777, 267, 2777, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 1222, 63, 1246, 14, 1188, 63, 16, 63, 16, 358, 267, 291, 14, 629, 8, 552, 8, 3059, 395, 413, 9, 267, 4112, 275, 2777, 14, 2030, 398, 327, 901, 2879, 6918, 641, 3663, 5767, 267, 5767, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 1188, 2278, 1733, 4157, 267, 702, 822, 8, 6502, 9, 690, 413, 267, 543, 291, 14, 1855, 8, 2590, 63, 1025, 304, 288, 1433, 17323, 275, 5767, 14, 2030, 339, 347, 511, 63, 614, 63, 4316, 63, 409, 63, 18487, 8, 277, 304, 267, 408, 511, 1242, 18743, 408, 267, 327, 901, 9801, 5419, 641, 2849, 2777, 267, 2777, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 1222, 63, 1246, 14, 1188, 63, 16, 63, 16, 358, 267, 291, 14, 629, 8, 552, 8, 3059, 395, 413, 9, 267, 2777, 14, 2030, 275, 283, 3593, 7, 398, 327, 901, 9801, 6918, 641, 3663, 5767, 267, 5767, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 1188, 2278, 1733, 4157, 267, 702, 822, 8, 6502, 9, 690, 413, 267, 543, 291, 14, 1855, 8, 2590, 63, 1025, 304, 288, 5767, 14, 2030, 275, 283, 1906, 17323, 7, 339, 347, 511, 63, 709, 63, 14378, 8, 277, 304, 267, 408, 1104, 5492, 402, 9235, 1504, 408, 267, 327, 701, 849, 805, 1504, 787, 440, 5489, 436, 6863, 267, 901, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 1188, 26099, 955, 459, 890, 418, 267, 291, 14, 3334, 8, 698, 14, 1617, 9, 267, 291, 14, 1815, 8, 698, 14, 6753, 9, 398, 901, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 1188, 26099, 955, 459, 354, 418, 267, 291, 14, 1815, 8, 698, 14, 1617, 9, 267, 291, 14, 1815, 8, 698, 14, 6753, 9, 339, 347, 511, 63, 709, 63, 2865, 63, 16431, 8, 277, 304, 267, 408, 511, 2222, 13, 16431, 1504, 408, 267, 327, 2342, 3788, 267, 367, 1245, 315, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 1188, 2278, 1733, 779, 4682, 288, 327, 1104, 5492, 402, 901, 288, 291, 14, 629, 8, 1188, 14, 890, 12, 822, 8, 1188, 14, 2030, 503, 12381, 953, 327, 1104, 295, 31598, 2410, 2777, 365, 6042, 288, 1568, 275, 1245, 14, 890, 288, 1245, 14, 952, 3252, 2030, 356, 334, 1188, 14, 2030, 503, 4074, 435, 298, 21512, 5984, 288, 291, 14, 629, 8, 1188, 14, 890, 12, 1568, 435, 650, 9, 398, 327, 4539, 1930, 26, 9235, 901, 1928, 5936, 1471, 506, 9235, 267, 2777, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 10455, 2278, 981, 14079, 267, 291, 14, 1815, 8, 3059, 14, 2131, 9, 339, 347, 511, 63, 845, 63, 16431, 8, 277, 304, 267, 408, 511, 5489, 1504, 408, 267, 327, 2342, 314, 14779, 16582, 267, 16582, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 1222, 63, 1246, 14, 14410, 63, 16, 358, 267, 291, 14, 1815, 8, 552, 8, 14410, 14, 3431, 9, 690, 378, 9, 398, 327, 1104, 3788, 267, 536, 16, 275, 16582, 14, 354, 503, 3087, 267, 367, 1245, 315, 16582, 14, 3431, 26, 288, 291, 14, 629, 8, 1188, 14, 354, 12, 26503, 83, 61, 450, 83, 2, 450, 334, 354, 16, 12, 1245, 14, 2502, 14, 354, 430, 398, 327, 2811, 16582, 536, 12, 436, 1104, 4020, 3788, 267, 16582, 14, 354, 275, 536, 17, 275, 283, 52, 4878, 316, 3595, 8292, 13698, 267, 367, 1245, 315, 16582, 14, 3431, 26, 288, 291, 14, 629, 8, 1188, 14, 354, 12, 26503, 83, 61, 450, 83, 2, 450, 334, 354, 17, 12, 1245, 14, 2502, 14, 354, 430, 398, 327, 6258, 1245, 687, 16582, 12, 436, 1104, 4020, 267, 536, 18, 275, 283, 23296, 16582, 7, 267, 16582, 18, 275, 16582, 14, 1574, 3252, 354, 356, 536, 18, 1552, 267, 1245, 18, 275, 16582, 14, 3431, 59, 16, 61, 267, 1245, 18, 14, 14410, 275, 16582, 18, 267, 367, 1245, 315, 16582, 18, 14, 3431, 26, 288, 291, 14, 629, 8, 1188, 14, 354, 12, 26503, 83, 61, 450, 83, 2, 450, 334, 354, 18, 12, 1245, 14, 2502, 14, 354, 430, 339, 347, 511, 63, 713, 63, 9931, 8, 277, 304, 267, 408, 511, 15035, 11410, 1504, 408, 267, 13573, 275, 291, 14, 1813, 459, 396, 63, 1222, 63, 1246, 14, 3710, 418, 267, 2236, 352, 275, 13573, 14, 981, 3252, 354, 356, 283, 5583, 352, 3071, 267, 506, 273, 275, 13573, 14, 981, 3252, 354, 356, 283, 3655, 273, 1629, 3071, 267, 286, 1619, 275, 13573, 14, 981, 3252, 354, 356, 283, 3630, 728, 1132, 3071, 267, 477, 290, 275, 13573, 14, 981, 3252, 354, 356, 283, 872, 290, 3071, 267, 325, 20444, 275, 13573, 14, 981, 3252, 354, 356, 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 ]
a-langer/lo_report
modules/markupsafe/markupsafe/_constants.py
1535
4795
# -*- coding: utf-8 -*- """ markupsafe._constants ~~~~~~~~~~~~~~~~~~~~~ Highlevel implementation of the Markup string. :copyright: (c) 2010 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ HTML_ENTITIES = { 'AElig': 198, 'Aacute': 193, 'Acirc': 194, 'Agrave': 192, 'Alpha': 913, 'Aring': 197, 'Atilde': 195, 'Auml': 196, 'Beta': 914, 'Ccedil': 199, 'Chi': 935, 'Dagger': 8225, 'Delta': 916, 'ETH': 208, 'Eacute': 201, 'Ecirc': 202, 'Egrave': 200, 'Epsilon': 917, 'Eta': 919, 'Euml': 203, 'Gamma': 915, 'Iacute': 205, 'Icirc': 206, 'Igrave': 204, 'Iota': 921, 'Iuml': 207, 'Kappa': 922, 'Lambda': 923, 'Mu': 924, 'Ntilde': 209, 'Nu': 925, 'OElig': 338, 'Oacute': 211, 'Ocirc': 212, 'Ograve': 210, 'Omega': 937, 'Omicron': 927, 'Oslash': 216, 'Otilde': 213, 'Ouml': 214, 'Phi': 934, 'Pi': 928, 'Prime': 8243, 'Psi': 936, 'Rho': 929, 'Scaron': 352, 'Sigma': 931, 'THORN': 222, 'Tau': 932, 'Theta': 920, 'Uacute': 218, 'Ucirc': 219, 'Ugrave': 217, 'Upsilon': 933, 'Uuml': 220, 'Xi': 926, 'Yacute': 221, 'Yuml': 376, 'Zeta': 918, 'aacute': 225, 'acirc': 226, 'acute': 180, 'aelig': 230, 'agrave': 224, 'alefsym': 8501, 'alpha': 945, 'amp': 38, 'and': 8743, 'ang': 8736, 'apos': 39, 'aring': 229, 'asymp': 8776, 'atilde': 227, 'auml': 228, 'bdquo': 8222, 'beta': 946, 'brvbar': 166, 'bull': 8226, 'cap': 8745, 'ccedil': 231, 'cedil': 184, 'cent': 162, 'chi': 967, 'circ': 710, 'clubs': 9827, 'cong': 8773, 'copy': 169, 'crarr': 8629, 'cup': 8746, 'curren': 164, 'dArr': 8659, 'dagger': 8224, 'darr': 8595, 'deg': 176, 'delta': 948, 'diams': 9830, 'divide': 247, 'eacute': 233, 'ecirc': 234, 'egrave': 232, 'empty': 8709, 'emsp': 8195, 'ensp': 8194, 'epsilon': 949, 'equiv': 8801, 'eta': 951, 'eth': 240, 'euml': 235, 'euro': 8364, 'exist': 8707, 'fnof': 402, 'forall': 8704, 'frac12': 189, 'frac14': 188, 'frac34': 190, 'frasl': 8260, 'gamma': 947, 'ge': 8805, 'gt': 62, 'hArr': 8660, 'harr': 8596, 'hearts': 9829, 'hellip': 8230, 'iacute': 237, 'icirc': 238, 'iexcl': 161, 'igrave': 236, 'image': 8465, 'infin': 8734, 'int': 8747, 'iota': 953, 'iquest': 191, 'isin': 8712, 'iuml': 239, 'kappa': 954, 'lArr': 8656, 'lambda': 955, 'lang': 9001, 'laquo': 171, 'larr': 8592, 'lceil': 8968, 'ldquo': 8220, 'le': 8804, 'lfloor': 8970, 'lowast': 8727, 'loz': 9674, 'lrm': 8206, 'lsaquo': 8249, 'lsquo': 8216, 'lt': 60, 'macr': 175, 'mdash': 8212, 'micro': 181, 'middot': 183, 'minus': 8722, 'mu': 956, 'nabla': 8711, 'nbsp': 160, 'ndash': 8211, 'ne': 8800, 'ni': 8715, 'not': 172, 'notin': 8713, 'nsub': 8836, 'ntilde': 241, 'nu': 957, 'oacute': 243, 'ocirc': 244, 'oelig': 339, 'ograve': 242, 'oline': 8254, 'omega': 969, 'omicron': 959, 'oplus': 8853, 'or': 8744, 'ordf': 170, 'ordm': 186, 'oslash': 248, 'otilde': 245, 'otimes': 8855, 'ouml': 246, 'para': 182, 'part': 8706, 'permil': 8240, 'perp': 8869, 'phi': 966, 'pi': 960, 'piv': 982, 'plusmn': 177, 'pound': 163, 'prime': 8242, 'prod': 8719, 'prop': 8733, 'psi': 968, 'quot': 34, 'rArr': 8658, 'radic': 8730, 'rang': 9002, 'raquo': 187, 'rarr': 8594, 'rceil': 8969, 'rdquo': 8221, 'real': 8476, 'reg': 174, 'rfloor': 8971, 'rho': 961, 'rlm': 8207, 'rsaquo': 8250, 'rsquo': 8217, 'sbquo': 8218, 'scaron': 353, 'sdot': 8901, 'sect': 167, 'shy': 173, 'sigma': 963, 'sigmaf': 962, 'sim': 8764, 'spades': 9824, 'sub': 8834, 'sube': 8838, 'sum': 8721, 'sup': 8835, 'sup1': 185, 'sup2': 178, 'sup3': 179, 'supe': 8839, 'szlig': 223, 'tau': 964, 'there4': 8756, 'theta': 952, 'thetasym': 977, 'thinsp': 8201, 'thorn': 254, 'tilde': 732, 'times': 215, 'trade': 8482, 'uArr': 8657, 'uacute': 250, 'uarr': 8593, 'ucirc': 251, 'ugrave': 249, 'uml': 168, 'upsih': 978, 'upsilon': 965, 'uuml': 252, 'weierp': 8472, 'xi': 958, 'yacute': 253, 'yen': 165, 'yuml': 255, 'zeta': 950, 'zwj': 8205, 'zwnj': 8204 }
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 9189, 3489, 423, 5559, 272, 18294, 2878, 94, 339, 16332, 1896, 4514, 402, 314, 17504, 1059, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 421, 199, 4943, 63, 1309, 19144, 275, 469, 272, 283, 12500, 17506, 356, 413, 2905, 12, 272, 283, 33, 14696, 356, 413, 3129, 12, 272, 283, 33, 6092, 356, 413, 2635, 12, 272, 283, 33, 19612, 356, 13567, 12, 272, 283, 16192, 356, 1749, 969, 12, 272, 283, 1596, 316, 356, 413, 2576, 12, 272, 283, 33, 16488, 356, 413, 2720, 12, 272, 283, 33, 26297, 356, 32132, 12, 272, 283, 21732, 356, 1749, 1079, 12, 272, 283, 35, 27916, 356, 9013, 12, 272, 283, 29218, 356, 1749, 1276, 12, 272, 283, 36, 16267, 356, 1695, 10932, 12, 272, 283, 13411, 356, 1749, 975, 12, 272, 283, 21265, 356, 29203, 12, 272, 283, 37, 14696, 356, 1784, 12, 272, 283, 37, 6092, 356, 19328, 12, 272, 283, 37, 19612, 356, 1926, 12, 272, 283, 14057, 8746, 356, 1749, 1196, 12, 272, 283, 37, 502, 356, 1749, 1167, 12, 272, 283, 37, 26297, 356, 29202, 12, 272, 283, 15091, 356, 1749, 1046, 12, 272, 283, 41, 14696, 356, 24005, 12, 272, 283, 41, 6092, 356, 26761, 12, 272, 283, 41, 19612, 356, 14785, 12, 272, 283, 41, 12041, 356, 1749, 2025, 12, 272, 283, 41, 26297, 356, 31533, 12, 272, 283, 43, 15999, 356, 1749, 1081, 12, 272, 283, 21350, 356, 1749, 1789, 12, 272, 283, 16215, 356, 1749, 1194, 12, 272, 283, 46, 16488, 356, 499, 1643, 12, 272, 283, 21988, 356, 1749, 821, 12, 272, 283, 27588, 17506, 356, 650, 1703, 12, 272, 283, 47, 14696, 356, 30301, 12, 272, 283, 47, 6092, 356, 29532, 12, 272, 283, 47, 19612, 356, 26160, 12, 272, 283, 47, 29073, 356, 1749, 1401, 12, 272, 283, 47, 15003, 2641, 356, 1749, 1465, 12, 272, 283, 47, 7001, 356, 30630, 12, 272, 283, 47, 16488, 356, 499, 969, 12, 272, 283, 47, 26297, 356, 21237, 12, 272, 283, 5663, 73, 356, 1749, 1082, 12, 272, 283, 10542, 356, 1749, 1651, 12, 272, 283, 4562, 278, 356, 1695, 13440, 12, 272, 283, 48, 338, 356, 1749, 1344, 12, 272, 283, 50, 526, 356, 1749, 1398, 12, 272, 283, 51, 27627, 356, 650, 2528, 12, 272, 283, 23394, 356, 1749, 2192, 12, 272, 283, 2080, 32080, 356, 26485, 12, 272, 283, 52, 3844, 356, 1749, 708, 12, 272, 283, 2719, 1841, 356, 1749, 1165, 12, 272, 283, 53, 14696, 356, 32319, 12, 272, 283, 53, 6092, 356, 499, 1167, 12, 272, 283, 53, 19612, 356, 499, 1196, 12, 272, 283, 1721, 8746, 356, 1749, 1153, 12, 272, 283, 53, 26297, 356, 25647, 12, 272, 283, 14828, 356, 1749, 1479, 12, 272, 283, 57, 14696, 356, 499, 2025, 12, 272, 283, 57, 26297, 356, 650, 2114, 12, 272, 283, 25929, 356, 1749, 1085, 12, 272, 283, 65, 14696, 356, 28842, 12, 272, 283, 65, 6092, 356, 32584, 12, 272, 283, 14696, 356, 13576, 12, 272, 283, 3624, 17506, 356, 28700, 12, 272, 283, 643, 345, 432, 356, 18565, 12, 272, 283, 1895, 70, 3840, 356, 1695, 8216, 12, 272, 283, 4468, 356, 1749, 2322, 12, 272, 283, 5282, 356, 10448, 12, 272, 283, 460, 356, 1695, 21712, 12, 272, 283, 621, 356, 10513, 1344, 12, 272, 283, 439, 736, 356, 10551, 12, 272, 283, 9332, 356, 499, 1398, 12, 272, 283, 5660, 311, 356, 1695, 14626, 12, 272, 283, 2159, 76, 271, 356, 499, 1465, 12, 272, 283, 65, 26297, 356, 499, 1651, 12, 272, 283, 3691, 14209, 356, 1695, 9485, 12, 272, 283, 5683, 356, 1749, 2466, 12, 272, 283, 3289, 86, 1700, 356, 29923, 12, 272, 283, 66, 979, 356, 1695, 11085, 12, 272, 283, 2874, 356, 1695, 17007, 12, 272, 283, 67, 27916, 356, 499, 2192, 12, 272, 283, 27916, 356, 27631, 12, 272, 283, 2946, 356, 32729, 12, 272, 283, 13175, 356, 1749, 1822, 12, 272, 283, 6092, 356, 1520, 709, 12, 272, 283, 429, 30327, 356, 16096, 1465, 12, 272, 283, 388, 71, 356, 1695, 18507, 12, 272, 283, 1574, 356, 20680, 12, 272, 283, 1556, 5250, 356, 10300, 1398, 12, 272, 283, 17500, 356, 1695, 17718, 12, 272, 283, 895, 828, 356, 30380, 12, 272, 283, 68, 22011, 356, 10300, 1427, 12, 272, 283, 7406, 836, 356, 1695, 8731, 12, 272, 283, 4460, 82, 356, 1695, 16447, 12, 272, 283, 6458, 356, 27827, 12, 272, 283, 3136, 356, 1749, 2006, 12, 272, 283, 328, 19470, 356, 16096, 1216, 12, 272, 283, 16081, 356, 499, 2417, 12, 272, 283, 69, 14696, 356, 499, 1153, 12, 272, 283, 69, 6092, 356, 26569, 12, 272, 283, 69, 19612, 356, 499, 708, 12, 272, 283, 1667, 356, 10513, 1643, 12, 272, 283, 5633, 681, 356, 1695, 11874, 12, 272, 283, 287, 681, 356, 1695, 10860, 12, 272, 283, 15761, 356, 1749, 1887, 12, 272, 283, 20146, 356, 10523, 614, 12, 272, 283, 1841, 356, 1749, 2869, 12, 272, 283, 12391, 356, 21883, 12, 272, 283, 69, 26297, 356, 31071, 12, 272, 283, 27089, 356, 20582, 772, 12, 272, 283, 4494, 356, 10513, 1780, 12, 272, 283, 70, 889, 70, 356, 841, 996, 12, 272, 283, 509, 452, 356, 10513, 966, 12, 272, 283, 10865, 713, 356, 31446, 12, 272, 283, 10865, 1079, 356, 413, 1299, 12, 272, 283, 10865, 1082, 356, 29682, 12, 272, 283, 4391, 305, 76, 356, 1695, 13085, 12, 272, 283, 7325, 356, 1749, 2417, 12, 272, 283, 303, 356, 1695, 13027, 12, 272, 283, 3308, 356, 16202, 12, 272, 283, 72, 22011, 356, 10300, 2259, 12, 272, 283, 72, 5250, 356, 1695, 15112, 12, 272, 283, 426, 32611, 356, 16096, 1398, 12, 272, 283, 72, 16514, 356, 1695, 9687, 12, 272, 283, 73, 14696, 356, 499, 1401, 12, 272, 283, 530, 5958, 356, 27077, 12, 272, 283, 73, 476, 429, 356, 32372, 12, 272, 283, 528, 345, 432, 356, 499, 1344, 12, 272, 283, 1569, 356, 8264, 2182, 12, 272, 283, 262, 2408, 356, 10513, 1082, 12, 272 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 9189, 3489, 423, 5559, 272, 18294, 2878, 94, 339, 16332, 1896, 4514, 402, 314, 17504, 1059, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 421, 199, 4943, 63, 1309, 19144, 275, 469, 272, 283, 12500, 17506, 356, 413, 2905, 12, 272, 283, 33, 14696, 356, 413, 3129, 12, 272, 283, 33, 6092, 356, 413, 2635, 12, 272, 283, 33, 19612, 356, 13567, 12, 272, 283, 16192, 356, 1749, 969, 12, 272, 283, 1596, 316, 356, 413, 2576, 12, 272, 283, 33, 16488, 356, 413, 2720, 12, 272, 283, 33, 26297, 356, 32132, 12, 272, 283, 21732, 356, 1749, 1079, 12, 272, 283, 35, 27916, 356, 9013, 12, 272, 283, 29218, 356, 1749, 1276, 12, 272, 283, 36, 16267, 356, 1695, 10932, 12, 272, 283, 13411, 356, 1749, 975, 12, 272, 283, 21265, 356, 29203, 12, 272, 283, 37, 14696, 356, 1784, 12, 272, 283, 37, 6092, 356, 19328, 12, 272, 283, 37, 19612, 356, 1926, 12, 272, 283, 14057, 8746, 356, 1749, 1196, 12, 272, 283, 37, 502, 356, 1749, 1167, 12, 272, 283, 37, 26297, 356, 29202, 12, 272, 283, 15091, 356, 1749, 1046, 12, 272, 283, 41, 14696, 356, 24005, 12, 272, 283, 41, 6092, 356, 26761, 12, 272, 283, 41, 19612, 356, 14785, 12, 272, 283, 41, 12041, 356, 1749, 2025, 12, 272, 283, 41, 26297, 356, 31533, 12, 272, 283, 43, 15999, 356, 1749, 1081, 12, 272, 283, 21350, 356, 1749, 1789, 12, 272, 283, 16215, 356, 1749, 1194, 12, 272, 283, 46, 16488, 356, 499, 1643, 12, 272, 283, 21988, 356, 1749, 821, 12, 272, 283, 27588, 17506, 356, 650, 1703, 12, 272, 283, 47, 14696, 356, 30301, 12, 272, 283, 47, 6092, 356, 29532, 12, 272, 283, 47, 19612, 356, 26160, 12, 272, 283, 47, 29073, 356, 1749, 1401, 12, 272, 283, 47, 15003, 2641, 356, 1749, 1465, 12, 272, 283, 47, 7001, 356, 30630, 12, 272, 283, 47, 16488, 356, 499, 969, 12, 272, 283, 47, 26297, 356, 21237, 12, 272, 283, 5663, 73, 356, 1749, 1082, 12, 272, 283, 10542, 356, 1749, 1651, 12, 272, 283, 4562, 278, 356, 1695, 13440, 12, 272, 283, 48, 338, 356, 1749, 1344, 12, 272, 283, 50, 526, 356, 1749, 1398, 12, 272, 283, 51, 27627, 356, 650, 2528, 12, 272, 283, 23394, 356, 1749, 2192, 12, 272, 283, 2080, 32080, 356, 26485, 12, 272, 283, 52, 3844, 356, 1749, 708, 12, 272, 283, 2719, 1841, 356, 1749, 1165, 12, 272, 283, 53, 14696, 356, 32319, 12, 272, 283, 53, 6092, 356, 499, 1167, 12, 272, 283, 53, 19612, 356, 499, 1196, 12, 272, 283, 1721, 8746, 356, 1749, 1153, 12, 272, 283, 53, 26297, 356, 25647, 12, 272, 283, 14828, 356, 1749, 1479, 12, 272, 283, 57, 14696, 356, 499, 2025, 12, 272, 283, 57, 26297, 356, 650, 2114, 12, 272, 283, 25929, 356, 1749, 1085, 12, 272, 283, 65, 14696, 356, 28842, 12, 272, 283, 65, 6092, 356, 32584, 12, 272, 283, 14696, 356, 13576, 12, 272, 283, 3624, 17506, 356, 28700, 12, 272, 283, 643, 345, 432, 356, 18565, 12, 272, 283, 1895, 70, 3840, 356, 1695, 8216, 12, 272, 283, 4468, 356, 1749, 2322, 12, 272, 283, 5282, 356, 10448, 12, 272, 283, 460, 356, 1695, 21712, 12, 272, 283, 621, 356, 10513, 1344, 12, 272, 283, 439, 736, 356, 10551, 12, 272, 283, 9332, 356, 499, 1398, 12, 272, 283, 5660, 311, 356, 1695, 14626, 12, 272, 283, 2159, 76, 271, 356, 499, 1465, 12, 272, 283, 65, 26297, 356, 499, 1651, 12, 272, 283, 3691, 14209, 356, 1695, 9485, 12, 272, 283, 5683, 356, 1749, 2466, 12, 272, 283, 3289, 86, 1700, 356, 29923, 12, 272, 283, 66, 979, 356, 1695, 11085, 12, 272, 283, 2874, 356, 1695, 17007, 12, 272, 283, 67, 27916, 356, 499, 2192, 12, 272, 283, 27916, 356, 27631, 12, 272, 283, 2946, 356, 32729, 12, 272, 283, 13175, 356, 1749, 1822, 12, 272, 283, 6092, 356, 1520, 709, 12, 272, 283, 429, 30327, 356, 16096, 1465, 12, 272, 283, 388, 71, 356, 1695, 18507, 12, 272, 283, 1574, 356, 20680, 12, 272, 283, 1556, 5250, 356, 10300, 1398, 12, 272, 283, 17500, 356, 1695, 17718, 12, 272, 283, 895, 828, 356, 30380, 12, 272, 283, 68, 22011, 356, 10300, 1427, 12, 272, 283, 7406, 836, 356, 1695, 8731, 12, 272, 283, 4460, 82, 356, 1695, 16447, 12, 272, 283, 6458, 356, 27827, 12, 272, 283, 3136, 356, 1749, 2006, 12, 272, 283, 328, 19470, 356, 16096, 1216, 12, 272, 283, 16081, 356, 499, 2417, 12, 272, 283, 69, 14696, 356, 499, 1153, 12, 272, 283, 69, 6092, 356, 26569, 12, 272, 283, 69, 19612, 356, 499, 708, 12, 272, 283, 1667, 356, 10513, 1643, 12, 272, 283, 5633, 681, 356, 1695, 11874, 12, 272, 283, 287, 681, 356, 1695, 10860, 12, 272, 283, 15761, 356, 1749, 1887, 12, 272, 283, 20146, 356, 10523, 614, 12, 272, 283, 1841, 356, 1749, 2869, 12, 272, 283, 12391, 356, 21883, 12, 272, 283, 69, 26297, 356, 31071, 12, 272, 283, 27089, 356, 20582, 772, 12, 272, 283, 4494, 356, 10513, 1780, 12, 272, 283, 70, 889, 70, 356, 841, 996, 12, 272, 283, 509, 452, 356, 10513, 966, 12, 272, 283, 10865, 713, 356, 31446, 12, 272, 283, 10865, 1079, 356, 413, 1299, 12, 272, 283, 10865, 1082, 356, 29682, 12, 272, 283, 4391, 305, 76, 356, 1695, 13085, 12, 272, 283, 7325, 356, 1749, 2417, 12, 272, 283, 303, 356, 1695, 13027, 12, 272, 283, 3308, 356, 16202, 12, 272, 283, 72, 22011, 356, 10300, 2259, 12, 272, 283, 72, 5250, 356, 1695, 15112, 12, 272, 283, 426, 32611, 356, 16096, 1398, 12, 272, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dirtycoder/opbeat_python
opbeat/base.py
2
20371
""" opbeat.base ~~~~~~~~~~ :copyright: (c) 2011-2012 Opbeat Large portions are :copyright: (c) 2010 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from __future__ import absolute_import import contextlib import datetime import logging import sys import time import zlib import uuid import os import warnings from opbeat.utils import six from opbeat.utils.deprecation import deprecated import opbeat from opbeat.conf import defaults from opbeat.utils import opbeat_json as json, varmap from opbeat.utils.compat import atexit_register, urlparse from opbeat.utils.encoding import transform, shorten from opbeat.traces import RequestsStore from opbeat.utils.stacks import iter_stack_frames, get_culprit from opbeat.utils import stacks from opbeat.transport.http import HTTPTransport, AsyncHTTPTransport __all__ = ('Client',) class ModuleProxyCache(dict): def __missing__(self, key): module, class_name = key.rsplit('.', 1) handler = getattr(__import__(module, {}, {}, [class_name]), class_name) self[key] = handler return handler class ClientState(object): ONLINE = 1 ERROR = 0 def __init__(self): self.status = self.ONLINE self.last_check = None self.retry_number = 0 def should_try(self): if self.status == self.ONLINE: return True interval = min(self.retry_number, 6) ** 2 if time.time() - self.last_check > interval: return True return False def set_fail(self): self.status = self.ERROR self.retry_number += 1 self.last_check = time.time() def set_success(self): self.status = self.ONLINE self.last_check = None self.retry_number = 0 def did_fail(self): return self.status == self.ERROR class Client(object): """ The base opbeat client, which handles communication over the HTTP API to Opbeat servers. Will read default configuration from the environment variable ``OPBEAT_ORGANIZATION_ID``, ``OPBEAT_APP_ID`` and ``OPBEAT_SECRET_TOKEN`` if available. :: >>> from opbeat import Client >>> # Read configuration from environment >>> client = Client() >>> # Configure the client manually >>> client = Client( >>> include_paths=['my.package'], >>> organization_id='org_id', >>> app_id='app_id', >>> secret_token='secret_token', >>> ) >>> # Record an exception >>> try: >>> 1/0 >>> except ZeroDivisionError: >>> ident = client.get_ident(client.capture_exception()) >>> print "Exception caught; reference is %%s" %% ident """ logger = logging.getLogger('opbeat') protocol_version = '1.0' def __init__(self, organization_id=None, app_id=None, secret_token=None, include_paths=None, exclude_paths=None, timeout=None, hostname=None, auto_log_stacks=None, key=None, string_max_length=None, list_max_length=None, processors=None, servers=None, api_path=None, async=None, async_mode=None, traces_send_freq_secs=None, **kwargs): # configure loggers first cls = self.__class__ self.logger = logging.getLogger('%s.%s' % (cls.__module__, cls.__name__)) self.error_logger = logging.getLogger('opbeat.errors') self.state = ClientState() if organization_id is None and os.environ.get('OPBEAT_ORGANIZATION_ID'): msg = "Configuring opbeat from environment variable 'OPBEAT_ORGANIZATION_ID'" self.logger.info(msg) organization_id = os.environ['OPBEAT_ORGANIZATION_ID'] if app_id is None and os.environ.get('OPBEAT_APP_ID'): msg = "Configuring opbeat from environment variable 'OPBEAT_APP_ID'" self.logger.info(msg) app_id = os.environ['OPBEAT_APP_ID'] if secret_token is None and os.environ.get('OPBEAT_SECRET_TOKEN'): msg = "Configuring opbeat from environment variable 'OPBEAT_SECRET_TOKEN'" self.logger.info(msg) secret_token = os.environ['OPBEAT_SECRET_TOKEN'] self.servers = servers or defaults.SERVERS if async is not None and async_mode is None: warnings.warn( 'Usage of "async" argument is deprecated. Use "async_mode"', category=DeprecationWarning, stacklevel=2, ) async_mode = async self.async_mode = (async_mode is True or (defaults.ASYNC_MODE and async_mode is not False)) self._transport_class = AsyncHTTPTransport if self.async_mode else HTTPTransport self._transports = {} # servers may be set to a NoneType (for Django) if self.servers and not (organization_id and app_id and secret_token): msg = 'Missing configuration for client. Please see documentation.' self.logger.info(msg) self.include_paths = set(include_paths or defaults.INCLUDE_PATHS) self.exclude_paths = set(exclude_paths or defaults.EXCLUDE_PATHS) self.timeout = int(timeout or defaults.TIMEOUT) self.hostname = six.text_type(hostname or defaults.HOSTNAME) self.auto_log_stacks = bool(auto_log_stacks or defaults.AUTO_LOG_STACKS) self.string_max_length = int(string_max_length or defaults.MAX_LENGTH_STRING) self.list_max_length = int(list_max_length or defaults.MAX_LENGTH_LIST) self.traces_send_freq_secs = (traces_send_freq_secs or defaults.TRACES_SEND_FREQ_SECS) self.organization_id = six.text_type(organization_id) self.app_id = six.text_type(app_id) self.secret_token = six.text_type(secret_token) self.processors = processors or defaults.PROCESSORS self.module_cache = ModuleProxyCache() self.instrumentation_store = RequestsStore( lambda: self.get_stack_info_for_trace(iter_stack_frames(), False), self.traces_send_freq_secs) atexit_register(self.close) @contextlib.contextmanager def capture_trace(self, signature, kind='code.custom', extra=None, skip_frames=0, leaf=False): with self.instrumentation_store.trace(signature, kind, extra, skip_frames, leaf): yield def get_processors(self): for processor in self.processors: yield self.module_cache[processor](self) def get_ident(self, result): """ Returns a searchable string representing a message. >>> result = client.process(**kwargs) >>> ident = client.get_ident(result) """ return '$'.join(result) def get_handler(self, name): return self.module_cache[name](self) def get_stack_info_for_trace(self, frames, extended=True): """Overrideable in derived clients to add frames/info, e.g. templates 4.0: Use for error frames too. """ return stacks.get_stack_info(frames, extended) def build_msg_for_logging(self, event_type, data=None, date=None, extra=None, stack=None, **kwargs): """ Captures, processes and serializes an event into a dict object """ # create ID client-side so that it can be passed to application event_id = uuid.uuid4().hex if data is None: data = {} if extra is None: extra = {} if not date: date = datetime.datetime.utcnow() if stack is None: stack = self.auto_log_stacks self.build_msg(data=data) # if '.' not in event_type: # Assume it's a builtin event_type = 'opbeat.events.%s' % event_type handler = self.get_handler(event_type) result = handler.capture(**kwargs) # data (explicit) culprit takes over auto event detection culprit = result.pop('culprit', None) if data.get('culprit'): culprit = data['culprit'] for k, v in six.iteritems(result): if k not in data: data[k] = v if stack and 'stacktrace' not in data: if stack is True: frames = iter_stack_frames() else: frames = stack data.update({ 'stacktrace': { 'frames': varmap(lambda k, v: shorten(v, string_length=self.string_max_length, list_length=self.list_max_length), stacks.get_stack_info(frames)) }, }) if 'stacktrace' in data and not culprit: culprit = get_culprit( data['stacktrace']['frames'], self.include_paths, self.exclude_paths ) if not data.get('level'): data['level'] = 'error' if isinstance( data['level'], six.integer_types): data['level'] = logging.getLevelName(data['level']).lower() data.setdefault('extra', {}) # Shorten lists/strings for k, v in six.iteritems(extra): data['extra'][k] = shorten(v, string_length=self.string_max_length, list_length=self.list_max_length) if culprit: data['culprit'] = culprit # Run the data through processors for processor in self.get_processors(): data.update(processor.process(data)) # Make sure all data is coerced data = transform(data) if 'message' not in data: data['message'] = handler.to_string(data) # Make sure certain values are not too long for v in defaults.MAX_LENGTH_VALUES: if v in data: data[v] = shorten(data[v], string_length=defaults.MAX_LENGTH_VALUES[v] ) data.update({ 'timestamp': date, # 'time_spent': time_spent, 'client_supplied_id': event_id, }) return data def build_msg(self, data=None, **kwargs): data.setdefault('machine', {'hostname': self.hostname}) data.setdefault('organization_id', self.organization_id) data.setdefault('app_id', self.app_id) data.setdefault('secret_token', self.secret_token) return data def capture(self, event_type, data=None, date=None, api_path=None, extra=None, stack=None, **kwargs): """ Captures and processes an event and pipes it off to Client.send. To use structured data (interfaces) with capture: >>> client.capture('Message', message='foo', data={ >>> 'http': { >>> 'url': '...', >>> 'data': {}, >>> 'query_string': '...', >>> 'method': 'POST', >>> }, >>> 'logger': 'logger.name', >>> 'site': 'site.name', >>> }, extra={ >>> 'key': 'value', >>> }) The finalized ``data`` structure contains the following (some optional) builtin values: >>> { >>> # the culprit and version information >>> 'culprit': 'full.module.name', # or /arbitrary/path >>> >>> # arbitrary data provided by user >>> 'extra': { >>> 'key': 'value', >>> } >>> } :param event_type: the module path to the Event class. Builtins can use shorthand class notation and exclude the full module path. :param data: the data base :param date: the datetime of this event :param client_supplied_id: a 32-length unique string identifying this event :param extra: a dictionary of additional standard metadata :param culprit: a string representing the cause of this event (generally a path to a function) :return: a 32-length string identifying this event """ data = self.build_msg_for_logging(event_type, data, date, extra, stack, **kwargs) if not api_path: api_path = defaults.ERROR_API_PATH.format( data['organization_id'], data['app_id'] ) data['servers'] = [server+api_path for server in self.servers] self.send(**data) return data['client_supplied_id'] def _send_remote(self, url, data, headers=None): if headers is None: headers = {} parsed = urlparse.urlparse(url) transport = self._get_transport(parsed) if transport.async_mode: transport.send_async( data, headers, success_callback=self.handle_transport_success, fail_callback=self.handle_transport_fail ) else: response = transport.send(data, headers, timeout=self.timeout) self.handle_transport_success(url=response.info().get('Location')) return response def _get_log_message(self, data): # decode message so we can show the actual event try: data = self.decode(data) except: message = '<failed decoding data>' else: message = data.pop('message', '<no message value>') return message def _get_transport(self, parsed_url): if parsed_url not in self._transports: self._transports[parsed_url] = self._transport_class(parsed_url) return self._transports[parsed_url] def send_remote(self, url, data, headers=None): if not self.state.should_try(): message = self._get_log_message(data) self.error_logger.error(message) return try: self._send_remote(url=url, data=data, headers=headers) except Exception as e: self.handle_transport_fail(exception=e) def send(self, organization_id=None, app_id=None, secret_token=None, auth_header=None, servers=None, **data): """ Serializes the message and passes the payload onto ``send_encoded``. """ message = self.encode(data) try: return self.send_encoded(message, organization_id=organization_id, app_id=app_id, secret_token=secret_token, auth_header=auth_header, servers=servers) except TypeError: # Make the assumption that public_key wasnt supported warnings.warn( '%s.send_encoded needs updated to support ``**kwargs``' % ( type(self).__name__, ), DeprecationWarning ) return self.send_encoded(message) def send_encoded(self, message, organization_id, app_id, secret_token, auth_header=None, servers = None, **kwargs): """ Given an already serialized message, signs the message and passes the payload off to ``send_remote`` for each server specified in the servers configuration. """ servers = servers or self.servers if not servers: warnings.warn('opbeat client has no remote servers configured') return if not auth_header: if not organization_id: organization_id = self.organization_id if not app_id: app_id = self.app_id if not secret_token: secret_token = self.secret_token auth_header = "Bearer %s" % (secret_token) for url in servers: headers = { 'Authorization': auth_header, 'Content-Type': 'application/octet-stream', 'User-Agent': 'opbeat-python/%s' % opbeat.VERSION } self.send_remote(url=url, data=message, headers=headers) def encode(self, data): """ Serializes ``data`` into a raw string. """ # return json.dumps(data).encode('zlib') return zlib.compress(json.dumps(data).encode('utf8')) def decode(self, data): """ Unserializes a string, ``data``. """ return json.loads(zlib.decompress(data).decode('utf8')) def capture_message(self, message, **kwargs): """ Creates an event from ``message``. >>> client.capture_message('My event just happened!') """ return self.capture('Message', message=message, **kwargs) @deprecated(alternative="capture_message()") def captureMessage(self, message, **kwargs): """ Deprecated :param message: :type message: :param kwargs: :type kwargs: :return: :rtype: """ self.capture_message(message, **kwargs) def capture_exception(self, exc_info=None, **kwargs): """ Creates an event from an exception. >>> try: >>> exc_info = sys.exc_info() >>> client.capture_exception(exc_info) >>> finally: >>> del exc_info If exc_info is not provided, or is set to True, then this method will perform the ``exc_info = sys.exc_info()`` and the requisite clean-up for you. """ return self.capture('Exception', exc_info=exc_info, **kwargs) @deprecated(alternative="capture_exception()") def captureException(self, exc_info=None, **kwargs): """ Deprecated """ self.capture_exception(exc_info, **kwargs) def capture_query(self, query, params=(), engine=None, **kwargs): """ Creates an event for a SQL query. >>> client.capture_query('SELECT * FROM foo') """ return self.capture('Query', query=query, params=params, engine=engine, **kwargs) @deprecated(alternative="capture_query()") def captureQuery(self, *args, **kwargs): """ Deprecated """ self.capture_query(*args, **kwargs) def begin_transaction(self): self.instrumentation_store.transaction_start() def end_transaction(self, status_code, name): self.instrumentation_store.transaction_end(status_code, name) if self.instrumentation_store.should_collect(): self._traces_collect() def close(self): self._traces_collect() for url, transport in self._transports.items(): transport.close() def handle_transport_success(self, **kwargs): """ Success handler called by the transport """ if kwargs.get('url'): self.logger.info('Logged error at ' + kwargs['url']) self.state.set_success() def handle_transport_fail(self, **kwargs): """ Failure handler called by the transport """ exception = kwargs.get('exception') message = self._get_log_message(exception.data) self.error_logger.error(exception.args[0]) self.error_logger.error( 'Failed to submit message: %r', message, exc_info=True ) self.state.set_fail() def _traces_collect(self): transactions, traces = self.instrumentation_store.get_all() if not transactions or not traces: return data = self.build_msg({ 'transactions': transactions, 'traces': traces, }) api_path = defaults.TRANSACTIONS_API_PATH.format( self.organization_id, self.app_id, ) data['servers'] = [server + api_path for server in self.servers] self.send(**data) class DummyClient(Client): """Sends messages into an empty void""" def send(self, **kwargs): return None
bsd-3-clause
[ 624, 199, 411, 12522, 14, 1095, 199, 4919, 1714, 199, 199, 26, 7307, 26, 334, 67, 9, 7760, 13, 7409, 9319, 12522, 199, 199, 17149, 12468, 787, 199, 26, 7307, 26, 334, 67, 9, 7129, 701, 314, 428, 2373, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 199, 26, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 15502, 199, 646, 2197, 199, 646, 2050, 199, 646, 984, 199, 646, 900, 199, 646, 12472, 199, 646, 5377, 199, 199, 646, 747, 199, 646, 3598, 199, 199, 504, 1687, 12522, 14, 1208, 492, 3816, 199, 504, 1687, 12522, 14, 1208, 14, 15383, 492, 5906, 199, 646, 1687, 12522, 199, 504, 1687, 12522, 14, 2190, 492, 4243, 199, 504, 1687, 12522, 14, 1208, 492, 1687, 12522, 63, 1001, 465, 2022, 12, 2729, 1130, 199, 504, 1687, 12522, 14, 1208, 14, 5819, 492, 19840, 63, 2683, 12, 7097, 199, 504, 1687, 12522, 14, 1208, 14, 2991, 492, 5793, 12, 25123, 199, 504, 1687, 12522, 14, 28388, 492, 20260, 5502, 199, 504, 1687, 12522, 14, 1208, 14, 21707, 492, 2740, 63, 2340, 63, 8444, 12, 664, 63, 3119, 1359, 84, 199, 504, 1687, 12522, 14, 1208, 492, 26733, 199, 504, 1687, 12522, 14, 5545, 14, 1014, 492, 3101, 7836, 12, 15223, 2856, 7836, 199, 199, 363, 452, 363, 275, 661, 3041, 9538, 421, 199, 533, 5673, 4936, 4437, 8, 807, 304, 272, 347, 636, 4752, 721, 277, 12, 790, 304, 267, 859, 12, 1021, 63, 354, 275, 790, 14, 13490, 14078, 413, 9, 398, 3016, 275, 2519, 3460, 646, 721, 578, 12, 5479, 355, 5479, 359, 533, 63, 354, 2522, 1021, 63, 354, 9, 398, 291, 59, 498, 61, 275, 3016, 398, 372, 3016, 421, 199, 533, 6810, 2223, 8, 785, 304, 272, 5258, 6174, 275, 413, 272, 12539, 275, 378, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1205, 275, 291, 14, 615, 6174, 267, 291, 14, 2019, 63, 1074, 275, 488, 267, 291, 14, 7154, 63, 1955, 275, 378, 339, 347, 1077, 63, 893, 8, 277, 304, 267, 340, 291, 14, 1205, 508, 291, 14, 615, 6174, 26, 288, 372, 715, 398, 6252, 275, 1748, 8, 277, 14, 7154, 63, 1955, 12, 1227, 9, 1011, 499, 398, 340, 900, 14, 521, 342, 446, 291, 14, 2019, 63, 1074, 690, 6252, 26, 288, 372, 715, 398, 372, 756, 339, 347, 663, 63, 1633, 8, 277, 304, 267, 291, 14, 1205, 275, 291, 14, 3170, 267, 291, 14, 7154, 63, 1955, 847, 413, 267, 291, 14, 2019, 63, 1074, 275, 900, 14, 521, 342, 339, 347, 663, 63, 3742, 8, 277, 304, 267, 291, 14, 1205, 275, 291, 14, 615, 6174, 267, 291, 14, 2019, 63, 1074, 275, 488, 267, 291, 14, 7154, 63, 1955, 275, 378, 339, 347, 8103, 63, 1633, 8, 277, 304, 267, 372, 291, 14, 1205, 508, 291, 14, 3170, 421, 199, 533, 6810, 8, 785, 304, 272, 408, 272, 710, 1300, 1687, 12522, 1890, 12, 1314, 10022, 23506, 1806, 314, 272, 3101, 3261, 370, 9319, 12522, 8037, 14, 339, 12823, 1586, 849, 2897, 687, 314, 3734, 1750, 272, 1124, 1938, 6773, 619, 63, 25797, 879, 22800, 63, 998, 4542, 1124, 1938, 6773, 619, 63, 7121, 63, 998, 1040, 436, 1124, 1938, 6773, 619, 63, 12961, 63, 8803, 1040, 272, 340, 2808, 14, 3800, 339, 1306, 687, 1687, 12522, 492, 6810, 339, 1306, 327, 5574, 2897, 687, 3734, 272, 1306, 1890, 275, 6810, 342, 339, 1306, 327, 15453, 314, 1890, 10250, 272, 1306, 1890, 275, 6810, 8, 272, 1306, 258, 2387, 63, 3771, 2968, 1662, 14, 2491, 995, 272, 1306, 258, 13237, 63, 344, 534, 1308, 63, 344, 297, 272, 1306, 258, 1145, 63, 344, 534, 571, 63, 344, 297, 272, 1306, 258, 7565, 63, 1418, 534, 4731, 63, 1418, 297, 272, 1306, 776, 339, 1306, 327, 12651, 376, 1919, 272, 1306, 862, 26, 272, 1306, 258, 413, 15, 16, 272, 1306, 871, 25838, 26, 272, 1306, 258, 12893, 275, 1890, 14, 362, 63, 5425, 8, 1258, 14, 12685, 63, 1971, 1012, 272, 1306, 258, 870, 298, 1726, 15604, 27, 3659, 365, 11539, 83, 2, 11539, 12893, 272, 408, 272, 2512, 275, 2050, 14, 5572, 360, 411, 12522, 358, 272, 4113, 63, 1023, 275, 283, 17, 14, 16, 7, 339, 347, 636, 826, 721, 277, 12, 13237, 63, 344, 29, 403, 12, 1145, 63, 344, 29, 403, 12, 7565, 63, 1418, 29, 403, 12, 326, 2387, 63, 3771, 29, 403, 12, 5760, 63, 3771, 29, 403, 12, 326, 2653, 29, 403, 12, 6246, 29, 403, 12, 2599, 63, 793, 63, 21707, 29, 403, 12, 790, 29, 403, 12, 326, 1059, 63, 988, 63, 1267, 29, 403, 12, 769, 63, 988, 63, 1267, 29, 403, 12, 326, 21620, 29, 403, 12, 8037, 29, 403, 12, 2986, 63, 515, 29, 403, 12, 5316, 29, 403, 12, 326, 5316, 63, 632, 29, 403, 12, 26365, 63, 2254, 63, 5646, 63, 4855, 29, 403, 12, 326, 1011, 958, 304, 267, 327, 7908, 23445, 1642, 267, 843, 275, 291, 855, 533, 363, 267, 291, 14, 2921, 275, 2050, 14, 5572, 3508, 83, 4111, 83, 7, 450, 334, 1886, 855, 578, 3108, 288, 843, 855, 354, 8964, 267, 291, 14, 705, 63, 2921, 275, 2050, 14, 5572, 360, 411, 12522, 14, 2550, 358, 267, 291, 14, 929, 275, 6810, 2223, 342, 398, 340, 13237, 63, 344, 365, 488, 436, 747, 14, 2314, 14, 362, 360, 1938, 6773, 619, 63, 25797, 879, 22800, 63, 998, 735, 288, 1499, 275, 298, 2028, 4039, 1687, 12522, 687, 3734, 1750, 283, 1938, 6773, 619, 63, 25797, 879, 22800, 63, 998, 4065, 288, 291, 14, 2921, 14, 815, 8, 1328, 9, 288, 13237, 63, 344, 275, 747, 14, 2314, 459, 1938, 6773, 619, 63, 25797, 879, 22800, 63, 998, 418, 398, 340, 1145, 63, 344, 365, 488, 436, 747, 14, 2314, 14, 362, 360, 1938, 6773, 619, 63, 7121, 63, 998, 735, 288, 1499, 275, 298, 2028, 4039, 1687, 12522, 687, 3734, 1750, 283, 1938, 6773, 619, 63, 7121, 63, 998, 4065, 288, 291, 14, 2921, 14, 815, 8, 1328, 9, 288, 1145, 63, 344, 275, 747 ]
[ 199, 411, 12522, 14, 1095, 199, 4919, 1714, 199, 199, 26, 7307, 26, 334, 67, 9, 7760, 13, 7409, 9319, 12522, 199, 199, 17149, 12468, 787, 199, 26, 7307, 26, 334, 67, 9, 7129, 701, 314, 428, 2373, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 199, 26, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 15502, 199, 646, 2197, 199, 646, 2050, 199, 646, 984, 199, 646, 900, 199, 646, 12472, 199, 646, 5377, 199, 199, 646, 747, 199, 646, 3598, 199, 199, 504, 1687, 12522, 14, 1208, 492, 3816, 199, 504, 1687, 12522, 14, 1208, 14, 15383, 492, 5906, 199, 646, 1687, 12522, 199, 504, 1687, 12522, 14, 2190, 492, 4243, 199, 504, 1687, 12522, 14, 1208, 492, 1687, 12522, 63, 1001, 465, 2022, 12, 2729, 1130, 199, 504, 1687, 12522, 14, 1208, 14, 5819, 492, 19840, 63, 2683, 12, 7097, 199, 504, 1687, 12522, 14, 1208, 14, 2991, 492, 5793, 12, 25123, 199, 504, 1687, 12522, 14, 28388, 492, 20260, 5502, 199, 504, 1687, 12522, 14, 1208, 14, 21707, 492, 2740, 63, 2340, 63, 8444, 12, 664, 63, 3119, 1359, 84, 199, 504, 1687, 12522, 14, 1208, 492, 26733, 199, 504, 1687, 12522, 14, 5545, 14, 1014, 492, 3101, 7836, 12, 15223, 2856, 7836, 199, 199, 363, 452, 363, 275, 661, 3041, 9538, 421, 199, 533, 5673, 4936, 4437, 8, 807, 304, 272, 347, 636, 4752, 721, 277, 12, 790, 304, 267, 859, 12, 1021, 63, 354, 275, 790, 14, 13490, 14078, 413, 9, 398, 3016, 275, 2519, 3460, 646, 721, 578, 12, 5479, 355, 5479, 359, 533, 63, 354, 2522, 1021, 63, 354, 9, 398, 291, 59, 498, 61, 275, 3016, 398, 372, 3016, 421, 199, 533, 6810, 2223, 8, 785, 304, 272, 5258, 6174, 275, 413, 272, 12539, 275, 378, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1205, 275, 291, 14, 615, 6174, 267, 291, 14, 2019, 63, 1074, 275, 488, 267, 291, 14, 7154, 63, 1955, 275, 378, 339, 347, 1077, 63, 893, 8, 277, 304, 267, 340, 291, 14, 1205, 508, 291, 14, 615, 6174, 26, 288, 372, 715, 398, 6252, 275, 1748, 8, 277, 14, 7154, 63, 1955, 12, 1227, 9, 1011, 499, 398, 340, 900, 14, 521, 342, 446, 291, 14, 2019, 63, 1074, 690, 6252, 26, 288, 372, 715, 398, 372, 756, 339, 347, 663, 63, 1633, 8, 277, 304, 267, 291, 14, 1205, 275, 291, 14, 3170, 267, 291, 14, 7154, 63, 1955, 847, 413, 267, 291, 14, 2019, 63, 1074, 275, 900, 14, 521, 342, 339, 347, 663, 63, 3742, 8, 277, 304, 267, 291, 14, 1205, 275, 291, 14, 615, 6174, 267, 291, 14, 2019, 63, 1074, 275, 488, 267, 291, 14, 7154, 63, 1955, 275, 378, 339, 347, 8103, 63, 1633, 8, 277, 304, 267, 372, 291, 14, 1205, 508, 291, 14, 3170, 421, 199, 533, 6810, 8, 785, 304, 272, 408, 272, 710, 1300, 1687, 12522, 1890, 12, 1314, 10022, 23506, 1806, 314, 272, 3101, 3261, 370, 9319, 12522, 8037, 14, 339, 12823, 1586, 849, 2897, 687, 314, 3734, 1750, 272, 1124, 1938, 6773, 619, 63, 25797, 879, 22800, 63, 998, 4542, 1124, 1938, 6773, 619, 63, 7121, 63, 998, 1040, 436, 1124, 1938, 6773, 619, 63, 12961, 63, 8803, 1040, 272, 340, 2808, 14, 3800, 339, 1306, 687, 1687, 12522, 492, 6810, 339, 1306, 327, 5574, 2897, 687, 3734, 272, 1306, 1890, 275, 6810, 342, 339, 1306, 327, 15453, 314, 1890, 10250, 272, 1306, 1890, 275, 6810, 8, 272, 1306, 258, 2387, 63, 3771, 2968, 1662, 14, 2491, 995, 272, 1306, 258, 13237, 63, 344, 534, 1308, 63, 344, 297, 272, 1306, 258, 1145, 63, 344, 534, 571, 63, 344, 297, 272, 1306, 258, 7565, 63, 1418, 534, 4731, 63, 1418, 297, 272, 1306, 776, 339, 1306, 327, 12651, 376, 1919, 272, 1306, 862, 26, 272, 1306, 258, 413, 15, 16, 272, 1306, 871, 25838, 26, 272, 1306, 258, 12893, 275, 1890, 14, 362, 63, 5425, 8, 1258, 14, 12685, 63, 1971, 1012, 272, 1306, 258, 870, 298, 1726, 15604, 27, 3659, 365, 11539, 83, 2, 11539, 12893, 272, 408, 272, 2512, 275, 2050, 14, 5572, 360, 411, 12522, 358, 272, 4113, 63, 1023, 275, 283, 17, 14, 16, 7, 339, 347, 636, 826, 721, 277, 12, 13237, 63, 344, 29, 403, 12, 1145, 63, 344, 29, 403, 12, 7565, 63, 1418, 29, 403, 12, 326, 2387, 63, 3771, 29, 403, 12, 5760, 63, 3771, 29, 403, 12, 326, 2653, 29, 403, 12, 6246, 29, 403, 12, 2599, 63, 793, 63, 21707, 29, 403, 12, 790, 29, 403, 12, 326, 1059, 63, 988, 63, 1267, 29, 403, 12, 769, 63, 988, 63, 1267, 29, 403, 12, 326, 21620, 29, 403, 12, 8037, 29, 403, 12, 2986, 63, 515, 29, 403, 12, 5316, 29, 403, 12, 326, 5316, 63, 632, 29, 403, 12, 26365, 63, 2254, 63, 5646, 63, 4855, 29, 403, 12, 326, 1011, 958, 304, 267, 327, 7908, 23445, 1642, 267, 843, 275, 291, 855, 533, 363, 267, 291, 14, 2921, 275, 2050, 14, 5572, 3508, 83, 4111, 83, 7, 450, 334, 1886, 855, 578, 3108, 288, 843, 855, 354, 8964, 267, 291, 14, 705, 63, 2921, 275, 2050, 14, 5572, 360, 411, 12522, 14, 2550, 358, 267, 291, 14, 929, 275, 6810, 2223, 342, 398, 340, 13237, 63, 344, 365, 488, 436, 747, 14, 2314, 14, 362, 360, 1938, 6773, 619, 63, 25797, 879, 22800, 63, 998, 735, 288, 1499, 275, 298, 2028, 4039, 1687, 12522, 687, 3734, 1750, 283, 1938, 6773, 619, 63, 25797, 879, 22800, 63, 998, 4065, 288, 291, 14, 2921, 14, 815, 8, 1328, 9, 288, 13237, 63, 344, 275, 747, 14, 2314, 459, 1938, 6773, 619, 63, 25797, 879, 22800, 63, 998, 418, 398, 340, 1145, 63, 344, 365, 488, 436, 747, 14, 2314, 14, 362, 360, 1938, 6773, 619, 63, 7121, 63, 998, 735, 288, 1499, 275, 298, 2028, 4039, 1687, 12522, 687, 3734, 1750, 283, 1938, 6773, 619, 63, 7121, 63, 998, 4065, 288, 291, 14, 2921, 14, 815, 8, 1328, 9, 288, 1145, 63, 344, 275, 747, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sudosurootdev/kernel_lge_g3-1
tools/perf/scripts/python/net_dropmonitor.py
4235
1554
# Monitor the system for dropped packets and proudce a report of drop locations and counts import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import * drop_log = {} kallsyms = [] def get_kallsyms_table(): global kallsyms try: f = open("/proc/kallsyms", "r") linecount = 0 for line in f: linecount = linecount+1 f.seek(0) except: return j = 0 for line in f: loc = int(line.split()[0], 16) name = line.split()[2] j = j +1 if ((j % 100) == 0): print "\r" + str(j) + "/" + str(linecount), kallsyms.append({ 'loc': loc, 'name' : name}) print "\r" + str(j) + "/" + str(linecount) kallsyms.sort() return def get_sym(sloc): loc = int(sloc) for i in kallsyms: if (i['loc'] >= loc): return (i['name'], i['loc']-loc) return (None, 0) def print_drop_table(): print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT") for i in drop_log.keys(): (sym, off) = get_sym(i) if sym == None: sym = i print "%25s %25s %25s" % (sym, off, drop_log[i]) def trace_begin(): print "Starting trace (Ctrl-C to dump results)" def trace_end(): print "Gathering kallsyms data" get_kallsyms_table() print_drop_table() # called from perf, when it finds a correspoinding event def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, skbaddr, protocol, location): slocation = str(location) try: drop_log[slocation] = drop_log[slocation] + 1 except: drop_log[slocation] = 1
gpl-2.0
[ 3, 26504, 314, 2656, 367, 17481, 14593, 436, 557, 1181, 301, 282, 3622, 402, 5978, 9918, 436, 8242, 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, 507, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 4824, 63, 793, 275, 1052, 199, 32483, 275, 942, 199, 199, 318, 664, 63, 32483, 63, 1224, 837, 199, 198, 2966, 1022, 452, 13807, 199, 198, 893, 26, 507, 198, 70, 275, 1551, 4769, 4687, 15, 32483, 401, 298, 82, 531, 507, 198, 604, 835, 275, 378, 507, 198, 509, 1004, 315, 289, 26, 686, 198, 604, 835, 275, 1004, 835, 11, 17, 507, 198, 70, 14, 5507, 8, 16, 9, 199, 198, 2590, 26, 507, 198, 1107, 4388, 198, 74, 275, 378, 199, 198, 509, 1004, 315, 289, 26, 507, 198, 2102, 275, 1109, 8, 604, 14, 1294, 3430, 16, 467, 3193, 9, 507, 198, 354, 275, 1004, 14, 1294, 3430, 18, 61, 507, 198, 74, 275, 1335, 435, 17, 507, 198, 692, 3666, 74, 450, 2948, 9, 508, 378, 304, 686, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 395, 507, 198, 32483, 14, 740, 2561, 283, 2102, 356, 4355, 12, 283, 354, 7, 520, 536, 1552, 421, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 9, 199, 198, 32483, 14, 3191, 342, 199, 198, 1107, 199, 199, 318, 664, 63, 3840, 8, 83, 2102, 304, 199, 198, 2102, 275, 1109, 8, 83, 2102, 9, 199, 198, 509, 284, 315, 1022, 452, 13807, 26, 507, 198, 692, 334, 73, 459, 2102, 418, 2356, 4355, 304, 686, 198, 1107, 334, 73, 459, 354, 995, 284, 459, 2102, 418, 13, 2102, 9, 199, 198, 1107, 334, 403, 12, 378, 9, 199, 199, 318, 870, 63, 4824, 63, 1224, 837, 199, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 1689, 16575, 401, 298, 14839, 401, 298, 8760, 531, 199, 198, 509, 284, 315, 5978, 63, 793, 14, 1612, 837, 507, 198, 8, 3840, 12, 2331, 9, 275, 664, 63, 3840, 8, 73, 9, 507, 198, 692, 4678, 508, 488, 26, 686, 198, 3840, 275, 284, 507, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 334, 3840, 12, 2331, 12, 5978, 63, 793, 59, 73, 566, 421, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14139, 3307, 334, 9778, 13, 35, 370, 5461, 2058, 2924, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 298, 39, 7404, 316, 1022, 452, 13807, 666, 2, 199, 198, 362, 63, 32483, 63, 1224, 342, 199, 198, 1361, 63, 4824, 63, 1224, 342, 199, 199, 3, 2797, 687, 8582, 12, 1380, 652, 17651, 282, 1970, 470, 555, 688, 316, 1566, 199, 318, 11448, 363, 22197, 63, 6852, 8, 354, 12, 1067, 12, 5033, 12, 6513, 12, 14256, 12, 4422, 12, 1923, 12, 686, 198, 13664, 12, 4113, 12, 2909, 304, 199, 198, 83, 1985, 275, 620, 8, 1985, 9, 199, 198, 893, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 5978, 63, 793, 59, 83, 1985, 61, 435, 413, 199, 198, 2590, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 26504, 314, 2656, 367, 17481, 14593, 436, 557, 1181, 301, 282, 3622, 402, 5978, 9918, 436, 8242, 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, 507, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 4824, 63, 793, 275, 1052, 199, 32483, 275, 942, 199, 199, 318, 664, 63, 32483, 63, 1224, 837, 199, 198, 2966, 1022, 452, 13807, 199, 198, 893, 26, 507, 198, 70, 275, 1551, 4769, 4687, 15, 32483, 401, 298, 82, 531, 507, 198, 604, 835, 275, 378, 507, 198, 509, 1004, 315, 289, 26, 686, 198, 604, 835, 275, 1004, 835, 11, 17, 507, 198, 70, 14, 5507, 8, 16, 9, 199, 198, 2590, 26, 507, 198, 1107, 4388, 198, 74, 275, 378, 199, 198, 509, 1004, 315, 289, 26, 507, 198, 2102, 275, 1109, 8, 604, 14, 1294, 3430, 16, 467, 3193, 9, 507, 198, 354, 275, 1004, 14, 1294, 3430, 18, 61, 507, 198, 74, 275, 1335, 435, 17, 507, 198, 692, 3666, 74, 450, 2948, 9, 508, 378, 304, 686, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 395, 507, 198, 32483, 14, 740, 2561, 283, 2102, 356, 4355, 12, 283, 354, 7, 520, 536, 1552, 421, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 9, 199, 198, 32483, 14, 3191, 342, 199, 198, 1107, 199, 199, 318, 664, 63, 3840, 8, 83, 2102, 304, 199, 198, 2102, 275, 1109, 8, 83, 2102, 9, 199, 198, 509, 284, 315, 1022, 452, 13807, 26, 507, 198, 692, 334, 73, 459, 2102, 418, 2356, 4355, 304, 686, 198, 1107, 334, 73, 459, 354, 995, 284, 459, 2102, 418, 13, 2102, 9, 199, 198, 1107, 334, 403, 12, 378, 9, 199, 199, 318, 870, 63, 4824, 63, 1224, 837, 199, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 1689, 16575, 401, 298, 14839, 401, 298, 8760, 531, 199, 198, 509, 284, 315, 5978, 63, 793, 14, 1612, 837, 507, 198, 8, 3840, 12, 2331, 9, 275, 664, 63, 3840, 8, 73, 9, 507, 198, 692, 4678, 508, 488, 26, 686, 198, 3840, 275, 284, 507, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 334, 3840, 12, 2331, 12, 5978, 63, 793, 59, 73, 566, 421, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14139, 3307, 334, 9778, 13, 35, 370, 5461, 2058, 2924, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 298, 39, 7404, 316, 1022, 452, 13807, 666, 2, 199, 198, 362, 63, 32483, 63, 1224, 342, 199, 198, 1361, 63, 4824, 63, 1224, 342, 199, 199, 3, 2797, 687, 8582, 12, 1380, 652, 17651, 282, 1970, 470, 555, 688, 316, 1566, 199, 318, 11448, 363, 22197, 63, 6852, 8, 354, 12, 1067, 12, 5033, 12, 6513, 12, 14256, 12, 4422, 12, 1923, 12, 686, 198, 13664, 12, 4113, 12, 2909, 304, 199, 198, 83, 1985, 275, 620, 8, 1985, 9, 199, 198, 893, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 5978, 63, 793, 59, 83, 1985, 61, 435, 413, 199, 198, 2590, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
SivilTaram/edx-platform
cms/djangoapps/contentstore/migrations/0002_auto__del_field_videouploadconfig_status_whitelist.py
108
4442
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Deleting field 'VideoUploadConfig.status_whitelist' db.delete_column('contentstore_videouploadconfig', 'status_whitelist') def backwards(self, orm): # Adding field 'VideoUploadConfig.status_whitelist' db.add_column('contentstore_videouploadconfig', 'status_whitelist', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False) models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contentstore.videouploadconfig': { 'Meta': {'object_name': 'VideoUploadConfig'}, 'change_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'changed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'on_delete': 'models.PROTECT'}), 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'profile_whitelist': ('django.db.models.fields.TextField', [], {'blank': 'True'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) } } complete_apps = ['contentstore']
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 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, 267, 327, 15920, 901, 283, 9166, 10301, 2028, 14, 1205, 63, 14189, 7, 267, 1592, 14, 1807, 63, 2301, 360, 28160, 63, 3722, 5064, 888, 297, 283, 1205, 63, 14189, 358, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 9166, 10301, 2028, 14, 1205, 63, 14189, 7, 267, 1592, 14, 525, 63, 2301, 360, 28160, 63, 3722, 5064, 888, 297, 283, 1205, 63, 14189, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 885, 4581, 4596, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 28160, 14, 3722, 5064, 888, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 9166, 10301, 2028, 2267, 288, 283, 1461, 63, 602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 2495, 63, 2131, 63, 525, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2489, 63, 991, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 1899, 6256, 283, 2307, 356, 283, 549, 297, 283, 265, 63, 1807, 356, 283, 992, 14, 29148, 1604, 288, 283, 3827, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 2913, 63, 14189, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 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, 267, 327, 15920, 901, 283, 9166, 10301, 2028, 14, 1205, 63, 14189, 7, 267, 1592, 14, 1807, 63, 2301, 360, 28160, 63, 3722, 5064, 888, 297, 283, 1205, 63, 14189, 358, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 9166, 10301, 2028, 14, 1205, 63, 14189, 7, 267, 1592, 14, 525, 63, 2301, 360, 28160, 63, 3722, 5064, 888, 297, 283, 1205, 63, 14189, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 885, 4581, 4596, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 28160, 14, 3722, 5064, 888, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 9166, 10301, 2028, 2267, 288, 283, 1461, 63, 602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 2495, 63, 2131, 63, 525, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2489, 63, 991, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 1899, 6256, 283, 2307, 356, 283, 549, 297, 283, 265, 63, 1807, 356, 283, 992, 14, 29148, 1604, 288, 283, 3827, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 2913, 63, 14189, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 0 ]
[ 1, 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, 1, 1, 1, 1, 1, 1, 1, 1 ]
prechelt/typecheck-decorator
typecheck/test_typing_annotations.py
1
18996
import builtins import datetime as dt import io import re import sys import tempfile import typing as tg import pytest import typecheck as tc import typecheck.framework as fw from typecheck.testhelper import expected # global TypeVars, used in various places: X = tg.TypeVar('X') Tb = tg.TypeVar('Tb', bound=dt.date) Tc = tg.TypeVar('Tc', str, bytes) ############################################################################ # the typing module as such: def test_typing_module_weirdness(): # This was a Py3.4 bug in typing 3.5.0.1: assert issubclass(tg.Iterable, tg.Generic) == (sys.version_info >= (3,5)) # ItemsView comes out with three parameters: # one (T_co) from Iterable (via MappingView), # two (KT, VT_co) from Generic. # T_co must in fact be Tuple[KT, VT_co], but how would we know that? # Three parameters makes no sense; this is a mess. assert tg.ItemsView.__parameters__ == (tg.T_co, tg.KT, tg.VT_co) # This is an assumption in GenericMetaChecker._can_have_instance: assert not issubclass(tg.Sequence[X], tg.Iterable[X]) # very strange! ############################################################################ # Generic type with fixed content type @tc.typecheck def foo_Sequence_int_to_List_int(x: tg.Sequence[int], y) -> tg.List[int]: x.append(y) return x def test_Sequence_int_with_empty_Sequence(): assert foo_Sequence_int_to_List_int([], 4) == [4] def test_Sequence_int_OK(): assert foo_Sequence_int_to_List_int([1, 2], 4) == [1, 2, 4] def test_Sequence_int_with_no_Sequence(): with expected(tc.InputParameterError( "has got an incompatible value for x: 4")): foo_Sequence_int_to_List_int(4) def test_Sequence_int_with_wrong_Sequence(): with expected(tc.InputParameterError( "has got an incompatible value for x: ['mystring']")): foo_Sequence_int_to_List_int(["mystring"], 77) def test_Sequence_int_with_wrong_result(): with expected(tc.ReturnValueError( "has returned an incompatible value: [1, '2']")): foo_Sequence_int_to_List_int([1], "2") ############################################################################ # Generic stand-alone functions def test_TypeVarNamespace_without_instance(): class A: pass class B(A): pass for thetype in (int, float, str, list, dict, A, MyGeneric): ns = fw.TypeVarNamespace() assert not ns.is_generic_in(X) assert not ns.is_bound(X) ns.bind(X, thetype) assert ns.is_bound(X) assert ns.binding_of(X) == thetype assert ns.is_compatible(X, thetype) if thetype == A: assert ns.is_compatible(X, B) @tc.typecheck def foo_Sequence_X_to_Sequence_X(xs: tg.Sequence[X], x: X) -> tg.Sequence[X]: xs.append(x) return xs def test_Sequence_X_int_OK(): assert foo_Sequence_X_to_Sequence_X([1, 2], 4) == [1, 2, 4] def test_Sequence_X_int_notOK(): with expected(tc.InputParameterError( "foo_Sequence_X_to_Sequence_X() has got an incompatible value for x: a_string")): foo_Sequence_X_to_Sequence_X([1, 2], "a_string") ############################################################################ # TypeVarNamespace, Generic class with TypeVar binding on the instance level class MyGeneric(tg.Generic[X]): def __init__(self, initial_element=None): self.content = [] # a tg.Sequence if initial_element is not None: self.content.append(initial_element) @tc.typecheck def append(self, el: X): self.content.append(el) @tc.typecheck def get(self, index: int) -> X: return self.content[index] diverse_collection = (None, False, 1, 2.0, "three", [4], {5: "six"}, MyGeneric(), MyGeneric("seven"), MyGeneric[X](), MyGeneric[str]("seven"), dt.date.today(), dt.datetime.now(), ) # None must be first def test_TypeVarNamespace_with_instance(): mycollection = list(diverse_collection)[1:] # leave out None for element in mycollection: print(element) thetype = type(element) mygen = MyGeneric(element) ns = fw.TypeVarNamespace(mygen) assert ns._instance assert ns.is_generic_in(X) assert not ns.is_bound(X) ns.bind(X, thetype) assert ns.is_bound(X) assert ns.binding_of(X) == thetype assert ns.is_compatible(X, thetype) def test_MyGeneric_OK_and_not_OK(): for element1 in diverse_collection: for element2 in diverse_collection: if type(element1) == type(element2): continue mygen = MyGeneric(element1) mygen.append(element1) # binds X mygen.append(element1) # checks X binding: OK print(element1, element2) if (issubclass(type(element1), type(element2)) or issubclass(type(element2), type(element1))): mygen.append(element2) # conforms to X binding else: with expected(tc.InputParameterError("")): mygen.append(element2) # violates X binding # TODO: test Generic class with multiple inheritance ############################################################################ # type variable with bound or constraint @tc.typecheck def foo_with_bound(date1: Tb, date2: Tb): pass def test_TypeVar_bound_OK_sameclass(): foo_with_bound(dt.date.today(), dt.date.today()) def test_TypeVar_bound_OK_subclass(): foo_with_bound(dt.datetime.now(), dt.datetime.now()) def test_TypeVar_bound_OK_mixed_classes(): foo_with_bound(dt.datetime.now(), dt.date.today()) foo_with_bound(dt.date.today(), dt.datetime.now()) def test_TypeVar_bound_violated(): with (expected(tc.InputParameterError(""))): foo_with_bound(1, 2) # both same type, but not below the bound with (expected(tc.InputParameterError(""))): foo_with_bound(object(), object()) # above the bound @tc.typecheck def foo_with_constraint(date1: Tc, date2: Tc): pass def test_TypeVar_constraint_OK(): foo_with_constraint("str1", "str2") foo_with_constraint(b"bytes1", b"bytes2") def test_TypeVar_constraint_not_OK(): with (expected(tc.InputParameterError(""))): foo_with_constraint("str1", b"bytes1") with (expected(tc.InputParameterError(""))): foo_with_constraint(("b","y"), ("t","e")) ############################################################################ # Generic classes subclass relationship: def test_GenericMetaChecker_dot_can_have_subclass(): Ch = tc.typing_predicates.GenericMetaChecker # class alias assert Ch(tg.Sequence[int])._is_possible_subclass(list, tg.Sequence[int]) assert not Ch(tg.Sequence[int])._is_possible_subclass(int, tg.Sequence[int]) assert Ch(tg.Iterable[int])._is_possible_subclass(tg.Sequence[int], tg.Iterable[int]) ############################################################################ # Mapping, Set, MappingView @tc.typecheck def foo_Mapping_str_float_to_float(m: tg.Mapping[str,float], k: str) -> float: return m[k] def test_Mapping_str_float_OK(): assert foo_Mapping_str_float_to_float(dict(a=4.0), "a") == 4.0 def test_Mapping_str_float_not_OK(): with expected(tc.InputParameterError("{'a': True}")): # wrong value type assert foo_Mapping_str_float_to_float(dict(a=True), "a") == True with expected(tc.InputParameterError("{b'a': 4.0}")): # wrong key type assert foo_Mapping_str_float_to_float({b'a':4.0}, b"a") == 4.0 @tc.typecheck def foo_Set_Tc_Tc_to_bool(s: tg.Set[Tc], el: Tc) -> bool: return el in s def test_Set_Tc_OK(): assert foo_Set_Tc_Tc_to_bool(set(("yes","maybe")), "yes") assert not foo_Set_Tc_Tc_to_bool(set(("yes","maybe")), "no") assert foo_Set_Tc_Tc_to_bool(set((b"yes",b"maybe")), b"yes") def test_Set_Tc_not_OK(): with expected(tc.InputParameterError("")): assert foo_Set_Tc_Tc_to_bool(set(("yes",b"maybe")), "yes") with expected(tc.InputParameterError("")): assert foo_Set_Tc_Tc_to_bool(set((1, 2)), 2) with expected(tc.InputParameterError("")): assert foo_Set_Tc_Tc_to_bool(set((("yes",),("maybe",))), ("yes",)) @tc.typecheck def foo_KeysView_to_Sequence(v: tg.KeysView[Tc]) -> tg.Sequence[Tc]: result = [item for item in v] result.sort() assert len([item for item in v]) == len(result) # iterable not exhausted return result def test_KeysView_to_Sequence_OK(): assert foo_KeysView_to_Sequence(dict(a=11, b=12).keys()) == ['a', 'b'] assert foo_KeysView_to_Sequence({b'A':11, b'B':12}.keys()) == [b'A', b'B'] def test_KeysView_to_Sequence_not_OK(): with expected(tc.InputParameterError("v: dict_keys\(.*3.*")): assert foo_KeysView_to_Sequence({b'A':11, b'B':12, 3:13}.keys()) == [b'A', b'B', 13] ############################################################################ # for Iterator and Container we cannot check the actual content @tc.typecheck def foo_Iterator(i: tg.Iterator[dt.date]): pass @tc.typecheck def foo_Container(c: tg.Container[tg.Sequence[str]]): pass def test_Iterable_Iterator_Container_OK(): """ No extra code is needed to check Iterable, Iterator, and Container, because there is no suitable way to access their contents. """ foo_Iterator((dt.date.today(), dt.date.today()).__iter__()) foo_Container([["nested", "list"], ["of", "strings"]]) def test_Iterator_Container_content_not_OK_catchable(): """ Because there is no suitable way to access their contents, such generic types may still pass the typecheck if their content is of the wrong type. This is a fundamental problem, not an implementation gap. The only cases where improper contents will be caught is when the argument is _also_ tg.Iterable. """ with expected(tc.InputParameterError("list_iterator")): foo_Iterator(["shouldn't be", "strings here"].__iter__()) with expected(tc.InputParameterError("3, 4")): foo_Container([[3, 4], [5, 6]]) def test_Iterator_totally_not_OK(): with expected(tc.InputParameterError("")): foo_Iterator((dt.date.today(), dt.date.today())) # lacks .__next__() class MySpecialtyGeneric(tg.Container[X]): def __init__(self, contents): assert isinstance(contents, tg.Sequence) self.contents = contents # an 'nice' container, but hidden within def __iter__(self): return self.contents.__iter__() def __contains__(self, item): return item in self.contents @tc.typecheck def foo_MySpecialtyGeneric(c: MySpecialtyGeneric[float]): pass def test_Container_content_not_OK_not_catchable(): """ See above: With generics that are not otherwise checkable, wrong contents will not be detected. """ incorrect_content = MySpecialtyGeneric(["shouldn't be", "strings here"]) foo_Container(incorrect_content) # cannot detect foo_MySpecialtyGeneric(incorrect_content) # cannot detect ############################################################################ # NamedTuple Employee = tg.NamedTuple('Employee', [('name', str), ('id', int)]) Employee2 = tg.NamedTuple('Employee2', [('name', str), ('id', int)]) @tc.typecheck def foo_Employee(e: Employee): pass def test_NamedTuple_OK(): foo_Employee(Employee(name="Jones", id=99)) def test_NamedTuple_not_OK(): with expected(tc.InputParameterError("name=8, id=9)")): foo_Employee(Employee(name=8, id=9)) with expected(tc.InputParameterError("'aaa')")): foo_Employee(Employee(name='Jones', id='aaa')) with expected(tc.InputParameterError("Employee2(name='Jones', id=999)")): foo_Employee(Employee2(name='Jones', id=999)) ############################################################################ # Tuple @tc.typecheck def foo_Tuple_int_float_to_float(t: tg.Tuple[int, float]) -> float: return t[1] def test_Tuple_OK(): assert foo_Tuple_int_float_to_float((2, 3.0)) == 3.0 def test_Tuple_not_OK(): with expected(tc.InputParameterError("t: 2")): foo_Tuple_int_float_to_float(2) with expected(tc.InputParameterError("t: (2,)")): foo_Tuple_int_float_to_float((2,)) with expected(tc.InputParameterError("t: (2, None)")): foo_Tuple_int_float_to_float((2, None)) with expected(tc.InputParameterError("t: None")): foo_Tuple_int_float_to_float(None) with expected(tc.InputParameterError("t: (2, 3)")): foo_Tuple_int_float_to_float((2, 3)) with expected(tc.InputParameterError("t: (2, 3.0, 4.0)")): foo_Tuple_int_float_to_float((2, 3.0, 4.0)) ############################################################################ # Union @tc.typecheck def foo_Union_int_SequenceFloat(u: tg.Union[int, tg.Sequence[float]]): pass def test_Union_OK(): foo_Union_int_SequenceFloat(4) foo_Union_int_SequenceFloat([]) foo_Union_int_SequenceFloat([4.0, 5.0]) def test_Union_not_OK(): with expected(tc.InputParameterError("u: wrong")): foo_Union_int_SequenceFloat("wrong") with expected(tc.InputParameterError("u: [4]")): foo_Union_int_SequenceFloat([4]) with expected(tc.InputParameterError("u: None")): foo_Union_int_SequenceFloat(None) ############################################################################ # Optional # needs no implementation code, all work is done by tg itself @tc.typecheck def foo_Optional_Union_int_SequenceFloat(u: tg.Optional[tg.Union[int, tg.Sequence[float]]]): pass def test_Optional_OK(): foo_Optional_Union_int_SequenceFloat(None) foo_Optional_Union_int_SequenceFloat(4) foo_Optional_Union_int_SequenceFloat([]) foo_Optional_Union_int_SequenceFloat([4.0, 5.0]) def test_Optional_not_OK(): with expected(tc.InputParameterError("u: wrong")): foo_Optional_Union_int_SequenceFloat("wrong") with expected(tc.InputParameterError("u: [4]")): foo_Optional_Union_int_SequenceFloat([4]) ############################################################################ # Callable @tc.typecheck def foo_Callable(func: tg.Callable): pass @pytest.mark.skipif(True, reason="I have no idea what's the problem here.") def test_Callable_OK(): # TODO: What's going wrong here? assert callable(foo_Callable) # Not even one of the following works: foo_Callable(lambda: foo_Callable) foo_Callable(lambda x: 2*x) foo_Callable(builtins.callable) foo_Callable(builtins.dict) foo_Callable(builtins.len) foo_Callable(foo_Callable) ############################################################################ # _Protocol # is handled by TypeChecker without special code, so we do not test them all @tc.typecheck def foo_SupportsAbs(x: tg.SupportsAbs) -> tg.SupportsAbs: return abs(x) def test_SupportsAbs_OK(): assert foo_SupportsAbs(-4) == 4 assert foo_SupportsAbs(0.0) == 0.0 assert foo_SupportsAbs(True) == 1 def test_SupportsAbs_not_OK(): with expected(tc.InputParameterError("")): foo_SupportsAbs("-4") ############################################################################ # io # tg.io appears to be hardly useful as of 3.5 def test_io_is_halfhearted(): """ It would be pythonic if tg.io.IO applied to all file-like objects. But as of 3.5, it does not, which is what we assert here. """ with io.StringIO("my string as input") as f: assert not isinstance(f, tg.io.TextIO) assert not isinstance(f, tg.io.IO[str]) with tempfile.TemporaryFile("wb") as f: if "file" in dir(f): f = f.file # TemporaryFile() on non-POSIX platform assert not isinstance(f, tg.io.BinaryIO) assert not isinstance(f, tg.io.IO[bytes]) ############################################################################ # re # tg.io appears to be broken as of 3.5 def test_re_is_halfhearted(): """ As of 3.5, the implementation of tg appears to be incomplete for TypeAlias. All those asserts should in fact be successful. """ error = TypeError("Type aliases cannot be used with isinstance().") with expected(error): assert isinstance(re.compile("regexp"), tg.re.Pattern[str]) with expected(error): assert isinstance(re.compile(b"byteregexp"), tg.re.Pattern[bytes]) with expected(error): assert isinstance(re.match("regexp", "string"), tg.re.Match[str]) with expected(error): assert isinstance(re.match(b"regexp", b"string"), tg.re.Match[bytes]) ############################################################################ # 'MyClass' as str class A: @tc.typecheck def foo_something(self, another: 'A') -> 'A': return self def test_forward_reference_OK(): a1 = A() a2 = A() a1.foo_something(a2) def test_forward_reference_to_local_class_OK_or_not_OK(): class B: @tc.typecheck def foo_something(self, another: 'B') -> 'B': return self b1 = B() b2 = B() b1.foo_something(b2) with expected(tc.InputParameterError("something different")): b1.foo_something("something different") def test_forward_reference_not_OK(): a1 = A() with expected(tc.InputParameterError("something different")): a1.foo_something("something different") ############################################################################ # A complex example ComplexType = tg.Union[tg.Optional[tg.Sequence[tg.Mapping[Tc, tg.Optional[float]]]], Tc, bool, dt.date] @tc.typecheck def foo_wow_thats_nested(x: ComplexType) -> tg.Union[Tc, bool, float]: if isinstance(x, (str, bytes)): return x[0:3] elif isinstance(x, tg.Sequence): return x[0][sorted(x[0].keys())[0]] else: return x def test_complex_example_OK(): assert foo_wow_thats_nested(True) == True assert foo_wow_thats_nested('string') == 'str' assert foo_wow_thats_nested(b'bytes') == b'byt' assert foo_wow_thats_nested([dict(a=1.0, b=2.0)]) == 1.0 assert foo_wow_thats_nested([{b'a':1.0, b'1':2.0}]) == 2.0 def test_complex_example_not_OK(): with expected(tc.InputParameterError("1")): assert foo_wow_thats_nested(1) == 1 with expected(IndexError("")): foo_wow_thats_nested([]) with expected(tc.ReturnValueError("")): assert foo_wow_thats_nested(None) == None with expected(tc.ReturnValueError("")): assert foo_wow_thats_nested(dt.date.today()) == dt.date.today() with expected(tc.ReturnValueError("None")): assert foo_wow_thats_nested([dict(a=None, b=2.0)]) == None ############################################################################ # and last of all: Any @tc.typecheck def foo_Any(x: tg.Any) -> tg.Any: return x def test_Any_OK(): assert foo_Any(42) ############################################################################
bsd-2-clause
[ 646, 12963, 199, 646, 2197, 465, 4487, 199, 646, 5890, 199, 646, 295, 199, 646, 984, 199, 646, 5549, 199, 199, 646, 14090, 465, 22387, 199, 199, 646, 4613, 199, 199, 646, 730, 1074, 465, 14415, 199, 646, 730, 1074, 14, 4857, 465, 13908, 199, 504, 730, 1074, 14, 396, 3676, 492, 1420, 199, 199, 3, 2288, 2434, 16270, 12, 1202, 315, 7750, 9825, 26, 199, 199, 56, 275, 22387, 14, 804, 5894, 360, 56, 358, 199, 52, 66, 275, 22387, 14, 804, 5894, 360, 52, 66, 297, 3914, 29, 3583, 14, 602, 9, 199, 52, 67, 275, 22387, 14, 804, 5894, 360, 52, 67, 297, 620, 12, 2783, 9, 421, 199, 3949, 381, 199, 3, 314, 14090, 859, 465, 4066, 26, 199, 199, 318, 511, 63, 29747, 63, 578, 63, 1129, 5428, 4171, 837, 272, 327, 961, 1990, 282, 1611, 19, 14, 20, 6519, 315, 14090, 650, 14, 21, 14, 16, 14, 17, 26, 272, 702, 11602, 8, 17699, 14, 20852, 12, 22387, 14, 9417, 9, 508, 334, 1274, 14, 1023, 63, 815, 2356, 334, 19, 12, 21, 430, 272, 327, 20720, 2768, 12477, 734, 543, 7795, 2633, 26, 272, 327, 1373, 334, 52, 63, 331, 9, 687, 19937, 334, 12897, 12340, 2768, 395, 272, 327, 2877, 334, 12362, 12, 812, 52, 63, 331, 9, 687, 8307, 14, 272, 327, 377, 63, 331, 1471, 315, 10572, 506, 11634, 59, 12362, 12, 812, 52, 63, 331, 467, 1325, 4212, 3955, 781, 5715, 626, 31, 272, 327, 30467, 2633, 7704, 949, 12249, 27, 642, 365, 282, 15634, 14, 272, 702, 22387, 14, 7412, 2768, 855, 3214, 363, 508, 334, 17699, 14, 52, 63, 331, 12, 22387, 14, 12362, 12, 22387, 14, 8156, 63, 331, 9, 272, 327, 961, 365, 376, 30075, 315, 8307, 3396, 3048, 423, 2425, 63, 7804, 63, 842, 26, 272, 702, 440, 11602, 8, 17699, 14, 5826, 59, 56, 467, 22387, 14, 20852, 59, 56, 566, 327, 7437, 620, 618, 1, 421, 199, 3949, 381, 199, 3, 8307, 730, 543, 6317, 1564, 730, 199, 199, 32, 3641, 14, 466, 1074, 199, 318, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 8, 88, 26, 22387, 14, 5826, 59, 442, 467, 612, 9, 1035, 22387, 14, 1296, 59, 442, 2189, 272, 671, 14, 740, 8, 89, 9, 272, 372, 671, 421, 199, 318, 511, 63, 5826, 63, 442, 63, 1045, 63, 1667, 63, 5826, 837, 272, 702, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 8798, 841, 9, 508, 359, 20, 61, 199, 199, 318, 511, 63, 5826, 63, 442, 63, 3593, 837, 272, 702, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 779, 17, 12, 499, 467, 841, 9, 508, 359, 17, 12, 499, 12, 841, 61, 199, 199, 318, 511, 63, 5826, 63, 442, 63, 1045, 63, 889, 63, 5826, 837, 272, 543, 1420, 8, 3641, 14, 3205, 4720, 547, 8, 288, 298, 1989, 4788, 376, 18457, 574, 367, 671, 26, 841, 14150, 267, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 8, 20, 9, 199, 199, 318, 511, 63, 5826, 63, 442, 63, 1045, 63, 10603, 63, 5826, 837, 272, 543, 1420, 8, 3641, 14, 3205, 4720, 547, 8, 288, 298, 1989, 4788, 376, 18457, 574, 367, 671, 26, 788, 1662, 875, 418, 14150, 267, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 5234, 1662, 875, 2255, 8375, 9, 199, 199, 318, 511, 63, 5826, 63, 442, 63, 1045, 63, 10603, 63, 1099, 837, 272, 543, 1420, 8, 3641, 14, 1767, 3393, 8, 288, 298, 1989, 2138, 376, 18457, 574, 26, 359, 17, 12, 283, 18, 418, 14150, 267, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 779, 17, 467, 298, 18, 531, 199, 199, 3949, 381, 199, 3, 8307, 10584, 13, 10636, 3423, 199, 199, 318, 511, 63, 804, 5894, 8814, 63, 7395, 63, 842, 837, 272, 1021, 437, 26, 267, 986, 272, 1021, 699, 8, 33, 304, 267, 986, 272, 367, 314, 466, 315, 334, 442, 12, 2069, 12, 620, 12, 769, 12, 1211, 12, 437, 12, 4932, 9417, 304, 267, 700, 275, 13908, 14, 804, 5894, 8814, 342, 267, 702, 440, 700, 14, 374, 63, 6767, 63, 262, 8, 56, 9, 267, 702, 440, 700, 14, 374, 63, 3556, 8, 56, 9, 267, 700, 14, 3409, 8, 56, 12, 314, 466, 9, 267, 702, 700, 14, 374, 63, 3556, 8, 56, 9, 267, 702, 700, 14, 9140, 63, 1618, 8, 56, 9, 508, 314, 466, 267, 702, 700, 14, 374, 63, 6490, 8, 56, 12, 314, 466, 9, 267, 340, 314, 466, 508, 437, 26, 288, 702, 700, 14, 374, 63, 6490, 8, 56, 12, 699, 9, 421, 199, 32, 3641, 14, 466, 1074, 199, 318, 3925, 63, 5826, 63, 56, 63, 475, 63, 5826, 63, 56, 8, 7977, 26, 22387, 14, 5826, 59, 56, 467, 671, 26, 1323, 9, 1035, 22387, 14, 5826, 59, 56, 2189, 272, 12965, 14, 740, 8, 88, 9, 272, 372, 12965, 199, 199, 318, 511, 63, 5826, 63, 56, 63, 442, 63, 3593, 837, 272, 702, 3925, 63, 5826, 63, 56, 63, 475, 63, 5826, 63, 56, 779, 17, 12, 499, 467, 841, 9, 508, 359, 17, 12, 499, 12, 841, 61, 199, 199, 318, 511, 63, 5826, 63, 56, 63, 442, 63, 1397, 3593, 837, 272, 543, 1420, 8, 3641, 14, 3205, 4720, 547, 8, 288, 298, 1421, 63, 5826, 63, 56, 63, 475, 63, 5826, 63, 56, 342, 965, 4788, 376, 18457, 574, 367, 671, 26, 282, 63, 875, 14150, 267, 3925, 63, 5826, 63, 56, 63, 475, 63, 5826, 63, 56, 779, 17, 12, 499, 467, 298, 65, 63, 875, 531, 199, 199, 3949, 381, 199, 3, 2434, 5894, 8814, 12, 8307, 1021, 543, 2434, 5894, 11696, 641, 314, 1256, 2166, 199, 199, 533, 4932, 9417, 8, 17699, 14, 9417, 59, 56, 4682, 272, 347, 636, 826, 721, 277, 12, 2536, 63, 2108, 29, 403, 304, 267, 291, 14, 1317, 275, 942, 221, 327, 282, 22387, 14, 5826, 267, 340, 2536, 63, 2108, 365, 440, 488, 26, 288, 291, 14, 1317, 14, 740, 8, 2747, 63, 2108, 9, 339, 768, 3641 ]
[ 12963, 199, 646, 2197, 465, 4487, 199, 646, 5890, 199, 646, 295, 199, 646, 984, 199, 646, 5549, 199, 199, 646, 14090, 465, 22387, 199, 199, 646, 4613, 199, 199, 646, 730, 1074, 465, 14415, 199, 646, 730, 1074, 14, 4857, 465, 13908, 199, 504, 730, 1074, 14, 396, 3676, 492, 1420, 199, 199, 3, 2288, 2434, 16270, 12, 1202, 315, 7750, 9825, 26, 199, 199, 56, 275, 22387, 14, 804, 5894, 360, 56, 358, 199, 52, 66, 275, 22387, 14, 804, 5894, 360, 52, 66, 297, 3914, 29, 3583, 14, 602, 9, 199, 52, 67, 275, 22387, 14, 804, 5894, 360, 52, 67, 297, 620, 12, 2783, 9, 421, 199, 3949, 381, 199, 3, 314, 14090, 859, 465, 4066, 26, 199, 199, 318, 511, 63, 29747, 63, 578, 63, 1129, 5428, 4171, 837, 272, 327, 961, 1990, 282, 1611, 19, 14, 20, 6519, 315, 14090, 650, 14, 21, 14, 16, 14, 17, 26, 272, 702, 11602, 8, 17699, 14, 20852, 12, 22387, 14, 9417, 9, 508, 334, 1274, 14, 1023, 63, 815, 2356, 334, 19, 12, 21, 430, 272, 327, 20720, 2768, 12477, 734, 543, 7795, 2633, 26, 272, 327, 1373, 334, 52, 63, 331, 9, 687, 19937, 334, 12897, 12340, 2768, 395, 272, 327, 2877, 334, 12362, 12, 812, 52, 63, 331, 9, 687, 8307, 14, 272, 327, 377, 63, 331, 1471, 315, 10572, 506, 11634, 59, 12362, 12, 812, 52, 63, 331, 467, 1325, 4212, 3955, 781, 5715, 626, 31, 272, 327, 30467, 2633, 7704, 949, 12249, 27, 642, 365, 282, 15634, 14, 272, 702, 22387, 14, 7412, 2768, 855, 3214, 363, 508, 334, 17699, 14, 52, 63, 331, 12, 22387, 14, 12362, 12, 22387, 14, 8156, 63, 331, 9, 272, 327, 961, 365, 376, 30075, 315, 8307, 3396, 3048, 423, 2425, 63, 7804, 63, 842, 26, 272, 702, 440, 11602, 8, 17699, 14, 5826, 59, 56, 467, 22387, 14, 20852, 59, 56, 566, 327, 7437, 620, 618, 1, 421, 199, 3949, 381, 199, 3, 8307, 730, 543, 6317, 1564, 730, 199, 199, 32, 3641, 14, 466, 1074, 199, 318, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 8, 88, 26, 22387, 14, 5826, 59, 442, 467, 612, 9, 1035, 22387, 14, 1296, 59, 442, 2189, 272, 671, 14, 740, 8, 89, 9, 272, 372, 671, 421, 199, 318, 511, 63, 5826, 63, 442, 63, 1045, 63, 1667, 63, 5826, 837, 272, 702, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 8798, 841, 9, 508, 359, 20, 61, 199, 199, 318, 511, 63, 5826, 63, 442, 63, 3593, 837, 272, 702, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 779, 17, 12, 499, 467, 841, 9, 508, 359, 17, 12, 499, 12, 841, 61, 199, 199, 318, 511, 63, 5826, 63, 442, 63, 1045, 63, 889, 63, 5826, 837, 272, 543, 1420, 8, 3641, 14, 3205, 4720, 547, 8, 288, 298, 1989, 4788, 376, 18457, 574, 367, 671, 26, 841, 14150, 267, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 8, 20, 9, 199, 199, 318, 511, 63, 5826, 63, 442, 63, 1045, 63, 10603, 63, 5826, 837, 272, 543, 1420, 8, 3641, 14, 3205, 4720, 547, 8, 288, 298, 1989, 4788, 376, 18457, 574, 367, 671, 26, 788, 1662, 875, 418, 14150, 267, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 5234, 1662, 875, 2255, 8375, 9, 199, 199, 318, 511, 63, 5826, 63, 442, 63, 1045, 63, 10603, 63, 1099, 837, 272, 543, 1420, 8, 3641, 14, 1767, 3393, 8, 288, 298, 1989, 2138, 376, 18457, 574, 26, 359, 17, 12, 283, 18, 418, 14150, 267, 3925, 63, 5826, 63, 442, 63, 475, 63, 1296, 63, 442, 779, 17, 467, 298, 18, 531, 199, 199, 3949, 381, 199, 3, 8307, 10584, 13, 10636, 3423, 199, 199, 318, 511, 63, 804, 5894, 8814, 63, 7395, 63, 842, 837, 272, 1021, 437, 26, 267, 986, 272, 1021, 699, 8, 33, 304, 267, 986, 272, 367, 314, 466, 315, 334, 442, 12, 2069, 12, 620, 12, 769, 12, 1211, 12, 437, 12, 4932, 9417, 304, 267, 700, 275, 13908, 14, 804, 5894, 8814, 342, 267, 702, 440, 700, 14, 374, 63, 6767, 63, 262, 8, 56, 9, 267, 702, 440, 700, 14, 374, 63, 3556, 8, 56, 9, 267, 700, 14, 3409, 8, 56, 12, 314, 466, 9, 267, 702, 700, 14, 374, 63, 3556, 8, 56, 9, 267, 702, 700, 14, 9140, 63, 1618, 8, 56, 9, 508, 314, 466, 267, 702, 700, 14, 374, 63, 6490, 8, 56, 12, 314, 466, 9, 267, 340, 314, 466, 508, 437, 26, 288, 702, 700, 14, 374, 63, 6490, 8, 56, 12, 699, 9, 421, 199, 32, 3641, 14, 466, 1074, 199, 318, 3925, 63, 5826, 63, 56, 63, 475, 63, 5826, 63, 56, 8, 7977, 26, 22387, 14, 5826, 59, 56, 467, 671, 26, 1323, 9, 1035, 22387, 14, 5826, 59, 56, 2189, 272, 12965, 14, 740, 8, 88, 9, 272, 372, 12965, 199, 199, 318, 511, 63, 5826, 63, 56, 63, 442, 63, 3593, 837, 272, 702, 3925, 63, 5826, 63, 56, 63, 475, 63, 5826, 63, 56, 779, 17, 12, 499, 467, 841, 9, 508, 359, 17, 12, 499, 12, 841, 61, 199, 199, 318, 511, 63, 5826, 63, 56, 63, 442, 63, 1397, 3593, 837, 272, 543, 1420, 8, 3641, 14, 3205, 4720, 547, 8, 288, 298, 1421, 63, 5826, 63, 56, 63, 475, 63, 5826, 63, 56, 342, 965, 4788, 376, 18457, 574, 367, 671, 26, 282, 63, 875, 14150, 267, 3925, 63, 5826, 63, 56, 63, 475, 63, 5826, 63, 56, 779, 17, 12, 499, 467, 298, 65, 63, 875, 531, 199, 199, 3949, 381, 199, 3, 2434, 5894, 8814, 12, 8307, 1021, 543, 2434, 5894, 11696, 641, 314, 1256, 2166, 199, 199, 533, 4932, 9417, 8, 17699, 14, 9417, 59, 56, 4682, 272, 347, 636, 826, 721, 277, 12, 2536, 63, 2108, 29, 403, 304, 267, 291, 14, 1317, 275, 942, 221, 327, 282, 22387, 14, 5826, 267, 340, 2536, 63, 2108, 365, 440, 488, 26, 288, 291, 14, 1317, 14, 740, 8, 2747, 63, 2108, 9, 339, 768, 3641, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MillerDix/NEChromeX
flaskTest/venv/lib/python2.7/site-packages/pip/_vendor/webencodings/labels.py
512
8979
""" webencodings.labels ~~~~~~~~~~~~~~~~~~~ Map encoding labels to their name. :copyright: Copyright 2012 by Simon Sapin :license: BSD, see LICENSE for details. """ # XXX Do not edit! # This file is automatically generated by mklabels.py LABELS = { 'unicode-1-1-utf-8': 'utf-8', 'utf-8': 'utf-8', 'utf8': 'utf-8', '866': 'ibm866', 'cp866': 'ibm866', 'csibm866': 'ibm866', 'ibm866': 'ibm866', 'csisolatin2': 'iso-8859-2', 'iso-8859-2': 'iso-8859-2', 'iso-ir-101': 'iso-8859-2', 'iso8859-2': 'iso-8859-2', 'iso88592': 'iso-8859-2', 'iso_8859-2': 'iso-8859-2', 'iso_8859-2:1987': 'iso-8859-2', 'l2': 'iso-8859-2', 'latin2': 'iso-8859-2', 'csisolatin3': 'iso-8859-3', 'iso-8859-3': 'iso-8859-3', 'iso-ir-109': 'iso-8859-3', 'iso8859-3': 'iso-8859-3', 'iso88593': 'iso-8859-3', 'iso_8859-3': 'iso-8859-3', 'iso_8859-3:1988': 'iso-8859-3', 'l3': 'iso-8859-3', 'latin3': 'iso-8859-3', 'csisolatin4': 'iso-8859-4', 'iso-8859-4': 'iso-8859-4', 'iso-ir-110': 'iso-8859-4', 'iso8859-4': 'iso-8859-4', 'iso88594': 'iso-8859-4', 'iso_8859-4': 'iso-8859-4', 'iso_8859-4:1988': 'iso-8859-4', 'l4': 'iso-8859-4', 'latin4': 'iso-8859-4', 'csisolatincyrillic': 'iso-8859-5', 'cyrillic': 'iso-8859-5', 'iso-8859-5': 'iso-8859-5', 'iso-ir-144': 'iso-8859-5', 'iso8859-5': 'iso-8859-5', 'iso88595': 'iso-8859-5', 'iso_8859-5': 'iso-8859-5', 'iso_8859-5:1988': 'iso-8859-5', 'arabic': 'iso-8859-6', 'asmo-708': 'iso-8859-6', 'csiso88596e': 'iso-8859-6', 'csiso88596i': 'iso-8859-6', 'csisolatinarabic': 'iso-8859-6', 'ecma-114': 'iso-8859-6', 'iso-8859-6': 'iso-8859-6', 'iso-8859-6-e': 'iso-8859-6', 'iso-8859-6-i': 'iso-8859-6', 'iso-ir-127': 'iso-8859-6', 'iso8859-6': 'iso-8859-6', 'iso88596': 'iso-8859-6', 'iso_8859-6': 'iso-8859-6', 'iso_8859-6:1987': 'iso-8859-6', 'csisolatingreek': 'iso-8859-7', 'ecma-118': 'iso-8859-7', 'elot_928': 'iso-8859-7', 'greek': 'iso-8859-7', 'greek8': 'iso-8859-7', 'iso-8859-7': 'iso-8859-7', 'iso-ir-126': 'iso-8859-7', 'iso8859-7': 'iso-8859-7', 'iso88597': 'iso-8859-7', 'iso_8859-7': 'iso-8859-7', 'iso_8859-7:1987': 'iso-8859-7', 'sun_eu_greek': 'iso-8859-7', 'csiso88598e': 'iso-8859-8', 'csisolatinhebrew': 'iso-8859-8', 'hebrew': 'iso-8859-8', 'iso-8859-8': 'iso-8859-8', 'iso-8859-8-e': 'iso-8859-8', 'iso-ir-138': 'iso-8859-8', 'iso8859-8': 'iso-8859-8', 'iso88598': 'iso-8859-8', 'iso_8859-8': 'iso-8859-8', 'iso_8859-8:1988': 'iso-8859-8', 'visual': 'iso-8859-8', 'csiso88598i': 'iso-8859-8-i', 'iso-8859-8-i': 'iso-8859-8-i', 'logical': 'iso-8859-8-i', 'csisolatin6': 'iso-8859-10', 'iso-8859-10': 'iso-8859-10', 'iso-ir-157': 'iso-8859-10', 'iso8859-10': 'iso-8859-10', 'iso885910': 'iso-8859-10', 'l6': 'iso-8859-10', 'latin6': 'iso-8859-10', 'iso-8859-13': 'iso-8859-13', 'iso8859-13': 'iso-8859-13', 'iso885913': 'iso-8859-13', 'iso-8859-14': 'iso-8859-14', 'iso8859-14': 'iso-8859-14', 'iso885914': 'iso-8859-14', 'csisolatin9': 'iso-8859-15', 'iso-8859-15': 'iso-8859-15', 'iso8859-15': 'iso-8859-15', 'iso885915': 'iso-8859-15', 'iso_8859-15': 'iso-8859-15', 'l9': 'iso-8859-15', 'iso-8859-16': 'iso-8859-16', 'cskoi8r': 'koi8-r', 'koi': 'koi8-r', 'koi8': 'koi8-r', 'koi8-r': 'koi8-r', 'koi8_r': 'koi8-r', 'koi8-u': 'koi8-u', 'csmacintosh': 'macintosh', 'mac': 'macintosh', 'macintosh': 'macintosh', 'x-mac-roman': 'macintosh', 'dos-874': 'windows-874', 'iso-8859-11': 'windows-874', 'iso8859-11': 'windows-874', 'iso885911': 'windows-874', 'tis-620': 'windows-874', 'windows-874': 'windows-874', 'cp1250': 'windows-1250', 'windows-1250': 'windows-1250', 'x-cp1250': 'windows-1250', 'cp1251': 'windows-1251', 'windows-1251': 'windows-1251', 'x-cp1251': 'windows-1251', 'ansi_x3.4-1968': 'windows-1252', 'ascii': 'windows-1252', 'cp1252': 'windows-1252', 'cp819': 'windows-1252', 'csisolatin1': 'windows-1252', 'ibm819': 'windows-1252', 'iso-8859-1': 'windows-1252', 'iso-ir-100': 'windows-1252', 'iso8859-1': 'windows-1252', 'iso88591': 'windows-1252', 'iso_8859-1': 'windows-1252', 'iso_8859-1:1987': 'windows-1252', 'l1': 'windows-1252', 'latin1': 'windows-1252', 'us-ascii': 'windows-1252', 'windows-1252': 'windows-1252', 'x-cp1252': 'windows-1252', 'cp1253': 'windows-1253', 'windows-1253': 'windows-1253', 'x-cp1253': 'windows-1253', 'cp1254': 'windows-1254', 'csisolatin5': 'windows-1254', 'iso-8859-9': 'windows-1254', 'iso-ir-148': 'windows-1254', 'iso8859-9': 'windows-1254', 'iso88599': 'windows-1254', 'iso_8859-9': 'windows-1254', 'iso_8859-9:1989': 'windows-1254', 'l5': 'windows-1254', 'latin5': 'windows-1254', 'windows-1254': 'windows-1254', 'x-cp1254': 'windows-1254', 'cp1255': 'windows-1255', 'windows-1255': 'windows-1255', 'x-cp1255': 'windows-1255', 'cp1256': 'windows-1256', 'windows-1256': 'windows-1256', 'x-cp1256': 'windows-1256', 'cp1257': 'windows-1257', 'windows-1257': 'windows-1257', 'x-cp1257': 'windows-1257', 'cp1258': 'windows-1258', 'windows-1258': 'windows-1258', 'x-cp1258': 'windows-1258', 'x-mac-cyrillic': 'x-mac-cyrillic', 'x-mac-ukrainian': 'x-mac-cyrillic', 'chinese': 'gbk', 'csgb2312': 'gbk', 'csiso58gb231280': 'gbk', 'gb2312': 'gbk', 'gb_2312': 'gbk', 'gb_2312-80': 'gbk', 'gbk': 'gbk', 'iso-ir-58': 'gbk', 'x-gbk': 'gbk', 'gb18030': 'gb18030', 'hz-gb-2312': 'hz-gb-2312', 'big5': 'big5', 'big5-hkscs': 'big5', 'cn-big5': 'big5', 'csbig5': 'big5', 'x-x-big5': 'big5', 'cseucpkdfmtjapanese': 'euc-jp', 'euc-jp': 'euc-jp', 'x-euc-jp': 'euc-jp', 'csiso2022jp': 'iso-2022-jp', 'iso-2022-jp': 'iso-2022-jp', 'csshiftjis': 'shift_jis', 'ms_kanji': 'shift_jis', 'shift-jis': 'shift_jis', 'shift_jis': 'shift_jis', 'sjis': 'shift_jis', 'windows-31j': 'shift_jis', 'x-sjis': 'shift_jis', 'cseuckr': 'euc-kr', 'csksc56011987': 'euc-kr', 'euc-kr': 'euc-kr', 'iso-ir-149': 'euc-kr', 'korean': 'euc-kr', 'ks_c_5601-1987': 'euc-kr', 'ks_c_5601-1989': 'euc-kr', 'ksc5601': 'euc-kr', 'ksc_5601': 'euc-kr', 'windows-949': 'euc-kr', 'csiso2022kr': 'iso-2022-kr', 'iso-2022-kr': 'iso-2022-kr', 'utf-16be': 'utf-16be', 'utf-16': 'utf-16le', 'utf-16le': 'utf-16le', 'x-user-defined': 'x-user-defined', }
mit
[ 624, 339, 3330, 21138, 14, 3512, 272, 18294, 23597, 339, 9672, 2644, 3628, 370, 3932, 536, 14, 339, 520, 7307, 26, 1898, 6029, 701, 10751, 265, 428, 439, 262, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 199, 624, 199, 199, 3, 5787, 4226, 440, 5283, 1, 199, 3, 961, 570, 365, 5847, 4046, 701, 9199, 3512, 14, 647, 199, 199, 13837, 51, 275, 469, 272, 283, 2975, 13, 17, 13, 17, 13, 1624, 13, 24, 356, 257, 283, 1624, 13, 24, 297, 272, 283, 1624, 13, 24, 356, 5185, 283, 1624, 13, 24, 297, 272, 283, 1624, 24, 356, 4483, 283, 1624, 13, 24, 297, 272, 283, 13465, 356, 463, 283, 19870, 13465, 297, 272, 283, 1850, 13465, 356, 5185, 283, 19870, 13465, 297, 272, 283, 67, 6637, 77, 13465, 356, 3322, 283, 19870, 13465, 297, 272, 283, 19870, 13465, 356, 4519, 283, 19870, 13465, 297, 272, 283, 67, 2316, 393, 14667, 18, 356, 260, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 13, 4830, 13, 18, 356, 3515, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 13, 723, 13, 4893, 356, 3515, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 4830, 13, 18, 356, 3698, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 4830, 18, 356, 3322, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 63, 4830, 13, 18, 356, 3515, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 63, 4830, 13, 18, 26, 30828, 356, 258, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 76, 18, 356, 8295, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 10378, 18, 356, 4519, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 67, 2316, 393, 14667, 19, 356, 260, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 13, 4830, 13, 19, 356, 3515, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 13, 723, 13, 6996, 356, 3515, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 4830, 13, 19, 356, 3698, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 4830, 19, 356, 3322, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 63, 4830, 13, 19, 356, 3515, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 63, 4830, 13, 19, 26, 29313, 356, 258, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 76, 19, 356, 8295, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 10378, 19, 356, 4519, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 67, 2316, 393, 14667, 20, 356, 260, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 13, 4830, 13, 20, 356, 3515, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 13, 723, 13, 6019, 356, 3515, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 4830, 13, 20, 356, 3698, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 4830, 20, 356, 3322, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 63, 4830, 13, 20, 356, 3515, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 63, 4830, 13, 20, 26, 29313, 356, 258, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 76, 20, 356, 8295, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 10378, 20, 356, 4519, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 67, 2316, 393, 14667, 17405, 356, 221, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 17405, 356, 3322, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 13, 4830, 13, 21, 356, 3515, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 13, 723, 13, 9862, 356, 3515, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 4830, 13, 21, 356, 3698, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 4830, 21, 356, 3322, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 63, 4830, 13, 21, 356, 3515, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 63, 4830, 13, 21, 26, 29313, 356, 258, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 13998, 356, 4519, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 305, 573, 13, 23, 2036, 356, 3322, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 19551, 1152, 4830, 22, 69, 356, 260, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 19551, 1152, 4830, 22, 73, 356, 260, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 67, 2316, 393, 14667, 13998, 356, 259, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 825, 391, 13, 7636, 356, 3322, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 13, 4830, 13, 22, 356, 3515, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 13, 4830, 13, 22, 13, 69, 356, 263, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 13, 4830, 13, 22, 13, 73, 356, 263, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 13, 723, 13, 4195, 356, 3515, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 4830, 13, 22, 356, 3698, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 4830, 22, 356, 3322, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 63, 4830, 13, 22, 356, 3515, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 63, 4830, 13, 22, 26, 30828, 356, 258, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 67, 2316, 393, 1958, 14291, 356, 258, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 825, 391, 13, 7906, 356, 3322, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 69, 1653, 63, 25, 1651, 356, 3322, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 32007, 356, 5185, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 32007, 24, 356, 4519, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 4595, 13, 4830, 13, 23, 356, 3515, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 4595, 13, 723, 13, 7957, 356, 3515, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 4595, 4830, 13, 23, 356, 3698, 283, 4595, 13, 4830, 13 ]
[ 339, 3330, 21138, 14, 3512, 272, 18294, 23597, 339, 9672, 2644, 3628, 370, 3932, 536, 14, 339, 520, 7307, 26, 1898, 6029, 701, 10751, 265, 428, 439, 262, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 199, 624, 199, 199, 3, 5787, 4226, 440, 5283, 1, 199, 3, 961, 570, 365, 5847, 4046, 701, 9199, 3512, 14, 647, 199, 199, 13837, 51, 275, 469, 272, 283, 2975, 13, 17, 13, 17, 13, 1624, 13, 24, 356, 257, 283, 1624, 13, 24, 297, 272, 283, 1624, 13, 24, 356, 5185, 283, 1624, 13, 24, 297, 272, 283, 1624, 24, 356, 4483, 283, 1624, 13, 24, 297, 272, 283, 13465, 356, 463, 283, 19870, 13465, 297, 272, 283, 1850, 13465, 356, 5185, 283, 19870, 13465, 297, 272, 283, 67, 6637, 77, 13465, 356, 3322, 283, 19870, 13465, 297, 272, 283, 19870, 13465, 356, 4519, 283, 19870, 13465, 297, 272, 283, 67, 2316, 393, 14667, 18, 356, 260, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 13, 4830, 13, 18, 356, 3515, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 13, 723, 13, 4893, 356, 3515, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 4830, 13, 18, 356, 3698, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 4830, 18, 356, 3322, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 63, 4830, 13, 18, 356, 3515, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 4595, 63, 4830, 13, 18, 26, 30828, 356, 258, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 76, 18, 356, 8295, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 10378, 18, 356, 4519, 283, 4595, 13, 4830, 13, 18, 297, 272, 283, 67, 2316, 393, 14667, 19, 356, 260, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 13, 4830, 13, 19, 356, 3515, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 13, 723, 13, 6996, 356, 3515, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 4830, 13, 19, 356, 3698, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 4830, 19, 356, 3322, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 63, 4830, 13, 19, 356, 3515, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 4595, 63, 4830, 13, 19, 26, 29313, 356, 258, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 76, 19, 356, 8295, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 10378, 19, 356, 4519, 283, 4595, 13, 4830, 13, 19, 297, 272, 283, 67, 2316, 393, 14667, 20, 356, 260, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 13, 4830, 13, 20, 356, 3515, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 13, 723, 13, 6019, 356, 3515, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 4830, 13, 20, 356, 3698, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 4830, 20, 356, 3322, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 63, 4830, 13, 20, 356, 3515, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 4595, 63, 4830, 13, 20, 26, 29313, 356, 258, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 76, 20, 356, 8295, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 10378, 20, 356, 4519, 283, 4595, 13, 4830, 13, 20, 297, 272, 283, 67, 2316, 393, 14667, 17405, 356, 221, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 17405, 356, 3322, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 13, 4830, 13, 21, 356, 3515, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 13, 723, 13, 9862, 356, 3515, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 4830, 13, 21, 356, 3698, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 4830, 21, 356, 3322, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 63, 4830, 13, 21, 356, 3515, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 4595, 63, 4830, 13, 21, 26, 29313, 356, 258, 283, 4595, 13, 4830, 13, 21, 297, 272, 283, 13998, 356, 4519, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 305, 573, 13, 23, 2036, 356, 3322, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 19551, 1152, 4830, 22, 69, 356, 260, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 19551, 1152, 4830, 22, 73, 356, 260, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 67, 2316, 393, 14667, 13998, 356, 259, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 825, 391, 13, 7636, 356, 3322, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 13, 4830, 13, 22, 356, 3515, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 13, 4830, 13, 22, 13, 69, 356, 263, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 13, 4830, 13, 22, 13, 73, 356, 263, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 13, 723, 13, 4195, 356, 3515, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 4830, 13, 22, 356, 3698, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 4830, 22, 356, 3322, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 63, 4830, 13, 22, 356, 3515, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 4595, 63, 4830, 13, 22, 26, 30828, 356, 258, 283, 4595, 13, 4830, 13, 22, 297, 272, 283, 67, 2316, 393, 1958, 14291, 356, 258, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 825, 391, 13, 7906, 356, 3322, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 69, 1653, 63, 25, 1651, 356, 3322, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 32007, 356, 5185, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 32007, 24, 356, 4519, 283, 4595, 13, 4830, 13, 23, 297, 272, 283, 4595, 13, 4830, 13, 23, 356, 3515, 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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 ]
IV-GII/SocialCookies
ENV1/lib/python2.7/site-packages/django/db/models/fields/__init__.py
28
52768
from __future__ import unicode_literals import copy import datetime import decimal import math import warnings from base64 import b64decode, b64encode from itertools import tee from django.db import connection from django.db.models.loading import get_model from django.db.models.query_utils import QueryWrapper from django.conf import settings from django import forms from django.core import exceptions, validators from django.utils.datastructures import DictWrapper from django.utils.dateparse import parse_date, parse_datetime, parse_time from django.utils.functional import curry, total_ordering from django.utils.itercompat import is_iterator from django.utils.text import capfirst from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_text, force_text, force_bytes from django.utils.ipv6 import clean_ipv6_address from django.utils import six class Empty(object): pass class NOT_PROVIDED: pass # The values to use for "blank" in SelectFields. Will be appended to the start # of most "choices" lists. BLANK_CHOICE_DASH = [("", "---------")] def _load_field(app_label, model_name, field_name): return get_model(app_label, model_name)._meta.get_field_by_name(field_name)[0] class FieldDoesNotExist(Exception): pass # A guide to Field parameters: # # * name: The name of the field specifed in the model. # * attname: The attribute to use on the model object. This is the same as # "name", except in the case of ForeignKeys, where "_id" is # appended. # * db_column: The db_column specified in the model (or None). # * column: The database column for this field. This is the same as # "attname", except if db_column is specified. # # Code that introspects values, or does other dynamic things, should use # attname. For example, this gets the primary key value of object "obj": # # getattr(obj, opts.pk.attname) def _empty(of_cls): new = Empty() new.__class__ = of_cls return new @total_ordering class Field(object): """Base class for all field types""" # Designates whether empty strings fundamentally are allowed at the # database level. empty_strings_allowed = True empty_values = list(validators.EMPTY_VALUES) # These track each time a Field instance is created. Used to retain order. # The auto_creation_counter is used for fields that Django implicitly # creates, creation_counter is used for all user-specified fields. creation_counter = 0 auto_creation_counter = -1 default_validators = [] # Default set of validators default_error_messages = { 'invalid_choice': _('Value %(value)r is not a valid choice.'), 'null': _('This field cannot be null.'), 'blank': _('This field cannot be blank.'), 'unique': _('%(model_name)s with this %(field_label)s ' 'already exists.'), } # Generic field type description, usually overriden by subclasses def _description(self): return _('Field of type: %(field_type)s') % { 'field_type': self.__class__.__name__ } description = property(_description) def __init__(self, verbose_name=None, name=None, primary_key=False, max_length=None, unique=False, blank=False, null=False, db_index=False, rel=None, default=NOT_PROVIDED, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text='', db_column=None, db_tablespace=None, auto_created=False, validators=[], error_messages=None): self.name = name self.verbose_name = verbose_name self.primary_key = primary_key self.max_length, self._unique = max_length, unique self.blank, self.null = blank, null self.rel = rel self.default = default self.editable = editable self.serialize = serialize self.unique_for_date, self.unique_for_month = (unique_for_date, unique_for_month) self.unique_for_year = unique_for_year self._choices = choices or [] self.help_text = help_text self.db_column = db_column self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE self.auto_created = auto_created # Set db_index to True if the field has a relationship and doesn't # explicitly set db_index. self.db_index = db_index # Adjust the appropriate creation counter, and save our local copy. if auto_created: self.creation_counter = Field.auto_creation_counter Field.auto_creation_counter -= 1 else: self.creation_counter = Field.creation_counter Field.creation_counter += 1 self.validators = self.default_validators + validators messages = {} for c in reversed(self.__class__.__mro__): messages.update(getattr(c, 'default_error_messages', {})) messages.update(error_messages or {}) self.error_messages = messages def __eq__(self, other): # Needed for @total_ordering if isinstance(other, Field): return self.creation_counter == other.creation_counter return NotImplemented def __lt__(self, other): # This is needed because bisect does not take a comparison function. if isinstance(other, Field): return self.creation_counter < other.creation_counter return NotImplemented def __hash__(self): return hash(self.creation_counter) def __deepcopy__(self, memodict): # We don't have to deepcopy very much here, since most things are not # intended to be altered after initial creation. obj = copy.copy(self) if self.rel: obj.rel = copy.copy(self.rel) if hasattr(self.rel, 'field') and self.rel.field is self: obj.rel.field = obj memodict[id(self)] = obj return obj def __copy__(self): # We need to avoid hitting __reduce__, so define this # slightly weird copy construct. obj = Empty() obj.__class__ = self.__class__ obj.__dict__ = self.__dict__.copy() return obj def __reduce__(self): """ Pickling should return the model._meta.fields instance of the field, not a new copy of that field. So, we use the app cache to load the model and then the field back. """ if not hasattr(self, 'model'): # Fields are sometimes used without attaching them to models (for # example in aggregation). In this case give back a plain field # instance. The code below will create a new empty instance of # class self.__class__, then update its dict with self.__dict__ # values - so, this is very close to normal pickle. return _empty, (self.__class__,), self.__dict__ if self.model._deferred: # Deferred model will not be found from the app cache. This could # be fixed by reconstructing the deferred model on unpickle. raise RuntimeError("Fields of deferred models can't be reduced") return _load_field, (self.model._meta.app_label, self.model._meta.object_name, self.name) def to_python(self, value): """ Converts the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ return value def run_validators(self, value): if value in self.empty_values: return errors = [] for v in self.validators: try: v(value) except exceptions.ValidationError as e: if hasattr(e, 'code') and e.code in self.error_messages: e.message = self.error_messages[e.code] errors.extend(e.error_list) if errors: raise exceptions.ValidationError(errors) def validate(self, value, model_instance): """ Validates value and throws ValidationError. Subclasses should override this to provide validation logic. """ if not self.editable: # Skip validation for non-editable fields. return if self._choices and value not in self.empty_values: for option_key, option_value in self.choices: if isinstance(option_value, (list, tuple)): # This is an optgroup, so look inside the group for # options. for optgroup_key, optgroup_value in option_value: if value == optgroup_key: return elif value == option_key: return raise exceptions.ValidationError( self.error_messages['invalid_choice'], code='invalid_choice', params={'value': value}, ) if value is None and not self.null: raise exceptions.ValidationError(self.error_messages['null'], code='null') if not self.blank and value in self.empty_values: raise exceptions.ValidationError(self.error_messages['blank'], code='blank') def clean(self, value, model_instance): """ Convert the value's type and run validation. Validation errors from to_python and validate are propagated. The correct value is returned if no error is raised. """ value = self.to_python(value) self.validate(value, model_instance) self.run_validators(value) return value def db_type(self, connection): """ Returns the database column data type for this field, for the provided connection. """ # The default implementation of this method looks at the # backend-specific DATA_TYPES dictionary, looking up the field by its # "internal type". # # A Field class can implement the get_internal_type() method to specify # which *preexisting* Django Field class it's most similar to -- i.e., # a custom field might be represented by a TEXT column type, which is # the same as the TextField Django field type, which means the custom # field's get_internal_type() returns 'TextField'. # # But the limitation of the get_internal_type() / data_types approach # is that it cannot handle database column types that aren't already # mapped to one of the built-in Django field types. In this case, you # can implement db_type() instead of get_internal_type() to specify # exactly which wacky database column type you want to use. data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_") try: return (connection.creation.data_types[self.get_internal_type()] % data) except KeyError: return None @property def unique(self): return self._unique or self.primary_key def set_attributes_from_name(self, name): if not self.name: self.name = name self.attname, self.column = self.get_attname_column() if self.verbose_name is None and self.name: 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) if self.choices: setattr(cls, 'get_%s_display' % self.name, curry(cls._get_FIELD_display, field=self)) def get_attname(self): return self.name def get_attname_column(self): attname = self.get_attname() column = self.db_column or attname return attname, column def get_cache_name(self): return '_%s_cache' % self.name def get_internal_type(self): return self.__class__.__name__ def pre_save(self, model_instance, add): """ Returns field's value just before saving. """ return getattr(model_instance, self.attname) def get_prep_value(self, value): """ Perform preliminary non-db specific value checks and conversions. """ return value def get_db_prep_value(self, value, connection, prepared=False): """Returns field's value prepared for interacting with the database backend. Used by the default implementations of ``get_db_prep_save``and `get_db_prep_lookup``` """ if not prepared: value = self.get_prep_value(value) return value def get_db_prep_save(self, value, connection): """ Returns field's value prepared for saving into a database. """ return self.get_db_prep_value(value, connection=connection, prepared=False) def get_prep_lookup(self, lookup_type, value): """ Perform preliminary non-db specific lookup checks and conversions """ if hasattr(value, 'prepare'): return value.prepare() if hasattr(value, '_prepare'): return value._prepare() if lookup_type in ( 'iexact', 'contains', 'icontains', 'startswith', 'istartswith', 'endswith', 'iendswith', 'month', 'day', 'week_day', 'hour', 'minute', 'second', 'isnull', 'search', 'regex', 'iregex', ): return value elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'): return self.get_prep_value(value) elif lookup_type in ('range', 'in'): return [self.get_prep_value(v) for v in value] elif lookup_type == 'year': try: return int(value) except ValueError: raise ValueError("The __year lookup type requires an integer " "argument") raise TypeError("Field has invalid lookup: %s" % lookup_type) def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False): """ Returns field's value prepared for database lookup. """ if not prepared: value = self.get_prep_lookup(lookup_type, value) prepared = True if hasattr(value, 'get_compiler'): value = value.get_compiler(connection=connection) if hasattr(value, 'as_sql') or hasattr(value, '_as_sql'): # If the value has a relabeled_clone method it means the # value will be handled later on. if hasattr(value, 'relabeled_clone'): return value if hasattr(value, 'as_sql'): sql, params = value.as_sql() else: sql, params = value._as_sql(connection=connection) return QueryWrapper(('(%s)' % sql), params) if lookup_type in ('month', 'day', 'week_day', 'hour', 'minute', 'second', 'search', 'regex', 'iregex'): return [value] elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'): return [self.get_db_prep_value(value, connection=connection, prepared=prepared)] elif lookup_type in ('range', 'in'): return [self.get_db_prep_value(v, connection=connection, prepared=prepared) for v in value] elif lookup_type in ('contains', 'icontains'): return ["%%%s%%" % connection.ops.prep_for_like_query(value)] elif lookup_type == 'iexact': return [connection.ops.prep_for_iexact_query(value)] elif lookup_type in ('startswith', 'istartswith'): return ["%s%%" % connection.ops.prep_for_like_query(value)] elif lookup_type in ('endswith', 'iendswith'): return ["%%%s" % connection.ops.prep_for_like_query(value)] elif lookup_type == 'isnull': return [] elif lookup_type == 'year': if isinstance(self, DateTimeField): return connection.ops.year_lookup_bounds_for_datetime_field(value) elif isinstance(self, DateField): return connection.ops.year_lookup_bounds_for_date_field(value) else: return [value] # this isn't supposed to happen def has_default(self): """ Returns a boolean of whether this field has a default value. """ return self.default is not NOT_PROVIDED def get_default(self): """ Returns the default value for this field. """ if self.has_default(): if callable(self.default): return self.default() return force_text(self.default, strings_only=True) if (not self.empty_strings_allowed or (self.null and not connection.features.interprets_empty_strings_as_nulls)): return None return "" def get_validator_unique_lookup_type(self): return '%s__exact' % self.name def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH): """Returns choices with a default blank choices included, for use as SelectField choices for this field.""" first_choice = blank_choice if include_blank else [] if self.choices: return first_choice + list(self.choices) rel_model = self.rel.to if hasattr(self.rel, 'get_related_field'): lst = [(getattr(x, self.rel.get_related_field().attname), smart_text(x)) for x in rel_model._default_manager.complex_filter( self.rel.limit_choices_to)] else: lst = [(x._get_pk_val(), smart_text(x)) for x in rel_model._default_manager.complex_filter( self.rel.limit_choices_to)] return first_choice + lst def get_choices_default(self): return self.get_choices() def get_flatchoices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH): """ Returns flattened choices with a default blank choice included. """ first_choice = blank_choice if include_blank else [] return first_choice + list(self.flatchoices) def _get_val_from_obj(self, obj): if obj is not None: return getattr(obj, self.attname) else: return self.get_default() def value_to_string(self, obj): """ Returns a string value of this field from the passed obj. This is used by the serialization framework. """ return smart_text(self._get_val_from_obj(obj)) def bind(self, fieldmapping, original, bound_field_class): return bound_field_class(self, fieldmapping, original) def _get_choices(self): if is_iterator(self._choices): choices, self._choices = tee(self._choices) return choices else: return self._choices choices = property(_get_choices) def _get_flatchoices(self): """Flattened version of choices tuple.""" flat = [] for choice, value in self.choices: if isinstance(value, (list, tuple)): flat.extend(value) else: flat.append((choice,value)) return flat flatchoices = property(_get_flatchoices) def save_form_data(self, instance, data): setattr(instance, self.name, data) def formfield(self, form_class=None, choices_form_class=None, **kwargs): """ Returns a django.forms.Field instance for this database Field. """ defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} if self.has_default(): if callable(self.default): defaults['initial'] = self.default defaults['show_hidden_initial'] = True else: defaults['initial'] = self.get_default() if self.choices: # Fields with choices get special treatment. include_blank = (self.blank or not (self.has_default() or 'initial' in kwargs)) defaults['choices'] = self.get_choices(include_blank=include_blank) defaults['coerce'] = self.to_python if self.null: defaults['empty_value'] = None if choices_form_class is not None: form_class = choices_form_class else: form_class = forms.TypedChoiceField # Many of the subclass-specific formfield arguments (min_value, # max_value) don't apply for choice fields, so be sure to only pass # the values that TypedChoiceField will understand. for k in list(kwargs): if k not in ('coerce', 'empty_value', 'choices', 'required', 'widget', 'label', 'initial', 'help_text', 'error_messages', 'show_hidden_initial'): del kwargs[k] defaults.update(kwargs) if form_class is None: form_class = forms.CharField return form_class(**defaults) def value_from_object(self, obj): """ Returns the value of this field in the given model instance. """ return getattr(obj, self.attname) def __repr__(self): """ Displays the module, class and name of the field. """ path = '%s.%s' % (self.__class__.__module__, self.__class__.__name__) name = getattr(self, 'name', None) if name is not None: return '<%s: %s>' % (path, name) return '<%s>' % path class AutoField(Field): description = _("Integer") empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be an integer."), } def __init__(self, *args, **kwargs): assert kwargs.get('primary_key', False) is True, \ "%ss must have primary_key=True." % self.__class__.__name__ kwargs['blank'] = True Field.__init__(self, *args, **kwargs) def get_internal_type(self): return "AutoField" def to_python(self, value): if value is None: return value try: return int(value) except (TypeError, ValueError): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def validate(self, value, model_instance): pass def get_db_prep_value(self, value, connection, prepared=False): if not prepared: value = self.get_prep_value(value) value = connection.ops.validate_autopk_value(value) return value def get_prep_value(self, value): if value is None: return None return int(value) def contribute_to_class(self, cls, name): assert not cls._meta.has_auto_field, \ "A model can't have more than one AutoField." super(AutoField, self).contribute_to_class(cls, name) cls._meta.has_auto_field = True cls._meta.auto_field = self def formfield(self, **kwargs): return None class BooleanField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be either True or False."), } description = _("Boolean (Either True or False)") def __init__(self, *args, **kwargs): kwargs['blank'] = True Field.__init__(self, *args, **kwargs) def get_internal_type(self): return "BooleanField" def to_python(self, value): if value in (True, False): # if value is 1 or 0 than it's equal to True or False, but we want # to return a true bool for semantic reasons. return bool(value) if value in ('t', 'True', '1'): return True if value in ('f', 'False', '0'): return False raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def get_prep_lookup(self, lookup_type, value): # Special-case handling for filters coming from a Web request (e.g. the # admin interface). Only works for scalar values (not lists). If you're # passing in a list, you might as well make things the right type when # constructing the list. if value in ('1', '0'): value = bool(int(value)) return super(BooleanField, self).get_prep_lookup(lookup_type, value) def get_prep_value(self, value): if value is None: return None return bool(value) def formfield(self, **kwargs): # Unlike most fields, BooleanField figures out include_blank from # self.null instead of self.blank. if self.choices: include_blank = (self.null or not (self.has_default() or 'initial' in kwargs)) defaults = {'choices': self.get_choices( include_blank=include_blank)} else: defaults = {'form_class': forms.BooleanField} defaults.update(kwargs) return super(BooleanField, self).formfield(**defaults) class CharField(Field): description = _("String (up to %(max_length)s)") def __init__(self, *args, **kwargs): super(CharField, self).__init__(*args, **kwargs) self.validators.append(validators.MaxLengthValidator(self.max_length)) def get_internal_type(self): return "CharField" def to_python(self, value): if isinstance(value, six.string_types) or value is None: return value return smart_text(value) def get_prep_value(self, value): return self.to_python(value) def formfield(self, **kwargs): # Passing max_length to forms.CharField means that the value's length # will be validated twice. This is considered acceptable since we want # the value in the form field (to pass into widget for example). defaults = {'max_length': self.max_length} defaults.update(kwargs) return super(CharField, self).formfield(**defaults) # TODO: Maybe move this into contrib, because it's specialized. class CommaSeparatedIntegerField(CharField): default_validators = [validators.validate_comma_separated_integer_list] description = _("Comma-separated integers") def formfield(self, **kwargs): defaults = { 'error_messages': { 'invalid': _('Enter only digits separated by commas.'), } } defaults.update(kwargs) return super(CommaSeparatedIntegerField, self).formfield(**defaults) class DateField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid date format. It must be " "in YYYY-MM-DD format."), 'invalid_date': _("'%(value)s' value has the correct format (YYYY-MM-DD) " "but it is an invalid date."), } description = _("Date (without time)") def __init__(self, verbose_name=None, name=None, auto_now=False, auto_now_add=False, **kwargs): self.auto_now, self.auto_now_add = auto_now, auto_now_add if auto_now or auto_now_add: kwargs['editable'] = False kwargs['blank'] = True Field.__init__(self, verbose_name, name, **kwargs) def get_internal_type(self): return "DateField" def to_python(self, value): if value is None: return value if isinstance(value, datetime.datetime): if settings.USE_TZ and timezone.is_aware(value): # Convert aware datetimes to the default time zone # before casting them to dates (#17742). default_timezone = timezone.get_default_timezone() value = timezone.make_naive(value, default_timezone) return value.date() if isinstance(value, datetime.date): return value try: parsed = parse_date(value) if parsed is not None: return parsed except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_date'], code='invalid_date', params={'value': value}, ) raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def pre_save(self, model_instance, add): if self.auto_now or (self.auto_now_add and add): value = datetime.date.today() setattr(model_instance, self.attname, value) return value else: return super(DateField, self).pre_save(model_instance, add) def contribute_to_class(self, cls, name): super(DateField,self).contribute_to_class(cls, name) if not self.null: setattr(cls, 'get_next_by_%s' % self.name, curry(cls._get_next_or_previous_by_FIELD, field=self, is_next=True)) setattr(cls, 'get_previous_by_%s' % self.name, curry(cls._get_next_or_previous_by_FIELD, field=self, is_next=False)) def get_prep_lookup(self, lookup_type, value): # For dates lookups, convert the value to an int # so the database backend always sees a consistent type. if lookup_type in ('month', 'day', 'week_day', 'hour', 'minute', 'second'): return int(value) return super(DateField, self).get_prep_lookup(lookup_type, value) def get_prep_value(self, value): return self.to_python(value) def get_db_prep_value(self, value, connection, prepared=False): # Casts dates into the format expected by the backend if not prepared: value = self.get_prep_value(value) return connection.ops.value_to_db_date(value) def value_to_string(self, obj): val = self._get_val_from_obj(obj) return '' if val is None else val.isoformat() def formfield(self, **kwargs): defaults = {'form_class': forms.DateField} defaults.update(kwargs) return super(DateField, self).formfield(**defaults) class DateTimeField(DateField): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid format. It must be in " "YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format."), 'invalid_date': _("'%(value)s' value has the correct format " "(YYYY-MM-DD) but it is an invalid date."), 'invalid_datetime': _("'%(value)s' value has the correct format " "(YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]) " "but it is an invalid date/time."), } description = _("Date (with time)") # __init__ is inherited from DateField def get_internal_type(self): return "DateTimeField" def to_python(self, value): if value is None: return value if isinstance(value, datetime.datetime): return value if isinstance(value, datetime.date): value = datetime.datetime(value.year, value.month, value.day) if settings.USE_TZ: # For backwards compatibility, interpret naive datetimes in # local time. This won't work during DST change, but we can't # do much about it, so we let the exceptions percolate up the # call stack. warnings.warn("DateTimeField %s.%s received a naive datetime " "(%s) while time zone support is active." % (self.model.__name__, self.name, value), RuntimeWarning) default_timezone = timezone.get_default_timezone() value = timezone.make_aware(value, default_timezone) return value try: parsed = parse_datetime(value) if parsed is not None: return parsed except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_datetime'], code='invalid_datetime', params={'value': value}, ) try: parsed = parse_date(value) if parsed is not None: return datetime.datetime(parsed.year, parsed.month, parsed.day) except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_date'], code='invalid_date', params={'value': value}, ) raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def pre_save(self, model_instance, add): if self.auto_now or (self.auto_now_add and add): value = timezone.now() setattr(model_instance, self.attname, value) return value else: return super(DateTimeField, self).pre_save(model_instance, add) # contribute_to_class is inherited from DateField, it registers # get_next_by_FOO and get_prev_by_FOO # get_prep_lookup is inherited from DateField def get_prep_value(self, value): value = self.to_python(value) if value is not None and settings.USE_TZ and timezone.is_naive(value): # For backwards compatibility, interpret naive datetimes in local # time. This won't work during DST change, but we can't do much # about it, so we let the exceptions percolate up the call stack. warnings.warn("DateTimeField %s.%s received a naive datetime (%s)" " while time zone support is active." % (self.model.__name__, self.name, value), RuntimeWarning) default_timezone = timezone.get_default_timezone() value = timezone.make_aware(value, default_timezone) return value def get_db_prep_value(self, value, connection, prepared=False): # Casts datetimes into the format expected by the backend if not prepared: value = self.get_prep_value(value) return connection.ops.value_to_db_datetime(value) def value_to_string(self, obj): val = self._get_val_from_obj(obj) return '' if val is None else val.isoformat() def formfield(self, **kwargs): defaults = {'form_class': forms.DateTimeField} defaults.update(kwargs) return super(DateTimeField, self).formfield(**defaults) class DecimalField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be a decimal number."), } description = _("Decimal number") def __init__(self, verbose_name=None, name=None, max_digits=None, decimal_places=None, **kwargs): self.max_digits, self.decimal_places = max_digits, decimal_places Field.__init__(self, verbose_name, name, **kwargs) def get_internal_type(self): return "DecimalField" def to_python(self, value): if value is None: return value try: return decimal.Decimal(value) except decimal.InvalidOperation: raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def _format(self, value): if isinstance(value, six.string_types) or value is None: return value else: return self.format_number(value) def format_number(self, value): """ Formats a number into a string with the requisite number of digits and decimal places. """ # Method moved to django.db.backends.util. # # It is preserved because it is used by the oracle backend # (django.db.backends.oracle.query), and also for # backwards-compatibility with any external code which may have used # this method. from django.db.backends import util return util.format_number(value, self.max_digits, self.decimal_places) def get_db_prep_save(self, value, connection): return connection.ops.value_to_db_decimal(self.to_python(value), self.max_digits, self.decimal_places) def get_prep_value(self, value): return self.to_python(value) def formfield(self, **kwargs): defaults = { 'max_digits': self.max_digits, 'decimal_places': self.decimal_places, 'form_class': forms.DecimalField, } defaults.update(kwargs) return super(DecimalField, self).formfield(**defaults) class EmailField(CharField): default_validators = [validators.validate_email] description = _("Email address") def __init__(self, *args, **kwargs): # max_length should be overridden to 254 characters to be fully # compliant with RFCs 3696 and 5321 kwargs['max_length'] = kwargs.get('max_length', 75) CharField.__init__(self, *args, **kwargs) def formfield(self, **kwargs): # As with CharField, this will cause email validation to be performed # twice. defaults = { 'form_class': forms.EmailField, } defaults.update(kwargs) return super(EmailField, self).formfield(**defaults) class FilePathField(Field): description = _("File path") def __init__(self, verbose_name=None, name=None, path='', match=None, recursive=False, allow_files=True, allow_folders=False, **kwargs): self.path, self.match, self.recursive = path, match, recursive self.allow_files, self.allow_folders = allow_files, allow_folders kwargs['max_length'] = kwargs.get('max_length', 100) Field.__init__(self, verbose_name, name, **kwargs) def formfield(self, **kwargs): defaults = { 'path': self.path, 'match': self.match, 'recursive': self.recursive, 'form_class': forms.FilePathField, 'allow_files': self.allow_files, 'allow_folders': self.allow_folders, } defaults.update(kwargs) return super(FilePathField, self).formfield(**defaults) def get_internal_type(self): return "FilePathField" class FloatField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be a float."), } description = _("Floating point number") def get_prep_value(self, value): if value is None: return None return float(value) def get_internal_type(self): return "FloatField" def to_python(self, value): if value is None: return value try: return float(value) except (TypeError, ValueError): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def formfield(self, **kwargs): defaults = {'form_class': forms.FloatField} defaults.update(kwargs) return super(FloatField, self).formfield(**defaults) class IntegerField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be an integer."), } description = _("Integer") def get_prep_value(self, value): if value is None: return None return int(value) def get_prep_lookup(self, lookup_type, value): if ((lookup_type == 'gte' or lookup_type == 'lt') and isinstance(value, float)): value = math.ceil(value) return super(IntegerField, self).get_prep_lookup(lookup_type, value) def get_internal_type(self): return "IntegerField" def to_python(self, value): if value is None: return value try: return int(value) except (TypeError, ValueError): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def formfield(self, **kwargs): defaults = {'form_class': forms.IntegerField} defaults.update(kwargs) return super(IntegerField, self).formfield(**defaults) class BigIntegerField(IntegerField): empty_strings_allowed = False description = _("Big (8 byte) integer") MAX_BIGINT = 9223372036854775807 def get_internal_type(self): return "BigIntegerField" def formfield(self, **kwargs): defaults = {'min_value': -BigIntegerField.MAX_BIGINT - 1, 'max_value': BigIntegerField.MAX_BIGINT} defaults.update(kwargs) return super(BigIntegerField, self).formfield(**defaults) class IPAddressField(Field): empty_strings_allowed = False description = _("IPv4 address") def __init__(self, *args, **kwargs): kwargs['max_length'] = 15 Field.__init__(self, *args, **kwargs) def get_internal_type(self): return "IPAddressField" def formfield(self, **kwargs): defaults = {'form_class': forms.IPAddressField} defaults.update(kwargs) return super(IPAddressField, self).formfield(**defaults) class GenericIPAddressField(Field): empty_strings_allowed = True description = _("IP address") default_error_messages = {} def __init__(self, verbose_name=None, name=None, protocol='both', unpack_ipv4=False, *args, **kwargs): self.unpack_ipv4 = unpack_ipv4 self.protocol = protocol self.default_validators, invalid_error_message = \ validators.ip_address_validators(protocol, unpack_ipv4) self.default_error_messages['invalid'] = invalid_error_message kwargs['max_length'] = 39 Field.__init__(self, verbose_name, name, *args, **kwargs) def get_internal_type(self): return "GenericIPAddressField" def to_python(self, value): if value and ':' in value: return clean_ipv6_address(value, self.unpack_ipv4, self.error_messages['invalid']) return value def get_db_prep_value(self, value, connection, prepared=False): if not prepared: value = self.get_prep_value(value) return value or None def get_prep_value(self, value): if value and ':' in value: try: return clean_ipv6_address(value, self.unpack_ipv4) except exceptions.ValidationError: pass return value def formfield(self, **kwargs): defaults = { 'protocol': self.protocol, 'form_class': forms.GenericIPAddressField, } defaults.update(kwargs) return super(GenericIPAddressField, self).formfield(**defaults) class NullBooleanField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be either None, True or False."), } description = _("Boolean (Either True, False or None)") def __init__(self, *args, **kwargs): kwargs['null'] = True kwargs['blank'] = True Field.__init__(self, *args, **kwargs) def get_internal_type(self): return "NullBooleanField" def to_python(self, value): if value is None: return None if value in (True, False): return bool(value) if value in ('None',): return None if value in ('t', 'True', '1'): return True if value in ('f', 'False', '0'): return False raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def get_prep_lookup(self, lookup_type, value): # Special-case handling for filters coming from a Web request (e.g. the # admin interface). Only works for scalar values (not lists). If you're # passing in a list, you might as well make things the right type when # constructing the list. if value in ('1', '0'): value = bool(int(value)) return super(NullBooleanField, self).get_prep_lookup(lookup_type, value) def get_prep_value(self, value): if value is None: return None return bool(value) def formfield(self, **kwargs): defaults = { 'form_class': forms.NullBooleanField, 'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} defaults.update(kwargs) return super(NullBooleanField, self).formfield(**defaults) class PositiveIntegerField(IntegerField): description = _("Positive integer") def get_internal_type(self): return "PositiveIntegerField" def formfield(self, **kwargs): defaults = {'min_value': 0} defaults.update(kwargs) return super(PositiveIntegerField, self).formfield(**defaults) class PositiveSmallIntegerField(IntegerField): description = _("Positive small integer") def get_internal_type(self): return "PositiveSmallIntegerField" def formfield(self, **kwargs): defaults = {'min_value': 0} defaults.update(kwargs) return super(PositiveSmallIntegerField, self).formfield(**defaults) class SlugField(CharField): default_validators = [validators.validate_slug] description = _("Slug (up to %(max_length)s)") def __init__(self, *args, **kwargs): kwargs['max_length'] = kwargs.get('max_length', 50) # Set db_index=True unless it's been set manually. if 'db_index' not in kwargs: kwargs['db_index'] = True super(SlugField, self).__init__(*args, **kwargs) def get_internal_type(self): return "SlugField" def formfield(self, **kwargs): defaults = {'form_class': forms.SlugField} defaults.update(kwargs) return super(SlugField, self).formfield(**defaults) class SmallIntegerField(IntegerField): description = _("Small integer") def get_internal_type(self): return "SmallIntegerField" class TextField(Field): description = _("Text") def get_internal_type(self): return "TextField" def get_prep_value(self, value): if isinstance(value, six.string_types) or value is None: return value return smart_text(value) def formfield(self, **kwargs): defaults = {'widget': forms.Textarea} defaults.update(kwargs) return super(TextField, self).formfield(**defaults) class TimeField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid format. It must be in " "HH:MM[:ss[.uuuuuu]] format."), 'invalid_time': _("'%(value)s' value has the correct format " "(HH:MM[:ss[.uuuuuu]]) but it is an invalid time."), } description = _("Time") def __init__(self, verbose_name=None, name=None, auto_now=False, auto_now_add=False, **kwargs): self.auto_now, self.auto_now_add = auto_now, auto_now_add if auto_now or auto_now_add: kwargs['editable'] = False kwargs['blank'] = True Field.__init__(self, verbose_name, name, **kwargs) def get_internal_type(self): return "TimeField" def to_python(self, value): if value is None: return None if isinstance(value, datetime.time): return value if isinstance(value, datetime.datetime): # Not usually a good idea to pass in a datetime here (it loses # information), but this can be a side-effect of interacting with a # database backend (e.g. Oracle), so we'll be accommodating. return value.time() try: parsed = parse_time(value) if parsed is not None: return parsed except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_time'], code='invalid_time', params={'value': value}, ) raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def pre_save(self, model_instance, add): if self.auto_now or (self.auto_now_add and add): value = datetime.datetime.now().time() setattr(model_instance, self.attname, value) return value else: return super(TimeField, self).pre_save(model_instance, add) def get_prep_value(self, value): return self.to_python(value) def get_db_prep_value(self, value, connection, prepared=False): # Casts times into the format expected by the backend if not prepared: value = self.get_prep_value(value) return connection.ops.value_to_db_time(value) def value_to_string(self, obj): val = self._get_val_from_obj(obj) return '' if val is None else val.isoformat() def formfield(self, **kwargs): defaults = {'form_class': forms.TimeField} defaults.update(kwargs) return super(TimeField, self).formfield(**defaults) class URLField(CharField): default_validators = [validators.URLValidator()] description = _("URL") def __init__(self, verbose_name=None, name=None, **kwargs): kwargs['max_length'] = kwargs.get('max_length', 200) CharField.__init__(self, verbose_name, name, **kwargs) def formfield(self, **kwargs): # As with CharField, this will cause URL validation to be performed # twice. defaults = { 'form_class': forms.URLField, } defaults.update(kwargs) return super(URLField, self).formfield(**defaults) class BinaryField(Field): description = _("Raw binary data") empty_values = [None, b''] def __init__(self, *args, **kwargs): kwargs['editable'] = False super(BinaryField, self).__init__(*args, **kwargs) if self.max_length is not None: self.validators.append(validators.MaxLengthValidator(self.max_length)) def get_internal_type(self): return "BinaryField" def get_default(self): if self.has_default() and not callable(self.default): return self.default default = super(BinaryField, self).get_default() if default == '': return b'' return default def get_db_prep_value(self, value, connection, prepared=False): value = super(BinaryField, self ).get_db_prep_value(value, connection, prepared) if value is not None: return connection.Database.Binary(value) return value def value_to_string(self, obj): """Binary data is serialized as base64""" return b64encode(force_bytes(self._get_val_from_obj(obj))).decode('ascii') def to_python(self, value): # If it's a string, it should be base64-encoded data if isinstance(value, six.text_type): return six.memoryview(b64decode(force_bytes(value))) return value
gpl-2.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1331, 199, 646, 2197, 199, 646, 6107, 199, 646, 3473, 199, 646, 3598, 199, 504, 1300, 772, 492, 330, 772, 2708, 12, 330, 772, 2143, 199, 504, 7975, 492, 1565, 69, 199, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 697, 14, 992, 14, 8786, 492, 664, 63, 1238, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 8133, 4590, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1018, 492, 4967, 12, 14370, 199, 504, 1639, 14, 1208, 14, 23004, 492, 7448, 4590, 199, 504, 1639, 14, 1208, 14, 602, 1122, 492, 2198, 63, 602, 12, 2198, 63, 2083, 12, 2198, 63, 521, 199, 504, 1639, 14, 1208, 14, 15481, 492, 1094, 651, 12, 3141, 63, 7128, 199, 504, 1639, 14, 1208, 14, 1661, 5819, 492, 365, 63, 5778, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 505, 12, 3542, 63, 505, 12, 3542, 63, 2394, 199, 504, 1639, 14, 1208, 14, 4774, 22, 492, 3633, 63, 4774, 22, 63, 1562, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 533, 9630, 8, 785, 304, 272, 986, 199, 199, 533, 2845, 63, 21403, 1149, 26, 272, 986, 199, 199, 3, 710, 1338, 370, 675, 367, 298, 2500, 2, 315, 9496, 7304, 14, 12823, 506, 11544, 370, 314, 1343, 199, 3, 402, 4750, 298, 4577, 2, 5548, 14, 199, 20438, 63, 22544, 63, 29019, 275, 3842, 5151, 298, 9960, 11323, 199, 199, 318, 485, 912, 63, 698, 8, 571, 63, 1302, 12, 1402, 63, 354, 12, 901, 63, 354, 304, 272, 372, 664, 63, 1238, 8, 571, 63, 1302, 12, 1402, 63, 354, 10445, 2024, 14, 362, 63, 698, 63, 991, 63, 354, 8, 698, 63, 354, 2788, 16, 61, 199, 199, 533, 29994, 8, 1726, 304, 272, 986, 199, 199, 3, 437, 22885, 370, 5024, 2633, 26, 199, 3, 199, 3, 257, 627, 536, 26, 420, 710, 536, 402, 314, 901, 1106, 15800, 315, 314, 1402, 14, 199, 3, 257, 627, 15115, 354, 26, 257, 710, 2225, 370, 675, 641, 314, 1402, 909, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 354, 401, 871, 315, 314, 1930, 402, 481, 2692, 6340, 12, 2382, 2668, 344, 2, 365, 199, 3, 4483, 11544, 14, 199, 3, 257, 627, 1592, 63, 2301, 26, 710, 1592, 63, 2301, 2013, 315, 314, 1402, 334, 269, 488, 680, 199, 3, 257, 627, 2763, 26, 259, 710, 3050, 2763, 367, 642, 901, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 13651, 401, 871, 340, 1592, 63, 2301, 365, 2013, 14, 199, 3, 199, 3, 5495, 626, 1109, 21302, 83, 1338, 12, 503, 1630, 1163, 8336, 7645, 12, 1077, 675, 199, 3, 15115, 354, 14, 2104, 2893, 12, 642, 7545, 314, 5062, 790, 574, 402, 909, 298, 1113, 582, 199, 3, 199, 3, 258, 2519, 8, 1113, 12, 3999, 14, 2051, 14, 13651, 9, 199, 199, 318, 485, 1667, 8, 1618, 63, 1886, 304, 272, 892, 275, 9630, 342, 272, 892, 855, 533, 363, 275, 402, 63, 1886, 272, 372, 892, 199, 199, 32, 2923, 63, 7128, 199, 533, 5024, 8, 785, 304, 272, 408, 1563, 1021, 367, 1006, 901, 2943, 624, 339, 327, 29410, 2335, 3775, 2701, 3326, 27440, 14040, 1183, 787, 4370, 737, 314, 272, 327, 3050, 2166, 14, 272, 2701, 63, 5465, 63, 6541, 275, 715, 272, 2701, 63, 1459, 275, 769, 8, 11346, 14, 13993, 63, 15514, 9, 339, 327, 5723, 4426, 1924, 900, 282, 5024, 1256, 365, 2737, 14, 8051, 370, 8074, 1865, 14, 272, 327, 710, 2599, 63, 8782, 63, 5337, 365, 1202, 367, 1504, 626, 5634, 19796, 272, 327, 8491, 12, 7143, 63, 5337, 365, 1202, 367, 1006, 922, 13, 10085, 1504, 14, 272, 7143, 63, 5337, 275, 378, 272, 2599, 63, 8782, 63, 5337, 275, 446, 17, 272, 849, 63, 11346, 275, 942, 327, 3758, 663, 402, 14370, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 63, 5095, 356, 4018, 1110, 2818, 585, 9, 82, 365, 440, 282, 1686, 7141, 8038, 267, 283, 2307, 356, 4018, 2765, 901, 3913, 506, 2973, 8038, 267, 283, 2500, 356, 4018, 2765, 901, 3913, 506, 4596, 8038, 267, 283, 3235, 356, 4018, 2840, 1238, 63, 354, 9, 83, 543, 642, 2818, 698, 63, 1302, 9, 83, 283, 490, 283, 14039, 3495, 8038, 272, 789, 339, 327, 8307, 901, 730, 1369, 12, 9987, 1806, 25045, 701, 9180, 272, 347, 485, 1802, 8, 277, 304, 267, 372, 4018, 792, 402, 730, 26, 2818, 698, 63, 466, 9, 83, 358, 450, 469, 288, 283, 698, 63, 466, 356, 291, 855, 533, 4914, 354, 363, 267, 789, 272, 1369, 275, 3324, 1547, 1802, 9, 339, 347, 636, 826, 721, 277, 12, 3376, 63, 354, 29, 403, 12, 536, 29, 403, 12, 5062, 63, 498, 29, 797, 12, 288, 1390, 63, 1267, 29, 403, 12, 3747, 29, 797, 12, 4596, 29, 797, 12, 2973, 29, 797, 12, 288, 1592, 63, 1080, 29, 797, 12, 4668, 29, 403, 12, 849, 29, 4609, 63, 21403, 1149, 12, 14783, 29, 549, 12, 288, 8437, 29, 549, 12, 3747, 63, 509, 63, 602, 29, 403, 12, 3747, 63, 509, 63, 4482, 29, 403, 12, 288, 3747, 63, 509, 63, 3403, 29, 403, 12, 3415, 29, 403, 12, 1720, 63, 505, 4581, 1592, 63, 2301, 29, 403, 12, 288, 1592, 63, 26730, 29, 403, 12, 2599, 63, 3966, 29, 797, 12, 14370, 6034, 288, 1125, 63, 3431, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 3832, 63, 354, 275, 3376, 63, 354, 267, 291, 14, 3327, 63, 498, 275, 5062, 63, 498, 267, 291, 14, 988, 63, 1267, 12, 291, 423, 3235, 275, 1390, 63, 1267, 12, 3747, 267, 291, 14, 2500, 12, 291, 14, 2307, 275, 4596, 12, 2973, 267, 291, 14, 3369, 275, 4668, 267, 291, 14, 885, 275, 849, 267, 291, 14, 10820, 275, 14783, 267, 291 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1331, 199, 646, 2197, 199, 646, 6107, 199, 646, 3473, 199, 646, 3598, 199, 504, 1300, 772, 492, 330, 772, 2708, 12, 330, 772, 2143, 199, 504, 7975, 492, 1565, 69, 199, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 697, 14, 992, 14, 8786, 492, 664, 63, 1238, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 8133, 4590, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1018, 492, 4967, 12, 14370, 199, 504, 1639, 14, 1208, 14, 23004, 492, 7448, 4590, 199, 504, 1639, 14, 1208, 14, 602, 1122, 492, 2198, 63, 602, 12, 2198, 63, 2083, 12, 2198, 63, 521, 199, 504, 1639, 14, 1208, 14, 15481, 492, 1094, 651, 12, 3141, 63, 7128, 199, 504, 1639, 14, 1208, 14, 1661, 5819, 492, 365, 63, 5778, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 505, 12, 3542, 63, 505, 12, 3542, 63, 2394, 199, 504, 1639, 14, 1208, 14, 4774, 22, 492, 3633, 63, 4774, 22, 63, 1562, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 533, 9630, 8, 785, 304, 272, 986, 199, 199, 533, 2845, 63, 21403, 1149, 26, 272, 986, 199, 199, 3, 710, 1338, 370, 675, 367, 298, 2500, 2, 315, 9496, 7304, 14, 12823, 506, 11544, 370, 314, 1343, 199, 3, 402, 4750, 298, 4577, 2, 5548, 14, 199, 20438, 63, 22544, 63, 29019, 275, 3842, 5151, 298, 9960, 11323, 199, 199, 318, 485, 912, 63, 698, 8, 571, 63, 1302, 12, 1402, 63, 354, 12, 901, 63, 354, 304, 272, 372, 664, 63, 1238, 8, 571, 63, 1302, 12, 1402, 63, 354, 10445, 2024, 14, 362, 63, 698, 63, 991, 63, 354, 8, 698, 63, 354, 2788, 16, 61, 199, 199, 533, 29994, 8, 1726, 304, 272, 986, 199, 199, 3, 437, 22885, 370, 5024, 2633, 26, 199, 3, 199, 3, 257, 627, 536, 26, 420, 710, 536, 402, 314, 901, 1106, 15800, 315, 314, 1402, 14, 199, 3, 257, 627, 15115, 354, 26, 257, 710, 2225, 370, 675, 641, 314, 1402, 909, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 354, 401, 871, 315, 314, 1930, 402, 481, 2692, 6340, 12, 2382, 2668, 344, 2, 365, 199, 3, 4483, 11544, 14, 199, 3, 257, 627, 1592, 63, 2301, 26, 710, 1592, 63, 2301, 2013, 315, 314, 1402, 334, 269, 488, 680, 199, 3, 257, 627, 2763, 26, 259, 710, 3050, 2763, 367, 642, 901, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 13651, 401, 871, 340, 1592, 63, 2301, 365, 2013, 14, 199, 3, 199, 3, 5495, 626, 1109, 21302, 83, 1338, 12, 503, 1630, 1163, 8336, 7645, 12, 1077, 675, 199, 3, 15115, 354, 14, 2104, 2893, 12, 642, 7545, 314, 5062, 790, 574, 402, 909, 298, 1113, 582, 199, 3, 199, 3, 258, 2519, 8, 1113, 12, 3999, 14, 2051, 14, 13651, 9, 199, 199, 318, 485, 1667, 8, 1618, 63, 1886, 304, 272, 892, 275, 9630, 342, 272, 892, 855, 533, 363, 275, 402, 63, 1886, 272, 372, 892, 199, 199, 32, 2923, 63, 7128, 199, 533, 5024, 8, 785, 304, 272, 408, 1563, 1021, 367, 1006, 901, 2943, 624, 339, 327, 29410, 2335, 3775, 2701, 3326, 27440, 14040, 1183, 787, 4370, 737, 314, 272, 327, 3050, 2166, 14, 272, 2701, 63, 5465, 63, 6541, 275, 715, 272, 2701, 63, 1459, 275, 769, 8, 11346, 14, 13993, 63, 15514, 9, 339, 327, 5723, 4426, 1924, 900, 282, 5024, 1256, 365, 2737, 14, 8051, 370, 8074, 1865, 14, 272, 327, 710, 2599, 63, 8782, 63, 5337, 365, 1202, 367, 1504, 626, 5634, 19796, 272, 327, 8491, 12, 7143, 63, 5337, 365, 1202, 367, 1006, 922, 13, 10085, 1504, 14, 272, 7143, 63, 5337, 275, 378, 272, 2599, 63, 8782, 63, 5337, 275, 446, 17, 272, 849, 63, 11346, 275, 942, 327, 3758, 663, 402, 14370, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 63, 5095, 356, 4018, 1110, 2818, 585, 9, 82, 365, 440, 282, 1686, 7141, 8038, 267, 283, 2307, 356, 4018, 2765, 901, 3913, 506, 2973, 8038, 267, 283, 2500, 356, 4018, 2765, 901, 3913, 506, 4596, 8038, 267, 283, 3235, 356, 4018, 2840, 1238, 63, 354, 9, 83, 543, 642, 2818, 698, 63, 1302, 9, 83, 283, 490, 283, 14039, 3495, 8038, 272, 789, 339, 327, 8307, 901, 730, 1369, 12, 9987, 1806, 25045, 701, 9180, 272, 347, 485, 1802, 8, 277, 304, 267, 372, 4018, 792, 402, 730, 26, 2818, 698, 63, 466, 9, 83, 358, 450, 469, 288, 283, 698, 63, 466, 356, 291, 855, 533, 4914, 354, 363, 267, 789, 272, 1369, 275, 3324, 1547, 1802, 9, 339, 347, 636, 826, 721, 277, 12, 3376, 63, 354, 29, 403, 12, 536, 29, 403, 12, 5062, 63, 498, 29, 797, 12, 288, 1390, 63, 1267, 29, 403, 12, 3747, 29, 797, 12, 4596, 29, 797, 12, 2973, 29, 797, 12, 288, 1592, 63, 1080, 29, 797, 12, 4668, 29, 403, 12, 849, 29, 4609, 63, 21403, 1149, 12, 14783, 29, 549, 12, 288, 8437, 29, 549, 12, 3747, 63, 509, 63, 602, 29, 403, 12, 3747, 63, 509, 63, 4482, 29, 403, 12, 288, 3747, 63, 509, 63, 3403, 29, 403, 12, 3415, 29, 403, 12, 1720, 63, 505, 4581, 1592, 63, 2301, 29, 403, 12, 288, 1592, 63, 26730, 29, 403, 12, 2599, 63, 3966, 29, 797, 12, 14370, 6034, 288, 1125, 63, 3431, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 3832, 63, 354, 275, 3376, 63, 354, 267, 291, 14, 3327, 63, 498, 275, 5062, 63, 498, 267, 291, 14, 988, 63, 1267, 12, 291, 423, 3235, 275, 1390, 63, 1267, 12, 3747, 267, 291, 14, 2500, 12, 291, 14, 2307, 275, 4596, 12, 2973, 267, 291, 14, 3369, 275, 4668, 267, 291, 14, 885, 275, 849, 267, 291, 14, 10820, 275, 14783, 267, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
JukeboxPipeline/jukebox-core
src/jukeboxcore/addons/guerilla/guerillamgmt.py
1
82524
from PySide import QtGui from jukeboxcore.log import get_logger log = get_logger(__name__) from jukeboxcore import ostool from jukeboxcore import djadapter from jukeboxcore.gui.main import JB_MainWindow, JB_Dialog, dt_to_qdatetime from jukeboxcore.gui import treemodel from jukeboxcore.gui import djitemdata from jukeboxcore.plugins import JB_CoreStandaloneGuiPlugin from jukeboxcore.gui.widgets.guerillamgmt_ui import Ui_guerillamgmt_mwin from jukeboxcore.gui.widgets.guerilla.projectcreator_ui import Ui_projectcreator_dialog from jukeboxcore.gui.widgets.guerilla.prjadder_ui import Ui_prjadder_dialog from jukeboxcore.gui.widgets.guerilla.seqcreator_ui import Ui_seqcreator_dialog from jukeboxcore.gui.widgets.guerilla.atypecreator_ui import Ui_atypecreator_dialog from jukeboxcore.gui.widgets.guerilla.atypeadder_ui import Ui_atypeadder_dialog from jukeboxcore.gui.widgets.guerilla.depcreator_ui import Ui_depcreator_dialog from jukeboxcore.gui.widgets.guerilla.depadder_ui import Ui_depadder_dialog from jukeboxcore.gui.widgets.guerilla.usercreator_ui import Ui_usercreator_dialog from jukeboxcore.gui.widgets.guerilla.useradder_ui import Ui_useradder_dialog from jukeboxcore.gui.widgets.guerilla.shotcreator_ui import Ui_shotcreator_dialog from jukeboxcore.gui.widgets.guerilla.assetcreator_ui import Ui_assetcreator_dialog from jukeboxcore.gui.widgets.guerilla.assetadder_ui import Ui_assetadder_dialog from jukeboxcore.gui.widgets.guerilla.taskcreator_ui import Ui_taskcreator_dialog class ProjectCreatorDialog(JB_Dialog, Ui_projectcreator_dialog): """A Dialog to create a project """ def __init__(self, parent=None, flags=0): """Initialize a new project creator dialog :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(ProjectCreatorDialog, self).__init__(parent, flags) self.project = None self.setupUi(self) self.create_pb.clicked.connect(self.create_prj) def create_prj(self, ): """Create a project and store it in the self.project :returns: None :rtype: None :raises: None """ name = self.name_le.text() short = self.short_le.text() path = self.path_le.text() semester = self.semester_le.text() try: prj = djadapter.models.Project(name=name, short=short, path=path, semester=semester) prj.save() self.project = prj self.accept() except: log.exception("Could not create new project") class ProjectAdderDialog(JB_Dialog, Ui_prjadder_dialog): """A Dialog to add project to a project """ def __init__(self, atype=None, department=None, user=None, parent=None, flags=0): """Initialize a new project creator dialog :param atype: the atype to add the project to :type atype: :class:`djadapter.models.Atype` :param department: the department to add the project to :type department: :class:`djadapter.models.Department` :param parent: the parent object :param user: the user to tadd the project to :type user: :class:`djadapter.models.User` :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(ProjectAdderDialog, self).__init__(parent, flags) self._atype = atype self._dep = department self._user = user self.projects = [] self.setupUi(self) self.add_pb.clicked.connect(self.add_project) rootdata = treemodel.ListItemData(["Name", "Description"]) rootitem = treemodel.TreeItem(rootdata) if atype: projects = djadapter.projects.exclude(pk__in = atype.projects.all()) elif department: projects = djadapter.projects.exclude(pk__in = department.projects.all()) else: projects = djadapter.projects.exclude(users=user) for project in projects: projectdata = djitemdata.ProjectItemData(project) treemodel.TreeItem(projectdata, rootitem) self.model = treemodel.TreeModel(rootitem) self.prj_tablev.setModel(self.model) def add_project(self, ): """Add a project and store it in the self.projects :returns: None :rtype: None :raises: None """ i = self.prj_tablev.currentIndex() item = i.internalPointer() if item: project = item.internal_data() if self._atype: self._atype.projects.add(project) elif self._dep: self._dep.projects.add(project) else: project.users.add(self._user) self.projects.append(project) item.set_parent(None) class SequenceCreatorDialog(JB_Dialog, Ui_seqcreator_dialog): """A Dialog to create a sequence """ def __init__(self, project, parent=None, flags=0): """Initialize a new sequence creator dialog :param project: The project for the sequence :type project: :class:`jukeboxcore.djadapter.models.Project` :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(SequenceCreatorDialog, self).__init__(parent, flags) self._project = project self.sequence = None self.setupUi(self) self.create_pb.clicked.connect(self.create_seq) def create_seq(self, ): """Create a sequence and store it in the self.sequence :returns: None :rtype: None :raises: None """ name = self.name_le.text() desc = self.desc_pte.toPlainText() try: seq = djadapter.models.Sequence(name=name, project=self._project, description=desc) seq.save() self.sequence = seq self.accept() except: log.exception("Could not create new sequence") class AtypeCreatorDialog(JB_Dialog, Ui_atypecreator_dialog): """A Dialog to create a atype """ def __init__(self, projects=None, parent=None, flags=0): """Initialize a new atype creator dialog :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(AtypeCreatorDialog, self).__init__(parent, flags) self.projects = projects or [] self.atype = None self.setupUi(self) self.create_pb.clicked.connect(self.create_atype) def create_atype(self, ): """Create a atype and store it in the self.atype :returns: None :rtype: None :raises: None """ name = self.name_le.text() desc = self.desc_pte.toPlainText() try: atype = djadapter.models.Atype(name=name, description=desc) atype.save() for prj in self.projects: atype.projects.add(prj) self.atype = atype self.accept() except: log.exception("Could not create new assettype") class AtypeAdderDialog(JB_Dialog, Ui_atypeadder_dialog): """A Dialog to add atype to a project """ def __init__(self, project, parent=None, flags=0): """Initialize a new atype creator dialog :param project: The project for the atypes :type project: :class:`jukeboxcore.djadapter.models.Project` :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(AtypeAdderDialog, self).__init__(parent, flags) self._project = project self.atypes = [] self.setupUi(self) self.add_pb.clicked.connect(self.add_atype) rootdata = treemodel.ListItemData(["Name", "Description"]) rootitem = treemodel.TreeItem(rootdata) atypes = djadapter.atypes.exclude(projects=project) for atype in atypes: atypedata = djitemdata.AtypeItemData(atype) treemodel.TreeItem(atypedata, rootitem) self.model = treemodel.TreeModel(rootitem) self.atype_tablev.setModel(self.model) def add_atype(self, ): """Add a atype and store it in the self.atypes :returns: None :rtype: None :raises: None """ i = self.atype_tablev.currentIndex() item = i.internalPointer() if item: atype = item.internal_data() atype.projects.add(self._project) self.atypes.append(atype) item.set_parent(None) class DepCreatorDialog(JB_Dialog, Ui_depcreator_dialog): """A Dialog to create a dep """ def __init__(self, projects=None, parent=None, flags=0): """Initialize a new dep creator dialog :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(DepCreatorDialog, self).__init__(parent, flags) self.projects = projects or [] self.dep = None self.setupUi(self) self.create_pb.clicked.connect(self.create_dep) def create_dep(self, ): """Create a dep and store it in the self.dep :returns: None :rtype: None :raises: None """ name = self.name_le.text() short = self.short_le.text() assetflag = self.asset_rb.isChecked() ordervalue = self.ordervalue_sb.value() desc = self.desc_pte.toPlainText() try: dep = djadapter.models.Department(name=name, short=short, assetflag=assetflag, ordervalue=ordervalue, description=desc) dep.save() for prj in self.projects: dep.projects.add(prj) self.dep = dep self.accept() except: log.exception("Could not create new department.") class DepAdderDialog(JB_Dialog, Ui_depadder_dialog): """A Dialog to add departments to a project """ def __init__(self, project, parent=None, flags=0): """Initialize a new dep creator dialog :param project: The project for the deps :type project: :class:`jukeboxcore.djadapter.models.Project` :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(DepAdderDialog, self).__init__(parent, flags) self._project = project self.deps = [] self.setupUi(self) self.add_pb.clicked.connect(self.add_dep) rootdata = treemodel.ListItemData(["Name", "Description", "Ordervalue"]) rootitem = treemodel.TreeItem(rootdata) deps = djadapter.departments.exclude(projects=project) for dep in deps: depdata = djitemdata.DepartmentItemData(dep) treemodel.TreeItem(depdata, rootitem) self.model = treemodel.TreeModel(rootitem) self.dep_tablev.setModel(self.model) def add_dep(self, ): """Add a dep and store it in the self.deps :returns: None :rtype: None :raises: None """ i = self.dep_tablev.currentIndex() item = i.internalPointer() if item: dep = item.internal_data() dep.projects.add(self._project) self.deps.append(dep) item.set_parent(None) class UserCreatorDialog(JB_Dialog, Ui_usercreator_dialog): """A Dialog to create a user """ def __init__(self, projects=None, tasks=None, parent=None, flags=0): """Initialize a new user creator dialog :param projects: The projects for the user :type projects: list of :class:`jukeboxcore.djadapter.models.Project` :param tasks: The tasks for the user :type tasks: list of :class:`jukeboxcore.djadapter.models.Task` :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(UserCreatorDialog, self).__init__(parent, flags) self.projects = projects or [] self.tasks = tasks or [] self.user = None self.setupUi(self) self.create_pb.clicked.connect(self.create_user) def create_user(self, ): """Create a user and store it in the self.user :returns: None :rtype: None :raises: None """ name = self.username_le.text() if not name: self.username_le.setPlaceholderText("Please provide a username.") return first = self.first_le.text() last = self.last_le.text() email = self.email_le.text() try: user = djadapter.models.User(username=name, first_name=first, last_name=last, email=email) user.save() for prj in self.projects: prj.users.add(user) for task in self.tasks: task.users.add(user) self.user = user self.accept() except: log.exception("Could not create new assettype") class UserAdderDialog(JB_Dialog, Ui_useradder_dialog): """A Dialog to add user to a project """ def __init__(self, project=None, task=None, parent=None, flags=0): """Initialize a new user creator dialog :param project: The project for the users :type project: :class:`jukeboxcore.djadapter.models.Project` :param task: The task for the users :type task: :class:`jukeboxcore.djadapter.models.Task` :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(UserAdderDialog, self).__init__(parent, flags) self._project = project self._task = task self.users = [] self.setupUi(self) self.add_pb.clicked.connect(self.add_user) rootdata = treemodel.ListItemData(["Name", "Description"]) rootitem = treemodel.TreeItem(rootdata) if project: users = djadapter.users.exclude(project = project) else: users = djadapter.users.exclude(task = task) for user in users: userdata = djitemdata.UserItemData(user) treemodel.TreeItem(userdata, rootitem) self.model = treemodel.TreeModel(rootitem) self.user_tablev.setModel(self.model) def add_user(self, ): """Add a user and store it in the self.users :returns: None :rtype: None :raises: None """ i = self.user_tablev.currentIndex() item = i.internalPointer() if item: user = item.internal_data() if self._project: self._project.users.add(user) else: self._task.users.add(user) self.users.append(user) item.set_parent(None) class ShotCreatorDialog(JB_Dialog, Ui_shotcreator_dialog): """A Dialog to create a shot """ def __init__(self, sequence, parent=None, flags=0): """Initialize a new shot creator dialog :param sequence: the sequence for the shot :type sequence: :class:`jukeboxcore.djadapter.models.Shot` :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(ShotCreatorDialog, self).__init__(parent, flags) self.sequence = sequence self.shot = None self.setupUi(self) self.create_pb.clicked.connect(self.create_shot) def create_shot(self, ): """Create a shot and store it in the self.shot :returns: None :rtype: None :raises: None """ name = self.name_le.text() if not name: self.name_le.setPlaceholderText("Please enter a name!") return desc = self.desc_pte.toPlainText() try: shot = djadapter.models.Shot(sequence=self.sequence, project=self.sequence.project, name=name, description=desc) shot.save() self.shot = shot self.accept() except: log.exception("Could not create new shot") class AssetCreatorDialog(JB_Dialog, Ui_assetcreator_dialog): """A Dialog to create a asset """ def __init__(self, project, atype=None, parent=None, flags=0): """Initialize a new asset creator dialog :param project: the project of the asset :type project: :class:`jukeboxcore.djadapter.models.Project` :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(AssetCreatorDialog, self).__init__(parent, flags) self.project = project self.atype = atype self.asset = None self.setupUi(self) if not self.atype: self.atypes = list(project.atype_set.all()) atrootdata = treemodel.ListItemData(["Name"]) atrootitem = treemodel.TreeItem(atrootdata) for at in self.atypes: data = djitemdata.AtypeItemData(at) treemodel.TreeItem(data, atrootitem) self.atypemodel = treemodel.TreeModel(atrootitem) self.atype_cb.setModel(self.atypemodel) else: self.atype_cb.setVisible(False) self.atype_lb.setVisible(False) self.create_pb.clicked.connect(self.create_asset) def create_asset(self, ): """Create a asset and store it in the self.asset :returns: None :rtype: None :raises: None """ name = self.name_le.text() if not name: self.name_le.setPlaceholderText("Please enter a name!") return desc = self.desc_pte.toPlainText() if not self.atype: atypei = self.atype_cb.currentIndex() assert atypei >= 0 self.atype = self.atypes[atypei] try: asset = djadapter.models.Asset(atype=self.atype, project=self.project, name=name, description=desc) asset.save() self.asset = asset self.accept() except: log.exception("Could not create new asset") class AssetAdderDialog(JB_Dialog, Ui_assetadder_dialog): """A Dialog to add asset to a project """ def __init__(self, shot=None, asset=None, parent=None, flags=0): """Initialize a new asset creator dialog :param shot: The shot for the assets :type shot: :class:`jukeboxcore.djadapter.models.Shot` :param asset: The asset for the assets :type asset: :class:`jukeboxcore.djadapter.models.Asset` :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(AssetAdderDialog, self).__init__(parent, flags) self._shot = shot self._asset = asset self.assets = [] self.setupUi(self) self.add_pb.clicked.connect(self.add_asset) rootdata = treemodel.ListItemData(["Name"]) rootitem = treemodel.TreeItem(rootdata) self.model = treemodel.TreeModel(rootitem) self.asset_treev.setModel(self.model) atypes = {} if shot: assets = djadapter.assets.exclude(pk__in = shot.assets.all()).filter(project=shot.project) else: assets = djadapter.assets.exclude(pk__in = asset.assets.all()).filter(project=asset.project) for asset in assets: atype = asset.atype atypeitem = atypes.get(atype) if not atypeitem: atypedata = djitemdata.AtypeItemData(atype) atypeitem = treemodel.TreeItem(atypedata, rootitem) atypes[atype] = atypeitem assetdata = djitemdata.AssetItemData(asset) treemodel.TreeItem(assetdata, atypeitem) def add_asset(self, ): """Add a asset and store it in the self.assets :returns: None :rtype: None :raises: None """ i = self.asset_treev.currentIndex() item = i.internalPointer() if item: asset = item.internal_data() if not isinstance(asset, djadapter.models.Asset): return if self._shot: self._shot.assets.add(asset) else: self._asset.assets.add(asset) self.assets.append(asset) item.set_parent(None) class TaskCreatorDialog(JB_Dialog, Ui_taskcreator_dialog): """A Dialog to create a task """ def __init__(self, element, parent=None, flags=0): """Initialize a new task creator dialog :param element: the element for the task :type element: :class:`jukeboxcore.djadapter.models.Asset` | :class:`jukeboxcore.djadapter.models.Shot` :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(TaskCreatorDialog, self).__init__(parent, flags) self.element = element self.task = None self.setupUi(self) self.create_pb.clicked.connect(self.create_task) qs = djadapter.departments.filter(projects=element.project).exclude(pk__in = element.tasks.all().values_list('department', flat=True)) qs = qs.filter(assetflag=isinstance(element, djadapter.models.Asset)) self.deps = list(qs) atrootdata = treemodel.ListItemData(["Name"]) atrootitem = treemodel.TreeItem(atrootdata) for dep in self.deps: data = djitemdata.DepartmentItemData(dep) treemodel.TreeItem(data, atrootitem) self.model = treemodel.TreeModel(atrootitem) self.dep_cb.setModel(self.model) def create_task(self, ): """Create a task and store it in the self.task :returns: None :rtype: None :raises: None """ depi = self.dep_cb.currentIndex() assert depi >= 0 dep = self.deps[depi] deadline = self.deadline_de.dateTime().toPython() try: task = djadapter.models.Task(department=dep, project=self.element.project, element=self.element, deadline=deadline) task.save() self.task = task self.accept() except: log.exception("Could not create new task") class GuerillaMGMTWin(JB_MainWindow, Ui_guerillamgmt_mwin): """A tool for creating entries in the database and a little project management. """ def __init__(self, parent=None, flags=0): """Initialize a new GuerillaMGMTwin :param parent: the parent object :type parent: :class:`QtCore.QObject` :param flags: the window flags :type flags: :data:`QtCore.Qt.WindowFlags` :raises: None """ super(GuerillaMGMTWin, self).__init__(parent, flags) self.cur_prj = None self.cur_seq = None self.cur_shot = None self.cur_atype = None self.cur_asset = None self.cur_dep = None self.cur_task = None self.cur_user = None self.setupUi(self) self.setup_ui() try: self.setup_signals() except: log.exception("Exception setting up signals") def setup_ui(self, ): """Create all necessary ui elements for the tool :returns: None :rtype: None :raises: None """ log.debug("Setting up the ui") self.setup_prjs_page() self.setup_prj_page() self.setup_seq_page() self.setup_shot_page() self.setup_atype_page() self.setup_asset_page() self.setup_dep_page() self.setup_task_page() self.setup_users_page() self.setup_user_page() def setup_prjs_page(self, ): """Create and set the model on the projects page :returns: None :rtype: None :raises: None """ self.prjs_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) log.debug("Loading projects for projects page.") rootdata = treemodel.ListItemData(['Name', 'Short', 'Path', 'Created', 'Semester', 'Status', 'Resolution', 'FPS', 'Scale']) rootitem = treemodel.TreeItem(rootdata) prjs = djadapter.projects.all() for prj in prjs: prjdata = djitemdata.ProjectItemData(prj) treemodel.TreeItem(prjdata, rootitem) self.prjs_model = treemodel.TreeModel(rootitem) self.prjs_tablev.setModel(self.prjs_model) def setup_prj_page(self, ): """Create and set the model on the project page :returns: None :rtype: None :raises: None """ self.prj_seq_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) self.prj_atype_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) self.prj_dep_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) self.prj_user_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) def setup_seq_page(self, ): """Create and set the model on the sequence page :returns: None :rtype: None :raises: None """ self.seq_shot_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) def setup_shot_page(self, ): """Create and set the model on the shot page :returns: None :rtype: None :raises: None """ self.shot_asset_treev.header().setResizeMode(QtGui.QHeaderView.ResizeToContents) self.shot_task_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) def setup_atype_page(self, ): """Create and set the model on the atype page :returns: None :rtype: None :raises: None """ pass def setup_asset_page(self, ): """Create and set the model on the asset page :returns: None :rtype: None :raises: None """ self.asset_asset_treev.header().setResizeMode(QtGui.QHeaderView.ResizeToContents) self.asset_task_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) def setup_dep_page(self, ): """Create and set the model on the department page :returns: None :rtype: None :raises: None """ self.dep_prj_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) def setup_task_page(self, ): """Create and set the model on the task page :returns: None :rtype: None :raises: None """ self.task_user_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) def setup_users_page(self, ): """Create and set the model on the users page :returns: None :rtype: None :raises: None """ self.users_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) log.debug("Loading users for users page.") rootdata = treemodel.ListItemData(['Username', 'First', 'Last', 'Email']) rootitem = treemodel.TreeItem(rootdata) users = djadapter.users.all() for usr in users: usrdata = djitemdata.UserItemData(usr) treemodel.TreeItem(usrdata, rootitem) self.users_model = treemodel.TreeModel(rootitem) self.users_tablev.setModel(self.users_model) def setup_user_page(self, ): """Create and set the model on the user page :returns: None :rtype: None :raises: None """ self.user_prj_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) self.user_task_treev.header().setResizeMode(QtGui.QHeaderView.ResizeToContents) def setup_signals(self, ): """Connect the signals with the slots to make the ui functional :returns: None :rtype: None :raises: None """ log.debug("Setting up signals.") self.setup_prjs_signals() self.setup_prj_signals() self.setup_seq_signals() self.setup_shot_signals() self.setup_atype_signals() self.setup_asset_signals() self.setup_dep_signals() self.setup_task_signals() self.setup_users_signals() self.setup_user_signals() log.debug("Signals are set up.") def setup_prjs_signals(self, ): """Setup the signals for the projects page :returns: None :rtype: None :raises: None """ log.debug("Setting up projects page signals.") self.prjs_prj_view_pb.clicked.connect(self.prjs_view_prj) self.prjs_prj_create_pb.clicked.connect(self.prjs_create_prj) def setup_prj_signals(self, ): """Setup the signals for the project page :returns: None :rtype: None :raises: None """ log.debug("Setting up project page signals.") self.prj_seq_view_pb.clicked.connect(self.prj_view_seq) self.prj_seq_create_pb.clicked.connect(self.prj_create_seq) self.prj_atype_view_pb.clicked.connect(self.prj_view_atype) self.prj_atype_add_pb.clicked.connect(self.prj_add_atype) self.prj_atype_create_pb.clicked.connect(self.prj_create_atype) self.prj_dep_view_pb.clicked.connect(self.prj_view_dep) self.prj_dep_add_pb.clicked.connect(self.prj_add_dep) self.prj_dep_create_pb.clicked.connect(self.prj_create_dep) self.prj_user_view_pb.clicked.connect(self.prj_view_user) self.prj_user_add_pb.clicked.connect(self.prj_add_user) self.prj_user_remove_pb.clicked.connect(self.prj_remove_user) self.prj_user_create_pb.clicked.connect(self.prj_create_user) self.prj_path_view_pb.clicked.connect(self.prj_show_path) self.prj_desc_pte.textChanged.connect(self.prj_save) self.prj_semester_le.editingFinished.connect(self.prj_save) self.prj_fps_dsb.valueChanged.connect(self.prj_save) self.prj_res_x_sb.valueChanged.connect(self.prj_save) self.prj_res_y_sb.valueChanged.connect(self.prj_save) self.prj_scale_cb.currentIndexChanged.connect(self.prj_save) def setup_seq_signals(self, ): """Setup the signals for the sequence page :returns: None :rtype: None :raises: None """ log.debug("Setting up sequence page signals.") self.seq_prj_view_pb.clicked.connect(self.seq_view_prj) self.seq_shot_view_pb.clicked.connect(self.seq_view_shot) self.seq_shot_create_pb.clicked.connect(self.seq_create_shot) self.seq_desc_pte.textChanged.connect(self.seq_save) def setup_shot_signals(self, ): """Setup the signals for the shot page :returns: None :rtype: None :raises: None """ log.debug("Setting up shot page signals.") self.shot_prj_view_pb.clicked.connect(self.shot_view_prj) self.shot_seq_view_pb.clicked.connect(self.shot_view_seq) self.shot_asset_view_pb.clicked.connect(self.shot_view_asset) self.shot_asset_create_pb.clicked.connect(self.shot_create_asset) self.shot_asset_add_pb.clicked.connect(self.shot_add_asset) self.shot_asset_remove_pb.clicked.connect(self.shot_remove_asset) self.shot_task_view_pb.clicked.connect(self.shot_view_task) self.shot_task_create_pb.clicked.connect(self.shot_create_task) self.shot_start_sb.valueChanged.connect(self.shot_save) self.shot_end_sb.valueChanged.connect(self.shot_save) self.shot_handle_sb.valueChanged.connect(self.shot_save) self.shot_desc_pte.textChanged.connect(self.shot_save) def setup_atype_signals(self, ): """Setup the signals for the assettype page :returns: None :rtype: None :raises: None """ log.debug("Setting up atype page signals.") self.asset_prj_view_pb.clicked.connect(self.asset_view_prj) self.asset_atype_view_pb.clicked.connect(self.asset_view_atype) self.atype_asset_view_pb.clicked.connect(self.atype_view_asset) self.atype_asset_create_pb.clicked.connect(self.atype_create_asset) self.atype_desc_pte.textChanged.connect(self.atype_save) def setup_asset_signals(self, ): """Setup the signals for the asset page :returns: None :rtype: None :raises: None """ log.debug("Setting up asset signals.") self.asset_asset_view_pb.clicked.connect(self.asset_view_asset) self.asset_asset_create_pb.clicked.connect(self.asset_create_asset) self.asset_asset_add_pb.clicked.connect(self.asset_add_asset) self.asset_asset_remove_pb.clicked.connect(self.asset_remove_asset) self.asset_task_view_pb.clicked.connect(self.asset_view_task) self.asset_task_create_pb.clicked.connect(self.asset_create_task) self.asset_desc_pte.textChanged.connect(self.asset_save) def setup_dep_signals(self, ): """Setup the signals for the department page :returns: None :rtype: None :raises: None """ log.debug("Setting up department page signals.") self.dep_prj_view_pb.clicked.connect(self.dep_view_prj) self.dep_prj_add_pb.clicked.connect(self.dep_add_prj) self.dep_prj_remove_pb.clicked.connect(self.dep_remove_prj) self.dep_desc_pte.textChanged.connect(self.dep_save) self.dep_ordervalue_sb.valueChanged.connect(self.dep_save) def setup_task_signals(self, ): """Setup the signals for the task page :returns: None :rtype: None :raises: None """ log.debug("Setting up task page signals.") self.task_user_view_pb.clicked.connect(self.task_view_user) self.task_user_add_pb.clicked.connect(self.task_add_user) self.task_user_remove_pb.clicked.connect(self.task_remove_user) self.task_dep_view_pb.clicked.connect(self.task_view_dep) self.task_link_view_pb.clicked.connect(self.task_view_link) self.task_deadline_de.dateChanged.connect(self.task_save) self.task_status_cb.currentIndexChanged.connect(self.task_save) def setup_users_signals(self, ): """Setup the signals for the users page :returns: None :rtype: None :raises: None """ log.debug("Setting up users page signals.") self.users_user_view_pb.clicked.connect(self.users_view_user) self.users_user_create_pb.clicked.connect(self.create_user) def setup_user_signals(self, ): """Setup the signals for the user page :returns: None :rtype: None :raises: None """ log.debug("Setting up user page signals.") self.user_task_view_pb.clicked.connect(self.user_view_task) self.user_prj_view_pb.clicked.connect(self.user_view_prj) self.user_prj_add_pb.clicked.connect(self.user_add_prj) self.user_prj_remove_pb.clicked.connect(self.user_remove_prj) self.user_username_le.editingFinished.connect(self.user_save) self.user_first_le.editingFinished.connect(self.user_save) self.user_last_le.editingFinished.connect(self.user_save) self.user_email_le.editingFinished.connect(self.user_save) def prjs_view_prj(self, *args, **kwargs): """View the, in the projects table view selected, project. :returns: None :rtype: None :raises: None """ i = self.prjs_tablev.currentIndex() item = i.internalPointer() if item: prj = item.internal_data() self.view_prj(prj) def prjs_create_prj(self, *args, **kwargs): """Create a new project :returns: None :rtype: None :raises: None """ self.create_prj() def view_prj(self, prj): """View the given project on the project page :param prj: the project to view :type prj: :class:`jukeboxcore.djadapter.models.Project` :returns: None :rtype: None :raises: None """ log.debug('Viewing project %s', prj.name) self.cur_prj = None self.pages_tabw.setCurrentIndex(1) self.prj_name_le.setText(prj.name) self.prj_short_le.setText(prj.short) self.prj_path_le.setText(prj.path) self.prj_desc_pte.setPlainText(prj.description) self.prj_created_dte.setDateTime(dt_to_qdatetime(prj.date_created)) self.prj_semester_le.setText(prj.semester) self.prj_fps_dsb.setValue(prj.framerate) self.prj_res_x_sb.setValue(prj.resx) self.prj_res_y_sb.setValue(prj.resy) scalemap = {"m": 2, "meter": 2, "mm": 0, "millimeter": 0, "cm": 1, "centimeter": 1, "km": 3, "kilometer": 3, "inch": 4, "foot": 5, "yard": 6, "mile": 7} scaleindex = scalemap.get(prj.scale, -1) log.debug("Setting index of project scale combobox to %s. Scale is %s", scaleindex, prj.scale) self.prj_scale_cb.setCurrentIndex(scaleindex) seqrootdata = treemodel.ListItemData(['Name', "Description"]) seqrootitem = treemodel.TreeItem(seqrootdata) for seq in prj.sequence_set.all(): seqdata = djitemdata.SequenceItemData(seq) treemodel.TreeItem(seqdata, seqrootitem) self.prj_seq_model = treemodel.TreeModel(seqrootitem) self.prj_seq_tablev.setModel(self.prj_seq_model) atyperootdata = treemodel.ListItemData(['Name', "Description"]) atyperootitem = treemodel.TreeItem(atyperootdata) for atype in prj.atype_set.all(): atypedata = djitemdata.AtypeItemData(atype) treemodel.TreeItem(atypedata, atyperootitem) self.prj_atype_model = treemodel.TreeModel(atyperootitem) self.prj_atype_tablev.setModel(self.prj_atype_model) deprootdata = treemodel.ListItemData(['Name', "Description", "Ordervalue"]) deprootitem = treemodel.TreeItem(deprootdata) for dep in prj.department_set.all(): depdata = djitemdata.DepartmentItemData(dep) treemodel.TreeItem(depdata, deprootitem) self.prj_dep_model = treemodel.TreeModel(deprootitem) self.prj_dep_tablev.setModel(self.prj_dep_model) userrootdata = treemodel.ListItemData(['Username', 'First', 'Last', 'Email']) userrootitem = treemodel.TreeItem(userrootdata) for user in prj.users.all(): userdata = djitemdata.UserItemData(user) treemodel.TreeItem(userdata, userrootitem) self.prj_user_model = treemodel.TreeModel(userrootitem) self.prj_user_tablev.setModel(self.prj_user_model) self.cur_prj = prj def create_prj(self, atypes=None, deps=None): """Create and return a new project :param atypes: add the given atypes to the project :type atypes: list | None :param deps: add the given departmetns to the project :type deps: list | None :returns: The created project or None :rtype: None | :class:`jukeboxcore.djadapter.models.Project` :raises: None """ dialog = ProjectCreatorDialog(parent=self) dialog.exec_() prj = dialog.project if prj and atypes: for at in atypes: at.projects.add(prj) at.save() if prj and deps: for dep in deps: dep.projects.add(prj) dep.save() if prj: prjdata = djitemdata.ProjectItemData(prj) treemodel.TreeItem(prjdata, self.prjs_model.root) return prj def prj_view_seq(self, *args, **kwargs): """View the, in the prj_seq_tablev selected, sequence. :returns: None :rtype: None :raises: None """ if not self.cur_prj: return i = self.prj_seq_tablev.currentIndex() item = i.internalPointer() if item: seq = item.internal_data() self.view_seq(seq) def prj_create_seq(self, *args, **kwargs): """Create a new Sequence for the current project :returns: None :rtype: None :raises: None """ if not self.cur_prj: return seq = self.create_seq(project=self.cur_prj) if seq: seqdata = djitemdata.SequenceItemData(seq) treemodel.TreeItem(seqdata, self.prj_seq_model.root) def view_seq(self, seq): """View the given sequence on the sequence page :param seq: the sequence to view :type seq: :class:`jukeboxcore.djadapter.models.Sequence` :returns: None :rtype: None :raises: None """ log.debug('Viewing sequence %s', seq.name) self.cur_seq = None self.pages_tabw.setCurrentIndex(2) self.seq_name_le.setText(seq.name) self.seq_prj_le.setText(seq.project.name) self.seq_desc_pte.setPlainText(seq.description) shotrootdata = treemodel.ListItemData(['Name', "Description", "Duration", "Start", "End"]) shotrootitem = treemodel.TreeItem(shotrootdata) for shot in seq.shot_set.all(): shotdata = djitemdata.ShotItemData(shot) treemodel.TreeItem(shotdata, shotrootitem) self.seq_shot_model = treemodel.TreeModel(shotrootitem) self.seq_shot_tablev.setModel(self.seq_shot_model) self.cur_seq = seq def create_seq(self, project): """Create and return a new sequence :param project: the project for the sequence :type deps: :class:`jukeboxcore.djadapter.models.Project` :returns: The created sequence or None :rtype: None | :class:`jukeboxcore.djadapter.models.Sequence` :raises: None """ dialog = SequenceCreatorDialog(project=project, parent=self) dialog.exec_() seq = dialog.sequence return seq def prj_view_atype(self, *args, **kwargs): """View the, in the atype table view selected, assettype. :returns: None :rtype: None :raises: None """ if not self.cur_prj: return i = self.prj_atype_tablev.currentIndex() item = i.internalPointer() if item: atype = item.internal_data() self.view_atype(atype) def prj_add_atype(self, *args, **kwargs): """Add more assettypes to the project. :returns: None :rtype: None :raises: None """ if not self.cur_prj: return dialog = AtypeAdderDialog(project=self.cur_prj) dialog.exec_() atypes = dialog.atypes for atype in atypes: atypedata = djitemdata.AtypeItemData(atype) treemodel.TreeItem(atypedata, self.prj_atype_model.root) def prj_create_atype(self, *args, **kwargs): """Create a new project :returns: None :rtype: None :raises: None """ if not self.cur_prj: return atype = self.create_atype(projects=[self.cur_prj]) if atype: atypedata = djitemdata.AtypeItemData(atype) treemodel.TreeItem(atypedata, self.prj_atype_model.root) def create_atype(self, projects): """Create and return a new atype :param projects: the projects for the atype :type projects: :class:`jukeboxcore.djadapter.models.Project` :returns: The created atype or None :rtype: None | :class:`jukeboxcore.djadapter.models.Atype` :raises: None """ dialog = AtypeCreatorDialog(projects=projects, parent=self) dialog.exec_() atype = dialog.atype return atype def view_atype(self, atype): """View the given atype on the atype page :param atype: the atype to view :type atype: :class:`jukeboxcore.djadapter.models.Atype` :returns: None :rtype: None :raises: None """ if not self.cur_prj: return log.debug('Viewing atype %s', atype.name) self.cur_atype = None self.pages_tabw.setCurrentIndex(4) self.atype_name_le.setText(atype.name) self.atype_desc_pte.setPlainText(atype.description) assetrootdata = treemodel.ListItemData(['Name', 'Description']) assetrootitem = treemodel.TreeItem(assetrootdata) self.atype_asset_model = treemodel.TreeModel(assetrootitem) self.atype_asset_treev.setModel(self.atype_asset_model) for a in djadapter.assets.filter(project=self.cur_prj, atype=atype): assetdata = djitemdata.AssetItemData(a) treemodel.TreeItem(assetdata, assetrootitem) self.cur_atype = atype def prj_view_dep(self, *args, **kwargs): """View the, in the dep table view selected, department. :returns: None :rtype: None :raises: None """ if not self.cur_prj: return i = self.prj_dep_tablev.currentIndex() item = i.internalPointer() if item: dep = item.internal_data() self.view_dep(dep) def prj_add_dep(self, *args, **kwargs): """Add more departments to the project. :returns: None :rtype: None :raises: None """ if not self.cur_prj: return dialog = DepAdderDialog(project=self.cur_prj) dialog.exec_() deps = dialog.deps for dep in deps: depdata = djitemdata.DepartmentItemData(dep) treemodel.TreeItem(depdata, self.prj_dep_model.root) def prj_create_dep(self, *args, **kwargs): """Create a new project :returns: None :rtype: None :raises: None """ if not self.cur_prj: return dep = self.create_dep(projects=[self.cur_prj]) if dep: depdata = djitemdata.DepartmentItemData(dep) treemodel.TreeItem(depdata, self.prj_dep_model.root) def create_dep(self, projects): """Create and return a new dep :param projects: the projects for the dep :type projects: :class:`jukeboxcore.djadapter.models.Project` :returns: The created dep or None :rtype: None | :class:`jukeboxcore.djadapter.models.Dep` :raises: None """ dialog = DepCreatorDialog(projects=projects, parent=self) dialog.exec_() dep = dialog.dep return dep def view_dep(self, dep): """View the given department on the department page :param dep: the dep to view :type dep: :class:`jukeboxcore.djadapter.models.Department` :returns: None :rtype: None :raises: None """ log.debug('Viewing department %s', dep.name) self.cur_dep = None self.pages_tabw.setCurrentIndex(6) self.dep_name_le.setText(dep.name) self.dep_short_le.setText(dep.short) self.dep_shot_rb.setChecked(not dep.assetflag) self.dep_asset_rb.setChecked(dep.assetflag) self.dep_ordervalue_sb.setValue(dep.ordervalue) self.dep_desc_pte.setPlainText(dep.description) rootdata = treemodel.ListItemData(['Name', 'Short', 'Path', 'Created', 'Semester', 'Status', 'Resolution', 'FPS', 'Scale']) rootitem = treemodel.TreeItem(rootdata) prjs = dep.projects.all() for prj in prjs: prjdata = djitemdata.ProjectItemData(prj) treemodel.TreeItem(prjdata, rootitem) self.dep_prj_model = treemodel.TreeModel(rootitem) self.dep_prj_tablev.setModel(self.dep_prj_model) self.cur_dep = dep def prj_view_user(self, *args, **kwargs): """View the, in the user table view selected, user. :returns: None :rtype: None :raises: None """ if not self.cur_prj: return i = self.prj_user_tablev.currentIndex() item = i.internalPointer() if item: user = item.internal_data() self.view_user(user) def prj_add_user(self, *args, **kwargs): """Add more users to the project. :returns: None :rtype: None :raises: None """ if not self.cur_prj: return dialog = UserAdderDialog(project=self.cur_prj) dialog.exec_() users = dialog.users for user in users: userdata = djitemdata.UserItemData(user) treemodel.TreeItem(userdata, self.prj_user_model.root) self.cur_prj.save() def prj_remove_user(self, *args, **kwargs): """Remove the, in the user table view selected, user. :returns: None :rtype: None :raises: None """ if not self.cur_prj: return i = self.prj_user_tablev.currentIndex() item = i.internalPointer() if item: user = item.internal_data() log.debug("Removing user %s.", user.username) item.set_parent(None) self.cur_prj.users.remove(user) def prj_create_user(self, *args, **kwargs): """Create a new project :returns: None :rtype: None :raises: None """ if not self.cur_prj: return user = self.create_user(projects=[self.cur_prj]) if user: userdata = djitemdata.UserItemData(user) treemodel.TreeItem(userdata, self.prj_user_model.root) def create_user(self, projects=None, tasks=None): """Create and return a new user :param projects: the projects for the user :type projects: list of :class:`jukeboxcore.djadapter.models.Project` :param tasks: the tasks for the user :type tasks: list of :class:`jukeboxcore.djadapter.models.Task` :returns: The created user or None :rtype: None | :class:`jukeboxcore.djadapter.models.User` :raises: None """ projects = projects or [] tasks = tasks or [] dialog = UserCreatorDialog(projects=projects, tasks=tasks, parent=self) dialog.exec_() user = dialog.user if user: userdata = djitemdata.UserItemData(user) treemodel.TreeItem(userdata, self.users_model.root) return user def view_user(self, user): """View the given user on the user page :param user: the user to view :type user: :class:`jukeboxcore.djadapter.models.User` :returns: None :rtype: None :raises: None """ log.debug('Viewing user %s', user.username) self.cur_user = None self.pages_tabw.setCurrentIndex(9) self.user_username_le.setText(user.username) self.user_first_le.setText(user.first_name) self.user_last_le.setText(user.last_name) self.user_email_le.setText(user.email) prjrootdata = treemodel.ListItemData(['Name', 'Short', 'Path', 'Created', 'Semester', 'Status', 'Resolution', 'FPS', 'Scale']) prjrootitem = treemodel.TreeItem(prjrootdata) prjs = djadapter.projects.filter(users=user) for prj in prjs: prjdata = djitemdata.ProjectItemData(prj) treemodel.TreeItem(prjdata, prjrootitem) self.user_prj_model = treemodel.TreeModel(prjrootitem) self.user_prj_tablev.setModel(self.user_prj_model) taskrootdata = treemodel.ListItemData(['Name']) taskrootitem = treemodel.TreeItem(taskrootdata) self.user_task_model = treemodel.TreeModel(taskrootitem) self.user_task_treev.setModel(self.user_task_model) tasks = djadapter.tasks.filter(users=user) assets = {} shots = {} atypes = {} seqs = {} prjs = {} for t in tasks: tdata = djitemdata.TaskItemData(t) titem = treemodel.TreeItem(tdata) e = t.element if isinstance(e, djadapter.models.Asset): eitem = assets.get(e) if not eitem: edata = djitemdata.AssetItemData(e) eitem = treemodel.TreeItem(edata) assets[e] = eitem egrp = e.atype egrpitem = atypes.get(egrp) if not egrpitem: egrpdata = djitemdata.AtypeItemData(egrp) egrpitem = treemodel.TreeItem(egrpdata) atypes[egrp] = egrpitem else: eitem = shots.get(e) if not eitem: edata = djitemdata.ShotItemData(e) eitem = treemodel.TreeItem(edata) shots[e] = eitem egrp = e.sequence egrpitem = seqs.get(egrp) if not egrpitem: egrpdata = djitemdata.SequenceItemData(egrp) egrpitem = treemodel.TreeItem(egrpdata) seqs[egrp] = egrpitem if eitem not in egrpitem.childItems: eitem.set_parent(egrpitem) prj = egrp.project prjitem = prjs.get(prj) if not prjitem: prjdata = djitemdata.ProjectItemData(prj) prjitem = treemodel.TreeItem(prjdata, taskrootitem) prjs[prj] = prjitem assetdata = treemodel.ListItemData(["Asset"]) assetitem = treemodel.TreeItem(assetdata, prjitem) shotdata = treemodel.ListItemData(["Shot"]) shotitem = treemodel.TreeItem(shotdata, prjitem) else: assetitem = prjitem.child(0) shotitem = prjitem.child(1) if isinstance(egrp, djadapter.models.Atype) and egrpitem not in assetitem.childItems: egrpitem.set_parent(assetitem) elif isinstance(egrp, djadapter.models.Sequence) and egrpitem not in shotitem.childItems: egrpitem.set_parent(shotitem) titem.set_parent(eitem) self.cur_user = user def prj_show_path(self, ): """Show the dir in the a filebrowser of the project :returns: None :rtype: None :raises: None """ f = self.prj_path_le.text() osinter = ostool.get_interface() osinter.open_path(f) def prj_save(self): """Save the current project :returns: None :rtype: None :raises: None """ if not self.cur_prj: return desc = self.prj_desc_pte.toPlainText() semester = self.prj_semester_le.text() fps = self.prj_fps_dsb.value() resx = self.prj_res_x_sb.value() resy = self.prj_res_y_sb.value() scale = self.prj_scale_cb.currentText() self.cur_prj.description = desc self.cur_prj.semester = semester self.cur_prj.framerate = fps self.cur_prj.resx = resx self.cur_prj.resy = resy self.cur_prj.scale = scale self.cur_prj.save() def seq_save(self): """Save the current sequence :returns: None :rtype: None :raises: None """ if not self.cur_seq: return desc = self.seq_desc_pte.toPlainText() self.cur_seq.description = desc self.cur_seq.save() def seq_view_prj(self, ): """View the project or the current sequence :returns: None :rtype: None :raises: None """ if not self.cur_seq: return self.view_prj(self.cur_seq.project) def seq_view_shot(self, ): """View the shot that is selected in the table view of the sequence page :returns: None :rtype: None :raises: None """ if not self.cur_seq: return i = self.seq_shot_tablev.currentIndex() item = i.internalPointer() if item: shot = item.internal_data() self.view_shot(shot) def seq_create_shot(self, *args, **kwargs): """Create a new shot :returns: None :rtype: None :raises: None """ if not self.cur_seq: return shot = self.create_shot(sequence=self.cur_seq) if shot: shotdata = djitemdata.ShotItemData(shot) treemodel.TreeItem(shotdata, self.seq_shot_model.root) def view_shot(self, shot): """View the given shot :param shot: the shot to view :type shot: :class:`jukeboxcore.djadapter.models.Shot` :returns: None :rtype: None :raises: None """ log.debug('Viewing shot %s', shot.name) self.cur_shot = None self.pages_tabw.setCurrentIndex(3) self.shot_name_le.setText(shot.name) self.shot_prj_le.setText(shot.project.name) self.shot_seq_le.setText(shot.sequence.name) self.shot_start_sb.setValue(shot.startframe) self.shot_end_sb.setValue(shot.endframe) self.shot_handle_sb.setValue(shot.handlesize) self.shot_desc_pte.setPlainText(shot.description) assetsrootdata = treemodel.ListItemData(["Name", "Description"]) assetsrootitem = treemodel.TreeItem(assetsrootdata) self.shot_asset_model = treemodel.TreeModel(assetsrootitem) self.shot_asset_treev.setModel(self.shot_asset_model) atypes = {} assets = shot.assets.all() for a in assets: atype = a.atype atypeitem = atypes.get(atype) if not atypeitem: atypedata = djitemdata.AtypeItemData(atype) atypeitem = treemodel.TreeItem(atypedata, assetsrootitem) atypes[atype] = atypeitem assetdata = djitemdata.AssetItemData(a) treemodel.TreeItem(assetdata, atypeitem) tasksrootdata = treemodel.ListItemData(["Name", "Short"]) tasksrootitem = treemodel.TreeItem(tasksrootdata) self.shot_task_model = treemodel.TreeModel(tasksrootitem) self.shot_task_tablev.setModel(self.shot_task_model) tasks = shot.tasks.all() for t in tasks: tdata = djitemdata.TaskItemData(t) treemodel.TreeItem(tdata, tasksrootitem) self.cur_shot = shot def create_shot(self, sequence): """Create and return a new shot :param sequence: the sequence for the shot :type sequence: :class:`jukeboxcore.djadapter.models.Sequence` :returns: The created shot or None :rtype: None | :class:`jukeboxcore.djadapter.models.Shot` :raises: None """ dialog = ShotCreatorDialog(sequence=sequence, parent=self) dialog.exec_() shot = dialog.shot return shot def shot_view_prj(self, ): """View the project of the current shot :returns: None :rtype: None :raises: None """ if not self.cur_shot: return self.view_prj(self.cur_shot.project) def shot_view_seq(self, ): """View the sequence of the current shot :returns: None :rtype: None :raises: None """ if not self.cur_shot: return self.view_seq(self.cur_shot.sequence) def shot_view_task(self, ): """View the task that is currently selected on the shot page :returns: None :rtype: None :raises: None """ if not self.cur_shot: return i = self.shot_task_tablev.currentIndex() item = i.internalPointer() if item: task = item.internal_data() self.view_task(task) def shot_view_asset(self, ): """View the task that is currently selected on the shot page :returns: None :rtype: None :raises: None """ if not self.cur_shot: return i = self.shot_asset_treev.currentIndex() item = i.internalPointer() if item: asset = item.internal_data() if isinstance(asset, djadapter.models.Asset): self.view_asset(asset) def shot_create_task(self, *args, **kwargs): """Create a new task :returns: None :rtype: None :raises: None """ if not self.cur_shot: return task = self.create_task(element=self.cur_shot) if task: taskdata = djitemdata.TaskItemData(task) treemodel.TreeItem(taskdata, self.shot_task_model.root) def create_task(self, element): """Create a new task for the given element :param element: the element for the task :type element: :class:`jukeboxcore.djadapter.models.Shot` | :class:`jukeboxcore.djadapter.models.Asset` :returns: None :rtype: None :raises: None """ dialog = TaskCreatorDialog(element=element, parent=self) dialog.exec_() task = dialog.task return task def view_asset(self, asset): """View the given asset :param asset: the asset to view :type asset: :class:`jukeboxcore.djadapter.models.Asset` :returns: None :rtype: None :raises: None """ log.debug('Viewing asset %s', asset.name) self.cur_asset = None self.pages_tabw.setCurrentIndex(5) name = asset.name prj = asset.project.name atype = asset.atype.name desc = asset.description self.asset_name_le.setText(name) self.asset_prj_le.setText(prj) self.asset_atype_le.setText(atype) self.asset_desc_pte.setPlainText(desc) assetsrootdata = treemodel.ListItemData(["Name", "Description"]) assetsrootitem = treemodel.TreeItem(assetsrootdata) self.asset_asset_model = treemodel.TreeModel(assetsrootitem) self.asset_asset_treev.setModel(self.asset_asset_model) atypes = {} assets = asset.assets.all() for a in assets: atype = a.atype atypeitem = atypes.get(atype) if not atypeitem: atypedata = djitemdata.AtypeItemData(atype) atypeitem = treemodel.TreeItem(atypedata, assetsrootitem) atypes[atype] = atypeitem assetdata = djitemdata.AssetItemData(a) treemodel.TreeItem(assetdata, atypeitem) tasksrootdata = treemodel.ListItemData(["Name", "Short"]) tasksrootitem = treemodel.TreeItem(tasksrootdata) self.asset_task_model = treemodel.TreeModel(tasksrootitem) self.asset_task_tablev.setModel(self.asset_task_model) tasks = asset.tasks.all() for t in tasks: tdata = djitemdata.TaskItemData(t) treemodel.TreeItem(tdata, tasksrootitem) self.cur_asset = asset def shot_add_asset(self, *args, **kwargs): """Add more assets to the shot. :returns: None :rtype: None :raises: None """ if not self.cur_shot: return dialog = AssetAdderDialog(shot=self.cur_shot) dialog.exec_() assets = dialog.assets atypes = {} for c in self.shot_asset_model.root.childItems: atypes[c.internal_data()] = c for asset in assets: atypeitem = atypes.get(asset.atype) if not atypeitem: atypedata = djitemdata.AtypeItemData(asset.atype) atypeitem = treemodel.TreeItem(atypedata, self.shot_asset_model.root) atypes[asset.atype] = atypeitem assetdata = djitemdata.AssetItemData(asset) treemodel.TreeItem(assetdata, atypeitem) self.cur_shot.save() def shot_remove_asset(self, *args, **kwargs): """Remove the, in the asset table view selected, asset. :returns: None :rtype: None :raises: None """ if not self.cur_shot: return i = self.shot_asset_treev.currentIndex() item = i.internalPointer() if item: asset = item.internal_data() if not isinstance(asset, djadapter.models.Asset): return log.debug("Removing asset %s.", asset.name) item.set_parent(None) self.cur_shot.assets.remove(asset) def shot_create_asset(self, *args, **kwargs): """Create a new shot :returns: None :rtype: None :raises: None """ if not self.cur_shot: return asset = self.create_asset(project=self.cur_shot.project, shot=self.cur_shot) if not asset: return atypes = {} for c in self.shot_asset_model.root.childItems: atypes[c.internal_data()] = c atypeitem = atypes.get(asset.atype) if not atypeitem: atypedata = djitemdata.AtypeItemData(asset.atype) atypeitem = treemodel.TreeItem(atypedata, self.shot_asset_model.root) atypes[asset.atype] = atypeitem assetdata = djitemdata.AssetItemData(asset) treemodel.TreeItem(assetdata, atypeitem) def create_asset(self, project, atype=None, shot=None, asset=None): """Create and return a new asset :param project: the project for the asset :type project: :class:`jukeboxcore.djadapter.models.Project` :param atype: the assettype of the asset :type atype: :class:`jukeboxcore.djadapter.models.Atype` :param shot: the shot to add the asset to :type shot: :class:`jukeboxcore.djadapter.models.Shot` :param asset: the asset to add the new asset to :type asset: :class:`jukeboxcore.djadapter.models.Asset` :returns: The created asset or None :rtype: None | :class:`jukeboxcore.djadapter.models.Asset` :raises: None """ element = shot or asset dialog = AssetCreatorDialog(project=project, atype=atype, parent=self) dialog.exec_() asset = dialog.asset if not atype: element.assets.add(asset) return asset def view_task(self, task): """View the given task :param task: the task to view :type task: :class:`jukeboxcore.djadapter.models.Task` :returns: None :rtype: None :raises: None """ log.debug('Viewing task %s', task.name) self.cur_task = None self.pages_tabw.setCurrentIndex(7) self.task_dep_le.setText(task.name) statusmap = {"New": 0, "Open": 1, "Done":2} self.task_status_cb.setCurrentIndex(statusmap.get(task.status, -1)) dt = dt_to_qdatetime(task.deadline) if task.deadline else None self.task_deadline_de.setDateTime(dt) self.task_link_le.setText(task.element.name) userrootdata = treemodel.ListItemData(['Username', 'First', 'Last', 'Email']) userrootitem = treemodel.TreeItem(userrootdata) for user in task.users.all(): userdata = djitemdata.UserItemData(user) treemodel.TreeItem(userdata, userrootitem) self.task_user_model = treemodel.TreeModel(userrootitem) self.task_user_tablev.setModel(self.task_user_model) self.cur_task = task def shot_save(self, ): """Save the current shot :returns: None :rtype: None :raises: None """ if not self.cur_shot: return desc = self.shot_desc_pte.toPlainText() start = self.shot_start_sb.value() end = self.shot_end_sb.value() handle = self.shot_handle_sb.value() self.cur_shot.description = desc self.cur_shot.startframe = start self.cur_shot.endframe = end self.cur_shot.handlesize = handle self.cur_shot.save() def asset_view_prj(self, ): """View the project of the current asset :returns: None :rtype: None :raises: None """ if not self.cur_asset: return prj = self.cur_asset.project self.view_prj(prj) def asset_view_atype(self, ): """View the project of the current atype :returns: None :rtype: None :raises: None """ if not self.cur_asset: return atype = self.cur_asset.atype self.view_atype(atype) def atype_view_asset(self, ): """View the project of the current assettype :returns: None :rtype: None :raises: None """ if not self.cur_atype: return i = self.atype_asset_treev.currentIndex() item = i.internalPointer() if item: asset = item.internal_data() if isinstance(asset, djadapter.models.Asset): self.view_asset(asset) def atype_create_asset(self, ): """Create a new asset :returns: None :rtype: None :raises: None """ if not self.cur_atype: return asset = self.create_asset(project=self.cur_prj, atype=self.cur_atype) if not asset: return assetdata = djitemdata.AssetItemData(asset) treemodel.TreeItem(assetdata, self.atype_asset_model.root) def atype_save(self): """Save the current atype :returns: None :rtype: None :raises: None """ if not self.cur_atype: return desc = self.atype_desc_pte.toPlainText() self.cur_atype.description = desc self.cur_atype.save() def asset_view_asset(self, ): """View the task that is currently selected on the asset page :returns: None :rtype: None :raises: None """ if not self.cur_asset: return i = self.asset_asset_treev.currentIndex() item = i.internalPointer() if item: asset = item.internal_data() if isinstance(asset, djadapter.models.Asset): self.view_asset(asset) def asset_add_asset(self, *args, **kwargs): """Add more assets to the asset. :returns: None :rtype: None :raises: None """ if not self.cur_asset: return dialog = AssetAdderDialog(asset=self.cur_asset) dialog.exec_() assets = dialog.assets atypes = {} for c in self.asset_asset_model.root.childItems: atypes[c.internal_data()] = c for asset in assets: atypeitem = atypes.get(asset.atype) if not atypeitem: atypedata = djitemdata.AtypeItemData(asset.atype) atypeitem = treemodel.TreeItem(atypedata, self.asset_asset_model.root) atypes[asset.atype] = atypeitem assetdata = djitemdata.AssetItemData(asset) treemodel.TreeItem(assetdata, atypeitem) self.cur_asset.save() def asset_remove_asset(self, *args, **kwargs): """Remove the, in the asset table view selected, asset. :returns: None :rtype: None :raises: None """ if not self.cur_asset: return i = self.asset_asset_treev.currentIndex() item = i.internalPointer() if item: asset = item.internal_data() if not isinstance(asset, djadapter.models.Asset): return log.debug("Removing asset %s.", asset.name) item.set_parent(None) self.cur_asset.assets.remove(asset) def asset_create_asset(self, *args, **kwargs): """Create a new asset :returns: None :rtype: None :raises: None """ if not self.cur_asset: return asset = self.create_asset(project=self.cur_asset.project, asset=self.cur_asset) if not asset: return atypes = {} for c in self.asset_asset_model.root.childItems: atypes[c.internal_data()] = c atypeitem = atypes.get(asset.atype) if not atypeitem: atypedata = djitemdata.AtypeItemData(asset.atype) atypeitem = treemodel.TreeItem(atypedata, self.asset_asset_model.root) atypes[asset.atype] = atypeitem assetdata = djitemdata.AssetItemData(asset) treemodel.TreeItem(assetdata, atypeitem) def asset_view_task(self, ): """View the task that is currently selected on the asset page :returns: None :rtype: None :raises: None """ if not self.cur_asset: return i = self.asset_task_tablev.currentIndex() item = i.internalPointer() if item: task = item.internal_data() self.view_task(task) def asset_create_task(self, *args, **kwargs): """Create a new task :returns: None :rtype: None :raises: None """ if not self.cur_asset: return task = self.create_task(element=self.cur_asset) if task: taskdata = djitemdata.TaskItemData(task) treemodel.TreeItem(taskdata, self.asset_task_model.root) def asset_save(self): """Save the current asset :returns: None :rtype: None :raises: None """ if not self.cur_asset: return desc = self.asset_desc_pte.toPlainText() self.cur_asset.description = desc self.cur_asset.save() def dep_view_prj(self, ): """View the project that is currently selected :returns: None :rtype: None :raises: None """ if not self.cur_dep: return i = self.dep_prj_tablev.currentIndex() item = i.internalPointer() if item: prj = item.internal_data() self.view_prj(prj) def dep_add_prj(self, *args, **kwargs): """Add projects to the current department :returns: None :rtype: None :raises: None """ if not self.cur_dep: return dialog = ProjectAdderDialog(department=self.cur_dep) dialog.exec_() prjs = dialog.projects for prj in prjs: prjdata = djitemdata.ProjectItemData(prj) treemodel.TreeItem(prjdata, self.dep_prj_model.root) def dep_remove_prj(self, *args, **kwargs): """Remove the selected project from the department :returns: None :rtype: None :raises: None """ if not self.cur_dep: return i = self.dep_prj_tablev.currentIndex() item = i.internalPointer() if item: prj = item.internal_data() self.cur_dep.projects.remove(prj) item.set_parent(None) def dep_save(self, ): """Save the current department :returns: None :rtype: None :raises: None """ if not self.cur_dep: return ordervalue = self.dep_ordervalue_sb.value() desc = self.dep_desc_pte.toPlainText() self.cur_dep.ordervalue = ordervalue self.cur_dep.description = desc self.cur_dep.save() def task_view_user(self, ): """View the user that is currently selected :returns: None :rtype: None :raises: None """ if not self.cur_task: return i = self.task_user_tablev.currentIndex() item = i.internalPointer() if item: user = item.internal_data() self.view_user(user) def task_add_user(self, *args, **kwargs): """Add users to the current task :returns: None :rtype: None :raises: None """ if not self.cur_task: return dialog = UserAdderDialog(task=self.cur_task) dialog.exec_() users = dialog.users for user in users: userdata = djitemdata.UserItemData(user) treemodel.TreeItem(userdata, self.task_user_model.root) def task_remove_user(self, *args, **kwargs): """Remove the selected user from the task :returns: None :rtype: None :raises: None """ if not self.cur_task: return i = self.task_user_tablev.currentIndex() item = i.internalPointer() if item: user = item.internal_data() self.cur_task.users.remove(user) item.set_parent(None) def task_view_dep(self, ): """View the departmetn of the current task :returns: None :rtype: None :raises: None """ if not self.cur_task: return self.view_dep(self.cur_task.department) def task_view_link(self, ): """View the link of the current task :returns: None :rtype: None :raises: None """ if not self.cur_task: return e = self.cur_task.element if isinstance(e, djadapter.models.Asset): self.view_asset(e) else: self.view_shot(e) def task_save(self, ): """Save the current task :returns: None :rtype: None :raises: None """ if not self.cur_task: return deadline = self.task_deadline_de.dateTime().toPython() status = self.task_status_cb.currentText() self.cur_task.deadline = deadline self.cur_task.status = status self.cur_task.save() def users_view_user(self, ): """View the user that is currently selected :returns: None :rtype: None :raises: None """ i = self.users_tablev.currentIndex() item = i.internalPointer() if item: user = item.internal_data() self.view_user(user) def user_view_task(self, ): """View the task that is selected :returns: None :rtype: None :raises: None """ if not self.cur_user: return i = self.user_task_treev.currentIndex() item = i.internalPointer() if item: task = item.internal_data() if isinstance(task, djadapter.models.Task): self.view_task(task) def user_view_prj(self, ): """View the project that is currently selected :returns: None :rtype: None :raises: None """ i = self.user_prj_tablev.currentIndex() item = i.internalPointer() if item: prj = item.internal_data() self.view_prj(prj) def user_add_prj(self, *args, **kwargs): """Add projects to the current user :returns: None :rtype: None :raises: None """ if not self.cur_user: return dialog = ProjectAdderDialog(user=self.cur_user) dialog.exec_() prjs = dialog.projects for prj in prjs: prjdata = djitemdata.ProjectItemData(prj) treemodel.TreeItem(prjdata, self.user_prj_model.root) def user_remove_prj(self, *args, **kwargs): """Remove the selected project from the user :returns: None :rtype: None :raises: None """ if not self.cur_user: return i = self.user_prj_tablev.currentIndex() item = i.internalPointer() if item: prj = item.internal_data() prj.users.remove(self.cur_user) item.set_parent(None) def user_save(self): """Save the current user :returns: None :rtype: None :raises: None """ if not self.cur_user: return username = self.user_username_le.text() first = self.user_first_le.text() last = self.user_last_le.text() email = self.user_email_le.text() self.cur_user.username = username self.cur_user.first_name = first self.cur_user.last_name = last self.cur_user.email = email self.cur_user.save() class GuerillaMGMT(JB_CoreStandaloneGuiPlugin): """A plugin that can run a GuerillaMGMT tool This can be used as a standalone plugin. Before you call run, make sure that there is a running QApplication running. See :mod:`jukeboxcore.gui.main` for helpful functions. """ author = "David Zuber" copyright = "2015" version = "0.1" description = "A guerilla tool for projectmanagement and creating entries in the database." def init(self, ): """Do nothing on init! Call run() if you want to start the configeditor :returns: None :rtype: None :raises: None """ pass def uninit(self, ): """Do nothing on uninit! :returns: None :rtype: None :raises: None """ pass def run(self, parent=None): """Start the configeditor :returns: None :rtype: None :raises: None """ self.gw = GuerillaMGMTWin(parent=parent) self.gw.show()
bsd-3-clause
[ 504, 1611, 15414, 492, 5928, 199, 199, 504, 1335, 85, 415, 1977, 1018, 14, 793, 492, 664, 63, 2921, 199, 793, 275, 664, 63, 2921, 3460, 354, 3368, 199, 199, 504, 1335, 85, 415, 1977, 1018, 492, 312, 14308, 393, 199, 504, 1335, 85, 415, 1977, 1018, 492, 366, 74, 10394, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 973, 492, 1603, 34, 63, 16031, 12, 1603, 34, 63, 5619, 12, 4487, 63, 475, 63, 81, 2083, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 492, 3123, 1238, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 492, 366, 74, 1053, 576, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5265, 492, 1603, 34, 63, 5402, 18736, 10636, 4324, 5061, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 9752, 63, 1907, 492, 32471, 63, 6051, 281, 6165, 9752, 63, 77, 2676, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 1715, 9986, 63, 1907, 492, 32471, 63, 1715, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 2700, 74, 28874, 63, 1907, 492, 32471, 63, 2700, 74, 28874, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 3610, 9986, 63, 1907, 492, 32471, 63, 3610, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 8588, 9986, 63, 1907, 492, 32471, 63, 8588, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 8588, 28874, 63, 1907, 492, 32471, 63, 8588, 28874, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 2601, 9986, 63, 1907, 492, 32471, 63, 2601, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 2601, 28874, 63, 1907, 492, 32471, 63, 2601, 28874, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 751, 9986, 63, 1907, 492, 32471, 63, 751, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 751, 28874, 63, 1907, 492, 32471, 63, 751, 28874, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 2782, 9986, 63, 1907, 492, 32471, 63, 2782, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 6562, 9986, 63, 1907, 492, 32471, 63, 6562, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 6562, 28874, 63, 1907, 492, 32471, 63, 6562, 28874, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 1765, 9986, 63, 1907, 492, 32471, 63, 1765, 9986, 63, 7196, 421, 199, 533, 7290, 17523, 5619, 8, 42, 34, 63, 5619, 12, 32471, 63, 1715, 9986, 63, 7196, 304, 272, 408, 33, 30631, 370, 1218, 282, 2199, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 12, 3285, 29, 16, 304, 267, 408, 9345, 282, 892, 2199, 14875, 9592, 398, 520, 635, 1676, 26, 314, 1676, 909, 267, 520, 466, 1676, 26, 520, 533, 1705, 10901, 14, 32260, 64, 267, 520, 635, 3285, 26, 314, 4353, 3285, 267, 520, 466, 3285, 26, 520, 576, 1705, 10901, 14, 4238, 14, 4301, 6381, 64, 267, 520, 3536, 26, 488, 267, 408, 267, 1613, 8, 4761, 17523, 5619, 12, 291, 2843, 826, 721, 1708, 12, 3285, 9, 267, 291, 14, 1715, 275, 488, 267, 291, 14, 2758, 18203, 8, 277, 9, 267, 291, 14, 981, 63, 3317, 14, 11276, 14, 2242, 8, 277, 14, 981, 63, 2700, 74, 9, 339, 347, 1218, 63, 2700, 74, 8, 277, 12, 3461, 267, 408, 2499, 282, 2199, 436, 3877, 652, 315, 314, 291, 14, 1715, 398, 520, 5808, 26, 488, 267, 520, 4500, 26, 488, 267, 520, 3536, 26, 488, 267, 408, 267, 536, 275, 291, 14, 354, 63, 274, 14, 505, 342, 267, 3974, 275, 291, 14, 3612, 63, 274, 14, 505, 342, 267, 931, 275, 291, 14, 515, 63, 274, 14, 505, 342, 267, 542, 6415, 351, 275, 291, 14, 261, 6415, 351, 63, 274, 14, 505, 342, 267, 862, 26, 288, 5448, 74, 275, 366, 74, 10394, 14, 992, 14, 4761, 8, 354, 29, 354, 12, 3974, 29, 3612, 12, 931, 29, 515, 12, 542, 6415, 351, 29, 261, 6415, 351, 9, 288, 5448, 74, 14, 2117, 342, 288, 291, 14, 1715, 275, 5448, 74, 288, 291, 14, 5694, 342, 267, 871, 26, 288, 943, 14, 1971, 480, 6531, 440, 1218, 892, 2199, 531, 421, 199, 533, 7290, 2767, 424, 5619, 8, 42, 34, 63, 5619, 12, 32471, 63, 2700, 74, 28874, 63, 7196, 304, 272, 408, 33, 30631, 370, 1050, 2199, 370, 282, 2199, 272, 408, 339, 347, 636, 826, 721, 277, 12, 282, 466, 29, 403, 12, 27669, 29, 403, 12, 922, 29, 403, 12, 1676, 29, 403, 12, 3285, 29, 16, 304, 267, 408, 9345, 282, 892, 2199, 14875, 9592, 398, 520, 635, 282, 466, 26, 314, 282, 466, 370, 1050, 314, 2199, 370, 267, 520, 466, 282, 466, 26, 520, 533, 1705, 18256, 10394, 14, 992, 14, 33, 466, 64, 267, 520, 635, 27669, 26, 314, 27669, 370, 1050, 314, 2199, 370, 267, 520, 466, 27669, 26, 520, 533, 1705, 18256, 10394, 14, 992, 14, 872, 12493, 64, 267, 520, 635, 1676, 26, 314, 1676, 909, 267, 520, 635, 922, 26, 314, 922, 370, 307, 525, 314, 2199, 370, 267, 520, 466, 922, 26, 520, 533, 1705, 18256, 10394, 14, 992, 14, 1899, 64, 267, 520, 466, 1676, 26, 520, 533, 1705, 10901, 14, 32260, 64, 267, 520, 635, 3285, 26, 314, 4353, 3285, 267, 520, 466, 3285, 26, 520, 576, 1705, 10901, 14, 4238, 14, 4301, 6381, 64, 267, 520, 3536, 26, 488, 267, 408, 267, 1613, 8, 4761, 2767, 424, 5619, 12, 291, 2843 ]
[ 1611, 15414, 492, 5928, 199, 199, 504, 1335, 85, 415, 1977, 1018, 14, 793, 492, 664, 63, 2921, 199, 793, 275, 664, 63, 2921, 3460, 354, 3368, 199, 199, 504, 1335, 85, 415, 1977, 1018, 492, 312, 14308, 393, 199, 504, 1335, 85, 415, 1977, 1018, 492, 366, 74, 10394, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 973, 492, 1603, 34, 63, 16031, 12, 1603, 34, 63, 5619, 12, 4487, 63, 475, 63, 81, 2083, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 492, 3123, 1238, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 492, 366, 74, 1053, 576, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5265, 492, 1603, 34, 63, 5402, 18736, 10636, 4324, 5061, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 9752, 63, 1907, 492, 32471, 63, 6051, 281, 6165, 9752, 63, 77, 2676, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 1715, 9986, 63, 1907, 492, 32471, 63, 1715, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 2700, 74, 28874, 63, 1907, 492, 32471, 63, 2700, 74, 28874, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 3610, 9986, 63, 1907, 492, 32471, 63, 3610, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 8588, 9986, 63, 1907, 492, 32471, 63, 8588, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 8588, 28874, 63, 1907, 492, 32471, 63, 8588, 28874, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 2601, 9986, 63, 1907, 492, 32471, 63, 2601, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 2601, 28874, 63, 1907, 492, 32471, 63, 2601, 28874, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 751, 9986, 63, 1907, 492, 32471, 63, 751, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 751, 28874, 63, 1907, 492, 32471, 63, 751, 28874, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 2782, 9986, 63, 1907, 492, 32471, 63, 2782, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 6562, 9986, 63, 1907, 492, 32471, 63, 6562, 9986, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 6562, 28874, 63, 1907, 492, 32471, 63, 6562, 28874, 63, 7196, 199, 504, 1335, 85, 415, 1977, 1018, 14, 5885, 14, 8583, 14, 6051, 281, 6165, 14, 1765, 9986, 63, 1907, 492, 32471, 63, 1765, 9986, 63, 7196, 421, 199, 533, 7290, 17523, 5619, 8, 42, 34, 63, 5619, 12, 32471, 63, 1715, 9986, 63, 7196, 304, 272, 408, 33, 30631, 370, 1218, 282, 2199, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 12, 3285, 29, 16, 304, 267, 408, 9345, 282, 892, 2199, 14875, 9592, 398, 520, 635, 1676, 26, 314, 1676, 909, 267, 520, 466, 1676, 26, 520, 533, 1705, 10901, 14, 32260, 64, 267, 520, 635, 3285, 26, 314, 4353, 3285, 267, 520, 466, 3285, 26, 520, 576, 1705, 10901, 14, 4238, 14, 4301, 6381, 64, 267, 520, 3536, 26, 488, 267, 408, 267, 1613, 8, 4761, 17523, 5619, 12, 291, 2843, 826, 721, 1708, 12, 3285, 9, 267, 291, 14, 1715, 275, 488, 267, 291, 14, 2758, 18203, 8, 277, 9, 267, 291, 14, 981, 63, 3317, 14, 11276, 14, 2242, 8, 277, 14, 981, 63, 2700, 74, 9, 339, 347, 1218, 63, 2700, 74, 8, 277, 12, 3461, 267, 408, 2499, 282, 2199, 436, 3877, 652, 315, 314, 291, 14, 1715, 398, 520, 5808, 26, 488, 267, 520, 4500, 26, 488, 267, 520, 3536, 26, 488, 267, 408, 267, 536, 275, 291, 14, 354, 63, 274, 14, 505, 342, 267, 3974, 275, 291, 14, 3612, 63, 274, 14, 505, 342, 267, 931, 275, 291, 14, 515, 63, 274, 14, 505, 342, 267, 542, 6415, 351, 275, 291, 14, 261, 6415, 351, 63, 274, 14, 505, 342, 267, 862, 26, 288, 5448, 74, 275, 366, 74, 10394, 14, 992, 14, 4761, 8, 354, 29, 354, 12, 3974, 29, 3612, 12, 931, 29, 515, 12, 542, 6415, 351, 29, 261, 6415, 351, 9, 288, 5448, 74, 14, 2117, 342, 288, 291, 14, 1715, 275, 5448, 74, 288, 291, 14, 5694, 342, 267, 871, 26, 288, 943, 14, 1971, 480, 6531, 440, 1218, 892, 2199, 531, 421, 199, 533, 7290, 2767, 424, 5619, 8, 42, 34, 63, 5619, 12, 32471, 63, 2700, 74, 28874, 63, 7196, 304, 272, 408, 33, 30631, 370, 1050, 2199, 370, 282, 2199, 272, 408, 339, 347, 636, 826, 721, 277, 12, 282, 466, 29, 403, 12, 27669, 29, 403, 12, 922, 29, 403, 12, 1676, 29, 403, 12, 3285, 29, 16, 304, 267, 408, 9345, 282, 892, 2199, 14875, 9592, 398, 520, 635, 282, 466, 26, 314, 282, 466, 370, 1050, 314, 2199, 370, 267, 520, 466, 282, 466, 26, 520, 533, 1705, 18256, 10394, 14, 992, 14, 33, 466, 64, 267, 520, 635, 27669, 26, 314, 27669, 370, 1050, 314, 2199, 370, 267, 520, 466, 27669, 26, 520, 533, 1705, 18256, 10394, 14, 992, 14, 872, 12493, 64, 267, 520, 635, 1676, 26, 314, 1676, 909, 267, 520, 635, 922, 26, 314, 922, 370, 307, 525, 314, 2199, 370, 267, 520, 466, 922, 26, 520, 533, 1705, 18256, 10394, 14, 992, 14, 1899, 64, 267, 520, 466, 1676, 26, 520, 533, 1705, 10901, 14, 32260, 64, 267, 520, 635, 3285, 26, 314, 4353, 3285, 267, 520, 466, 3285, 26, 520, 576, 1705, 10901, 14, 4238, 14, 4301, 6381, 64, 267, 520, 3536, 26, 488, 267, 408, 267, 1613, 8, 4761, 2767, 424, 5619, 12, 291, 2843, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
valexandersaulys/airbnb_kaggle_contest
venv/lib/python3.4/site-packages/scipy/io/matlab/tests/test_streams.py
109
5442
""" Testing """ from __future__ import division, print_function, absolute_import import os import sys import zlib from io import BytesIO if sys.version_info[0] >= 3: cStringIO = BytesIO else: from cStringIO import StringIO as cStringIO from tempfile import mkstemp import numpy as np from numpy.testing import (assert_, assert_equal, assert_raises, run_module_suite) from scipy.io.matlab.streams import make_stream, \ GenericStream, cStringStream, FileStream, ZlibInputStream, \ _read_into, _read_string fs = None gs = None cs = None fname = None def setup(): val = b'a\x00string' global fs, gs, cs, fname fd, fname = mkstemp() fs = os.fdopen(fd, 'wb') fs.write(val) fs.close() fs = open(fname, 'rb') gs = BytesIO(val) cs = cStringIO(val) def teardown(): global fname, fs fs.close() del fs os.unlink(fname) def test_make_stream(): global fs, gs, cs # test stream initialization assert_(isinstance(make_stream(gs), GenericStream)) if sys.version_info[0] < 3: assert_(isinstance(make_stream(cs), cStringStream)) assert_(isinstance(make_stream(fs), FileStream)) def test_tell_seek(): global fs, gs, cs for s in (fs, gs, cs): st = make_stream(s) res = st.seek(0) yield assert_equal, res, 0 yield assert_equal, st.tell(), 0 res = st.seek(5) yield assert_equal, res, 0 yield assert_equal, st.tell(), 5 res = st.seek(2, 1) yield assert_equal, res, 0 yield assert_equal, st.tell(), 7 res = st.seek(-2, 2) yield assert_equal, res, 0 yield assert_equal, st.tell(), 6 def test_read(): global fs, gs, cs for s in (fs, gs, cs): st = make_stream(s) st.seek(0) res = st.read(-1) yield assert_equal, res, b'a\x00string' st.seek(0) res = st.read(4) yield assert_equal, res, b'a\x00st' # read into st.seek(0) res = _read_into(st, 4) yield assert_equal, res, b'a\x00st' res = _read_into(st, 4) yield assert_equal, res, b'ring' yield assert_raises, IOError, _read_into, st, 2 # read alloc st.seek(0) res = _read_string(st, 4) yield assert_equal, res, b'a\x00st' res = _read_string(st, 4) yield assert_equal, res, b'ring' yield assert_raises, IOError, _read_string, st, 2 class TestZlibInputStream(object): def _get_data(self, size): data = np.random.randint(0, 256, size).astype(np.uint8).tostring() compressed_data = zlib.compress(data) stream = BytesIO(compressed_data) return stream, len(compressed_data), data def test_read(self): block_size = 131072 SIZES = [0, 1, 10, block_size//2, block_size-1, block_size, block_size+1, 2*block_size-1] READ_SIZES = [block_size//2, block_size-1, block_size, block_size+1] def check(size, read_size): compressed_stream, compressed_data_len, data = self._get_data(size) stream = ZlibInputStream(compressed_stream, compressed_data_len) data2 = b'' so_far = 0 while True: block = stream.read(min(read_size, size - so_far)) if not block: break so_far += len(block) data2 += block assert_equal(data, data2) for size in SIZES: for read_size in READ_SIZES: yield check, size, read_size def test_read_max_length(self): size = 1234 data = np.random.randint(0, 256, size).astype(np.uint8).tostring() compressed_data = zlib.compress(data) compressed_stream = BytesIO(compressed_data + b"abbacaca") stream = ZlibInputStream(compressed_stream, len(compressed_data)) stream.read(len(data)) assert_equal(compressed_stream.tell(), len(compressed_data)) assert_raises(IOError, stream.read, 1) def test_seek(self): compressed_stream, compressed_data_len, data = self._get_data(1024) stream = ZlibInputStream(compressed_stream, compressed_data_len) stream.seek(123) p = 123 assert_equal(stream.tell(), p) d1 = stream.read(11) assert_equal(d1, data[p:p+11]) stream.seek(321, 1) p = 123+11+321 assert_equal(stream.tell(), p) d2 = stream.read(21) assert_equal(d2, data[p:p+21]) stream.seek(641, 0) p = 641 assert_equal(stream.tell(), p) d3 = stream.read(11) assert_equal(d3, data[p:p+11]) assert_raises(IOError, stream.seek, 10, 2) assert_raises(IOError, stream.seek, -1, 1) assert_raises(ValueError, stream.seek, 1, 123) stream.seek(10000, 1) assert_raises(IOError, stream.read, 12) def test_all_data_read(self): compressed_stream, compressed_data_len, data = self._get_data(1024) stream = ZlibInputStream(compressed_stream, compressed_data_len) assert_(not stream.all_data_read()) stream.seek(512) assert_(not stream.all_data_read()) stream.seek(1024) assert_(stream.all_data_read()) if __name__ == "__main__": run_module_suite()
gpl-2.0
[ 624, 11940, 199, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 646, 747, 199, 646, 984, 199, 646, 12472, 199, 199, 504, 5890, 492, 11808, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 272, 15073, 275, 11808, 199, 2836, 26, 272, 687, 15073, 492, 5228, 465, 15073, 199, 199, 504, 5549, 492, 333, 6080, 808, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 2680, 14, 4776, 492, 334, 479, 3131, 702, 63, 1452, 12, 702, 63, 3536, 12, 2574, 1255, 63, 578, 63, 5768, 9, 199, 199, 504, 7026, 14, 2308, 14, 569, 5561, 14, 11231, 492, 1852, 63, 1745, 12, 971, 272, 8307, 3296, 12, 286, 1558, 3296, 12, 3814, 3296, 12, 3107, 773, 27611, 12, 971, 272, 485, 739, 63, 9924, 12, 485, 739, 63, 875, 421, 199, 2319, 275, 488, 199, 458, 275, 488, 199, 1259, 275, 488, 199, 5252, 275, 488, 421, 199, 318, 3272, 837, 272, 1139, 275, 330, 7, 65, 60, 88, 383, 875, 7, 272, 2288, 7449, 12, 8763, 12, 7117, 12, 6748, 272, 6111, 12, 6748, 275, 333, 6080, 808, 342, 272, 7449, 275, 747, 14, 23140, 8, 2592, 12, 283, 6603, 358, 272, 7449, 14, 952, 8, 637, 9, 272, 7449, 14, 1600, 342, 272, 7449, 275, 1551, 8, 5252, 12, 283, 4848, 358, 272, 8763, 275, 11808, 8, 637, 9, 272, 7117, 275, 15073, 8, 637, 9, 421, 199, 318, 17558, 837, 272, 2288, 6748, 12, 7449, 272, 7449, 14, 1600, 342, 272, 2150, 7449, 272, 747, 14, 7162, 8, 5252, 9, 421, 199, 318, 511, 63, 1875, 63, 1745, 837, 272, 2288, 7449, 12, 8763, 12, 7117, 272, 327, 511, 2547, 11097, 272, 702, 2531, 6074, 8, 1875, 63, 1745, 8, 458, 395, 8307, 3296, 430, 272, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 267, 702, 2531, 6074, 8, 1875, 63, 1745, 8, 1259, 395, 286, 1558, 3296, 430, 267, 702, 2531, 6074, 8, 1875, 63, 1745, 8, 2319, 395, 3814, 3296, 430, 421, 199, 318, 511, 63, 9974, 63, 5507, 837, 272, 2288, 7449, 12, 8763, 12, 7117, 272, 367, 308, 315, 334, 2319, 12, 8763, 12, 7117, 304, 267, 410, 275, 1852, 63, 1745, 8, 83, 9, 267, 522, 275, 410, 14, 5507, 8, 16, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 378, 267, 1995, 702, 63, 1452, 12, 410, 14, 9974, 1062, 378, 267, 522, 275, 410, 14, 5507, 8, 21, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 378, 267, 1995, 702, 63, 1452, 12, 410, 14, 9974, 1062, 959, 267, 522, 275, 410, 14, 5507, 8, 18, 12, 413, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 378, 267, 1995, 702, 63, 1452, 12, 410, 14, 9974, 1062, 1520, 267, 522, 275, 410, 14, 5507, 2801, 18, 12, 499, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 378, 267, 1995, 702, 63, 1452, 12, 410, 14, 9974, 1062, 1227, 421, 199, 318, 511, 63, 739, 837, 272, 2288, 7449, 12, 8763, 12, 7117, 272, 367, 308, 315, 334, 2319, 12, 8763, 12, 7117, 304, 267, 410, 275, 1852, 63, 1745, 8, 83, 9, 267, 410, 14, 5507, 8, 16, 9, 267, 522, 275, 410, 14, 739, 2801, 17, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 65, 60, 88, 383, 875, 7, 267, 410, 14, 5507, 8, 16, 9, 267, 522, 275, 410, 14, 739, 8, 20, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 65, 60, 88, 383, 270, 7, 267, 327, 1586, 1901, 267, 410, 14, 5507, 8, 16, 9, 267, 522, 275, 485, 739, 63, 9924, 8, 270, 12, 841, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 65, 60, 88, 383, 270, 7, 267, 522, 275, 485, 739, 63, 9924, 8, 270, 12, 841, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 5985, 7, 267, 1995, 702, 63, 3536, 12, 5925, 12, 485, 739, 63, 9924, 12, 410, 12, 499, 267, 327, 1586, 29447, 267, 410, 14, 5507, 8, 16, 9, 267, 522, 275, 485, 739, 63, 875, 8, 270, 12, 841, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 65, 60, 88, 383, 270, 7, 267, 522, 275, 485, 739, 63, 875, 8, 270, 12, 841, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 5985, 7, 267, 1995, 702, 63, 3536, 12, 5925, 12, 485, 739, 63, 875, 12, 410, 12, 499, 421, 199, 533, 1379, 58, 773, 27611, 8, 785, 304, 272, 347, 485, 362, 63, 576, 8, 277, 12, 1568, 304, 267, 666, 275, 980, 14, 2355, 14, 8393, 8, 16, 12, 7633, 12, 1568, 680, 6041, 8, 1590, 14, 1635, 24, 680, 14028, 342, 267, 12335, 63, 576, 275, 12472, 14, 6447, 8, 576, 9, 267, 2547, 275, 11808, 8, 10895, 63, 576, 9, 267, 372, 2547, 12, 822, 8, 10895, 63, 576, 395, 666, 339, 347, 511, 63, 739, 8, 277, 304, 267, 1853, 63, 890, 275, 4944, 709, 2819, 398, 428, 5357, 654, 275, 359, 16, 12, 413, 12, 1616, 12, 1853, 63, 890, 501, 18, 12, 1853, 63, 890, 13, 17, 12, 326, 1853, 63, 890, 12, 1853, 63, 890, 11, 17, 12, 499, 10, 1457, 63, 890, 13, 17, 61, 398, 16767, 63, 2684, 58, 654, 275, 359, 1457, 63, 890, 501, 18, 12, 1853, 63, 890, 13, 17, 12, 1993, 1853, 63, 890, 12, 1853, 63, 890, 11, 17, 61, 398, 347, 1104, 8, 890, 12, 1586, 63, 890, 304, 288, 12335, 63, 1745, 12, 12335, 63, 576, 63, 552, 12, 666, 275, 291, 423, 362, 63, 576, 8, 890, 9, 288, 2547, 275, 3107, 773, 27611, 8, 10895, 63, 1745, 12, 12335, 63, 576, 63, 552, 9, 288, 666, 18, 275, 330, 891, 288, 880, 63, 15315, 275, 378, 288, 1830, 715, 26, 355, 1853, 275, 2547, 14, 739, 8, 827, 8, 739, 63, 890, 12, 3147, 1568, 446, 880, 63, 15315, 430, 355, 340, 440, 1853, 26, 490, 2059, 355, 880, 63, 15315, 847, 822, 8 ]
[ 11940, 199, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 646, 747, 199, 646, 984, 199, 646, 12472, 199, 199, 504, 5890, 492, 11808, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 272, 15073, 275, 11808, 199, 2836, 26, 272, 687, 15073, 492, 5228, 465, 15073, 199, 199, 504, 5549, 492, 333, 6080, 808, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 2680, 14, 4776, 492, 334, 479, 3131, 702, 63, 1452, 12, 702, 63, 3536, 12, 2574, 1255, 63, 578, 63, 5768, 9, 199, 199, 504, 7026, 14, 2308, 14, 569, 5561, 14, 11231, 492, 1852, 63, 1745, 12, 971, 272, 8307, 3296, 12, 286, 1558, 3296, 12, 3814, 3296, 12, 3107, 773, 27611, 12, 971, 272, 485, 739, 63, 9924, 12, 485, 739, 63, 875, 421, 199, 2319, 275, 488, 199, 458, 275, 488, 199, 1259, 275, 488, 199, 5252, 275, 488, 421, 199, 318, 3272, 837, 272, 1139, 275, 330, 7, 65, 60, 88, 383, 875, 7, 272, 2288, 7449, 12, 8763, 12, 7117, 12, 6748, 272, 6111, 12, 6748, 275, 333, 6080, 808, 342, 272, 7449, 275, 747, 14, 23140, 8, 2592, 12, 283, 6603, 358, 272, 7449, 14, 952, 8, 637, 9, 272, 7449, 14, 1600, 342, 272, 7449, 275, 1551, 8, 5252, 12, 283, 4848, 358, 272, 8763, 275, 11808, 8, 637, 9, 272, 7117, 275, 15073, 8, 637, 9, 421, 199, 318, 17558, 837, 272, 2288, 6748, 12, 7449, 272, 7449, 14, 1600, 342, 272, 2150, 7449, 272, 747, 14, 7162, 8, 5252, 9, 421, 199, 318, 511, 63, 1875, 63, 1745, 837, 272, 2288, 7449, 12, 8763, 12, 7117, 272, 327, 511, 2547, 11097, 272, 702, 2531, 6074, 8, 1875, 63, 1745, 8, 458, 395, 8307, 3296, 430, 272, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 267, 702, 2531, 6074, 8, 1875, 63, 1745, 8, 1259, 395, 286, 1558, 3296, 430, 267, 702, 2531, 6074, 8, 1875, 63, 1745, 8, 2319, 395, 3814, 3296, 430, 421, 199, 318, 511, 63, 9974, 63, 5507, 837, 272, 2288, 7449, 12, 8763, 12, 7117, 272, 367, 308, 315, 334, 2319, 12, 8763, 12, 7117, 304, 267, 410, 275, 1852, 63, 1745, 8, 83, 9, 267, 522, 275, 410, 14, 5507, 8, 16, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 378, 267, 1995, 702, 63, 1452, 12, 410, 14, 9974, 1062, 378, 267, 522, 275, 410, 14, 5507, 8, 21, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 378, 267, 1995, 702, 63, 1452, 12, 410, 14, 9974, 1062, 959, 267, 522, 275, 410, 14, 5507, 8, 18, 12, 413, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 378, 267, 1995, 702, 63, 1452, 12, 410, 14, 9974, 1062, 1520, 267, 522, 275, 410, 14, 5507, 2801, 18, 12, 499, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 378, 267, 1995, 702, 63, 1452, 12, 410, 14, 9974, 1062, 1227, 421, 199, 318, 511, 63, 739, 837, 272, 2288, 7449, 12, 8763, 12, 7117, 272, 367, 308, 315, 334, 2319, 12, 8763, 12, 7117, 304, 267, 410, 275, 1852, 63, 1745, 8, 83, 9, 267, 410, 14, 5507, 8, 16, 9, 267, 522, 275, 410, 14, 739, 2801, 17, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 65, 60, 88, 383, 875, 7, 267, 410, 14, 5507, 8, 16, 9, 267, 522, 275, 410, 14, 739, 8, 20, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 65, 60, 88, 383, 270, 7, 267, 327, 1586, 1901, 267, 410, 14, 5507, 8, 16, 9, 267, 522, 275, 485, 739, 63, 9924, 8, 270, 12, 841, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 65, 60, 88, 383, 270, 7, 267, 522, 275, 485, 739, 63, 9924, 8, 270, 12, 841, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 5985, 7, 267, 1995, 702, 63, 3536, 12, 5925, 12, 485, 739, 63, 9924, 12, 410, 12, 499, 267, 327, 1586, 29447, 267, 410, 14, 5507, 8, 16, 9, 267, 522, 275, 485, 739, 63, 875, 8, 270, 12, 841, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 65, 60, 88, 383, 270, 7, 267, 522, 275, 485, 739, 63, 875, 8, 270, 12, 841, 9, 267, 1995, 702, 63, 1452, 12, 522, 12, 330, 7, 5985, 7, 267, 1995, 702, 63, 3536, 12, 5925, 12, 485, 739, 63, 875, 12, 410, 12, 499, 421, 199, 533, 1379, 58, 773, 27611, 8, 785, 304, 272, 347, 485, 362, 63, 576, 8, 277, 12, 1568, 304, 267, 666, 275, 980, 14, 2355, 14, 8393, 8, 16, 12, 7633, 12, 1568, 680, 6041, 8, 1590, 14, 1635, 24, 680, 14028, 342, 267, 12335, 63, 576, 275, 12472, 14, 6447, 8, 576, 9, 267, 2547, 275, 11808, 8, 10895, 63, 576, 9, 267, 372, 2547, 12, 822, 8, 10895, 63, 576, 395, 666, 339, 347, 511, 63, 739, 8, 277, 304, 267, 1853, 63, 890, 275, 4944, 709, 2819, 398, 428, 5357, 654, 275, 359, 16, 12, 413, 12, 1616, 12, 1853, 63, 890, 501, 18, 12, 1853, 63, 890, 13, 17, 12, 326, 1853, 63, 890, 12, 1853, 63, 890, 11, 17, 12, 499, 10, 1457, 63, 890, 13, 17, 61, 398, 16767, 63, 2684, 58, 654, 275, 359, 1457, 63, 890, 501, 18, 12, 1853, 63, 890, 13, 17, 12, 1993, 1853, 63, 890, 12, 1853, 63, 890, 11, 17, 61, 398, 347, 1104, 8, 890, 12, 1586, 63, 890, 304, 288, 12335, 63, 1745, 12, 12335, 63, 576, 63, 552, 12, 666, 275, 291, 423, 362, 63, 576, 8, 890, 9, 288, 2547, 275, 3107, 773, 27611, 8, 10895, 63, 1745, 12, 12335, 63, 576, 63, 552, 9, 288, 666, 18, 275, 330, 891, 288, 880, 63, 15315, 275, 378, 288, 1830, 715, 26, 355, 1853, 275, 2547, 14, 739, 8, 827, 8, 739, 63, 890, 12, 3147, 1568, 446, 880, 63, 15315, 430, 355, 340, 440, 1853, 26, 490, 2059, 355, 880, 63, 15315, 847, 822, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
DefyVentures/edx-platform
common/lib/capa/capa/safe_exec/lazymod.py
193
1200
"""A module proxy for delayed importing of modules. From http://barnesc.blogspot.com/2006/06/automatic-python-imports-with-autoimp.html, in the public domain. """ import sys class LazyModule(object): """A lazy module proxy.""" def __init__(self, modname): self.__dict__['__name__'] = modname self._set_mod(None) def _set_mod(self, mod): if mod is not None: self.__dict__ = mod.__dict__ self.__dict__['_lazymod_mod'] = mod def _load_mod(self): __import__(self.__name__) self._set_mod(sys.modules[self.__name__]) def __getattr__(self, name): if self.__dict__['_lazymod_mod'] is None: self._load_mod() mod = self.__dict__['_lazymod_mod'] if hasattr(mod, name): return getattr(mod, name) else: try: subname = '%s.%s' % (self.__name__, name) __import__(subname) submod = getattr(mod, name) except ImportError: raise AttributeError("'module' object has no attribute %r" % name) self.__dict__[name] = LazyModule(subname) return self.__dict__[name]
agpl-3.0
[ 624, 33, 859, 4566, 367, 24725, 16306, 402, 4621, 14, 199, 199, 2532, 1455, 921, 66, 1060, 19303, 14, 66, 7270, 14173, 14, 957, 15, 7968, 15, 1690, 15, 23292, 13, 1548, 13, 12775, 13, 1045, 13, 2495, 3236, 14, 1360, 12, 199, 262, 314, 4575, 2881, 14, 199, 199, 624, 199, 199, 646, 984, 421, 199, 533, 22373, 2377, 8, 785, 304, 272, 408, 33, 9617, 859, 4566, 1041, 339, 347, 636, 826, 721, 277, 12, 13526, 304, 267, 291, 855, 807, 363, 13742, 354, 17501, 275, 13526, 267, 291, 423, 409, 63, 1494, 8, 403, 9, 339, 347, 485, 409, 63, 1494, 8, 277, 12, 3413, 304, 267, 340, 3413, 365, 440, 488, 26, 288, 291, 855, 807, 363, 275, 3413, 855, 807, 363, 267, 291, 855, 807, 363, 8680, 6395, 1494, 63, 1494, 418, 275, 3413, 339, 347, 485, 912, 63, 1494, 8, 277, 304, 267, 636, 646, 721, 277, 855, 354, 3368, 267, 291, 423, 409, 63, 1494, 8, 1274, 14, 3112, 59, 277, 855, 354, 363, 566, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 340, 291, 855, 807, 363, 8680, 6395, 1494, 63, 1494, 418, 365, 488, 26, 288, 291, 423, 912, 63, 1494, 342, 398, 3413, 275, 291, 855, 807, 363, 8680, 6395, 1494, 63, 1494, 418, 398, 340, 2688, 8, 1494, 12, 536, 304, 288, 372, 2519, 8, 1494, 12, 536, 9, 267, 587, 26, 288, 862, 26, 355, 1007, 354, 275, 1543, 83, 4111, 83, 7, 450, 334, 277, 855, 354, 3108, 536, 9, 355, 636, 646, 721, 954, 354, 9, 355, 1007, 1494, 275, 2519, 8, 1494, 12, 536, 9, 288, 871, 3545, 26, 355, 746, 4281, 15587, 578, 7, 909, 965, 949, 2225, 450, 82, 2, 450, 536, 9, 288, 291, 855, 807, 12298, 354, 61, 275, 22373, 2377, 8, 954, 354, 9, 288, 372, 291, 855, 807, 12298, 354, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 33, 859, 4566, 367, 24725, 16306, 402, 4621, 14, 199, 199, 2532, 1455, 921, 66, 1060, 19303, 14, 66, 7270, 14173, 14, 957, 15, 7968, 15, 1690, 15, 23292, 13, 1548, 13, 12775, 13, 1045, 13, 2495, 3236, 14, 1360, 12, 199, 262, 314, 4575, 2881, 14, 199, 199, 624, 199, 199, 646, 984, 421, 199, 533, 22373, 2377, 8, 785, 304, 272, 408, 33, 9617, 859, 4566, 1041, 339, 347, 636, 826, 721, 277, 12, 13526, 304, 267, 291, 855, 807, 363, 13742, 354, 17501, 275, 13526, 267, 291, 423, 409, 63, 1494, 8, 403, 9, 339, 347, 485, 409, 63, 1494, 8, 277, 12, 3413, 304, 267, 340, 3413, 365, 440, 488, 26, 288, 291, 855, 807, 363, 275, 3413, 855, 807, 363, 267, 291, 855, 807, 363, 8680, 6395, 1494, 63, 1494, 418, 275, 3413, 339, 347, 485, 912, 63, 1494, 8, 277, 304, 267, 636, 646, 721, 277, 855, 354, 3368, 267, 291, 423, 409, 63, 1494, 8, 1274, 14, 3112, 59, 277, 855, 354, 363, 566, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 340, 291, 855, 807, 363, 8680, 6395, 1494, 63, 1494, 418, 365, 488, 26, 288, 291, 423, 912, 63, 1494, 342, 398, 3413, 275, 291, 855, 807, 363, 8680, 6395, 1494, 63, 1494, 418, 398, 340, 2688, 8, 1494, 12, 536, 304, 288, 372, 2519, 8, 1494, 12, 536, 9, 267, 587, 26, 288, 862, 26, 355, 1007, 354, 275, 1543, 83, 4111, 83, 7, 450, 334, 277, 855, 354, 3108, 536, 9, 355, 636, 646, 721, 954, 354, 9, 355, 1007, 1494, 275, 2519, 8, 1494, 12, 536, 9, 288, 871, 3545, 26, 355, 746, 4281, 15587, 578, 7, 909, 965, 949, 2225, 450, 82, 2, 450, 536, 9, 288, 291, 855, 807, 12298, 354, 61, 275, 22373, 2377, 8, 954, 354, 9, 288, 372, 291, 855, 807, 12298, 354, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
tbullmann/heuhaufen
publication/generators_and_depth/aggregate.py
1
5320
import os import pandas import numpy as np from bokeh.palettes import Viridis4 as palette from bokeh.layouts import layout, column, row from bokeh.plotting import figure, output_file, show, ColumnDataSource from bokeh.models import HoverTool, Div, DataTable, TableColumn, NumberFormatter, LinearAxis, Select, CustomJS, Slider, Button import json # must be imported after bokeh def main(test_path='temp/publication/how_deep/test'): labels = ['membranes', 'synapses', 'mitochondria'] # concatenate the evaluation and parameters for all runs dfs = [] for label in labels: for run in range(1,21): df = read_run_from_json_and_csv(test_path, run, label) dfs.append(df) data = pandas.concat(dfs) # save aggregated data (in long format) data.to_csv(os.path.join(test_path, 'summary_long.csv')) # convert long to wide: label x metric --> label_metric metrics = data.columns.to_series().groupby(data.dtypes).groups[np.dtype('float64')] data2 = data.pivot_table(index=['generator', 'layers', 'sample'], columns='label', values=metrics) data2.columns = ['{}_{}'.format(x, y) for x, y in zip(data2.columns.get_level_values(1), data2.columns.get_level_values(0))] data2 = data2.reset_index() # save aggregated data (in wide format) data2.to_csv(os.path.join(test_path, 'summary_wide.csv')) # TODO: interactive plot with bokeh # bokeh_plot(data2, test_path) # not fully functional, e.g. cannot change label and metric def read_run_from_json_and_csv(test_path, run, label): # path to the test result for a particular model base_path = os.path.join(test_path, '%d' % run) # getting parameters from the options json file with open(os.path.join(base_path, "options.json")) as f: options = dict(json.loads(f.read()).items()) generator = options['generator'] # calculate the number of layers depending on generator network and its specific parameters if generator == 'unet': layers = options['u_depth'] * 2 # 1 for down sampling and 1 for up sampling at each level elif generator == 'densenet': layers = options['n_dense_blocks'] * options['n_dense_layers'] + 6 # 3 for each encoder and decoder elif generator == 'resnet': layers = options['n_res_blocks'] * 2 + 6 # 2 for transformation, 3 for each encoder and decoder elif generator == 'highwaynet': layers = options['n_highway_units'] * 2 + 6 # 2 for transformation, 3 for each encoder and decoder # read evaluation results df = pandas.read_csv(os.path.join(base_path, 'evaluation/%s.csv' % label)) # no index_col # add parameters df['generator'] = generator df['layers'] = layers df['label'] = label df['run'] = run return df def bokeh_plot(data, test_path): networks = ['unet', 'resnet', 'highwaynet', 'densenet'] # assuming all float values are metrics metrics = data.columns.to_series().groupby(data.dtypes).groups[np.dtype('float64')] # calculate mean for each data_mean = data.groupby(['generator', 'layers'])[metrics].mean().reset_index() source = dict() source_mean = dict() for network in networks: source[network] = ColumnDataSource(data[data.generator == network]) source_mean[network] = ColumnDataSource(data_mean[data_mean.generator == network]) output_file(os.path.join(test_path, "select.html")) description = Div(text=""" <h1>Evaluation of network type and depth for generator</h1> <p> Interact with the widgets to select metric and evaluated label. </p> """, width=1000) fig = figure(plot_width=1000, plot_height=1000, tools=['box_select', 'reset']) fig.xaxis.axis_label = "layers" fig.yaxis.axis_label = "value of metric" plots = [] for network, column_color in zip(networks, palette): plot = fig.line('layers', metrics[0], legend=dict(value=network), color=column_color, source=source_mean[network]) plot = fig.scatter('layers', metrics[0], legend=dict(value=network), color=column_color, source=source[network]) # legend which can hide/select a specific metric fig.legend.location = "bottom_right" fig.legend.click_policy = "hide" choices = metrics axis = 'y' axis_callback_code = """ plot.glyph.{axis}.field = cb_obj.value axis.attributes.axis_label = cb_obj.value; axis.trigger('change'); source.change.emit(); """ if axis == 'x': fig.xaxis.visible = None position = 'below' initial_choice = 0 else: fig.yaxis.visible = None position = 'left' initial_choice = 1 linear_axis = LinearAxis(axis_label=choices[initial_choice]) fig.add_layout(linear_axis, position) callback1 = CustomJS(args=dict(source=source[network], axis=linear_axis, plot=plot), code=axis_callback_code.format(axis=axis)) ticker = Select(value=choices[initial_choice], options=choices, title=axis + '-axis') ticker.js_on_change('value', callback1) l = layout([ [description], [ticker], [fig] ], sizing_mode='fixed') show(l) if __name__ == "__main__": main() else: main()
mit
[ 646, 747, 199, 646, 10634, 199, 646, 2680, 465, 980, 199, 199, 504, 25214, 14, 387, 2723, 744, 492, 6561, 322, 2297, 20, 465, 17986, 199, 504, 25214, 14, 4209, 83, 492, 7054, 12, 2763, 12, 1962, 199, 504, 25214, 14, 2798, 1337, 492, 9658, 12, 1072, 63, 493, 12, 2498, 12, 4996, 16693, 199, 504, 25214, 14, 992, 492, 869, 1883, 5157, 12, 32077, 12, 3918, 3186, 12, 6957, 4547, 12, 4860, 7772, 12, 12489, 11220, 12, 9496, 12, 8388, 11378, 12, 428, 11306, 12, 16005, 199, 199, 646, 2022, 259, 327, 1471, 506, 8439, 2410, 25214, 421, 199, 318, 2446, 8, 396, 63, 515, 534, 808, 15, 22678, 15, 1917, 63, 16131, 15, 396, 735, 272, 3628, 275, 788, 278, 887, 1312, 397, 297, 283, 9466, 25036, 297, 283, 1147, 79, 335, 7835, 23714, 418, 339, 327, 24788, 314, 11735, 436, 2633, 367, 1006, 7858, 272, 366, 2319, 275, 942, 272, 367, 1768, 315, 3628, 26, 267, 367, 1255, 315, 1425, 8, 17, 12, 2025, 304, 288, 4051, 275, 1586, 63, 1065, 63, 504, 63, 1001, 63, 460, 63, 4737, 8, 396, 63, 515, 12, 1255, 12, 1768, 9, 288, 366, 2319, 14, 740, 8, 1587, 9, 272, 666, 275, 10634, 14, 9419, 8, 10434, 9, 339, 327, 3354, 26913, 666, 334, 262, 1846, 1475, 9, 272, 666, 14, 475, 63, 4737, 8, 736, 14, 515, 14, 904, 8, 396, 63, 515, 12, 283, 4705, 63, 2809, 14, 4737, 1333, 339, 327, 3957, 1846, 370, 20239, 26, 1768, 671, 6370, 10541, 1768, 63, 5165, 272, 7186, 275, 666, 14, 3406, 14, 475, 63, 5602, 1252, 16968, 8, 576, 14, 5717, 680, 2634, 59, 1590, 14, 2271, 360, 1609, 772, 5440, 272, 666, 18, 275, 666, 14, 21558, 63, 1224, 8, 1080, 2968, 4679, 297, 283, 4359, 297, 283, 3271, 995, 4362, 534, 1302, 297, 1338, 29, 6759, 9, 272, 666, 18, 14, 3406, 275, 788, 2440, 63, 11123, 908, 8, 88, 12, 612, 9, 367, 671, 12, 612, 315, 2151, 3482, 8, 576, 18, 14, 3406, 14, 362, 63, 1896, 63, 1459, 8, 17, 395, 666, 18, 14, 3406, 14, 362, 63, 1896, 63, 1459, 8, 16, 10524, 272, 666, 18, 275, 666, 18, 14, 3958, 63, 1080, 342, 339, 327, 3354, 26913, 666, 334, 262, 20239, 1475, 9, 272, 666, 18, 14, 475, 63, 4737, 8, 736, 14, 515, 14, 904, 8, 396, 63, 515, 12, 283, 4705, 63, 13062, 14, 4737, 1333, 339, 327, 3254, 26, 12777, 5137, 543, 25214, 272, 327, 25214, 63, 2798, 8, 576, 18, 12, 511, 63, 515, 9, 221, 327, 440, 9999, 22380, 12, 325, 14, 71, 14, 3913, 1570, 1768, 436, 6370, 421, 199, 318, 1586, 63, 1065, 63, 504, 63, 1001, 63, 460, 63, 4737, 8, 396, 63, 515, 12, 1255, 12, 1768, 304, 339, 327, 931, 370, 314, 511, 754, 367, 282, 6770, 1402, 272, 1300, 63, 515, 275, 747, 14, 515, 14, 904, 8, 396, 63, 515, 12, 1543, 68, 7, 450, 1255, 9, 339, 327, 10232, 2633, 687, 314, 1511, 2022, 570, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 1095, 63, 515, 12, 298, 1419, 14, 1001, 2237, 465, 289, 26, 267, 1511, 275, 1211, 8, 1001, 14, 3640, 8, 70, 14, 739, 8801, 1744, 1012, 272, 4306, 275, 1511, 459, 4679, 418, 339, 327, 8671, 314, 1329, 402, 9393, 10298, 641, 4306, 2784, 436, 2399, 2488, 2633, 272, 340, 4306, 508, 283, 324, 386, 356, 267, 9393, 275, 1511, 459, 85, 63, 4631, 418, 627, 499, 221, 327, 413, 367, 3224, 15877, 436, 413, 367, 1536, 15877, 737, 1924, 2166, 272, 916, 4306, 508, 283, 7253, 846, 356, 267, 9393, 275, 1511, 459, 78, 63, 7253, 63, 4166, 418, 627, 1511, 459, 78, 63, 7253, 63, 4359, 418, 435, 1227, 221, 327, 650, 367, 1924, 10295, 436, 10334, 272, 916, 4306, 508, 283, 28998, 356, 267, 9393, 275, 1511, 459, 78, 63, 470, 63, 4166, 418, 627, 499, 435, 1227, 221, 327, 499, 367, 13315, 12, 650, 367, 1924, 10295, 436, 10334, 272, 916, 4306, 508, 283, 6260, 3316, 846, 356, 267, 9393, 275, 1511, 459, 78, 63, 6260, 3316, 63, 5260, 418, 627, 499, 435, 1227, 221, 327, 499, 367, 13315, 12, 650, 367, 1924, 10295, 436, 10334, 339, 327, 1586, 11735, 2058, 272, 4051, 275, 10634, 14, 739, 63, 4737, 8, 736, 14, 515, 14, 904, 8, 1095, 63, 515, 12, 283, 19154, 3149, 83, 14, 4737, 7, 450, 1768, 430, 221, 327, 949, 1478, 63, 761, 339, 327, 1050, 2633, 272, 4051, 459, 4679, 418, 275, 4306, 272, 4051, 459, 4359, 418, 275, 9393, 272, 4051, 459, 1302, 418, 275, 1768, 272, 4051, 459, 1065, 418, 275, 1255, 339, 372, 4051, 199, 199, 318, 25214, 63, 2798, 8, 576, 12, 511, 63, 515, 304, 339, 11759, 275, 788, 324, 386, 297, 283, 28998, 297, 283, 6260, 3316, 846, 297, 283, 7253, 846, 418, 2378, 327, 18002, 1006, 2069, 1338, 787, 7186, 272, 7186, 275, 666, 14, 3406, 14, 475, 63, 5602, 1252, 16968, 8, 576, 14, 5717, 680, 2634, 59, 1590, 14, 2271, 360, 1609, 772, 5440, 339, 327, 8671, 4615, 367, 1924, 272, 666, 63, 3670, 275, 666, 14, 16968, 2941, 4679, 297, 283, 4359, 25945, 6759, 1055, 3670, 1252, 3958, 63, 1080, 342, 272, 1350, 275, 1211, 342, 272, 1350, 63, 3670, 275, 1211, 342, 272, 367, 2784, 315, 11759, 26, 267, 1350, 59, 1200, 61, 275, 4996, 16693, 8, 576, 59, 576, 14, 4679, 508, 2784, 566, 267, 1350, 63, 3670, 59, 1200, 61, 275, 4996, 16693, 8, 576, 63, 3670, 59, 576, 63, 3670, 14, 4679, 508, 2784, 566, 272, 1072, 63, 493, 8, 736, 14, 515, 14, 904, 8, 396, 63, 515, 12, 298, 2416, 14, 1360, 2237, 272, 1369, 275, 32077, 8, 505, 11916, 267, 665, 72, 17, 30, 29786, 402, 2784, 730, 436, 5818, 367, 4306, 1108, 72, 17, 30, 267, 665, 80, 30, 267, 8883, 1957, 543, 314, 11114, 370, 3504, 6370, 436, 13006, 1768, 14, 267, 3068, 80, 30, 267, 10327, 3462, 29, 5279, 9, 272, 6085, 275, 9658, 8, 2798, 63, 2063, 29, 5279, 12, 5137, 63, 3333, 29, 5279, 12, 7249, 2968 ]
[ 747, 199, 646, 10634, 199, 646, 2680, 465, 980, 199, 199, 504, 25214, 14, 387, 2723, 744, 492, 6561, 322, 2297, 20, 465, 17986, 199, 504, 25214, 14, 4209, 83, 492, 7054, 12, 2763, 12, 1962, 199, 504, 25214, 14, 2798, 1337, 492, 9658, 12, 1072, 63, 493, 12, 2498, 12, 4996, 16693, 199, 504, 25214, 14, 992, 492, 869, 1883, 5157, 12, 32077, 12, 3918, 3186, 12, 6957, 4547, 12, 4860, 7772, 12, 12489, 11220, 12, 9496, 12, 8388, 11378, 12, 428, 11306, 12, 16005, 199, 199, 646, 2022, 259, 327, 1471, 506, 8439, 2410, 25214, 421, 199, 318, 2446, 8, 396, 63, 515, 534, 808, 15, 22678, 15, 1917, 63, 16131, 15, 396, 735, 272, 3628, 275, 788, 278, 887, 1312, 397, 297, 283, 9466, 25036, 297, 283, 1147, 79, 335, 7835, 23714, 418, 339, 327, 24788, 314, 11735, 436, 2633, 367, 1006, 7858, 272, 366, 2319, 275, 942, 272, 367, 1768, 315, 3628, 26, 267, 367, 1255, 315, 1425, 8, 17, 12, 2025, 304, 288, 4051, 275, 1586, 63, 1065, 63, 504, 63, 1001, 63, 460, 63, 4737, 8, 396, 63, 515, 12, 1255, 12, 1768, 9, 288, 366, 2319, 14, 740, 8, 1587, 9, 272, 666, 275, 10634, 14, 9419, 8, 10434, 9, 339, 327, 3354, 26913, 666, 334, 262, 1846, 1475, 9, 272, 666, 14, 475, 63, 4737, 8, 736, 14, 515, 14, 904, 8, 396, 63, 515, 12, 283, 4705, 63, 2809, 14, 4737, 1333, 339, 327, 3957, 1846, 370, 20239, 26, 1768, 671, 6370, 10541, 1768, 63, 5165, 272, 7186, 275, 666, 14, 3406, 14, 475, 63, 5602, 1252, 16968, 8, 576, 14, 5717, 680, 2634, 59, 1590, 14, 2271, 360, 1609, 772, 5440, 272, 666, 18, 275, 666, 14, 21558, 63, 1224, 8, 1080, 2968, 4679, 297, 283, 4359, 297, 283, 3271, 995, 4362, 534, 1302, 297, 1338, 29, 6759, 9, 272, 666, 18, 14, 3406, 275, 788, 2440, 63, 11123, 908, 8, 88, 12, 612, 9, 367, 671, 12, 612, 315, 2151, 3482, 8, 576, 18, 14, 3406, 14, 362, 63, 1896, 63, 1459, 8, 17, 395, 666, 18, 14, 3406, 14, 362, 63, 1896, 63, 1459, 8, 16, 10524, 272, 666, 18, 275, 666, 18, 14, 3958, 63, 1080, 342, 339, 327, 3354, 26913, 666, 334, 262, 20239, 1475, 9, 272, 666, 18, 14, 475, 63, 4737, 8, 736, 14, 515, 14, 904, 8, 396, 63, 515, 12, 283, 4705, 63, 13062, 14, 4737, 1333, 339, 327, 3254, 26, 12777, 5137, 543, 25214, 272, 327, 25214, 63, 2798, 8, 576, 18, 12, 511, 63, 515, 9, 221, 327, 440, 9999, 22380, 12, 325, 14, 71, 14, 3913, 1570, 1768, 436, 6370, 421, 199, 318, 1586, 63, 1065, 63, 504, 63, 1001, 63, 460, 63, 4737, 8, 396, 63, 515, 12, 1255, 12, 1768, 304, 339, 327, 931, 370, 314, 511, 754, 367, 282, 6770, 1402, 272, 1300, 63, 515, 275, 747, 14, 515, 14, 904, 8, 396, 63, 515, 12, 1543, 68, 7, 450, 1255, 9, 339, 327, 10232, 2633, 687, 314, 1511, 2022, 570, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 1095, 63, 515, 12, 298, 1419, 14, 1001, 2237, 465, 289, 26, 267, 1511, 275, 1211, 8, 1001, 14, 3640, 8, 70, 14, 739, 8801, 1744, 1012, 272, 4306, 275, 1511, 459, 4679, 418, 339, 327, 8671, 314, 1329, 402, 9393, 10298, 641, 4306, 2784, 436, 2399, 2488, 2633, 272, 340, 4306, 508, 283, 324, 386, 356, 267, 9393, 275, 1511, 459, 85, 63, 4631, 418, 627, 499, 221, 327, 413, 367, 3224, 15877, 436, 413, 367, 1536, 15877, 737, 1924, 2166, 272, 916, 4306, 508, 283, 7253, 846, 356, 267, 9393, 275, 1511, 459, 78, 63, 7253, 63, 4166, 418, 627, 1511, 459, 78, 63, 7253, 63, 4359, 418, 435, 1227, 221, 327, 650, 367, 1924, 10295, 436, 10334, 272, 916, 4306, 508, 283, 28998, 356, 267, 9393, 275, 1511, 459, 78, 63, 470, 63, 4166, 418, 627, 499, 435, 1227, 221, 327, 499, 367, 13315, 12, 650, 367, 1924, 10295, 436, 10334, 272, 916, 4306, 508, 283, 6260, 3316, 846, 356, 267, 9393, 275, 1511, 459, 78, 63, 6260, 3316, 63, 5260, 418, 627, 499, 435, 1227, 221, 327, 499, 367, 13315, 12, 650, 367, 1924, 10295, 436, 10334, 339, 327, 1586, 11735, 2058, 272, 4051, 275, 10634, 14, 739, 63, 4737, 8, 736, 14, 515, 14, 904, 8, 1095, 63, 515, 12, 283, 19154, 3149, 83, 14, 4737, 7, 450, 1768, 430, 221, 327, 949, 1478, 63, 761, 339, 327, 1050, 2633, 272, 4051, 459, 4679, 418, 275, 4306, 272, 4051, 459, 4359, 418, 275, 9393, 272, 4051, 459, 1302, 418, 275, 1768, 272, 4051, 459, 1065, 418, 275, 1255, 339, 372, 4051, 199, 199, 318, 25214, 63, 2798, 8, 576, 12, 511, 63, 515, 304, 339, 11759, 275, 788, 324, 386, 297, 283, 28998, 297, 283, 6260, 3316, 846, 297, 283, 7253, 846, 418, 2378, 327, 18002, 1006, 2069, 1338, 787, 7186, 272, 7186, 275, 666, 14, 3406, 14, 475, 63, 5602, 1252, 16968, 8, 576, 14, 5717, 680, 2634, 59, 1590, 14, 2271, 360, 1609, 772, 5440, 339, 327, 8671, 4615, 367, 1924, 272, 666, 63, 3670, 275, 666, 14, 16968, 2941, 4679, 297, 283, 4359, 25945, 6759, 1055, 3670, 1252, 3958, 63, 1080, 342, 272, 1350, 275, 1211, 342, 272, 1350, 63, 3670, 275, 1211, 342, 272, 367, 2784, 315, 11759, 26, 267, 1350, 59, 1200, 61, 275, 4996, 16693, 8, 576, 59, 576, 14, 4679, 508, 2784, 566, 267, 1350, 63, 3670, 59, 1200, 61, 275, 4996, 16693, 8, 576, 63, 3670, 59, 576, 63, 3670, 14, 4679, 508, 2784, 566, 272, 1072, 63, 493, 8, 736, 14, 515, 14, 904, 8, 396, 63, 515, 12, 298, 2416, 14, 1360, 2237, 272, 1369, 275, 32077, 8, 505, 11916, 267, 665, 72, 17, 30, 29786, 402, 2784, 730, 436, 5818, 367, 4306, 1108, 72, 17, 30, 267, 665, 80, 30, 267, 8883, 1957, 543, 314, 11114, 370, 3504, 6370, 436, 13006, 1768, 14, 267, 3068, 80, 30, 267, 10327, 3462, 29, 5279, 9, 272, 6085, 275, 9658, 8, 2798, 63, 2063, 29, 5279, 12, 5137, 63, 3333, 29, 5279, 12, 7249, 2968, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bcoca/ansible
lib/ansible/parsing/splitter.py
15
11349
# (c) 2014 James Cammarata, <jcammarata@ansible.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import codecs import re from ansible.errors import AnsibleParserError from ansible.module_utils._text import to_text from ansible.parsing.quoting import unquote # Decode escapes adapted from rspeer's answer here: # http://stackoverflow.com/questions/4020539/process-escape-sequences-in-a-string-in-python _HEXCHAR = '[a-fA-F0-9]' _ESCAPE_SEQUENCE_RE = re.compile(r''' ( \\U{0} # 8-digit hex escapes | \\u{1} # 4-digit hex escapes | \\x{2} # 2-digit hex escapes | \\N\{{[^}}]+\}} # Unicode characters by name | \\[\\'"abfnrtv] # Single-character escapes )'''.format(_HEXCHAR * 8, _HEXCHAR * 4, _HEXCHAR * 2), re.UNICODE | re.VERBOSE) def _decode_escapes(s): def decode_match(match): return codecs.decode(match.group(0), 'unicode-escape') return _ESCAPE_SEQUENCE_RE.sub(decode_match, s) def parse_kv(args, check_raw=False): ''' Convert a string of key/value items to a dict. If any free-form params are found and the check_raw option is set to True, they will be added to a new parameter called '_raw_params'. If check_raw is not enabled, they will simply be ignored. ''' args = to_text(args, nonstring='passthru') options = {} if args is not None: try: vargs = split_args(args) except IndexError as e: raise AnsibleParserError("Unable to parse argument string", orig_exc=e) except ValueError as ve: if 'no closing quotation' in str(ve).lower(): raise AnsibleParserError("error parsing argument string, try quoting the entire line.", orig_exc=ve) else: raise raw_params = [] for orig_x in vargs: x = _decode_escapes(orig_x) if "=" in x: pos = 0 try: while True: pos = x.index('=', pos + 1) if pos > 0 and x[pos - 1] != '\\': break except ValueError: # ran out of string, but we must have some escaped equals, # so replace those and append this to the list of raw params raw_params.append(x.replace('\\=', '=')) continue k = x[:pos] v = x[pos + 1:] # FIXME: make the retrieval of this list of shell/command options a function, so the list is centralized if check_raw and k not in ('creates', 'removes', 'chdir', 'executable', 'warn', 'stdin', 'stdin_add_newline', 'strip_empty_ends'): raw_params.append(orig_x) else: options[k.strip()] = unquote(v.strip()) else: raw_params.append(orig_x) # recombine the free-form params, if any were found, and assign # them to a special option for use later by the shell/command module if len(raw_params) > 0: options[u'_raw_params'] = join_args(raw_params) return options def _get_quote_state(token, quote_char): ''' the goal of this block is to determine if the quoted string is unterminated in which case it needs to be put back together ''' # the char before the current one, used to see if # the current character is escaped prev_char = None for idx, cur_char in enumerate(token): if idx > 0: prev_char = token[idx - 1] if cur_char in '"\'' and prev_char != '\\': if quote_char: if cur_char == quote_char: quote_char = None else: quote_char = cur_char return quote_char def _count_jinja2_blocks(token, cur_depth, open_token, close_token): ''' this function counts the number of opening/closing blocks for a given opening/closing type and adjusts the current depth for that block based on the difference ''' num_open = token.count(open_token) num_close = token.count(close_token) if num_open != num_close: cur_depth += (num_open - num_close) if cur_depth < 0: cur_depth = 0 return cur_depth def join_args(s): ''' Join the original cmd based on manipulations by split_args(). This retains the original newlines and whitespaces. ''' result = '' for p in s: if len(result) == 0 or result.endswith('\n'): result += p else: result += ' ' + p return result def split_args(args): ''' Splits args on whitespace, but intelligently reassembles those that may have been split over a jinja2 block or quotes. When used in a remote module, we won't ever have to be concerned about jinja2 blocks, however this function is/will be used in the core portions as well before the args are templated. example input: a=b c="foo bar" example output: ['a=b', 'c="foo bar"'] Basically this is a variation shlex that has some more intelligence for how Ansible needs to use it. ''' # the list of params parsed out of the arg string # this is going to be the result value when we are done params = [] # Initial split on newlines items = args.split('\n') # iterate over the tokens, and reassemble any that may have been # split on a space inside a jinja2 block. # ex if tokens are "{{", "foo", "}}" these go together # These variables are used # to keep track of the state of the parsing, since blocks and quotes # may be nested within each other. quote_char = None inside_quotes = False print_depth = 0 # used to count nested jinja2 {{ }} blocks block_depth = 0 # used to count nested jinja2 {% %} blocks comment_depth = 0 # used to count nested jinja2 {# #} blocks # now we loop over each split chunk, coalescing tokens if the white space # split occurred within quotes or a jinja2 block of some kind for (itemidx, item) in enumerate(items): # we split on spaces and newlines separately, so that we # can tell which character we split on for reassembly # inside quotation characters tokens = item.split(' ') line_continuation = False for (idx, token) in enumerate(tokens): # Empty entries means we have subsequent spaces # We want to hold onto them so we can reconstruct them later if len(token) == 0 and idx != 0: params[-1] += ' ' continue # if we hit a line continuation character, but # we're not inside quotes, ignore it and continue # on to the next token while setting a flag if token == '\\' and not inside_quotes: line_continuation = True continue # store the previous quoting state for checking later was_inside_quotes = inside_quotes quote_char = _get_quote_state(token, quote_char) inside_quotes = quote_char is not None # multiple conditions may append a token to the list of params, # so we keep track with this flag to make sure it only happens once # append means add to the end of the list, don't append means concatenate # it to the end of the last token appended = False # if we're inside quotes now, but weren't before, append the token # to the end of the list, since we'll tack on more to it later # otherwise, if we're inside any jinja2 block, inside quotes, or we were # inside quotes (but aren't now) concat this token to the last param if inside_quotes and not was_inside_quotes and not(print_depth or block_depth or comment_depth): params.append(token) appended = True elif print_depth or block_depth or comment_depth or inside_quotes or was_inside_quotes: if idx == 0 and was_inside_quotes: params[-1] = "%s%s" % (params[-1], token) elif len(tokens) > 1: spacer = '' if idx > 0: spacer = ' ' params[-1] = "%s%s%s" % (params[-1], spacer, token) else: params[-1] = "%s\n%s" % (params[-1], token) appended = True # if the number of paired block tags is not the same, the depth has changed, so we calculate that here # and may append the current token to the params (if we haven't previously done so) prev_print_depth = print_depth print_depth = _count_jinja2_blocks(token, print_depth, "{{", "}}") if print_depth != prev_print_depth and not appended: params.append(token) appended = True prev_block_depth = block_depth block_depth = _count_jinja2_blocks(token, block_depth, "{%", "%}") if block_depth != prev_block_depth and not appended: params.append(token) appended = True prev_comment_depth = comment_depth comment_depth = _count_jinja2_blocks(token, comment_depth, "{#", "#}") if comment_depth != prev_comment_depth and not appended: params.append(token) appended = True # finally, if we're at zero depth for all blocks and not inside quotes, and have not # yet appended anything to the list of params, we do so now if not (print_depth or block_depth or comment_depth) and not inside_quotes and not appended and token != '': params.append(token) # if this was the last token in the list, and we have more than # one item (meaning we split on newlines), add a newline back here # to preserve the original structure if len(items) > 1 and itemidx != len(items) - 1 and not line_continuation: params[-1] += '\n' # always clear the line continuation flag line_continuation = False # If we're done and things are not at zero depth or we're still inside quotes, # raise an error to indicate that the args were unbalanced if print_depth or block_depth or comment_depth or inside_quotes: raise AnsibleParserError(u"failed at splitting arguments, either an unbalanced jinja2 block or quotes: {0}".format(args)) return params
gpl-3.0
[ 3, 334, 67, 9, 6927, 1603, 14015, 445, 455, 4584, 419, 12, 665, 74, 15176, 4584, 419, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 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, 6010, 199, 646, 295, 199, 199, 504, 3242, 14, 2550, 492, 31775, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 505, 199, 504, 3242, 14, 11059, 14, 25272, 492, 14342, 421, 199, 3, 22462, 24644, 26266, 687, 10717, 7866, 1159, 6385, 2348, 26, 199, 3, 1455, 921, 23153, 14, 957, 15, 16069, 15, 13314, 1717, 1355, 15, 1412, 13, 3765, 13, 13436, 13, 262, 13, 65, 13, 875, 13, 262, 13, 1548, 199, 63, 21377, 5901, 275, 6730, 65, 13, 13753, 13, 38, 16, 13, 25, 6616, 199, 63, 28879, 63, 16585, 63, 907, 275, 295, 14, 2014, 8, 82, 2344, 272, 334, 8522, 53, 91, 16, 93, 3698, 327, 1695, 13, 8573, 6318, 24644, 272, 1204, 8522, 85, 91, 17, 93, 3698, 327, 841, 13, 8573, 6318, 24644, 272, 1204, 8522, 88, 91, 18, 93, 3698, 327, 499, 13, 8573, 6318, 24644, 272, 1204, 8522, 46, 60, 3638, 4735, 4863, 24621, 4863, 221, 327, 6140, 4110, 701, 536, 272, 1204, 8522, 59, 1103, 4065, 371, 2324, 2591, 86, 61, 221, 327, 13050, 13, 10856, 24644, 272, 776, 891, 1370, 908, 1547, 21377, 5901, 627, 1695, 12, 485, 21377, 5901, 627, 841, 12, 485, 21377, 5901, 627, 499, 395, 295, 14, 12819, 1204, 295, 14, 16075, 9, 421, 199, 318, 485, 2708, 63, 3765, 83, 8, 83, 304, 272, 347, 4849, 63, 1431, 8, 1431, 304, 267, 372, 6010, 14, 2708, 8, 1431, 14, 923, 8, 16, 395, 283, 2975, 13, 3765, 358, 339, 372, 485, 28879, 63, 16585, 63, 907, 14, 954, 8, 2708, 63, 1431, 12, 308, 9, 421, 199, 318, 2198, 63, 11475, 8, 589, 12, 1104, 63, 1773, 29, 797, 304, 272, 1449, 272, 7905, 282, 1059, 402, 790, 15, 585, 2974, 370, 282, 1211, 14, 982, 1263, 2867, 13, 964, 1862, 272, 787, 1911, 436, 314, 1104, 63, 1773, 945, 365, 663, 370, 715, 12, 2985, 911, 506, 3483, 272, 370, 282, 892, 2725, 2797, 2513, 1773, 63, 1162, 1370, 982, 1104, 63, 1773, 365, 440, 5223, 12, 272, 2985, 911, 9329, 506, 5525, 14, 272, 1449, 339, 1249, 275, 370, 63, 505, 8, 589, 12, 2222, 875, 534, 15534, 270, 6271, 85, 358, 339, 1511, 275, 1052, 272, 340, 1249, 365, 440, 488, 26, 267, 862, 26, 288, 373, 589, 275, 3715, 63, 589, 8, 589, 9, 267, 871, 7888, 465, 325, 26, 288, 746, 31775, 480, 6005, 370, 2198, 1423, 1059, 401, 2306, 63, 2804, 29, 69, 9, 267, 871, 1722, 465, 11199, 26, 288, 340, 283, 889, 11261, 25101, 7, 315, 620, 8, 432, 680, 2325, 837, 355, 746, 31775, 480, 705, 6057, 1423, 1059, 12, 862, 18593, 314, 8039, 1004, 4765, 2306, 63, 2804, 29, 432, 9, 288, 587, 26, 355, 746, 398, 3066, 63, 1162, 275, 942, 267, 367, 2306, 63, 88, 315, 373, 589, 26, 288, 671, 275, 485, 2708, 63, 3765, 83, 8, 2981, 63, 88, 9, 288, 340, 22250, 315, 671, 26, 355, 2086, 275, 378, 355, 862, 26, 490, 1830, 715, 26, 717, 2086, 275, 671, 14, 1080, 25283, 2086, 435, 413, 9, 717, 340, 2086, 690, 378, 436, 671, 59, 1712, 446, 413, 61, 1137, 29082, 1169, 2059, 355, 871, 1722, 26, 490, 327, 21471, 734, 402, 1059, 12, 1325, 781, 1471, 1172, 2005, 11077, 18527, 12, 490, 327, 880, 3350, 5204, 436, 5666, 642, 370, 314, 769, 402, 3066, 1862, 490, 3066, 63, 1162, 14, 740, 8, 88, 14, 1814, 11671, 4009, 26143, 1333, 490, 1980, 2234, 1022, 275, 671, 1491, 1712, 61, 355, 373, 275, 671, 59, 1712, 435, 413, 2938, 2234, 327, 7600, 26, 1852, 314, 27157, 402, 642, 769, 402, 5218, 15, 1531, 1511, 282, 805, 12, 880, 314, 769, 365, 18796, 1759, 355, 340, 1104, 63, 1773, 436, 1022, 440, 315, 661, 28219, 297, 283, 264, 4912, 297, 283, 8563, 297, 283, 5904, 297, 283, 4050, 297, 283, 6626, 297, 283, 6626, 63, 525, 63, 12210, 297, 283, 1913, 63, 1667, 63, 3198, 735, 490, 3066, 63, 1162, 14, 740, 8, 2981, 63, 88, 9, 355, 587, 26, 490, 1511, 59, 75, 14, 1913, 5106, 275, 14342, 8, 86, 14, 1913, 1012, 288, 587, 26, 355, 3066, 63, 1162, 14, 740, 8, 2981, 63, 88, 9, 398, 327, 295, 13307, 314, 2867, 13, 964, 1862, 12, 340, 1263, 4898, 1911, 12, 436, 5090, 267, 327, 3062, 370, 282, 4539, 945, 367, 675, 2945, 701, 314, 5218, 15, 1531, 859, 267, 340, 822, 8, 1773, 63, 1162, 9, 690, 378, 26, 288, 1511, 59, 85, 26142, 1773, 63, 1162, 418, 275, 4263, 63, 589, 8, 1773, 63, 1162, 9, 339, 372, 1511, 421, 199, 318, 485, 362, 63, 3513, 63, 929, 8, 1418, 12, 6313, 63, 1560, 304, 272, 1449, 272, 314, 14850, 402, 642, 1853, 365, 370, 6705, 340, 314, 10999, 1059, 272, 365, 625, 18375, 315, 1314, 1930, 652, 4839, 370, 506, 5324 ]
[ 334, 67, 9, 6927, 1603, 14015, 445, 455, 4584, 419, 12, 665, 74, 15176, 4584, 419, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 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, 6010, 199, 646, 295, 199, 199, 504, 3242, 14, 2550, 492, 31775, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 505, 199, 504, 3242, 14, 11059, 14, 25272, 492, 14342, 421, 199, 3, 22462, 24644, 26266, 687, 10717, 7866, 1159, 6385, 2348, 26, 199, 3, 1455, 921, 23153, 14, 957, 15, 16069, 15, 13314, 1717, 1355, 15, 1412, 13, 3765, 13, 13436, 13, 262, 13, 65, 13, 875, 13, 262, 13, 1548, 199, 63, 21377, 5901, 275, 6730, 65, 13, 13753, 13, 38, 16, 13, 25, 6616, 199, 63, 28879, 63, 16585, 63, 907, 275, 295, 14, 2014, 8, 82, 2344, 272, 334, 8522, 53, 91, 16, 93, 3698, 327, 1695, 13, 8573, 6318, 24644, 272, 1204, 8522, 85, 91, 17, 93, 3698, 327, 841, 13, 8573, 6318, 24644, 272, 1204, 8522, 88, 91, 18, 93, 3698, 327, 499, 13, 8573, 6318, 24644, 272, 1204, 8522, 46, 60, 3638, 4735, 4863, 24621, 4863, 221, 327, 6140, 4110, 701, 536, 272, 1204, 8522, 59, 1103, 4065, 371, 2324, 2591, 86, 61, 221, 327, 13050, 13, 10856, 24644, 272, 776, 891, 1370, 908, 1547, 21377, 5901, 627, 1695, 12, 485, 21377, 5901, 627, 841, 12, 485, 21377, 5901, 627, 499, 395, 295, 14, 12819, 1204, 295, 14, 16075, 9, 421, 199, 318, 485, 2708, 63, 3765, 83, 8, 83, 304, 272, 347, 4849, 63, 1431, 8, 1431, 304, 267, 372, 6010, 14, 2708, 8, 1431, 14, 923, 8, 16, 395, 283, 2975, 13, 3765, 358, 339, 372, 485, 28879, 63, 16585, 63, 907, 14, 954, 8, 2708, 63, 1431, 12, 308, 9, 421, 199, 318, 2198, 63, 11475, 8, 589, 12, 1104, 63, 1773, 29, 797, 304, 272, 1449, 272, 7905, 282, 1059, 402, 790, 15, 585, 2974, 370, 282, 1211, 14, 982, 1263, 2867, 13, 964, 1862, 272, 787, 1911, 436, 314, 1104, 63, 1773, 945, 365, 663, 370, 715, 12, 2985, 911, 506, 3483, 272, 370, 282, 892, 2725, 2797, 2513, 1773, 63, 1162, 1370, 982, 1104, 63, 1773, 365, 440, 5223, 12, 272, 2985, 911, 9329, 506, 5525, 14, 272, 1449, 339, 1249, 275, 370, 63, 505, 8, 589, 12, 2222, 875, 534, 15534, 270, 6271, 85, 358, 339, 1511, 275, 1052, 272, 340, 1249, 365, 440, 488, 26, 267, 862, 26, 288, 373, 589, 275, 3715, 63, 589, 8, 589, 9, 267, 871, 7888, 465, 325, 26, 288, 746, 31775, 480, 6005, 370, 2198, 1423, 1059, 401, 2306, 63, 2804, 29, 69, 9, 267, 871, 1722, 465, 11199, 26, 288, 340, 283, 889, 11261, 25101, 7, 315, 620, 8, 432, 680, 2325, 837, 355, 746, 31775, 480, 705, 6057, 1423, 1059, 12, 862, 18593, 314, 8039, 1004, 4765, 2306, 63, 2804, 29, 432, 9, 288, 587, 26, 355, 746, 398, 3066, 63, 1162, 275, 942, 267, 367, 2306, 63, 88, 315, 373, 589, 26, 288, 671, 275, 485, 2708, 63, 3765, 83, 8, 2981, 63, 88, 9, 288, 340, 22250, 315, 671, 26, 355, 2086, 275, 378, 355, 862, 26, 490, 1830, 715, 26, 717, 2086, 275, 671, 14, 1080, 25283, 2086, 435, 413, 9, 717, 340, 2086, 690, 378, 436, 671, 59, 1712, 446, 413, 61, 1137, 29082, 1169, 2059, 355, 871, 1722, 26, 490, 327, 21471, 734, 402, 1059, 12, 1325, 781, 1471, 1172, 2005, 11077, 18527, 12, 490, 327, 880, 3350, 5204, 436, 5666, 642, 370, 314, 769, 402, 3066, 1862, 490, 3066, 63, 1162, 14, 740, 8, 88, 14, 1814, 11671, 4009, 26143, 1333, 490, 1980, 2234, 1022, 275, 671, 1491, 1712, 61, 355, 373, 275, 671, 59, 1712, 435, 413, 2938, 2234, 327, 7600, 26, 1852, 314, 27157, 402, 642, 769, 402, 5218, 15, 1531, 1511, 282, 805, 12, 880, 314, 769, 365, 18796, 1759, 355, 340, 1104, 63, 1773, 436, 1022, 440, 315, 661, 28219, 297, 283, 264, 4912, 297, 283, 8563, 297, 283, 5904, 297, 283, 4050, 297, 283, 6626, 297, 283, 6626, 63, 525, 63, 12210, 297, 283, 1913, 63, 1667, 63, 3198, 735, 490, 3066, 63, 1162, 14, 740, 8, 2981, 63, 88, 9, 355, 587, 26, 490, 1511, 59, 75, 14, 1913, 5106, 275, 14342, 8, 86, 14, 1913, 1012, 288, 587, 26, 355, 3066, 63, 1162, 14, 740, 8, 2981, 63, 88, 9, 398, 327, 295, 13307, 314, 2867, 13, 964, 1862, 12, 340, 1263, 4898, 1911, 12, 436, 5090, 267, 327, 3062, 370, 282, 4539, 945, 367, 675, 2945, 701, 314, 5218, 15, 1531, 859, 267, 340, 822, 8, 1773, 63, 1162, 9, 690, 378, 26, 288, 1511, 59, 85, 26142, 1773, 63, 1162, 418, 275, 4263, 63, 589, 8, 1773, 63, 1162, 9, 339, 372, 1511, 421, 199, 318, 485, 362, 63, 3513, 63, 929, 8, 1418, 12, 6313, 63, 1560, 304, 272, 1449, 272, 314, 14850, 402, 642, 1853, 365, 370, 6705, 340, 314, 10999, 1059, 272, 365, 625, 18375, 315, 1314, 1930, 652, 4839, 370, 506, 5324, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rouault/mapnik
scons/scons-local-2.3.4/SCons/Scanner/IDL.py
9
1807
"""SCons.Scanner.IDL This module implements the depenency scanner for IDL (Interface Definition Language) files. """ # # Copyright (c) 2001 - 2014 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # __revision__ = "src/engine/SCons/Scanner/IDL.py 2014/09/27 12:51:43 garyo" import SCons.Node.FS import SCons.Scanner def IDLScan(): """Return a prototype Scanner instance for scanning IDL source files""" cs = SCons.Scanner.ClassicCPP("IDLScan", "$IDLSUFFIXES", "CPPPATH", '^[ \t]*(?:#[ \t]*include|[ \t]*import)[ \t]+(<|")([^>"]+)(>|")') return cs # Local Variables: # tab-width:4 # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4:
lgpl-2.1
[ 624, 18521, 14, 20843, 14, 11505, 199, 199, 2765, 859, 9031, 314, 477, 897, 9501, 19121, 367, 14575, 334, 4267, 199, 10701, 8466, 9, 1584, 14, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 446, 6927, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 20843, 15, 11505, 14, 647, 221, 6927, 15, 1643, 15, 1465, 3144, 26, 2869, 26, 2824, 486, 695, 79, 2, 199, 199, 646, 8218, 14, 1716, 14, 7079, 199, 646, 8218, 14, 20843, 199, 199, 318, 2870, 5296, 2425, 837, 272, 408, 1767, 282, 19393, 28628, 1256, 367, 24928, 14575, 1350, 1584, 624, 272, 7117, 275, 8218, 14, 20843, 14, 30722, 67, 14533, 480, 998, 5296, 2425, 401, 3303, 7880, 998, 5296, 8158, 3867, 654, 401, 3303, 298, 14533, 3243, 401, 3303, 14452, 59, 971, 84, 3672, 5169, 3, 59, 971, 84, 3672, 2613, 17884, 971, 84, 3672, 646, 2788, 971, 84, 2807, 27530, 92, 531, 7059, 30, 937, 29653, 21521, 531, 358, 272, 372, 7117, 199, 199, 3, 10111, 17198, 26, 199, 3, 5174, 13, 2063, 26, 20, 199, 3, 4363, 13, 8741, 13, 632, 26, 20613, 199, 3, 9599, 26, 199, 3, 6695, 26, 663, 26414, 20849, 29, 20, 20105, 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 ]
[ 18521, 14, 20843, 14, 11505, 199, 199, 2765, 859, 9031, 314, 477, 897, 9501, 19121, 367, 14575, 334, 4267, 199, 10701, 8466, 9, 1584, 14, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 446, 6927, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 20843, 15, 11505, 14, 647, 221, 6927, 15, 1643, 15, 1465, 3144, 26, 2869, 26, 2824, 486, 695, 79, 2, 199, 199, 646, 8218, 14, 1716, 14, 7079, 199, 646, 8218, 14, 20843, 199, 199, 318, 2870, 5296, 2425, 837, 272, 408, 1767, 282, 19393, 28628, 1256, 367, 24928, 14575, 1350, 1584, 624, 272, 7117, 275, 8218, 14, 20843, 14, 30722, 67, 14533, 480, 998, 5296, 2425, 401, 3303, 7880, 998, 5296, 8158, 3867, 654, 401, 3303, 298, 14533, 3243, 401, 3303, 14452, 59, 971, 84, 3672, 5169, 3, 59, 971, 84, 3672, 2613, 17884, 971, 84, 3672, 646, 2788, 971, 84, 2807, 27530, 92, 531, 7059, 30, 937, 29653, 21521, 531, 358, 272, 372, 7117, 199, 199, 3, 10111, 17198, 26, 199, 3, 5174, 13, 2063, 26, 20, 199, 3, 4363, 13, 8741, 13, 632, 26, 20613, 199, 3, 9599, 26, 199, 3, 6695, 26, 663, 26414, 20849, 29, 20, 20105, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Statoil/libres
python/res/enkf/ert_template.py
1
2187
# Copyright (C) 2012 Equinor ASA, Norway. # # The file 'ert_template.py' is part of ERT - Ensemble based Reservoir Tool. # # ERT 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. # # ERT 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 at <http://www.gnu.org/licenses/gpl.html> # for more details. from cwrap import BaseCClass from res import ResPrototype class ErtTemplate(BaseCClass): TYPE_NAME = "ert_template" _free = ResPrototype("void ert_template_free( ert_template )") _get_template_file = ResPrototype("char* ert_template_get_template_file(ert_template)") _get_target_file = ResPrototype("char* ert_template_get_target_file(ert_template)") _get_arg_list = ResPrototype("subst_list_ref ert_template_get_arg_list( ert_template )") def __init__(self): raise NotImplementedError("Class can not be instantiated directly!") def get_template_file(self): """ @rtype: str """ return self._get_template_file() def get_target_file(self): """ @rtype: str """ return self._get_target_file() def get_args_as_string(self): """ @rtype: str """ args_list = self._get_arg_list() return ", ".join(["{}={}".format(key, args_list.get(key)) for key in args_list.keys()]) def __eq__(self, other): return self.get_template_file() == other.get_template_file() and\ self.get_target_file() == other.get_target_file() and\ self.get_args_as_string() == other.get_args_as_string() def __ne__(self, other): return not self == other def __repr__(self): return "ErtTemplate({}, {}, {})".format( self.get_template_file(), self.get_target_file(), self.get_args_as_string()) def free(self): self._free()
gpl-3.0
[ 3, 221, 1898, 334, 35, 9, 6029, 221, 662, 392, 262, 269, 437, 4251, 12, 653, 269, 3316, 14, 199, 3, 199, 3, 221, 710, 570, 283, 15299, 63, 1160, 14, 647, 7, 365, 1777, 402, 221, 5397, 446, 3447, 8834, 4079, 799, 25943, 723, 15650, 14, 199, 3, 199, 3, 221, 221, 5397, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 221, 5397, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 199, 3, 221, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 199, 3, 221, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 199, 3, 221, 1666, 314, 1664, 1696, 1684, 844, 737, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 30, 199, 3, 221, 367, 1655, 2436, 14, 199, 504, 286, 3823, 492, 3523, 35, 2543, 199, 504, 522, 492, 3591, 25565, 421, 199, 533, 221, 539, 84, 4231, 8, 1563, 35, 2543, 304, 272, 11511, 63, 2339, 275, 298, 15299, 63, 1160, 2, 339, 485, 4624, 5185, 275, 3591, 25565, 480, 1647, 221, 9266, 84, 63, 1160, 63, 4624, 8, 9266, 84, 63, 1160, 776, 531, 272, 485, 362, 63, 1160, 63, 493, 221, 275, 3591, 25565, 480, 1560, 10, 9266, 84, 63, 1160, 63, 362, 63, 1160, 63, 493, 8, 15299, 63, 1160, 6320, 272, 485, 362, 63, 1375, 63, 493, 259, 275, 3591, 25565, 480, 1560, 10, 9266, 84, 63, 1160, 63, 362, 63, 1375, 63, 493, 8, 15299, 63, 1160, 6320, 272, 485, 362, 63, 1273, 63, 513, 755, 275, 3591, 25565, 480, 16747, 63, 513, 63, 1121, 9266, 84, 63, 1160, 63, 362, 63, 1273, 63, 513, 8, 9266, 84, 63, 1160, 776, 531, 339, 347, 636, 826, 721, 277, 304, 267, 746, 4279, 480, 2543, 883, 440, 506, 17544, 5370, 9124, 339, 347, 664, 63, 1160, 63, 493, 8, 277, 304, 267, 408, 768, 4500, 26, 620, 408, 267, 372, 291, 423, 362, 63, 1160, 63, 493, 342, 339, 347, 664, 63, 1375, 63, 493, 8, 277, 304, 267, 408, 768, 4500, 26, 620, 408, 267, 372, 291, 423, 362, 63, 1375, 63, 493, 342, 339, 347, 664, 63, 589, 63, 305, 63, 875, 8, 277, 304, 267, 408, 768, 4500, 26, 620, 408, 267, 1249, 63, 513, 275, 291, 423, 362, 63, 1273, 63, 513, 342, 267, 372, 3872, 3680, 904, 5234, 2440, 7622, 1674, 908, 8, 498, 12, 1249, 63, 513, 14, 362, 8, 498, 430, 367, 790, 315, 1249, 63, 513, 14, 1612, 9383, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 362, 63, 1160, 63, 493, 342, 221, 508, 1163, 14, 362, 63, 1160, 63, 493, 342, 436, 60, 2049, 291, 14, 362, 63, 1375, 63, 493, 342, 259, 508, 1163, 14, 362, 63, 1375, 63, 493, 342, 436, 60, 2049, 291, 14, 362, 63, 589, 63, 305, 63, 875, 342, 508, 1163, 14, 362, 63, 589, 63, 305, 63, 875, 342, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 508, 1163, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 539, 84, 4231, 16037, 5479, 5009, 1674, 908, 8, 288, 291, 14, 362, 63, 1160, 63, 493, 1062, 288, 291, 14, 362, 63, 1375, 63, 493, 1062, 288, 291, 14, 362, 63, 589, 63, 305, 63, 875, 1012, 339, 347, 2867, 8, 277, 304, 267, 291, 423, 4624, 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 ]
[ 221, 1898, 334, 35, 9, 6029, 221, 662, 392, 262, 269, 437, 4251, 12, 653, 269, 3316, 14, 199, 3, 199, 3, 221, 710, 570, 283, 15299, 63, 1160, 14, 647, 7, 365, 1777, 402, 221, 5397, 446, 3447, 8834, 4079, 799, 25943, 723, 15650, 14, 199, 3, 199, 3, 221, 221, 5397, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 221, 5397, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 199, 3, 221, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 199, 3, 221, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 199, 3, 221, 1666, 314, 1664, 1696, 1684, 844, 737, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 30, 199, 3, 221, 367, 1655, 2436, 14, 199, 504, 286, 3823, 492, 3523, 35, 2543, 199, 504, 522, 492, 3591, 25565, 421, 199, 533, 221, 539, 84, 4231, 8, 1563, 35, 2543, 304, 272, 11511, 63, 2339, 275, 298, 15299, 63, 1160, 2, 339, 485, 4624, 5185, 275, 3591, 25565, 480, 1647, 221, 9266, 84, 63, 1160, 63, 4624, 8, 9266, 84, 63, 1160, 776, 531, 272, 485, 362, 63, 1160, 63, 493, 221, 275, 3591, 25565, 480, 1560, 10, 9266, 84, 63, 1160, 63, 362, 63, 1160, 63, 493, 8, 15299, 63, 1160, 6320, 272, 485, 362, 63, 1375, 63, 493, 259, 275, 3591, 25565, 480, 1560, 10, 9266, 84, 63, 1160, 63, 362, 63, 1375, 63, 493, 8, 15299, 63, 1160, 6320, 272, 485, 362, 63, 1273, 63, 513, 755, 275, 3591, 25565, 480, 16747, 63, 513, 63, 1121, 9266, 84, 63, 1160, 63, 362, 63, 1273, 63, 513, 8, 9266, 84, 63, 1160, 776, 531, 339, 347, 636, 826, 721, 277, 304, 267, 746, 4279, 480, 2543, 883, 440, 506, 17544, 5370, 9124, 339, 347, 664, 63, 1160, 63, 493, 8, 277, 304, 267, 408, 768, 4500, 26, 620, 408, 267, 372, 291, 423, 362, 63, 1160, 63, 493, 342, 339, 347, 664, 63, 1375, 63, 493, 8, 277, 304, 267, 408, 768, 4500, 26, 620, 408, 267, 372, 291, 423, 362, 63, 1375, 63, 493, 342, 339, 347, 664, 63, 589, 63, 305, 63, 875, 8, 277, 304, 267, 408, 768, 4500, 26, 620, 408, 267, 1249, 63, 513, 275, 291, 423, 362, 63, 1273, 63, 513, 342, 267, 372, 3872, 3680, 904, 5234, 2440, 7622, 1674, 908, 8, 498, 12, 1249, 63, 513, 14, 362, 8, 498, 430, 367, 790, 315, 1249, 63, 513, 14, 1612, 9383, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 362, 63, 1160, 63, 493, 342, 221, 508, 1163, 14, 362, 63, 1160, 63, 493, 342, 436, 60, 2049, 291, 14, 362, 63, 1375, 63, 493, 342, 259, 508, 1163, 14, 362, 63, 1375, 63, 493, 342, 436, 60, 2049, 291, 14, 362, 63, 589, 63, 305, 63, 875, 342, 508, 1163, 14, 362, 63, 589, 63, 305, 63, 875, 342, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 508, 1163, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 539, 84, 4231, 16037, 5479, 5009, 1674, 908, 8, 288, 291, 14, 362, 63, 1160, 63, 493, 1062, 288, 291, 14, 362, 63, 1375, 63, 493, 1062, 288, 291, 14, 362, 63, 589, 63, 305, 63, 875, 1012, 339, 347, 2867, 8, 277, 304, 267, 291, 423, 4624, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
blueskyjunkie/timeTools
timetools/synchronization/compliance/ituTG8261/eecOption1/networkWander.py
1
1252
# # Copyright 2017 Russell Smiley # # This file is part of timetools. # # timetools 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. # # timetools 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 timetools. If not, see <http://www.gnu.org/licenses/>. # import timetools.synchronization.compliance.analysis as tsca # Rec. ITU-T G.8261/Y.1361 (08/2013), Section 9.2.1.1, Table 4, pp 20 mtieNs = tsca.Mask([ ([0.1, 2.5], [250]), ([2.5, 20], [0, 100]), ([20, 2000], [2000]), ([2000], ([0.01, 433], [1, 0.2])) ]) # Rec. ITU-T G.8261/Y.1361 (08/2013), Section 9.2.1.1, Table 5, pp 21 tdevNs = tsca.Mask([ ([0.1, 17.14], [12]), ([17.14, 100], [0, 0.7]), ([100, 1e6], ([58, 1.2, 3e-4], [0, 0.5, 1])) ])
gpl-3.0
[ 3, 199, 3, 1898, 9708, 820, 527, 23235, 16392, 441, 89, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 900, 2537, 14, 199, 3, 199, 3, 900, 2537, 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, 900, 2537, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 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, 900, 2537, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 646, 900, 2537, 14, 16473, 2072, 14, 863, 3636, 14, 10466, 465, 307, 7101, 421, 199, 3, 799, 67, 14, 473, 21364, 13, 52, 598, 14, 24, 15128, 15, 57, 14, 969, 2976, 334, 2036, 15, 6965, 395, 15247, 1749, 14, 18, 14, 17, 14, 17, 12, 6957, 841, 12, 11618, 3388, 199, 199, 77, 23958, 2438, 275, 307, 7101, 14, 5144, 779, 7287, 16, 14, 17, 12, 499, 14, 21, 467, 359, 7991, 2522, 15324, 7287, 18, 14, 21, 12, 3388, 467, 359, 16, 12, 2948, 2522, 15324, 7287, 1165, 12, 12293, 467, 359, 8269, 2522, 15324, 7287, 8269, 467, 7287, 16, 14, 614, 12, 841, 1153, 467, 359, 17, 12, 378, 14, 18, 2459, 4794, 421, 199, 3, 799, 67, 14, 473, 21364, 13, 52, 598, 14, 24, 15128, 15, 57, 14, 969, 2976, 334, 2036, 15, 6965, 395, 15247, 1749, 14, 18, 14, 17, 14, 17, 12, 6957, 959, 12, 11618, 7829, 199, 199, 84, 2374, 2438, 275, 307, 7101, 14, 5144, 779, 7287, 16, 14, 17, 12, 5557, 14, 1079, 467, 359, 713, 2522, 15324, 7287, 1196, 14, 1079, 12, 2948, 467, 359, 16, 12, 378, 14, 23, 2522, 15324, 7287, 1960, 12, 413, 69, 22, 467, 7287, 2010, 12, 413, 14, 18, 12, 650, 69, 13, 20, 467, 359, 16, 12, 378, 14, 21, 12, 413, 2459, 4794, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 9708, 820, 527, 23235, 16392, 441, 89, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 900, 2537, 14, 199, 3, 199, 3, 900, 2537, 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, 900, 2537, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 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, 900, 2537, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 646, 900, 2537, 14, 16473, 2072, 14, 863, 3636, 14, 10466, 465, 307, 7101, 421, 199, 3, 799, 67, 14, 473, 21364, 13, 52, 598, 14, 24, 15128, 15, 57, 14, 969, 2976, 334, 2036, 15, 6965, 395, 15247, 1749, 14, 18, 14, 17, 14, 17, 12, 6957, 841, 12, 11618, 3388, 199, 199, 77, 23958, 2438, 275, 307, 7101, 14, 5144, 779, 7287, 16, 14, 17, 12, 499, 14, 21, 467, 359, 7991, 2522, 15324, 7287, 18, 14, 21, 12, 3388, 467, 359, 16, 12, 2948, 2522, 15324, 7287, 1165, 12, 12293, 467, 359, 8269, 2522, 15324, 7287, 8269, 467, 7287, 16, 14, 614, 12, 841, 1153, 467, 359, 17, 12, 378, 14, 18, 2459, 4794, 421, 199, 3, 799, 67, 14, 473, 21364, 13, 52, 598, 14, 24, 15128, 15, 57, 14, 969, 2976, 334, 2036, 15, 6965, 395, 15247, 1749, 14, 18, 14, 17, 14, 17, 12, 6957, 959, 12, 11618, 7829, 199, 199, 84, 2374, 2438, 275, 307, 7101, 14, 5144, 779, 7287, 16, 14, 17, 12, 5557, 14, 1079, 467, 359, 713, 2522, 15324, 7287, 1196, 14, 1079, 12, 2948, 467, 359, 16, 12, 378, 14, 23, 2522, 15324, 7287, 1960, 12, 413, 69, 22, 467, 7287, 2010, 12, 413, 14, 18, 12, 650, 69, 13, 20, 467, 359, 16, 12, 378, 14, 21, 12, 413, 2459, 4794, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
bkirui/odoo
addons/project_timesheet/report/task_report.py
336
4030
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from datetime import datetime from dateutil.relativedelta import relativedelta from openerp.osv import fields,osv from openerp import tools class report_timesheet_task_user(osv.osv): _name = "report.timesheet.task.user" _auto = False _order = "name" def get_hrs_timesheet(self, cr, uid, ids, name, args, context): result = {} for record in self.browse(cr, uid, ids, context): last_date = datetime.strptime(record.name, '%Y-%m-%d') + relativedelta(months=1) - relativedelta(days=1) obj = self.pool.get('hr_timesheet_sheet.sheet.day') sheet_ids = obj.search(cr, uid, [('sheet_id.user_id','=',record.user_id.id),('name','>=',record.name),('name','<=',last_date.strftime('%Y-%m-%d'))]) data_days = obj.read(cr, uid, sheet_ids, ['name','sheet_id.user_id','total_attendance']) total = 0.0 for day_attendance in data_days: total += day_attendance['total_attendance'] result[record.id] = total return result _columns = { 'name': fields.char('Date'), 'year': fields.char('Year', size=4, required=False, readonly=True), 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month', readonly=True), 'user_id': fields.many2one('res.users', 'User',readonly=True), 'timesheet_hrs': fields.function(get_hrs_timesheet, string="Timesheet Hours"), 'task_hrs' : fields.float('Task Hours'), } def init(self, cr): tools.drop_view_if_exists(cr, 'report_timesheet_task_user') cr.execute(""" create or replace view report_timesheet_task_user as ( select ((r.id*12)+to_number(months.m_id,'999999'))::integer as id, months.name as name, r.id as user_id, to_char(to_date(months.name, 'YYYY/MM/DD'),'YYYY') as year, to_char(to_date(months.name, 'YYYY/MM/DD'),'MM') as month, (select sum(hours) from project_task_work where user_id = r.id and date between to_date(months.name, 'YYYY/MM/DD') and (to_date(months.name, 'YYYY/MM/DD') + interval '1 month' - interval '1 day') ) as task_hrs from res_users r, (select to_char(p.date,'YYYY-MM-01') as name, to_char(p.date,'YYYYMM') as m_id from project_task_work p union select to_char(h.name,'YYYY-MM-01') as name, to_char(h.name,'YYYYMM') as m_id from hr_timesheet_sheet_sheet_day h) as months group by r.id,months.m_id,months.name, to_char(to_date(months.name, 'YYYY/MM/DD'),'YYYY') , to_char(to_date(months.name, 'YYYY/MM/DD'),'MM') ) """) # 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, 504, 2197, 492, 2197, 199, 504, 22208, 14, 32300, 492, 20599, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 4795, 199, 504, 5166, 492, 7249, 199, 199, 533, 3622, 63, 17739, 63, 1765, 63, 751, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 3070, 14, 17739, 14, 1765, 14, 751, 2, 272, 485, 2495, 275, 756, 272, 485, 1648, 275, 298, 354, 2, 339, 347, 664, 63, 72, 2393, 63, 17739, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1249, 12, 1067, 304, 267, 754, 275, 1052, 267, 367, 2777, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 304, 288, 2061, 63, 602, 275, 2197, 14, 9866, 8, 3059, 14, 354, 12, 1543, 57, 3295, 77, 3295, 68, 358, 435, 20599, 8, 16745, 29, 17, 9, 446, 20599, 8, 4899, 29, 17, 9, 288, 1559, 275, 291, 14, 2293, 14, 362, 360, 6271, 63, 17739, 63, 5069, 14, 5069, 14, 2977, 358, 288, 12083, 63, 1580, 275, 1559, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 5069, 63, 344, 14, 751, 63, 344, 18937, 3059, 14, 751, 63, 344, 14, 344, 11169, 354, 1673, 30, 4009, 3059, 14, 354, 11169, 354, 1673, 28, 4009, 2019, 63, 602, 14, 6205, 3508, 57, 3295, 77, 3295, 68, 1333, 566, 288, 666, 63, 4899, 275, 1559, 14, 739, 8, 1556, 12, 1747, 12, 12083, 63, 1580, 12, 788, 354, 1673, 5069, 63, 344, 14, 751, 63, 344, 1673, 2923, 63, 23985, 1105, 288, 3141, 275, 378, 14, 16, 288, 367, 5382, 63, 23985, 315, 666, 63, 4899, 26, 355, 3141, 847, 5382, 63, 23985, 459, 2923, 63, 23985, 418, 288, 754, 59, 3059, 14, 344, 61, 275, 3141, 267, 372, 754, 339, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 2506, 659, 267, 283, 3403, 356, 1504, 14, 1560, 360, 15731, 297, 1568, 29, 20, 12, 1415, 29, 797, 12, 6863, 29, 549, 395, 267, 283, 4482, 356, 955, 14, 5592, 8318, 614, 1673, 19825, 20527, 659, 661, 996, 1673, 27717, 26709, 659, 661, 1644, 1673, 45, 1047, 659, 661, 966, 1673, 33, 28026, 659, 661, 1717, 1673, 15586, 659, 661, 1690, 1673, 42, 11474, 659, 3303, 661, 1780, 1673, 42, 21797, 659, 661, 2036, 1673, 21640, 833, 659, 661, 1643, 1673, 23337, 31575, 659, 661, 709, 1673, 17584, 22459, 659, 661, 845, 1673, 1944, 432, 976, 659, 661, 713, 1673, 872, 26381, 2665, 7, 14306, 297, 6863, 29, 549, 395, 267, 283, 751, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 1899, 297, 6753, 29, 549, 395, 267, 283, 17739, 63, 72, 2393, 356, 1504, 14, 1593, 8, 362, 63, 72, 2393, 63, 17739, 12, 1059, 628, 1366, 5069, 869, 16363, 1288, 267, 283, 1765, 63, 72, 2393, 7, 520, 1504, 14, 1609, 360, 4476, 869, 16363, 659, 272, 789, 339, 347, 4205, 8, 277, 12, 2467, 304, 267, 7249, 14, 4824, 63, 1345, 63, 692, 63, 2444, 8, 1556, 12, 283, 3070, 63, 17739, 63, 1765, 63, 751, 358, 267, 2467, 14, 2526, 4852, 1218, 503, 3350, 2455, 3622, 63, 17739, 63, 1765, 63, 751, 465, 334, 267, 3504, 268, 3666, 82, 14, 344, 10, 713, 6393, 475, 63, 1955, 8, 16745, 14, 77, 63, 344, 2584, 20036, 8109, 26, 4115, 465, 1305, 12, 2049, 20096, 14, 354, 465, 536, 12, 2049, 519, 14, 344, 465, 922, 63, 344, 12, 2049, 370, 63, 1560, 8, 475, 63, 602, 8, 16745, 14, 354, 12, 283, 15703, 15, 3218, 15, 5745, 659, 7, 15703, 358, 465, 5361, 12, 2049, 370, 63, 1560, 8, 475, 63, 602, 8, 16745, 14, 354, 12, 283, 15703, 15, 3218, 15, 5745, 659, 7, 3218, 358, 465, 5794, 12, 2049, 334, 2416, 3089, 8, 8419, 9, 687, 2199, 63, 1765, 63, 800, 2382, 922, 63, 344, 275, 519, 14, 344, 436, 1434, 3382, 370, 63, 602, 8, 16745, 14, 354, 12, 283, 15703, 15, 3218, 15, 5745, 358, 436, 334, 475, 63, 602, 8, 16745, 14, 354, 12, 283, 15703, 15, 3218, 15, 5745, 358, 435, 6252, 283, 17, 5794, 7, 446, 288, 6252, 283, 17, 5382, 358, 776, 465, 2120, 63, 72, 2393, 267, 687, 522, 63, 3707, 519, 12, 355, 334, 2416, 370, 63, 1560, 8, 80, 14, 602, 2584, 15703, 13, 3218, 13, 614, 358, 465, 536, 12, 288, 370, 63, 1560, 8, 80, 14, 602, 2584, 15703, 3218, 358, 465, 333, 63, 344, 355, 687, 2199, 63, 1765, 63, 800, 299, 953, 13629, 355, 3504, 370, 63, 1560, 8, 72, 14, 354, 2584, 15703, 13, 3218, 13, 614, 358, 465, 536, 12, 355, 370, 63, 1560, 8, 72, 14, 354, 2584, 15703, 3218, 358, 465, 333, 63, 344, 355, 687, 16140, 63, 17739, 63, 5069, 63, 5069, 63, 2977, 394, 9, 465, 20096, 953, 1572, 701, 355, 519, 14, 344, 12, 16745, 14, 77, 63, 344, 12, 16745, 14 ]
[ 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, 504, 2197, 492, 2197, 199, 504, 22208, 14, 32300, 492, 20599, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 4795, 199, 504, 5166, 492, 7249, 199, 199, 533, 3622, 63, 17739, 63, 1765, 63, 751, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 3070, 14, 17739, 14, 1765, 14, 751, 2, 272, 485, 2495, 275, 756, 272, 485, 1648, 275, 298, 354, 2, 339, 347, 664, 63, 72, 2393, 63, 17739, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1249, 12, 1067, 304, 267, 754, 275, 1052, 267, 367, 2777, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 304, 288, 2061, 63, 602, 275, 2197, 14, 9866, 8, 3059, 14, 354, 12, 1543, 57, 3295, 77, 3295, 68, 358, 435, 20599, 8, 16745, 29, 17, 9, 446, 20599, 8, 4899, 29, 17, 9, 288, 1559, 275, 291, 14, 2293, 14, 362, 360, 6271, 63, 17739, 63, 5069, 14, 5069, 14, 2977, 358, 288, 12083, 63, 1580, 275, 1559, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 5069, 63, 344, 14, 751, 63, 344, 18937, 3059, 14, 751, 63, 344, 14, 344, 11169, 354, 1673, 30, 4009, 3059, 14, 354, 11169, 354, 1673, 28, 4009, 2019, 63, 602, 14, 6205, 3508, 57, 3295, 77, 3295, 68, 1333, 566, 288, 666, 63, 4899, 275, 1559, 14, 739, 8, 1556, 12, 1747, 12, 12083, 63, 1580, 12, 788, 354, 1673, 5069, 63, 344, 14, 751, 63, 344, 1673, 2923, 63, 23985, 1105, 288, 3141, 275, 378, 14, 16, 288, 367, 5382, 63, 23985, 315, 666, 63, 4899, 26, 355, 3141, 847, 5382, 63, 23985, 459, 2923, 63, 23985, 418, 288, 754, 59, 3059, 14, 344, 61, 275, 3141, 267, 372, 754, 339, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 2506, 659, 267, 283, 3403, 356, 1504, 14, 1560, 360, 15731, 297, 1568, 29, 20, 12, 1415, 29, 797, 12, 6863, 29, 549, 395, 267, 283, 4482, 356, 955, 14, 5592, 8318, 614, 1673, 19825, 20527, 659, 661, 996, 1673, 27717, 26709, 659, 661, 1644, 1673, 45, 1047, 659, 661, 966, 1673, 33, 28026, 659, 661, 1717, 1673, 15586, 659, 661, 1690, 1673, 42, 11474, 659, 3303, 661, 1780, 1673, 42, 21797, 659, 661, 2036, 1673, 21640, 833, 659, 661, 1643, 1673, 23337, 31575, 659, 661, 709, 1673, 17584, 22459, 659, 661, 845, 1673, 1944, 432, 976, 659, 661, 713, 1673, 872, 26381, 2665, 7, 14306, 297, 6863, 29, 549, 395, 267, 283, 751, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 1899, 297, 6753, 29, 549, 395, 267, 283, 17739, 63, 72, 2393, 356, 1504, 14, 1593, 8, 362, 63, 72, 2393, 63, 17739, 12, 1059, 628, 1366, 5069, 869, 16363, 1288, 267, 283, 1765, 63, 72, 2393, 7, 520, 1504, 14, 1609, 360, 4476, 869, 16363, 659, 272, 789, 339, 347, 4205, 8, 277, 12, 2467, 304, 267, 7249, 14, 4824, 63, 1345, 63, 692, 63, 2444, 8, 1556, 12, 283, 3070, 63, 17739, 63, 1765, 63, 751, 358, 267, 2467, 14, 2526, 4852, 1218, 503, 3350, 2455, 3622, 63, 17739, 63, 1765, 63, 751, 465, 334, 267, 3504, 268, 3666, 82, 14, 344, 10, 713, 6393, 475, 63, 1955, 8, 16745, 14, 77, 63, 344, 2584, 20036, 8109, 26, 4115, 465, 1305, 12, 2049, 20096, 14, 354, 465, 536, 12, 2049, 519, 14, 344, 465, 922, 63, 344, 12, 2049, 370, 63, 1560, 8, 475, 63, 602, 8, 16745, 14, 354, 12, 283, 15703, 15, 3218, 15, 5745, 659, 7, 15703, 358, 465, 5361, 12, 2049, 370, 63, 1560, 8, 475, 63, 602, 8, 16745, 14, 354, 12, 283, 15703, 15, 3218, 15, 5745, 659, 7, 3218, 358, 465, 5794, 12, 2049, 334, 2416, 3089, 8, 8419, 9, 687, 2199, 63, 1765, 63, 800, 2382, 922, 63, 344, 275, 519, 14, 344, 436, 1434, 3382, 370, 63, 602, 8, 16745, 14, 354, 12, 283, 15703, 15, 3218, 15, 5745, 358, 436, 334, 475, 63, 602, 8, 16745, 14, 354, 12, 283, 15703, 15, 3218, 15, 5745, 358, 435, 6252, 283, 17, 5794, 7, 446, 288, 6252, 283, 17, 5382, 358, 776, 465, 2120, 63, 72, 2393, 267, 687, 522, 63, 3707, 519, 12, 355, 334, 2416, 370, 63, 1560, 8, 80, 14, 602, 2584, 15703, 13, 3218, 13, 614, 358, 465, 536, 12, 288, 370, 63, 1560, 8, 80, 14, 602, 2584, 15703, 3218, 358, 465, 333, 63, 344, 355, 687, 2199, 63, 1765, 63, 800, 299, 953, 13629, 355, 3504, 370, 63, 1560, 8, 72, 14, 354, 2584, 15703, 13, 3218, 13, 614, 358, 465, 536, 12, 355, 370, 63, 1560, 8, 72, 14, 354, 2584, 15703, 3218, 358, 465, 333, 63, 344, 355, 687, 16140, 63, 17739, 63, 5069, 63, 5069, 63, 2977, 394, 9, 465, 20096, 953, 1572, 701, 355, 519, 14, 344, 12, 16745, 14, 77, 63, 344, 12, 16745, 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, 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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 ]
oemof/oemof_base
src/oemof/solph/groupings.py
1
2875
# -*- coding: utf-8 -*- """Groupings needed on an energy system for it to work with solph. If you want to use solph on an energy system, you need to create it with these groupings specified like this: .. code-block: python from oemof.network import EnergySystem import solph energy_system = EnergySystem(groupings=solph.GROUPINGS) SPDX-FileCopyrightText: Uwe Krien <krien@uni-bremen.de> SPDX-FileCopyrightText: Simon Hilpert SPDX-FileCopyrightText: Cord Kaldemeyer SPDX-FileCopyrightText: Stephan Günther SPDX-License-Identifier: MIT """ from oemof.network import groupings as groupings from oemof.solph import blocks def constraint_grouping(node, fallback=lambda *xs, **ks: None): """Grouping function for constraints. This function can be passed in a list to :attr:`groupings` of :class:`oemof.solph.network.EnergySystem`. Parameters ---------- node : :class:`Node <oemof.network.Node` The node for which the figure out a constraint group. fallback : callable, optional A function of one argument. If `node` doesn't have a `constraint_group` attribute, this is used to group the node instead. Defaults to not group the node at all. """ # TODO: Refactor this for looser coupling between modules. # This code causes an unwanted tight coupling between the `groupings` and # `network` modules, resulting in having to do an import at runtime in the # init method of solph's `EnergySystem`. A better way would be to add a # method (maybe `constraints`, `constraint_group`, `constraint_type` or # something like that) to solph's node hierarchy, which gets overridden in # each subclass to return the appropriate value. Then we can just call the # method here. # This even gives other users/us the ability to customize/extend how # constraints are grouped by overriding the method in future subclasses. cg = getattr(node, "constraint_group", fallback) return cg() standard_flow_grouping = groupings.FlowsWithNodes(constant_key=blocks.Flow) def _investment_grouping(stf): if hasattr(stf[2], "investment"): if stf[2].investment is not None: return True else: return False investment_flow_grouping = groupings.FlowsWithNodes( constant_key=blocks.InvestmentFlow, # stf: a tuple consisting of (source, target, flow), so stf[2] is the flow. filter=_investment_grouping, ) def _nonconvex_grouping(stf): if hasattr(stf[2], "nonconvex"): if stf[2].nonconvex is not None: return True else: return False nonconvex_flow_grouping = groupings.FlowsWithNodes( constant_key=blocks.NonConvexFlow, filter=_nonconvex_grouping ) GROUPINGS = [ constraint_grouping, investment_flow_grouping, standard_flow_grouping, nonconvex_flow_grouping, ]
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 2448, 780, 4346, 641, 376, 12304, 2656, 367, 652, 370, 1736, 543, 8597, 838, 14, 199, 199, 3917, 1265, 2934, 370, 675, 8597, 838, 641, 376, 12304, 2656, 12, 1265, 1929, 370, 1218, 652, 543, 3520, 199, 923, 780, 2013, 2839, 642, 26, 339, 2508, 1233, 13, 1457, 26, 2366, 339, 687, 312, 69, 573, 70, 14, 1200, 492, 662, 1372, 4312, 3989, 272, 492, 8597, 838, 339, 12304, 63, 2253, 275, 662, 1372, 4312, 3989, 8, 923, 780, 29, 7873, 838, 14, 7823, 3881, 9, 199, 199, 5763, 19596, 13, 1173, 7384, 1872, 26, 738, 1129, 1804, 322, 287, 665, 75, 322, 287, 32, 5411, 13, 10205, 1410, 14, 271, 30, 199, 5763, 19596, 13, 1173, 7384, 1872, 26, 10751, 265, 869, 382, 28621, 199, 5763, 19596, 13, 1173, 7384, 1872, 26, 445, 2181, 1804, 279, 271, 278, 23009, 199, 5763, 19596, 13, 1173, 7384, 1872, 26, 17854, 16014, 598, 17709, 78, 728, 199, 199, 5763, 19596, 13, 3761, 13, 7544, 26, 10697, 199, 199, 624, 199, 199, 504, 312, 69, 573, 70, 14, 1200, 492, 1572, 780, 465, 1572, 780, 199, 199, 504, 312, 69, 573, 70, 14, 7873, 838, 492, 5664, 421, 199, 318, 5828, 63, 22390, 8, 932, 12, 9567, 29, 2734, 627, 7977, 12, 1011, 6080, 26, 488, 304, 272, 408, 2448, 316, 805, 367, 9565, 14, 339, 961, 805, 883, 506, 3032, 315, 282, 769, 370, 520, 962, 1705, 923, 780, 64, 402, 272, 520, 533, 1705, 13361, 573, 70, 14, 7873, 838, 14, 1200, 14, 9900, 3989, 2313, 339, 3897, 272, 4143, 272, 1031, 520, 520, 533, 1705, 1716, 665, 13361, 573, 70, 14, 1200, 14, 1716, 64, 267, 710, 1031, 367, 1314, 314, 9658, 734, 282, 5828, 1572, 14, 272, 9567, 520, 4550, 12, 2716, 267, 437, 805, 402, 1373, 1423, 14, 982, 658, 932, 64, 3181, 1133, 1172, 282, 658, 5631, 63, 923, 64, 267, 2225, 12, 642, 365, 1202, 370, 1572, 314, 1031, 3140, 14, 7827, 370, 440, 267, 1572, 314, 1031, 737, 1006, 14, 272, 408, 272, 327, 3254, 26, 799, 4778, 642, 367, 560, 13041, 512, 384, 2983, 3382, 4621, 14, 272, 327, 961, 1233, 14486, 376, 625, 19361, 3367, 913, 512, 384, 2983, 3382, 314, 658, 923, 780, 64, 436, 272, 327, 658, 1200, 64, 4621, 12, 9183, 315, 9445, 370, 886, 376, 492, 737, 8836, 315, 314, 272, 327, 4205, 1083, 402, 8597, 838, 1159, 658, 9900, 3989, 2313, 437, 8034, 4340, 3955, 506, 370, 1050, 282, 272, 327, 1083, 334, 11853, 658, 9882, 3559, 658, 5631, 63, 923, 3559, 658, 5631, 63, 466, 64, 503, 272, 327, 6020, 2839, 626, 9, 370, 8597, 838, 1159, 1031, 14446, 12, 1314, 7545, 10087, 315, 272, 327, 1924, 5516, 370, 372, 314, 5827, 574, 14, 9442, 781, 883, 2951, 1240, 314, 272, 327, 1083, 2348, 14, 272, 327, 961, 2755, 10557, 1163, 4390, 15, 527, 314, 21255, 370, 17551, 15, 2880, 4212, 272, 327, 9565, 787, 16251, 701, 18972, 314, 1083, 315, 6466, 9180, 14, 339, 19711, 275, 2519, 8, 932, 12, 298, 5631, 63, 923, 401, 9567, 9, 272, 372, 19711, 342, 421, 199, 6807, 63, 1659, 63, 22390, 275, 1572, 780, 14, 5060, 83, 3007, 6300, 8, 4083, 63, 498, 29, 4166, 14, 5060, 9, 421, 199, 318, 485, 262, 13981, 434, 63, 22390, 8, 270, 70, 304, 272, 340, 2688, 8, 270, 70, 59, 18, 467, 298, 262, 13981, 434, 2349, 267, 340, 410, 70, 59, 18, 1055, 262, 13981, 434, 365, 440, 488, 26, 288, 372, 715, 272, 587, 26, 267, 372, 756, 421, 199, 262, 13981, 434, 63, 1659, 63, 22390, 275, 1572, 780, 14, 5060, 83, 3007, 6300, 8, 272, 4413, 63, 498, 29, 4166, 14, 607, 13981, 434, 5060, 12, 272, 327, 410, 70, 26, 282, 2008, 22581, 402, 334, 1365, 12, 1347, 12, 6369, 395, 880, 410, 70, 59, 18, 61, 365, 314, 6369, 14, 272, 2457, 3699, 262, 13981, 434, 63, 22390, 12, 199, 9, 421, 199, 318, 485, 2865, 388, 26221, 63, 22390, 8, 270, 70, 304, 272, 340, 2688, 8, 270, 70, 59, 18, 467, 298, 2865, 388, 26221, 2349, 267, 340, 410, 70, 59, 18, 1055, 2865, 388, 26221, 365, 440, 488, 26, 288, 372, 715, 272, 587, 26, 267, 372, 756, 421, 199, 2865, 388, 26221, 63, 1659, 63, 22390, 275, 1572, 780, 14, 5060, 83, 3007, 6300, 8, 272, 4413, 63, 498, 29, 4166, 14, 6932, 714, 26221, 5060, 12, 2457, 3699, 2865, 388, 26221, 63, 22390, 199, 9, 421, 199, 7823, 3881, 275, 359, 272, 5828, 63, 22390, 12, 272, 315, 13981, 434, 63, 1659, 63, 22390, 12, 272, 4465, 63, 1659, 63, 22390, 12, 272, 2222, 388, 26221, 63, 1659, 63, 22390, 12, 199, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 2448, 780, 4346, 641, 376, 12304, 2656, 367, 652, 370, 1736, 543, 8597, 838, 14, 199, 199, 3917, 1265, 2934, 370, 675, 8597, 838, 641, 376, 12304, 2656, 12, 1265, 1929, 370, 1218, 652, 543, 3520, 199, 923, 780, 2013, 2839, 642, 26, 339, 2508, 1233, 13, 1457, 26, 2366, 339, 687, 312, 69, 573, 70, 14, 1200, 492, 662, 1372, 4312, 3989, 272, 492, 8597, 838, 339, 12304, 63, 2253, 275, 662, 1372, 4312, 3989, 8, 923, 780, 29, 7873, 838, 14, 7823, 3881, 9, 199, 199, 5763, 19596, 13, 1173, 7384, 1872, 26, 738, 1129, 1804, 322, 287, 665, 75, 322, 287, 32, 5411, 13, 10205, 1410, 14, 271, 30, 199, 5763, 19596, 13, 1173, 7384, 1872, 26, 10751, 265, 869, 382, 28621, 199, 5763, 19596, 13, 1173, 7384, 1872, 26, 445, 2181, 1804, 279, 271, 278, 23009, 199, 5763, 19596, 13, 1173, 7384, 1872, 26, 17854, 16014, 598, 17709, 78, 728, 199, 199, 5763, 19596, 13, 3761, 13, 7544, 26, 10697, 199, 199, 624, 199, 199, 504, 312, 69, 573, 70, 14, 1200, 492, 1572, 780, 465, 1572, 780, 199, 199, 504, 312, 69, 573, 70, 14, 7873, 838, 492, 5664, 421, 199, 318, 5828, 63, 22390, 8, 932, 12, 9567, 29, 2734, 627, 7977, 12, 1011, 6080, 26, 488, 304, 272, 408, 2448, 316, 805, 367, 9565, 14, 339, 961, 805, 883, 506, 3032, 315, 282, 769, 370, 520, 962, 1705, 923, 780, 64, 402, 272, 520, 533, 1705, 13361, 573, 70, 14, 7873, 838, 14, 1200, 14, 9900, 3989, 2313, 339, 3897, 272, 4143, 272, 1031, 520, 520, 533, 1705, 1716, 665, 13361, 573, 70, 14, 1200, 14, 1716, 64, 267, 710, 1031, 367, 1314, 314, 9658, 734, 282, 5828, 1572, 14, 272, 9567, 520, 4550, 12, 2716, 267, 437, 805, 402, 1373, 1423, 14, 982, 658, 932, 64, 3181, 1133, 1172, 282, 658, 5631, 63, 923, 64, 267, 2225, 12, 642, 365, 1202, 370, 1572, 314, 1031, 3140, 14, 7827, 370, 440, 267, 1572, 314, 1031, 737, 1006, 14, 272, 408, 272, 327, 3254, 26, 799, 4778, 642, 367, 560, 13041, 512, 384, 2983, 3382, 4621, 14, 272, 327, 961, 1233, 14486, 376, 625, 19361, 3367, 913, 512, 384, 2983, 3382, 314, 658, 923, 780, 64, 436, 272, 327, 658, 1200, 64, 4621, 12, 9183, 315, 9445, 370, 886, 376, 492, 737, 8836, 315, 314, 272, 327, 4205, 1083, 402, 8597, 838, 1159, 658, 9900, 3989, 2313, 437, 8034, 4340, 3955, 506, 370, 1050, 282, 272, 327, 1083, 334, 11853, 658, 9882, 3559, 658, 5631, 63, 923, 3559, 658, 5631, 63, 466, 64, 503, 272, 327, 6020, 2839, 626, 9, 370, 8597, 838, 1159, 1031, 14446, 12, 1314, 7545, 10087, 315, 272, 327, 1924, 5516, 370, 372, 314, 5827, 574, 14, 9442, 781, 883, 2951, 1240, 314, 272, 327, 1083, 2348, 14, 272, 327, 961, 2755, 10557, 1163, 4390, 15, 527, 314, 21255, 370, 17551, 15, 2880, 4212, 272, 327, 9565, 787, 16251, 701, 18972, 314, 1083, 315, 6466, 9180, 14, 339, 19711, 275, 2519, 8, 932, 12, 298, 5631, 63, 923, 401, 9567, 9, 272, 372, 19711, 342, 421, 199, 6807, 63, 1659, 63, 22390, 275, 1572, 780, 14, 5060, 83, 3007, 6300, 8, 4083, 63, 498, 29, 4166, 14, 5060, 9, 421, 199, 318, 485, 262, 13981, 434, 63, 22390, 8, 270, 70, 304, 272, 340, 2688, 8, 270, 70, 59, 18, 467, 298, 262, 13981, 434, 2349, 267, 340, 410, 70, 59, 18, 1055, 262, 13981, 434, 365, 440, 488, 26, 288, 372, 715, 272, 587, 26, 267, 372, 756, 421, 199, 262, 13981, 434, 63, 1659, 63, 22390, 275, 1572, 780, 14, 5060, 83, 3007, 6300, 8, 272, 4413, 63, 498, 29, 4166, 14, 607, 13981, 434, 5060, 12, 272, 327, 410, 70, 26, 282, 2008, 22581, 402, 334, 1365, 12, 1347, 12, 6369, 395, 880, 410, 70, 59, 18, 61, 365, 314, 6369, 14, 272, 2457, 3699, 262, 13981, 434, 63, 22390, 12, 199, 9, 421, 199, 318, 485, 2865, 388, 26221, 63, 22390, 8, 270, 70, 304, 272, 340, 2688, 8, 270, 70, 59, 18, 467, 298, 2865, 388, 26221, 2349, 267, 340, 410, 70, 59, 18, 1055, 2865, 388, 26221, 365, 440, 488, 26, 288, 372, 715, 272, 587, 26, 267, 372, 756, 421, 199, 2865, 388, 26221, 63, 1659, 63, 22390, 275, 1572, 780, 14, 5060, 83, 3007, 6300, 8, 272, 4413, 63, 498, 29, 4166, 14, 6932, 714, 26221, 5060, 12, 2457, 3699, 2865, 388, 26221, 63, 22390, 199, 9, 421, 199, 7823, 3881, 275, 359, 272, 5828, 63, 22390, 12, 272, 315, 13981, 434, 63, 1659, 63, 22390, 12, 272, 4465, 63, 1659, 63, 22390, 12, 272, 2222, 388, 26221, 63, 1659, 63, 22390, 12, 199, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
biswajitsahu/kuma
kuma/actioncounters/tests/tests.py
9
8421
from django.core.exceptions import MultipleObjectsReturned from django.contrib.auth import get_user_model from django.contrib.auth.models import AnonymousUser from django.contrib.contenttypes.models import ContentType from django.http import HttpRequest from django.test import TransactionTestCase from nose.tools import eq_, ok_ from nose.plugins.attrib import attr from kuma.core.utils import get_unique from ..models import ActionCounterUnique from .models import TestModel class ActionCountersTest(TransactionTestCase): def setUp(self): super(ActionCountersTest, self).setUp() User = get_user_model() self.user1 = User.objects.create_user( 'tester1', 'tester2@tester.com', 'tester1') self.user2 = User.objects.create_user( 'tester2', 'tester2@tester.com', 'tester2') self.obj_1 = TestModel(title="alpha") self.obj_1.save() def mk_request(self, user=None, ip='192.168.123.123', user_agent='FakeBrowser 1.0'): request = HttpRequest() request.user = user and user or AnonymousUser() request.method = 'GET' request.META['REMOTE_ADDR'] = ip request.META['HTTP_USER_AGENT'] = user_agent return request @attr('bug694544') def test_bug694544(self): """Bug 694544: unicode character in request details should not break""" try: action_name = "likes" obj_1 = self.obj_1 obj_1_ct = ContentType.objects.get_for_model(obj_1) request = self.mk_request(user_agent=u"Some\xef\xbf\xbdbrowser") user, ip, user_agent, unique_hash = get_unique(obj_1_ct, obj_1.pk, name=action_name, request=request) except UnicodeDecodeError: ok_(False, "UnicodeDecodeError should not be thrown") @attr('bad_multiple') def test_bad_multiple_counters(self): """ Force multiple counters, possibly result of race condition, ensure graceful handling """ action_name = "likes" obj_1 = self.obj_1 obj_1_ct = ContentType.objects.get_for_model(obj_1) request = self.mk_request() user, ip, user_agent, unique_hash = get_unique(obj_1_ct, obj_1.pk, name=action_name, request=request) # Create an initial counter record directly. u1 = ActionCounterUnique(content_type=obj_1_ct, object_pk=obj_1.pk, name=action_name, total=1, ip=ip, user_agent=user_agent, user=user) u1.save() # Adding a duplicate counter should be prevented at the model level. try: u2 = ActionCounterUnique(content_type=obj_1_ct, object_pk=obj_1.pk, name=action_name, total=1, ip=ip, user_agent=user_agent, user=user) u2.save() ok_(False, "This should have triggered an IntegrityError") except: pass # Try get_unique_for_request, which should turn up the single unique # record created earlier. try: (u, created) = ActionCounterUnique.objects.get_unique_for_request( obj_1, action_name, request) eq_(False, created) except MultipleObjectsReturned: ok_(False, "MultipleObjectsReturned should not be raised") def test_basic_action_increment(self): """Action attempted with several different kinds of unique identifiers""" obj_1 = self.obj_1 # set up request for anonymous user #1 request = self.mk_request() # anonymous user #1 likes user2 obj_1.likes.increment(request) eq_(1, obj_1.likes.total) # anonymous user #1 likes user2, again obj_1.likes.increment(request) eq_(1, obj_1.likes.total) # set up request for anonymous user #2 request = self.mk_request(ip='192.168.123.1') # anonymous user #2 likes user2 obj_1.likes.increment(request) eq_(2, obj_1.likes.total) # anonymous user #2 likes user2, again obj_1.likes.increment(request) eq_(2, obj_1.likes.total) # set up request for authenticated user1 request = self.mk_request(user=self.user1) # authenticated user1 likes user2 obj_1.likes.increment(request) eq_(3, obj_1.likes.total) # authenticated user1 likes user2, again obj_1.likes.increment(request) eq_(3, obj_1.likes.total) # authenticated user1 likes user2, again, from another IP request.META['REMOTE_ADDR'] = '192.168.123.50' obj_1.likes.increment(request) eq_(3, obj_1.likes.total) # set up request for user agent Mozilla 1.0 request = self.mk_request(ip='192.168.123.50', user_agent='Mozilla 1.0') obj_1.likes.increment(request) eq_(4, obj_1.likes.total) # set up request for user agent Safari 1.0 request = self.mk_request(ip='192.168.123.50', user_agent='Safari 1.0') obj_1.likes.increment(request) eq_(5, obj_1.likes.total) def test_action_with_max(self): """Action with a max_total_per_unique greater than 1""" obj_1 = self.obj_1 MAX = obj_1.views.field.max_total_per_unique request = self.mk_request(ip='192.168.123.123') for x in range(1, MAX + 1): obj_1.views.increment(request) eq_(x, obj_1.views.total) obj_1.views.increment(request) eq_(MAX, obj_1.views.total) obj_1.views.increment(request) eq_(MAX, obj_1.views.total) def test_action_with_min(self): """Action with a min_total_per_unique greater than 1""" obj_1 = self.obj_1 MIN = obj_1.frobs.field.min_total_per_unique request = self.mk_request(ip='192.168.123.123') for x in range(1, (0 - MIN) + 1): obj_1.frobs.decrement(request) eq_(0 - x, obj_1.frobs.total) obj_1.frobs.decrement(request) eq_(MIN, obj_1.frobs.total) obj_1.frobs.decrement(request) eq_(MIN, obj_1.frobs.total) def test_action_count_per_unique(self): """Exercise action counts per unique and ensure overall total works""" obj_1 = self.obj_1 MAX = obj_1.boogs.field.max_total_per_unique MIN = obj_1.boogs.field.min_total_per_unique UNIQUES = ( dict(user=self.user1), dict(user=self.user2), dict(ip='192.168.123.123'), dict(ip='192.168.123.150', user_agent="Safari 1.0"), dict(ip='192.168.123.150', user_agent="Mozilla 1.0"), dict(ip='192.168.123.160'), ) for unique in UNIQUES: request = self.mk_request(**unique) for x in range(1, MAX + 1): obj_1.boogs.increment(request) eq_(x, obj_1.boogs.get_total_for_request(request)) obj_1.boogs.increment(request) obj_1.boogs.increment(request) eq_(MAX, obj_1.boogs.get_total_for_request(request)) eq_(MAX * len(UNIQUES), obj_1.boogs.total) # Undo all the increments before going below zero for unique in UNIQUES: request = self.mk_request(**unique) for x in range(1, MAX + 1): obj_1.boogs.decrement(request) for unique in UNIQUES: request = self.mk_request(**unique) for x in range(1, (0 - MIN) + 1): obj_1.boogs.decrement(request) eq_(0 - x, obj_1.boogs.get_total_for_request(request)) obj_1.boogs.decrement(request) obj_1.boogs.decrement(request) eq_(MIN, obj_1.boogs.get_total_for_request(request)) eq_(MIN * len(UNIQUES), obj_1.boogs.total) def test_count_starts_at_zero(self): """ Make sure initial count is zero. Sounds dumb, but it was a bug at one point. """ request = self.mk_request() eq_(0, self.obj_1.likes.get_total_for_request(request))
mpl-2.0
[ 504, 1639, 14, 1018, 14, 3924, 492, 14326, 11188, 28239, 199, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 29952, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 1014, 492, 20730, 199, 504, 1639, 14, 396, 492, 18244, 1746, 199, 199, 504, 11354, 14, 2537, 492, 3850, 3131, 4112, 63, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 1022, 85, 391, 14, 1018, 14, 1208, 492, 664, 63, 3235, 199, 504, 2508, 992, 492, 10033, 11348, 11427, 199, 504, 1275, 992, 492, 1379, 1685, 421, 199, 533, 10033, 24532, 878, 774, 8, 10161, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 3310, 24532, 878, 774, 12, 291, 680, 5996, 342, 267, 2876, 275, 664, 63, 751, 63, 1238, 342, 267, 291, 14, 751, 17, 275, 2876, 14, 1462, 14, 981, 63, 751, 8, 288, 283, 8234, 17, 297, 283, 8234, 18, 32, 8234, 14, 957, 297, 283, 8234, 17, 358, 267, 291, 14, 751, 18, 275, 2876, 14, 1462, 14, 981, 63, 751, 8, 288, 283, 8234, 18, 297, 283, 8234, 18, 32, 8234, 14, 957, 297, 283, 8234, 18, 358, 398, 291, 14, 1113, 63, 17, 275, 1379, 1685, 8, 1213, 628, 4468, 531, 267, 291, 14, 1113, 63, 17, 14, 2117, 342, 339, 347, 9199, 63, 1069, 8, 277, 12, 922, 29, 403, 12, 3384, 534, 5756, 14, 6568, 14, 4288, 14, 4288, 297, 922, 63, 4054, 534, 8249, 11930, 413, 14, 16, 735, 267, 1056, 275, 20730, 342, 267, 1056, 14, 751, 275, 922, 436, 922, 503, 29952, 342, 267, 1056, 14, 765, 275, 283, 2970, 7, 267, 1056, 14, 10614, 459, 16058, 63, 7803, 418, 275, 3384, 267, 1056, 14, 10614, 459, 2856, 63, 3791, 63, 14565, 418, 275, 922, 63, 4054, 267, 372, 1056, 339, 768, 962, 360, 1266, 1876, 12383, 20, 358, 272, 347, 511, 63, 1266, 1876, 12383, 20, 8, 277, 304, 267, 408, 17545, 1227, 2635, 16298, 26, 2649, 4528, 315, 1056, 2436, 1077, 440, 2059, 624, 267, 862, 26, 288, 1595, 63, 354, 275, 298, 29572, 2, 288, 1559, 63, 17, 275, 291, 14, 1113, 63, 17, 288, 1559, 63, 17, 63, 319, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1113, 63, 17, 9, 953, 1056, 275, 291, 14, 3880, 63, 1069, 8, 751, 63, 4054, 29, 85, 2, 7700, 60, 9532, 60, 9566, 60, 1774, 697, 5202, 531, 288, 922, 12, 3384, 12, 922, 63, 4054, 12, 3747, 63, 2227, 275, 664, 63, 3235, 8, 1113, 63, 17, 63, 319, 12, 15491, 1559, 63, 17, 14, 2051, 12, 15491, 536, 29, 1287, 63, 354, 12, 15491, 1056, 29, 1069, 9, 267, 871, 18965, 26, 288, 4112, 2531, 797, 12, 298, 7087, 12620, 1077, 440, 506, 14031, 531, 339, 768, 962, 360, 4087, 63, 6048, 358, 272, 347, 511, 63, 4087, 63, 6048, 63, 16558, 8, 277, 304, 267, 408, 267, 18771, 3663, 21272, 12, 12570, 754, 402, 21209, 5558, 12, 267, 4868, 19756, 1893, 7252, 267, 408, 267, 1595, 63, 354, 275, 298, 29572, 2, 267, 1559, 63, 17, 275, 291, 14, 1113, 63, 17, 267, 1559, 63, 17, 63, 319, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1113, 63, 17, 9, 398, 1056, 275, 291, 14, 3880, 63, 1069, 342, 267, 922, 12, 3384, 12, 922, 63, 4054, 12, 3747, 63, 2227, 275, 664, 63, 3235, 8, 1113, 63, 17, 63, 319, 12, 1559, 63, 17, 14, 2051, 12, 10940, 536, 29, 1287, 63, 354, 12, 10940, 1056, 29, 1069, 9, 398, 327, 2790, 376, 2536, 7055, 2777, 5370, 14, 267, 399, 17, 275, 10033, 11348, 11427, 8, 1317, 63, 466, 29, 1113, 63, 17, 63, 319, 12, 909, 63, 2051, 29, 1113, 63, 17, 14, 2051, 12, 639, 536, 29, 1287, 63, 354, 12, 3141, 29, 17, 12, 3384, 29, 711, 12, 639, 922, 63, 4054, 29, 751, 63, 4054, 12, 922, 29, 751, 9, 267, 399, 17, 14, 2117, 342, 398, 327, 12934, 282, 9250, 7055, 1077, 506, 876, 1856, 471, 737, 314, 1402, 2166, 14, 267, 862, 26, 288, 399, 18, 275, 10033, 11348, 11427, 8, 1317, 63, 466, 29, 1113, 63, 17, 63, 319, 12, 909, 63, 2051, 29, 1113, 63, 17, 14, 2051, 12, 3660, 536, 29, 1287, 63, 354, 12, 3141, 29, 17, 12, 3384, 29, 711, 12, 3660, 922, 63, 4054, 29, 751, 63, 4054, 12, 922, 29, 751, 9, 288, 399, 18, 14, 2117, 342, 288, 4112, 2531, 797, 12, 298, 2765, 1077, 1172, 15572, 376, 26864, 531, 267, 871, 26, 288, 986, 398, 327, 7649, 664, 63, 3235, 63, 509, 63, 1069, 12, 1314, 1077, 7485, 1536, 314, 2849, 3747, 267, 327, 2777, 2737, 14119, 14, 267, 862, 26, 288, 334, 85, 12, 2737, 9, 275, 10033, 11348, 11427, 14, 1462, 14, 362, 63, 3235, 63, 509, 63, 1069, 8, 355, 1559, 63, 17, 12, 1595, 63, 354, 12, 1056, 9, 288, 3850, 2531, 797, 12, 2737, 9, 267, 871, 14326, 11188, 28239, 26, 288, 4112, 2531, 797, 12, 298, 8433, 11188, 28239, 1077, 440, 506, 4915, 531, 339, 347, 511, 63, 4316, 63, 1287, 63, 9728, 8, 277, 304, 267, 408, 3310, 22040, 543, 9978, 3365, 24241, 402, 3747, 14154, 624, 398, 1559, 63, 17, 275, 291, 14, 1113, 63, 17, 398, 327, 663, 1536, 1056, 367, 16535, 922, 327, 17, 267, 1056, 275, 291, 14, 3880, 63, 1069, 342, 398, 327, 16535, 922, 327, 17, 1212, 9246, 922, 18, 267, 1559, 63, 17, 14, 29572, 14, 9728, 8, 1069, 9, 267, 3850, 2531, 17, 12, 1559, 63, 17, 14, 29572, 14, 2923, 9, 398, 327, 16535, 922, 327, 17, 1212, 9246, 922, 18, 12, 4020, 267, 1559, 63, 17, 14, 29572, 14, 9728, 8, 1069, 9, 267, 3850, 2531, 17, 12, 1559, 63, 17, 14, 29572, 14, 2923, 9, 398, 327, 663, 1536, 1056, 367, 16535, 922, 327, 18, 267, 1056, 275, 291, 14, 3880, 63, 1069, 8, 711, 534, 5756, 14, 6568, 14, 4288, 14, 17, 358, 398, 327, 16535, 922, 327, 18, 1212 ]
[ 1639, 14, 1018, 14, 3924, 492, 14326, 11188, 28239, 199, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 29952, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 1014, 492, 20730, 199, 504, 1639, 14, 396, 492, 18244, 1746, 199, 199, 504, 11354, 14, 2537, 492, 3850, 3131, 4112, 63, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 1022, 85, 391, 14, 1018, 14, 1208, 492, 664, 63, 3235, 199, 504, 2508, 992, 492, 10033, 11348, 11427, 199, 504, 1275, 992, 492, 1379, 1685, 421, 199, 533, 10033, 24532, 878, 774, 8, 10161, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 3310, 24532, 878, 774, 12, 291, 680, 5996, 342, 267, 2876, 275, 664, 63, 751, 63, 1238, 342, 267, 291, 14, 751, 17, 275, 2876, 14, 1462, 14, 981, 63, 751, 8, 288, 283, 8234, 17, 297, 283, 8234, 18, 32, 8234, 14, 957, 297, 283, 8234, 17, 358, 267, 291, 14, 751, 18, 275, 2876, 14, 1462, 14, 981, 63, 751, 8, 288, 283, 8234, 18, 297, 283, 8234, 18, 32, 8234, 14, 957, 297, 283, 8234, 18, 358, 398, 291, 14, 1113, 63, 17, 275, 1379, 1685, 8, 1213, 628, 4468, 531, 267, 291, 14, 1113, 63, 17, 14, 2117, 342, 339, 347, 9199, 63, 1069, 8, 277, 12, 922, 29, 403, 12, 3384, 534, 5756, 14, 6568, 14, 4288, 14, 4288, 297, 922, 63, 4054, 534, 8249, 11930, 413, 14, 16, 735, 267, 1056, 275, 20730, 342, 267, 1056, 14, 751, 275, 922, 436, 922, 503, 29952, 342, 267, 1056, 14, 765, 275, 283, 2970, 7, 267, 1056, 14, 10614, 459, 16058, 63, 7803, 418, 275, 3384, 267, 1056, 14, 10614, 459, 2856, 63, 3791, 63, 14565, 418, 275, 922, 63, 4054, 267, 372, 1056, 339, 768, 962, 360, 1266, 1876, 12383, 20, 358, 272, 347, 511, 63, 1266, 1876, 12383, 20, 8, 277, 304, 267, 408, 17545, 1227, 2635, 16298, 26, 2649, 4528, 315, 1056, 2436, 1077, 440, 2059, 624, 267, 862, 26, 288, 1595, 63, 354, 275, 298, 29572, 2, 288, 1559, 63, 17, 275, 291, 14, 1113, 63, 17, 288, 1559, 63, 17, 63, 319, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1113, 63, 17, 9, 953, 1056, 275, 291, 14, 3880, 63, 1069, 8, 751, 63, 4054, 29, 85, 2, 7700, 60, 9532, 60, 9566, 60, 1774, 697, 5202, 531, 288, 922, 12, 3384, 12, 922, 63, 4054, 12, 3747, 63, 2227, 275, 664, 63, 3235, 8, 1113, 63, 17, 63, 319, 12, 15491, 1559, 63, 17, 14, 2051, 12, 15491, 536, 29, 1287, 63, 354, 12, 15491, 1056, 29, 1069, 9, 267, 871, 18965, 26, 288, 4112, 2531, 797, 12, 298, 7087, 12620, 1077, 440, 506, 14031, 531, 339, 768, 962, 360, 4087, 63, 6048, 358, 272, 347, 511, 63, 4087, 63, 6048, 63, 16558, 8, 277, 304, 267, 408, 267, 18771, 3663, 21272, 12, 12570, 754, 402, 21209, 5558, 12, 267, 4868, 19756, 1893, 7252, 267, 408, 267, 1595, 63, 354, 275, 298, 29572, 2, 267, 1559, 63, 17, 275, 291, 14, 1113, 63, 17, 267, 1559, 63, 17, 63, 319, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1113, 63, 17, 9, 398, 1056, 275, 291, 14, 3880, 63, 1069, 342, 267, 922, 12, 3384, 12, 922, 63, 4054, 12, 3747, 63, 2227, 275, 664, 63, 3235, 8, 1113, 63, 17, 63, 319, 12, 1559, 63, 17, 14, 2051, 12, 10940, 536, 29, 1287, 63, 354, 12, 10940, 1056, 29, 1069, 9, 398, 327, 2790, 376, 2536, 7055, 2777, 5370, 14, 267, 399, 17, 275, 10033, 11348, 11427, 8, 1317, 63, 466, 29, 1113, 63, 17, 63, 319, 12, 909, 63, 2051, 29, 1113, 63, 17, 14, 2051, 12, 639, 536, 29, 1287, 63, 354, 12, 3141, 29, 17, 12, 3384, 29, 711, 12, 639, 922, 63, 4054, 29, 751, 63, 4054, 12, 922, 29, 751, 9, 267, 399, 17, 14, 2117, 342, 398, 327, 12934, 282, 9250, 7055, 1077, 506, 876, 1856, 471, 737, 314, 1402, 2166, 14, 267, 862, 26, 288, 399, 18, 275, 10033, 11348, 11427, 8, 1317, 63, 466, 29, 1113, 63, 17, 63, 319, 12, 909, 63, 2051, 29, 1113, 63, 17, 14, 2051, 12, 3660, 536, 29, 1287, 63, 354, 12, 3141, 29, 17, 12, 3384, 29, 711, 12, 3660, 922, 63, 4054, 29, 751, 63, 4054, 12, 922, 29, 751, 9, 288, 399, 18, 14, 2117, 342, 288, 4112, 2531, 797, 12, 298, 2765, 1077, 1172, 15572, 376, 26864, 531, 267, 871, 26, 288, 986, 398, 327, 7649, 664, 63, 3235, 63, 509, 63, 1069, 12, 1314, 1077, 7485, 1536, 314, 2849, 3747, 267, 327, 2777, 2737, 14119, 14, 267, 862, 26, 288, 334, 85, 12, 2737, 9, 275, 10033, 11348, 11427, 14, 1462, 14, 362, 63, 3235, 63, 509, 63, 1069, 8, 355, 1559, 63, 17, 12, 1595, 63, 354, 12, 1056, 9, 288, 3850, 2531, 797, 12, 2737, 9, 267, 871, 14326, 11188, 28239, 26, 288, 4112, 2531, 797, 12, 298, 8433, 11188, 28239, 1077, 440, 506, 4915, 531, 339, 347, 511, 63, 4316, 63, 1287, 63, 9728, 8, 277, 304, 267, 408, 3310, 22040, 543, 9978, 3365, 24241, 402, 3747, 14154, 624, 398, 1559, 63, 17, 275, 291, 14, 1113, 63, 17, 398, 327, 663, 1536, 1056, 367, 16535, 922, 327, 17, 267, 1056, 275, 291, 14, 3880, 63, 1069, 342, 398, 327, 16535, 922, 327, 17, 1212, 9246, 922, 18, 267, 1559, 63, 17, 14, 29572, 14, 9728, 8, 1069, 9, 267, 3850, 2531, 17, 12, 1559, 63, 17, 14, 29572, 14, 2923, 9, 398, 327, 16535, 922, 327, 17, 1212, 9246, 922, 18, 12, 4020, 267, 1559, 63, 17, 14, 29572, 14, 9728, 8, 1069, 9, 267, 3850, 2531, 17, 12, 1559, 63, 17, 14, 29572, 14, 2923, 9, 398, 327, 663, 1536, 1056, 367, 16535, 922, 327, 18, 267, 1056, 275, 291, 14, 3880, 63, 1069, 8, 711, 534, 5756, 14, 6568, 14, 4288, 14, 17, 358, 398, 327, 16535, 922, 327, 18, 1212, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
NIRALUser/RodentThickness
Applications/RodentThickness/Testing/Data/vtkPointAttributes.py
2
3379
import sys # path="/tools/Python/Python-2.7.3/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg:/tools/Python/Python-2.7.3/lib/python2.7/site-packages/pip-1.0-py2.7.egg:/tools/Python/Python-2.7.3/lib/python2.7/site-packages/VTK-6.0-py2.7.egg:/tools/Python/Python-2.7.3/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg:/tools/Python/Python-2.7.3/lib/python2.7/site-packages/SimpleITK-0.6.0.dev208-py2.7.egg:/tools/Python/Python-2.7.3/lib/python27.zip:/tools/Python/Python-2.7.3/lib/python2.7:/tools/Python/Python-2.7.3/lib/python2.7/plat-linux2:/tools/Python/Python-2.7.3/lib/python2.7/lib-tk:/tools/Python/Python-2.7.3/lib/python2.7/lib-old:/tools/Python/Python-2.7.3/lib/python2.7/lib-dynload:/tools/Python/Python-2.7.3/lib/python2.7/site-packages".split(":") # for p in path: # sys.path.insert(0, p) from vtk import * from optparse import OptionParser import csv,sys import niralvtk as nv import numpy as np def removeAttributes(opts, args): print args inputvtk = args[0] outputvtk = args[1] inVTK = nv.readVTK(inputvtk); nArrays = inVTK.GetPointData().GetNumberOfArrays() arrayNames = [] for k in range(0,nArrays): arrayNames.append(inVTK.GetPointData().GetArrayName(k)) print arrayNames for name in arrayNames: inVTK.GetPointData().RemoveArray(name) nv.writeVTK(outputvtk, inVTK) def main(opts, argv): inputvtk = argv[0] outputvtk = argv[1] inVTK = nv.readVTK(inputvtk); if (opts.sep == "0"): csvreader = csv.reader(open(opts.csvfile, "r")) elif (opts.sep == "1"): csvreader = csv.reader(open(opts.csvfile, "r"), delimiter=',') elif (opts.sep == "2"): csvreader = csv.reader(open(opts.csvfile, "r"), delimiter='\t') first = csvreader.next() if (opts.header): header = first first = csvreader.next() if (opts.names != ""): header = opts.names.split(",") print header nCols = len(first) nPoints = inVTK.GetNumberOfPoints() data = np.zeros([nPoints,nCols]) for k in range(0,nCols): data[0,k] = float(first[k]) print "# points:", nPoints for j in range(1,nPoints): print j first = csvreader.next() for k in range(0,nCols): data[j,k] = float(first[k]) for k in range(0,nCols): arr = vtkDoubleArray() if (len(header) > 0): arr.SetName(header[k]) arr.SetNumberOfTuples(nPoints) for j in range(0,nPoints): arr.SetValue(j,data[j,k]) inVTK.GetPointData().AddArray(arr) nv.writeVTK(outputvtk, inVTK) if (__name__ == "__main__"): parser = OptionParser(usage="usage: %prog [options] input-vtk output-vtk") parser.add_option("-i", "--input", dest="csvfile", help="input attribute csv file", metavar="CSVFILE") parser.add_option("-t", "--title", dest="header", help="use first line as header", action="store_true", default=False); parser.add_option("-n", "--columnNames", dest="names", help="use this as column names", metavar="NAME1,NAME2,...", default=""); parser.add_option("-r", "--removeAttributes", dest="removeAttrs", help="remove all attributes", action="store_true", default=False); parser.add_option("-s", "--separator", dest="sep", help="separator (0=space, 1=comma, 2=tab)", default="0") (opts, args) = parser.parse_args() if (len(args) < 2): parser.print_help() else: if (opts.removeAttrs): removeAttributes(opts, args) else: main(opts, args)
gpl-3.0
[ 199, 646, 984, 199, 199, 3, 931, 9555, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 15, 13623, 13, 16, 14, 22, 67, 845, 13, 647, 18, 14, 23, 14, 5799, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 15, 9983, 13, 17, 14, 16, 13, 647, 18, 14, 23, 14, 5799, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 15, 8156, 43, 13, 22, 14, 16, 13, 647, 18, 14, 23, 14, 5799, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 15, 3470, 13, 16, 14, 22, 14, 1651, 13, 647, 18, 14, 23, 14, 5799, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 15, 3184, 649, 43, 13, 16, 14, 22, 14, 16, 14, 2374, 10630, 13, 647, 18, 14, 23, 14, 5799, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 1465, 14, 3065, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 14156, 13, 5135, 18, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 773, 13, 2663, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 773, 13, 1753, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 773, 13, 17883, 912, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 1674, 1294, 20063, 199, 199, 3, 367, 299, 315, 931, 26, 199, 3, 258, 984, 14, 515, 14, 3176, 8, 16, 12, 299, 9, 4388, 199, 504, 11144, 492, 627, 199, 504, 8691, 492, 13491, 199, 646, 7392, 12, 1274, 199, 646, 302, 723, 279, 11919, 465, 26510, 199, 646, 2680, 465, 980, 199, 199, 318, 2813, 5379, 8, 3291, 12, 1249, 304, 523, 870, 1249, 523, 1324, 11919, 275, 1249, 59, 16, 61, 523, 1072, 11919, 275, 1249, 59, 17, 61, 819, 315, 8156, 43, 275, 26510, 14, 739, 8156, 43, 8, 1210, 11919, 2736, 523, 302, 29033, 275, 315, 8156, 43, 14, 30418, 1451, 1252, 1002, 16030, 29033, 342, 523, 1625, 5866, 275, 942, 523, 367, 1022, 315, 1425, 8, 16, 12, 78, 29033, 304, 272, 1625, 5866, 14, 740, 8, 262, 8156, 43, 14, 30418, 1451, 1252, 1002, 3836, 985, 8, 75, 430, 819, 870, 1625, 5866, 523, 367, 536, 315, 1625, 5866, 26, 272, 315, 8156, 43, 14, 30418, 1451, 1252, 5587, 3836, 8, 354, 9, 819, 26510, 14, 952, 8156, 43, 8, 1199, 11919, 12, 315, 8156, 43, 9, 199, 199, 318, 2446, 8, 3291, 12, 9238, 304, 523, 1324, 11919, 275, 9238, 59, 16, 61, 523, 1072, 11919, 275, 9238, 59, 17, 61, 819, 315, 8156, 43, 275, 26510, 14, 739, 8156, 43, 8, 1210, 11919, 2736, 523, 340, 334, 3291, 14, 4127, 508, 298, 16, 2349, 272, 7392, 5503, 275, 7392, 14, 5503, 8, 1490, 8, 3291, 14, 4737, 493, 12, 298, 82, 2237, 523, 916, 334, 3291, 14, 4127, 508, 298, 17, 2349, 272, 7392, 5503, 275, 7392, 14, 5503, 8, 1490, 8, 3291, 14, 4737, 493, 12, 298, 82, 1288, 11172, 4009, 358, 523, 916, 334, 3291, 14, 4127, 508, 298, 18, 2349, 272, 7392, 5503, 275, 7392, 14, 5503, 8, 1490, 8, 3291, 14, 4737, 493, 12, 298, 82, 1288, 11172, 17115, 84, 358, 2043, 8330, 1642, 275, 7392, 5503, 14, 2184, 342, 523, 340, 334, 3291, 14, 1291, 304, 272, 1406, 275, 1642, 272, 1642, 275, 7392, 5503, 14, 2184, 342, 819, 340, 334, 3291, 14, 1247, 1137, 26430, 272, 1406, 275, 3999, 14, 1247, 14, 1294, 20324, 819, 870, 1406, 12244, 302, 17203, 275, 822, 8, 2246, 9, 523, 302, 10225, 275, 315, 8156, 43, 14, 1002, 16030, 10225, 342, 221, 819, 666, 275, 980, 14, 4250, 779, 78, 10225, 12, 78, 17203, 566, 523, 367, 1022, 315, 1425, 8, 16, 12, 78, 17203, 304, 272, 666, 59, 16, 12, 75, 61, 275, 2069, 8, 2246, 59, 75, 566, 819, 870, 5426, 4501, 6783, 302, 10225, 523, 367, 1335, 315, 1425, 8, 17, 12, 78, 10225, 304, 272, 870, 1335, 272, 1642, 275, 7392, 5503, 14, 2184, 342, 272, 367, 1022, 315, 1425, 8, 16, 12, 78, 17203, 304, 489, 666, 59, 74, 12, 75, 61, 275, 2069, 8, 2246, 59, 75, 566, 819, 367, 1022, 315, 1425, 8, 16, 12, 78, 17203, 304, 272, 7953, 275, 11144, 7281, 3836, 342, 272, 340, 334, 552, 8, 1291, 9, 690, 378, 304, 489, 7953, 14, 1084, 985, 8, 1291, 59, 75, 566, 272, 7953, 14, 1084, 16030, 7075, 83, 8, 78, 10225, 9, 272, 367, 1335, 315, 1425, 8, 16, 12, 78, 10225, 304, 489, 7953, 14, 21322, 8, 74, 12, 576, 59, 74, 12, 75, 566, 272, 315, 8156, 43, 14, 30418, 1451, 1252, 1123, 3836, 8, 5250, 9, 27404, 26510, 14, 952, 8156, 43, 8, 1199, 11919, 12, 315, 8156, 43, 9, 199, 199, 692, 25373, 354, 363, 508, 4396, 973, 363, 2349, 523, 1798, 275, 13491, 8, 3807, 628, 3807, 26, 450, 6595, 359, 1419, 61, 1324, 13, 11919, 1072, 13, 11919, 531, 523, 1798, 14, 525, 63, 1422, 6096, 73, 401, 4320, 1210, 401, 2053, 628, 4737, 493, 401, 1720, 628, 1210, 2225, 7392, 570, 401, 8214, 628, 19018, 3817, 531, 523, 1798, 14, 525, 63, 1422, 6096, 84, 401, 4320, 1213, 401, 2053, 628, 1291, 401, 1720, 628, 1180, 1642, 1004, 465, 1406, 401, 1595, 628, 1617, 63, 2052, 401, 849, 29, 797, 2736 ]
[ 646, 984, 199, 199, 3, 931, 9555, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 15, 13623, 13, 16, 14, 22, 67, 845, 13, 647, 18, 14, 23, 14, 5799, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 15, 9983, 13, 17, 14, 16, 13, 647, 18, 14, 23, 14, 5799, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 15, 8156, 43, 13, 22, 14, 16, 13, 647, 18, 14, 23, 14, 5799, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 15, 3470, 13, 16, 14, 22, 14, 1651, 13, 647, 18, 14, 23, 14, 5799, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 15, 3184, 649, 43, 13, 16, 14, 22, 14, 16, 14, 2374, 10630, 13, 647, 18, 14, 23, 14, 5799, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 1465, 14, 3065, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 14156, 13, 5135, 18, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 773, 13, 2663, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 773, 13, 1753, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 773, 13, 17883, 912, 11254, 2537, 15, 4718, 15, 4718, 13, 18, 14, 23, 14, 19, 15, 773, 15, 1548, 18, 14, 23, 15, 2124, 13, 5154, 1674, 1294, 20063, 199, 199, 3, 367, 299, 315, 931, 26, 199, 3, 258, 984, 14, 515, 14, 3176, 8, 16, 12, 299, 9, 4388, 199, 504, 11144, 492, 627, 199, 504, 8691, 492, 13491, 199, 646, 7392, 12, 1274, 199, 646, 302, 723, 279, 11919, 465, 26510, 199, 646, 2680, 465, 980, 199, 199, 318, 2813, 5379, 8, 3291, 12, 1249, 304, 523, 870, 1249, 523, 1324, 11919, 275, 1249, 59, 16, 61, 523, 1072, 11919, 275, 1249, 59, 17, 61, 819, 315, 8156, 43, 275, 26510, 14, 739, 8156, 43, 8, 1210, 11919, 2736, 523, 302, 29033, 275, 315, 8156, 43, 14, 30418, 1451, 1252, 1002, 16030, 29033, 342, 523, 1625, 5866, 275, 942, 523, 367, 1022, 315, 1425, 8, 16, 12, 78, 29033, 304, 272, 1625, 5866, 14, 740, 8, 262, 8156, 43, 14, 30418, 1451, 1252, 1002, 3836, 985, 8, 75, 430, 819, 870, 1625, 5866, 523, 367, 536, 315, 1625, 5866, 26, 272, 315, 8156, 43, 14, 30418, 1451, 1252, 5587, 3836, 8, 354, 9, 819, 26510, 14, 952, 8156, 43, 8, 1199, 11919, 12, 315, 8156, 43, 9, 199, 199, 318, 2446, 8, 3291, 12, 9238, 304, 523, 1324, 11919, 275, 9238, 59, 16, 61, 523, 1072, 11919, 275, 9238, 59, 17, 61, 819, 315, 8156, 43, 275, 26510, 14, 739, 8156, 43, 8, 1210, 11919, 2736, 523, 340, 334, 3291, 14, 4127, 508, 298, 16, 2349, 272, 7392, 5503, 275, 7392, 14, 5503, 8, 1490, 8, 3291, 14, 4737, 493, 12, 298, 82, 2237, 523, 916, 334, 3291, 14, 4127, 508, 298, 17, 2349, 272, 7392, 5503, 275, 7392, 14, 5503, 8, 1490, 8, 3291, 14, 4737, 493, 12, 298, 82, 1288, 11172, 4009, 358, 523, 916, 334, 3291, 14, 4127, 508, 298, 18, 2349, 272, 7392, 5503, 275, 7392, 14, 5503, 8, 1490, 8, 3291, 14, 4737, 493, 12, 298, 82, 1288, 11172, 17115, 84, 358, 2043, 8330, 1642, 275, 7392, 5503, 14, 2184, 342, 523, 340, 334, 3291, 14, 1291, 304, 272, 1406, 275, 1642, 272, 1642, 275, 7392, 5503, 14, 2184, 342, 819, 340, 334, 3291, 14, 1247, 1137, 26430, 272, 1406, 275, 3999, 14, 1247, 14, 1294, 20324, 819, 870, 1406, 12244, 302, 17203, 275, 822, 8, 2246, 9, 523, 302, 10225, 275, 315, 8156, 43, 14, 1002, 16030, 10225, 342, 221, 819, 666, 275, 980, 14, 4250, 779, 78, 10225, 12, 78, 17203, 566, 523, 367, 1022, 315, 1425, 8, 16, 12, 78, 17203, 304, 272, 666, 59, 16, 12, 75, 61, 275, 2069, 8, 2246, 59, 75, 566, 819, 870, 5426, 4501, 6783, 302, 10225, 523, 367, 1335, 315, 1425, 8, 17, 12, 78, 10225, 304, 272, 870, 1335, 272, 1642, 275, 7392, 5503, 14, 2184, 342, 272, 367, 1022, 315, 1425, 8, 16, 12, 78, 17203, 304, 489, 666, 59, 74, 12, 75, 61, 275, 2069, 8, 2246, 59, 75, 566, 819, 367, 1022, 315, 1425, 8, 16, 12, 78, 17203, 304, 272, 7953, 275, 11144, 7281, 3836, 342, 272, 340, 334, 552, 8, 1291, 9, 690, 378, 304, 489, 7953, 14, 1084, 985, 8, 1291, 59, 75, 566, 272, 7953, 14, 1084, 16030, 7075, 83, 8, 78, 10225, 9, 272, 367, 1335, 315, 1425, 8, 16, 12, 78, 10225, 304, 489, 7953, 14, 21322, 8, 74, 12, 576, 59, 74, 12, 75, 566, 272, 315, 8156, 43, 14, 30418, 1451, 1252, 1123, 3836, 8, 5250, 9, 27404, 26510, 14, 952, 8156, 43, 8, 1199, 11919, 12, 315, 8156, 43, 9, 199, 199, 692, 25373, 354, 363, 508, 4396, 973, 363, 2349, 523, 1798, 275, 13491, 8, 3807, 628, 3807, 26, 450, 6595, 359, 1419, 61, 1324, 13, 11919, 1072, 13, 11919, 531, 523, 1798, 14, 525, 63, 1422, 6096, 73, 401, 4320, 1210, 401, 2053, 628, 4737, 493, 401, 1720, 628, 1210, 2225, 7392, 570, 401, 8214, 628, 19018, 3817, 531, 523, 1798, 14, 525, 63, 1422, 6096, 84, 401, 4320, 1213, 401, 2053, 628, 1291, 401, 1720, 628, 1180, 1642, 1004, 465, 1406, 401, 1595, 628, 1617, 63, 2052, 401, 849, 29, 797, 2736, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
LaMi-/pmatic
ccu_pkg/python/lib/python2.7/encodings/mac_greek.py
593
13977
""" Python Character Mapping Codec mac_greek generated from 'MAPPINGS/VENDORS/APPLE/GREEK.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_table) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_table)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_table)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='mac-greek', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Table decoding_table = ( u'\x00' # 0x00 -> CONTROL CHARACTER u'\x01' # 0x01 -> CONTROL CHARACTER u'\x02' # 0x02 -> CONTROL CHARACTER u'\x03' # 0x03 -> CONTROL CHARACTER u'\x04' # 0x04 -> CONTROL CHARACTER u'\x05' # 0x05 -> CONTROL CHARACTER u'\x06' # 0x06 -> CONTROL CHARACTER u'\x07' # 0x07 -> CONTROL CHARACTER u'\x08' # 0x08 -> CONTROL CHARACTER u'\t' # 0x09 -> CONTROL CHARACTER u'\n' # 0x0A -> CONTROL CHARACTER u'\x0b' # 0x0B -> CONTROL CHARACTER u'\x0c' # 0x0C -> CONTROL CHARACTER u'\r' # 0x0D -> CONTROL CHARACTER u'\x0e' # 0x0E -> CONTROL CHARACTER u'\x0f' # 0x0F -> CONTROL CHARACTER u'\x10' # 0x10 -> CONTROL CHARACTER u'\x11' # 0x11 -> CONTROL CHARACTER u'\x12' # 0x12 -> CONTROL CHARACTER u'\x13' # 0x13 -> CONTROL CHARACTER u'\x14' # 0x14 -> CONTROL CHARACTER u'\x15' # 0x15 -> CONTROL CHARACTER u'\x16' # 0x16 -> CONTROL CHARACTER u'\x17' # 0x17 -> CONTROL CHARACTER u'\x18' # 0x18 -> CONTROL CHARACTER u'\x19' # 0x19 -> CONTROL CHARACTER u'\x1a' # 0x1A -> CONTROL CHARACTER u'\x1b' # 0x1B -> CONTROL CHARACTER u'\x1c' # 0x1C -> CONTROL CHARACTER u'\x1d' # 0x1D -> CONTROL CHARACTER u'\x1e' # 0x1E -> CONTROL CHARACTER u'\x1f' # 0x1F -> CONTROL CHARACTER u' ' # 0x20 -> SPACE u'!' # 0x21 -> EXCLAMATION MARK u'"' # 0x22 -> QUOTATION MARK u'#' # 0x23 -> NUMBER SIGN u'$' # 0x24 -> DOLLAR SIGN u'%' # 0x25 -> PERCENT SIGN u'&' # 0x26 -> AMPERSAND u"'" # 0x27 -> APOSTROPHE u'(' # 0x28 -> LEFT PARENTHESIS u')' # 0x29 -> RIGHT PARENTHESIS u'*' # 0x2A -> ASTERISK u'+' # 0x2B -> PLUS SIGN u',' # 0x2C -> COMMA u'-' # 0x2D -> HYPHEN-MINUS u'.' # 0x2E -> FULL STOP u'/' # 0x2F -> SOLIDUS u'0' # 0x30 -> DIGIT ZERO u'1' # 0x31 -> DIGIT ONE u'2' # 0x32 -> DIGIT TWO u'3' # 0x33 -> DIGIT THREE u'4' # 0x34 -> DIGIT FOUR u'5' # 0x35 -> DIGIT FIVE u'6' # 0x36 -> DIGIT SIX u'7' # 0x37 -> DIGIT SEVEN u'8' # 0x38 -> DIGIT EIGHT u'9' # 0x39 -> DIGIT NINE u':' # 0x3A -> COLON u';' # 0x3B -> SEMICOLON u'<' # 0x3C -> LESS-THAN SIGN u'=' # 0x3D -> EQUALS SIGN u'>' # 0x3E -> GREATER-THAN SIGN u'?' # 0x3F -> QUESTION MARK u'@' # 0x40 -> COMMERCIAL AT u'A' # 0x41 -> LATIN CAPITAL LETTER A u'B' # 0x42 -> LATIN CAPITAL LETTER B u'C' # 0x43 -> LATIN CAPITAL LETTER C u'D' # 0x44 -> LATIN CAPITAL LETTER D u'E' # 0x45 -> LATIN CAPITAL LETTER E u'F' # 0x46 -> LATIN CAPITAL LETTER F u'G' # 0x47 -> LATIN CAPITAL LETTER G u'H' # 0x48 -> LATIN CAPITAL LETTER H u'I' # 0x49 -> LATIN CAPITAL LETTER I u'J' # 0x4A -> LATIN CAPITAL LETTER J u'K' # 0x4B -> LATIN CAPITAL LETTER K u'L' # 0x4C -> LATIN CAPITAL LETTER L u'M' # 0x4D -> LATIN CAPITAL LETTER M u'N' # 0x4E -> LATIN CAPITAL LETTER N u'O' # 0x4F -> LATIN CAPITAL LETTER O u'P' # 0x50 -> LATIN CAPITAL LETTER P u'Q' # 0x51 -> LATIN CAPITAL LETTER Q u'R' # 0x52 -> LATIN CAPITAL LETTER R u'S' # 0x53 -> LATIN CAPITAL LETTER S u'T' # 0x54 -> LATIN CAPITAL LETTER T u'U' # 0x55 -> LATIN CAPITAL LETTER U u'V' # 0x56 -> LATIN CAPITAL LETTER V u'W' # 0x57 -> LATIN CAPITAL LETTER W u'X' # 0x58 -> LATIN CAPITAL LETTER X u'Y' # 0x59 -> LATIN CAPITAL LETTER Y u'Z' # 0x5A -> LATIN CAPITAL LETTER Z u'[' # 0x5B -> LEFT SQUARE BRACKET u'\\' # 0x5C -> REVERSE SOLIDUS u']' # 0x5D -> RIGHT SQUARE BRACKET u'^' # 0x5E -> CIRCUMFLEX ACCENT u'_' # 0x5F -> LOW LINE u'`' # 0x60 -> GRAVE ACCENT u'a' # 0x61 -> LATIN SMALL LETTER A u'b' # 0x62 -> LATIN SMALL LETTER B u'c' # 0x63 -> LATIN SMALL LETTER C u'd' # 0x64 -> LATIN SMALL LETTER D u'e' # 0x65 -> LATIN SMALL LETTER E u'f' # 0x66 -> LATIN SMALL LETTER F u'g' # 0x67 -> LATIN SMALL LETTER G u'h' # 0x68 -> LATIN SMALL LETTER H u'i' # 0x69 -> LATIN SMALL LETTER I u'j' # 0x6A -> LATIN SMALL LETTER J u'k' # 0x6B -> LATIN SMALL LETTER K u'l' # 0x6C -> LATIN SMALL LETTER L u'm' # 0x6D -> LATIN SMALL LETTER M u'n' # 0x6E -> LATIN SMALL LETTER N u'o' # 0x6F -> LATIN SMALL LETTER O u'p' # 0x70 -> LATIN SMALL LETTER P u'q' # 0x71 -> LATIN SMALL LETTER Q u'r' # 0x72 -> LATIN SMALL LETTER R u's' # 0x73 -> LATIN SMALL LETTER S u't' # 0x74 -> LATIN SMALL LETTER T u'u' # 0x75 -> LATIN SMALL LETTER U u'v' # 0x76 -> LATIN SMALL LETTER V u'w' # 0x77 -> LATIN SMALL LETTER W u'x' # 0x78 -> LATIN SMALL LETTER X u'y' # 0x79 -> LATIN SMALL LETTER Y u'z' # 0x7A -> LATIN SMALL LETTER Z u'{' # 0x7B -> LEFT CURLY BRACKET u'|' # 0x7C -> VERTICAL LINE u'}' # 0x7D -> RIGHT CURLY BRACKET u'~' # 0x7E -> TILDE u'\x7f' # 0x7F -> CONTROL CHARACTER u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS u'\xb9' # 0x81 -> SUPERSCRIPT ONE u'\xb2' # 0x82 -> SUPERSCRIPT TWO u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE u'\xb3' # 0x84 -> SUPERSCRIPT THREE u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS u'\u0385' # 0x87 -> GREEK DIALYTIKA TONOS u'\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE u'\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS u'\u0384' # 0x8B -> GREEK TONOS u'\xa8' # 0x8C -> DIAERESIS u'\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE u'\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE u'\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX u'\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS u'\xa3' # 0x92 -> POUND SIGN u'\u2122' # 0x93 -> TRADE MARK SIGN u'\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX u'\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS u'\u2022' # 0x96 -> BULLET u'\xbd' # 0x97 -> VULGAR FRACTION ONE HALF u'\u2030' # 0x98 -> PER MILLE SIGN u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS u'\xa6' # 0x9B -> BROKEN BAR u'\u20ac' # 0x9C -> EURO SIGN # before Mac OS 9.2.2, was SOFT HYPHEN u'\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE u'\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS u'\u2020' # 0xA0 -> DAGGER u'\u0393' # 0xA1 -> GREEK CAPITAL LETTER GAMMA u'\u0394' # 0xA2 -> GREEK CAPITAL LETTER DELTA u'\u0398' # 0xA3 -> GREEK CAPITAL LETTER THETA u'\u039b' # 0xA4 -> GREEK CAPITAL LETTER LAMDA u'\u039e' # 0xA5 -> GREEK CAPITAL LETTER XI u'\u03a0' # 0xA6 -> GREEK CAPITAL LETTER PI u'\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S u'\xae' # 0xA8 -> REGISTERED SIGN u'\xa9' # 0xA9 -> COPYRIGHT SIGN u'\u03a3' # 0xAA -> GREEK CAPITAL LETTER SIGMA u'\u03aa' # 0xAB -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA u'\xa7' # 0xAC -> SECTION SIGN u'\u2260' # 0xAD -> NOT EQUAL TO u'\xb0' # 0xAE -> DEGREE SIGN u'\xb7' # 0xAF -> MIDDLE DOT u'\u0391' # 0xB0 -> GREEK CAPITAL LETTER ALPHA u'\xb1' # 0xB1 -> PLUS-MINUS SIGN u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO u'\xa5' # 0xB4 -> YEN SIGN u'\u0392' # 0xB5 -> GREEK CAPITAL LETTER BETA u'\u0395' # 0xB6 -> GREEK CAPITAL LETTER EPSILON u'\u0396' # 0xB7 -> GREEK CAPITAL LETTER ZETA u'\u0397' # 0xB8 -> GREEK CAPITAL LETTER ETA u'\u0399' # 0xB9 -> GREEK CAPITAL LETTER IOTA u'\u039a' # 0xBA -> GREEK CAPITAL LETTER KAPPA u'\u039c' # 0xBB -> GREEK CAPITAL LETTER MU u'\u03a6' # 0xBC -> GREEK CAPITAL LETTER PHI u'\u03ab' # 0xBD -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA u'\u03a8' # 0xBE -> GREEK CAPITAL LETTER PSI u'\u03a9' # 0xBF -> GREEK CAPITAL LETTER OMEGA u'\u03ac' # 0xC0 -> GREEK SMALL LETTER ALPHA WITH TONOS u'\u039d' # 0xC1 -> GREEK CAPITAL LETTER NU u'\xac' # 0xC2 -> NOT SIGN u'\u039f' # 0xC3 -> GREEK CAPITAL LETTER OMICRON u'\u03a1' # 0xC4 -> GREEK CAPITAL LETTER RHO u'\u2248' # 0xC5 -> ALMOST EQUAL TO u'\u03a4' # 0xC6 -> GREEK CAPITAL LETTER TAU u'\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK u'\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK u'\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS u'\xa0' # 0xCA -> NO-BREAK SPACE u'\u03a5' # 0xCB -> GREEK CAPITAL LETTER UPSILON u'\u03a7' # 0xCC -> GREEK CAPITAL LETTER CHI u'\u0386' # 0xCD -> GREEK CAPITAL LETTER ALPHA WITH TONOS u'\u0388' # 0xCE -> GREEK CAPITAL LETTER EPSILON WITH TONOS u'\u0153' # 0xCF -> LATIN SMALL LIGATURE OE u'\u2013' # 0xD0 -> EN DASH u'\u2015' # 0xD1 -> HORIZONTAL BAR u'\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK u'\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK u'\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK u'\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK u'\xf7' # 0xD6 -> DIVISION SIGN u'\u0389' # 0xD7 -> GREEK CAPITAL LETTER ETA WITH TONOS u'\u038a' # 0xD8 -> GREEK CAPITAL LETTER IOTA WITH TONOS u'\u038c' # 0xD9 -> GREEK CAPITAL LETTER OMICRON WITH TONOS u'\u038e' # 0xDA -> GREEK CAPITAL LETTER UPSILON WITH TONOS u'\u03ad' # 0xDB -> GREEK SMALL LETTER EPSILON WITH TONOS u'\u03ae' # 0xDC -> GREEK SMALL LETTER ETA WITH TONOS u'\u03af' # 0xDD -> GREEK SMALL LETTER IOTA WITH TONOS u'\u03cc' # 0xDE -> GREEK SMALL LETTER OMICRON WITH TONOS u'\u038f' # 0xDF -> GREEK CAPITAL LETTER OMEGA WITH TONOS u'\u03cd' # 0xE0 -> GREEK SMALL LETTER UPSILON WITH TONOS u'\u03b1' # 0xE1 -> GREEK SMALL LETTER ALPHA u'\u03b2' # 0xE2 -> GREEK SMALL LETTER BETA u'\u03c8' # 0xE3 -> GREEK SMALL LETTER PSI u'\u03b4' # 0xE4 -> GREEK SMALL LETTER DELTA u'\u03b5' # 0xE5 -> GREEK SMALL LETTER EPSILON u'\u03c6' # 0xE6 -> GREEK SMALL LETTER PHI u'\u03b3' # 0xE7 -> GREEK SMALL LETTER GAMMA u'\u03b7' # 0xE8 -> GREEK SMALL LETTER ETA u'\u03b9' # 0xE9 -> GREEK SMALL LETTER IOTA u'\u03be' # 0xEA -> GREEK SMALL LETTER XI u'\u03ba' # 0xEB -> GREEK SMALL LETTER KAPPA u'\u03bb' # 0xEC -> GREEK SMALL LETTER LAMDA u'\u03bc' # 0xED -> GREEK SMALL LETTER MU u'\u03bd' # 0xEE -> GREEK SMALL LETTER NU u'\u03bf' # 0xEF -> GREEK SMALL LETTER OMICRON u'\u03c0' # 0xF0 -> GREEK SMALL LETTER PI u'\u03ce' # 0xF1 -> GREEK SMALL LETTER OMEGA WITH TONOS u'\u03c1' # 0xF2 -> GREEK SMALL LETTER RHO u'\u03c3' # 0xF3 -> GREEK SMALL LETTER SIGMA u'\u03c4' # 0xF4 -> GREEK SMALL LETTER TAU u'\u03b8' # 0xF5 -> GREEK SMALL LETTER THETA u'\u03c9' # 0xF6 -> GREEK SMALL LETTER OMEGA u'\u03c2' # 0xF7 -> GREEK SMALL LETTER FINAL SIGMA u'\u03c7' # 0xF8 -> GREEK SMALL LETTER CHI u'\u03c5' # 0xF9 -> GREEK SMALL LETTER UPSILON u'\u03b6' # 0xFA -> GREEK SMALL LETTER ZETA u'\u03ca' # 0xFB -> GREEK SMALL LETTER IOTA WITH DIALYTIKA u'\u03cb' # 0xFC -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA u'\u0390' # 0xFD -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS u'\u03b0' # 0xFE -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS u'\xad' # 0xFF -> SOFT HYPHEN # before Mac OS 9.2.2, was undefined ) ### Encoding table encoding_table=codecs.charmap_build(decoding_table)
gpl-2.0
[ 624, 2018, 17660, 12340, 13732, 4497, 63, 32007, 4046, 687, 283, 32362, 15, 27839, 4149, 15, 31683, 15, 39, 7440, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 3088, 13, 32007, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 8098, 9502, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 8098, 9502, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 8098, 9502, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 8098, 9502, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 8098, 9502, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 8098, 9502, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 8098, 9502, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 8098, 9502, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 8098, 9502, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8098, 9502, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 8098, 9502, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 8098, 9502, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 8098, 9502, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 8098, 9502, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 8098, 9502, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 8098, 9502, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 8098, 9502, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 8098, 9502, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 8098, 9502, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 8098, 9502, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 8098, 9502, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 8098, 9502, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 399, 7, 17, 7, 263, 327, 221, 378, 88, 2192, 1035, 7298, 13051, 272, 399, 7, 18, 7 ]
[ 2018, 17660, 12340, 13732, 4497, 63, 32007, 4046, 687, 283, 32362, 15, 27839, 4149, 15, 31683, 15, 39, 7440, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 3088, 13, 32007, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 8098, 9502, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 8098, 9502, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 8098, 9502, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 8098, 9502, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 8098, 9502, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 8098, 9502, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 8098, 9502, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 8098, 9502, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 8098, 9502, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8098, 9502, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 8098, 9502, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 8098, 9502, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 8098, 9502, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 8098, 9502, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 8098, 9502, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 8098, 9502, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 8098, 9502, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 8098, 9502, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 8098, 9502, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 8098, 9502, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 8098, 9502, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 8098, 9502, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 399, 7, 17, 7, 263, 327, 221, 378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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
imsut/commons
src/python/twitter/pants/targets/jvm_target.py
1
2954
# ================================================================================================== # Copyright 2011 Twitter, Inc. # -------------------------------------------------------------------------------------------------- # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this work except in compliance with the License. # You may obtain a copy of the License in the LICENSE file, or at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ================================================================================================== import os from twitter.pants.targets.internal import InternalTarget from twitter.pants.targets.jar_dependency import JarDependency from twitter.pants.targets.with_sources import TargetWithSources class JvmTarget(InternalTarget, TargetWithSources): """A base class for all java module targets that provides path and dependency translation.""" def __init__(self, name, sources, dependencies, excludes=None, buildflags=None, is_meta=False, configurations=None): InternalTarget.__init__(self, name, dependencies, is_meta) TargetWithSources.__init__(self, name, is_meta) self.declared_dependencies = set(dependencies or []) self.add_label('jvm') self.sources = self._resolve_paths(self.target_base, sources) or [] for source in self.sources: rel_path = os.path.join(self.target_base, source) TargetWithSources.register_source(rel_path, self) self.excludes = excludes or [] self.buildflags = buildflags or [] custom_antxml = '%s.xml' % self.name buildfile = self.address.buildfile.full_path custom_antxml_path = os.path.join(os.path.dirname(buildfile), custom_antxml) self.custom_antxml_path = custom_antxml_path if os.path.exists(custom_antxml_path) else None self.configurations = configurations def _as_jar_dependency(self): jar_dependency, _, _ = self._get_artifact_info() jar = JarDependency(org = jar_dependency.org, name = jar_dependency.name, rev = None) jar.id = self.id return jar def _as_jar_dependencies(self): yield self._as_jar_dependency() def _get_artifact_info(self): provides = self._provides() exported = bool(provides) org = provides.org if exported else 'internal' module = provides.name if exported else self.id version = provides.rev if exported else None id = "%s-%s" % (provides.org, provides.name) if exported else self.id return JarDependency(org = org, name = module, rev = version), id, exported def _provides(self): return None
apache-2.0
[ 3, 7819, 2486, 29, 199, 3, 1898, 7760, 19259, 12, 3277, 14, 199, 3, 5620, 1444, 306, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 1736, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 315, 314, 5113, 570, 12, 503, 737, 26, 199, 3, 199, 3, 221, 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, 7819, 2486, 29, 199, 199, 646, 747, 199, 199, 504, 15811, 14, 21970, 14, 4684, 14, 4672, 492, 12624, 4277, 199, 504, 15811, 14, 21970, 14, 4684, 14, 7338, 63, 8575, 492, 1603, 285, 14403, 199, 504, 15811, 14, 21970, 14, 4684, 14, 1045, 63, 4553, 492, 10256, 3007, 13959, 199, 199, 533, 1603, 2611, 4277, 8, 8405, 4277, 12, 10256, 3007, 13959, 304, 523, 408, 33, 1300, 1021, 367, 1006, 12120, 859, 4545, 626, 6571, 931, 436, 5936, 7761, 1041, 819, 347, 636, 826, 721, 277, 12, 536, 12, 5274, 12, 5124, 12, 2049, 23388, 29, 403, 12, 2049, 1900, 2469, 29, 403, 12, 2049, 365, 63, 2024, 29, 797, 12, 2049, 13422, 29, 403, 304, 272, 12624, 4277, 855, 826, 721, 277, 12, 536, 12, 5124, 12, 365, 63, 2024, 9, 272, 10256, 3007, 13959, 855, 826, 721, 277, 12, 536, 12, 365, 63, 2024, 9, 339, 291, 14, 13545, 63, 5714, 275, 663, 8, 5714, 503, 3073, 272, 291, 14, 525, 63, 1302, 360, 15813, 358, 272, 291, 14, 4553, 275, 291, 423, 6983, 63, 3771, 8, 277, 14, 1375, 63, 1095, 12, 5274, 9, 503, 942, 272, 367, 1350, 315, 291, 14, 4553, 26, 489, 4668, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1375, 63, 1095, 12, 1350, 9, 489, 10256, 3007, 13959, 14, 2683, 63, 1365, 8, 3369, 63, 515, 12, 291, 9, 272, 291, 14, 26984, 275, 23388, 503, 942, 272, 291, 14, 1506, 2469, 275, 1900, 2469, 503, 942, 339, 3537, 63, 867, 1652, 275, 1543, 83, 14, 1652, 7, 450, 291, 14, 354, 272, 1900, 493, 275, 291, 14, 1562, 14, 1506, 493, 14, 2861, 63, 515, 272, 3537, 63, 867, 1652, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 1506, 493, 395, 3537, 63, 867, 1652, 9, 272, 291, 14, 4229, 63, 867, 1652, 63, 515, 275, 3537, 63, 867, 1652, 63, 515, 340, 747, 14, 515, 14, 2444, 8, 4229, 63, 867, 1652, 63, 515, 9, 587, 488, 339, 291, 14, 10057, 275, 13422, 819, 347, 485, 305, 63, 7338, 63, 8575, 8, 277, 304, 272, 16290, 63, 8575, 12, 5501, 485, 275, 291, 423, 362, 63, 16154, 63, 815, 342, 272, 16290, 275, 1603, 285, 14403, 8, 1308, 275, 16290, 63, 8575, 14, 1308, 12, 536, 275, 16290, 63, 8575, 14, 354, 12, 6822, 275, 488, 9, 272, 16290, 14, 344, 275, 291, 14, 344, 272, 372, 16290, 819, 347, 485, 305, 63, 7338, 63, 5714, 8, 277, 304, 272, 1995, 291, 423, 305, 63, 7338, 63, 8575, 342, 819, 347, 485, 362, 63, 16154, 63, 815, 8, 277, 304, 272, 6571, 275, 291, 423, 20121, 342, 272, 16629, 275, 2155, 8, 20121, 9, 339, 5981, 275, 6571, 14, 1308, 340, 16629, 587, 283, 4672, 7, 272, 859, 275, 6571, 14, 354, 340, 16629, 587, 291, 14, 344, 272, 1015, 275, 6571, 14, 4964, 340, 16629, 587, 488, 339, 1305, 275, 2071, 83, 3295, 83, 2, 450, 334, 20121, 14, 1308, 12, 6571, 14, 354, 9, 340, 16629, 587, 291, 14, 344, 339, 372, 1603, 285, 14403, 8, 1308, 275, 5981, 12, 536, 275, 859, 12, 6822, 275, 1015, 395, 1305, 12, 16629, 819, 347, 485, 20121, 8, 277, 304, 272, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 7819, 2486, 29, 199, 3, 1898, 7760, 19259, 12, 3277, 14, 199, 3, 5620, 1444, 306, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 1736, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 315, 314, 5113, 570, 12, 503, 737, 26, 199, 3, 199, 3, 221, 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, 7819, 2486, 29, 199, 199, 646, 747, 199, 199, 504, 15811, 14, 21970, 14, 4684, 14, 4672, 492, 12624, 4277, 199, 504, 15811, 14, 21970, 14, 4684, 14, 7338, 63, 8575, 492, 1603, 285, 14403, 199, 504, 15811, 14, 21970, 14, 4684, 14, 1045, 63, 4553, 492, 10256, 3007, 13959, 199, 199, 533, 1603, 2611, 4277, 8, 8405, 4277, 12, 10256, 3007, 13959, 304, 523, 408, 33, 1300, 1021, 367, 1006, 12120, 859, 4545, 626, 6571, 931, 436, 5936, 7761, 1041, 819, 347, 636, 826, 721, 277, 12, 536, 12, 5274, 12, 5124, 12, 2049, 23388, 29, 403, 12, 2049, 1900, 2469, 29, 403, 12, 2049, 365, 63, 2024, 29, 797, 12, 2049, 13422, 29, 403, 304, 272, 12624, 4277, 855, 826, 721, 277, 12, 536, 12, 5124, 12, 365, 63, 2024, 9, 272, 10256, 3007, 13959, 855, 826, 721, 277, 12, 536, 12, 365, 63, 2024, 9, 339, 291, 14, 13545, 63, 5714, 275, 663, 8, 5714, 503, 3073, 272, 291, 14, 525, 63, 1302, 360, 15813, 358, 272, 291, 14, 4553, 275, 291, 423, 6983, 63, 3771, 8, 277, 14, 1375, 63, 1095, 12, 5274, 9, 503, 942, 272, 367, 1350, 315, 291, 14, 4553, 26, 489, 4668, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1375, 63, 1095, 12, 1350, 9, 489, 10256, 3007, 13959, 14, 2683, 63, 1365, 8, 3369, 63, 515, 12, 291, 9, 272, 291, 14, 26984, 275, 23388, 503, 942, 272, 291, 14, 1506, 2469, 275, 1900, 2469, 503, 942, 339, 3537, 63, 867, 1652, 275, 1543, 83, 14, 1652, 7, 450, 291, 14, 354, 272, 1900, 493, 275, 291, 14, 1562, 14, 1506, 493, 14, 2861, 63, 515, 272, 3537, 63, 867, 1652, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 1506, 493, 395, 3537, 63, 867, 1652, 9, 272, 291, 14, 4229, 63, 867, 1652, 63, 515, 275, 3537, 63, 867, 1652, 63, 515, 340, 747, 14, 515, 14, 2444, 8, 4229, 63, 867, 1652, 63, 515, 9, 587, 488, 339, 291, 14, 10057, 275, 13422, 819, 347, 485, 305, 63, 7338, 63, 8575, 8, 277, 304, 272, 16290, 63, 8575, 12, 5501, 485, 275, 291, 423, 362, 63, 16154, 63, 815, 342, 272, 16290, 275, 1603, 285, 14403, 8, 1308, 275, 16290, 63, 8575, 14, 1308, 12, 536, 275, 16290, 63, 8575, 14, 354, 12, 6822, 275, 488, 9, 272, 16290, 14, 344, 275, 291, 14, 344, 272, 372, 16290, 819, 347, 485, 305, 63, 7338, 63, 5714, 8, 277, 304, 272, 1995, 291, 423, 305, 63, 7338, 63, 8575, 342, 819, 347, 485, 362, 63, 16154, 63, 815, 8, 277, 304, 272, 6571, 275, 291, 423, 20121, 342, 272, 16629, 275, 2155, 8, 20121, 9, 339, 5981, 275, 6571, 14, 1308, 340, 16629, 587, 283, 4672, 7, 272, 859, 275, 6571, 14, 354, 340, 16629, 587, 291, 14, 344, 272, 1015, 275, 6571, 14, 4964, 340, 16629, 587, 488, 339, 1305, 275, 2071, 83, 3295, 83, 2, 450, 334, 20121, 14, 1308, 12, 6571, 14, 354, 9, 340, 16629, 587, 291, 14, 344, 339, 372, 1603, 285, 14403, 8, 1308, 275, 5981, 12, 536, 275, 859, 12, 6822, 275, 1015, 395, 1305, 12, 16629, 819, 347, 485, 20121, 8, 277, 304, 272, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
DefyVentures/edx-platform
common/lib/symmath/symmath/symmath_check.py
36
12584
#!/usr/bin/python # -*- coding: utf-8 -*- # # File: symmath_check.py # Date: 02-May-12 (creation) # # Symbolic mathematical expression checker for edX. Uses sympy to check for expression equality. # # Takes in math expressions given as Presentation MathML (from ASCIIMathML), converts to Content MathML using SnuggleTeX import traceback from .formula import * import logging log = logging.getLogger(__name__) #----------------------------------------------------------------------------- # check function interface # # This is one of the main entry points to call. def symmath_check_simple(expect, ans, adict={}, symtab=None, extra_options=None): """ Check a symbolic mathematical expression using sympy. The input is an ascii string (not MathML) converted to math using sympy.sympify. """ options = {'__MATRIX__': False, '__ABC__': False, '__LOWER__': False} if extra_options: options.update(extra_options) for op in options: # find options in expect string if op in expect: expect = expect.replace(op, '') options[op] = True expect = expect.replace('__OR__', '__or__') # backwards compatibility if options['__LOWER__']: expect = expect.lower() ans = ans.lower() try: ret = check(expect, ans, matrix=options['__MATRIX__'], abcsym=options['__ABC__'], symtab=symtab, ) except Exception, err: return {'ok': False, 'msg': 'Error %s<br/>Failed in evaluating check(%s,%s)' % (err, expect, ans) } return ret #----------------------------------------------------------------------------- # pretty generic checking function def check(expect, given, numerical=False, matrix=False, normphase=False, abcsym=False, do_qubit=True, symtab=None, dosimplify=False): """ Returns dict with 'ok': True if check is good, False otherwise 'msg': response message (in HTML) "expect" may have multiple possible acceptable answers, separated by "__OR__" """ if "__or__" in expect: # if multiple acceptable answers eset = expect.split('__or__') # then see if any match for eone in eset: ret = check(eone, given, numerical, matrix, normphase, abcsym, do_qubit, symtab, dosimplify) if ret['ok']: return ret return ret flags = {} if "__autonorm__" in expect: flags['autonorm'] = True expect = expect.replace('__autonorm__', '') matrix = True threshold = 1.0e-3 if "__threshold__" in expect: (expect, st) = expect.split('__threshold__') threshold = float(st) numerical = True if str(given) == '' and not (str(expect) == ''): return {'ok': False, 'msg': ''} try: xgiven = my_sympify(given, normphase, matrix, do_qubit=do_qubit, abcsym=abcsym, symtab=symtab) except Exception, err: return {'ok': False, 'msg': 'Error %s<br/> in evaluating your expression "%s"' % (err, given)} try: xexpect = my_sympify(expect, normphase, matrix, do_qubit=do_qubit, abcsym=abcsym, symtab=symtab) except Exception, err: return {'ok': False, 'msg': 'Error %s<br/> in evaluating OUR expression "%s"' % (err, expect)} if 'autonorm' in flags: # normalize trace of matrices try: xgiven /= xgiven.trace() except Exception, err: return {'ok': False, 'msg': 'Error %s<br/> in normalizing trace of your expression %s' % (err, to_latex(xgiven))} try: xexpect /= xexpect.trace() except Exception, err: return {'ok': False, 'msg': 'Error %s<br/> in normalizing trace of OUR expression %s' % (err, to_latex(xexpect))} msg = 'Your expression was evaluated as ' + to_latex(xgiven) # msg += '<br/>Expected ' + to_latex(xexpect) # msg += "<br/>flags=%s" % flags if matrix and numerical: xgiven = my_evalf(xgiven, chop=True) dm = my_evalf(sympy.Matrix(xexpect) - sympy.Matrix(xgiven), chop=True) msg += " = " + to_latex(xgiven) if abs(dm.vec().norm().evalf()) < threshold: return {'ok': True, 'msg': msg} else: pass #msg += "dm = " + to_latex(dm) + " diff = " + str(abs(dm.vec().norm().evalf())) #msg += "expect = " + to_latex(xexpect) elif dosimplify: if (sympy.simplify(xexpect) == sympy.simplify(xgiven)): return {'ok': True, 'msg': msg} elif numerical: if (abs((xexpect - xgiven).evalf(chop=True)) < threshold): return {'ok': True, 'msg': msg} elif (xexpect == xgiven): return {'ok': True, 'msg': msg} #msg += "<p/>expect='%s', given='%s'" % (expect,given) # debugging # msg += "<p/> dot test " + to_latex(dot(sympy.Symbol('x'),sympy.Symbol('y'))) return {'ok': False, 'msg': msg} #----------------------------------------------------------------------------- # helper function to convert all <p> to <span class='inline-error'> def make_error_message(msg): # msg = msg.replace('<p>','<p><span class="inline-error">').replace('</p>','</span></p>') msg = '<div class="capa_alert">%s</div>' % msg return msg def is_within_tolerance(expected, actual, tolerance): if expected == 0: return (abs(actual) < tolerance) else: return (abs(abs(actual - expected) / expected) < tolerance) #----------------------------------------------------------------------------- # Check function interface, which takes pmathml input # # This is one of the main entry points to call. def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None): """ Check a symbolic mathematical expression using sympy. The input may be presentation MathML. Uses formula. This is the default Symbolic Response checking function Desc of args: expect is a sympy string representing the correct answer. It is interpreted using my_sympify (from formula.py), which reads strings as sympy input (e.g. 'integrate(x^2, (x,1,2))' would be valid, and evaluate to give 1.5) ans is student-typed answer. It is expected to be ascii math, but the code below would support a sympy string. dynamath is the PMathML string converted by MathJax. It is used if evaluation with ans is not sufficient. options is a string with these possible substrings, set as an xml property of the problem: -matrix - make a sympy matrix, rather than a list of lists, if possible -qubit - passed to my_sympify -imaginary - used in formla, presumably to signal to use i as sqrt(-1)? -numerical - force numerical comparison. """ msg = '' # msg += '<p/>abname=%s' % abname # msg += '<p/>adict=%s' % (repr(adict).replace('<','&lt;')) threshold = 1.0e-3 # for numerical comparison (also with matrices) DEBUG = debug if xml is not None: DEBUG = xml.get('debug', False) # override debug flag using attribute in symbolicmath xml if DEBUG in ['0', 'False']: DEBUG = False # options do_matrix = 'matrix' in (options or '') do_qubit = 'qubit' in (options or '') do_imaginary = 'imaginary' in (options or '') do_numerical = 'numerical' in (options or '') # parse expected answer try: fexpect = my_sympify(str(expect), matrix=do_matrix, do_qubit=do_qubit) except Exception, err: msg += '<p>Error %s in parsing OUR expected answer "%s"</p>' % (err, expect) return {'ok': False, 'msg': make_error_message(msg)} ###### Sympy input ####### # if expected answer is a number, try parsing provided answer as a number also try: fans = my_sympify(str(ans), matrix=do_matrix, do_qubit=do_qubit) except Exception, err: fans = None # do a numerical comparison if both expected and answer are numbers if hasattr(fexpect, 'is_number') and fexpect.is_number \ and hasattr(fans, 'is_number') and fans.is_number: if is_within_tolerance(fexpect, fans, threshold): return {'ok': True, 'msg': msg} else: msg += '<p>You entered: %s</p>' % to_latex(fans) return {'ok': False, 'msg': msg} if do_numerical: # numerical answer expected - force numerical comparison if is_within_tolerance(fexpect, fans, threshold): return {'ok': True, 'msg': msg} else: msg += '<p>You entered: %s (note that a numerical answer is expected)</p>' % to_latex(fans) return {'ok': False, 'msg': msg} if fexpect == fans: msg += '<p>You entered: %s</p>' % to_latex(fans) return {'ok': True, 'msg': msg} ###### PMathML input ###### # convert mathml answer to formula try: mmlans = dynamath[0] if dynamath else None except Exception, err: mmlans = None if not mmlans: return {'ok': False, 'msg': '[symmath_check] failed to get MathML for input; dynamath=%s' % dynamath} f = formula(mmlans, options=options) # get sympy representation of the formula # if DEBUG: msg += '<p/> mmlans=%s' % repr(mmlans).replace('<','&lt;') try: fsym = f.sympy msg += '<p>You entered: %s</p>' % to_latex(f.sympy) except Exception, err: log.exception("Error evaluating expression '%s' as a valid equation" % ans) msg += "<p>Error in evaluating your expression '%s' as a valid equation</p>" % (ans) if "Illegal math" in str(err): msg += "<p>Illegal math expression</p>" if DEBUG: msg += 'Error: %s' % str(err).replace('<', '&lt;') msg += '<hr>' msg += '<p><font color="blue">DEBUG messages:</p>' msg += "<p><pre>%s</pre></p>" % traceback.format_exc() msg += '<p>cmathml=<pre>%s</pre></p>' % f.cmathml.replace('<', '&lt;') msg += '<p>pmathml=<pre>%s</pre></p>' % mmlans.replace('<', '&lt;') msg += '<hr>' return {'ok': False, 'msg': make_error_message(msg)} # do numerical comparison with expected if hasattr(fexpect, 'is_number') and fexpect.is_number: if hasattr(fsym, 'is_number') and fsym.is_number: if abs(abs(fsym - fexpect) / fexpect) < threshold: return {'ok': True, 'msg': msg} return {'ok': False, 'msg': msg} msg += "<p>Expecting a numerical answer!</p>" msg += "<p>given = %s</p>" % repr(ans) msg += "<p>fsym = %s</p>" % repr(fsym) # msg += "<p>cmathml = <pre>%s</pre></p>" % str(f.cmathml).replace('<','&lt;') return {'ok': False, 'msg': make_error_message(msg)} # Here is a good spot for adding calls to X.simplify() or X.expand(), # allowing equivalence over binomial expansion or trig identities # exactly the same? if fexpect == fsym: return {'ok': True, 'msg': msg} if isinstance(fexpect, list): try: xgiven = my_evalf(fsym, chop=True) dm = my_evalf(sympy.Matrix(fexpect) - sympy.Matrix(xgiven), chop=True) if abs(dm.vec().norm().evalf()) < threshold: return {'ok': True, 'msg': msg} except sympy.ShapeError: msg += "<p>Error - your input vector or matrix has the wrong dimensions" return {'ok': False, 'msg': make_error_message(msg)} except Exception, err: msg += "<p>Error %s in comparing expected (a list) and your answer</p>" % str(err).replace('<', '&lt;') if DEBUG: msg += "<p/><pre>%s</pre>" % traceback.format_exc() return {'ok': False, 'msg': make_error_message(msg)} #diff = (fexpect-fsym).simplify() #fsym = fsym.simplify() #fexpect = fexpect.simplify() try: diff = (fexpect - fsym) except Exception, err: diff = None if DEBUG: msg += '<hr>' msg += '<p><font color="blue">DEBUG messages:</p>' msg += "<p>Got: %s</p>" % repr(fsym) # msg += "<p/>Got: %s" % str([type(x) for x in fsym.atoms()]).replace('<','&lt;') msg += "<p>Expecting: %s</p>" % repr(fexpect).replace('**', '^').replace('hat(I)', 'hat(i)') # msg += "<p/>Expecting: %s" % str([type(x) for x in fexpect.atoms()]).replace('<','&lt;') if diff: msg += "<p>Difference: %s</p>" % to_latex(diff) msg += '<hr>' # Used to return more keys: 'ex': fexpect, 'got': fsym return {'ok': False, 'msg': msg}
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3814, 26, 257, 4678, 3442, 63, 1074, 14, 647, 199, 3, 6148, 26, 257, 12497, 13, 15586, 13, 713, 334, 8782, 9, 199, 3, 199, 3, 21478, 9670, 610, 28491, 3965, 7739, 367, 3988, 56, 14, 221, 14911, 5840, 370, 1104, 367, 3965, 16612, 14, 199, 3, 199, 3, 17415, 315, 3473, 8455, 1627, 465, 5543, 1150, 425, 21066, 1698, 334, 504, 4319, 3553, 1469, 1619, 1698, 395, 15373, 370, 6646, 21066, 1698, 1808, 428, 78, 1518, 3845, 12589, 199, 199, 646, 5190, 199, 504, 1275, 16798, 492, 627, 199, 646, 2050, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 18045, 199, 3, 1104, 805, 3217, 199, 3, 199, 3, 961, 365, 1373, 402, 314, 2446, 2397, 4501, 370, 1240, 14, 421, 199, 318, 4678, 3442, 63, 1074, 63, 4129, 8, 4921, 12, 4987, 12, 282, 807, 10324, 1847, 2037, 371, 29, 403, 12, 2402, 63, 1419, 29, 403, 304, 272, 408, 272, 2670, 282, 13673, 610, 28491, 3965, 1808, 5840, 14, 272, 710, 1324, 365, 376, 13294, 1059, 334, 1397, 21066, 1698, 9, 6702, 370, 3473, 1808, 5840, 14, 1786, 18456, 14, 272, 408, 339, 1511, 275, 791, 363, 23483, 3706, 756, 12, 2560, 8390, 3706, 756, 12, 2560, 5896, 540, 3706, 756, 93, 272, 340, 2402, 63, 1419, 26, 267, 1511, 14, 873, 8, 2911, 63, 1419, 9, 272, 367, 1687, 315, 1511, 26, 9622, 198, 3, 2342, 1511, 315, 4282, 1059, 267, 340, 1687, 315, 4282, 26, 288, 4282, 275, 4282, 14, 1814, 8, 411, 12, 4074, 288, 1511, 59, 411, 61, 275, 715, 272, 4282, 275, 4282, 14, 1814, 10714, 726, 7500, 2560, 269, 13766, 198, 327, 8552, 7163, 339, 340, 1511, 13742, 5896, 540, 363, 2565, 267, 4282, 275, 4282, 14, 2325, 342, 267, 4987, 275, 4987, 14, 2325, 342, 339, 862, 26, 267, 2203, 275, 1104, 8, 4921, 12, 4987, 12, 490, 3634, 29, 1419, 13742, 23483, 363, 995, 490, 2236, 1259, 12828, 29, 1419, 13742, 8390, 363, 995, 490, 1847, 2037, 371, 29, 1786, 2037, 371, 12, 490, 776, 272, 871, 2186, 12, 2329, 26, 267, 372, 791, 745, 356, 756, 12, 355, 283, 1328, 356, 283, 547, 450, 83, 28, 3289, 3133, 4276, 315, 27083, 1104, 4042, 83, 8719, 83, 3171, 450, 334, 1508, 12, 4282, 12, 4987, 9, 355, 789, 272, 372, 2203, 199, 199, 18045, 199, 3, 7268, 7809, 7907, 805, 421, 199, 318, 1104, 8, 4921, 12, 1627, 12, 15470, 29, 797, 12, 3634, 29, 797, 12, 6590, 311, 72, 482, 29, 797, 12, 2236, 1259, 12828, 29, 797, 12, 886, 63, 392, 2075, 29, 549, 12, 1847, 2037, 371, 29, 403, 12, 886, 19084, 29, 797, 304, 272, 408, 272, 1803, 1211, 543, 2541, 283, 745, 356, 715, 340, 1104, 365, 6954, 12, 756, 4257, 489, 283, 1328, 356, 1177, 1245, 334, 262, 4163, 9, 339, 298, 4921, 2, 1443, 1172, 3663, 3962, 14712, 17133, 12, 11673, 701, 4396, 726, 16526, 339, 408, 339, 340, 4396, 269, 16526, 315, 4282, 26, 1057, 198, 3, 340, 3663, 14712, 17133, 267, 325, 409, 275, 4282, 14, 1294, 10714, 269, 13766, 198, 198, 3, 2066, 1937, 340, 1263, 1336, 267, 367, 325, 368, 315, 325, 409, 26, 288, 2203, 275, 1104, 8, 69, 368, 12, 1627, 12, 15470, 12, 3634, 12, 6590, 311, 72, 482, 12, 2236, 1259, 12828, 12, 886, 63, 392, 2075, 12, 1847, 2037, 371, 12, 886, 19084, 9, 288, 340, 2203, 459, 745, 2565, 355, 372, 2203, 267, 372, 2203, 339, 3285, 275, 1052, 272, 340, 4396, 6898, 265, 1025, 16526, 315, 4282, 26, 267, 3285, 459, 6898, 265, 1025, 418, 275, 715, 267, 4282, 275, 4282, 14, 1814, 10714, 6898, 265, 1025, 7500, 4074, 267, 3634, 275, 715, 339, 8765, 275, 413, 14, 16, 69, 13, 19, 272, 340, 4396, 7227, 16526, 315, 4282, 26, 267, 334, 4921, 12, 410, 9, 275, 4282, 14, 1294, 10714, 7227, 13766, 267, 8765, 275, 2069, 8, 270, 9, 267, 15470, 275, 715, 339, 340, 620, 8, 11809, 9, 508, 2125, 436, 440, 334, 495, 8, 4921, 9, 508, 21019, 267, 372, 791, 745, 356, 756, 12, 283, 1328, 356, 28174, 339, 862, 26, 267, 671, 11809, 275, 3002, 63, 1786, 18456, 8, 11809, 12, 6590, 311, 72, 482, 12, 3634, 12, 886, 63, 392, 2075, 29, 1117, 63, 392, 2075, 12, 2236, 1259, 12828, 29, 371, 1259, 12828, 12, 1847, 2037, 371, 29, 1786, 2037, 371, 9, 272, 871, 2186, 12, 2329, 26, 267, 372, 791, 745, 356, 756, 12, 283, 1328, 356, 283, 547, 450, 83, 28, 3289, 3133, 315, 27083, 2195, 3965, 2071, 83, 4507, 450, 334, 1508, 12, 1627, 6769, 339, 862, 26, 267, 671, 4921, 275, 3002, 63, 1786, 18456, 8, 4921, 12, 6590, 311, 72, 482, 12, 3634, 12, 886, 63, 392, 2075, 29, 1117, 63, 392, 2075, 12, 2236, 1259, 12828, 29, 371, 1259, 12828, 12, 1847, 2037, 371, 29, 1786, 2037, 371, 9, 272, 871, 2186, 12, 2329, 26, 267, 372, 791, 745, 356, 756, 12, 283, 1328, 356, 283, 547, 450, 83, 28, 3289, 3133, 315, 27083, 593, 1230, 3965, 2071, 83, 4507, 450, 334, 1508, 12, 4282, 6769, 339, 340, 283, 6898, 265, 1025, 7, 315, 3285, 26, 198, 327, 7666, 3307, 402, 12627, 267, 862, 26, 288, 671, 11809, 12257, 671, 11809, 14, 3446, 342, 267, 871, 2186, 12, 2329, 26, 288, 372, 791, 745, 356, 756, 12, 283, 1328, 356, 283, 547, 450, 83, 28, 3289, 3133, 315, 3293, 9147, 3307, 402, 2195, 3965, 450, 83, 7, 450, 334, 1508, 12, 370, 63, 7572, 8, 88, 11809, 430, 93, 267, 862, 26, 288, 671, 4921, 12257, 671, 4921, 14, 3446, 342, 267, 871, 2186, 12, 2329, 26, 288, 372, 791, 745, 356, 756, 12, 283, 1328, 356, 283, 547, 450, 83, 28, 3289, 3133, 315, 3293, 9147, 3307, 402, 593, 1230, 3965, 450, 83, 7, 450, 334, 1508, 12, 370, 63, 7572, 8, 88, 4921, 430, 93, 339, 1499, 275, 283, 14398, 3965, 1990, 13006, 465, 283, 435, 370, 63, 7572, 8, 88, 11809, 9, 272, 327, 1499, 847 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3814, 26, 257, 4678, 3442, 63, 1074, 14, 647, 199, 3, 6148, 26, 257, 12497, 13, 15586, 13, 713, 334, 8782, 9, 199, 3, 199, 3, 21478, 9670, 610, 28491, 3965, 7739, 367, 3988, 56, 14, 221, 14911, 5840, 370, 1104, 367, 3965, 16612, 14, 199, 3, 199, 3, 17415, 315, 3473, 8455, 1627, 465, 5543, 1150, 425, 21066, 1698, 334, 504, 4319, 3553, 1469, 1619, 1698, 395, 15373, 370, 6646, 21066, 1698, 1808, 428, 78, 1518, 3845, 12589, 199, 199, 646, 5190, 199, 504, 1275, 16798, 492, 627, 199, 646, 2050, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 18045, 199, 3, 1104, 805, 3217, 199, 3, 199, 3, 961, 365, 1373, 402, 314, 2446, 2397, 4501, 370, 1240, 14, 421, 199, 318, 4678, 3442, 63, 1074, 63, 4129, 8, 4921, 12, 4987, 12, 282, 807, 10324, 1847, 2037, 371, 29, 403, 12, 2402, 63, 1419, 29, 403, 304, 272, 408, 272, 2670, 282, 13673, 610, 28491, 3965, 1808, 5840, 14, 272, 710, 1324, 365, 376, 13294, 1059, 334, 1397, 21066, 1698, 9, 6702, 370, 3473, 1808, 5840, 14, 1786, 18456, 14, 272, 408, 339, 1511, 275, 791, 363, 23483, 3706, 756, 12, 2560, 8390, 3706, 756, 12, 2560, 5896, 540, 3706, 756, 93, 272, 340, 2402, 63, 1419, 26, 267, 1511, 14, 873, 8, 2911, 63, 1419, 9, 272, 367, 1687, 315, 1511, 26, 9622, 198, 3, 2342, 1511, 315, 4282, 1059, 267, 340, 1687, 315, 4282, 26, 288, 4282, 275, 4282, 14, 1814, 8, 411, 12, 4074, 288, 1511, 59, 411, 61, 275, 715, 272, 4282, 275, 4282, 14, 1814, 10714, 726, 7500, 2560, 269, 13766, 198, 327, 8552, 7163, 339, 340, 1511, 13742, 5896, 540, 363, 2565, 267, 4282, 275, 4282, 14, 2325, 342, 267, 4987, 275, 4987, 14, 2325, 342, 339, 862, 26, 267, 2203, 275, 1104, 8, 4921, 12, 4987, 12, 490, 3634, 29, 1419, 13742, 23483, 363, 995, 490, 2236, 1259, 12828, 29, 1419, 13742, 8390, 363, 995, 490, 1847, 2037, 371, 29, 1786, 2037, 371, 12, 490, 776, 272, 871, 2186, 12, 2329, 26, 267, 372, 791, 745, 356, 756, 12, 355, 283, 1328, 356, 283, 547, 450, 83, 28, 3289, 3133, 4276, 315, 27083, 1104, 4042, 83, 8719, 83, 3171, 450, 334, 1508, 12, 4282, 12, 4987, 9, 355, 789, 272, 372, 2203, 199, 199, 18045, 199, 3, 7268, 7809, 7907, 805, 421, 199, 318, 1104, 8, 4921, 12, 1627, 12, 15470, 29, 797, 12, 3634, 29, 797, 12, 6590, 311, 72, 482, 29, 797, 12, 2236, 1259, 12828, 29, 797, 12, 886, 63, 392, 2075, 29, 549, 12, 1847, 2037, 371, 29, 403, 12, 886, 19084, 29, 797, 304, 272, 408, 272, 1803, 1211, 543, 2541, 283, 745, 356, 715, 340, 1104, 365, 6954, 12, 756, 4257, 489, 283, 1328, 356, 1177, 1245, 334, 262, 4163, 9, 339, 298, 4921, 2, 1443, 1172, 3663, 3962, 14712, 17133, 12, 11673, 701, 4396, 726, 16526, 339, 408, 339, 340, 4396, 269, 16526, 315, 4282, 26, 1057, 198, 3, 340, 3663, 14712, 17133, 267, 325, 409, 275, 4282, 14, 1294, 10714, 269, 13766, 198, 198, 3, 2066, 1937, 340, 1263, 1336, 267, 367, 325, 368, 315, 325, 409, 26, 288, 2203, 275, 1104, 8, 69, 368, 12, 1627, 12, 15470, 12, 3634, 12, 6590, 311, 72, 482, 12, 2236, 1259, 12828, 12, 886, 63, 392, 2075, 12, 1847, 2037, 371, 12, 886, 19084, 9, 288, 340, 2203, 459, 745, 2565, 355, 372, 2203, 267, 372, 2203, 339, 3285, 275, 1052, 272, 340, 4396, 6898, 265, 1025, 16526, 315, 4282, 26, 267, 3285, 459, 6898, 265, 1025, 418, 275, 715, 267, 4282, 275, 4282, 14, 1814, 10714, 6898, 265, 1025, 7500, 4074, 267, 3634, 275, 715, 339, 8765, 275, 413, 14, 16, 69, 13, 19, 272, 340, 4396, 7227, 16526, 315, 4282, 26, 267, 334, 4921, 12, 410, 9, 275, 4282, 14, 1294, 10714, 7227, 13766, 267, 8765, 275, 2069, 8, 270, 9, 267, 15470, 275, 715, 339, 340, 620, 8, 11809, 9, 508, 2125, 436, 440, 334, 495, 8, 4921, 9, 508, 21019, 267, 372, 791, 745, 356, 756, 12, 283, 1328, 356, 28174, 339, 862, 26, 267, 671, 11809, 275, 3002, 63, 1786, 18456, 8, 11809, 12, 6590, 311, 72, 482, 12, 3634, 12, 886, 63, 392, 2075, 29, 1117, 63, 392, 2075, 12, 2236, 1259, 12828, 29, 371, 1259, 12828, 12, 1847, 2037, 371, 29, 1786, 2037, 371, 9, 272, 871, 2186, 12, 2329, 26, 267, 372, 791, 745, 356, 756, 12, 283, 1328, 356, 283, 547, 450, 83, 28, 3289, 3133, 315, 27083, 2195, 3965, 2071, 83, 4507, 450, 334, 1508, 12, 1627, 6769, 339, 862, 26, 267, 671, 4921, 275, 3002, 63, 1786, 18456, 8, 4921, 12, 6590, 311, 72, 482, 12, 3634, 12, 886, 63, 392, 2075, 29, 1117, 63, 392, 2075, 12, 2236, 1259, 12828, 29, 371, 1259, 12828, 12, 1847, 2037, 371, 29, 1786, 2037, 371, 9, 272, 871, 2186, 12, 2329, 26, 267, 372, 791, 745, 356, 756, 12, 283, 1328, 356, 283, 547, 450, 83, 28, 3289, 3133, 315, 27083, 593, 1230, 3965, 2071, 83, 4507, 450, 334, 1508, 12, 4282, 6769, 339, 340, 283, 6898, 265, 1025, 7, 315, 3285, 26, 198, 327, 7666, 3307, 402, 12627, 267, 862, 26, 288, 671, 11809, 12257, 671, 11809, 14, 3446, 342, 267, 871, 2186, 12, 2329, 26, 288, 372, 791, 745, 356, 756, 12, 283, 1328, 356, 283, 547, 450, 83, 28, 3289, 3133, 315, 3293, 9147, 3307, 402, 2195, 3965, 450, 83, 7, 450, 334, 1508, 12, 370, 63, 7572, 8, 88, 11809, 430, 93, 267, 862, 26, 288, 671, 4921, 12257, 671, 4921, 14, 3446, 342, 267, 871, 2186, 12, 2329, 26, 288, 372, 791, 745, 356, 756, 12, 283, 1328, 356, 283, 547, 450, 83, 28, 3289, 3133, 315, 3293, 9147, 3307, 402, 593, 1230, 3965, 450, 83, 7, 450, 334, 1508, 12, 370, 63, 7572, 8, 88, 4921, 430, 93, 339, 1499, 275, 283, 14398, 3965, 1990, 13006, 465, 283, 435, 370, 63, 7572, 8, 88, 11809, 9, 272, 327, 1499, 847, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jmesteve/medical
openerp/addons/sale/report/sale_report.py
13
5526
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp import tools from openerp.osv import fields, osv class sale_report(osv.osv): _name = "sale.report" _description = "Sales Orders Statistics" _auto = False _rec_name = 'date' _columns = { 'date': fields.date('Date Order', readonly=True), 'date_confirm': fields.date('Date Confirm', readonly=True), 'year': fields.char('Year', size=4, readonly=True), 'month': fields.selection([('01', 'January'), ('02', 'February'), ('03', 'March'), ('04', 'April'), ('05', 'May'), ('06', 'June'), ('07', 'July'), ('08', 'August'), ('09', 'September'), ('10', 'October'), ('11', 'November'), ('12', 'December')], 'Month', readonly=True), 'day': fields.char('Day', size=128, readonly=True), 'product_id': fields.many2one('product.product', 'Product', readonly=True), 'product_uom': fields.many2one('product.uom', 'Unit of Measure', readonly=True), 'product_uom_qty': fields.float('# of Qty', readonly=True), 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True), 'shop_id': fields.many2one('sale.shop', 'Shop', readonly=True), 'company_id': fields.many2one('res.company', 'Company', readonly=True), 'user_id': fields.many2one('res.users', 'Salesperson', readonly=True), 'price_total': fields.float('Total Price', readonly=True), 'delay': fields.float('Commitment Delay', digits=(16,2), readonly=True), 'categ_id': fields.many2one('product.category','Category of Product', readonly=True), 'nbr': fields.integer('# of Lines', readonly=True), 'state': fields.selection([ ('draft', 'Quotation'), ('waiting_date', 'Waiting Schedule'), ('manual', 'Manual In Progress'), ('progress', 'In Progress'), ('invoice_except', 'Invoice Exception'), ('done', 'Done'), ('cancel', 'Cancelled') ], 'Order Status', readonly=True), 'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', readonly=True), 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', readonly=True), } _order = 'date desc' def init(self, cr): tools.drop_view_if_exists(cr, 'sale_report') cr.execute(""" create or replace view sale_report as ( select min(l.id) as id, l.product_id as product_id, t.uom_id as product_uom, sum(l.product_uom_qty / u.factor * u2.factor) as product_uom_qty, sum(l.product_uom_qty * l.price_unit * (100.0-l.discount) / 100.0) as price_total, 1 as nbr, s.date_order as date, s.date_confirm as date_confirm, to_char(s.date_order, 'YYYY') as year, to_char(s.date_order, 'MM') as month, to_char(s.date_order, 'YYYY-MM-DD') as day, s.partner_id as partner_id, s.user_id as user_id, s.shop_id as shop_id, s.company_id as company_id, extract(epoch from avg(date_trunc('day',s.date_confirm)-date_trunc('day',s.create_date)))/(24*60*60)::decimal(16,2) as delay, s.state, t.categ_id as categ_id, s.pricelist_id as pricelist_id, s.project_id as analytic_account_id from sale_order s join sale_order_line l on (s.id=l.order_id) left join product_product p on (l.product_id=p.id) left join product_template t on (p.product_tmpl_id=t.id) left join product_uom u on (u.id=l.product_uom) left join product_uom u2 on (u2.id=t.uom_id) group by l.product_id, l.product_uom_qty, l.order_id, t.uom_id, t.categ_id, s.date_order, s.date_confirm, s.partner_id, s.user_id, s.shop_id, s.company_id, s.state, s.pricelist_id, s.project_id ) """) sale_report() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 13590, 63, 3070, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 8515, 14, 3070, 2, 272, 485, 1802, 275, 298, 18220, 4236, 7735, 28365, 2, 272, 485, 2495, 275, 756, 272, 485, 2761, 63, 354, 275, 283, 602, 7, 272, 485, 3406, 275, 469, 267, 283, 602, 356, 1504, 14, 602, 360, 2506, 9240, 297, 6863, 29, 549, 395, 267, 283, 602, 63, 9548, 356, 1504, 14, 602, 360, 2506, 32112, 297, 6863, 29, 549, 395, 267, 283, 3403, 356, 1504, 14, 1560, 360, 15731, 297, 1568, 29, 20, 12, 6863, 29, 549, 395, 267, 283, 4482, 356, 1504, 14, 5592, 8318, 614, 297, 283, 19825, 20527, 659, 661, 996, 297, 283, 27717, 26709, 659, 661, 1644, 297, 283, 45, 1047, 659, 661, 966, 297, 283, 33, 28026, 659, 288, 661, 1717, 297, 283, 15586, 659, 661, 1690, 297, 283, 42, 11474, 659, 661, 1780, 297, 283, 42, 21797, 659, 661, 2036, 297, 283, 21640, 833, 659, 661, 1643, 297, 283, 23337, 31575, 659, 288, 661, 709, 297, 283, 17584, 22459, 659, 661, 845, 297, 283, 1944, 432, 976, 659, 661, 713, 297, 283, 872, 26381, 2665, 283, 14306, 297, 6863, 29, 549, 395, 267, 283, 2977, 356, 1504, 14, 1560, 360, 12631, 297, 1568, 29, 3933, 12, 6863, 29, 549, 395, 267, 283, 2558, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2558, 14, 2558, 297, 283, 5884, 297, 6863, 29, 549, 395, 267, 283, 2558, 63, 7519, 356, 1504, 14, 3479, 18, 368, 360, 2558, 14, 7519, 297, 283, 5072, 402, 22933, 297, 6863, 29, 549, 395, 267, 283, 2558, 63, 7519, 63, 5643, 356, 1504, 14, 1609, 7863, 402, 1413, 369, 297, 6863, 29, 549, 395, 398, 283, 3899, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 297, 283, 24120, 297, 6863, 29, 549, 395, 267, 283, 10568, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 8515, 14, 10568, 297, 283, 2662, 411, 297, 6863, 29, 549, 395, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 297, 283, 16063, 297, 6863, 29, 549, 395, 267, 283, 751, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 18220, 5484, 297, 6863, 29, 549, 395, 267, 283, 4777, 63, 2923, 356, 1504, 14, 1609, 360, 7316, 20276, 297, 6863, 29, 549, 395, 267, 283, 5814, 356, 1504, 14, 1609, 360, 11421, 434, 18464, 1187, 297, 7576, 2687, 975, 12, 18, 395, 6863, 29, 549, 395, 267, 283, 3533, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2558, 14, 3710, 1673, 7841, 402, 12705, 297, 6863, 29, 549, 395, 267, 283, 23299, 356, 1504, 14, 4115, 7863, 402, 29406, 297, 6863, 29, 549, 395, 267, 283, 929, 356, 1504, 14, 5592, 779, 288, 661, 7185, 297, 283, 2371, 357, 425, 659, 288, 661, 14093, 63, 602, 297, 283, 19189, 24317, 659, 288, 661, 9285, 297, 283, 22382, 1010, 21211, 659, 288, 661, 5734, 297, 283, 607, 21211, 659, 288, 661, 5404, 63, 2590, 297, 283, 21092, 2186, 659, 288, 661, 4456, 297, 283, 10759, 659, 288, 661, 6406, 297, 283, 22127, 358, 288, 2156, 283, 4738, 9795, 297, 6863, 29, 549, 395, 267, 283, 17385, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2558, 14, 17385, 297, 283, 11826, 513, 297, 6863, 29, 549, 395, 267, 283, 9782, 63, 2048, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2048, 14, 9782, 14, 2048, 297, 283, 8014, 764, 9973, 297, 6863, 29, 549, 395, 272, 789, 272, 485, 1648, 275, 283, 602, 4328, 7, 339, 347, 4205, 8, 277, 12, 2467, 304, 267, 7249, 14, 4824, 63, 1345, 63, 692, 63, 2444, 8, 1556, 12, 283, 8515, 63, 3070, 358, 267, 2467, 14, 2526, 4852, 288, 1218, 503, 3350, 2455, 13590, 63, 3070, 465, 334, 355, 3504, 490, 1748, 8, 76, 14, 344, 9, 465, 1305, 12, 490, 634, 14, 2558, 63, 344, 465, 3336, 63, 344, 12, 490, 307, 14, 7519, 63, 344, 465, 3336, 63, 7519, 12, 490, 3089, 8, 76, 14, 2558, 63, 7519, 63, 5643, 1182, 399, 14, 4778, 627, 399, 18, 14, 4778, 9, 465, 3336, 63, 7519, 63, 5643, 12, 490, 3089, 8, 76, 14, 2558, 63, 7519, 63, 5643, 627, 634, 14, 4777, 63, 3248, 627, 334, 1960, 14, 16, 13, 76, 14, 15446, 9, 1182, 2948, 14, 16, 9, 465, 8033, 63, 2923, 12, 490, 413, 465, 31646, 12, 490, 308, 14, 602, 63, 1648, 465, 1434, 12, 490, 308, 14, 602, 63, 9548, 465, 1434, 63, 9548, 12, 490, 370, 63, 1560, 8, 83, 14, 602, 63, 1648, 12, 283, 15703, 358, 465, 5361, 12, 490, 370, 63, 1560, 8, 83, 14, 602, 63, 1648, 12, 283, 3218, 358, 465, 5794, 12, 490, 370, 63, 1560, 8 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 13590, 63, 3070, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 8515, 14, 3070, 2, 272, 485, 1802, 275, 298, 18220, 4236, 7735, 28365, 2, 272, 485, 2495, 275, 756, 272, 485, 2761, 63, 354, 275, 283, 602, 7, 272, 485, 3406, 275, 469, 267, 283, 602, 356, 1504, 14, 602, 360, 2506, 9240, 297, 6863, 29, 549, 395, 267, 283, 602, 63, 9548, 356, 1504, 14, 602, 360, 2506, 32112, 297, 6863, 29, 549, 395, 267, 283, 3403, 356, 1504, 14, 1560, 360, 15731, 297, 1568, 29, 20, 12, 6863, 29, 549, 395, 267, 283, 4482, 356, 1504, 14, 5592, 8318, 614, 297, 283, 19825, 20527, 659, 661, 996, 297, 283, 27717, 26709, 659, 661, 1644, 297, 283, 45, 1047, 659, 661, 966, 297, 283, 33, 28026, 659, 288, 661, 1717, 297, 283, 15586, 659, 661, 1690, 297, 283, 42, 11474, 659, 661, 1780, 297, 283, 42, 21797, 659, 661, 2036, 297, 283, 21640, 833, 659, 661, 1643, 297, 283, 23337, 31575, 659, 288, 661, 709, 297, 283, 17584, 22459, 659, 661, 845, 297, 283, 1944, 432, 976, 659, 661, 713, 297, 283, 872, 26381, 2665, 283, 14306, 297, 6863, 29, 549, 395, 267, 283, 2977, 356, 1504, 14, 1560, 360, 12631, 297, 1568, 29, 3933, 12, 6863, 29, 549, 395, 267, 283, 2558, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2558, 14, 2558, 297, 283, 5884, 297, 6863, 29, 549, 395, 267, 283, 2558, 63, 7519, 356, 1504, 14, 3479, 18, 368, 360, 2558, 14, 7519, 297, 283, 5072, 402, 22933, 297, 6863, 29, 549, 395, 267, 283, 2558, 63, 7519, 63, 5643, 356, 1504, 14, 1609, 7863, 402, 1413, 369, 297, 6863, 29, 549, 395, 398, 283, 3899, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 297, 283, 24120, 297, 6863, 29, 549, 395, 267, 283, 10568, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 8515, 14, 10568, 297, 283, 2662, 411, 297, 6863, 29, 549, 395, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 297, 283, 16063, 297, 6863, 29, 549, 395, 267, 283, 751, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 18220, 5484, 297, 6863, 29, 549, 395, 267, 283, 4777, 63, 2923, 356, 1504, 14, 1609, 360, 7316, 20276, 297, 6863, 29, 549, 395, 267, 283, 5814, 356, 1504, 14, 1609, 360, 11421, 434, 18464, 1187, 297, 7576, 2687, 975, 12, 18, 395, 6863, 29, 549, 395, 267, 283, 3533, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2558, 14, 3710, 1673, 7841, 402, 12705, 297, 6863, 29, 549, 395, 267, 283, 23299, 356, 1504, 14, 4115, 7863, 402, 29406, 297, 6863, 29, 549, 395, 267, 283, 929, 356, 1504, 14, 5592, 779, 288, 661, 7185, 297, 283, 2371, 357, 425, 659, 288, 661, 14093, 63, 602, 297, 283, 19189, 24317, 659, 288, 661, 9285, 297, 283, 22382, 1010, 21211, 659, 288, 661, 5734, 297, 283, 607, 21211, 659, 288, 661, 5404, 63, 2590, 297, 283, 21092, 2186, 659, 288, 661, 4456, 297, 283, 10759, 659, 288, 661, 6406, 297, 283, 22127, 358, 288, 2156, 283, 4738, 9795, 297, 6863, 29, 549, 395, 267, 283, 17385, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2558, 14, 17385, 297, 283, 11826, 513, 297, 6863, 29, 549, 395, 267, 283, 9782, 63, 2048, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2048, 14, 9782, 14, 2048, 297, 283, 8014, 764, 9973, 297, 6863, 29, 549, 395, 272, 789, 272, 485, 1648, 275, 283, 602, 4328, 7, 339, 347, 4205, 8, 277, 12, 2467, 304, 267, 7249, 14, 4824, 63, 1345, 63, 692, 63, 2444, 8, 1556, 12, 283, 8515, 63, 3070, 358, 267, 2467, 14, 2526, 4852, 288, 1218, 503, 3350, 2455, 13590, 63, 3070, 465, 334, 355, 3504, 490, 1748, 8, 76, 14, 344, 9, 465, 1305, 12, 490, 634, 14, 2558, 63, 344, 465, 3336, 63, 344, 12, 490, 307, 14, 7519, 63, 344, 465, 3336, 63, 7519, 12, 490, 3089, 8, 76, 14, 2558, 63, 7519, 63, 5643, 1182, 399, 14, 4778, 627, 399, 18, 14, 4778, 9, 465, 3336, 63, 7519, 63, 5643, 12, 490, 3089, 8, 76, 14, 2558, 63, 7519, 63, 5643, 627, 634, 14, 4777, 63, 3248, 627, 334, 1960, 14, 16, 13, 76, 14, 15446, 9, 1182, 2948, 14, 16, 9, 465, 8033, 63, 2923, 12, 490, 413, 465, 31646, 12, 490, 308, 14, 602, 63, 1648, 465, 1434, 12, 490, 308, 14, 602, 63, 9548, 465, 1434, 63, 9548, 12, 490, 370, 63, 1560, 8, 83, 14, 602, 63, 1648, 12, 283, 15703, 358, 465, 5361, 12, 490, 370, 63, 1560, 8, 83, 14, 602, 63, 1648, 12, 283, 3218, 358, 465, 5794, 12, 490, 370, 63, 1560, 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, 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= ['_skeletons.hdf5', '_trajectories.hdf5', '_features.hdf5', '_intensities.hdf5', '_feat_manual.hdf5', '_subsample.avi', '.wcon.zip', '_featuresN.hdf5' ] IMG_EXT = ['.png', '.jpeg', '.jpg', '.tif', '.tiff', '.bmp'] def remove_ext(fname): for rext in RESERVED_EXT: if fname.endswith(rext): return fname.replace(rext, '') return os.path.splitext(fname)[0] def get_base_name(fname): return os.path.basename(remove_ext(fname)) def replace_subdir(original_dir, original_subdir, new_subdir): # construct the results dir on base of the mask_dir_root original_dir = os.path.normpath(original_dir) subdir_list = original_dir.split(os.sep) for ii in range(len(subdir_list))[::-1]: if subdir_list[ii] == original_subdir: subdir_list[ii] = new_subdir break # the counter arrived to zero, add new_subdir at the end of the directory if ii == 0: if subdir_list[-1] == '': del subdir_list[-1] subdir_list.append(new_subdir) return (os.sep).join(subdir_list) def save_modified_table(file_name, modified_table, table_name): tab_recarray = modified_table.to_records(index=False) with tables.File(file_name, "r+") as fid: dum_name = table_name + '_d' if '/' + dum_name in fid: fid.remove_node('/', dum_name) newT = fid.create_table( '/', dum_name, obj=tab_recarray, filters=TABLE_FILTERS) oldT = fid.get_node('/' + table_name) old_args = [x for x in dir(oldT._v_attrs) if not x.startswith('_')] for key in old_args: if not key in newT._v_attrs and not key.startswith('FIELD'): newT.attrs[key] = oldT.attrs[key] fid.remove_node('/', table_name) newT.rename(table_name)
mit
[ 646, 747, 199, 646, 6716, 199, 504, 1275, 9923, 492, 9934, 63, 9905, 51, 199, 199, 26933, 63, 2472, 275, 4044, 29250, 83, 14, 19912, 21, 297, 8892, 2513, 1239, 963, 6112, 14, 19912, 21, 297, 8892, 2513, 3179, 14, 19912, 21, 297, 8892, 2513, 262, 724, 338, 1417, 14, 19912, 21, 297, 8892, 2513, 11873, 63, 9285, 14, 19912, 21, 297, 355, 2513, 954, 3271, 14, 7194, 297, 355, 1987, 87, 388, 14, 3065, 297, 355, 2513, 3179, 46, 14, 19912, 21, 7, 355, 1622, 199, 199, 26246, 63, 2472, 275, 18953, 4524, 297, 1987, 14230, 297, 1987, 8476, 297, 1987, 9142, 297, 1987, 29119, 297, 1987, 22308, 418, 199, 199, 318, 2813, 63, 832, 8, 5252, 304, 272, 367, 295, 400, 315, 12565, 540, 14112, 63, 2472, 26, 267, 340, 6748, 14, 4130, 8, 264, 400, 304, 288, 372, 6748, 14, 1814, 8, 264, 400, 12, 4074, 272, 372, 747, 14, 515, 14, 7973, 8, 5252, 2788, 16, 61, 199, 199, 318, 664, 63, 1095, 63, 354, 8, 5252, 304, 272, 372, 747, 14, 515, 14, 4846, 8, 2168, 63, 832, 8, 5252, 430, 199, 199, 318, 3350, 63, 10622, 8, 5043, 63, 694, 12, 3379, 63, 10622, 12, 892, 63, 10622, 304, 272, 327, 6982, 314, 2058, 2935, 641, 1300, 402, 314, 3656, 63, 694, 63, 1231, 272, 3379, 63, 694, 275, 747, 14, 515, 14, 9267, 8, 5043, 63, 694, 9, 272, 15488, 63, 513, 275, 3379, 63, 694, 14, 1294, 8, 736, 14, 4127, 9, 272, 367, 15393, 315, 1425, 8, 552, 8, 10622, 63, 513, 430, 14172, 17, 2189, 267, 340, 15488, 63, 513, 59, 5908, 61, 508, 3379, 63, 10622, 26, 288, 15488, 63, 513, 59, 5908, 61, 275, 892, 63, 10622, 288, 2059, 272, 327, 314, 7055, 601, 322, 1354, 370, 4697, 12, 1050, 892, 63, 10622, 737, 314, 1284, 402, 314, 2082, 272, 340, 15393, 508, 378, 26, 267, 340, 15488, 63, 513, 1988, 17, 61, 508, 8061, 288, 2150, 15488, 63, 513, 1988, 17, 61, 267, 15488, 63, 513, 14, 740, 8, 1222, 63, 10622, 9, 339, 372, 334, 736, 14, 4127, 680, 904, 8, 10622, 63, 513, 9, 199, 199, 318, 3354, 63, 5540, 63, 1224, 8, 493, 63, 354, 12, 6042, 63, 1224, 12, 1817, 63, 354, 304, 272, 5174, 63, 2761, 1144, 275, 6042, 63, 1224, 14, 475, 63, 6502, 8, 1080, 29, 797, 9, 272, 543, 6716, 14, 1173, 8, 493, 63, 354, 12, 298, 82, 21425, 465, 8289, 26, 267, 366, 453, 63, 354, 275, 1817, 63, 354, 435, 2513, 68, 7, 267, 340, 7324, 435, 366, 453, 63, 354, 315, 8289, 26, 288, 8289, 14, 2168, 63, 932, 10998, 366, 453, 63, 354, 9, 398, 892, 52, 275, 8289, 14, 981, 63, 1224, 8, 288, 17220, 288, 366, 453, 63, 354, 12, 288, 1559, 29, 2902, 63, 2761, 1144, 12, 288, 4766, 29, 8723, 63, 9905, 51, 9, 398, 2269, 52, 275, 8289, 14, 362, 63, 932, 2336, 7, 435, 1817, 63, 354, 9, 267, 2269, 63, 589, 275, 359, 88, 367, 671, 315, 2935, 8, 1753, 52, 423, 86, 63, 3288, 9, 340, 440, 671, 14, 2460, 6412, 5440, 267, 367, 790, 315, 2269, 63, 589, 26, 7846, 340, 440, 790, 315, 892, 52, 423, 86, 63, 3288, 436, 440, 790, 14, 2460, 360, 8609, 735, 355, 892, 52, 14, 3288, 59, 498, 61, 275, 2269, 52, 14, 3288, 59, 498, 61, 21695, 8289, 14, 2168, 63, 932, 10998, 1817, 63, 354, 9, 267, 892, 52, 14, 8165, 8, 1224, 63, 354, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 646, 6716, 199, 504, 1275, 9923, 492, 9934, 63, 9905, 51, 199, 199, 26933, 63, 2472, 275, 4044, 29250, 83, 14, 19912, 21, 297, 8892, 2513, 1239, 963, 6112, 14, 19912, 21, 297, 8892, 2513, 3179, 14, 19912, 21, 297, 8892, 2513, 262, 724, 338, 1417, 14, 19912, 21, 297, 8892, 2513, 11873, 63, 9285, 14, 19912, 21, 297, 355, 2513, 954, 3271, 14, 7194, 297, 355, 1987, 87, 388, 14, 3065, 297, 355, 2513, 3179, 46, 14, 19912, 21, 7, 355, 1622, 199, 199, 26246, 63, 2472, 275, 18953, 4524, 297, 1987, 14230, 297, 1987, 8476, 297, 1987, 9142, 297, 1987, 29119, 297, 1987, 22308, 418, 199, 199, 318, 2813, 63, 832, 8, 5252, 304, 272, 367, 295, 400, 315, 12565, 540, 14112, 63, 2472, 26, 267, 340, 6748, 14, 4130, 8, 264, 400, 304, 288, 372, 6748, 14, 1814, 8, 264, 400, 12, 4074, 272, 372, 747, 14, 515, 14, 7973, 8, 5252, 2788, 16, 61, 199, 199, 318, 664, 63, 1095, 63, 354, 8, 5252, 304, 272, 372, 747, 14, 515, 14, 4846, 8, 2168, 63, 832, 8, 5252, 430, 199, 199, 318, 3350, 63, 10622, 8, 5043, 63, 694, 12, 3379, 63, 10622, 12, 892, 63, 10622, 304, 272, 327, 6982, 314, 2058, 2935, 641, 1300, 402, 314, 3656, 63, 694, 63, 1231, 272, 3379, 63, 694, 275, 747, 14, 515, 14, 9267, 8, 5043, 63, 694, 9, 272, 15488, 63, 513, 275, 3379, 63, 694, 14, 1294, 8, 736, 14, 4127, 9, 272, 367, 15393, 315, 1425, 8, 552, 8, 10622, 63, 513, 430, 14172, 17, 2189, 267, 340, 15488, 63, 513, 59, 5908, 61, 508, 3379, 63, 10622, 26, 288, 15488, 63, 513, 59, 5908, 61, 275, 892, 63, 10622, 288, 2059, 272, 327, 314, 7055, 601, 322, 1354, 370, 4697, 12, 1050, 892, 63, 10622, 737, 314, 1284, 402, 314, 2082, 272, 340, 15393, 508, 378, 26, 267, 340, 15488, 63, 513, 1988, 17, 61, 508, 8061, 288, 2150, 15488, 63, 513, 1988, 17, 61, 267, 15488, 63, 513, 14, 740, 8, 1222, 63, 10622, 9, 339, 372, 334, 736, 14, 4127, 680, 904, 8, 10622, 63, 513, 9, 199, 199, 318, 3354, 63, 5540, 63, 1224, 8, 493, 63, 354, 12, 6042, 63, 1224, 12, 1817, 63, 354, 304, 272, 5174, 63, 2761, 1144, 275, 6042, 63, 1224, 14, 475, 63, 6502, 8, 1080, 29, 797, 9, 272, 543, 6716, 14, 1173, 8, 493, 63, 354, 12, 298, 82, 21425, 465, 8289, 26, 267, 366, 453, 63, 354, 275, 1817, 63, 354, 435, 2513, 68, 7, 267, 340, 7324, 435, 366, 453, 63, 354, 315, 8289, 26, 288, 8289, 14, 2168, 63, 932, 10998, 366, 453, 63, 354, 9, 398, 892, 52, 275, 8289, 14, 981, 63, 1224, 8, 288, 17220, 288, 366, 453, 63, 354, 12, 288, 1559, 29, 2902, 63, 2761, 1144, 12, 288, 4766, 29, 8723, 63, 9905, 51, 9, 398, 2269, 52, 275, 8289, 14, 362, 63, 932, 2336, 7, 435, 1817, 63, 354, 9, 267, 2269, 63, 589, 275, 359, 88, 367, 671, 315, 2935, 8, 1753, 52, 423, 86, 63, 3288, 9, 340, 440, 671, 14, 2460, 6412, 5440, 267, 367, 790, 315, 2269, 63, 589, 26, 7846, 340, 440, 790, 315, 892, 52, 423, 86, 63, 3288, 436, 440, 790, 14, 2460, 360, 8609, 735, 355, 892, 52, 14, 3288, 59, 498, 61, 275, 2269, 52, 14, 3288, 59, 498, 61, 21695, 8289, 14, 2168, 63, 932, 10998, 1817, 63, 354, 9, 267, 892, 52, 14, 8165, 8, 1224, 63, 354, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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# n is the number of pieces to animate; default is 4, maximum 15. # # The bitmap file can be any X11 bitmap file (look in # /usr/include/X11/bitmaps for samples); it is displayed as the # background of the animation. Default is no bitmap. # This uses Steen Lumholt's Tk interface from Tkinter import * # Basic Towers-of-Hanoi algorithm: move n pieces from a to b, using c # as temporary. For each move, call report() def hanoi(n, a, b, c, report): if n <= 0: return hanoi(n-1, a, c, b, report) report(n, a, b) hanoi(n-1, c, b, a, report) # The graphical interface class Tkhanoi: # Create our objects def __init__(self, n, bitmap = None): self.n = n self.tk = tk = Tk() self.canvas = c = Canvas(tk) c.pack() width, height = tk.getint(c['width']), tk.getint(c['height']) # Add background bitmap if bitmap: self.bitmap = c.create_bitmap(width//2, height//2, bitmap=bitmap, foreground='blue') # Generate pegs pegwidth = 10 pegheight = height//2 pegdist = width//3 x1, y1 = (pegdist-pegwidth)//2, height*1//3 x2, y2 = x1+pegwidth, y1+pegheight self.pegs = [] p = c.create_rectangle(x1, y1, x2, y2, fill='black') self.pegs.append(p) x1, x2 = x1+pegdist, x2+pegdist p = c.create_rectangle(x1, y1, x2, y2, fill='black') self.pegs.append(p) x1, x2 = x1+pegdist, x2+pegdist p = c.create_rectangle(x1, y1, x2, y2, fill='black') self.pegs.append(p) self.tk.update() # Generate pieces pieceheight = pegheight//16 maxpiecewidth = pegdist*2//3 minpiecewidth = 2*pegwidth self.pegstate = [[], [], []] self.pieces = {} x1, y1 = (pegdist-maxpiecewidth)//2, y2-pieceheight-2 x2, y2 = x1+maxpiecewidth, y1+pieceheight dx = (maxpiecewidth-minpiecewidth) // (2*max(1, n-1)) for i in range(n, 0, -1): p = c.create_rectangle(x1, y1, x2, y2, fill='red') self.pieces[i] = p self.pegstate[0].append(i) x1, x2 = x1 + dx, x2-dx y1, y2 = y1 - pieceheight-2, y2-pieceheight-2 self.tk.update() self.tk.after(25) # Run -- never returns def run(self): while 1: hanoi(self.n, 0, 1, 2, self.report) hanoi(self.n, 1, 2, 0, self.report) hanoi(self.n, 2, 0, 1, self.report) hanoi(self.n, 0, 2, 1, self.report) hanoi(self.n, 2, 1, 0, self.report) hanoi(self.n, 1, 0, 2, self.report) # Reporting callback for the actual hanoi function def report(self, i, a, b): if self.pegstate[a][-1] != i: raise RuntimeError # Assertion del self.pegstate[a][-1] p = self.pieces[i] c = self.canvas # Lift the piece above peg a ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a]) while 1: x1, y1, x2, y2 = c.bbox(p) if y2 < ay1: break c.move(p, 0, -1) self.tk.update() # Move it towards peg b bx1, by1, bx2, by2 = c.bbox(self.pegs[b]) newcenter = (bx1+bx2)//2 while 1: x1, y1, x2, y2 = c.bbox(p) center = (x1+x2)//2 if center == newcenter: break if center > newcenter: c.move(p, -1, 0) else: c.move(p, 1, 0) self.tk.update() # Move it down on top of the previous piece pieceheight = y2-y1 newbottom = by2 - pieceheight*len(self.pegstate[b]) - 2 while 1: x1, y1, x2, y2 = c.bbox(p) if y2 >= newbottom: break c.move(p, 0, 1) self.tk.update() # Update peg state self.pegstate[b].append(i) # Main program def main(): import sys, string # First argument is number of pegs, default 4 if sys.argv[1:]: n = string.atoi(sys.argv[1]) else: n = 4 # Second argument is bitmap file, default none if sys.argv[2:]: bitmap = sys.argv[2] # Reverse meaning of leading '@' compared to Tk if bitmap[0] == '@': bitmap = bitmap[1:] else: bitmap = '@' + bitmap else: bitmap = None # Create the graphical objects... h = Tkhanoi(n, bitmap) # ...and run! h.run() # Call main when run as script if __name__ == '__main__': main()
apache-2.0
[ 3, 1626, 12754, 377, 583, 1192, 402, 869, 8143, 73, 1808, 12435, 543, 2716, 20810, 570, 315, 199, 3, 8020, 14, 199, 3, 199, 3, 11028, 26, 10157, 72, 8143, 73, 359, 78, 359, 20299, 493, 2677, 199, 3, 199, 3, 302, 365, 314, 1329, 402, 10338, 370, 376, 6897, 27, 849, 365, 841, 12, 5696, 4114, 14, 199, 3, 199, 3, 710, 20810, 570, 883, 506, 1263, 1323, 845, 20810, 570, 334, 11660, 315, 199, 3, 1182, 2647, 15, 2613, 15, 56, 845, 15, 2075, 8919, 367, 5845, 2736, 652, 365, 9080, 465, 314, 199, 3, 8020, 402, 314, 24154, 14, 221, 3758, 365, 949, 20810, 14, 199, 199, 3, 961, 4440, 17854, 287, 491, 453, 24588, 84, 1159, 12435, 3217, 199, 504, 16826, 492, 627, 421, 199, 3, 10082, 377, 583, 1192, 13, 1618, 13, 40, 8143, 73, 5563, 26, 4057, 302, 10338, 687, 282, 370, 330, 12, 1808, 286, 199, 3, 465, 7937, 14, 221, 2104, 1924, 4057, 12, 1240, 3622, 342, 199, 318, 394, 8143, 73, 8, 78, 12, 282, 12, 330, 12, 286, 12, 3622, 304, 272, 340, 302, 2695, 378, 26, 372, 272, 394, 8143, 73, 8, 78, 13, 17, 12, 282, 12, 286, 12, 330, 12, 3622, 9, 272, 3622, 8, 78, 12, 282, 12, 330, 9, 272, 394, 8143, 73, 8, 78, 13, 17, 12, 286, 12, 330, 12, 282, 12, 3622, 9, 421, 199, 3, 710, 3343, 2652, 3217, 199, 533, 12435, 72, 8143, 73, 26, 339, 327, 2790, 4154, 2251, 272, 347, 636, 826, 721, 277, 12, 302, 12, 20810, 275, 488, 304, 267, 291, 14, 78, 275, 302, 267, 291, 14, 2663, 275, 10157, 275, 12435, 342, 267, 291, 14, 7682, 275, 286, 275, 29349, 8, 2663, 9, 267, 286, 14, 1389, 342, 267, 3462, 12, 4569, 275, 10157, 14, 26627, 8, 67, 459, 2063, 3815, 10157, 14, 26627, 8, 67, 459, 3333, 1105, 398, 327, 2654, 8020, 20810, 267, 340, 20810, 26, 288, 291, 14, 20299, 275, 286, 14, 981, 63, 20299, 8, 2063, 501, 18, 12, 4569, 501, 18, 12, 5101, 20810, 29, 20299, 12, 5101, 24470, 534, 6304, 358, 398, 327, 7958, 4837, 458, 267, 4837, 71, 2063, 275, 1616, 267, 4837, 71, 3333, 275, 4569, 501, 18, 267, 4837, 71, 2686, 275, 3462, 501, 19, 267, 671, 17, 12, 612, 17, 275, 334, 11997, 2686, 13, 11997, 2063, 28428, 18, 12, 4569, 10, 17, 501, 19, 267, 671, 18, 12, 612, 18, 275, 671, 17, 11, 11997, 2063, 12, 612, 17, 11, 11997, 3333, 267, 291, 14, 321, 458, 275, 942, 267, 299, 275, 286, 14, 981, 63, 19954, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 12, 5554, 534, 8399, 358, 267, 291, 14, 321, 458, 14, 740, 8, 80, 9, 267, 671, 17, 12, 671, 18, 275, 671, 17, 11, 11997, 2686, 12, 671, 18, 11, 11997, 2686, 267, 299, 275, 286, 14, 981, 63, 19954, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 12, 5554, 534, 8399, 358, 267, 291, 14, 321, 458, 14, 740, 8, 80, 9, 267, 671, 17, 12, 671, 18, 275, 671, 17, 11, 11997, 2686, 12, 671, 18, 11, 11997, 2686, 267, 299, 275, 286, 14, 981, 63, 19954, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 12, 5554, 534, 8399, 358, 267, 291, 14, 321, 458, 14, 740, 8, 80, 9, 267, 291, 14, 2663, 14, 873, 342, 398, 327, 7958, 10338, 267, 14854, 3333, 275, 4837, 71, 3333, 501, 975, 267, 1390, 20082, 2063, 275, 4837, 71, 2686, 10, 18, 501, 19, 267, 1748, 20082, 2063, 275, 499, 10, 11997, 2063, 267, 291, 14, 11997, 929, 275, 3474, 467, 990, 942, 61, 267, 291, 14, 15655, 275, 1052, 267, 671, 17, 12, 612, 17, 275, 334, 11997, 2686, 13, 988, 20082, 2063, 28428, 18, 12, 612, 18, 13, 20082, 3333, 13, 18, 267, 671, 18, 12, 612, 18, 275, 671, 17, 11, 988, 20082, 2063, 12, 612, 17, 11, 20082, 3333, 267, 11868, 275, 334, 988, 20082, 2063, 13, 827, 20082, 2063, 9, 5001, 334, 18, 10, 988, 8, 17, 12, 302, 13, 17, 430, 267, 367, 284, 315, 1425, 8, 78, 12, 378, 12, 446, 17, 304, 288, 299, 275, 286, 14, 981, 63, 19954, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 12, 5554, 534, 581, 358, 288, 291, 14, 15655, 59, 73, 61, 275, 299, 288, 291, 14, 11997, 929, 59, 16, 1055, 740, 8, 73, 9, 288, 671, 17, 12, 671, 18, 275, 671, 17, 435, 11868, 12, 671, 18, 13, 8373, 288, 612, 17, 12, 612, 18, 275, 612, 17, 446, 14854, 3333, 13, 18, 12, 612, 18, 13, 20082, 3333, 13, 18, 288, 291, 14, 2663, 14, 873, 342, 288, 291, 14, 2663, 14, 4399, 8, 821, 9, 339, 327, 3378, 1553, 7078, 2529, 272, 347, 1255, 8, 277, 304, 267, 1830, 413, 26, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 378, 12, 413, 12, 499, 12, 291, 14, 3070, 9, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 413, 12, 499, 12, 378, 12, 291, 14, 3070, 9, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 499, 12, 378, 12, 413, 12, 291, 14, 3070, 9, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 378, 12, 499, 12, 413, 12, 291, 14, 3070, 9, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 499, 12, 413, 12, 378, 12, 291, 14, 3070, 9, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 413, 12, 378, 12, 499, 12, 291, 14, 3070, 9, 339, 327, 11774, 316, 3233, 367, 314, 3503, 394, 8143, 73, 805, 272, 347, 3622, 8, 277, 12, 284, 12, 282, 12, 330, 304, 267, 340, 291, 14, 11997, 929, 59, 65, 15898, 17, 61, 1137, 284, 26, 746, 6064, 327, 3709, 4535, 267, 2150, 291, 14, 11997, 929, 59, 65, 15898, 17, 61, 267, 299, 275, 291, 14, 15655, 59, 73, 61, 267, 286, 275, 291, 14, 7682, 398, 327, 491, 2949, 314, 14854, 3432, 4837, 71, 282, 267, 2185, 17, 12, 282, 89, 17, 12, 2185, 18 ]
[ 1626, 12754, 377, 583, 1192, 402, 869, 8143, 73, 1808, 12435, 543, 2716, 20810, 570, 315, 199, 3, 8020, 14, 199, 3, 199, 3, 11028, 26, 10157, 72, 8143, 73, 359, 78, 359, 20299, 493, 2677, 199, 3, 199, 3, 302, 365, 314, 1329, 402, 10338, 370, 376, 6897, 27, 849, 365, 841, 12, 5696, 4114, 14, 199, 3, 199, 3, 710, 20810, 570, 883, 506, 1263, 1323, 845, 20810, 570, 334, 11660, 315, 199, 3, 1182, 2647, 15, 2613, 15, 56, 845, 15, 2075, 8919, 367, 5845, 2736, 652, 365, 9080, 465, 314, 199, 3, 8020, 402, 314, 24154, 14, 221, 3758, 365, 949, 20810, 14, 199, 199, 3, 961, 4440, 17854, 287, 491, 453, 24588, 84, 1159, 12435, 3217, 199, 504, 16826, 492, 627, 421, 199, 3, 10082, 377, 583, 1192, 13, 1618, 13, 40, 8143, 73, 5563, 26, 4057, 302, 10338, 687, 282, 370, 330, 12, 1808, 286, 199, 3, 465, 7937, 14, 221, 2104, 1924, 4057, 12, 1240, 3622, 342, 199, 318, 394, 8143, 73, 8, 78, 12, 282, 12, 330, 12, 286, 12, 3622, 304, 272, 340, 302, 2695, 378, 26, 372, 272, 394, 8143, 73, 8, 78, 13, 17, 12, 282, 12, 286, 12, 330, 12, 3622, 9, 272, 3622, 8, 78, 12, 282, 12, 330, 9, 272, 394, 8143, 73, 8, 78, 13, 17, 12, 286, 12, 330, 12, 282, 12, 3622, 9, 421, 199, 3, 710, 3343, 2652, 3217, 199, 533, 12435, 72, 8143, 73, 26, 339, 327, 2790, 4154, 2251, 272, 347, 636, 826, 721, 277, 12, 302, 12, 20810, 275, 488, 304, 267, 291, 14, 78, 275, 302, 267, 291, 14, 2663, 275, 10157, 275, 12435, 342, 267, 291, 14, 7682, 275, 286, 275, 29349, 8, 2663, 9, 267, 286, 14, 1389, 342, 267, 3462, 12, 4569, 275, 10157, 14, 26627, 8, 67, 459, 2063, 3815, 10157, 14, 26627, 8, 67, 459, 3333, 1105, 398, 327, 2654, 8020, 20810, 267, 340, 20810, 26, 288, 291, 14, 20299, 275, 286, 14, 981, 63, 20299, 8, 2063, 501, 18, 12, 4569, 501, 18, 12, 5101, 20810, 29, 20299, 12, 5101, 24470, 534, 6304, 358, 398, 327, 7958, 4837, 458, 267, 4837, 71, 2063, 275, 1616, 267, 4837, 71, 3333, 275, 4569, 501, 18, 267, 4837, 71, 2686, 275, 3462, 501, 19, 267, 671, 17, 12, 612, 17, 275, 334, 11997, 2686, 13, 11997, 2063, 28428, 18, 12, 4569, 10, 17, 501, 19, 267, 671, 18, 12, 612, 18, 275, 671, 17, 11, 11997, 2063, 12, 612, 17, 11, 11997, 3333, 267, 291, 14, 321, 458, 275, 942, 267, 299, 275, 286, 14, 981, 63, 19954, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 12, 5554, 534, 8399, 358, 267, 291, 14, 321, 458, 14, 740, 8, 80, 9, 267, 671, 17, 12, 671, 18, 275, 671, 17, 11, 11997, 2686, 12, 671, 18, 11, 11997, 2686, 267, 299, 275, 286, 14, 981, 63, 19954, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 12, 5554, 534, 8399, 358, 267, 291, 14, 321, 458, 14, 740, 8, 80, 9, 267, 671, 17, 12, 671, 18, 275, 671, 17, 11, 11997, 2686, 12, 671, 18, 11, 11997, 2686, 267, 299, 275, 286, 14, 981, 63, 19954, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 12, 5554, 534, 8399, 358, 267, 291, 14, 321, 458, 14, 740, 8, 80, 9, 267, 291, 14, 2663, 14, 873, 342, 398, 327, 7958, 10338, 267, 14854, 3333, 275, 4837, 71, 3333, 501, 975, 267, 1390, 20082, 2063, 275, 4837, 71, 2686, 10, 18, 501, 19, 267, 1748, 20082, 2063, 275, 499, 10, 11997, 2063, 267, 291, 14, 11997, 929, 275, 3474, 467, 990, 942, 61, 267, 291, 14, 15655, 275, 1052, 267, 671, 17, 12, 612, 17, 275, 334, 11997, 2686, 13, 988, 20082, 2063, 28428, 18, 12, 612, 18, 13, 20082, 3333, 13, 18, 267, 671, 18, 12, 612, 18, 275, 671, 17, 11, 988, 20082, 2063, 12, 612, 17, 11, 20082, 3333, 267, 11868, 275, 334, 988, 20082, 2063, 13, 827, 20082, 2063, 9, 5001, 334, 18, 10, 988, 8, 17, 12, 302, 13, 17, 430, 267, 367, 284, 315, 1425, 8, 78, 12, 378, 12, 446, 17, 304, 288, 299, 275, 286, 14, 981, 63, 19954, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 12, 5554, 534, 581, 358, 288, 291, 14, 15655, 59, 73, 61, 275, 299, 288, 291, 14, 11997, 929, 59, 16, 1055, 740, 8, 73, 9, 288, 671, 17, 12, 671, 18, 275, 671, 17, 435, 11868, 12, 671, 18, 13, 8373, 288, 612, 17, 12, 612, 18, 275, 612, 17, 446, 14854, 3333, 13, 18, 12, 612, 18, 13, 20082, 3333, 13, 18, 288, 291, 14, 2663, 14, 873, 342, 288, 291, 14, 2663, 14, 4399, 8, 821, 9, 339, 327, 3378, 1553, 7078, 2529, 272, 347, 1255, 8, 277, 304, 267, 1830, 413, 26, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 378, 12, 413, 12, 499, 12, 291, 14, 3070, 9, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 413, 12, 499, 12, 378, 12, 291, 14, 3070, 9, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 499, 12, 378, 12, 413, 12, 291, 14, 3070, 9, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 378, 12, 499, 12, 413, 12, 291, 14, 3070, 9, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 499, 12, 413, 12, 378, 12, 291, 14, 3070, 9, 288, 394, 8143, 73, 8, 277, 14, 78, 12, 413, 12, 378, 12, 499, 12, 291, 14, 3070, 9, 339, 327, 11774, 316, 3233, 367, 314, 3503, 394, 8143, 73, 805, 272, 347, 3622, 8, 277, 12, 284, 12, 282, 12, 330, 304, 267, 340, 291, 14, 11997, 929, 59, 65, 15898, 17, 61, 1137, 284, 26, 746, 6064, 327, 3709, 4535, 267, 2150, 291, 14, 11997, 929, 59, 65, 15898, 17, 61, 267, 299, 275, 291, 14, 15655, 59, 73, 61, 267, 286, 275, 291, 14, 7682, 398, 327, 491, 2949, 314, 14854, 3432, 4837, 71, 282, 267, 2185, 17, 12, 282, 89, 17, 12, 2185, 18, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Jichao/skia
tools/skp/page_sets/skia_css3gradients_desktop.py
32
1393
# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # pylint: disable=W0401,W0614 from telemetry import story from telemetry.page import page as page_module from telemetry.page import shared_page_state class SkiaBuildbotDesktopPage(page_module.Page): def __init__(self, url, page_set): super(SkiaBuildbotDesktopPage, self).__init__( url=url, page_set=page_set, credentials_path='data/credentials.json', shared_page_state_class=shared_page_state.SharedDesktopPageState) self.archive_data_file = 'data/skia_css3gradients_desktop.json' def RunSmoothness(self, action_runner): action_runner.ScrollElement() def RunNavigateSteps(self, action_runner): action_runner.Navigate(self.url) action_runner.Wait(15) class SkiaCss3gradientsDesktopPageSet(story.StorySet): """ Pages designed to represent the median, not highly optimized web """ def __init__(self): super(SkiaCss3gradientsDesktopPageSet, self).__init__( archive_data_file='data/skia_css3gradients_desktop.json') urls_list = [ # Why: http://code.google.com/p/chromium/issues/detail?id=168448 'https://www.webkit.org/blog/1424/css3-gradients/', ] for url in urls_list: self.AddStory(SkiaBuildbotDesktopPage(url, self))
bsd-3-clause
[ 3, 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 3, 4287, 26, 3507, 29, 55, 28025, 12, 55, 1690, 1079, 421, 199, 504, 17298, 492, 19222, 199, 504, 17298, 14, 1606, 492, 2034, 465, 2034, 63, 578, 199, 504, 17298, 14, 1606, 492, 5709, 63, 1606, 63, 929, 421, 199, 533, 29201, 4674, 3425, 3018, 20436, 3276, 8, 1606, 63, 578, 14, 3276, 304, 819, 347, 636, 826, 721, 277, 12, 1166, 12, 2034, 63, 409, 304, 272, 1613, 8, 14194, 4674, 3425, 3018, 20436, 3276, 12, 291, 2843, 826, 721, 267, 1166, 29, 633, 12, 267, 2034, 63, 409, 29, 1606, 63, 409, 12, 267, 6235, 63, 515, 534, 576, 15, 6942, 14, 1001, 297, 267, 5709, 63, 1606, 63, 929, 63, 533, 29, 5555, 63, 1606, 63, 929, 14, 12197, 20436, 3276, 2223, 9, 272, 291, 14, 6404, 63, 576, 63, 493, 275, 283, 576, 15, 1339, 4674, 63, 3919, 19, 13065, 63, 14487, 14, 1001, 7, 819, 347, 3378, 51, 11607, 4171, 8, 277, 12, 1595, 63, 5933, 304, 272, 1595, 63, 5933, 14, 13127, 2162, 342, 819, 347, 3378, 31914, 20960, 8, 277, 12, 1595, 63, 5933, 304, 272, 1595, 63, 5933, 14, 31914, 8, 277, 14, 633, 9, 272, 1595, 63, 5933, 14, 7536, 8, 1046, 9, 421, 199, 533, 29201, 4674, 35, 385, 19, 13065, 20436, 3276, 1084, 8, 17372, 14, 25120, 1084, 304, 819, 408, 510, 7441, 19829, 370, 2954, 314, 17312, 12, 440, 4721, 590, 20212, 3330, 408, 819, 347, 636, 826, 721, 277, 304, 272, 1613, 8, 14194, 4674, 35, 385, 19, 13065, 20436, 3276, 1084, 12, 291, 2843, 826, 721, 489, 6359, 63, 576, 63, 493, 534, 576, 15, 1339, 4674, 63, 3919, 19, 13065, 63, 14487, 14, 1001, 358, 339, 8187, 63, 513, 275, 359, 489, 327, 6827, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 13211, 15, 10115, 15, 5506, 31, 344, 29, 975, 1349, 2006, 489, 283, 2859, 921, 1544, 14, 12554, 14, 1308, 15, 11486, 15, 1079, 1194, 15, 3919, 19, 13, 13065, 3678, 272, 1622, 339, 367, 1166, 315, 8187, 63, 513, 26, 489, 291, 14, 1123, 25120, 8, 14194, 4674, 3425, 3018, 20436, 3276, 8, 633, 12, 291, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 3, 4287, 26, 3507, 29, 55, 28025, 12, 55, 1690, 1079, 421, 199, 504, 17298, 492, 19222, 199, 504, 17298, 14, 1606, 492, 2034, 465, 2034, 63, 578, 199, 504, 17298, 14, 1606, 492, 5709, 63, 1606, 63, 929, 421, 199, 533, 29201, 4674, 3425, 3018, 20436, 3276, 8, 1606, 63, 578, 14, 3276, 304, 819, 347, 636, 826, 721, 277, 12, 1166, 12, 2034, 63, 409, 304, 272, 1613, 8, 14194, 4674, 3425, 3018, 20436, 3276, 12, 291, 2843, 826, 721, 267, 1166, 29, 633, 12, 267, 2034, 63, 409, 29, 1606, 63, 409, 12, 267, 6235, 63, 515, 534, 576, 15, 6942, 14, 1001, 297, 267, 5709, 63, 1606, 63, 929, 63, 533, 29, 5555, 63, 1606, 63, 929, 14, 12197, 20436, 3276, 2223, 9, 272, 291, 14, 6404, 63, 576, 63, 493, 275, 283, 576, 15, 1339, 4674, 63, 3919, 19, 13065, 63, 14487, 14, 1001, 7, 819, 347, 3378, 51, 11607, 4171, 8, 277, 12, 1595, 63, 5933, 304, 272, 1595, 63, 5933, 14, 13127, 2162, 342, 819, 347, 3378, 31914, 20960, 8, 277, 12, 1595, 63, 5933, 304, 272, 1595, 63, 5933, 14, 31914, 8, 277, 14, 633, 9, 272, 1595, 63, 5933, 14, 7536, 8, 1046, 9, 421, 199, 533, 29201, 4674, 35, 385, 19, 13065, 20436, 3276, 1084, 8, 17372, 14, 25120, 1084, 304, 819, 408, 510, 7441, 19829, 370, 2954, 314, 17312, 12, 440, 4721, 590, 20212, 3330, 408, 819, 347, 636, 826, 721, 277, 304, 272, 1613, 8, 14194, 4674, 35, 385, 19, 13065, 20436, 3276, 1084, 12, 291, 2843, 826, 721, 489, 6359, 63, 576, 63, 493, 534, 576, 15, 1339, 4674, 63, 3919, 19, 13065, 63, 14487, 14, 1001, 358, 339, 8187, 63, 513, 275, 359, 489, 327, 6827, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 13211, 15, 10115, 15, 5506, 31, 344, 29, 975, 1349, 2006, 489, 283, 2859, 921, 1544, 14, 12554, 14, 1308, 15, 11486, 15, 1079, 1194, 15, 3919, 19, 13, 13065, 3678, 272, 1622, 339, 367, 1166, 315, 8187, 63, 513, 26, 489, 291, 14, 1123, 25120, 8, 14194, 4674, 3425, 3018, 20436, 3276, 8, 633, 12, 291, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
girving/tensorflow
tensorflow/python/tools/api/generator/doc_srcs.py
9
3894
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Specifies sources of doc strings for API modules.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections from tensorflow.python.util import tf_export # Specifies docstring source for a module. # Only one of docstring or docstring_module_name should be set. # * If docstring is set, then we will use this docstring when # for the module. # * If docstring_module_name is set, then we will copy the docstring # from docstring source module. DocSource = collections.namedtuple( 'DocSource', ['docstring', 'docstring_module_name']) # Each attribute of DocSource is optional. DocSource.__new__.__defaults__ = (None,) * len(DocSource._fields) _TENSORFLOW_DOC_SOURCES = { 'app': DocSource(docstring_module_name='platform.app'), 'compat': DocSource(docstring_module_name='util.compat'), 'distributions': DocSource( docstring_module_name='ops.distributions.distributions'), 'bitwise': DocSource(docstring_module_name='ops.bitwise_ops'), 'errors': DocSource(docstring_module_name='framework.errors'), 'gfile': DocSource(docstring_module_name='platform.gfile'), 'graph_util': DocSource(docstring_module_name='framework.graph_util'), 'image': DocSource(docstring_module_name='ops.image_ops'), 'keras.estimator': DocSource(docstring_module_name='keras.estimator'), 'linalg': DocSource(docstring_module_name='ops.linalg_ops'), 'logging': DocSource(docstring_module_name='ops.logging_ops'), 'losses': DocSource(docstring_module_name='ops.losses.losses'), 'manip': DocSource(docstring_module_name='ops.manip_ops'), 'math': DocSource(docstring_module_name='ops.math_ops'), 'metrics': DocSource(docstring_module_name='ops.metrics'), 'nn': DocSource(docstring_module_name='ops.nn_ops'), 'nn.rnn_cell': DocSource(docstring_module_name='ops.rnn_cell'), 'python_io': DocSource(docstring_module_name='lib.io.python_io'), 'resource_loader': DocSource( docstring_module_name='platform.resource_loader'), 'sets': DocSource(docstring_module_name='ops.sets'), 'sparse': DocSource(docstring_module_name='ops.sparse_ops'), 'spectral': DocSource(docstring_module_name='ops.spectral_ops'), 'strings': DocSource(docstring_module_name='ops.string_ops'), 'sysconfig': DocSource(docstring_module_name='platform.sysconfig'), 'test': DocSource(docstring_module_name='platform.test'), 'train': DocSource(docstring_module_name='training.training'), } _ESTIMATOR_DOC_SOURCES = { 'estimator': DocSource( docstring_module_name='estimator_lib'), 'estimator.export': DocSource( docstring_module_name='export.export_lib'), 'estimator.inputs': DocSource( docstring_module_name='inputs.inputs'), } def get_doc_sources(api_name): """Get a map from module to a DocSource object. Args: api_name: API you want to generate (e.g. `tensorflow` or `estimator`). Returns: Map from module name to DocSource object. """ if api_name == tf_export.TENSORFLOW_API_NAME: return _TENSORFLOW_DOC_SOURCES if api_name == tf_export.ESTIMATOR_API_NAME: return _ESTIMATOR_DOC_SOURCES return {}
apache-2.0
[ 3, 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 6154, 5604, 5274, 402, 1382, 3326, 367, 3261, 4621, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 5055, 199, 199, 504, 3228, 14, 1548, 14, 1974, 492, 2833, 63, 3790, 421, 199, 3, 11015, 9214, 1350, 367, 282, 859, 14, 199, 3, 5972, 1373, 402, 9214, 503, 9214, 63, 578, 63, 354, 1077, 506, 663, 14, 199, 3, 627, 982, 9214, 365, 663, 12, 2066, 781, 911, 675, 642, 9214, 1380, 199, 3, 257, 367, 314, 859, 14, 199, 3, 627, 982, 9214, 63, 578, 63, 354, 365, 663, 12, 2066, 781, 911, 1331, 314, 9214, 199, 3, 257, 687, 9214, 1350, 859, 14, 199, 3768, 2980, 275, 5055, 14, 18921, 8, 272, 283, 3768, 2980, 297, 788, 12485, 297, 283, 12485, 63, 578, 63, 354, 1105, 199, 3, 7048, 2225, 402, 5454, 2980, 365, 2716, 14, 199, 3768, 2980, 855, 1222, 4914, 4322, 363, 275, 334, 403, 4258, 627, 822, 8, 3768, 2980, 423, 955, 9, 199, 199, 63, 52, 17850, 17114, 63, 16618, 63, 25744, 275, 469, 272, 283, 571, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 3246, 14, 571, 659, 272, 283, 5819, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1974, 14, 5819, 659, 272, 283, 5613, 356, 5454, 2980, 8, 267, 9214, 63, 578, 63, 354, 534, 1483, 14, 5613, 14, 5613, 659, 272, 283, 28831, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 28831, 63, 1483, 659, 272, 283, 2550, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 4857, 14, 2550, 659, 272, 283, 30325, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 3246, 14, 30325, 659, 272, 283, 2180, 63, 1974, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 4857, 14, 2180, 63, 1974, 659, 272, 283, 1569, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 1569, 63, 1483, 659, 272, 283, 8811, 14, 8627, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 8811, 14, 8627, 659, 272, 283, 10096, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 10096, 63, 1483, 659, 272, 283, 4806, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 4806, 63, 1483, 659, 272, 283, 17865, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 17865, 14, 17865, 659, 272, 283, 29798, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 29798, 63, 1483, 659, 272, 283, 3442, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 3442, 63, 1483, 659, 272, 283, 6759, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 6759, 659, 272, 283, 4411, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 4411, 63, 1483, 659, 272, 283, 4411, 14, 12845, 63, 3890, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 12845, 63, 3890, 659, 272, 283, 1548, 63, 2308, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 773, 14, 2308, 14, 1548, 63, 2308, 659, 272, 283, 1927, 63, 3422, 356, 5454, 2980, 8, 267, 9214, 63, 578, 63, 354, 534, 3246, 14, 1927, 63, 3422, 659, 272, 283, 2193, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 2193, 659, 272, 283, 4421, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 4421, 63, 1483, 659, 272, 283, 31738, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 31738, 63, 1483, 659, 272, 283, 5465, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 875, 63, 1483, 659, 272, 283, 24030, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 3246, 14, 24030, 659, 272, 283, 396, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 3246, 14, 396, 659, 272, 283, 2834, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 7588, 14, 7588, 659, 199, 93, 199, 199, 63, 1719, 1469, 6467, 63, 16618, 63, 25744, 275, 469, 272, 283, 8627, 356, 5454, 2980, 8, 267, 9214, 63, 578, 63, 354, 534, 8627, 63, 773, 659, 272, 283, 8627, 14, 3790, 356, 5454, 2980, 8, 267, 9214, 63, 578, 63, 354, 534, 3790, 14, 3790, 63, 773, 659, 272, 283, 8627, 14, 3711, 356, 5454, 2980, 8, 267, 9214, 63, 578, 63, 354, 534, 3711, 14, 3711, 659, 199, 93, 421, 199, 318, 664, 63, 1301, 63, 4553, 8, 1246, 63, 354, 304, 523, 408, 1002, 282, 2341, 687, 859, 370, 282, 5454, 2980, 909, 14, 819, 3033, 26, 272, 2986, 63, 354, 26, 3261, 1265, 2934, 370, 3550, 334, 69, 14, 71, 14, 658, 16008, 64, 503, 658, 8627, 14963, 819, 1803, 26, 272, 9672, 687, 859, 536, 370, 5454, 2980, 909, 14, 523, 408, 523, 340, 2986, 63, 354, 508, 2833, 63, 3790, 14, 52, 17850, 17114, 63, 3735, 63, 2339, 26, 272, 372, 485, 52, 17850, 17114, 63, 16618, 63, 25744, 523, 340, 2986, 63, 354, 508, 2833, 63, 3790, 14, 1719, 1469, 6467, 63, 3735, 63, 2339, 26, 272, 372, 485, 1719, 1469, 6467, 63, 16618, 63 ]
[ 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 6154, 5604, 5274, 402, 1382, 3326, 367, 3261, 4621, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 5055, 199, 199, 504, 3228, 14, 1548, 14, 1974, 492, 2833, 63, 3790, 421, 199, 3, 11015, 9214, 1350, 367, 282, 859, 14, 199, 3, 5972, 1373, 402, 9214, 503, 9214, 63, 578, 63, 354, 1077, 506, 663, 14, 199, 3, 627, 982, 9214, 365, 663, 12, 2066, 781, 911, 675, 642, 9214, 1380, 199, 3, 257, 367, 314, 859, 14, 199, 3, 627, 982, 9214, 63, 578, 63, 354, 365, 663, 12, 2066, 781, 911, 1331, 314, 9214, 199, 3, 257, 687, 9214, 1350, 859, 14, 199, 3768, 2980, 275, 5055, 14, 18921, 8, 272, 283, 3768, 2980, 297, 788, 12485, 297, 283, 12485, 63, 578, 63, 354, 1105, 199, 3, 7048, 2225, 402, 5454, 2980, 365, 2716, 14, 199, 3768, 2980, 855, 1222, 4914, 4322, 363, 275, 334, 403, 4258, 627, 822, 8, 3768, 2980, 423, 955, 9, 199, 199, 63, 52, 17850, 17114, 63, 16618, 63, 25744, 275, 469, 272, 283, 571, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 3246, 14, 571, 659, 272, 283, 5819, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1974, 14, 5819, 659, 272, 283, 5613, 356, 5454, 2980, 8, 267, 9214, 63, 578, 63, 354, 534, 1483, 14, 5613, 14, 5613, 659, 272, 283, 28831, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 28831, 63, 1483, 659, 272, 283, 2550, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 4857, 14, 2550, 659, 272, 283, 30325, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 3246, 14, 30325, 659, 272, 283, 2180, 63, 1974, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 4857, 14, 2180, 63, 1974, 659, 272, 283, 1569, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 1569, 63, 1483, 659, 272, 283, 8811, 14, 8627, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 8811, 14, 8627, 659, 272, 283, 10096, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 10096, 63, 1483, 659, 272, 283, 4806, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 4806, 63, 1483, 659, 272, 283, 17865, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 17865, 14, 17865, 659, 272, 283, 29798, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 29798, 63, 1483, 659, 272, 283, 3442, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 3442, 63, 1483, 659, 272, 283, 6759, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 6759, 659, 272, 283, 4411, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 4411, 63, 1483, 659, 272, 283, 4411, 14, 12845, 63, 3890, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 12845, 63, 3890, 659, 272, 283, 1548, 63, 2308, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 773, 14, 2308, 14, 1548, 63, 2308, 659, 272, 283, 1927, 63, 3422, 356, 5454, 2980, 8, 267, 9214, 63, 578, 63, 354, 534, 3246, 14, 1927, 63, 3422, 659, 272, 283, 2193, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 2193, 659, 272, 283, 4421, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 4421, 63, 1483, 659, 272, 283, 31738, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 31738, 63, 1483, 659, 272, 283, 5465, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 1483, 14, 875, 63, 1483, 659, 272, 283, 24030, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 3246, 14, 24030, 659, 272, 283, 396, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 3246, 14, 396, 659, 272, 283, 2834, 356, 5454, 2980, 8, 12485, 63, 578, 63, 354, 534, 7588, 14, 7588, 659, 199, 93, 199, 199, 63, 1719, 1469, 6467, 63, 16618, 63, 25744, 275, 469, 272, 283, 8627, 356, 5454, 2980, 8, 267, 9214, 63, 578, 63, 354, 534, 8627, 63, 773, 659, 272, 283, 8627, 14, 3790, 356, 5454, 2980, 8, 267, 9214, 63, 578, 63, 354, 534, 3790, 14, 3790, 63, 773, 659, 272, 283, 8627, 14, 3711, 356, 5454, 2980, 8, 267, 9214, 63, 578, 63, 354, 534, 3711, 14, 3711, 659, 199, 93, 421, 199, 318, 664, 63, 1301, 63, 4553, 8, 1246, 63, 354, 304, 523, 408, 1002, 282, 2341, 687, 859, 370, 282, 5454, 2980, 909, 14, 819, 3033, 26, 272, 2986, 63, 354, 26, 3261, 1265, 2934, 370, 3550, 334, 69, 14, 71, 14, 658, 16008, 64, 503, 658, 8627, 14963, 819, 1803, 26, 272, 9672, 687, 859, 536, 370, 5454, 2980, 909, 14, 523, 408, 523, 340, 2986, 63, 354, 508, 2833, 63, 3790, 14, 52, 17850, 17114, 63, 3735, 63, 2339, 26, 272, 372, 485, 52, 17850, 17114, 63, 16618, 63, 25744, 523, 340, 2986, 63, 354, 508, 2833, 63, 3790, 14, 1719, 1469, 6467, 63, 3735, 63, 2339, 26, 272, 372, 485, 1719, 1469, 6467, 63, 16618, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
Stargrazer82301/CAAPR
CAAPR/CAAPR_AstroMagic/PTS/pts/modeling/config/launch_best.py
1
1734
#!/usr/bin/env python # -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition() definition.add_section("wavelengths") definition.sections["wavelengths"].add_optional("unit", str, "the unit of the wavelengths", "micron") definition.sections["wavelengths"].add_optional("min", float, "the minimum wavelength", 0.05) definition.sections["wavelengths"].add_optional("max", float, "the maximum wavelength", 1000) definition.sections["wavelengths"].add_optional("npoints", int, "the number of wavelength points", 300) definition.sections["wavelengths"].add_optional("min_zoom", float, "the minium wavelength of the zoomed-in grid", 1) definition.sections["wavelengths"].add_optional("max_zoom", float, "the maximum wavelength of the zoomed-in grid", 30) definition.sections["wavelengths"].add_optional("npoints_zoom", int, "the number of wavelength points in the zoomed-in grid", 300) definition.add_optional("packages", float, "the number of photon packages per wavelength", 1e6) definition.add_optional("selfabsorption", bool, "whether self-absorption should be enabled", True) definition.add_optional("remote", str, "the remote host on which to launch the simulations", "nancy") # -----------------------------------------------------------------
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 24, 1882, 199, 3, 1011, 5815, 30948, 1116, 9153, 199, 3, 1011, 755, 510, 9730, 1553, 2018, 15650, 6065, 367, 6449, 543, 20062, 3927, 52, 3515, 1011, 199, 3, 1011, 755, 22405, 103, 437, 495, 15222, 2652, 17985, 7297, 8658, 12, 598, 72, 484, 15904, 3515, 1011, 199, 3, 1011, 5815, 30948, 1116, 9153, 199, 199, 3, 3161, 314, 12082, 510, 9730, 3992, 436, 4621, 199, 504, 21286, 14, 1018, 14, 4316, 83, 14, 4758, 492, 11595, 10701, 199, 199, 3, 5620, 13, 199, 199, 3, 2790, 314, 2897, 199, 7463, 275, 11595, 10701, 342, 199, 199, 7463, 14, 525, 63, 2792, 480, 10024, 14563, 531, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 3248, 401, 620, 12, 298, 1589, 4137, 402, 314, 12204, 14563, 401, 298, 15003, 2641, 531, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 827, 401, 2069, 12, 298, 1589, 7481, 12204, 1267, 401, 378, 14, 1717, 9, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 988, 401, 2069, 12, 298, 1589, 5696, 12204, 1267, 401, 5198, 9, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 78, 3438, 401, 1109, 12, 298, 1589, 1329, 402, 12204, 1267, 4501, 401, 9601, 9, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 827, 63, 10598, 401, 2069, 12, 298, 1589, 1748, 5170, 12204, 1267, 402, 314, 1315, 79, 1377, 68, 13, 262, 6068, 401, 413, 9, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 988, 63, 10598, 401, 2069, 12, 298, 1589, 5696, 12204, 1267, 402, 314, 1315, 79, 1377, 68, 13, 262, 6068, 401, 4233, 9, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 78, 3438, 63, 10598, 401, 1109, 12, 298, 1589, 1329, 402, 12204, 1267, 4501, 315, 314, 1315, 79, 1377, 68, 13, 262, 6068, 401, 9601, 9, 199, 199, 7463, 14, 525, 63, 4144, 480, 5154, 401, 2069, 12, 298, 1589, 1329, 402, 3945, 357, 265, 6117, 1126, 12204, 1267, 401, 413, 69, 22, 9, 199, 7463, 14, 525, 63, 4144, 480, 277, 371, 1509, 494, 401, 2155, 12, 298, 87, 3081, 291, 13, 371, 1509, 494, 1077, 506, 5223, 401, 715, 9, 199, 7463, 14, 525, 63, 4144, 480, 3846, 401, 620, 12, 298, 1589, 3982, 1591, 641, 1314, 370, 10623, 314, 4389, 21429, 401, 298, 4304, 1480, 531, 199, 199, 3, 5620, 13, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 24, 1882, 199, 3, 1011, 5815, 30948, 1116, 9153, 199, 3, 1011, 755, 510, 9730, 1553, 2018, 15650, 6065, 367, 6449, 543, 20062, 3927, 52, 3515, 1011, 199, 3, 1011, 755, 22405, 103, 437, 495, 15222, 2652, 17985, 7297, 8658, 12, 598, 72, 484, 15904, 3515, 1011, 199, 3, 1011, 5815, 30948, 1116, 9153, 199, 199, 3, 3161, 314, 12082, 510, 9730, 3992, 436, 4621, 199, 504, 21286, 14, 1018, 14, 4316, 83, 14, 4758, 492, 11595, 10701, 199, 199, 3, 5620, 13, 199, 199, 3, 2790, 314, 2897, 199, 7463, 275, 11595, 10701, 342, 199, 199, 7463, 14, 525, 63, 2792, 480, 10024, 14563, 531, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 3248, 401, 620, 12, 298, 1589, 4137, 402, 314, 12204, 14563, 401, 298, 15003, 2641, 531, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 827, 401, 2069, 12, 298, 1589, 7481, 12204, 1267, 401, 378, 14, 1717, 9, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 988, 401, 2069, 12, 298, 1589, 5696, 12204, 1267, 401, 5198, 9, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 78, 3438, 401, 1109, 12, 298, 1589, 1329, 402, 12204, 1267, 4501, 401, 9601, 9, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 827, 63, 10598, 401, 2069, 12, 298, 1589, 1748, 5170, 12204, 1267, 402, 314, 1315, 79, 1377, 68, 13, 262, 6068, 401, 413, 9, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 988, 63, 10598, 401, 2069, 12, 298, 1589, 5696, 12204, 1267, 402, 314, 1315, 79, 1377, 68, 13, 262, 6068, 401, 4233, 9, 199, 7463, 14, 7786, 905, 10024, 14563, 4140, 525, 63, 4144, 480, 78, 3438, 63, 10598, 401, 1109, 12, 298, 1589, 1329, 402, 12204, 1267, 4501, 315, 314, 1315, 79, 1377, 68, 13, 262, 6068, 401, 9601, 9, 199, 199, 7463, 14, 525, 63, 4144, 480, 5154, 401, 2069, 12, 298, 1589, 1329, 402, 3945, 357, 265, 6117, 1126, 12204, 1267, 401, 413, 69, 22, 9, 199, 7463, 14, 525, 63, 4144, 480, 277, 371, 1509, 494, 401, 2155, 12, 298, 87, 3081, 291, 13, 371, 1509, 494, 1077, 506, 5223, 401, 715, 9, 199, 7463, 14, 525, 63, 4144, 480, 3846, 401, 620, 12, 298, 1589, 3982, 1591, 641, 1314, 370, 10623, 314, 4389, 21429, 401, 298, 4304, 1480, 531, 199, 199, 3, 5620, 13, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
drufat/sympy
sympy/interactive/ipythonprinting.py
118
1785
""" A print function that pretty prints SymPy objects. :moduleauthor: Brian Granger Usage ===== To use this extension, execute: %load_ext sympy.interactive.ipythonprinting Once the extension is loaded, SymPy Basic objects are automatically pretty-printed in the terminal and rendered in LaTeX in the Qt console and notebook. """ #----------------------------------------------------------------------------- # Copyright (C) 2008 The IPython Development Team # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- from __future__ import print_function, division import warnings from sympy.interactive.printing import init_printing from sympy.utilities.exceptions import SymPyDeprecationWarning #----------------------------------------------------------------------------- # Definitions of special display functions for use with IPython #----------------------------------------------------------------------------- def load_ipython_extension(ip): """Load the extension in IPython.""" # Since Python filters deprecation warnings by default, # we add a filter to make sure this message will be shown. warnings.simplefilter("once", SymPyDeprecationWarning) SymPyDeprecationWarning( feature="using %load_ext sympy.interactive.ipythonprinting", useinstead="from sympy import init_printing ; init_printing()", deprecated_since_version="0.7.3", issue=7013 ).warn() init_printing(ip=ip)
bsd-3-clause
[ 624, 199, 33, 870, 805, 626, 7268, 14767, 21478, 2713, 2251, 14, 199, 199, 26, 578, 2502, 26, 699, 18429, 598, 82, 12974, 199, 199, 7692, 199, 19989, 199, 199, 1378, 675, 642, 3329, 12, 5341, 26, 339, 450, 912, 63, 832, 5840, 14, 13543, 14, 22691, 26514, 199, 199, 25690, 314, 3329, 365, 6511, 12, 21478, 2713, 10082, 2251, 787, 5847, 199, 9118, 13, 27131, 315, 314, 11167, 436, 8018, 315, 14081, 315, 314, 3959, 8559, 436, 199, 19174, 14, 199, 199, 624, 199, 18045, 199, 3, 221, 1898, 334, 35, 9, 9079, 221, 710, 16243, 15290, 11682, 199, 3, 199, 3, 221, 17484, 1334, 314, 2895, 402, 314, 6289, 844, 14, 221, 710, 2615, 4190, 365, 315, 199, 3, 221, 314, 570, 9685, 12, 1854, 465, 1777, 402, 642, 2032, 14, 199, 18045, 199, 199, 18045, 199, 3, 24339, 199, 18045, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 646, 3598, 199, 199, 504, 5840, 14, 13543, 14, 26514, 492, 4205, 63, 26514, 199, 504, 5840, 14, 16355, 14, 3924, 492, 21478, 2713, 15561, 199, 199, 18045, 199, 3, 22659, 852, 402, 4539, 2929, 3423, 367, 675, 543, 16243, 199, 18045, 199, 199, 318, 2248, 63, 22691, 63, 3435, 8, 711, 304, 272, 408, 6200, 314, 3329, 315, 16243, 1041, 272, 327, 9336, 2018, 4766, 17831, 3598, 701, 849, 12, 272, 327, 781, 1050, 282, 2457, 370, 1852, 3238, 642, 1245, 911, 506, 9164, 14, 272, 3598, 14, 18815, 480, 5089, 401, 21478, 2713, 15561, 9, 272, 21478, 2713, 15561, 8, 267, 3878, 628, 4941, 450, 912, 63, 832, 5840, 14, 13543, 14, 22691, 26514, 401, 267, 675, 23145, 628, 504, 5840, 492, 4205, 63, 26514, 8700, 4205, 63, 26514, 24017, 267, 5906, 63, 8585, 63, 1023, 628, 16, 14, 23, 14, 19, 401, 267, 4976, 29, 23, 13264, 272, 7092, 4050, 342, 272, 4205, 63, 26514, 8, 711, 29, 711, 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 ]
[ 199, 33, 870, 805, 626, 7268, 14767, 21478, 2713, 2251, 14, 199, 199, 26, 578, 2502, 26, 699, 18429, 598, 82, 12974, 199, 199, 7692, 199, 19989, 199, 199, 1378, 675, 642, 3329, 12, 5341, 26, 339, 450, 912, 63, 832, 5840, 14, 13543, 14, 22691, 26514, 199, 199, 25690, 314, 3329, 365, 6511, 12, 21478, 2713, 10082, 2251, 787, 5847, 199, 9118, 13, 27131, 315, 314, 11167, 436, 8018, 315, 14081, 315, 314, 3959, 8559, 436, 199, 19174, 14, 199, 199, 624, 199, 18045, 199, 3, 221, 1898, 334, 35, 9, 9079, 221, 710, 16243, 15290, 11682, 199, 3, 199, 3, 221, 17484, 1334, 314, 2895, 402, 314, 6289, 844, 14, 221, 710, 2615, 4190, 365, 315, 199, 3, 221, 314, 570, 9685, 12, 1854, 465, 1777, 402, 642, 2032, 14, 199, 18045, 199, 199, 18045, 199, 3, 24339, 199, 18045, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 646, 3598, 199, 199, 504, 5840, 14, 13543, 14, 26514, 492, 4205, 63, 26514, 199, 504, 5840, 14, 16355, 14, 3924, 492, 21478, 2713, 15561, 199, 199, 18045, 199, 3, 22659, 852, 402, 4539, 2929, 3423, 367, 675, 543, 16243, 199, 18045, 199, 199, 318, 2248, 63, 22691, 63, 3435, 8, 711, 304, 272, 408, 6200, 314, 3329, 315, 16243, 1041, 272, 327, 9336, 2018, 4766, 17831, 3598, 701, 849, 12, 272, 327, 781, 1050, 282, 2457, 370, 1852, 3238, 642, 1245, 911, 506, 9164, 14, 272, 3598, 14, 18815, 480, 5089, 401, 21478, 2713, 15561, 9, 272, 21478, 2713, 15561, 8, 267, 3878, 628, 4941, 450, 912, 63, 832, 5840, 14, 13543, 14, 22691, 26514, 401, 267, 675, 23145, 628, 504, 5840, 492, 4205, 63, 26514, 8700, 4205, 63, 26514, 24017, 267, 5906, 63, 8585, 63, 1023, 628, 16, 14, 23, 14, 19, 401, 267, 4976, 29, 23, 13264, 272, 7092, 4050, 342, 272, 4205, 63, 26514, 8, 711, 29, 711, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 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, 0 ]
brettlangdon/dd-agent
checks.d/teamcity.py
3
6264
# stdlib import time # 3p import requests # project from checks import AgentCheck from config import _is_affirmative class TeamCityCheck(AgentCheck): HEADERS = {'Accept': 'application/json'} DEFAULT_TIMEOUT = 10 NEW_BUILD_URL = "http://{server}/guestAuth/app/rest/builds/?locator=buildType:{build_conf},sinceBuild:id:{since_build},status:SUCCESS" LAST_BUILD_URL = "http://{server}/guestAuth/app/rest/builds/?locator=buildType:{build_conf},count:1" NEW_BUILD_URL_AUTHENTICATED = "http://{server}/httpAuth/app/rest/builds/?locator=buildType:{build_conf},sinceBuild:id:{since_build},status:SUCCESS" LAST_BUILD_URL_AUTHENTICATED = "http://{server}/httpAuth/app/rest/builds/?locator=buildType:{build_conf},count:1" def __init__(self, name, init_config, agentConfig, instances=None): AgentCheck.__init__(self, name, init_config, agentConfig, instances) # Keep track of last build IDs per instance self.last_build_ids = {} def _initialize_if_required(self, instance_name, server, build_conf, ssl_validation, basic_http_authentication): # Already initialized if instance_name in self.last_build_ids: return self.log.debug("Initializing {0}".format(instance_name)) if basic_http_authentication: build_url = self.LAST_BUILD_URL_AUTHENTICATED.format( server=server, build_conf=build_conf ) else: build_url = self.LAST_BUILD_URL.format( server=server, build_conf=build_conf ) try: resp = requests.get(build_url, timeout=self.DEFAULT_TIMEOUT, headers=self.HEADERS, verify=ssl_validation) resp.raise_for_status() last_build_id = resp.json().get('build')[0].get('id') except requests.exceptions.HTTPError: if resp.status_code == 401: self.log.error("Access denied. You must enable guest authentication") self.log.error( "Failed to retrieve last build ID with code {0} for instance '{1}'" .format(resp.status_code, instance_name) ) raise except Exception: self.log.exception( "Unhandled exception to get last build ID for instance '{0}'" .format(instance_name) ) raise self.log.debug( "Last build id for instance {0} is {1}." .format(instance_name, last_build_id) ) self.last_build_ids[instance_name] = last_build_id def _build_and_send_event(self, new_build, instance_name, is_deployment, host, tags): self.log.debug("Found new build with id {0}, saving and alerting.".format(new_build["id"])) self.last_build_ids[instance_name] = new_build["id"] event_dict = { 'timestamp': int(time.time()), 'source_type_name': 'teamcity', 'host': host, 'tags': [], } if is_deployment: event_dict['event_type'] = 'teamcity_deployment' event_dict['msg_title'] = "{0} deployed to {1}".format(instance_name, host) event_dict['msg_text'] = "Build Number: {0}\n\nMore Info: {1}".format(new_build["number"], new_build["webUrl"]) event_dict['tags'].append('deployment') else: event_dict['event_type'] = "build" event_dict['msg_title'] = "Build for {0} successful".format(instance_name) event_dict['msg_text'] = "Build Number: {0}\nDeployed To: {1}\n\nMore Info: {2}".format(new_build["number"], host, new_build["webUrl"]) event_dict['tags'].append('build') if tags: event_dict["tags"].extend(tags) self.event(event_dict) def check(self, instance): instance_name = instance.get('name') if instance_name is None: raise Exception("Each instance must have a unique name") ssl_validation = _is_affirmative(instance.get('ssl_validation', True)) server = instance.get('server') if 'server' is None: raise Exception("Each instance must have a server") build_conf = instance.get('build_configuration') if build_conf is None: raise Exception("Each instance must have a build configuration") host = instance.get('host_affected') or self.hostname tags = instance.get('tags') is_deployment = _is_affirmative(instance.get('is_deployment', False)) basic_http_authentication = _is_affirmative(instance.get('basic_http_authentication', False)) self._initialize_if_required(instance_name, server, build_conf, ssl_validation, basic_http_authentication) # Look for new successful builds if basic_http_authentication: new_build_url = self.NEW_BUILD_URL_AUTHENTICATED.format( server=server, build_conf=build_conf, since_build=self.last_build_ids[instance_name] ) else: new_build_url = self.NEW_BUILD_URL.format( server=server, build_conf=build_conf, since_build=self.last_build_ids[instance_name] ) try: resp = requests.get(new_build_url, timeout=self.DEFAULT_TIMEOUT, headers=self.HEADERS, verify=ssl_validation) resp.raise_for_status() new_builds = resp.json() if new_builds["count"] == 0: self.log.debug("No new builds found.") else: self._build_and_send_event(new_builds["build"][0], instance_name, is_deployment, host, tags) except requests.exceptions.HTTPError: self.log.exception( "Couldn't fetch last build, got code {0}" .format(resp.status_code) ) raise except Exception: self.log.exception( "Couldn't fetch last build, unhandled exception" ) raise
bsd-3-clause
[ 3, 26678, 199, 646, 900, 199, 199, 3, 650, 80, 199, 646, 4145, 199, 199, 3, 2199, 199, 504, 5920, 492, 19866, 1799, 199, 504, 1101, 492, 485, 374, 63, 2756, 1795, 391, 857, 421, 199, 533, 11682, 17024, 1799, 8, 7788, 1799, 304, 272, 13053, 3960, 275, 791, 8422, 356, 283, 3578, 15, 1001, 936, 272, 6186, 63, 8899, 275, 1616, 272, 18689, 63, 8248, 63, 2632, 275, 298, 1014, 20193, 1000, 5995, 10409, 2817, 15, 571, 15, 3911, 15, 10838, 10197, 6354, 29, 1506, 804, 14534, 1506, 63, 2190, 1386, 8585, 3425, 26, 344, 14534, 8585, 63, 1506, 1386, 1205, 26, 12779, 2, 272, 491, 11307, 63, 8248, 63, 2632, 275, 298, 1014, 20193, 1000, 5995, 10409, 2817, 15, 571, 15, 3911, 15, 10838, 10197, 6354, 29, 1506, 804, 14534, 1506, 63, 2190, 1386, 835, 26, 17, 2, 272, 18689, 63, 8248, 63, 2632, 63, 22923, 6989, 275, 298, 1014, 20193, 1000, 5995, 1014, 2817, 15, 571, 15, 3911, 15, 10838, 10197, 6354, 29, 1506, 804, 14534, 1506, 63, 2190, 1386, 8585, 3425, 26, 344, 14534, 8585, 63, 1506, 1386, 1205, 26, 12779, 2, 272, 491, 11307, 63, 8248, 63, 2632, 63, 22923, 6989, 275, 298, 1014, 20193, 1000, 5995, 1014, 2817, 15, 571, 15, 3911, 15, 10838, 10197, 6354, 29, 1506, 804, 14534, 1506, 63, 2190, 1386, 835, 26, 17, 2, 339, 347, 636, 826, 721, 277, 12, 536, 12, 4205, 63, 888, 12, 6631, 2028, 12, 4454, 29, 403, 304, 267, 19866, 1799, 855, 826, 721, 277, 12, 536, 12, 4205, 63, 888, 12, 6631, 2028, 12, 4454, 9, 398, 327, 14797, 4426, 402, 2061, 1900, 11449, 1126, 1256, 267, 291, 14, 2019, 63, 1506, 63, 1580, 275, 1052, 339, 347, 485, 8489, 63, 692, 63, 2427, 8, 277, 12, 1256, 63, 354, 12, 1654, 12, 1900, 63, 2190, 12, 6149, 63, 6136, 12, 5678, 63, 1014, 63, 11725, 304, 267, 327, 21086, 10038, 267, 340, 1256, 63, 354, 315, 291, 14, 2019, 63, 1506, 63, 1580, 26, 288, 372, 398, 291, 14, 793, 14, 1757, 480, 5733, 9147, 469, 16, 5469, 908, 8, 842, 63, 354, 430, 398, 340, 5678, 63, 1014, 63, 11725, 26, 288, 1900, 63, 633, 275, 291, 14, 16901, 63, 8248, 63, 2632, 63, 22923, 6989, 14, 908, 8, 355, 1654, 29, 1000, 12, 355, 1900, 63, 2190, 29, 1506, 63, 2190, 288, 776, 267, 587, 26, 288, 1900, 63, 633, 275, 291, 14, 16901, 63, 8248, 63, 2632, 14, 908, 8, 355, 1654, 29, 1000, 12, 355, 1900, 63, 2190, 29, 1506, 63, 2190, 288, 776, 267, 862, 26, 288, 3085, 275, 4145, 14, 362, 8, 1506, 63, 633, 12, 2653, 29, 277, 14, 3472, 63, 8899, 12, 2323, 29, 277, 14, 21178, 12, 4911, 29, 4266, 63, 6136, 9, 288, 3085, 14, 3730, 63, 509, 63, 1205, 342, 953, 2061, 63, 1506, 63, 344, 275, 3085, 14, 1001, 1252, 362, 360, 1506, 5832, 16, 1055, 362, 360, 344, 358, 267, 871, 4145, 14, 3924, 14, 12815, 26, 288, 340, 3085, 14, 1205, 63, 600, 508, 13952, 26, 355, 291, 14, 793, 14, 705, 480, 3946, 23355, 14, 2047, 1471, 4756, 13980, 6299, 531, 288, 291, 14, 793, 14, 705, 8, 355, 298, 4276, 370, 8044, 2061, 1900, 2870, 543, 1233, 469, 16, 93, 367, 1256, 5041, 17, 93, 4065, 355, 1275, 908, 8, 4518, 14, 1205, 63, 600, 12, 1256, 63, 354, 9, 288, 776, 288, 746, 267, 871, 2186, 26, 288, 291, 14, 793, 14, 1971, 8, 355, 298, 1358, 11217, 1919, 370, 664, 2061, 1900, 2870, 367, 1256, 5041, 16, 93, 4065, 355, 1275, 908, 8, 842, 63, 354, 9, 288, 776, 288, 746, 398, 291, 14, 793, 14, 1757, 8, 288, 298, 6090, 1900, 1305, 367, 1256, 469, 16, 93, 365, 469, 17, 93, 2122, 288, 1275, 908, 8, 842, 63, 354, 12, 2061, 63, 1506, 63, 344, 9, 267, 776, 267, 291, 14, 2019, 63, 1506, 63, 1580, 59, 842, 63, 354, 61, 275, 2061, 63, 1506, 63, 344, 339, 347, 485, 1506, 63, 460, 63, 2254, 63, 1430, 8, 277, 12, 892, 63, 1506, 12, 1256, 63, 354, 12, 365, 63, 13605, 12, 1591, 12, 3762, 304, 267, 291, 14, 793, 14, 1757, 480, 3601, 892, 1900, 543, 1305, 469, 16, 1386, 13369, 436, 282, 1435, 1337, 15848, 908, 8, 1222, 63, 1506, 905, 344, 13045, 267, 291, 14, 2019, 63, 1506, 63, 1580, 59, 842, 63, 354, 61, 275, 892, 63, 1506, 905, 344, 937, 398, 1566, 63, 807, 275, 469, 288, 283, 3954, 356, 1109, 8, 521, 14, 521, 4000, 288, 283, 1365, 63, 466, 63, 354, 356, 283, 5969, 3690, 297, 288, 283, 1102, 356, 1591, 12, 288, 283, 2969, 356, 990, 267, 789, 267, 340, 365, 63, 13605, 26, 288, 1566, 63, 807, 459, 1430, 63, 466, 418, 275, 283, 5969, 3690, 63, 13605, 7, 288, 1566, 63, 807, 459, 1328, 63, 1213, 418, 275, 5310, 16, 93, 26181, 370, 469, 17, 5469, 908, 8, 842, 63, 354, 12, 1591, 9, 288, 1566, 63, 807, 459, 1328, 63, 505, 418, 275, 298, 3425, 4860, 26, 469, 16, 4988, 78, 60, 78, 11053, 10332, 26, 469, 17, 5469, 908, 8, 1222, 63, 1506, 905, 1955, 2255, 12268, 221, 892, 63, 1506, 905, 2520, 6417, 3135, 288, 1566, 63, 807, 459, 2969, 2278, 740, 360, 13605, 358, 267, 587, 26, 288, 1566, 63, 807, 459, 1430, 63, 466, 418, 275, 298, 1506, 2, 288, 1566, 63, 807, 459, 1328, 63, 1213, 418, 275, 298, 3425, 367, 469, 16, 93, 9512, 1674, 908, 8, 842, 63, 354, 9, 953, 1566, 63, 807, 459, 1328, 63, 505, 418, 275, 298, 3425, 4860, 26, 469, 16, 4988, 78, 27597, 379, 4005, 26, 469, 17, 4988, 78, 60, 78, 11053, 10332, 26, 469, 18, 5469, 908, 8, 1222, 63, 1506, 905, 1955, 2255, 12268, 8540, 1591, 12, 892, 63, 1506, 905, 2520, 6417, 3135, 288, 1566, 63, 807, 459, 2969, 2278, 740, 360, 1506, 358, 398, 340, 3762, 26, 288, 1566, 63, 807, 905, 2969, 4140, 2880, 8, 2969, 9, 398, 291, 14, 1430, 8, 1430, 63, 807, 9, 339, 347, 1104, 8, 277, 12, 1256, 304, 267, 1256, 63 ]
[ 26678, 199, 646, 900, 199, 199, 3, 650, 80, 199, 646, 4145, 199, 199, 3, 2199, 199, 504, 5920, 492, 19866, 1799, 199, 504, 1101, 492, 485, 374, 63, 2756, 1795, 391, 857, 421, 199, 533, 11682, 17024, 1799, 8, 7788, 1799, 304, 272, 13053, 3960, 275, 791, 8422, 356, 283, 3578, 15, 1001, 936, 272, 6186, 63, 8899, 275, 1616, 272, 18689, 63, 8248, 63, 2632, 275, 298, 1014, 20193, 1000, 5995, 10409, 2817, 15, 571, 15, 3911, 15, 10838, 10197, 6354, 29, 1506, 804, 14534, 1506, 63, 2190, 1386, 8585, 3425, 26, 344, 14534, 8585, 63, 1506, 1386, 1205, 26, 12779, 2, 272, 491, 11307, 63, 8248, 63, 2632, 275, 298, 1014, 20193, 1000, 5995, 10409, 2817, 15, 571, 15, 3911, 15, 10838, 10197, 6354, 29, 1506, 804, 14534, 1506, 63, 2190, 1386, 835, 26, 17, 2, 272, 18689, 63, 8248, 63, 2632, 63, 22923, 6989, 275, 298, 1014, 20193, 1000, 5995, 1014, 2817, 15, 571, 15, 3911, 15, 10838, 10197, 6354, 29, 1506, 804, 14534, 1506, 63, 2190, 1386, 8585, 3425, 26, 344, 14534, 8585, 63, 1506, 1386, 1205, 26, 12779, 2, 272, 491, 11307, 63, 8248, 63, 2632, 63, 22923, 6989, 275, 298, 1014, 20193, 1000, 5995, 1014, 2817, 15, 571, 15, 3911, 15, 10838, 10197, 6354, 29, 1506, 804, 14534, 1506, 63, 2190, 1386, 835, 26, 17, 2, 339, 347, 636, 826, 721, 277, 12, 536, 12, 4205, 63, 888, 12, 6631, 2028, 12, 4454, 29, 403, 304, 267, 19866, 1799, 855, 826, 721, 277, 12, 536, 12, 4205, 63, 888, 12, 6631, 2028, 12, 4454, 9, 398, 327, 14797, 4426, 402, 2061, 1900, 11449, 1126, 1256, 267, 291, 14, 2019, 63, 1506, 63, 1580, 275, 1052, 339, 347, 485, 8489, 63, 692, 63, 2427, 8, 277, 12, 1256, 63, 354, 12, 1654, 12, 1900, 63, 2190, 12, 6149, 63, 6136, 12, 5678, 63, 1014, 63, 11725, 304, 267, 327, 21086, 10038, 267, 340, 1256, 63, 354, 315, 291, 14, 2019, 63, 1506, 63, 1580, 26, 288, 372, 398, 291, 14, 793, 14, 1757, 480, 5733, 9147, 469, 16, 5469, 908, 8, 842, 63, 354, 430, 398, 340, 5678, 63, 1014, 63, 11725, 26, 288, 1900, 63, 633, 275, 291, 14, 16901, 63, 8248, 63, 2632, 63, 22923, 6989, 14, 908, 8, 355, 1654, 29, 1000, 12, 355, 1900, 63, 2190, 29, 1506, 63, 2190, 288, 776, 267, 587, 26, 288, 1900, 63, 633, 275, 291, 14, 16901, 63, 8248, 63, 2632, 14, 908, 8, 355, 1654, 29, 1000, 12, 355, 1900, 63, 2190, 29, 1506, 63, 2190, 288, 776, 267, 862, 26, 288, 3085, 275, 4145, 14, 362, 8, 1506, 63, 633, 12, 2653, 29, 277, 14, 3472, 63, 8899, 12, 2323, 29, 277, 14, 21178, 12, 4911, 29, 4266, 63, 6136, 9, 288, 3085, 14, 3730, 63, 509, 63, 1205, 342, 953, 2061, 63, 1506, 63, 344, 275, 3085, 14, 1001, 1252, 362, 360, 1506, 5832, 16, 1055, 362, 360, 344, 358, 267, 871, 4145, 14, 3924, 14, 12815, 26, 288, 340, 3085, 14, 1205, 63, 600, 508, 13952, 26, 355, 291, 14, 793, 14, 705, 480, 3946, 23355, 14, 2047, 1471, 4756, 13980, 6299, 531, 288, 291, 14, 793, 14, 705, 8, 355, 298, 4276, 370, 8044, 2061, 1900, 2870, 543, 1233, 469, 16, 93, 367, 1256, 5041, 17, 93, 4065, 355, 1275, 908, 8, 4518, 14, 1205, 63, 600, 12, 1256, 63, 354, 9, 288, 776, 288, 746, 267, 871, 2186, 26, 288, 291, 14, 793, 14, 1971, 8, 355, 298, 1358, 11217, 1919, 370, 664, 2061, 1900, 2870, 367, 1256, 5041, 16, 93, 4065, 355, 1275, 908, 8, 842, 63, 354, 9, 288, 776, 288, 746, 398, 291, 14, 793, 14, 1757, 8, 288, 298, 6090, 1900, 1305, 367, 1256, 469, 16, 93, 365, 469, 17, 93, 2122, 288, 1275, 908, 8, 842, 63, 354, 12, 2061, 63, 1506, 63, 344, 9, 267, 776, 267, 291, 14, 2019, 63, 1506, 63, 1580, 59, 842, 63, 354, 61, 275, 2061, 63, 1506, 63, 344, 339, 347, 485, 1506, 63, 460, 63, 2254, 63, 1430, 8, 277, 12, 892, 63, 1506, 12, 1256, 63, 354, 12, 365, 63, 13605, 12, 1591, 12, 3762, 304, 267, 291, 14, 793, 14, 1757, 480, 3601, 892, 1900, 543, 1305, 469, 16, 1386, 13369, 436, 282, 1435, 1337, 15848, 908, 8, 1222, 63, 1506, 905, 344, 13045, 267, 291, 14, 2019, 63, 1506, 63, 1580, 59, 842, 63, 354, 61, 275, 892, 63, 1506, 905, 344, 937, 398, 1566, 63, 807, 275, 469, 288, 283, 3954, 356, 1109, 8, 521, 14, 521, 4000, 288, 283, 1365, 63, 466, 63, 354, 356, 283, 5969, 3690, 297, 288, 283, 1102, 356, 1591, 12, 288, 283, 2969, 356, 990, 267, 789, 267, 340, 365, 63, 13605, 26, 288, 1566, 63, 807, 459, 1430, 63, 466, 418, 275, 283, 5969, 3690, 63, 13605, 7, 288, 1566, 63, 807, 459, 1328, 63, 1213, 418, 275, 5310, 16, 93, 26181, 370, 469, 17, 5469, 908, 8, 842, 63, 354, 12, 1591, 9, 288, 1566, 63, 807, 459, 1328, 63, 505, 418, 275, 298, 3425, 4860, 26, 469, 16, 4988, 78, 60, 78, 11053, 10332, 26, 469, 17, 5469, 908, 8, 1222, 63, 1506, 905, 1955, 2255, 12268, 221, 892, 63, 1506, 905, 2520, 6417, 3135, 288, 1566, 63, 807, 459, 2969, 2278, 740, 360, 13605, 358, 267, 587, 26, 288, 1566, 63, 807, 459, 1430, 63, 466, 418, 275, 298, 1506, 2, 288, 1566, 63, 807, 459, 1328, 63, 1213, 418, 275, 298, 3425, 367, 469, 16, 93, 9512, 1674, 908, 8, 842, 63, 354, 9, 953, 1566, 63, 807, 459, 1328, 63, 505, 418, 275, 298, 3425, 4860, 26, 469, 16, 4988, 78, 27597, 379, 4005, 26, 469, 17, 4988, 78, 60, 78, 11053, 10332, 26, 469, 18, 5469, 908, 8, 1222, 63, 1506, 905, 1955, 2255, 12268, 8540, 1591, 12, 892, 63, 1506, 905, 2520, 6417, 3135, 288, 1566, 63, 807, 459, 2969, 2278, 740, 360, 1506, 358, 398, 340, 3762, 26, 288, 1566, 63, 807, 905, 2969, 4140, 2880, 8, 2969, 9, 398, 291, 14, 1430, 8, 1430, 63, 807, 9, 339, 347, 1104, 8, 277, 12, 1256, 304, 267, 1256, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
Alwnikrotikz/cortex-vfx
test/IECore/CurvesMergeOpTest.py
12
2851
########################################################################## # # Copyright (c) 2009-2013, Image Engine Design 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 Image Engine Design nor the names of any # other contributors to this software may be used to endorse or # promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ########################################################################## import unittest import IECore class CurvesMergeOpTest( unittest.TestCase ) : def test( self ) : v = IECore.V3f p1 = IECore.V3fVectorData( [ v( 0 ), v( 1 ), v( 2 ), v( 3 ) ], IECore.GeometricData.Interpretation.Point ) p2 = IECore.V3fVectorData( [ v( 4 ), v( 5 ), v( 6 ), v( 7 ), v( 8 ), v( 9 ), v( 10 ), v( 11 ) ] ) c1 = IECore.CurvesPrimitive( IECore.IntVectorData( [ 4 ] ), IECore.CubicBasisf.catmullRom(), False, p1 ) c2 = IECore.CurvesPrimitive( IECore.IntVectorData( [ 4, 4 ] ), IECore.CubicBasisf.catmullRom(), False, p2 ) merged = IECore.CurvesMergeOp()( input=c1, curves=c2 ) for v in IECore.PrimitiveVariable.Interpolation.values : i = IECore.PrimitiveVariable.Interpolation( v ) if i!=IECore.PrimitiveVariable.Interpolation.Invalid and i!=IECore.PrimitiveVariable.Interpolation.Constant : self.assertEqual( merged.variableSize( i ), c1.variableSize( i ) + c2.variableSize( i ) ) pMerged = p1 pMerged.extend( p2 ) self.assertEqual( merged["P"].data, pMerged ) if __name__ == "__main__": unittest.main()
bsd-3-clause
[ 26863, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 8937, 13, 6965, 12, 6047, 12580, 29410, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 258, 627, 11443, 314, 536, 402, 6047, 12580, 29410, 6590, 314, 1561, 402, 1263, 199, 3, 755, 1163, 8417, 370, 642, 2032, 1443, 506, 1202, 370, 10692, 503, 199, 3, 755, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 199, 3, 755, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 221, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 221, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 221, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 221, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 221, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 221, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 221, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 26863, 199, 199, 646, 2882, 199, 646, 14707, 199, 199, 533, 7319, 2310, 11359, 4619, 774, 8, 2882, 14, 1746, 776, 520, 421, 198, 318, 511, 8, 291, 776, 520, 2742, 198, 86, 275, 14707, 14, 54, 19, 70, 507, 198, 80, 17, 275, 14707, 14, 54, 19, 70, 26679, 8, 359, 373, 8, 378, 2318, 373, 8, 413, 2318, 373, 8, 499, 2318, 373, 8, 650, 776, 2156, 14707, 14, 4240, 15890, 1451, 14, 2620, 25133, 425, 14, 3428, 776, 507, 198, 80, 18, 275, 14707, 14, 54, 19, 70, 26679, 8, 359, 373, 8, 841, 2318, 373, 8, 959, 2318, 373, 8, 1227, 2318, 373, 8, 1520, 2318, 373, 8, 1695, 2318, 373, 8, 1749, 2318, 373, 8, 1616, 2318, 373, 8, 4119, 776, 1622, 776, 28550, 198, 67, 17, 275, 14707, 14, 3864, 2310, 22231, 8, 14707, 14, 3241, 26679, 8, 359, 841, 1622, 2318, 14707, 14, 35, 456, 530, 34, 4864, 70, 14, 3385, 77, 979, 50, 676, 1062, 756, 12, 299, 17, 776, 507, 198, 67, 18, 275, 14707, 14, 3864, 2310, 22231, 8, 14707, 14, 3241, 26679, 8, 359, 841, 12, 841, 1622, 2318, 14707, 14, 35, 456, 530, 34, 4864, 70, 14, 3385, 77, 979, 50, 676, 1062, 756, 12, 299, 18, 776, 1871, 507, 198, 15269, 275, 14707, 14, 3864, 2310, 11359, 4619, 24851, 1324, 29, 67, 17, 12, 1094, 2310, 29, 67, 18, 776, 9068, 198, 509, 373, 315, 14707, 14, 22231, 2773, 14, 32653, 14, 1459, 520, 686, 198, 73, 275, 14707, 14, 22231, 2773, 14, 32653, 8, 373, 776, 686, 198, 692, 284, 1111, 41, 13682, 14, 22231, 2773, 14, 32653, 14, 3364, 436, 284, 1111, 41, 13682, 14, 22231, 2773, 14, 32653, 14, 9737, 520, 1585, 198, 277, 14, 629, 8, 9545, 14, 1975, 2320, 8, 284, 2318, 286, 17, 14, 1975, 2320, 8, 284, 776, 435, 286, 18, 14, 1975, 2320, 8, 284, 776, 776, 2742, 198, 80, 16797, 3046, 275, 299, 17, 507, 198, 80, 16797, 3046, 14, 2880, 8, 299, 18, 776, 507, 198, 277, 14, 629, 8, 9545, 905, 48, 4140, 576, 12, 299, 16797, 3046, 776, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 199, 3, 221, 1898, 334, 67, 9, 8937, 13, 6965, 12, 6047, 12580, 29410, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 258, 627, 11443, 314, 536, 402, 6047, 12580, 29410, 6590, 314, 1561, 402, 1263, 199, 3, 755, 1163, 8417, 370, 642, 2032, 1443, 506, 1202, 370, 10692, 503, 199, 3, 755, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 199, 3, 755, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 221, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 221, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 221, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 221, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 221, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 221, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 221, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 26863, 199, 199, 646, 2882, 199, 646, 14707, 199, 199, 533, 7319, 2310, 11359, 4619, 774, 8, 2882, 14, 1746, 776, 520, 421, 198, 318, 511, 8, 291, 776, 520, 2742, 198, 86, 275, 14707, 14, 54, 19, 70, 507, 198, 80, 17, 275, 14707, 14, 54, 19, 70, 26679, 8, 359, 373, 8, 378, 2318, 373, 8, 413, 2318, 373, 8, 499, 2318, 373, 8, 650, 776, 2156, 14707, 14, 4240, 15890, 1451, 14, 2620, 25133, 425, 14, 3428, 776, 507, 198, 80, 18, 275, 14707, 14, 54, 19, 70, 26679, 8, 359, 373, 8, 841, 2318, 373, 8, 959, 2318, 373, 8, 1227, 2318, 373, 8, 1520, 2318, 373, 8, 1695, 2318, 373, 8, 1749, 2318, 373, 8, 1616, 2318, 373, 8, 4119, 776, 1622, 776, 28550, 198, 67, 17, 275, 14707, 14, 3864, 2310, 22231, 8, 14707, 14, 3241, 26679, 8, 359, 841, 1622, 2318, 14707, 14, 35, 456, 530, 34, 4864, 70, 14, 3385, 77, 979, 50, 676, 1062, 756, 12, 299, 17, 776, 507, 198, 67, 18, 275, 14707, 14, 3864, 2310, 22231, 8, 14707, 14, 3241, 26679, 8, 359, 841, 12, 841, 1622, 2318, 14707, 14, 35, 456, 530, 34, 4864, 70, 14, 3385, 77, 979, 50, 676, 1062, 756, 12, 299, 18, 776, 1871, 507, 198, 15269, 275, 14707, 14, 3864, 2310, 11359, 4619, 24851, 1324, 29, 67, 17, 12, 1094, 2310, 29, 67, 18, 776, 9068, 198, 509, 373, 315, 14707, 14, 22231, 2773, 14, 32653, 14, 1459, 520, 686, 198, 73, 275, 14707, 14, 22231, 2773, 14, 32653, 8, 373, 776, 686, 198, 692, 284, 1111, 41, 13682, 14, 22231, 2773, 14, 32653, 14, 3364, 436, 284, 1111, 41, 13682, 14, 22231, 2773, 14, 32653, 14, 9737, 520, 1585, 198, 277, 14, 629, 8, 9545, 14, 1975, 2320, 8, 284, 2318, 286, 17, 14, 1975, 2320, 8, 284, 776, 435, 286, 18, 14, 1975, 2320, 8, 284, 776, 776, 2742, 198, 80, 16797, 3046, 275, 299, 17, 507, 198, 80, 16797, 3046, 14, 2880, 8, 299, 18, 776, 507, 198, 277, 14, 629, 8, 9545, 905, 48, 4140, 576, 12, 299, 16797, 3046, 776, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
afandria/sky_engine
build/util/lib/common/unittest_util.py
29
4933
# Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utilities for dealing with the python unittest module.""" import fnmatch import sys import unittest class _TextTestResult(unittest._TextTestResult): """A test result class that can print formatted text results to a stream. Results printed in conformance with gtest output format, like: [ RUN ] autofill.AutofillTest.testAutofillInvalid: "test desc." [ OK ] autofill.AutofillTest.testAutofillInvalid [ RUN ] autofill.AutofillTest.testFillProfile: "test desc." [ OK ] autofill.AutofillTest.testFillProfile [ RUN ] autofill.AutofillTest.testFillProfileCrazyCharacters: "Test." [ OK ] autofill.AutofillTest.testFillProfileCrazyCharacters """ def __init__(self, stream, descriptions, verbosity): unittest._TextTestResult.__init__(self, stream, descriptions, verbosity) self._fails = set() def _GetTestURI(self, test): return '%s.%s.%s' % (test.__class__.__module__, test.__class__.__name__, test._testMethodName) def getDescription(self, test): return '%s: "%s"' % (self._GetTestURI(test), test.shortDescription()) def startTest(self, test): unittest.TestResult.startTest(self, test) self.stream.writeln('[ RUN ] %s' % self.getDescription(test)) def addSuccess(self, test): unittest.TestResult.addSuccess(self, test) self.stream.writeln('[ OK ] %s' % self._GetTestURI(test)) def addError(self, test, err): unittest.TestResult.addError(self, test, err) self.stream.writeln('[ ERROR ] %s' % self._GetTestURI(test)) self._fails.add(self._GetTestURI(test)) def addFailure(self, test, err): unittest.TestResult.addFailure(self, test, err) self.stream.writeln('[ FAILED ] %s' % self._GetTestURI(test)) self._fails.add(self._GetTestURI(test)) def getRetestFilter(self): return ':'.join(self._fails) class TextTestRunner(unittest.TextTestRunner): """Test Runner for displaying test results in textual format. Results are displayed in conformance with google test output. """ def __init__(self, verbosity=1): unittest.TextTestRunner.__init__(self, stream=sys.stderr, verbosity=verbosity) def _makeResult(self): return _TextTestResult(self.stream, self.descriptions, self.verbosity) def GetTestsFromSuite(suite): """Returns all the tests from a given test suite.""" tests = [] for x in suite: if isinstance(x, unittest.TestSuite): tests += GetTestsFromSuite(x) else: tests += [x] return tests def GetTestNamesFromSuite(suite): """Returns a list of every test name in the given suite.""" return map(lambda x: GetTestName(x), GetTestsFromSuite(suite)) def GetTestName(test): """Gets the test name of the given unittest test.""" return '.'.join([test.__class__.__module__, test.__class__.__name__, test._testMethodName]) def FilterTestSuite(suite, gtest_filter): """Returns a new filtered tests suite based on the given gtest filter. See http://code.google.com/p/googletest/wiki/AdvancedGuide for gtest_filter specification. """ return unittest.TestSuite(FilterTests(GetTestsFromSuite(suite), gtest_filter)) def FilterTests(all_tests, gtest_filter): """Filter a list of tests based on the given gtest filter. Args: all_tests: List of tests (unittest.TestSuite) gtest_filter: Filter to apply. Returns: Filtered subset of the given list of tests. """ test_names = [GetTestName(test) for test in all_tests] filtered_names = FilterTestNames(test_names, gtest_filter) return [test for test in all_tests if GetTestName(test) in filtered_names] def FilterTestNames(all_tests, gtest_filter): """Filter a list of test names based on the given gtest filter. See http://code.google.com/p/googletest/wiki/AdvancedGuide for gtest_filter specification. Args: all_tests: List of test names. gtest_filter: Filter to apply. Returns: Filtered subset of the given list of test names. """ pattern_groups = gtest_filter.split('-') positive_patterns = ['*'] if pattern_groups[0]: positive_patterns = pattern_groups[0].split(':') negative_patterns = None if len(pattern_groups) > 1: negative_patterns = pattern_groups[1].split(':') tests = [] for test in all_tests: # Test name must by matched by one positive pattern. for pattern in positive_patterns: if fnmatch.fnmatch(test, pattern): break else: continue # Test name must not be matched by any negative patterns. for pattern in negative_patterns or []: if fnmatch.fnmatch(test, pattern): break else: tests += [test] return tests
bsd-3-clause
[ 3, 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 22905, 367, 23654, 543, 314, 2366, 2882, 859, 1041, 199, 199, 646, 15951, 199, 646, 984, 199, 646, 2882, 421, 199, 533, 485, 1872, 13120, 8, 2796, 423, 1872, 13120, 304, 523, 408, 33, 511, 754, 1021, 626, 883, 870, 7871, 1318, 2058, 370, 282, 2547, 14, 819, 24288, 12487, 315, 406, 11478, 543, 9088, 1072, 1475, 12, 2839, 26, 523, 359, 21277, 263, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 3358, 4498, 3364, 26, 298, 396, 4328, 2122, 523, 359, 260, 9949, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 3358, 4498, 3364, 523, 359, 21277, 263, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 12914, 5736, 26, 298, 396, 4328, 2122, 523, 359, 260, 9949, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 12914, 5736, 523, 359, 21277, 263, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 12914, 5736, 35, 30566, 9272, 26, 298, 774, 2122, 523, 359, 260, 9949, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 12914, 5736, 35, 30566, 9272, 523, 408, 523, 347, 636, 826, 721, 277, 12, 2547, 12, 18714, 12, 8661, 304, 272, 2882, 423, 1872, 13120, 855, 826, 721, 277, 12, 2547, 12, 18714, 12, 8661, 9, 272, 291, 423, 15762, 275, 663, 342, 819, 347, 485, 28967, 7639, 8, 277, 12, 511, 304, 272, 372, 1543, 83, 4111, 83, 4111, 83, 7, 450, 334, 396, 855, 533, 4914, 578, 3108, 586, 511, 855, 533, 4914, 354, 3108, 586, 511, 423, 25008, 985, 9, 819, 347, 664, 5831, 8, 277, 12, 511, 304, 272, 372, 1543, 83, 26, 2071, 83, 4507, 450, 334, 277, 423, 28967, 7639, 8, 396, 395, 511, 14, 3612, 5831, 1012, 819, 347, 1343, 774, 8, 277, 12, 511, 304, 272, 2882, 14, 13120, 14, 29344, 8, 277, 12, 511, 9, 272, 291, 14, 1745, 14, 21768, 11894, 21277, 263, 1622, 450, 83, 7, 450, 291, 14, 362, 5831, 8, 396, 430, 819, 347, 1050, 8300, 8, 277, 12, 511, 304, 272, 2882, 14, 13120, 14, 525, 8300, 8, 277, 12, 511, 9, 272, 291, 14, 1745, 14, 21768, 11894, 260, 9949, 1622, 450, 83, 7, 450, 291, 423, 28967, 7639, 8, 396, 430, 819, 347, 1050, 547, 8, 277, 12, 511, 12, 2329, 304, 272, 2882, 14, 13120, 14, 30787, 8, 277, 12, 511, 12, 2329, 9, 272, 291, 14, 1745, 14, 21768, 11894, 420, 12539, 1622, 450, 83, 7, 450, 291, 423, 28967, 7639, 8, 396, 430, 272, 291, 423, 15762, 14, 525, 8, 277, 423, 28967, 7639, 8, 396, 430, 819, 347, 1050, 6782, 8, 277, 12, 511, 12, 2329, 304, 272, 2882, 14, 13120, 14, 525, 6782, 8, 277, 12, 511, 12, 2329, 9, 272, 291, 14, 1745, 14, 21768, 11894, 258, 26892, 1622, 450, 83, 7, 450, 291, 423, 28967, 7639, 8, 396, 430, 272, 291, 423, 15762, 14, 525, 8, 277, 423, 28967, 7639, 8, 396, 430, 819, 347, 664, 497, 396, 4131, 8, 277, 304, 272, 372, 29010, 904, 8, 277, 423, 15762, 9, 421, 199, 533, 4516, 13649, 8, 2796, 14, 24285, 304, 523, 408, 774, 3378, 1372, 367, 20589, 511, 2058, 315, 25884, 1475, 14, 819, 24288, 787, 9080, 315, 406, 11478, 543, 6233, 511, 1072, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 8661, 29, 17, 304, 272, 2882, 14, 24285, 855, 826, 721, 277, 12, 2547, 29, 1274, 14, 3083, 12, 3660, 8661, 29, 9833, 9, 819, 347, 485, 1875, 2889, 8, 277, 304, 272, 372, 485, 1872, 13120, 8, 277, 14, 1745, 12, 291, 14, 21713, 12, 291, 14, 9833, 9, 421, 199, 318, 2372, 11519, 6207, 8, 5768, 304, 523, 408, 3407, 1006, 314, 2295, 687, 282, 1627, 511, 5241, 1041, 523, 2295, 275, 942, 523, 367, 671, 315, 5241, 26, 272, 340, 1228, 8, 88, 12, 2882, 14, 10591, 304, 489, 2295, 847, 2372, 11519, 6207, 8, 88, 9, 272, 587, 26, 489, 2295, 847, 359, 88, 61, 523, 372, 2295, 421, 199, 318, 2372, 774, 5866, 2532, 6207, 8, 5768, 304, 523, 408, 3407, 282, 769, 402, 4036, 511, 536, 315, 314, 1627, 5241, 1041, 523, 372, 2341, 8, 2734, 671, 26, 2372, 774, 985, 8, 88, 395, 2372, 11519, 6207, 8, 5768, 430, 421, 199, 318, 2372, 774, 985, 8, 396, 304, 523, 408, 14426, 314, 511, 536, 402, 314, 1627, 2882, 511, 1041, 523, 372, 15671, 904, 779, 396, 855, 533, 4914, 578, 3108, 673, 511, 855, 533, 4914, 354, 3108, 673, 511, 423, 25008, 985, 566, 421, 199, 318, 9388, 10591, 8, 5768, 12, 9088, 63, 1541, 304, 523, 408, 3407, 282, 892, 9806, 2295, 5241, 4079, 641, 314, 1627, 9088, 2457, 14, 819, 1666, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 3098, 396, 15, 6797, 15, 23613, 4324, 271, 523, 367, 9088, 63, 1541, 8929, 14, 523, 408, 523, 372, 2882, 14, 10591, 8, 4131, 2925, 8, 1002, 11519, 6207, 8, 5768, 395, 9088, 63, 1541, 430, 421, 199, 318, 9388, 2925, 8, 452, 63, 2219, 12, 9088, 63, 1541, 304, 523, 408, 4131, 282, 769, 402, 2295, 4079, 641, 314, 1627, 9088, 2457, 14, 819, 3033, 26, 272, 1006, 63, 2219, 26, 3820, 402, 2295, 334, 2796, 14, 10591, 9, 272, 9088, 63, 1541, 26, 9388, 370, 4838, 14, 819, 1803, 26, 272, 17887, 3014, 10026, 402, 314, 1627, 769, 402, 2295, 14, 523, 408, 523, 511, 63, 1247, 275, 359, 28967, 985, 8, 396, 9, 367, 511, 315, 1006, 63, 2219, 61, 523, 9806, 63, 1247, 275, 9388, 774, 5866, 8, 396, 63, 1247, 12, 9088, 63, 1541, 9, 523, 372, 359, 396, 367, 511, 315, 1006, 63, 2219, 340, 2372, 774, 985, 8, 396, 9, 315, 9806, 63, 1247, 61, 421, 199, 318, 9388, 774, 5866, 8, 452, 63, 2219, 12, 9088, 63, 1541, 304, 523, 408, 4131, 282, 769, 402, 511, 1561, 4079, 641, 314, 1627, 9088, 2457, 14, 819, 1666, 1455, 921, 600, 14, 3098 ]
[ 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 22905, 367, 23654, 543, 314, 2366, 2882, 859, 1041, 199, 199, 646, 15951, 199, 646, 984, 199, 646, 2882, 421, 199, 533, 485, 1872, 13120, 8, 2796, 423, 1872, 13120, 304, 523, 408, 33, 511, 754, 1021, 626, 883, 870, 7871, 1318, 2058, 370, 282, 2547, 14, 819, 24288, 12487, 315, 406, 11478, 543, 9088, 1072, 1475, 12, 2839, 26, 523, 359, 21277, 263, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 3358, 4498, 3364, 26, 298, 396, 4328, 2122, 523, 359, 260, 9949, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 3358, 4498, 3364, 523, 359, 21277, 263, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 12914, 5736, 26, 298, 396, 4328, 2122, 523, 359, 260, 9949, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 12914, 5736, 523, 359, 21277, 263, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 12914, 5736, 35, 30566, 9272, 26, 298, 774, 2122, 523, 359, 260, 9949, 1622, 2599, 4498, 14, 3358, 4498, 774, 14, 396, 12914, 5736, 35, 30566, 9272, 523, 408, 523, 347, 636, 826, 721, 277, 12, 2547, 12, 18714, 12, 8661, 304, 272, 2882, 423, 1872, 13120, 855, 826, 721, 277, 12, 2547, 12, 18714, 12, 8661, 9, 272, 291, 423, 15762, 275, 663, 342, 819, 347, 485, 28967, 7639, 8, 277, 12, 511, 304, 272, 372, 1543, 83, 4111, 83, 4111, 83, 7, 450, 334, 396, 855, 533, 4914, 578, 3108, 586, 511, 855, 533, 4914, 354, 3108, 586, 511, 423, 25008, 985, 9, 819, 347, 664, 5831, 8, 277, 12, 511, 304, 272, 372, 1543, 83, 26, 2071, 83, 4507, 450, 334, 277, 423, 28967, 7639, 8, 396, 395, 511, 14, 3612, 5831, 1012, 819, 347, 1343, 774, 8, 277, 12, 511, 304, 272, 2882, 14, 13120, 14, 29344, 8, 277, 12, 511, 9, 272, 291, 14, 1745, 14, 21768, 11894, 21277, 263, 1622, 450, 83, 7, 450, 291, 14, 362, 5831, 8, 396, 430, 819, 347, 1050, 8300, 8, 277, 12, 511, 304, 272, 2882, 14, 13120, 14, 525, 8300, 8, 277, 12, 511, 9, 272, 291, 14, 1745, 14, 21768, 11894, 260, 9949, 1622, 450, 83, 7, 450, 291, 423, 28967, 7639, 8, 396, 430, 819, 347, 1050, 547, 8, 277, 12, 511, 12, 2329, 304, 272, 2882, 14, 13120, 14, 30787, 8, 277, 12, 511, 12, 2329, 9, 272, 291, 14, 1745, 14, 21768, 11894, 420, 12539, 1622, 450, 83, 7, 450, 291, 423, 28967, 7639, 8, 396, 430, 272, 291, 423, 15762, 14, 525, 8, 277, 423, 28967, 7639, 8, 396, 430, 819, 347, 1050, 6782, 8, 277, 12, 511, 12, 2329, 304, 272, 2882, 14, 13120, 14, 525, 6782, 8, 277, 12, 511, 12, 2329, 9, 272, 291, 14, 1745, 14, 21768, 11894, 258, 26892, 1622, 450, 83, 7, 450, 291, 423, 28967, 7639, 8, 396, 430, 272, 291, 423, 15762, 14, 525, 8, 277, 423, 28967, 7639, 8, 396, 430, 819, 347, 664, 497, 396, 4131, 8, 277, 304, 272, 372, 29010, 904, 8, 277, 423, 15762, 9, 421, 199, 533, 4516, 13649, 8, 2796, 14, 24285, 304, 523, 408, 774, 3378, 1372, 367, 20589, 511, 2058, 315, 25884, 1475, 14, 819, 24288, 787, 9080, 315, 406, 11478, 543, 6233, 511, 1072, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 8661, 29, 17, 304, 272, 2882, 14, 24285, 855, 826, 721, 277, 12, 2547, 29, 1274, 14, 3083, 12, 3660, 8661, 29, 9833, 9, 819, 347, 485, 1875, 2889, 8, 277, 304, 272, 372, 485, 1872, 13120, 8, 277, 14, 1745, 12, 291, 14, 21713, 12, 291, 14, 9833, 9, 421, 199, 318, 2372, 11519, 6207, 8, 5768, 304, 523, 408, 3407, 1006, 314, 2295, 687, 282, 1627, 511, 5241, 1041, 523, 2295, 275, 942, 523, 367, 671, 315, 5241, 26, 272, 340, 1228, 8, 88, 12, 2882, 14, 10591, 304, 489, 2295, 847, 2372, 11519, 6207, 8, 88, 9, 272, 587, 26, 489, 2295, 847, 359, 88, 61, 523, 372, 2295, 421, 199, 318, 2372, 774, 5866, 2532, 6207, 8, 5768, 304, 523, 408, 3407, 282, 769, 402, 4036, 511, 536, 315, 314, 1627, 5241, 1041, 523, 372, 2341, 8, 2734, 671, 26, 2372, 774, 985, 8, 88, 395, 2372, 11519, 6207, 8, 5768, 430, 421, 199, 318, 2372, 774, 985, 8, 396, 304, 523, 408, 14426, 314, 511, 536, 402, 314, 1627, 2882, 511, 1041, 523, 372, 15671, 904, 779, 396, 855, 533, 4914, 578, 3108, 673, 511, 855, 533, 4914, 354, 3108, 673, 511, 423, 25008, 985, 566, 421, 199, 318, 9388, 10591, 8, 5768, 12, 9088, 63, 1541, 304, 523, 408, 3407, 282, 892, 9806, 2295, 5241, 4079, 641, 314, 1627, 9088, 2457, 14, 819, 1666, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 3098, 396, 15, 6797, 15, 23613, 4324, 271, 523, 367, 9088, 63, 1541, 8929, 14, 523, 408, 523, 372, 2882, 14, 10591, 8, 4131, 2925, 8, 1002, 11519, 6207, 8, 5768, 395, 9088, 63, 1541, 430, 421, 199, 318, 9388, 2925, 8, 452, 63, 2219, 12, 9088, 63, 1541, 304, 523, 408, 4131, 282, 769, 402, 2295, 4079, 641, 314, 1627, 9088, 2457, 14, 819, 3033, 26, 272, 1006, 63, 2219, 26, 3820, 402, 2295, 334, 2796, 14, 10591, 9, 272, 9088, 63, 1541, 26, 9388, 370, 4838, 14, 819, 1803, 26, 272, 17887, 3014, 10026, 402, 314, 1627, 769, 402, 2295, 14, 523, 408, 523, 511, 63, 1247, 275, 359, 28967, 985, 8, 396, 9, 367, 511, 315, 1006, 63, 2219, 61, 523, 9806, 63, 1247, 275, 9388, 774, 5866, 8, 396, 63, 1247, 12, 9088, 63, 1541, 9, 523, 372, 359, 396, 367, 511, 315, 1006, 63, 2219, 340, 2372, 774, 985, 8, 396, 9, 315, 9806, 63, 1247, 61, 421, 199, 318, 9388, 774, 5866, 8, 452, 63, 2219, 12, 9088, 63, 1541, 304, 523, 408, 4131, 282, 769, 402, 511, 1561, 4079, 641, 314, 1627, 9088, 2457, 14, 819, 1666, 1455, 921, 600, 14, 3098, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Jarn/jarn.mkrelease
jarn/mkrelease/tests/test_git.py
1
18107
import unittest import os from os.path import join, isdir from jarn.mkrelease.scm import Git from jarn.mkrelease.process import Process from jarn.mkrelease.testing import GitSetup from jarn.mkrelease.testing import MockProcess from jarn.mkrelease.testing import quiet class ValidUrlTests(unittest.TestCase): def testGitUrl(self): scm = Git() self.assertEqual(scm.is_valid_url('git://'), True) def testRsyncUrl(self): scm = Git() self.assertEqual(scm.is_valid_url('rsync://'), True) def testSshUrl(self): scm = Git() self.assertEqual(scm.is_valid_url('ssh://'), True) def testHttpUrl(self): scm = Git() self.assertEqual(scm.is_valid_url('http://'), True) def testHttpsUrl(self): scm = Git() self.assertEqual(scm.is_valid_url('https://'), True) def testFileUrl(self): scm = Git() self.assertEqual(scm.is_valid_url('file://'), True) def testBadProtocol(self): scm = Git() self.assertEqual(scm.is_valid_url('svn://'), False) def testEmptyString(self): scm = Git() self.assertEqual(scm.is_valid_url(''), False) def testGitSshUrl(self): scm = Git() self.assertEqual(scm.is_valid_url('git@github.com:Jarn/jarn.mkrelease'), True) class ValidSandboxTests(GitSetup): def testSandbox(self): scm = Git() self.assertEqual(scm.is_valid_sandbox(self.packagedir), True) def testSubdirOfSandbox(self): scm = Git() self.assertEqual(scm.is_valid_sandbox(join(self.packagedir, 'testpackage')), True) def testNotExists(self): scm = Git() self.assertEqual(scm.is_valid_sandbox('foo'), False) def testNotADir(self): scm = Git() self.assertEqual(scm.is_valid_sandbox(join(self.packagedir, 'setup.py')), False) def testNotACheckout(self): scm = Git() self.destroy() self.assertEqual(scm.is_valid_sandbox(self.packagedir), False) @quiet def testCheckRaises(self): scm = Git() self.assertRaises(SystemExit, scm.check_valid_sandbox, 'foo') self.assertRaises(SystemExit, scm.check_valid_sandbox, join(self.packagedir, 'setup.py')) self.destroy() self.assertRaises(SystemExit, scm.check_valid_sandbox, self.packagedir) class RootFromSandboxTests(GitSetup): def testGetRoot(self): scm = Git() self.assertEqual(scm.get_root_from_sandbox(self.packagedir), self.packagedir) def testGetSubfolderRoot(self): scm = Git() self.assertEqual(scm.get_root_from_sandbox(join(self.packagedir, 'testpackage')), self.packagedir) def testGetCloneRoot(self): scm = Git() self.clone() self.assertEqual(scm.get_root_from_sandbox(self.clonedir), self.clonedir) def testGetCloneSubfolderRoot(self): scm = Git() self.clone() self.assertEqual(scm.get_root_from_sandbox(join(self.clonedir, 'testpackage')), self.clonedir) @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.get_root_from_sandbox, self.packagedir) @quiet def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.get_root_from_sandbox, self.packagedir) class BranchFromSandboxTests(GitSetup): def testGetLocalBranch(self): scm = Git() self.assertEqual(scm.get_branch_from_sandbox(self.packagedir), 'master') def testGetLocalBranchFromBranch(self): scm = Git() self.branch(self.packagedir, '2.x') self.assertEqual(scm.get_branch_from_sandbox(self.packagedir), '2.x') def testGetRemoteBranch(self): scm = Git() self.clone() self.assertEqual(scm.get_branch_from_sandbox(self.clonedir), 'master') @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.get_branch_from_sandbox, self.packagedir) @quiet def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.get_branch_from_sandbox, self.packagedir) class RemoteFromSandboxTests(GitSetup): def testGetLocal(self): scm = Git() self.assertEqual(scm.get_remote_from_sandbox(self.packagedir), '') def testGetRemote(self): scm = Git() self.clone() self.assertEqual(scm.get_remote_from_sandbox(self.clonedir), 'origin') @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.get_remote_from_sandbox, self.packagedir) @quiet def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.get_remote_from_sandbox, self.packagedir) @quiet def testWhitebox(self): def func(cmd): if cmd == 'git branch': return 0, ['* master'] return 1, [] scm = Git(MockProcess(func=func)) self.assertRaises(SystemExit, scm.get_remote_from_sandbox, self.packagedir) class TrackedBranchFromSandboxTests(GitSetup): def testGetLocal(self): scm = Git() self.assertEqual(scm.get_tracked_branch_from_sandbox(self.packagedir), '') def testGetRemote(self): scm = Git() self.clone() self.assertEqual(scm.get_tracked_branch_from_sandbox(self.clonedir), 'master') @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.get_tracked_branch_from_sandbox, self.packagedir) @quiet def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.get_tracked_branch_from_sandbox, self.packagedir) @quiet def testWhitebox(self): def func(cmd): if cmd == 'git branch': return 0, ['* master'] return 1, [] scm = Git(MockProcess(func=func)) self.assertRaises(SystemExit, scm.get_tracked_branch_from_sandbox, self.packagedir) class UrlFromSandboxTests(GitSetup): def testGetLocalUrl(self): scm = Git() self.assertEqual(scm.get_url_from_sandbox(self.packagedir), '') def testGetRemoteUrl(self): scm = Git() self.clone() self.assertEqual(scm.get_url_from_sandbox(self.clonedir), self.packagedir) @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.get_url_from_sandbox, self.packagedir) @quiet def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.get_url_from_sandbox, self.packagedir) @quiet def testWhitebox(self): self.called = 0 def func(cmd): if cmd == 'git branch': return 0, ['* master'] if cmd == 'git config -l': self.called += 1 if self.called == 1: return 0, ['branch.master.remote=origin'] return 1, [] scm = Git(MockProcess(func=func)) self.assertRaises(SystemExit, scm.get_url_from_sandbox, self.packagedir) class RemoteSandboxTests(GitSetup): def testIsLocal(self): scm = Git() self.assertEqual(scm.is_remote_sandbox(self.packagedir), False) def testIsRemote(self): scm = Git() self.clone() self.assertEqual(scm.is_remote_sandbox(self.clonedir), True) @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.is_remote_sandbox, self.packagedir) @quiet def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.is_remote_sandbox, self.packagedir) class DirtySandboxTests(GitSetup): def testCleanSandbox(self): scm = Git() self.assertEqual(scm.is_dirty_sandbox(self.packagedir), False) def testModifiedFile(self): scm = Git() self.modify(self.packagedir) self.assertEqual(scm.is_dirty_sandbox(self.packagedir), True) def testRemovedFile(self): scm = Git() self.remove(self.packagedir) self.assertEqual(scm.is_dirty_sandbox(self.packagedir), True) def testDeletedButTrackedFile(self): scm = Git() self.delete(self.packagedir) # Note: The sandbox is reported as *dirty* self.assertEqual(scm.is_dirty_sandbox(self.packagedir), True) @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.is_dirty_sandbox, self.packagedir) @quiet def testBadProcess(self): scm = Git(MockProcess(rc=128)) self.assertRaises(SystemExit, scm.is_dirty_sandbox, self.packagedir) @quiet def testCheckRaises(self): scm = Git() self.modify(self.packagedir) self.assertRaises(SystemExit, scm.check_dirty_sandbox, self.packagedir) class UncleanSandboxTests(GitSetup): def testCleanSandbox(self): scm = Git() self.assertEqual(scm.is_unclean_sandbox(self.packagedir), False) def testModifiedFile(self): scm = Git() self.modify(self.packagedir) self.assertEqual(scm.is_unclean_sandbox(self.packagedir), True) def testRemovedFile(self): scm = Git() self.remove(self.packagedir) self.assertEqual(scm.is_unclean_sandbox(self.packagedir), True) def testDeletedButTrackedFile(self): scm = Git() self.delete(self.packagedir) # Note: The sandbox is reported as unclean self.assertEqual(scm.is_unclean_sandbox(self.packagedir), True) @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.is_unclean_sandbox, self.packagedir) @quiet def testBadProcess(self): scm = Git(MockProcess(rc=128)) self.assertRaises(SystemExit, scm.is_unclean_sandbox, self.packagedir) @quiet def testCheckRaises(self): scm = Git() self.modify(self.packagedir) self.assertRaises(SystemExit, scm.check_unclean_sandbox, self.packagedir) class CommitSandboxTests(GitSetup): def testCommitCleanSandbox(self): scm = Git(Process(quiet=True)) self.assertEqual(scm.commit_sandbox(self.packagedir, 'testpackage', '2.6', False), 0) def testCommitDirtySandbox(self): scm = Git(Process(quiet=True)) self.modify(self.packagedir) self.assertEqual(scm.commit_sandbox(self.packagedir, 'testpackage', '2.6', False), 0) @quiet def testCommitAndPushCleanLocalSandbox(self): scm = Git(Process(quiet=True)) self.assertEqual(scm.commit_sandbox(self.packagedir, 'testpackage', '2.6', True), 0) @quiet def testCommitAndPushDirtyLocalSandbox(self): scm = Git(Process(quiet=True)) self.modify(self.packagedir) self.assertEqual(scm.commit_sandbox(self.packagedir, 'testpackage', '2.6', True), 0) def testCommitAndPushCleanRemoteSandbox(self): scm = Git(Process(quiet=True)) self.clone() self.assertEqual(scm.commit_sandbox(self.clonedir, 'testpackage', '2.6', True), 0) def testCommitAndPushDirtyRemoteSandbox(self): scm = Git(Process(quiet=True)) self.clone() self.modify(self.clonedir) self.assertEqual(scm.commit_sandbox(self.clonedir, 'testpackage', '2.6', True), 0) self.verify(self.clonedir) self.update(self.packagedir) self.verify(self.packagedir) @quiet def testBadPush(self): scm = Git(Process(quiet=True)) self.clone() self.destroy() self.assertRaises(SystemExit, scm.commit_sandbox, self.clonedir, 'testpackage', '2.6', True) @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.commit_sandbox, self.packagedir, 'testpackage', '2.6', False) @quiet def testBadProcess(self): scm = Git(MockProcess(rc=255)) self.assertRaises(SystemExit, scm.commit_sandbox, self.packagedir, 'testpackage', '2.6', False) class CloneUrlTests(GitSetup): def testCloneUrl(self): scm = Git(Process(quiet=True)) self.assertEqual(scm.clone_url(self.packagedir, 'testclone'), 0) self.assertEqual(isdir('testclone'), True) @quiet def testBadServer(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.clone_url, self.packagedir, 'testclone') @quiet def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.clone_url, self.packagedir, 'testclone') class BranchIdTests(GitSetup): def testMakeBranchId(self): scm = Git() self.assertEqual(scm.make_branchid(self.packagedir, '2.x'), '2.x') def testEmptyBranchId(self): scm = Git() self.assertEqual(scm.make_branchid(self.packagedir, ''), 'master') class SwitchBranchTests(GitSetup): @quiet def testSwitchBranch(self): scm = Git(Process(quiet=True)) self.branch(self.packagedir, '2.x') self.assertEqual(scm.get_branch_from_sandbox(self.packagedir), '2.x') self.assertEqual(scm.switch_branch(self.packagedir, 'master'), 0) self.assertEqual(scm.get_branch_from_sandbox(self.packagedir), 'master') @quiet def testSwitchSameBranch(self): scm = Git() self.assertEqual(scm.get_branch_from_sandbox(self.packagedir), 'master') self.assertEqual(scm.switch_branch(self.packagedir, 'master'), 0) self.assertEqual(scm.get_branch_from_sandbox(self.packagedir), 'master') @quiet def testSwitchRemoteBranch(self): scm = Git(Process(quiet=True)) self.branch(self.packagedir, '2.x') self.clone() self.assertEqual(scm.get_branch_from_sandbox(self.clonedir), 'master') self.assertEqual(scm.switch_branch(self.clonedir, '2.x'), 0) self.assertEqual(scm.get_branch_from_sandbox(self.clonedir), '2.x') @quiet def testSwitchUnknownBranch(self): scm = Git(Process(quiet=True)) self.assertRaises(SystemExit, scm.switch_branch, self.packagedir, '2.x') @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.switch_branch, self.packagedir, 'master') @quiet def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.switch_branch, self.packagedir, 'master') class TagExistsTests(GitSetup): def testTagDoesNotExist(self): scm = Git() self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), False) def testTagExists(self): scm = Git() self.tag(self.packagedir, '2.6') self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), True) @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.check_tag_exists, self.packagedir, '2.6') @quiet def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.check_tag_exists, self.packagedir, '2.6') @quiet def testCheckRaises(self): scm = Git() self.tag(self.packagedir, '2.6') self.assertRaises(SystemExit, scm.check_tag_exists, self.packagedir, '2.6') class CreateTagTests(GitSetup): def testCreateTag(self): scm = Git() self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), False) self.assertEqual(scm.create_tag(self.packagedir, '2.6', 'testpackage', '2.6', False), 0) self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), True) @quiet def testCreateExistingTag(self): scm = Git(Process(quiet=True)) self.assertEqual(scm.create_tag(self.packagedir, '2.6', 'testpackage', '2.6', False), 0) self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), True) self.assertRaises(SystemExit, scm.create_tag, self.packagedir, '2.6', 'testpackage', '2.6', False) @quiet def testCreateAndPushLocalTag(self): scm = Git() self.assertEqual(scm.create_tag(self.packagedir, '2.6', 'testpackage', '2.6', True), 0) self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), True) def testCreateAndPushRemoteTag(self): scm = Git(Process(quiet=True)) self.clone() self.assertEqual(scm.create_tag(self.clonedir, '2.6', 'testpackage', '2.6', True), 0) self.assertEqual(scm.tag_exists(self.clonedir, '2.6'), True) self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), True) @quiet def testBadPush(self): scm = Git(Process(quiet=True)) self.clone() self.destroy() self.assertRaises(SystemExit, scm.create_tag, self.packagedir, '2.6', 'testpackage', '2.6', True) @quiet def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.create_tag, self.packagedir, '2.6', 'testpackage', '2.6', False) @quiet def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.create_tag, self.packagedir, '2.6', 'testpackage', '2.6', False) class GetVersionTests(unittest.TestCase): def testGetVersion(self): scm = Git() self.assertNotEqual(scm.get_version(), '') def testVersionInfo(self): scm = Git() self.assertNotEqual(scm.version_info, ()) def test_suite(): return unittest.defaultTestLoader.loadTestsFromName(__name__)
bsd-2-clause
[ 646, 2882, 199, 646, 747, 199, 199, 504, 747, 14, 515, 492, 4263, 12, 26004, 199, 199, 504, 1335, 1060, 14, 3880, 3221, 14, 17143, 492, 12579, 199, 199, 504, 1335, 1060, 14, 3880, 3221, 14, 1412, 492, 7132, 199, 199, 504, 1335, 1060, 14, 3880, 3221, 14, 4776, 492, 12579, 8555, 199, 504, 1335, 1060, 14, 3880, 3221, 14, 4776, 492, 4420, 3498, 199, 504, 1335, 1060, 14, 3880, 3221, 14, 4776, 492, 11971, 421, 199, 533, 4821, 6417, 2925, 8, 2796, 14, 1746, 304, 339, 347, 511, 14686, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 3187, 921, 659, 715, 9, 339, 347, 511, 50, 5186, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 27152, 921, 659, 715, 9, 339, 347, 511, 51, 609, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 5510, 921, 659, 715, 9, 339, 347, 511, 5779, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 1014, 921, 659, 715, 9, 339, 347, 511, 5779, 83, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 2859, 921, 659, 715, 9, 339, 347, 511, 1173, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 493, 921, 659, 715, 9, 339, 347, 511, 5725, 3658, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 6836, 921, 659, 756, 9, 339, 347, 511, 4699, 1558, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 31150, 756, 9, 339, 347, 511, 14686, 51, 609, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 3187, 32, 5031, 14, 957, 26, 42, 1060, 15, 74, 1060, 14, 3880, 3221, 659, 715, 9, 421, 199, 533, 4821, 29155, 2925, 8, 14686, 8555, 304, 339, 347, 511, 29155, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 16647, 8, 277, 14, 2491, 694, 395, 715, 9, 339, 347, 511, 2610, 694, 3466, 29155, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 16647, 8, 904, 8, 277, 14, 2491, 694, 12, 283, 396, 2491, 3855, 715, 9, 339, 347, 511, 25095, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 16647, 360, 1421, 659, 756, 9, 339, 347, 511, 1763, 1554, 723, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 16647, 8, 904, 8, 277, 14, 2491, 694, 12, 283, 2758, 14, 647, 3855, 756, 9, 339, 347, 511, 1763, 1348, 801, 548, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 7237, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 16647, 8, 277, 14, 2491, 694, 395, 756, 9, 339, 768, 10243, 272, 347, 511, 1799, 1811, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 1855, 8, 24738, 12, 25811, 14, 1074, 63, 1078, 63, 16647, 12, 283, 1421, 358, 267, 291, 14, 1855, 8, 24738, 12, 25811, 14, 1074, 63, 1078, 63, 16647, 12, 4263, 8, 277, 14, 2491, 694, 12, 283, 2758, 14, 647, 1333, 267, 291, 14, 7237, 342, 267, 291, 14, 1855, 8, 24738, 12, 25811, 14, 1074, 63, 1078, 63, 16647, 12, 291, 14, 2491, 694, 9, 421, 199, 533, 12826, 2532, 29155, 2925, 8, 14686, 8555, 304, 339, 347, 19970, 6405, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 362, 63, 1231, 63, 504, 63, 16647, 8, 277, 14, 2491, 694, 395, 586, 291, 14, 2491, 694, 9, 339, 347, 19970, 2610, 3741, 6405, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 362, 63, 1231, 63, 504, 63, 16647, 8, 904, 8, 277, 14, 2491, 694, 12, 283, 396, 2491, 3855, 586, 291, 14, 2491, 694, 9, 339, 347, 19970, 21222, 6405, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 6311, 342, 267, 291, 14, 629, 8, 17143, 14, 362, 63, 1231, 63, 504, 63, 16647, 8, 277, 14, 6311, 694, 395, 586, 291, 14, 6311, 694, 9, 339, 347, 19970, 21222, 2610, 3741, 6405, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 6311, 342, 267, 291, 14, 629, 8, 17143, 14, 362, 63, 1231, 63, 504, 63, 16647, 8, 904, 8, 277, 14, 6311, 694, 12, 283, 396, 2491, 3855, 586, 291, 14, 6311, 694, 9, 339, 768, 10243, 272, 347, 511, 5725, 29155, 8, 277, 304, 267, 25811, 275, 12579, 8, 3498, 8, 10243, 29, 549, 430, 267, 291, 14, 7237, 342, 267, 291, 14, 1855, 8, 24738, 12, 25811, 14, 362, 63, 1231, 63, 504, 63, 16647, 12, 291, 14, 2491, 694, 9, 339, 768, 10243, 272, 347, 511, 5725, 3498, 8, 277, 304, 267, 25811, 275, 12579, 8, 3346, 3498, 8, 1195, 29, 17, 430, 267, 291, 14, 1855, 8, 24738, 12, 25811, 14, 362, 63, 1231, 63, 504, 63, 16647, 12, 291, 14, 2491, 694, 9, 421, 199, 533, 699, 2965, 2532, 29155, 2925, 8, 14686, 8555, 304, 339, 347, 19970, 5339, 12526, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 362, 63, 4694, 63, 504, 63, 16647, 8, 277, 14, 2491, 694, 395, 283, 4133, 358, 339, 347, 19970, 5339, 12526, 2532, 12526, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 4694, 8, 277, 14, 2491, 694, 12, 283, 18, 14, 88, 358, 267, 291, 14 ]
[ 2882, 199, 646, 747, 199, 199, 504, 747, 14, 515, 492, 4263, 12, 26004, 199, 199, 504, 1335, 1060, 14, 3880, 3221, 14, 17143, 492, 12579, 199, 199, 504, 1335, 1060, 14, 3880, 3221, 14, 1412, 492, 7132, 199, 199, 504, 1335, 1060, 14, 3880, 3221, 14, 4776, 492, 12579, 8555, 199, 504, 1335, 1060, 14, 3880, 3221, 14, 4776, 492, 4420, 3498, 199, 504, 1335, 1060, 14, 3880, 3221, 14, 4776, 492, 11971, 421, 199, 533, 4821, 6417, 2925, 8, 2796, 14, 1746, 304, 339, 347, 511, 14686, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 3187, 921, 659, 715, 9, 339, 347, 511, 50, 5186, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 27152, 921, 659, 715, 9, 339, 347, 511, 51, 609, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 5510, 921, 659, 715, 9, 339, 347, 511, 5779, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 1014, 921, 659, 715, 9, 339, 347, 511, 5779, 83, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 2859, 921, 659, 715, 9, 339, 347, 511, 1173, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 493, 921, 659, 715, 9, 339, 347, 511, 5725, 3658, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 6836, 921, 659, 756, 9, 339, 347, 511, 4699, 1558, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 31150, 756, 9, 339, 347, 511, 14686, 51, 609, 6417, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 633, 360, 3187, 32, 5031, 14, 957, 26, 42, 1060, 15, 74, 1060, 14, 3880, 3221, 659, 715, 9, 421, 199, 533, 4821, 29155, 2925, 8, 14686, 8555, 304, 339, 347, 511, 29155, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 16647, 8, 277, 14, 2491, 694, 395, 715, 9, 339, 347, 511, 2610, 694, 3466, 29155, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 16647, 8, 904, 8, 277, 14, 2491, 694, 12, 283, 396, 2491, 3855, 715, 9, 339, 347, 511, 25095, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 16647, 360, 1421, 659, 756, 9, 339, 347, 511, 1763, 1554, 723, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 16647, 8, 904, 8, 277, 14, 2491, 694, 12, 283, 2758, 14, 647, 3855, 756, 9, 339, 347, 511, 1763, 1348, 801, 548, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 7237, 342, 267, 291, 14, 629, 8, 17143, 14, 374, 63, 1078, 63, 16647, 8, 277, 14, 2491, 694, 395, 756, 9, 339, 768, 10243, 272, 347, 511, 1799, 1811, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 1855, 8, 24738, 12, 25811, 14, 1074, 63, 1078, 63, 16647, 12, 283, 1421, 358, 267, 291, 14, 1855, 8, 24738, 12, 25811, 14, 1074, 63, 1078, 63, 16647, 12, 4263, 8, 277, 14, 2491, 694, 12, 283, 2758, 14, 647, 1333, 267, 291, 14, 7237, 342, 267, 291, 14, 1855, 8, 24738, 12, 25811, 14, 1074, 63, 1078, 63, 16647, 12, 291, 14, 2491, 694, 9, 421, 199, 533, 12826, 2532, 29155, 2925, 8, 14686, 8555, 304, 339, 347, 19970, 6405, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 362, 63, 1231, 63, 504, 63, 16647, 8, 277, 14, 2491, 694, 395, 586, 291, 14, 2491, 694, 9, 339, 347, 19970, 2610, 3741, 6405, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 362, 63, 1231, 63, 504, 63, 16647, 8, 904, 8, 277, 14, 2491, 694, 12, 283, 396, 2491, 3855, 586, 291, 14, 2491, 694, 9, 339, 347, 19970, 21222, 6405, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 6311, 342, 267, 291, 14, 629, 8, 17143, 14, 362, 63, 1231, 63, 504, 63, 16647, 8, 277, 14, 6311, 694, 395, 586, 291, 14, 6311, 694, 9, 339, 347, 19970, 21222, 2610, 3741, 6405, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 6311, 342, 267, 291, 14, 629, 8, 17143, 14, 362, 63, 1231, 63, 504, 63, 16647, 8, 904, 8, 277, 14, 6311, 694, 12, 283, 396, 2491, 3855, 586, 291, 14, 6311, 694, 9, 339, 768, 10243, 272, 347, 511, 5725, 29155, 8, 277, 304, 267, 25811, 275, 12579, 8, 3498, 8, 10243, 29, 549, 430, 267, 291, 14, 7237, 342, 267, 291, 14, 1855, 8, 24738, 12, 25811, 14, 362, 63, 1231, 63, 504, 63, 16647, 12, 291, 14, 2491, 694, 9, 339, 768, 10243, 272, 347, 511, 5725, 3498, 8, 277, 304, 267, 25811, 275, 12579, 8, 3346, 3498, 8, 1195, 29, 17, 430, 267, 291, 14, 1855, 8, 24738, 12, 25811, 14, 362, 63, 1231, 63, 504, 63, 16647, 12, 291, 14, 2491, 694, 9, 421, 199, 533, 699, 2965, 2532, 29155, 2925, 8, 14686, 8555, 304, 339, 347, 19970, 5339, 12526, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 629, 8, 17143, 14, 362, 63, 4694, 63, 504, 63, 16647, 8, 277, 14, 2491, 694, 395, 283, 4133, 358, 339, 347, 19970, 5339, 12526, 2532, 12526, 8, 277, 304, 267, 25811, 275, 12579, 342, 267, 291, 14, 4694, 8, 277, 14, 2491, 694, 12, 283, 18, 14, 88, 358, 267, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ionutbalutoiu/ironic
ironic/drivers/modules/ilo/boot.py
2
16854
# Copyright 2015 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ Boot Interface for iLO drivers and its supporting methods. """ import os import tempfile from ironic_lib import utils as ironic_utils from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils import six.moves.urllib.parse as urlparse from ironic.common import boot_devices from ironic.common import exception from ironic.common.glance_service import service_utils from ironic.common.i18n import _ from ironic.common.i18n import _LE from ironic.common.i18n import _LW from ironic.common import image_service from ironic.common import images from ironic.common import swift from ironic.conductor import utils as manager_utils from ironic.drivers import base from ironic.drivers.modules import deploy_utils from ironic.drivers.modules.ilo import common as ilo_common LOG = logging.getLogger(__name__) CONF = cfg.CONF REQUIRED_PROPERTIES = { 'ilo_deploy_iso': _("UUID (from Glance) of the deployment ISO. " "Required.") } COMMON_PROPERTIES = REQUIRED_PROPERTIES def parse_driver_info(node): """Gets the driver specific Node deployment info. This method validates whether the 'driver_info' property of the supplied node contains the required information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the driver_info values. :raises: MissingParameterValue, if any of the required parameters are missing. """ info = node.driver_info d_info = {} d_info['ilo_deploy_iso'] = info.get('ilo_deploy_iso') error_msg = _("Error validating iLO virtual media deploy. Some parameters" " were missing in node's driver_info") deploy_utils.check_for_missing_params(d_info, error_msg) return d_info def _get_boot_iso_object_name(node): """Returns the boot iso object name for a given node. :param node: the node for which object name is to be provided. """ return "boot-%s" % node.uuid def _get_boot_iso(task, root_uuid): """This method returns a boot ISO to boot the node. It chooses one of the three options in the order as below: 1. Does nothing if 'ilo_boot_iso' is present in node's instance_info and 'boot_iso_created_in_web_server' is not set in 'driver_internal_info'. 2. Image deployed has a meta-property 'boot_iso' in Glance. This should refer to the UUID of the boot_iso which exists in Glance. 3. Generates a boot ISO on the fly using kernel and ramdisk mentioned in the image deployed. It uploads the generated boot ISO to Swift. :param task: a TaskManager instance containing the node to act on. :param root_uuid: the uuid of the root partition. :returns: boot ISO URL. Should be either of below: * A Swift object - It should be of format 'swift:<object-name>'. It is assumed that the image object is present in CONF.ilo.swift_ilo_container; * A Glance image - It should be format 'glance://<glance-image-uuid>' or just <glance-image-uuid>; * An HTTP URL. On error finding the boot iso, it returns None. :raises: MissingParameterValue, if any of the required parameters are missing in the node's driver_info or instance_info. :raises: InvalidParameterValue, if any of the parameters have invalid value in the node's driver_info or instance_info. :raises: SwiftOperationError, if operation with Swift fails. :raises: ImageCreationFailed, if creation of boot ISO failed. :raises: exception.ImageRefValidationFailed if ilo_boot_iso is not HTTP(S) URL. """ LOG.debug("Trying to get a boot ISO to boot the baremetal node") # Option 1 - Check if user has provided ilo_boot_iso in node's # instance_info driver_internal_info = task.node.driver_internal_info boot_iso_created_in_web_server = ( driver_internal_info.get('boot_iso_created_in_web_server')) if (task.node.instance_info.get('ilo_boot_iso') and not boot_iso_created_in_web_server): LOG.debug("Using ilo_boot_iso provided in node's instance_info") boot_iso = task.node.instance_info['ilo_boot_iso'] if not service_utils.is_glance_image(boot_iso): try: image_service.HttpImageService().validate_href(boot_iso) except exception.ImageRefValidationFailed: with excutils.save_and_reraise_exception(): LOG.error(_LE("Virtual media deploy accepts only Glance " "images or HTTP(S) URLs as " "instance_info['ilo_boot_iso']. Either %s " "is not a valid HTTP(S) URL or is " "not reachable."), boot_iso) return task.node.instance_info['ilo_boot_iso'] # Option 2 - Check if user has provided a boot_iso in Glance. If boot_iso # is a supported non-glance href execution will proceed to option 3. deploy_info = _parse_deploy_info(task.node) image_href = deploy_info['image_source'] image_properties = ( images.get_image_properties( task.context, image_href, ['boot_iso', 'kernel_id', 'ramdisk_id'])) boot_iso_uuid = image_properties.get('boot_iso') kernel_href = (task.node.instance_info.get('kernel') or image_properties.get('kernel_id')) ramdisk_href = (task.node.instance_info.get('ramdisk') or image_properties.get('ramdisk_id')) if boot_iso_uuid: LOG.debug("Found boot_iso %s in Glance", boot_iso_uuid) return boot_iso_uuid if not kernel_href or not ramdisk_href: LOG.error(_LE("Unable to find kernel or ramdisk for " "image %(image)s to generate boot ISO for %(node)s"), {'image': image_href, 'node': task.node.uuid}) return # NOTE(rameshg87): Functionality to share the boot ISOs created for # similar instances (instances with same deployed image) is # not implemented as of now. Creation/Deletion of such a shared boot ISO # will require synchronisation across conductor nodes for the shared boot # ISO. Such a synchronisation mechanism doesn't exist in ironic as of now. # Option 3 - Create boot_iso from kernel/ramdisk, upload to Swift # or web server and provide its name. deploy_iso_uuid = deploy_info['ilo_deploy_iso'] boot_mode = deploy_utils.get_boot_mode_for_deploy(task.node) boot_iso_object_name = _get_boot_iso_object_name(task.node) kernel_params = CONF.pxe.pxe_append_params with tempfile.NamedTemporaryFile(dir=CONF.tempdir) as fileobj: boot_iso_tmp_file = fileobj.name images.create_boot_iso(task.context, boot_iso_tmp_file, kernel_href, ramdisk_href, deploy_iso_uuid, root_uuid, kernel_params, boot_mode) if CONF.ilo.use_web_server_for_images: boot_iso_url = ( ilo_common.copy_image_to_web_server(boot_iso_tmp_file, boot_iso_object_name)) driver_internal_info = task.node.driver_internal_info driver_internal_info['boot_iso_created_in_web_server'] = True task.node.driver_internal_info = driver_internal_info task.node.save() LOG.debug("Created boot_iso %(boot_iso)s for node %(node)s", {'boot_iso': boot_iso_url, 'node': task.node.uuid}) return boot_iso_url else: container = CONF.ilo.swift_ilo_container swift_api = swift.SwiftAPI() swift_api.create_object(container, boot_iso_object_name, boot_iso_tmp_file) LOG.debug("Created boot_iso %s in Swift", boot_iso_object_name) return 'swift:%s' % boot_iso_object_name def _clean_up_boot_iso_for_instance(node): """Deletes the boot ISO if it was created for the instance. :param node: an ironic node object. """ ilo_boot_iso = node.instance_info.get('ilo_boot_iso') if not ilo_boot_iso: return if ilo_boot_iso.startswith('swift'): swift_api = swift.SwiftAPI() container = CONF.ilo.swift_ilo_container boot_iso_object_name = _get_boot_iso_object_name(node) try: swift_api.delete_object(container, boot_iso_object_name) except exception.SwiftOperationError as e: LOG.exception(_LE("Failed to clean up boot ISO for node " "%(node)s. Error: %(error)s."), {'node': node.uuid, 'error': e}) elif CONF.ilo.use_web_server_for_images: result = urlparse.urlparse(ilo_boot_iso) ilo_boot_iso_name = os.path.basename(result.path) boot_iso_path = os.path.join( CONF.deploy.http_root, ilo_boot_iso_name) ironic_utils.unlink_without_raise(boot_iso_path) def _parse_deploy_info(node): """Gets the instance and driver specific Node deployment info. This method validates whether the 'instance_info' and 'driver_info' property of the supplied node contains the required information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the instance_info and driver_info values. :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ info = {} info.update(deploy_utils.get_image_instance_info(node)) info.update(parse_driver_info(node)) return info class IloVirtualMediaBoot(base.BootInterface): def get_properties(self): return COMMON_PROPERTIES def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue, if some information is invalid. :raises: MissingParameterValue if 'kernel_id' and 'ramdisk_id' are missing in the Glance image or 'kernel' and 'ramdisk' not provided in instance_info for non-Glance image. """ node = task.node d_info = _parse_deploy_info(node) if node.driver_internal_info.get('is_whole_disk_image'): props = [] elif service_utils.is_glance_image(d_info['image_source']): props = ['kernel_id', 'ramdisk_id'] else: props = ['kernel', 'ramdisk'] deploy_utils.validate_image_properties(task.context, d_info, props) def prepare_ramdisk(self, task, ramdisk_params): """Prepares the boot of deploy ramdisk using virtual media. This method prepares the boot of the deploy ramdisk after reading relevant information from the node's driver_info and instance_info. :param task: a task from TaskManager. :param ramdisk_params: the parameters to be passed to the ramdisk. :returns: None :raises: MissingParameterValue, if some information is missing in node's driver_info or instance_info. :raises: InvalidParameterValue, if some information provided is invalid. :raises: IronicException, if some power or set boot boot device operation failed on the node. :raises: IloOperationError, if some operation on iLO failed. """ node = task.node # Clear ilo_boot_iso if it's a glance image to force recreate # another one again (or use existing one in glance). # This is mainly for rebuild scenario. if service_utils.is_glance_image( node.instance_info.get('image_source')): instance_info = node.instance_info instance_info.pop('ilo_boot_iso', None) node.instance_info = instance_info node.save() # Eject all virtual media devices, as we are going to use them # during deploy. ilo_common.eject_vmedia_devices(task) deploy_nic_mac = deploy_utils.get_single_nic_with_vif_port_id(task) ramdisk_params['BOOTIF'] = deploy_nic_mac deploy_iso = node.driver_info['ilo_deploy_iso'] ilo_common.setup_vmedia(task, deploy_iso, ramdisk_params) def prepare_instance(self, task): """Prepares the boot of instance. This method prepares the boot of the instance after reading relevant information from the node's instance_info. It does the following depending on boot_option for deploy: - If the boot_option requested for this deploy is 'local' or image is a whole disk image, then it sets the node to boot from disk. - Otherwise it finds/creates the boot ISO to boot the instance image, attaches the boot ISO to the bare metal and then sets the node to boot from CDROM. :param task: a task from TaskManager. :returns: None :raises: IloOperationError, if some operation on iLO failed. """ ilo_common.cleanup_vmedia_boot(task) # For iscsi_ilo driver, we boot from disk every time if the image # deployed is a whole disk image. node = task.node iwdi = node.driver_internal_info.get('is_whole_disk_image') if deploy_utils.get_boot_option(node) == "local" or iwdi: manager_utils.node_set_boot_device(task, boot_devices.DISK, persistent=True) else: drv_int_info = node.driver_internal_info root_uuid_or_disk_id = drv_int_info.get('root_uuid_or_disk_id') if root_uuid_or_disk_id: self._configure_vmedia_boot(task, root_uuid_or_disk_id) else: LOG.warning(_LW("The UUID for the root partition could not " "be found for node %s"), node.uuid) def clean_up_instance(self, task): """Cleans up the boot of instance. This method cleans up the environment that was setup for booting the instance. It ejects virtual media :param task: a task from TaskManager. :returns: None :raises: IloOperationError, if some operation on iLO failed. """ _clean_up_boot_iso_for_instance(task.node) driver_internal_info = task.node.driver_internal_info driver_internal_info.pop('boot_iso_created_in_web_server', None) driver_internal_info.pop('root_uuid_or_disk_id', None) task.node.driver_internal_info = driver_internal_info task.node.save() ilo_common.cleanup_vmedia_boot(task) def clean_up_ramdisk(self, task): """Cleans up the boot of ironic ramdisk. This method cleans up virtual media devices setup for the deploy ramdisk. :param task: a task from TaskManager. :returns: None :raises: IloOperationError, if some operation on iLO failed. """ ilo_common.cleanup_vmedia_boot(task) def _configure_vmedia_boot(self, task, root_uuid): """Configure vmedia boot for the node. :param task: a task from TaskManager. :param root_uuid: uuid of the root partition :returns: None :raises: IloOperationError, if some operation on iLO failed. """ node = task.node boot_iso = _get_boot_iso(task, root_uuid) if not boot_iso: LOG.error(_LE("Cannot get boot ISO for node %s"), node.uuid) return # Upon deploy complete, some distros cloud images reboot the system as # part of its configuration. Hence boot device should be persistent and # not one-time. ilo_common.setup_vmedia_for_boot(task, boot_iso) manager_utils.node_set_boot_device(task, boot_devices.CDROM, persistent=True) i_info = node.instance_info i_info['ilo_boot_iso'] = boot_iso node.instance_info = i_info node.save()
apache-2.0
[ 3, 1898, 6900, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 624, 199, 17989, 14816, 367, 284, 1484, 19016, 436, 2399, 21038, 3102, 14, 199, 624, 199, 199, 646, 747, 199, 646, 5549, 199, 199, 504, 28372, 63, 773, 492, 3778, 465, 28372, 63, 1208, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 1208, 492, 32763, 199, 646, 3816, 14, 4912, 14, 4078, 14, 1122, 465, 7097, 199, 199, 504, 28372, 14, 2330, 492, 8498, 63, 6410, 199, 504, 28372, 14, 2330, 492, 1919, 199, 504, 28372, 14, 2330, 14, 18773, 63, 1364, 492, 2435, 63, 1208, 199, 504, 28372, 14, 2330, 14, 73, 1085, 78, 492, 485, 199, 504, 28372, 14, 2330, 14, 73, 1085, 78, 492, 485, 906, 199, 504, 28372, 14, 2330, 14, 73, 1085, 78, 492, 485, 20145, 199, 504, 28372, 14, 2330, 492, 1834, 63, 1364, 199, 504, 28372, 14, 2330, 492, 5935, 199, 504, 28372, 14, 2330, 492, 16275, 199, 504, 28372, 14, 28678, 492, 3778, 465, 5256, 63, 1208, 199, 504, 28372, 14, 13337, 492, 1300, 199, 504, 28372, 14, 13337, 14, 3112, 492, 12287, 63, 1208, 199, 504, 28372, 14, 13337, 14, 3112, 14, 11737, 492, 2863, 465, 284, 320, 63, 2330, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3103, 275, 4810, 14, 3103, 199, 199, 12496, 63, 18858, 29807, 275, 469, 272, 283, 11737, 63, 11060, 63, 4595, 356, 3824, 8757, 334, 504, 598, 76, 554, 9, 402, 314, 14295, 9055, 14, 298, 717, 298, 8030, 2685, 199, 93, 199, 21637, 63, 18858, 29807, 275, 25090, 63, 18858, 29807, 421, 199, 318, 2198, 63, 3090, 63, 815, 8, 932, 304, 272, 408, 14426, 314, 5253, 2488, 5013, 14295, 2256, 14, 339, 961, 1083, 29280, 3775, 314, 283, 3090, 63, 815, 7, 3324, 402, 314, 272, 6841, 1031, 3509, 314, 1415, 2556, 367, 642, 5253, 370, 272, 12287, 5935, 370, 314, 1031, 14, 339, 520, 635, 1031, 26, 282, 2849, 5013, 14, 272, 520, 5808, 26, 437, 1211, 543, 314, 5253, 63, 815, 1338, 14, 272, 520, 3536, 26, 15626, 24637, 12, 340, 1263, 402, 314, 1415, 2633, 787, 267, 4124, 14, 272, 408, 272, 2256, 275, 1031, 14, 3090, 63, 815, 272, 366, 63, 815, 275, 1052, 272, 366, 63, 815, 459, 11737, 63, 11060, 63, 4595, 418, 275, 2256, 14, 362, 360, 11737, 63, 11060, 63, 4595, 358, 339, 1125, 63, 1328, 275, 3824, 547, 1686, 1958, 284, 1484, 5791, 5898, 12287, 14, 6601, 2633, 2, 2116, 298, 4898, 4124, 315, 1031, 1159, 5253, 63, 815, 531, 272, 12287, 63, 1208, 14, 1074, 63, 509, 63, 4752, 63, 1162, 8, 68, 63, 815, 12, 1125, 63, 1328, 9, 339, 372, 366, 63, 815, 421, 199, 318, 485, 362, 63, 4930, 63, 4595, 63, 785, 63, 354, 8, 932, 304, 272, 408, 3407, 314, 8498, 11601, 909, 536, 367, 282, 1627, 1031, 14, 339, 520, 635, 1031, 26, 314, 1031, 367, 1314, 909, 536, 365, 370, 506, 2741, 14, 272, 408, 272, 372, 298, 4930, 3295, 83, 2, 450, 1031, 14, 2580, 421, 199, 318, 485, 362, 63, 4930, 63, 4595, 8, 1765, 12, 1738, 63, 2580, 304, 272, 408, 2765, 1083, 2529, 282, 8498, 9055, 370, 8498, 314, 1031, 14, 339, 2779, 2468, 32128, 1373, 402, 314, 7795, 1511, 315, 314, 1865, 465, 5084, 26, 272, 413, 14, 12078, 6548, 340, 283, 11737, 63, 4930, 63, 4595, 7, 365, 3451, 315, 1031, 1159, 1256, 63, 815, 436, 2126, 283, 4930, 63, 4595, 63, 3966, 63, 262, 63, 2520, 63, 1000, 7, 365, 440, 663, 315, 283, 3090, 63, 4672, 63, 815, 1370, 272, 499, 14, 6047, 26181, 965, 282, 3404, 13, 1829, 283, 4930, 63, 4595, 7, 315, 598, 76, 554, 14, 961, 1077, 2126, 10618, 370, 314, 11134, 402, 314, 8498, 63, 4595, 1314, 3495, 315, 598, 76, 554, 14, 272, 650, 14, 21687, 282, 8498, 9055, 641, 314, 23158, 1808, 5114, 436, 21394, 4032, 26239, 315, 2126, 314, 1834, 26181, 14, 2779, 26598, 314, 4046, 8498, 9055, 370, 16666, 2949, 14, 339, 520, 635, 2120, 26, 282, 8495, 2988, 1256, 3035, 314, 1031, 370, 2454, 641, 14, 272, 520, 635, 1738, 63, 2580, 26, 314, 5377, 402, 314, 1738, 6484, 14, 272, 520, 5808, 26, 8498, 9055, 2851, 14, 7719, 506, 1902, 402, 5084, 26, 267, 627, 437, 16666, 2949, 909, 446, 2779, 1077, 506, 402, 1475, 283, 13215, 16875, 785, 13, 354, 22936, 2779, 365, 881, 10826, 626, 314, 1834, 909, 365, 3451, 315, 881, 6392, 14, 11737, 14, 13215, 63, 11737, 63, 3600, 27, 267, 627, 437, 598, 76, 554, 1834, 446, 2779, 1077, 506, 1475, 283, 18773, 921, 28, 18773, 13, 1569, 13, 2580, 3524, 881, 503, 2951, 665, 18773, 13, 1569, 13, 2580, 30, 27, 267, 627, 1626, 3101, 2851, 14, 267, 4068, 1125, 17196, 314, 8498, 11601, 12, 652, 2529, 488, 14, 272, 520, 3536, 26, 15626, 24637, 12, 340, 1263, 402, 314, 1415, 2633, 787, 267, 4124, 315, 314, 1031, 1159, 5253, 63, 815, 503, 1256, 63, 815, 14, 272, 520, 3536, 26, 6378, 24637, 12, 340, 1263, 402, 314, 2633, 1172, 3866, 267, 574, 315, 314, 1031, 1159, 5253, 63, 815, 503, 1256, 63, 815, 14, 272, 520, 3536, 26, 16666, 2949, 3632, 5263, 12, 340, 3439, 543, 16666, 2949, 6918, 14, 272, 520 ]
[ 1898, 6900, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 624, 199, 17989, 14816, 367, 284, 1484, 19016, 436, 2399, 21038, 3102, 14, 199, 624, 199, 199, 646, 747, 199, 646, 5549, 199, 199, 504, 28372, 63, 773, 492, 3778, 465, 28372, 63, 1208, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 1208, 492, 32763, 199, 646, 3816, 14, 4912, 14, 4078, 14, 1122, 465, 7097, 199, 199, 504, 28372, 14, 2330, 492, 8498, 63, 6410, 199, 504, 28372, 14, 2330, 492, 1919, 199, 504, 28372, 14, 2330, 14, 18773, 63, 1364, 492, 2435, 63, 1208, 199, 504, 28372, 14, 2330, 14, 73, 1085, 78, 492, 485, 199, 504, 28372, 14, 2330, 14, 73, 1085, 78, 492, 485, 906, 199, 504, 28372, 14, 2330, 14, 73, 1085, 78, 492, 485, 20145, 199, 504, 28372, 14, 2330, 492, 1834, 63, 1364, 199, 504, 28372, 14, 2330, 492, 5935, 199, 504, 28372, 14, 2330, 492, 16275, 199, 504, 28372, 14, 28678, 492, 3778, 465, 5256, 63, 1208, 199, 504, 28372, 14, 13337, 492, 1300, 199, 504, 28372, 14, 13337, 14, 3112, 492, 12287, 63, 1208, 199, 504, 28372, 14, 13337, 14, 3112, 14, 11737, 492, 2863, 465, 284, 320, 63, 2330, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3103, 275, 4810, 14, 3103, 199, 199, 12496, 63, 18858, 29807, 275, 469, 272, 283, 11737, 63, 11060, 63, 4595, 356, 3824, 8757, 334, 504, 598, 76, 554, 9, 402, 314, 14295, 9055, 14, 298, 717, 298, 8030, 2685, 199, 93, 199, 21637, 63, 18858, 29807, 275, 25090, 63, 18858, 29807, 421, 199, 318, 2198, 63, 3090, 63, 815, 8, 932, 304, 272, 408, 14426, 314, 5253, 2488, 5013, 14295, 2256, 14, 339, 961, 1083, 29280, 3775, 314, 283, 3090, 63, 815, 7, 3324, 402, 314, 272, 6841, 1031, 3509, 314, 1415, 2556, 367, 642, 5253, 370, 272, 12287, 5935, 370, 314, 1031, 14, 339, 520, 635, 1031, 26, 282, 2849, 5013, 14, 272, 520, 5808, 26, 437, 1211, 543, 314, 5253, 63, 815, 1338, 14, 272, 520, 3536, 26, 15626, 24637, 12, 340, 1263, 402, 314, 1415, 2633, 787, 267, 4124, 14, 272, 408, 272, 2256, 275, 1031, 14, 3090, 63, 815, 272, 366, 63, 815, 275, 1052, 272, 366, 63, 815, 459, 11737, 63, 11060, 63, 4595, 418, 275, 2256, 14, 362, 360, 11737, 63, 11060, 63, 4595, 358, 339, 1125, 63, 1328, 275, 3824, 547, 1686, 1958, 284, 1484, 5791, 5898, 12287, 14, 6601, 2633, 2, 2116, 298, 4898, 4124, 315, 1031, 1159, 5253, 63, 815, 531, 272, 12287, 63, 1208, 14, 1074, 63, 509, 63, 4752, 63, 1162, 8, 68, 63, 815, 12, 1125, 63, 1328, 9, 339, 372, 366, 63, 815, 421, 199, 318, 485, 362, 63, 4930, 63, 4595, 63, 785, 63, 354, 8, 932, 304, 272, 408, 3407, 314, 8498, 11601, 909, 536, 367, 282, 1627, 1031, 14, 339, 520, 635, 1031, 26, 314, 1031, 367, 1314, 909, 536, 365, 370, 506, 2741, 14, 272, 408, 272, 372, 298, 4930, 3295, 83, 2, 450, 1031, 14, 2580, 421, 199, 318, 485, 362, 63, 4930, 63, 4595, 8, 1765, 12, 1738, 63, 2580, 304, 272, 408, 2765, 1083, 2529, 282, 8498, 9055, 370, 8498, 314, 1031, 14, 339, 2779, 2468, 32128, 1373, 402, 314, 7795, 1511, 315, 314, 1865, 465, 5084, 26, 272, 413, 14, 12078, 6548, 340, 283, 11737, 63, 4930, 63, 4595, 7, 365, 3451, 315, 1031, 1159, 1256, 63, 815, 436, 2126, 283, 4930, 63, 4595, 63, 3966, 63, 262, 63, 2520, 63, 1000, 7, 365, 440, 663, 315, 283, 3090, 63, 4672, 63, 815, 1370, 272, 499, 14, 6047, 26181, 965, 282, 3404, 13, 1829, 283, 4930, 63, 4595, 7, 315, 598, 76, 554, 14, 961, 1077, 2126, 10618, 370, 314, 11134, 402, 314, 8498, 63, 4595, 1314, 3495, 315, 598, 76, 554, 14, 272, 650, 14, 21687, 282, 8498, 9055, 641, 314, 23158, 1808, 5114, 436, 21394, 4032, 26239, 315, 2126, 314, 1834, 26181, 14, 2779, 26598, 314, 4046, 8498, 9055, 370, 16666, 2949, 14, 339, 520, 635, 2120, 26, 282, 8495, 2988, 1256, 3035, 314, 1031, 370, 2454, 641, 14, 272, 520, 635, 1738, 63, 2580, 26, 314, 5377, 402, 314, 1738, 6484, 14, 272, 520, 5808, 26, 8498, 9055, 2851, 14, 7719, 506, 1902, 402, 5084, 26, 267, 627, 437, 16666, 2949, 909, 446, 2779, 1077, 506, 402, 1475, 283, 13215, 16875, 785, 13, 354, 22936, 2779, 365, 881, 10826, 626, 314, 1834, 909, 365, 3451, 315, 881, 6392, 14, 11737, 14, 13215, 63, 11737, 63, 3600, 27, 267, 627, 437, 598, 76, 554, 1834, 446, 2779, 1077, 506, 1475, 283, 18773, 921, 28, 18773, 13, 1569, 13, 2580, 3524, 881, 503, 2951, 665, 18773, 13, 1569, 13, 2580, 30, 27, 267, 627, 1626, 3101, 2851, 14, 267, 4068, 1125, 17196, 314, 8498, 11601, 12, 652, 2529, 488, 14, 272, 520, 3536, 26, 15626, 24637, 12, 340, 1263, 402, 314, 1415, 2633, 787, 267, 4124, 315, 314, 1031, 1159, 5253, 63, 815, 503, 1256, 63, 815, 14, 272, 520, 3536, 26, 6378, 24637, 12, 340, 1263, 402, 314, 2633, 1172, 3866, 267, 574, 315, 314, 1031, 1159, 5253, 63, 815, 503, 1256, 63, 815, 14, 272, 520, 3536, 26, 16666, 2949, 3632, 5263, 12, 340, 3439, 543, 16666, 2949, 6918, 14, 272, 520, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
attia42/twitter_word2vec
kmeans/experimentm.py
1
3559
import csv import nltk from nltk.tokenize import word_tokenize import string from nltk import pos_tag from gensim.models.word2vec import Word2Vec from gensim import matutils from numpy import array, float32 as REAL from sklearn.cluster import MiniBatchKMeans, KMeans from multiprocessing import Pool from collections import Counter #string.punctuation #string.digits file = 'training.1600000.processed.noemoticon2.csv' #file = 'testdata.manual.2009.06.14.csv' tags = ["NNP", "NN", "NNS"] ncls = 1000 niters = 1000 nreplay_kmeans = 1 lower = False redundant = ["aw", "aww", "awww", "awwww", "haha", "lol", "wow", "wtf", "xd", "yay", "http", "www", "com", "ah", "ahh", "ahhh", "amp"] def preprocess(tweet): ret_tweet = "" i = -1 nn = [] raw_tweet = tweet for ch in string.punctuation.replace("'","") + string.digits: tweet = tweet.replace(ch, " ") tweet_pos = {} if lower: tweet = tweet.lower() try: toks = word_tokenize(tweet) pos = pos_tag(toks) nn = [p for p in pos if p[1] in tags] #nn = [p for p in pos if p == 'NNP'] except: pass if(len(nn)): tweet_pos["NN"] = nn ret_tweet = tweet_pos return ret_tweet raw = [] with open(file, 'rb') as csvfile: content = csv.reader(csvfile, delimiter=',', quotechar='"') for row in content: tweet = row[5] raw.append(tweet) p = Pool(6) tweets = p.map(preprocess, raw) t1 = [] t2 = [] for i in range(len(tweets)): if len(tweets[i]): t1.append(raw[i]) t2.append(tweets[i]) raw = t1 tweets = t2 print "Loading model..." wv = Word2Vec.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True) vectors = [] for i in range(len(tweets)): tweet = tweets[i] nns = tweet['NN'] vector = [] #print nns mean = [] no_wv_tweet = True for w in nns: if len(w[0]) > 1 and w[0] in wv and w[0].lower() not in redundant: no_wv_tweet = False #print w[0] weight = 1 if w[1] == 'NNP': weight = 100 mean.append(weight * wv[w[0]]) if(len(mean)): vectors.append(matutils.unitvec(array(mean).mean(axis=0)).astype(REAL)) else: vectors.append([]) t1 = [] t2 = [] t3 = [] for i in range(len(vectors)): if vectors[i] != None and len(vectors[i]): t1.append(raw[i]) t2.append(tweets[i]) t3.append(vectors[i]) raw = t1 tweets = t2 vectors = t3 #kmeans = KMeans(init='k-means++', n_clusters=ncls, n_init=1) kmeans = MiniBatchKMeans(init='k-means++', n_clusters=ncls, n_init=nreplay_kmeans, max_iter=niters) kmeans.fit(vectors) clss = kmeans.predict(vectors) clusters = [[] for i in range(ncls)] for i in range(len(vectors)): cls = clss[i] clusters[cls].append(i) clusterstags = [[] for i in range(ncls)] countarr = [] for c in clusters: counts = Counter() for i in c: t = [x[0] for x in tweets[i]["NN"] ]#if x[1] == "NNP"] #tn = [x[1] for x in tweets[i]["NN"]] sentence = " ".join(t) #+ tn) counts.update(word.strip('.,?!"\'').lower() for word in sentence.split()) countarr.append(counts) output = "" for i in range(ncls): output = "Most common words for this cluster:\n" output += str(countarr[i].most_common(12)) output += "\n\n\n\n\n\n" output += "Word2vec space of related words:\n" wv_rel = wv.most_similar([kmeans.cluster_centers_[i]], topn=10) output += str(wv_rel) output += "\n\n\n\n\n\n" for t in clusters[i]: output += str(raw[t]) + "\n" #output += "\n\n\n" nm = [x[0] for x in countarr[i].most_common(5)] nm = str(" ".join(nm)) for ch in string.punctuation: nm = nm.replace(ch, " ") f = open('clusters/' + nm +'.txt', 'wb') f.write(output) f.close()
mit
[ 646, 7392, 199, 646, 24706, 199, 504, 24706, 14, 15246, 492, 4349, 63, 15246, 199, 646, 1059, 199, 504, 24706, 492, 2086, 63, 1450, 199, 504, 3805, 5206, 14, 992, 14, 1027, 18, 6046, 492, 14644, 18, 14373, 199, 504, 3805, 5206, 492, 2530, 1208, 199, 504, 2680, 492, 1625, 12, 2069, 708, 465, 5363, 748, 199, 504, 6357, 14, 4201, 492, 24954, 8842, 43, 21190, 12, 1804, 21190, 199, 504, 12866, 492, 15553, 199, 504, 5055, 492, 14427, 6905, 199, 3, 875, 14, 25181, 199, 3, 875, 14, 7022, 421, 199, 493, 275, 283, 7588, 14, 975, 5345, 14, 7292, 14, 889, 69, 573, 280, 388, 18, 14, 4737, 7, 199, 3, 493, 275, 283, 18481, 14, 9285, 14, 8664, 14, 1690, 14, 1079, 14, 4737, 7, 199, 2969, 275, 2097, 7178, 48, 401, 298, 7178, 401, 298, 46, 2709, 937, 421, 199, 78, 1886, 275, 5198, 199, 8445, 878, 275, 5198, 199, 78, 19540, 63, 75, 11579, 275, 413, 199, 2325, 275, 756, 199, 199, 581, 17013, 275, 2097, 10084, 401, 298, 65, 978, 401, 298, 65, 1544, 401, 298, 65, 978, 978, 401, 298, 2411, 2411, 401, 298, 320, 76, 401, 298, 87, 583, 401, 298, 87, 3249, 401, 298, 2207, 401, 298, 89, 1187, 401, 298, 1014, 401, 298, 1544, 401, 298, 957, 401, 298, 11326, 401, 298, 11326, 72, 401, 298, 11326, 12156, 401, 298, 5282, 937, 199, 199, 318, 23351, 8, 23508, 304, 199, 198, 3292, 63, 23508, 275, 3087, 199, 198, 73, 275, 446, 17, 199, 198, 4411, 275, 942, 199, 198, 1773, 63, 23508, 275, 21217, 507, 421, 198, 509, 682, 315, 1059, 14, 25181, 14, 1814, 27769, 7230, 435, 1059, 14, 7022, 26, 507, 198, 23508, 275, 21217, 14, 1814, 8, 335, 12, 298, 6099, 8299, 198, 23508, 63, 1712, 275, 1052, 199, 198, 692, 5117, 26, 507, 198, 23508, 275, 21217, 14, 2325, 342, 507, 8299, 198, 893, 26, 507, 198, 29328, 275, 4349, 63, 15246, 8, 23508, 9, 507, 198, 1712, 275, 2086, 63, 1450, 8, 29328, 9, 507, 198, 4411, 275, 359, 80, 367, 299, 315, 2086, 340, 299, 59, 17, 61, 315, 3762, 61, 507, 198, 3, 4411, 275, 359, 80, 367, 299, 315, 2086, 340, 299, 508, 283, 7178, 48, 418, 199, 198, 2590, 26, 507, 198, 1529, 199, 198, 692, 8, 552, 8, 4411, 2298, 507, 198, 23508, 63, 1712, 905, 7178, 937, 275, 11542, 507, 198, 3292, 63, 23508, 275, 21217, 63, 1712, 16737, 199, 198, 1107, 2203, 63, 23508, 421, 199, 1773, 275, 942, 199, 1045, 1551, 8, 493, 12, 283, 4848, 358, 465, 7392, 493, 26, 507, 198, 1317, 275, 7392, 14, 5503, 8, 4737, 493, 12, 11172, 4009, 297, 6313, 1560, 534, 9008, 507, 198, 509, 1962, 315, 1564, 26, 686, 198, 23508, 275, 1962, 59, 21, 61, 686, 198, 1773, 14, 740, 8, 23508, 9, 4388, 199, 80, 275, 15553, 8, 22, 9, 199, 84, 18588, 275, 299, 14, 1130, 8, 17677, 12, 3066, 9, 199, 84, 17, 275, 942, 199, 84, 18, 275, 942, 199, 509, 284, 315, 1425, 8, 552, 8, 84, 18588, 2298, 199, 198, 692, 822, 8, 84, 18588, 59, 73, 4682, 507, 198, 84, 17, 14, 740, 8, 1773, 59, 73, 566, 507, 198, 84, 18, 14, 740, 8, 84, 18588, 59, 73, 566, 199, 1773, 275, 307, 17, 199, 84, 18588, 275, 307, 18, 421, 199, 1361, 298, 19236, 1402, 11500, 199, 26880, 275, 14644, 18, 14373, 14, 912, 63, 1027, 18, 6046, 63, 908, 360, 13266, 24730, 13, 12280, 13, 7371, 5863, 14, 1393, 297, 3366, 29, 549, 9, 199, 199, 12280, 275, 942, 421, 199, 509, 284, 315, 1425, 8, 552, 8, 84, 18588, 2298, 199, 198, 23508, 275, 307, 18588, 59, 73, 61, 199, 198, 78, 561, 275, 21217, 459, 7178, 418, 199, 198, 4106, 275, 942, 199, 198, 3, 1361, 302, 561, 9948, 198, 3670, 275, 942, 199, 198, 889, 63, 26880, 63, 23508, 275, 715, 8299, 198, 509, 336, 315, 302, 561, 26, 507, 198, 692, 822, 8, 87, 59, 16, 566, 690, 413, 436, 336, 59, 16, 61, 315, 336, 86, 436, 336, 59, 16, 1055, 2325, 342, 440, 315, 22649, 26, 686, 198, 889, 63, 26880, 63, 23508, 275, 756, 686, 198, 3, 1361, 336, 59, 16, 61, 686, 198, 3463, 275, 413, 686, 198, 692, 336, 59, 17, 61, 508, 283, 7178, 48, 356, 1585, 198, 3463, 275, 2948, 686, 198, 3670, 14, 740, 8, 3463, 627, 336, 86, 59, 87, 59, 16, 3934, 199, 198, 692, 8, 552, 8, 3670, 2298, 507, 198, 12280, 14, 740, 8, 569, 1208, 14, 3248, 6046, 8, 1144, 8, 3670, 680, 3670, 8, 3127, 29, 16, 4992, 6041, 8, 15508, 430, 199, 198, 2836, 26, 507, 198, 12280, 14, 740, 4157, 6905, 199, 84, 17, 275, 942, 199, 84, 18, 275, 942, 199, 84, 19, 275, 942, 199, 509, 284, 315, 1425, 8, 552, 8, 12280, 2298, 199, 198, 692, 11102, 59, 73, 61, 1137, 488, 436, 822, 8, 12280, 59, 73, 4682, 507, 198, 84, 17, 14, 740, 8, 1773, 59, 73, 566, 507, 198, 84, 18, 14, 740, 8, 84, 18588, 59, 73, 566, 507, 198, 84, 19, 14, 740, 8, 12280, 59, 73, 566, 199, 1773, 275, 307, 17, 199, 84, 18588, 275, 307, 18, 199, 12280, 275, 307, 19, 6905, 199, 3, 75, 11579, 275, 1804, 21190, 8, 826, 534, 75, 13, 11579, 31249, 302, 63, 9170, 29, 78, 1886, 12, 302, 63, 826, 29, 17, 9, 199, 75, 11579, 275, 24954, 8842, 43, 21190, 8, 826, 534, 75, 13, 11579, 31249, 302, 63, 9170, 29, 78, 1886, 12, 302, 63, 826, 29, 78, 19540, 63, 75, 11579, 12, 1390, 63, 1661, 29, 8445, 878, 9, 199, 75, 11579, 14, 3269, 8, 12280, 9, 421, 199, 429, 385, 275, 1022, 11579, 14, 6892, 8, 12280, 9, 199, 199, 9170, 275, 3474, 61, 367, 284, 315, 1425, 8, 78, 1886, 1874, 199, 199, 509, 284, 315, 1425, 8, 552, 8, 12280, 2298, 199, 198, 1886, 275, 824, 385, 59, 73, 61, 199, 198, 9170, 59, 1886, 1055, 740, 8, 73, 9, 421, 199, 4201, 1207, 458, 275, 3474, 61, 367 ]
[ 7392, 199, 646, 24706, 199, 504, 24706, 14, 15246, 492, 4349, 63, 15246, 199, 646, 1059, 199, 504, 24706, 492, 2086, 63, 1450, 199, 504, 3805, 5206, 14, 992, 14, 1027, 18, 6046, 492, 14644, 18, 14373, 199, 504, 3805, 5206, 492, 2530, 1208, 199, 504, 2680, 492, 1625, 12, 2069, 708, 465, 5363, 748, 199, 504, 6357, 14, 4201, 492, 24954, 8842, 43, 21190, 12, 1804, 21190, 199, 504, 12866, 492, 15553, 199, 504, 5055, 492, 14427, 6905, 199, 3, 875, 14, 25181, 199, 3, 875, 14, 7022, 421, 199, 493, 275, 283, 7588, 14, 975, 5345, 14, 7292, 14, 889, 69, 573, 280, 388, 18, 14, 4737, 7, 199, 3, 493, 275, 283, 18481, 14, 9285, 14, 8664, 14, 1690, 14, 1079, 14, 4737, 7, 199, 2969, 275, 2097, 7178, 48, 401, 298, 7178, 401, 298, 46, 2709, 937, 421, 199, 78, 1886, 275, 5198, 199, 8445, 878, 275, 5198, 199, 78, 19540, 63, 75, 11579, 275, 413, 199, 2325, 275, 756, 199, 199, 581, 17013, 275, 2097, 10084, 401, 298, 65, 978, 401, 298, 65, 1544, 401, 298, 65, 978, 978, 401, 298, 2411, 2411, 401, 298, 320, 76, 401, 298, 87, 583, 401, 298, 87, 3249, 401, 298, 2207, 401, 298, 89, 1187, 401, 298, 1014, 401, 298, 1544, 401, 298, 957, 401, 298, 11326, 401, 298, 11326, 72, 401, 298, 11326, 12156, 401, 298, 5282, 937, 199, 199, 318, 23351, 8, 23508, 304, 199, 198, 3292, 63, 23508, 275, 3087, 199, 198, 73, 275, 446, 17, 199, 198, 4411, 275, 942, 199, 198, 1773, 63, 23508, 275, 21217, 507, 421, 198, 509, 682, 315, 1059, 14, 25181, 14, 1814, 27769, 7230, 435, 1059, 14, 7022, 26, 507, 198, 23508, 275, 21217, 14, 1814, 8, 335, 12, 298, 6099, 8299, 198, 23508, 63, 1712, 275, 1052, 199, 198, 692, 5117, 26, 507, 198, 23508, 275, 21217, 14, 2325, 342, 507, 8299, 198, 893, 26, 507, 198, 29328, 275, 4349, 63, 15246, 8, 23508, 9, 507, 198, 1712, 275, 2086, 63, 1450, 8, 29328, 9, 507, 198, 4411, 275, 359, 80, 367, 299, 315, 2086, 340, 299, 59, 17, 61, 315, 3762, 61, 507, 198, 3, 4411, 275, 359, 80, 367, 299, 315, 2086, 340, 299, 508, 283, 7178, 48, 418, 199, 198, 2590, 26, 507, 198, 1529, 199, 198, 692, 8, 552, 8, 4411, 2298, 507, 198, 23508, 63, 1712, 905, 7178, 937, 275, 11542, 507, 198, 3292, 63, 23508, 275, 21217, 63, 1712, 16737, 199, 198, 1107, 2203, 63, 23508, 421, 199, 1773, 275, 942, 199, 1045, 1551, 8, 493, 12, 283, 4848, 358, 465, 7392, 493, 26, 507, 198, 1317, 275, 7392, 14, 5503, 8, 4737, 493, 12, 11172, 4009, 297, 6313, 1560, 534, 9008, 507, 198, 509, 1962, 315, 1564, 26, 686, 198, 23508, 275, 1962, 59, 21, 61, 686, 198, 1773, 14, 740, 8, 23508, 9, 4388, 199, 80, 275, 15553, 8, 22, 9, 199, 84, 18588, 275, 299, 14, 1130, 8, 17677, 12, 3066, 9, 199, 84, 17, 275, 942, 199, 84, 18, 275, 942, 199, 509, 284, 315, 1425, 8, 552, 8, 84, 18588, 2298, 199, 198, 692, 822, 8, 84, 18588, 59, 73, 4682, 507, 198, 84, 17, 14, 740, 8, 1773, 59, 73, 566, 507, 198, 84, 18, 14, 740, 8, 84, 18588, 59, 73, 566, 199, 1773, 275, 307, 17, 199, 84, 18588, 275, 307, 18, 421, 199, 1361, 298, 19236, 1402, 11500, 199, 26880, 275, 14644, 18, 14373, 14, 912, 63, 1027, 18, 6046, 63, 908, 360, 13266, 24730, 13, 12280, 13, 7371, 5863, 14, 1393, 297, 3366, 29, 549, 9, 199, 199, 12280, 275, 942, 421, 199, 509, 284, 315, 1425, 8, 552, 8, 84, 18588, 2298, 199, 198, 23508, 275, 307, 18588, 59, 73, 61, 199, 198, 78, 561, 275, 21217, 459, 7178, 418, 199, 198, 4106, 275, 942, 199, 198, 3, 1361, 302, 561, 9948, 198, 3670, 275, 942, 199, 198, 889, 63, 26880, 63, 23508, 275, 715, 8299, 198, 509, 336, 315, 302, 561, 26, 507, 198, 692, 822, 8, 87, 59, 16, 566, 690, 413, 436, 336, 59, 16, 61, 315, 336, 86, 436, 336, 59, 16, 1055, 2325, 342, 440, 315, 22649, 26, 686, 198, 889, 63, 26880, 63, 23508, 275, 756, 686, 198, 3, 1361, 336, 59, 16, 61, 686, 198, 3463, 275, 413, 686, 198, 692, 336, 59, 17, 61, 508, 283, 7178, 48, 356, 1585, 198, 3463, 275, 2948, 686, 198, 3670, 14, 740, 8, 3463, 627, 336, 86, 59, 87, 59, 16, 3934, 199, 198, 692, 8, 552, 8, 3670, 2298, 507, 198, 12280, 14, 740, 8, 569, 1208, 14, 3248, 6046, 8, 1144, 8, 3670, 680, 3670, 8, 3127, 29, 16, 4992, 6041, 8, 15508, 430, 199, 198, 2836, 26, 507, 198, 12280, 14, 740, 4157, 6905, 199, 84, 17, 275, 942, 199, 84, 18, 275, 942, 199, 84, 19, 275, 942, 199, 509, 284, 315, 1425, 8, 552, 8, 12280, 2298, 199, 198, 692, 11102, 59, 73, 61, 1137, 488, 436, 822, 8, 12280, 59, 73, 4682, 507, 198, 84, 17, 14, 740, 8, 1773, 59, 73, 566, 507, 198, 84, 18, 14, 740, 8, 84, 18588, 59, 73, 566, 507, 198, 84, 19, 14, 740, 8, 12280, 59, 73, 566, 199, 1773, 275, 307, 17, 199, 84, 18588, 275, 307, 18, 199, 12280, 275, 307, 19, 6905, 199, 3, 75, 11579, 275, 1804, 21190, 8, 826, 534, 75, 13, 11579, 31249, 302, 63, 9170, 29, 78, 1886, 12, 302, 63, 826, 29, 17, 9, 199, 75, 11579, 275, 24954, 8842, 43, 21190, 8, 826, 534, 75, 13, 11579, 31249, 302, 63, 9170, 29, 78, 1886, 12, 302, 63, 826, 29, 78, 19540, 63, 75, 11579, 12, 1390, 63, 1661, 29, 8445, 878, 9, 199, 75, 11579, 14, 3269, 8, 12280, 9, 421, 199, 429, 385, 275, 1022, 11579, 14, 6892, 8, 12280, 9, 199, 199, 9170, 275, 3474, 61, 367, 284, 315, 1425, 8, 78, 1886, 1874, 199, 199, 509, 284, 315, 1425, 8, 552, 8, 12280, 2298, 199, 198, 1886, 275, 824, 385, 59, 73, 61, 199, 198, 9170, 59, 1886, 1055, 740, 8, 73, 9, 421, 199, 4201, 1207, 458, 275, 3474, 61, 367, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hbisheng/ucore_os_lab
related_info/lab8/sfs-homework.py
45
13723
#! /usr/bin/env python import random from optparse import OptionParser DEBUG = False def dprint(str): if DEBUG: print str printOps = True printState = True printFinal = True class bitmap: def __init__(self, size): self.size = size self.bmap = [] for num in range(size): self.bmap.append(0) def alloc(self): for num in range(len(self.bmap)): if self.bmap[num] == 0: self.bmap[num] = 1 return num return -1 def free(self, num): assert(self.bmap[num] == 1) self.bmap[num] = 0 def markAllocated(self, num): assert(self.bmap[num] == 0) self.bmap[num] = 1 def dump(self): s = '' for i in range(len(self.bmap)): s += str(self.bmap[i]) return s class block: def __init__(self, ftype): assert(ftype == 'd' or ftype == 'f' or ftype == 'free') self.ftype = ftype # only for directories, properly a subclass but who cares self.dirUsed = 0 self.maxUsed = 32 self.dirList = [] self.data = '' def dump(self): if self.ftype == 'free': return '[]' elif self.ftype == 'd': rc = '' for d in self.dirList: # d is of the form ('name', inum) short = '(%s,%s)' % (d[0], d[1]) if rc == '': rc = short else: rc += ' ' + short return '['+rc+']' # return '%s' % self.dirList else: return '[%s]' % self.data def setType(self, ftype): assert(self.ftype == 'free') self.ftype = ftype def addData(self, data): assert(self.ftype == 'f') self.data = data def getNumEntries(self): assert(self.ftype == 'd') return self.dirUsed def getFreeEntries(self): assert(self.ftype == 'd') return self.maxUsed - self.dirUsed def getEntry(self, num): assert(self.ftype == 'd') assert(num < self.dirUsed) return self.dirList[num] def addDirEntry(self, name, inum): assert(self.ftype == 'd') self.dirList.append((name, inum)) self.dirUsed += 1 assert(self.dirUsed <= self.maxUsed) def delDirEntry(self, name): assert(self.ftype == 'd') tname = name.split('/') dname = tname[len(tname) - 1] for i in range(len(self.dirList)): if self.dirList[i][0] == dname: self.dirList.pop(i) self.dirUsed -= 1 return assert(1 == 0) def dirEntryExists(self, name): assert(self.ftype == 'd') for d in self.dirList: if name == d[0]: return True return False def free(self): assert(self.ftype != 'free') if self.ftype == 'd': # check for only dot, dotdot here assert(self.dirUsed == 2) self.dirUsed = 0 self.data = '' self.ftype = 'free' class inode: def __init__(self, ftype='free', addr=-1, refCnt=1): self.setAll(ftype, addr, refCnt) def setAll(self, ftype, addr, refCnt): assert(ftype == 'd' or ftype == 'f' or ftype == 'free') self.ftype = ftype self.addr = addr self.refCnt = refCnt def incRefCnt(self): self.refCnt += 1 def decRefCnt(self): self.refCnt -= 1 def getRefCnt(self): return self.refCnt def setType(self, ftype): assert(ftype == 'd' or ftype == 'f' or ftype == 'free') self.ftype = ftype def setAddr(self, block): self.addr = block def getSize(self): if self.addr == -1: return 0 else: return 1 def getAddr(self): return self.addr def getType(self): return self.ftype def free(self): self.ftype = 'free' self.addr = -1 class fs: def __init__(self, numInodes, numData): self.numInodes = numInodes self.numData = numData self.ibitmap = bitmap(self.numInodes) self.inodes = [] for i in range(self.numInodes): self.inodes.append(inode()) self.dbitmap = bitmap(self.numData) self.data = [] for i in range(self.numData): self.data.append(block('free')) # root inode self.ROOT = 0 # create root directory self.ibitmap.markAllocated(self.ROOT) self.inodes[self.ROOT].setAll('d', 0, 2) self.dbitmap.markAllocated(self.ROOT) self.data[0].setType('d') self.data[0].addDirEntry('.', self.ROOT) self.data[0].addDirEntry('..', self.ROOT) # these is just for the fake workload generator self.files = [] self.dirs = ['/'] self.nameToInum = {'/':self.ROOT} def dump(self): print 'inode bitmap ', self.ibitmap.dump() print 'inodes ', for i in range(0,self.numInodes): ftype = self.inodes[i].getType() if ftype == 'free': print '[]', else: print '[%s a:%s r:%d]' % (ftype, self.inodes[i].getAddr(), self.inodes[i].getRefCnt()), print '' print 'data bitmap ', self.dbitmap.dump() print 'data ', for i in range(self.numData): print self.data[i].dump(), print '' def makeName(self): p = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] return p[int(random.random() * len(p))] def inodeAlloc(self): return self.ibitmap.alloc() def inodeFree(self, inum): self.ibitmap.free(inum) self.inodes[inum].free() def dataAlloc(self): return self.dbitmap.alloc() def dataFree(self, bnum): self.dbitmap.free(bnum) self.data[bnum].free() def getParent(self, name): tmp = name.split('/') if len(tmp) == 2: return '/' pname = '' for i in range(1, len(tmp)-1): pname = pname + '/' + tmp[i] return pname def deleteFile(self, tfile): if printOps: print 'unlink("%s");' % tfile inum = self.nameToInum[tfile] # YOUR CODE, YOUR ID # IF inode.refcnt ==1, THEN free data blocks first, then free inode, ELSE dec indoe.refcnt # remove from parent directory: delete from parent inum, delete from parent addr # DONE # finally, remove from files list self.files.remove(tfile) return 0 def createLink(self, target, newfile, parent): # YOUR CODE, YOUR ID # find info about parent # is there room in the parent directory? # if the newfile was already in parent dir? # now, find inumber of target # inc parent ref count # now add to directory # DONE return tinum def createFile(self, parent, newfile, ftype): # YOUR CODE, YOUR ID # find info about parent # is there room in the parent directory? # have to make sure file name is unique # find free inode # if a directory, have to allocate directory block for basic (., ..) info # now ok to init inode properly # inc parent ref count # and add to directory of parent # DONE return inum def writeFile(self, tfile, data): inum = self.nameToInum[tfile] curSize = self.inodes[inum].getSize() dprint('writeFile: inum:%d cursize:%d refcnt:%d' % (inum, curSize, self.inodes[inum].getRefCnt())) # YOUR CODE, YOUR ID # file is full? # no data blocks left # write file data # DONE if printOps: print 'fd=open("%s", O_WRONLY|O_APPEND); write(fd, buf, BLOCKSIZE); close(fd);' % tfile return 0 def doDelete(self): dprint('doDelete') if len(self.files) == 0: return -1 dfile = self.files[int(random.random() * len(self.files))] dprint('try delete(%s)' % dfile) return self.deleteFile(dfile) def doLink(self): dprint('doLink') if len(self.files) == 0: return -1 parent = self.dirs[int(random.random() * len(self.dirs))] nfile = self.makeName() # pick random target target = self.files[int(random.random() * len(self.files))] # get full name of newfile if parent == '/': fullName = parent + nfile else: fullName = parent + '/' + nfile dprint('try createLink(%s %s %s)' % (target, nfile, parent)) inum = self.createLink(target, nfile, parent) if inum >= 0: self.files.append(fullName) self.nameToInum[fullName] = inum if printOps: print 'link("%s", "%s");' % (target, fullName) return 0 return -1 def doCreate(self, ftype): dprint('doCreate') parent = self.dirs[int(random.random() * len(self.dirs))] nfile = self.makeName() if ftype == 'd': tlist = self.dirs else: tlist = self.files if parent == '/': fullName = parent + nfile else: fullName = parent + '/' + nfile dprint('try createFile(%s %s %s)' % (parent, nfile, ftype)) inum = self.createFile(parent, nfile, ftype) if inum >= 0: tlist.append(fullName) self.nameToInum[fullName] = inum if parent == '/': parent = '' if ftype == 'd': if printOps: print 'mkdir("%s/%s");' % (parent, nfile) else: if printOps: print 'creat("%s/%s");' % (parent, nfile) return 0 return -1 def doAppend(self): dprint('doAppend') if len(self.files) == 0: return -1 afile = self.files[int(random.random() * len(self.files))] dprint('try writeFile(%s)' % afile) data = chr(ord('a') + int(random.random() * 26)) rc = self.writeFile(afile, data) return rc def run(self, numRequests): self.percentMkdir = 0.40 self.percentWrite = 0.40 self.percentDelete = 0.20 self.numRequests = numRequests print 'Initial state' print '' self.dump() print '' for i in range(numRequests): if printOps == False: print 'Which operation took place?' rc = -1 while rc == -1: r = random.random() if r < 0.3: rc = self.doAppend() dprint('doAppend rc:%d' % rc) elif r < 0.5: rc = self.doDelete() dprint('doDelete rc:%d' % rc) elif r < 0.7: rc = self.doLink() dprint('doLink rc:%d' % rc) else: if random.random() < 0.75: rc = self.doCreate('f') dprint('doCreate(f) rc:%d' % rc) else: rc = self.doCreate('d') dprint('doCreate(d) rc:%d' % rc) if printState == True: print '' self.dump() print '' else: print '' print ' State of file system (inode bitmap, inodes, data bitmap, data)?' print '' if printFinal: print '' print 'Summary of files, directories::' print '' print ' Files: ', self.files print ' Directories:', self.dirs print '' # # main program # parser = OptionParser() parser.add_option('-s', '--seed', default=0, help='the random seed', action='store', type='int', dest='seed') parser.add_option('-i', '--numInodes', default=8, help='number of inodes in file system', action='store', type='int', dest='numInodes') parser.add_option('-d', '--numData', default=8, help='number of data blocks in file system', action='store', type='int', dest='numData') parser.add_option('-n', '--numRequests', default=10, help='number of requests to simulate', action='store', type='int', dest='numRequests') parser.add_option('-r', '--reverse', default=False, help='instead of printing state, print ops', action='store_true', dest='reverse') parser.add_option('-p', '--printFinal', default=False, help='print the final set of files/dirs', action='store_true', dest='printFinal') (options, args) = parser.parse_args() print 'ARG seed', options.seed print 'ARG numInodes', options.numInodes print 'ARG numData', options.numData print 'ARG numRequests', options.numRequests print 'ARG reverse', options.reverse print 'ARG printFinal', options.printFinal print '' random.seed(options.seed) if options.reverse: printState = False printOps = True else: printState = True printOps = False printOps = True printState = True printFinal = options.printFinal # # have to generate RANDOM requests to the file system # that are VALID! # f = fs(options.numInodes, options.numData) # # ops: mkdir rmdir : create delete : append write # f.run(options.numRequests)
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 2196, 199, 504, 8691, 492, 13491, 199, 199, 5287, 275, 756, 199, 199, 318, 366, 1361, 8, 495, 304, 272, 340, 10990, 26, 267, 870, 620, 199, 199, 1361, 16452, 420, 275, 715, 199, 1361, 2223, 259, 275, 715, 199, 1361, 12776, 259, 275, 715, 199, 199, 533, 20810, 26, 272, 347, 636, 826, 721, 277, 12, 1568, 304, 267, 291, 14, 890, 275, 1568, 267, 291, 14, 66, 1130, 275, 942, 267, 367, 1967, 315, 1425, 8, 890, 304, 288, 291, 14, 66, 1130, 14, 740, 8, 16, 9, 339, 347, 29447, 8, 277, 304, 267, 367, 1967, 315, 1425, 8, 552, 8, 277, 14, 66, 1130, 2298, 288, 340, 291, 14, 66, 1130, 59, 1507, 61, 508, 378, 26, 355, 291, 14, 66, 1130, 59, 1507, 61, 275, 413, 355, 372, 1967, 267, 372, 446, 17, 339, 347, 2867, 8, 277, 12, 1967, 304, 267, 702, 8, 277, 14, 66, 1130, 59, 1507, 61, 508, 413, 9, 267, 291, 14, 66, 1130, 59, 1507, 61, 275, 378, 339, 347, 2216, 2439, 13340, 8, 277, 12, 1967, 304, 267, 702, 8, 277, 14, 66, 1130, 59, 1507, 61, 508, 378, 9, 267, 291, 14, 66, 1130, 59, 1507, 61, 275, 413, 339, 347, 5461, 8, 277, 304, 267, 308, 275, 2125, 267, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 66, 1130, 2298, 288, 308, 847, 620, 8, 277, 14, 66, 1130, 59, 73, 566, 267, 372, 308, 199, 199, 533, 1853, 26, 272, 347, 636, 826, 721, 277, 12, 8570, 304, 267, 702, 8, 10386, 508, 283, 68, 7, 503, 8570, 508, 283, 70, 7, 503, 8570, 508, 283, 4624, 358, 267, 291, 14, 10386, 275, 8570, 267, 327, 1454, 367, 6602, 12, 7684, 282, 5516, 1325, 3963, 1704, 470, 267, 291, 14, 694, 9167, 275, 378, 267, 291, 14, 988, 9167, 275, 4337, 267, 291, 14, 694, 1296, 275, 942, 267, 291, 14, 576, 259, 275, 2125, 339, 347, 5461, 8, 277, 304, 267, 340, 291, 14, 10386, 508, 283, 4624, 356, 288, 372, 6730, 6616, 267, 916, 291, 14, 10386, 508, 283, 68, 356, 288, 4819, 275, 2125, 288, 367, 366, 315, 291, 14, 694, 1296, 26, 355, 327, 366, 365, 402, 314, 1824, 661, 354, 297, 315, 453, 9, 355, 3974, 275, 25676, 83, 8719, 83, 3171, 450, 334, 68, 59, 16, 467, 366, 59, 17, 566, 355, 340, 4819, 508, 8061, 490, 4819, 275, 3974, 355, 587, 26, 490, 4819, 847, 283, 283, 435, 3974, 288, 372, 22640, 11, 1195, 11, 418, 7, 288, 327, 372, 1543, 83, 7, 450, 291, 14, 694, 1296, 267, 587, 26, 288, 372, 30423, 83, 6616, 450, 291, 14, 576, 339, 347, 663, 804, 8, 277, 12, 8570, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 4624, 358, 267, 291, 14, 10386, 275, 8570, 339, 347, 1050, 1451, 8, 277, 12, 666, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 70, 358, 267, 291, 14, 576, 275, 666, 339, 347, 664, 5667, 17816, 8, 277, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 372, 291, 14, 694, 9167, 339, 347, 664, 10146, 17816, 8, 277, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 372, 291, 14, 988, 9167, 446, 291, 14, 694, 9167, 339, 347, 664, 3900, 8, 277, 12, 1967, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 702, 8, 1507, 665, 291, 14, 694, 9167, 9, 267, 372, 291, 14, 694, 1296, 59, 1507, 61, 339, 347, 1050, 3567, 3900, 8, 277, 12, 536, 12, 315, 453, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 291, 14, 694, 1296, 14, 740, 1332, 354, 12, 315, 453, 430, 267, 291, 14, 694, 9167, 847, 413, 267, 702, 8, 277, 14, 694, 9167, 2695, 291, 14, 988, 9167, 9, 339, 347, 2150, 3567, 3900, 8, 277, 12, 536, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 307, 354, 275, 536, 14, 1294, 7825, 267, 366, 354, 275, 307, 354, 59, 552, 8, 31383, 9, 446, 413, 61, 267, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 694, 1296, 2298, 288, 340, 291, 14, 694, 1296, 59, 73, 1527, 16, 61, 508, 366, 354, 26, 355, 291, 14, 694, 1296, 14, 1935, 8, 73, 9, 355, 291, 14, 694, 9167, 4862, 413, 355, 372, 267, 702, 8, 17, 508, 378, 9, 339, 347, 2935, 3900, 7965, 8, 277, 12, 536, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 367, 366, 315, 291, 14, 694, 1296, 26, 288, 340, 536, 508, 366, 59, 16, 2189, 355, 372, 715, 267, 372, 756, 339, 347, 2867, 8, 277, 304, 267, 702, 8, 277, 14, 10386, 1137, 283, 4624, 358, 267, 340, 291, 14, 10386, 508, 283, 68, 356, 288, 327, 1104, 367, 1454, 6308, 12, 6308, 3287, 2348, 288, 702, 8, 277, 14, 694, 9167, 508, 499, 9, 288, 291, 14, 694, 9167, 275, 378, 267, 291, 14, 576, 221, 275, 2125, 267, 291, 14, 10386, 275, 283, 4624, 7, 199, 199, 533, 25115, 26, 272, 347, 636, 826, 721, 277, 12, 8570, 534, 4624, 297, 5552, 4022, 17, 12, 2984, 31847, 29, 17, 304, 267, 291, 14, 409, 2422, 8, 10386, 12, 5552, 12, 2984, 31847, 9, 339, 347, 663, 2422, 8, 277, 12, 8570, 12, 5552, 12, 2984, 31847, 304, 267, 702, 8, 10386, 508, 283, 68, 7, 503, 8570, 508, 283, 70, 7, 503, 8570, 508, 283, 4624, 358, 267, 291, 14, 10386, 221, 275, 8570, 267, 291, 14, 2697, 257, 275, 5552, 267, 291, 14, 1121, 31847, 275, 2984, 31847, 339, 347, 12864, 2891, 31847, 8, 277, 304, 267, 291, 14, 1121, 31847, 847, 413, 339, 347, 9700, 2891, 31847, 8, 277, 304, 267, 291, 14, 1121, 31847, 4862, 413, 339, 347, 664, 2891, 31847, 8, 277, 304, 267, 372, 291, 14, 1121, 31847, 339, 347, 663, 804, 8, 277, 12, 8570, 304, 267, 702, 8, 10386, 508, 283, 68, 7, 503, 8570, 508, 283, 70, 7, 503, 8570, 508, 283, 4624, 358 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 2196, 199, 504, 8691, 492, 13491, 199, 199, 5287, 275, 756, 199, 199, 318, 366, 1361, 8, 495, 304, 272, 340, 10990, 26, 267, 870, 620, 199, 199, 1361, 16452, 420, 275, 715, 199, 1361, 2223, 259, 275, 715, 199, 1361, 12776, 259, 275, 715, 199, 199, 533, 20810, 26, 272, 347, 636, 826, 721, 277, 12, 1568, 304, 267, 291, 14, 890, 275, 1568, 267, 291, 14, 66, 1130, 275, 942, 267, 367, 1967, 315, 1425, 8, 890, 304, 288, 291, 14, 66, 1130, 14, 740, 8, 16, 9, 339, 347, 29447, 8, 277, 304, 267, 367, 1967, 315, 1425, 8, 552, 8, 277, 14, 66, 1130, 2298, 288, 340, 291, 14, 66, 1130, 59, 1507, 61, 508, 378, 26, 355, 291, 14, 66, 1130, 59, 1507, 61, 275, 413, 355, 372, 1967, 267, 372, 446, 17, 339, 347, 2867, 8, 277, 12, 1967, 304, 267, 702, 8, 277, 14, 66, 1130, 59, 1507, 61, 508, 413, 9, 267, 291, 14, 66, 1130, 59, 1507, 61, 275, 378, 339, 347, 2216, 2439, 13340, 8, 277, 12, 1967, 304, 267, 702, 8, 277, 14, 66, 1130, 59, 1507, 61, 508, 378, 9, 267, 291, 14, 66, 1130, 59, 1507, 61, 275, 413, 339, 347, 5461, 8, 277, 304, 267, 308, 275, 2125, 267, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 66, 1130, 2298, 288, 308, 847, 620, 8, 277, 14, 66, 1130, 59, 73, 566, 267, 372, 308, 199, 199, 533, 1853, 26, 272, 347, 636, 826, 721, 277, 12, 8570, 304, 267, 702, 8, 10386, 508, 283, 68, 7, 503, 8570, 508, 283, 70, 7, 503, 8570, 508, 283, 4624, 358, 267, 291, 14, 10386, 275, 8570, 267, 327, 1454, 367, 6602, 12, 7684, 282, 5516, 1325, 3963, 1704, 470, 267, 291, 14, 694, 9167, 275, 378, 267, 291, 14, 988, 9167, 275, 4337, 267, 291, 14, 694, 1296, 275, 942, 267, 291, 14, 576, 259, 275, 2125, 339, 347, 5461, 8, 277, 304, 267, 340, 291, 14, 10386, 508, 283, 4624, 356, 288, 372, 6730, 6616, 267, 916, 291, 14, 10386, 508, 283, 68, 356, 288, 4819, 275, 2125, 288, 367, 366, 315, 291, 14, 694, 1296, 26, 355, 327, 366, 365, 402, 314, 1824, 661, 354, 297, 315, 453, 9, 355, 3974, 275, 25676, 83, 8719, 83, 3171, 450, 334, 68, 59, 16, 467, 366, 59, 17, 566, 355, 340, 4819, 508, 8061, 490, 4819, 275, 3974, 355, 587, 26, 490, 4819, 847, 283, 283, 435, 3974, 288, 372, 22640, 11, 1195, 11, 418, 7, 288, 327, 372, 1543, 83, 7, 450, 291, 14, 694, 1296, 267, 587, 26, 288, 372, 30423, 83, 6616, 450, 291, 14, 576, 339, 347, 663, 804, 8, 277, 12, 8570, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 4624, 358, 267, 291, 14, 10386, 275, 8570, 339, 347, 1050, 1451, 8, 277, 12, 666, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 70, 358, 267, 291, 14, 576, 275, 666, 339, 347, 664, 5667, 17816, 8, 277, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 372, 291, 14, 694, 9167, 339, 347, 664, 10146, 17816, 8, 277, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 372, 291, 14, 988, 9167, 446, 291, 14, 694, 9167, 339, 347, 664, 3900, 8, 277, 12, 1967, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 702, 8, 1507, 665, 291, 14, 694, 9167, 9, 267, 372, 291, 14, 694, 1296, 59, 1507, 61, 339, 347, 1050, 3567, 3900, 8, 277, 12, 536, 12, 315, 453, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 291, 14, 694, 1296, 14, 740, 1332, 354, 12, 315, 453, 430, 267, 291, 14, 694, 9167, 847, 413, 267, 702, 8, 277, 14, 694, 9167, 2695, 291, 14, 988, 9167, 9, 339, 347, 2150, 3567, 3900, 8, 277, 12, 536, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 307, 354, 275, 536, 14, 1294, 7825, 267, 366, 354, 275, 307, 354, 59, 552, 8, 31383, 9, 446, 413, 61, 267, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 694, 1296, 2298, 288, 340, 291, 14, 694, 1296, 59, 73, 1527, 16, 61, 508, 366, 354, 26, 355, 291, 14, 694, 1296, 14, 1935, 8, 73, 9, 355, 291, 14, 694, 9167, 4862, 413, 355, 372, 267, 702, 8, 17, 508, 378, 9, 339, 347, 2935, 3900, 7965, 8, 277, 12, 536, 304, 267, 702, 8, 277, 14, 10386, 508, 283, 68, 358, 267, 367, 366, 315, 291, 14, 694, 1296, 26, 288, 340, 536, 508, 366, 59, 16, 2189, 355, 372, 715, 267, 372, 756, 339, 347, 2867, 8, 277, 304, 267, 702, 8, 277, 14, 10386, 1137, 283, 4624, 358, 267, 340, 291, 14, 10386, 508, 283, 68, 356, 288, 327, 1104, 367, 1454, 6308, 12, 6308, 3287, 2348, 288, 702, 8, 277, 14, 694, 9167, 508, 499, 9, 288, 291, 14, 694, 9167, 275, 378, 267, 291, 14, 576, 221, 275, 2125, 267, 291, 14, 10386, 275, 283, 4624, 7, 199, 199, 533, 25115, 26, 272, 347, 636, 826, 721, 277, 12, 8570, 534, 4624, 297, 5552, 4022, 17, 12, 2984, 31847, 29, 17, 304, 267, 291, 14, 409, 2422, 8, 10386, 12, 5552, 12, 2984, 31847, 9, 339, 347, 663, 2422, 8, 277, 12, 8570, 12, 5552, 12, 2984, 31847, 304, 267, 702, 8, 10386, 508, 283, 68, 7, 503, 8570, 508, 283, 70, 7, 503, 8570, 508, 283, 4624, 358, 267, 291, 14, 10386, 221, 275, 8570, 267, 291, 14, 2697, 257, 275, 5552, 267, 291, 14, 1121, 31847, 275, 2984, 31847, 339, 347, 12864, 2891, 31847, 8, 277, 304, 267, 291, 14, 1121, 31847, 847, 413, 339, 347, 9700, 2891, 31847, 8, 277, 304, 267, 291, 14, 1121, 31847, 4862, 413, 339, 347, 664, 2891, 31847, 8, 277, 304, 267, 372, 291, 14, 1121, 31847, 339, 347, 663, 804, 8, 277, 12, 8570, 304, 267, 702, 8, 10386, 508, 283, 68, 7, 503, 8570, 508, 283, 70, 7, 503, 8570, 508, 283, 4624, 358, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
WhittKinley/aima-python
submissions/Fritz/c4-11-28/ConnectFourText.py
29
1607
from ConnectFour import ConnectFour class ConnectFourText(ConnectFour): def current(self): print(self.players[self.first_player]) def drop(self, column): ConnectFour.drop(self, column) print(self) if self.game_over != False: print('Game has ended.') return def __print__(self): s = ' ' + ''.join([str(i + 1) + ' ' for i in range(self.size['c'])]) + '\n' for r1 in range(self.size['r']): r = self.size['r'] - r1 - 1 s += '|' for c in range(self.size['c']): if len(self.grid[c]) > r: s += self.grid[c][r] else: s += ' ' s += '|' s += '\n' s += '+' + (2 * self.size['c'] - 1) * '-' + '+\n' if self.game_over == 'win': s += 'Player ' + self.players[self.first_player] + ' wins!' elif self.game_over == 'draw': s += 'DRAW!' else: s += 'Turn: ' + self.players[self.first_player] return s def __repr__(self): return self.__print__(); def play(self): # print('HOW TO PLAY:\nSelect a number of column (1-' + str( # self.size['c']) + ') and pass the keyboard to your opponent.\n') print(self) valid_columns = list(map(str, range(1, self.size['c'] + 1))) while self.game_over == False: c = input('Select a column: ') print() if c in valid_columns: self.drop(int(c) - 1) # print('I hope you enjoyed it!')
mit
[ 504, 15175, 24766, 492, 15175, 24766, 421, 199, 533, 15175, 24766, 1872, 8, 8631, 24766, 304, 272, 347, 1453, 8, 277, 304, 267, 870, 8, 277, 14, 20716, 59, 277, 14, 2246, 63, 6147, 566, 339, 347, 5978, 8, 277, 12, 2763, 304, 267, 15175, 24766, 14, 4824, 8, 277, 12, 2763, 9, 267, 870, 8, 277, 9, 267, 340, 291, 14, 5097, 63, 1883, 1137, 756, 26, 288, 870, 360, 11454, 965, 22480, 2659, 267, 372, 339, 347, 636, 1361, 721, 277, 304, 267, 308, 275, 283, 283, 435, 6522, 904, 779, 495, 8, 73, 435, 413, 9, 435, 283, 283, 367, 284, 315, 1425, 8, 277, 14, 890, 459, 67, 31161, 435, 1557, 78, 7, 267, 367, 519, 17, 315, 1425, 8, 277, 14, 890, 459, 82, 9090, 288, 519, 275, 291, 14, 890, 459, 82, 418, 446, 519, 17, 446, 413, 288, 308, 847, 24628, 288, 367, 286, 315, 1425, 8, 277, 14, 890, 459, 67, 9090, 355, 340, 822, 8, 277, 14, 3825, 59, 67, 566, 690, 519, 26, 490, 308, 847, 291, 14, 3825, 59, 67, 1527, 82, 61, 355, 587, 26, 490, 308, 847, 283, 283, 355, 308, 847, 24628, 288, 308, 847, 1557, 78, 7, 267, 308, 847, 20246, 435, 334, 18, 627, 291, 14, 890, 459, 67, 418, 446, 413, 9, 627, 10791, 435, 6681, 60, 78, 7, 267, 340, 291, 14, 5097, 63, 1883, 508, 283, 2676, 356, 288, 308, 847, 283, 10921, 283, 435, 291, 14, 20716, 59, 277, 14, 2246, 63, 6147, 61, 435, 283, 29431, 11213, 267, 916, 291, 14, 5097, 63, 1883, 508, 283, 5485, 356, 288, 308, 847, 283, 12118, 11213, 267, 587, 26, 288, 308, 847, 283, 16838, 26, 283, 435, 291, 14, 20716, 59, 277, 14, 2246, 63, 6147, 61, 267, 372, 308, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 855, 1361, 4533, 27, 339, 347, 5232, 8, 277, 304, 2126, 327, 870, 360, 16210, 2296, 10092, 3448, 3427, 78, 5446, 282, 1329, 402, 2763, 334, 17, 15668, 435, 620, 8, 2126, 327, 258, 291, 14, 890, 459, 67, 1105, 435, 5320, 436, 986, 314, 18716, 370, 2195, 1687, 10339, 3134, 78, 358, 267, 870, 8, 277, 9, 267, 1686, 63, 3406, 275, 769, 8, 1130, 8, 495, 12, 1425, 8, 17, 12, 291, 14, 890, 459, 67, 418, 435, 413, 1724, 267, 1830, 291, 14, 5097, 63, 1883, 508, 756, 26, 288, 286, 275, 1324, 360, 5446, 282, 2763, 26, 5320, 288, 870, 342, 288, 340, 286, 315, 1686, 63, 3406, 26, 355, 291, 14, 4824, 8, 442, 8, 67, 9, 446, 413, 9, 2126, 327, 870, 360, 41, 3661, 1265, 655, 26729, 379, 652, 10916, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 15175, 24766, 492, 15175, 24766, 421, 199, 533, 15175, 24766, 1872, 8, 8631, 24766, 304, 272, 347, 1453, 8, 277, 304, 267, 870, 8, 277, 14, 20716, 59, 277, 14, 2246, 63, 6147, 566, 339, 347, 5978, 8, 277, 12, 2763, 304, 267, 15175, 24766, 14, 4824, 8, 277, 12, 2763, 9, 267, 870, 8, 277, 9, 267, 340, 291, 14, 5097, 63, 1883, 1137, 756, 26, 288, 870, 360, 11454, 965, 22480, 2659, 267, 372, 339, 347, 636, 1361, 721, 277, 304, 267, 308, 275, 283, 283, 435, 6522, 904, 779, 495, 8, 73, 435, 413, 9, 435, 283, 283, 367, 284, 315, 1425, 8, 277, 14, 890, 459, 67, 31161, 435, 1557, 78, 7, 267, 367, 519, 17, 315, 1425, 8, 277, 14, 890, 459, 82, 9090, 288, 519, 275, 291, 14, 890, 459, 82, 418, 446, 519, 17, 446, 413, 288, 308, 847, 24628, 288, 367, 286, 315, 1425, 8, 277, 14, 890, 459, 67, 9090, 355, 340, 822, 8, 277, 14, 3825, 59, 67, 566, 690, 519, 26, 490, 308, 847, 291, 14, 3825, 59, 67, 1527, 82, 61, 355, 587, 26, 490, 308, 847, 283, 283, 355, 308, 847, 24628, 288, 308, 847, 1557, 78, 7, 267, 308, 847, 20246, 435, 334, 18, 627, 291, 14, 890, 459, 67, 418, 446, 413, 9, 627, 10791, 435, 6681, 60, 78, 7, 267, 340, 291, 14, 5097, 63, 1883, 508, 283, 2676, 356, 288, 308, 847, 283, 10921, 283, 435, 291, 14, 20716, 59, 277, 14, 2246, 63, 6147, 61, 435, 283, 29431, 11213, 267, 916, 291, 14, 5097, 63, 1883, 508, 283, 5485, 356, 288, 308, 847, 283, 12118, 11213, 267, 587, 26, 288, 308, 847, 283, 16838, 26, 283, 435, 291, 14, 20716, 59, 277, 14, 2246, 63, 6147, 61, 267, 372, 308, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 855, 1361, 4533, 27, 339, 347, 5232, 8, 277, 304, 2126, 327, 870, 360, 16210, 2296, 10092, 3448, 3427, 78, 5446, 282, 1329, 402, 2763, 334, 17, 15668, 435, 620, 8, 2126, 327, 258, 291, 14, 890, 459, 67, 1105, 435, 5320, 436, 986, 314, 18716, 370, 2195, 1687, 10339, 3134, 78, 358, 267, 870, 8, 277, 9, 267, 1686, 63, 3406, 275, 769, 8, 1130, 8, 495, 12, 1425, 8, 17, 12, 291, 14, 890, 459, 67, 418, 435, 413, 1724, 267, 1830, 291, 14, 5097, 63, 1883, 508, 756, 26, 288, 286, 275, 1324, 360, 5446, 282, 2763, 26, 5320, 288, 870, 342, 288, 340, 286, 315, 1686, 63, 3406, 26, 355, 291, 14, 4824, 8, 442, 8, 67, 9, 446, 413, 9, 2126, 327, 870, 360, 41, 3661, 1265, 655, 26729, 379, 652, 10916, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
notriddle/servo
tests/wpt/web-platform-tests/tools/pywebsocket/test/testdata/handlers/sub/plain_wsh.py
499
1789
# Copyright 2009, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. def web_socket_do_extra_handshake(request): pass def web_socket_transfer_data(request): request.connection.write('sub/plain_wsh.py is called for %s, %s' % (request.ws_resource, request.ws_protocol)) # vi:sts=4 sw=4 et
mpl-2.0
[ 3, 1898, 8937, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 318, 3330, 63, 3450, 63, 1117, 63, 2911, 63, 11913, 8, 1069, 304, 272, 986, 421, 199, 318, 3330, 63, 3450, 63, 9609, 63, 576, 8, 1069, 304, 272, 1056, 14, 2105, 14, 952, 360, 954, 15, 6104, 63, 87, 609, 14, 647, 365, 2797, 367, 450, 83, 12, 450, 83, 7, 450, 2490, 334, 1069, 14, 3569, 63, 1927, 12, 1056, 14, 3569, 63, 3922, 430, 421, 199, 3, 1321, 26, 10329, 29, 20, 5584, 29, 20, 10844, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 8937, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 318, 3330, 63, 3450, 63, 1117, 63, 2911, 63, 11913, 8, 1069, 304, 272, 986, 421, 199, 318, 3330, 63, 3450, 63, 9609, 63, 576, 8, 1069, 304, 272, 1056, 14, 2105, 14, 952, 360, 954, 15, 6104, 63, 87, 609, 14, 647, 365, 2797, 367, 450, 83, 12, 450, 83, 7, 450, 2490, 334, 1069, 14, 3569, 63, 1927, 12, 1056, 14, 3569, 63, 3922, 430, 421, 199, 3, 1321, 26, 10329, 29, 20, 5584, 29, 20, 10844, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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, 0, 0, 0, 0, 0 ]
fga-gpp-mds/2017.2-Receituario-Medico
medical_prescription/exam/test/test_view_list_custom_exam.py
1
2151
# Django imports from django.test import TestCase from django.test.client import RequestFactory from django.contrib.auth.models import AnonymousUser from django.core.exceptions import PermissionDenied # Local Django imports from exam.views import ListCustomExams from user.models import User, Patient, HealthProfessional class ListExamsTest(TestCase): def setUp(self): self.factory = RequestFactory() self.health_professional = HealthProfessional.objects.create_user(email='doctor@doctor.com', password='senha12') self.patient = Patient.objects.create_user(email='patient@patient.com', password='senha12', CEP='72850735', UF='DF', city='Brasília', neighborhood='Asa sul', complement='Bloco 2 QD 701') self.user = User.objects.create_user(email='user@user.com', password='senha12') def teste_exam_get_exam_without_login(self): request = self.factory.get('/exam/list_custom_exams/') request.user = AnonymousUser() response = ListCustomExams.as_view()(request) self.assertEqual(response.status_code, 302) def teste_exam_get_exam_with_patient(self): request = self.factory.get('/exam/list_custom_exams/') request.user = self.patient with self.assertRaises(PermissionDenied): ListCustomExams.as_view()(request) def teste_exam_get_exam_with_user(self): request = self.factory.get('/exam/list_custom_exams/') request.user = self.user with self.assertRaises(PermissionDenied): ListCustomExams.as_view()(request) def teste_exam_get_exam_with_health_professional(self): request = self.factory.get('/exam/list_custom_exams/') request.user = self.health_professional response = ListCustomExams.as_view()(request) self.assertEqual(response.status_code, 200)
mit
[ 3, 5634, 8925, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 29952, 199, 504, 1639, 14, 1018, 14, 3924, 492, 23724, 199, 199, 3, 10111, 5634, 8925, 199, 504, 15735, 14, 4196, 492, 3820, 7223, 920, 19470, 199, 504, 922, 14, 992, 492, 2876, 12, 510, 31078, 12, 5311, 6130, 919, 70, 28661, 421, 199, 533, 3820, 920, 19470, 774, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 3702, 275, 18638, 342, 267, 291, 14, 9665, 63, 14979, 28661, 275, 5311, 6130, 919, 70, 28661, 14, 1462, 14, 981, 63, 751, 8, 2123, 534, 1117, 630, 32, 1117, 630, 14, 957, 297, 2505, 534, 2464, 2411, 713, 358, 267, 291, 14, 25067, 275, 510, 31078, 14, 1462, 14, 981, 63, 751, 8, 2123, 534, 25067, 32, 25067, 14, 957, 297, 8962, 2505, 534, 2464, 2411, 713, 297, 8962, 445, 6102, 534, 32725, 13583, 1276, 297, 8962, 738, 38, 534, 3888, 297, 8962, 14492, 534, 34, 6360, 13676, 21796, 297, 8962, 15503, 10422, 534, 33, 2231, 308, 348, 297, 8962, 2831, 434, 534, 34, 320, 331, 499, 1413, 36, 1520, 614, 358, 267, 291, 14, 751, 275, 2876, 14, 1462, 14, 981, 63, 751, 8, 2123, 534, 751, 32, 751, 14, 957, 297, 2505, 534, 2464, 2411, 713, 358, 339, 347, 221, 744, 266, 63, 15425, 63, 362, 63, 15425, 63, 7395, 63, 2886, 8, 277, 304, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 15425, 15, 513, 63, 4229, 63, 15425, 83, 6217, 267, 1056, 14, 751, 275, 29952, 342, 398, 1177, 275, 3820, 7223, 920, 19470, 14, 305, 63, 1345, 24851, 1069, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 339, 347, 221, 744, 266, 63, 15425, 63, 362, 63, 15425, 63, 1045, 63, 25067, 8, 277, 304, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 15425, 15, 513, 63, 4229, 63, 15425, 83, 6217, 267, 1056, 14, 751, 275, 291, 14, 25067, 398, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 3820, 7223, 920, 19470, 14, 305, 63, 1345, 24851, 1069, 9, 339, 347, 221, 744, 266, 63, 15425, 63, 362, 63, 15425, 63, 1045, 63, 751, 8, 277, 304, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 15425, 15, 513, 63, 4229, 63, 15425, 83, 6217, 267, 1056, 14, 751, 275, 291, 14, 751, 398, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 3820, 7223, 920, 19470, 14, 305, 63, 1345, 24851, 1069, 9, 339, 347, 221, 744, 266, 63, 15425, 63, 362, 63, 15425, 63, 1045, 63, 9665, 63, 14979, 28661, 8, 277, 304, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 15425, 15, 513, 63, 4229, 63, 15425, 83, 6217, 267, 1056, 14, 751, 275, 291, 14, 9665, 63, 14979, 28661, 398, 1177, 275, 3820, 7223, 920, 19470, 14, 305, 63, 1345, 24851, 1069, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 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 ]
[ 5634, 8925, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 29952, 199, 504, 1639, 14, 1018, 14, 3924, 492, 23724, 199, 199, 3, 10111, 5634, 8925, 199, 504, 15735, 14, 4196, 492, 3820, 7223, 920, 19470, 199, 504, 922, 14, 992, 492, 2876, 12, 510, 31078, 12, 5311, 6130, 919, 70, 28661, 421, 199, 533, 3820, 920, 19470, 774, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 3702, 275, 18638, 342, 267, 291, 14, 9665, 63, 14979, 28661, 275, 5311, 6130, 919, 70, 28661, 14, 1462, 14, 981, 63, 751, 8, 2123, 534, 1117, 630, 32, 1117, 630, 14, 957, 297, 2505, 534, 2464, 2411, 713, 358, 267, 291, 14, 25067, 275, 510, 31078, 14, 1462, 14, 981, 63, 751, 8, 2123, 534, 25067, 32, 25067, 14, 957, 297, 8962, 2505, 534, 2464, 2411, 713, 297, 8962, 445, 6102, 534, 32725, 13583, 1276, 297, 8962, 738, 38, 534, 3888, 297, 8962, 14492, 534, 34, 6360, 13676, 21796, 297, 8962, 15503, 10422, 534, 33, 2231, 308, 348, 297, 8962, 2831, 434, 534, 34, 320, 331, 499, 1413, 36, 1520, 614, 358, 267, 291, 14, 751, 275, 2876, 14, 1462, 14, 981, 63, 751, 8, 2123, 534, 751, 32, 751, 14, 957, 297, 2505, 534, 2464, 2411, 713, 358, 339, 347, 221, 744, 266, 63, 15425, 63, 362, 63, 15425, 63, 7395, 63, 2886, 8, 277, 304, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 15425, 15, 513, 63, 4229, 63, 15425, 83, 6217, 267, 1056, 14, 751, 275, 29952, 342, 398, 1177, 275, 3820, 7223, 920, 19470, 14, 305, 63, 1345, 24851, 1069, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 339, 347, 221, 744, 266, 63, 15425, 63, 362, 63, 15425, 63, 1045, 63, 25067, 8, 277, 304, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 15425, 15, 513, 63, 4229, 63, 15425, 83, 6217, 267, 1056, 14, 751, 275, 291, 14, 25067, 398, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 3820, 7223, 920, 19470, 14, 305, 63, 1345, 24851, 1069, 9, 339, 347, 221, 744, 266, 63, 15425, 63, 362, 63, 15425, 63, 1045, 63, 751, 8, 277, 304, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 15425, 15, 513, 63, 4229, 63, 15425, 83, 6217, 267, 1056, 14, 751, 275, 291, 14, 751, 398, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 3820, 7223, 920, 19470, 14, 305, 63, 1345, 24851, 1069, 9, 339, 347, 221, 744, 266, 63, 15425, 63, 362, 63, 15425, 63, 1045, 63, 9665, 63, 14979, 28661, 8, 277, 304, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 15425, 15, 513, 63, 4229, 63, 15425, 83, 6217, 267, 1056, 14, 751, 275, 291, 14, 9665, 63, 14979, 28661, 398, 1177, 275, 3820, 7223, 920, 19470, 14, 305, 63, 1345, 24851, 1069, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 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, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tfrancart/schemaorg
lib/html5lib/tests/test_treewalkers.py
72
12240
import os import sys import StringIO import unittest import warnings warnings.simplefilter("error") from support import html5lib_test_files, TestData, convertExpected from html5lib import html5parser, treewalkers, treebuilders, constants from html5lib.filters.lint import Filter as LintFilter, LintError def PullDOMAdapter(node): from xml.dom import Node from xml.dom.pulldom import START_ELEMENT, END_ELEMENT, COMMENT, CHARACTERS if node.nodeType in (Node.DOCUMENT_NODE, Node.DOCUMENT_FRAGMENT_NODE): for childNode in node.childNodes: for event in PullDOMAdapter(childNode): yield event elif node.nodeType == Node.DOCUMENT_TYPE_NODE: raise NotImplementedError("DOCTYPE nodes are not supported by PullDOM") elif node.nodeType == Node.COMMENT_NODE: yield COMMENT, node elif node.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): yield CHARACTERS, node elif node.nodeType == Node.ELEMENT_NODE: yield START_ELEMENT, node for childNode in node.childNodes: for event in PullDOMAdapter(childNode): yield event yield END_ELEMENT, node else: raise NotImplementedError("Node type not supported: " + str(node.nodeType)) treeTypes = { "simpletree": {"builder": treebuilders.getTreeBuilder("simpletree"), "walker": treewalkers.getTreeWalker("simpletree")}, "DOM": {"builder": treebuilders.getTreeBuilder("dom"), "walker": treewalkers.getTreeWalker("dom")}, "PullDOM": {"builder": treebuilders.getTreeBuilder("dom"), "adapter": PullDOMAdapter, "walker": treewalkers.getTreeWalker("pulldom")}, } #Try whatever etree implementations are available from a list that are #"supposed" to work try: import xml.etree.ElementTree as ElementTree treeTypes['ElementTree'] = \ {"builder": treebuilders.getTreeBuilder("etree", ElementTree), "walker": treewalkers.getTreeWalker("etree", ElementTree)} except ImportError: try: import elementtree.ElementTree as ElementTree treeTypes['ElementTree'] = \ {"builder": treebuilders.getTreeBuilder("etree", ElementTree), "walker": treewalkers.getTreeWalker("etree", ElementTree)} except ImportError: pass try: import xml.etree.cElementTree as ElementTree treeTypes['cElementTree'] = \ {"builder": treebuilders.getTreeBuilder("etree", ElementTree), "walker": treewalkers.getTreeWalker("etree", ElementTree)} except ImportError: try: import cElementTree as ElementTree treeTypes['cElementTree'] = \ {"builder": treebuilders.getTreeBuilder("etree", ElementTree), "walker": treewalkers.getTreeWalker("etree", ElementTree)} except ImportError: pass try: import lxml.etree as ElementTree # treeTypes['lxml_as_etree'] = \ # {"builder": treebuilders.getTreeBuilder("etree", ElementTree), # "walker": treewalkers.getTreeWalker("etree", ElementTree)} treeTypes['lxml_native'] = \ {"builder": treebuilders.getTreeBuilder("lxml"), "walker": treewalkers.getTreeWalker("lxml")} except ImportError: pass try: import BeautifulSoup treeTypes["beautifulsoup"] = \ {"builder": treebuilders.getTreeBuilder("beautifulsoup"), "walker": treewalkers.getTreeWalker("beautifulsoup")} except ImportError: pass #Try whatever etree implementations are available from a list that are #"supposed" to work try: import pxdom treeTypes['pxdom'] = \ {"builder": treebuilders.getTreeBuilder("dom", pxdom), "walker": treewalkers.getTreeWalker("dom")} except ImportError: pass try: from genshi.core import QName, Attrs from genshi.core import START, END, TEXT, COMMENT, DOCTYPE def GenshiAdapter(tree): text = None for token in treewalkers.getTreeWalker("simpletree")(tree): type = token["type"] if type in ("Characters", "SpaceCharacters"): if text is None: text = token["data"] else: text += token["data"] elif text is not None: yield TEXT, text, (None, -1, -1) text = None if type in ("StartTag", "EmptyTag"): if token["namespace"]: name = u"{%s}%s" % (token["namespace"], token["name"]) else: name = token["name"] yield (START, (QName(name), Attrs([(QName(attr),value) for attr,value in token["data"]])), (None, -1, -1)) if type == "EmptyTag": type = "EndTag" if type == "EndTag": yield END, QName(token["name"]), (None, -1, -1) elif type == "Comment": yield COMMENT, token["data"], (None, -1, -1) elif type == "Doctype": yield DOCTYPE, (token["name"], token["publicId"], token["systemId"]), (None, -1, -1) else: pass # FIXME: What to do? if text is not None: yield TEXT, text, (None, -1, -1) #treeTypes["genshi"] = \ # {"builder": treebuilders.getTreeBuilder("simpletree"), # "adapter": GenshiAdapter, # "walker": treewalkers.getTreeWalker("genshi")} except ImportError: pass def concatenateCharacterTokens(tokens): charactersToken = None for token in tokens: type = token["type"] if type in ("Characters", "SpaceCharacters"): if charactersToken is None: charactersToken = {"type": "Characters", "data": token["data"]} else: charactersToken["data"] += token["data"] else: if charactersToken is not None: yield charactersToken charactersToken = None yield token if charactersToken is not None: yield charactersToken def convertTokens(tokens): output = [] indent = 0 for token in concatenateCharacterTokens(tokens): type = token["type"] if type in ("StartTag", "EmptyTag"): if (token["namespace"] and token["namespace"] != constants.namespaces["html"]): if token["namespace"] in constants.prefixes: name = constants.prefixes[token["namespace"]] else: name = token["namespace"] name += u" " + token["name"] else: name = token["name"] output.append(u"%s<%s>" % (" "*indent, name)) indent += 2 attrs = token["data"] if attrs: #TODO: Remove this if statement, attrs should always exist for (namespace,name),value in sorted(attrs.items()): if namespace: if namespace in constants.prefixes: outputname = constants.prefixes[namespace] else: outputname = namespace outputname += u" " + name else: outputname = name output.append(u"%s%s=\"%s\"" % (" "*indent, outputname, value)) if type == "EmptyTag": indent -= 2 elif type == "EndTag": indent -= 2 elif type == "Comment": output.append("%s<!-- %s -->" % (" "*indent, token["data"])) elif type == "Doctype": if token["name"]: if token["publicId"]: output.append("""%s<!DOCTYPE %s "%s" "%s">"""% (" "*indent, token["name"], token["publicId"], token["systemId"] and token["systemId"] or "")) elif token["systemId"]: output.append("""%s<!DOCTYPE %s "" "%s">"""% (" "*indent, token["name"], token["systemId"])) else: output.append("%s<!DOCTYPE %s>"%(" "*indent, token["name"])) else: output.append("%s<!DOCTYPE >" % (" "*indent,)) elif type in ("Characters", "SpaceCharacters"): output.append("%s\"%s\"" % (" "*indent, token["data"])) else: pass # TODO: what to do with errors? return u"\n".join(output) import re attrlist = re.compile(r"^(\s+)\w+=.*(\n\1\w+=.*)+",re.M) def sortattrs(x): lines = x.group(0).split("\n") lines.sort() return "\n".join(lines) class TokenTestCase(unittest.TestCase): def test_all_tokens(self): expected = [ {'data': {}, 'type': 'StartTag', 'namespace': u'http://www.w3.org/1999/xhtml', 'name': u'html'}, {'data': {}, 'type': 'StartTag', 'namespace': u'http://www.w3.org/1999/xhtml', 'name': u'head'}, {'data': {}, 'type': 'EndTag', 'namespace': u'http://www.w3.org/1999/xhtml', 'name': u'head'}, {'data': {}, 'type': 'StartTag', 'namespace': u'http://www.w3.org/1999/xhtml', 'name': u'body'}, {'data': u'a', 'type': 'Characters'}, {'data': {}, 'type': 'StartTag', 'namespace': u'http://www.w3.org/1999/xhtml', 'name': u'div'}, {'data': u'b', 'type': 'Characters'}, {'data': {}, 'type': 'EndTag', 'namespace': u'http://www.w3.org/1999/xhtml', 'name': u'div'}, {'data': u'c', 'type': 'Characters'}, {'data': {}, 'type': 'EndTag', 'namespace': u'http://www.w3.org/1999/xhtml', 'name': u'body'}, {'data': {}, 'type': 'EndTag', 'namespace': u'http://www.w3.org/1999/xhtml', 'name': u'html'} ] for treeName, treeCls in treeTypes.iteritems(): p = html5parser.HTMLParser(tree = treeCls["builder"]) document = p.parse("<html><head></head><body>a<div>b</div>c</body></html>") document = treeCls.get("adapter", lambda x: x)(document) output = treeCls["walker"](document) for expectedToken, outputToken in zip(expected, output): self.assertEquals(expectedToken, outputToken) def run_test(innerHTML, input, expected, errors, treeClass): try: p = html5parser.HTMLParser(tree = treeClass["builder"]) if innerHTML: document = p.parseFragment(StringIO.StringIO(input), innerHTML) else: document = p.parse(StringIO.StringIO(input)) except constants.DataLossWarning: #Ignore testcases we know we don't pass return document = treeClass.get("adapter", lambda x: x)(document) try: output = convertTokens(treeClass["walker"](document)) output = attrlist.sub(sortattrs, output) expected = attrlist.sub(sortattrs, convertExpected(expected)) assert expected == output, "\n".join([ "", "Input:", input, "", "Expected:", expected, "", "Received:", output ]) except NotImplementedError: pass # Amnesty for those that confess... def test_treewalker(): sys.stdout.write('Testing tree walkers '+ " ".join(treeTypes.keys()) + "\n") for treeName, treeCls in treeTypes.iteritems(): files = html5lib_test_files('tree-construction') for filename in files: testName = os.path.basename(filename).replace(".dat","") tests = TestData(filename, "data") for index, test in enumerate(tests): (input, errors, innerHTML, expected) = [test[key] for key in ("data", "errors", "document-fragment", "document")] errors = errors.split("\n") yield run_test, innerHTML, input, expected, errors, treeCls
apache-2.0
[ 646, 747, 199, 646, 984, 199, 646, 5228, 199, 646, 2882, 199, 646, 3598, 199, 199, 5451, 14, 18815, 480, 705, 531, 199, 199, 504, 2291, 492, 3517, 21, 773, 63, 396, 63, 1725, 12, 1379, 1451, 12, 3957, 6964, 199, 199, 504, 3517, 21, 773, 492, 3517, 21, 2087, 12, 20991, 546, 4878, 1192, 12, 3123, 20968, 12, 5262, 199, 504, 3517, 21, 773, 14, 4273, 14, 3854, 492, 9388, 465, 491, 442, 4131, 12, 491, 442, 547, 199, 199, 318, 27705, 1649, 2054, 68, 4185, 8, 932, 304, 272, 687, 2748, 14, 4556, 492, 5013, 272, 687, 2748, 14, 4556, 14, 9302, 4556, 492, 13910, 63, 12535, 12, 7729, 63, 12535, 12, 25071, 12, 8518, 3036, 3960, 339, 340, 1031, 14, 12412, 315, 334, 1716, 14, 7884, 63, 8063, 12, 5013, 14, 7884, 63, 28147, 63, 8063, 304, 267, 367, 29694, 315, 1031, 14, 10626, 26, 288, 367, 1566, 315, 27705, 1649, 2054, 68, 4185, 8, 1739, 1716, 304, 355, 1995, 1566, 339, 916, 1031, 14, 12412, 508, 5013, 14, 7884, 63, 2711, 63, 8063, 26, 267, 746, 4279, 480, 16556, 3380, 787, 440, 3748, 701, 27705, 10462, 531, 339, 916, 1031, 14, 12412, 508, 5013, 14, 10973, 63, 8063, 26, 267, 1995, 25071, 12, 1031, 339, 916, 1031, 14, 12412, 315, 334, 1716, 14, 3876, 63, 8063, 12, 5013, 14, 14049, 63, 13835, 63, 8063, 304, 267, 1995, 8518, 3036, 3960, 12, 1031, 339, 916, 1031, 14, 12412, 508, 5013, 14, 12535, 63, 8063, 26, 267, 1995, 13910, 63, 12535, 12, 1031, 267, 367, 29694, 315, 1031, 14, 10626, 26, 288, 367, 1566, 315, 27705, 1649, 2054, 68, 4185, 8, 1739, 1716, 304, 355, 1995, 1566, 267, 1995, 7729, 63, 12535, 12, 1031, 339, 587, 26, 267, 746, 4279, 480, 1716, 730, 440, 3748, 26, 298, 435, 620, 8, 932, 14, 12412, 430, 199, 199, 2350, 4100, 275, 469, 199, 2, 4129, 2350, 582, 221, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 4129, 2350, 1288, 355, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 4129, 2350, 25988, 199, 2, 10462, 582, 260, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 4556, 1288, 355, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 4556, 25988, 199, 2, 27318, 10462, 582, 258, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 4556, 1288, 355, 298, 10394, 582, 27705, 1649, 2054, 68, 4185, 12, 355, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9302, 4556, 25988, 199, 93, 199, 199, 3, 12357, 15685, 7559, 12591, 787, 2808, 687, 282, 769, 626, 787, 199, 23662, 1961, 5824, 2, 370, 1736, 199, 893, 26, 272, 492, 2748, 14, 9464, 14, 15325, 465, 13139, 272, 3123, 4100, 459, 15325, 418, 275, 971, 267, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 9464, 401, 13139, 395, 268, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9464, 401, 13139, 6769, 199, 2590, 3545, 26, 272, 862, 26, 267, 492, 1819, 2350, 14, 15325, 465, 13139, 267, 3123, 4100, 459, 15325, 418, 275, 971, 288, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 9464, 401, 13139, 395, 1467, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9464, 401, 13139, 6769, 272, 871, 3545, 26, 267, 986, 199, 199, 893, 26, 272, 492, 2748, 14, 9464, 14, 67, 15325, 465, 13139, 272, 3123, 4100, 459, 67, 15325, 418, 275, 971, 267, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 9464, 401, 13139, 395, 268, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9464, 401, 13139, 6769, 199, 2590, 3545, 26, 272, 862, 26, 267, 492, 286, 15325, 465, 13139, 267, 3123, 4100, 459, 67, 15325, 418, 275, 971, 288, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 9464, 401, 13139, 395, 1467, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9464, 401, 13139, 6769, 272, 871, 3545, 26, 267, 986, 199, 199, 893, 26, 272, 492, 14490, 14, 9464, 465, 13139, 199, 3, 259, 3123, 4100, 459, 22899, 63, 305, 63, 9464, 418, 275, 971, 199, 3, 263, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 9464, 401, 13139, 395, 199, 3, 260, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9464, 401, 13139, 6769, 272, 3123, 4100, 459, 22899, 63, 6106, 418, 275, 971, 267, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 22899, 1288, 268, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 22899, 531, 93, 199, 2590, 3545, 26, 272, 986, 199, 199, 893, 26, 272, 492, 17132, 272, 3123, 4100, 905, 1235, 25146, 9317, 937, 275, 971, 267, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 1235, 25146, 9317, 1288, 268, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 1235, 25146, 9317, 531, 93, 199, 2590, 3545, 26, 272, 986, 1362, 199, 3, 12357, 15685, 7559, 12591, 787, 2808, 687, 282, 769, 626, 787, 199, 23662, 1961, 5824, 2, 370, 1736, 199, 893, 26, 272, 492, 299, 2207, 676, 272, 3123, 4100, 459, 80, 2207, 676, 418, 275, 971, 267, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 4556, 401, 299, 2207, 676, 395, 268, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 4556, 531, 93, 199, 2590, 3545, 26, 272, 986, 199, 199, 893, 26, 272, 687, 3805, 19377, 14, 1018, 492, 1413, 985, 12, 20516, 83, 272, 687, 3805, 19377, 14, 1018, 492, 13910, 12, 7729, 12, 11951, 12, 25071, 12, 3506, 7540, 339, 347, 18870, 19377, 10200, 8, 2350, 304, 267, 1318, 275, 488, 267, 367, 1526, 315, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 4129, 2350, 25232, 2350, 304, 288, 730, 275, 1526, 905, 466, 937, 288, 340, 730, 315, 1689, 9272, 401, 298, 28501, 2349, 355, 340, 1318, 365, 488, 26, 490, 1318, 275, 1526, 905, 576, 937, 355, 587, 26, 490, 1318, 847 ]
[ 747, 199, 646, 984, 199, 646, 5228, 199, 646, 2882, 199, 646, 3598, 199, 199, 5451, 14, 18815, 480, 705, 531, 199, 199, 504, 2291, 492, 3517, 21, 773, 63, 396, 63, 1725, 12, 1379, 1451, 12, 3957, 6964, 199, 199, 504, 3517, 21, 773, 492, 3517, 21, 2087, 12, 20991, 546, 4878, 1192, 12, 3123, 20968, 12, 5262, 199, 504, 3517, 21, 773, 14, 4273, 14, 3854, 492, 9388, 465, 491, 442, 4131, 12, 491, 442, 547, 199, 199, 318, 27705, 1649, 2054, 68, 4185, 8, 932, 304, 272, 687, 2748, 14, 4556, 492, 5013, 272, 687, 2748, 14, 4556, 14, 9302, 4556, 492, 13910, 63, 12535, 12, 7729, 63, 12535, 12, 25071, 12, 8518, 3036, 3960, 339, 340, 1031, 14, 12412, 315, 334, 1716, 14, 7884, 63, 8063, 12, 5013, 14, 7884, 63, 28147, 63, 8063, 304, 267, 367, 29694, 315, 1031, 14, 10626, 26, 288, 367, 1566, 315, 27705, 1649, 2054, 68, 4185, 8, 1739, 1716, 304, 355, 1995, 1566, 339, 916, 1031, 14, 12412, 508, 5013, 14, 7884, 63, 2711, 63, 8063, 26, 267, 746, 4279, 480, 16556, 3380, 787, 440, 3748, 701, 27705, 10462, 531, 339, 916, 1031, 14, 12412, 508, 5013, 14, 10973, 63, 8063, 26, 267, 1995, 25071, 12, 1031, 339, 916, 1031, 14, 12412, 315, 334, 1716, 14, 3876, 63, 8063, 12, 5013, 14, 14049, 63, 13835, 63, 8063, 304, 267, 1995, 8518, 3036, 3960, 12, 1031, 339, 916, 1031, 14, 12412, 508, 5013, 14, 12535, 63, 8063, 26, 267, 1995, 13910, 63, 12535, 12, 1031, 267, 367, 29694, 315, 1031, 14, 10626, 26, 288, 367, 1566, 315, 27705, 1649, 2054, 68, 4185, 8, 1739, 1716, 304, 355, 1995, 1566, 267, 1995, 7729, 63, 12535, 12, 1031, 339, 587, 26, 267, 746, 4279, 480, 1716, 730, 440, 3748, 26, 298, 435, 620, 8, 932, 14, 12412, 430, 199, 199, 2350, 4100, 275, 469, 199, 2, 4129, 2350, 582, 221, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 4129, 2350, 1288, 355, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 4129, 2350, 25988, 199, 2, 10462, 582, 260, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 4556, 1288, 355, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 4556, 25988, 199, 2, 27318, 10462, 582, 258, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 4556, 1288, 355, 298, 10394, 582, 27705, 1649, 2054, 68, 4185, 12, 355, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9302, 4556, 25988, 199, 93, 199, 199, 3, 12357, 15685, 7559, 12591, 787, 2808, 687, 282, 769, 626, 787, 199, 23662, 1961, 5824, 2, 370, 1736, 199, 893, 26, 272, 492, 2748, 14, 9464, 14, 15325, 465, 13139, 272, 3123, 4100, 459, 15325, 418, 275, 971, 267, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 9464, 401, 13139, 395, 268, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9464, 401, 13139, 6769, 199, 2590, 3545, 26, 272, 862, 26, 267, 492, 1819, 2350, 14, 15325, 465, 13139, 267, 3123, 4100, 459, 15325, 418, 275, 971, 288, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 9464, 401, 13139, 395, 1467, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9464, 401, 13139, 6769, 272, 871, 3545, 26, 267, 986, 199, 199, 893, 26, 272, 492, 2748, 14, 9464, 14, 67, 15325, 465, 13139, 272, 3123, 4100, 459, 67, 15325, 418, 275, 971, 267, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 9464, 401, 13139, 395, 268, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9464, 401, 13139, 6769, 199, 2590, 3545, 26, 272, 862, 26, 267, 492, 286, 15325, 465, 13139, 267, 3123, 4100, 459, 67, 15325, 418, 275, 971, 288, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 9464, 401, 13139, 395, 1467, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9464, 401, 13139, 6769, 272, 871, 3545, 26, 267, 986, 199, 199, 893, 26, 272, 492, 14490, 14, 9464, 465, 13139, 199, 3, 259, 3123, 4100, 459, 22899, 63, 305, 63, 9464, 418, 275, 971, 199, 3, 263, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 9464, 401, 13139, 395, 199, 3, 260, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 9464, 401, 13139, 6769, 272, 3123, 4100, 459, 22899, 63, 6106, 418, 275, 971, 267, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 22899, 1288, 268, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 22899, 531, 93, 199, 2590, 3545, 26, 272, 986, 199, 199, 893, 26, 272, 492, 17132, 272, 3123, 4100, 905, 1235, 25146, 9317, 937, 275, 971, 267, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 1235, 25146, 9317, 1288, 268, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 1235, 25146, 9317, 531, 93, 199, 2590, 3545, 26, 272, 986, 1362, 199, 3, 12357, 15685, 7559, 12591, 787, 2808, 687, 282, 769, 626, 787, 199, 23662, 1961, 5824, 2, 370, 1736, 199, 893, 26, 272, 492, 299, 2207, 676, 272, 3123, 4100, 459, 80, 2207, 676, 418, 275, 971, 267, 2420, 5649, 582, 3123, 20968, 14, 362, 20437, 480, 4556, 401, 299, 2207, 676, 395, 268, 298, 87, 14976, 582, 221, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 4556, 531, 93, 199, 2590, 3545, 26, 272, 986, 199, 199, 893, 26, 272, 687, 3805, 19377, 14, 1018, 492, 1413, 985, 12, 20516, 83, 272, 687, 3805, 19377, 14, 1018, 492, 13910, 12, 7729, 12, 11951, 12, 25071, 12, 3506, 7540, 339, 347, 18870, 19377, 10200, 8, 2350, 304, 267, 1318, 275, 488, 267, 367, 1526, 315, 20991, 546, 4878, 1192, 14, 362, 3987, 26020, 480, 4129, 2350, 25232, 2350, 304, 288, 730, 275, 1526, 905, 466, 937, 288, 340, 730, 315, 1689, 9272, 401, 298, 28501, 2349, 355, 340, 1318, 365, 488, 26, 490, 1318, 275, 1526, 905, 576, 937, 355, 587, 26, 490, 1318, 847, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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_parameters_widget_layout.py
1
2158
# # Project: MXCuBE # https://github.com/mxcube # # This file is part of MXCuBE software. # # MXCuBE is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # MXCuBE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with MXCuBE. If not, see <http://www.gnu.org/licenses/>. from mxcubeqt.utils import qt_import __credits__ = ["MXCuBE collaboration"] __license__ = "LGPLv3+" class OptimisationParametersWidgetLayout(qt_import.QWidget): """ Widget is used to define characterisation optimization parameters like maximum resolution, aimed multiplicity, and etc. """ def __init__(self, parent=None, name=None, window_flags=0): qt_import.QWidget.__init__(self, parent, qt_import.Qt.WindowFlags(window_flags)) if not name: self.setObjectName("OptimisationParametersWidgetLayout") # Hardware objects ---------------------------------------------------- # Internal variables -------------------------------------------------- # Graphic elements ---------------------------------------------------- self.opt_param_widget = qt_import.load_ui_file( "optimization_parameters_widget_layout.ui" ) # Layout -------------------------------------------------------------- _main_vlayout = qt_import.QVBoxLayout(self) _main_vlayout.addWidget(self.opt_param_widget) _main_vlayout.setSpacing(0) _main_vlayout.setContentsMargins(0, 0, 0, 0) # Size policies ------------------------------------------------------- # Other --------------------------------------------------------------- self.setAttribute(qt_import.Qt.WA_WState_Polished)
lgpl-3.0
[ 3, 199, 3, 221, 7290, 26, 603, 20770, 85, 6773, 199, 3, 221, 4178, 921, 5031, 14, 957, 15, 77, 1812, 3375, 199, 3, 199, 3, 221, 961, 570, 365, 1777, 402, 603, 20770, 85, 6773, 2032, 14, 199, 3, 199, 3, 221, 603, 20770, 85, 6773, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 603, 20770, 85, 6773, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 221, 3180, 543, 603, 20770, 85, 6773, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 333, 1812, 3375, 8440, 14, 1208, 492, 19227, 63, 646, 199, 199, 363, 22461, 363, 275, 2097, 17401, 35, 85, 6773, 1048, 5561, 14496, 937, 199, 363, 1682, 363, 275, 298, 44, 28863, 19, 5207, 421, 199, 533, 9319, 280, 1292, 425, 5976, 3339, 4798, 8, 8440, 63, 646, 14, 23894, 304, 272, 408, 272, 16905, 365, 1202, 370, 5627, 2735, 266, 5719, 425, 13712, 2633, 2839, 5696, 272, 12401, 12, 282, 21538, 8897, 20976, 12, 436, 5423, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 12, 536, 29, 403, 12, 4353, 63, 2469, 29, 16, 304, 398, 19227, 63, 646, 14, 23894, 855, 826, 721, 277, 12, 1676, 12, 19227, 63, 646, 14, 4238, 14, 4301, 6381, 8, 3806, 63, 2469, 430, 398, 340, 440, 536, 26, 288, 291, 14, 10376, 480, 4619, 280, 1292, 425, 5976, 3339, 4798, 531, 398, 327, 22825, 1068, 2251, 9527, 375, 398, 327, 12624, 2860, 23271, 398, 327, 11513, 530, 4008, 9527, 375, 267, 291, 14, 2992, 63, 635, 63, 3440, 275, 19227, 63, 646, 14, 912, 63, 1907, 63, 493, 8, 288, 298, 31405, 63, 3214, 63, 3440, 63, 4209, 14, 1907, 2, 267, 776, 398, 327, 25604, 9527, 10965, 267, 485, 973, 63, 86, 4209, 275, 19227, 63, 646, 14, 25527, 18536, 8, 277, 9, 267, 485, 973, 63, 86, 4209, 14, 9475, 8, 277, 14, 2992, 63, 635, 63, 3440, 9, 267, 485, 973, 63, 86, 4209, 14, 409, 24052, 8, 16, 9, 267, 485, 973, 63, 86, 4209, 14, 409, 11383, 15182, 83, 8, 16, 12, 378, 12, 378, 12, 378, 9, 398, 327, 14579, 14118, 9527, 12797, 398, 327, 5439, 9527, 18964, 267, 291, 14, 17618, 8, 8440, 63, 646, 14, 4238, 14, 9004, 63, 55, 2223, 63, 1575, 1891, 379, 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 ]
[ 199, 3, 221, 7290, 26, 603, 20770, 85, 6773, 199, 3, 221, 4178, 921, 5031, 14, 957, 15, 77, 1812, 3375, 199, 3, 199, 3, 221, 961, 570, 365, 1777, 402, 603, 20770, 85, 6773, 2032, 14, 199, 3, 199, 3, 221, 603, 20770, 85, 6773, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 603, 20770, 85, 6773, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 221, 3180, 543, 603, 20770, 85, 6773, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 333, 1812, 3375, 8440, 14, 1208, 492, 19227, 63, 646, 199, 199, 363, 22461, 363, 275, 2097, 17401, 35, 85, 6773, 1048, 5561, 14496, 937, 199, 363, 1682, 363, 275, 298, 44, 28863, 19, 5207, 421, 199, 533, 9319, 280, 1292, 425, 5976, 3339, 4798, 8, 8440, 63, 646, 14, 23894, 304, 272, 408, 272, 16905, 365, 1202, 370, 5627, 2735, 266, 5719, 425, 13712, 2633, 2839, 5696, 272, 12401, 12, 282, 21538, 8897, 20976, 12, 436, 5423, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 12, 536, 29, 403, 12, 4353, 63, 2469, 29, 16, 304, 398, 19227, 63, 646, 14, 23894, 855, 826, 721, 277, 12, 1676, 12, 19227, 63, 646, 14, 4238, 14, 4301, 6381, 8, 3806, 63, 2469, 430, 398, 340, 440, 536, 26, 288, 291, 14, 10376, 480, 4619, 280, 1292, 425, 5976, 3339, 4798, 531, 398, 327, 22825, 1068, 2251, 9527, 375, 398, 327, 12624, 2860, 23271, 398, 327, 11513, 530, 4008, 9527, 375, 267, 291, 14, 2992, 63, 635, 63, 3440, 275, 19227, 63, 646, 14, 912, 63, 1907, 63, 493, 8, 288, 298, 31405, 63, 3214, 63, 3440, 63, 4209, 14, 1907, 2, 267, 776, 398, 327, 25604, 9527, 10965, 267, 485, 973, 63, 86, 4209, 275, 19227, 63, 646, 14, 25527, 18536, 8, 277, 9, 267, 485, 973, 63, 86, 4209, 14, 9475, 8, 277, 14, 2992, 63, 635, 63, 3440, 9, 267, 485, 973, 63, 86, 4209, 14, 409, 24052, 8, 16, 9, 267, 485, 973, 63, 86, 4209, 14, 409, 11383, 15182, 83, 8, 16, 12, 378, 12, 378, 12, 378, 9, 398, 327, 14579, 14118, 9527, 12797, 398, 327, 5439, 9527, 18964, 267, 291, 14, 17618, 8, 8440, 63, 646, 14, 4238, 14, 9004, 63, 55, 2223, 63, 1575, 1891, 379, 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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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 ]
hyperized/ansible
lib/ansible/modules/packaging/language/pear.py
54
7094
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2012, Afterburn <https://github.com/afterburn> # (c) 2013, Aaron Bull Schaefer <aaron@elasticdog.com> # (c) 2015, Jonathan Lestrelin <jonathan.lestrelin@gmail.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 = ''' --- module: pear short_description: Manage pear/pecl packages description: - Manage PHP packages with the pear package manager. version_added: 2.0 author: - Jonathan Lestrelin (@jle64) <jonathan.lestrelin@gmail.com> options: name: description: - Name of the package to install, upgrade, or remove. required: true state: description: - Desired state of the package. default: "present" choices: ["present", "absent", "latest"] executable: description: - Path to the pear executable version_added: "2.4" ''' EXAMPLES = ''' # Install pear package - pear: name: Net_URL2 state: present # Install pecl package - pear: name: pecl/json_post state: present # Upgrade package - pear: name: Net_URL2 state: latest # Remove packages - pear: name: Net_URL2,pecl/json_post state: absent ''' import os from ansible.module_utils._text import to_text from ansible.module_utils.basic import AnsibleModule def get_local_version(pear_output): """Take pear remoteinfo output and get the installed version""" lines = pear_output.split('\n') for line in lines: if 'Installed ' in line: installed = line.rsplit(None, 1)[-1].strip() if installed == '-': continue return installed return None def _get_pear_path(module): if module.params['executable'] and os.path.isfile(module.params['executable']): result = module.params['executable'] else: result = module.get_bin_path('pear', True, [module.params['executable']]) return result def get_repository_version(pear_output): """Take pear remote-info output and get the latest version""" lines = pear_output.split('\n') for line in lines: if 'Latest ' in line: return line.rsplit(None, 1)[-1].strip() return None def query_package(module, name, state="present"): """Query the package status in both the local system and the repository. Returns a boolean to indicate if the package is installed, and a second boolean to indicate if the package is up-to-date.""" if state == "present": lcmd = "%s info %s" % (_get_pear_path(module), name) lrc, lstdout, lstderr = module.run_command(lcmd, check_rc=False) if lrc != 0: # package is not installed locally return False, False rcmd = "%s remote-info %s" % (_get_pear_path(module), name) rrc, rstdout, rstderr = module.run_command(rcmd, check_rc=False) # get the version installed locally (if any) lversion = get_local_version(rstdout) # get the version in the repository rversion = get_repository_version(rstdout) if rrc == 0: # Return True to indicate that the package is installed locally, # and the result of the version number comparison # to determine if the package is up-to-date. return True, (lversion == rversion) return False, False def remove_packages(module, packages): remove_c = 0 # Using a for loop in case of error, we can report the package that failed for package in packages: # Query the package first, to see if we even need to remove installed, updated = query_package(module, package) if not installed: continue cmd = "%s uninstall %s" % (_get_pear_path(module), package) rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc != 0: module.fail_json(msg="failed to remove %s: %s" % (package, to_text(stdout + stderr))) remove_c += 1 if remove_c > 0: module.exit_json(changed=True, msg="removed %s package(s)" % remove_c) module.exit_json(changed=False, msg="package(s) already absent") def install_packages(module, state, packages): install_c = 0 for i, package in enumerate(packages): # if the package is installed and state == present # or state == latest and is up-to-date then skip installed, updated = query_package(module, package) if installed and (state == 'present' or (state == 'latest' and updated)): continue if state == 'present': command = 'install' if state == 'latest': command = 'upgrade' cmd = "%s %s %s" % (_get_pear_path(module), command, package) rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc != 0: module.fail_json(msg="failed to install %s: %s" % (package, to_text(stdout + stderr))) install_c += 1 if install_c > 0: module.exit_json(changed=True, msg="installed %s package(s)" % (install_c)) module.exit_json(changed=False, msg="package(s) already installed") def check_packages(module, packages, state): would_be_changed = [] for package in packages: installed, updated = query_package(module, package) if ((state in ["present", "latest"] and not installed) or (state == "absent" and installed) or (state == "latest" and not updated)): would_be_changed.append(package) if would_be_changed: if state == "absent": state = "removed" module.exit_json(changed=True, msg="%s package(s) would be %s" % ( len(would_be_changed), state)) else: module.exit_json(change=False, msg="package(s) already %s" % state) def main(): module = AnsibleModule( argument_spec=dict( name=dict(aliases=['pkg'], required=True), state=dict(default='present', choices=['present', 'installed', "latest", 'absent', 'removed']), executable=dict(default=None, required=False, type='path')), supports_check_mode=True) p = module.params # normalize the state parameter if p['state'] in ['present', 'installed']: p['state'] = 'present' elif p['state'] in ['absent', 'removed']: p['state'] = 'absent' if p['name']: pkgs = p['name'].split(',') pkg_files = [] for i, pkg in enumerate(pkgs): pkg_files.append(None) if module.check_mode: check_packages(module, pkgs, p['state']) if p['state'] in ['present', 'latest']: install_packages(module, p['state'], pkgs) elif p['state'] == 'absent': remove_packages(module, pkgs) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6029, 12, 12836, 30736, 665, 2859, 921, 5031, 14, 957, 15, 4399, 30736, 30, 199, 3, 334, 67, 9, 6171, 12, 437, 285, 265, 699, 979, 22985, 3624, 2412, 665, 65, 285, 265, 32, 15565, 13889, 14, 957, 30, 199, 3, 334, 67, 9, 6900, 12, 1603, 265, 1619, 290, 491, 597, 264, 472, 665, 74, 265, 1619, 290, 14, 14899, 264, 472, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 299, 2210, 199, 3612, 63, 1802, 26, 14944, 299, 2210, 15, 321, 429, 6117, 199, 1802, 26, 272, 446, 14944, 510, 18635, 6117, 543, 314, 299, 2210, 2559, 5256, 14, 199, 1023, 63, 3270, 26, 499, 14, 16, 199, 2502, 26, 272, 446, 1603, 265, 1619, 290, 491, 597, 264, 472, 8593, 74, 274, 772, 9, 665, 74, 265, 1619, 290, 14, 14899, 264, 472, 32, 6799, 14, 957, 30, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 2559, 370, 3907, 12, 10754, 12, 503, 2813, 14, 267, 1415, 26, 2549, 339, 1174, 26, 267, 1369, 26, 288, 446, 1487, 5381, 1174, 402, 314, 2559, 14, 267, 849, 26, 298, 1881, 2, 267, 3415, 26, 2097, 1881, 401, 298, 5575, 401, 298, 7410, 937, 272, 7286, 26, 489, 1369, 26, 267, 446, 6912, 370, 314, 299, 2210, 7286, 489, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 13276, 299, 2210, 2559, 199, 13, 299, 2210, 26, 272, 536, 26, 5365, 63, 2632, 18, 272, 1174, 26, 3451, 199, 199, 3, 13276, 4837, 429, 2559, 199, 13, 299, 2210, 26, 272, 536, 26, 4837, 429, 15, 1001, 63, 1932, 272, 1174, 26, 3451, 199, 199, 3, 4949, 4523, 2559, 199, 13, 299, 2210, 26, 272, 536, 26, 5365, 63, 2632, 18, 272, 1174, 26, 8839, 199, 199, 3, 5852, 6117, 199, 13, 299, 2210, 26, 272, 536, 26, 5365, 63, 2632, 18, 12, 321, 429, 15, 1001, 63, 1932, 272, 1174, 26, 9552, 199, 2344, 199, 199, 646, 747, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 505, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 318, 664, 63, 1832, 63, 1023, 8, 16343, 63, 1199, 304, 272, 408, 27200, 299, 2210, 3982, 815, 1072, 436, 664, 314, 4903, 1015, 624, 272, 2385, 275, 299, 2210, 63, 1199, 14, 1294, 2258, 78, 358, 272, 367, 1004, 315, 2385, 26, 267, 340, 283, 21268, 283, 315, 1004, 26, 288, 4903, 275, 1004, 14, 13490, 8, 403, 12, 413, 15786, 17, 1055, 1913, 342, 288, 340, 4903, 508, 20905, 355, 1980, 288, 372, 4903, 272, 372, 488, 421, 199, 318, 485, 362, 63, 16343, 63, 515, 8, 578, 304, 272, 340, 859, 14, 1162, 459, 5904, 418, 436, 747, 14, 515, 14, 6292, 8, 578, 14, 1162, 459, 5904, 9090, 267, 754, 275, 859, 14, 1162, 459, 5904, 418, 272, 587, 26, 267, 754, 275, 859, 14, 362, 63, 1393, 63, 515, 360, 16343, 297, 715, 12, 359, 578, 14, 1162, 459, 5904, 12121, 272, 372, 754, 421, 199, 318, 664, 63, 8421, 63, 1023, 8, 16343, 63, 1199, 304, 272, 408, 27200, 299, 2210, 3982, 13, 815, 1072, 436, 664, 314, 8839, 1015, 624, 272, 2385, 275, 299, 2210, 63, 1199, 14, 1294, 2258, 78, 358, 272, 367, 1004, 315, 2385, 26, 267, 340, 283, 31438, 283, 315, 1004, 26, 288, 372, 1004, 14, 13490, 8, 403, 12, 413, 15786, 17, 1055, 1913, 342, 272, 372, 488, 421, 199, 318, 1827, 63, 2491, 8, 578, 12, 536, 12, 1174, 628, 1881, 2349, 272, 408, 3227, 314, 2559, 2004, 315, 3865, 314, 2257, 2656, 436, 314, 7611, 14, 272, 1803, 282, 5046, 370, 6623, 340, 314, 2559, 365, 4903, 12, 272, 436, 282, 3499, 5046, 370, 6623, 340, 314, 2559, 365, 1536, 13, 475, 13, 602, 1041, 272, 340, 1174, 508, 298, 1881, 582, 267, 634, 1760, 275, 2071, 83, 2256, 450, 83, 2, 450, 6110, 362, 63, 16343, 63, 515, 8, 578, 395, 536, 9, 267, 634, 1195, 12, 634, 2703, 12, 634, 3083, 275, 859, 14, 1065, 63, 1531, 8, 76, 1760, 12, 1104, 63, 1195, 29, 797, 9, 267, 340, 634, 1195, 1137, 378, 26, 288, 327, 2559, 365, 440, 4903, 17738, 288, 372, 756, 12, 756, 398, 519, 1760, 275, 2071, 83, 3982, 13, 815, 450, 83, 2, 450, 6110, 362, 63, 16343, 63, 515, 8, 578, 395, 536, 9, 267, 519, 1195, 12, 519, 2703, 12, 519, 3083, 275, 859, 14, 1065, 63, 1531, 8, 1195, 1064, 12, 1104, 63, 1195, 29, 797, 9, 398, 327, 664, 314, 1015, 4903, 17738, 334, 692, 1263, 9, 267, 634, 1023, 275, 664, 63, 1832, 63, 1023, 8, 82, 2703, 9, 398, 327, 664, 314, 1015, 315, 314, 7611, 267, 519, 1023, 275, 664, 63, 8421, 63, 1023, 8, 82, 2703, 9, 398, 340, 519, 1195, 508, 378, 26, 288, 327, 1432, 715, 370, 6623, 626, 314, 2559, 365, 4903, 17738, 12, 288, 327, 436, 314, 754, 402, 314, 1015, 1329, 9132, 288, 327, 370, 6705, 340, 314, 2559, 365, 1536, 13, 475, 13, 602, 14, 288, 372, 715, 12, 334, 76, 1023, 508, 519, 1023, 9, 398, 372, 756, 12, 756, 421, 199, 318, 2813, 63, 5154, 8, 578, 12, 6117, 304, 272, 2813, 63, 67, 275, 378, 272, 327, 11719, 282, 367, 4438, 315, 1930, 402, 1125, 12, 781, 883, 3622, 314, 2559, 626, 3405, 272, 367, 2559, 315 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6029, 12, 12836, 30736, 665, 2859, 921, 5031, 14, 957, 15, 4399, 30736, 30, 199, 3, 334, 67, 9, 6171, 12, 437, 285, 265, 699, 979, 22985, 3624, 2412, 665, 65, 285, 265, 32, 15565, 13889, 14, 957, 30, 199, 3, 334, 67, 9, 6900, 12, 1603, 265, 1619, 290, 491, 597, 264, 472, 665, 74, 265, 1619, 290, 14, 14899, 264, 472, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 299, 2210, 199, 3612, 63, 1802, 26, 14944, 299, 2210, 15, 321, 429, 6117, 199, 1802, 26, 272, 446, 14944, 510, 18635, 6117, 543, 314, 299, 2210, 2559, 5256, 14, 199, 1023, 63, 3270, 26, 499, 14, 16, 199, 2502, 26, 272, 446, 1603, 265, 1619, 290, 491, 597, 264, 472, 8593, 74, 274, 772, 9, 665, 74, 265, 1619, 290, 14, 14899, 264, 472, 32, 6799, 14, 957, 30, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 2559, 370, 3907, 12, 10754, 12, 503, 2813, 14, 267, 1415, 26, 2549, 339, 1174, 26, 267, 1369, 26, 288, 446, 1487, 5381, 1174, 402, 314, 2559, 14, 267, 849, 26, 298, 1881, 2, 267, 3415, 26, 2097, 1881, 401, 298, 5575, 401, 298, 7410, 937, 272, 7286, 26, 489, 1369, 26, 267, 446, 6912, 370, 314, 299, 2210, 7286, 489, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 13276, 299, 2210, 2559, 199, 13, 299, 2210, 26, 272, 536, 26, 5365, 63, 2632, 18, 272, 1174, 26, 3451, 199, 199, 3, 13276, 4837, 429, 2559, 199, 13, 299, 2210, 26, 272, 536, 26, 4837, 429, 15, 1001, 63, 1932, 272, 1174, 26, 3451, 199, 199, 3, 4949, 4523, 2559, 199, 13, 299, 2210, 26, 272, 536, 26, 5365, 63, 2632, 18, 272, 1174, 26, 8839, 199, 199, 3, 5852, 6117, 199, 13, 299, 2210, 26, 272, 536, 26, 5365, 63, 2632, 18, 12, 321, 429, 15, 1001, 63, 1932, 272, 1174, 26, 9552, 199, 2344, 199, 199, 646, 747, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 505, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 318, 664, 63, 1832, 63, 1023, 8, 16343, 63, 1199, 304, 272, 408, 27200, 299, 2210, 3982, 815, 1072, 436, 664, 314, 4903, 1015, 624, 272, 2385, 275, 299, 2210, 63, 1199, 14, 1294, 2258, 78, 358, 272, 367, 1004, 315, 2385, 26, 267, 340, 283, 21268, 283, 315, 1004, 26, 288, 4903, 275, 1004, 14, 13490, 8, 403, 12, 413, 15786, 17, 1055, 1913, 342, 288, 340, 4903, 508, 20905, 355, 1980, 288, 372, 4903, 272, 372, 488, 421, 199, 318, 485, 362, 63, 16343, 63, 515, 8, 578, 304, 272, 340, 859, 14, 1162, 459, 5904, 418, 436, 747, 14, 515, 14, 6292, 8, 578, 14, 1162, 459, 5904, 9090, 267, 754, 275, 859, 14, 1162, 459, 5904, 418, 272, 587, 26, 267, 754, 275, 859, 14, 362, 63, 1393, 63, 515, 360, 16343, 297, 715, 12, 359, 578, 14, 1162, 459, 5904, 12121, 272, 372, 754, 421, 199, 318, 664, 63, 8421, 63, 1023, 8, 16343, 63, 1199, 304, 272, 408, 27200, 299, 2210, 3982, 13, 815, 1072, 436, 664, 314, 8839, 1015, 624, 272, 2385, 275, 299, 2210, 63, 1199, 14, 1294, 2258, 78, 358, 272, 367, 1004, 315, 2385, 26, 267, 340, 283, 31438, 283, 315, 1004, 26, 288, 372, 1004, 14, 13490, 8, 403, 12, 413, 15786, 17, 1055, 1913, 342, 272, 372, 488, 421, 199, 318, 1827, 63, 2491, 8, 578, 12, 536, 12, 1174, 628, 1881, 2349, 272, 408, 3227, 314, 2559, 2004, 315, 3865, 314, 2257, 2656, 436, 314, 7611, 14, 272, 1803, 282, 5046, 370, 6623, 340, 314, 2559, 365, 4903, 12, 272, 436, 282, 3499, 5046, 370, 6623, 340, 314, 2559, 365, 1536, 13, 475, 13, 602, 1041, 272, 340, 1174, 508, 298, 1881, 582, 267, 634, 1760, 275, 2071, 83, 2256, 450, 83, 2, 450, 6110, 362, 63, 16343, 63, 515, 8, 578, 395, 536, 9, 267, 634, 1195, 12, 634, 2703, 12, 634, 3083, 275, 859, 14, 1065, 63, 1531, 8, 76, 1760, 12, 1104, 63, 1195, 29, 797, 9, 267, 340, 634, 1195, 1137, 378, 26, 288, 327, 2559, 365, 440, 4903, 17738, 288, 372, 756, 12, 756, 398, 519, 1760, 275, 2071, 83, 3982, 13, 815, 450, 83, 2, 450, 6110, 362, 63, 16343, 63, 515, 8, 578, 395, 536, 9, 267, 519, 1195, 12, 519, 2703, 12, 519, 3083, 275, 859, 14, 1065, 63, 1531, 8, 1195, 1064, 12, 1104, 63, 1195, 29, 797, 9, 398, 327, 664, 314, 1015, 4903, 17738, 334, 692, 1263, 9, 267, 634, 1023, 275, 664, 63, 1832, 63, 1023, 8, 82, 2703, 9, 398, 327, 664, 314, 1015, 315, 314, 7611, 267, 519, 1023, 275, 664, 63, 8421, 63, 1023, 8, 82, 2703, 9, 398, 340, 519, 1195, 508, 378, 26, 288, 327, 1432, 715, 370, 6623, 626, 314, 2559, 365, 4903, 17738, 12, 288, 327, 436, 314, 754, 402, 314, 1015, 1329, 9132, 288, 327, 370, 6705, 340, 314, 2559, 365, 1536, 13, 475, 13, 602, 14, 288, 372, 715, 12, 334, 76, 1023, 508, 519, 1023, 9, 398, 372, 756, 12, 756, 421, 199, 318, 2813, 63, 5154, 8, 578, 12, 6117, 304, 272, 2813, 63, 67, 275, 378, 272, 327, 11719, 282, 367, 4438, 315, 1930, 402, 1125, 12, 781, 883, 3622, 314, 2559, 626, 3405, 272, 367, 2559, 315, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 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/demo/faber-pg.py
3
5852
import sys import asyncio import json import random from ctypes import cdll from time import sleep import platform import logging from indy import wallet from indy.error import ErrorCode, IndyError from vcx.api.connection import Connection from vcx.api.credential_def import CredentialDef from vcx.api.issuer_credential import IssuerCredential from vcx.api.proof import Proof from vcx.api.schema import Schema from vcx.api.utils import vcx_agent_provision from vcx.api.vcx_init import vcx_init_with_config from vcx.state import State, ProofState from demo_utils import * # logging.basicConfig(level=logging.DEBUG) uncomment to get logs # 'agency_url': URL of the agency # 'agency_did': public DID of the agency # 'agency_verkey': public verkey of the agency # 'wallet_name': name for newly created encrypted wallet # 'wallet_key': encryption key for encoding wallet # 'payment_method': method that will be used for payments provisionConfig = { 'agency_url':'http://localhost:8080', 'agency_did':'VsKV7grR1BUE29mG2Fm2kX', 'agency_verkey':'Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR', 'wallet_name':'faber_wallet_' + str(random.randint(100, 999)), 'wallet_key':'123', 'payment_method': 'null', 'enterprise_seed':'000000000000000000000000Trustee1' } if len(sys.argv) > 1 and sys.argv[1] == '--postgres': # load postgres dll and configure postgres wallet load_postgres_plugin(provisionConfig) print("Success, loaded postgres wallet storage") async def main(): if len(sys.argv) > 1 and sys.argv[1] == '--postgres': # create wallet in advance await create_postgres_wallet(provisionConfig) payment_plugin = cdll.LoadLibrary("/usr/local/lib/libnullpay" + file_ext()) payment_plugin.nullpay_init() handled_offers = [] handled_requests = [] print("#1 Provision an agent and wallet, get back configuration details") config = await vcx_agent_provision(json.dumps(provisionConfig)) config = json.loads(config) # Set some additional configuration options specific to faber config['institution_name'] = 'Faber' config['institution_logo_url'] = 'http://robohash.org/234' config['genesis_path'] = 'docker.txn' print("#2 Initialize libvcx with new configuration") await vcx_init_with_config(json.dumps(config)) print("#3 Create a new schema and cred def on the ledger") schema_uuid = 'schema_uuid' schema_name = 'degree schema' schema_attrs = ['name', 'date', 'degree', 'age'] creddef_uuid = 'credef_uuid' creddef_name = 'degree' cred_def_json = await create_schema_and_cred_def(schema_uuid, schema_name, schema_attrs, creddef_uuid, creddef_name) print("#5 Create a connection to alice and print out the invite details") connection_to_alice = await Connection.create('alice') await connection_to_alice.connect('{"use_public_did": true}') await connection_to_alice.update_state() details = await connection_to_alice.invite_details(False) print("**invite details**") print(json.dumps(details)) print("******************") connection_data = await connection_to_alice.serialize() connection_to_alice.release() connection_to_alice = None while True: print("#6 Poll agency and wait for alice to accept the invitation (start alice.py now)") connection_to_alice = await Connection.deserialize(connection_data) await connection_to_alice.update_state() connection_state = await connection_to_alice.get_state() if connection_state == State.Accepted: break else: connection_data = await connection_to_alice.serialize() connection_to_alice.release() connection_to_alice = None sleep(5) print("Serialize connection") connection_data = await connection_to_alice.serialize() connection_to_alice.release() connection_to_alice = None option = input('(1) Issue Credential, (2) Send Proof Request, (3) Poll for Messages (X) Exit? [1/2/3/X] ') while option != 'X' and option != 'x': print("Deserialize connection") my_connection = await Connection.deserialize(connection_data) sleep(2) if option == '1': schema_attrs = { 'name': 'alice', 'date': '05-2018', 'degree': 'maths', 'age': '24', } cred_tag = 'alice_degree' cred_name = 'cred' await send_credential_request(my_connection, cred_def_json, schema_attrs, cred_tag, cred_name) elif option == '2': proof_attrs = [ {'name': 'name', 'restrictions': [{'issuer_did': config['institution_did']}]}, {'name': 'date', 'restrictions': [{'issuer_did': config['institution_did']}]}, {'name': 'degree', 'restrictions': [{'issuer_did': config['institution_did']}]}, {'name': 'self_attested_thing'} ] proof_predicates = [{'name':'age', 'p_type':'>=', 'p_value':18},] proof_uuid = 'proof_uuid' proof_name = 'proof_from_alice' await send_proof_request(my_connection, config['institution_did'], proof_attrs, proof_uuid, proof_name, proof_predicates) elif option == '3': await handle_messages(my_connection, handled_offers, handled_requests) sleep(2) print("Serialize connection") connection_data = await my_connection.serialize() my_connection.release() my_connection = None option = input('(1) Issue Credential, (2) Send Proof Request, (3) Poll for Messages (X) Exit? [1/2/3/X] ') print("Done, pause before exiting program") sleep(2) if __name__ == '__main__': loop = asyncio.get_event_loop() loop.run_until_complete(main())
apache-2.0
[ 646, 984, 199, 646, 16195, 199, 646, 2022, 199, 646, 2196, 199, 504, 5577, 492, 286, 9259, 199, 504, 900, 492, 9435, 199, 646, 4298, 199, 199, 646, 2050, 199, 199, 504, 7654, 89, 492, 20534, 199, 504, 7654, 89, 14, 705, 492, 4520, 3034, 12, 473, 977, 89, 547, 199, 199, 504, 373, 11859, 14, 1246, 14, 2105, 492, 8113, 199, 504, 373, 11859, 14, 1246, 14, 15591, 63, 318, 492, 9750, 3256, 6172, 199, 504, 373, 11859, 14, 1246, 14, 26484, 63, 15591, 492, 473, 385, 14262, 23330, 199, 504, 373, 11859, 14, 1246, 14, 496, 1618, 492, 2165, 1618, 199, 504, 373, 11859, 14, 1246, 14, 3629, 492, 13268, 199, 504, 373, 11859, 14, 1246, 14, 1208, 492, 373, 11859, 63, 4054, 63, 13717, 199, 504, 373, 11859, 14, 1246, 14, 6737, 88, 63, 826, 492, 373, 11859, 63, 826, 63, 1045, 63, 888, 199, 504, 373, 11859, 14, 929, 492, 8511, 12, 2165, 1618, 2223, 199, 199, 504, 14779, 63, 1208, 492, 627, 199, 199, 3, 2050, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 9, 625, 3349, 370, 664, 9610, 421, 199, 3, 283, 643, 9501, 63, 633, 356, 2851, 402, 314, 1839, 9501, 199, 3, 283, 643, 9501, 63, 14887, 356, 221, 4575, 577, 998, 402, 314, 1839, 9501, 199, 3, 283, 643, 9501, 63, 422, 498, 356, 4575, 809, 498, 402, 314, 1839, 9501, 199, 3, 283, 13892, 63, 354, 356, 536, 367, 13903, 2737, 14862, 20534, 199, 3, 283, 13892, 63, 498, 356, 14396, 790, 367, 2644, 20534, 199, 3, 283, 7948, 63, 765, 356, 1083, 626, 911, 506, 1202, 367, 8633, 1470, 199, 13717, 2028, 275, 469, 523, 283, 643, 9501, 63, 633, 5242, 1014, 921, 5967, 26, 15844, 297, 523, 283, 643, 9501, 63, 14887, 5242, 20343, 43, 54, 23, 2587, 50, 17, 2910, 37, 1398, 77, 39, 18, 38, 77, 18, 75, 56, 297, 523, 283, 643, 9501, 63, 422, 498, 5242, 1966, 90, 301, 18, 53, 13073, 58, 19, 87, 53, 72, 54, 21889, 18, 44, 70, 19982, 83, 24, 78, 36, 90, 55, 87, 31765, 18, 8886, 23, 37, 90, 7178, 19, 28786, 50, 297, 523, 283, 13892, 63, 354, 5242, 21159, 281, 63, 13892, 8650, 435, 620, 8, 2355, 14, 8393, 8, 1960, 12, 22291, 1826, 523, 283, 13892, 63, 498, 5242, 4288, 297, 523, 283, 7948, 63, 765, 356, 283, 2307, 297, 523, 283, 24375, 63, 5176, 5242, 9409, 3607, 14064, 527, 15557, 17, 7, 199, 93, 421, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 436, 984, 14, 3020, 59, 17, 61, 508, 2850, 10675, 356, 272, 327, 2248, 19533, 17112, 436, 7908, 19533, 20534, 272, 2248, 63, 10675, 63, 2718, 8, 13717, 2028, 9, 339, 870, 480, 8300, 12, 6511, 19533, 20534, 4887, 531, 421, 199, 4146, 347, 2446, 837, 272, 340, 822, 8, 1274, 14, 3020, 9, 690, 413, 436, 984, 14, 3020, 59, 17, 61, 508, 2850, 10675, 356, 267, 327, 1218, 20534, 315, 18695, 267, 5517, 1218, 63, 10675, 63, 13892, 8, 13717, 2028, 9, 339, 11628, 63, 2718, 275, 286, 9259, 14, 6200, 7424, 4769, 2647, 15, 1832, 15, 773, 15, 773, 2307, 5989, 2, 435, 570, 63, 832, 1012, 272, 11628, 63, 2718, 14, 2307, 5989, 63, 826, 342, 339, 8860, 63, 1997, 1192, 275, 942, 272, 8860, 63, 6615, 275, 942, 339, 870, 10064, 17, 2165, 2317, 376, 6631, 436, 20534, 12, 664, 1771, 2897, 2436, 531, 272, 1101, 275, 5517, 373, 11859, 63, 4054, 63, 13717, 8, 1001, 14, 4180, 8, 13717, 2028, 430, 272, 1101, 275, 2022, 14, 3640, 8, 888, 9, 272, 327, 2494, 2005, 4722, 2897, 1511, 2488, 370, 31507, 281, 272, 1101, 459, 3615, 28433, 63, 354, 418, 275, 283, 38, 371, 281, 7, 272, 1101, 459, 3615, 28433, 63, 9733, 63, 633, 418, 275, 283, 1014, 921, 293, 656, 2227, 14, 1308, 15, 5533, 7, 272, 1101, 459, 10654, 2316, 63, 515, 418, 275, 283, 9991, 14, 18174, 7, 2286, 870, 10064, 18, 11578, 1973, 6737, 88, 543, 892, 2897, 531, 272, 5517, 373, 11859, 63, 826, 63, 1045, 63, 888, 8, 1001, 14, 4180, 8, 888, 430, 339, 870, 10064, 19, 2790, 282, 892, 4177, 436, 22314, 347, 641, 314, 29239, 836, 531, 272, 4177, 63, 2580, 275, 283, 3629, 63, 2580, 7, 272, 4177, 63, 354, 275, 283, 10956, 4177, 7, 272, 4177, 63, 3288, 275, 788, 354, 297, 283, 602, 297, 283, 10956, 297, 283, 474, 418, 272, 22314, 318, 63, 2580, 275, 283, 1353, 318, 63, 2580, 7, 272, 22314, 318, 63, 354, 275, 283, 10956, 7, 272, 22314, 63, 318, 63, 1001, 275, 5517, 1218, 63, 3629, 63, 460, 63, 18639, 63, 318, 8, 3629, 63, 2580, 12, 4177, 63, 354, 12, 4177, 63, 3288, 12, 22314, 318, 63, 2580, 12, 22314, 318, 63, 354, 9, 339, 870, 10064, 21, 2790, 282, 1950, 370, 741, 1885, 436, 870, 734, 314, 24542, 2436, 531, 272, 1950, 63, 475, 63, 19179, 275, 5517, 8113, 14, 981, 360, 19179, 358, 272, 5517, 1950, 63, 475, 63, 19179, 14, 2242, 360, 6641, 1180, 63, 3455, 63, 14887, 582, 2549, 12216, 272, 5517, 1950, 63, 475, 63, 19179, 14, 873, 63, 929, 342, 272, 2436, 275, 5517, 1950, 63, 475, 63, 19179, 14, 19061, 63, 5087, 8, 797, 9, 272, 870, 480, 538, 19061, 2436, 538, 531, 272, 870, 8, 1001, 14, 4180, 8, 5087, 430, 272, 870, 480, 3096, 538, 531, 339, 1950, 63, 576, 275, 5517, 1950, 63, 475, 63, 19179, 14, 3549, 342, 272, 1950, 63, 475, 63, 19179, 14, 3221, 342, 272, 1950, 63, 475, 63, 19179, 275, 488, 339, 1830, 715, 26, 267, 870, 10064, 22, 25306, 1839, 9501, 436, 3618, 367, 741, 1885, 370, 4729, 314, 4572, 5314, 334, 928, 741, 1885, 14, 647, 3063, 6320, 267, 1950, 63, 475, 63, 19179, 275, 5517, 8113, 14, 11143, 8, 2105, 63, 576, 9, 267, 5517, 1950, 63, 475, 63, 19179, 14, 873, 63, 929, 342, 267, 1950, 63, 929, 275, 5517, 1950, 63, 475, 63, 19179, 14, 362, 63, 929, 342, 267, 340, 1950, 63, 929, 508, 8511, 14, 1945, 7203, 26, 288, 2059, 267, 587, 26, 288 ]
[ 984, 199, 646, 16195, 199, 646, 2022, 199, 646, 2196, 199, 504, 5577, 492, 286, 9259, 199, 504, 900, 492, 9435, 199, 646, 4298, 199, 199, 646, 2050, 199, 199, 504, 7654, 89, 492, 20534, 199, 504, 7654, 89, 14, 705, 492, 4520, 3034, 12, 473, 977, 89, 547, 199, 199, 504, 373, 11859, 14, 1246, 14, 2105, 492, 8113, 199, 504, 373, 11859, 14, 1246, 14, 15591, 63, 318, 492, 9750, 3256, 6172, 199, 504, 373, 11859, 14, 1246, 14, 26484, 63, 15591, 492, 473, 385, 14262, 23330, 199, 504, 373, 11859, 14, 1246, 14, 496, 1618, 492, 2165, 1618, 199, 504, 373, 11859, 14, 1246, 14, 3629, 492, 13268, 199, 504, 373, 11859, 14, 1246, 14, 1208, 492, 373, 11859, 63, 4054, 63, 13717, 199, 504, 373, 11859, 14, 1246, 14, 6737, 88, 63, 826, 492, 373, 11859, 63, 826, 63, 1045, 63, 888, 199, 504, 373, 11859, 14, 929, 492, 8511, 12, 2165, 1618, 2223, 199, 199, 504, 14779, 63, 1208, 492, 627, 199, 199, 3, 2050, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 9, 625, 3349, 370, 664, 9610, 421, 199, 3, 283, 643, 9501, 63, 633, 356, 2851, 402, 314, 1839, 9501, 199, 3, 283, 643, 9501, 63, 14887, 356, 221, 4575, 577, 998, 402, 314, 1839, 9501, 199, 3, 283, 643, 9501, 63, 422, 498, 356, 4575, 809, 498, 402, 314, 1839, 9501, 199, 3, 283, 13892, 63, 354, 356, 536, 367, 13903, 2737, 14862, 20534, 199, 3, 283, 13892, 63, 498, 356, 14396, 790, 367, 2644, 20534, 199, 3, 283, 7948, 63, 765, 356, 1083, 626, 911, 506, 1202, 367, 8633, 1470, 199, 13717, 2028, 275, 469, 523, 283, 643, 9501, 63, 633, 5242, 1014, 921, 5967, 26, 15844, 297, 523, 283, 643, 9501, 63, 14887, 5242, 20343, 43, 54, 23, 2587, 50, 17, 2910, 37, 1398, 77, 39, 18, 38, 77, 18, 75, 56, 297, 523, 283, 643, 9501, 63, 422, 498, 5242, 1966, 90, 301, 18, 53, 13073, 58, 19, 87, 53, 72, 54, 21889, 18, 44, 70, 19982, 83, 24, 78, 36, 90, 55, 87, 31765, 18, 8886, 23, 37, 90, 7178, 19, 28786, 50, 297, 523, 283, 13892, 63, 354, 5242, 21159, 281, 63, 13892, 8650, 435, 620, 8, 2355, 14, 8393, 8, 1960, 12, 22291, 1826, 523, 283, 13892, 63, 498, 5242, 4288, 297, 523, 283, 7948, 63, 765, 356, 283, 2307, 297, 523, 283, 24375, 63, 5176, 5242, 9409, 3607, 14064, 527, 15557, 17, 7, 199, 93, 421, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 436, 984, 14, 3020, 59, 17, 61, 508, 2850, 10675, 356, 272, 327, 2248, 19533, 17112, 436, 7908, 19533, 20534, 272, 2248, 63, 10675, 63, 2718, 8, 13717, 2028, 9, 339, 870, 480, 8300, 12, 6511, 19533, 20534, 4887, 531, 421, 199, 4146, 347, 2446, 837, 272, 340, 822, 8, 1274, 14, 3020, 9, 690, 413, 436, 984, 14, 3020, 59, 17, 61, 508, 2850, 10675, 356, 267, 327, 1218, 20534, 315, 18695, 267, 5517, 1218, 63, 10675, 63, 13892, 8, 13717, 2028, 9, 339, 11628, 63, 2718, 275, 286, 9259, 14, 6200, 7424, 4769, 2647, 15, 1832, 15, 773, 15, 773, 2307, 5989, 2, 435, 570, 63, 832, 1012, 272, 11628, 63, 2718, 14, 2307, 5989, 63, 826, 342, 339, 8860, 63, 1997, 1192, 275, 942, 272, 8860, 63, 6615, 275, 942, 339, 870, 10064, 17, 2165, 2317, 376, 6631, 436, 20534, 12, 664, 1771, 2897, 2436, 531, 272, 1101, 275, 5517, 373, 11859, 63, 4054, 63, 13717, 8, 1001, 14, 4180, 8, 13717, 2028, 430, 272, 1101, 275, 2022, 14, 3640, 8, 888, 9, 272, 327, 2494, 2005, 4722, 2897, 1511, 2488, 370, 31507, 281, 272, 1101, 459, 3615, 28433, 63, 354, 418, 275, 283, 38, 371, 281, 7, 272, 1101, 459, 3615, 28433, 63, 9733, 63, 633, 418, 275, 283, 1014, 921, 293, 656, 2227, 14, 1308, 15, 5533, 7, 272, 1101, 459, 10654, 2316, 63, 515, 418, 275, 283, 9991, 14, 18174, 7, 2286, 870, 10064, 18, 11578, 1973, 6737, 88, 543, 892, 2897, 531, 272, 5517, 373, 11859, 63, 826, 63, 1045, 63, 888, 8, 1001, 14, 4180, 8, 888, 430, 339, 870, 10064, 19, 2790, 282, 892, 4177, 436, 22314, 347, 641, 314, 29239, 836, 531, 272, 4177, 63, 2580, 275, 283, 3629, 63, 2580, 7, 272, 4177, 63, 354, 275, 283, 10956, 4177, 7, 272, 4177, 63, 3288, 275, 788, 354, 297, 283, 602, 297, 283, 10956, 297, 283, 474, 418, 272, 22314, 318, 63, 2580, 275, 283, 1353, 318, 63, 2580, 7, 272, 22314, 318, 63, 354, 275, 283, 10956, 7, 272, 22314, 63, 318, 63, 1001, 275, 5517, 1218, 63, 3629, 63, 460, 63, 18639, 63, 318, 8, 3629, 63, 2580, 12, 4177, 63, 354, 12, 4177, 63, 3288, 12, 22314, 318, 63, 2580, 12, 22314, 318, 63, 354, 9, 339, 870, 10064, 21, 2790, 282, 1950, 370, 741, 1885, 436, 870, 734, 314, 24542, 2436, 531, 272, 1950, 63, 475, 63, 19179, 275, 5517, 8113, 14, 981, 360, 19179, 358, 272, 5517, 1950, 63, 475, 63, 19179, 14, 2242, 360, 6641, 1180, 63, 3455, 63, 14887, 582, 2549, 12216, 272, 5517, 1950, 63, 475, 63, 19179, 14, 873, 63, 929, 342, 272, 2436, 275, 5517, 1950, 63, 475, 63, 19179, 14, 19061, 63, 5087, 8, 797, 9, 272, 870, 480, 538, 19061, 2436, 538, 531, 272, 870, 8, 1001, 14, 4180, 8, 5087, 430, 272, 870, 480, 3096, 538, 531, 339, 1950, 63, 576, 275, 5517, 1950, 63, 475, 63, 19179, 14, 3549, 342, 272, 1950, 63, 475, 63, 19179, 14, 3221, 342, 272, 1950, 63, 475, 63, 19179, 275, 488, 339, 1830, 715, 26, 267, 870, 10064, 22, 25306, 1839, 9501, 436, 3618, 367, 741, 1885, 370, 4729, 314, 4572, 5314, 334, 928, 741, 1885, 14, 647, 3063, 6320, 267, 1950, 63, 475, 63, 19179, 275, 5517, 8113, 14, 11143, 8, 2105, 63, 576, 9, 267, 5517, 1950, 63, 475, 63, 19179, 14, 873, 63, 929, 342, 267, 1950, 63, 929, 275, 5517, 1950, 63, 475, 63, 19179, 14, 362, 63, 929, 342, 267, 340, 1950, 63, 929, 508, 8511, 14, 1945, 7203, 26, 288, 2059, 267, 587, 26, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
gohin/django
django/contrib/sites/models.py
316
3743
from __future__ import unicode_literals import string from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models from django.db.models.signals import pre_delete, pre_save from django.http.request import split_domain_port from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ SITE_CACHE = {} def _simple_domain_name_validator(value): """ Validates that the given value contains no whitespaces to prevent common typos. """ if not value: return checks = ((s in value) for s in string.whitespace) if any(checks): raise ValidationError( _("The domain name cannot contain any spaces or tabs."), code='invalid', ) class SiteManager(models.Manager): use_in_migrations = True def _get_site_by_id(self, site_id): if site_id not in SITE_CACHE: site = self.get(pk=site_id) SITE_CACHE[site_id] = site return SITE_CACHE[site_id] def _get_site_by_request(self, request): host = request.get_host() try: # First attempt to look up the site by host with or without port. if host not in SITE_CACHE: SITE_CACHE[host] = self.get(domain__iexact=host) return SITE_CACHE[host] except Site.DoesNotExist: # Fallback to looking up site after stripping port from the host. domain, port = split_domain_port(host) if not port: raise if domain not in SITE_CACHE: SITE_CACHE[domain] = self.get(domain__iexact=domain) return SITE_CACHE[domain] def get_current(self, request=None): """ Returns the current Site based on the SITE_ID in the project's settings. If SITE_ID isn't defined, it returns the site with domain matching request.get_host(). The ``Site`` object is cached the first time it's retrieved from the database. """ from django.conf import settings if getattr(settings, 'SITE_ID', ''): site_id = settings.SITE_ID return self._get_site_by_id(site_id) elif request: return self._get_site_by_request(request) raise ImproperlyConfigured( "You're using the Django \"sites framework\" without having " "set the SITE_ID setting. Create a site in your database and " "set the SITE_ID setting or pass a request to " "Site.objects.get_current() to fix this error." ) def clear_cache(self): """Clears the ``Site`` object cache.""" global SITE_CACHE SITE_CACHE = {} @python_2_unicode_compatible class Site(models.Model): domain = models.CharField(_('domain name'), max_length=100, validators=[_simple_domain_name_validator], unique=True) name = models.CharField(_('display name'), max_length=50) objects = SiteManager() class Meta: db_table = 'django_site' verbose_name = _('site') verbose_name_plural = _('sites') ordering = ('domain',) def __str__(self): return self.domain def clear_site_cache(sender, **kwargs): """ Clears the cache (if primed) each time a site is saved or deleted """ instance = kwargs['instance'] using = kwargs['using'] try: del SITE_CACHE[instance.pk] except KeyError: pass try: del SITE_CACHE[Site.objects.using(using).get(pk=instance.pk).domain] except (KeyError, Site.DoesNotExist): pass pre_save.connect(clear_site_cache, sender=Site) pre_delete.connect(clear_site_cache, sender=Site)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1059, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 12, 8505, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 14, 10458, 492, 876, 63, 1807, 12, 876, 63, 2117, 199, 504, 1639, 14, 1014, 14, 1069, 492, 3715, 63, 2261, 63, 719, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 7917, 63, 8677, 275, 1052, 421, 199, 318, 485, 4129, 63, 2261, 63, 354, 63, 11034, 8, 585, 304, 272, 408, 272, 4821, 2335, 626, 314, 1627, 574, 3509, 949, 704, 31926, 370, 7981, 2863, 272, 10284, 1712, 14, 272, 408, 272, 340, 440, 574, 26, 267, 372, 272, 5920, 275, 3666, 83, 315, 574, 9, 367, 308, 315, 1059, 14, 8506, 9, 272, 340, 1263, 8, 8625, 304, 267, 746, 8505, 8, 288, 3824, 1918, 2881, 536, 3913, 1395, 1263, 7883, 503, 12187, 7651, 288, 1233, 534, 3197, 297, 267, 776, 421, 199, 533, 11666, 2988, 8, 992, 14, 2988, 304, 272, 675, 63, 262, 63, 7685, 275, 715, 339, 347, 485, 362, 63, 2124, 63, 991, 63, 344, 8, 277, 12, 4770, 63, 344, 304, 267, 340, 4770, 63, 344, 440, 315, 428, 4427, 63, 8677, 26, 288, 4770, 275, 291, 14, 362, 8, 2051, 29, 2124, 63, 344, 9, 288, 428, 4427, 63, 8677, 59, 2124, 63, 344, 61, 275, 4770, 267, 372, 428, 4427, 63, 8677, 59, 2124, 63, 344, 61, 339, 347, 485, 362, 63, 2124, 63, 991, 63, 1069, 8, 277, 12, 1056, 304, 267, 1591, 275, 1056, 14, 362, 63, 1102, 342, 267, 862, 26, 288, 327, 7758, 7427, 370, 3648, 1536, 314, 4770, 701, 1591, 543, 503, 1928, 1844, 14, 288, 340, 1591, 440, 315, 428, 4427, 63, 8677, 26, 355, 428, 4427, 63, 8677, 59, 1102, 61, 275, 291, 14, 362, 8, 2261, 363, 32344, 29, 1102, 9, 288, 372, 428, 4427, 63, 8677, 59, 1102, 61, 267, 871, 11666, 14, 7400, 26, 288, 327, 481, 5421, 370, 10023, 1536, 4770, 2410, 4024, 3637, 1844, 687, 314, 1591, 14, 288, 2881, 12, 1844, 275, 3715, 63, 2261, 63, 719, 8, 1102, 9, 288, 340, 440, 1844, 26, 355, 746, 288, 340, 2881, 440, 315, 428, 4427, 63, 8677, 26, 355, 428, 4427, 63, 8677, 59, 2261, 61, 275, 291, 14, 362, 8, 2261, 363, 32344, 29, 2261, 9, 288, 372, 428, 4427, 63, 8677, 59, 2261, 61, 339, 347, 664, 63, 1818, 8, 277, 12, 1056, 29, 403, 304, 267, 408, 267, 1803, 314, 1453, 11666, 4079, 641, 314, 428, 4427, 63, 998, 315, 314, 2199, 1159, 2202, 14, 267, 982, 428, 4427, 63, 998, 5712, 1133, 3247, 12, 652, 2529, 314, 4770, 543, 2881, 4877, 267, 1056, 14, 362, 63, 1102, 1252, 710, 1124, 8972, 1040, 909, 365, 6328, 314, 1642, 900, 652, 1159, 267, 12396, 687, 314, 3050, 14, 267, 408, 267, 687, 1639, 14, 2190, 492, 2202, 267, 340, 2519, 8, 1751, 12, 283, 7917, 63, 998, 297, 21019, 288, 4770, 63, 344, 275, 2202, 14, 7917, 63, 998, 288, 372, 291, 423, 362, 63, 2124, 63, 991, 63, 344, 8, 2124, 63, 344, 9, 267, 916, 1056, 26, 288, 372, 291, 423, 362, 63, 2124, 63, 991, 63, 1069, 8, 1069, 9, 398, 746, 11897, 8, 288, 298, 5556, 3984, 1808, 314, 5634, 8441, 8619, 10059, 4451, 1928, 9445, 298, 288, 298, 409, 314, 428, 4427, 63, 998, 4260, 14, 2790, 282, 4770, 315, 2195, 3050, 436, 298, 288, 298, 409, 314, 428, 4427, 63, 998, 4260, 503, 986, 282, 1056, 370, 298, 288, 298, 8972, 14, 1462, 14, 362, 63, 1818, 342, 370, 5325, 642, 1125, 2122, 267, 776, 339, 347, 5436, 63, 1637, 8, 277, 304, 267, 408, 9721, 83, 314, 1124, 8972, 1040, 909, 2581, 1041, 267, 2288, 428, 4427, 63, 8677, 267, 428, 4427, 63, 8677, 275, 1052, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 11666, 8, 992, 14, 1685, 304, 339, 2881, 275, 1709, 14, 2183, 6723, 2261, 536, 659, 1390, 63, 1267, 29, 1960, 12, 267, 14370, 1524, 63, 4129, 63, 2261, 63, 354, 63, 11034, 467, 3747, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 6723, 2918, 536, 659, 1390, 63, 1267, 29, 1400, 9, 272, 2251, 275, 11666, 2988, 342, 339, 1021, 6288, 26, 267, 1592, 63, 1224, 275, 283, 1176, 63, 2124, 7, 267, 3376, 63, 354, 275, 4018, 2124, 358, 267, 3376, 63, 354, 63, 10019, 275, 4018, 8619, 358, 267, 7794, 275, 661, 2261, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 2261, 421, 199, 318, 5436, 63, 2124, 63, 1637, 8, 8114, 12, 1011, 958, 304, 272, 408, 272, 14836, 83, 314, 2581, 334, 692, 1979, 3594, 9, 1924, 900, 282, 4770, 365, 6290, 503, 5463, 272, 408, 272, 1256, 275, 2074, 459, 842, 418, 272, 1808, 275, 2074, 459, 4941, 418, 272, 862, 26, 267, 2150, 428, 4427, 63, 8677, 59, 842, 14, 2051, 61, 272, 871, 4067, 26, 267, 986, 272, 862, 26, 267, 2150, 428, 4427, 63, 8677, 59, 8972, 14, 1462, 14, 4941, 8, 4941, 680, 362, 8, 2051, 29, 842, 14, 2051, 680, 2261, 61, 272, 871, 334, 10230, 12, 11666, 14, 7400, 304, 267, 986, 199, 657, 63, 2117, 14, 2242, 8, 3584, 63, 2124, 63, 1637, 12, 8904, 29, 8972, 9, 199, 657, 63, 1807, 14, 2242, 8, 3584, 63, 2124, 63, 1637, 12, 8904, 29, 8972, 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 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1059, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 12, 8505, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 14, 10458, 492, 876, 63, 1807, 12, 876, 63, 2117, 199, 504, 1639, 14, 1014, 14, 1069, 492, 3715, 63, 2261, 63, 719, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 7917, 63, 8677, 275, 1052, 421, 199, 318, 485, 4129, 63, 2261, 63, 354, 63, 11034, 8, 585, 304, 272, 408, 272, 4821, 2335, 626, 314, 1627, 574, 3509, 949, 704, 31926, 370, 7981, 2863, 272, 10284, 1712, 14, 272, 408, 272, 340, 440, 574, 26, 267, 372, 272, 5920, 275, 3666, 83, 315, 574, 9, 367, 308, 315, 1059, 14, 8506, 9, 272, 340, 1263, 8, 8625, 304, 267, 746, 8505, 8, 288, 3824, 1918, 2881, 536, 3913, 1395, 1263, 7883, 503, 12187, 7651, 288, 1233, 534, 3197, 297, 267, 776, 421, 199, 533, 11666, 2988, 8, 992, 14, 2988, 304, 272, 675, 63, 262, 63, 7685, 275, 715, 339, 347, 485, 362, 63, 2124, 63, 991, 63, 344, 8, 277, 12, 4770, 63, 344, 304, 267, 340, 4770, 63, 344, 440, 315, 428, 4427, 63, 8677, 26, 288, 4770, 275, 291, 14, 362, 8, 2051, 29, 2124, 63, 344, 9, 288, 428, 4427, 63, 8677, 59, 2124, 63, 344, 61, 275, 4770, 267, 372, 428, 4427, 63, 8677, 59, 2124, 63, 344, 61, 339, 347, 485, 362, 63, 2124, 63, 991, 63, 1069, 8, 277, 12, 1056, 304, 267, 1591, 275, 1056, 14, 362, 63, 1102, 342, 267, 862, 26, 288, 327, 7758, 7427, 370, 3648, 1536, 314, 4770, 701, 1591, 543, 503, 1928, 1844, 14, 288, 340, 1591, 440, 315, 428, 4427, 63, 8677, 26, 355, 428, 4427, 63, 8677, 59, 1102, 61, 275, 291, 14, 362, 8, 2261, 363, 32344, 29, 1102, 9, 288, 372, 428, 4427, 63, 8677, 59, 1102, 61, 267, 871, 11666, 14, 7400, 26, 288, 327, 481, 5421, 370, 10023, 1536, 4770, 2410, 4024, 3637, 1844, 687, 314, 1591, 14, 288, 2881, 12, 1844, 275, 3715, 63, 2261, 63, 719, 8, 1102, 9, 288, 340, 440, 1844, 26, 355, 746, 288, 340, 2881, 440, 315, 428, 4427, 63, 8677, 26, 355, 428, 4427, 63, 8677, 59, 2261, 61, 275, 291, 14, 362, 8, 2261, 363, 32344, 29, 2261, 9, 288, 372, 428, 4427, 63, 8677, 59, 2261, 61, 339, 347, 664, 63, 1818, 8, 277, 12, 1056, 29, 403, 304, 267, 408, 267, 1803, 314, 1453, 11666, 4079, 641, 314, 428, 4427, 63, 998, 315, 314, 2199, 1159, 2202, 14, 267, 982, 428, 4427, 63, 998, 5712, 1133, 3247, 12, 652, 2529, 314, 4770, 543, 2881, 4877, 267, 1056, 14, 362, 63, 1102, 1252, 710, 1124, 8972, 1040, 909, 365, 6328, 314, 1642, 900, 652, 1159, 267, 12396, 687, 314, 3050, 14, 267, 408, 267, 687, 1639, 14, 2190, 492, 2202, 267, 340, 2519, 8, 1751, 12, 283, 7917, 63, 998, 297, 21019, 288, 4770, 63, 344, 275, 2202, 14, 7917, 63, 998, 288, 372, 291, 423, 362, 63, 2124, 63, 991, 63, 344, 8, 2124, 63, 344, 9, 267, 916, 1056, 26, 288, 372, 291, 423, 362, 63, 2124, 63, 991, 63, 1069, 8, 1069, 9, 398, 746, 11897, 8, 288, 298, 5556, 3984, 1808, 314, 5634, 8441, 8619, 10059, 4451, 1928, 9445, 298, 288, 298, 409, 314, 428, 4427, 63, 998, 4260, 14, 2790, 282, 4770, 315, 2195, 3050, 436, 298, 288, 298, 409, 314, 428, 4427, 63, 998, 4260, 503, 986, 282, 1056, 370, 298, 288, 298, 8972, 14, 1462, 14, 362, 63, 1818, 342, 370, 5325, 642, 1125, 2122, 267, 776, 339, 347, 5436, 63, 1637, 8, 277, 304, 267, 408, 9721, 83, 314, 1124, 8972, 1040, 909, 2581, 1041, 267, 2288, 428, 4427, 63, 8677, 267, 428, 4427, 63, 8677, 275, 1052, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 11666, 8, 992, 14, 1685, 304, 339, 2881, 275, 1709, 14, 2183, 6723, 2261, 536, 659, 1390, 63, 1267, 29, 1960, 12, 267, 14370, 1524, 63, 4129, 63, 2261, 63, 354, 63, 11034, 467, 3747, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 6723, 2918, 536, 659, 1390, 63, 1267, 29, 1400, 9, 272, 2251, 275, 11666, 2988, 342, 339, 1021, 6288, 26, 267, 1592, 63, 1224, 275, 283, 1176, 63, 2124, 7, 267, 3376, 63, 354, 275, 4018, 2124, 358, 267, 3376, 63, 354, 63, 10019, 275, 4018, 8619, 358, 267, 7794, 275, 661, 2261, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 2261, 421, 199, 318, 5436, 63, 2124, 63, 1637, 8, 8114, 12, 1011, 958, 304, 272, 408, 272, 14836, 83, 314, 2581, 334, 692, 1979, 3594, 9, 1924, 900, 282, 4770, 365, 6290, 503, 5463, 272, 408, 272, 1256, 275, 2074, 459, 842, 418, 272, 1808, 275, 2074, 459, 4941, 418, 272, 862, 26, 267, 2150, 428, 4427, 63, 8677, 59, 842, 14, 2051, 61, 272, 871, 4067, 26, 267, 986, 272, 862, 26, 267, 2150, 428, 4427, 63, 8677, 59, 8972, 14, 1462, 14, 4941, 8, 4941, 680, 362, 8, 2051, 29, 842, 14, 2051, 680, 2261, 61, 272, 871, 334, 10230, 12, 11666, 14, 7400, 304, 267, 986, 199, 657, 63, 2117, 14, 2242, 8, 3584, 63, 2124, 63, 1637, 12, 8904, 29, 8972, 9, 199, 657, 63, 1807, 14, 2242, 8, 3584, 63, 2124, 63, 1637, 12, 8904, 29, 8972, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
yongtang/tensorflow
tensorflow/python/framework/registry_test.py
14
1986
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for tensorflow.ops.registry.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from absl.testing import parameterized from tensorflow.python.framework import registry from tensorflow.python.platform import test def bar(): pass class RegistryTest(test.TestCase, parameterized.TestCase): class Foo(object): pass # Test the registry basics on both classes (Foo) and functions (bar). @parameterized.parameters([Foo, bar]) def testRegistryBasics(self, candidate): myreg = registry.Registry('testRegistry') with self.assertRaises(LookupError): myreg.lookup('testKey') myreg.register(candidate) self.assertEqual(myreg.lookup(candidate.__name__), candidate) myreg.register(candidate, 'testKey') self.assertEqual(myreg.lookup('testKey'), candidate) self.assertEqual( sorted(myreg.list()), sorted(['testKey', candidate.__name__])) def testDuplicate(self): myreg = registry.Registry('testbar') myreg.register(bar, 'Bar') with self.assertRaisesRegex( KeyError, r'Registering two testbar with name \'Bar\'! ' r'\(Previous registration was in [^ ]+ .*.py:[0-9]+\)'): myreg.register(bar, 'Bar') if __name__ == '__main__': test.main()
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 2925, 367, 3228, 14, 1483, 14, 5189, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 2853, 76, 14, 4776, 492, 29526, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 7086, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 318, 4681, 837, 523, 986, 421, 199, 533, 20738, 774, 8, 396, 14, 1746, 12, 29526, 14, 1746, 304, 819, 1021, 8024, 8, 785, 304, 272, 986, 819, 327, 1379, 314, 7086, 5678, 83, 641, 3865, 3992, 334, 5686, 9, 436, 3423, 334, 1700, 680, 523, 768, 25000, 14, 3214, 779, 5686, 12, 4681, 566, 523, 347, 511, 10899, 6845, 83, 8, 277, 12, 7627, 304, 272, 3002, 1135, 275, 7086, 14, 10899, 360, 396, 10899, 358, 272, 543, 291, 14, 1855, 8, 32060, 304, 489, 3002, 1135, 14, 3892, 360, 396, 1197, 358, 272, 3002, 1135, 14, 2683, 8, 9007, 9, 272, 291, 14, 629, 8, 1662, 1135, 14, 3892, 8, 9007, 855, 354, 10139, 7627, 9, 272, 3002, 1135, 14, 2683, 8, 9007, 12, 283, 396, 1197, 358, 272, 291, 14, 629, 8, 1662, 1135, 14, 3892, 360, 396, 1197, 659, 7627, 9, 272, 291, 14, 629, 8, 267, 3355, 8, 1662, 1135, 14, 513, 4000, 3355, 2941, 396, 1197, 297, 7627, 855, 354, 363, 2459, 819, 347, 511, 14773, 8, 277, 304, 272, 3002, 1135, 275, 7086, 14, 10899, 360, 396, 1700, 358, 272, 3002, 1135, 14, 2683, 8, 1700, 12, 283, 5281, 358, 272, 543, 291, 14, 16499, 8, 267, 4067, 12, 519, 7, 7099, 316, 2877, 511, 1700, 543, 536, 8891, 5281, 3985, 1, 283, 267, 519, 1154, 8, 18021, 10991, 1990, 315, 359, 62, 1622, 11, 1275, 4856, 647, 7766, 16, 13, 25, 24621, 9, 735, 489, 3002, 1135, 14, 2683, 8, 1700, 12, 283, 5281, 358, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 511, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 2925, 367, 3228, 14, 1483, 14, 5189, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 2853, 76, 14, 4776, 492, 29526, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 7086, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 318, 4681, 837, 523, 986, 421, 199, 533, 20738, 774, 8, 396, 14, 1746, 12, 29526, 14, 1746, 304, 819, 1021, 8024, 8, 785, 304, 272, 986, 819, 327, 1379, 314, 7086, 5678, 83, 641, 3865, 3992, 334, 5686, 9, 436, 3423, 334, 1700, 680, 523, 768, 25000, 14, 3214, 779, 5686, 12, 4681, 566, 523, 347, 511, 10899, 6845, 83, 8, 277, 12, 7627, 304, 272, 3002, 1135, 275, 7086, 14, 10899, 360, 396, 10899, 358, 272, 543, 291, 14, 1855, 8, 32060, 304, 489, 3002, 1135, 14, 3892, 360, 396, 1197, 358, 272, 3002, 1135, 14, 2683, 8, 9007, 9, 272, 291, 14, 629, 8, 1662, 1135, 14, 3892, 8, 9007, 855, 354, 10139, 7627, 9, 272, 3002, 1135, 14, 2683, 8, 9007, 12, 283, 396, 1197, 358, 272, 291, 14, 629, 8, 1662, 1135, 14, 3892, 360, 396, 1197, 659, 7627, 9, 272, 291, 14, 629, 8, 267, 3355, 8, 1662, 1135, 14, 513, 4000, 3355, 2941, 396, 1197, 297, 7627, 855, 354, 363, 2459, 819, 347, 511, 14773, 8, 277, 304, 272, 3002, 1135, 275, 7086, 14, 10899, 360, 396, 1700, 358, 272, 3002, 1135, 14, 2683, 8, 1700, 12, 283, 5281, 358, 272, 543, 291, 14, 16499, 8, 267, 4067, 12, 519, 7, 7099, 316, 2877, 511, 1700, 543, 536, 8891, 5281, 3985, 1, 283, 267, 519, 1154, 8, 18021, 10991, 1990, 315, 359, 62, 1622, 11, 1275, 4856, 647, 7766, 16, 13, 25, 24621, 9, 735, 489, 3002, 1135, 14, 2683, 8, 1700, 12, 283, 5281, 358, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 511, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
BillmanH/termite
execute.py
3
8107
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import argparse import ConfigParser import logging import time import os from pipeline.tokenize import Tokenize from pipeline.import_mallet import ImportMallet from pipeline.import_stmt import ImportStmt from pipeline.compute_saliency import ComputeSaliency from pipeline.compute_similarity import ComputeSimilarity from pipeline.compute_seriation import ComputeSeriation from pipeline.prepare_data_for_client import PrepareDataForClient class Execute( object ): """ Runs entire data processing pipeline and sets up client. Execute data processing scripts in order: 1. tokenize.py: Tokenize corpus 2. train_stmt/mallet.py: Train model 3. compute_saliency.py: Compute term saliency 4. compute_similarity.py: Compute term similarity 5. compute_seriation.py: Seriates terms 6. prepare_data_for_client.py: Generates datafiles for client 7. prepare_vis_for_client.py: Copies necessary scripts for client Input is configuration file specifying target corpus and destination directory. Creates multiple directories that store files from each stage of the pipeline. Among the directories is the public_html directory that holds all client files. """ DEFAULT_NUM_TOPICS = 25 def __init__( self, logging_level ): self.logger = logging.getLogger( 'Execute' ) self.logger.setLevel( logging_level ) handler = logging.StreamHandler( sys.stderr ) handler.setLevel( logging_level ) self.logger.addHandler( handler ) def execute( self, corpus_format, corpus_path, tokenization, model_library, model_path, data_path, num_topics, number_of_seriated_terms ): assert corpus_format is not None assert corpus_path is not None assert model_library is not None assert model_library == 'stmt' or model_library == 'mallet' assert model_path is not None assert data_path is not None if num_topics is None: num_topics = Execute.DEFAULT_NUM_TOPICS assert number_of_seriated_terms is not None self.logger.info( '--------------------------------------------------------------------------------' ) self.logger.info( 'Tokenizing source corpus...' ) self.logger.info( ' corpus_path = %s (%s)', corpus_path, corpus_format ) self.logger.info( ' model_path = %s (%s)', model_path, model_library ) self.logger.info( ' data_path = %s', data_path ) self.logger.info( ' num_topics = %d', num_topics ) self.logger.info( ' number_of_seriated_terms = %s', number_of_seriated_terms ) self.logger.info( '--------------------------------------------------------------------------------' ) self.logger.info( 'Current time = {}'.format( time.ctime() ) ) Tokenize( self.logger.level ).execute( corpus_format, corpus_path, data_path, tokenization ) self.logger.info( 'Current time = {}'.format( time.ctime() ) ) if model_library == 'stmt': command = 'pipeline/train_stmt.sh {} {} {}'.format( data_path + '/tokens/tokens.txt', model_path, num_topics ) os.system( command ) ImportStmt( self.logger.level ).execute( model_library, model_path, data_path ) if model_library == 'mallet': command = 'pipeline/train_mallet.sh {} {} {}'.format( data_path + '/tokens/tokens.txt', model_path, num_topics ) os.system( command ) ImportMallet( self.logger.level ).execute( model_library, model_path, data_path ) self.logger.info( 'Current time = {}'.format( time.ctime() ) ) ComputeSaliency( self.logger.level ).execute( data_path ) self.logger.info( 'Current time = {}'.format( time.ctime() ) ) ComputeSimilarity( self.logger.level ).execute( data_path ) self.logger.info( 'Current time = {}'.format( time.ctime() ) ) ComputeSeriation( self.logger.level ).execute( data_path, number_of_seriated_terms ) self.logger.info( 'Current time = {}'.format( time.ctime() ) ) PrepareDataForClient( self.logger.level ).execute( data_path ) self.logger.info( 'Current time = {}'.format( time.ctime() ) ) command = 'pipeline/prepare_vis_for_client.sh {}'.format( data_path ) os.system( command ) self.logger.info( 'Current time = {}'.format( time.ctime() ) ) #-------------------------------------------------------------------------------# def main(): parser = argparse.ArgumentParser( description = 'Prepare data for Termite.' ) parser.add_argument( 'config_file' , type = str, help = 'Termite configuration file.' ) parser.add_argument( '--corpus-format', type = str, dest = 'corpus_format', help = 'Override corpus format in the config file.' ) parser.add_argument( '--corpus-path' , type = str, dest = 'corpus_path' , help = 'Override corpus path in the config file.' ) parser.add_argument( '--model-library', type = str, dest = 'model_library', help = 'Override model library in the config file.' ) parser.add_argument( '--model-path' , type = str, dest = 'model_path' , help = 'Override model path in the config file.' ) parser.add_argument( '--num-topcis' , type = int, dest = 'num_topics' , help = 'Override number of topics in the config file.' ) parser.add_argument( '--data-path' , type = str, dest = 'data_path' , help = 'Override data path in the config file.' ) parser.add_argument( '--number-of-seriated-terms', type = int, dest = 'number_of_seriated_terms', help = 'Override the number of terms to seriate.' ) parser.add_argument( '--logging' , type = int, dest = 'logging' , help = 'Override logging level specified in config file.' ) args = parser.parse_args() corpus_format = None corpus_path = None model_library = None model_path = None data_path = None num_topics = None number_of_seriated_terms = None logging_level = 20 # Read in default values from the configuration file config = ConfigParser.RawConfigParser() config.read( args.config_file ) if config.has_section( 'Corpus' ) and config.has_option( 'Corpus', 'format' ): corpus_format = config.get( 'Corpus', 'format' ) if config.has_section( 'Corpus' ) and config.has_option( 'Corpus', 'path' ): corpus_path = config.get( 'Corpus', 'path' ) if config.has_section( 'Corpus' ) and config.has_option( 'Corpus', 'tokenization' ): tokenization = config.get( 'Corpus', 'tokenization' ) if config.has_section( 'TopicModel' ) and config.has_option( 'TopicModel', 'library' ): model_library = config.get( 'TopicModel', 'library' ) if config.has_section( 'TopicModel' ) and config.has_option( 'TopicModel', 'path' ): model_path = config.get( 'TopicModel', 'path' ) if config.has_section( 'TopicModel' ) and config.has_option( 'TopicModel', 'num_topics' ): num_topics = config.getint( 'TopicModel', 'num_topics' ) if config.has_section( 'Termite' ) and config.has_option( 'Termite', 'path' ): data_path = config.get( 'Termite', 'path' ) if config.has_section( 'Termite' ) and config.has_option( 'Termite', 'number_of_seriated_terms' ): number_of_seriated_terms = config.getint( 'Termite', 'number_of_seriated_terms' ) if config.has_section( 'Misc' ) and config.has_option( 'Misc', 'logging' ): logging_level = config.getint( 'Misc', 'logging' ) # Read in user-specifiec values from the program arguments if args.corpus_format is not None: corpus_format = args.corpus_format if args.corpus_path is not None: corpus_path = args.corpus_path if args.model_library is not None: model_library = args.model_library if args.model_path is not None: model_path = args.model_path if args.num_topics is not None: num_topics = args.num_topics if args.data_path is not None: data_path = args.data_path if args.number_of_seriated_terms is not None: number_of_seriated_terms = args.number_of_seriated_terms if args.logging is not None: logging_level = args.logging Execute( logging_level ).execute( corpus_format, corpus_path, tokenization, model_library, model_path, data_path, num_topics, number_of_seriated_terms ) if __name__ == '__main__': main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 984, 199, 646, 7534, 199, 646, 14196, 199, 646, 2050, 199, 199, 646, 900, 199, 646, 747, 199, 504, 7679, 14, 15246, 492, 8767, 794, 199, 504, 7679, 14, 646, 63, 2174, 2723, 492, 3161, 45, 9478, 199, 504, 7679, 14, 646, 63, 9649, 492, 3161, 32431, 199, 504, 7679, 14, 3357, 63, 6327, 73, 9501, 492, 8354, 51, 10874, 9501, 199, 504, 7679, 14, 3357, 63, 21965, 492, 8354, 7467, 13093, 199, 504, 7679, 14, 3357, 63, 261, 322, 425, 492, 8354, 1505, 73, 425, 199, 504, 7679, 14, 6726, 63, 576, 63, 509, 63, 1258, 492, 17008, 1451, 1858, 3041, 199, 199, 533, 17009, 8, 909, 3461, 421, 198, 624, 199, 198, 16291, 8039, 666, 6661, 7679, 436, 5951, 1536, 1890, 14, 8299, 198, 12049, 666, 6661, 10554, 315, 1865, 26, 507, 198, 17, 14, 13343, 14, 647, 26, 9622, 198, 3264, 794, 16831, 507, 198, 18, 14, 3560, 63, 9649, 15, 2174, 2723, 14, 647, 26, 198, 18591, 1402, 507, 198, 19, 14, 4526, 63, 6327, 73, 9501, 14, 647, 26, 198, 198, 8564, 6707, 308, 10874, 9501, 507, 198, 20, 14, 4526, 63, 21965, 14, 647, 26, 198, 8564, 6707, 22838, 507, 198, 21, 14, 4526, 63, 261, 322, 425, 14, 647, 26, 198, 1505, 73, 2335, 2895, 507, 198, 22, 14, 9275, 63, 576, 63, 509, 63, 1258, 14, 647, 26, 198, 20551, 666, 1725, 367, 1890, 507, 198, 23, 14, 9275, 63, 5068, 63, 509, 63, 1258, 14, 647, 26, 198, 29042, 5784, 10554, 367, 1890, 8299, 198, 3205, 365, 2897, 570, 9176, 1347, 16831, 436, 5724, 2082, 14, 8299, 198, 10607, 3663, 6602, 626, 3877, 1584, 687, 1924, 9546, 402, 314, 7679, 14, 9948, 198, 33, 22130, 314, 6602, 365, 314, 4575, 63, 1360, 2082, 626, 15164, 1006, 1890, 1584, 14, 199, 198, 624, 8299, 198, 3472, 63, 7125, 63, 11422, 21174, 275, 5661, 8299, 198, 318, 636, 826, 721, 291, 12, 2050, 63, 1896, 3461, 507, 198, 277, 14, 2921, 275, 2050, 14, 5572, 8, 283, 12049, 7, 776, 507, 198, 277, 14, 2921, 14, 13548, 8, 2050, 63, 1896, 776, 507, 198, 2232, 275, 2050, 14, 22482, 8, 984, 14, 3083, 776, 507, 198, 2232, 14, 13548, 8, 2050, 63, 1896, 776, 507, 198, 277, 14, 2921, 14, 18826, 8, 3016, 776, 8299, 198, 318, 5341, 8, 291, 12, 16831, 63, 908, 12, 16831, 63, 515, 12, 1526, 2072, 12, 1402, 63, 4342, 12, 1402, 63, 515, 12, 666, 63, 515, 12, 1967, 63, 11299, 12, 1329, 63, 1618, 63, 261, 322, 972, 63, 9187, 3461, 9068, 198, 479, 16831, 63, 908, 365, 440, 488, 507, 198, 479, 16831, 63, 515, 365, 440, 488, 507, 198, 479, 1402, 63, 4342, 365, 440, 488, 507, 198, 479, 1402, 63, 4342, 508, 283, 9649, 7, 503, 1402, 63, 4342, 508, 283, 2174, 2723, 7, 507, 198, 479, 1402, 63, 515, 365, 440, 488, 507, 198, 479, 666, 63, 515, 365, 440, 488, 507, 198, 692, 1967, 63, 11299, 365, 488, 26, 686, 198, 1507, 63, 11299, 275, 17009, 14, 3472, 63, 7125, 63, 11422, 21174, 507, 198, 479, 1329, 63, 1618, 63, 261, 322, 972, 63, 9187, 365, 440, 488, 9068, 198, 277, 14, 2921, 14, 815, 8, 283, 3606, 777, 7, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 3264, 9147, 1350, 16831, 13698, 2476, 10473, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 259, 16831, 63, 515, 275, 450, 83, 4366, 83, 3196, 16831, 63, 515, 12, 16831, 63, 908, 14960, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 259, 1402, 63, 515, 275, 450, 83, 4366, 83, 3196, 1402, 63, 515, 12, 1402, 63, 4342, 19242, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 259, 666, 63, 515, 275, 450, 83, 297, 666, 63, 515, 2476, 8540, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 259, 1967, 63, 11299, 275, 450, 68, 297, 1967, 63, 11299, 2476, 8295, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 259, 1329, 63, 1618, 63, 261, 322, 972, 63, 9187, 275, 450, 83, 297, 1329, 63, 1618, 63, 261, 322, 972, 63, 9187, 10473, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 3606, 777, 7, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 5639, 900, 275, 9499, 908, 8, 900, 14, 20691, 342, 776, 776, 9068, 198, 3264, 794, 8, 291, 14, 2921, 14, 1896, 7092, 2526, 8, 16831, 63, 908, 12, 16831, 63, 515, 12, 666, 63, 515, 12, 1526, 2072, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 5639, 900, 275, 9499, 908, 8, 900, 14, 20691, 342, 776, 776, 9068, 198, 692, 1402, 63, 4342, 508, 283, 9649, 356, 686, 198, 1531, 275, 283, 7379, 15, 2834, 63, 9649, 14, 609, 1052, 1052, 9499, 908, 8, 666, 63, 515, 435, 1994, 4504, 15, 4504, 14, 2424, 297, 1402, 63, 515, 12, 1967, 63, 11299, 776, 686, 198, 736, 14, 2253, 8, 1414, 776, 686, 198, 6295, 32431, 8, 291, 14, 2921, 14, 1896, 7092, 2526, 8, 1402, 63, 4342, 12, 1402, 63, 515, 12, 666, 63, 515, 776, 507, 198, 692, 1402, 63, 4342, 508, 283, 2174, 2723, 356, 686, 198, 1531, 275, 283, 7379, 15, 2834, 63, 2174, 2723, 14, 609, 1052, 1052, 9499, 908, 8, 666, 63, 515, 435, 1994, 4504, 15, 4504, 14, 2424, 297, 1402, 63, 515, 12, 1967, 63, 11299, 776, 686, 198, 736, 14, 2253, 8, 1414, 776, 686, 198, 6295, 45, 9478, 8, 291, 14, 2921, 14, 1896, 7092, 2526, 8, 1402, 63, 4342, 12, 1402, 63, 515, 12, 666, 63, 515, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 5639, 900, 275, 9499, 908, 8, 900, 14, 20691, 342, 776, 776, 9068, 198, 8564, 51, 10874, 9501, 8, 291, 14, 2921, 14, 1896, 7092, 2526, 8, 666, 63, 515, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 5639, 900, 275, 9499, 908, 8, 900, 14, 20691, 342, 776, 776, 2742, 198, 8564, 7467, 13093, 8, 291 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 984, 199, 646, 7534, 199, 646, 14196, 199, 646, 2050, 199, 199, 646, 900, 199, 646, 747, 199, 504, 7679, 14, 15246, 492, 8767, 794, 199, 504, 7679, 14, 646, 63, 2174, 2723, 492, 3161, 45, 9478, 199, 504, 7679, 14, 646, 63, 9649, 492, 3161, 32431, 199, 504, 7679, 14, 3357, 63, 6327, 73, 9501, 492, 8354, 51, 10874, 9501, 199, 504, 7679, 14, 3357, 63, 21965, 492, 8354, 7467, 13093, 199, 504, 7679, 14, 3357, 63, 261, 322, 425, 492, 8354, 1505, 73, 425, 199, 504, 7679, 14, 6726, 63, 576, 63, 509, 63, 1258, 492, 17008, 1451, 1858, 3041, 199, 199, 533, 17009, 8, 909, 3461, 421, 198, 624, 199, 198, 16291, 8039, 666, 6661, 7679, 436, 5951, 1536, 1890, 14, 8299, 198, 12049, 666, 6661, 10554, 315, 1865, 26, 507, 198, 17, 14, 13343, 14, 647, 26, 9622, 198, 3264, 794, 16831, 507, 198, 18, 14, 3560, 63, 9649, 15, 2174, 2723, 14, 647, 26, 198, 18591, 1402, 507, 198, 19, 14, 4526, 63, 6327, 73, 9501, 14, 647, 26, 198, 198, 8564, 6707, 308, 10874, 9501, 507, 198, 20, 14, 4526, 63, 21965, 14, 647, 26, 198, 8564, 6707, 22838, 507, 198, 21, 14, 4526, 63, 261, 322, 425, 14, 647, 26, 198, 1505, 73, 2335, 2895, 507, 198, 22, 14, 9275, 63, 576, 63, 509, 63, 1258, 14, 647, 26, 198, 20551, 666, 1725, 367, 1890, 507, 198, 23, 14, 9275, 63, 5068, 63, 509, 63, 1258, 14, 647, 26, 198, 29042, 5784, 10554, 367, 1890, 8299, 198, 3205, 365, 2897, 570, 9176, 1347, 16831, 436, 5724, 2082, 14, 8299, 198, 10607, 3663, 6602, 626, 3877, 1584, 687, 1924, 9546, 402, 314, 7679, 14, 9948, 198, 33, 22130, 314, 6602, 365, 314, 4575, 63, 1360, 2082, 626, 15164, 1006, 1890, 1584, 14, 199, 198, 624, 8299, 198, 3472, 63, 7125, 63, 11422, 21174, 275, 5661, 8299, 198, 318, 636, 826, 721, 291, 12, 2050, 63, 1896, 3461, 507, 198, 277, 14, 2921, 275, 2050, 14, 5572, 8, 283, 12049, 7, 776, 507, 198, 277, 14, 2921, 14, 13548, 8, 2050, 63, 1896, 776, 507, 198, 2232, 275, 2050, 14, 22482, 8, 984, 14, 3083, 776, 507, 198, 2232, 14, 13548, 8, 2050, 63, 1896, 776, 507, 198, 277, 14, 2921, 14, 18826, 8, 3016, 776, 8299, 198, 318, 5341, 8, 291, 12, 16831, 63, 908, 12, 16831, 63, 515, 12, 1526, 2072, 12, 1402, 63, 4342, 12, 1402, 63, 515, 12, 666, 63, 515, 12, 1967, 63, 11299, 12, 1329, 63, 1618, 63, 261, 322, 972, 63, 9187, 3461, 9068, 198, 479, 16831, 63, 908, 365, 440, 488, 507, 198, 479, 16831, 63, 515, 365, 440, 488, 507, 198, 479, 1402, 63, 4342, 365, 440, 488, 507, 198, 479, 1402, 63, 4342, 508, 283, 9649, 7, 503, 1402, 63, 4342, 508, 283, 2174, 2723, 7, 507, 198, 479, 1402, 63, 515, 365, 440, 488, 507, 198, 479, 666, 63, 515, 365, 440, 488, 507, 198, 692, 1967, 63, 11299, 365, 488, 26, 686, 198, 1507, 63, 11299, 275, 17009, 14, 3472, 63, 7125, 63, 11422, 21174, 507, 198, 479, 1329, 63, 1618, 63, 261, 322, 972, 63, 9187, 365, 440, 488, 9068, 198, 277, 14, 2921, 14, 815, 8, 283, 3606, 777, 7, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 3264, 9147, 1350, 16831, 13698, 2476, 10473, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 259, 16831, 63, 515, 275, 450, 83, 4366, 83, 3196, 16831, 63, 515, 12, 16831, 63, 908, 14960, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 259, 1402, 63, 515, 275, 450, 83, 4366, 83, 3196, 1402, 63, 515, 12, 1402, 63, 4342, 19242, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 259, 666, 63, 515, 275, 450, 83, 297, 666, 63, 515, 2476, 8540, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 259, 1967, 63, 11299, 275, 450, 68, 297, 1967, 63, 11299, 2476, 8295, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 259, 1329, 63, 1618, 63, 261, 322, 972, 63, 9187, 275, 450, 83, 297, 1329, 63, 1618, 63, 261, 322, 972, 63, 9187, 10473, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 3606, 777, 7, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 5639, 900, 275, 9499, 908, 8, 900, 14, 20691, 342, 776, 776, 9068, 198, 3264, 794, 8, 291, 14, 2921, 14, 1896, 7092, 2526, 8, 16831, 63, 908, 12, 16831, 63, 515, 12, 666, 63, 515, 12, 1526, 2072, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 5639, 900, 275, 9499, 908, 8, 900, 14, 20691, 342, 776, 776, 9068, 198, 692, 1402, 63, 4342, 508, 283, 9649, 356, 686, 198, 1531, 275, 283, 7379, 15, 2834, 63, 9649, 14, 609, 1052, 1052, 9499, 908, 8, 666, 63, 515, 435, 1994, 4504, 15, 4504, 14, 2424, 297, 1402, 63, 515, 12, 1967, 63, 11299, 776, 686, 198, 736, 14, 2253, 8, 1414, 776, 686, 198, 6295, 32431, 8, 291, 14, 2921, 14, 1896, 7092, 2526, 8, 1402, 63, 4342, 12, 1402, 63, 515, 12, 666, 63, 515, 776, 507, 198, 692, 1402, 63, 4342, 508, 283, 2174, 2723, 356, 686, 198, 1531, 275, 283, 7379, 15, 2834, 63, 2174, 2723, 14, 609, 1052, 1052, 9499, 908, 8, 666, 63, 515, 435, 1994, 4504, 15, 4504, 14, 2424, 297, 1402, 63, 515, 12, 1967, 63, 11299, 776, 686, 198, 736, 14, 2253, 8, 1414, 776, 686, 198, 6295, 45, 9478, 8, 291, 14, 2921, 14, 1896, 7092, 2526, 8, 1402, 63, 4342, 12, 1402, 63, 515, 12, 666, 63, 515, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 5639, 900, 275, 9499, 908, 8, 900, 14, 20691, 342, 776, 776, 9068, 198, 8564, 51, 10874, 9501, 8, 291, 14, 2921, 14, 1896, 7092, 2526, 8, 666, 63, 515, 776, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 5639, 900, 275, 9499, 908, 8, 900, 14, 20691, 342, 776, 776, 2742, 198, 8564, 7467, 13093, 8, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
PowerHMC/HmcRestClient
src/managed_system/PowerOnManagedSystem.py
1
2162
# Copyright 2015, 2016 IBM Corp. # # 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 src.utility import HTTPClient,HmcHeaders,HMCClientLogger import xml.etree.ElementTree as etree import os log = HMCClientLogger.HMCClientLogger(__name__) from src.common.JobStatus import * ROOT = 'ManagedSystem' CONTENT_TYPE ='application/vnd.ibm.powervm.web+xml; type=JobRequest' class PowerOnManagedSystem(JobStatus): """ Power On the Selected ManagedSystem if its not in operating state else shows error """ def __init__(self): """ initializes root and content-type """ self.content_type = CONTENT_TYPE self.root = ROOT def poweron_ManagedSystem(self, ip, managedsystem_uuid, x_api_session): """ Args: ip:ip address of hmc managedsystem_uuid:UUID of managedsystem x_api_session:session to be used """ super().__init__(ip, self.root, self.content_type, x_api_session) log.log_debug("power on managed system started") headers_object=HmcHeaders.HmcHeaders("web") namespace=headers_object.ns["xmlns"] directory = os.path.dirname(__file__) inputpayload=open(directory+"\data\poweron_managedsystem.xml","r") request_object=HTTPClient.HTTPClient('uom',ip,self.root,self.content_type,session_id=x_api_session) request_object.HTTPPut(payload=inputpayload,append=str(managedsystem_uuid)+"/do/PowerOn") log.log_debug(request_object.response) if request_object.response_b: self.get_job_status(request_object)
apache-2.0
[ 3, 1898, 6900, 12, 7800, 26202, 22304, 14, 199, 3, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 2928, 14, 16877, 492, 3101, 3041, 12, 40, 5466, 9883, 12, 27699, 2571, 864, 4455, 199, 646, 2748, 14, 9464, 14, 15325, 465, 7559, 199, 646, 747, 199, 793, 275, 869, 45, 2571, 864, 4455, 14, 27699, 2571, 864, 4455, 3460, 354, 3368, 199, 504, 2928, 14, 2330, 14, 6694, 3694, 492, 627, 199, 199, 5441, 275, 283, 22625, 3989, 7, 199, 9663, 63, 2711, 275, 7, 3578, 15, 26379, 14, 19870, 14, 5652, 2611, 14, 2520, 11, 1652, 27, 730, 29, 6694, 2017, 7, 199, 199, 533, 18879, 3314, 22625, 3989, 8, 6694, 3694, 304, 272, 408, 272, 18879, 4068, 314, 3240, 2820, 4688, 6028, 3989, 340, 2399, 440, 315, 17406, 1174, 587, 272, 13703, 1125, 272, 408, 2286, 347, 636, 826, 721, 277, 304, 267, 408, 268, 2536, 6491, 1738, 436, 1564, 13, 466, 267, 408, 267, 291, 14, 1317, 63, 466, 275, 29417, 63, 2711, 267, 291, 14, 1231, 275, 16547, 339, 347, 7074, 265, 63, 22625, 3989, 8, 277, 12, 3384, 12, 9635, 795, 3045, 63, 2580, 12, 671, 63, 1246, 63, 1730, 304, 267, 408, 267, 3033, 26, 288, 3384, 26, 711, 2287, 402, 394, 5466, 288, 9635, 795, 3045, 63, 2580, 26, 8757, 402, 9635, 795, 3045, 288, 671, 63, 1246, 63, 1730, 26, 1730, 370, 506, 1202, 267, 408, 267, 1613, 11027, 826, 721, 711, 12, 291, 14, 1231, 12, 291, 14, 1317, 63, 466, 12, 671, 63, 1246, 63, 1730, 9, 267, 943, 14, 793, 63, 1757, 480, 5652, 641, 12883, 2656, 8239, 531, 267, 2323, 63, 785, 29, 40, 5466, 9883, 14, 40, 5466, 9883, 480, 2520, 531, 267, 3231, 29, 2139, 63, 785, 14, 561, 905, 13991, 937, 267, 2082, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 267, 1324, 4749, 29, 1490, 8, 3619, 25789, 576, 60, 5652, 265, 63, 9053, 795, 3045, 14, 1652, 2266, 82, 531, 267, 1056, 63, 785, 29, 27757, 14, 27757, 360, 7519, 297, 711, 12, 277, 14, 1231, 12, 277, 14, 1317, 63, 466, 12, 1730, 63, 344, 29, 88, 63, 1246, 63, 1730, 9, 267, 1056, 63, 785, 14, 2856, 18989, 8, 4749, 29, 1210, 4749, 12, 740, 29, 495, 8, 9053, 795, 3045, 63, 2580, 18663, 15, 1117, 15, 6921, 3314, 531, 267, 943, 14, 793, 63, 1757, 8, 1069, 63, 785, 14, 1310, 9, 267, 340, 1056, 63, 785, 14, 1310, 63, 66, 26, 288, 291, 14, 362, 63, 2423, 63, 1205, 8, 1069, 63, 785, 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 ]
[ 1898, 6900, 12, 7800, 26202, 22304, 14, 199, 3, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 2928, 14, 16877, 492, 3101, 3041, 12, 40, 5466, 9883, 12, 27699, 2571, 864, 4455, 199, 646, 2748, 14, 9464, 14, 15325, 465, 7559, 199, 646, 747, 199, 793, 275, 869, 45, 2571, 864, 4455, 14, 27699, 2571, 864, 4455, 3460, 354, 3368, 199, 504, 2928, 14, 2330, 14, 6694, 3694, 492, 627, 199, 199, 5441, 275, 283, 22625, 3989, 7, 199, 9663, 63, 2711, 275, 7, 3578, 15, 26379, 14, 19870, 14, 5652, 2611, 14, 2520, 11, 1652, 27, 730, 29, 6694, 2017, 7, 199, 199, 533, 18879, 3314, 22625, 3989, 8, 6694, 3694, 304, 272, 408, 272, 18879, 4068, 314, 3240, 2820, 4688, 6028, 3989, 340, 2399, 440, 315, 17406, 1174, 587, 272, 13703, 1125, 272, 408, 2286, 347, 636, 826, 721, 277, 304, 267, 408, 268, 2536, 6491, 1738, 436, 1564, 13, 466, 267, 408, 267, 291, 14, 1317, 63, 466, 275, 29417, 63, 2711, 267, 291, 14, 1231, 275, 16547, 339, 347, 7074, 265, 63, 22625, 3989, 8, 277, 12, 3384, 12, 9635, 795, 3045, 63, 2580, 12, 671, 63, 1246, 63, 1730, 304, 267, 408, 267, 3033, 26, 288, 3384, 26, 711, 2287, 402, 394, 5466, 288, 9635, 795, 3045, 63, 2580, 26, 8757, 402, 9635, 795, 3045, 288, 671, 63, 1246, 63, 1730, 26, 1730, 370, 506, 1202, 267, 408, 267, 1613, 11027, 826, 721, 711, 12, 291, 14, 1231, 12, 291, 14, 1317, 63, 466, 12, 671, 63, 1246, 63, 1730, 9, 267, 943, 14, 793, 63, 1757, 480, 5652, 641, 12883, 2656, 8239, 531, 267, 2323, 63, 785, 29, 40, 5466, 9883, 14, 40, 5466, 9883, 480, 2520, 531, 267, 3231, 29, 2139, 63, 785, 14, 561, 905, 13991, 937, 267, 2082, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 267, 1324, 4749, 29, 1490, 8, 3619, 25789, 576, 60, 5652, 265, 63, 9053, 795, 3045, 14, 1652, 2266, 82, 531, 267, 1056, 63, 785, 29, 27757, 14, 27757, 360, 7519, 297, 711, 12, 277, 14, 1231, 12, 277, 14, 1317, 63, 466, 12, 1730, 63, 344, 29, 88, 63, 1246, 63, 1730, 9, 267, 1056, 63, 785, 14, 2856, 18989, 8, 4749, 29, 1210, 4749, 12, 740, 29, 495, 8, 9053, 795, 3045, 63, 2580, 18663, 15, 1117, 15, 6921, 3314, 531, 267, 943, 14, 793, 63, 1757, 8, 1069, 63, 785, 14, 1310, 9, 267, 340, 1056, 63, 785, 14, 1310, 63, 66, 26, 288, 291, 14, 362, 63, 2423, 63, 1205, 8, 1069, 63, 785, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mtconley/turntable
test/lib/python2.7/site-packages/scipy/interpolate/fitpack2.py
7
57978
""" fitpack --- curve and surface fitting with splines fitpack is based on a collection of Fortran routines DIERCKX by P. Dierckx (see http://www.netlib.org/dierckx/) transformed to double routines by Pearu Peterson. """ # Created by Pearu Peterson, June,August 2003 from __future__ import division, print_function, absolute_import __all__ = [ 'UnivariateSpline', 'InterpolatedUnivariateSpline', 'LSQUnivariateSpline', 'BivariateSpline', 'LSQBivariateSpline', 'SmoothBivariateSpline', 'LSQSphereBivariateSpline', 'SmoothSphereBivariateSpline', 'RectBivariateSpline', 'RectSphereBivariateSpline'] import warnings from numpy import zeros, concatenate, alltrue, ravel, all, diff, array, ones import numpy as np from . import fitpack from . import dfitpack ################ Univariate spline #################### _curfit_messages = {1:""" The required storage space exceeds the available storage space, as specified by the parameter nest: nest too small. If nest is already large (say nest > m/2), it may also indicate that s is too small. The approximation returned is the weighted least-squares spline according to the knots t[0],t[1],...,t[n-1]. (n=nest) the parameter fp gives the corresponding weighted sum of squared residuals (fp>s). """, 2:""" A theoretically impossible result was found during the iteration proces for finding a smoothing spline with fp = s: s too small. There is an approximation returned but the corresponding weighted sum of squared residuals does not satisfy the condition abs(fp-s)/s < tol.""", 3:""" The maximal number of iterations maxit (set to 20 by the program) allowed for finding a smoothing spline with fp=s has been reached: s too small. There is an approximation returned but the corresponding weighted sum of squared residuals does not satisfy the condition abs(fp-s)/s < tol.""", 10:""" Error on entry, no approximation returned. The following conditions must hold: xb<=x[0]<x[1]<...<x[m-1]<=xe, w[i]>0, i=0..m-1 if iopt=-1: xb<t[k+1]<t[k+2]<...<t[n-k-2]<xe""" } # UnivariateSpline, ext parameter can be an int or a string _extrap_modes = {0: 0, 'extrapolate': 0, 1: 1, 'zeros': 1, 2: 2, 'raise': 2, 3: 3, 'const': 3} class UnivariateSpline(object): """ One-dimensional smoothing spline fit to a given set of data points. Fits a spline y = spl(x) of degree `k` to the provided `x`, `y` data. `s` specifies the number of knots by specifying a smoothing condition. Parameters ---------- x : (N,) array_like 1-D array of independent input data. Must be increasing. y : (N,) array_like 1-D array of dependent input data, of the same length as `x`. w : (N,) array_like, optional Weights for spline fitting. Must be positive. If None (default), weights are all equal. bbox : (2,) array_like, optional 2-sequence specifying the boundary of the approximation interval. If None (default), ``bbox=[x[0], x[-1]]``. k : int, optional Degree of the smoothing spline. Must be <= 5. Default is k=3, a cubic spline. s : float or None, optional Positive smoothing factor used to choose the number of knots. Number of knots will be increased until the smoothing condition is satisfied:: sum((w[i] * (y[i]-spl(x[i])))**2, axis=0) <= s If None (default), ``s = len(w)`` which should be a good value if ``1/w[i]`` is an estimate of the standard deviation of ``y[i]``. If 0, spline will interpolate through all data points. ext : int or str, optional Controls the extrapolation mode for elements not in the interval defined by the knot sequence. * if ext=0 or 'extrapolate', return the extrapolated value. * if ext=1 or 'zeros', return 0 * if ext=2 or 'raise', raise a ValueError * if ext=3 of 'const', return the boundary value. The default value is 0. See Also -------- InterpolatedUnivariateSpline : Subclass with smoothing forced to 0 LSQUnivariateSpline : Subclass in which knots are user-selected instead of being set by smoothing condition splrep : An older, non object-oriented wrapping of FITPACK splev, sproot, splint, spalde BivariateSpline : A similar class for two-dimensional spline interpolation Notes ----- The number of data points must be larger than the spline degree `k`. **NaN handling**: If the input arrays contain ``nan`` values, the result is not useful, since the underlying spline fitting routines cannot deal with ``nan`` . A workaround is to use zero weights for not-a-number data points: >>> w = np.isnan(y) >>> y[w] = 0. >>> spl = UnivariateSpline(x, y, w=~w) Notice the need to replace a ``nan`` by a numerical value (precise value does not matter as long as the corresponding weight is zero.) Examples -------- >>> import matplotlib.pyplot as plt >>> from scipy.interpolate import UnivariateSpline >>> x = np.linspace(-3, 3, 50) >>> y = np.exp(-x**2) + 0.1 * np.random.randn(50) >>> plt.plot(x, y, 'ro', ms=5) Use the default value for the smoothing parameter: >>> spl = UnivariateSpline(x, y) >>> xs = np.linspace(-3, 3, 1000) >>> plt.plot(xs, spl(xs), 'g', lw=3) Manually change the amount of smoothing: >>> spl.set_smoothing_factor(0.5) >>> plt.plot(xs, spl(xs), 'b', lw=3) >>> plt.show() """ def __init__(self, x, y, w=None, bbox=[None]*2, k=3, s=None, ext=0): # _data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier try: self.ext = _extrap_modes[ext] except KeyError: raise ValueError("Unknown extrapolation mode %s." % ext) data = dfitpack.fpcurf0(x,y,k,w=w, xb=bbox[0],xe=bbox[1],s=s) if data[-1] == 1: # nest too small, setting to maximum bound data = self._reset_nest(data) self._data = data self._reset_class() @classmethod def _from_tck(cls, tck, ext=0): """Construct a spline object from given tck""" self = cls.__new__(cls) t, c, k = tck self._eval_args = tck #_data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier self._data = (None,None,None,None,None,k,None,len(t),t, c,None,None,None,None) self.ext = ext return self def _reset_class(self): data = self._data n,t,c,k,ier = data[7],data[8],data[9],data[5],data[-1] self._eval_args = t[:n],c[:n],k if ier == 0: # the spline returned has a residual sum of squares fp # such that abs(fp-s)/s <= tol with tol a relative # tolerance set to 0.001 by the program pass elif ier == -1: # the spline returned is an interpolating spline self._set_class(InterpolatedUnivariateSpline) elif ier == -2: # the spline returned is the weighted least-squares # polynomial of degree k. In this extreme case fp gives # the upper bound fp0 for the smoothing factor s. self._set_class(LSQUnivariateSpline) else: # error if ier == 1: self._set_class(LSQUnivariateSpline) message = _curfit_messages.get(ier,'ier=%s' % (ier)) warnings.warn(message) def _set_class(self, cls): self._spline_class = cls if self.__class__ in (UnivariateSpline, InterpolatedUnivariateSpline, LSQUnivariateSpline): self.__class__ = cls else: # It's an unknown subclass -- don't change class. cf. #731 pass def _reset_nest(self, data, nest=None): n = data[10] if nest is None: k,m = data[5],len(data[0]) nest = m+k+1 # this is the maximum bound for nest else: if not n <= nest: raise ValueError("`nest` can only be increased") t, c, fpint, nrdata = [np.resize(data[j], nest) for j in [8,9,11,12]] args = data[:8] + (t,c,n,fpint,nrdata,data[13]) data = dfitpack.fpcurf1(*args) return data def set_smoothing_factor(self, s): """ Continue spline computation with the given smoothing factor s and with the knots found at the last call. This routine modifies the spline in place. """ data = self._data if data[6] == -1: warnings.warn('smoothing factor unchanged for' 'LSQ spline with fixed knots') return args = data[:6] + (s,) + data[7:] data = dfitpack.fpcurf1(*args) if data[-1] == 1: # nest too small, setting to maximum bound data = self._reset_nest(data) self._data = data self._reset_class() def __call__(self, x, nu=0, ext=None): """ Evaluate spline (or its nu-th derivative) at positions x. Parameters ---------- x : array_like A 1-D array of points at which to return the value of the smoothed spline or its derivatives. Note: x can be unordered but the evaluation is more efficient if x is (partially) ordered. nu : int The order of derivative of the spline to compute. ext : int Controls the value returned for elements of ``x`` not in the interval defined by the knot sequence. * if ext=0 or 'extrapolate', return the extrapolated value. * if ext=1 or 'zeros', return 0 * if ext=2 or 'raise', raise a ValueError * if ext=3 or 'const', return the boundary value. The default value is 0, passed from the initialization of UnivariateSpline. """ x = np.asarray(x) # empty input yields empty output if x.size == 0: return array([]) # if nu is None: # return dfitpack.splev(*(self._eval_args+(x,))) # return dfitpack.splder(nu=nu,*(self._eval_args+(x,))) if ext is None: ext = self.ext else: try: ext = _extrap_modes[ext] except KeyError: raise ValueError("Unknown extrapolation mode %s." % ext) return fitpack.splev(x, self._eval_args, der=nu, ext=ext) def get_knots(self): """ Return positions of (boundary and interior) knots of the spline. """ data = self._data k,n = data[5],data[7] return data[8][k:n-k] def get_coeffs(self): """Return spline coefficients.""" data = self._data k,n = data[5],data[7] return data[9][:n-k-1] def get_residual(self): """Return weighted sum of squared residuals of the spline approximation: ``sum((w[i] * (y[i]-spl(x[i])))**2, axis=0)``. """ return self._data[10] def integral(self, a, b): """ Return definite integral of the spline between two given points. """ return dfitpack.splint(*(self._eval_args+(a,b))) def derivatives(self, x): """ Return all derivatives of the spline at the point x.""" d,ier = dfitpack.spalde(*(self._eval_args+(x,))) if not ier == 0: raise ValueError("Error code returned by spalde: %s" % ier) return d def roots(self): """ Return the zeros of the spline. Restriction: only cubic splines are supported by fitpack. """ k = self._data[5] if k == 3: z,m,ier = dfitpack.sproot(*self._eval_args[:2]) if not ier == 0: raise ValueError("Error code returned by spalde: %s" % ier) return z[:m] raise NotImplementedError('finding roots unsupported for ' 'non-cubic splines') def derivative(self, n=1): """ Construct a new spline representing the derivative of this spline. Parameters ---------- n : int, optional Order of derivative to evaluate. Default: 1 Returns ------- spline : UnivariateSpline Spline of order k2=k-n representing the derivative of this spline. See Also -------- splder, antiderivative Notes ----- .. versionadded:: 0.13.0 Examples -------- This can be used for finding maxima of a curve: >>> from scipy.interpolate import UnivariateSpline >>> x = np.linspace(0, 10, 70) >>> y = np.sin(x) >>> spl = UnivariateSpline(x, y, k=4, s=0) Now, differentiate the spline and find the zeros of the derivative. (NB: `sproot` only works for order 3 splines, so we fit an order 4 spline): >>> spl.derivative().roots() / np.pi array([ 0.50000001, 1.5 , 2.49999998]) This agrees well with roots :math:`\pi/2 + n\pi` of `cos(x) = sin'(x)`. """ tck = fitpack.splder(self._eval_args, n) return UnivariateSpline._from_tck(tck, self.ext) def antiderivative(self, n=1): """ Construct a new spline representing the antiderivative of this spline. Parameters ---------- n : int, optional Order of antiderivative to evaluate. Default: 1 Returns ------- spline : UnivariateSpline Spline of order k2=k+n representing the antiderivative of this spline. Notes ----- .. versionadded:: 0.13.0 See Also -------- splantider, derivative Examples -------- >>> from scipy.interpolate import UnivariateSpline >>> x = np.linspace(0, np.pi/2, 70) >>> y = 1 / np.sqrt(1 - 0.8*np.sin(x)**2) >>> spl = UnivariateSpline(x, y, s=0) The derivative is the inverse operation of the antiderivative, although some floating point error accumulates: >>> spl(1.7), spl.antiderivative().derivative()(1.7) (array(2.1565429877197317), array(2.1565429877201865)) Antiderivative can be used to evaluate definite integrals: >>> ispl = spl.antiderivative() >>> ispl(np.pi/2) - ispl(0) 2.2572053588768486 This is indeed an approximation to the complete elliptic integral :math:`K(m) = \\int_0^{\\pi/2} [1 - m\\sin^2 x]^{-1/2} dx`: >>> from scipy.special import ellipk >>> ellipk(0.8) 2.2572053268208538 """ tck = fitpack.splantider(self._eval_args, n) return UnivariateSpline._from_tck(tck, self.ext) class InterpolatedUnivariateSpline(UnivariateSpline): """ One-dimensional interpolating spline for a given set of data points. Fits a spline y = spl(x) of degree `k` to the provided `x`, `y` data. Spline function passes through all provided points. Equivalent to `UnivariateSpline` with s=0. Parameters ---------- x : (N,) array_like Input dimension of data points -- must be increasing y : (N,) array_like input dimension of data points w : (N,) array_like, optional Weights for spline fitting. Must be positive. If None (default), weights are all equal. bbox : (2,) array_like, optional 2-sequence specifying the boundary of the approximation interval. If None (default), ``bbox=[x[0], x[-1]]``. k : int, optional Degree of the smoothing spline. Must be 1 <= `k` <= 5. ext : int or str, optional Controls the extrapolation mode for elements not in the interval defined by the knot sequence. * if ext=0 or 'extrapolate', return the extrapolated value. * if ext=1 or 'zeros', return 0 * if ext=2 or 'raise', raise a ValueError * if ext=3 of 'const', return the boundary value. The default value is 0. See Also -------- UnivariateSpline : Superclass -- allows knots to be selected by a smoothing condition LSQUnivariateSpline : spline for which knots are user-selected splrep : An older, non object-oriented wrapping of FITPACK splev, sproot, splint, spalde BivariateSpline : A similar class for two-dimensional spline interpolation Notes ----- The number of data points must be larger than the spline degree `k`. Examples -------- >>> import matplotlib.pyplot as plt >>> from scipy.interpolate import InterpolatedUnivariateSpline >>> x = np.linspace(-3, 3, 50) >>> y = np.exp(-x**2) + 0.1 * np.random.randn(50) >>> spl = InterpolatedUnivariateSpline(x, y) >>> plt.plot(x, y, 'ro', ms=5) >>> xs = np.linspace(-3, 3, 1000) >>> plt.plot(xs, spl(xs), 'g', lw=3, alpha=0.7) >>> plt.show() Notice that the ``spl(x)`` interpolates `y`: >>> spl.get_residual() 0.0 """ def __init__(self, x, y, w=None, bbox=[None]*2, k=3, ext=0): # _data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier self._data = dfitpack.fpcurf0(x,y,k,w=w, xb=bbox[0],xe=bbox[1],s=0) self._reset_class() try: self.ext = _extrap_modes[ext] except KeyError: raise ValueError("Unknown extrapolation mode %s." % ext) _fpchec_error_string = """The input parameters have been rejected by fpchec. \ This means that at least one of the following conditions is violated: 1) k+1 <= n-k-1 <= m 2) t(1) <= t(2) <= ... <= t(k+1) t(n-k) <= t(n-k+1) <= ... <= t(n) 3) t(k+1) < t(k+2) < ... < t(n-k) 4) t(k+1) <= x(i) <= t(n-k) 5) The conditions specified by Schoenberg and Whitney must hold for at least one subset of data points, i.e., there must be a subset of data points y(j) such that t(j) < y(j) < t(j+k+1), j=1,2,...,n-k-1 """ class LSQUnivariateSpline(UnivariateSpline): """ One-dimensional spline with explicit internal knots. Fits a spline y = spl(x) of degree `k` to the provided `x`, `y` data. `t` specifies the internal knots of the spline Parameters ---------- x : (N,) array_like Input dimension of data points -- must be increasing y : (N,) array_like Input dimension of data points t : (M,) array_like interior knots of the spline. Must be in ascending order and:: bbox[0] < t[0] < ... < t[-1] < bbox[-1] w : (N,) array_like, optional weights for spline fitting. Must be positive. If None (default), weights are all equal. bbox : (2,) array_like, optional 2-sequence specifying the boundary of the approximation interval. If None (default), ``bbox = [x[0], x[-1]]``. k : int, optional Degree of the smoothing spline. Must be 1 <= `k` <= 5. Default is k=3, a cubic spline. ext : int or str, optional Controls the extrapolation mode for elements not in the interval defined by the knot sequence. * if ext=0 or 'extrapolate', return the extrapolated value. * if ext=1 or 'zeros', return 0 * if ext=2 or 'raise', raise a ValueError * if ext=3 of 'const', return the boundary value. The default value is 0. Raises ------ ValueError If the interior knots do not satisfy the Schoenberg-Whitney conditions See Also -------- UnivariateSpline : Superclass -- knots are specified by setting a smoothing condition InterpolatedUnivariateSpline : spline passing through all points splrep : An older, non object-oriented wrapping of FITPACK splev, sproot, splint, spalde BivariateSpline : A similar class for two-dimensional spline interpolation Notes ----- The number of data points must be larger than the spline degree `k`. Knots `t` must satisfy the Schoenberg-Whitney conditions, i.e., there must be a subset of data points ``x[j]`` such that ``t[j] < x[j] < t[j+k+1]``, for ``j=0, 1,...,n-k-2``. Examples -------- >>> from scipy.interpolate import LSQUnivariateSpline >>> import matplotlib.pyplot as plt >>> x = np.linspace(-3, 3, 50) >>> y = np.exp(-x**2) + 0.1 * np.random.randn(50) Fit a smoothing spline with a pre-defined internal knots: >>> t = [-1, 0, 1] >>> spl = LSQUnivariateSpline(x, y, t) >>> xs = np.linspace(-3, 3, 1000) >>> plt.plot(x, y, 'ro', ms=5) >>> plt.plot(xs, spl(xs), 'g-', lw=3) >>> plt.show() Check the knot vector: >>> spl.get_knots() array([-3., -1., 0., 1., 3.]) """ def __init__(self, x, y, t, w=None, bbox=[None]*2, k=3, ext=0): # _data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier xb = bbox[0] xe = bbox[1] if xb is None: xb = x[0] if xe is None: xe = x[-1] t = concatenate(([xb]*(k+1), t, [xe]*(k+1))) n = len(t) if not alltrue(t[k+1:n-k]-t[k:n-k-1] > 0, axis=0): raise ValueError('Interior knots t must satisfy ' 'Schoenberg-Whitney conditions') if not dfitpack.fpchec(x, t, k) == 0: raise ValueError(_fpchec_error_string) data = dfitpack.fpcurfm1(x, y, k, t, w=w, xb=xb, xe=xe) self._data = data[:-3] + (None, None, data[-1]) self._reset_class() try: self.ext = _extrap_modes[ext] except KeyError: raise ValueError("Unknown extrapolation mode %s." % ext) ################ Bivariate spline #################### class _BivariateSplineBase(object): """ Base class for Bivariate spline s(x,y) interpolation on the rectangle [xb,xe] x [yb, ye] calculated from a given set of data points (x,y,z). See Also -------- bisplrep, bisplev : an older wrapping of FITPACK BivariateSpline : implementation of bivariate spline interpolation on a plane grid SphereBivariateSpline : implementation of bivariate spline interpolation on a spherical grid """ def get_residual(self): """ Return weighted sum of squared residuals of the spline approximation: sum ((w[i]*(z[i]-s(x[i],y[i])))**2,axis=0) """ return self.fp def get_knots(self): """ Return a tuple (tx,ty) where tx,ty contain knots positions of the spline with respect to x-, y-variable, respectively. The position of interior and additional knots are given as t[k+1:-k-1] and t[:k+1]=b, t[-k-1:]=e, respectively. """ return self.tck[:2] def get_coeffs(self): """ Return spline coefficients.""" return self.tck[2] def __call__(self, x, y, mth=None, dx=0, dy=0, grid=True): """ Evaluate the spline or its derivatives at given positions. Parameters ---------- x, y : array-like Input coordinates. If `grid` is False, evaluate the spline at points ``(x[i], y[i]), i=0, ..., len(x)-1``. Standard Numpy broadcasting is obeyed. If `grid` is True: evaluate spline at the grid points defined by the coordinate arrays x, y. The arrays must be sorted to increasing order. dx : int Order of x-derivative .. versionadded:: 0.14.0 dy : int Order of y-derivative .. versionadded:: 0.14.0 grid : bool Whether to evaluate the results on a grid spanned by the input arrays, or at points specified by the input arrays. .. versionadded:: 0.14.0 mth : str Deprecated argument. Has no effect. """ x = np.asarray(x) y = np.asarray(y) if mth is not None: warnings.warn("The `mth` argument is deprecated and will be removed", FutureWarning) tx, ty, c = self.tck[:3] kx, ky = self.degrees if grid: if x.size == 0 or y.size == 0: return np.zeros((x.size, y.size), dtype=self.tck[2].dtype) if dx or dy: z,ier = dfitpack.parder(tx,ty,c,kx,ky,dx,dy,x,y) if not ier == 0: raise ValueError("Error code returned by parder: %s" % ier) else: z,ier = dfitpack.bispev(tx,ty,c,kx,ky,x,y) if not ier == 0: raise ValueError("Error code returned by bispev: %s" % ier) else: # standard Numpy broadcasting if x.shape != y.shape: x, y = np.broadcast_arrays(x, y) shape = x.shape x = x.ravel() y = y.ravel() if x.size == 0 or y.size == 0: return np.zeros(shape, dtype=self.tck[2].dtype) if dx or dy: z,ier = dfitpack.pardeu(tx,ty,c,kx,ky,dx,dy,x,y) if not ier == 0: raise ValueError("Error code returned by pardeu: %s" % ier) else: z,ier = dfitpack.bispeu(tx,ty,c,kx,ky,x,y) if not ier == 0: raise ValueError("Error code returned by bispeu: %s" % ier) z = z.reshape(shape) return z _surfit_messages = {1:""" The required storage space exceeds the available storage space: nxest or nyest too small, or s too small. The weighted least-squares spline corresponds to the current set of knots.""", 2:""" A theoretically impossible result was found during the iteration process for finding a smoothing spline with fp = s: s too small or badly chosen eps. Weighted sum of squared residuals does not satisfy abs(fp-s)/s < tol.""", 3:""" the maximal number of iterations maxit (set to 20 by the program) allowed for finding a smoothing spline with fp=s has been reached: s too small. Weighted sum of squared residuals does not satisfy abs(fp-s)/s < tol.""", 4:""" No more knots can be added because the number of b-spline coefficients (nx-kx-1)*(ny-ky-1) already exceeds the number of data points m: either s or m too small. The weighted least-squares spline corresponds to the current set of knots.""", 5:""" No more knots can be added because the additional knot would (quasi) coincide with an old one: s too small or too large a weight to an inaccurate data point. The weighted least-squares spline corresponds to the current set of knots.""", 10:""" Error on entry, no approximation returned. The following conditions must hold: xb<=x[i]<=xe, yb<=y[i]<=ye, w[i]>0, i=0..m-1 If iopt==-1, then xb<tx[kx+1]<tx[kx+2]<...<tx[nx-kx-2]<xe yb<ty[ky+1]<ty[ky+2]<...<ty[ny-ky-2]<ye""", -3:""" The coefficients of the spline returned have been computed as the minimal norm least-squares solution of a (numerically) rank deficient system (deficiency=%i). If deficiency is large, the results may be inaccurate. Deficiency may strongly depend on the value of eps.""" } class BivariateSpline(_BivariateSplineBase): """ Base class for bivariate splines. This describes a spline ``s(x, y)`` of degrees ``kx`` and ``ky`` on the rectangle ``[xb, xe] * [yb, ye]`` calculated from a given set of data points ``(x, y, z)``. This class is meant to be subclassed, not instantiated directly. To construct these splines, call either `SmoothBivariateSpline` or `LSQBivariateSpline`. See Also -------- UnivariateSpline : a similar class for univariate spline interpolation SmoothBivariateSpline : to create a BivariateSpline through the given points LSQBivariateSpline : to create a BivariateSpline using weighted least-squares fitting SphereBivariateSpline : bivariate spline interpolation in spherical cooridinates bisplrep : older wrapping of FITPACK bisplev : older wrapping of FITPACK """ @classmethod def _from_tck(cls, tck): """Construct a spline object from given tck and degree""" self = cls.__new__(cls) if len(tck) != 5: raise ValueError("tck should be a 5 element tuple of tx, ty, c, kx, ky") self.tck = tck[:3] self.degrees = tck[3:] return self def ev(self, xi, yi, dx=0, dy=0): """ Evaluate the spline at points Returns the interpolated value at ``(xi[i], yi[i]), i=0,...,len(xi)-1``. Parameters ---------- xi, yi : array-like Input coordinates. Standard Numpy broadcasting is obeyed. dx : int Order of x-derivative .. versionadded:: 0.14.0 dy : int Order of y-derivative .. versionadded:: 0.14.0 """ return self.__call__(xi, yi, dx=dx, dy=dy, grid=False) def integral(self, xa, xb, ya, yb): """ Evaluate the integral of the spline over area [xa,xb] x [ya,yb]. Parameters ---------- xa, xb : float The end-points of the x integration interval. ya, yb : float The end-points of the y integration interval. Returns ------- integ : float The value of the resulting integral. """ tx,ty,c = self.tck[:3] kx,ky = self.degrees return dfitpack.dblint(tx,ty,c,kx,ky,xa,xb,ya,yb) class SmoothBivariateSpline(BivariateSpline): """ Smooth bivariate spline approximation. Parameters ---------- x, y, z : array_like 1-D sequences of data points (order is not important). w : array_like, optional Positive 1-D sequence of weights, of same length as `x`, `y` and `z`. bbox : array_like, optional Sequence of length 4 specifying the boundary of the rectangular approximation domain. By default, ``bbox=[min(x,tx),max(x,tx), min(y,ty),max(y,ty)]``. kx, ky : ints, optional Degrees of the bivariate spline. Default is 3. s : float, optional Positive smoothing factor defined for estimation condition: ``sum((w[i]*(z[i]-s(x[i], y[i])))**2, axis=0) <= s`` Default ``s=len(w)`` which should be a good value if ``1/w[i]`` is an estimate of the standard deviation of ``z[i]``. eps : float, optional A threshold for determining the effective rank of an over-determined linear system of equations. `eps` should have a value between 0 and 1, the default is 1e-16. See Also -------- bisplrep : an older wrapping of FITPACK bisplev : an older wrapping of FITPACK UnivariateSpline : a similar class for univariate spline interpolation LSQUnivariateSpline : to create a BivariateSpline using weighted Notes ----- The length of `x`, `y` and `z` should be at least ``(kx+1) * (ky+1)``. """ def __init__(self, x, y, z, w=None, bbox=[None] * 4, kx=3, ky=3, s=None, eps=None): xb,xe,yb,ye = bbox nx,tx,ny,ty,c,fp,wrk1,ier = dfitpack.surfit_smth(x,y,z,w, xb,xe,yb,ye, kx,ky,s=s, eps=eps,lwrk2=1) if ier > 10: # lwrk2 was to small, re-run nx,tx,ny,ty,c,fp,wrk1,ier = dfitpack.surfit_smth(x,y,z,w, xb,xe,yb,ye, kx,ky,s=s, eps=eps,lwrk2=ier) if ier in [0,-1,-2]: # normal return pass else: message = _surfit_messages.get(ier,'ier=%s' % (ier)) warnings.warn(message) self.fp = fp self.tck = tx[:nx],ty[:ny],c[:(nx-kx-1)*(ny-ky-1)] self.degrees = kx,ky class LSQBivariateSpline(BivariateSpline): """ Weighted least-squares bivariate spline approximation. Parameters ---------- x, y, z : array_like 1-D sequences of data points (order is not important). tx, ty : array_like Strictly ordered 1-D sequences of knots coordinates. w : array_like, optional Positive 1-D array of weights, of the same length as `x`, `y` and `z`. bbox : (4,) array_like, optional Sequence of length 4 specifying the boundary of the rectangular approximation domain. By default, ``bbox=[min(x,tx),max(x,tx), min(y,ty),max(y,ty)]``. kx, ky : ints, optional Degrees of the bivariate spline. Default is 3. s : float, optional Positive smoothing factor defined for estimation condition: ``sum((w[i]*(z[i]-s(x[i], y[i])))**2, axis=0) <= s`` Default ``s=len(w)`` which should be a good value if ``1/w[i]`` is an estimate of the standard deviation of ``z[i]``. eps : float, optional A threshold for determining the effective rank of an over-determined linear system of equations. `eps` should have a value between 0 and 1, the default is 1e-16. See Also -------- bisplrep : an older wrapping of FITPACK bisplev : an older wrapping of FITPACK UnivariateSpline : a similar class for univariate spline interpolation SmoothBivariateSpline : create a smoothing BivariateSpline Notes ----- The length of `x`, `y` and `z` should be at least ``(kx+1) * (ky+1)``. """ def __init__(self, x, y, z, tx, ty, w=None, bbox=[None]*4, kx=3, ky=3, eps=None): nx = 2*kx+2+len(tx) ny = 2*ky+2+len(ty) tx1 = zeros((nx,),float) ty1 = zeros((ny,),float) tx1[kx+1:nx-kx-1] = tx ty1[ky+1:ny-ky-1] = ty xb,xe,yb,ye = bbox tx1,ty1,c,fp,ier = dfitpack.surfit_lsq(x,y,z,tx1,ty1,w, xb,xe,yb,ye, kx,ky,eps,lwrk2=1) if ier > 10: tx1,ty1,c,fp,ier = dfitpack.surfit_lsq(x,y,z,tx1,ty1,w, xb,xe,yb,ye, kx,ky,eps,lwrk2=ier) if ier in [0,-1,-2]: # normal return pass else: if ier < -2: deficiency = (nx-kx-1)*(ny-ky-1)+ier message = _surfit_messages.get(-3) % (deficiency) else: message = _surfit_messages.get(ier, 'ier=%s' % (ier)) warnings.warn(message) self.fp = fp self.tck = tx1, ty1, c self.degrees = kx, ky class RectBivariateSpline(BivariateSpline): """ Bivariate spline approximation over a rectangular mesh. Can be used for both smoothing and interpolating data. Parameters ---------- x,y : array_like 1-D arrays of coordinates in strictly ascending order. z : array_like 2-D array of data with shape (x.size,y.size). bbox : array_like, optional Sequence of length 4 specifying the boundary of the rectangular approximation domain. By default, ``bbox=[min(x,tx),max(x,tx), min(y,ty),max(y,ty)]``. kx, ky : ints, optional Degrees of the bivariate spline. Default is 3. s : float, optional Positive smoothing factor defined for estimation condition: ``sum((w[i]*(z[i]-s(x[i], y[i])))**2, axis=0) <= s`` Default is ``s=0``, which is for interpolation. See Also -------- SmoothBivariateSpline : a smoothing bivariate spline for scattered data bisplrep : an older wrapping of FITPACK bisplev : an older wrapping of FITPACK UnivariateSpline : a similar class for univariate spline interpolation """ def __init__(self, x, y, z, bbox=[None] * 4, kx=3, ky=3, s=0): x, y = ravel(x), ravel(y) if not all(diff(x) > 0.0): raise TypeError('x must be strictly increasing') if not all(diff(y) > 0.0): raise TypeError('y must be strictly increasing') if not ((x.min() == x[0]) and (x.max() == x[-1])): raise TypeError('x must be strictly ascending') if not ((y.min() == y[0]) and (y.max() == y[-1])): raise TypeError('y must be strictly ascending') if not x.size == z.shape[0]: raise TypeError('x dimension of z must have same number of ' 'elements as x') if not y.size == z.shape[1]: raise TypeError('y dimension of z must have same number of ' 'elements as y') z = ravel(z) xb, xe, yb, ye = bbox nx, tx, ny, ty, c, fp, ier = dfitpack.regrid_smth(x, y, z, xb, xe, yb, ye, kx, ky, s) if ier not in [0, -1, -2]: msg = _surfit_messages.get(ier, 'ier=%s' % (ier)) raise ValueError(msg) self.fp = fp self.tck = tx[:nx], ty[:ny], c[:(nx - kx - 1) * (ny - ky - 1)] self.degrees = kx, ky _spherefit_messages = _surfit_messages.copy() _spherefit_messages[10] = """ ERROR. On entry, the input data are controlled on validity. The following restrictions must be satisfied: -1<=iopt<=1, m>=2, ntest>=8 ,npest >=8, 0<eps<1, 0<=teta(i)<=pi, 0<=phi(i)<=2*pi, w(i)>0, i=1,...,m lwrk1 >= 185+52*v+10*u+14*u*v+8*(u-1)*v**2+8*m kwrk >= m+(ntest-7)*(npest-7) if iopt=-1: 8<=nt<=ntest , 9<=np<=npest 0<tt(5)<tt(6)<...<tt(nt-4)<pi 0<tp(5)<tp(6)<...<tp(np-4)<2*pi if iopt>=0: s>=0 if one of these conditions is found to be violated,control is immediately repassed to the calling program. in that case there is no approximation returned.""" _spherefit_messages[-3] = """ WARNING. The coefficients of the spline returned have been computed as the minimal norm least-squares solution of a (numerically) rank deficient system (deficiency=%i, rank=%i). Especially if the rank deficiency, which is computed by 6+(nt-8)*(np-7)+ier, is large, the results may be inaccurate. They could also seriously depend on the value of eps.""" class SphereBivariateSpline(_BivariateSplineBase): """ Bivariate spline s(x,y) of degrees 3 on a sphere, calculated from a given set of data points (theta,phi,r). .. versionadded:: 0.11.0 See Also -------- bisplrep, bisplev : an older wrapping of FITPACK UnivariateSpline : a similar class for univariate spline interpolation SmoothUnivariateSpline : to create a BivariateSpline through the given points LSQUnivariateSpline : to create a BivariateSpline using weighted least-squares fitting """ def __call__(self, theta, phi, dtheta=0, dphi=0, grid=True): """ Evaluate the spline or its derivatives at given positions. Parameters ---------- theta, phi : array-like Input coordinates. If `grid` is False, evaluate the spline at points ``(theta[i], phi[i]), i=0, ..., len(x)-1``. Standard Numpy broadcasting is obeyed. If `grid` is True: evaluate spline at the grid points defined by the coordinate arrays theta, phi. The arrays must be sorted to increasing order. dtheta : int Order of theta-derivative .. versionadded:: 0.14.0 dphi : int Order of phi-derivative .. versionadded:: 0.14.0 grid : bool Whether to evaluate the results on a grid spanned by the input arrays, or at points specified by the input arrays. .. versionadded:: 0.14.0 """ theta = np.asarray(theta) phi = np.asarray(phi) if theta.size > 0 and (theta.min() < 0. or theta.max() > np.pi): raise ValueError("requested theta out of bounds.") if phi.size > 0 and (phi.min() < 0. or phi.max() > 2. * np.pi): raise ValueError("requested phi out of bounds.") return _BivariateSplineBase.__call__(self, theta, phi, dx=dtheta, dy=dphi, grid=grid) def ev(self, theta, phi, dtheta=0, dphi=0): """ Evaluate the spline at points Returns the interpolated value at ``(theta[i], phi[i]), i=0,...,len(theta)-1``. Parameters ---------- theta, phi : array-like Input coordinates. Standard Numpy broadcasting is obeyed. dtheta : int Order of theta-derivative .. versionadded:: 0.14.0 dphi : int Order of phi-derivative .. versionadded:: 0.14.0 """ return self.__call__(theta, phi, dtheta=dtheta, dphi=dphi, grid=False) class SmoothSphereBivariateSpline(SphereBivariateSpline): """ Smooth bivariate spline approximation in spherical coordinates. .. versionadded:: 0.11.0 Parameters ---------- theta, phi, r : array_like 1-D sequences of data points (order is not important). Coordinates must be given in radians. Theta must lie within the interval (0, pi), and phi must lie within the interval (0, 2pi). w : array_like, optional Positive 1-D sequence of weights. s : float, optional Positive smoothing factor defined for estimation condition: ``sum((w(i)*(r(i) - s(theta(i), phi(i))))**2, axis=0) <= s`` Default ``s=len(w)`` which should be a good value if 1/w[i] is an estimate of the standard deviation of r[i]. eps : float, optional A threshold for determining the effective rank of an over-determined linear system of equations. `eps` should have a value between 0 and 1, the default is 1e-16. Notes ----- For more information, see the FITPACK_ site about this function. .. _FITPACK: http://www.netlib.org/dierckx/sphere.f Examples -------- Suppose we have global data on a coarse grid (the input data does not have to be on a grid): >>> theta = np.linspace(0., np.pi, 7) >>> phi = np.linspace(0., 2*np.pi, 9) >>> data = np.empty((theta.shape[0], phi.shape[0])) >>> data[:,0], data[0,:], data[-1,:] = 0., 0., 0. >>> data[1:-1,1], data[1:-1,-1] = 1., 1. >>> data[1,1:-1], data[-2,1:-1] = 1., 1. >>> data[2:-2,2], data[2:-2,-2] = 2., 2. >>> data[2,2:-2], data[-3,2:-2] = 2., 2. >>> data[3,3:-2] = 3. >>> data = np.roll(data, 4, 1) We need to set up the interpolator object >>> lats, lons = np.meshgrid(theta, phi) >>> from scipy.interpolate import SmoothSphereBivariateSpline >>> lut = SmoothSphereBivariateSpline(lats.ravel(), lons.ravel(), data.T.ravel(),s=3.5) As a first test, we'll see what the algorithm returns when run on the input coordinates >>> data_orig = lut(theta, phi) Finally we interpolate the data to a finer grid >>> fine_lats = np.linspace(0., np.pi, 70) >>> fine_lons = np.linspace(0., 2 * np.pi, 90) >>> data_smth = lut(fine_lats, fine_lons) >>> fig = plt.figure() >>> ax1 = fig.add_subplot(131) >>> ax1.imshow(data, interpolation='nearest') >>> ax2 = fig.add_subplot(132) >>> ax2.imshow(data_orig, interpolation='nearest') >>> ax3 = fig.add_subplot(133) >>> ax3.imshow(data_smth, interpolation='nearest') >>> plt.show() """ def __init__(self, theta, phi, r, w=None, s=0., eps=1E-16): if np.issubclass_(w, float): w = ones(len(theta)) * w nt_, tt_, np_, tp_, c, fp, ier = dfitpack.spherfit_smth(theta, phi, r, w=w, s=s, eps=eps) if ier not in [0, -1, -2]: message = _spherefit_messages.get(ier, 'ier=%s' % (ier)) raise ValueError(message) self.fp = fp self.tck = tt_[:nt_], tp_[:np_], c[:(nt_ - 4) * (np_ - 4)] self.degrees = (3, 3) class LSQSphereBivariateSpline(SphereBivariateSpline): """ Weighted least-squares bivariate spline approximation in spherical coordinates. .. versionadded:: 0.11.0 Parameters ---------- theta, phi, r : array_like 1-D sequences of data points (order is not important). Coordinates must be given in radians. Theta must lie within the interval (0, pi), and phi must lie within the interval (0, 2pi). tt, tp : array_like Strictly ordered 1-D sequences of knots coordinates. Coordinates must satisfy ``0 < tt[i] < pi``, ``0 < tp[i] < 2*pi``. w : array_like, optional Positive 1-D sequence of weights, of the same length as `theta`, `phi` and `r`. eps : float, optional A threshold for determining the effective rank of an over-determined linear system of equations. `eps` should have a value between 0 and 1, the default is 1e-16. Notes ----- For more information, see the FITPACK_ site about this function. .. _FITPACK: http://www.netlib.org/dierckx/sphere.f Examples -------- Suppose we have global data on a coarse grid (the input data does not have to be on a grid): >>> theta = np.linspace(0., np.pi, 7) >>> phi = np.linspace(0., 2*np.pi, 9) >>> data = np.empty((theta.shape[0], phi.shape[0])) >>> data[:,0], data[0,:], data[-1,:] = 0., 0., 0. >>> data[1:-1,1], data[1:-1,-1] = 1., 1. >>> data[1,1:-1], data[-2,1:-1] = 1., 1. >>> data[2:-2,2], data[2:-2,-2] = 2., 2. >>> data[2,2:-2], data[-3,2:-2] = 2., 2. >>> data[3,3:-2] = 3. >>> data = np.roll(data, 4, 1) We need to set up the interpolator object. Here, we must also specify the coordinates of the knots to use. >>> lats, lons = np.meshgrid(theta, phi) >>> knotst, knotsp = theta.copy(), phi.copy() >>> knotst[0] += .0001 >>> knotst[-1] -= .0001 >>> knotsp[0] += .0001 >>> knotsp[-1] -= .0001 >>> from scipy.interpolate import LSQSphereBivariateSpline >>> lut = LSQSphereBivariateSpline(lats.ravel(), lons.ravel(), data.T.ravel(),knotst,knotsp) As a first test, we'll see what the algorithm returns when run on the input coordinates >>> data_orig = lut(theta, phi) Finally we interpolate the data to a finer grid >>> fine_lats = np.linspace(0., np.pi, 70) >>> fine_lons = np.linspace(0., 2*np.pi, 90) >>> data_lsq = lut(fine_lats, fine_lons) >>> fig = plt.figure() >>> ax1 = fig.add_subplot(131) >>> ax1.imshow(data, interpolation='nearest') >>> ax2 = fig.add_subplot(132) >>> ax2.imshow(data_orig, interpolation='nearest') >>> ax3 = fig.add_subplot(133) >>> ax3.imshow(data_lsq, interpolation='nearest') >>> plt.show() """ def __init__(self, theta, phi, r, tt, tp, w=None, eps=1E-16): if np.issubclass_(w, float): w = ones(len(theta)) * w nt_, np_ = 8 + len(tt), 8 + len(tp) tt_, tp_ = zeros((nt_,), float), zeros((np_,), float) tt_[4:-4], tp_[4:-4] = tt, tp tt_[-4:], tp_[-4:] = np.pi, 2. * np.pi tt_, tp_, c, fp, ier = dfitpack.spherfit_lsq(theta, phi, r, tt_, tp_, w=w, eps=eps) if ier < -2: deficiency = 6 + (nt_ - 8) * (np_ - 7) + ier message = _spherefit_messages.get(-3) % (deficiency, -ier) warnings.warn(message) elif ier not in [0, -1, -2]: message = _spherefit_messages.get(ier, 'ier=%s' % (ier)) raise ValueError(message) self.fp = fp self.tck = tt_, tp_, c self.degrees = (3, 3) _spfit_messages = _surfit_messages.copy() _spfit_messages[10] = """ ERROR: on entry, the input data are controlled on validity the following restrictions must be satisfied. -1<=iopt(1)<=1, 0<=iopt(2)<=1, 0<=iopt(3)<=1, -1<=ider(1)<=1, 0<=ider(2)<=1, ider(2)=0 if iopt(2)=0. -1<=ider(3)<=1, 0<=ider(4)<=1, ider(4)=0 if iopt(3)=0. mu >= mumin (see above), mv >= 4, nuest >=8, nvest >= 8, kwrk>=5+mu+mv+nuest+nvest, lwrk >= 12+nuest*(mv+nvest+3)+nvest*24+4*mu+8*mv+max(nuest,mv+nvest) 0< u(i-1)<u(i)< pi,i=2,..,mu, -pi<=v(1)< pi, v(1)<v(i-1)<v(i)<v(1)+2*pi, i=3,...,mv if iopt(1)=-1: 8<=nu<=min(nuest,mu+6+iopt(2)+iopt(3)) 0<tu(5)<tu(6)<...<tu(nu-4)< pi 8<=nv<=min(nvest,mv+7) v(1)<tv(5)<tv(6)<...<tv(nv-4)<v(1)+2*pi the schoenberg-whitney conditions, i.e. there must be subset of grid co-ordinates uu(p) and vv(q) such that tu(p) < uu(p) < tu(p+4) ,p=1,...,nu-4 (iopt(2)=1 and iopt(3)=1 also count for a uu-value tv(q) < vv(q) < tv(q+4) ,q=1,...,nv-4 (vv(q) is either a value v(j) or v(j)+2*pi) if iopt(1)>=0: s>=0 if s=0: nuest>=mu+6+iopt(2)+iopt(3), nvest>=mv+7 if one of these conditions is found to be violated,control is immediately repassed to the calling program. in that case there is no approximation returned.""" class RectSphereBivariateSpline(SphereBivariateSpline): """ Bivariate spline approximation over a rectangular mesh on a sphere. Can be used for smoothing data. .. versionadded:: 0.11.0 Parameters ---------- u : array_like 1-D array of latitude coordinates in strictly ascending order. Coordinates must be given in radians and lie within the interval (0, pi). v : array_like 1-D array of longitude coordinates in strictly ascending order. Coordinates must be given in radians, and must lie within (0, 2pi). r : array_like 2-D array of data with shape ``(u.size, v.size)``. s : float, optional Positive smoothing factor defined for estimation condition (``s=0`` is for interpolation). pole_continuity : bool or (bool, bool), optional Order of continuity at the poles ``u=0`` (``pole_continuity[0]``) and ``u=pi`` (``pole_continuity[1]``). The order of continuity at the pole will be 1 or 0 when this is True or False, respectively. Defaults to False. pole_values : float or (float, float), optional Data values at the poles ``u=0`` and ``u=pi``. Either the whole parameter or each individual element can be None. Defaults to None. pole_exact : bool or (bool, bool), optional Data value exactness at the poles ``u=0`` and ``u=pi``. If True, the value is considered to be the right function value, and it will be fitted exactly. If False, the value will be considered to be a data value just like the other data values. Defaults to False. pole_flat : bool or (bool, bool), optional For the poles at ``u=0`` and ``u=pi``, specify whether or not the approximation has vanishing derivatives. Defaults to False. See Also -------- RectBivariateSpline : bivariate spline approximation over a rectangular mesh Notes ----- Currently, only the smoothing spline approximation (``iopt[0] = 0`` and ``iopt[0] = 1`` in the FITPACK routine) is supported. The exact least-squares spline approximation is not implemented yet. When actually performing the interpolation, the requested `v` values must lie within the same length 2pi interval that the original `v` values were chosen from. For more information, see the FITPACK_ site about this function. .. _FITPACK: http://www.netlib.org/dierckx/spgrid.f Examples -------- Suppose we have global data on a coarse grid >>> lats = np.linspace(10, 170, 9) * np.pi / 180. >>> lons = np.linspace(0, 350, 18) * np.pi / 180. >>> data = np.dot(np.atleast_2d(90. - np.linspace(-80., 80., 18)).T, np.atleast_2d(180. - np.abs(np.linspace(0., 350., 9)))).T We want to interpolate it to a global one-degree grid >>> new_lats = np.linspace(1, 180, 180) * np.pi / 180 >>> new_lons = np.linspace(1, 360, 360) * np.pi / 180 >>> new_lats, new_lons = np.meshgrid(new_lats, new_lons) We need to set up the interpolator object >>> from scipy.interpolate import RectSphereBivariateSpline >>> lut = RectSphereBivariateSpline(lats, lons, data) Finally we interpolate the data. The `RectSphereBivariateSpline` object only takes 1-D arrays as input, therefore we need to do some reshaping. >>> data_interp = lut.ev(new_lats.ravel(), ... new_lons.ravel()).reshape((360, 180)).T Looking at the original and the interpolated data, one can see that the interpolant reproduces the original data very well: >>> fig = plt.figure() >>> ax1 = fig.add_subplot(211) >>> ax1.imshow(data, interpolation='nearest') >>> ax2 = fig.add_subplot(212) >>> ax2.imshow(data_interp, interpolation='nearest') >>> plt.show() Chosing the optimal value of ``s`` can be a delicate task. Recommended values for ``s`` depend on the accuracy of the data values. If the user has an idea of the statistical errors on the data, she can also find a proper estimate for ``s``. By assuming that, if she specifies the right ``s``, the interpolator will use a spline ``f(u,v)`` which exactly reproduces the function underlying the data, she can evaluate ``sum((r(i,j)-s(u(i),v(j)))**2)`` to find a good estimate for this ``s``. For example, if she knows that the statistical errors on her ``r(i,j)``-values are not greater than 0.1, she may expect that a good ``s`` should have a value not larger than ``u.size * v.size * (0.1)**2``. If nothing is known about the statistical error in ``r(i,j)``, ``s`` must be determined by trial and error. The best is then to start with a very large value of ``s`` (to determine the least-squares polynomial and the corresponding upper bound ``fp0`` for ``s``) and then to progressively decrease the value of ``s`` (say by a factor 10 in the beginning, i.e. ``s = fp0 / 10, fp0 / 100, ...`` and more carefully as the approximation shows more detail) to obtain closer fits. The interpolation results for different values of ``s`` give some insight into this process: >>> fig2 = plt.figure() >>> s = [3e9, 2e9, 1e9, 1e8] >>> for ii in xrange(len(s)): >>> lut = RectSphereBivariateSpline(lats, lons, data, s=s[ii]) >>> data_interp = lut.ev(new_lats.ravel(), ... new_lons.ravel()).reshape((360, 180)).T >>> ax = fig2.add_subplot(2, 2, ii+1) >>> ax.imshow(data_interp, interpolation='nearest') >>> ax.set_title("s = %g" % s[ii]) >>> plt.show() """ def __init__(self, u, v, r, s=0., pole_continuity=False, pole_values=None, pole_exact=False, pole_flat=False): iopt = np.array([0, 0, 0], dtype=int) ider = np.array([-1, 0, -1, 0], dtype=int) if pole_values is None: pole_values = (None, None) elif isinstance(pole_values, (float, np.float32, np.float64)): pole_values = (pole_values, pole_values) if isinstance(pole_continuity, bool): pole_continuity = (pole_continuity, pole_continuity) if isinstance(pole_exact, bool): pole_exact = (pole_exact, pole_exact) if isinstance(pole_flat, bool): pole_flat = (pole_flat, pole_flat) r0, r1 = pole_values iopt[1:] = pole_continuity if r0 is None: ider[0] = -1 else: ider[0] = pole_exact[0] if r1 is None: ider[2] = -1 else: ider[2] = pole_exact[1] ider[1], ider[3] = pole_flat u, v = np.ravel(u), np.ravel(v) if not np.all(np.diff(u) > 0.0): raise TypeError('u must be strictly increasing') if not np.all(np.diff(v) > 0.0): raise TypeError('v must be strictly increasing') if not u.size == r.shape[0]: raise TypeError('u dimension of r must have same number of ' 'elements as u') if not v.size == r.shape[1]: raise TypeError('v dimension of r must have same number of ' 'elements as v') if pole_continuity[1] is False and pole_flat[1] is True: raise TypeError('if pole_continuity is False, so must be ' 'pole_flat') if pole_continuity[0] is False and pole_flat[0] is True: raise TypeError('if pole_continuity is False, so must be ' 'pole_flat') r = np.ravel(r) nu, tu, nv, tv, c, fp, ier = dfitpack.regrid_smth_spher(iopt, ider, u.copy(), v.copy(), r.copy(), r0, r1, s) if ier not in [0, -1, -2]: msg = _spfit_messages.get(ier, 'ier=%s' % (ier)) raise ValueError(msg) self.fp = fp self.tck = tu[:nu], tv[:nv], c[:(nu - 4) * (nv-4)] self.degrees = (3, 3)
mit
[ 624, 199, 3269, 1389, 10894, 15318, 436, 13195, 21774, 543, 2249, 1278, 199, 199, 3269, 1389, 365, 4079, 641, 282, 3245, 402, 19998, 14975, 5266, 540, 2504, 56, 199, 991, 510, 14, 3757, 281, 346, 88, 334, 3239, 1455, 921, 1544, 14, 846, 773, 14, 1308, 15, 328, 281, 346, 88, 24793, 14834, 199, 475, 4270, 14975, 701, 510, 2210, 85, 22912, 834, 14, 199, 624, 199, 3, 18208, 701, 510, 2210, 85, 22912, 834, 12, 1603, 11474, 12, 21640, 833, 13004, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 363, 452, 363, 275, 359, 272, 283, 1358, 23225, 27558, 297, 272, 283, 22713, 972, 1358, 23225, 27558, 297, 272, 283, 5296, 49, 1358, 23225, 27558, 297, 339, 283, 34, 23225, 27558, 297, 272, 283, 5296, 31893, 23225, 27558, 297, 272, 283, 51, 11607, 34, 23225, 27558, 297, 272, 283, 5296, 49, 22385, 34, 23225, 27558, 297, 272, 283, 51, 11607, 22385, 34, 23225, 27558, 297, 272, 283, 8252, 34, 23225, 27558, 297, 272, 283, 8252, 22385, 34, 23225, 27558, 418, 421, 199, 646, 3598, 199, 199, 504, 2680, 492, 10136, 12, 24788, 12, 1006, 2052, 12, 660, 1090, 12, 1006, 12, 3915, 12, 1625, 12, 7869, 199, 646, 2680, 465, 980, 199, 199, 504, 1275, 492, 5542, 1389, 199, 504, 1275, 492, 366, 3269, 1389, 421, 199, 749, 1910, 23225, 30213, 21905, 381, 199, 199, 63, 895, 3269, 63, 3431, 275, 469, 17, 26, 624, 199, 1918, 1415, 4887, 4601, 22338, 314, 2808, 4887, 4601, 12, 465, 199, 10085, 701, 314, 2725, 10715, 26, 10715, 4634, 7425, 14, 982, 10715, 365, 2575, 199, 9629, 334, 19787, 10715, 690, 333, 15, 18, 395, 652, 1443, 2597, 6623, 626, 308, 365, 4634, 7425, 14, 199, 1918, 22772, 2138, 365, 314, 14609, 5210, 13, 20956, 30213, 199, 645, 5422, 370, 314, 1022, 1397, 83, 307, 59, 16, 467, 84, 59, 17, 467, 11577, 84, 59, 78, 13, 17, 1055, 334, 78, 29, 15272, 9, 314, 2725, 4090, 199, 71, 7602, 314, 5226, 14609, 3089, 402, 20478, 16731, 83, 334, 3997, 30, 83, 680, 199, 7208, 490, 499, 26, 624, 199, 33, 314, 720, 17269, 26847, 754, 1990, 1911, 5309, 314, 8494, 199, 496, 823, 367, 17196, 282, 308, 22610, 30213, 543, 4090, 275, 308, 26, 308, 4634, 7425, 14, 199, 10924, 365, 376, 22772, 2138, 1325, 314, 5226, 14609, 3089, 199, 1618, 20478, 16731, 83, 1630, 440, 23082, 314, 5558, 2853, 8, 3997, 13, 83, 2447, 83, 665, 9561, 17129, 490, 650, 26, 624, 199, 1918, 1390, 7265, 1329, 402, 10615, 1390, 390, 334, 409, 370, 3388, 701, 314, 2240, 9, 199, 6541, 367, 17196, 282, 308, 22610, 30213, 543, 4090, 29, 83, 965, 2757, 13075, 26, 308, 199, 7354, 7425, 14, 199, 10924, 365, 376, 22772, 2138, 1325, 314, 5226, 14609, 3089, 199, 1618, 20478, 16731, 83, 1630, 440, 23082, 314, 5558, 2853, 8, 3997, 13, 83, 2447, 83, 665, 9561, 17129, 490, 1616, 26, 624, 199, 547, 641, 2397, 12, 949, 22772, 2138, 14, 710, 2569, 3704, 199, 7790, 10266, 26, 199, 1774, 12932, 88, 59, 16, 61, 28, 88, 59, 17, 61, 28, 1396, 28, 88, 59, 77, 13, 17, 61, 12932, 1845, 12, 336, 59, 73, 28474, 16, 12, 284, 29, 16, 703, 77, 13, 17, 199, 692, 284, 2992, 4022, 17, 26, 523, 10346, 28, 84, 59, 75, 11, 17, 61, 28, 84, 59, 75, 11, 18, 61, 28, 1396, 28, 84, 59, 78, 13, 75, 13, 18, 61, 28, 1845, 624, 490, 789, 421, 199, 3, 1910, 23225, 27558, 12, 1599, 2725, 883, 506, 376, 1109, 503, 282, 1059, 199, 63, 832, 1330, 63, 10433, 275, 469, 16, 26, 378, 12, 283, 832, 1330, 16288, 356, 378, 12, 326, 413, 26, 413, 12, 283, 4250, 356, 413, 12, 326, 499, 26, 499, 12, 283, 3730, 356, 499, 12, 326, 650, 26, 650, 12, 283, 1297, 356, 650, 93, 421, 199, 533, 1910, 23225, 27558, 8, 785, 304, 272, 408, 272, 7309, 13, 13014, 308, 22610, 30213, 5542, 370, 282, 1627, 663, 402, 666, 4501, 14, 339, 481, 1405, 282, 30213, 612, 275, 23168, 8, 88, 9, 402, 13666, 658, 75, 64, 370, 314, 2741, 658, 88, 3559, 658, 89, 64, 666, 14, 221, 658, 83, 64, 272, 9314, 314, 1329, 402, 1022, 1397, 83, 701, 9176, 282, 308, 22610, 5558, 14, 339, 3897, 272, 4143, 272, 671, 520, 334, 46, 4258, 1625, 63, 2930, 267, 413, 13, 36, 1625, 402, 12717, 1324, 666, 14, 9498, 506, 22255, 14, 272, 612, 520, 334, 46, 4258, 1625, 63, 2930, 267, 413, 13, 36, 1625, 402, 11410, 1324, 666, 12, 402, 314, 2011, 2582, 465, 658, 88, 2313, 272, 336, 520, 334, 46, 4258, 1625, 63, 2930, 12, 2716, 267, 2136, 2492, 367, 30213, 21774, 14, 221, 9498, 506, 7317, 14, 221, 982, 488, 334, 885, 395, 267, 4931, 787, 1006, 4472, 14, 272, 12494, 520, 334, 18, 4258, 1625, 63, 2930, 12, 2716, 267, 499, 13, 4041, 9176, 314, 8424, 402, 314, 22772, 6252, 14, 982, 267, 488, 334, 885, 395, 1124, 11246, 1524, 88, 59, 16, 467, 671, 1988, 17, 2677, 4345, 272, 1022, 520, 1109, 12, 2716, 267, 1487, 71, 850, 402, 314, 308, 22610, 30213, 14, 221, 9498, 506, 2695, 959, 14, 267, 3758, 365, 1022, 29, 19, 12, 282, 22217, 530, 30213, 14, 272, 308, 520, 2069, 503, 488, 12, 2716, 267, 30245, 308, 22610, 6535, 1202, 370, 11496, 314, 1329, 402, 1022, 1397, 83, 14, 221, 4860, 267, 402, 1022, 1397, 83, 911, 506, 10035, 11185, 5133, 314, 308, 22610, 5558, 365, 23233, 447, 953, 3089, 1332, 87, 59, 73, 61, 627, 334, 89, 59, 73, 11285, 15276, 8, 88, 59, 73, 11845, 538, 18, 12, 3114, 29, 16, 9, 2695, 308, 398, 982, 488, 334, 885, 395, 1124, 83, 275, 822, 8, 87, 9719, 1314, 1077, 506, 282, 6954, 574, 340, 4960, 1124, 17, 15, 87, 59, 73, 21133, 365, 376, 14497, 402, 314, 4465, 18458, 402, 1124, 89, 59, 73, 30029, 27439, 982, 378, 12, 30213, 911, 28884, 4012, 1006, 666, 4501, 14, 272, 1599, 520, 1109, 503, 620, 12, 2716, 267, 29001, 314, 31964, 10410 ]
[ 199, 3269, 1389, 10894, 15318, 436, 13195, 21774, 543, 2249, 1278, 199, 199, 3269, 1389, 365, 4079, 641, 282, 3245, 402, 19998, 14975, 5266, 540, 2504, 56, 199, 991, 510, 14, 3757, 281, 346, 88, 334, 3239, 1455, 921, 1544, 14, 846, 773, 14, 1308, 15, 328, 281, 346, 88, 24793, 14834, 199, 475, 4270, 14975, 701, 510, 2210, 85, 22912, 834, 14, 199, 624, 199, 3, 18208, 701, 510, 2210, 85, 22912, 834, 12, 1603, 11474, 12, 21640, 833, 13004, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 363, 452, 363, 275, 359, 272, 283, 1358, 23225, 27558, 297, 272, 283, 22713, 972, 1358, 23225, 27558, 297, 272, 283, 5296, 49, 1358, 23225, 27558, 297, 339, 283, 34, 23225, 27558, 297, 272, 283, 5296, 31893, 23225, 27558, 297, 272, 283, 51, 11607, 34, 23225, 27558, 297, 272, 283, 5296, 49, 22385, 34, 23225, 27558, 297, 272, 283, 51, 11607, 22385, 34, 23225, 27558, 297, 272, 283, 8252, 34, 23225, 27558, 297, 272, 283, 8252, 22385, 34, 23225, 27558, 418, 421, 199, 646, 3598, 199, 199, 504, 2680, 492, 10136, 12, 24788, 12, 1006, 2052, 12, 660, 1090, 12, 1006, 12, 3915, 12, 1625, 12, 7869, 199, 646, 2680, 465, 980, 199, 199, 504, 1275, 492, 5542, 1389, 199, 504, 1275, 492, 366, 3269, 1389, 421, 199, 749, 1910, 23225, 30213, 21905, 381, 199, 199, 63, 895, 3269, 63, 3431, 275, 469, 17, 26, 624, 199, 1918, 1415, 4887, 4601, 22338, 314, 2808, 4887, 4601, 12, 465, 199, 10085, 701, 314, 2725, 10715, 26, 10715, 4634, 7425, 14, 982, 10715, 365, 2575, 199, 9629, 334, 19787, 10715, 690, 333, 15, 18, 395, 652, 1443, 2597, 6623, 626, 308, 365, 4634, 7425, 14, 199, 1918, 22772, 2138, 365, 314, 14609, 5210, 13, 20956, 30213, 199, 645, 5422, 370, 314, 1022, 1397, 83, 307, 59, 16, 467, 84, 59, 17, 467, 11577, 84, 59, 78, 13, 17, 1055, 334, 78, 29, 15272, 9, 314, 2725, 4090, 199, 71, 7602, 314, 5226, 14609, 3089, 402, 20478, 16731, 83, 334, 3997, 30, 83, 680, 199, 7208, 490, 499, 26, 624, 199, 33, 314, 720, 17269, 26847, 754, 1990, 1911, 5309, 314, 8494, 199, 496, 823, 367, 17196, 282, 308, 22610, 30213, 543, 4090, 275, 308, 26, 308, 4634, 7425, 14, 199, 10924, 365, 376, 22772, 2138, 1325, 314, 5226, 14609, 3089, 199, 1618, 20478, 16731, 83, 1630, 440, 23082, 314, 5558, 2853, 8, 3997, 13, 83, 2447, 83, 665, 9561, 17129, 490, 650, 26, 624, 199, 1918, 1390, 7265, 1329, 402, 10615, 1390, 390, 334, 409, 370, 3388, 701, 314, 2240, 9, 199, 6541, 367, 17196, 282, 308, 22610, 30213, 543, 4090, 29, 83, 965, 2757, 13075, 26, 308, 199, 7354, 7425, 14, 199, 10924, 365, 376, 22772, 2138, 1325, 314, 5226, 14609, 3089, 199, 1618, 20478, 16731, 83, 1630, 440, 23082, 314, 5558, 2853, 8, 3997, 13, 83, 2447, 83, 665, 9561, 17129, 490, 1616, 26, 624, 199, 547, 641, 2397, 12, 949, 22772, 2138, 14, 710, 2569, 3704, 199, 7790, 10266, 26, 199, 1774, 12932, 88, 59, 16, 61, 28, 88, 59, 17, 61, 28, 1396, 28, 88, 59, 77, 13, 17, 61, 12932, 1845, 12, 336, 59, 73, 28474, 16, 12, 284, 29, 16, 703, 77, 13, 17, 199, 692, 284, 2992, 4022, 17, 26, 523, 10346, 28, 84, 59, 75, 11, 17, 61, 28, 84, 59, 75, 11, 18, 61, 28, 1396, 28, 84, 59, 78, 13, 75, 13, 18, 61, 28, 1845, 624, 490, 789, 421, 199, 3, 1910, 23225, 27558, 12, 1599, 2725, 883, 506, 376, 1109, 503, 282, 1059, 199, 63, 832, 1330, 63, 10433, 275, 469, 16, 26, 378, 12, 283, 832, 1330, 16288, 356, 378, 12, 326, 413, 26, 413, 12, 283, 4250, 356, 413, 12, 326, 499, 26, 499, 12, 283, 3730, 356, 499, 12, 326, 650, 26, 650, 12, 283, 1297, 356, 650, 93, 421, 199, 533, 1910, 23225, 27558, 8, 785, 304, 272, 408, 272, 7309, 13, 13014, 308, 22610, 30213, 5542, 370, 282, 1627, 663, 402, 666, 4501, 14, 339, 481, 1405, 282, 30213, 612, 275, 23168, 8, 88, 9, 402, 13666, 658, 75, 64, 370, 314, 2741, 658, 88, 3559, 658, 89, 64, 666, 14, 221, 658, 83, 64, 272, 9314, 314, 1329, 402, 1022, 1397, 83, 701, 9176, 282, 308, 22610, 5558, 14, 339, 3897, 272, 4143, 272, 671, 520, 334, 46, 4258, 1625, 63, 2930, 267, 413, 13, 36, 1625, 402, 12717, 1324, 666, 14, 9498, 506, 22255, 14, 272, 612, 520, 334, 46, 4258, 1625, 63, 2930, 267, 413, 13, 36, 1625, 402, 11410, 1324, 666, 12, 402, 314, 2011, 2582, 465, 658, 88, 2313, 272, 336, 520, 334, 46, 4258, 1625, 63, 2930, 12, 2716, 267, 2136, 2492, 367, 30213, 21774, 14, 221, 9498, 506, 7317, 14, 221, 982, 488, 334, 885, 395, 267, 4931, 787, 1006, 4472, 14, 272, 12494, 520, 334, 18, 4258, 1625, 63, 2930, 12, 2716, 267, 499, 13, 4041, 9176, 314, 8424, 402, 314, 22772, 6252, 14, 982, 267, 488, 334, 885, 395, 1124, 11246, 1524, 88, 59, 16, 467, 671, 1988, 17, 2677, 4345, 272, 1022, 520, 1109, 12, 2716, 267, 1487, 71, 850, 402, 314, 308, 22610, 30213, 14, 221, 9498, 506, 2695, 959, 14, 267, 3758, 365, 1022, 29, 19, 12, 282, 22217, 530, 30213, 14, 272, 308, 520, 2069, 503, 488, 12, 2716, 267, 30245, 308, 22610, 6535, 1202, 370, 11496, 314, 1329, 402, 1022, 1397, 83, 14, 221, 4860, 267, 402, 1022, 1397, 83, 911, 506, 10035, 11185, 5133, 314, 308, 22610, 5558, 365, 23233, 447, 953, 3089, 1332, 87, 59, 73, 61, 627, 334, 89, 59, 73, 11285, 15276, 8, 88, 59, 73, 11845, 538, 18, 12, 3114, 29, 16, 9, 2695, 308, 398, 982, 488, 334, 885, 395, 1124, 83, 275, 822, 8, 87, 9719, 1314, 1077, 506, 282, 6954, 574, 340,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
projectcalico/calico-nova
nova/tests/functional/v3/test_images.py
14
3676
# Copyright 2012 Nebula, Inc. # Copyright 2013 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from nova.tests.functional.v3 import api_sample_base from nova.tests.unit.image import fake class ImagesSampleJsonTest(api_sample_base.ApiSampleTestBaseV3): extension_name = 'images' extra_extensions_to_load = ["image-metadata"] def test_images_list(self): # Get api sample of images get list request. response = self._do_get('images') subs = self._get_regexes() self._verify_response('images-list-get-resp', subs, response, 200) def test_image_get(self): # Get api sample of one single image details request. image_id = fake.get_valid_image_id() response = self._do_get('images/%s' % image_id) subs = self._get_regexes() subs['image_id'] = image_id self._verify_response('image-get-resp', subs, response, 200) def test_images_details(self): # Get api sample of all images details request. response = self._do_get('images/detail') subs = self._get_regexes() self._verify_response('images-details-get-resp', subs, response, 200) def test_image_metadata_get(self): # Get api sample of an image metadata request. image_id = fake.get_valid_image_id() response = self._do_get('images/%s/metadata' % image_id) subs = self._get_regexes() subs['image_id'] = image_id self._verify_response('image-metadata-get-resp', subs, response, 200) def test_image_metadata_post(self): # Get api sample to update metadata of an image metadata request. image_id = fake.get_valid_image_id() response = self._do_post( 'images/%s/metadata' % image_id, 'image-metadata-post-req', {}) subs = self._get_regexes() self._verify_response('image-metadata-post-resp', subs, response, 200) def test_image_metadata_put(self): # Get api sample of image metadata put request. image_id = fake.get_valid_image_id() response = self._do_put('%s/images/%s/metadata' % (self.api.project_id, image_id), 'image-metadata-put-req', {}) subs = self._get_regexes() self._verify_response('image-metadata-put-resp', subs, response, 200) def test_image_meta_key_get(self): # Get api sample of an image metadata key request. image_id = fake.get_valid_image_id() key = "kernel_id" response = self._do_get('images/%s/metadata/%s' % (image_id, key)) subs = self._get_regexes() self._verify_response('image-meta-key-get', subs, response, 200) def test_image_meta_key_put(self): # Get api sample of image metadata key put request. image_id = fake.get_valid_image_id() key = "auto_disk_config" response = self._do_put('images/%s/metadata/%s' % (image_id, key), 'image-meta-key-put-req', {}) subs = self._get_regexes() self._verify_response('image-meta-key-put-resp', subs, response, 200)
apache-2.0
[ 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 1898, 6171, 26202, 22304, 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, 421, 199, 504, 5913, 14, 2219, 14, 15481, 14, 86, 19, 492, 2986, 63, 3271, 63, 1095, 199, 504, 5913, 14, 2219, 14, 3248, 14, 1569, 492, 4026, 421, 199, 533, 32658, 8176, 9653, 774, 8, 1246, 63, 3271, 63, 1095, 14, 7394, 8176, 14440, 54, 19, 304, 272, 3329, 63, 354, 275, 283, 4782, 7, 272, 2402, 63, 5359, 63, 475, 63, 912, 275, 2097, 1569, 13, 2343, 937, 339, 347, 511, 63, 4782, 63, 513, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 5935, 664, 769, 1056, 14, 267, 1177, 275, 291, 423, 1117, 63, 362, 360, 4782, 358, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 4782, 13, 513, 13, 362, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 362, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 1373, 2849, 1834, 2436, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 1177, 275, 291, 423, 1117, 63, 362, 360, 4782, 3149, 83, 7, 450, 1834, 63, 344, 9, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 13868, 459, 1569, 63, 344, 418, 275, 1834, 63, 344, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 362, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 4782, 63, 5087, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 1006, 5935, 2436, 1056, 14, 267, 1177, 275, 291, 423, 1117, 63, 362, 360, 4782, 15, 5506, 358, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 4782, 13, 5087, 13, 362, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 2343, 63, 362, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 376, 1834, 3341, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 1177, 275, 291, 423, 1117, 63, 362, 360, 4782, 3149, 83, 15, 2343, 7, 450, 1834, 63, 344, 9, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 13868, 459, 1569, 63, 344, 418, 275, 1834, 63, 344, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 2343, 13, 362, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 2343, 63, 1932, 8, 277, 304, 267, 327, 2372, 2986, 2690, 370, 1678, 3341, 402, 376, 1834, 3341, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 1177, 275, 291, 423, 1117, 63, 1932, 8, 355, 283, 4782, 3149, 83, 15, 2343, 7, 450, 1834, 63, 344, 12, 355, 283, 1569, 13, 2343, 13, 1932, 13, 2103, 297, 5009, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 2343, 13, 1932, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 2343, 63, 524, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 1834, 3341, 5324, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 1177, 275, 291, 423, 1117, 63, 524, 3508, 83, 15, 4782, 3149, 83, 15, 2343, 7, 450, 1816, 334, 277, 14, 1246, 14, 1715, 63, 344, 12, 1834, 63, 344, 395, 1816, 283, 1569, 13, 2343, 13, 524, 13, 2103, 297, 5009, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 2343, 13, 524, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 2024, 63, 498, 63, 362, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 376, 1834, 3341, 790, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 790, 275, 298, 4989, 63, 344, 2, 267, 1177, 275, 291, 423, 1117, 63, 362, 360, 4782, 3149, 83, 15, 2343, 3149, 83, 7, 450, 334, 1569, 63, 344, 12, 790, 430, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 2024, 13, 498, 13, 362, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 2024, 63, 498, 63, 524, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 1834, 3341, 790, 5324, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 790, 275, 298, 2495, 63, 4032, 63, 888, 2, 267, 1177, 275, 291, 423, 1117, 63, 524, 360, 4782, 3149, 83, 15, 2343, 3149, 83, 7, 450, 334, 1569, 63, 344, 12, 790, 395, 1816, 283, 1569, 13, 2024, 13, 498, 13, 524, 13, 2103, 297, 5009, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 2024, 13, 498, 13, 524, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 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 ]
[ 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 1898, 6171, 26202, 22304, 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, 421, 199, 504, 5913, 14, 2219, 14, 15481, 14, 86, 19, 492, 2986, 63, 3271, 63, 1095, 199, 504, 5913, 14, 2219, 14, 3248, 14, 1569, 492, 4026, 421, 199, 533, 32658, 8176, 9653, 774, 8, 1246, 63, 3271, 63, 1095, 14, 7394, 8176, 14440, 54, 19, 304, 272, 3329, 63, 354, 275, 283, 4782, 7, 272, 2402, 63, 5359, 63, 475, 63, 912, 275, 2097, 1569, 13, 2343, 937, 339, 347, 511, 63, 4782, 63, 513, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 5935, 664, 769, 1056, 14, 267, 1177, 275, 291, 423, 1117, 63, 362, 360, 4782, 358, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 4782, 13, 513, 13, 362, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 362, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 1373, 2849, 1834, 2436, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 1177, 275, 291, 423, 1117, 63, 362, 360, 4782, 3149, 83, 7, 450, 1834, 63, 344, 9, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 13868, 459, 1569, 63, 344, 418, 275, 1834, 63, 344, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 362, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 4782, 63, 5087, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 1006, 5935, 2436, 1056, 14, 267, 1177, 275, 291, 423, 1117, 63, 362, 360, 4782, 15, 5506, 358, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 4782, 13, 5087, 13, 362, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 2343, 63, 362, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 376, 1834, 3341, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 1177, 275, 291, 423, 1117, 63, 362, 360, 4782, 3149, 83, 15, 2343, 7, 450, 1834, 63, 344, 9, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 13868, 459, 1569, 63, 344, 418, 275, 1834, 63, 344, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 2343, 13, 362, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 2343, 63, 1932, 8, 277, 304, 267, 327, 2372, 2986, 2690, 370, 1678, 3341, 402, 376, 1834, 3341, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 1177, 275, 291, 423, 1117, 63, 1932, 8, 355, 283, 4782, 3149, 83, 15, 2343, 7, 450, 1834, 63, 344, 12, 355, 283, 1569, 13, 2343, 13, 1932, 13, 2103, 297, 5009, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 2343, 13, 1932, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 2343, 63, 524, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 1834, 3341, 5324, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 1177, 275, 291, 423, 1117, 63, 524, 3508, 83, 15, 4782, 3149, 83, 15, 2343, 7, 450, 1816, 334, 277, 14, 1246, 14, 1715, 63, 344, 12, 1834, 63, 344, 395, 1816, 283, 1569, 13, 2343, 13, 524, 13, 2103, 297, 5009, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 2343, 13, 524, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 2024, 63, 498, 63, 362, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 376, 1834, 3341, 790, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 790, 275, 298, 4989, 63, 344, 2, 267, 1177, 275, 291, 423, 1117, 63, 362, 360, 4782, 3149, 83, 15, 2343, 3149, 83, 7, 450, 334, 1569, 63, 344, 12, 790, 430, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 2024, 13, 498, 13, 362, 297, 13868, 12, 1177, 12, 1926, 9, 339, 347, 511, 63, 1569, 63, 2024, 63, 498, 63, 524, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 1834, 3341, 790, 5324, 1056, 14, 267, 1834, 63, 344, 275, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 342, 267, 790, 275, 298, 2495, 63, 4032, 63, 888, 2, 267, 1177, 275, 291, 423, 1117, 63, 524, 360, 4782, 3149, 83, 15, 2343, 3149, 83, 7, 450, 334, 1569, 63, 344, 12, 790, 395, 1816, 283, 1569, 13, 2024, 13, 498, 13, 524, 13, 2103, 297, 5009, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 291, 423, 4712, 63, 1310, 360, 1569, 13, 2024, 13, 498, 13, 524, 13, 4518, 297, 13868, 12, 1177, 12, 1926, 9, 199, 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 ]
ryansb/boto
boto/logs/exceptions.py
150
1732
# -*- coding: utf-8 -*- # Copyright (c) 2012 Thomas Parslow http://almostobsolete.net/ # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # from boto.exception import BotoServerError class LimitExceededException(BotoServerError): pass class DataAlreadyAcceptedException(BotoServerError): pass class ResourceInUseException(BotoServerError): pass class ServiceUnavailableException(BotoServerError): pass class InvalidParameterException(BotoServerError): pass class ResourceNotFoundException(BotoServerError): pass class ResourceAlreadyExistsException(BotoServerError): pass class OperationAbortedException(BotoServerError): pass class InvalidSequenceTokenException(BotoServerError): pass
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 6029, 27864, 2235, 14362, 1455, 921, 4398, 25385, 14, 846, 15, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 3, 199, 504, 6055, 14, 1971, 492, 24411, 17692, 421, 199, 533, 22672, 24748, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 3918, 16760, 1945, 7203, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7337, 31425, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7591, 28049, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 6378, 4720, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7337, 22646, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7337, 16760, 7965, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 17954, 5583, 1376, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 6378, 5826, 3264, 1726, 8, 20380, 17692, 304, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 6029, 27864, 2235, 14362, 1455, 921, 4398, 25385, 14, 846, 15, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 3, 199, 504, 6055, 14, 1971, 492, 24411, 17692, 421, 199, 533, 22672, 24748, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 3918, 16760, 1945, 7203, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7337, 31425, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7591, 28049, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 6378, 4720, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7337, 22646, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 7337, 16760, 7965, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 17954, 5583, 1376, 1726, 8, 20380, 17692, 304, 272, 986, 421, 199, 533, 6378, 5826, 3264, 1726, 8, 20380, 17692, 304, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mmlr/qemu-haiku
roms/seabios/scripts/readserial.py
11
6173
#!/usr/bin/env python # Script that can read from a serial device and show timestamps. # # Copyright (C) 2009 Kevin O'Connor <kevin@koconnor.net> # # This file may be distributed under the terms of the GNU GPLv3 license. # Usage: # tools/readserial.py /dev/ttyUSB0 115200 import sys import time import select import optparse from python23compat import as_bytes # Reset time counter after this much idle time. RESTARTINTERVAL = 60 # Number of bits in a transmitted byte - 8N1 is 1 start bit + 8 data # bits + 1 stop bit. BITSPERBYTE = 10 def calibrateserialwrite(outfile, byteadjust): # Build 4000 bytes of dummy data. data = "0123456789" * 4 + "012345678" + "\n" data = data * 80 while 1: st = time.time() outfile.write(as_bytes(data)) outfile.flush() et = time.time() sys.stdout.write( "Wrote %d - %.1fus per char (theory states %.1fus)\n" % ( len(data), (et-st) / len(data) * 1000000, byteadjust * 1000000)) sys.stdout.flush() time.sleep(3) def calibrateserialread(infile, byteadjust): starttime = lasttime = 0 totalchars = 0 while 1: select.select([infile], [], []) d = infile.read(4096) curtime = time.time() if curtime - lasttime > 1.0: if starttime and totalchars: sys.stdout.write( "Calibrating on %d bytes - %.1fus per char" " (theory states %.1fus)\n" % ( totalchars, float(lasttime - starttime) * 1000000 / totalchars, byteadjust * 1000000)) totalchars = 0 starttime = curtime else: totalchars += len(d) lasttime = curtime def readserial(infile, logfile, byteadjust): lasttime = 0 while 1: # Read data try: res = select.select([infile, sys.stdin], [], []) except KeyboardInterrupt: sys.stdout.write("\n") break if sys.stdin in res[0]: # Got keyboard input - force reset on next serial input sys.stdin.read(1) lasttime = 0 if len(res[0]) == 1: continue d = infile.read(4096) if not d: break datatime = time.time() datatime -= len(d) * byteadjust # Reset start time if no data for some time if datatime - lasttime > RESTARTINTERVAL: starttime = datatime charcount = 0 isnewline = 1 msg = "\n\n======= %s (adjust=%.1fus)\n" % ( time.asctime(time.localtime(datatime)), byteadjust * 1000000) sys.stdout.write(msg) logfile.write(as_bytes(msg)) lasttime = datatime # Translate unprintable chars; add timestamps out = as_bytes("") for c in d: if isnewline: delta = datatime - starttime - (charcount * byteadjust) out += "%06.3f: " % delta isnewline = 0 oc = ord(c) charcount += 1 datatime += byteadjust if oc == 0x0d: continue if oc == 0x00: out += "<00>\n" isnewline = 1 continue if oc == 0x0a: out += "\n" isnewline = 1 continue if oc < 0x20 or oc >= 0x7f and oc != 0x09: out += "<%02x>" % oc continue out += c if (sys.version_info > (3, 0)): sys.stdout.buffer.write(out) else: sys.stdout.write(out) sys.stdout.flush() logfile.write(out) logfile.flush() def main(): usage = "%prog [options] [<serialdevice> [<baud>]]" opts = optparse.OptionParser(usage) opts.add_option("-f", "--file", action="store_false", dest="serial", default=True, help="read from file instead of serialdevice") opts.add_option("-n", "--no-adjust", action="store_false", dest="adjustbaud", default=True, help="don't adjust times by serial rate") opts.add_option("-c", "--calibrate-read", action="store_true", dest="calibrate_read", default=False, help="read from serial port to calibrate it") opts.add_option("-C", "--calibrate-write", action="store_true", dest="calibrate_write", default=False, help="write to serial port to calibrate it") opts.add_option("-t", "--time", type="float", dest="time", default=None, help="time to write one byte on serial port (in us)") options, args = opts.parse_args() serialport = 0 baud = 115200 if len(args) > 2: opts.error("Too many arguments") if len(args) > 0: serialport = args[0] if len(args) > 1: baud = int(args[1]) byteadjust = float(BITSPERBYTE) / baud if options.time is not None: byteadjust = options.time / 1000000.0 if not options.adjustbaud: byteadjust = 0.0 if options.serial: # Read from serial port try: import serial except ImportError: print(""" Unable to find pyserial package ( http://pyserial.sourceforge.net/ ). On Linux machines try: yum install pyserial Or: apt-get install python-serial """) sys.exit(1) ser = serial.Serial(serialport, baud, timeout=0) else: # Read from a file ser = open(serialport, 'rb') import fcntl import os fcntl.fcntl(ser, fcntl.F_SETFL , fcntl.fcntl(ser, fcntl.F_GETFL) | os.O_NONBLOCK) if options.calibrate_read: calibrateserialread(ser, byteadjust) return if options.calibrate_write: calibrateserialwrite(ser, byteadjust) return logname = time.strftime("seriallog-%Y%m%d_%H%M%S.log") f = open(logname, 'wb') readserial(ser, f, byteadjust) if __name__ == '__main__': main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 14914, 626, 883, 1586, 687, 282, 3012, 2243, 436, 2498, 22496, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 221, 25645, 11908, 593, 7, 714, 6505, 665, 415, 11908, 32, 7697, 1631, 269, 14, 846, 30, 199, 3, 199, 3, 961, 570, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 14629, 86, 19, 4190, 14, 199, 199, 3, 11028, 26, 199, 3, 257, 7249, 15, 739, 2171, 14, 647, 1182, 2374, 15, 4707, 19919, 16, 22560, 1840, 199, 199, 646, 984, 199, 646, 900, 199, 646, 3504, 199, 646, 8691, 199, 199, 504, 2366, 1789, 5819, 492, 465, 63, 2394, 199, 199, 3, 15510, 900, 7055, 2410, 642, 8298, 15072, 900, 14, 199, 15740, 2294, 17359, 275, 5212, 199, 3, 4860, 402, 5821, 315, 282, 29818, 3696, 446, 1695, 46, 17, 365, 413, 1343, 4546, 435, 1695, 666, 199, 3, 5821, 435, 413, 3631, 4546, 14, 199, 14662, 4227, 19714, 275, 1616, 199, 199, 318, 12855, 1866, 2171, 952, 8, 4984, 12, 3696, 10917, 304, 272, 327, 6516, 31092, 2783, 402, 7283, 666, 14, 272, 666, 275, 298, 11371, 2, 627, 841, 435, 298, 9461, 12970, 2, 435, 1867, 78, 2, 272, 666, 275, 666, 627, 5939, 272, 1830, 413, 26, 267, 410, 275, 900, 14, 521, 342, 267, 4386, 14, 952, 8, 305, 63, 2394, 8, 576, 430, 267, 4386, 14, 4939, 342, 267, 10844, 275, 900, 14, 521, 342, 267, 984, 14, 2703, 14, 952, 8, 288, 298, 55, 22665, 450, 68, 446, 10536, 17, 31958, 1126, 1495, 334, 1589, 1089, 6363, 10536, 17, 31958, 2862, 78, 2, 450, 334, 355, 822, 8, 576, 395, 334, 386, 13, 270, 9, 1182, 822, 8, 576, 9, 627, 19492, 12, 3696, 10917, 627, 19492, 430, 267, 984, 14, 2703, 14, 4939, 342, 267, 900, 14, 4532, 8, 19, 9, 199, 199, 318, 12855, 1866, 2171, 739, 8, 13880, 12, 3696, 10917, 304, 272, 1343, 521, 275, 2061, 521, 275, 378, 272, 3141, 6574, 275, 378, 272, 1830, 413, 26, 267, 3504, 14, 2416, 779, 13880, 467, 990, 3073, 267, 366, 275, 14734, 14, 739, 8, 20579, 9, 267, 1094, 521, 275, 900, 14, 521, 342, 267, 340, 1094, 521, 446, 2061, 521, 690, 413, 14, 16, 26, 288, 340, 1343, 521, 436, 3141, 6574, 26, 355, 984, 14, 2703, 14, 952, 8, 490, 298, 26015, 10417, 641, 450, 68, 2783, 446, 10536, 17, 31958, 1126, 1495, 2, 490, 298, 334, 1589, 1089, 6363, 10536, 17, 31958, 2862, 78, 2, 450, 334, 717, 3141, 6574, 12, 717, 2069, 8, 2019, 521, 446, 1343, 521, 9, 627, 19492, 1182, 3141, 6574, 12, 717, 3696, 10917, 627, 19492, 430, 288, 3141, 6574, 275, 378, 288, 1343, 521, 275, 1094, 521, 267, 587, 26, 288, 3141, 6574, 847, 822, 8, 68, 9, 267, 2061, 521, 275, 1094, 521, 199, 199, 318, 1586, 2171, 8, 13880, 12, 17251, 12, 3696, 10917, 304, 272, 2061, 521, 275, 378, 272, 1830, 413, 26, 267, 327, 5574, 666, 267, 862, 26, 288, 522, 275, 3504, 14, 2416, 779, 13880, 12, 984, 14, 6626, 467, 990, 3073, 267, 871, 13483, 26, 288, 984, 14, 2703, 14, 952, 4582, 78, 531, 288, 2059, 267, 340, 984, 14, 6626, 315, 522, 59, 16, 2189, 288, 327, 24734, 18716, 1324, 446, 3542, 5305, 641, 2163, 3012, 1324, 288, 984, 14, 6626, 14, 739, 8, 17, 9, 288, 2061, 521, 275, 378, 288, 340, 822, 8, 470, 59, 16, 566, 508, 413, 26, 355, 1980, 267, 366, 275, 14734, 14, 739, 8, 20579, 9, 267, 340, 440, 366, 26, 288, 2059, 267, 666, 521, 275, 900, 14, 521, 342, 398, 666, 521, 4862, 822, 8, 68, 9, 627, 3696, 10917, 398, 327, 15510, 1343, 900, 340, 949, 666, 367, 2005, 900, 267, 340, 666, 521, 446, 2061, 521, 690, 14880, 2294, 17359, 26, 288, 1343, 521, 275, 666, 521, 288, 1495, 835, 275, 378, 288, 365, 12210, 275, 413, 288, 1499, 275, 1867, 78, 60, 78, 18673, 450, 83, 334, 10917, 2458, 14, 17, 31958, 2862, 78, 2, 450, 334, 355, 900, 14, 18331, 8, 521, 14, 15198, 8, 576, 521, 1826, 3696, 10917, 627, 19492, 9, 288, 984, 14, 2703, 14, 952, 8, 1328, 9, 288, 17251, 14, 952, 8, 305, 63, 2394, 8, 1328, 430, 267, 2061, 521, 275, 666, 521, 398, 327, 25540, 625, 20557, 8365, 27, 1050, 22496, 267, 734, 275, 465, 63, 2394, 10804, 267, 367, 286, 315, 366, 26, 288, 340, 365, 12210, 26, 355, 5762, 275, 666, 521, 446, 1343, 521, 446, 334, 1560, 835, 627, 3696, 10917, 9, 355, 734, 847, 2071, 1690, 14, 19, 70, 26, 298, 450, 5762, 355, 365, 12210, 275, 378, 288, 4244, 275, 6206, 8, 67, 9, 288, 1495, 835, 847, 413, 288, 666, 521, 847, 3696, 10917, 288, 340, 4244, 508, 378, 88, 16, 68, 26, 355, 1980, 288, 340, 4244, 508, 378, 88, 383, 26, 355, 734, 847, 3886, 383, 3072, 78, 2, 355, 365, 12210, 275, 413, 355, 1980, 288, 340, 4244, 508, 378, 88, 16, 65, 26, 355, 734, 847, 1867, 78, 2, 355, 365, 12210, 275, 413, 355, 1980, 288, 340, 4244, 665, 378, 88, 1165, 503, 4244, 2356, 378, 88, 23, 70, 436, 4244, 1137, 378, 88, 1643, 26, 355, 734, 847, 23054, 996, 88, 4335, 450, 4244, 355, 1980, 288, 734, 847, 286, 398, 340, 334, 1274, 14, 1023, 63, 815, 690, 334, 19, 12, 378, 2298, 288, 984, 14, 2703, 14, 2738, 14, 952, 8, 548, 9, 267, 587, 26, 288, 984, 14, 2703, 14, 952, 8, 548, 9, 267, 984, 14, 2703, 14, 4939, 342, 267, 17251, 14, 952, 8, 548, 9, 267, 17251, 14, 4939, 342, 199, 199, 318, 2446, 837, 272, 4503, 275, 2071, 6595, 359, 1419, 61, 24936, 2171, 1782, 30, 24936, 2470, 1181, 30, 2677, 2, 272, 3999, 275, 8691, 14, 14553, 8, 3807, 9, 272, 3999, 14, 525, 63, 1422, 6096, 70, 401, 4320, 493, 401, 490, 1595, 628, 1617, 63, 3910, 401, 2053, 628, 2171, 401, 849, 29, 549, 12, 490, 1720, 628, 739, 687, 570, 3140, 402, 3012, 1782, 531, 272, 3999, 14, 525, 63, 1422 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 14914, 626, 883, 1586, 687, 282, 3012, 2243, 436, 2498, 22496, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 221, 25645, 11908, 593, 7, 714, 6505, 665, 415, 11908, 32, 7697, 1631, 269, 14, 846, 30, 199, 3, 199, 3, 961, 570, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 14629, 86, 19, 4190, 14, 199, 199, 3, 11028, 26, 199, 3, 257, 7249, 15, 739, 2171, 14, 647, 1182, 2374, 15, 4707, 19919, 16, 22560, 1840, 199, 199, 646, 984, 199, 646, 900, 199, 646, 3504, 199, 646, 8691, 199, 199, 504, 2366, 1789, 5819, 492, 465, 63, 2394, 199, 199, 3, 15510, 900, 7055, 2410, 642, 8298, 15072, 900, 14, 199, 15740, 2294, 17359, 275, 5212, 199, 3, 4860, 402, 5821, 315, 282, 29818, 3696, 446, 1695, 46, 17, 365, 413, 1343, 4546, 435, 1695, 666, 199, 3, 5821, 435, 413, 3631, 4546, 14, 199, 14662, 4227, 19714, 275, 1616, 199, 199, 318, 12855, 1866, 2171, 952, 8, 4984, 12, 3696, 10917, 304, 272, 327, 6516, 31092, 2783, 402, 7283, 666, 14, 272, 666, 275, 298, 11371, 2, 627, 841, 435, 298, 9461, 12970, 2, 435, 1867, 78, 2, 272, 666, 275, 666, 627, 5939, 272, 1830, 413, 26, 267, 410, 275, 900, 14, 521, 342, 267, 4386, 14, 952, 8, 305, 63, 2394, 8, 576, 430, 267, 4386, 14, 4939, 342, 267, 10844, 275, 900, 14, 521, 342, 267, 984, 14, 2703, 14, 952, 8, 288, 298, 55, 22665, 450, 68, 446, 10536, 17, 31958, 1126, 1495, 334, 1589, 1089, 6363, 10536, 17, 31958, 2862, 78, 2, 450, 334, 355, 822, 8, 576, 395, 334, 386, 13, 270, 9, 1182, 822, 8, 576, 9, 627, 19492, 12, 3696, 10917, 627, 19492, 430, 267, 984, 14, 2703, 14, 4939, 342, 267, 900, 14, 4532, 8, 19, 9, 199, 199, 318, 12855, 1866, 2171, 739, 8, 13880, 12, 3696, 10917, 304, 272, 1343, 521, 275, 2061, 521, 275, 378, 272, 3141, 6574, 275, 378, 272, 1830, 413, 26, 267, 3504, 14, 2416, 779, 13880, 467, 990, 3073, 267, 366, 275, 14734, 14, 739, 8, 20579, 9, 267, 1094, 521, 275, 900, 14, 521, 342, 267, 340, 1094, 521, 446, 2061, 521, 690, 413, 14, 16, 26, 288, 340, 1343, 521, 436, 3141, 6574, 26, 355, 984, 14, 2703, 14, 952, 8, 490, 298, 26015, 10417, 641, 450, 68, 2783, 446, 10536, 17, 31958, 1126, 1495, 2, 490, 298, 334, 1589, 1089, 6363, 10536, 17, 31958, 2862, 78, 2, 450, 334, 717, 3141, 6574, 12, 717, 2069, 8, 2019, 521, 446, 1343, 521, 9, 627, 19492, 1182, 3141, 6574, 12, 717, 3696, 10917, 627, 19492, 430, 288, 3141, 6574, 275, 378, 288, 1343, 521, 275, 1094, 521, 267, 587, 26, 288, 3141, 6574, 847, 822, 8, 68, 9, 267, 2061, 521, 275, 1094, 521, 199, 199, 318, 1586, 2171, 8, 13880, 12, 17251, 12, 3696, 10917, 304, 272, 2061, 521, 275, 378, 272, 1830, 413, 26, 267, 327, 5574, 666, 267, 862, 26, 288, 522, 275, 3504, 14, 2416, 779, 13880, 12, 984, 14, 6626, 467, 990, 3073, 267, 871, 13483, 26, 288, 984, 14, 2703, 14, 952, 4582, 78, 531, 288, 2059, 267, 340, 984, 14, 6626, 315, 522, 59, 16, 2189, 288, 327, 24734, 18716, 1324, 446, 3542, 5305, 641, 2163, 3012, 1324, 288, 984, 14, 6626, 14, 739, 8, 17, 9, 288, 2061, 521, 275, 378, 288, 340, 822, 8, 470, 59, 16, 566, 508, 413, 26, 355, 1980, 267, 366, 275, 14734, 14, 739, 8, 20579, 9, 267, 340, 440, 366, 26, 288, 2059, 267, 666, 521, 275, 900, 14, 521, 342, 398, 666, 521, 4862, 822, 8, 68, 9, 627, 3696, 10917, 398, 327, 15510, 1343, 900, 340, 949, 666, 367, 2005, 900, 267, 340, 666, 521, 446, 2061, 521, 690, 14880, 2294, 17359, 26, 288, 1343, 521, 275, 666, 521, 288, 1495, 835, 275, 378, 288, 365, 12210, 275, 413, 288, 1499, 275, 1867, 78, 60, 78, 18673, 450, 83, 334, 10917, 2458, 14, 17, 31958, 2862, 78, 2, 450, 334, 355, 900, 14, 18331, 8, 521, 14, 15198, 8, 576, 521, 1826, 3696, 10917, 627, 19492, 9, 288, 984, 14, 2703, 14, 952, 8, 1328, 9, 288, 17251, 14, 952, 8, 305, 63, 2394, 8, 1328, 430, 267, 2061, 521, 275, 666, 521, 398, 327, 25540, 625, 20557, 8365, 27, 1050, 22496, 267, 734, 275, 465, 63, 2394, 10804, 267, 367, 286, 315, 366, 26, 288, 340, 365, 12210, 26, 355, 5762, 275, 666, 521, 446, 1343, 521, 446, 334, 1560, 835, 627, 3696, 10917, 9, 355, 734, 847, 2071, 1690, 14, 19, 70, 26, 298, 450, 5762, 355, 365, 12210, 275, 378, 288, 4244, 275, 6206, 8, 67, 9, 288, 1495, 835, 847, 413, 288, 666, 521, 847, 3696, 10917, 288, 340, 4244, 508, 378, 88, 16, 68, 26, 355, 1980, 288, 340, 4244, 508, 378, 88, 383, 26, 355, 734, 847, 3886, 383, 3072, 78, 2, 355, 365, 12210, 275, 413, 355, 1980, 288, 340, 4244, 508, 378, 88, 16, 65, 26, 355, 734, 847, 1867, 78, 2, 355, 365, 12210, 275, 413, 355, 1980, 288, 340, 4244, 665, 378, 88, 1165, 503, 4244, 2356, 378, 88, 23, 70, 436, 4244, 1137, 378, 88, 1643, 26, 355, 734, 847, 23054, 996, 88, 4335, 450, 4244, 355, 1980, 288, 734, 847, 286, 398, 340, 334, 1274, 14, 1023, 63, 815, 690, 334, 19, 12, 378, 2298, 288, 984, 14, 2703, 14, 2738, 14, 952, 8, 548, 9, 267, 587, 26, 288, 984, 14, 2703, 14, 952, 8, 548, 9, 267, 984, 14, 2703, 14, 4939, 342, 267, 17251, 14, 952, 8, 548, 9, 267, 17251, 14, 4939, 342, 199, 199, 318, 2446, 837, 272, 4503, 275, 2071, 6595, 359, 1419, 61, 24936, 2171, 1782, 30, 24936, 2470, 1181, 30, 2677, 2, 272, 3999, 275, 8691, 14, 14553, 8, 3807, 9, 272, 3999, 14, 525, 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 ]
chen0510566/MissionPlanner
Lib/timeit.py
50
12387
#! /usr/bin/env python """Tool for measuring execution time of small code snippets. This module avoids a number of common traps for measuring execution times. See also Tim Peters' introduction to the Algorithms chapter in the Python Cookbook, published by O'Reilly. Library usage: see the Timer class. Command line usage: python timeit.py [-n N] [-r N] [-s S] [-t] [-c] [-h] [--] [statement] Options: -n/--number N: how many times to execute 'statement' (default: see below) -r/--repeat N: how many times to repeat the timer (default 3) -s/--setup S: statement to be executed once initially (default 'pass') -t/--time: use time.time() (default on Unix) -c/--clock: use time.clock() (default on Windows) -v/--verbose: print raw timing results; repeat for more digits precision -h/--help: print this usage message and exit --: separate options from statement, use when statement starts with - statement: statement to be timed (default 'pass') A multi-line statement may be given by specifying each line as a separate argument; indented lines are possible by enclosing an argument in quotes and using leading spaces. Multiple -s options are treated similarly. If -n is not given, a suitable number of loops is calculated by trying successive powers of 10 until the total time is at least 0.2 seconds. The difference in default timer function is because on Windows, clock() has microsecond granularity but time()'s granularity is 1/60th of a second; on Unix, clock() has 1/100th of a second granularity and time() is much more precise. On either platform, the default timer functions measure wall clock time, not the CPU time. This means that other processes running on the same computer may interfere with the timing. The best thing to do when accurate timing is necessary is to repeat the timing a few times and use the best time. The -r option is good for this; the default of 3 repetitions is probably enough in most cases. On Unix, you can use clock() to measure CPU time. Note: there is a certain baseline overhead associated with executing a pass statement. The code here doesn't try to hide it, but you should be aware of it. The baseline overhead can be measured by invoking the program without arguments. The baseline overhead differs between Python versions! Also, to fairly compare older Python versions to Python 2.3, you may want to use python -O for the older versions to avoid timing SET_LINENO instructions. """ import gc import sys import time try: import itertools except ImportError: # Must be an older Python version (see timeit() below) itertools = None __all__ = ["Timer"] dummy_src_name = "<timeit-src>" default_number = 1000000 default_repeat = 3 if sys.platform == "win32": # On Windows, the best timer is time.clock() default_timer = time.clock else: # On most other platforms the best timer is time.time() default_timer = time.time # Don't change the indentation of the template; the reindent() calls # in Timer.__init__() depend on setup being indented 4 spaces and stmt # being indented 8 spaces. template = """ def inner(_it, _timer): %(setup)s _t0 = _timer() for _i in _it: %(stmt)s _t1 = _timer() return _t1 - _t0 """ def reindent(src, indent): """Helper to reindent a multi-line statement.""" return src.replace("\n", "\n" + " "*indent) def _template_func(setup, func): """Create a timer function. Used if the "statement" is a callable.""" def inner(_it, _timer, _func=func): setup() _t0 = _timer() for _i in _it: _func() _t1 = _timer() return _t1 - _t0 return inner class Timer: """Class for timing execution speed of small code snippets. The constructor takes a statement to be timed, an additional statement used for setup, and a timer function. Both statements default to 'pass'; the timer function is platform-dependent (see module doc string). To measure the execution time of the first statement, use the timeit() method. The repeat() method is a convenience to call timeit() multiple times and return a list of results. The statements may contain newlines, as long as they don't contain multi-line string literals. """ def __init__(self, stmt="pass", setup="pass", timer=default_timer): """Constructor. See class doc string.""" self.timer = timer ns = {} if isinstance(stmt, basestring): stmt = reindent(stmt, 8) if isinstance(setup, basestring): setup = reindent(setup, 4) src = template % {'stmt': stmt, 'setup': setup} elif hasattr(setup, '__call__'): src = template % {'stmt': stmt, 'setup': '_setup()'} ns['_setup'] = setup else: raise ValueError("setup is neither a string nor callable") self.src = src # Save for traceback display code = compile(src, dummy_src_name, "exec") exec code in globals(), ns self.inner = ns["inner"] elif hasattr(stmt, '__call__'): self.src = None if isinstance(setup, basestring): _setup = setup def setup(): exec _setup in globals(), ns elif not hasattr(setup, '__call__'): raise ValueError("setup is neither a string nor callable") self.inner = _template_func(setup, stmt) else: raise ValueError("stmt is neither a string nor callable") def print_exc(self, file=None): """Helper to print a traceback from the timed code. Typical use: t = Timer(...) # outside the try/except try: t.timeit(...) # or t.repeat(...) except: t.print_exc() The advantage over the standard traceback is that source lines in the compiled template will be displayed. The optional file argument directs where the traceback is sent; it defaults to sys.stderr. """ import linecache, traceback if self.src is not None: linecache.cache[dummy_src_name] = (len(self.src), None, self.src.split("\n"), dummy_src_name) # else the source is already stored somewhere else traceback.print_exc(file=file) def timeit(self, number=default_number): """Time 'number' executions of the main statement. To be precise, this executes the setup statement once, and then returns the time it takes to execute the main statement a number of times, as a float measured in seconds. The argument is the number of times through the loop, defaulting to one million. The main statement, the setup statement and the timer function to be used are passed to the constructor. """ if itertools: it = itertools.repeat(None, number) else: it = [None] * number gcold = gc.isenabled() gc.disable() timing = self.inner(it, self.timer) if gcold: gc.enable() return timing def repeat(self, repeat=default_repeat, number=default_number): """Call timeit() a few times. This is a convenience function that calls the timeit() repeatedly, returning a list of results. The first argument specifies how many times to call timeit(), defaulting to 3; the second argument specifies the timer argument, defaulting to one million. Note: it's tempting to calculate mean and standard deviation from the result vector and report these. However, this is not very useful. In a typical case, the lowest value gives a lower bound for how fast your machine can run the given code snippet; higher values in the result vector are typically not caused by variability in Python's speed, but by other processes interfering with your timing accuracy. So the min() of the result is probably the only number you should be interested in. After that, you should look at the entire vector and apply common sense rather than statistics. """ r = [] for i in range(repeat): t = self.timeit(number) r.append(t) return r def timeit(stmt="pass", setup="pass", timer=default_timer, number=default_number): """Convenience function to create Timer object and call timeit method.""" return Timer(stmt, setup, timer).timeit(number) def repeat(stmt="pass", setup="pass", timer=default_timer, repeat=default_repeat, number=default_number): """Convenience function to create Timer object and call repeat method.""" return Timer(stmt, setup, timer).repeat(repeat, number) def main(args=None): """Main program, used when run as a script. The optional argument specifies the command line to be parsed, defaulting to sys.argv[1:]. The return value is an exit code to be passed to sys.exit(); it may be None to indicate success. When an exception happens during timing, a traceback is printed to stderr and the return value is 1. Exceptions at other times (including the template compilation) are not caught. """ if args is None: args = sys.argv[1:] import getopt try: opts, args = getopt.getopt(args, "n:s:r:tcvh", ["number=", "setup=", "repeat=", "time", "clock", "verbose", "help"]) except getopt.error, err: print err print "use -h/--help for command line help" return 2 timer = default_timer stmt = "\n".join(args) or "pass" number = 0 # auto-determine setup = [] repeat = default_repeat verbose = 0 precision = 3 for o, a in opts: if o in ("-n", "--number"): number = int(a) if o in ("-s", "--setup"): setup.append(a) if o in ("-r", "--repeat"): repeat = int(a) if repeat <= 0: repeat = 1 if o in ("-t", "--time"): timer = time.time if o in ("-c", "--clock"): timer = time.clock if o in ("-v", "--verbose"): if verbose: precision += 1 verbose += 1 if o in ("-h", "--help"): print __doc__, return 0 setup = "\n".join(setup) or "pass" # Include the current directory, so that local imports work (sys.path # contains the directory of this script, rather than the current # directory) import os sys.path.insert(0, os.curdir) t = Timer(stmt, setup, timer) if number == 0: # determine number so that 0.2 <= total time < 2.0 for i in range(1, 10): number = 10**i try: x = t.timeit(number) except: t.print_exc() return 1 if verbose: print "%d loops -> %.*g secs" % (number, precision, x) if x >= 0.2: break try: r = t.repeat(repeat, number) except: t.print_exc() return 1 best = min(r) if verbose: print "raw times:", " ".join(["%.*g" % (precision, x) for x in r]) print "%d loops," % number, usec = best * 1e6 / number if usec < 1000: print "best of %d: %.*g usec per loop" % (repeat, precision, usec) else: msec = usec / 1000 if msec < 1000: print "best of %d: %.*g msec per loop" % (repeat, precision, msec) else: sec = msec / 1000 print "best of %d: %.*g sec per loop" % (repeat, precision, sec) return None if __name__ == "__main__": sys.exit(main())
gpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 2999, 199, 624, 5157, 367, 17616, 4039, 6451, 900, 402, 7425, 1233, 19484, 14, 2999, 199, 2765, 859, 23674, 282, 1329, 402, 2863, 1468, 1190, 367, 17616, 4039, 6451, 202, 199, 4508, 14, 221, 1666, 2597, 26244, 11379, 878, 7, 13318, 5199, 370, 314, 4580, 12719, 17044, 315, 202, 199, 1589, 2018, 1849, 32632, 12, 3267, 701, 593, 7, 497, 382, 590, 14, 2999, 199, 7424, 4503, 26, 1937, 314, 22287, 1021, 14, 2999, 199, 3110, 1004, 4503, 26, 1128, 2366, 900, 390, 14, 647, 5243, 78, 653, 61, 5243, 82, 653, 61, 5243, 83, 428, 61, 5243, 84, 61, 5243, 67, 61, 5243, 72, 61, 19344, 61, 359, 6242, 61, 2999, 199, 4558, 26, 10292, 446, 78, 25695, 1955, 653, 26, 4212, 5002, 5431, 370, 5341, 283, 6242, 7, 334, 885, 26, 1937, 5084, 9, 10292, 446, 82, 25695, 8755, 653, 26, 4212, 5002, 5431, 370, 11982, 314, 9715, 334, 885, 650, 9, 10292, 446, 83, 25695, 2758, 428, 26, 5164, 370, 506, 7934, 5403, 22801, 334, 885, 283, 1529, 358, 10292, 446, 84, 25695, 521, 26, 675, 900, 14, 521, 342, 334, 885, 641, 13074, 9, 10292, 446, 67, 25695, 9597, 26, 675, 900, 14, 9597, 342, 334, 885, 641, 5417, 9, 10292, 446, 86, 25695, 3832, 26, 870, 3066, 20542, 2058, 27, 11982, 367, 1655, 7576, 7151, 10292, 446, 72, 25695, 3437, 26, 870, 642, 4503, 1245, 436, 4458, 10292, 1553, 26, 7396, 1511, 687, 5164, 12, 675, 1380, 5164, 9174, 543, 446, 10292, 5164, 26, 5164, 370, 506, 18590, 334, 885, 283, 1529, 358, 2999, 199, 33, 3510, 13, 604, 5164, 1443, 506, 1627, 701, 9176, 1924, 1004, 465, 282, 202, 199, 24904, 1423, 27, 19197, 2385, 787, 3962, 701, 25188, 376, 202, 199, 2094, 315, 9344, 436, 1808, 9186, 7883, 14, 221, 14326, 446, 83, 1511, 787, 202, 199, 84, 9640, 8545, 590, 14, 2999, 199, 3917, 446, 78, 365, 440, 1627, 12, 282, 11233, 1329, 402, 17222, 365, 12950, 701, 9936, 202, 199, 28251, 823, 3398, 13131, 1192, 402, 1616, 5133, 314, 3141, 900, 365, 737, 5210, 378, 14, 18, 4696, 14, 2999, 199, 1918, 8865, 315, 849, 9715, 805, 365, 2952, 641, 5417, 12, 202, 199, 9597, 342, 965, 25824, 9202, 22504, 1325, 900, 11716, 83, 9202, 22504, 365, 413, 15, 2259, 273, 202, 199, 1618, 282, 3499, 27, 641, 13074, 12, 12516, 342, 965, 413, 15, 1960, 273, 402, 282, 3499, 9202, 22504, 436, 202, 199, 521, 342, 365, 8298, 1655, 28334, 14, 221, 4068, 1902, 4298, 12, 314, 849, 9715, 202, 199, 5777, 9775, 19882, 12516, 900, 12, 440, 314, 11952, 900, 14, 221, 961, 4910, 626, 202, 199, 1848, 10358, 3879, 641, 314, 2011, 24189, 1443, 1640, 771, 264, 543, 314, 202, 199, 14639, 14, 221, 710, 5526, 8377, 370, 886, 1380, 23189, 20542, 365, 5784, 365, 370, 202, 199, 8755, 314, 20542, 282, 9284, 5431, 436, 675, 314, 5526, 900, 14, 221, 710, 446, 82, 945, 365, 202, 199, 8302, 367, 642, 27, 314, 849, 402, 650, 6375, 7752, 365, 8646, 8321, 315, 4750, 202, 199, 9403, 14, 221, 4068, 13074, 12, 1265, 883, 675, 12516, 342, 370, 9775, 11952, 900, 14, 2999, 199, 7443, 26, 2337, 365, 282, 9842, 18828, 24075, 4568, 543, 14043, 282, 202, 199, 1529, 5164, 14, 221, 710, 1233, 2348, 3181, 1133, 862, 370, 13714, 652, 12, 1325, 1265, 1077, 202, 199, 1235, 20381, 402, 652, 14, 221, 710, 18828, 24075, 883, 506, 27396, 701, 26750, 314, 202, 199, 6815, 1928, 2368, 14, 2999, 199, 1918, 18828, 24075, 22754, 3382, 2018, 5459, 1, 221, 6121, 12, 370, 202, 199, 667, 723, 590, 6540, 12731, 2018, 5459, 370, 2018, 499, 14, 19, 12, 1265, 1443, 2934, 370, 202, 199, 1180, 2366, 446, 47, 367, 314, 12731, 5459, 370, 5126, 20542, 11543, 63, 6143, 15577, 202, 199, 20718, 14, 202, 199, 624, 2999, 199, 646, 9486, 202, 199, 646, 984, 202, 199, 646, 900, 202, 199, 893, 26, 1128, 492, 7975, 202, 199, 2590, 3545, 26, 1128, 327, 9498, 506, 376, 12731, 2018, 1015, 334, 3239, 900, 390, 342, 5084, 9, 1128, 7975, 275, 488, 2999, 199, 363, 452, 363, 275, 2097, 7929, 937, 2999, 199, 5869, 63, 2164, 63, 354, 275, 3886, 521, 390, 13, 2164, 4335, 202, 199, 885, 63, 1955, 275, 19492, 202, 199, 885, 63, 8755, 275, 650, 2999, 199, 692, 984, 14, 3246, 508, 298, 2676, 708, 582, 1128, 327, 4068, 5417, 12, 314, 5526, 9715, 365, 900, 14, 9597, 342, 1128, 849, 63, 7414, 275, 900, 14, 9597, 202, 199, 2836, 26, 1128, 327, 4068, 4750, 1163, 10677, 314, 5526, 9715, 365, 900, 14, 521, 342, 1128, 849, 63, 7414, 275, 900, 14, 521, 2999, 199, 3, 7529, 1133, 1570, 314, 14311, 402, 314, 1978, 27, 314, 295, 3724, 342, 4882, 202, 199, 3, 315, 22287, 855, 826, 4533, 11687, 641, 3272, 3769, 19197, 841, 7883, 436, 12284, 202, 199, 3, 3769, 19197, 1695, 7883, 14, 202, 199, 1160, 275, 408, 202, 199, 318, 6506, 1547, 390, 12, 485, 7414, 304, 1128, 2818, 2758, 9, 83, 1128, 485, 84, 16, 275, 485, 7414, 342, 1128, 367, 485, 73, 315, 485, 390, 26, 1039, 2818, 9649, 9, 83, 1128, 485, 84, 17, 275, 485, 7414, 342, 1128, 372, 485, 84, 17, 446, 485, 84, 16, 202, 199, 624, 2999, 199, 318, 295, 3724, 8, 2164, 12, 4363, 304, 1128, 408, 4433, 370, 295, 3724, 282, 3510, 13, 604, 5164, 1041, 1128, 372, 2928, 14, 1814, 4582, 78, 401, 1867, 78, 2, 435, 298, 8969, 3724, 9, 2999, 199, 318, 485, 1160, 63, 1532, 8, 2758, 12, 2562, 304, 1128, 408, 2499, 282, 9715, 805, 14, 8051, 340, 314, 298, 6242, 2, 365, 282, 4550, 1041, 1128, 347, 6506, 1547, 390, 12, 485, 7414, 12, 485, 1532, 29, 1532, 304, 1039, 3272, 342, 1039, 485, 84, 16, 275, 485, 7414, 342, 1039, 367, 485, 73, 315, 485, 390, 26, 1675, 485, 1532, 342, 1039, 485, 84, 17, 275, 485, 7414, 342, 1039, 372, 485, 84, 17, 446, 485, 84, 16, 1128, 372, 6506, 2999, 199, 533, 22287, 26, 1128, 408, 2543, 367, 20542, 6451, 8112, 402, 7425, 1233 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 2999, 199, 624, 5157, 367, 17616, 4039, 6451, 900, 402, 7425, 1233, 19484, 14, 2999, 199, 2765, 859, 23674, 282, 1329, 402, 2863, 1468, 1190, 367, 17616, 4039, 6451, 202, 199, 4508, 14, 221, 1666, 2597, 26244, 11379, 878, 7, 13318, 5199, 370, 314, 4580, 12719, 17044, 315, 202, 199, 1589, 2018, 1849, 32632, 12, 3267, 701, 593, 7, 497, 382, 590, 14, 2999, 199, 7424, 4503, 26, 1937, 314, 22287, 1021, 14, 2999, 199, 3110, 1004, 4503, 26, 1128, 2366, 900, 390, 14, 647, 5243, 78, 653, 61, 5243, 82, 653, 61, 5243, 83, 428, 61, 5243, 84, 61, 5243, 67, 61, 5243, 72, 61, 19344, 61, 359, 6242, 61, 2999, 199, 4558, 26, 10292, 446, 78, 25695, 1955, 653, 26, 4212, 5002, 5431, 370, 5341, 283, 6242, 7, 334, 885, 26, 1937, 5084, 9, 10292, 446, 82, 25695, 8755, 653, 26, 4212, 5002, 5431, 370, 11982, 314, 9715, 334, 885, 650, 9, 10292, 446, 83, 25695, 2758, 428, 26, 5164, 370, 506, 7934, 5403, 22801, 334, 885, 283, 1529, 358, 10292, 446, 84, 25695, 521, 26, 675, 900, 14, 521, 342, 334, 885, 641, 13074, 9, 10292, 446, 67, 25695, 9597, 26, 675, 900, 14, 9597, 342, 334, 885, 641, 5417, 9, 10292, 446, 86, 25695, 3832, 26, 870, 3066, 20542, 2058, 27, 11982, 367, 1655, 7576, 7151, 10292, 446, 72, 25695, 3437, 26, 870, 642, 4503, 1245, 436, 4458, 10292, 1553, 26, 7396, 1511, 687, 5164, 12, 675, 1380, 5164, 9174, 543, 446, 10292, 5164, 26, 5164, 370, 506, 18590, 334, 885, 283, 1529, 358, 2999, 199, 33, 3510, 13, 604, 5164, 1443, 506, 1627, 701, 9176, 1924, 1004, 465, 282, 202, 199, 24904, 1423, 27, 19197, 2385, 787, 3962, 701, 25188, 376, 202, 199, 2094, 315, 9344, 436, 1808, 9186, 7883, 14, 221, 14326, 446, 83, 1511, 787, 202, 199, 84, 9640, 8545, 590, 14, 2999, 199, 3917, 446, 78, 365, 440, 1627, 12, 282, 11233, 1329, 402, 17222, 365, 12950, 701, 9936, 202, 199, 28251, 823, 3398, 13131, 1192, 402, 1616, 5133, 314, 3141, 900, 365, 737, 5210, 378, 14, 18, 4696, 14, 2999, 199, 1918, 8865, 315, 849, 9715, 805, 365, 2952, 641, 5417, 12, 202, 199, 9597, 342, 965, 25824, 9202, 22504, 1325, 900, 11716, 83, 9202, 22504, 365, 413, 15, 2259, 273, 202, 199, 1618, 282, 3499, 27, 641, 13074, 12, 12516, 342, 965, 413, 15, 1960, 273, 402, 282, 3499, 9202, 22504, 436, 202, 199, 521, 342, 365, 8298, 1655, 28334, 14, 221, 4068, 1902, 4298, 12, 314, 849, 9715, 202, 199, 5777, 9775, 19882, 12516, 900, 12, 440, 314, 11952, 900, 14, 221, 961, 4910, 626, 202, 199, 1848, 10358, 3879, 641, 314, 2011, 24189, 1443, 1640, 771, 264, 543, 314, 202, 199, 14639, 14, 221, 710, 5526, 8377, 370, 886, 1380, 23189, 20542, 365, 5784, 365, 370, 202, 199, 8755, 314, 20542, 282, 9284, 5431, 436, 675, 314, 5526, 900, 14, 221, 710, 446, 82, 945, 365, 202, 199, 8302, 367, 642, 27, 314, 849, 402, 650, 6375, 7752, 365, 8646, 8321, 315, 4750, 202, 199, 9403, 14, 221, 4068, 13074, 12, 1265, 883, 675, 12516, 342, 370, 9775, 11952, 900, 14, 2999, 199, 7443, 26, 2337, 365, 282, 9842, 18828, 24075, 4568, 543, 14043, 282, 202, 199, 1529, 5164, 14, 221, 710, 1233, 2348, 3181, 1133, 862, 370, 13714, 652, 12, 1325, 1265, 1077, 202, 199, 1235, 20381, 402, 652, 14, 221, 710, 18828, 24075, 883, 506, 27396, 701, 26750, 314, 202, 199, 6815, 1928, 2368, 14, 2999, 199, 1918, 18828, 24075, 22754, 3382, 2018, 5459, 1, 221, 6121, 12, 370, 202, 199, 667, 723, 590, 6540, 12731, 2018, 5459, 370, 2018, 499, 14, 19, 12, 1265, 1443, 2934, 370, 202, 199, 1180, 2366, 446, 47, 367, 314, 12731, 5459, 370, 5126, 20542, 11543, 63, 6143, 15577, 202, 199, 20718, 14, 202, 199, 624, 2999, 199, 646, 9486, 202, 199, 646, 984, 202, 199, 646, 900, 202, 199, 893, 26, 1128, 492, 7975, 202, 199, 2590, 3545, 26, 1128, 327, 9498, 506, 376, 12731, 2018, 1015, 334, 3239, 900, 390, 342, 5084, 9, 1128, 7975, 275, 488, 2999, 199, 363, 452, 363, 275, 2097, 7929, 937, 2999, 199, 5869, 63, 2164, 63, 354, 275, 3886, 521, 390, 13, 2164, 4335, 202, 199, 885, 63, 1955, 275, 19492, 202, 199, 885, 63, 8755, 275, 650, 2999, 199, 692, 984, 14, 3246, 508, 298, 2676, 708, 582, 1128, 327, 4068, 5417, 12, 314, 5526, 9715, 365, 900, 14, 9597, 342, 1128, 849, 63, 7414, 275, 900, 14, 9597, 202, 199, 2836, 26, 1128, 327, 4068, 4750, 1163, 10677, 314, 5526, 9715, 365, 900, 14, 521, 342, 1128, 849, 63, 7414, 275, 900, 14, 521, 2999, 199, 3, 7529, 1133, 1570, 314, 14311, 402, 314, 1978, 27, 314, 295, 3724, 342, 4882, 202, 199, 3, 315, 22287, 855, 826, 4533, 11687, 641, 3272, 3769, 19197, 841, 7883, 436, 12284, 202, 199, 3, 3769, 19197, 1695, 7883, 14, 202, 199, 1160, 275, 408, 202, 199, 318, 6506, 1547, 390, 12, 485, 7414, 304, 1128, 2818, 2758, 9, 83, 1128, 485, 84, 16, 275, 485, 7414, 342, 1128, 367, 485, 73, 315, 485, 390, 26, 1039, 2818, 9649, 9, 83, 1128, 485, 84, 17, 275, 485, 7414, 342, 1128, 372, 485, 84, 17, 446, 485, 84, 16, 202, 199, 624, 2999, 199, 318, 295, 3724, 8, 2164, 12, 4363, 304, 1128, 408, 4433, 370, 295, 3724, 282, 3510, 13, 604, 5164, 1041, 1128, 372, 2928, 14, 1814, 4582, 78, 401, 1867, 78, 2, 435, 298, 8969, 3724, 9, 2999, 199, 318, 485, 1160, 63, 1532, 8, 2758, 12, 2562, 304, 1128, 408, 2499, 282, 9715, 805, 14, 8051, 340, 314, 298, 6242, 2, 365, 282, 4550, 1041, 1128, 347, 6506, 1547, 390, 12, 485, 7414, 12, 485, 1532, 29, 1532, 304, 1039, 3272, 342, 1039, 485, 84, 16, 275, 485, 7414, 342, 1039, 367, 485, 73, 315, 485, 390, 26, 1675, 485, 1532, 342, 1039, 485, 84, 17, 275, 485, 7414, 342, 1039, 372, 485, 84, 17, 446, 485, 84, 16, 1128, 372, 6506, 2999, 199, 533, 22287, 26, 1128, 408, 2543, 367, 20542, 6451, 8112, 402, 7425, 1233, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
netroby/vitess
py/vtdb/db_object_range_sharded.py
6
21233
"""Module containing base classes for range-sharded database objects. There are two base classes for tables that live in range-sharded keyspace - 1. DBObjectRangeSharded - This should be used for tables that only reference lookup entities but don't create or manage them. Please see examples in test/clientlib_tests/db_class_sharded.py. 2. DBObjectEntityRangeSharded - This inherits from DBObjectRangeSharded and is used for tables and also create new lookup relationships. This module also contains helper methods for cursor creation for accessing lookup tables and methods for dml and select for the above mentioned base classes. """ import functools import struct from vtdb import db_object from vtdb import dbexceptions from vtdb import keyrange from vtdb import keyrange_constants from vtdb import shard_constants from vtdb import sql_builder from vtdb import vtgate_cursor # This creates a 64 binary packed string for keyspace_id. # This is used for cursor creation so that keyspace_id can # be passed as rpc param for vtgate. pack_keyspace_id = struct.Struct('!Q').pack # This unpacks the keyspace_id so that it can be used # in bind variables. def unpack_keyspace_id(kid): return struct.Struct('!Q').unpack(kid)[0] class DBObjectRangeSharded(db_object.DBObjectBase): """Base class for range-sharded db classes. This provides default implementation of routing helper methods, cursor creation and common database access operations. """ # keyspace of this table. This is needed for routing. keyspace = None # sharding scheme for this base class. sharding = shard_constants.RANGE_SHARDED # table name for the corresponding database table. This is used in query # construction. table_name = None # List of columns on the database table. This is used in query construction. columns_list = None #FIXME: is this needed ? id_column_name = None # sharding_key_column_name defines column name for sharding key for this # table. sharding_key_column_name = None # entity_id_lookup_map defines entity lookup relationship. It is a map of # column names for this table to lookup class that contains the mapping of # this entity to sharding key for this keyspace. entity_id_lookup_map = None # column_lookup_name_map defines the map of column names from this table # to the corresponding lookup table. This should be used when column_names # in the main table and lookup table is different. This is used in # conjunction with sharding_key_column_name and entity_id_lookup_map. column_lookup_name_map = None @classmethod def create_shard_routing(class_, *pargs, **kargs): """This creates the ShardRouting object based on the kargs. This prunes the routing kargs so as not to interfere with the actual database method. Args: *pargs: Positional arguments **kargs: Routing key-value params. These are used to determine routing. There are two mutually exclusive mechanisms to indicate routing. 1. entity_id_map {"entity_id_column": entity_id_value} where entity_id_column could be the sharding key or a lookup based entity column of this table. This helps determine the keyspace_ids for the cursor. 2. keyrange - This helps determine the keyrange for the cursor. Returns: ShardRouting object and modified kargs """ lookup_cursor_method = pargs[0] routing = db_object.ShardRouting(class_.keyspace) entity_id_map = None entity_id_map = kargs.get("entity_id_map", None) if entity_id_map is None: kr = None key_range = kargs.get("keyrange", None) if isinstance(key_range, keyrange.KeyRange): kr = key_range else: kr = keyrange.KeyRange(key_range) if kr is not None: routing.keyrange = kr # Both entity_id_map and keyrange have been evaluated. Return. return routing # entity_id_map is not None if len(entity_id_map) != 1: dbexceptions.ProgrammingError("Invalid entity_id_map '%s'" % entity_id_map) entity_id_col = entity_id_map.keys()[0] entity_id = entity_id_map[entity_id_col] #TODO: the current api means that if a table doesn't have the sharding key column name # then it cannot pass in sharding key for routing purposes. Will this cause # extra load on lookup db/cache ? This is cleaner from a design perspective. if entity_id_col == class_.sharding_key_column_name: # Routing using sharding key. routing.sharding_key = entity_id if not class_.is_sharding_key_valid(routing.sharding_key): raise dbexceptions.InternalError("Invalid sharding_key %s" % routing.sharding_key) else: # Routing using lookup based entity. routing.entity_column_name = entity_id_col routing.entity_id_sharding_key_map = class_.lookup_sharding_key_from_entity_id( lookup_cursor_method, entity_id_col, entity_id) return routing @classmethod def create_vtgate_cursor(class_, vtgate_conn, tablet_type, is_dml, **cursor_kargs): cursor_method = functools.partial(db_object.create_cursor_from_params, vtgate_conn, tablet_type, False) routing = class_.create_shard_routing(cursor_method, **cursor_kargs) if is_dml: if routing.sharding_key is None or db_object._is_iterable_container(routing.sharding_key): dbexceptions.InternalError( "Writes require unique sharding_key") keyspace_ids = None keyranges = None if routing.sharding_key is not None: keyspace_ids = [] if db_object._is_iterable_container(routing.sharding_key): for sk in routing.sharding_key: kid = class_.sharding_key_to_keyspace_id(sk) keyspace_ids.append(pack_keyspace_id(kid)) else: kid = class_.sharding_key_to_keyspace_id(routing.sharding_key) keyspace_ids = [pack_keyspace_id(kid),] elif routing.entity_id_sharding_key_map is not None: keyspace_ids = [] for sharding_key in routing.entity_id_sharding_key_map.values(): keyspace_ids.append(pack_keyspace_id(class_.sharding_key_to_keyspace_id(sharding_key))) elif routing.keyrange: keyranges = [routing.keyrange,] cursor = vtgate_cursor.VTGateCursor(vtgate_conn, class_.keyspace, tablet_type, keyspace_ids=keyspace_ids, keyranges=keyranges, writable=is_dml) cursor.routing = routing return cursor @classmethod def get_lookup_column_name(class_, column_name): """Return the lookup column name for a column name from this table. If the entry doesn't exist it is assumed that the column_name is same. """ if class_.column_lookup_name_map is None: return column_name return class_.column_lookup_name_map.get(column_name, column_name) @classmethod def lookup_sharding_key_from_entity_id(class_, cursor_method, entity_id_column, entity_id): """This method is used to map any entity id to sharding key. Args: entity_id_column: Non-sharding key indexes that can be used for query routing. entity_id: entity id value. Returns: sharding key to be used for routing. """ entity_lookup_column = class_.get_lookup_column_name(entity_id_column) lookup_class = class_.entity_id_lookup_map[entity_id_column] rows = lookup_class.get(cursor_method, entity_lookup_column, entity_id) entity_id_sharding_key_map = {} if len(rows) == 0: #return entity_id_sharding_key_map raise dbexceptions.DatabaseError("LookupRow not found") if class_.sharding_key_column_name is not None: sk_lookup_column = class_.get_lookup_column_name(class_.sharding_key_column_name) else: # This is needed since the table may not have a sharding key column name # but the lookup map will have it. lookup_column_names = rows[0].keys() if len(lookup_column_names) != 2: raise dbexceptions.ProgrammingError( "lookup table has more than two columns.") sk_lookup_column = list(set(lookup_column_names) - set(list(entity_lookup_column)))[0] for row in rows: en_id = row[entity_lookup_column] sk = row[sk_lookup_column] entity_id_sharding_key_map[en_id] = sk return entity_id_sharding_key_map @db_object.db_class_method def select_by_ids(class_, cursor, where_column_value_pairs, columns_list=None, order_by=None, group_by=None, limit=None, **kwargs): """This method is used to perform in-clause queries. Such queries can cause vtgate to scatter over multiple shards. This uses execute_entity_ids method of vtgate cursor and the entity column and the associated entity_keyspace_id_map is computed based on the routing used - sharding_key or entity_id_map. """ if columns_list is None: columns_list = class_.columns_list query, bind_vars = class_.create_select_query(where_column_value_pairs, columns_list=columns_list, order_by=order_by, group_by=group_by, limit=limit, **kwargs) entity_col_name = None entity_id_keyspace_id_map = {} if cursor.routing.sharding_key is not None: # If the in-clause is based on sharding key entity_col_name = class_.sharding_key_column_name if db_object._is_iterable_container(cursor.routing.sharding_key): for sk in list(cursor.routing.sharding_key): entity_id_keyspace_id_map[sk] = pack_keyspace_id(class_.sharding_key_to_keyspace_id(sk)) else: sk = cursor.routing.sharding_key entity_id_keyspace_id_map[sk] = pack_keyspace_id(class_.sharding_key_to_keyspace_id(sk)) elif cursor.routing.entity_id_sharding_key_map is not None: # If the in-clause is based on entity column entity_col_name = cursor.routing.entity_column_name for en_id, sk in cursor.routing.entity_id_sharding_key_map.iteritems(): entity_id_keyspace_id_map[en_id] = pack_keyspace_id(class_.sharding_key_to_keyspace_id(sk)) else: dbexceptions.ProgrammingError("Invalid routing method used.") # cursor.routing.entity_column_name is set while creating shard routing. rowcount = cursor.execute_entity_ids(query, bind_vars, entity_id_keyspace_id_map, entity_col_name) rows = cursor.fetchall() return [sql_builder.DBRow(columns_list, row) for row in rows] @classmethod def is_sharding_key_valid(class_, sharding_key): """Method to check the validity of sharding key for the table. Args: sharding_key: sharding_key to be validated. Returns: bool """ raise NotImplementedError @classmethod def sharding_key_to_keyspace_id(class_, sharding_key): """Method to create keyspace_id from sharding_key. Args: sharding_key: sharding_key Returns: keyspace_id """ raise NotImplementedError @db_object.db_class_method def insert(class_, cursor, **bind_vars): if class_.columns_list is None: raise dbexceptions.ProgrammingError("DB class should define columns_list") keyspace_id = bind_vars.get('keyspace_id', None) if keyspace_id is None: kid = cursor.keyspace_ids[0] keyspace_id = unpack_keyspace_id(kid) bind_vars['keyspace_id'] = keyspace_id query, bind_vars = class_.create_insert_query(**bind_vars) cursor.execute(query, bind_vars) return cursor.lastrowid @classmethod def _add_keyspace_id(class_, keyspace_id, where_column_value_pairs): where_col_dict = dict(where_column_value_pairs) if 'keyspace_id' not in where_col_dict: where_column_value_pairs.append(('keyspace_id', keyspace_id)) return where_column_value_pairs @db_object.write_db_class_method def update_columns(class_, cursor, where_column_value_pairs, update_column_value_pairs): where_column_value_pairs = class_._add_keyspace_id( unpack_keyspace_id(cursor.keyspace_ids[0]), where_column_value_pairs) query, bind_vars = class_.create_update_query(where_column_value_pairs, update_column_value_pairs) rowcount = cursor.execute(query, bind_vars) # If the entity_id column is being updated, update lookup map. if class_.entity_id_lookup_map is not None: for entity_col in class_.entity_id_lookup_map.keys(): if entity_col in update_column_value_pairs: class_.update_sharding_key_entity_id_lookup( cursor, sharding_key, entity_col, update_column_value_pairs[entity_col]) return rowcount @db_object.write_db_class_method def delete_by_columns(class_, cursor, where_column_value_pairs, limit=None): if not where_column_value_pairs: raise dbexceptions.ProgrammingError("deleting the whole table is not allowed") where_column_value_pairs = class_._add_keyspace_id( unpack_keyspace_id(cursor.keyspace_ids[0]), where_column_value_pairs) query, bind_vars = sql_builder.delete_by_columns_query(class_.table_name, where_column_value_pairs, limit=limit) cursor.execute(query, bind_vars) if cursor.rowcount == 0: raise dbexceptions.DatabaseError("DB Row not found") return cursor.rowcount class DBObjectEntityRangeSharded(DBObjectRangeSharded): """Base class for sharded tables that also needs to create and manage lookup entities. This provides default implementation of routing helper methods, cursor creation and common database access operations. """ @classmethod def get_insert_id_from_lookup(class_, cursor_method, entity_id_col, **bind_vars): """This method is used to map any entity id to sharding key. Args: entity_id_column: Non-sharding key indexes that can be used for query routing. entity_id: entity id value. Returns: sharding key to be used for routing. """ lookup_class = class_.entity_id_lookup_map[entity_id_col] new_bind_vars = {} for col, value in bind_vars.iteritems(): lookup_col = class_.get_lookup_column_name(col) new_bind_vars[lookup_col] = value class_._validate_column_value_pairs_for_write(**new_bind_vars) return lookup_class.create(cursor_method, **new_bind_vars) @classmethod def delete_sharding_key_entity_id_lookup(class_, cursor_method, sharding_key): sharding_key_lookup_column = class_.get_lookup_column_name(class_.sharding_key_column_name) for lookup_class in class_.entity_id_lookup_map.values(): lookup_class.delete(cursor_method, sharding_key_lookup_column, sharding_key) @classmethod def update_sharding_key_entity_id_lookup(class_, cursor_method, sharding_key, entity_id_column, new_entity_id): sharding_key_lookup_column = class_.get_lookup_column_name(class_.sharding_key_column_name) entity_id_lookup_column = class_.get_lookup_column_name(entity_id_column) lookup_class = class_.entity_id_lookup_map[entity_id_column] return lookup_class.update(cursor_method, sharding_key_lookup_column, sharding_key, entity_id_lookup_column, new_entity_id) @db_object.write_db_class_method def insert_primary(class_, cursor, **bind_vars): if class_.columns_list is None: raise dbexceptions.ProgrammingError("DB class should define columns_list") query, bind_vars = class_.create_insert_query(**bind_vars) cursor.execute(query, bind_vars) return cursor.lastrowid @classmethod def insert(class_, cursor_method, **bind_vars): """ This method creates the lookup relationship as well as the insert in the primary table. The creation of the lookup entry also creates the primary key for the row in the primary table. The lookup relationship is determined by class_.column_lookup_name_map and the bind variables passed in. There are two types of entities - 1. Table for which the entity that is also the primary sharding key for this keyspace. 2. Entity table that creates a new entity and needs to create a lookup between that entity and sharding key. """ if class_.sharding_key_column_name is None: raise dbexceptions.ProgrammingError( "sharding_key_column_name empty for DBObjectEntityRangeSharded") # Used for insert into class_.table_name new_inserted_key = None # Used for routing the insert_primary entity_id_map = {} if (not class_.entity_id_lookup_map or not isinstance(class_.entity_id_lookup_map, dict)): raise dbexceptions.ProgrammingError( "Invalid entity_id_lookup_map %s" % class_.entity_id_lookup_map) entity_col = class_.entity_id_lookup_map.keys()[0] # Create the lookup entry first if class_.sharding_key_column_name in bind_vars: # Secondary entity creation sharding_key = bind_vars[class_.sharding_key_column_name] lookup_bind_vars = {class_.sharding_key_column_name: sharding_key} entity_id = class_.get_insert_id_from_lookup(cursor_method, entity_col, **lookup_bind_vars) bind_vars[entity_col] = entity_id new_inserted_key = entity_id entity_id_map[entity_col] = entity_id else: # Primary sharding key creation # FIXME: what if class_.entity_id_lookup_map was empty ? # there would need to be some table on which there was an auto-inc # to generate the primary sharding key. entity_id = bind_vars[entity_col] lookup_bind_vars = {entity_col: entity_id} sharding_key = class_.get_insert_id_from_lookup(cursor_method, entity_col, **lookup_bind_vars) bind_vars[class_.sharding_key_column_name] = sharding_key new_inserted_key = sharding_key entity_id_map[class_.sharding_key_column_name] = sharding_key # FIXME: is the not value check correct ? if 'keyspace_id' not in bind_vars or not bind_vars['keyspace_id']: keyspace_id = class_.sharding_key_to_keyspace_id(sharding_key) bind_vars['keyspace_id'] = keyspace_id # entity_id_map is used for routing and hence passed to cursor_method new_cursor = functools.partial(cursor_method, entity_id_map=entity_id_map) class_.insert_primary(new_cursor, **bind_vars) return new_inserted_key @db_object.write_db_class_method def update_columns(class_, cursor, where_column_value_pairs, update_column_value_pairs): sharding_key = cursor.routing.sharding_key if sharding_key is None: raise dbexceptions.ProgrammingError("sharding_key cannot be empty") # update the primary table first. query, bind_vars = class_.create_update_query( where_column_value_pairs, update_column_value_pairs) rowcount = cursor.execute(query, bind_vars) # If the entity_id column is being updated, update lookup map. lookup_cursor_method = functools.partial( db_object.create_cursor_from_old_cursor, cursor) update_column_value_pairs = dict(update_column_value_pairs) for entity_col in class_.entity_id_lookup_map.keys(): if entity_col in update_column_value_pairs: class_.update_sharding_key_entity_id_lookup( lookup_cursor_method, sharding_key, entity_col, update_column_value_pairs[entity_col]) return rowcount @db_object.write_db_class_method def delete_by_columns(class_, cursor, where_column_value_pairs, limit=None): sharding_key = cursor.routing.sharding_key if sharding_key is None: raise dbexceptions.ProgrammingError("sharding_key cannot be empty") if not where_column_value_pairs: raise dbexceptions.ProgrammingError("deleting the whole table is not allowed") query, bind_vars = sql_builder.delete_by_columns_query(class_.table_name, where_column_value_pairs, limit=limit) cursor.execute(query, bind_vars) if cursor.rowcount == 0: raise dbexceptions.DatabaseError("DB Row not found") rowcount = cursor.rowcount #delete the lookup map. lookup_cursor_method = functools.partial( db_object.create_cursor_from_old_cursor, cursor) class_.delete_sharding_key_entity_id_lookup(lookup_cursor_method, sharding_key) return rowcount
bsd-3-clause
[ 624, 2377, 3035, 1300, 3992, 367, 1425, 13, 609, 12910, 3050, 2251, 14, 199, 199, 10924, 787, 2877, 1300, 3992, 367, 6716, 626, 12166, 315, 1425, 13, 609, 12910, 27710, 446, 199, 17, 14, 6249, 1692, 4709, 2662, 12910, 446, 221, 961, 1077, 506, 1202, 367, 6716, 626, 1454, 3659, 4237, 9045, 199, 7911, 2793, 1133, 1218, 503, 9635, 3062, 14, 7754, 1937, 7251, 315, 511, 15, 1258, 773, 63, 2219, 15, 697, 63, 533, 63, 609, 12910, 14, 647, 14, 199, 18, 14, 6249, 1692, 7302, 4709, 2662, 12910, 446, 961, 21592, 687, 6249, 1692, 4709, 2662, 12910, 436, 365, 1202, 367, 6716, 199, 460, 2597, 1218, 892, 4237, 20045, 14, 199, 2765, 859, 2597, 3509, 5922, 3102, 367, 3920, 7143, 367, 18549, 4237, 6716, 199, 460, 3102, 367, 366, 757, 436, 3504, 367, 314, 3432, 26239, 1300, 3992, 14, 199, 624, 199, 646, 9143, 199, 646, 2702, 199, 199, 504, 18585, 697, 492, 1592, 63, 785, 199, 504, 18585, 697, 492, 1592, 3924, 199, 504, 18585, 697, 492, 790, 1842, 199, 504, 18585, 697, 492, 790, 1842, 63, 5559, 199, 504, 18585, 697, 492, 11814, 63, 5559, 199, 504, 18585, 697, 492, 3875, 63, 5649, 199, 504, 18585, 697, 492, 18585, 3237, 63, 3937, 421, 199, 3, 961, 8491, 282, 5049, 3366, 13170, 1059, 367, 27710, 63, 344, 14, 199, 3, 961, 365, 1202, 367, 3920, 7143, 880, 626, 27710, 63, 344, 883, 199, 3, 506, 3032, 465, 8985, 1215, 367, 18585, 3237, 14, 199, 1389, 63, 16365, 63, 344, 275, 2702, 14, 4836, 16157, 49, 1959, 1389, 421, 199, 3, 961, 7787, 83, 314, 27710, 63, 344, 880, 626, 652, 883, 506, 1202, 199, 3, 315, 5398, 2860, 14, 199, 318, 7787, 63, 16365, 63, 344, 8, 75, 344, 304, 199, 372, 2702, 14, 4836, 16157, 49, 1959, 5301, 8, 75, 344, 2788, 16, 61, 421, 199, 533, 6249, 1692, 4709, 2662, 12910, 8, 697, 63, 785, 14, 2846, 8141, 304, 523, 408, 1563, 1021, 367, 1425, 13, 609, 12910, 1592, 3992, 14, 819, 961, 6571, 849, 4514, 402, 14870, 5922, 3102, 12, 3920, 523, 7143, 436, 2863, 3050, 2879, 5331, 14, 523, 408, 523, 327, 27710, 402, 642, 1817, 14, 961, 365, 4346, 367, 14870, 14, 523, 27710, 275, 488, 819, 327, 11814, 316, 5687, 367, 642, 1300, 1021, 14, 523, 11814, 316, 275, 11814, 63, 5559, 14, 15167, 63, 11152, 8280, 819, 327, 1817, 536, 367, 314, 5226, 3050, 1817, 14, 961, 365, 1202, 315, 1827, 523, 327, 14538, 14, 523, 1817, 63, 354, 275, 488, 819, 327, 3820, 402, 4362, 641, 314, 3050, 1817, 14, 961, 365, 1202, 315, 1827, 14538, 14, 523, 4362, 63, 513, 275, 488, 819, 327, 31779, 26, 365, 642, 4346, 5805, 523, 1305, 63, 2301, 63, 354, 275, 488, 819, 327, 11814, 316, 63, 498, 63, 2301, 63, 354, 7890, 2763, 536, 367, 11814, 316, 790, 367, 642, 523, 327, 1817, 14, 523, 11814, 316, 63, 498, 63, 2301, 63, 354, 275, 488, 819, 327, 4642, 63, 344, 63, 3892, 63, 1130, 7890, 4642, 4237, 8931, 14, 2779, 365, 282, 2341, 402, 523, 327, 2763, 1561, 367, 642, 1817, 370, 4237, 1021, 626, 3509, 314, 4412, 402, 523, 327, 642, 4642, 370, 11814, 316, 790, 367, 642, 27710, 14, 523, 4642, 63, 344, 63, 3892, 63, 1130, 275, 488, 819, 327, 2763, 63, 3892, 63, 354, 63, 1130, 7890, 314, 2341, 402, 2763, 1561, 687, 642, 1817, 523, 327, 370, 314, 5226, 4237, 1817, 14, 961, 1077, 506, 1202, 1380, 2763, 63, 1247, 523, 327, 315, 314, 2446, 1817, 436, 4237, 1817, 365, 3365, 14, 961, 365, 1202, 315, 523, 327, 22888, 543, 11814, 316, 63, 498, 63, 2301, 63, 354, 436, 4642, 63, 344, 63, 3892, 63, 1130, 14, 523, 2763, 63, 3892, 63, 354, 63, 1130, 275, 488, 819, 768, 3744, 523, 347, 1218, 63, 10810, 63, 9492, 8, 533, 3131, 627, 462, 458, 12, 221, 1011, 24459, 304, 272, 408, 2765, 8491, 314, 5244, 1005, 8056, 909, 4079, 641, 314, 1022, 589, 14, 272, 961, 29501, 397, 314, 14870, 1022, 589, 880, 465, 440, 370, 1640, 771, 264, 543, 314, 272, 3503, 3050, 1083, 14, 339, 3033, 26, 489, 627, 462, 458, 26, 15483, 279, 2368, 489, 1011, 24459, 26, 30790, 316, 790, 13, 585, 1862, 14, 5723, 787, 1202, 370, 6705, 14870, 14, 489, 6006, 787, 2877, 16108, 13914, 562, 10832, 706, 370, 6623, 14870, 14, 489, 413, 14, 4642, 63, 344, 63, 1130, 2420, 4502, 63, 344, 63, 2301, 582, 4642, 63, 344, 63, 585, 93, 2382, 4642, 63, 344, 63, 2301, 489, 4293, 506, 314, 11814, 316, 790, 503, 282, 4237, 4079, 4642, 2763, 402, 642, 1817, 14, 961, 489, 22577, 6705, 314, 27710, 63, 1580, 367, 314, 3920, 14, 489, 499, 14, 790, 1842, 446, 961, 22577, 6705, 314, 790, 1842, 367, 314, 3920, 14, 339, 1803, 26, 1362, 5244, 1005, 8056, 909, 436, 6042, 1022, 589, 272, 408, 272, 4237, 63, 3937, 63, 765, 275, 299, 589, 59, 16, 61, 272, 14870, 275, 1592, 63, 785, 14, 20019, 8056, 8, 533, 3754, 16365, 9, 272, 4642, 63, 344, 63, 1130, 275, 488, 339, 4642, 63, 344, 63, 1130, 275, 1022, 589, 14, 362, 480, 4502, 63, 344, 63, 1130, 401, 488, 9, 272, 340, 4642, 63, 344, 63, 1130, 365, 488, 26, 489, 1022, 82, 275, 488, 489, 790, 63, 1842, 275, 1022, 589, 14, 362, 480, 498, 1842, 401, 488, 9, 489, 340, 1228, 8, 498, 63, 1842, 12, 790, 1842, 14, 1197, 4709, 304, 267, 1022, 82, 275, 790, 63, 1842, 489, 587, 26, 267, 1022, 82, 275, 790, 1842, 14, 1197, 4709, 8, 498, 63, 1842, 9, 489, 340, 1022, 82, 365, 440, 488, 26, 267, 14870, 14, 498, 1842, 275, 1022, 82, 489, 327, 17650, 4642, 63, 344, 63, 1130, 436, 790, 1842, 1172, 2757, 13006, 14, 1432, 14, 489, 372, 14870, 339, 327, 4642, 63, 344, 63, 1130, 365, 440, 488, 272, 340, 822, 8, 4502, 63, 344, 63, 1130, 9, 1137, 413, 26, 489, 1592, 3924, 14, 11411, 547, 480, 3364, 4642, 63, 344, 63, 1130, 1543, 83, 4065, 450, 4642, 63, 344, 63, 1130, 9, 339, 4642, 63 ]
[ 2377, 3035, 1300, 3992, 367, 1425, 13, 609, 12910, 3050, 2251, 14, 199, 199, 10924, 787, 2877, 1300, 3992, 367, 6716, 626, 12166, 315, 1425, 13, 609, 12910, 27710, 446, 199, 17, 14, 6249, 1692, 4709, 2662, 12910, 446, 221, 961, 1077, 506, 1202, 367, 6716, 626, 1454, 3659, 4237, 9045, 199, 7911, 2793, 1133, 1218, 503, 9635, 3062, 14, 7754, 1937, 7251, 315, 511, 15, 1258, 773, 63, 2219, 15, 697, 63, 533, 63, 609, 12910, 14, 647, 14, 199, 18, 14, 6249, 1692, 7302, 4709, 2662, 12910, 446, 961, 21592, 687, 6249, 1692, 4709, 2662, 12910, 436, 365, 1202, 367, 6716, 199, 460, 2597, 1218, 892, 4237, 20045, 14, 199, 2765, 859, 2597, 3509, 5922, 3102, 367, 3920, 7143, 367, 18549, 4237, 6716, 199, 460, 3102, 367, 366, 757, 436, 3504, 367, 314, 3432, 26239, 1300, 3992, 14, 199, 624, 199, 646, 9143, 199, 646, 2702, 199, 199, 504, 18585, 697, 492, 1592, 63, 785, 199, 504, 18585, 697, 492, 1592, 3924, 199, 504, 18585, 697, 492, 790, 1842, 199, 504, 18585, 697, 492, 790, 1842, 63, 5559, 199, 504, 18585, 697, 492, 11814, 63, 5559, 199, 504, 18585, 697, 492, 3875, 63, 5649, 199, 504, 18585, 697, 492, 18585, 3237, 63, 3937, 421, 199, 3, 961, 8491, 282, 5049, 3366, 13170, 1059, 367, 27710, 63, 344, 14, 199, 3, 961, 365, 1202, 367, 3920, 7143, 880, 626, 27710, 63, 344, 883, 199, 3, 506, 3032, 465, 8985, 1215, 367, 18585, 3237, 14, 199, 1389, 63, 16365, 63, 344, 275, 2702, 14, 4836, 16157, 49, 1959, 1389, 421, 199, 3, 961, 7787, 83, 314, 27710, 63, 344, 880, 626, 652, 883, 506, 1202, 199, 3, 315, 5398, 2860, 14, 199, 318, 7787, 63, 16365, 63, 344, 8, 75, 344, 304, 199, 372, 2702, 14, 4836, 16157, 49, 1959, 5301, 8, 75, 344, 2788, 16, 61, 421, 199, 533, 6249, 1692, 4709, 2662, 12910, 8, 697, 63, 785, 14, 2846, 8141, 304, 523, 408, 1563, 1021, 367, 1425, 13, 609, 12910, 1592, 3992, 14, 819, 961, 6571, 849, 4514, 402, 14870, 5922, 3102, 12, 3920, 523, 7143, 436, 2863, 3050, 2879, 5331, 14, 523, 408, 523, 327, 27710, 402, 642, 1817, 14, 961, 365, 4346, 367, 14870, 14, 523, 27710, 275, 488, 819, 327, 11814, 316, 5687, 367, 642, 1300, 1021, 14, 523, 11814, 316, 275, 11814, 63, 5559, 14, 15167, 63, 11152, 8280, 819, 327, 1817, 536, 367, 314, 5226, 3050, 1817, 14, 961, 365, 1202, 315, 1827, 523, 327, 14538, 14, 523, 1817, 63, 354, 275, 488, 819, 327, 3820, 402, 4362, 641, 314, 3050, 1817, 14, 961, 365, 1202, 315, 1827, 14538, 14, 523, 4362, 63, 513, 275, 488, 819, 327, 31779, 26, 365, 642, 4346, 5805, 523, 1305, 63, 2301, 63, 354, 275, 488, 819, 327, 11814, 316, 63, 498, 63, 2301, 63, 354, 7890, 2763, 536, 367, 11814, 316, 790, 367, 642, 523, 327, 1817, 14, 523, 11814, 316, 63, 498, 63, 2301, 63, 354, 275, 488, 819, 327, 4642, 63, 344, 63, 3892, 63, 1130, 7890, 4642, 4237, 8931, 14, 2779, 365, 282, 2341, 402, 523, 327, 2763, 1561, 367, 642, 1817, 370, 4237, 1021, 626, 3509, 314, 4412, 402, 523, 327, 642, 4642, 370, 11814, 316, 790, 367, 642, 27710, 14, 523, 4642, 63, 344, 63, 3892, 63, 1130, 275, 488, 819, 327, 2763, 63, 3892, 63, 354, 63, 1130, 7890, 314, 2341, 402, 2763, 1561, 687, 642, 1817, 523, 327, 370, 314, 5226, 4237, 1817, 14, 961, 1077, 506, 1202, 1380, 2763, 63, 1247, 523, 327, 315, 314, 2446, 1817, 436, 4237, 1817, 365, 3365, 14, 961, 365, 1202, 315, 523, 327, 22888, 543, 11814, 316, 63, 498, 63, 2301, 63, 354, 436, 4642, 63, 344, 63, 3892, 63, 1130, 14, 523, 2763, 63, 3892, 63, 354, 63, 1130, 275, 488, 819, 768, 3744, 523, 347, 1218, 63, 10810, 63, 9492, 8, 533, 3131, 627, 462, 458, 12, 221, 1011, 24459, 304, 272, 408, 2765, 8491, 314, 5244, 1005, 8056, 909, 4079, 641, 314, 1022, 589, 14, 272, 961, 29501, 397, 314, 14870, 1022, 589, 880, 465, 440, 370, 1640, 771, 264, 543, 314, 272, 3503, 3050, 1083, 14, 339, 3033, 26, 489, 627, 462, 458, 26, 15483, 279, 2368, 489, 1011, 24459, 26, 30790, 316, 790, 13, 585, 1862, 14, 5723, 787, 1202, 370, 6705, 14870, 14, 489, 6006, 787, 2877, 16108, 13914, 562, 10832, 706, 370, 6623, 14870, 14, 489, 413, 14, 4642, 63, 344, 63, 1130, 2420, 4502, 63, 344, 63, 2301, 582, 4642, 63, 344, 63, 585, 93, 2382, 4642, 63, 344, 63, 2301, 489, 4293, 506, 314, 11814, 316, 790, 503, 282, 4237, 4079, 4642, 2763, 402, 642, 1817, 14, 961, 489, 22577, 6705, 314, 27710, 63, 1580, 367, 314, 3920, 14, 489, 499, 14, 790, 1842, 446, 961, 22577, 6705, 314, 790, 1842, 367, 314, 3920, 14, 339, 1803, 26, 1362, 5244, 1005, 8056, 909, 436, 6042, 1022, 589, 272, 408, 272, 4237, 63, 3937, 63, 765, 275, 299, 589, 59, 16, 61, 272, 14870, 275, 1592, 63, 785, 14, 20019, 8056, 8, 533, 3754, 16365, 9, 272, 4642, 63, 344, 63, 1130, 275, 488, 339, 4642, 63, 344, 63, 1130, 275, 1022, 589, 14, 362, 480, 4502, 63, 344, 63, 1130, 401, 488, 9, 272, 340, 4642, 63, 344, 63, 1130, 365, 488, 26, 489, 1022, 82, 275, 488, 489, 790, 63, 1842, 275, 1022, 589, 14, 362, 480, 498, 1842, 401, 488, 9, 489, 340, 1228, 8, 498, 63, 1842, 12, 790, 1842, 14, 1197, 4709, 304, 267, 1022, 82, 275, 790, 63, 1842, 489, 587, 26, 267, 1022, 82, 275, 790, 1842, 14, 1197, 4709, 8, 498, 63, 1842, 9, 489, 340, 1022, 82, 365, 440, 488, 26, 267, 14870, 14, 498, 1842, 275, 1022, 82, 489, 327, 17650, 4642, 63, 344, 63, 1130, 436, 790, 1842, 1172, 2757, 13006, 14, 1432, 14, 489, 372, 14870, 339, 327, 4642, 63, 344, 63, 1130, 365, 440, 488, 272, 340, 822, 8, 4502, 63, 344, 63, 1130, 9, 1137, 413, 26, 489, 1592, 3924, 14, 11411, 547, 480, 3364, 4642, 63, 344, 63, 1130, 1543, 83, 4065, 450, 4642, 63, 344, 63, 1130, 9, 339, 4642, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mhotwagner/abackend
abackend-env/lib/python3.5/site-packages/django/utils/http.py
285
9978
from __future__ import unicode_literals import base64 import calendar import datetime import re import sys import unicodedata from binascii import Error as BinasciiError from email.utils import formatdate from django.utils import six from django.utils.datastructures import MultiValueDict from django.utils.encoding import force_bytes, force_str, force_text from django.utils.functional import allow_lazy from django.utils.six.moves.urllib.parse import ( quote, quote_plus, unquote, unquote_plus, urlencode as original_urlencode, urlparse, ) ETAG_MATCH = re.compile(r'(?:W/)?"((?:\\.|[^"])*)"') MONTHS = 'jan feb mar apr may jun jul aug sep oct nov dec'.split() __D = r'(?P<day>\d{2})' __D2 = r'(?P<day>[ \d]\d)' __M = r'(?P<mon>\w{3})' __Y = r'(?P<year>\d{4})' __Y2 = r'(?P<year>\d{2})' __T = r'(?P<hour>\d{2}):(?P<min>\d{2}):(?P<sec>\d{2})' RFC1123_DATE = re.compile(r'^\w{3}, %s %s %s %s GMT$' % (__D, __M, __Y, __T)) RFC850_DATE = re.compile(r'^\w{6,9}, %s-%s-%s %s GMT$' % (__D, __M, __Y2, __T)) ASCTIME_DATE = re.compile(r'^\w{3} %s %s %s %s$' % (__M, __D2, __T, __Y)) RFC3986_GENDELIMS = str(":/?#[]@") RFC3986_SUBDELIMS = str("!$&'()*+,;=") PROTOCOL_TO_PORT = { 'http': 80, 'https': 443, } def urlquote(url, safe='/'): """ A version of Python's urllib.quote() function that can operate on unicode strings. The url is first UTF-8 encoded before quoting. The returned string can safely be used as part of an argument to a subsequent iri_to_uri() call without double-quoting occurring. """ return force_text(quote(force_str(url), force_str(safe))) urlquote = allow_lazy(urlquote, six.text_type) def urlquote_plus(url, safe=''): """ A version of Python's urllib.quote_plus() function that can operate on unicode strings. The url is first UTF-8 encoded before quoting. The returned string can safely be used as part of an argument to a subsequent iri_to_uri() call without double-quoting occurring. """ return force_text(quote_plus(force_str(url), force_str(safe))) urlquote_plus = allow_lazy(urlquote_plus, six.text_type) def urlunquote(quoted_url): """ A wrapper for Python's urllib.unquote() function that can operate on the result of django.utils.http.urlquote(). """ return force_text(unquote(force_str(quoted_url))) urlunquote = allow_lazy(urlunquote, six.text_type) def urlunquote_plus(quoted_url): """ A wrapper for Python's urllib.unquote_plus() function that can operate on the result of django.utils.http.urlquote_plus(). """ return force_text(unquote_plus(force_str(quoted_url))) urlunquote_plus = allow_lazy(urlunquote_plus, six.text_type) def urlencode(query, doseq=0): """ A version of Python's urllib.urlencode() function that can operate on unicode strings. The parameters are first cast to UTF-8 encoded strings and then encoded as per normal. """ if isinstance(query, MultiValueDict): query = query.lists() elif hasattr(query, 'items'): query = query.items() return original_urlencode( [(force_str(k), [force_str(i) for i in v] if isinstance(v, (list, tuple)) else force_str(v)) for k, v in query], doseq) def cookie_date(epoch_seconds=None): """ Formats the time to ensure compatibility with Netscape's cookie standard. Accepts a floating point number expressed in seconds since the epoch, in UTC - such as that outputted by time.time(). If set to None, defaults to the current time. Outputs a string in the format 'Wdy, DD-Mon-YYYY HH:MM:SS GMT'. """ rfcdate = formatdate(epoch_seconds) return '%s-%s-%s GMT' % (rfcdate[:7], rfcdate[8:11], rfcdate[12:25]) def http_date(epoch_seconds=None): """ Formats the time to match the RFC1123 date format as specified by HTTP RFC2616 section 3.3.1. Accepts a floating point number expressed in seconds since the epoch, in UTC - such as that outputted by time.time(). If set to None, defaults to the current time. Outputs a string in the format 'Wdy, DD Mon YYYY HH:MM:SS GMT'. """ return formatdate(epoch_seconds, usegmt=True) def parse_http_date(date): """ Parses a date format as specified by HTTP RFC2616 section 3.3.1. The three formats allowed by the RFC are accepted, even if only the first one is still in widespread use. Returns an integer expressed in seconds since the epoch, in UTC. """ # emails.Util.parsedate does the job for RFC1123 dates; unfortunately # RFC2616 makes it mandatory to support RFC850 dates too. So we roll # our own RFC-compliant parsing. for regex in RFC1123_DATE, RFC850_DATE, ASCTIME_DATE: m = regex.match(date) if m is not None: break else: raise ValueError("%r is not in a valid HTTP date format" % date) try: year = int(m.group('year')) if year < 100: if year < 70: year += 2000 else: year += 1900 month = MONTHS.index(m.group('mon').lower()) + 1 day = int(m.group('day')) hour = int(m.group('hour')) min = int(m.group('min')) sec = int(m.group('sec')) result = datetime.datetime(year, month, day, hour, min, sec) return calendar.timegm(result.utctimetuple()) except Exception: six.reraise(ValueError, ValueError("%r is not a valid date" % date), sys.exc_info()[2]) def parse_http_date_safe(date): """ Same as parse_http_date, but returns None if the input is invalid. """ try: return parse_http_date(date) except Exception: pass # Base 36 functions: useful for generating compact URLs def base36_to_int(s): """ Converts a base 36 string to an ``int``. Raises ``ValueError` if the input won't fit into an int. """ # To prevent overconsumption of server resources, reject any # base36 string that is long than 13 base36 digits (13 digits # is sufficient to base36-encode any 64-bit integer) if len(s) > 13: raise ValueError("Base36 input too large") value = int(s, 36) # ... then do a final check that the value will fit into an int to avoid # returning a long (#15067). The long type was removed in Python 3. if six.PY2 and value > sys.maxint: raise ValueError("Base36 input too large") return value def int_to_base36(i): """ Converts an integer to a base36 string """ char_set = '0123456789abcdefghijklmnopqrstuvwxyz' if i < 0: raise ValueError("Negative base36 conversion input.") if six.PY2: if not isinstance(i, six.integer_types): raise TypeError("Non-integer base36 conversion input.") if i > sys.maxint: raise ValueError("Base36 conversion input too large.") if i < 36: return char_set[i] b36 = '' while i != 0: i, n = divmod(i, 36) b36 = char_set[n] + b36 return b36 def urlsafe_base64_encode(s): """ Encodes a bytestring in base64 for use in URLs, stripping any trailing equal signs. """ return base64.urlsafe_b64encode(s).rstrip(b'\n=') def urlsafe_base64_decode(s): """ Decodes a base64 encoded string, adding back any trailing equal signs that might have been stripped. """ s = force_bytes(s) try: return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'=')) except (LookupError, BinasciiError) as e: raise ValueError(e) def parse_etags(etag_str): """ Parses a string with one or several etags passed in If-None-Match and If-Match headers by the rules in RFC 2616. Returns a list of etags without surrounding double quotes (") and unescaped from \<CHAR>. """ etags = ETAG_MATCH.findall(etag_str) if not etags: # etag_str has wrong format, treat it as an opaque string then return [etag_str] etags = [e.encode('ascii').decode('unicode_escape') for e in etags] return etags def quote_etag(etag): """ Wraps a string in double quotes escaping contents as necessary. """ return '"%s"' % etag.replace('\\', '\\\\').replace('"', '\\"') def same_origin(url1, url2): """ Checks if two URLs are 'same-origin' """ p1, p2 = urlparse(url1), urlparse(url2) try: o1 = (p1.scheme, p1.hostname, p1.port or PROTOCOL_TO_PORT[p1.scheme]) o2 = (p2.scheme, p2.hostname, p2.port or PROTOCOL_TO_PORT[p2.scheme]) return o1 == o2 except (ValueError, KeyError): return False def is_safe_url(url, host=None): """ Return ``True`` if the url is a safe redirection (i.e. it doesn't point to a different host and uses a safe scheme). Always returns ``False`` on an empty url. """ if url is not None: url = url.strip() if not url: return False # Chrome treats \ completely as / url = url.replace('\\', '/') # Chrome considers any URL with more than two slashes to be absolute, but # urlparse is not so flexible. Treat any url with three slashes as unsafe. if url.startswith('///'): return False url_info = urlparse(url) # Forbid URLs like http:///example.com - with a scheme, but without a hostname. # In that URL, example.com is not the hostname but, a path component. However, # Chrome will still consider example.com to be the hostname, so we must not # allow this syntax. if not url_info.netloc and url_info.scheme: return False # Forbid URLs that start with control characters. Some browsers (like # Chrome) ignore quite a few control characters at the start of a # URL and might consider the URL as scheme relative. if unicodedata.category(url[0])[0] == 'C': return False return ((not url_info.netloc or url_info.netloc == host) and (not url_info.scheme or url_info.scheme in ['http', 'https']))
mit
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1300, 772, 199, 646, 11234, 199, 646, 2197, 199, 646, 295, 199, 646, 984, 199, 646, 23128, 199, 504, 14755, 492, 4520, 465, 32613, 4371, 547, 199, 504, 3031, 14, 1208, 492, 1475, 602, 199, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 23004, 492, 6879, 24811, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 3542, 63, 495, 12, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 15481, 492, 2040, 63, 6395, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 14, 4078, 14, 1122, 492, 334, 272, 6313, 12, 6313, 63, 6666, 12, 14342, 12, 14342, 63, 6666, 12, 16511, 465, 3379, 63, 10738, 12, 272, 7097, 12, 199, 9, 199, 199, 775, 1254, 63, 14747, 275, 295, 14, 2014, 8, 82, 20459, 55, 15, 5547, 2, 17304, 18589, 14, 23629, 3135, 25952, 358, 199, 199, 16413, 51, 275, 283, 24418, 1964, 66, 7557, 282, 2700, 1443, 1335, 324, 1335, 348, 18336, 7375, 17162, 949, 86, 9700, 1370, 1294, 342, 199, 363, 36, 275, 519, 10120, 48, 28, 2977, 3072, 68, 91, 18, 29668, 199, 363, 36, 18, 275, 519, 10120, 48, 28, 2977, 9514, 971, 68, 7272, 68, 3171, 199, 363, 45, 275, 519, 10120, 48, 28, 2106, 3072, 87, 91, 19, 29668, 199, 363, 57, 275, 519, 10120, 48, 28, 3403, 3072, 68, 91, 20, 29668, 199, 363, 57, 18, 275, 519, 10120, 48, 28, 3403, 3072, 68, 91, 18, 29668, 199, 363, 52, 275, 519, 10120, 48, 28, 5180, 3072, 68, 91, 18, 22558, 2229, 48, 28, 827, 3072, 68, 91, 18, 22558, 2229, 48, 28, 3321, 3072, 68, 91, 18, 29668, 199, 14468, 17, 4288, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 19, 1386, 450, 83, 450, 83, 450, 83, 450, 83, 19152, 12913, 450, 25373, 36, 12, 636, 45, 12, 636, 57, 12, 636, 52, 430, 199, 14468, 21419, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 22, 12, 25, 1386, 450, 83, 3295, 83, 3295, 83, 450, 83, 19152, 12913, 450, 25373, 36, 12, 636, 45, 12, 636, 57, 18, 12, 636, 52, 430, 199, 1179, 1028, 3465, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 19, 93, 450, 83, 450, 83, 450, 83, 450, 83, 12913, 450, 25373, 45, 12, 636, 36, 18, 12, 636, 52, 12, 636, 57, 430, 199, 199, 14468, 29451, 63, 9289, 4424, 1469, 51, 275, 620, 20308, 10197, 3, 8607, 32, 531, 199, 14468, 29451, 63, 6348, 4424, 1469, 51, 275, 620, 19232, 4, 6, 7, 25608, 28061, 27, 23758, 199, 199, 9583, 63, 2566, 63, 3657, 275, 469, 272, 283, 1014, 356, 5939, 12, 272, 283, 2859, 356, 23865, 12, 199, 93, 421, 199, 318, 1166, 3513, 8, 633, 12, 5048, 8805, 735, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 3513, 342, 805, 626, 883, 19218, 641, 2649, 272, 3326, 14, 710, 1166, 365, 1642, 9094, 13, 24, 5737, 2544, 18593, 14, 710, 2138, 1059, 272, 883, 19353, 506, 1202, 465, 1777, 402, 376, 1423, 370, 282, 13372, 24086, 63, 475, 63, 2302, 342, 1240, 272, 1928, 4270, 13, 25272, 4781, 5985, 14, 272, 408, 272, 372, 3542, 63, 505, 8, 3513, 8, 3990, 63, 495, 8, 633, 395, 3542, 63, 495, 8, 3489, 1724, 199, 633, 3513, 275, 2040, 63, 6395, 8, 633, 3513, 12, 3816, 14, 505, 63, 466, 9, 421, 199, 318, 1166, 3513, 63, 6666, 8, 633, 12, 5048, 9280, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 3513, 63, 6666, 342, 805, 626, 883, 19218, 641, 272, 2649, 3326, 14, 710, 1166, 365, 1642, 9094, 13, 24, 5737, 2544, 18593, 14, 710, 272, 2138, 1059, 883, 19353, 506, 1202, 465, 1777, 402, 376, 1423, 370, 282, 13372, 272, 24086, 63, 475, 63, 2302, 342, 1240, 1928, 4270, 13, 25272, 4781, 5985, 14, 272, 408, 272, 372, 3542, 63, 505, 8, 3513, 63, 6666, 8, 3990, 63, 495, 8, 633, 395, 3542, 63, 495, 8, 3489, 1724, 199, 633, 3513, 63, 6666, 275, 2040, 63, 6395, 8, 633, 3513, 63, 6666, 12, 3816, 14, 505, 63, 466, 9, 421, 199, 318, 1166, 12240, 8, 9888, 63, 633, 304, 272, 408, 272, 437, 4975, 367, 2018, 1159, 4011, 14, 12240, 342, 805, 626, 883, 19218, 641, 272, 314, 754, 402, 1639, 14, 1208, 14, 1014, 14, 633, 3513, 1252, 272, 408, 272, 372, 3542, 63, 505, 8, 12240, 8, 3990, 63, 495, 8, 9888, 63, 633, 1724, 199, 633, 12240, 275, 2040, 63, 6395, 8, 633, 12240, 12, 3816, 14, 505, 63, 466, 9, 421, 199, 318, 1166, 12240, 63, 6666, 8, 9888, 63, 633, 304, 272, 408, 272, 437, 4975, 367, 2018, 1159, 4011, 14, 12240, 63, 6666, 342, 805, 626, 883, 19218, 641, 272, 314, 754, 402, 1639, 14, 1208, 14, 1014, 14, 633, 3513, 63, 6666, 1252, 272, 408, 272, 372, 3542, 63, 505, 8, 12240, 63, 6666, 8, 3990, 63, 495, 8, 9888, 63, 633, 1724, 199, 633, 12240, 63, 6666, 275, 2040, 63, 6395, 8, 633, 12240, 63, 6666, 12, 3816, 14, 505, 63, 466, 9, 421, 199, 318, 16511, 8, 1131, 12, 886, 3610, 29, 16, 304, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 10738, 342, 805, 626, 883, 19218, 641, 272, 2649, 3326, 14, 710, 2633, 787, 1642, 9106, 370, 9094, 13, 24, 5737, 3326, 436, 272, 2066, 5737, 465, 1126, 3293, 14, 272, 408, 272, 340, 1228, 8, 1131, 12, 6879, 24811, 304, 267, 1827, 275, 1827, 14, 6717, 342, 272, 916, 2688, 8, 1131, 12, 283, 1744, 735, 267, 1827, 275, 1827, 14, 1744, 342, 272, 372, 3379, 63, 10738, 8, 267, 3842, 3990, 63, 495, 8, 75, 395, 268, 359, 3990, 63, 495, 8, 73, 9, 367, 284, 315, 373, 61, 340, 1228, 8, 86, 12, 334, 513, 12, 2008, 430, 587, 3542, 63, 495, 8, 86, 430, 288, 367, 1022, 12, 373, 315, 1827, 467, 267, 886, 3610, 9, 421, 199, 318, 5494, 63, 602, 8, 7367, 63, 4515, 29, 403, 304, 272, 408, 272, 9701, 83 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1300, 772, 199, 646, 11234, 199, 646, 2197, 199, 646, 295, 199, 646, 984, 199, 646, 23128, 199, 504, 14755, 492, 4520, 465, 32613, 4371, 547, 199, 504, 3031, 14, 1208, 492, 1475, 602, 199, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 23004, 492, 6879, 24811, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 3542, 63, 495, 12, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 15481, 492, 2040, 63, 6395, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 14, 4078, 14, 1122, 492, 334, 272, 6313, 12, 6313, 63, 6666, 12, 14342, 12, 14342, 63, 6666, 12, 16511, 465, 3379, 63, 10738, 12, 272, 7097, 12, 199, 9, 199, 199, 775, 1254, 63, 14747, 275, 295, 14, 2014, 8, 82, 20459, 55, 15, 5547, 2, 17304, 18589, 14, 23629, 3135, 25952, 358, 199, 199, 16413, 51, 275, 283, 24418, 1964, 66, 7557, 282, 2700, 1443, 1335, 324, 1335, 348, 18336, 7375, 17162, 949, 86, 9700, 1370, 1294, 342, 199, 363, 36, 275, 519, 10120, 48, 28, 2977, 3072, 68, 91, 18, 29668, 199, 363, 36, 18, 275, 519, 10120, 48, 28, 2977, 9514, 971, 68, 7272, 68, 3171, 199, 363, 45, 275, 519, 10120, 48, 28, 2106, 3072, 87, 91, 19, 29668, 199, 363, 57, 275, 519, 10120, 48, 28, 3403, 3072, 68, 91, 20, 29668, 199, 363, 57, 18, 275, 519, 10120, 48, 28, 3403, 3072, 68, 91, 18, 29668, 199, 363, 52, 275, 519, 10120, 48, 28, 5180, 3072, 68, 91, 18, 22558, 2229, 48, 28, 827, 3072, 68, 91, 18, 22558, 2229, 48, 28, 3321, 3072, 68, 91, 18, 29668, 199, 14468, 17, 4288, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 19, 1386, 450, 83, 450, 83, 450, 83, 450, 83, 19152, 12913, 450, 25373, 36, 12, 636, 45, 12, 636, 57, 12, 636, 52, 430, 199, 14468, 21419, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 22, 12, 25, 1386, 450, 83, 3295, 83, 3295, 83, 450, 83, 19152, 12913, 450, 25373, 36, 12, 636, 45, 12, 636, 57, 18, 12, 636, 52, 430, 199, 1179, 1028, 3465, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 19, 93, 450, 83, 450, 83, 450, 83, 450, 83, 12913, 450, 25373, 45, 12, 636, 36, 18, 12, 636, 52, 12, 636, 57, 430, 199, 199, 14468, 29451, 63, 9289, 4424, 1469, 51, 275, 620, 20308, 10197, 3, 8607, 32, 531, 199, 14468, 29451, 63, 6348, 4424, 1469, 51, 275, 620, 19232, 4, 6, 7, 25608, 28061, 27, 23758, 199, 199, 9583, 63, 2566, 63, 3657, 275, 469, 272, 283, 1014, 356, 5939, 12, 272, 283, 2859, 356, 23865, 12, 199, 93, 421, 199, 318, 1166, 3513, 8, 633, 12, 5048, 8805, 735, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 3513, 342, 805, 626, 883, 19218, 641, 2649, 272, 3326, 14, 710, 1166, 365, 1642, 9094, 13, 24, 5737, 2544, 18593, 14, 710, 2138, 1059, 272, 883, 19353, 506, 1202, 465, 1777, 402, 376, 1423, 370, 282, 13372, 24086, 63, 475, 63, 2302, 342, 1240, 272, 1928, 4270, 13, 25272, 4781, 5985, 14, 272, 408, 272, 372, 3542, 63, 505, 8, 3513, 8, 3990, 63, 495, 8, 633, 395, 3542, 63, 495, 8, 3489, 1724, 199, 633, 3513, 275, 2040, 63, 6395, 8, 633, 3513, 12, 3816, 14, 505, 63, 466, 9, 421, 199, 318, 1166, 3513, 63, 6666, 8, 633, 12, 5048, 9280, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 3513, 63, 6666, 342, 805, 626, 883, 19218, 641, 272, 2649, 3326, 14, 710, 1166, 365, 1642, 9094, 13, 24, 5737, 2544, 18593, 14, 710, 272, 2138, 1059, 883, 19353, 506, 1202, 465, 1777, 402, 376, 1423, 370, 282, 13372, 272, 24086, 63, 475, 63, 2302, 342, 1240, 1928, 4270, 13, 25272, 4781, 5985, 14, 272, 408, 272, 372, 3542, 63, 505, 8, 3513, 63, 6666, 8, 3990, 63, 495, 8, 633, 395, 3542, 63, 495, 8, 3489, 1724, 199, 633, 3513, 63, 6666, 275, 2040, 63, 6395, 8, 633, 3513, 63, 6666, 12, 3816, 14, 505, 63, 466, 9, 421, 199, 318, 1166, 12240, 8, 9888, 63, 633, 304, 272, 408, 272, 437, 4975, 367, 2018, 1159, 4011, 14, 12240, 342, 805, 626, 883, 19218, 641, 272, 314, 754, 402, 1639, 14, 1208, 14, 1014, 14, 633, 3513, 1252, 272, 408, 272, 372, 3542, 63, 505, 8, 12240, 8, 3990, 63, 495, 8, 9888, 63, 633, 1724, 199, 633, 12240, 275, 2040, 63, 6395, 8, 633, 12240, 12, 3816, 14, 505, 63, 466, 9, 421, 199, 318, 1166, 12240, 63, 6666, 8, 9888, 63, 633, 304, 272, 408, 272, 437, 4975, 367, 2018, 1159, 4011, 14, 12240, 63, 6666, 342, 805, 626, 883, 19218, 641, 272, 314, 754, 402, 1639, 14, 1208, 14, 1014, 14, 633, 3513, 63, 6666, 1252, 272, 408, 272, 372, 3542, 63, 505, 8, 12240, 63, 6666, 8, 3990, 63, 495, 8, 9888, 63, 633, 1724, 199, 633, 12240, 63, 6666, 275, 2040, 63, 6395, 8, 633, 12240, 63, 6666, 12, 3816, 14, 505, 63, 466, 9, 421, 199, 318, 16511, 8, 1131, 12, 886, 3610, 29, 16, 304, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 10738, 342, 805, 626, 883, 19218, 641, 272, 2649, 3326, 14, 710, 2633, 787, 1642, 9106, 370, 9094, 13, 24, 5737, 3326, 436, 272, 2066, 5737, 465, 1126, 3293, 14, 272, 408, 272, 340, 1228, 8, 1131, 12, 6879, 24811, 304, 267, 1827, 275, 1827, 14, 6717, 342, 272, 916, 2688, 8, 1131, 12, 283, 1744, 735, 267, 1827, 275, 1827, 14, 1744, 342, 272, 372, 3379, 63, 10738, 8, 267, 3842, 3990, 63, 495, 8, 75, 395, 268, 359, 3990, 63, 495, 8, 73, 9, 367, 284, 315, 373, 61, 340, 1228, 8, 86, 12, 334, 513, 12, 2008, 430, 587, 3542, 63, 495, 8, 86, 430, 288, 367, 1022, 12, 373, 315, 1827, 467, 267, 886, 3610, 9, 421, 199, 318, 5494, 63, 602, 8, 7367, 63, 4515, 29, 403, 304, 272, 408, 272, 9701, 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,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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 ]
Nablaquabla/sns-analysis
ba-missing-files.py
1
5827
import os import time as tm import sys # Handles the creation of condor files for a given set of directories # ----------------------------------------------------------------------------- def createCondorFile(dataDir,outDir,run,day,time): # Condor submission file name convention: run-day-time.condor with open('/home/bjs66/CondorFiles/%s-%s-%s.condor'%(run,day,time),'w') as f: # Fixed program location' f.write('Executable = /home/bjs66/GitHub/sns-analysis/sns-analysis-v3\n') # Arguments passed to the exe: # Set main run directory, e.g. Run-15-10-02-27-32-23/151002 # Set current time to be analzyed (w/o .zip extension!), e.g. 184502 # Set output directory, eg Output/ Run-15-10-02-27-32-23/151002 f.write('Arguments = \"3 %s %s %s 1\"\n'%(dataDir,time,outDir)) # Standard cluster universe f.write('universe = vanilla\n') f.write('getenv = true\n') # Program needs at least 250 MB of free memory to hold unzipped data f.write('request_memory = 300\n') # Output, error and log name convention: run-day-time.log/out/err f.write('log = ../../Logs/%s-%s-%s.log\n'%(run,day,time)) f.write('Output = ../../Outs/%s-%s-%s.out\n'%(run,day,time)) f.write('Error = ../../Errs/%s-%ss-%s.err\n'%(run,day,time)) # Do not write any emails f.write('notification = never\n') f.write('+Department = Physics\n') f.write('should_transfer_files = NO\n') # Add single job to queue f.write('Queue') # Main function handling all internals # ----------------------------------------------------------------------------- def main(runMissing): # Choose main directory, i.e. ~/csi/beam_on_data/Run-15-06-25-xyz/ mainRunDir = '/var/phy/project/phil/grayson/COHERENT/CsI/' # Choose output directory, i.e. ~/output/Run-15-06-25-xyz/ mainOutDir = '/var/phy/project/phil/grayson/COHERENT/CsI/bjs-analysis/' # Choose run to analyze # runDirs = ['Run-15-03-27-12-42-26'] # run = 'Run-15-03-30-13-33-05' # run = 'Run-15-04-08-11-38-28' # run = 'Run-15-04-17-16-56-59' # run = 'Run-15-04-29-16-34-44' # runDirs = ['Run-15-05-05-16-09-12'] # run = 'Run-15-05-11-11-46-30' # run = 'Run-15-05-19-17-04-44' # run = 'Run-15-05-27-11-13-46' # runDirs = ['Run-15-05-05-16-09-12','Run-15-05-11-11-46-30','Run-15-05-19-17-04-44','Run-15-05-27-11-13-46'] runDirs = ['Run-15-03-27-12-42-26','Run-15-03-30-13-33-05','Run-15-04-08-11-38-28','Run-15-04-17-16-56-59','Run-15-04-29-16-34-44', 'Run-15-05-05-16-09-12','Run-15-05-11-11-46-30','Run-15-05-19-17-04-44','Run-15-05-27-11-13-46'] subdirs = {} days_in = {'Run-15-03-27-12-42-26': ['150327','150328','150329','150330'], 'Run-15-03-30-13-33-05': ['150330','150331','150401','150402','150403','150404','150405','150406','150407','150408'], 'Run-15-04-08-11-38-28': ['150408','150409','150410','150411','150412','150413','150414','150415','150416'], 'Run-15-04-17-16-56-59': ['150417','150418','150419','150420','150421','150422','150423','150424','150425','150426','150427','150428','150429'], 'Run-15-04-29-16-34-44': ['150429','150430','150501','150502','150503','150504','150505'], 'Run-15-05-05-16-09-12': ['150505','150506','150507','150508','150509','150510','150511'], 'Run-15-05-11-11-46-30': ['150512','150513','150514','150515','150516','150517','150518','150519'], 'Run-15-05-19-17-04-44': ['150519','150520','150521','150522','150523','150524','150525','150526','150527'], 'Run-15-05-27-11-13-46': ['150527','150528','150529','150530','150531','150601','150602','150603','150604','150605','150606','150607','150608','150609']} for run in runDirs: for day in days_in[run]: subdirs[run] = 'brillance_data' print run,day # Prepare paths for further processing dataRunDir = mainRunDir + '%s/%s/%s'%(subdirs[run],run,day) outDir = mainOutDir + '%s/%s'%(run,day) # Get all times within the day folder chosen inputList = [x.split('.')[0] for x in os.listdir(dataRunDir)] # Get all times within the day folder chosen outputList_B = [x.split('-')[1] for x in os.listdir(outDir) if 'B-' in x] outputList_S = [x.split('-')[1] for x in os.listdir(outDir) if 'S-' in x] outputList_I = [x.split('-')[1] for x in os.listdir(outDir) if 'I-' in x] # Check if there is a file missing in the day folder if len(inputList) != len(outputList_B) or len(inputList) != len(outputList_S) or len(inputList) != len(outputList_I): missingB = set(inputList) - set(outputList_B) missingI = set(inputList) - set(outputList_I) missingS = set(inputList) - set(outputList_S) missing = list((missingB | missingI) | missingS) if len(missing) > 0: print len(missing) if runMissing == '1': for m in missing: createCondorFile(dataRunDir,outDir,run,day,m) cmd = 'condor_submit /home/bjs66/CondorFiles/%s-%s-%s.condor'%(run,day,m) os.system(cmd) if __name__ == '__main__': main(sys.argv[1])
gpl-3.0
[ 646, 747, 199, 646, 900, 465, 7352, 199, 646, 984, 199, 199, 3, 23873, 314, 7143, 402, 9288, 269, 1584, 367, 282, 1627, 663, 402, 6602, 199, 3, 13722, 199, 318, 1218, 23735, 269, 1173, 8, 576, 3567, 12, 548, 3567, 12, 1065, 12, 2977, 12, 521, 304, 272, 327, 1448, 68, 269, 13071, 570, 536, 16129, 26, 1255, 13, 2977, 13, 521, 14, 2067, 269, 272, 543, 1551, 2336, 4219, 15, 468, 83, 1272, 15, 23735, 269, 5535, 3149, 83, 3295, 83, 3295, 83, 14, 2067, 269, 13328, 1065, 12, 2977, 12, 521, 26582, 87, 358, 465, 289, 26, 2728, 327, 18659, 2240, 2909, 7, 267, 289, 14, 952, 360, 18039, 275, 1182, 4219, 15, 468, 83, 1272, 15, 14686, 15338, 15, 83, 561, 13, 10466, 15, 83, 561, 13, 10466, 13, 86, 19, 60, 78, 358, 2728, 327, 7628, 3032, 370, 314, 14778, 26, 267, 327, 2494, 2446, 1255, 2082, 12, 325, 14, 71, 14, 3378, 13, 1046, 13, 709, 13, 996, 13, 1465, 13, 708, 13, 1789, 15, 1046, 32562, 6722, 327, 2494, 1453, 900, 370, 506, 376, 279, 3605, 379, 334, 87, 15, 79, 1275, 3065, 3329, 1, 395, 325, 14, 71, 14, 413, 16963, 996, 6722, 327, 2494, 1072, 2082, 12, 11837, 7242, 15, 3378, 13, 1046, 13, 709, 13, 996, 13, 1465, 13, 708, 13, 1789, 15, 1046, 32562, 267, 289, 14, 952, 360, 14517, 275, 8441, 19, 450, 83, 450, 83, 450, 83, 413, 13356, 78, 13328, 576, 3567, 12, 521, 12, 548, 3567, 430, 221, 2728, 327, 9739, 4350, 15439, 2077, 267, 289, 14, 952, 360, 30519, 257, 275, 20744, 6165, 60, 78, 358, 267, 289, 14, 952, 360, 12959, 258, 275, 2549, 60, 78, 358, 398, 327, 18841, 4839, 737, 5210, 16074, 19487, 402, 2867, 4402, 370, 10266, 29379, 1915, 666, 267, 289, 14, 952, 360, 1069, 63, 4844, 275, 9601, 60, 78, 358, 489, 267, 327, 7242, 12, 1125, 436, 943, 536, 16129, 26, 1255, 13, 2977, 13, 521, 14, 793, 15, 548, 15, 1508, 267, 289, 14, 952, 360, 793, 275, 24272, 5093, 16333, 3149, 83, 3295, 83, 3295, 83, 14, 793, 60, 78, 13328, 1065, 12, 2977, 12, 521, 430, 267, 289, 14, 952, 360, 2959, 275, 24272, 5093, 2204, 83, 3149, 83, 3295, 83, 3295, 83, 14, 548, 60, 78, 13328, 1065, 12, 2977, 12, 521, 430, 267, 289, 14, 952, 360, 547, 275, 24272, 5093, 539, 2393, 3149, 83, 3295, 385, 3295, 83, 14, 1508, 60, 78, 13328, 1065, 12, 2977, 12, 521, 430, 2728, 327, 4226, 440, 2218, 1263, 14931, 267, 289, 14, 952, 360, 6761, 275, 7078, 60, 78, 358, 267, 289, 14, 952, 19975, 872, 12493, 221, 275, 24309, 17378, 60, 78, 358, 267, 289, 14, 952, 360, 5626, 63, 9609, 63, 1725, 275, 4825, 60, 78, 358, 2728, 327, 2654, 2849, 3906, 370, 4126, 267, 289, 14, 952, 360, 3737, 358, 268, 199, 3, 11298, 805, 7252, 1006, 5007, 83, 199, 3, 13722, 199, 318, 2446, 8, 1065, 7718, 304, 263, 2043, 327, 29826, 2446, 2082, 12, 284, 14, 69, 14, 6146, 15, 19551, 15, 14529, 63, 265, 63, 576, 15, 2540, 13, 1046, 13, 1690, 13, 821, 13, 8568, 15, 272, 2446, 2540, 3567, 275, 1994, 1391, 15, 6581, 15, 1715, 15, 838, 382, 15, 926, 588, 265, 15, 1439, 3452, 1309, 15, 13912, 41, 4805, 2286, 327, 29826, 1072, 2082, 12, 284, 14, 69, 14, 6146, 15, 1199, 15, 2540, 13, 1046, 13, 1690, 13, 821, 13, 8568, 15, 272, 2446, 30654, 275, 1994, 1391, 15, 6581, 15, 1715, 15, 838, 382, 15, 926, 588, 265, 15, 1439, 3452, 1309, 15, 13912, 41, 15, 468, 83, 13, 10466, 4805, 339, 327, 29826, 1255, 370, 19897, 199, 3, 259, 1255, 17051, 275, 788, 2540, 13, 1046, 13, 1644, 13, 1465, 13, 713, 13, 2260, 13, 1479, 418, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 1644, 13, 1216, 13, 969, 13, 1153, 13, 1717, 7, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 966, 13, 2036, 13, 845, 13, 1703, 13, 1651, 7, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 966, 13, 1196, 13, 975, 13, 1367, 13, 1427, 7, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 966, 13, 1398, 13, 975, 13, 1082, 13, 1602, 7, 199, 3, 259, 1255, 17051, 275, 788, 2540, 13, 1046, 13, 1717, 13, 1717, 13, 975, 13, 1643, 13, 713, 418, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 1717, 13, 845, 13, 845, 13, 2466, 13, 1216, 7, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 1717, 13, 1167, 13, 1196, 13, 966, 13, 1602, 7, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 1717, 13, 1465, 13, 845, 13, 969, 13, 2466, 7, 199, 3, 259, 1255, 17051, 275, 788, 2540, 13, 1046, 13, 1717, 13, 1717, 13, 975, 13, 1643, 13, 713, 1673, 2540, 13, 1046, 13, 1717, 13, 845, 13, 845, 13, 2466, 13, 1216, 1673, 2540, 13, 1046, 13, 1717, 13, 1167, 13, 1196, 13, 966, 13, 1602, 1673, 2540, 13, 1046, 13, 1717, 13, 1465, 13, 845, 13, 969, 13, 2466, 418, 272, 1255, 17051, 275, 788, 2540, 13, 1046, 13, 1644, 13, 1465, 13, 713, 13, 2260, 13, 1479, 1673, 2540, 13, 1046, 13, 1644, 13, 1216, 13, 969, 13, 1153, 13, 1717, 1673, 2540, 13, 1046, 13, 966, 13, 2036, 13, 845, 13, 1703, 13, 1651, 1673, 2540, 13, 1046, 13, 966, 13, 1196, 13, 975, 13, 1367, 13, 1427, 1673, 2540, 13, 1046, 13, 966, 13, 1398, 13, 975, 13, 1082, 13, 1602, 297, 2049, 283, 2540, 13, 1046, 13, 1717, 13, 1717, 13, 975, 13, 1643, 13, 713, 1673, 2540, 13, 1046, 13, 1717, 13, 845, 13, 845, 13, 2466, 13, 1216, 1673, 2540, 13, 1046, 13, 1717, 13, 1167, 13, 1196, 13, 966, 13, 1602, 1673, 2540, 13, 1046, 13, 1717, 13, 1465, 13, 845, 13, 969, 13, 2466, 418, 2286, 31396, 275, 1052, 2286, 7609, 63, 262, 275, 791, 2540, 13, 1046, 13, 1644, 13, 1465, 13, 713, 13, 2260, 13, 1479, 356, 788, 8251, 11754, 1673, 8251, 12870, 1673 ]
[ 747, 199, 646, 900, 465, 7352, 199, 646, 984, 199, 199, 3, 23873, 314, 7143, 402, 9288, 269, 1584, 367, 282, 1627, 663, 402, 6602, 199, 3, 13722, 199, 318, 1218, 23735, 269, 1173, 8, 576, 3567, 12, 548, 3567, 12, 1065, 12, 2977, 12, 521, 304, 272, 327, 1448, 68, 269, 13071, 570, 536, 16129, 26, 1255, 13, 2977, 13, 521, 14, 2067, 269, 272, 543, 1551, 2336, 4219, 15, 468, 83, 1272, 15, 23735, 269, 5535, 3149, 83, 3295, 83, 3295, 83, 14, 2067, 269, 13328, 1065, 12, 2977, 12, 521, 26582, 87, 358, 465, 289, 26, 2728, 327, 18659, 2240, 2909, 7, 267, 289, 14, 952, 360, 18039, 275, 1182, 4219, 15, 468, 83, 1272, 15, 14686, 15338, 15, 83, 561, 13, 10466, 15, 83, 561, 13, 10466, 13, 86, 19, 60, 78, 358, 2728, 327, 7628, 3032, 370, 314, 14778, 26, 267, 327, 2494, 2446, 1255, 2082, 12, 325, 14, 71, 14, 3378, 13, 1046, 13, 709, 13, 996, 13, 1465, 13, 708, 13, 1789, 15, 1046, 32562, 6722, 327, 2494, 1453, 900, 370, 506, 376, 279, 3605, 379, 334, 87, 15, 79, 1275, 3065, 3329, 1, 395, 325, 14, 71, 14, 413, 16963, 996, 6722, 327, 2494, 1072, 2082, 12, 11837, 7242, 15, 3378, 13, 1046, 13, 709, 13, 996, 13, 1465, 13, 708, 13, 1789, 15, 1046, 32562, 267, 289, 14, 952, 360, 14517, 275, 8441, 19, 450, 83, 450, 83, 450, 83, 413, 13356, 78, 13328, 576, 3567, 12, 521, 12, 548, 3567, 430, 221, 2728, 327, 9739, 4350, 15439, 2077, 267, 289, 14, 952, 360, 30519, 257, 275, 20744, 6165, 60, 78, 358, 267, 289, 14, 952, 360, 12959, 258, 275, 2549, 60, 78, 358, 398, 327, 18841, 4839, 737, 5210, 16074, 19487, 402, 2867, 4402, 370, 10266, 29379, 1915, 666, 267, 289, 14, 952, 360, 1069, 63, 4844, 275, 9601, 60, 78, 358, 489, 267, 327, 7242, 12, 1125, 436, 943, 536, 16129, 26, 1255, 13, 2977, 13, 521, 14, 793, 15, 548, 15, 1508, 267, 289, 14, 952, 360, 793, 275, 24272, 5093, 16333, 3149, 83, 3295, 83, 3295, 83, 14, 793, 60, 78, 13328, 1065, 12, 2977, 12, 521, 430, 267, 289, 14, 952, 360, 2959, 275, 24272, 5093, 2204, 83, 3149, 83, 3295, 83, 3295, 83, 14, 548, 60, 78, 13328, 1065, 12, 2977, 12, 521, 430, 267, 289, 14, 952, 360, 547, 275, 24272, 5093, 539, 2393, 3149, 83, 3295, 385, 3295, 83, 14, 1508, 60, 78, 13328, 1065, 12, 2977, 12, 521, 430, 2728, 327, 4226, 440, 2218, 1263, 14931, 267, 289, 14, 952, 360, 6761, 275, 7078, 60, 78, 358, 267, 289, 14, 952, 19975, 872, 12493, 221, 275, 24309, 17378, 60, 78, 358, 267, 289, 14, 952, 360, 5626, 63, 9609, 63, 1725, 275, 4825, 60, 78, 358, 2728, 327, 2654, 2849, 3906, 370, 4126, 267, 289, 14, 952, 360, 3737, 358, 268, 199, 3, 11298, 805, 7252, 1006, 5007, 83, 199, 3, 13722, 199, 318, 2446, 8, 1065, 7718, 304, 263, 2043, 327, 29826, 2446, 2082, 12, 284, 14, 69, 14, 6146, 15, 19551, 15, 14529, 63, 265, 63, 576, 15, 2540, 13, 1046, 13, 1690, 13, 821, 13, 8568, 15, 272, 2446, 2540, 3567, 275, 1994, 1391, 15, 6581, 15, 1715, 15, 838, 382, 15, 926, 588, 265, 15, 1439, 3452, 1309, 15, 13912, 41, 4805, 2286, 327, 29826, 1072, 2082, 12, 284, 14, 69, 14, 6146, 15, 1199, 15, 2540, 13, 1046, 13, 1690, 13, 821, 13, 8568, 15, 272, 2446, 30654, 275, 1994, 1391, 15, 6581, 15, 1715, 15, 838, 382, 15, 926, 588, 265, 15, 1439, 3452, 1309, 15, 13912, 41, 15, 468, 83, 13, 10466, 4805, 339, 327, 29826, 1255, 370, 19897, 199, 3, 259, 1255, 17051, 275, 788, 2540, 13, 1046, 13, 1644, 13, 1465, 13, 713, 13, 2260, 13, 1479, 418, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 1644, 13, 1216, 13, 969, 13, 1153, 13, 1717, 7, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 966, 13, 2036, 13, 845, 13, 1703, 13, 1651, 7, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 966, 13, 1196, 13, 975, 13, 1367, 13, 1427, 7, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 966, 13, 1398, 13, 975, 13, 1082, 13, 1602, 7, 199, 3, 259, 1255, 17051, 275, 788, 2540, 13, 1046, 13, 1717, 13, 1717, 13, 975, 13, 1643, 13, 713, 418, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 1717, 13, 845, 13, 845, 13, 2466, 13, 1216, 7, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 1717, 13, 1167, 13, 1196, 13, 966, 13, 1602, 7, 199, 3, 259, 1255, 275, 283, 2540, 13, 1046, 13, 1717, 13, 1465, 13, 845, 13, 969, 13, 2466, 7, 199, 3, 259, 1255, 17051, 275, 788, 2540, 13, 1046, 13, 1717, 13, 1717, 13, 975, 13, 1643, 13, 713, 1673, 2540, 13, 1046, 13, 1717, 13, 845, 13, 845, 13, 2466, 13, 1216, 1673, 2540, 13, 1046, 13, 1717, 13, 1167, 13, 1196, 13, 966, 13, 1602, 1673, 2540, 13, 1046, 13, 1717, 13, 1465, 13, 845, 13, 969, 13, 2466, 418, 272, 1255, 17051, 275, 788, 2540, 13, 1046, 13, 1644, 13, 1465, 13, 713, 13, 2260, 13, 1479, 1673, 2540, 13, 1046, 13, 1644, 13, 1216, 13, 969, 13, 1153, 13, 1717, 1673, 2540, 13, 1046, 13, 966, 13, 2036, 13, 845, 13, 1703, 13, 1651, 1673, 2540, 13, 1046, 13, 966, 13, 1196, 13, 975, 13, 1367, 13, 1427, 1673, 2540, 13, 1046, 13, 966, 13, 1398, 13, 975, 13, 1082, 13, 1602, 297, 2049, 283, 2540, 13, 1046, 13, 1717, 13, 1717, 13, 975, 13, 1643, 13, 713, 1673, 2540, 13, 1046, 13, 1717, 13, 845, 13, 845, 13, 2466, 13, 1216, 1673, 2540, 13, 1046, 13, 1717, 13, 1167, 13, 1196, 13, 966, 13, 1602, 1673, 2540, 13, 1046, 13, 1717, 13, 1465, 13, 845, 13, 969, 13, 2466, 418, 2286, 31396, 275, 1052, 2286, 7609, 63, 262, 275, 791, 2540, 13, 1046, 13, 1644, 13, 1465, 13, 713, 13, 2260, 13, 1479, 356, 788, 8251, 11754, 1673, 8251, 12870, 1673, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bryanph/OIPA
OIPA/iati_synchroniser/migrations/0001_initial.py
3
3637
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ] operations = [ migrations.CreateModel( name='Codelist', fields=[ ('name', models.CharField(max_length=100, serialize=False, primary_key=True)), ('description', models.TextField(max_length=1000, null=True, blank=True)), ('count', models.CharField(max_length=10, null=True, blank=True)), ('fields', models.CharField(max_length=255, null=True, blank=True)), ('date_updated', models.DateTimeField(auto_now=True)), ], options={ }, bases=(models.Model,), ), migrations.CreateModel( name='IatiXmlSource', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('ref', models.CharField(help_text='Reference for the XML file. Preferred usage: Name on IATI registry', max_length=70, verbose_name='Reference')), ('title', models.CharField(max_length=255)), ('type', models.IntegerField(default=1, choices=[(1, 'Activity Files'), (2, 'Organisation Files')])), ('source_url', models.CharField(help_text='Hyperlink to an iati activity or organisation XML file.', unique=True, max_length=255)), ('date_created', models.DateTimeField(auto_now_add=True)), ('date_updated', models.DateTimeField(auto_now_add=True)), ('update_interval', models.CharField(default=b'month', max_length=20, choices=[(b'day', 'Day'), (b'week', 'Week'), (b'month', 'Month'), (b'year', 'Year')])), ('last_found_in_registry', models.DateTimeField(default=None, null=True)), ('xml_activity_count', models.IntegerField(default=None, null=True)), ('oipa_activity_count', models.IntegerField(default=None, null=True)), ('iati_standard_version', models.CharField(default=b'', max_length=10)), ('is_parsed', models.BooleanField(default=False)), ('added_manually', models.BooleanField(default=True)), ], options={ 'ordering': ['ref'], 'verbose_name_plural': 'IATI XML sources', }, bases=(models.Model,), ), migrations.CreateModel( name='Publisher', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('org_id', models.CharField(max_length=100)), ('org_abbreviate', models.CharField(max_length=55)), ('org_name', models.CharField(max_length=255)), ('default_interval', models.CharField(default='MONTHLY', max_length=55, verbose_name='Interval', choices=[('YEARLY', 'Parse yearly'), ('MONTHLY', 'Parse monthly'), ('WEEKLY', 'Parse weekly'), ('DAILY', 'Parse daily')])), ('XML_total_activity_count', models.IntegerField(default=None, null=True)), ('OIPA_total_activity_count', models.IntegerField(default=None, null=True)), ], options={ }, bases=(models.Model,), ), migrations.AddField( model_name='iatixmlsource', name='publisher', field=models.ForeignKey(to='iati_synchroniser.Publisher'), preserve_default=True, ), ]
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 3034, 513, 297, 288, 1504, 1524, 355, 661, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 8437, 29, 797, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 1802, 297, 1709, 14, 6254, 8, 988, 63, 1267, 29, 5279, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 835, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 955, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 602, 63, 5334, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 1826, 288, 2156, 288, 1511, 3126, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 41, 2159, 8672, 2980, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 8437, 29, 797, 12, 2599, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 1121, 297, 1709, 14, 2183, 8, 3437, 63, 505, 534, 5083, 367, 314, 4692, 570, 14, 510, 1121, 7165, 4503, 26, 2812, 641, 473, 19735, 7086, 297, 1390, 63, 1267, 29, 2760, 12, 3376, 63, 354, 534, 5083, 3855, 355, 661, 1213, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 1826, 355, 661, 466, 297, 1709, 14, 3901, 8, 885, 29, 17, 12, 3415, 17497, 17, 12, 283, 14350, 16920, 659, 334, 18, 12, 283, 11014, 13181, 16920, 2023, 395, 355, 661, 1365, 63, 633, 297, 1709, 14, 2183, 8, 3437, 63, 505, 534, 18727, 1073, 370, 376, 284, 2159, 10679, 503, 5981, 13181, 4692, 570, 3130, 3747, 29, 549, 12, 1390, 63, 1267, 29, 2299, 1826, 355, 661, 602, 63, 3966, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 355, 661, 602, 63, 5334, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 355, 661, 873, 63, 4284, 297, 1709, 14, 2183, 8, 885, 29, 66, 6704, 265, 273, 297, 1390, 63, 1267, 29, 1165, 12, 3415, 17497, 66, 5121, 1187, 297, 283, 12631, 659, 334, 66, 7, 6419, 297, 283, 20995, 659, 334, 66, 6704, 265, 273, 297, 283, 14306, 659, 334, 66, 7, 3403, 297, 283, 15731, 2023, 395, 355, 661, 2019, 63, 4214, 63, 262, 63, 5189, 297, 1709, 14, 4626, 8, 885, 29, 403, 12, 2973, 29, 549, 1826, 355, 661, 1652, 63, 8240, 63, 835, 297, 1709, 14, 3901, 8, 885, 29, 403, 12, 2973, 29, 549, 1826, 355, 661, 16142, 387, 63, 8240, 63, 835, 297, 1709, 14, 3901, 8, 885, 29, 403, 12, 2973, 29, 549, 1826, 355, 661, 73, 2159, 63, 6807, 63, 1023, 297, 1709, 14, 2183, 8, 885, 29, 66, 6448, 1390, 63, 1267, 29, 709, 1826, 355, 661, 374, 63, 6751, 297, 1709, 14, 5036, 8, 885, 29, 797, 1826, 355, 661, 3270, 63, 1237, 3163, 297, 1709, 14, 5036, 8, 885, 29, 549, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 7128, 356, 788, 1121, 995, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 41, 19735, 4692, 5274, 297, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 27341, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 8437, 29, 797, 12, 2599, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 1308, 63, 344, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 1826, 355, 661, 1308, 63, 371, 23988, 323, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1229, 1826, 355, 661, 1308, 63, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 1826, 355, 661, 885, 63, 4284, 297, 1709, 14, 2183, 8, 885, 534, 16413, 6084, 297, 1390, 63, 1267, 29, 1229, 12, 3376, 63, 354, 534, 8227, 297, 3415, 11699, 19216, 6084, 297, 283, 4003, 5361, 590, 659, 661, 16413, 6084, 297, 283, 4003, 5794, 590, 659, 661, 24929, 6084, 297, 283, 4003, 8620, 590, 659, 661, 36, 6593, 57, 297, 283, 4003, 26122, 2023, 395, 355, 661, 4317, 63, 2923, 63, 8240, 63, 835, 297, 1709, 14, 3901, 8, 885, 29, 403, 12, 2973, 29, 549, 1826, 355, 661, 47, 1772, 33, 63, 2923, 63, 8240, 63, 835, 297, 1709, 14, 3901, 8, 885, 29, 403, 12, 2973, 29, 549, 1826, 288, 2156, 288, 1511, 3126, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 73, 2159, 10198, 478, 616, 297, 288, 536, 534, 12789, 297, 288, 901, 29, 992, 14, 3190, 8, 475, 534, 73, 2159, 63, 16473, 25696, 14, 27341, 659, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 3034, 513, 297, 288, 1504, 1524, 355, 661, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 8437, 29, 797, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 1802, 297, 1709, 14, 6254, 8, 988, 63, 1267, 29, 5279, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 835, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 955, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 602, 63, 5334, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 1826, 288, 2156, 288, 1511, 3126, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 41, 2159, 8672, 2980, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 8437, 29, 797, 12, 2599, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 1121, 297, 1709, 14, 2183, 8, 3437, 63, 505, 534, 5083, 367, 314, 4692, 570, 14, 510, 1121, 7165, 4503, 26, 2812, 641, 473, 19735, 7086, 297, 1390, 63, 1267, 29, 2760, 12, 3376, 63, 354, 534, 5083, 3855, 355, 661, 1213, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 1826, 355, 661, 466, 297, 1709, 14, 3901, 8, 885, 29, 17, 12, 3415, 17497, 17, 12, 283, 14350, 16920, 659, 334, 18, 12, 283, 11014, 13181, 16920, 2023, 395, 355, 661, 1365, 63, 633, 297, 1709, 14, 2183, 8, 3437, 63, 505, 534, 18727, 1073, 370, 376, 284, 2159, 10679, 503, 5981, 13181, 4692, 570, 3130, 3747, 29, 549, 12, 1390, 63, 1267, 29, 2299, 1826, 355, 661, 602, 63, 3966, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 355, 661, 602, 63, 5334, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 355, 661, 873, 63, 4284, 297, 1709, 14, 2183, 8, 885, 29, 66, 6704, 265, 273, 297, 1390, 63, 1267, 29, 1165, 12, 3415, 17497, 66, 5121, 1187, 297, 283, 12631, 659, 334, 66, 7, 6419, 297, 283, 20995, 659, 334, 66, 6704, 265, 273, 297, 283, 14306, 659, 334, 66, 7, 3403, 297, 283, 15731, 2023, 395, 355, 661, 2019, 63, 4214, 63, 262, 63, 5189, 297, 1709, 14, 4626, 8, 885, 29, 403, 12, 2973, 29, 549, 1826, 355, 661, 1652, 63, 8240, 63, 835, 297, 1709, 14, 3901, 8, 885, 29, 403, 12, 2973, 29, 549, 1826, 355, 661, 16142, 387, 63, 8240, 63, 835, 297, 1709, 14, 3901, 8, 885, 29, 403, 12, 2973, 29, 549, 1826, 355, 661, 73, 2159, 63, 6807, 63, 1023, 297, 1709, 14, 2183, 8, 885, 29, 66, 6448, 1390, 63, 1267, 29, 709, 1826, 355, 661, 374, 63, 6751, 297, 1709, 14, 5036, 8, 885, 29, 797, 1826, 355, 661, 3270, 63, 1237, 3163, 297, 1709, 14, 5036, 8, 885, 29, 549, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 7128, 356, 788, 1121, 995, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 41, 19735, 4692, 5274, 297, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 27341, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 8437, 29, 797, 12, 2599, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 1308, 63, 344, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 1826, 355, 661, 1308, 63, 371, 23988, 323, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1229, 1826, 355, 661, 1308, 63, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 1826, 355, 661, 885, 63, 4284, 297, 1709, 14, 2183, 8, 885, 534, 16413, 6084, 297, 1390, 63, 1267, 29, 1229, 12, 3376, 63, 354, 534, 8227, 297, 3415, 11699, 19216, 6084, 297, 283, 4003, 5361, 590, 659, 661, 16413, 6084, 297, 283, 4003, 5794, 590, 659, 661, 24929, 6084, 297, 283, 4003, 8620, 590, 659, 661, 36, 6593, 57, 297, 283, 4003, 26122, 2023, 395, 355, 661, 4317, 63, 2923, 63, 8240, 63, 835, 297, 1709, 14, 3901, 8, 885, 29, 403, 12, 2973, 29, 549, 1826, 355, 661, 47, 1772, 33, 63, 2923, 63, 8240, 63, 835, 297, 1709, 14, 3901, 8, 885, 29, 403, 12, 2973, 29, 549, 1826, 288, 2156, 288, 1511, 3126, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 73, 2159, 10198, 478, 616, 297, 288, 536, 534, 12789, 297, 288, 901, 29, 992, 14, 3190, 8, 475, 534, 73, 2159, 63, 16473, 25696, 14, 27341, 659, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
CamelBackNotation/CarnotKE
jyhton/lib-python/2.7/ctypes/macholib/dyld.py
253
5341
###################################################################### # This file should be kept compatible with Python 2.3, see PEP 291. # ###################################################################### """ dyld emulation """ import os from framework import framework_info from dylib import dylib_info from itertools import * __all__ = [ 'dyld_find', 'framework_find', 'framework_info', 'dylib_info', ] # These are the defaults as per man dyld(1) # DEFAULT_FRAMEWORK_FALLBACK = [ os.path.expanduser("~/Library/Frameworks"), "/Library/Frameworks", "/Network/Library/Frameworks", "/System/Library/Frameworks", ] DEFAULT_LIBRARY_FALLBACK = [ os.path.expanduser("~/lib"), "/usr/local/lib", "/lib", "/usr/lib", ] def ensure_utf8(s): """Not all of PyObjC and Python understand unicode paths very well yet""" if isinstance(s, unicode): return s.encode('utf8') return s def dyld_env(env, var): if env is None: env = os.environ rval = env.get(var) if rval is None: return [] return rval.split(':') def dyld_image_suffix(env=None): if env is None: env = os.environ return env.get('DYLD_IMAGE_SUFFIX') def dyld_framework_path(env=None): return dyld_env(env, 'DYLD_FRAMEWORK_PATH') def dyld_library_path(env=None): return dyld_env(env, 'DYLD_LIBRARY_PATH') def dyld_fallback_framework_path(env=None): return dyld_env(env, 'DYLD_FALLBACK_FRAMEWORK_PATH') def dyld_fallback_library_path(env=None): return dyld_env(env, 'DYLD_FALLBACK_LIBRARY_PATH') def dyld_image_suffix_search(iterator, env=None): """For a potential path iterator, add DYLD_IMAGE_SUFFIX semantics""" suffix = dyld_image_suffix(env) if suffix is None: return iterator def _inject(iterator=iterator, suffix=suffix): for path in iterator: if path.endswith('.dylib'): yield path[:-len('.dylib')] + suffix + '.dylib' else: yield path + suffix yield path return _inject() def dyld_override_search(name, env=None): # If DYLD_FRAMEWORK_PATH is set and this dylib_name is a # framework name, use the first file that exists in the framework # path if any. If there is none go on to search the DYLD_LIBRARY_PATH # if any. framework = framework_info(name) if framework is not None: for path in dyld_framework_path(env): yield os.path.join(path, framework['name']) # If DYLD_LIBRARY_PATH is set then use the first file that exists # in the path. If none use the original name. for path in dyld_library_path(env): yield os.path.join(path, os.path.basename(name)) def dyld_executable_path_search(name, executable_path=None): # If we haven't done any searching and found a library and the # dylib_name starts with "@executable_path/" then construct the # library name. if name.startswith('@executable_path/') and executable_path is not None: yield os.path.join(executable_path, name[len('@executable_path/'):]) def dyld_default_search(name, env=None): yield name framework = framework_info(name) if framework is not None: fallback_framework_path = dyld_fallback_framework_path(env) for path in fallback_framework_path: yield os.path.join(path, framework['name']) fallback_library_path = dyld_fallback_library_path(env) for path in fallback_library_path: yield os.path.join(path, os.path.basename(name)) if framework is not None and not fallback_framework_path: for path in DEFAULT_FRAMEWORK_FALLBACK: yield os.path.join(path, framework['name']) if not fallback_library_path: for path in DEFAULT_LIBRARY_FALLBACK: yield os.path.join(path, os.path.basename(name)) def dyld_find(name, executable_path=None, env=None): """ Find a library or framework using dyld semantics """ name = ensure_utf8(name) executable_path = ensure_utf8(executable_path) for path in dyld_image_suffix_search(chain( dyld_override_search(name, env), dyld_executable_path_search(name, executable_path), dyld_default_search(name, env), ), env): if os.path.isfile(path): return path raise ValueError("dylib %s could not be found" % (name,)) def framework_find(fn, executable_path=None, env=None): """ Find a framework using dyld semantics in a very loose manner. Will take input such as: Python Python.framework Python.framework/Versions/Current """ try: return dyld_find(fn, executable_path=executable_path, env=env) except ValueError, e: pass fmwk_index = fn.rfind('.framework') if fmwk_index == -1: fmwk_index = len(fn) fn += '.framework' fn = os.path.join(fn, os.path.basename(fn[:fmwk_index])) try: return dyld_find(fn, executable_path=executable_path, env=env) except ValueError: raise e def test_dyld_find(): env = {} assert dyld_find('libSystem.dylib') == '/usr/lib/libSystem.dylib' assert dyld_find('System.framework/System') == '/System/Library/Frameworks/System.framework/System' if __name__ == '__main__': test_dyld_find()
apache-2.0
[ 18022, 199, 3, 221, 961, 570, 1077, 506, 16204, 9025, 543, 2018, 499, 14, 19, 12, 1937, 13663, 499, 3328, 14, 327, 199, 18022, 199, 624, 199, 8161, 1447, 15074, 199, 624, 199, 199, 646, 747, 199, 504, 10059, 492, 10059, 63, 815, 199, 504, 13119, 773, 492, 13119, 773, 63, 815, 199, 504, 7975, 492, 627, 199, 199, 363, 452, 363, 275, 359, 272, 283, 8161, 1447, 63, 1623, 297, 283, 4857, 63, 1623, 297, 272, 283, 4857, 63, 815, 297, 283, 22305, 63, 815, 297, 199, 61, 199, 199, 3, 5723, 787, 314, 4243, 465, 1126, 2169, 13119, 1447, 8, 17, 9, 199, 3, 199, 3472, 63, 12683, 8406, 63, 38, 1761, 7111, 275, 359, 272, 747, 14, 515, 14, 12131, 20793, 15, 7424, 15, 30052, 1288, 272, 3286, 7424, 15, 30052, 401, 272, 3286, 4491, 15, 7424, 15, 30052, 401, 272, 3286, 3989, 15, 7424, 15, 30052, 401, 199, 61, 199, 199, 3472, 63, 16983, 63, 38, 1761, 7111, 275, 359, 272, 747, 14, 515, 14, 12131, 20793, 15, 773, 1288, 272, 3286, 2647, 15, 1832, 15, 773, 401, 272, 3286, 773, 401, 272, 3286, 2647, 15, 773, 401, 199, 61, 199, 199, 318, 4868, 63, 1624, 24, 8, 83, 304, 272, 408, 1763, 1006, 402, 1611, 5665, 35, 436, 2018, 20647, 2649, 3792, 7437, 5521, 5966, 624, 272, 340, 1228, 8, 83, 12, 2649, 304, 267, 372, 308, 14, 2143, 360, 1624, 24, 358, 272, 372, 308, 199, 199, 318, 13119, 1447, 63, 1813, 8, 1813, 12, 2729, 304, 272, 340, 2589, 365, 488, 26, 267, 2589, 275, 747, 14, 2314, 272, 15010, 275, 2589, 14, 362, 8, 1391, 9, 272, 340, 15010, 365, 488, 26, 267, 372, 942, 272, 372, 15010, 14, 1294, 11633, 199, 199, 318, 13119, 1447, 63, 1569, 63, 4511, 8, 1813, 29, 403, 304, 272, 340, 2589, 365, 488, 26, 267, 2589, 275, 747, 14, 2314, 272, 372, 2589, 14, 362, 360, 11446, 6533, 63, 9438, 63, 12273, 358, 199, 199, 318, 13119, 1447, 63, 4857, 63, 515, 8, 1813, 29, 403, 304, 272, 372, 13119, 1447, 63, 1813, 8, 1813, 12, 283, 11446, 6533, 63, 12683, 8406, 63, 3243, 358, 199, 199, 318, 13119, 1447, 63, 4342, 63, 515, 8, 1813, 29, 403, 304, 272, 372, 13119, 1447, 63, 1813, 8, 1813, 12, 283, 11446, 6533, 63, 16983, 63, 3243, 358, 199, 199, 318, 13119, 1447, 63, 10538, 63, 4857, 63, 515, 8, 1813, 29, 403, 304, 272, 372, 13119, 1447, 63, 1813, 8, 1813, 12, 283, 11446, 6533, 63, 38, 1761, 7111, 63, 12683, 8406, 63, 3243, 358, 199, 199, 318, 13119, 1447, 63, 10538, 63, 4342, 63, 515, 8, 1813, 29, 403, 304, 272, 372, 13119, 1447, 63, 1813, 8, 1813, 12, 283, 11446, 6533, 63, 38, 1761, 7111, 63, 16983, 63, 3243, 358, 199, 199, 318, 13119, 1447, 63, 1569, 63, 4511, 63, 1733, 8, 5778, 12, 2589, 29, 403, 304, 272, 408, 1858, 282, 12330, 931, 6122, 12, 1050, 577, 57, 6533, 63, 9438, 63, 12273, 19002, 624, 272, 4739, 275, 13119, 1447, 63, 1569, 63, 4511, 8, 1813, 9, 272, 340, 4739, 365, 488, 26, 267, 372, 6122, 272, 347, 485, 14815, 8, 5778, 29, 5778, 12, 4739, 29, 4511, 304, 267, 367, 931, 315, 6122, 26, 288, 340, 931, 14, 4130, 5175, 22305, 735, 355, 1995, 931, 4439, 552, 5175, 22305, 5440, 435, 4739, 435, 1987, 22305, 7, 288, 587, 26, 355, 1995, 931, 435, 4739, 288, 1995, 931, 272, 372, 485, 14815, 342, 199, 199, 318, 13119, 1447, 63, 4415, 63, 1733, 8, 354, 12, 2589, 29, 403, 304, 272, 327, 982, 577, 57, 6533, 63, 12683, 8406, 63, 3243, 365, 663, 436, 642, 13119, 773, 63, 354, 365, 282, 272, 327, 10059, 536, 12, 675, 314, 1642, 570, 626, 3495, 315, 314, 10059, 272, 327, 931, 340, 1263, 14, 221, 982, 2337, 365, 7179, 2621, 641, 370, 2754, 314, 577, 57, 6533, 63, 16983, 63, 3243, 272, 327, 340, 1263, 14, 339, 10059, 275, 10059, 63, 815, 8, 354, 9, 339, 340, 10059, 365, 440, 488, 26, 267, 367, 931, 315, 13119, 1447, 63, 4857, 63, 515, 8, 1813, 304, 288, 1995, 747, 14, 515, 14, 904, 8, 515, 12, 10059, 459, 354, 1105, 339, 327, 982, 577, 57, 6533, 63, 16983, 63, 3243, 365, 663, 2066, 675, 314, 1642, 570, 626, 3495, 272, 327, 315, 314, 931, 14, 221, 982, 7179, 675, 314, 3379, 536, 14, 272, 367, 931, 315, 13119, 1447, 63, 4342, 63, 515, 8, 1813, 304, 267, 1995, 747, 14, 515, 14, 904, 8, 515, 12, 747, 14, 515, 14, 4846, 8, 354, 430, 199, 199, 318, 13119, 1447, 63, 5904, 63, 515, 63, 1733, 8, 354, 12, 7286, 63, 515, 29, 403, 304, 272, 327, 982, 781, 19051, 1133, 4224, 1263, 18112, 436, 1911, 282, 3555, 436, 314, 272, 327, 13119, 773, 63, 354, 9174, 543, 9244, 5904, 63, 515, 6687, 2066, 6982, 314, 272, 327, 3555, 536, 14, 272, 340, 536, 14, 2460, 16591, 5904, 63, 515, 6217, 436, 7286, 63, 515, 365, 440, 488, 26, 267, 1995, 747, 14, 515, 14, 904, 8, 5904, 63, 515, 12, 536, 59, 552, 16591, 5904, 63, 515, 26985, 566, 199, 199, 318, 13119, 1447, 63, 885, 63, 1733, 8, 354, 12, 2589, 29, 403, 304, 272, 1995, 536, 339, 10059, 275, 10059, 63, 815, 8, 354, 9, 339, 340, 10059, 365, 440, 488, 26, 267, 9567, 63, 4857, 63, 515, 275, 13119, 1447, 63, 10538, 63, 4857, 63, 515, 8, 1813, 9, 267, 367, 931, 315, 9567, 63, 4857, 63, 515, 26, 288, 1995, 747, 14, 515, 14, 904, 8, 515, 12, 10059, 459, 354, 1105, 339, 9567, 63, 4342, 63, 515, 275, 13119, 1447, 63, 10538, 63, 4342, 63, 515, 8, 1813, 9, 272, 367, 931, 315, 9567, 63, 4342, 63, 515, 26, 267, 1995, 747, 14, 515, 14, 904, 8, 515, 12, 747, 14, 515, 14, 4846, 8, 354, 430, 339, 340, 10059, 365, 440, 488, 436, 440, 9567, 63, 4857, 63, 515, 26, 267, 367, 931, 315, 6186, 63, 12683, 8406, 63, 38, 1761, 7111, 26, 288, 1995, 747, 14, 515, 14, 904, 8, 515, 12, 10059, 459, 354 ]
[ 199, 3, 221, 961, 570, 1077, 506, 16204, 9025, 543, 2018, 499, 14, 19, 12, 1937, 13663, 499, 3328, 14, 327, 199, 18022, 199, 624, 199, 8161, 1447, 15074, 199, 624, 199, 199, 646, 747, 199, 504, 10059, 492, 10059, 63, 815, 199, 504, 13119, 773, 492, 13119, 773, 63, 815, 199, 504, 7975, 492, 627, 199, 199, 363, 452, 363, 275, 359, 272, 283, 8161, 1447, 63, 1623, 297, 283, 4857, 63, 1623, 297, 272, 283, 4857, 63, 815, 297, 283, 22305, 63, 815, 297, 199, 61, 199, 199, 3, 5723, 787, 314, 4243, 465, 1126, 2169, 13119, 1447, 8, 17, 9, 199, 3, 199, 3472, 63, 12683, 8406, 63, 38, 1761, 7111, 275, 359, 272, 747, 14, 515, 14, 12131, 20793, 15, 7424, 15, 30052, 1288, 272, 3286, 7424, 15, 30052, 401, 272, 3286, 4491, 15, 7424, 15, 30052, 401, 272, 3286, 3989, 15, 7424, 15, 30052, 401, 199, 61, 199, 199, 3472, 63, 16983, 63, 38, 1761, 7111, 275, 359, 272, 747, 14, 515, 14, 12131, 20793, 15, 773, 1288, 272, 3286, 2647, 15, 1832, 15, 773, 401, 272, 3286, 773, 401, 272, 3286, 2647, 15, 773, 401, 199, 61, 199, 199, 318, 4868, 63, 1624, 24, 8, 83, 304, 272, 408, 1763, 1006, 402, 1611, 5665, 35, 436, 2018, 20647, 2649, 3792, 7437, 5521, 5966, 624, 272, 340, 1228, 8, 83, 12, 2649, 304, 267, 372, 308, 14, 2143, 360, 1624, 24, 358, 272, 372, 308, 199, 199, 318, 13119, 1447, 63, 1813, 8, 1813, 12, 2729, 304, 272, 340, 2589, 365, 488, 26, 267, 2589, 275, 747, 14, 2314, 272, 15010, 275, 2589, 14, 362, 8, 1391, 9, 272, 340, 15010, 365, 488, 26, 267, 372, 942, 272, 372, 15010, 14, 1294, 11633, 199, 199, 318, 13119, 1447, 63, 1569, 63, 4511, 8, 1813, 29, 403, 304, 272, 340, 2589, 365, 488, 26, 267, 2589, 275, 747, 14, 2314, 272, 372, 2589, 14, 362, 360, 11446, 6533, 63, 9438, 63, 12273, 358, 199, 199, 318, 13119, 1447, 63, 4857, 63, 515, 8, 1813, 29, 403, 304, 272, 372, 13119, 1447, 63, 1813, 8, 1813, 12, 283, 11446, 6533, 63, 12683, 8406, 63, 3243, 358, 199, 199, 318, 13119, 1447, 63, 4342, 63, 515, 8, 1813, 29, 403, 304, 272, 372, 13119, 1447, 63, 1813, 8, 1813, 12, 283, 11446, 6533, 63, 16983, 63, 3243, 358, 199, 199, 318, 13119, 1447, 63, 10538, 63, 4857, 63, 515, 8, 1813, 29, 403, 304, 272, 372, 13119, 1447, 63, 1813, 8, 1813, 12, 283, 11446, 6533, 63, 38, 1761, 7111, 63, 12683, 8406, 63, 3243, 358, 199, 199, 318, 13119, 1447, 63, 10538, 63, 4342, 63, 515, 8, 1813, 29, 403, 304, 272, 372, 13119, 1447, 63, 1813, 8, 1813, 12, 283, 11446, 6533, 63, 38, 1761, 7111, 63, 16983, 63, 3243, 358, 199, 199, 318, 13119, 1447, 63, 1569, 63, 4511, 63, 1733, 8, 5778, 12, 2589, 29, 403, 304, 272, 408, 1858, 282, 12330, 931, 6122, 12, 1050, 577, 57, 6533, 63, 9438, 63, 12273, 19002, 624, 272, 4739, 275, 13119, 1447, 63, 1569, 63, 4511, 8, 1813, 9, 272, 340, 4739, 365, 488, 26, 267, 372, 6122, 272, 347, 485, 14815, 8, 5778, 29, 5778, 12, 4739, 29, 4511, 304, 267, 367, 931, 315, 6122, 26, 288, 340, 931, 14, 4130, 5175, 22305, 735, 355, 1995, 931, 4439, 552, 5175, 22305, 5440, 435, 4739, 435, 1987, 22305, 7, 288, 587, 26, 355, 1995, 931, 435, 4739, 288, 1995, 931, 272, 372, 485, 14815, 342, 199, 199, 318, 13119, 1447, 63, 4415, 63, 1733, 8, 354, 12, 2589, 29, 403, 304, 272, 327, 982, 577, 57, 6533, 63, 12683, 8406, 63, 3243, 365, 663, 436, 642, 13119, 773, 63, 354, 365, 282, 272, 327, 10059, 536, 12, 675, 314, 1642, 570, 626, 3495, 315, 314, 10059, 272, 327, 931, 340, 1263, 14, 221, 982, 2337, 365, 7179, 2621, 641, 370, 2754, 314, 577, 57, 6533, 63, 16983, 63, 3243, 272, 327, 340, 1263, 14, 339, 10059, 275, 10059, 63, 815, 8, 354, 9, 339, 340, 10059, 365, 440, 488, 26, 267, 367, 931, 315, 13119, 1447, 63, 4857, 63, 515, 8, 1813, 304, 288, 1995, 747, 14, 515, 14, 904, 8, 515, 12, 10059, 459, 354, 1105, 339, 327, 982, 577, 57, 6533, 63, 16983, 63, 3243, 365, 663, 2066, 675, 314, 1642, 570, 626, 3495, 272, 327, 315, 314, 931, 14, 221, 982, 7179, 675, 314, 3379, 536, 14, 272, 367, 931, 315, 13119, 1447, 63, 4342, 63, 515, 8, 1813, 304, 267, 1995, 747, 14, 515, 14, 904, 8, 515, 12, 747, 14, 515, 14, 4846, 8, 354, 430, 199, 199, 318, 13119, 1447, 63, 5904, 63, 515, 63, 1733, 8, 354, 12, 7286, 63, 515, 29, 403, 304, 272, 327, 982, 781, 19051, 1133, 4224, 1263, 18112, 436, 1911, 282, 3555, 436, 314, 272, 327, 13119, 773, 63, 354, 9174, 543, 9244, 5904, 63, 515, 6687, 2066, 6982, 314, 272, 327, 3555, 536, 14, 272, 340, 536, 14, 2460, 16591, 5904, 63, 515, 6217, 436, 7286, 63, 515, 365, 440, 488, 26, 267, 1995, 747, 14, 515, 14, 904, 8, 5904, 63, 515, 12, 536, 59, 552, 16591, 5904, 63, 515, 26985, 566, 199, 199, 318, 13119, 1447, 63, 885, 63, 1733, 8, 354, 12, 2589, 29, 403, 304, 272, 1995, 536, 339, 10059, 275, 10059, 63, 815, 8, 354, 9, 339, 340, 10059, 365, 440, 488, 26, 267, 9567, 63, 4857, 63, 515, 275, 13119, 1447, 63, 10538, 63, 4857, 63, 515, 8, 1813, 9, 267, 367, 931, 315, 9567, 63, 4857, 63, 515, 26, 288, 1995, 747, 14, 515, 14, 904, 8, 515, 12, 10059, 459, 354, 1105, 339, 9567, 63, 4342, 63, 515, 275, 13119, 1447, 63, 10538, 63, 4342, 63, 515, 8, 1813, 9, 272, 367, 931, 315, 9567, 63, 4342, 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